creaContours_lib
wxContourMainFrame.h
Go to the documentation of this file.
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 # pour la Sant�)
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
8 #
9 # This software is governed by the CeCILL-B license under French law and
10 # abiding by the rules of distribution of free software. You can use,
11 # modify and/ or redistribute the software under the terms of the CeCILL-B
12 # license as circulated by CEA, CNRS and INRIA at the following URL
13 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 # or in the file LICENSE.txt.
15 #
16 # As a counterpart to the access to the source code and rights to copy,
17 # modify and redistribute granted by the license, users are provided only
18 # with a limited warranty and the software's author, the holder of the
19 # economic rights, and the successive licensors have only limited
20 # liability.
21 #
22 # The fact that you are presently reading this means that you have had
23 # knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
25 
26 #ifndef __wxContourMainFrame_h_INCLUDED_H__
27 #define __wxContourMainFrame_h_INCLUDED_H__
28 
29 
30 // -----------------------------------------------------------------------------------------------------------
31 // WX headers inclusion.
32 // For compilers that support precompilation, includes <wx/wx.h>.
33 // -----------------------------------------------------------------------------------------------------------
34 
35 #include <wx/wxprec.h>
36 #ifdef __BORLANDC__
37 #pragma hdrstop
38 #endif
39 #ifndef WX_PRECOMP
40 #include <wx/wx.h>
41 #endif
42 
43 
44 //------------------------------------------------------------------------------------------------------------
45 // Includes
46 //------------------------------------------------------------------------------------------------------------
47 #include "wx/aui/aui.h"
48 
49 #include "interfMainPanel.h"
50 #include "KernelManagerContour.h"
51 
52 //#include "wxVtkBaseView_SceneManager.h"
53 #include "wxInstantChooserPanel.h"
54 #include "wxContourViewPanel.h"
55 
56 //#include "ContourWorkspace.h"
57 #include "ContourExtractData.h"
58 #include "PerformingOperation.h"
59 
60 #include "manualLineControler.h"
61 #include "manualContourModelLine.h"
62 #include "manualViewLine.h"
63 
64 #include "ThresholdImageView.h"
65 #include "ThresholdImageViewPanel.h"
66 #include "ColorLayerImageView.h"
67 #include "ColorLayerImageViewPanel.h"
68 
69 
70 //ITK
71 #include "itkImage.h"
72 #include "itkGeodesicActiveContourLevelSetImageFilter.h"
73 
74 #include "itkCurvatureAnisotropicDiffusionImageFilter.h"
75 #include "itkGradientMagnitudeRecursiveGaussianImageFilter.h"
76 #include "itkSigmoidImageFilter.h"
77 #include "itkFastMarchingImageFilter.h"
78 #include "itkRescaleIntensityImageFilter.h"
79 #include "itkBinaryThresholdImageFilter.h"
80 #include "itkZeroCrossingImageFilter.h"
81 #include "itkCastImageFilter.h"
82 
83 //EED10JUIN2011 #include "itkImageFileWriter.h"
84 
87 
88 //VTK
89 #include <vtkImageSeedConnectivity.h>
90 #include <vtkImageMarchingCubes.h>
91 #include "vtkContourFilter.h"
92 #include "vtkMarchingContourFilter.h"
93 #include "vtkPolyDataConnectivityFilter.h"
94 #include "vtkCleanPolyData.h"
95 #include "vtkImageReslice.h"
96 #include "vtkMetaImageWriter.h"
97 #include "vtkImageData.h"
98 #include "vtkTransform.h"
99 
100 #include "vtkCamera.h"
101 #include "vtkImageActor.h"
102 #include <vtkImageMapToColors.h>
103 #include <vtkLookupTable.h>
104 #include <vtkCommand.h>
105 
106 //#include "vtkMetaImageReader.h"
107 
108 //------------------------------------------------------------------------------------------------------------
109 // Events declaration
110 //------------------------------------------------------------------------------------------------------------
111 
112 //BEGIN_DECLARE_EVENT_TYPES()
113 //END_DECLARE_EVENT_TYPES()
114 
118 //------------------------------------------------------------------------------------------------------------
119 // Class definition
120 //------------------------------------------------------------------------------------------------------------
121 class interfMainPanel;
122 class wxContourMainFrame : public wxPanel {
123 
124  public:
125 
126  //------------------------------------------------------------------------------------------------------------
127  // Constructors & Destructors
128  //------------------------------------------------------------------------------------------------------------
129 
130 
131  wxContourMainFrame(wxWindow* parent, wxWindowID id,const wxString& title,const wxPoint& pos,const wxSize& size,long style = wxDEFAULT_FRAME_STYLE | wxSUNKEN_BORDER);
132  wxContourMainFrame(wxWindow* parent, wxWindowID id,const wxString& title,const wxPoint& pos,const wxSize& size,std::vector<vtkImageData*> images, long style = wxDEFAULT_FRAME_STYLE | wxSUNKEN_BORDER,std::string datadir="C:/Creatis/creaContoursBin/RelWithDebInfo/");
133 
135 
136  //------------------------------------------------------------------------------------------------------------
137  // Creational and initialization methods
138  //------------------------------------------------------------------------------------------------------------
139 
140  void setVectImages(std::vector<vtkImageData*> imgs);
141 
142  bool configurePanels( );
143 
144  bool addNewPanel(wxPanel* panel);
145 
146  wxAuiNotebook * createNotebook();
147 
148  void createInstantChooserPanel(wxAuiNotebook * parent);
149 
150  void createViewPanel(wxAuiNotebook * parent);
151 
152  void createInstantChooserPanel(wxWindow * parent);
153 
154  void createViewPanel(wxWindow * parent);
155 
156  void setInstantChooserPanel( wxInstantChooserPanel * theInstantChooserPanel );
157 
158  void getMaskValue(vtkImageData ** mask,vtkImageData ** value,int typeContourGroup, int selection, int minZ, int maxZ);
159 
160  void SaveImageResult(std::string directory,std::string namefile, vtkImageData* mask,vtkImageData* value);
161 
162  void ShowToolsPanel(bool show);
163 
164 
168 
169 
173 
174 
175  //------------------------------------------------------------------------------------------------------------
176  // Attributes getters and setters
177  //------------------------------------------------------------------------------------------------------------
178  static wxContourMainFrame* getInstance(wxWindow* parent, wxWindowID id,const wxString& title,const wxPoint& pos,const wxSize& size,std::vector<vtkImageData*> images, long style = wxDEFAULT_FRAME_STYLE | wxSUNKEN_BORDER, std::string datadir="C:/Creatis/creaContoursBin/RelWithDebInfo/");
180  static void resetInstance();
181 
182  //------------------------------------------------------------------------------------------------------------
183  // Other functional methods
184  //------------------------------------------------------------------------------------------------------------
185 
186  /*
187  ** This method returns the vector of images selected by the user
188  ** return value std::vector<vtkImageData*>
189  */
190  std::vector<vtkImageData*> getVectImages();
191 
195  void onCreateContourSpline( );
196  void onCreateContourRectangle( );
197  void onCreateContourCircle( );
198  void onCreateContourLine( );
199  void onCreateContourPoints( );
200  void onCreateContourPolygon( );
201  void onCreateContourBullEye(wxPanel* pan);
203  void onDeleteContour();
204  void deleteContours( std::vector<std::string> keyNamesVector );
205  void deleteContour( std::string theKeyName );
207  void onDeleteAllContours();
208  void deleteAllContours();
209  void setConceptValue( std::string name, int value );
211  bool getIfConceptCheckedAt( std::string name, int pos );
212 
213  void changeInstant();
214 
215  int getNamesWrappingSize();
216 
217  std::string getNameWrapping(int i);
218 
219  void updateInstantOutlines();
220  void updateInstantImageData();
221  void updateInstantAxes();
222 
223  void onChangeDeep(int val);
224 
226  void onCopy();
227  void onPaste();
228  void onUndo();
229  void onRedo();
230  void createCopyContourOf ( std::string anExistingKName, std::vector<int> &instantNoTouchData, bool append );
231  void createMirrorContourOf ( std::string anExistingKName, std::vector<int> &instantNoTouchData, bool append );
233  void onLoad();
234  void onSave();
235  void onImport();
236  void onTest();
237  void openContours( FILE *pFile, FILE *pFileData, bool staticContour );
238 
239  void RefreshInterface();
240 
241  vtkImageData* getImageData();
242 
243  void onSegmentationOneSlice(int isovalue,int sampling,int method);
244  void onSegmentationOneSliceITK(wxString distance, wxString sigma, wxString alfa, wxString beta, wxString propagation, wxString iterations, wxString inflation);
245  void SegmentationOneSlice( int x, int y, int z, int isovalue, int sampling, int method );
246  void SegmentationOneSliceITK(int x, int y, int z, wxString distance, wxString sigma, wxString alfa, wxString beta, wxString propagation, wxString iterations, wxString inflation);
247  void Mirror( int x, int y, int z, int isovalue, int sampling, int method );
248  int GetImageDataSizeZ();
249  void GetImageDataRange(double *range);
250  void onSegmentationAllSlice(int minZ,int maxZ,int isovalue,int sampling,int method);
251 
252  //AD
253  void referenceLine();
254  void refLineHide();
255  void refLineShow();
256  void refLineChangeWidth(int width);
257 
258  //AD
259  void onMirror();
260 
261 
262 //====================================================================================================
263 
264  void showAxis(bool show);
265  void onRigidPressed();
266  void onWidthOfContour(double width);
267  int getColorWindow();
268  int getWindowLevel();
269  void onBrigthnessColorWindowLevel(int colorwindow,int windowlevel);
270  void onInterpolation(bool interpolate);
271  void onChangeInstant(std::string name,int actual);
272  void resetAppend();
273  void onSpreadAdd();
274  void onSpreadAddAll();
275  void onSpreadGo(int type);
276  void getInstantVector(std::vector<int>& tempVector);
277  std::vector<std::string> getOutlinesName(int slide);
278 
279  //
280  //
281  // @param typeContourGroup - int The operation id (AND,OR,XOR,ALL=3)
282  //
283  void onInformationContourLabels(int typeContourGroup,int selection,int minimumZ,int maximumZ,int grayRangeMin, int grayRangeMax);
284  void onSaveResults(std::string directory,std::string namefile, std::string filename,
285  int typeContourGroup, int selection, int minZ, int maxZ, bool XYZValues, bool contourImage, bool statistics);
286  void SaveValuesXYZ(std::string directory,std::string namefile, int typeContourGroup);
287  void onChangeInstantInstantPanel(std::string name,int value, int minshow, int maxshow);
288  void onSnakePressed();
290  void ShowResultImages(int typeContourGroup, int selection, int minZ, int maxZ );
291  wxPanel *getMaskImageViewPanel(wxWindow *parent);
292  void SetContourGroup(int contourGroup);
293  wxPanel *getThresholdImageViewPanel(wxWindow *parent);
294  wxPanel *getColorLayerImageViewPanel(wxWindow *parent);
295 
296 
297 //CMRU 17-08-09-----------------------------------------------------------------------------------------------
298 
304  void onPrintLabel (wxString label, manualBaseModel* manualModel);
305 
310  void onInsertCalculation(manualBaseModel* manualModel);
311 
316  double onePixelSize(double value);
317 
321  int getType();
322 
326  double getContourSizeInPixels();
327 
331  manualBaseModel* getContour();
332 
336  std::string GetFileLocation();
337 
342  void SetFileLocation(std::string newFileLocation);
343 //------------------------------------------------------------------------------------------------------------
344 
345  void SetScalarRange(int grayRangeMin, int grayRangeMax);
346 
347 //------------------------------------------------------------------------------------------------------------
348 
349 private:
350  //------------------------------------------------------------------------------------------------------------
351  // Private methods
352  //------------------------------------------------------------------------------------------------------------
353 
354 
355  //------------------------------------------------------------------------------------------------------------
356  // Attributtes
357  //------------------------------------------------------------------------------------------------------------
358 
364  std::string _datadir;
367 
368  //AD: 03-09: This attributes represents the reference line that is going to be used for the mirroring
369  manualLineControler *_refLineControl;
370  manualContourModelLine *_refLineModel;
371  manualViewLine *_refLineView;
372 
373  wxAuiManager m_mgr;
374  wxAuiNotebook *notebook;
378 
379  // Contour Image Mask
380  ThresholdImageView *_viewMaskImage;
381  ThresholdImageViewPanel *_viewMaskImagePanel;
382 
383  // Threshold Image
384  ThresholdImageView *_viewThresholdImage;
385  ThresholdImageViewPanel *_viewThresholdImagePanel;
386 
387  // Color Layer Image
388  ColorLayerImageView *_viewColorLayerImage;
389  ColorLayerImageViewPanel *_viewColorLayerImagePanel;
390  std::vector<vtkImageData*> _images;
392 
393  // temporary variables readding .roi file
397  void readDimSpc(FILE *pFile, bool interactiveOption);
398 
399 
400  /*DECLARE_CLASS(wxContourMainFrame)
401  // any class wishing to process wxWindows events must use this macro
402  DECLARE_EVENT_TABLE()*/
405  void createContour( int typeContour );
406  //manualContourModel * factoryManualContourModel(int typeContour);
407  manualBaseModel * factoryManualContourModel(wxPanel* panel);
408  ContourExtractData *_contourextractdata;
409 
410  void saveState();
411  void loadState(std::string filename);
412 
413 // void loadContours( FILE *pFile, bool staticContour );
414 
415  void saveFileWithContours( std::string filename );
416  void onLoadContours(std::string fileNameContourROI, bool interactiveInterface);
417  void SetZForAllContours(int pz);
418 
419  int inredo;
420  int inundo;
421  std::string stundoredo;
422  static char COPY;
423 
424 //CMRU 17-08-09-----------------------------------------------------------------------------------------------
425  wxWindow *infoWin2;
429  std::string _imageLocation;
430  std::string _fileLocation;
431 //------------------------------------------------------------------------------------------------------------
432 
433 };
434 
435 #endif