MeVisLabToolboxReference
|
00001 // **InsertLicense** code 00002 //---------------------------------------------------------------------------------- 00004 00009 //---------------------------------------------------------------------------------- 00010 00011 00012 #ifndef __SoView2DCSOExtensibleEditor_H 00013 #define __SoView2DCSOExtensibleEditor_H 00014 00015 #include <SoView2DExtension.h> 00016 #include <SoView2DCSOEditor/SoView2DCSOExtensibleEditor/SoCSOEditorExtension.h> 00017 #include <SoView2DCSOEditor/SoView2DCSOExtensibleEditor/extensions/SoCSODefaultRenderer/SoCSODefaultRenderer.h> 00018 00019 typedef std::vector<SoCSOEditorExtension*> ExtensionList; 00020 00021 ML_START_NAMESPACE 00022 class CSO; 00023 class CSOList; 00024 ML_END_NAMESPACE 00025 00026 class SoCSOTransform; 00027 00028 class CSOCreateAction; 00029 class CSOSelectAndMoveAction; 00030 class CSOLabelMoveAction; 00031 class CSOTransformAction; 00032 class CSOInsertSeedPointIntoPathPointListAction; 00033 00034 class CSOCopyCommandAction; 00035 class CSOCutCommandAction; 00036 class CSOPasteCommandAction; 00037 00038 class CSODeleteSeedPointCommandAction; 00039 class CSODeleteCSOCommandAction; 00040 00041 class CSOUndoCommandAction; 00042 class CSORedoCommandAction; 00043 00044 class CSOCancelCommandAction; 00045 00046 ML_START_NAMESPACE 00047 class CSOVisualizationSettings; 00048 ML_END_NAMESPACE 00049 00050 struct CSODefaultRendererInformation 00051 { 00052 CSODefaultRendererInformation() 00053 { 00054 hasRenderedCSO = false; 00055 } 00056 bool hasRenderedCSO; 00057 CSODrawSliceInformation drawSliceInformation; 00058 }; 00059 00060 class SOCSO_EXPORT SoView2DCSOExtensibleEditor : public SoView2DExtension 00061 { 00062 public: 00063 00065 SoView2DCSOExtensibleEditor(); 00067 static void initClass(); 00068 00070 SoSFMLBase inCSOList; 00072 SoSFNode inExtensions; 00074 SoSFMLBase inVisualizationSettings; 00077 SoSFString creatorExtensionId; 00079 SoSFBool interactOnlyWithSelectedCSO; 00081 SoSFBool alwaysCreateNewCSOs; 00083 SoSFBool alwaysModifyExistingCSOs; 00085 SoSFBool keyCommandsEnabled; 00088 SoSFBool renderLeftOverCSOsWithDefaultRenderer; 00091 SoSFBool renderCSOsOnlyOnImagesTheyWereCreatedOn; 00093 SoSFInt32 csoIdUnderMouseCursor; 00095 SoSFBool isCreatingNewCSO; 00096 00098 void getExtensions(ExtensionList& extensions); 00100 ml::CSOList* getInputCSOList(); 00103 std::string getDefaultCreatorString() const { return std::string("__default"); } 00104 00106 virtual void pointerPosition(const SoPointerPosition& pos); 00108 virtual void pointerLeftWindow(); 00110 virtual void fieldChanged(SoSensor* sensor); 00111 00113 ml::CSOVisualizationSettings* getVisualizationSettings(); 00114 00116 SoCSOEditorExtension* getActiveEditor() const { return _activeEditor; } 00118 SoCSODefaultRenderer* getDefaultRenderer(); 00120 void setInteractionModifier(int mode) { _interactionMode = mode; } 00122 int getInteractionModifier() const { return _interactionMode; } 00123 00125 void setCSOUnderTheMouseId(int id); 00126 00129 bool shouldShowCSOForCurrentTimePoint(const CSODrawView2DInfos& view2DInfos, ml::CSO* cso); 00131 bool shouldShowCSORegardingParallelState(const CSODrawSliceInformation& sliceInfo, const CSODrawView2DInfos& view2DInfos, ml::CSO* cso); 00133 bool shouldShowCSOBeyondSlice(const CSODrawSliceInformation& sliceInfo, const CSODrawView2DInfos& view2DInfos, ml::CSO* cso); 00135 bool shouldShowCSOOnImageWithId(const CSODrawView2DInfos& view2DInfos, ml::CSO* cso); 00136 00137 protected: 00138 00140 ~SoView2DCSOExtensibleEditor(); 00141 00143 virtual void startDrawing(View2DSliceList* slicelist); 00144 00146 virtual void draw(View2DSliceList* slicelist, View2DSlice* slice, int sliceZ); 00147 00149 void fillCSOSliceInformation(const CSODrawCSOInfos& csoInfos, const CSODrawView2DInfos& view2DInfos, CSODrawSliceInformation& sliceInfo); 00151 static void csoListNotificationCB(void* userData, int notificationFlag); 00152 00154 virtual void doAction(SoAction *action); 00156 SoCSOTransform* _csoTransform; 00157 00158 private: 00159 00160 ml::CSOVisualizationSettings _dummyVisualizationSettings; 00161 SoCSODefaultRenderer _defaultRenderer; 00162 00163 bool _activeCreatorEditorDirty; 00164 00165 SoFieldSensor* _inCSOListSensor; 00166 static void _inCSOListCB(void* data, SoSensor*); 00167 00168 SbVec3f _currentPointerWorldPosition; 00169 SbVec3f _startPointerWorldPosition; 00170 int _currentTimePointIndex; 00171 00172 void storeCopiedCSOGroupInformation(); 00173 00174 void setActiveEditor(const ExtensionList& extensions); 00175 void setActionsEnabled(); 00176 void setTriggerFieldsToActions(); 00177 00178 void copySelectedCSOs(); 00179 00180 void copySelectedCSOsToInternalList(ml::CSOList* csoList); 00181 void cutSelectedCSOs(); 00182 void pasteCSOs(); 00183 00184 void deleteSelectedCSOs(); 00185 void deleteSelectedSeedPoint(); 00186 00187 void undo(); 00188 void redo(); 00189 00190 void cancel(); 00191 00192 // Returns whether the given CSO should be rendered. 00193 bool shouldRenderCSO(ml::CSO* cso, const CSODrawView2DInfos& view2DInfos, const CSODrawSliceInformation& sliceInfo); 00194 00195 void resetAllExtensionCaches(); 00196 00197 // this is the editor active for creating new CSOs 00198 SoCSOEditorExtension* _activeEditor; 00199 00200 CSOLabelMoveAction* _labelMoveAction; 00201 CSOTransformAction* _transformAction; 00202 CSOInsertSeedPointIntoPathPointListAction* _insertSeedPointAction; 00203 CSOSelectAndMoveAction* _selectAndMoveAction; 00204 CSOCreateAction* _createAction; 00205 00206 int _interactionMode; 00207 00208 CSOCopyCommandAction* _copyCommandAction; 00209 CSOCutCommandAction* _cutCommandAction; 00210 CSOPasteCommandAction* _pasteCommandAction; 00211 00212 CSODeleteSeedPointCommandAction* _deleteSeedPointCommandAction; 00213 CSODeleteCSOCommandAction* _deleteCSOCommandAction; 00214 00215 CSOUndoCommandAction* _undoCommandAction; 00216 CSORedoCommandAction* _redoCommandAction; 00217 00218 CSOCancelCommandAction* _cancelCommandAction; 00219 00220 std::vector < ml::CSO* > _copiedCSOs; 00221 std::map < int, std::vector< int > > _copiedCSOGroupIds; 00222 00223 void notifyCSOListObservers(ml::CSOList* csoList); 00224 00225 // make the keyboard commands friends so they 00226 // can access private/protected methods. 00227 friend class CSOCopyCommandAction; 00228 friend class CSOCutCommandAction; 00229 friend class CSOPasteCommandAction; 00230 00231 friend class CSODeleteSeedPointCommandAction; 00232 friend class CSODeleteCSOCommandAction; 00233 00234 friend class CSOUndoCommandAction; 00235 friend class CSORedoCommandAction; 00236 00237 friend class CSOCancelCommandAction; 00238 00239 SO_NODE_HEADER(SoView2DCSOExtensibleEditor); 00240 }; 00241 00242 00243 #endif // __SoView2DCSOExtensibleEditor_H