1 #ifndef __wxContourMainFrame_h_INCLUDED_H__
2 #define __wxContourMainFrame_h_INCLUDED_H__
5 // -----------------------------------------------------------------------------------------------------------
6 // WX headers inclusion.
7 // For compilers that support precompilation, includes <wx/wx.h>.
8 // -----------------------------------------------------------------------------------------------------------
10 #include <wx/wxprec.h>
19 //------------------------------------------------------------------------------------------------------------
21 //------------------------------------------------------------------------------------------------------------
22 #include "wx/aui/aui.h"
24 #include "interfMainPanel.h"
25 #include "KernelManagerContour.h"
27 //#include "wxVtkBaseView_SceneManager.h"
28 #include "wxInstantChooserPanel.h"
29 #include "wxContourViewPanel.h"
31 //#include "ContourWorkspace.h"
32 #include "ContourExtractData.h"
33 #include "PerformingOperation.h"
35 #include "manualLineControler.h"
36 #include "manualContourModelLine.h"
37 #include "manualViewLine.h"
39 #include "ThresholdImageView.h"
40 #include "ThresholdImageViewPanel.h"
41 #include "ColorLayerImageView.h"
42 #include "ColorLayerImageViewPanel.h"
47 #include "itkGeodesicActiveContourLevelSetImageFilter.h"
49 #include "itkCurvatureAnisotropicDiffusionImageFilter.h"
50 #include "itkGradientMagnitudeRecursiveGaussianImageFilter.h"
51 #include "itkSigmoidImageFilter.h"
52 #include "itkFastMarchingImageFilter.h"
53 #include "itkRescaleIntensityImageFilter.h"
54 #include "itkBinaryThresholdImageFilter.h"
55 #include "itkZeroCrossingImageFilter.h"
56 #include "itkCastImageFilter.h"
58 #include "itkImageFileWriter.h"
60 #include "itkImageToVTKImageFilter.h"
61 #include "itkVTKImageToImageFilter.h"
64 #include <vtkImageSeedConnectivity.h>
65 #include <vtkImageMarchingCubes.h>
66 #include "vtkContourFilter.h"
67 #include "vtkMarchingContourFilter.h"
68 #include "vtkPolyDataConnectivityFilter.h"
69 #include "vtkCleanPolyData.h"
70 #include "vtkImageReslice.h"
71 #include "vtkMetaImageWriter.h"
72 #include "vtkImageData.h"
73 #include "vtkTransform.h"
75 #include "vtkCamera.h"
76 #include "vtkImageActor.h"
77 #include <vtkImageMapToColors.h>
78 #include <vtkLookupTable.h>
79 #include <vtkCommand.h>
81 //#include "vtkMetaImageReader.h"
83 //------------------------------------------------------------------------------------------------------------
85 //------------------------------------------------------------------------------------------------------------
87 //BEGIN_DECLARE_EVENT_TYPES()
88 //END_DECLARE_EVENT_TYPES()
90 /** file wxContourMainFrame.h */
93 //------------------------------------------------------------------------------------------------------------
95 //------------------------------------------------------------------------------------------------------------
96 class interfMainPanel;
97 class wxContourMainFrame : public wxPanel {
101 //------------------------------------------------------------------------------------------------------------
102 // Constructors & Destructors
103 //------------------------------------------------------------------------------------------------------------
106 wxContourMainFrame(wxWindow* parent, wxWindowID id,const wxString& title,const wxPoint& pos,const wxSize& size,long style = wxDEFAULT_FRAME_STYLE | wxSUNKEN_BORDER);
107 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/");
109 ~wxContourMainFrame();
111 //------------------------------------------------------------------------------------------------------------
112 // Creational and initialization methods
113 //------------------------------------------------------------------------------------------------------------
115 void setVectImages(std::vector<vtkImageData*> imgs);
117 bool configurePanels( );
119 bool addNewPanel(wxPanel* panel);
121 wxAuiNotebook * createNotebook();
123 void createInstantChooserPanel(wxAuiNotebook * parent);
125 void createViewPanel(wxAuiNotebook * parent);
127 void createInstantChooserPanel(wxWindow * parent);
129 void createViewPanel(wxWindow * parent);
131 void setInstantChooserPanel( wxInstantChooserPanel * theInstantChooserPanel );
133 void getMaskValue(vtkImageData ** mask,vtkImageData ** value,int typeContourGroup, int selection, int minZ, int maxZ);
135 void SaveImageResult(std::string directory,std::string namefile, vtkImageData* mask,vtkImageData* value);
137 void ShowToolsPanel(bool show);
140 ////------------------------------------------------------------------------------------------------------------
141 //// Methods for capturing events
142 ////------------------------------------------------------------------------------------------------------------
145 ////------------------------------------------------------------------------------------------------------------
146 //// Model management methods
147 ////------------------------------------------------------------------------------------------------------------
150 //------------------------------------------------------------------------------------------------------------
151 // Attributes getters and setters
152 //------------------------------------------------------------------------------------------------------------
153 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/");
154 static wxContourMainFrame* getInstance();
155 static void resetInstance();
157 //------------------------------------------------------------------------------------------------------------
158 // Other functional methods
159 //------------------------------------------------------------------------------------------------------------
162 ** This method returns the vector of images selected by the user
163 ** return value std::vector<vtkImageData*>
165 std::vector<vtkImageData*> getVectImages();
168 ** This methods connect the event in the class interfMainPanel with the world of the appli
170 void onCreateContourSpline( );
171 void onCreateContourRectangle( );
172 void onCreateContourCircle( );
173 void onCreateContourLine( );
174 void onCreateContourPoints( );
175 void onCreateContourPolygon( );
176 void onCreateContourBullEye(wxPanel* pan);
177 /////////////////////////////////
178 void onDeleteContour();
179 void deleteContours( std::vector<std::string> keyNamesVector );
180 void deleteContour( std::string theKeyName );
181 void onDeleteContoursActSlice();
182 void onDeleteAllContours();
183 void deleteAllContours();
184 void setConceptValue( std::string name, int value );
185 ConceptDataWrap* getLastConceptData();
186 bool getIfConceptCheckedAt( std::string name, int pos );
188 void changeInstant();
190 int getNamesWrappingSize();
192 std::string getNameWrapping(int i);
194 void updateInstantOutlines();
195 void updateInstantImageData();
196 void updateInstantAxes();
198 void onChangeDeep(int val);
200 ///////////////////////////
205 void createCopyContourOf ( std::string anExistingKName, std::vector<int> &instantNoTouchData, bool append );
206 void createMirrorContourOf ( std::string anExistingKName, std::vector<int> &instantNoTouchData, bool append );
207 ///////////////////////7
212 void openContours( FILE *pFile, FILE *pFileData, int version, bool staticContour );
214 void RefreshInterface();
216 vtkImageData* getImageData();
218 void onSegmentationOneSlice(int isovalue,int sampling,int method);
219 void onSegmentationOneSliceITK(wxString distance, wxString sigma, wxString alfa, wxString beta, wxString propagation, wxString iterations, wxString inflation);
220 void SegmentationOneSlice( int x, int y, int z, int isovalue, int sampling, int method );
221 void SegmentationOneSliceITK(int x, int y, int z, wxString distance, wxString sigma, wxString alfa, wxString beta, wxString propagation, wxString iterations, wxString inflation);
222 void Mirror( int x, int y, int z, int isovalue, int sampling, int method );
223 int GetImageDataSizeZ();
224 void GetImageDataRange(double *range);
225 void onSegmentationAllSlice(int minZ,int maxZ,int isovalue,int sampling,int method);
228 void referenceLine();
231 void refLineChangeWidth(int width);
237 //====================================================================================================
239 void showAxis(bool show);
240 void onRigidPressed();
241 void onWidthOfContour(double width);
242 int getColorWindow();
243 int getWindowLevel();
244 void onBrigthnessColorWindowLevel(int colorwindow,int windowlevel);
245 void onInterpolation(bool interpolate);
246 void onChangeInstant(std::string name,int actual);
249 void onSpreadGo(int type);
250 void getInstantVector(std::vector<int>& tempVector);
251 std::vector<std::string> getOutlinesName(int slide);
255 // @param typeContourGroup - int The operation id (AND,OR,XOR,ALL=3)
257 void onInformationContourLabels(int typeContourGroup,int selection,int minimumZ,int maximumZ,int grayRangeMin, int grayRangeMax);
258 void onSaveResults(std::string directory,std::string namefile, std::string filename,
259 int typeContourGroup, int selection, int minZ, int maxZ, bool XYZValues, bool contourImage, bool statistics);
260 void SaveValuesXYZ(std::string directory,std::string namefile, int typeContourGroup);
261 void onChangeInstantInstantPanel(std::string name,int value, int minshow, int maxshow);
262 void onSnakePressed();
263 void saveFileWithContoursAutomatique();
264 void ShowResultImages(int typeContourGroup, int selection, int minZ, int maxZ );
265 wxPanel *getMaskImageViewPanel(wxWindow *parent);
266 void SetContourGroup(int contourGroup);
267 wxPanel *getThresholdImageViewPanel(wxWindow *parent);
268 wxPanel *getColorLayerImageViewPanel(wxWindow *parent);
271 //CMRU 17-08-09-----------------------------------------------------------------------------------------------
274 * Associates the String parameter with the contour
275 * @param label Label entered by the user
276 * @param manualBaseModel Currently selected contour
278 void onPrintLabel (wxString label, manualBaseModel* manualModel);
281 * Calculates the size of the contour received as a parameter. Uses the measure of a pixel in millimeters.
282 * @param manualBaseModel Currently selected contour
284 void onInsertCalculation(manualBaseModel* manualModel);
287 * Assigns and returns the value of a pixel in millimeters
288 @ param value Measure of the pixel in millimeters
290 double onePixelSize(double value);
293 * Returns the type of the currently selected contour
298 * Returns the size in pixels of the currently selected contour
300 double getContourSizeInPixels();
303 * Returns the currently selected contour. If no contour is selected returns NULL
305 manualBaseModel* getContour();
308 * Returns the Path of the data persistence file
310 std::string GetFileLocation();
313 * Assign a new path to the data persistence file
314 @ param newFileLocation New path of the file
316 void SetFileLocation(std::string newFileLocation);
317 //------------------------------------------------------------------------------------------------------------
319 void SetScalarRange(int grayRangeMin, int grayRangeMax);
321 //------------------------------------------------------------------------------------------------------------
324 //------------------------------------------------------------------------------------------------------------
326 //------------------------------------------------------------------------------------------------------------
329 //------------------------------------------------------------------------------------------------------------
331 //------------------------------------------------------------------------------------------------------------
334 static wxContourMainFrame* instance;
335 KernelManagerContour* kernelManager;
336 interfMainPanel* _pannew;
337 PerformingOperation* _performingOperation;
338 std::string _datadir;
339 wxContourViewPanel* _theViewPanel;
340 wxInstantChooserPanel * _instantPanel;
342 //AD: 03-09: This attributes represents the reference line that is going to be used for the mirroring
343 manualLineControler * _refLineControl;
344 manualContourModelLine * _refLineModel;
345 manualViewLine * _refLineView;
348 wxAuiNotebook * notebook;
349 long m_notebook_style;
350 long m_notebook_theme;
351 int _numberOfVariablesStatistics;
353 // Contour Image Mask
354 ThresholdImageView *_viewMaskImage;
355 ThresholdImageViewPanel *_viewMaskImagePanel;
358 ThresholdImageView *_viewThresholdImage;
359 ThresholdImageViewPanel *_viewThresholdImagePanel;
362 ColorLayerImageView *_viewColorLayerImage;
363 ColorLayerImageViewPanel *_viewColorLayerImagePanel;
364 std::vector<vtkImageData*> _images;
367 /*DECLARE_CLASS(wxContourMainFrame)
368 // any class wishing to process wxWindows events must use this macro
369 DECLARE_EVENT_TABLE()*/
370 bool _creatingContoursActive;
371 ////////JCP 21 - 11 - 08
372 void createContour( int typeContour );
373 //manualContourModel * factoryManualContourModel(int typeContour);
374 manualBaseModel * factoryManualContourModel(wxPanel* panel);
375 ContourExtractData *_contourextractdata;
378 void loadState(std::string filename);
379 void loadContours( FILE *pFile, bool staticContour );
380 void saveFileWithContours( std::string filename );
381 void onLoadContours(std::string fileNameContourROI);
385 std::string stundoredo;
388 //CMRU 17-08-09-----------------------------------------------------------------------------------------------
390 wxPanel *calibrationPanel;
391 wxPanel *calibrationPanelError;
392 double _onePixelSize;
393 std::string _imageLocation;
394 std::string _fileLocation;
395 //------------------------------------------------------------------------------------------------------------