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"
100 #include "vtkCamera.h"
101 #include "vtkImageActor.h"
102 #include <vtkImageMapToColors.h>
103 #include <vtkLookupTable.h>
104 #include <vtkCommand.h>
106 //#include "vtkMetaImageReader.h"
108 //------------------------------------------------------------------------------------------------------------
109 // Events declaration
110 //------------------------------------------------------------------------------------------------------------
112 //BEGIN_DECLARE_EVENT_TYPES()
113 //END_DECLARE_EVENT_TYPES()
115 /** file wxContourMainFrame.h */
118 //------------------------------------------------------------------------------------------------------------
120 //------------------------------------------------------------------------------------------------------------
121 class interfMainPanel;
122 class wxContourMainFrame : public wxPanel {
126 //------------------------------------------------------------------------------------------------------------
127 // Constructors & Destructors
128 //------------------------------------------------------------------------------------------------------------
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/");
134 ~wxContourMainFrame();
136 //------------------------------------------------------------------------------------------------------------
137 // Creational and initialization methods
138 //------------------------------------------------------------------------------------------------------------
140 void setVectImages(std::vector<vtkImageData*> imgs);
142 bool configurePanels( );
144 bool addNewPanel(wxPanel* panel);
146 wxAuiNotebook * createNotebook();
148 void createInstantChooserPanel(wxAuiNotebook * parent);
150 void createViewPanel(wxAuiNotebook * parent);
152 void createInstantChooserPanel(wxWindow * parent);
154 void createViewPanel(wxWindow * parent);
156 void setInstantChooserPanel( wxInstantChooserPanel * theInstantChooserPanel );
158 void getMaskValue(vtkImageData ** mask,vtkImageData ** value,int typeContourGroup, int selection, int minZ, int maxZ);
160 void SaveImageResult(std::string directory,std::string namefile, vtkImageData* mask,vtkImageData* value);
162 void ShowToolsPanel(bool show);
165 ////------------------------------------------------------------------------------------------------------------
166 //// Methods for capturing events
167 ////------------------------------------------------------------------------------------------------------------
170 ////------------------------------------------------------------------------------------------------------------
171 //// Model management methods
172 ////------------------------------------------------------------------------------------------------------------
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/");
179 static wxContourMainFrame* getInstance();
180 static void resetInstance();
182 //------------------------------------------------------------------------------------------------------------
183 // Other functional methods
184 //------------------------------------------------------------------------------------------------------------
187 ** This method returns the vector of images selected by the user
188 ** return value std::vector<vtkImageData*>
190 std::vector<vtkImageData*> getVectImages();
193 ** This methods connect the event in the class interfMainPanel with the world of the appli
195 void onCreateContourSpline( );
196 void onCreateContourRectangle( );
197 void onCreateContourCircle( );
198 void onCreateContourLine( );
199 void onCreateContourPoints( );
200 void onCreateContourPolygon( );
201 void onCreateContourBullEye(wxPanel* pan);
202 /////////////////////////////////
203 void onDeleteContour();
204 void deleteContours( std::vector<std::string> keyNamesVector );
205 void deleteContour( std::string theKeyName );
206 void onDeleteContoursActSlice();
207 void onDeleteAllContours();
208 void deleteAllContours();
209 void setConceptValue( std::string name, int value );
210 ConceptDataWrap* getLastConceptData();
211 bool getIfConceptCheckedAt( std::string name, int pos );
213 void changeInstant();
215 int getNamesWrappingSize();
217 std::string getNameWrapping(int i);
219 void updateInstantOutlines();
220 void updateInstantImageData();
221 void updateInstantAxes();
223 void onChangeDeep(int val);
225 ///////////////////////////
230 void createCopyContourOf ( std::string anExistingKName, std::vector<int> &instantNoTouchData, bool append );
231 void createMirrorContourOf ( std::string anExistingKName, std::vector<int> &instantNoTouchData, bool append );
232 ///////////////////////7
237 void openContours( FILE *pFile, FILE *pFileData, bool staticContour );
239 void RefreshInterface();
241 vtkImageData* getImageData();
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);
253 void referenceLine();
256 void refLineChangeWidth(int width);
262 void FlipContours(int typeContourFlip, int flipDirection);
263 void FlipSelectedContours(int flipDirection);
264 void FlipActualSliceContours(int flipDirection);
265 void FlipAllContours(int flipDirection);
266 void FlipLstOfContours(std::vector<std::string> lstNameThings, int flipDirection);
269 //====================================================================================================
271 void showAxis(bool show);
272 void onRigidPressed();
273 void onWidthOfContour(double width);
274 int getColorWindow();
275 int getWindowLevel();
276 void onBrigthnessColorWindowLevel(int colorwindow,int windowlevel);
277 void onInterpolation(bool interpolate);
278 void onChangeInstant(std::string name,int actual);
281 void onSpreadAddAll();
282 void onSpreadGo(int type);
283 void getInstantVector(std::vector<int>& tempVector);
284 std::vector<std::string> getOutlinesName(int slide);
288 // @param typeContourGroup - int The operation id (AND,OR,XOR,ALL=3)
290 void onInformationContourLabels(int typeContourGroup,int selection,int minimumZ,int maximumZ,int grayRangeMin, int grayRangeMax);
291 void onSaveResults(std::string directory,std::string namefile, std::string filename,
292 int typeContourGroup, int selection, int minZ, int maxZ, bool XYZValues, bool contourImage, bool statistics);
293 void SaveValuesXYZ(std::string directory,std::string namefile, int typeContourGroup);
294 void onChangeInstantInstantPanel(std::string name,int value, int minshow, int maxshow);
295 void onSnakePressed();
296 void saveFileWithContoursAutomatique();
297 void ShowResultImages(int typeContourGroup, int selection, int minZ, int maxZ );
298 wxPanel *getMaskImageViewPanel(wxWindow *parent);
299 void SetContourGroup(int contourGroup);
300 wxPanel *getThresholdImageViewPanel(wxWindow *parent);
301 wxPanel *getColorLayerImageViewPanel(wxWindow *parent);
304 //CMRU 17-08-09-----------------------------------------------------------------------------------------------
307 * Associates the String parameter with the contour
308 * @param label Label entered by the user
309 * @param manualBaseModel Currently selected contour
311 void onPrintLabel (wxString label, manualBaseModel* manualModel);
314 * Calculates the size of the contour received as a parameter. Uses the measure of a pixel in millimeters.
315 * @param manualBaseModel Currently selected contour
317 void onInsertCalculation(manualBaseModel* manualModel);
320 * Assigns and returns the value of a pixel in millimeters
321 @ param value Measure of the pixel in millimeters
323 double onePixelSize(double value);
326 * Returns the type of the currently selected contour
331 * Returns the size in pixels of the currently selected contour
333 double getContourSizeInPixels();
336 * Returns the currently selected contour. If no contour is selected returns NULL
338 manualBaseModel* getContour();
341 * Returns the Path of the data persistence file
343 std::string GetFileLocation();
346 * Assign a new path to the data persistence file
347 @ param newFileLocation New path of the file
349 void SetFileLocation(std::string newFileLocation);
350 //------------------------------------------------------------------------------------------------------------
352 void SetScalarRange(int grayRangeMin, int grayRangeMax);
354 //------------------------------------------------------------------------------------------------------------
357 //------------------------------------------------------------------------------------------------------------
359 //------------------------------------------------------------------------------------------------------------
362 //------------------------------------------------------------------------------------------------------------
364 //------------------------------------------------------------------------------------------------------------
367 static wxContourMainFrame *instance;
368 KernelManagerContour *kernelManager;
369 interfMainPanel *_pannew;
370 PerformingOperation *_performingOperation;
371 std::string _datadir;
372 wxContourViewPanel *_theViewPanel;
373 wxInstantChooserPanel *_instantPanel;
375 //AD: 03-09: This attributes represents the reference line that is going to be used for the mirroring
376 manualLineControler *_refLineControl;
377 manualContourModelLine *_refLineModel;
378 manualViewLine *_refLineView;
381 wxAuiNotebook *notebook;
382 long m_notebook_style;
383 long m_notebook_theme;
384 int _numberOfVariablesStatistics;
386 // Contour Image Mask
387 ThresholdImageView *_viewMaskImage;
388 ThresholdImageViewPanel *_viewMaskImagePanel;
391 ThresholdImageView *_viewThresholdImage;
392 ThresholdImageViewPanel *_viewThresholdImagePanel;
395 ColorLayerImageViewPanel *_viewColorLayerImagePanel;
396 std::vector<vtkImageData*> _images;
399 // temporary variables readding .roi file
400 int _tmpReadFileImageDim[3];
401 double _tmpReadFileImageSpac[3];
402 int _tmpReadFileTypeOfTransformation;
403 void readDimSpc(FILE *pFile, bool interactiveOption);
406 /*DECLARE_CLASS(wxContourMainFrame)
407 // any class wishing to process wxWindows events must use this macro
408 DECLARE_EVENT_TABLE()*/
409 bool _creatingContoursActive;
410 ////////JCP 21 - 11 - 08
411 void createContour( int typeContour );
412 //manualContourModel * factoryManualContourModel(int typeContour);
413 manualBaseModel * factoryManualContourModel(wxPanel* panel);
414 ContourExtractData *_contourextractdata;
417 void loadState(std::string filename);
419 // void loadContours( FILE *pFile, bool staticContour );
421 void saveFileWithContours( std::string filename );
422 void onLoadContours(std::string fileNameContourROI, bool interactiveInterface);
423 void SetZForAllContours(int pz);
427 std::string stundoredo;
430 //CMRU 17-08-09-----------------------------------------------------------------------------------------------
432 wxPanel *calibrationPanel;
433 wxPanel *calibrationPanelError;
434 double _onePixelSize;
435 std::string _imageLocation;
436 std::string _fileLocation;
437 //------------------------------------------------------------------------------------------------------------