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