MeVisLabToolboxReference
MeVis/Foundation/Sources/MLInventorBinding/SoViewerProxy.h
Go to the documentation of this file.
00001 // **InsertLicense** code
00002 //----------------------------------------------------------------------------------
00004 
00009 //----------------------------------------------------------------------------------
00010 
00011 #ifndef __SoViewerProxy_H
00012 #define __SoViewerProxy_H
00013 
00014 #ifndef __InventorWrapperDllInit_H
00015 #include "InventorWrapperDllInit.h"
00016 #endif
00017 
00020 class INVENTORWRAPPER_API SoViewerProxy
00021 {
00022 public:
00024     virtual ~SoViewerProxy() {}
00025 
00028     enum {
00029         UNDEFINED_CURSOR = -1,
00030         DEFAULT_CURSOR = 0,
00031         FORBIDDEN_CURSOR,
00032         POINTING_HAND_CURSOR,
00033         OPEN_HAND_CURSOR,
00034         CLOSED_HAND_CURSOR,
00035         MOVE_ALL_CURSOR,
00036         MOVE_HORI_CURSOR,
00037         MOVE_VERT_CURSOR,
00038         MOVE_FDIAG_CURSOR,
00039         MOVE_BDIAG_CURSOR,
00040         MOVE_INOUT_CURSOR,
00041         ROTATE_X_CURSOR,
00042         ROTATE_Y_CURSOR,
00043         ROTATE_Z_CURSOR,
00044         ROTATE_XY_CURSOR,
00045         ZOOM_CURSOR,
00046         ZOOM_IN_CURSOR,
00047         ZOOM_OUT_CURSOR,
00048         CROSS_CURSOR,
00049         CROSS_PLUS_CURSOR,
00050         CROSS_MINUS_CURSOR,
00051         CROSS_MOVE_CURSOR,
00052         CROSS_ROTATE_CURSOR,
00053         CROSS_RECT_CURSOR,
00054         CROSS_OVAL_CURSOR,
00055         CROSS_VECTOR_CURSOR,
00056         CROSS_FREEFORM_CURSOR,
00057         CROSS_POINT_CURSOR,
00058         CROSS_LINE_CURSOR,
00059         CROSS_CURVE_CURSOR,
00060         CROSS_POLYLINE_CURSOR,
00061         CROSS_POLYGON_CURSOR,
00062         CROSS_FILL_CURSOR,
00063         CROSS_LINK_CURSOR,
00064         CROSS_0_CURSOR,
00065         CROSS_1_CURSOR,
00066         CROSS_2_CURSOR,
00067         CROSS_3_CURSOR,
00068         CROSS_4_CURSOR,
00069         CROSS_5_CURSOR,
00070         CROSS_6_CURSOR,
00071         CROSS_7_CURSOR,
00072         CROSS_8_CURSOR,
00073         CROSS_9_CURSOR,
00074         LUT_CURSOR,
00075         LUT_1_CURSOR,
00076         LUT_2_CURSOR,
00077         LUT_3_CURSOR,
00078         SLICING_CURSOR,
00079         PREDEFINED_CURSOR_COUNT
00080     } cursorShapeEnum;
00081 
00084     static const char * const * cursorShapeNames();
00085 
00088     virtual void setCursor (int /*shapeID*/) {}
00089 
00091     virtual bool hasShape (int shapeID);
00092 
00094     static int getNextFreeShapeID();
00095 
00107     virtual int defineCursor (const char* /*cursorImgFileName*/,
00108                               int /*hotSpotX*/ = -1, int /*hotSpotY*/ = -1, int /*id*/ = -1) { return -1; }
00109 
00112     virtual bool getCurrentCursorPosition(int& x, int& y);
00113 
00115     virtual bool isInitialRendering() const { return false; }
00116 
00119     virtual bool isUserInterationEventInQueue() const { return false; }
00120 
00121 protected:
00123     SoViewerProxy() {}
00124 };
00125 
00126 /*
00127 code fragments to define your own cursor:
00128 
00129 simple (but slightly wrong way):
00130 
00131     // in constructor
00132     myCursor = -1;
00133 
00134     // when setting cursor:
00135     SoViewerProxy* viewerProxy = SoViewerElement::get (action->getState());
00136     if (viewerProxy) {
00137         if (myCursor == -1) {
00138             myCursor = viewerProxy->defineCursor ("images/myCursor.png", 5, 7);
00139         }
00140         viewerProxy->setCursor (myCursor);
00141     }
00142 
00143 
00144 better:
00145 
00146     // in constructor
00147     myCursor = SoViewerProxy::getNextFreeShapeID();
00148 
00149     // when setting cursor:
00150     SoViewerProxy* viewerProxy = SoViewerElement::get (action->getState());
00151     if (viewerProxy) {
00152         viewerProxy->defineCursor ("images/myCursor.png", 5, 7, myCursor);  // does nothing after the first time!
00153         viewerProxy->setCursor (myCursor);
00154     }
00155 
00156 when only using pre-defined cursor shapes:
00157 
00158     // when setting cursor:
00159     SoViewerElement::setCursor (action->getState(),
00160                                 SoViewerProxy::MOVE_ALL_CURSOR); // no pointer check necessary
00161 
00162 
00163 if you want to make the cursor shape accessible through a SoField declare it like this:
00164 
00165     SO_NODE_ADD_FIELD(cursorShape, (SoViewerProxy::UNDEFINED_CURSOR));
00166     SO_NODE_DEFINE_CURSOR_SHAPE_ENUM(SoViewerProxy::cursorShapeEnum);
00167     SO_NODE_SET_SF_ENUM_TYPE(cursorShape, SoViewerProxy::cursorShapeEnum);
00168 
00169 and set it like this:
00170 
00171     SoViewerElement::setCursor (action->getState(), cursorShape.getValue());
00172 
00173 
00174 */
00175 
00176 #endif // __SOVIEWERPROXY_H