]> Creatis software - creaContours.git/blob - lib/Interface_Icons_NDimensions/interfMainPanel.cxx
1597c26c53b792ccd2911433fc98801b3f4d206a
[creaContours.git] / lib / Interface_Icons_NDimensions / interfMainPanel.cxx
1 #include "interfMainPanel.h"
2
3 /*
4 #include "interfNewContourMenu.h"
5 #include "interfIOMenu.h"
6 #include "interfEditMenu.h"
7 #include "interfDeleteMenu.h"
8 #include "interfToolsMenu.h"
9 #include "interfToolsSpreadPanel.h"
10 #include "interfMenuBar.h"
11 #include "interfSegmentationMenu.h"
12 */
13
14 interfMainPanel* interfMainPanel::interfmainpanel=NULL;
15 wxFrame* interfMainPanel::_newframe=NULL;
16
17 interfMainPanel::interfMainPanel(wxWindow * parent, int sizex, int sizey, wxEvtHandler * evtHandler, std::string datadir)
18 : wxPanel(parent, -1, wxDefaultPosition, wxSize(sizex, sizey), wxBORDER_SUNKEN)
19 {
20
21         PANEL = "New Contour";
22         PANEL1 = "I/O";
23         PANEL2 = "Edit";
24         PANEL3 = "Delete";
25         PANEL4 = "Tools";  
26         PANEL5 = "Segmentation";
27         segmentPanel = NULL;
28         segmentPanelITK = NULL;
29         configPanel = NULL;
30         spreadPanel = NULL;
31         infoWin = NULL;
32         informationPanel = NULL;
33         mirrorPanel = NULL;
34         thresholdPanel = NULL;
35         currentWindow = NULL;
36         
37         splitterwindow = new wxSplitterWindow(this,-1, wxDefaultPosition, wxSize(sizex, sizey), wxSP_3DSASH, wxString(_T("")));
38
39         splitterwindow->SetMinimumPaneSize( 10 );
40         sizey = sizey/8;
41
42         wxPanel* toolpanel = new wxPanel(splitterwindow, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
43
44         wxFlexGridSizer* flexsizer = new wxFlexGridSizer(6,2,1,1);      
45         toolpanel->SetSizer(flexsizer, true);
46         toolpanel->SetAutoLayout( true );
47
48         wxButton* b = getButton(toolpanel);
49         b->SetClientData(&PANEL);
50         wxButton* b1 = getButton(toolpanel);
51         b1->SetClientData(&PANEL1);
52         wxButton* b2 = getButton(toolpanel);
53         b2->SetClientData(&PANEL2);
54         wxButton* b3 = getButton(toolpanel);
55         b3->SetClientData(&PANEL3);
56         wxButton* b4 = getButton(toolpanel);
57         b4->SetClientData(&PANEL4);
58         wxButton* b5 = getButton(toolpanel);
59         b5->SetClientData(&PANEL5);
60
61         wxPanel* mentex = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
62         wxPanel* mentex1 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
63         wxPanel* mentex2 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
64         wxPanel* mentex3 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
65         wxPanel* mentex4 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
66         wxPanel* mentex5 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
67         
68         menubar = new interfNewContourMenu(mentex, sizex, sizey, evtHandler, datadir);          
69         menubar1 = new interfIOMenu(mentex1, sizex, sizey, evtHandler, datadir);        
70         menubar2 = new interfEditMenu(mentex2, sizex, sizey, evtHandler, datadir);      
71         menubar3 = new interfDeleteMenu(mentex3, sizex, sizey, evtHandler, datadir);    
72         menubar4 = new interfToolsMenu(mentex4, sizex,sizey, evtHandler, datadir);
73         menubar5 = new interfSegmentationMenu(mentex5, sizex,sizey, evtHandler, datadir);
74                 
75         statictext = getText(mentex, PANEL);    
76         statictext1 = getText(mentex1, PANEL1); 
77         statictext2 = getText(mentex2, PANEL2); 
78         statictext3 = getText(mentex3, PANEL3); 
79         statictext4 = getText(mentex4, PANEL4); 
80         statictext5 = getText(mentex5, PANEL5); 
81         
82         flexsizer->Add(b, wxFIXED_MINSIZE);
83         flexsizer->Add(setMenuTextSizer(mentex, menubar,statictext), wxFIXED_MINSIZE);
84
85         flexsizer->Add(b1, wxFIXED_MINSIZE);
86         flexsizer->Add(setMenuTextSizer(mentex1, menubar1,statictext1), wxFIXED_MINSIZE);
87         
88         flexsizer->Add(b2, wxFIXED_MINSIZE);
89         flexsizer->Add(setMenuTextSizer(mentex2, menubar2,statictext2), wxFIXED_MINSIZE);
90         
91         flexsizer->Add(b3, wxFIXED_MINSIZE);
92         flexsizer->Add(setMenuTextSizer(mentex3, menubar3,statictext3), wxFIXED_MINSIZE);
93         
94         flexsizer->Add(b4, wxFIXED_MINSIZE);
95         flexsizer->Add(setMenuTextSizer(mentex4, menubar4,statictext4), wxFIXED_MINSIZE);
96
97         flexsizer->Add(b5, wxFIXED_MINSIZE);
98         flexsizer->Add(setMenuTextSizer(mentex5, menubar5,statictext5), wxFIXED_MINSIZE);
99
100         toolpanel->Update();
101         toolpanel->Layout();
102
103         infoPanel = new wxPanel(splitterwindow, -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
104         wxFlexGridSizer* infosizer = new wxFlexGridSizer(1,1,2,2);      
105         infoPanel->SetSizer(infosizer, true);
106         infoPanel->SetAutoLayout( true );       
107                 
108         splitterwindow->Initialize(toolpanel);
109         splitterwindow->SetSashGravity(1);
110         splitterwindow->SplitHorizontally(toolpanel, infoPanel);        
111                 
112         Connect(b->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
113         Connect(b1->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
114         Connect(b2->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
115         Connect(b3->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
116         Connect(b4->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
117         Connect(b5->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
118
119         this->Layout();
120 }
121
122 interfMainPanel::~interfMainPanel(void)
123 {
124 }
125
126 interfMainPanel* interfMainPanel::getInstance(wxWindow* parent, std::string datadir, wxEvtHandler * evtHandler){        
127
128         _newframe = new wxFrame(parent, -1, wxT(" Contour Tools "), wxPoint(25,50), wxSize(350,900),wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION |  wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT);
129         
130                                                                                                                                                                                 
131         if(interfmainpanel == NULL){
132                 interfmainpanel = new interfMainPanel(_newframe, 350, 900, evtHandler, datadir);
133         }
134
135         _newframe->Show(TRUE);
136         return interfmainpanel;
137 }
138
139 interfMainPanel* interfMainPanel::getInstance(wxWindow* parent, wxEvtHandler * evtHandler){     
140
141         _newframe = new wxFrame(parent, -1, wxT(" Contour Tools "), wxPoint(25,50), wxSize(350,900),wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION |  wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT );
142
143         if(interfmainpanel == NULL){
144                 interfmainpanel = new interfMainPanel(_newframe, 350, 900, evtHandler);
145         }
146
147         _newframe->Show(TRUE);
148         return interfmainpanel;
149 }
150 bool interfMainPanel::Show(bool show){
151         return _newframe->Show(show);
152 }
153 interfMainPanel* interfMainPanel::getInstance()
154 {       
155
156         return interfmainpanel;
157 }
158
159 void interfMainPanel :: resetInstance()
160 {
161         //delete interfmainpanel;
162         delete _newframe;
163         interfmainpanel = NULL;
164 }
165
166 wxPanel* interfMainPanel::initializeToolsPanel(wxWindow* parent, int sizex, int sizey, wxEvtHandler * evtHandler){
167
168
169         wxPanel* panel = new wxPanel(parent, -1, wxDefaultPosition, wxSize(sizex, sizey), wxBORDER_SUNKEN, wxString(_T("Spread")));
170
171         wxFlexGridSizer* flexsizer = new wxFlexGridSizer(2,1,2,2)       ;
172         panel->SetSizer(flexsizer, true);
173         panel->SetAutoLayout( true );
174
175         interfToolsMenu* menu = new interfToolsMenu(panel, sizex, sizey, evtHandler);
176         toolspread = new interfToolsSpreadPanel(panel, sizex, 300, evtHandler);
177
178         flexsizer->Add(menu, wxFIXED_MINSIZE);
179         flexsizer->Add(toolspread, wxFIXED_MINSIZE);
180         
181         panel->Layout();        
182         
183
184         return panel;
185 }
186
187
188 /**
189 **      Adds a new checkbox to the scrolledwindow using the checkboxsizer
190 **      @Params id of contour
191 **      
192 **/
193 void interfMainPanel::addContourCheckBox(std::string id){
194         toolspread->addContourCheckBox(id);
195 }
196
197 /**
198 **      Removes a checkbox from the list of checkboxes in the flexsizer (checkboxsizer)
199 **      @Params id of contour
200 **      
201 **/
202 void interfMainPanel::removeContourCheckBox(std::string id){
203         toolspread->removeContourCheckBox(id);
204 }
205
206 void interfMainPanel::onActionButtonPressed1( wxCommandEvent& event ){
207         //((interfToolsMenu*)menubar4)->hideAxis();
208         wxButton* b = (wxButton*)event.GetEventObject();
209         wxPanel* dmenu;
210         wxStaticText* text;
211         std::string dstring = *((std::string*) b->GetClientData());
212         int sizechange=0;
213
214
215         if(dstring.compare(PANEL)==0){
216                 dmenu = menubar;
217                 text = statictext;
218         }else if(dstring.compare(PANEL1)==0 ){
219                 dmenu = menubar1;       
220                 text = statictext1;
221         }else if(dstring.compare(PANEL2)==0){
222                 dmenu = menubar2;
223                 text = statictext2;
224         }else if(dstring.compare(PANEL3)==0){
225                 dmenu = menubar3;
226                 text = statictext3;
227         }else if(dstring.compare(PANEL4)==0){
228                 dmenu = menubar4;
229                 text = statictext4;
230         }else if(dstring.compare(PANEL5)==0){
231                 dmenu = menubar5;
232                 text = statictext5;
233         }
234
235         if(wxStrcmp(b->GetLabel(),_T("+"))==0 ){
236                 dmenu->Show(true);
237                 sizechange = 1;
238                 b->SetLabel(_T("-"));
239         }else{
240                 dmenu->Show(false);             
241                 sizechange = -1;
242                 b->SetLabel(_T("+"));
243         }       
244         
245         sizechange *= dmenu->GetSize().GetHeight();
246         splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()+sizechange);
247         
248         this->Layout();
249         this->Refresh();
250 }
251
252 wxStaticText* interfMainPanel::getText(wxWindow* parent, std::string nom){
253         return new wxStaticText(parent, -1, wxString(nom.c_str(),wxConvUTF8), wxDefaultPosition, 
254                                                         wxDefaultSize, wxALIGN_CENTRE, wxString(nom.c_str(),wxConvUTF8));
255 }
256
257 wxButton* interfMainPanel::getButton(wxWindow* parent){
258         wxButton* b = new wxButton(parent, -1, wxString(_T("-")), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT, 
259                                                                 wxDefaultValidator, wxString(_T("-"))); 
260         return b;
261 }
262
263 wxPanel* interfMainPanel::setMenuTextSizer(wxWindow* parent, wxPanel* panel, wxStaticText* text){
264
265         wxFlexGridSizer* flexsizer = new wxFlexGridSizer(2,1,2,2);      
266         parent->SetSizer(flexsizer, true);
267         parent->SetAutoLayout( true );
268
269         flexsizer->Add(text, wxFLEX_GROWMODE_ALL);
270         flexsizer->Add(panel, wxFLEX_GROWMODE_ALL);
271
272         parent->Layout();
273         return (wxPanel*)parent;
274         
275 }
276
277 /**
278 **      Shows the panel in the 
279 **/
280 void interfMainPanel::showPanel(wxWindow* panel)
281 {
282         wxContourMainFrame::getInstance()->showAxis(false);
283         wxSizer* sizer = infoPanel->GetSizer();
284
285         if(currentWindow != NULL){
286                 currentWindow->Hide();
287                 sizer->Remove(currentWindow);
288         }       
289         sizer->Add(panel);
290     currentWindow = panel;
291         currentWindow->Show(true);
292
293         splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()+1);
294         splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()-1);
295
296         infoPanel->Layout();
297         infoPanel->Refresh();
298         this->Layout();
299         this->Refresh();
300 }
301
302 /**
303 **      Hide the panel in the lower box
304 **/
305 void interfMainPanel::hidePanel( ){
306         wxContourMainFrame::getInstance()->showAxis(false);
307         wxSizer* sizer = infoPanel->GetSizer();
308
309         if(currentWindow != NULL){
310                 currentWindow->Hide();
311                 sizer->Remove(currentWindow);
312         }
313         wxPanel * emptyPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
314         sizer->Add(emptyPanel);
315     currentWindow = emptyPanel;
316         currentWindow->Show(true);
317
318         splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()+1);
319         splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()-1);
320
321         infoPanel->Layout();
322         infoPanel->Refresh();
323         this->Layout();
324         this->Refresh();
325 }
326
327 /**
328 **      Gets the Information panel
329 **/
330 wxPanel* interfMainPanel::getInfoPanel(){
331         return infoPanel;
332 }
333
334 void interfMainPanel::onCreateContourSpline( ){
335         wxContourMainFrame::getInstance()->showAxis(false);
336         wxContourMainFrame::getInstance()->onCreateContourSpline();
337 }
338 void interfMainPanel::onCreateContourRectangle( ){
339         wxContourMainFrame::getInstance()->showAxis(false);
340     wxContourMainFrame::getInstance()->onCreateContourRectangle();
341 }
342 void interfMainPanel::onCreateContourCircle( ){
343         wxContourMainFrame::getInstance()->showAxis(false);
344     wxContourMainFrame::getInstance()->onCreateContourCircle();
345 }
346 void interfMainPanel::onCreateContourLine( ){
347         wxContourMainFrame::getInstance()->showAxis(false);
348     wxContourMainFrame::getInstance()->onCreateContourLine();
349 }
350 void interfMainPanel::onCreateContoursBullEye(wxPanel* panBull){
351         wxContourMainFrame::getInstance()->showAxis(false);
352         wxContourMainFrame::getInstance()->onCreateContourBullEye(panBull);
353 }
354 void interfMainPanel::onDeleteContour(){
355         wxContourMainFrame::getInstance()->showAxis(false);
356         wxContourMainFrame::getInstance()->onDeleteContour();
357 }
358 void interfMainPanel::onDeleteContoursActSlice(){
359         wxContourMainFrame::getInstance()->showAxis(false);
360         wxContourMainFrame::getInstance()->onDeleteContoursActSlice();
361 }
362 void interfMainPanel::onDeleteAllContours(){
363         wxContourMainFrame::getInstance()->showAxis(false);
364         wxContourMainFrame::getInstance()->onDeleteAllContours();
365 }
366
367 void interfMainPanel::onCopy(){
368         wxContourMainFrame::getInstance()->onCopy();
369 }
370 void interfMainPanel::onPaste(){
371         wxContourMainFrame::getInstance()->onPaste();
372 }
373 void interfMainPanel::onUndo(){
374         wxContourMainFrame::getInstance()->onUndo();
375 }
376 void interfMainPanel::onRedo(){
377         wxContourMainFrame::getInstance()->onRedo();
378 }
379 void interfMainPanel::onLoad(){
380         wxContourMainFrame::getInstance()->onLoad();
381 }
382 void interfMainPanel::onSave(){
383         wxContourMainFrame::getInstance()->     onSave();
384 }
385 void interfMainPanel::RefreshInterface(){
386         wxContourMainFrame::getInstance()->RefreshInterface();
387 }
388
389 vtkImageData* interfMainPanel::getImageData(){
390         return wxContourMainFrame::getInstance()->getImageData();
391 }
392
393 void interfMainPanel::getImageRange(double  range[2] )
394 {
395         vtkImageData * img = getImageData();
396         img->GetScalarRange(range);
397 }
398
399 void interfMainPanel::onSegmentationOneSlice(int isovalue,int sampling,int method)
400 {
401         wxContourMainFrame::getInstance()->onSegmentationOneSlice(isovalue, sampling, method);
402 }
403
404 void interfMainPanel::onSegmentationOneSliceITK(wxString distance, wxString sigma, wxString alfa, wxString beta, wxString propagation, wxString iterations, wxString inflation){
405         wxContourMainFrame::getInstance()->onSegmentationOneSliceITK(distance, sigma, alfa, beta, propagation, iterations, inflation);
406 }
407
408 int interfMainPanel::GetImageDataSizeZ(){
409         return wxContourMainFrame::getInstance()->GetImageDataSizeZ();
410 }
411
412 void interfMainPanel::onSegmentationAllSlice(int minZ,int maxZ,int isovalue,int sampling,int method){
413         wxContourMainFrame::getInstance()->onSegmentationAllSlice(minZ, maxZ,isovalue,sampling,method);
414 }
415
416 void interfMainPanel::setLabelSegmentationPanelVTK(wxString tmpString){ 
417     ((interfSegmentationPanelVTK*)segmentationPanel)->setLabel(tmpString);
418 }
419 void interfMainPanel::onSegmentationPressed(){
420         if(segmentPanel == NULL){
421                 segmentPanel = new wxPanel(getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
422                 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);    
423                 segmentPanel->SetSizer(flexsizer, true);
424                 segmentPanel->SetAutoLayout( true );    
425                 segmentPanel->SetEventHandler(this);
426                 
427                 //wxPanel* panel = contourevent->getSegmentationPanel(segmentPanel);
428                 segmentationPanel = new interfSegmentationPanelVTK(segmentPanel);
429         
430
431                 wxStaticText* stattext = new wxStaticText(segmentPanel, -1, wxString(_T("   Automatic Segmentation   ")), wxDefaultPosition,
432                         wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
433
434                 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
435                 flexsizer->Add(segmentationPanel, wxEXPAND);
436                 segmentPanel->Layout();
437         }
438         showPanel(segmentPanel);
439         wxContourMainFrame::getInstance()->showAxis(true);
440         axisshown = true;
441 }
442
443 void interfMainPanel::onSegmentationPressedITK(){
444     if(segmentPanelITK == NULL){
445                 segmentPanelITK = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
446                         
447
448                 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);    
449                 segmentPanelITK->SetSizer(flexsizer, true);
450                 segmentPanelITK->SetAutoLayout( true ); 
451                 //segmentPanelITK->SetEventHandler(this->contourevent);
452                 
453                 //wxPanel* panel = contourevent->getSegmentationPanelITK(segmentPanelITK);
454                 wxPanel* panel = new interfSegmentationPanelITK(segmentPanelITK);
455         
456
457                 wxStaticText* stattext = new wxStaticText(segmentPanelITK, -1, wxString(_T("   Automatic ITK Segmentation   ")), wxDefaultPosition,
458                         wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
459
460                 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
461                 flexsizer->Add(panel, wxEXPAND);
462                 segmentPanelITK->Layout();
463         }
464         showPanel(segmentPanelITK);
465         wxContourMainFrame::getInstance()->showAxis(true);
466         axisshown = true;
467 }
468
469 void interfMainPanel::onRigidPressed(){
470         wxContourMainFrame::getInstance()->onRigidPressed();
471 }
472
473 void interfMainPanel::onWidthOfContour(double width){    
474         wxContourMainFrame::getInstance()->onWidthOfContour(width);
475 }
476
477 int interfMainPanel::getColorWindow(){
478         return wxContourMainFrame::getInstance()->getColorWindow();
479 }
480 int interfMainPanel::getWindowLevel(){
481         return wxContourMainFrame::getInstance()->getWindowLevel();
482 }
483 void interfMainPanel::onBrigthnessColorWindowLevel(int colorwindow,int windowlevel){
484         wxContourMainFrame::getInstance()->onBrigthnessColorWindowLevel(colorwindow, windowlevel);
485 }
486
487 void interfMainPanel::onInterpolation(bool interpolate)
488 {
489         wxContourMainFrame::getInstance()->onInterpolation(interpolate);
490 }
491
492 void interfMainPanel::onConfigurationPressed(){
493
494         if(configPanel == NULL){
495                 configPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
496                 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);    
497                 configPanel->SetSizer(flexsizer, true);
498                 configPanel->SetAutoLayout( true );     
499                 //configPanel->SetEventHandler(this->contourevent);
500                 
501                 wxPanel* panel = new interfConfigurationPanel(configPanel);
502
503                 wxStaticText* stattext = new wxStaticText(configPanel, -1, wxString(_T("   Interface Configuration   ")), wxDefaultPosition,
504                         wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
505
506                 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
507
508                 flexsizer->Add(panel, wxEXPAND);
509                 configPanel->Layout();
510
511         }
512         showPanel(configPanel);
513 }
514
515 void interfMainPanel::onSpreadPressed(){
516     if(spreadPanel==NULL){
517
518                 spreadPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
519                 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);    
520                 spreadPanel->SetSizer(flexsizer, true);
521                 spreadPanel->SetAutoLayout( true );     
522                 //spreadPanel->SetEventHandler(this->contourevent);
523                 
524                 //wxPanel* panel = contourevent->getSpreadPanel(spreadPanel);
525                 panelSpread = new interfSpreadPanel(spreadPanel);
526         
527
528                 wxStaticText* stattext = new wxStaticText(spreadPanel, -1, wxString(_T("   Automatic Spread   ")), wxDefaultPosition,
529                         wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
530
531                 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
532                 flexsizer->Add(panelSpread, wxEXPAND);
533                 spreadPanel->Layout();
534         }       
535         showPanel(spreadPanel);
536         //hideAxis();
537 }
538
539 void interfMainPanel::resetAppend(){
540         wxContourMainFrame::getInstance()->resetAppend();
541 }
542
543 void interfMainPanel::onSpreadAdd(){
544         wxContourMainFrame::getInstance()->onSpreadAdd();
545 }
546
547 void interfMainPanel::appendStringSpread(std::string val){
548     panelSpread->appendStringSpread(val);
549 }
550
551 void interfMainPanel::onSpreadGo(int type){
552         wxContourMainFrame::getInstance()->onSpreadGo(type);
553 }
554 void interfMainPanel::setStringSpread(std::string stringtemp){
555         panelSpread->setStringSpread(stringtemp);
556 }
557
558 void interfMainPanel::onInformationPressed(){
559         if(infoWin ==NULL){
560                 infoWin                                         = new wxFrame (this, -1,_T("  Statistics  "), wxDefaultPosition, wxDefaultSize, wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION |  wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT | wxRESIZE_BORDER  );
561                 infoWin->SetSize( wxSize(825,650) );
562                 
563                 wxSize sizepanel(825,675);
564                 informationPanel                                                                        = new interfInformationPanel(infoWin);//contourevent->getInformationPanel(infoWin);
565
566                 wxBoxSizer * sizerPanel         = new wxBoxSizer(wxHORIZONTAL);
567                 sizerPanel -> Add( informationPanel     , 1, wxEXPAND ,0);
568
569                 infoWin->SetSizer( sizerPanel );
570                 infoWin->SetAutoLayout( true );
571                 infoWin->Layout();
572
573                 infoWin->Show();
574
575         }else {
576
577                 if (infoWin->IsShown()==true)
578                 {
579                         infoWin->Show(false);
580                 } else  {
581                         //contourevent->FillGridWithContoursInformation();
582                         infoWin->Show(true);
583                 }
584         }       
585 }
586
587 void interfMainPanel::getInstantVector(std::vector<int>& tempVector){
588         wxContourMainFrame::getInstance()->getInstantVector(tempVector);
589 }
590
591 std::vector<std::string> interfMainPanel::getOutlinesName(int slide){
592         return wxContourMainFrame::getInstance()->getOutlinesName(slide);
593 }
594
595 void interfMainPanel::onInformationContourLabels(int typeContourGroup,int selection,int minZ,int maxZ,int grayRangeMin,int grayRangeMax){
596         wxContourMainFrame::getInstance()->onInformationContourLabels(typeContourGroup, selection, minZ, maxZ,grayRangeMin,grayRangeMax);
597 }
598
599 void interfMainPanel::setStringInfoPanel(wxString tmpString){
600         if(informationPanel!=NULL){
601                 ((interfInformationPanel*)informationPanel)->setStringInfoPanel(tmpString);
602         }
603 }
604
605 void interfMainPanel::setRowLabelInfoPanel(int z, wxString tempString){
606         ((interfInformationPanel*)informationPanel)->setRowLabelInfoPanel(z, tempString);
607 }
608
609 int interfMainPanel::getNumberColsInformationPanel(){
610         return ((interfInformationPanel*)informationPanel)->getNumberCols();
611 }
612
613 void interfMainPanel::appendColsInformationPanel(int _numberOfVariablesStatistics){
614         ((interfInformationPanel*)informationPanel)->appendCols(_numberOfVariablesStatistics);
615 }
616
617 void interfMainPanel::setCellValueInfoPanel(int z,int tmpIntA,wxString tempString){
618         ((interfInformationPanel*)informationPanel)->setCellValue(z, tmpIntA, tempString);
619 }
620
621 void interfMainPanel::setColLableInfoPanel(int tmpIntB,wxString tmpTitleString){
622         ((interfInformationPanel*)informationPanel)->setColLabel(tmpIntB, tmpTitleString);
623
624 }
625
626 void interfMainPanel::onSaveResults(std::string directory,std::string namefile, std::string filename, 
627                                                                         int typeContourGroup, int selection, int minZ, int maxZ ,bool XYZValues, bool contourImage, bool statistics)
628 {
629         wxContourMainFrame::getInstance()->onSaveResults(directory, namefile, filename, 
630                 typeContourGroup, selection, minZ,maxZ, XYZValues, contourImage, statistics);
631 }
632
633 wxString interfMainPanel::getCellValue(int j,int i){
634         return ((interfInformationPanel*)informationPanel)->getCellValue(j, i );
635 }
636
637 void interfMainPanel::onSnakePressed()
638 {
639         axisshown=false;
640         wxContourMainFrame::getInstance()->showAxis(axisshown);
641     wxContourMainFrame::getInstance()->onSnakePressed();
642 }
643
644 void interfMainPanel::onMirrorPressed(){
645     if(mirrorPanel==NULL)
646         {
647
648                 mirrorPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
649                 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);    
650                 mirrorPanel->SetSizer(flexsizer, true);
651                 mirrorPanel->SetAutoLayout( true );     
652                 panelMirror = new interfMirrorPanel(mirrorPanel);
653         
654                 wxStaticText* stattext = new wxStaticText(mirrorPanel, -1, wxString(_T("   Mirroring Tool   ")), wxDefaultPosition,
655                         wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
656
657                 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
658                 flexsizer->Add(panelMirror, wxEXPAND);
659                 mirrorPanel->Layout();
660
661                 refLineShown=true;
662                 wxContourMainFrame::getInstance()->referenceLine();
663         }       
664
665         else
666         {
667
668                 if (!refLineShown)
669                 {
670                         wxContourMainFrame::getInstance()->refLineShow();
671                         refLineShown=true;
672                 }
673         }
674
675         showPanel(mirrorPanel);
676 }
677
678 void interfMainPanel::onMirror()
679 {
680         wxContourMainFrame::getInstance()->onMirror();
681 }
682
683 void interfMainPanel::onMirrorAxisShow()
684 {
685         if (!refLineShown)
686         {
687                 wxContourMainFrame::getInstance()->refLineShow();
688                 refLineShown=true;
689         }
690 }
691
692 void interfMainPanel::onMirrorAxisHide()
693 {
694         if (refLineShown)
695         {
696                 wxContourMainFrame::getInstance()->refLineHide();
697                 refLineShown=false;
698         }
699 }
700
701 void interfMainPanel::onMirrorChangeWidth(int width)
702 {
703         wxContourMainFrame::getInstance()->refLineChangeWidth(width);
704 }
705
706
707 void interfMainPanel::onThreshold()
708 {
709         wxContourMainFrame::getInstance()->onThreshold();
710 }
711
712 void interfMainPanel::onThresholdChange()
713 {
714         wxContourMainFrame::getInstance()->onThresholdChange();
715 }
716
717 void interfMainPanel::onThresholdInstantChange(double range[])
718 {
719         panelThreshold->onThresholdInstantChange(range);
720 }
721
722 void interfMainPanel::onThresholdInterpolation(bool interpolate)
723 {
724         wxContourMainFrame::getInstance()->onThresholdInterpolation(interpolate);
725 }
726
727 void interfMainPanel::onThresholdChangeOpacity (int opacity)
728 {
729         wxContourMainFrame::getInstance()->onThresholdChangeOpacity(opacity);
730 }
731
732 void interfMainPanel::onThresholdRemove()
733 {
734         wxContourMainFrame::getInstance()->onThresholdRemove();
735 }
736
737 void interfMainPanel::onThresholdPressed()
738 {
739     if(thresholdPanel==NULL)
740         {
741
742                 thresholdPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
743                 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);    
744                 thresholdPanel->SetSizer(flexsizer, true);
745                 thresholdPanel->SetAutoLayout( true );  
746                 panelThreshold = new interfThresholdPanel(thresholdPanel);
747         
748                 wxStaticText* stattext = new wxStaticText(thresholdPanel, -1, wxString(_T("   Threshold Tool   ")), wxDefaultPosition,
749                         wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
750
751                 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
752                 flexsizer->Add(panelThreshold, wxEXPAND);
753                 thresholdPanel->Layout();
754
755         }       
756         showPanel(thresholdPanel);
757 }
758
759 void interfMainPanel::ShowResultImages(int typeContourGroup, int selection, int minZ, int maxZ)
760 {
761         wxContourMainFrame::getInstance()->ShowResultImages(typeContourGroup, selection, minZ, maxZ);
762 }
763
764