X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcreaVtk%2FMeshManagerModel.h;h=b74204c20a3010df654b1c07fbcda1ec97e6c5b2;hb=0105528a5e3a8a9bb4f1e7b313e6a4e437ddb5e6;hp=b2f5dc9051b13963e1383c8cf511ce6f54140d12;hpb=7ea07ff0d06edfe66780de979e34b7932357a1f5;p=creaVtk.git diff --git a/lib/creaVtk/MeshManagerModel.h b/lib/creaVtk/MeshManagerModel.h index b2f5dc9..b74204c 100644 --- a/lib/creaVtk/MeshManagerModel.h +++ b/lib/creaVtk/MeshManagerModel.h @@ -24,6 +24,59 @@ # knowledge of the CeCILL-B license and that you accept its terms. # ------------------------------------------------------------------------ */ +#include +#include +#include + +template +class HistoryHandler{ +public: + HistoryHandler(int maxElements); + ~HistoryHandler(); + void CleanHistory(); + StateType* Undo(StateType* State); + StateType* UndoKeepCurrent(); + StateType* Redo(StateType* State); + StateType* RedoKeepCurrent(); + void Save(StateType* State); + StateType* GetPrevious(); + StateType* GetNext(); + int UndoSize(); + int RedoSize(); + +private: + std::deque undoStack; + std::deque redoStack; + int maxElements; +}; + +class MeshModel{ + +public: + MeshModel(int id); + MeshModel(vtkPolyData* mesh, int id); + MeshModel(MeshModel* meshModel); + ~MeshModel(); + + void SetMeshBase(vtkPolyData* mesh); + void SetMeshMemoryMode(vtkPolyData* mesh); + void CopySetMeshBase(vtkPolyData* mesh); + void ResetMeshTemp(); + void ResetMeshTemp_(); + vtkPolyData* GetMeshBase(); + vtkPolyData* GetMeshTemp(); + int GetId(); + std::string GetName(); + + +protected: + +private: + vtkPolyData *_meshBase; + vtkPolyData *_meshTemp; + int _meshId; + std::string _name; +}; #ifndef _MESHMANAGERMODEL_H_ #define _MESHMANAGERMODEL_H_ @@ -33,8 +86,6 @@ // [classdescription] //--------------------------------------------- -#include - class MeshManagerModel { @@ -43,16 +94,66 @@ class MeshManagerModel //--------------------------------------------- public : MeshManagerModel(); + MeshManagerModel(std::vector meshList); ~MeshManagerModel(); + void SetHistory(int maxCapacity); + void ResetHistory(); + void ResetAll(); + void SetMeshBase(vtkPolyData* mesh); void SetMeshMemoryMode(vtkPolyData* mesh); + void MeshMemoryModeOn(); + void MeshMemoryModeOff(); void CopySetMeshBase(vtkPolyData* mesh); void ResetMeshTemp(); - void ResetMeshTemp_(); + //void ResetMeshTemp_(); vtkPolyData* GetMeshBase(); vtkPolyData* GetMeshTemp(); - virtual void RefreshOutputs(); + + virtual void RefreshOutputs(bool signalBox); + + std::shared_ptr GetMeshModel(); + int GetNumberOfMeshes(); + + void AddMesh_(vtkPolyData* mesh); + void AddMesh(vtkPolyData* mesh); + + void AddEmptyMesh_(); + void AddEmptyMesh(); + + void AddMeshes(std::vector meshList); + void AddMeshes_(std::vector meshList); + + void InsertMeshesAtCurrent_(std::vector meshList); + void InsertMeshesAtCurrent(std::vector meshList); + + void InsertMeshModels_(std::vector meshModelList); + void InsertMeshModels(std::vector meshModelList); + + void SelectMesh(int i); + void SelectMeshByName(std::string meshName); + + void DeleteMesh_(int position); + void DeleteMesh(int position); + void DeleteMeshByName(std::string meshName); + void DeleteCurrentMesh(); + + void DeleteAll_(); + void DeleteAll(); + + void ReplaceMesh(std::vector meshList); + + void NextMesh(); + void PreviousMesh(); + + void SaveMemoryMode(); + void Undo(); + void Redo(); + + std::vector GetMeshNames(); + std::vector GetAllPolyDatas(); + int GetCurrentMesh(); //--Method template---------------------------- // void FunctionName(int& parameterA); @@ -67,8 +168,33 @@ protected: //Methods and attributes only visible by this class //--------------------------------------------- private: - vtkPolyData *_meshBase; - vtkPolyData *_meshTemp; + + std::vector> _meshes; + int currentMesh; + int meshId; + int lastModified; + bool memoryMode; + + class ManagerState{ + public: + ManagerState(std::vector> meshesToSave, int meshId, int modifiedId); + ~ManagerState(); + std::vector>& GetMeshes(); + int GetMeshId(); + int GetModifiedPos(); + private: + std::vector> savedMeshes; + int savedModifiedPos; + int savedId; + }; + + void Save(); + void RestoreState(ManagerState* state); + void RestoreStateMemoryMode(ManagerState* state); + + HistoryHandler *history; + + }; //-end of _MESHMANAGERMODEL_H_------------------------------------------------------