MeVisLab Toolbox Reference
SoView2DSlider.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2013, 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 
19 
20 #include "../View2DIcons.h"
21 
24 {
25  SO_NODE_HEADER(SoView2DSlider);
26 
27 public:
30  {
31  ORIENTATION_HORIZONTAL = 0,
32  ORIENTATION_VERTICAL = 1
33  };
34 
36  {
37  HIT_RESULT_NONE = 0,
38  HIT_RESULT_BEFORE_INDICATOR = 1,
39  HIT_RESULT_ON_INDICATOR = 2,
40  HIT_RESULT_BEHIND_INDICATOR = 3
41  };
42 
43 
46  SoSFFloat minimumValue;
48  SoSFFloat maximumValue;
50  SoSFFloat currentValue;
53  SoSFBool useTracking;
58  SoSFFloat stepSize;
61  SoSFFloat snapSize;
63  SoSFBool revertDirection;
64 
66  SoSFBool isMouseOver;
68  SoSFBool isDragging;
69 
71  SoSFEnum orientation;
73  SoSFFloat relativeXPosition;
75  SoSFFloat relativeYPosition;
77  SoSFFloat relativeLength;
79  SoSFFloat relativeWidth;
80 
82  SoSFColor indicatorColor;
84  SoSFFloat indicatorAlpha;
86  SoSFColor sliderColor;
88  SoSFFloat sliderAlpha;
90 
96  SoSFString indicatorIconFile;
97 
102  SoSFString backgroundIconFile;
104 
106  static void initClass();
107 
111  ~SoView2DSlider() override;
112 
114  void draw(View2DSliceList* dsl, View2DSlice* dslice, int slice) override;
115 
117  bool evalEvent(SoView2D* view2d, View2DSliceList* slicelist, View2DEvent* ec, View2DEventPhase phase) override;
118 
120  bool ignoreEvent(View2DEvent* ec) override;
121 
123  bool implementsManagedInteractionAndClassicEventHandling() const override { return false; }
124 
125 protected:
126 
128  int getHitResult(SoView2D* view2d, const SbVec2f& deviceHitPosition);
130  bool positionIsInBox(const SbVec2f& position, const SbVec2f& boundingBoxMin, const SbVec2f& boundingBoxMax) const;
131 
134  void computeDeviceBoxes(View2DSliceList* dsl, int slice, SbVec2f &sliderMin, SbVec2f &sliderMax, SbVec2f &indicatorMin, SbVec2f &indicatorMax);
135 
136 
138  void fillDeviceBoundingBoxWholeSlider(SbVec2f& minBoundingBox, SbVec2f& maxBoundingBox);
140  void fillDeviceBoundingBoxIndicator(SbVec2f& minBoundingBox, SbVec2f& maxBoundingBox);
141 
143  SbVec2f getMiddleDevicePosition(View2DSliceList* slicelist, int z);
145  float getDeviceSliderLength(View2DSliceList* slicelist, int z);
147  float getDeviceSliderWidth(View2DSliceList* slicelist, int z);
148 
150  void fillVisibleDeviceRect(View2DSliceList* slicelist, int z, SbVec2f& minDeviceRect, SbVec2f& maxDeviceRect);
151 
153  void startDragging(const SbVec2f& currentDevicePosition);
155  void dragging(const SbVec2f& currentDevicePosition);
157  void stopDragging();
158 
169 
171  SbVec2f _sliderMin;
173  SbVec2f _sliderMax;
174 
179 
184 
187  bool isSensitiveAt(const SoPointerPosition& pos) override;
188  void setHighlightAt(const SoPointerPosition&) override;
189  void unsetHighlight() override;
190  void startPressAt(const SoPointerPosition& pos) override;
191  void dragMoveTo(const SoPointerPosition& pos) override;
192  SoPointingAction* endPress(int clickCount) override;
194 };
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.
SoPointerPosition manages the current position of the mouse cursor.
SoPointingAction is the base class for any mouse based interaction.
SoView2DInteractionExtension is base class for all SoView2DExtensions that want to support the Manage...
Displays an interactive slider in a 2D view.
void setupIndicatorIcon()
Setting up the indicator icon.
void dragging(const SbVec2f &currentDevicePosition)
Dragging the indicator.
void setupBackgroundIcon()
Setting up the background icon.
float getDeviceSliderLength(View2DSliceList *slicelist, int z)
Returns the length of the slider, depending on its orientation.
static void initClass()
Inventor runtime type system.
bool ignoreEvent(View2DEvent *ec) override
Overwrite ignoreEvent -> ignore the "ignoreHandledEvents"-Field.
void dragMoveTo(const SoPointerPosition &pos) override
int getHitResult(SoView2D *view2d, const SbVec2f &deviceHitPosition)
Returns the hit result for the slider.
SoSFFloat relativeWidth
Width of the slider/indicator, relative to the shortest axis.
bool _isDragging
Is the user currently dragging?
SoSFColor indicatorColor
Color of the indicator.
bool isSensitiveAt(const SoPointerPosition &pos) override
interface forwarded from SoPointingAction:
SoSFFloat relativeYPosition
Relative position in y-direction.
void fillDeviceBoundingBoxWholeSlider(SbVec2f &minBoundingBox, SbVec2f &maxBoundingBox)
Fills the bounding box min/max vectors for the whole slider.
SbVec2f _startDevicePosition
Start device position.
SbVec2f getMiddleDevicePosition(View2DSliceList *slicelist, int z)
Returns the middle position in device coordinates from the relative values and the current viewport.
void unsetHighlight() override
SoSFBool useBackgroundIconFile
Shall the icon file be used for visualizing the slider's background? Otherwise, the background is ren...
SoSFFloat stepSize
The step size.
SoSFBool isMouseOver
Is the mouse over the slider (not set if an incompatible modifier mask is set)
float _currentValue
The current value, used when in non-tracking mode.
SoSFBool useIndicatorIconFile
SoSFFloat relativeLength
Length of the slider, relative to the viewport's axis of orientation.
float _startDraggingCurrentValue
Current value at start of dragging.
void stopDragging()
Stop dragging the indicator.
float getDeviceSliderWidth(View2DSliceList *slicelist, int z)
Returns the width of the slider, depending on its orientation.
SoSFString backgroundIconFile
Name of the slider's background icon file.
SoSFBool revertDirection
Shall the indicator be reverted from max to min?
void startPressAt(const SoPointerPosition &pos) override
SoView2DSlider()
Constructor.
SoSFString indicatorIconFile
Name of the indicator's icon file.
void setHighlightAt(const SoPointerPosition &) override
SoSFFloat indicatorAlpha
Alpha value of indicator color.
SoSFFloat relativeXPosition
Relative position in x-direction.
bool positionIsInBox(const SbVec2f &position, const SbVec2f &boundingBoxMin, const SbVec2f &boundingBoxMax) const
Returns whether the given position is in the given bounding box.
void fillVisibleDeviceRect(View2DSliceList *slicelist, int z, SbVec2f &minDeviceRect, SbVec2f &maxDeviceRect)
Fills the given min/max vectors with the device coordinates of the visible rectangle.
SoSFFloat sliderAlpha
Alpha value of slider.
SoSFColor sliderColor
Color of the slider.
bool evalEvent(SoView2D *view2d, View2DSliceList *slicelist, View2DEvent *ec, View2DEventPhase phase) override
reimplemented from SoView2DExtension
SbVec2f _currentDevicePosition
Current device position.
SoSFEnum orientation
Defines the orientation.
void computeDeviceBoxes(View2DSliceList *dsl, int slice, SbVec2f &sliderMin, SbVec2f &sliderMax, SbVec2f &indicatorMin, SbVec2f &indicatorMax)
Computes and fills the boxes in device coordinates for the slider and the indicator.
SoSFBool useTracking
Shall each interaction lead to a value change or shall the value only be changed on finishing the int...
void startDragging(const SbVec2f &currentDevicePosition)
Start dragging the indicator.
~SoView2DSlider() override
Destructor.
SoSFFloat maximumValue
The maximum value.
SbVec2f _sliderMax
Slider max bounding box at event time.
bool implementsManagedInteractionAndClassicEventHandling() const override
This extension does not implement the classic event handling.
SbVec2f _sliderMin
Slider min bounding box at event time.
SoSFFloat snapSize
The snap size.
SoSFFloat currentValue
The current value.
View2DIcons * _backgroundIcon
The slider's background icon.
void fillDeviceBoundingBoxIndicator(SbVec2f &minBoundingBox, SbVec2f &maxBoundingBox)
Fills the bounding box min/max vectors for the indicator only.
View2DIcons * _indicatorIcon
The slider's indicator icon.
void draw(View2DSliceList *dsl, View2DSlice *dslice, int slice) override
reimplemented from SoView2DExtension
SoSFFloat minimumValue
SoSFBool isDragging
Set while the user drags the indicator.
SLIDER_ORIENTATION
Enumeration of the slider's orientations.
SoPointingAction * endPress(int clickCount) override
SoView2D is a 2D viewer for image data.
Definition: SoView2D.h:62
View2DEvent stores all information on an event on a SoView2D.
Defines and implements a class to store multiple images and draw them via OpenGL.
Definition: View2DIcons.h:24
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
Definition: View2DSlice.h:48