]> Creatis software - creaVtk.git/blob - bbtk_creaVtk_PKG/src/bbcreaVtkMeshManager_tool.cxx
#3507 Undo and Redo Meshes
[creaVtk.git] / bbtk_creaVtk_PKG / src / bbcreaVtkMeshManager_tool.cxx
1 //===== 
2 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
3 //===== 
4 #include "bbcreaVtkMeshManager_tool.h"
5 #include "bbcreaVtkPackage.h"
6 namespace bbcreaVtk
7 {
8
9 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,MeshManager_tool)
10 BBTK_BLACK_BOX_IMPLEMENTATION(MeshManager_tool,bbtk::AtomicBlackBox);
11 //===== 
12 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
13 //===== 
14 void MeshManager_tool::Process()
15 {
16 // THE MAIN PROCESSING METHOD BODY
17 //   Here we simply set the input 'In' value to the output 'Out'
18 //   And print out the output value
19 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
20 //    void bbSet{Input|Output}NAME(const TYPE&)
21 //    const TYPE& bbGet{Input|Output}NAME() const 
22 //    Where :
23 //    * NAME is the name of the input/output
24 //      (the one provided in the attribute 'name' of the tag 'input')
25 //    * TYPE is the C++ type of the input/output
26 //      (the one provided in the attribute 'type' of the tag 'input')
27 //    bbSetOutputOut( bbGetInputIn() );
28 //    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
29     
30     if (bbGetInputMeshManagerModel()!=NULL)
31     {
32         if (bbGetInputTool()==10) // Undo
33         {
34                 bbGetInputMeshManagerModel()->Undo();
35             //printf("EED Warning!   MeshManager_tool Undo   Not implemented.\n");
36         } // if Tool 10 Undo
37         
38         if (bbGetInputTool()==20) // Redo
39         {
40                 bbGetInputMeshManagerModel()->Redo();
41             //printf("EED Warning!   MeshManager_tool Redo   Not implemented.\n");
42         } // if Tool 20 Redo
43
44         if (bbGetInputTool()==30)  // Set
45         {
46             if (bbGetInputMesh()!=NULL){
47                 vtkPoints   *points = bbGetInputMesh()->GetPoints();
48                 if (points!=NULL)
49                 {
50                     bbGetInputMeshManagerModel()->SetMeshBase( bbGetInputMesh() );
51                 } // if points!=NULL
52             } // Mesh!=NULL
53         } // if Tool 30 Set
54
55         if (bbGetInputTool()==35)  // Set memory mode
56         {
57                 bbGetInputMeshManagerModel()->SetMeshMemoryMode( bbGetInputMesh() );
58         } // if Tool 35 Set memory mode
59                 if(bbGetInputTool() == 37) // Save State Memory Mode
60         {
61                 if(bbGetInputStringParam().length() > 0){       
62                                 cout << " MeshManager_tool : MeshManagerModel    Executed tool 37" << endl;//bGetInputMeshManagerModel()->Save();
63                         bbGetInputMeshManagerModel()->SaveMemoryMode();
64                     //  cout << bbGetInputStringParam() << endl;
65                 }
66         }
67         if (bbGetInputTool()==32)  // Copy and Set
68         {
69                 bbGetInputMeshManagerModel()->CopySetMeshBase( bbGetInputMesh() );
70         } // if Tool 35 Set memory mode
71
72         
73         if (bbGetInputTool()==40) // ResetMeshTemp
74         {
75             bbGetInputMeshManagerModel()->ResetMeshTemp();
76         } // if Tool 40 Reset
77         
78         if(bbGetInputTool() == 50) // Set Array of Meshes
79         {
80                 if(bbGetInputMeshes().size() > 1)
81                 {
82                         bbGetInputMeshManagerModel()->ReplaceMesh(bbGetInputMeshes());
83                     }
84         }
85         if(bbGetInputTool() == 60) // Select Mesh by Name
86         {
87                 if(!bbGetInputStringParam().empty())
88                 {
89                         bbGetInputMeshManagerModel()->SelectMeshByName(bbGetInputStringParam());
90                     }
91         }
92         if(bbGetInputTool() == 70) // Delete Current Mesh
93         {
94                     bbGetInputMeshManagerModel()->DeleteCurrentMesh();
95         }
96     } else {
97         printf("EED Warning! MeshManager_tool : MeshManagerModel not defined. \n");
98     }// if MeshManagerModel != NULL
99 }
100
101 //===== 
102 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
103 //===== 
104 void MeshManager_tool::bbUserSetDefaultValues()
105 {
106 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
107 //    Here we initialize the input 'In' to 0
108    bbSetInputTool(0);
109    bbSetInputMesh(NULL);
110    bbSetInputMeshManagerModel(NULL);
111 }
112
113 //===== 
114 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
115 //===== 
116 void MeshManager_tool::bbUserInitializeProcessing()
117 {
118 //  THE INITIALIZATION METHOD BODY :
119 //    Here does nothing 
120 //    but this is where you should allocate the internal/output pointers 
121 //    if any
122 }
123 //===== 
124 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
125 //===== 
126 void MeshManager_tool::bbUserFinalizeProcessing()
127 {
128 //  THE FINALIZATION METHOD BODY :
129 //    Here does nothing 
130 //    but this is where you should desallocate the internal/output pointers 
131 //    if any
132 }
133
134 } // EO namespace bbcreaVtk
135
136