]> Creatis software - cpPlugins.git/blob - appli/ImageMPR/ImageMPR.h
undo redo for images in viewer
[cpPlugins.git] / appli / ImageMPR / ImageMPR.h
1 #ifndef __IMAGEMPR__H__
2 #define __IMAGEMPR__H__
3
4 #include <vector>
5
6 // Qt stuff
7 #include <QMainWindow>
8
9 // vtk stuff
10 #include <vtkSmartPointer.h>
11 #include <cpExtensions/Visualization/MPRObjects.h>
12
13 // Plugins interface
14 #include <cpPlugins/Interface/Interface.h>
15 #include <cpPlugins/Interface/ProcessObject.h>
16 #include <cpPlugins/Interface/Image.h>
17 #include <cpPlugins/Interface/ImplicitFunction.h>
18 #include <cpPlugins/Interface/Mesh.h>
19 #include <vtkMetaImageWriter.h>
20 #include <vtkMetaImageReader.h>
21
22
23 // -------------------------------------------------------------------------
24 namespace Ui
25 {
26   class ImageMPR;
27 }
28
29 //==========================================================================
30 // Plugins types
31 //typedef cpPlugins::Interface::Interface        TPluginsInterface;
32 //typedef cpPlugins::Interface::Object           TPluginObject;
33 //typedef cpPlugins::Interface::DataObject       TPluginData;
34 //typedef cpPlugins::Interface::Image            TPluginImage;
35 //typedef cpPlugins::Interface::ImplicitFunction TPluginImplicitFunction;
36 //typedef cpPlugins::Interface::Mesh             TPluginMesh;
37 //typedef cpPlugins::Interface::ProcessObject    TPluginFilter;
38 //typedef cpPlugins::Interface::Parameters       TParameters;
39 //
40 //typedef cpExtensions::Visualization::MPRObjects TMPRObjects;
41
42
43
44
45 //class MementoState
46 //{
47 //private:
48 //      long m_Id;
49 //      
50 //public:
51 //      
52 //      MementoState()
53 //      {
54 //              m_Id = 0;
55 //      };
56 //
57 //      MementoState(long id, TPluginImage* _img)
58 //      {
59 //              char * base = "state";
60 //              std::ostringstream oss;
61 //              oss << id;
62 //              std::string str = oss.str();
63 //              auto complement = str.c_str();
64 //
65 //              std::string fileName(base);
66 //              fileName.append(complement);
67 //              fileName.append(".mhd");
68 //
69 //              std::string fileNameRaw(base);
70 //              fileNameRaw.append(complement);
71 //              fileNameRaw.append(".raw");
72 //              save(fileName, fileNameRaw, _img);
73 //      }
74 //
75 //      vtkSmartPointer<vtkMetaImageReader> getMemento(long id)
76 //      {
77 //              char * base = "state";
78 //              std::ostringstream oss;
79 //              oss << id;
80 //              std::string str = oss.str();
81 //              auto complement = str.c_str();
82 //
83 //              std::string fileName(base);
84 //              fileName.append(complement);
85 //              fileName.append(".mhd");
86 //              return load(fileName);
87 //      }
88 //
89 //      void save(const std::string& filename, const std::string& filenameRaw, TPluginImage* img) {
90 //              vtkSmartPointer<vtkMetaImageWriter> writer =
91 //                      vtkSmartPointer<vtkMetaImageWriter>::New();
92 //              writer->SetInputData(img->GetVTK< vtkImageData >());
93 //              writer->SetFileName(filename.c_str());
94 //              writer->SetRAWFileName(filenameRaw.c_str());
95 //              writer->Write();
96 //      }
97 //
98 //      vtkSmartPointer<vtkMetaImageReader> load(const std::string& filename) {
99 //              vtkSmartPointer<vtkMetaImageReader> reader =
100 //              vtkSmartPointer<vtkMetaImageReader>::New();
101 //              reader->SetFileName(filename.c_str());
102 //              reader->Update();       
103 //              return reader;
104 //      }
105 //
106 //};
107
108 //==========================================================================
109
110 // -------------------------------------------------------------------------
111 /**
112  */
113
114
115
116 class ImageMPR
117   : public QMainWindow
118 {
119   Q_OBJECT;
120
121 public:
122   // Plugins types
123   typedef cpPlugins::Interface::Interface        TPluginsInterface;
124   typedef cpPlugins::Interface::Object           TPluginObject;
125   typedef cpPlugins::Interface::DataObject       TPluginData;
126   typedef cpPlugins::Interface::Image            TPluginImage;
127   typedef cpPlugins::Interface::ImplicitFunction TPluginImplicitFunction;
128   typedef cpPlugins::Interface::Mesh             TPluginMesh;
129   typedef cpPlugins::Interface::ProcessObject    TPluginFilter;
130   typedef cpPlugins::Interface::Parameters       TParameters;
131
132   typedef cpExtensions::Visualization::MPRObjects TMPRObjects;
133
134 public:
135   explicit ImageMPR( QWidget* parent = 0 );
136   virtual ~ImageMPR( );
137
138 protected:
139   bool _LoadPlugins( const std::string& filename );
140   std::string _LoadImage( TPluginImage::Pointer& image );
141   std::string _ConfigureMeshActors( );
142
143 private slots:
144   void _triggered_actionOpenPlugins( );
145   void _triggered_actionOpenInputImage( );
146   void _triggered_actionOpenSegmentation( );
147   void _triggered_actionOpenInputPolyData( );
148   void _triggered_actionImageToImage( );
149   void _triggered_actionImageToMesh( );
150   void _triggered_actionUndo();
151   void _triggered_actionRedo();
152 private:
153   Ui::ImageMPR* m_UI;
154
155   // Plugins objects
156   TPluginsInterface m_Plugins;
157
158   // Needed object from plugins
159   std::string m_ImageReaderClass;
160   std::string m_ImageWriterClass;
161   std::string m_MeshReaderClass;
162   std::string m_MeshWriterClass;
163   std::string m_MeshCutterClass;
164
165   // Real data
166   TPluginImage::Pointer m_Image;
167   TPluginImage::Pointer m_Segmentation;
168   TPluginMesh::Pointer  m_Mesh;
169
170   // Cutters
171   TPluginFilter::Pointer m_Cutters[ 3 ];
172   TPluginImplicitFunction::Pointer m_Planes[ 3 ];
173
174   // Visualization stuff
175   vtkSmartPointer< TMPRObjects > m_MPRObjects;
176
177   // Memento stuff
178   unsigned long m_state;
179
180   /* TODO
181      vtkSmartPointer< vtkOrientationMarkerWidget > m_3DOrientationWidget;
182   */
183 };
184
185 #endif // __IMAGEMPR__H__
186
187 // eof - $RCSfile$