MeVisLab Resolution Independence API
SoViewerNode.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_NODE_H
14 #define SO_VIEWER_NODE_H
15 
17 #include "XVInventor.h"
18 #include "XVcallbacks.h"
19 
20 #include <Inventor/nodes/SoSubNode.h>
21 #include <Inventor/nodes/SoSeparator.h>
22 
23 #include <SoViewerProxy.h>
24 
25 
26 class SoWinRenderArea;
27 
28 //=============================================================
30 
41 class INVENTORGUIWRAPPER_API SoViewerNode : public SoSeparator {
42 
43  SO_NODE_HEADER(SoViewerNode);
44 
45  public:
46  static void initClass();
47 
49 
51 
55  virtual void* createViewer(void* hwnd, SoNode* scene);
56 
58  virtual void deleteViewer(void* viewer);
59 
61  virtual void* getCurrentViewer() { return _currentViewer; };
62 
64  virtual void syncFromViewerNode(SoViewerNode* /* node */ ) {};
65 
67  void setKeyPressedCB(InvKeyPressedCB* cb, void* data) { _keyPressedCB = cb; _keyPressedCBData = data; };
68 
70  bool keyPressedNotify(void* message) {
71  if (_keyPressedCB) return (*_keyPressedCB)(_keyPressedCBData, this, message) ? true : false;
72  else return false;
73  }
74 
76  void setHandleEventCB(InvHandleEventCB* cb, void* data) { _handleEventCB = cb; _handleEventCBData = data; };
77 
79  bool handleEventNotify(void* message) {
80  if (_handleEventCB) return (*_handleEventCB)(_handleEventCBData, this, message) ? true : false;
81  else return false;
82  }
83 
85  void setGenerateMovieCB(InvGenerateMovieCB* cb, void* data) { _movieCB = cb; _movieCBData = data; };
86 
88  void generateMovie(const char* name,const char* extension, int count, float framerate, const char* targetFile=nullptr) {
89  if (_movieCB) (*_movieCB)(_movieCBData, this, name, extension, count, framerate, targetFile);
90  }
91 
92  protected:
97 
98  ~SoViewerNode() override;
99 
112 };
113 
114 #endif
#define INVENTORGUIWRAPPER_API
Library initialization interface of the inventor GUI wrapper.
void InvGenerateMovieCB(void *data, void *component, const char *name, const char *extension, int count, float framerate, const char *targetFile)
Callback used for movie generation.
Definition: XVcallbacks.h:34
int InvKeyPressedCB(void *data, void *component, void *message)
Callback used for key pressed forwarding (return 1 if used, 0 else) (deprecated!)
Definition: XVcallbacks.h:26
int InvHandleEventCB(void *data, void *component, void *message)
Callback used for event handling of viewers (return 1 if handled, 0 else) this replaces the above Inv...
Definition: XVcallbacks.h:31
Base class for all viewer nodes in MeVisLab.
Definition: SoViewerNode.h:41
void * _movieCBData
callback data for movie generation
Definition: SoViewerNode.h:103
void setKeyPressedCB(InvKeyPressedCB *cb, void *data)
set a keypressed callback
Definition: SoViewerNode.h:67
void * _currentViewer
pointer to the current viewer (void, because the concrete type is unkown)
Definition: SoViewerNode.h:94
SoViewerProxy * _viewerProxy
pointer to the proxy for this viewer
Definition: SoViewerNode.h:96
void * _handleEventCBData
callback data for handleEvent
Definition: SoViewerNode.h:111
virtual void * createViewer(void *hwnd, SoNode *scene)
create a viewer in the given window, the scene is shown in the viewer
virtual void deleteViewer(void *viewer)
delete the viewer that was created with createViewer
static void initClass()
virtual void * getCurrentViewer()
returns the currently viewer (or NULL, if none was created)
Definition: SoViewerNode.h:61
virtual void syncFromViewerNode(SoViewerNode *)
sync field from given src viewer node (derive to add more synched fields)
Definition: SoViewerNode.h:64
InvHandleEventCB * _handleEventCB
callback for handleEvent
Definition: SoViewerNode.h:109
~SoViewerNode() override
void generateMovie(const char *name, const char *extension, int count, float framerate, const char *targetFile=nullptr)
run move generation
Definition: SoViewerNode.h:88
void * _keyPressedCBData
callback data for key pressed
Definition: SoViewerNode.h:107
bool keyPressedNotify(void *message)
run keypressed cb
Definition: SoViewerNode.h:70
InvGenerateMovieCB * _movieCB
callback for movie generation
Definition: SoViewerNode.h:101
void setHandleEventCB(InvHandleEventCB *cb, void *data)
set a handle event callback
Definition: SoViewerNode.h:76
InvKeyPressedCB * _keyPressedCB
callback for key pressed
Definition: SoViewerNode.h:105
bool handleEventNotify(void *message)
run handle event cb
Definition: SoViewerNode.h:79
void setGenerateMovieCB(InvGenerateMovieCB *cb, void *data)
set movie generation callback
Definition: SoViewerNode.h:85
This class gives access to state of a viewer during scene graph traversal.
Definition: SoViewerProxy.h:30