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"
88 #include "itkImageToVTKImageFilter.h"
89 #include "itkVTKImageToImageFilter.h"
92 #include <vtkImageSeedConnectivity.h>
93 #include <vtkImageMarchingCubes.h>
94 #include "vtkContourFilter.h"
95 #include "vtkMarchingContourFilter.h"
96 #include "vtkPolyDataConnectivityFilter.h"
97 #include "vtkCleanPolyData.h"
98 #include "vtkImageReslice.h"
99 #include "vtkMetaImageWriter.h"
100 #include "vtkImageData.h"
101 #include "vtkTransform.h"
102 #include "vtkCamera.h"
103 #include "vtkImageActor.h"
104 #include <vtkImageMapToColors.h>
105 #include <vtkLookupTable.h>
106 #include <vtkCommand.h>
108 //#include "vtkMetaImageReader.h"
110 //------------------------------------------------------------------------------------------------------------
111 // Events declaration
112 //------------------------------------------------------------------------------------------------------------
114 //BEGIN_DECLARE_EVENT_TYPES()
115 //END_DECLARE_EVENT_TYPES()
117 /** file wxContourMainFrame.h */
120 //------------------------------------------------------------------------------------------------------------
122 //------------------------------------------------------------------------------------------------------------
123 class interfMainPanel;
124 class wxContourMainFrame : public wxPanel {
126 //------------------------------------------------------------------------------------------------------------
127 // Constructors & Destructors
128 //------------------------------------------------------------------------------------------------------------
129 wxContourMainFrame(wxWindow* parent, wxWindowID id,const wxString& title,const wxPoint& pos,const wxSize& size,long style = wxDEFAULT_FRAME_STYLE | wxSUNKEN_BORDER);
130 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/");
131 ~wxContourMainFrame();
132 //------------------------------------------------------------------------------------------------------------
133 // Creational and initialization methods
134 //------------------------------------------------------------------------------------------------------------
135 void setVectImages(std::vector<vtkImageData*> imgs);
136 bool configurePanels( );
137 bool addNewPanel(wxPanel* panel);
138 wxAuiNotebook * createNotebook();
139 void createInstantChooserPanel(wxAuiNotebook * parent);
140 void createViewPanel(wxAuiNotebook * parent);
141 void createInstantChooserPanel(wxWindow * parent);
142 void createViewPanel(wxWindow * parent);
143 void setInstantChooserPanel( wxInstantChooserPanel * theInstantChooserPanel );
144 void getMaskValue(vtkImageData ** mask,vtkImageData ** value,int typeContourGroup, int selection, int minZ, int maxZ);
145 void SaveImageResult(std::string directory,std::string namefile, vtkImageData* mask,vtkImageData* value);
146 void ShowToolsPanel(bool show);
147 ////------------------------------------------------------------------------------------------------------------
148 //// Methods for capturing events
149 ////------------------------------------------------------------------------------------------------------------
151 ////------------------------------------------------------------------------------------------------------------
152 //// Model management methods
153 ////------------------------------------------------------------------------------------------------------------
155 //------------------------------------------------------------------------------------------------------------
156 // Attributes getters and setters
157 //------------------------------------------------------------------------------------------------------------
158 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/");
159 static wxContourMainFrame* getInstance();
160 static void resetInstance();
162 //------------------------------------------------------------------------------------------------------------
163 // Other functional methods
164 //------------------------------------------------------------------------------------------------------------
167 ** This method returns the vector of images selected by the user
168 ** return value std::vector<vtkImageData*>
170 std::vector<vtkImageData*> getVectImages();
173 ** This methods connect the event in the class interfMainPanel with the world of the appli
175 void onCreateContourSpline( );
176 void onCreateContourRectangle( );
177 void onCreateContourCircle( );
178 void onCreateContourLine( );
179 void onCreateContourPoints( );
180 void onCreateContourPolygon( );
181 void onCreateContourBullEye(wxPanel* pan);
182 /////////////////////////////////
183 void onDeleteContour();
184 void deleteContours( std::vector<std::string> keyNamesVector );
185 void deleteContour( std::string theKeyName );
186 void onDeleteContoursActSlice();
187 void onDeleteAllContours();
188 void deleteAllContours();
189 void setConceptValue( std::string name, int value );
190 ConceptDataWrap* getLastConceptData();
191 bool getIfConceptCheckedAt( std::string name, int pos );
192 void changeInstant();
193 int getNamesWrappingSize();
194 std::string getNameWrapping(int i);
195 void updateInstantOutlines();
196 void updateInstantImageData();
197 void updateInstantAxes();
198 void onChangeDeep(int val);
199 ///////////////////////////
204 void createCopyContourOf ( std::string anExistingKName, std::vector<int> &instantNoTouchData, bool append );
205 void createMirrorContourOf ( std::string anExistingKName, std::vector<int> &instantNoTouchData, bool append );
206 ///////////////////////7
211 void openContours( FILE *pFile, FILE *pFileData, bool staticContour );
212 void RefreshInterface();
213 vtkImageData* getImageData();
214 void onSegmentationOneSlice(int isovalue,int sampling,int method);
215 void onSegmentationOneSliceITK(wxString distance, wxString sigma, wxString alfa, wxString beta, wxString propagation, wxString iterations, wxString inflation);
216 void SegmentationOneSlice( int x, int y, int z, int isovalue, int sampling, int method );
217 void SegmentationOneSliceITK(int x, int y, int z, wxString distance, wxString sigma, wxString alfa, wxString beta, wxString propagation, wxString iterations, wxString inflation);
218 void Mirror( int x, int y, int z, int isovalue, int sampling, int method );
219 int GetImageDataSizeZ();
220 void GetImageDataRange(double *range);
221 void onSegmentationAllSlice(int minZ,int maxZ,int isovalue,int sampling,int method);
224 void referenceLine();
227 void refLineChangeWidth(int width);
233 void FlipContours(int typeContourFlip, int flipDirection);
234 void FlipSelectedContours(int flipDirection);
235 void FlipActualSliceContours(int flipDirection);
236 void FlipAllContours(int flipDirection);
237 void FlipLstOfContours(std::vector<std::string> lstNameThings, int flipDirection);
239 //====================================================================================================
241 void showAxis(bool show);
242 void onRigidPressed();
243 void onWidthOfContour(double width);
244 int getColorWindow();
245 int getWindowLevel();
246 void onBrigthnessColorWindowLevel(int colorwindow,int windowlevel);
247 void onInterpolation(bool interpolate);
248 void onShowTextContour(bool show);
249 void onBeforeAfterContour(bool before, bool after);
250 void onJumpSlice(int step,int shift);
251 void onChangeInstant(std::string name,int actual);
254 void onSpreadAddAll();
255 void onSpreadGo(int type);
256 void getInstantVector(std::vector<int>& tempVector);
257 std::vector<std::string> getOutlinesName(int slide);
261 // @param typeContourGroup - int The operation id (AND,OR,XOR,ALL=3)
263 void onInformationContourLabels(int typeContourGroup,int selection,int minimumZ,int maximumZ,int grayRangeMin, int grayRangeMax);
264 void onSaveResults(std::string directory,std::string namefile, std::string filename,
265 int typeContourGroup, int selection, int minZ, int maxZ, bool XYZValues, bool contourImage, bool statistics);
266 void SaveValuesXYZ(std::string directory,std::string namefile, int typeContourGroup);
267 void onChangeInstantInstantPanel(std::string name,int value, int minshow, int maxshow);
268 void onSnakePressed();
269 void saveFileWithContoursAutomatique();
270 void ShowResultImages(int typeContourGroup, int selection, int minZ, int maxZ );
271 wxPanel *getMaskImageViewPanel(wxWindow *parent);
272 void SetContourGroup(int contourGroup);
273 wxPanel *getThresholdImageViewPanel(wxWindow *parent);
274 wxPanel *getColorLayerImageViewPanel(wxWindow *parent);
275 void SetColorLayerImage(vtkImageData*);
277 //CMRU 17-08-09-----------------------------------------------------------------------------------------------
280 * Associates the String parameter with the contour
281 * @param label Label entered by the user
282 * @param manualBaseModel Currently selected contour
284 void onPrintLabel (wxString label, manualBaseModel* manualModel);
287 * Calculates the size of the contour received as a parameter. Uses the measure of a pixel in millimeters.
288 * @param manualBaseModel Currently selected contour
290 void onInsertCalculation(manualBaseModel* manualModel);
293 * Assigns and returns the value of a pixel in millimeters
294 @ param value Measure of the pixel in millimeters
296 double onePixelSize(double value);
299 * Returns the type of the currently selected contour
304 * Returns the size in pixels of the currently selected contour
306 double getContourSizeInPixels();
309 * Returns the currently selected contour. If no contour is selected returns NULL
311 manualBaseModel* getContour();
314 * Returns the Path of the data persistence file
316 std::string GetFileLocation();
319 * Assign a new path to the data persistence file
320 @ param newFileLocation New path of the file
322 void SetFileLocation(std::string newFileLocation);
323 //------------------------------------------------------------------------------------------------------------
325 void SetScalarRange(int grayRangeMin, int grayRangeMax);
326 std::string GetStringTypeImage( vtkImageData* image);
328 //------------------------------------------------------------------------------------------------------------
330 void SetXY(int x,int y);
334 //------------------------------------------------------------------------------------------------------------
336 //------------------------------------------------------------------------------------------------------------
339 //------------------------------------------------------------------------------------------------------------
341 //------------------------------------------------------------------------------------------------------------
344 static wxContourMainFrame *instance;
345 KernelManagerContour *kernelManager;
346 interfMainPanel *_pannew;
347 PerformingOperation *_performingOperation;
348 std::string _datadir;
349 wxContourViewPanel *_theViewPanel;
350 wxInstantChooserPanel *_instantPanel;
352 //AD: 03-09: This attributes represents the reference line that is going to be used for the mirroring
353 manualLineControler *_refLineControl;
354 manualContourModelLine *_refLineModel;
355 manualViewLine *_refLineView;
358 wxAuiNotebook *notebook;
359 long m_notebook_style;
360 long m_notebook_theme;
361 int _numberOfVariablesStatistics;
363 // Contour Image Mask
364 ThresholdImageView *_viewMaskImage;
365 ThresholdImageViewPanel *_viewMaskImagePanel;
368 ThresholdImageView *_viewThresholdImage;
369 ThresholdImageViewPanel *_viewThresholdImagePanel;
372 ColorLayerImageViewPanel *_viewColorLayerImagePanel;
373 std::vector<vtkImageData*> _images;
376 // temporary variables readding .roi file
377 int _tmpReadFileImageDim[3];
378 double _tmpReadFileImageSpac[3];
379 int _tmpReadFileTypeOfTransformation;
380 void readDimSpc(FILE *pFile, bool interactiveOption);
383 /*DECLARE_CLASS(wxContourMainFrame)
384 // any class wishing to process wxWindows events must use this macro
385 DECLARE_EVENT_TABLE()*/
386 bool _creatingContoursActive;
387 ////////JCP 21 - 11 - 08
388 void createContour( int typeContour );
389 //manualContourModel * factoryManualContourModel(int typeContour);
390 manualBaseModel * factoryManualContourModel(wxPanel* panel);
391 ContourExtractData *_contourextractdata;
394 void loadState(std::string filename);
396 // void loadContours( FILE *pFile, bool staticContour );
398 void saveFileWithContours( std::string filename );
399 void onLoadContours(std::string fileNameContourROI, bool interactiveInterface);
400 void SetZForAllContours(int pz);
404 std::string stundoredo;
407 //CMRU 17-08-09-----------------------------------------------------------------------------------------------
409 wxPanel *calibrationPanel;
410 wxPanel *calibrationPanelError;
411 double _onePixelSize;
412 std::string _imageLocation;
413 std::string _fileLocation;
414 //------------------------------------------------------------------------------------------------------------
416 wxFrame *_frameShowResultImages;