MeVisLab Resolution Independence API
SoViewportRegion.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#ifndef SO_VIEWPORT_REGION_H
14#define SO_VIEWPORT_REGION_H
15
16
19
20#include <Inventor/fields/SoSFBool.h>
21#include <Inventor/fields/SoSFInt32.h>
22#include <Inventor/nodes/SoSeparator.h>
23#include <Inventor/nodes/SoSubNode.h>
24#include <Inventor/events/SoMouseButtonEvent.h>
25#include <Inventor/sensors/SoFieldSensor.h>
26#include <Inventor/sensors/SoNodeSensor.h>
27
28#include <Inventor/fields/SoSFVec2f.h>
29#include <Inventor/fields/SoSFEnum.h>
30#include <Inventor/nodes/SoPerspectiveCamera.h>
31
32#include "SoUtilsSystem.h"
33
34class SoGLRenderAction;
35class SoGetBoundingBoxAction;
36class SoRayPickAction;
37class SoViewportRegionWrapper;
38
39typedef SbViewportRegion(*CallbackFunctionPtr)(void*, SbViewportRegion);
40
41class SOUTILS_EXPORT SoViewportRegion : public SoSeparator
42{
43
45 SO_NODE_HEADER(SoViewportRegion);
46
47public:
50
52 static void initClass();
53
54 // position mode for one dimension: position and size of the overlay can be defined using two scalar values per dimension
55 // this enum defines how those two values have to be interpreted (position or size?)
57 POSITION_MODE_MIN_AND_MAX, //2 positions are defined: left and right or lower and upper border
58 POSITION_MODE_CENTER_AND_SIZE, //1 position and 1 size are defined: center and width or height
59 POSITION_MODE_MIN_AND_SIZE, //1 position and 1 size are defined: left or lower border and width or height
60 POSITION_MODE_MAX_AND_SIZE //1 position and 1 size are defined: right or upper border and width or height
61 };
62
63 // defines for one (1D-) position if it is related to the minimum (left or lower) or maximum (right or upper) border or the center of the dimension
65 REFERENCE_MODE_MIN, //related to left or lower border
66 REFERENCE_MODE_CENTER, //related to center
67 REFERENCE_MODE_MAX //related to right or upper border
68 };
69
70 // defines for one scalar whether it is defined in pixels or relative to the size of one dimension
72 DOMAIN_MODE_ABSOLUTE, //value given in pixels
73 DOMAIN_MODE_RELATIVE_TO_HEIGHT, //value given in percent (0-1) of the height
74 DOMAIN_MODE_RELATIVE_TO_WIDTH, //value given in percent (0-1) of the width
75 DOMAIN_MODE_RELATIVE_TO_MIN, //value given in percent (0-1) of the minimum of width and height
76 DOMAIN_MODE_RELATIVE_TO_MAX, //value given in percent (0-1) of the minimum of width and height
77 };
78
79 // defines, what camera is used for the rendering of the scene
86
88
90 SoSFBool on;
91
93 SoSFBool modifyVP;
94
96 SoSFBool usePreviousVP;
97
100
103
106
109
111 SoSFFloat x1;
112
115
117 SoSFEnum x1DomainMode;
118
120 SoSFFloat x2;
121
124
126 SoSFEnum x2DomainMode;
127
130
132 SoSFFloat y1;
133
136
138 SoSFEnum y1DomainMode;
139
141 SoSFFloat y2;
142
145
147 SoSFEnum y2DomainMode;
148
151
154
157
160
163
166
169
172
175
177 SoSFBool enableBorder;
178
180 SoSFInt32 borderWidth;
181
183 SoSFColor borderColor;
184
186 SoSFFloat borderAlpha;
187
190
193
196
198
200 void getBoundingBox(SoGetBoundingBoxAction *action) override;
201
203 void GLRenderBelowPath(SoGLRenderAction *action) override;
204
206 void handleEvent(SoHandleEventAction *action) override;
207
210 {
211 _vprCallbackFunction = cb;
212 _vprCallbackFunctionObject = p;
213 resetViewportRegion();
214 }
215
217 void resetViewportRegion() { _prevInVPR = SbViewportRegion(0, 0); };
218
219
220protected:
223
225 SbViewVolume::ProjectionType _projType;
226 SbViewportRegion _prevInVPR, _prevOutVPR;
227
228 SoRef<SoCamera> _insetCam;
229
231 SbViewportRegion getViewportRegion(SoState *state);
232
234 int getInterpretedPosition(float value, int width, int height, bool isY, ReferenceMode refMode, DomainMode domMode);
235
237 int getInterpretedSize(float value, int width, int height, DomainMode domMode);
238
240 void onVPRFieldChanged(SoField*) { resetViewportRegion(); };
241
242
243 private:
244 SbBool _calcBBoxIntern;
245
246 CallbackFunctionPtr _vprCallbackFunction;
247 void *_vprCallbackFunctionObject;
248};
249
250#endif // __SoViewportRegion_H
#define SOUTILS_EXPORT
System dependent includes. Disables some compiler/linker warnings.
SbViewportRegion(* CallbackFunctionPtr)(void *, SbViewportRegion)
SoViewportRegion()
Constructor.
SoSFFloat y1
First value for viewport region definition in the y-dimension (lower border, upper border or center)
SbViewVolume::ProjectionType _projType
SoSFBool mapEventToViewport
Enable/Disable mapping of event coordinates to the viewport region.
SoSFBool forwardEvents
Enable/Disable forwarding of events to children.
SoSFBool renderDelayedPaths
Enable/Disable delayed path rendering.
SoSFEnum x2ReferenceMode
Reference for x2.
SoSFBool forwardEventsInViewportOnly
If true, only events that occurred in the viewport region will be forwarded.
int getInterpretedPosition(float value, int width, int height, bool isY, ReferenceMode refMode, DomainMode domMode)
Interprets value as position in relation to given size based on the ReferenceMode and the DomainMode.
SoSFEnum x1DomainMode
Domain of x1.
SbViewportRegion getViewportRegion(SoState *state)
Computes the ViewportRegion.
SoSFFloat borderAlpha
Alpha used for drawing the border.
SoRef< SoCamera > _insetCam
void onVPRFieldChanged(SoField *)
Called on changes of fields that may influence the viewport region definition.
SoSFFloat x2
Second value for viewport region definition in the x-dimension (width or right border)
SoSFEnum x2DomainMode
Domain of x1.
SoSFEnum yPositionMode
Define how specify the viewport region in the y-dimension.
SoSFBool autoScaleAbsoluteValuesHiDPI
Enable automatic rescaling of absolute values in high DPI rendering.
void GLRenderBelowPath(SoGLRenderAction *action) override
Reimplemented GLRenderBelowPath to render child graph with modified viewportSize.
SoSFEnum y1ReferenceMode
Reference for y1.
SoSFBool consumeEventsInViewport
Enable/Disable consumption of handled events.
SoSFBool cacheViewportRegion
Enable caching of viewport region.
ProjectionType _prevProjType
void getBoundingBox(SoGetBoundingBoxAction *action) override
Get bounding box.
SoSFFloat y2
Second value for viewport region definition in the y-dimension (height or upper border)
SoSFColor borderColor
Color used for drawing the border.
SoSFBool enableBackground
Enable/Disable drawing of a background.
SoSFBool usePreviousVP
Enable/Disable relative viewport region modification.
SoSFBool on
! Fields
SoSFEnum projectionType
Used ProjectionType.
SoSFFloat x1
First value for viewport region definition in the x-dimension (right border, left border or center)
SoSFFloat backgroundAlpha
Alpha used for drawing the background.
SoSFBool detectMouseOver
Enable/Disable mouse over detection.
SbViewportRegion _prevInVPR
SoSFEnum x1ReferenceMode
Reference for x1.
static void initClass()
Initializes this class (called on dll initialization).
SoSFEnum xPositionMode
Define how specify the viewport region in the x-dimension.
SoSFBool enableBorder
Enable/Disable drawing of a border.
int getInterpretedSize(float value, int width, int height, DomainMode domMode)
Interprets value as size in relation to given size based on the DomainMode.
SoSFBool mouseOverViewport
Indicates if the mouse is over the viewport region.
SoSFInt32 borderWidth
Width of the border.
SoSFBool useViewportRegionDefinitionCallback
Enable usage of callback function for viewport region definition.
SoSFBool modifyVP
Enable/Disable viewport region modification.
SoSFEnum y2ReferenceMode
Reference for y2.
void resetViewportRegion()
resets _prevInVPR and therfore forces recomputation of the viewport region
~SoViewportRegion() override
Destructor.
void handleEvent(SoHandleEventAction *action) override
Handle event is reimplemented to forward events with modified viewportSize.
SoSFEnum y1DomainMode
Domain of y1.
SoSFColor backgroundColor
Color used for drawing the background.
SoSFEnum y2DomainMode
Domain of y2.
@ AUTO
same type as previous camera in state
void connectViewportRegionDefinitionCallback(CallbackFunctionPtr cb, void *p)
Called by wrapper to create connection.
SoSFBool keepViewportWhileDragging
Do not change into/out of viewport while dragging (hold mouse button pressed)