]> 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()==31)  // Set/Update PolyData Reference
56         {
57             if (bbGetInputMesh()!=NULL){
58                 vtkPoints   *points = bbGetInputMesh()->GetPoints();
59                 if (points!=NULL)
60                 {
61                     bbGetInputMeshManagerModel()->UpdateMeshReference( bbGetInputMesh() );
62                 } // if points!=NULL
63             } // Mesh!=NULL
64         } // if Tool 30 Set
65
66         if (bbGetInputTool()==35)  // Set memory mode
67         {
68                 bbGetInputMeshManagerModel()->SetMeshMemoryMode( bbGetInputMesh() );
69         } // if Tool 35 Set memory mode
70
71         if (bbGetInputTool()==32)  // Copy and Set
72         {
73                 bbGetInputMeshManagerModel()->CopySetMeshBase( bbGetInputMesh() );
74         } // if Tool 35 Set memory mode
75
76         
77         if (bbGetInputTool()==40) // ResetMeshTemp
78         {
79             bbGetInputMeshManagerModel()->ResetMeshTemp();
80         } // if Tool 40 Reset
81         
82         if(bbGetInputTool() == 50) // Set Array of Meshes
83         {
84                 if(bbGetInputMeshes().size() > 1)
85                 {
86                         bbGetInputMeshManagerModel()->ReplaceMesh(bbGetInputMeshes());
87                     }
88         }
89         if(bbGetInputTool() == 60) // Select Mesh by Name
90         {
91                 if(!bbGetInputStringParam().empty())
92                 {
93                         bbGetInputMeshManagerModel()->SelectMeshByName(bbGetInputStringParam());
94                     }
95         }
96         if(bbGetInputTool() == 70) // Delete Current Mesh
97         {
98                     bbGetInputMeshManagerModel()->DeleteCurrentMesh();
99         }
100     } else {
101         printf("EED Warning! MeshManager_tool : MeshManagerModel not defined. \n");
102     }// if MeshManagerModel != NULL
103 }
104
105 //===== 
106 // 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)
107 //===== 
108 void MeshManager_tool::bbUserSetDefaultValues()
109 {
110 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
111 //    Here we initialize the input 'In' to 0
112    bbSetInputTool(0);
113    bbSetInputMesh(NULL);
114    bbSetInputMeshManagerModel(NULL);
115 }
116
117 //===== 
118 // 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)
119 //===== 
120 void MeshManager_tool::bbUserInitializeProcessing()
121 {
122 //  THE INITIALIZATION METHOD BODY :
123 //    Here does nothing 
124 //    but this is where you should allocate the internal/output pointers 
125 //    if any
126 }
127 //===== 
128 // 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)
129 //===== 
130 void MeshManager_tool::bbUserFinalizeProcessing()
131 {
132 //  THE FINALIZATION METHOD BODY :
133 //    Here does nothing 
134 //    but this is where you should desallocate the internal/output pointers 
135 //    if any
136 }
137
138 } // EO namespace bbcreaVtk
139
140