MeVisLabToolboxReference
|
00001 // **InsertLicense** code 00002 //---------------------------------------------------------------------------------- 00004 00009 //---------------------------------------------------------------------------------- 00010 00011 00012 #ifndef __SoCSOTransformEditor_H 00013 #define __SoCSOTransformEditor_H 00014 00015 00016 #include <SoView2DCSOEditor/SoView2DCSOExtensibleEditor/SoCSOEditorExtension.h> 00017 00019 00020 ML_START_NAMESPACE 00021 class CSO; 00022 ML_END_NAMESPACE 00023 00025 00027 class SOCSO_EXPORT SoCSOTransformEditor : public SoCSOEditorExtension 00028 { 00029 SO_NODE_HEADER(SoCSOTransformEditor); 00030 00031 public: 00032 00034 SoCSOTransformEditor(); 00036 ~SoCSOTransformEditor(); 00037 00039 virtual void draw(const CSODrawCSOInfos& csoInfos, const CSODrawView2DInfos& view2DInfos, const CSODrawSliceInformation& drawSliceInfo, SoView2DCSOExtensibleEditor* editor); 00040 00042 static void initClass(); 00043 00044 virtual bool evaluateHitPoint(const ml::Vector3& worldPosition, View2DSliceList* slicelist, ml::CSOList* csoList, ml::CSO*& cso, 00045 SoView2DCSOExtensibleEditor* editor); 00048 virtual bool evaluateHitPoint(const ml::Vector3& , View2DSliceList* , ml::CSOList* , 00049 const ml::CSOBoundingBox& , SoView2DCSOExtensibleEditor* , 00050 ml::CSO*& , ml::CSOSeedPoint*& , 00051 ml::CSOPathPoints*& , float& ) 00052 { 00053 return false; 00054 } 00055 00057 bool isEligibleForTransforming(ml::CSO* cso) const; 00058 00059 void transformStartPressAt(const SoPointerPosition& pos); 00060 void transformDragMoveTo(const SoPointerPosition& pos); 00061 SoPointingAction* transformEndPress(int clickCount); 00062 00063 virtual void createStartPressAt(const SoPointerPosition& ) {} 00064 virtual void createDragMoveTo(const SoPointerPosition& ) {} 00065 virtual bool createEndPress(int ) { return false; } 00066 00067 virtual void selectAndMoveStartPressAt(const SoPointerPosition& ) {} 00068 virtual void selectAndMoveDragMoveTo(const SoPointerPosition& ) {} 00069 virtual SoPointingAction* selectAndMoveEndPress(int ) { return NULL; } 00070 00071 virtual int cursorShape() const { return _cursorShape; } 00072 00073 virtual bool shouldRenderSpecific(ml::CSO*) const { return false; } 00074 virtual bool shouldRenderGeneral(ml::CSO*) const { return true; } 00075 00076 SoSFBool hideHandlesWhileInteracting; 00077 00078 SoSFBool allowScale; 00079 SoSFBool allowTranslation; 00080 // SoSFBool allowRotation; 00081 00082 SoSFFloat scaleHandleMargin; 00083 SoSFFloat translateHandleAreaSize; 00084 00085 protected: 00086 00087 void drawInteractionHandleAsSeedPointAt(ml::CSO* cso, float deviceX, float deviceY); 00088 00089 00090 private: 00091 00093 enum ScaleDirection { 00094 UN = -1, 00095 NW = 0, 00096 N = 1, 00097 NE = 2, 00098 W = 3, 00099 E = 4, 00100 SW = 5, 00101 S = 6, 00102 SE = 7 00103 }; 00104 00106 static void baseEventCB(void* userData, ml::BaseEvent* event); 00109 void attachAsListenerTo(ml::CSOList* csoList); 00111 ml::CSOList* _listenToCSOList; 00112 00114 bool isInSelectionDistance(const SbVec2f& pos1, const SbVec2f& pos2, float selectionDistance) const; 00116 bool isInTranslationArea(const SbVec2f& mouseDevicePosition)const; 00117 00118 00120 void clearHandlesPositions(); 00122 void setScaleCursorShape(); 00124 void limitScaleOffset(SbVec2f& scaleOffset); 00126 void computeMoveAndScaleFactors(const SbVec3f& offsetX, const SbVec3f& offsetY, float voxelBBX, float voxelBBY, 00127 float& voxelMoveX, float& voxelMoveY, float& voxelScaleX, float& voxelScaleY) const; 00128 00129 std::vector < SbVec2f > _scaleHandlesPositions; 00130 std::vector < SbVec2f > _translateHandlesPositions; 00131 00133 void resetActiveHandleIndices() 00134 { 00135 _activeScaleHandleIndex = -1; 00136 _activeTranslateHandleIndex = -1; 00137 } 00138 00140 bool shouldShowHandles() const; 00141 bool _isInteracting; 00143 int _activeScaleHandleIndex; 00145 int _activeTranslateHandleIndex; 00146 00147 SbVec2f _startDevicePosition; 00148 SbVec3f _lastWorldPosition; 00149 00150 ml::Matrix4 _worldToVoxelMatrix; 00151 ml::Matrix4 _voxelToWorldMatrix; 00152 ml::CSOBoundingBox _csoVoxelBoundingBox; 00153 00154 int _cursorShape; 00155 00156 ml::CSO* _selectedCSO; 00157 }; 00158 00160 00161 #endif // __SoCSOTransformEditor_H