MeVisLabToolboxReference
MeVisLab/Standard/Sources/ML/MLCSO/CSOBase/CSOUndoRedo/CSOUndoRedoCommands.h
Go to the documentation of this file.
00001 // **InsertLicense** code
00002 //----------------------------------------------------------------------------------
00004 
00009 //----------------------------------------------------------------------------------
00010 
00011 #ifndef __CSOUndoRedoCommands_H
00012 #define __CSOUndoRedoCommands_H
00013 
00014 #include "MLCSOIncludes.h"
00015 #include "CSOBase/CSOList.h"
00016 
00017 
00018 ML_START_NAMESPACE
00019 
00021 
00023 class MLCSO_EXPORT CSOCommand 
00024 {
00025 public:
00026 
00028   CSOCommand();
00030   virtual ~CSOCommand();
00031 
00035   virtual int execute() = 0;
00036 
00038   std::string commandName;
00039 
00041   int getGroupId() const { return _undoGroupId; }
00043   void setGroupId(int groupId) { _undoGroupId = groupId; }
00044 
00045 private:
00046 
00047   int _undoGroupId;
00048 };
00049 
00051 
00053 class MLCSO_EXPORT CSOCmdAddCSO : public CSOCommand
00054 {
00055 public:
00056 
00058   CSOCmdAddCSO(const CSOListPtr& csoList, CSO* cso);
00060   virtual ~CSOCmdAddCSO();
00061 
00063   virtual int execute();
00064 
00065 
00066 private:
00067 
00068   CSOList* _csoList;
00069   CSO*     _addCSO;
00070   unsigned int _lastCurrentCSOId;
00071   unsigned int _csoId;
00072   std::vector<unsigned int> _csoGroupIds;
00073 };
00074 
00076 
00078 class MLCSO_EXPORT CSOCmdRemoveCSO : public CSOCommand
00079 {
00080 public:
00081 
00083   CSOCmdRemoveCSO(const CSOListPtr& csoList, CSO* cso);
00085   virtual ~CSOCmdRemoveCSO();
00086 
00088   virtual int execute();
00089 
00090 private:
00091 
00092   CSOList* _csoList;    
00093   unsigned int _removeCSOId;
00094 };
00095 
00097 
00099 class MLCSO_EXPORT CSOCmdAddCSOGroup : public CSOCommand
00100 {
00101 public:
00102 
00104   CSOCmdAddCSOGroup(const CSOListPtr& csoList, CSOGroup* group);
00106   virtual ~CSOCmdAddCSOGroup();
00107 
00109   virtual int execute();
00110 
00111 private:
00112 
00113   CSOList* _csoList;
00114   CSOGroup*  _csoGroup;
00115   unsigned int _lastCurrentGroupId;
00116   unsigned int _groupId;
00117   std::vector<unsigned int> _groupCSOIds;
00118 };
00119 
00121 
00123 class MLCSO_EXPORT CSOCmdRemoveCSOGroup : public CSOCommand
00124 {
00125 public:
00127   CSOCmdRemoveCSOGroup(const CSOListPtr& csoList, CSOGroup* group);
00129   virtual ~CSOCmdRemoveCSOGroup();
00130 
00132   virtual int execute();
00133 
00134 private:
00135 
00136   CSOList* _csoList;
00137   unsigned int _csoGroupId;
00138 };
00139 
00141 
00143 class MLCSO_EXPORT CSOCmdAddCSOtoGroup : public CSOCommand
00144 {
00145 public:
00146 
00148   CSOCmdAddCSOtoGroup(const CSOListPtr& csoList, CSO* cso, CSOGroup* group);
00150   virtual ~CSOCmdAddCSOtoGroup();
00151 
00153   virtual int execute();
00154 
00155 private:
00156 
00157   CSOList* _csoList;
00158   unsigned int _csoId;
00159   unsigned int _groupId;
00160 };
00161 
00162 
00164 
00166 class MLCSO_EXPORT CSOCmdRemoveCSOfromGroup : public CSOCommand
00167 {
00168 public:
00169 
00171   CSOCmdRemoveCSOfromGroup(const CSOListPtr& csoList, CSO* cso, CSOGroup* group);
00173   virtual ~CSOCmdRemoveCSOfromGroup();
00174 
00176   virtual int execute();
00177 
00178 private:
00179 
00180   CSOList* _csoList;
00181   unsigned int _csoId;
00182   unsigned int _groupId;
00183 };
00184 
00186 
00188 class MLCSO_EXPORT CSOCmdAddCSOList : public CSOCommand
00189 {
00190 public:
00191 
00193   CSOCmdAddCSOList(const CSOListPtr& csoList);
00195   virtual ~CSOCmdAddCSOList();
00196 
00198   virtual int execute();
00199 
00200 private:
00201 
00202   CSOList* _addCSOList;
00203   CSOList* _origCSOList;
00204 };
00205 
00207 
00209 class MLCSO_EXPORT CSOCmdMoveContour : public CSOCommand
00210 {
00211 public:
00212 
00214   CSOCmdMoveContour(const CSOListPtr& csoList, CSO* cso, Vector3 fromPos, Vector3 toPos, int fromTPI, int toTPI);
00216   ~CSOCmdMoveContour();
00217 
00219   virtual int execute();
00220 
00221 private:
00222 
00223   CSOList* _csoList;
00224   unsigned int _csoId;    
00225   Vector3 _fromPos;
00226   Vector3 _toPos;
00227   int _fromTimePointIndex;
00228   int _toTimePointIndex;
00229 };
00230 
00232 
00234 class MLCSO_EXPORT CSOCmdMoveSeedPoint : public CSOCommand
00235 {
00236 public:
00237 
00239   CSOCmdMoveSeedPoint(const CSOListPtr& csoList, CSO* cso);
00241   ~CSOCmdMoveSeedPoint();
00242 
00244   virtual int execute();
00245 
00246 private:
00247 
00248   CSOList* _csoList;
00249   unsigned int _csoId;
00250 
00251   unsigned int _numSeedPoints;
00252   unsigned int _numPathPoints;
00253 
00254   Vector3*  _seedPositions;
00255   std::vector<Vector4>* _pathPointPositionValues;
00256 };
00257 
00259 
00261 class MLCSO_EXPORT CSOCmdInsertRemoveSeedPoint : public CSOCommand
00262 {
00263 public:
00264 
00266   CSOCmdInsertRemoveSeedPoint(const CSOListPtr& csoList, CSO* cso);
00268   ~CSOCmdInsertRemoveSeedPoint();
00269 
00271   virtual int execute();
00272 
00273 private:
00274 
00275   CSOList* _csoList;
00276   unsigned int _csoId;
00277   std::string _type;
00278   std::string _subType;
00279 
00280   CSO _originalGeometry;
00281 };
00282 
00284 
00286 
00288 class MLCSO_EXPORT CSOCmdAddCSOSet : public CSOCommand
00289 {
00290 public:
00291 
00293   CSOCmdAddCSOSet(const CSOListPtr& csoList, const std::vector<CSO*>& csos);
00295   virtual ~CSOCmdAddCSOSet();
00296 
00298   virtual int execute();
00299 
00300 
00301 private:
00302 
00303   struct CSOUndoRedoData {
00304     CSOUndoRedoData() 
00305       : cso(NULL), csoId(0) {}
00306     CSOUndoRedoData(CSO* _cso, unsigned int _csoId, const std::vector<unsigned int>& _csoGroupIds) 
00307       : cso(_cso), csoId(_csoId), csoGroupIds(_csoGroupIds) {}
00308     CSO*                      cso;
00309     unsigned int              csoId;
00310     std::vector<unsigned int> csoGroupIds;
00311   };
00312 
00313   CSOList* _csoList;
00314   unsigned int _lastCurrentCSOId;
00315   std::vector<CSOUndoRedoData> _csoUndoRedoData;
00316 };
00317 
00319 
00321 class MLCSO_EXPORT CSOCmdRemoveCSOSet : public CSOCommand
00322 {
00323 public:
00324 
00326   CSOCmdRemoveCSOSet(const CSOListPtr& csoList, const std::vector<CSO*>& csos);
00328   virtual ~CSOCmdRemoveCSOSet();
00329 
00331   virtual int execute();
00332 
00333 private:
00334 
00335   CSOList* _csoList;    
00336   std::vector<unsigned int> _removeCSOIds;
00337 };
00338 
00340 
00342 class MLCSO_EXPORT CSOCmdModifySet : public CSOCommand
00343 {
00344 public:
00345 
00347   CSOCmdModifySet(const CSOListPtr& csoList, const std::vector<CSO*>& csos);
00349   ~CSOCmdModifySet();
00350 
00352   virtual int execute();
00353 
00354 private:
00355 
00356   struct CSOUndoRedoData {
00357 
00358     CSOUndoRedoData() : _seedPositions(NULL), _pathPointPositionValues(NULL) {}
00359     CSOUndoRedoData(unsigned int csoId, const std::string& type, int markerMode, bool csoIsClosed, unsigned int numSeedPoints, unsigned int numPathPoints, Vector3* seedPositions, std::vector<Vector4>* pathPointPositionValues) 
00360       : _csoId(csoId), _type(type), _seedPointStyle(markerMode), _csoIsClosed(csoIsClosed), _numSeedPoints(numSeedPoints), _numPathPoints(numPathPoints), _seedPositions(seedPositions), _pathPointPositionValues(pathPointPositionValues) {}
00361 
00362     unsigned int _csoId;
00363     std::string _type;
00364     int _seedPointStyle;
00365     bool _csoIsClosed;
00366     unsigned int _numSeedPoints;
00367     unsigned int _numPathPoints;
00368     Vector3*  _seedPositions;
00369     std::vector<Vector4>* _pathPointPositionValues;
00370   };
00371 
00372   CSOList* _csoList;
00373 
00374   std::vector<CSOUndoRedoData> _csoUndoRedoData;
00375 
00376 };
00377 
00379 
00380 
00381 ML_END_NAMESPACE
00382 
00383 #endif // __CSOUndoRedoCommands_H
00384