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 //EED #include "ColorLayerImageView.h"
42 //EED #include "ColorLayerImageViewPanel.h"
45 //#include "ContourThing.h"
46 //#include "AxeThing.h"
47 //#include "ImageSourceThing.h"
48 //#include "ImageSectionThing.h"
49 //#include "InstantMembersNameList.h"
50 //#include "OutlineGroup.h"
51 //#include "SomeEnvironment.h"
52 //#include "ContourWorkspace.h"
53 //#include "ContourWrap_ViewControl.h"
54 //#include "Instant.h"
55 //#include "PerformingOperation.h"
57 //#include "ContourThing.h"
59 //#include "OutlineModelManager.h"
61 //#include "wxContour_ButtonsBar.h"
62 //#include "wxContour_ControlPanel.h"
64 //#include "wxContour_Grid.h"
65 //#include "wxContour_DrawToolsPanel.h"
66 //#include "wxContour_OperationsToolsPanel.h"
67 //#include "wxContour_AutomaticFormsToolsPanel.h"
68 //#include "wxContour_StandardToolsPanel.h"
69 //#include "wxContour_EdtionToolsPanel.h"
70 //#include "wxContour_ListViewPanel.h"
75 #include "itkGeodesicActiveContourLevelSetImageFilter.h"
77 #include "itkCurvatureAnisotropicDiffusionImageFilter.h"
78 #include "itkGradientMagnitudeRecursiveGaussianImageFilter.h"
79 #include "itkSigmoidImageFilter.h"
80 #include "itkFastMarchingImageFilter.h"
81 #include "itkRescaleIntensityImageFilter.h"
82 #include "itkBinaryThresholdImageFilter.h"
83 #include "itkZeroCrossingImageFilter.h"
84 #include "itkCastImageFilter.h"
86 #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"
103 #include "vtkCamera.h"
104 #include "vtkImageActor.h"
105 #include <vtkImageMapToColors.h>
106 #include <vtkLookupTable.h>
107 #include <vtkCommand.h>
109 //#include "vtkMetaImageReader.h"
111 //------------------------------------------------------------------------------------------------------------
112 // Events declaration
113 //------------------------------------------------------------------------------------------------------------
115 //BEGIN_DECLARE_EVENT_TYPES()
116 //END_DECLARE_EVENT_TYPES()
118 /** file wxContourMainFrame.h */
121 //------------------------------------------------------------------------------------------------------------
123 //------------------------------------------------------------------------------------------------------------
124 class interfMainPanel;
125 class wxContourMainFrame : public wxPanel {
129 //------------------------------------------------------------------------------------------------------------
130 // Constructors & Destructors
131 //------------------------------------------------------------------------------------------------------------
134 wxContourMainFrame(wxWindow* parent, wxWindowID id,const wxString& title,const wxPoint& pos,const wxSize& size,long style = wxDEFAULT_FRAME_STYLE | wxSUNKEN_BORDER);
135 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/");
137 ~wxContourMainFrame();
139 //------------------------------------------------------------------------------------------------------------
140 // Creational and initialization methods
141 //------------------------------------------------------------------------------------------------------------
143 void setVectImages(std::vector<vtkImageData*> imgs);
145 bool configurePanels( );
147 bool addNewPanel(wxPanel* panel);
149 wxAuiNotebook * createNotebook();
151 void createInstantChooserPanel(wxAuiNotebook * parent);
153 void createViewPanel(wxAuiNotebook * parent);
155 void createInstantChooserPanel(wxWindow * parent);
157 void createViewPanel(wxWindow * parent);
159 void setInstantChooserPanel( wxInstantChooserPanel * theInstantChooserPanel );
161 void getMaskValue(vtkImageData ** mask,vtkImageData ** value,int typeContourGroup, int selection, int minZ, int maxZ);
163 void SaveImageResult(std::string directory,std::string namefile, vtkImageData* mask,vtkImageData* value);
165 void ShowToolsPanel(bool show);
168 // void setButtonsBar( wxContour_ButtonsBar * theButtonsBar );
169 // void setGrid( wxContour_Grid * theGridPanel );
170 // void setDrawToolsPanel( wxContour_DrawToolsPanel * theDrawToolsPanel );
171 // void setOperationsToolsPanel( wxContour_OperationsToolsPanel * theDrawToolsPanel );
172 // void setAutomaticFormsPanel( wxContour_AutomaticFormsToolsPanel * theAutoFormsPanel );
173 // void setStandardToolsPanel( wxContour_StandardToolsPanel * theStandardToolsPanel );
174 // void setEditionToolsPanel( wxContour_EdtionToolsPanel * theEditionToolsPanel );
175 // void setListViewPanel( wxContour_ListViewPanel * theListViewPanel );
178 ////------------------------------------------------------------------------------------------------------------
179 //// Methods for capturing events
180 ////------------------------------------------------------------------------------------------------------------
183 ////------------------------------------------------------------------------------------------------------------
184 //// Model management methods
185 ////------------------------------------------------------------------------------------------------------------
188 //------------------------------------------------------------------------------------------------------------
189 // Attributes getters and setters
190 //------------------------------------------------------------------------------------------------------------
191 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/");
192 static wxContourMainFrame* getInstance();
193 static void resetInstance();
195 //------------------------------------------------------------------------------------------------------------
196 // Other functional methods
197 //------------------------------------------------------------------------------------------------------------
200 ** This method returns the vector of images selected by the user
201 ** return value std::vector<vtkImageData*>
203 std::vector<vtkImageData*> getVectImages();
206 ** This methods connect the event in the class interfMainPanel with the world of the appli
208 void onCreateContourSpline( );
209 void onCreateContourRectangle( );
210 void onCreateContourCircle( );
211 void onCreateContourLine( );
212 void onCreateContourPoints( );
213 void onCreateContourPolygon( );
214 void onCreateContourBullEye(wxPanel* pan);
215 /////////////////////////////////
216 void onDeleteContour();
217 void deleteContours( std::vector<std::string> keyNamesVector );
218 void deleteContour( std::string theKeyName );
219 void onDeleteContoursActSlice();
220 void onDeleteAllContours();
221 void deleteAllContours();
222 void setConceptValue( std::string name, int value );
223 ConceptDataWrap* getLastConceptData();
224 bool getIfConceptCheckedAt( std::string name, int pos );
226 void changeInstant();
228 int getNamesWrappingSize();
230 std::string getNameWrapping(int i);
232 void updateInstantOutlines();
233 void updateInstantImageData();
234 void updateInstantAxes();
236 void onChangeDeep(int val);
238 ///////////////////////////
243 void createCopyContourOf ( std::string anExistingKName, std::vector<int> &instantNoTouchData, bool append );
244 void createMirrorContourOf ( std::string anExistingKName, std::vector<int> &instantNoTouchData, bool append );
245 ///////////////////////7
250 void openContours( FILE *pFile, FILE *pFileData, int version, bool staticContour );
252 void RefreshInterface();
254 vtkImageData* getImageData();
256 void onSegmentationOneSlice(int isovalue,int sampling,int method);
257 void onSegmentationOneSliceITK(wxString distance, wxString sigma, wxString alfa, wxString beta, wxString propagation, wxString iterations, wxString inflation);
258 void SegmentationOneSlice( int x, int y, int z, int isovalue, int sampling, int method );
259 void SegmentationOneSliceITK(int x, int y, int z, wxString distance, wxString sigma, wxString alfa, wxString beta, wxString propagation, wxString iterations, wxString inflation);
260 void Mirror( int x, int y, int z, int isovalue, int sampling, int method );
261 int GetImageDataSizeZ();
262 void GetImageDataRange(double *range);
263 void onSegmentationAllSlice(int minZ,int maxZ,int isovalue,int sampling,int method);
266 void referenceLine();
269 void refLineChangeWidth(int width);
275 //====================================================================================================
277 void showAxis(bool show);
279 void onRigidPressed();
281 void onWidthOfContour(double width);
283 int getColorWindow();
284 int getWindowLevel();
286 void onBrigthnessColorWindowLevel(int colorwindow,int windowlevel);
288 void onInterpolation(bool interpolate);
290 void onChangeInstant(std::string name,int actual);
296 void onSpreadGo(int type);
298 void getInstantVector(std::vector<int>& tempVector);
300 std::vector<std::string> getOutlinesName(int slide);
304 // @param typeContourGroup - int The operation id (AND,OR,XOR,ALL=3)
306 void onInformationContourLabels(int typeContourGroup,int selection,int minimumZ,int maximumZ,int grayRangeMin, int grayRangeMax);
308 void onSaveResults(std::string directory,std::string namefile, std::string filename,
309 int typeContourGroup, int selection, int minZ, int maxZ, bool XYZValues, bool contourImage, bool statistics);
311 void SaveValuesXYZ(std::string directory,std::string namefile, int typeContourGroup);
315 void onChangeInstantInstantPanel(std::string name,int value, int minshow, int maxshow);
317 void onSnakePressed();
319 void saveFileWithContoursAutomatique();
321 void ShowResultImages(int typeContourGroup, int selection, int minZ, int maxZ );
323 wxPanel *getMaskImageViewPanel(wxWindow *parent);
324 void SetContourGroup(int contourGroup);
325 wxPanel *getThresholdImageViewPanel(wxWindow *parent);
326 wxPanel *getColorLayerImageViewPanel(wxWindow *parent);
329 //CMRU 17-08-09-----------------------------------------------------------------------------------------------
332 * Associates the String parameter with the contour
333 * @param label Label entered by the user
334 * @param manualBaseModel Currently selected contour
336 void onPrintLabel (wxString label, manualBaseModel* manualModel);
339 * Calculates the size of the contour received as a parameter. Uses the measure of a pixel in millimeters.
340 * @param manualBaseModel Currently selected contour
342 void onInsertCalculation(manualBaseModel* manualModel);
345 * Assigns and returns the value of a pixel in millimeters
346 @ param value Measure of the pixel in millimeters
348 double onePixelSize(double value);
351 * Returns the type of the currently selected contour
356 * Returns the size in pixels of the currently selected contour
358 double getContourSizeInPixels();
361 * Returns the currently selected contour. If no contour is selected returns NULL
363 manualBaseModel* getContour();
366 * Returns the Path of the data persistence file
368 std::string GetFileLocation();
371 * Assign a new path to the data persistence file
372 @ param newFileLocation New path of the file
374 void SetFileLocation(std::string newFileLocation);
375 //------------------------------------------------------------------------------------------------------------
377 void SetScalarRange(int grayRangeMin, int grayRangeMax);
379 //------------------------------------------------------------------------------------------------------------
382 //------------------------------------------------------------------------------------------------------------
384 //------------------------------------------------------------------------------------------------------------
387 //------------------------------------------------------------------------------------------------------------
389 //------------------------------------------------------------------------------------------------------------
393 static wxContourMainFrame* instance;
395 KernelManagerContour* kernelManager;
397 interfMainPanel* _pannew;
399 PerformingOperation* _performingOperation;
401 std::string _datadir;
403 wxContourViewPanel* _theViewPanel;
405 wxInstantChooserPanel * _instantPanel;
407 //AD: 03-09: This attributes represents the reference line that is going to be used for the mirroring
408 manualLineControler * _refLineControl;
409 manualContourModelLine * _refLineModel;
410 manualViewLine * _refLineView;
415 wxAuiNotebook * notebook;
417 long m_notebook_style;
418 long m_notebook_theme;
419 int _numberOfVariablesStatistics;
422 // Contour Image Mask
423 ThresholdImageView *_viewMaskImage;
424 ThresholdImageViewPanel *_viewMaskImagePanel;
427 ThresholdImageView *_viewThresholdImage;
428 ThresholdImageViewPanel *_viewThresholdImagePanel;
431 //EED ColorLayerImageView *_viewColorLayerImage;
432 //EED ColorLayerImageViewPanel *_viewColorLayerImagePanel;
433 wxPanel *_viewColorLayerImagePanel;
435 std::vector<vtkImageData*> _images;
443 /*DECLARE_CLASS(wxContourMainFrame)
444 // any class wishing to process wxWindows events must use this macro
445 DECLARE_EVENT_TABLE()*/
446 bool _creatingContoursActive;
447 ////////JCP 21 - 11 - 08
448 void createContour( int typeContour );
450 //manualContourModel * factoryManualContourModel(int typeContour);
452 manualBaseModel * factoryManualContourModel(wxPanel* panel);
454 ContourExtractData *_contourextractdata;
458 void loadState(std::string filename);
459 void loadContours( FILE *pFile, bool staticContour );
461 void saveFileWithContours( std::string filename );
462 void onLoadContours(std::string fileNameContourROI);
466 std::string stundoredo;
471 //CMRU 17-08-09-----------------------------------------------------------------------------------------------
473 wxPanel *calibrationPanel;
474 wxPanel *calibrationPanelError;
475 double _onePixelSize;
476 std::string _imageLocation;
477 std::string _fileLocation;
478 //------------------------------------------------------------------------------------------------------------