MeVisLab Resolution Independence API
SoQtViewerProxy.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_QT_VIEWER_PROXY_H
14#define SO_QT_VIEWER_PROXY_H
15
17
18#include <QCursor>
19
20#include <SoViewerProxy.h>
21
22#include <Inventor/nodes/SoSubNode.h>
23#include <Inventor/nodes/SoGroup.h>
24
25class SoQtRenderArea;
26class SoAction;
27
29{
31
32 /* This class also implements an easy mechanism to override predefined cursors:
33 Put a property called "OverrideCursorDirectory" into your MeVisLab
34 preferences file and point it to the directory with the alternative cursors in
35 PNG graphics format.
36
37 Preferred cursor size is 32x32, the hot spot is always in the middle of the image.
38 If you need another hotspot, you can add the hotspot location in the filename
39 after an exclamation point (but before the file ending), like
40
41 otherCursor11!8,12.png
42
43 For support of high resolution displays, add an additional file of size 64x64,
44 omitting the hotspot location, like this:
45
46 otherCursor11@2x.png
47
48 The base file name is usually the name of the enumeration value in lower case
49 with the underscores removed and the letters after the underscores in upper case.
50 Then append an eventual hotspot location and ".png".
51 Exceptions from this rule - with additional upper case letters - are:
52 moveFDiagCursor.png
53 moveBDiagCursor.png
54 moveInOutCursor.png
55 rotateXYCursor.png
56 crossFreeFormCursor.png
57 crossPolyLineCursor.png
58 */
59
60public:
62 SoQtViewerProxy (SoQtRenderArea* renderArea = nullptr);
64 ~SoQtViewerProxy() override {}
65
68 void setCursor (int shapeID) override;
69
72 void setForceCursor(int shapeID) override;
73
75 int getCursor() { return _requestedShape; }
76
78 bool hasShape (int shapeID) override;
79
85 int defineCursor (const char* cursorImgFileName, int hotSpotX = -1, int hotSpotY = -1,
86 int id = -1) override;
87
89 static bool forceDefineCursor (int id, const char* cursorImgFileName, int hotSpotX = -1, int hotSpotY = -1);
90
98
100 virtual void resetCursor();
101
103 virtual void evaluateCursor();
104
108 static void resetCursorCB (void* userData, SoAction* action);
109
115 static void evaluateCursorCB (void* userData, SoAction* action);
116
120 virtual bool actionMayChangeCursor(SoAction* action);
122
125 bool getCurrentCursorPosition(int& x, int& y) override;
126
130
132 bool isInitialRendering() const override;
133
135 bool isUserInterationEventInQueue() const override;
136
138 static QCursor getCursor(int shapeID);
139
141 static QPixmap getPixmap(int shapeID);
142
144 static QPixmap getPixmap2x(int shapeID);
145
149 static int getShapeID(const QCursor& cursor);
150
152 static bool isSameCursor(const QCursor& a, const QCursor& b);
153
156 double getDevicePixelRatio() override;
157
158protected:
160 SoQtRenderArea* _renderArea;
161
164
167};
168
169//===========================================================================
170
174{
175 SO_NODE_HEADER(SoQtViewerProxyNode);
176
177public:
181
183 static void initClass();
184
186 void GLRender(SoGLRenderAction *action) override;
187 void handleEvent(SoHandleEventAction *action) override;
188
189protected:
191};
192
193
194#endif // __SoQtViewerProxy_H
#define INVENTORGUIWRAPPER_API
SoQtViewerProxyNode will put a SoViewerElement with the given SoQtViewerProxy into the scene and also...
~SoQtViewerProxyNode() override
void GLRender(SoGLRenderAction *action) override
Sets SoQtViewerProxy before scene traversal.
SoQtViewerProxyNode(SoQtViewerProxy *proxy=nullptr)
Constructor.
SoQtViewerProxy * _proxy
static void initClass()
Initializes this class.
void handleEvent(SoHandleEventAction *action) override
bool isInitialRendering() const override
Returns true if the viewer does the initial rendering after it became visible.
int getCursor()
Returns the requested cursor shape.
static bool isSameCursor(const QCursor &a, const QCursor &b)
Compares cursor shapes.
static QPixmap getPixmap(int shapeID)
Returns the QPixmap associated with the given shapeID in 1x resolution.
bool isUserInterationEventInQueue() const override
Returns whether a user interaction event is the the GUI event queue.
bool getCurrentCursorPosition(int &x, int &y) override
Returns the current cursor position relative to the viewing window.
virtual void resetCursor()
Resets the stored cursor shape. This must be called before event handling traversal.
static int getShapeID(const QCursor &cursor)
Returns the shape ID associated with the given cursor.
static QCursor getCursor(int shapeID)
Returns the QCursor associated with the given shapeID.
SoQtRenderArea * _renderArea
Pointer to the actual viewer.
static void resetCursorCB(void *userData, SoAction *action)
This callback can be used together with a SoCallback node, userData must be set to the pointer to thi...
static void initializeDefaultCursors()
On some platforms, it may not be possible to initialize the default cursors at any time,...
static bool forceDefineCursor(int id, const char *cursorImgFileName, int hotSpotX=-1, int hotSpotY=-1)
defineCursor simply calls this method, which will overwrite previous shapes.
void setForceCursor(int shapeID) override
Enforces the setting the cursor, even from mouseOverUpdates.
virtual bool actionMayChangeCursor(SoAction *action)
Returns whether the given action may change the cursor.
SoQtViewerProxy(SoQtRenderArea *renderArea=nullptr)
This class implements access to the state of the SoQtMeVis viewer.
bool _cursorEnforced
Cursor setting was enforced.
int defineCursor(const char *cursorImgFileName, int hotSpotX=-1, int hotSpotY=-1, int id=-1) override
Defines new cursor shape - successful operation is only guaranteed with PNG-Images with size 32x32,...
virtual void evaluateCursor()
Evaluates the set cursor shape. This must be called after event handling traversal.
static QPixmap getPixmap2x(int shapeID)
Returns the QPixmap associated with the given shapeID in 2x resolution.
static void evaluateCursorCB(void *userData, SoAction *action)
This callback can be used together with a SoCallback node, userData must be set to the pointer to thi...
void setCursor(int shapeID) override
Sets the cursor of the viewer to pre- or user-defined shape.
int _requestedShape
Currently requested cursor shape.
~SoQtViewerProxy() override
Destructor.
bool hasShape(int shapeID) override
Checks whether this shape has already been defined.
This class gives access to state of a viewer during scene graph traversal.
double getDevicePixelRatio() override
Returns the ratio between physical pixels and device-independent pixels for the viewer.