MeVisLab Toolbox Reference
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
160 };
161
164 static const char * const * cursorShapeNames();
165
169
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
282If 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.
void setDevicePixelRatio(double scaleFactor)
SoResolutionIndependentViewerProxy()
Constructor.
~SoResolutionIndependentViewerProxy() override
Destructor.
double _devicePixelRatio
Device pixel ratio.
SoViewerProxy()
Protected constructor. Class must be derived to be adapted to actual viewer.
virtual int defineCursor(const char *, int=-1, int=-1, int=-1)
virtual bool getCurrentCursorPosition(int &x, int &y)
virtual bool isHighQualityOffscreenRendering() const
Returns true if high quality offscreen rendering (e.g., for OffscreenRenderer) is desired.
virtual ~SoViewerProxy()
Destructor.
virtual void setCursor(int)
virtual bool hasShape(int shapeID)
Returns true if the cursor shape has already been defined.
static const char *const * cursorShapeNames()
static int getPredefinedCursorCount()
static const ml::EnumValues< cursorShapeEnum > & getCursorShapeEnumValues()
Returns 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()
Returns the next free ID for defining custom cursor shape.
virtual bool isUserInterationEventInQueue() const
virtual SoMetaInformationMap * getMetaInformationMap()
virtual void setForceCursor(int shapeID)
double getDevicePixelRatio() override
virtual double getDevicePixelRatio()