MeVisLabToolboxReference
|
00001 #ifndef __SoView2DPlane_H 00002 #define __SoView2DPlane_H 00003 //---------------------------------------------------------------------------------- 00004 // **InsertLicense** code 00005 //---------------------------------------------------------------------------------- 00012 //---------------------------------------------------------------------------------- 00013 00014 #ifndef __SoView2DInteractionExtension_H 00015 #include "SoView2DInteractionExtension.h" 00016 #endif 00017 00018 #include <XVEnterScope.h> 00019 #include <Inventor/fields/SoSFPlane.h> 00020 #include <Inventor/fields/SoSFFloat.h> 00021 #include <Inventor/fields/SoSFVec3f.h> 00022 #include <Inventor/fields/SoSFBool.h> 00023 #include <Inventor/fields/SoSFInt32.h> 00024 #include <Inventor/fields/SoSFMatrix.h> 00025 #include <XVLeaveScope.h> 00026 00027 class SoView2D; 00028 00029 class SOVIEW2D_API SoView2DPlane : public SoView2DInteractionExtension { 00030 00031 SO_NODE_HEADER(SoView2DPlane); 00032 00033 public: 00034 enum InteractionMode { 00035 TRANSLATE, 00036 ROTATE, 00037 BOTH 00038 }; 00039 00040 enum NormalShape { 00041 TRIANGLE, 00042 ARROW 00043 }; 00044 00046 00048 SoSFPlane plane; 00049 00053 SoSFEnum interactionMode; 00054 00057 SoSFBool maskValidAndHit; 00058 00060 SoSFFloat blendMin; 00062 SoSFFloat blendMax; 00064 SoSFBool normalOn; 00066 SoSFBool externalRotationAxisOn; 00068 SoSFVec3f externalRotationAxis; 00070 SoSFFloat centerGapSize; 00072 SoSFInt32 normalSize; 00074 SoSFFloat normalOffset; 00076 SoSFEnum normalShape; 00078 SoSFMatrix rotationDifference; 00080 SoSFFloat translationLineFraction; 00082 SoSFBool useTranslationRange; 00084 SoSFFloat translationRangeMin; 00086 SoSFFloat translationRangeMax; 00088 SoSFBool fixedLineWidth; 00090 SoSFBool useAntiAliasing; 00092 SoSFBool useMouseCursors; 00094 00096 static void initClass(); 00097 00099 SoView2DPlane(); 00100 00102 virtual void draw(View2DSliceList *dsl, View2DSlice* dslice, int slice); 00103 00105 bool evalEvent(SoView2D* view2d, View2DSliceList* slicelist, 00106 View2DEvent* ec, View2DEventPhase phase); 00107 00108 void setExternalRotationAxis(SbVec3f rotPosition){_rotPos = rotPosition;} 00109 00110 protected: 00112 void clipLinePoint (float &p1x, float &p1y, float p2x, float p2y, 00113 float x0, float x1); 00114 00116 bool clipToSliceRect(SbVec2f& p1, SbVec2f& p2, View2DSlice *dslice); 00117 00119 void drawPlaneLine (View2DSliceList *dsl, View2DSlice *dslice, SbVec2f p1, SbVec2f p2); 00120 00122 void drawNormal (View2DSliceList *dsl, View2DSlice *dslice, SbVec2f p1, SbVec2f p2); 00123 00125 enum HIT_MODE {NO_HIT = 0, HIT_ROTATE = 1, HIT_TRANSLATE = 3}; 00126 00128 HIT_MODE _hitPlane(const SbVec3f &point, View2DSliceList* dsl, int& proposedCursorShape); 00129 00131 void dragMoveTo(const SbVec3f& point, View2DSliceList* slicelist); 00132 00134 00135 virtual int getCurrentCursor(SoViewerProxy* viewerProxy); 00136 virtual bool isSensitiveAt(const SoPointerPosition& pos); 00137 virtual void startPressAt(const SoPointerPosition& pos); 00138 virtual void dragMoveTo(const SoPointerPosition& pos); 00139 virtual SoPointingAction* endPress(int clickCount); 00141 00142 private: 00144 SbVec3f _edge[2]; 00145 00147 float _oldDistance; 00148 00150 SbVec3f _rotPos; 00151 00153 SbVec3f _startPos, _lastPos; 00154 00156 HIT_MODE _eventHitMode; 00158 int _cursorShape; 00159 00160 SbBool _rotPosIsValid; 00161 }; 00162 00163 #endif