MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
SoView2DRectangle.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2007, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13
15
16#pragma once
17
18#include "SoView2D.h"
20#include "SoView2DLabel.h"
21#include "View2DSliceList.h"
22
23#include <Inventor/fields/SoSFInt32.h>
24#include <Inventor/fields/SoSFVec3f.h>
25
27{
28 void reset(View2DSliceList* slicelist, int slice)
29 {
30 hitID = 0;
31 currentSlice = slice;
32 viewer = slicelist->getOwner();
33 }
34 bool isDrawnOnViewer(View2DSliceList* slicelist, int slice) const
35 {
36 return (viewer == slicelist->getOwner() && currentSlice == slice);
37 }
41};
42
43
46{
47 SO_NODE_HEADER(SoView2DRectangle);
48
49public:
51
53
58
71
80
83
86
89
92
98
101
104
107
114
121
123
125 static void initClass();
126
129
131 void draw(View2DSliceList* dsl, View2DSlice* dslice, int slice) override;
132
134 void drawLabelText(float px, float py, float qx, float qy);
135
137 bool evalEvent(SoView2D* view2d, View2DSliceList* slicelist, View2DEvent* ec, View2DEventPhase phase) override;
138
140 bool ignoreEvent(View2DEvent* ec) override;
141
142protected:
150
152 DragMode performHitTest(float dx, float dy, const SbVec3f& voxelPos, View2DSliceList* sliceList);
154
156 void performDrag(const SoPointerPosition& pos, bool setStart);
157 void performDrag(const SbVec3f& voxelPos, bool setStart, View2DSliceList* sliceList);
158
161 bool isSensitiveAt(const SoPointerPosition& pos) override;
162 void startPressAt(const SoPointerPosition& pos) override;
163 void dragMoveTo(const SoPointerPosition& pos) override;
164 SoPointingAction* endPress(int clickCount) override;
165 void pointerPosition(SoState*, const SoPointerPosition& pos) override;
166 void pointerLeftWindow(SoState*) override;
168
175
177 {
178 const float x = mousePosition[0];
179 const float y = mousePosition[1];
180
181 const float minX = std::min(upperLeft[0], lowerRight[0]);
182 const float maxX = std::max(upperLeft[0], lowerRight[0]);
183 const float minY = std::min(upperLeft[1], lowerRight[1]);
184 const float maxY = std::max(upperLeft[1], lowerRight[1]);
185
186 return (x > minX && x < maxX && y > minY && y < maxY);
187 }
188
189 void drawHitSideLine(float startX, float startY, float endX, float endY, View2DSliceList* sliceList, int slice) const;
190 void drawThickLine(float startX, float startY, float endX, float endY) const;
191 void drawThinLine(float startX, float startY, float endX, float endY) const;
192
195
199 bool _startDeviceXHigher{};
201 bool _startDeviceYHigher{};
202
203 bool _swappedDeviceX{};
204 bool _swappedDeviceY{};
205
207 bool _dragx{};
209 bool _dragy{};
210
213
214 bool isSliceInMiddleOfRectangleExcludingTopAndBottom(int slice, float vz1, float vz2) const;
215 bool isSliceIntersectingRectangle(int slice, float vz1, float vz2) const;
216
219
221 bool _draggingInCooperativeMode{};
222
223private:
226};
View2DEventPhase
event phase for simple extensions that grab the focus, do something (motion) and are released afterwa...
#define SOVIEW2D_API
File to resolve system dependencies in View2D library.
void pointerPosition(SoState *state, const SoPointerPosition &pos) override
Same as below, with additional SoState argument. By default, simply calls the below version.
virtual void pointerLeftWindow()
This is called when the mouse cursor leaves the window.
SoPointerPosition manages the current position of the mouse cursor.
SoPointingAction is the base class for any mouse based interaction.
bool isPointInsideDeviceRect(float pointX, float pointY, float centerX, float centerY, float hitRectangleSize=0.0)
returns whether the given point is inside a rectangle around the given center.
float getSelectDist()
Set the distance tolerance on hit checking in pixels.
SoView2DInteractionExtension is base class for all SoView2DExtensions that want to support the Manage...
allows drawing and editing of a rectangle on a SoView2D
SoView2DRectangle()
Constructor.
bool isSensitiveAt(const SoPointerPosition &pos) override
interface forwarded from SoPointingAction:
SoSFFloat lineBlendOnto
line blend factor when on border of rectangle
DragMode performHitTest(const SoPointerPosition &pos)
bool isSliceIntersectingRectangle(int slice, float vz1, float vz2) const
void drawThinLine(float startX, float startY, float endX, float endY) const
SoSFInt32 labelFontSize
font size of text
SoSFFloat labelHorizontalOffset
void drawLabelText(float px, float py, float qx, float qy)
draws the label (given top-left/bottom-right positions of the rectangle on the slice)
SoSFBool selectOutside
allow selection outside of rectangle
void performDrag(const SoPointerPosition &pos, bool setStart)
perform drag operation (this uses members set by performHitTest)
void dragMoveTo(const SoPointerPosition &pos) override
SoSFBool shadeAllExterior
shade all exterior, also there where the slice does not cross the box.
void draw(View2DSliceList *dsl, View2DSlice *dslice, int slice) override
reimplemented from SoView2DExtension
DragMode _dragMode
specify drag mode
void startPressAt(const SoPointerPosition &pos) override
DragMode
type for specifying dragging mode
SoSFFloat blendInside
blend factor inside of rectangle
SbVec3f _lastWorldPos
last world position
SoSFBool fixZOn
Fields.
bool evalEvent(SoView2D *view2d, View2DSliceList *slicelist, View2DEvent *ec, View2DEventPhase phase) override
reimplemented from SoView2DExtension
SoSFFloat blendOutside
blend factor outside of rectangle
bool isMouseInsideRectangle(const SbVec2f &mousePosition, const SbVec2f &upperLeft, const SbVec2f &lowerRight)
void pointerPosition(SoState *, const SoPointerPosition &pos) override
Same as below, with additional SoState argument. By default, simply calls the below version.
SoSFBool isUnderMouse
flag that indicated is the rectangle is under the mouse
SoSFBool cooperative
enable cooperative mode
SoSFFloat shadeExterior
shade the exterior of the rectangle
void drawHitSideLine(float startX, float startY, float endX, float endY, View2DSliceList *sliceList, int slice) const
SoSFEnum labelVerticalBoxPosition
SoSFBool useSideLineColor
Should the side lines have their own color?
SoSFVec3f endWorldPos
end world position of rectangle
bool isSliceInMiddleOfRectangleExcludingTopAndBottom(int slice, float vz1, float vz2) const
SoSFEnum lineStyle
line style
SoSFColor sideLineColor
Optional side line color.
SoSFColor handleColor
Optional handle color.
SoSFFloat lineBlendInside
line blend factor when inside of rectangle
SoPointingAction * endPress(int clickCount) override
SoSFBool resetToImage
reset to 80 percent of the original image
void performDrag(const SbVec3f &voxelPos, bool setStart, View2DSliceList *sliceList)
SoSFFloat lineBlendOutside
line blend factor when outside of rectangle
static void initClass()
inventor runtime type system
SoSFFloat blendOnto
blend factor on border of rectangle
SoSFBool useHandleColor
Should the handles have their own color?
SoSFEnum labelHorizontalBoxPosition
void drawThickLine(float startX, float startY, float endX, float endY) const
bool isPointInsideDeviceCornerHandle(const SbVec2f &cornerHandlePosition, const SbVec2f &mousePosition)
bool ignoreEvent(View2DEvent *ec) override
Overwrite ignoreEvent -> ignore the "ignoreHandledEvents"-Field.
DragMode performHitTest(float dx, float dy, const SbVec3f &voxelPos, View2DSliceList *sliceList)
perform hit test where the rectangle is hit, returns the possible drag mode
SoSFColor labelColor
text color to use
SoSFBool labelShadow
flag if text shadow should be drawn
SoSFVec3f startWorldPos
start world position of rectangle
SoSFBool allowDrag
allow dragging of the rectangle
void pointerLeftWindow(SoState *) override
Same as below, with additional SoState argument. By defaults, simply calls the below version.
SoView2D is a 2D viewer for image data.
Definition SoView2D.h:62
View2DEvent stores all information on an event on a SoView2D.
a list that holds all View2DSlice objects (lazily created) of a SoView2D
SoView2D * getOwner() const
Get the owning SoView2D.
a single slice that is stored in a View2DSliceList, typically created by a View2DSliceList
Definition View2DSlice.h:48
ML_OPENGL_END_NAMESPACE T GLHiDPIScale(T x)
Convenience template function to scale a value.
Definition mlGLHiDPI.h:67
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
Allows drawing and editing of a rectangle on a SoView2D.
bool isDrawnOnViewer(View2DSliceList *slicelist, int slice) const
SoView2D * viewer
void reset(View2DSliceList *slicelist, int slice)