1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
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
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.
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
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 # ------------------------------------------------------------------------ */
26 #ifndef __wxContourMainFrame_h_INCLUDED_H__
27 #define __wxContourMainFrame_h_INCLUDED_H__
30 // -----------------------------------------------------------------------------------------------------------
31 // WX headers inclusion.
32 // For compilers that support precompilation, includes <wx/wx.h>.
33 // -----------------------------------------------------------------------------------------------------------
35 #include <wx/wxprec.h>
44 //------------------------------------------------------------------------------------------------------------
46 //------------------------------------------------------------------------------------------------------------
47 #include "wx/aui/aui.h"
49 #include "interfMainPanel.h"
50 #include "KernelManagerContour.h"
52 //#include "wxVtkBaseView_SceneManager.h"
53 #include "wxInstantChooserPanel.h"
54 #include "wxContourViewPanel.h"
56 //#include "ContourWorkspace.h"
57 #include "ContourExtractData.h"
58 #include "PerformingOperation.h"
60 #include "manualLineControler.h"
61 #include "manualContourModelLine.h"
62 #include "manualViewLine.h"
64 #include "ThresholdImageView.h"
65 #include "ThresholdImageViewPanel.h"
66 #include "ColorLayerImageView.h"
67 #include "ColorLayerImageViewPanel.h"
72 #include "itkGeodesicActiveContourLevelSetImageFilter.h"
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"
83 //EED10JUIN2011 #include "itkImageFileWriter.h"
85 #include "itkImageToVTKImageFilter.h"
86 #include "itkVTKImageToImageFilter.h"
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 #include "vtkCamera.h"
100 #include "vtkImageActor.h"
101 #include <vtkImageMapToColors.h>
102 #include <vtkLookupTable.h>
103 #include <vtkCommand.h>
105 //#include "vtkMetaImageReader.h"
107 //------------------------------------------------------------------------------------------------------------
108 // Events declaration
109 //------------------------------------------------------------------------------------------------------------
111 //BEGIN_DECLARE_EVENT_TYPES()
112 //END_DECLARE_EVENT_TYPES()
114 /** file wxContourMainFrame.h */
117 //------------------------------------------------------------------------------------------------------------
119 //------------------------------------------------------------------------------------------------------------
120 class interfMainPanel;
121 class wxContourMainFrame : public wxPanel {
125 //------------------------------------------------------------------------------------------------------------
126 // Constructors & Destructors
127 //------------------------------------------------------------------------------------------------------------
130 wxContourMainFrame(wxWindow* parent, wxWindowID id,const wxString& title,const wxPoint& pos,const wxSize& size,long style = wxDEFAULT_FRAME_STYLE | wxSUNKEN_BORDER);
131 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 ~wxContourMainFrame();
135 //------------------------------------------------------------------------------------------------------------
136 // Creational and initialization methods
137 //------------------------------------------------------------------------------------------------------------
139 void setVectImages(std::vector<vtkImageData*> imgs);
141 bool configurePanels( );
143 bool addNewPanel(wxPanel* panel);
145 wxAuiNotebook * createNotebook();
147 void createInstantChooserPanel(wxAuiNotebook * parent);
149 void createViewPanel(wxAuiNotebook * parent);
151 void createInstantChooserPanel(wxWindow * parent);
153 void createViewPanel(wxWindow * parent);
155 void setInstantChooserPanel( wxInstantChooserPanel * theInstantChooserPanel );
157 void getMaskValue(vtkImageData ** mask,vtkImageData ** value,int typeContourGroup, int selection, int minZ, int maxZ);
159 void SaveImageResult(std::string directory,std::string namefile, vtkImageData* mask,vtkImageData* value);
161 void ShowToolsPanel(bool show);
164 ////------------------------------------------------------------------------------------------------------------
165 //// Methods for capturing events
166 ////------------------------------------------------------------------------------------------------------------
169 ////------------------------------------------------------------------------------------------------------------
170 //// Model management methods
171 ////------------------------------------------------------------------------------------------------------------
174 //------------------------------------------------------------------------------------------------------------
175 // Attributes getters and setters
176 //------------------------------------------------------------------------------------------------------------
177 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/");
178 static wxContourMainFrame* getInstance();
179 static void resetInstance();
181 //------------------------------------------------------------------------------------------------------------
182 // Other functional methods
183 //------------------------------------------------------------------------------------------------------------
186 ** This method returns the vector of images selected by the user
187 ** return value std::vector<vtkImageData*>
189 std::vector<vtkImageData*> getVectImages();
192 ** This methods connect the event in the class interfMainPanel with the world of the appli
194 void onCreateContourSpline( );
195 void onCreateContourRectangle( );
196 void onCreateContourCircle( );
197 void onCreateContourLine( );
198 void onCreateContourPoints( );
199 void onCreateContourPolygon( );
200 void onCreateContourBullEye(wxPanel* pan);
201 /////////////////////////////////
202 void onDeleteContour();
203 void deleteContours( std::vector<std::string> keyNamesVector );
204 void deleteContour( std::string theKeyName );
205 void onDeleteContoursActSlice();
206 void onDeleteAllContours();
207 void deleteAllContours();
208 void setConceptValue( std::string name, int value );
209 ConceptDataWrap* getLastConceptData();
210 bool getIfConceptCheckedAt( std::string name, int pos );
211 void changeInstant();
212 int getNamesWrappingSize();
213 std::string getNameWrapping(int i);
214 void updateInstantOutlines();
215 void updateInstantImageData();
216 void updateInstantAxes();
217 void onChangeDeep(int val);
218 ///////////////////////////
223 void createCopyContourOf ( std::string anExistingKName, std::vector<int> &instantNoTouchData, bool append );
224 void createMirrorContourOf ( std::string anExistingKName, std::vector<int> &instantNoTouchData, bool append );
225 ///////////////////////7
230 void openContours( FILE *pFile, FILE *pFileData, bool staticContour );
231 void RefreshInterface();
232 vtkImageData* getImageData();
233 void onSegmentationOneSlice(int isovalue,int sampling,int method);
234 void onSegmentationOneSliceITK(wxString distance, wxString sigma, wxString alfa, wxString beta, wxString propagation, wxString iterations, wxString inflation);
235 void SegmentationOneSlice( int x, int y, int z, int isovalue, int sampling, int method );
236 void SegmentationOneSliceITK(int x, int y, int z, wxString distance, wxString sigma, wxString alfa, wxString beta, wxString propagation, wxString iterations, wxString inflation);
237 void Mirror( int x, int y, int z, int isovalue, int sampling, int method );
238 int GetImageDataSizeZ();
239 void GetImageDataRange(double *range);
240 void onSegmentationAllSlice(int minZ,int maxZ,int isovalue,int sampling,int method);
243 void referenceLine();
246 void refLineChangeWidth(int width);
252 void FlipContours(int typeContourFlip, int flipDirection);
253 void FlipSelectedContours(int flipDirection);
254 void FlipActualSliceContours(int flipDirection);
255 void FlipAllContours(int flipDirection);
256 void FlipLstOfContours(std::vector<std::string> lstNameThings, int flipDirection);
258 //====================================================================================================
260 void showAxis(bool show);
261 void onRigidPressed();
262 void onWidthOfContour(double width);
263 int getColorWindow();
264 int getWindowLevel();
265 void onBrigthnessColorWindowLevel(int colorwindow,int windowlevel);
266 void onInterpolation(bool interpolate);
267 void onChangeInstant(std::string name,int actual);
270 void onSpreadAddAll();
271 void onSpreadGo(int type);
272 void getInstantVector(std::vector<int>& tempVector);
273 std::vector<std::string> getOutlinesName(int slide);
277 // @param typeContourGroup - int The operation id (AND,OR,XOR,ALL=3)
279 void onInformationContourLabels(int typeContourGroup,int selection,int minimumZ,int maximumZ,int grayRangeMin, int grayRangeMax);
280 void onSaveResults(std::string directory,std::string namefile, std::string filename,
281 int typeContourGroup, int selection, int minZ, int maxZ, bool XYZValues, bool contourImage, bool statistics);
282 void SaveValuesXYZ(std::string directory,std::string namefile, int typeContourGroup);
283 void onChangeInstantInstantPanel(std::string name,int value, int minshow, int maxshow);
284 void onSnakePressed();
285 void saveFileWithContoursAutomatique();
286 void ShowResultImages(int typeContourGroup, int selection, int minZ, int maxZ );
287 wxPanel *getMaskImageViewPanel(wxWindow *parent);
288 void SetContourGroup(int contourGroup);
289 wxPanel *getThresholdImageViewPanel(wxWindow *parent);
290 wxPanel *getColorLayerImageViewPanel(wxWindow *parent);
292 //CMRU 17-08-09-----------------------------------------------------------------------------------------------
295 * Associates the String parameter with the contour
296 * @param label Label entered by the user
297 * @param manualBaseModel Currently selected contour
299 void onPrintLabel (wxString label, manualBaseModel* manualModel);
302 * Calculates the size of the contour received as a parameter. Uses the measure of a pixel in millimeters.
303 * @param manualBaseModel Currently selected contour
305 void onInsertCalculation(manualBaseModel* manualModel);
308 * Assigns and returns the value of a pixel in millimeters
309 @ param value Measure of the pixel in millimeters
311 double onePixelSize(double value);
314 * Returns the type of the currently selected contour
319 * Returns the size in pixels of the currently selected contour
321 double getContourSizeInPixels();
324 * Returns the currently selected contour. If no contour is selected returns NULL
326 manualBaseModel* getContour();
329 * Returns the Path of the data persistence file
331 std::string GetFileLocation();
334 * Assign a new path to the data persistence file
335 @ param newFileLocation New path of the file
337 void SetFileLocation(std::string newFileLocation);
338 //------------------------------------------------------------------------------------------------------------
340 void SetScalarRange(int grayRangeMin, int grayRangeMax);
342 std::string GetStringTypeImage( vtkImageData* image);
344 //------------------------------------------------------------------------------------------------------------
347 //------------------------------------------------------------------------------------------------------------
349 //------------------------------------------------------------------------------------------------------------
352 //------------------------------------------------------------------------------------------------------------
354 //------------------------------------------------------------------------------------------------------------
357 static wxContourMainFrame *instance;
358 KernelManagerContour *kernelManager;
359 interfMainPanel *_pannew;
360 PerformingOperation *_performingOperation;
361 std::string _datadir;
362 wxContourViewPanel *_theViewPanel;
363 wxInstantChooserPanel *_instantPanel;
365 //AD: 03-09: This attributes represents the reference line that is going to be used for the mirroring
366 manualLineControler *_refLineControl;
367 manualContourModelLine *_refLineModel;
368 manualViewLine *_refLineView;
371 wxAuiNotebook *notebook;
372 long m_notebook_style;
373 long m_notebook_theme;
374 int _numberOfVariablesStatistics;
376 // Contour Image Mask
377 ThresholdImageView *_viewMaskImage;
378 ThresholdImageViewPanel *_viewMaskImagePanel;
381 ThresholdImageView *_viewThresholdImage;
382 ThresholdImageViewPanel *_viewThresholdImagePanel;
385 ColorLayerImageViewPanel *_viewColorLayerImagePanel;
386 std::vector<vtkImageData*> _images;
389 // temporary variables readding .roi file
390 int _tmpReadFileImageDim[3];
391 double _tmpReadFileImageSpac[3];
392 int _tmpReadFileTypeOfTransformation;
393 void readDimSpc(FILE *pFile, bool interactiveOption);
396 /*DECLARE_CLASS(wxContourMainFrame)
397 // any class wishing to process wxWindows events must use this macro
398 DECLARE_EVENT_TABLE()*/
399 bool _creatingContoursActive;
400 ////////JCP 21 - 11 - 08
401 void createContour( int typeContour );
402 //manualContourModel * factoryManualContourModel(int typeContour);
403 manualBaseModel * factoryManualContourModel(wxPanel* panel);
404 ContourExtractData *_contourextractdata;
407 void loadState(std::string filename);
409 // void loadContours( FILE *pFile, bool staticContour );
411 void saveFileWithContours( std::string filename );
412 void onLoadContours(std::string fileNameContourROI, bool interactiveInterface);
413 void SetZForAllContours(int pz);
417 std::string stundoredo;
420 //CMRU 17-08-09-----------------------------------------------------------------------------------------------
422 wxPanel *calibrationPanel;
423 wxPanel *calibrationPanelError;
424 double _onePixelSize;
425 std::string _imageLocation;
426 std::string _fileLocation;
427 //------------------------------------------------------------------------------------------------------------
429 wxFrame *_frameShowResultImages;