21#include <ThirdPartyWarningsDisable.h>
23#include <Inventor/nodes/SoNode.h>
24#include <Inventor/nodes/SoSubNode.h>
25#include <Inventor/fields/SoSFFloat.h>
26#include <Inventor/fields/SoSFBool.h>
27#include <Inventor/fields/SoSFTrigger.h>
28#include <Inventor/fields/SoSFEnum.h>
29#include <Inventor/fields/SoSFColor.h>
30#include <Inventor/sensors/SoNodeSensor.h>
31#include <Inventor/nodes/SoGroup.h>
32#include <Inventor/events/SoEvent.h>
33#include <Inventor/events/SoMouseButtonEvent.h>
34#include <Inventor/events/SoSpaceballButtonEvent.h>
35#include <Inventor/events/SoKeyboardEvent.h>
36#include <Inventor/events/SoLocation2Event.h>
37#include <Inventor/events/SoMotion3Event.h>
39#include <ThirdPartyWarningsRestore.h>
74#define TEST_STATE(state,flag) (((state)==IGNORED)?TRUE:(((state)==PRESSED)==((flag)!=0)))
80#pragma warning (disable : 4355)
81#pragma warning (disable : 4275)
82#pragma warning (disable : 4251)
83#pragma warning (disable : 4138)
86#pragma warning (disable : 4800)
117 bool b1,
bool b2,
bool b3,
127 bool b1,
bool b2,
bool b3,
198#define EventContainer View2DEvent
199#define EventPhase View2DEventPhase
210#define VIEW2D_DEFINE_LINE_STYLE_ENUM \
211 SO_NODE_DEFINE_ENUM_VALUE(LineStyles, SOLID); \
212 SO_NODE_DEFINE_ENUM_VALUE(LineStyles, DASHED); \
213 SO_NODE_DEFINE_ENUM_VALUE(LineStyles, DOTTED); \
214 SO_NODE_DEFINE_ENUM_VALUE(LineStyles, LONG_DASHED);
216#define VIEW2D_ADD_LINE_STYLE_FIELD(lineStyleField) \
217 SO_NODE_ADD_FIELD(lineStyleField, (SOLID)); \
218 SO_NODE_SET_SF_ENUM_TYPE(lineStyleField, LineStyles);
380 virtual bool isFixZOn() {
return fixZOn.getValue(); };
511 bool _createNewModeRequest;
tristateType
mode used for event filter
View2DEventPhase
event phase for simple extensions that grab the focus, do something (motion) and are released afterwa...
@ EVENT_START
mouse mask of extension has become true (correct button+key combination)
@ EVENT_ANY
Event phase is undefined and has to be checked by getEvent() method.
@ EVENT_MOUSEOVER_UPDATE
An update was requested because a redraw is about to happen and the extension should show actual valu...
@ EVENT_MOTION
Motion while mask is still true.
@ EVENT_KEY_RELEASED
Key was released.
@ EVENT_RELEASE
Mask of extension has become false.
@ EVENT_KEY_PRESSED
Key was pressed.
@ EVENT_MOUSEWHEEL
Mouse wheel was turned.
LineStyles
Definition of line styles for stippling.
#define SOVIEW2D_API
File to resolve system dependencies in View2D library.
SoInteractionProviderNode is the base class for all interaction nodes in OpenInventor.
The SoSFMLImage field is the interface used by Inventor Nodes to access image data (in the current im...
SoView2DExtension Base class for all View2DExtensions used for drawing and event handling on the View...
void handleEvent(SoHandleEventAction *action) override
SoSFBool wantsMouseWheelEvents
flag if MouseWheel events should be passed to evalEvent()
int getX()
get the x device position of current event, only returns valid result when called inside of evalEvent...
virtual bool isActive()
returns if the extension is active (derive this method in child) (in createNewMode or with a selected...
static bool isImageParallel(SoSFMLImage *image, View2DSliceList *dsl)
Return true if image is parallel to the image of the slice list up to slice thickness.
SoSFBool needsValidVoxel
sets if a valid voxel must be hit to get evalEvent() calls
SoSFEnum control
shift control for mouse mask
void pick(SoPickAction *action) override
static float pointToLineDistance(SbVec3f point, SbVec3f line1, SbVec3f line2)
calculate 3D point to line distance
void setCreateNewMode(bool flag)
set this extension to create new objects
static void disableLineStippling(const SoSFEnum &lineStyleField)
void init()
setup internal state
void drawFixedSizeMiniCircleAt(float xp, float yp)
Draws a fixed size small circle at the given position.
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.
static void enableLineStippling(const SoSFEnum &lineStyleField)
Set/reset stippling pattern.
virtual bool ignoreEvent(View2DEvent *ec)
Return true if ec has been handled before and if ignoreHandledEvents is True.
int getY()
get the y device position of current event, only returns valid result when called inside of evalEvent...
static float snapToPixelCenter(float coordinateComponent)
Snaps the coordinate component to the pixel center.
SoSFEnum shift
shift modifier for mouse mask
SoSFBool editingOn
flag if the extension should edit objects on mouse events, needs to be checked inside of the evalEven...
void getMatrix(SoGetMatrixAction *action) override
virtual bool implementsManagedInteractionAndClassicEventHandling() const
return true if this node is a hybrid module providing managed interaction and classic event handling ...
bool wantsMouseOverUpdates() const
public access to _wantsMouseOverUpdateEvents
void drawFilledMiniRect(float xp, float yp, float ext, float lineWidth=1.f)
Draws a small filled rectangle with given half side length.
SoSFBool clipToSlice
Flag to clip drawing to slice.
bool _wantsMouseOverUpdateEvents
set this flag to receive mouse over events while the extension is active
SoSFEnum button1
mouse mask for button1
View2DEvent * getEvent()
get the current event (when inside of evalEvent)
SoSFTrigger createNewModeRequest
~SoView2DExtension() override
destructor
int getSelectedModifierMask()
Get compare and ignore mask for the currently selected button/modifier combination,...
bool isCreateNewMode()
check if extension is in createNewMode
virtual void createNewModeRequestTriggered(SoField *)
called when createNewModeRequest field ist touched:
SoPointingAction::Trigger getPointingActionTriggerFromFields()
Get the trigger that matches the button/modifier field state.
static void getAxisOrientation(int axis, SbMatrix &matrix, char &negativeResult, char &positiveResult)
Geometry helpers.
virtual bool isClipToSlice()
check if the image is clipped to slice
virtual void deleteSelectedObject()
deletes the currently active object (derive this method in child) (called by SoView2D)
bool isCreateNewModeRequest()
check if extension has a request for createNewMode
SoSFBool setEventHandled
Set event handled if it is indeed handled by this extension.
Sign
defines the sign of a number, with zero as an extra value
void setCreateNewModeRequest(bool flag)
set that extension want to become createNewMode
SoSFBool maskValid
flag if the event mask is valid.
static void initClass()
Initializes this class.
virtual bool evalEvent(SoView2D *view2d, View2DSliceList *slicelist, View2DEvent *ec, View2DEventPhase phase)
Called by the SoView2D for each event that happens on the viewer.
void drawDashedMiniRect(float xp, float yp, float ext, float lineWidth)
SoNodeSensor * _nodeSensor
node sensor that is used to notice field changes
void drawFilledMiniCircle(float xp, float yp, float ext, float lineWidth=1.f)
Draws a small filled circle with given center point and radius.
float getSelectDist()
Set the distance tolerance on hit checking in pixels.
SoView2DExtension()
Constructor.
virtual bool isDrawingOn()
check if drawing is on
void doAction(SoAction *action) override
SoSFBool wantsAllEvents
flag if ALL events should be passed to evalEvent(), if disabled, events are only passed to evalEvent ...
virtual void overwriteDrawingSettings(SoView2DDrawingSettings &)
virtual void endDrawing(View2DSliceList *)
virtual bool isEditingOn()
check if editing is on
SoSFBool wantsKeyEvents
flag if keyboard events should be passed to evalEvent()
virtual void fieldChanged(SoSensor *sensor)
handle if any field has changed
SoSFBool drawingOn
flag if the extension should draw, needs to be checked inside of the draw() method
void drawMiniTriangle(float xp, float yp, float ext, float lineWidth=1.f)
Draws a small triangle with given center point, half height and line width.
virtual void getStatusString(SbString &status)
get the current status of this extension
virtual void editingOnChanged(SoField *)
called when editingOn field is touched:
void callback(SoCallbackAction *action) override
virtual bool evaluateEvent(SoView2D *view2d, View2DEvent *ec)
void GLRender(SoGLRenderAction *action) override
Inventor actions.
SoSFEnum alt
shift alt for mouse mask
SoSFColor color
color that should be used for drawing
SoSFEnum button2
mouse mask for button2
int getSelectedIgnoreMask()
void drawMiniCircle(float xp, float yp, float ext, float lineWidth=1.f)
Draws a small circle with given center point and radius.
SoSFFloat selectionTolerance
the selection tolerance in pixels
static float pointToLineDistance(SbVec2f point, SbVec2f line1, SbVec2f line2)
calculate 2D point to line distance
virtual void draw(View2DSliceList *slicelist, View2DSlice *slice, int sliceZ)
Called by the SoView2D for each slice that is rendered.
SoSFBool fixZOn
DEPRECATED flag that indicates that the extension should fix the z value, only used in SoView2DRectan...
virtual void buttonMaskChanged(SoField *)
called when one of the button/modifier fields is touched:
SoSFBool renderOnSlab
defines if the extension should be rendered on all slab slices
SoSFEnum button3
mouse mask for button3
void drawFilledMiniTriangle(float xp, float yp, float ext, float lineWidth=1.f)
Draws a small filled triangle with given center point and half height.
virtual void consumeEvent(View2DEvent *ec, bool handled=TRUE)
Set handled-flag of ec to true (= consumed) if handled is True and setEventHandled is True.
void getBoundingBox(SoGetBoundingBoxAction *action) override
SoSFBool ignoreHandledEvents
Ignore events, that have been handled by previous extensions.
SoSFBool createNewMode
flag if extension is in createNewMode
virtual bool isFixZOn()
check if z should stay fixed
virtual void startDrawing(View2DSliceList *)
static Sign edgeIntersectWithPlane(const SbVec3f &v1, const SbVec3f &v2, const SbPlane &plane, SbVec3f &intersect)
intersect given edge from v1 to v2 with given plane, returns sign and intersect point
void drawMiniRect(float xp, float yp, float ext, float lineWidth=1.f)
Draws a small rectangle with given half side length and a line width.
virtual void updateValues()
Update fields to local variables, may be reimplemented if you want to update additional local vars.
void drawVoxelBorder(View2DSlice *slice, float vx, float vy, float vz)
surround the given voxel with a border
SoSFEnum cursorShape
Set cursor shape if the mouse mask fits and mouseEvents are effectively sent to evalEvent for editing...
static void fieldChangedCB(void *data, SoSensor *sensor)
inventor callbacks if any field has changed, calls fieldChanged
SoView2D is a 2D viewer for image data.
View2DEvent stores all information on an event on a SoView2D.
bool isOverViewer
is the device position on the viewer area
bool mouseOverUpdate
mouse over update
bool doubleclick
check if the event is a double click
bool handled
flag if the event was handled by someone
int button
index of button this event relates to
float slicePosX
voxel position if a slice was hit
bool button1
button1-3 currently down?
bool isKeyPressed
is key press event
void setValues(bool sh, bool ct, bool al, bool pr, bool mo, bool re, bool dc, bool b1, bool b2, bool b3, int dpx, int dpy, bool ov, int button, bool isKP, bool isKR, bool iVK, int kk, bool iVSP, float spx, float spy, float spz, long secs, long usecs, const SoEvent *event)
void print()
Method to get a string for coding/decoding the events.
View2DEvent(bool sh, bool ct, bool al, bool pr, bool mo, bool re, bool dc, bool b1, bool b2, bool b3, int dpx, int dpy, bool ov, int button, bool isKP, bool isKR, bool iVK, int kk, bool iVSP, float spx, float spy, float spz, long secs, long usecs, const SoEvent *event)
bool isValidSlicePos
was a slice hit?
bool isValidKey
is a valid key code
bool shift
Public members to be read from user.
int devicePosY
device Y position on the viewport (can also be virtual coordinate when rendered in 3D)
bool release
mouse released
int devicePosX
device X position on the viewport (can also be a virtual coordinate when rendered in 3D)
bool isKeyReleased
is key release event
long second
timestamp of event
View2DEvent()
Constructors to initialize the class.
const SoEvent * soevent
original soevent, you should not use this normally
bool sliceHit()
check if a slice was hit
a list that holds all View2DSlice objects (lazily created) of a SoView2D
a single slice that is stored in a View2DSliceList, typically created by a View2DSliceList
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
Drawing settings that can be overwritten by extensions.
SoView2DDrawingSettings()