MeVisLab Resolution Independence API
SoViewerProxy.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_VIEWER_PROXY_H
14#define SO_VIEWER_PROXY_H
15
17
19#include <ThirdPartyWarningsDisable.h>
20#include <Inventor/SbBasic.h>
21#include <ThirdPartyWarningsRestore.h>
22
23#include <mlFields.h>
24
26
30{
31public:
33 virtual ~SoViewerProxy() {}
34
38 UNDEFINED_CURSOR = -1,
39 DEFAULT_CURSOR = 0,
159 PREDEFINED_CURSOR_COUNT
160 };
161
164 static const char * const * cursorShapeNames();
165
169
171 static const ml::EnumValues<cursorShapeEnum>& getCursorShapeEnumValues();
172
175 virtual void setCursor (int /*shapeID*/) {}
176
178 virtual bool hasShape (int shapeID);
179
181 static int getNextFreeShapeID();
182
197 virtual int defineCursor (const char* /*cursorImgFileName*/,
198 int /*hotSpotX*/ = -1, int /*hotSpotY*/ = -1, int /*id*/ = -1) { return -1; }
199
202 virtual bool getCurrentCursorPosition(int& x, int& y);
203
205 virtual bool isInitialRendering() const { return false; }
206
208 virtual bool isHighQualityOffscreenRendering() const { return false; }
209
212 virtual bool isUserInterationEventInQueue() const { return false; }
213
217 virtual SoMetaInformationMap* getMetaInformationMap() { return nullptr; }
218
221 virtual double getDevicePixelRatio() { return 1.0; }
222
225 virtual void setForceCursor(int shapeID) { setCursor(shapeID); }
226
227protected:
230};
231
233{
234public:
239
242 double getDevicePixelRatio() override;
243
244SoINTERNAL public:
245 void setDevicePixelRatio(double scaleFactor);
246
247protected:
250};
251
252/*
253code fragments to define your own cursor:
254
255simple (but slightly wrong way):
256
257 // in constructor
258 myCursor = -1;
259
260 // when setting cursor:
261 SoViewerProxy* viewerProxy = SoViewerElement::get (action->getState());
262 if (viewerProxy) {
263 if (myCursor == -1) {
264 myCursor = viewerProxy->defineCursor ("images/myCursor.png", 5, 7);
265 }
266 viewerProxy->setCursor (myCursor);
267 }
268
269
270better:
271
272 // in constructor
273 myCursor = SoViewerProxy::getNextFreeShapeID();
274
275 // when setting cursor:
276 SoViewerProxy* viewerProxy = SoViewerElement::get (action->getState());
277 if (viewerProxy) {
278 viewerProxy->defineCursor ("images/myCursor.png", 5, 7, myCursor); // does nothing after the first time!
279 viewerProxy->setCursor (myCursor);
280 }
281
282when only using pre-defined cursor shapes:
283
284 // when setting cursor:
285 SoViewerElement::setCursor (action->getState(),
286 SoViewerProxy::MOVE_ALL_CURSOR); // no pointer check necessary
287
288
289if you want to make the cursor shape accessible through a SoField declare it like this:
290
291 SO_NODE_ADD_FIELD(cursorShape, (SoViewerProxy::UNDEFINED_CURSOR));
292 SO_NODE_DEFINE_CURSOR_SHAPE_ENUM(SoViewerProxy::cursorShapeEnum);
293 SO_NODE_SET_SF_ENUM_TYPE(cursorShape, SoViewerProxy::cursorShapeEnum);
294
295and set it like this:
296
297 SoViewerElement::setCursor (action->getState(), cursorShape.getValue());
298
299
300*/
301
302#endif // __SOVIEWERPROXY_H
#define INVENTORWRAPPER_API
Library initialization and export macros for platform independecy of project.
SoMetaInformationMap allows to record information on the current render state.
void setDevicePixelRatio(double scaleFactor)
SoResolutionIndependentViewerProxy()
Constructor.
~SoResolutionIndependentViewerProxy() override
Destructor.
double _devicePixelRatio
device pixel ratio
This class gives access to state of a viewer during scene graph traversal.
SoViewerProxy()
Protected constructor. Class must be derived to be adapted to actual viewer.
virtual int defineCursor(const char *, int=-1, int=-1, int=-1)
Define new cursor shape - successful operation is only guaranteed with PNG-Images with size 32x32,...
virtual bool getCurrentCursorPosition(int &x, int &y)
Get current cursor position relative to the viewing window.
cursorShapeEnum
pre-defined cursor shapes; note that you must adapt the list of names in SoViewerProxy....
virtual bool isHighQualityOffscreenRendering() const
returns true if high quality offscreen rendering (e.g. for OffscreenRenderer) is desired
virtual ~SoViewerProxy()
Destructor.
virtual void setCursor(int)
Set cursor of viewer to pre- or user-defined shape, invalid values will set cursor to default shape.
virtual bool hasShape(int shapeID)
return true if the cursor shape has already been defined
static const char *const * cursorShapeNames()
return list of strings containing cursor shape names; this includes UNDEFINED_CURSOR,...
static int getPredefinedCursorCount()
get number of predefined cursors from code (instead of requiring a re-compilation of all using librar...
static const ml::EnumValues< cursorShapeEnum > & getCursorShapeEnumValues()
get enum values record for use with ml::TypedEnumField
virtual bool isInitialRendering() const
returns true if the viewer does the initial rendering after it became visible
static int getNextFreeShapeID()
return the next free id for defining your own cursor shape
virtual bool isUserInterationEventInQueue() const
returns if a user interaction event is the the GUI event queue (or in a remote rendering scenario in ...
virtual SoMetaInformationMap * getMetaInformationMap()
returns the current SoMetaInformationMap, which allows storing of the current meta information / rend...
virtual void setForceCursor(int shapeID)
Enforce setting the cursor, even from mouseOverUpdates.
double getDevicePixelRatio() override
Returns the ratio between physical pixels and device-independent pixels for the viewer.
virtual double getDevicePixelRatio()
Returns the ratio between physical pixels and device-independent pixels for the viewer.