MeVisLab Resolution Independence API
Loading...
Searching...
No Matches
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:
34 {}
35
161 };
162
165 static const char* const* cursorShapeNames();
166
170
172 static const ml::EnumValues<cursorShapeEnum>& getCursorShapeEnumValues();
173
176 virtual void setCursor(int /*shapeID*/)
177 {}
178
180 virtual bool hasShape(int shapeID);
181
183 static int getNextFreeShapeID();
184
199 virtual int defineCursor(const char* /*cursorImgFileName*/, int /*hotSpotX*/ = -1, int /*hotSpotY*/ = -1,
200 int /*id*/ = -1)
201 {
202 return -1;
203 }
204
207 virtual bool getCurrentCursorPosition(int& x, int& y);
208
210 virtual bool isInitialRendering() const
211 {
212 return false;
213 }
214
217 {
218 return false;
219 }
220
223 virtual bool isUserInterationEventInQueue() const
224 {
225 return false;
226 }
227
232 {
233 return nullptr;
234 }
235
238 virtual double getDevicePixelRatio()
239 {
240 return 1.0;
241 }
242
245 virtual void setForceCursor(int shapeID)
246 {
247 setCursor(shapeID);
248 }
249
250protected:
254};
255
257{
258public:
264
267 double getDevicePixelRatio() override;
268
269SoINTERNAL public : void setDevicePixelRatio(double scaleFactor);
270
271protected:
274};
275
276/*
277Code fragments to define your own cursor:
278
279Simple (but slightly wrong way):
280
281 // in constructor
282 myCursor = -1;
283
284 // when setting cursor:
285 SoViewerProxy* viewerProxy = SoViewerElement::get (action->getState());
286 if (viewerProxy) {
287 if (myCursor == -1) {
288 myCursor = viewerProxy->defineCursor ("images/myCursor.png", 5, 7);
289 }
290 viewerProxy->setCursor (myCursor);
291 }
292
293
294Better:
295
296 // in constructor
297 myCursor = SoViewerProxy::getNextFreeShapeID();
298
299 // when setting cursor:
300 SoViewerProxy* viewerProxy = SoViewerElement::get (action->getState());
301 if (viewerProxy) {
302 viewerProxy->defineCursor ("images/myCursor.png", 5, 7, myCursor); // does nothing after the first time!
303 viewerProxy->setCursor (myCursor);
304 }
305
306If only using pre-defined cursor shapes:
307
308 // when setting cursor:
309 SoViewerElement::setCursor (action->getState(),
310 SoViewerProxy::MOVE_ALL_CURSOR); // no pointer check necessary
311
312
313If you want to make the cursor shape accessible through a SoField declare it like this:
314
315 SO_NODE_ADD_FIELD(cursorShape, (SoViewerProxy::UNDEFINED_CURSOR));
316 SO_NODE_DEFINE_CURSOR_SHAPE_ENUM(SoViewerProxy::cursorShapeEnum);
317 SO_NODE_SET_SF_ENUM_TYPE(cursorShape, SoViewerProxy::cursorShapeEnum);
318
319and set it like this:
320
321 SoViewerElement::setCursor (action->getState(), cursorShape.getValue());
322
323
324*/
325
326#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()