MeVisLabToolboxReference
MeVisLab/Standard/Sources/Inventor/SoCSO/CSOProcessor/CSOFreehandProcessor/CSOFreehandProcessor.h
Go to the documentation of this file.
00001 // **InsertLicense** code
00002 //----------------------------------------------------------------------------------
00006 
00011 //----------------------------------------------------------------------------------
00012 
00013 #ifndef __CSOFreehandProcessor_H
00014 #define __CSOFreehandProcessor_H
00015 
00016 
00017 #include "SoCSOSystem.h"
00018 #include "CSOProcessor/CSOProcessor.h"
00019 
00020 
00021 ML_START_NAMESPACE
00022 
00023 
00025 
00027 enum GENERAL_CREATION_MODE {
00028   CREATION_MODE_POINT                = 0, 
00029   CREATION_MODE_CLOSED_POLYLINE      = 1, 
00030   CREATION_MODE_CLOSED_SPLINE        = 2, 
00031   CREATION_MODE_CLOSED_FREEHAND      = 3, 
00032   CREATION_MODE_CLOSED_INTERPOLATION = 4, 
00033   CREATION_MODE_OPEN_POLYLINE        = 5, 
00034   CREATION_MODE_OPEN_SPLINE          = 6, 
00035   CREATION_MODE_OPEN_FREEHAND        = 7  
00036 };
00037 
00039 
00041 enum FINISHING_MODES {
00042   FINISH_ON_RELEASE      = 0, 
00043   FINISH_ON_DOUBLE_CLICK = 1  
00044 };
00045 
00047 enum SEED_POINT_PLACEMENT {
00048   PLACE_SEED_ON_CLICK       = 0, 
00049   PLACE_SEED_WHILE_DRAGGING = 1  
00050 };
00051 
00053 
00055 enum INTERPOLATION_MODES {
00056   INTERPOLATION_MODE_LINEAR_INTERPOLATION = 0, 
00057   INTERPOLATION_MODE_SPLINE_INTERPOLATION = 1, 
00058   INTERPOLATION_MODE_SPLINE_APPROXIMATION = 2  
00059 };
00060 
00062 
00066 class SOCSO_EXPORT CSOFreehandProcessor : public CSOProcessor
00067 {
00068 
00069 public:
00070 
00072   CSOFreehandProcessor();
00073 
00077   virtual bool process(CSOEvalEventView2DInfos view2DInfos, CSOEvalEventCSOInfos csoInfos);
00078 
00081   virtual bool needsMemoryImage();
00082 
00084   virtual void setMemoryImage(float* imageData, int sizex, int sizey, int voxelPosZ,  
00085     float* voxelToWorldMatrix, float* worldToVoxelMatrix, View2DSliceList* slicelist);
00086 
00088   bool isCurrentlyGenerating();
00090   bool isCurrentlyEditing();
00092   bool couldCloseCSO();
00093 
00095   virtual void resetInteractionState();
00096 
00098   virtual void triggerSetMouseCursor(SoView2D* view2d, bool shouldSetMouseCursor);
00099 
00100 protected:
00101 
00103   virtual ~CSOFreehandProcessor();
00104 
00108   virtual void handleNotification(Field* field);
00109 
00111   virtual void activateAttachments();
00112 
00113 private:
00114 
00115   /* FIELDS */
00116 
00118   EnumField* _creationModeFld;
00119 
00123   EnumField* _interpolationModeFld;
00124 
00127   IntField* _minNumSeedPointsFld;
00128 
00132   FloatField* _minSeedPointDistanceFld;
00133 
00135   BoolField* _shouldCloseOnFinishFld;
00137   EnumField* _finishingModeFld;
00139   BoolField* _useFinishingDistanceFld;
00142   FloatField* _finishingDistanceFld;
00144   EnumField* _seedPlacementPolicyFld;
00147   IntField* _numInterpolationStepsFld;
00148  
00151   BoolField* _showInteractivePreviewFld;
00152 
00153 
00154   /* STATE VARIABLES */    
00155 
00158   CSOBoundingBox _slabBB;
00159 
00161   CSOList* _csoList;
00162 
00164   int _cursorShape;
00165 
00167   Vector3 _moveStartPosition;
00169   Vector3 _lastCurrentPosition;
00170 
00172   CSO* _currentlyActiveCSO;
00174   CSOSeedPoint* _currentlyActiveSeedPoint;
00176   CSOPathPoints* _currentlyActivePathPoints;
00177 
00179   bool _isMovingSeedPoint;
00181   bool _isGeneratingCSO;
00183   bool _isPrevCSOFinished;
00185   bool _couldCloseCurrentCSO;
00187   bool _hasInsertedSeedIntoPath;
00188 
00190   SbVec3f _sliceNormal0;
00192   SbVec3f _sliceNormal1;
00194   SbVec3f _sliceNormal2;
00195 
00197   std::string _currentSubType;
00198 
00199 
00200   /* METHODS */
00201 
00204   void _interpolate();
00206   void _interpolate(CSO* cso, CSOPathPoints* pPoints);
00209   void _configurePresets();
00211   void _finishCurrentCSO();
00213   CSOSeedPoint* _getClosestSeedPoint(Vector3& hitpos, CSOPathPoints* toSplitPath);
00215   float _distanceNoSqrt(float x1, float y1, float z1, float x2, float y2, float z2);
00217   bool _closingDistanceCriteriaFulfilled(const Vector3& currentMousePos, View2DSliceList* slicelist);
00220   bool _isWithinRangeDistance(const Vector3& startPos, const Vector3& endPos, float rangeDistance, View2DSliceList* slicelist) const;
00222   void _setCurrentSubType();
00223 
00224   ML_MODULE_CLASS_HEADER(CSOFreehandProcessor);
00225 };
00226 
00228 
00229 
00230 ML_END_NAMESPACE
00231 
00232 #endif // __CSOFreehandProcessor_H