]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/wxMaracasFrame02.cxx
compila
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / wxMaracasFrame02.cxx
1 /*=========================================================================
2
3   Program:   wxMaracas
4   Module:    $RCSfile: wxMaracasFrame02.cxx,v $
5   Language:  C++
6   Date:      $Date: 2008/10/31 16:32:10 $
7   Version:   $Revision: 1.1 $
8
9   Copyright: (c) 2002, 2003
10   License:
11   
12      This software is distributed WITHOUT ANY WARRANTY; without even 
13      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
14      PURPOSE.  See the above copyright notice for more information.
15
16 =========================================================================*/
17
18
19 #include <wx/wx.h>
20 #include <wx/frame.h>
21 #include <wx/dir.h>
22 #include <wx/arrstr.h>
23
24 #include <vtkCommand.h>
25 #include <vtkImageChangeInformation.h>
26 #include <vtkImageCast.h>
27 #include <vtkImageData.h>
28 #include <vtkImageViewer2.h>
29 #include <vtkCamera.h>
30 #include <vtkRenderer.h>
31
32
33 #include <gdcm.h> 
34 #include <gdcmFile.h> 
35 #include "vtkGdcmReader.h"
36
37
38 #include "wxMaracasParametersDialog.h"
39 #include "wxMaracasDataBrowser.h"
40 #include "widgets/wxSTLWidget_02.h"
41 #include "widgets/wxSTLWidget_03.h"
42 #include "widgets/wxMPRWidget.h"
43
44
45 #include <wx/panel.h>
46 #include <wx/toolbar.h>
47 #include <wx/dialog.h>
48 #include <wx/colordlg.h>
49 #include <wx/listctrl.h>
50 #include <wx/textctrl.h>
51
52 // EED Borrame not used
53 #include "wxMaracasImageBrowser.h"
54
55 #include "wxMaracasHelpDialog.h"
56 #include "marDictionary.h"
57 #include "kernel/marImageData.h"
58
59
60
61 //using namespace std;
62 #include "wxMaracasFrame02.h"
63
64 #include "ILPD/src/controlerInterface/ILPDViewListPatient.h"
65 #include "ILPD/src/wxInterface/ILPDViewWxWindow.h"
66
67
68 // ----------------------------------------------------------------------------
69 // Maracas "logic world" headers
70 // ----------------------------------------------------------------------------
71 //#include <kernel/marInterface.h>
72
73 #ifndef __WXMSW__
74   #include "res/bitmaps/connect.xpm"
75   #include "res/bitmaps/params.xpm"
76   #include "res/bitmaps/imagebrowser.xpm"
77   #include "res/bitmaps/3D.xpm"
78   #include "res/bitmaps/plans.xpm"
79   #include "res/bitmaps/quant.xpm"
80   #include "res/bitmaps/rotate.xpm"
81   #include "res/bitmaps/bright.xpm"
82   #include "res/bitmaps/pan.xpm"
83   #include "res/bitmaps/zoom.xpm"
84   #include "res/bitmaps/clear.xpm"
85   #include "res/bitmaps/intensity.xpm"
86   #include "res/bitmaps/help.xpm"
87   #include "res/bitmaps/stl.xpm"
88   #include "res/bitmaps/creatis_logo.xpm"
89   #include "res/bitmaps/MPR.xpm"
90   #include "res/bitmaps/Axis_JF.xpm"
91   #include "res/bitmaps/Axis_JF_MH1.xpm"
92   #include "res/bitmaps/Axis_JF_MH2.xpm"
93   #include "res/bitmaps/ProcessingCT.xpm"
94   #include "res/bitmaps/QuantificationCT.xpm"
95   #include "res/icons/maracas.xpm"
96
97
98   #include "res/bitmaps2/v2_bi_bl_CTQuantification.xpm"
99   #include "res/bitmaps2/v2_bi_bl_Information.xpm"
100   #include "res/bitmaps2/v2_bi_bl_IRMQuantification.xpm"
101   #include "res/bitmaps2/v2_bi_bl_ListPatient_Voi.xpm"
102   #include "res/bitmaps2/v2_bi_bl_Logo.xpm"
103   #include "res/bitmaps2/v2_bi_bl_ManualRegistration.xpm"
104   #include "res/bitmaps2/v2_bi_bl_Params.xpm"
105   #include "res/bitmaps2/v2_bi_bl_Processing.xpm"
106   #include "res/bitmaps2/v2_bi_bl_STLFormat.xpm"
107   #include "res/bitmaps2/v2_bi_bl_Tests.xpm"
108   #include "res/bitmaps2/v2_bi_bl_VascularTree.xpm"
109   #include "res/bitmaps2/v2_bi_mask.xpm"
110   #include "res/bitmaps2/v2_bi_re_CTQuantification.xpm"
111   #include "res/bitmaps2/v2_bi_re_IRMQuantification.xpm"
112   #include "res/bitmaps2/v2_bi_re_ListPatient_Voi.xpm"
113   #include "res/bitmaps2/v2_bi_re_Logo.xpm"
114   #include "res/bitmaps2/v2_bi_re_ManualRegistration.xpm"
115   #include "res/bitmaps2/v2_bi_re_Params.xpm"
116   #include "res/bitmaps2/v2_bi_re_Processing.xpm"
117   #include "res/bitmaps2/v2_bi_re_STLFormat.xpm"
118   #include "res/bitmaps2/v2_bi_re_Tests.xpm"
119   #include "res/bitmaps2/v2_bi_re_VascularTree.xpm"
120   #include "res/bitmaps2/v2_sm_bl_AddAllPatients.xpm"
121   #include "res/bitmaps2/v2_sm_bl_AddPatient.xpm"
122   #include "res/bitmaps2/v2_sm_bl_AxisExtraction.xpm"
123   #include "res/bitmaps2/v2_sm_bl_CreateDICOMDIR.xpm"
124   #include "res/bitmaps2/v2_sm_bl_ListPatient.xpm"
125   #include "res/bitmaps2/v2_sm_bl_MPR.xpm"
126   #include "res/bitmaps2/v2_sm_bl_OpenDICOMDIR.xpm"
127   #include "res/bitmaps2/v2_sm_bl_OpenDirectory.xpm"
128   #include "res/bitmaps2/v2_sm_bl_ProcessingCT.xpm"
129   #include "res/bitmaps2/v2_sm_bl_Processing.xpm"
130   #include "res/bitmaps2/v2_sm_bl_Quantification.xpm"
131   #include "res/bitmaps2/v2_sm_bl_STLFormat.xpm"
132   #include "res/bitmaps2/v2_sm_bl_TreeExtraction_JF_MH.xpm"
133   #include "res/bitmaps2/v2_sm_bl_voi.xpm"
134   #include "res/bitmaps2/v2_sm_mask.xpm"
135   #include "res/bitmaps2/v2_sm_re_ListPatient.xpm"
136   #include "res/bitmaps2/v2_sm_re_voi.xpm"
137   #include "res/bitmaps2/v2_sm_tr_MPR.xpm"
138   #include "res/bitmaps2/v2_sm_tr_Processing.xpm"
139   #include "res/bitmaps2/v2_sm_tr_Quantification.xpm"
140   #include "res/bitmaps2/v2_sm_tr_STLFormat.xpm"
141   #include "res/bitmaps2/v2_sm_tr_VOI.xpm"
142 #endif
143
144
145
146
147
148
149 BEGIN_EVENT_TABLE( wxMaracasFrame02, wxFrame )
150     EVT_MENU( ID_TOOLBAR_DATA_BROWSER    , wxMaracasFrame02::OnLoadPatientData                  )
151
152     EVT_MENU(   ID_TOOLBAR_PARAMETERS           , wxMaracasFrame02::OnParameters                        )
153     EVT_MENU(   ID_TOOLBAR_IMAGE_BROWSER        , wxMaracasFrame02::OnLoadImageData02           )
154     EVT_MENU(   ID_TOOLBAR_3D_BROWSER           , wxMaracasFrame02::OnStartExperiment           )
155     EVT_MENU(   ID_TOOLBAR_HELP                         , wxMaracasFrame02::OnHelp                                      )
156     EVT_MENU(   ID_TOOLBAR_PLANS                        , wxMaracasFrame02::OnQuant                                     )
157
158     EVT_MENU(   ID_TOOLBAR_MPR                          , wxMaracasFrame02::OnMPR                                       )
159     EVT_MENU(   ID_TOOLBAR_PROCESSING_CT        , wxMaracasFrame02::OnProcessingCT                      )
160     EVT_MENU(   ID_TOOLBAR_QUANTIFICATION_CT, wxMaracasFrame02::OnQuantificationCT              )
161
162     EVT_MENU(   ID_TOOLBAR_EMPTY_PANEL          , wxMaracasFrame02::OnEmptyPanel                        )
163     EVT_MENU(   ID_TOOLBAR_EMPTY_PANEL_2        , wxMaracasFrame02::OnEmptyPanel_2                      )
164
165     EVT_MENU(   ID_TOOLBAR_STL                          , wxMaracasFrame02::OnStl                                       )
166     EVT_CLOSE(                                                        wxMaracasFrame02::OnQuit                                  )
167
168         // EED : This is not top  !!!!!!!!!!!
169         EVT_TOOL( 19999                                                  , wxMaracasFrame02::OnRegenerateAll            )
170         EVT_TOOL( 19998                                                  , wxMaracasFrame02::OnRegenerateSplineAxe      )
171         EVT_TOOL( 19997                                                  , wxMaracasFrame02::OnCleanContours            )
172         EVT_TOOL( 19996                                                  , wxMaracasFrame02::OnRegenerateSignal         )
173
174     EVT_LIST_ITEM_ACTIVATED( ID_SERIES_LIST,            wxMaracasFrame02::OnLoadImageData       )
175
176         EVT_TOOL(wxSurfaceWidget::ID_BUTTON_NEW_AXIS,   wxMaracasFrame02::OnNewAxis                     )
177         EVT_TOOL(wxSurfaceWidget::ID_BUTTON_DELETE_AXIS,wxMaracasFrame02::OnDeleteAxis          )
178 END_EVENT_TABLE( );
179
180 //----------------------------------------------------------------------------
181 wxMaracasFrame02::wxMaracasFrame02( wxFrame *parent, wxWindowID id, 
182                                 marInterface *mar, marInterfaceCT *marCT, 
183                                                                 char *dictionaryFileName, 
184                                                                 const wxString& title, const wxPoint& pos, 
185                                                                 const wxSize& size, long style) 
186               : wxFrame( parent, id, title, pos, size, style)
187 {
188         marDictionary marDict;
189 //      marDict.LoadDictionary_French();
190         marDict.LoadDictionary_English();
191 //      marDict.LoadDictionary_Japanese();
192         
193
194 /*
195         if (!marDict.LoadDictionaryFile(dictionaryFileName)){
196                         wxMessageBox( _T("Error: File(s) marDict.txt not found..."),
197                                           _T("DxMM : MARACAS"), wxOK | wxCENTRE | wxICON_ERROR , this);
198         }
199
200 */
201     _mar = mar;
202         _marCT = marCT;
203     
204     //good luck !
205     vtkObject *a = vtkObject::New();
206     a->GlobalWarningDisplayOff();
207     a->Delete();
208
209     // At the begining, there were nothing, just a window...
210     _actual_panel = NULL;
211
212     // And the programmer said: let there be a status bar
213     this->CreateStatusBar( );
214     
215     this->GetStatusBar()->SetFieldsCount( 2 );
216     wxRect rect;
217     this->GetStatusBar()->GetFieldRect(1, rect);
218     //wxPoint pos;
219     //wxSize size;
220     //_progressGauge = new wxGauge( this->GetStatusBar(), -1, 100);
221 //    _progressGauge = new wxGauge( this->GetStatusBar(), -1, 50,
222 //    rect.GetPosition(), rect.GetSize());
223     this->GetStatusBar()->Show();
224     this->PositionStatusBar();
225
226     // And an icon (to be unique)
227     //TODO change the icon to the real one!
228     this->SetIcon( wxICON( maracas_icon ) );
229
230     // And a toolbar (for dummy users)
231     this->RecreateToolbar( );
232
233 }
234 //----------------------------------------------------------------------------
235 void wxMaracasFrame02::RecreateToolbar( )
236 {
237     wxToolBar* toolBar = this->GetToolBar( );
238     delete toolBar;
239     this->SetToolBar( NULL );
240
241     toolBar = this->CreateToolBar( TOOLBAR_STYLE, ID_TOOLBAR );
242
243     // Set up toolbar
244     wxBitmap toolBarBitmaps[ 28+1 ];
245
246  /**
247   * wxBitmap vs. wxBITMAP -> add _xpm at the end of the file
248   */
249     toolBarBitmaps[  0 ] = wxBITMAP( toolbar_connect                    );
250     toolBarBitmaps[  4 ] = wxBITMAP( toolbar_params                             );
251     toolBarBitmaps[  7 ] = wxBITMAP( toolbar_imagebrowser               );
252     toolBarBitmaps[  9 ] = wxBITMAP( toolbar_triD                               );
253     toolBarBitmaps[ 10 ] = wxBITMAP( toolbar_plans                              );
254     toolBarBitmaps[ 11 ] = wxBITMAP( toolbar_quant                              );
255     toolBarBitmaps[ 12 ] = wxBITMAP( toolbar_rotate                             );
256     toolBarBitmaps[ 13 ] = wxBITMAP( toolbar_bright                             );
257     toolBarBitmaps[ 14 ] = wxBITMAP( toolbar_pan                                );
258     toolBarBitmaps[ 15 ] = wxBITMAP( toolbar_zoom                               );
259     toolBarBitmaps[ 16 ] = wxBITMAP( toolbar_clear                              );
260     toolBarBitmaps[ 17 ] = wxBITMAP( toolbar_intensity                          );
261     toolBarBitmaps[ 20 ] = wxBITMAP( toolbar_help                               );
262
263     toolBarBitmaps[ 21 ] = wxBITMAP( vesselstoolbar_stl                 );
264
265     toolBarBitmaps[ 22 ] = wxBITMAP( creatis_logo                               );
266     toolBarBitmaps[ 23 ] = wxBITMAP( TOOLBAR_MPR                                );
267     toolBarBitmaps[ 24 ] = wxBITMAP( TOOLBAR_AXIS_JF                    );
268     toolBarBitmaps[ 25 ] = wxBITMAP( TOOLBAR_AXIS_JF_MH1                );
269     toolBarBitmaps[ 26 ] = wxBITMAP( TOOLBAR_AXIS_JF_MH2                );
270     toolBarBitmaps[ 27 ] = wxBITMAP( TOOLBAR_PROCESSINGCT               );
271     toolBarBitmaps[ 28 ] = wxBITMAP( TOOLBAR_QUANTIFICATIONCT   );
272
273     /*
274       toolBarBitmaps[  1 ] = wxBitmap( toolbar_loadexp );
275       toolBarBitmaps[  2 ] = wxBitmap( toolbar_save );
276       toolBarBitmaps[  3 ] = wxBitmap( toolbar_excel );
277       toolBarBitmaps[  5 ] = wxBitmap( toolbar_wizard );
278       toolBarBitmaps[  6 ] = wxBitmap( toolbar_back );
279       toolBarBitmaps[  8 ] = wxBitmap( toolbar_subtract );
280
281       toolBarBitmaps[ 18 ] = wxBitmap( toolbar_linear );
282       toolBarBitmaps[ 19 ] = wxBitmap( toolbar_area );
283     */
284     // Set size & margins
285     toolBar->SetMargins( 4, 4 );
286     toolBar->SetToolBitmapSize( wxSize( toolBarBitmaps[ 0 ].GetWidth( ), toolBarBitmaps[ 0 ].GetHeight( ) ) );
287
288     // Adding tools
289     toolBar->AddTool( ID_TOOLBAR_DATA_BROWSER, toolBarBitmaps[ 0 ], _T("Patient data"), _T("Load patient data: studies & series") );
290     toolBar->AddSeparator( );
291     toolBar->AddTool( ID_TOOLBAR_IMAGE_BROWSER, toolBarBitmaps[ 7 ], _T("Load image data"), _T("Load DICOM images from disk") );
292     toolBar->AddSeparator( );
293     toolBar->AddTool( ID_TOOLBAR_3D_BROWSER, toolBarBitmaps[ 9 ], _T("Start 3D"), _T("Load 3D representation") );
294     toolBar->AddSeparator( );
295     toolBar->AddTool( ID_TOOLBAR_PLANS, toolBarBitmaps[ 10 ], _T("Plan"), _T("Planes") );
296     toolBar->AddSeparator( );
297     toolBar->AddTool( ID_TOOLBAR_STL, toolBarBitmaps[ 21 ], _T("STL"), _T("Stl") );
298     toolBar->AddSeparator( );
299
300
301
302 //EED    toolBar->AddTool( ID_TOOLBAR_QUANT, toolBarBitmaps[ 11 ], "Quant", "Quant" );
303 //EED    toolBar->AddSeparator( );
304     //The following has been commented out temporarlily
305     /*
306     toolBar->AddTool( ID_TOOLBAR_ROTATE, toolBarBitmaps[ 12 ], "Rotate", "Rotate" );
307     toolBar->AddSeparator( );
308     toolBar->AddTool( ID_TOOLBAR_BRIGHT, toolBarBitmaps[ 13 ], "Bright", "Bright" );
309     toolBar->AddSeparator( );
310     toolBar->AddTool( ID_TOOLBAR_PAN, toolBarBitmaps[ 14 ], "Pan", "Pan" );
311     toolBar->AddSeparator( );
312     toolBar->AddTool( ID_TOOLBAR_ZOOM, toolBarBitmaps[ 15 ], "Zoom", "Zoom" );
313     toolBar->AddSeparator( );
314     toolBar->AddTool( ID_TOOLBAR_CLEAR, toolBarBitmaps[ 16 ], "Clear", "Clear" );
315     toolBar->AddSeparator( );
316     toolBar->AddTool( ID_TOOLBAR_INTENSITY, toolBarBitmaps[ 17 ], "Intensity", "Intensity" );
317     toolBar->AddSeparator( );*/
318     toolBar->AddTool( ID_TOOLBAR_PARAMETERS     , toolBarBitmaps[ 4 ]   , _T("Parameters"), _T("Load parameters for modifying") );
319     toolBar->AddTool( ID_TOOLBAR_HELP           , toolBarBitmaps[ 20 ]  , _T("Help"), _T("Help") );
320
321     toolBar->AddSeparator( );
322     toolBar->AddTool( ID_TOOLBAR_MPR            , toolBarBitmaps[ 23 ], _T("MPR"), _T("MPR") );
323     toolBar->AddTool( ID_TOOLBAR_PROCESSING_CT          , toolBarBitmaps[ 27 ], _T("ProcessingCT"), _T("ProcessingCT") );
324     toolBar->AddTool( ID_TOOLBAR_QUANTIFICATION_CT      , toolBarBitmaps[ 28 ], _T("QuantificationCT"), _T("QuantificationCT") );
325     toolBar->AddSeparator( );
326     toolBar->AddTool( ID_TOOLBAR_EMPTY_PANEL            , toolBarBitmaps[ 24 ], _T("EmptyPanel"), _T("EmptyPanel") );
327     toolBar->AddTool( ID_TOOLBAR_EMPTY_PANEL_2          , toolBarBitmaps[ 26 ], _T("EmptyPanel_2"), _T("EmptyPanel_2") );
328     toolBar->AddSeparator( );
329
330
331         wxBitmapButton *btnCreatisLogo = new wxBitmapButton(toolBar,-1/*ID_BUTTON_ABOUTCREATIS*/,toolBarBitmaps[ 22 ] );
332         btnCreatisLogo->SetSize(81+10,20+10);
333         btnCreatisLogo->SetBackgroundColour(wxColour(0,0,153));
334         Connect(btnCreatisLogo->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxMaracasFrame02::OnAboutCreatis       );
335
336         toolBar->AddControl(btnCreatisLogo);
337
338     toolBar->Realize( );
339     toolBar->SetRows( 1 );
340     
341 }
342
343 //----------------------------------------------------------------------------
344 void wxMaracasFrame02::OnAboutCreatis( wxCommandEvent& event ){
345
346         wxMaracasHelpDialog *dlg = new wxMaracasHelpDialog(this, -1, "Creatis", wxPoint(200,200), wxDefaultSize, wxDEFAULT_DIALOG_STYLE);
347         dlg->ShowModal();
348         dlg->Close();
349
350 }
351
352 //----------------------------------------------------------------------------
353 void wxMaracasFrame02::OnQuit( wxCloseEvent& event ){
354
355     if( _actual_panel != NULL ) delete _actual_panel;
356
357
358         this->Destroy();
359
360
361 }
362 //----------------------------------------------------------------------------
363 void wxMaracasFrame02::OnLoadPatientData( wxCommandEvent& event )
364 {
365   wxBusyCursor wait;
366     wxToolBar* toolBar = this->GetToolBar( );
367     //Disabling tool
368     //wxToolBar::EnableTool This function should only be called after Realize.
369     toolBar->EnableTool(ID_TOOLBAR_IMAGE_BROWSER         , true);
370     toolBar->EnableTool(ID_TOOLBAR_3D_BROWSER            , false);
371     toolBar->EnableTool(ID_TOOLBAR_PLANS                         , false);
372     toolBar->EnableTool(ID_TOOLBAR_QUANT                         , false);
373         toolBar->EnableTool(ID_TOOLBAR_STL                               , false);
374
375         toolBar->EnableTool(ID_TOOLBAR_MPR                               , false);
376         toolBar->EnableTool(ID_TOOLBAR_PROCESSING_CT     , false);
377         toolBar->EnableTool(ID_TOOLBAR_QUANTIFICATION_CT , false);
378         toolBar->EnableTool(ID_TOOLBAR_EMPTY_PANEL               , false);
379         toolBar->EnableTool(ID_TOOLBAR_EMPTY_PANEL_2     , false        );
380
381
382   //  Create panel
383   if( _actual_panel != NULL ) delete _actual_panel;
384
385
386
387 /*
388 ver esto para reconectar ILPD
389 wxMaracasFrame02::OnLoadPatientData
390 wxMaracasFrame02::OnLoadImageData02
391 wxMaracasApp02::OnInit
392 */
393
394 // EED ILPD
395   wxILPD* pnl = new wxILPD( this );
396   ILPDViewListPatient*  _ilpdViewListPatient    = new ILPDViewListPatient( new ILPDViewWxWindow(pnl) );
397
398 //  wxMaracasDataBrowser* pnl = new wxMaracasDataBrowser( this, _mar, -1 );
399
400
401   _actual_panel = pnl;
402
403   // cf.: http://www.wxwindows.org/manuals/2.4.0/wx490.htm
404   // Force a resize. This should probably be replaced by a call to a wxFrame
405   // function that lays out default decorations and the remaining content window.
406   wxSizeEvent myevent(wxSize(-1, -1), this->GetId());
407   this->OnSize(myevent);
408   this->Show(true);
409
410   // Load panel data
411 //  pnl->LoadData( );
412
413
414 }
415
416
417 //----------------------------------------------------------------------------
418 void wxMaracasFrame02::OnParameters( wxCommandEvent& event )
419 {
420   wxMaracasParametersDialog *d = new wxMaracasParametersDialog( this, _mar );
421   d->ShowModal( );
422   d->Close( true );
423 }
424
425 // EED Borrme not used
426 //----------------------------------------------------------------------------
427 void wxMaracasFrame02::OnLoadImageData( wxListEvent& event ){
428   wxBusyCursor wait;
429
430   //  Create panel
431   if( _actual_panel != NULL ) delete _actual_panel;
432   wxMaracasImageBrowser* pnl = new wxMaracasImageBrowser( this, _mar, -1 );
433
434   // Resize
435   _actual_panel = pnl;
436
437   // Load panel data
438   wxSizeEvent myevent(wxSize(-1, -1), this->GetId());
439   this->OnSize(myevent);
440   //this->Show(true);
441
442   //wxDialog dialog(this, -1, "coucou");
443   //dialog.ShowModal();
444   //dialog.Show(true);
445   //wxGauge gauge( this, -1, 50);
446
447     /**
448       AS a first step I'll pass a wxGauge as parameter this doesn't 
449       sound very good, should use EVT_TIMER instead...
450     */
451     _mar->_dicom->loadActualSerie( this->_progressGauge );
452     vtkImageData *dummy = _mar->_dicom->getVolume( )->castVtk();
453     //float range[2];
454     //dummy->GetScalarRange( range );
455
456     pnl->LoadData( dummy );
457     //_view_image->ConstructVTK(  (vtkImageData *)_mar->_dicom->getVolume( ));
458     //^ this is not working ??? I don't understand why, some VTK pipeline mystery
459
460     this->GetToolBar()->EnableTool(ID_TOOLBAR_IMAGE_BROWSER, false);
461     this->GetToolBar()->EnableTool(ID_TOOLBAR_3D_BROWSER, true);
462
463         this->GetToolBar()->EnableTool(ID_TOOLBAR_PLANS, false);
464         this->GetToolBar()->EnableTool(ID_TOOLBAR_STL, false);
465
466         //Add patient name to the frame title
467     this->SetTitle( _T("Patient Name : ") + _mar->_dicom->GetPatientName() );
468 }
469
470
471 //----------------------------------------------------------------------------
472 void wxMaracasFrame02::OnLoadImageData02( wxCommandEvent& event ){
473   wxBusyCursor wait;
474
475
476 // EED ILPD
477   wxILPD *wxilpd=(wxILPD*)_actual_panel;
478   vector <string*> lstStringFileName;
479   wxilpd->GetLstImageFiles(&lstStringFileName);
480   if (lstStringFileName.size()!=0)
481   {
482                 marGdcmDicomILPD *margdcmdicomILPD = (marGdcmDicomILPD*)_mar->_dicom;
483                 marGdcmDicomILPD *margdcmdicomILPD2 = (marGdcmDicomILPD*)_marCT->_dicom;
484 //              margdcmdicomILPD->SetListImages( &lstStringFileName );
485 //              margdcmdicomILPD2->SetListImages( &lstStringFileName );
486
487
488           //  Create panel
489         if( _actual_panel != NULL ) delete _actual_panel;
490         wxMaracasImageBrowser02* pnl = new wxMaracasImageBrowser02( this, _mar->_dicom, _mar->_parameters );
491
492           // Resize
493         _actual_panel = pnl;
494
495           // Load panel data
496         wxSizeEvent myevent(wxSize(-1, -1), this->GetId());
497         this->OnSize(myevent);
498
499         _mar->_dicom->loadActualSerie( this->_progressGauge );
500         _marCT->_dicom->loadActualSerie( this->_progressGauge);
501         vtkImageData *dummy = _mar->_dicom->getVolume( )->castVtk();
502         pnl->LoadData( new marImageData(dummy) );
503         pnl->Start();
504
505         this->GetToolBar()->EnableTool(ID_TOOLBAR_IMAGE_BROWSER , false );
506         this->GetToolBar()->EnableTool(ID_TOOLBAR_3D_BROWSER    , true  );
507         this->GetToolBar()->EnableTool(ID_TOOLBAR_PLANS         , false );
508         this->GetToolBar()->EnableTool(ID_TOOLBAR_STL           , false );
509         this->GetToolBar()->EnableTool(ID_TOOLBAR_MPR           , true  );
510         this->GetToolBar()->EnableTool(ID_TOOLBAR_EMPTY_PANEL   , false );
511         this->GetToolBar()->EnableTool(ID_TOOLBAR_EMPTY_PANEL_2 , true  );
512
513   } // if lstStringFileName.size
514
515
516
517 //Add patient name to the frame title
518 // EED attention 
519 //    this->SetTitle( "Patient Name : " + _mar->_dicom->GetPatientName() );
520
521 }
522
523
524 //----------------------------------------------------------------------------
525
526 void wxMaracasFrame02::OnStartExperiment( wxCommandEvent& event )
527 {
528         wxBusyCursor wait;
529         int voi[ 6 ];
530         if (((wxMaracasImageBrowser02*)_actual_panel )->GetRoiSelected()){
531                 ((wxMaracasImageBrowser02*)_actual_panel )->ForceToFinisReadActiveImages( );
532                 ((wxMaracasImageBrowser02*)_actual_panel )->GetROI( voi );
533
534                 _mar->_experiment->setVOI( voi );
535                 _mar->initExperiment( );
536
537                 //  Create panel
538                 if( _actual_panel != NULL ) { delete _actual_panel; }
539                 _wxmaracas3dbrowser = new wxMaracas3DBrowser( this, _mar, -1,ID_TOOLBAR_PLANS );
540                 _actual_panel = _wxmaracas3dbrowser;
541
542                 wxSizeEvent myevent(wxSize(-1, -1), this->GetId());
543                 this->OnSize(myevent);
544                 //this->Show(true);
545
546                 // Load panel data
547                 _wxmaracas3dbrowser->LoadData( );
548   
549                 //this->GetToolBar()->EnableTool(ID_TOOLBAR_DATA_BROWSER, false);
550                 this->GetToolBar()->EnableTool(ID_TOOLBAR_IMAGE_BROWSER         , true);
551                 this->GetToolBar()->EnableTool(ID_TOOLBAR_3D_BROWSER            , false);
552                 this->GetToolBar()->EnableTool(ID_TOOLBAR_EMPTY_PANEL           , false );
553                 this->GetToolBar()->EnableTool(ID_TOOLBAR_MPR                   , false );
554                 this->GetToolBar()->EnableTool(ID_TOOLBAR_EMPTY_PANEL           , false );
555                 this->GetToolBar()->EnableTool(ID_TOOLBAR_EMPTY_PANEL_2         , false );
556         } else {
557                 wxMessageDialog *msg =new wxMessageDialog(this, _T("VOI not selected"), _T("Warning"), wxOK );
558                 msg->ShowModal();
559                 msg->Destroy();
560         }
561 }
562 //----------------------------------------------------------------------------
563 void wxMaracasFrame02::OnHelp (wxCommandEvent& event )
564 {
565   wxMaracasHelpDialog* help = new wxMaracasHelpDialog(this, -1);
566   help->ShowModal();
567 }
568 //----------------------------------------------------------------------------
569 void wxMaracasFrame02::OnStl(wxCommandEvent& event ){
570
571         DeletePanels();
572
573         _wxmaracassurfaceSTLwidget = new wxSurfaceSTLWidget(this);
574         _wxmaracassurfaceSTLwidget->ShowMARACASData( _mar );
575         _actual_panel = _wxmaracassurfaceSTLwidget;
576
577         wxSizeEvent myevent(wxSize(-1, -1), this->GetId());
578         this->OnSize(myevent);
579         this->Show(true);
580
581         // Load panel data
582         this->GetToolBar()->EnableTool(ID_TOOLBAR_PLANS                 , true  );
583         this->GetToolBar()->EnableTool(ID_TOOLBAR_3D_BROWSER            , false );
584         this->GetToolBar()->EnableTool(ID_TOOLBAR_STL                   , false );
585         this->GetToolBar()->EnableTool(ID_TOOLBAR_IMAGE_BROWSER         , true  );
586         this->GetToolBar()->EnableTool(ID_TOOLBAR_MPR                   , false );
587         this->GetToolBar()->EnableTool(ID_TOOLBAR_EMPTY_PANEL           , false );
588         this->GetToolBar()->EnableTool(ID_TOOLBAR_EMPTY_PANEL_2         , false );
589 }
590 //----------------------------------------------------------------------------
591 void wxMaracasFrame02::OnQuant (wxCommandEvent& event )
592 {
593         DeletePanels();
594         _wxmaracasquantification = new wxMaracasQuantification( this, _mar, -1 );
595         _actual_panel = _wxmaracasquantification;
596
597
598         wxSizeEvent myevent(wxSize(-1, -1), this->GetId());
599         this->OnSize(myevent);
600         this->Show(true);
601
602         // Load panel data
603         _wxmaracasquantification->LoadData( );
604         this->GetToolBar()->EnableTool(ID_TOOLBAR_PLANS, false);
605         this->GetToolBar()->EnableTool(ID_TOOLBAR_3D_BROWSER, false);
606 }
607
608 //----------------------------------------------------------------------------
609 void wxMaracasFrame02::OnQuantificationCT (wxCommandEvent& event )
610 {
611         DeletePanels();
612         _wxmaracasquantification_ct = new wxMaracasQuantificationCT( this, _marCT, -1 );
613         _actual_panel = _wxmaracasquantification;
614
615
616         wxSizeEvent myevent(wxSize(-1, -1), this->GetId());
617         this->OnSize(myevent);
618         this->Show(true);
619
620         // Load panel data
621         _wxmaracasquantification_ct->LoadData( );
622 //      this->GetToolBar()->EnableTool(ID_TOOLBAR_PLANS, false);
623 //      this->GetToolBar()->EnableTool(ID_TOOLBAR_3D_BROWSER, false);
624 }
625
626
627
628 //----------------------------------------------------------------------------
629 void wxMaracasFrame02::OnMPR(wxCommandEvent& event ){
630 printf("EED wxMaracasFrame02::OnMPR A\n");
631         wxBusyCursor wait;
632
633         int voi[ 6 ];
634         if (((wxMaracasImageBrowser02*)_actual_panel )->GetRoiSelected()){
635                 ((wxMaracasImageBrowser02*)_actual_panel )->ForceToFinisReadActiveImages( );
636                 ((wxMaracasImageBrowser02*)_actual_panel )->GetROI( voi );
637
638                 _mar->_experiment->setVOI( voi );
639                 _mar->initExperiment( );
640                 _marCT->setVOI(voi);
641                 _marCT->SetDicom(_mar->_dicom);
642                 _marCT->initExperiment();
643
644
645                 vtkImageData    *imagedata;
646                 imagedata               = _marCT->getDynData( )->getVolume( )->castVtk();
647                 marImageData    *marimagedata = new marImageData(imagedata);
648                         
649                 //  Create panel
650                 if( _actual_panel != NULL ) { delete _actual_panel; }
651                 _wxMaracasMPR = new wxMaracasMPR( this, marimagedata ,_mar->_parameters->getVoxelSize() );
652                 _wxMaracasMPR->ConfigureVTK();
653                 // Resize
654                 _actual_panel = _wxMaracasMPR;
655
656                 wxSizeEvent myevent(wxSize(-1, -1), this->GetId());
657                 this->OnSize(myevent);
658                 //this->Show(true);
659   
660                 //this->GetToolBar()->EnableTool(ID_TOOLBAR_DATA_BROWSER, false);
661                 this->GetToolBar()->EnableTool(ID_TOOLBAR_IMAGE_BROWSER         , true  );
662                 this->GetToolBar()->EnableTool(ID_TOOLBAR_3D_BROWSER            , false );
663                 this->GetToolBar()->EnableTool(ID_TOOLBAR_MPR                   , false );
664                 this->GetToolBar()->EnableTool(ID_TOOLBAR_PROCESSING_CT         , true  );
665                 this->GetToolBar()->EnableTool(ID_TOOLBAR_EMPTY_PANEL           , true  );
666                 this->GetToolBar()->EnableTool(ID_TOOLBAR_EMPTY_PANEL_2         , false );
667         } else {
668                 wxMessageDialog *msg =new wxMessageDialog(this, _T("VOI not selected"), _T("Warning"), wxOK );
669                 msg->ShowModal();
670                 msg->Destroy();
671         }
672
673
674 printf("EED wxMaracasFrame02::OnMPR B\n");
675         
676 }
677
678 //----------------------------------------------------------------------------
679 void wxMaracasFrame02::OnEmptyPanel(wxCommandEvent& event )
680 {
681
682         wxBusyCursor wait;
683
684         vtkMPRBaseData *vtkmpr2DData = ((wxMaracasMPR*)_actual_panel )->GetVtkMPRBaseData();
685         vtkImageData *imagedata = vtkmpr2DData->GetImageData();
686
687         int     x = (int)vtkmpr2DData->GetX();
688         int     y = (int)vtkmpr2DData->GetY();
689         int     z = (int)vtkmpr2DData->GetZ();
690         //  Create panel
691         if( _actual_panel != NULL ) { delete _actual_panel; }
692         _wxMaracasEmptyPanel = new wxMaracasEmptyPanel(this);
693         _wxMaracasEmptyPanel->ConfigureVTK(imagedata, x , y , z );
694
695         _actual_panel = _wxMaracasEmptyPanel;
696
697         wxSizeEvent myevent(wxSize(-1, -1), this->GetId());
698         this->OnSize(myevent);
699         //this->Show(true);
700   
701         //this->GetToolBar()->EnableTool(ID_TOOLBAR_DATA_BROWSER, false);
702         this->GetToolBar()->EnableTool(ID_TOOLBAR_IMAGE_BROWSER         , true  );
703         this->GetToolBar()->EnableTool(ID_TOOLBAR_3D_BROWSER            , false );
704         this->GetToolBar()->EnableTool(ID_TOOLBAR_MPR                   , false );
705         this->GetToolBar()->EnableTool(ID_TOOLBAR_EMPTY_PANEL           , false );
706         this->GetToolBar()->EnableTool(ID_TOOLBAR_EMPTY_PANEL_2         , false );
707
708
709 /*
710         wxBusyCursor wait;
711         vtkMPRBaseData *vtkmprbaseData = ((wxMaracasMPR*)_actual_panel )->GetVtkMPRBaseData();
712
713         vtkImageData *imagedata = vtkmprbaseData->GetImageData();
714
715         _mar->initExperiment( );
716
717         int     x = vtkmprbaseData->GetX();
718         int     y = vtkmprbaseData->GetY();
719         int     z = vtkmprbaseData->GetZ();
720         //  Create panel
721         if( _actual_panel != NULL ) { delete _actual_panel; }
722         _wxMaracasEmptyPanel = new wxMaracasEmptyPanel(this, _mar);
723         _wxMaracasEmptyPanel->ConfigureVTK(imagedata, x , y , z );
724
725         _actual_panel = _wxMaracasEmptyPanel;
726
727         wxSizeEvent myevent(wxSize(-1, -1), this->GetId());
728         this->OnSize(myevent);
729         //this->Show(true);
730
731         //this->GetToolBar()->EnableTool(ID_TOOLBAR_DATA_BROWSER, false);
732         this->GetToolBar()->EnableTool(ID_TOOLBAR_IMAGE_BROWSER         , true  );
733         this->GetToolBar()->EnableTool(ID_TOOLBAR_3D_BROWSER            , false );
734                 this->GetToolBar()->EnableTool(ID_TOOLBAR_MPR                   , false );
735                 this->GetToolBar()->EnableTool(ID_TOOLBAR_PLANS                 , true  );
736         this->GetToolBar()->EnableTool(ID_TOOLBAR_EMPTY_PANEL           , false );
737         this->GetToolBar()->EnableTool(ID_TOOLBAR_EMPTY_PANEL_2         , false );
738 */
739 }
740
741 //----------------------------------------------------------------------------
742 void wxMaracasFrame02::OnProcessingCT(wxCommandEvent& event )
743 {
744 printf("EED  wxMaracasFrame02::OnProcessingCT \n");
745         wxBusyCursor wait;
746         vtkMPRBaseData *vtkmprbaseData = ((wxMaracasMPR*)_actual_panel )->GetVtkMPRBaseData();
747
748         marImageData *marimagedata = vtkmprbaseData->GetMarImageData();
749
750         _marCT->initExperiment( );
751
752         int     x = (int)vtkmprbaseData->GetX();
753         int     y = (int)vtkmprbaseData->GetY();
754         int     z = (int)vtkmprbaseData->GetZ();
755         //  Create panel
756         if( _actual_panel != NULL ) { delete _actual_panel; }
757         _wxMaracasProcessingCT = new wxMaracasProcessingCT(this, _marCT);
758         _wxMaracasProcessingCT->ConfigureVTK(marimagedata, x , y , z );
759
760         _actual_panel = _wxMaracasProcessingCT;
761
762         wxSizeEvent myevent(wxSize(-1, -1), this->GetId());
763         this->OnSize(myevent);
764         //this->Show(true);
765
766         //this->GetToolBar()->EnableTool(ID_TOOLBAR_DATA_BROWSER, false);
767         this->GetToolBar()->EnableTool(ID_TOOLBAR_IMAGE_BROWSER         , true  );
768         this->GetToolBar()->EnableTool(ID_TOOLBAR_3D_BROWSER            , false );
769         this->GetToolBar()->EnableTool(ID_TOOLBAR_MPR                   , false );
770         this->GetToolBar()->EnableTool(ID_TOOLBAR_PLANS                 , false );
771         this->GetToolBar()->EnableTool(ID_TOOLBAR_QUANTIFICATION_CT     , true  );
772         this->GetToolBar()->EnableTool(ID_TOOLBAR_EMPTY_PANEL           , false );
773         this->GetToolBar()->EnableTool(ID_TOOLBAR_EMPTY_PANEL_2         , false );
774 }
775
776
777
778 //----------------------------------------------------------------------------
779 void wxMaracasFrame02::OnEmptyPanel_2(wxCommandEvent& event )
780 {
781         wxBusyCursor wait;
782         int voi[ 6 ];
783
784         if (((wxMaracasImageBrowser02*)_actual_panel )->GetRoiSelected()){
785                 ((wxMaracasImageBrowser02*)_actual_panel )->ForceToFinisReadActiveImages( );
786                 ((wxMaracasImageBrowser02*)_actual_panel )->GetROI( voi );
787
788                 _mar->_experiment->setVOI( voi );
789                 _mar->initExperiment( );
790
791                 //  Create panel
792                 if( _actual_panel != NULL ) { delete _actual_panel; }
793                 _wxMaracasEmptyPanel_2 = new wxMaracasEmptyPanel_2(this,_mar);
794                 _wxMaracasEmptyPanel_2->ConfigureVTK();
795
796                 _actual_panel = _wxMaracasEmptyPanel_2;
797
798                 wxSizeEvent myevent(wxSize(-1, -1), this->GetId());
799                 this->OnSize(myevent);
800                 //this->Show(true);
801   
802                 //this->GetToolBar()->EnableTool(ID_TOOLBAR_DATA_BROWSER, false);
803                 this->GetToolBar()->EnableTool(ID_TOOLBAR_IMAGE_BROWSER         , true  );
804                 this->GetToolBar()->EnableTool(ID_TOOLBAR_3D_BROWSER            , false );
805                 this->GetToolBar()->EnableTool(ID_TOOLBAR_MPR                           , false );
806                 this->GetToolBar()->EnableTool(ID_TOOLBAR_EMPTY_PANEL           , false );
807                 this->GetToolBar()->EnableTool(ID_TOOLBAR_EMPTY_PANEL_2         , false );
808         } else {
809                 wxMessageDialog *msg =new wxMessageDialog(this, _T("VOI not selected"), _T("Warning"), wxOK );
810                 msg->ShowModal();
811                 msg->Destroy();
812         }
813 }
814
815
816 //----------------------------------------------------------------------------
817 void wxMaracasFrame02::OnNewAxis(wxCommandEvent &WXUNUSED(event))
818 {
819         this->GetToolBar()->EnableTool(ID_TOOLBAR_PLANS, true);
820         this->GetToolBar()->EnableTool(ID_TOOLBAR_STL, true);
821 }
822 //----------------------------------------------------------------------------
823 void wxMaracasFrame02::OnDeleteAxis(wxCommandEvent &WXUNUSED(event)){
824         this->GetToolBar()->EnableTool(ID_TOOLBAR_PLANS , false);
825         this->GetToolBar()->EnableTool(ID_TOOLBAR_STL   , false);
826 }
827 //----------------------------------------------------------------------------
828 void wxMaracasFrame02::OnRegenerateAll(  wxCommandEvent& event  ){
829         if (_wxmaracas3dbrowser!=NULL)          { _wxmaracas3dbrowser->RegenerateAll(true);              }
830         if (_wxmaracasquantification!=NULL) { _wxmaracasquantification->RegenerateAll(true); }
831 }
832 //----------------------------------------------------------------------------
833 void wxMaracasFrame02::OnRegenerateSplineAxe(  wxCommandEvent& event  ){
834         if (_wxmaracas3dbrowser!=NULL)          { _wxmaracas3dbrowser->RegenerateAll(false);            }
835         if (_wxmaracasquantification!=NULL) { _wxmaracasquantification->RegenerateAll(false);   }
836 }
837 //----------------------------------------------------------------------------
838 void wxMaracasFrame02::OnCleanContours(  wxCommandEvent& event  ){
839         if (_wxmaracasquantification!=NULL) { _wxmaracasquantification->CleanContours();        }
840 }
841 //----------------------------------------------------------------------------
842 void wxMaracasFrame02::OnRegenerateSignal(  wxCommandEvent& event  ){
843         if (_wxmaracasquantification!=NULL) { _wxmaracasquantification->RegenerateSignal();     }
844 }
845 //----------------------------------------------------------------------------
846 void wxMaracasFrame02::DeletePanels ( ){
847         delete _actual_panel;
848         _wxmaracasquantification        =       NULL;
849         _wxmaracas3dbrowser                     =       NULL;
850 }
851
852
853
854 //----------------------------------------------------------------------------
855 //----------------------------------------------------------------------------
856 //----------------------------------------------------------------------------
857
858
859 wxProcessingImagesControl::wxProcessingImagesControl(wxWindow *parent)
860 : wxPanel (parent,-1)
861 {
862         wxBitmapButton *btnIRMQuant;
863         wxBitmapButton *btnCTQuant;
864         wxBitmapButton *btnSTL;
865         wxBitmapButton *btnManualRegistration;
866         wxBitmapButton *btnVascularTree;
867         wxBitmapButton *btnTests;
868
869         wxBitmap bitmapMask =wxBITMAP( TOOLBAR_V2_bi_mask );
870
871     wxBitmap toolBarBitmapsA[ 5+1 ];
872     wxBitmap toolBarBitmapsB[ 5+1 ];
873
874     toolBarBitmapsA[  0 ] = wxBITMAP( TOOLBAR_V2_bi_bl_IRMQuantification );
875     toolBarBitmapsA[  1 ] = wxBITMAP( TOOLBAR_V2_bi_bl_CTQuantification  );
876     toolBarBitmapsA[  2 ] = wxBITMAP( TOOLBAR_V2_bi_bl_VascularTree              );
877     toolBarBitmapsA[  3 ] = wxBITMAP( TOOLBAR_V2_bi_bl_STLFormat                 );
878     toolBarBitmapsA[  4 ] = wxBITMAP( TOOLBAR_V2_bi_bl_Tests                     );
879     toolBarBitmapsA[  5 ] = wxBITMAP( TOOLBAR_V2_bi_bl_ManualRegistration);
880
881         toolBarBitmapsA[0].SetMask( new wxMask(bitmapMask) );
882         toolBarBitmapsA[1].SetMask( new wxMask(bitmapMask) );
883         toolBarBitmapsA[2].SetMask( new wxMask(bitmapMask) );
884         toolBarBitmapsA[3].SetMask( new wxMask(bitmapMask) );
885         toolBarBitmapsA[4].SetMask( new wxMask(bitmapMask) );
886         toolBarBitmapsA[5].SetMask( new wxMask(bitmapMask) );
887
888
889     toolBarBitmapsB[  0 ] = wxBITMAP( TOOLBAR_V2_bi_re_IRMQuantification );
890     toolBarBitmapsB[  1 ] = wxBITMAP( TOOLBAR_V2_bi_re_CTQuantification  );
891     toolBarBitmapsB[  2 ] = wxBITMAP( TOOLBAR_V2_bi_re_VascularTree              );
892     toolBarBitmapsB[  3 ] = wxBITMAP( TOOLBAR_V2_bi_re_STLFormat                 );
893     toolBarBitmapsB[  4 ] = wxBITMAP( TOOLBAR_V2_bi_re_Tests                     );
894     toolBarBitmapsB[  5 ] = wxBITMAP( TOOLBAR_V2_bi_re_ManualRegistration);
895
896         toolBarBitmapsB[0].SetMask( new wxMask(bitmapMask) );
897         toolBarBitmapsB[1].SetMask( new wxMask(bitmapMask) );
898         toolBarBitmapsB[2].SetMask( new wxMask(bitmapMask) );
899         toolBarBitmapsB[3].SetMask( new wxMask(bitmapMask) );
900         toolBarBitmapsB[4].SetMask( new wxMask(bitmapMask) );
901         toolBarBitmapsB[5].SetMask( new wxMask(bitmapMask) );
902
903
904         // IRM Quantification
905     btnIRMQuant = new wxBitmapButton( this, -1, toolBarBitmapsA[ 0 ],wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|wxBU_BOTTOM );
906         btnIRMQuant->SetBitmapSelected(toolBarBitmapsB[ 0 ]);
907
908         // CT Quantification
909     btnCTQuant = new wxBitmapButton( this, -1, toolBarBitmapsA[ 1 ],wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|wxBU_BOTTOM );      
910         btnCTQuant->SetBitmapSelected(toolBarBitmapsB[ 1 ]);
911
912         // Vascular Tree
913     btnVascularTree = new wxBitmapButton( this, -1, toolBarBitmapsA[ 2 ],wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|wxBU_BOTTOM ); 
914         btnVascularTree->SetBitmapSelected(toolBarBitmapsB[ 2 ]);
915
916         // STL
917     btnSTL = new wxBitmapButton( this, -1, toolBarBitmapsA[ 3 ],wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|wxBU_BOTTOM );  
918         btnSTL->SetBitmapSelected(toolBarBitmapsB[ 3 ]);
919
920         // Tests
921     btnTests = new wxBitmapButton( this, -1, toolBarBitmapsA[ 4 ],wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|wxBU_BOTTOM );        
922         btnTests->SetBitmapSelected(toolBarBitmapsB[ 4 ]);
923
924         // Tests2
925     btnManualRegistration = new wxBitmapButton( this, -1, toolBarBitmapsA[ 5 ],wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|wxBU_BOTTOM );   
926         btnManualRegistration->SetBitmapSelected(toolBarBitmapsB[ 5 ]);
927
928         wxBoxSizer *sizer= new wxBoxSizer(wxHORIZONTAL);
929         sizer->Add( btnIRMQuant                         , 1, wxALL, 0);
930         sizer->Add( btnCTQuant                          , 1, wxALL, 0);
931         sizer->Add( btnVascularTree                     , 1, wxALL, 0);
932         sizer->Add( btnSTL                                      , 1, wxALL, 0);
933         sizer->Add( btnManualRegistration       , 1, wxALL, 0);
934         sizer->Add( btnTests                            , 1, wxALL, 0);
935
936         this->SetAutoLayout(true);
937         this->SetSizer(sizer);
938         this->Layout(); 
939
940         Connect(btnIRMQuant->GetId()                    , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxProcessingImagesControl::OnActiveIRMQuantificationFrame                     );
941         Connect(btnCTQuant->GetId()                             , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxProcessingImagesControl::OnActiveCTQuantificationFrame                      );
942         Connect(btnVascularTree->GetId()                , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxProcessingImagesControl::OnActiveVascularTreeExtractionFrame        );
943         Connect(btnSTL->GetId()                                 , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxProcessingImagesControl::OnActiveSTLFormatFrame                                     );
944         Connect(btnManualRegistration->GetId()  , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxProcessingImagesControl::OnActiveTests2Frame                                        );
945         Connect(btnTests->GetId()                               , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxProcessingImagesControl::OnActiveTestsFrame                                         );
946 }
947
948 //----------------------------------------------------------------------------
949
950 wxProcessingImagesControl::~wxProcessingImagesControl()
951 {
952 }
953
954 //----------------------------------------------------------------------------
955 void wxProcessingImagesControl::OnActiveIRMQuantificationFrame(wxCommandEvent& event)
956 {
957         wxCommandEvent newevent(wxEVT_COMMAND_MENU_SELECTED,11112);
958         this->GetParent()->ProcessEvent(newevent);
959 //      _wxmaracasframe03->CreateWindowMDI(20);
960 }
961 //----------------------------------------------------------------------------
962 void wxProcessingImagesControl::OnActiveCTQuantificationFrame(wxCommandEvent& event)
963 {
964         wxCommandEvent newevent(wxEVT_COMMAND_MENU_SELECTED,11113);
965         this->GetParent()->ProcessEvent(newevent);
966 //      _wxmaracasframe03->CreateWindowMDI(30);
967 }
968 //----------------------------------------------------------------------------
969 void wxProcessingImagesControl::OnActiveVascularTreeExtractionFrame(wxCommandEvent& event)
970 {
971         wxCommandEvent newevent(wxEVT_COMMAND_MENU_SELECTED,11114);
972         this->GetParent()->ProcessEvent(newevent);
973 //      _wxmaracasframe03->CreateWindowMDI(40);
974 }
975 //----------------------------------------------------------------------------
976 void wxProcessingImagesControl::OnActiveSTLFormatFrame(wxCommandEvent& event)
977 {
978         wxCommandEvent newevent(wxEVT_COMMAND_MENU_SELECTED,11115);
979         this->GetParent()->ProcessEvent(newevent);
980 //      _wxmaracasframe03->CreateWindowMDI(50);
981 }
982 //----------------------------------------------------------------------------
983 void wxProcessingImagesControl::OnActiveTestsFrame(wxCommandEvent& event)
984 {
985         wxCommandEvent newevent(wxEVT_COMMAND_MENU_SELECTED,11116);
986         this->GetParent()->ProcessEvent(newevent);
987 //      _wxmaracasframe03->CreateWindowMDI(60);
988 }
989 //----------------------------------------------------------------------------
990 void wxProcessingImagesControl::OnActiveTests2Frame(wxCommandEvent& event)
991 {
992         wxCommandEvent newevent(wxEVT_COMMAND_MENU_SELECTED,11117);
993         this->GetParent()->ProcessEvent(newevent);
994 //      _wxmaracasframe03->CreateWindowMDI(60);
995 }
996
997
998
999 //----------------------------------------------------------------------------
1000 //----------------------------------------------------------------------------
1001 //----------------------------------------------------------------------------
1002
1003
1004 wxProcessingImagesTabControl::wxProcessingImagesTabControl(wxWindow *parent,marInterface *mar,wxMaracasNoteBookPatientLstVoi  *patientlstvoi)
1005 : wxPanel (parent,-1)
1006 {
1007
1008         _mar                            =       mar;
1009         _patientlstvoi                  =       patientlstvoi;
1010         _irmQuantification              =       NULL;
1011         _ctQuantification               =       NULL;
1012         _vascularTreeExtraction         =       NULL;
1013         _stlFormat                      =       NULL;
1014
1015         _noteBook = new wxNotebook(this, -1);
1016         _noteBook->SetSize(750,300);
1017
1018         wxBitmap bitmapMask = wxBITMAP( TOOLBAR_V2_bi_mask );
1019
1020         wxBitmap bitmap0 = wxBITMAP( TOOLBAR_V2_bi_bl_Information);
1021         wxBitmap bitmap1 = wxBITMAP( TOOLBAR_V2_bi_bl_IRMQuantification);
1022         wxBitmap bitmap2 = wxBITMAP( TOOLBAR_V2_bi_bl_CTQuantification);
1023         wxBitmap bitmap3 = wxBITMAP( TOOLBAR_V2_bi_bl_VascularTree);
1024         wxBitmap bitmap4 = wxBITMAP( TOOLBAR_V2_bi_bl_STLFormat);
1025
1026         bitmap0.SetMask( new wxMask(bitmapMask) );
1027         bitmap1.SetMask( new wxMask(bitmapMask) );
1028         bitmap2.SetMask( new wxMask(bitmapMask) );
1029         bitmap3.SetMask( new wxMask(bitmapMask) );
1030         bitmap4.SetMask( new wxMask(bitmapMask) );
1031
1032         wxImageList *imageList = new wxImageList(100,100);
1033         imageList->Add( bitmap0 );  // 0
1034         imageList->Add( bitmap1 );  // 1
1035         imageList->Add( bitmap2 );  // 2
1036         imageList->Add( bitmap3 );  // 3
1037         imageList->Add( bitmap4 );  // 4
1038         _noteBook->SetImageList(imageList);
1039
1040         _noteBook->AddPage(new wxPanel(this,-1),_T("Information  ")             , true, 0 );
1041         _noteBook->AddPage(new wxPanel(this,-1),_T("IRM Quantification")        , true, 1 );
1042         _noteBook->AddPage(new wxPanel(this,-1),_T("CT Quantification")         , true, 2 );
1043         _noteBook->AddPage(new wxPanel(this,-1),_T("Vascular Tree")             , true, 3 );
1044         _noteBook->AddPage(new wxPanel(this,-1),_T("STL Format")                , true, 4 );
1045         _noteBook->SetSelection(0);
1046
1047         Connect(_noteBook->GetId() , wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING  , (wxObjectEventFunction) &wxProcessingImagesTabControl::OnChangingPage );
1048         Connect(_noteBook->GetId() , wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED   , (wxObjectEventFunction) &wxProcessingImagesTabControl::OnChangePage );
1049
1050         wxBoxSizer *sizer= new wxBoxSizer(wxVERTICAL);
1051         sizer->Add( _noteBook           , 1, wxALL|wxEXPAND, 0);
1052
1053         this->SetAutoLayout(true);
1054         this->SetSizer(sizer);
1055         this->Layout(); 
1056 }
1057
1058 //----------------------------------------------------------------------------
1059
1060 wxProcessingImagesTabControl::~wxProcessingImagesTabControl()
1061 {
1062 }
1063
1064 //----------------------------------------------------------------------------
1065 void wxProcessingImagesTabControl::OnChangingPage(wxNotebookEvent& event)
1066 {
1067 }
1068 //----------------------------------------------------------------------------
1069 void wxProcessingImagesTabControl::OnChangePage(wxNotebookEvent& event)
1070 {
1071         wxBusyCursor wait;
1072         if (_noteBook->GetSelection()==1)
1073         {
1074                 if (_irmQuantification==NULL){
1075                         int page=1;
1076                         int voi[ 6 ];
1077                         wxMaracasImageBrowser02 *imageBrowser= _patientlstvoi->GetWxMaracasImageBrowser02();
1078                         imageBrowser->ForceToFinisReadActiveImages( );
1079                         imageBrowser->GetROI( voi );
1080                         _mar->_experiment->setVOI( voi );
1081                         _irmQuantification = new wxMaracasNoteBookIRMQuantification(_noteBook->GetPage(page),_mar);
1082                         wxBoxSizer *sizer= new wxBoxSizer(wxHORIZONTAL);
1083                         sizer->Add( _irmQuantification , 1, wxALL|wxEXPAND, 0); 
1084                         _noteBook->GetPage(page)->SetAutoLayout(true);
1085                         _noteBook->GetPage(page)->SetSizer(sizer);
1086                         _noteBook->GetPage(page)->Layout();             
1087                 }
1088         }
1089         if (_noteBook->GetSelection()==2)
1090         {
1091                 if (_ctQuantification==NULL){
1092                         int page=2;
1093                         int voi[ 6 ];
1094                         wxMaracasImageBrowser02 *imageBrowser= _patientlstvoi->GetWxMaracasImageBrowser02();
1095                         imageBrowser->ForceToFinisReadActiveImages( );
1096                         imageBrowser->GetROI( voi );
1097                         _mar->_experiment->setVOI( voi );
1098                         string namefileParent=_patientlstvoi->GetRWCM_namefileVOI();
1099                         _ctQuantification = new wxMaracasNoteBookCTQuantification(_noteBook->GetPage(page),_mar,namefileParent);
1100                         wxBoxSizer *sizer= new wxBoxSizer(wxHORIZONTAL);
1101                         sizer->Add( _ctQuantification , 1, wxALL|wxGROW, 0);    
1102                         _noteBook->GetPage(page)->SetAutoLayout(true);
1103                         _noteBook->GetPage(page)->SetSizer(sizer);
1104                         _noteBook->GetPage(page)->Layout();             
1105                 }
1106         }
1107
1108         if (_noteBook->GetSelection()==3)
1109         {
1110                 if (_vascularTreeExtraction==NULL){
1111                         int page=3;
1112                         int voi[ 6 ];
1113                         wxMaracasImageBrowser02 *imageBrowser= _patientlstvoi->GetWxMaracasImageBrowser02();
1114                         imageBrowser->ForceToFinisReadActiveImages( );
1115                         imageBrowser->GetROI( voi );
1116                         _mar->_experiment->setVOI( voi );
1117                         _vascularTreeExtraction = new wxMaracasNoteBookVascularTreeExtraction(_noteBook->GetPage(page),_mar);
1118                         wxBoxSizer *sizer= new wxBoxSizer(wxHORIZONTAL);
1119                         sizer->Add( _vascularTreeExtraction , 1, wxALL|wxGROW, 0);      
1120                         _noteBook->GetPage(page)->SetAutoLayout(true);
1121                         _noteBook->GetPage(page)->SetSizer(sizer);
1122                         _noteBook->GetPage(page)->Layout();             
1123                 }
1124         }
1125
1126         if (_noteBook->GetSelection()==4)
1127         {
1128                 if (_stlFormat==NULL){
1129                         int page=4;
1130                         int voi[ 6 ];
1131                         wxMaracasImageBrowser02 *imageBrowser= _patientlstvoi->GetWxMaracasImageBrowser02();
1132                         imageBrowser->ForceToFinisReadActiveImages( );
1133                         imageBrowser->GetROI( voi );
1134                         _mar->_experiment->setVOI( voi );
1135                         _stlFormat = new wxMaracasNoteBookSTLFormat(_noteBook->GetPage(page),_mar);
1136                         wxBoxSizer *sizer= new wxBoxSizer(wxHORIZONTAL);
1137                         sizer->Add( _stlFormat , 1, wxALL|wxGROW, 0);   
1138                         _noteBook->GetPage(page)->SetAutoLayout(true);
1139                         _noteBook->GetPage(page)->SetSizer(sizer);
1140                         _noteBook->GetPage(page)->Layout();             
1141                 }
1142         }
1143         Refresh();
1144 }
1145
1146
1147 //----------------------------------------------------------------------------
1148 //----------------------------------------------------------------------------
1149 //----------------------------------------------------------------------------
1150
1151
1152 BEGIN_EVENT_TABLE(wxMaracasFrame03, wxMDIParentFrame)
1153 // Borrame
1154 //    EVT_MENU(MDI_CHILD_QUIT, MyChild::OnQuit)
1155 //    EVT_MENU(MDI_REFRESH, MyChild::OnRefresh)
1156 //    EVT_MENU(MDI_CHANGE_TITLE, MyChild::OnChangeTitle)
1157 //    EVT_MENU(MDI_CHANGE_POSITION, MyChild::OnChangePosition)
1158 //    EVT_MENU(MDI_CHANGE_SIZE, MyChild::OnChangeSize)
1159       EVT_MENU(20002, wxMaracasFrame03::OnActiveProcessingModules)
1160
1161           EVT_MENU(ID_WXILPD_BUTTON_DELETE_ALL_DB                       , wxMaracasFrame03::eventMenuDeleteAllPatientInDB)
1162           EVT_MENU(ID_WXILPD_BUTTON_DELETE_DB                           , wxMaracasFrame03::eventMenuDeletePatientInDB)
1163
1164           EVT_MENU(ID_WXILPD_BUTTON_FILTER_DB                           , wxMaracasFrame03::OnFilterInDB)
1165           EVT_MENU(ID_WXILPD_BUTTON_ORDERING_DB                         , wxMaracasFrame03::OnOrderingInDB)
1166           EVT_MENU(ID_WXILPD_BUTTON_EDIT_COLUMN                         , wxMaracasFrame03::OnEditColumnsInDB)
1167
1168
1169 //      EVT_SIZE(wxMaracasFrame03::OnSize)
1170 //    EVT_MOVE(MyChild::OnMove)
1171
1172 //    EVT_CLOSE(wxMaracasPatientLstVoiChiFra::OnClose)
1173
1174
1175       EVT_MENU(11110                    , wxMaracasFrame03::OnActivePatientListVoiFrame                 )
1176       EVT_MENU(11111                    , wxMaracasFrame03::OnActiveProcessingFrame                             )
1177       EVT_MENU(11112                    , wxMaracasFrame03::OnActiveIRMQuantificationFrame              )
1178       EVT_MENU(11113                    , wxMaracasFrame03::OnActiveCTQuantificationFrame               )
1179       EVT_MENU(11114                    , wxMaracasFrame03::OnActiveVascularTreeExtractionFrame )
1180       EVT_MENU(11115                    , wxMaracasFrame03::OnActiveSTLFormatFrame                              )
1181       EVT_MENU(11116                    , wxMaracasFrame03::OnActiveTestsFrame                                  )
1182       EVT_MENU(11117                    , wxMaracasFrame03::OnActiveTests2Frame                                 )
1183
1184       EVT_MENU(MDI_PARAMETERS   , wxMaracasFrame03::OnActiveParams                                              )
1185       EVT_MENU(MDI_ABOUT                , wxMaracasFrame03::OnActiveAbout                                               )
1186       EVT_MENU(MDI_QUIT                 , wxMaracasFrame03::OnActiveQuit                                                )
1187 END_EVENT_TABLE()
1188
1189
1190
1191
1192 wxMaracasFrame03::wxMaracasFrame03( wxFrame *parent, wxWindowID id, 
1193                                 marInterface *mar, char *dictionaryFileName,
1194                                 const wxString& title, const wxPoint& pos, 
1195                                 const wxSize& size, long style) 
1196        : wxMDIParentFrame(parent, id, title, pos, size,
1197                           style | wxNO_FULL_REPAINT_ON_RESIZE)
1198 {
1199
1200         wxFont font=wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT );
1201
1202         _mar                            = mar;
1203         _option_menu                    = NULL;
1204         _manualRegistrationPanel        = NULL;
1205
1206         marDictionary marDict;
1207 //      marDict.LoadDictionary_French();
1208         marDict.LoadDictionary_English();
1209 //      marDict.LoadDictionary_Japanese();
1210
1211 //    CreateToolBar(wxNO_BORDER | wxTB_FLAT | wxTB_HORIZONTAL);
1212 //    InitToolBar(GetToolBar());
1213
1214         CreateWindowMDI(0);
1215         Configure_WindowMDI(0);
1216 }
1217 //----------------------------------------------------------------------------
1218 wxMaracasFrame03::~wxMaracasFrame03()
1219 {
1220 }
1221
1222
1223 //----------------------------------------------------------------------------
1224
1225 void wxMaracasFrame03::eventMenuDeleteAllPatientInDB(wxCommandEvent& event)
1226 {
1227         if (_patientlstvoi->GetNoteBook()->GetSelection()==0)
1228         {
1229                 if (_patientlstvoi->GetWxILPD()->GetNotebook()->GetSelection()==0)
1230                 {
1231                         _patientlstvoi->GetWxILPD()->eventBtnDeleteAllPatientInDB(event);
1232                 }
1233         }
1234 }
1235
1236 //----------------------------------------------------------------------------
1237
1238 void wxMaracasFrame03::eventMenuDeletePatientInDB(wxCommandEvent& event)
1239 {
1240         if (_patientlstvoi->GetNoteBook()->GetSelection()==0)
1241         {
1242                 if (_patientlstvoi->GetWxILPD()->GetNotebook()->GetSelection()==0)
1243                 {
1244                         _patientlstvoi->GetWxILPD()->eventBtnDeletePatientInDB(event);
1245                 }
1246         }
1247 }
1248
1249 //----------------------------------------------------------------------------
1250
1251 void wxMaracasFrame03::OnFilterInDB(wxCommandEvent& event)
1252 {
1253         if (_patientlstvoi->GetNoteBook()->GetSelection()==0)
1254         {
1255                 if (_patientlstvoi->GetWxILPD()->GetNotebook()->GetSelection()==0)
1256                 {
1257                         _patientlstvoi->GetWxILPD()->OnFilter(event);
1258                 }
1259         }
1260 }
1261 //----------------------------------------------------------------------------
1262 void wxMaracasFrame03::OnOrderingInDB(wxCommandEvent& event)
1263 {
1264         if (_patientlstvoi->GetNoteBook()->GetSelection()==0)
1265         {
1266                 if (_patientlstvoi->GetWxILPD()->GetNotebook()->GetSelection()==0)
1267                 {
1268                         _patientlstvoi->GetWxILPD()->OnOrdering(event);
1269                 }
1270         }
1271 }
1272 //----------------------------------------------------------------------------
1273 void wxMaracasFrame03::OnEditColumnsInDB(wxCommandEvent& event)
1274 {
1275         if (_patientlstvoi->GetNoteBook()->GetSelection()==0)
1276         {
1277                 if (_patientlstvoi->GetWxILPD()->GetNotebook()->GetSelection()==0)
1278                 {
1279                         _patientlstvoi->GetWxILPD()->OnEditColumns(event);
1280                 }
1281         }
1282 }
1283
1284
1285
1286 //----------------------------------------------------------------------------
1287 void wxMaracasFrame03::OnActiveProcessingModules(wxCommandEvent& event)
1288 {
1289 /*
1290         _btnProcessingData      -> Enable();
1291         _btnCTQuant                     -> Enable();
1292         _btnIRMQuant            -> Enable();
1293         _btnTreeExtrac          -> Enable();
1294         _btnSTLFormat           -> Enable();
1295 */
1296         if (_option_menu!=NULL)
1297         {
1298                 _option_menu->Enable(11111, true );
1299                 _option_menu->Enable(11112, true );
1300                 _option_menu->Enable(11113, true );
1301                 _option_menu->Enable(11114, true );
1302                 _option_menu->Enable(11115, true );
1303                 _option_menu->Enable(11116, true );
1304         }
1305 }
1306
1307 //----------------------------------------------------------------------------
1308 void wxMaracasFrame03::InitToolBar(wxToolBar* toolBar)
1309 {
1310
1311     // Set up toolbar
1312     wxBitmap toolBarBitmapsA[ 8+1 ];
1313     wxBitmap toolBarBitmapsB[ 8+1 ];
1314
1315     toolBarBitmapsA[  0 ] = wxBITMAP( TOOLBAR_V2_bi_bl_ListPatient_Voi   );
1316     toolBarBitmapsA[  1 ] = wxBITMAP( TOOLBAR_V2_bi_bl_Processing        );
1317     toolBarBitmapsA[  2 ] = wxBITMAP( TOOLBAR_V2_bi_bl_Params                    );
1318     toolBarBitmapsA[  3 ] = wxBITMAP( TOOLBAR_V2_bi_bl_Logo                      );
1319     toolBarBitmapsA[  4 ] = wxBITMAP( TOOLBAR_V2_bi_bl_IRMQuantification );
1320     toolBarBitmapsA[  5 ] = wxBITMAP( TOOLBAR_V2_bi_bl_CTQuantification  );
1321     toolBarBitmapsA[  6 ] = wxBITMAP( TOOLBAR_V2_bi_bl_VascularTree              );
1322     toolBarBitmapsA[  7 ] = wxBITMAP( TOOLBAR_V2_bi_bl_STLFormat                 );
1323     toolBarBitmapsA[  8 ] = wxBITMAP( TOOLBAR_V2_bi_bl_ManualRegistration);
1324
1325     toolBarBitmapsB[  0 ] = wxBITMAP( TOOLBAR_V2_bi_re_ListPatient_Voi   );
1326     toolBarBitmapsB[  1 ] = wxBITMAP( TOOLBAR_V2_bi_re_Processing        );
1327     toolBarBitmapsB[  2 ] = wxBITMAP( TOOLBAR_V2_bi_re_Params            );
1328     toolBarBitmapsB[  3 ] = wxBITMAP( TOOLBAR_V2_bi_re_Logo              );
1329     toolBarBitmapsB[  4 ] = wxBITMAP( TOOLBAR_V2_bi_re_IRMQuantification );
1330     toolBarBitmapsB[  5 ] = wxBITMAP( TOOLBAR_V2_bi_re_CTQuantification  );
1331     toolBarBitmapsB[  6 ] = wxBITMAP( TOOLBAR_V2_bi_re_VascularTree              );
1332     toolBarBitmapsB[  7 ] = wxBITMAP( TOOLBAR_V2_bi_re_STLFormat                 );
1333     toolBarBitmapsB[  8 ] = wxBITMAP( TOOLBAR_V2_bi_re_ManualRegistration);
1334
1335     // Set size & margins
1336     toolBar->SetMargins( 5, 5 );
1337     toolBar->SetToolBitmapSize( wxSize( toolBarBitmapsA[0].GetWidth()+20, toolBarBitmapsA[0].GetHeight()+20 ) );
1338
1339     // List Patient
1340     wxBitmapButton *btn0 = new wxBitmapButton( toolBar, -1, toolBarBitmapsA[ 0 ],wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|wxBU_BOTTOM );
1341         btn0->SetBitmapSelected(toolBarBitmapsB[ 0 ]);
1342
1343     // Processing data
1344     _btnProcessingData = new wxBitmapButton( toolBar, -1, toolBarBitmapsA[ 1 ]);
1345         _btnProcessingData->SetBitmapSelected(toolBarBitmapsB[ 1 ]);
1346         _btnProcessingData->Disable();
1347
1348         // Params
1349     wxBitmapButton *btn2 = new wxBitmapButton( toolBar, -1, toolBarBitmapsA[ 2 ],wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|wxBU_BOTTOM );
1350         btn2->SetBitmapSelected(toolBarBitmapsB[ 2 ]);
1351
1352         // Logo Creatis
1353     wxBitmapButton *btn3 = new wxBitmapButton( toolBar, -1, toolBarBitmapsA[ 3 ],wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|wxBU_BOTTOM );
1354         btn3->SetBitmapSelected(toolBarBitmapsB[ 3 ]);
1355
1356         // IRM Quantification
1357     _btnIRMQuant = new wxBitmapButton( toolBar, -1, toolBarBitmapsA[ 4 ],wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|wxBU_BOTTOM );
1358         _btnIRMQuant->SetBitmapSelected(toolBarBitmapsB[ 4 ]);
1359         _btnIRMQuant->Disable();
1360
1361         // CT Quantification
1362     _btnCTQuant = new wxBitmapButton( toolBar, -1, toolBarBitmapsA[ 5 ],wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|wxBU_BOTTOM );
1363         _btnCTQuant->SetBitmapSelected(toolBarBitmapsB[ 5 ]);
1364         _btnCTQuant->Disable();
1365
1366         // Vascular Tree Extraction
1367     _btnTreeExtrac = new wxBitmapButton( toolBar, -1, toolBarBitmapsA[ 6 ],wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|wxBU_BOTTOM );
1368         _btnTreeExtrac->SetBitmapSelected(toolBarBitmapsB[ 6 ]);
1369         _btnTreeExtrac->Disable();
1370
1371         // STL Format
1372     _btnSTLFormat = new wxBitmapButton( toolBar, -1, toolBarBitmapsA[ 7 ],wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|wxBU_BOTTOM );
1373         _btnSTLFormat->SetBitmapSelected(toolBarBitmapsB[ 7 ]);
1374         _btnSTLFormat->Disable();
1375
1376     toolBar->AddControl( btn0                           );
1377     toolBar->AddControl( _btnProcessingData );
1378     toolBar->AddSeparator( );
1379     toolBar->AddControl( _btnIRMQuant           );
1380     toolBar->AddControl( _btnCTQuant            );
1381     toolBar->AddControl( _btnTreeExtrac         );
1382     toolBar->AddControl( _btnSTLFormat          );
1383     toolBar->AddSeparator( );
1384     toolBar->AddControl( btn2                           );
1385     toolBar->AddControl( btn3                           );
1386
1387         toolBar->Realize();
1388 //      toolBar->SetBackgroundColour( wxColour(130,130,130) );
1389
1390         Connect(btn0->GetId()                           , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxMaracasFrame03::OnActivePatientListVoiFrame                 );
1391         Connect(_btnProcessingData->GetId()     , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxMaracasFrame03::OnActiveProcessingFrame                             );
1392         Connect(btn2->GetId()                           , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxMaracasFrame03::OnActiveParams                                              );
1393         Connect(btn3->GetId()                           , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxMaracasFrame03::OnActiveAbout                                               );
1394         Connect(_btnIRMQuant->GetId()           , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxMaracasFrame03::OnActiveIRMQuantificationFrame              );
1395         Connect(_btnCTQuant->GetId()            , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxMaracasFrame03::OnActiveCTQuantificationFrame               );
1396         Connect(_btnTreeExtrac->GetId()         , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxMaracasFrame03::OnActiveVascularTreeExtractionFrame );
1397         Connect(_btnSTLFormat->GetId()          , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxMaracasFrame03::OnActiveSTLFormatFrame                              );
1398
1399
1400
1401 }
1402 //----------------------------------------------------------------------------
1403
1404 wxMenuBar *wxMaracasFrame03::CreateMenuBarBase(){
1405     // Make a menubar
1406     wxMenu *file_menu = new wxMenu;
1407
1408     file_menu->Append(MDI_QUIT, _T("&Exit"));
1409
1410     wxMenu *help_menu = new wxMenu;
1411     help_menu->Append(MDI_PARAMETERS    , _T("Pa&rameters"));
1412     help_menu->Append(MDI_ABOUT                 , _T("&About"));
1413
1414     wxMenuBar *menu_bar = new wxMenuBar;
1415     menu_bar->Append(file_menu   , _T("&File"));
1416     menu_bar->Append(help_menu   , _T("&Help"));
1417
1418         return menu_bar;   
1419 }
1420 //----------------------------------------------------------------------------
1421 void wxMaracasFrame03::OnActivePatientListVoiFrame(wxCommandEvent& event)
1422 {
1423         _frame_ListPatieint_Voi->Maximize();
1424 }
1425 //----------------------------------------------------------------------------
1426 void wxMaracasFrame03::OnActiveProcessingFrame(wxCommandEvent& event)
1427 {
1428         CreateWindowMDI(10);
1429         CreateWindowMDI(11);
1430 }
1431 //----------------------------------------------------------------------------
1432 void wxMaracasFrame03::OnActiveParams(wxCommandEvent& event)
1433 {
1434   wxMaracasParametersDialog *d = new wxMaracasParametersDialog( this, _mar );
1435   d->ShowModal( );
1436   d->Close( true );
1437 }
1438 //----------------------------------------------------------------------------
1439 void wxMaracasFrame03::OnActiveAbout(wxCommandEvent& event)
1440 {
1441   wxMaracasHelpDialog* help = new wxMaracasHelpDialog(this, -1);
1442   help->ShowModal();
1443 }
1444 //----------------------------------------------------------------------------
1445 void wxMaracasFrame03::OnActiveQuit(wxCommandEvent& event)
1446 {
1447         this->Close();
1448 }
1449
1450 //----------------------------------------------------------------------------
1451 void wxMaracasFrame03::OnActiveIRMQuantificationFrame(wxCommandEvent& event)
1452 {
1453         CreateWindowMDI(20);
1454 }
1455 //----------------------------------------------------------------------------
1456 void wxMaracasFrame03::OnActiveCTQuantificationFrame(wxCommandEvent& event)
1457 {
1458         CreateWindowMDI(30);
1459 }
1460 //----------------------------------------------------------------------------
1461 void wxMaracasFrame03::OnActiveVascularTreeExtractionFrame(wxCommandEvent& event)
1462 {
1463         CreateWindowMDI(40);
1464 }
1465 //----------------------------------------------------------------------------
1466 void wxMaracasFrame03::OnActiveSTLFormatFrame(wxCommandEvent& event)
1467 {
1468         CreateWindowMDI(50);
1469 }
1470 //----------------------------------------------------------------------------
1471 void wxMaracasFrame03::OnActiveTestsFrame(wxCommandEvent& event)
1472 {
1473         CreateWindowMDI(60);
1474 }
1475 //----------------------------------------------------------------------------
1476 void wxMaracasFrame03::OnActiveTests2Frame(wxCommandEvent& event)
1477 {
1478         CreateWindowMDI(70);
1479 }
1480
1481
1482 //----------------------------------------------------------------------------
1483 void wxMaracasFrame03::CreateWindowMDI( int type)
1484 {
1485 //    wxMaracasGenericChiFra *subframe=NULL;
1486     wxFrame                *subframe=NULL;
1487         wxString title_sf;
1488
1489         // Patient List
1490         if (type==0){
1491                 wxMaracasGenericChiFra *subframeTMP=NULL;
1492                 subframeTMP = new wxMaracasGenericChiFra(this, _T("..."),
1493                                                         wxPoint(50, 50), wxSize(300, 300),wxDEFAULT_FRAME_STYLE  );
1494                 subframeTMP->SetBlockCloseEvent(true);
1495                 subframe=subframeTMP;
1496                 subframe->Maximize();
1497                 _patientlstvoi = new wxMaracasNoteBookPatientLstVoi(subframe);
1498                 _patientlstvoi->SetMarInterface(_mar);
1499                 _frame_ListPatieint_Voi=subframe;
1500             title_sf=_T("Patient List");
1501
1502                 wxMenu *database_menu = new wxMenu();
1503                 database_menu->Append( ID_WXILPD_BUTTON_DELETE_ALL_DB   , _T("Delete all patients"));
1504                 database_menu->Append( ID_WXILPD_BUTTON_DELETE_DB               , _T("Delete Patient"));
1505                 database_menu->AppendSeparator();
1506                 database_menu->Append( ID_WXILPD_BUTTON_FILTER_DB               , _T("Filter"));
1507                 database_menu->Append( ID_WXILPD_BUTTON_ORDERING_DB             , _T("Ordering"));
1508                 database_menu->Append( ID_WXILPD_BUTTON_EDIT_COLUMN             , _T("Edit Column"));
1509
1510
1511                 _option_menu = new wxMenu;
1512                 _option_menu->Append(11110, _T("Patient &List - Voi"));
1513                 _option_menu->Append(11111, _T("&Processing"));
1514                 _option_menu->AppendSeparator();
1515                 _option_menu->Append(11112, _T("&IRM Quantification"));
1516                 _option_menu->Append(11113, _T("&CT Quantification"));
1517                 _option_menu->AppendSeparator();
1518                 _option_menu->Append(11114, _T("&Vascular Tree Extraction"));
1519                 _option_menu->AppendSeparator();
1520                 _option_menu->Append(11115, _T("&STL"));
1521                 _option_menu->AppendSeparator();
1522                 _option_menu->Append(11116, _T("&Tests"));
1523
1524                 _option_menu->Enable(11111, false );
1525                 _option_menu->Enable(11112, false );
1526                 _option_menu->Enable(11113, false );
1527                 _option_menu->Enable(11114, false );
1528                 _option_menu->Enable(11115, false );
1529                 _option_menu->Enable(11116, false );
1530
1531                 wxMenuBar *menu_bar = CreateMenuBarBase();
1532
1533                 subframe->SetMenuBar(menu_bar);
1534                 menu_bar->Insert(2,database_menu,_T("Data Base") );
1535                 menu_bar->Insert(2,_option_menu,_T("Options") );
1536         }
1537
1538         // Processing 1
1539         if (type==10){
1540 #ifdef WIN32
1541                 subframe = new wxMaracasGenericChiFra(this, _T("..."),wxPoint(-1, -1),wxSize(225, 260),wxDEFAULT_FRAME_STYLE);
1542                 wxMenuBar *menu_bar = CreateMenuBarBase();
1543                 subframe->SetMenuBar(menu_bar);
1544 #else
1545                 subframe = new wxFrame(this, -1, _T("..."));
1546 #endif
1547                 new wxProcessingImagesControl(subframe);
1548                 title_sf=_T("Processing Images");
1549         }
1550
1551         // Processing 2
1552         if (type==11){
1553 #ifdef WIN32
1554                 subframe = new wxMaracasGenericChiFra(this, _T("..."),wxPoint(-1, -1),wxSize(750, 600),wxDEFAULT_FRAME_STYLE);
1555                 wxMenuBar *menu_bar = CreateMenuBarBase();
1556                 subframe->SetMenuBar(menu_bar);
1557 #else
1558                 subframe = new wxFrame(this, -1, _T("..."));
1559 #endif
1560                 subframe->Maximize();
1561                 new wxProcessingImagesTabControl(subframe,_mar,_patientlstvoi);
1562                 title_sf=_T("Processing Images");
1563         }
1564
1565         // IRM Quantification 
1566         if (type==20){
1567                 wxBusyCursor wait;
1568                 int voi[ 6 ];
1569                 wxMaracasImageBrowser02 *imageBrowser= _patientlstvoi->GetWxMaracasImageBrowser02();
1570                 imageBrowser->ForceToFinisReadActiveImages( );
1571                 imageBrowser->GetROI( voi );
1572                 _mar->_experiment->setVOI( voi );
1573
1574 #ifdef WIN32
1575                 subframe = new wxMaracasGenericChiFra(this, _T("..."),wxPoint(-1, -1),wxSize(750, 600),wxDEFAULT_FRAME_STYLE);
1576                 wxMenuBar *menu_bar = CreateMenuBarBase();
1577                 subframe->SetMenuBar(menu_bar);
1578 #else
1579                 subframe = new wxFrame(this, -1, _T("..."));
1580 #endif
1581
1582                 subframe->Maximize();
1583                 wxMaracasNoteBookIRMQuantification *irmQuantification = new wxMaracasNoteBookIRMQuantification(subframe,_mar);
1584                 title_sf=_T("IRM Quantification");
1585         }
1586
1587         // CT Quantification 
1588         if (type==30){
1589                 wxBusyCursor wait;
1590                 int voi[ 6 ];
1591
1592 //EEDx11
1593                 wxMaracasImageBrowser02 *imageBrowser= _patientlstvoi->GetWxMaracasImageBrowser02();
1594                 imageBrowser->ForceToFinisReadActiveImages( );
1595                 imageBrowser->GetROI( voi );
1596                 _mar->_experiment->setVOI( voi );
1597
1598 #ifdef WIN32
1599                 subframe = new wxMaracasGenericChiFra(this, _T("..."),wxPoint(-1, -1),wxSize(750, 600),wxDEFAULT_FRAME_STYLE);
1600                 wxMenuBar *menu_bar = CreateMenuBarBase();
1601                 subframe->SetMenuBar(menu_bar);
1602 #else
1603                 subframe = new wxFrame(this, -1, _T("..."));
1604 #endif
1605
1606                 subframe->Maximize();
1607
1608 //EEDx11
1609                 string namefileParent=_patientlstvoi->GetRWCM_namefileVOI();
1610                 wxMaracasNoteBookCTQuantification *ctQuantification = new wxMaracasNoteBookCTQuantification(subframe,_mar,namefileParent);
1611                 title_sf=_T("CT Quantification");
1612         }
1613
1614         // Vascular Tree Extraction 
1615         if (type==40){
1616                 wxBusyCursor wait;
1617                 int voi[ 6 ];
1618 //EEDx11
1619                 wxMaracasImageBrowser02 *imageBrowser= _patientlstvoi->GetWxMaracasImageBrowser02();
1620                 imageBrowser->ForceToFinisReadActiveImages( );
1621                 imageBrowser->GetROI( voi );
1622                 _mar->_experiment->setVOI( voi );
1623
1624
1625 #ifdef WIN32
1626                 subframe = new wxMaracasGenericChiFra(this, _T("..."),wxPoint(-1, -1),wxSize(750, 600),wxDEFAULT_FRAME_STYLE);
1627                 wxMenuBar *menu_bar = CreateMenuBarBase();
1628                 subframe->SetMenuBar(menu_bar);
1629 #else
1630                 subframe = new wxFrame(this, -1, _T("..."));
1631 #endif
1632                 subframe->Maximize();
1633 //EEDx11
1634                 wxMaracasNoteBookVascularTreeExtraction *vascularTreeExtraction = new wxMaracasNoteBookVascularTreeExtraction(subframe,_mar);
1635                 title_sf=_T("Vascular Tree Extraction");
1636
1637         }
1638         
1639         // STL Format  
1640         if (type==50){
1641                 wxBusyCursor wait;
1642                 int voi[ 6 ];
1643
1644 //EEDx11
1645                 wxMaracasImageBrowser02 *imageBrowser= _patientlstvoi->GetWxMaracasImageBrowser02();
1646                 imageBrowser->ForceToFinisReadActiveImages( );
1647                 imageBrowser->GetROI( voi );
1648                 _mar->_experiment->setVOI( voi );
1649
1650
1651
1652 #ifdef WIN32
1653                 subframe = new wxMaracasGenericChiFra(this, _T("..."),wxPoint(-1, -1),wxSize(750, 600),wxDEFAULT_FRAME_STYLE);
1654                 wxMenuBar *menu_bar = CreateMenuBarBase();
1655                 subframe->SetMenuBar(menu_bar);
1656 #else
1657                 subframe = new wxFrame(this, -1, _T("..."));
1658 #endif
1659
1660                 subframe->Maximize();
1661 //EEDx11
1662                 wxMaracasNoteBookSTLFormat *stlFormat = new wxMaracasNoteBookSTLFormat(subframe,_mar);
1663
1664                 title_sf=_T("STL Format");
1665         }
1666
1667         
1668         // Test Format  
1669         if (type==60){
1670                 wxBusyCursor wait;
1671                 int voi[ 6 ];
1672                 wxMaracasImageBrowser02 *imageBrowser= _patientlstvoi->GetWxMaracasImageBrowser02();
1673                 imageBrowser->ForceToFinisReadActiveImages( );
1674                 imageBrowser->GetROI( voi );
1675                 _mar->_experiment->setVOI( voi );
1676
1677 #ifdef WIN32
1678                 subframe = new wxMaracasGenericChiFra(this, _T("..."),wxPoint(-1, -1),wxSize(750, 600),wxDEFAULT_FRAME_STYLE);
1679                 wxMenuBar *menu_bar = CreateMenuBarBase();
1680                 subframe->SetMenuBar(menu_bar);
1681 #else
1682                 subframe = new wxFrame(this, -1, _T("..."));
1683 #endif
1684
1685                 subframe->Maximize();
1686                 wxMaracasNoteBookTests *testsPanel = new wxMaracasNoteBookTests(subframe,_mar);
1687                 title_sf=_T("Tests");
1688         }
1689
1690 // EED 7 Nov 2006
1691         // Test2 Format  
1692         if (type==70){
1693                 bool ok=false;
1694
1695                 if (_manualRegistrationPanel==NULL)
1696                 {
1697                         ok=true;
1698                 } else {
1699                         if ( _manualRegistrationPanel->GetIfSecondVolumeExist()==true )
1700                         {
1701                                 ok=true;
1702                         } else {
1703                                 _manualRegistrationPanel->GenerateSecondVolume(_mar);
1704                                 _manualRegistrationPanel=NULL;
1705                         }
1706                 }
1707
1708                 if (ok==true){
1709                         wxBusyCursor wait;
1710                         int voi[ 6 ];
1711                         wxMaracasImageBrowser02 *imageBrowser= _patientlstvoi->GetWxMaracasImageBrowser02();
1712                         imageBrowser->ForceToFinisReadActiveImages( );
1713                         imageBrowser->GetROI( voi );
1714                         _mar->_experiment->setVOI( voi );
1715
1716 #ifdef WIN32
1717                         subframe = new wxMaracasGenericChiFra(this, _T("..."),wxPoint(-1, -1),wxSize(750, 600),wxDEFAULT_FRAME_STYLE);
1718                         wxMenuBar *menu_bar = CreateMenuBarBase();
1719                         subframe->SetMenuBar(menu_bar);
1720 #else
1721                         subframe = new wxFrame(this, -1, _T("..."));
1722 #endif
1723
1724                         subframe->Maximize();
1725                         _manualRegistrationPanel = new wxMaracasNoteBookManualRegistration(subframe,_mar);
1726                         title_sf=_T("Manual registration");
1727                 }
1728         }
1729
1730
1731
1732         if (subframe!=NULL)
1733         {
1734                 subframe->SetTitle(title_sf);
1735                 subframe->CreateStatusBar();
1736                 subframe->SetStatusText(title_sf);
1737                 subframe->Show(TRUE);
1738         }
1739
1740
1741 }
1742
1743 //----------------------------------------------------------------------------
1744
1745 void wxMaracasFrame03::Configure_WindowMDI( int type)
1746 {
1747         if (type==0)
1748         {
1749 //              _patientlstvoi->Configure();
1750         }
1751 }
1752
1753
1754 //----------------------------------------------------------------------------
1755 //----------------------------------------------------------------------------
1756 //----------------------------------------------------------------------------
1757
1758
1759 BEGIN_EVENT_TABLE(wxMaracasGenericChiFra, wxMDIChildFrame)
1760 // Borrame
1761 //    EVT_MENU(MDI_CHILD_QUIT, MyChild::OnQuit)
1762 //    EVT_MENU(MDI_REFRESH, MyChild::OnRefresh)
1763 //    EVT_MENU(MDI_CHANGE_TITLE, MyChild::OnChangeTitle)
1764 //    EVT_MENU(MDI_CHANGE_POSITION, MyChild::OnChangePosition)
1765 //    EVT_MENU(MDI_CHANGE_SIZE, MyChild::OnChangeSize)
1766
1767 //    EVT_SIZE(MyChild::OnSize)
1768 //    EVT_MOVE(MyChild::OnMove)
1769
1770     EVT_CLOSE(wxMaracasGenericChiFra::OnClose)
1771 END_EVENT_TABLE()
1772
1773
1774 wxMaracasGenericChiFra::wxMaracasGenericChiFra(wxMDIParentFrame *parent, const wxString& title,
1775                  const wxPoint& pos, const wxSize& size,
1776                  const long style)
1777        : wxMDIChildFrame(parent, -1, title, pos, size,
1778                          style | wxNO_FULL_REPAINT_ON_RESIZE)
1779 {
1780         _blockClose=false;
1781 }
1782 //----------------------------------------------------------------------------
1783 wxMaracasGenericChiFra::~wxMaracasGenericChiFra()
1784 {
1785         wxMDIParentFrame *parent = (wxMDIParentFrame*)GetParent();
1786         parent->ActivateNext();
1787 }
1788
1789
1790 //----------------------------------------------------------------------------
1791 void wxMaracasGenericChiFra::OnClose(wxCloseEvent& event)
1792 {
1793         if (_blockClose==true){
1794                 wxMessageDialog msg(this, _T("You can't close this window.."), _T("Message box"), wxOK );
1795                 msg.ShowModal();
1796                 event.Veto();
1797                 return;
1798         } else {
1799                 event.Skip();
1800         }
1801 }
1802 //----------------------------------------------------------------------------
1803 void wxMaracasGenericChiFra::SetBlockCloseEvent(bool blockClose)
1804 {
1805         _blockClose=blockClose;
1806 }
1807
1808 //----------------------------------------------------------------------------
1809 //----------------------------------------------------------------------------
1810 //----------------------------------------------------------------------------
1811
1812 // EED 3 Nov 2006
1813
1814
1815 FileInfoNode::FileInfoNode(string filename, string dirfile)
1816 {
1817         _filename               = filename;
1818         _filenameParent = "";
1819         _dirfile                = dirfile;
1820 }
1821 //----------------------------------------------------------------------------
1822 FileInfoNode::~FileInfoNode()
1823 {
1824 }
1825 //----------------------------------------------------------------------------
1826 string FileInfoNode::GetFileName()
1827 {
1828         return _filename;
1829 }
1830 //----------------------------------------------------------------------------
1831 string FileInfoNode::GetFileNameParent()
1832 {
1833         return _filenameParent;
1834 }
1835 //----------------------------------------------------------------------------
1836 void FileInfoNode::SetFileNameParent(string parent)
1837 {
1838         _filenameParent=parent;
1839 }
1840 //----------------------------------------------------------------------------
1841 string FileInfoNode::GetDirFile()
1842 {
1843         return _dirfile;
1844 }
1845
1846 //----------------------------------------------------------------------------
1847 //----------------------------------------------------------------------------
1848 //----------------------------------------------------------------------------
1849
1850 FileInformationModel::FileInformationModel()
1851 {
1852 }
1853 //----------------------------------------------------------------------------
1854 FileInformationModel::~FileInformationModel()
1855 {
1856 }
1857 //----------------------------------------------------------------------------
1858 int     FileInformationModel::GetSizeLstFile_filter()
1859 {
1860         int count=0;
1861         int i,size = _lstFileInfoNodes.size();
1862         for ( i=0 ; i<size ; i++ )
1863         {
1864                 if (_lstFileInfoNodes[i]->GetFileNameParent()==_filtre_1)
1865                 {
1866                         count++;
1867                 }
1868         }
1869         return count;
1870 }
1871 //----------------------------------------------------------------------------
1872 string FileInformationModel::GetFileName_filter(int i)
1873 {
1874         string result;
1875         int count=0;
1876         int ii,size = _lstFileInfoNodes.size();
1877         for ( ii=0 ; ii<size ; ii++ )
1878         {
1879                 if ( (_lstFileInfoNodes[ii]->GetFileNameParent()==_filtre_1) && (count==i) )
1880                 {
1881                         result=_lstFileInfoNodes[ii]->GetFileName();
1882                         break;
1883                 }
1884
1885                 if (_lstFileInfoNodes[ii]->GetFileNameParent()==_filtre_1)
1886                 {
1887                         count++;
1888                 }
1889         }
1890         return result;
1891 }
1892 //----------------------------------------------------------------------------
1893 int     FileInformationModel::GetSizeLstFile()
1894 {
1895         return _lstFileInfoNodes.size();
1896 }
1897 //----------------------------------------------------------------------------
1898 string FileInformationModel::GetFileName(int i)
1899 {
1900         return _lstFileInfoNodes[i]->GetFileName();
1901 }
1902 //----------------------------------------------------------------------------
1903 void FileInformationModel::ResetModel()
1904 {
1905         int i,size=_lstFileInfoNodes.size();
1906         for(i=0;i<size;i++)
1907         {
1908                 delete _lstFileInfoNodes[i];
1909         }
1910         _lstFileInfoNodes.clear();
1911 }
1912 //----------------------------------------------------------------------------
1913 void FileInformationModel::ReadModel(string dirFile)
1914 {
1915         ResetModel();
1916
1917         wxString wxdirfile( wxString(dirFile.c_str() , wxConvUTF8) );
1918         wxDir dir(wxdirfile);
1919     if ( !dir.IsOpened() )
1920     {
1921         // deal with the error here - wxDir would already log an error message
1922         // explaining the exact reason of the failure
1923         return;
1924     }
1925         wxString filename=_T("");
1926     bool cont = dir.GetFirst(&filename, _T("*.MaracasInfo"));
1927     while ( cont )
1928     {
1929                 _lstFileInfoNodes.push_back( new FileInfoNode( (const char*)(filename.mb_str()) , dirFile) );
1930                 filename=_T("");
1931         cont = dir.GetNext( &filename );
1932     }
1933         LinkRelations();
1934 }
1935 //----------------------------------------------------------------------------
1936 void FileInformationModel::Filtre_1(string filtre)
1937 {
1938         _filtre_1=filtre;
1939 }
1940
1941 //----------------------------------------------------------------------------
1942 void FileInformationModel::LinkRelations()
1943 {
1944         char tmp[255];
1945         FILE *ff;
1946         string filename;
1947         string dirfile;
1948         string name;
1949         int i,size=_lstFileInfoNodes.size();
1950         for(i=0;i<size;i++)
1951         {
1952                 filename        = _lstFileInfoNodes[i]->GetFileName();
1953                 dirfile         = _lstFileInfoNodes[i]->GetDirFile();
1954                 name=dirfile+"/";
1955                 name=name+filename;
1956                 ff=fopen(name.c_str(),"r+");
1957                 fscanf(ff,"%s",tmp);
1958                 fscanf(ff,"%s",tmp);
1959                 fscanf(ff,"%s",tmp);
1960                 _lstFileInfoNodes[i]->SetFileNameParent(tmp);
1961                 fclose(ff);
1962         }
1963 }
1964
1965
1966
1967 //----------------------------------------------------------------------------
1968 //----------------------------------------------------------------------------
1969 //----------------------------------------------------------------------------
1970
1971 string wxReadWriteConf::_workDirectory  =       "c:/Maracas_configuration/";
1972
1973
1974 wxReadWriteConf::wxReadWriteConf(wxWindow *parent,string parentFile)
1975 : wxDialog(parent, -1, wxString(_T("Read-Write Configuration")) ,wxDefaultPosition,wxSize(800,400), wxRESIZE_BORDER|wxDEFAULT_DIALOG_STYLE  )
1976 {
1977         _parentFile = parentFile;
1978         wxButton *btnDirectory = new wxButton(this,-1,_T("Directory"));
1979         _directoryTXT = new wxStaticText(this , -1 , wxString(_workDirectory.c_str(), wxConvUTF8) );
1980
1981         wxString tempTXT(_T("Parent File:  "));
1982         tempTXT=tempTXT +  wxString(_parentFile.c_str(), wxConvUTF8);
1983         wxStaticText *parentFileTXT = new wxStaticText(this , -1 , tempTXT );
1984         Connect(btnDirectory->GetId(),wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction) &wxReadWriteConf::eventBtnWorkDirectory);
1985         wxWindow *wxwindow = CreateReadModule(this);    
1986         wxBoxSizer *sizerA = new wxBoxSizer(wxHORIZONTAL);
1987         sizerA->Add(parentFileTXT,1,wxALL,5);
1988         wxBoxSizer *sizerB = new wxBoxSizer(wxHORIZONTAL);
1989         sizerB->Add(btnDirectory,1,wxALL,5);
1990         sizerB->Add(_directoryTXT,1,wxALL,10);
1991
1992         wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
1993         sizer->Add(sizerA,0,wxALL,0);
1994         sizer->Add(sizerB,0,wxALL,5);
1995         sizer->Add(wxwindow,1,wxGROW|wxEXPAND,0);
1996         this->SetSizer(sizer);
1997         this->Layout(); 
1998
1999         _nameReadFile="";
2000         _fim = new FileInformationModel();
2001         ResetView();
2002 }
2003 //----------------------------------------------------------------------------
2004 wxReadWriteConf::~wxReadWriteConf()
2005 {
2006 }
2007 //----------------------------------------------------------------------------
2008 void wxReadWriteConf::ResetView()
2009 {
2010         _fim->Filtre_1(_parentFile);
2011         _fim->ReadModel(_workDirectory);
2012         RefreshReadFilesList();
2013         RefreshAllFilesList();
2014 }
2015 //----------------------------------------------------------------------------
2016 wxWindow *wxReadWriteConf::CreateReadModule(wxWindow *parent)
2017 {
2018         wxPanel *panel = new wxPanel(parent,-1);
2019
2020         _wxviewinfo= new wxTextCtrl(panel,-1,_T(""),wxDefaultPosition,wxDefaultSize,wxTE_MULTILINE|wxHSCROLL  );
2021
2022         wxBoxSizer * sizer = new wxBoxSizer(wxHORIZONTAL);
2023         sizer->Add( CreateListFilesModule(panel), 1,wxGROW|wxEXPAND,0 );
2024         sizer->Add( _wxviewinfo , 1,wxEXPAND,0 );
2025
2026         panel->SetSizer(sizer);
2027         panel->Layout();        
2028
2029         return panel;
2030 }
2031
2032 //----------------------------------------------------------------------------
2033 wxWindow *wxReadWriteConf::CreateListFilesModule(wxWindow *parent)
2034 {
2035         wxPanel *panel                  = new wxPanel(parent,-1);
2036         wxNotebook *notebook    = new wxNotebook(panel,-1); 
2037         notebook->AddPage( CreateReadFileModule(notebook) ,wxString(_T("Read File")));
2038         notebook->AddPage( CreateListAllFilesModule(notebook) ,wxString(_T("All files")));
2039         notebook->AddPage( new wxPanel(notebook,-1) ,wxString(_T("Files Relation")));
2040         wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
2041         sizer->Add(notebook,1,wxEXPAND|wxGROW,0);
2042         panel->SetSizer(sizer);
2043         panel->Layout();        
2044         return panel;
2045 }
2046 //----------------------------------------------------------------------------
2047 wxWindow *wxReadWriteConf::CreateReadFileModule(wxWindow *parent)
2048 {
2049         wxPanel *panel = new wxPanel(parent,-1);
2050                                  _wxlstFiles    =       new wxListBox( panel ,  -1 , wxDefaultPosition , wxSize(900,900) );
2051         wxButton        *btnReadFile    =       new wxButton(panel, -1, _T("    Read \n information file") );
2052         wxButton        *btnWriteFile   =       new wxButton(panel, -1, _T("    Create \n new file information"));
2053         wxButton        *btnReWriteFile =       new wxButton(panel, -1, _T("    ReWrite \n file information"));
2054
2055
2056         Connect(_wxlstFiles->GetId(),wxEVT_COMMAND_LISTBOX_SELECTED ,(wxObjectEventFunction) &wxReadWriteConf::OnShowFile01);
2057         Connect(_wxlstFiles->GetId(),wxEVT_COMMAND_LISTBOX_DOUBLECLICKED ,(wxObjectEventFunction) &wxReadWriteConf::eventBtnReadFile);
2058          
2059         Connect(btnReadFile->GetId(),wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction) &wxReadWriteConf::eventBtnReadFile);
2060         Connect(btnWriteFile->GetId(),wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction) &wxReadWriteConf::eventBtnWriteFile);
2061         Connect(btnReWriteFile->GetId(),wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction) &wxReadWriteConf::eventBtnReWriteFile);
2062
2063         wxBoxSizer *sizerB                      =       new wxBoxSizer(wxHORIZONTAL);
2064         sizerB->Add( btnReadFile , 1 , wxALL|wxALIGN_CENTER|wxEXPAND , 5 );
2065         sizerB->Add( btnWriteFile , 1 , wxALL|wxALIGN_CENTER|wxEXPAND , 5 );
2066         sizerB->Add( btnReWriteFile , 1 , wxALL|wxALIGN_CENTER|wxEXPAND , 5 );
2067         wxBoxSizer *sizer                       =       new wxBoxSizer(wxVERTICAL);
2068         sizer->Add( _wxlstFiles , 1 , wxGROW | wxEXPAND , 0 );
2069         sizer->Add( sizerB , 0 , wxALIGN_CENTER , 5 );
2070         panel->SetSizer(sizer);
2071         panel->Layout();        
2072         return panel;
2073 }
2074
2075 //----------------------------------------------------------------------------
2076 wxWindow *wxReadWriteConf::CreateListAllFilesModule(wxWindow *parent)
2077 {
2078         wxPanel *panel                  =       new wxPanel(parent,-1);
2079                         _wxlstAllFiles  =       new wxListBox( panel ,  -1 , wxDefaultPosition , wxSize(900,900) );
2080
2081         Connect(_wxlstAllFiles->GetId(),wxEVT_COMMAND_LISTBOX_SELECTED ,(wxObjectEventFunction) &wxReadWriteConf::OnShowFile02);
2082
2083         wxBoxSizer *sizer                       =       new wxBoxSizer(wxVERTICAL);
2084         sizer->Add( _wxlstAllFiles , 1 , wxGROW | wxEXPAND , 0 );
2085         panel->SetSizer(sizer);
2086         panel->Layout();        
2087         return panel;
2088 }
2089
2090 //----------------------------------------------------------------------------
2091 void wxReadWriteConf::eventBtnReadFile(wxCommandEvent &event)
2092 {
2093         if (_nameReadFile!="")
2094         {
2095                 wxCommandEvent newevent(wxEVT_COMMAND_MENU_SELECTED,30002);
2096                 this->GetParent()->ProcessEvent(newevent);
2097                 this->Close();
2098         }
2099 }
2100 //----------------------------------------------------------------------------
2101 void wxReadWriteConf::eventBtnReWriteFile(wxCommandEvent &event)
2102 {       
2103         _nameWriteFile=_nameReadFile;
2104         int sizeStr=_nameWriteFile.length() - string(".MaracasInfo").length();
2105     _nameWriteFile = _nameWriteFile.substr(0,sizeStr);
2106
2107         if (_nameWriteFile!="")
2108         {
2109                 wxString msg(_nameReadFile.c_str(), wxConvUTF8);
2110                 msg = msg+_T("\n\n\nYou really want to modify this file ?");
2111                 int result = wxMessageDialog(this,msg,_T("Warning.."),wxOK | wxCANCEL).ShowModal();
2112                 if (result==wxID_OK){
2113                         wxCommandEvent newevent(wxEVT_COMMAND_MENU_SELECTED,30001);
2114                         this->GetParent()->ProcessEvent(newevent);
2115                         this->ResetView();
2116                         this->Close();
2117                 }
2118         } else {
2119                 wxMessageDialog(this,_T("First, you have to select a file."),_T("Warning.."), wxOK).ShowModal();
2120         }
2121 }
2122 //----------------------------------------------------------------------------
2123 void wxReadWriteConf::eventBtnWriteFile(wxCommandEvent &event)
2124 {
2125         wxTextEntryDialog *filedlg = new wxTextEntryDialog(this, _T("Write MaracaInfo"));
2126         if(filedlg->ShowModal() == wxID_OK)
2127     {   
2128                 wxBusyCursor wait;
2129                 string nameFile( (const char*)(filedlg->GetValue().mb_str()) );
2130                 if (nameFile!=""){
2131
2132                         string name = _workDirectory+"/"+nameFile+".MaracasInfo";
2133                         FILE *ff=fopen( name.c_str() , "r+" );
2134                         if (ff!=NULL)
2135                         {
2136                                 fclose(ff);
2137                                 wxMessageDialog(this,_T("...Error... \n\nThis file already exists."),_T("Error.."), wxOK).ShowModal();
2138                         } else {
2139                                 _nameWriteFile=nameFile;
2140                                 wxCommandEvent newevent(wxEVT_COMMAND_MENU_SELECTED,30001);
2141                                 this->GetParent()->ProcessEvent(newevent);
2142                                 this->ResetView();
2143                                 this->Close();
2144                         } 
2145                 }
2146     }
2147
2148 }
2149 //----------------------------------------------------------------------------
2150 void wxReadWriteConf::OnShowFile01(wxCommandEvent &event)
2151 {
2152         int id=_wxlstFiles->GetSelection();
2153         if (id!=-1){
2154                 _nameReadFile = (const char*)(_wxlstFiles->GetString(id).mb_str());
2155                 ShowInformation(_wxlstFiles,_wxviewinfo);
2156         }
2157 }
2158 //----------------------------------------------------------------------------
2159 void wxReadWriteConf::OnShowFile02(wxCommandEvent &event)
2160 {
2161         ShowInformation(_wxlstAllFiles,_wxviewinfo);
2162 }
2163 //----------------------------------------------------------------------------
2164 void wxReadWriteConf::ShowInformation(wxListBox *wxlistbox , wxTextCtrl* wxtextctrl )
2165 {
2166         int id=wxlistbox->GetSelection();
2167         if (id!=-1){
2168                 string namefile = (const char*)(wxlistbox->GetString(id).mb_str());
2169                 if (namefile!=""){
2170                         wxString text;
2171                         char tmp[255];
2172                         FILE *ff;
2173                         string nf(this->_workDirectory);
2174                         nf=nf+"/";
2175                         nf=nf+namefile.c_str();
2176
2177                         text = wxString(nf.c_str(), wxConvUTF8);
2178                         text = text + _T("\n--------------------------------------------\n");
2179
2180                         ff=fopen(nf.c_str(),"r+");
2181                         while (!feof(ff)){
2182                                 strcpy(tmp,"");
2183                                 fgets(tmp,255,ff);
2184                                 text = text + wxString(tmp, wxConvUTF8);
2185                         }
2186                         fclose(ff);
2187
2188                         wxtextctrl->SetValue(text);
2189                 }
2190         }
2191 }
2192 //----------------------------------------------------------------------------
2193 void wxReadWriteConf::eventBtnWorkDirectory(wxCommandEvent &event)
2194 {
2195
2196
2197         wxDirDialog *filedlg = new wxDirDialog(this, _T("Work Directory"), wxString(_workDirectory.c_str(), wxConvUTF8) );
2198         if(filedlg->ShowModal() == wxID_OK)
2199     {   
2200                 wxBusyCursor wait;
2201                 _workDirectory = (const char*)(filedlg->GetPath().mb_str());
2202                 _directoryTXT->SetLabel( wxString(_workDirectory.c_str(), wxConvUTF8) );
2203                 ResetView();
2204         }
2205 }
2206 //----------------------------------------------------------------------------
2207 void wxReadWriteConf::RefreshReadFilesList()
2208 {
2209         _wxlstFiles->Clear();
2210         wxString wxfilename;
2211         int i,size = _fim->GetSizeLstFile_filter();
2212         for (i=0; i<size; i++)
2213         {
2214                 _wxlstFiles->Append( wxString(_fim->GetFileName_filter(i).c_str(), wxConvUTF8) );
2215         }
2216 }
2217 //----------------------------------------------------------------------------
2218 void wxReadWriteConf::RefreshAllFilesList()
2219 {
2220         _wxlstAllFiles->Clear();
2221         wxString wxfilename;
2222         int i,size = _fim->GetSizeLstFile();
2223         for (i=0; i<size; i++)
2224         {
2225                 _wxlstAllFiles->Append( wxString(_fim->GetFileName(i).c_str(), wxConvUTF8) );
2226         }
2227 }
2228 //----------------------------------------------------------------------------
2229 string wxReadWriteConf::GetNameWriteFile()
2230 {
2231         return _nameWriteFile;
2232 }
2233 //----------------------------------------------------------------------------
2234 string wxReadWriteConf::GetNameReadFile()
2235 {
2236         return _nameReadFile;
2237 }
2238
2239 //----------------------------------------------------------------------------
2240 string wxReadWriteConf::GetWorkDirectory()
2241 {
2242         return _workDirectory;
2243 }
2244
2245 string wxReadWriteConf::GetParentFile()
2246 {
2247         return _parentFile;
2248 }
2249
2250 //----------------------------------------------------------------------------
2251 //----------------------------------------------------------------------------
2252 //----------------------------------------------------------------------------
2253
2254
2255 BEGIN_EVENT_TABLE(wxMaracasNoteBookPatientLstVoi , wxPanel)
2256 // Borrame
2257 //    EVT_MENU(MDI_CHILD_QUIT, MyChild::OnQuit)
2258 //    EVT_MENU(MDI_REFRESH, MyChild::OnRefresh)
2259 //    EVT_MENU(MDI_CHANGE_TITLE, MyChild::OnChangeTitle)
2260 //    EVT_MENU(MDI_CHANGE_POSITION, MyChild::OnChangePosition)
2261 //    EVT_MENU(MDI_CHANGE_SIZE, MyChild::OnChangeSize)
2262 //      EVT_MENU(20001, wxMaracasNoteBookPatientLstVoi::OnSelectPatientStudySerieImage)
2263
2264 //    EVT_SIZE(MyChild::OnSize)
2265 //    EVT_MOVE(MyChild::OnMove)
2266
2267 //    EVT_CLOSE(wxMaracasPatientLstVoiChiFra::OnClose)
2268
2269       EVT_MENU(30001, wxMaracasNoteBookPatientLstVoi::OnPersistence_Write)
2270       EVT_MENU(30002, wxMaracasNoteBookPatientLstVoi::OnPersistence_Read)
2271
2272
2273 END_EVENT_TABLE()
2274
2275
2276 wxMaracasNoteBookPatientLstVoi::wxMaracasNoteBookPatientLstVoi(wxWindow *parent)
2277        : wxPanel(parent, -1)
2278 {
2279
2280         this->SetAutoLayout(true);
2281
2282
2283 //EED 4 oct 2006
2284         _marRAWFiles                            = NULL;
2285         _marRAW2Files                           = NULL;
2286         _marRAW2AsciiFiles                      = NULL;
2287         _marGdcmDicomILPD                       = NULL;
2288
2289
2290 // EED 14 Nov 2006
2291         _wxreadwriteconf=NULL;
2292
2293
2294         _wxMaracasMPR                           = NULL;
2295         _wxMaracasImageBrowser02        = NULL;
2296         _mar2                                           = NULL;
2297
2298         _widgetMesure                           = NULL;
2299 //EED 15Avril2008               _wxvtk2Dbaseview                        = NULL;
2300 //EED 15Avril2008               _vtkbasedata                            = NULL; 
2301
2302         _backStringFirstFile                    = "";
2303         _backStringFirstFile2                   = "";
2304
2305         _voiBack[0]=_voiBack[1]=_voiBack[2]=_voiBack[3]=_voiBack[4]=_voiBack[5]=-1;
2306         
2307         _noteBook = new wxNotebook(this, -1);
2308
2309         _noteBook->SetSize(750,300);
2310         wxImageList *imageList = new wxImageList(50,50);
2311
2312         wxBitmap mask= wxBITMAP( TOOLBAR_V2_sm_mask );
2313
2314         wxBitmap bitmap0        = wxBITMAP( TOOLBAR_V2_sm_bl_ListPatient );
2315         wxBitmap bitmap1        = wxBITMAP( TOOLBAR_V2_sm_re_ListPatient );
2316         wxBitmap bitmap2        = wxBITMAP( TOOLBAR_V2_sm_re_ListPatient );
2317         wxBitmap bitmap3        = wxBITMAP( TOOLBAR_V2_sm_bl_voi );
2318         wxBitmap bitmap4        = wxBITMAP( TOOLBAR_V2_sm_re_voi );
2319         wxBitmap bitmap5        = wxBITMAP( TOOLBAR_V2_sm_tr_VOI );
2320         wxBitmap bitmap6        = wxBITMAP( TOOLBAR_V2_sm_bl_Processing );
2321         wxBitmap bitmap7        = wxBITMAP( TOOLBAR_V2_sm_bl_Processing );
2322         wxBitmap bitmap8        = wxBITMAP( TOOLBAR_V2_sm_tr_Processing );
2323         wxBitmap bitmap9        = wxBITMAP( TOOLBAR_V2_sm_bl_MPR );
2324         wxBitmap bitmap10       = wxBITMAP( TOOLBAR_V2_sm_bl_MPR );
2325         wxBitmap bitmap11       = wxBITMAP( TOOLBAR_V2_sm_tr_MPR );
2326
2327         bitmap0.SetMask(new wxMask( mask ));
2328         bitmap1.SetMask(new wxMask( mask ));
2329         bitmap2.SetMask(new wxMask( mask ));
2330         bitmap3.SetMask(new wxMask( mask ));
2331         bitmap4.SetMask(new wxMask( mask ));
2332         bitmap5.SetMask(new wxMask( mask ));
2333         bitmap6.SetMask(new wxMask( mask ));
2334         bitmap7.SetMask(new wxMask( mask ));
2335         bitmap8.SetMask(new wxMask( mask ));
2336         bitmap9.SetMask(new wxMask( mask ));
2337         bitmap10.SetMask(new wxMask( mask ));
2338         bitmap11.SetMask(new wxMask( mask ));
2339
2340         imageList->Add(  bitmap0        );      // 0
2341         imageList->Add(  bitmap1        );      // 1
2342         imageList->Add(  bitmap2        );      // 2
2343         imageList->Add(  bitmap3        );      // 3
2344         imageList->Add(  bitmap4        );      // 4
2345         imageList->Add(  bitmap4        );      // 5
2346         imageList->Add(  bitmap6        );      // 6
2347         imageList->Add(  bitmap7        );      // 7
2348         imageList->Add(  bitmap8        );      // 8
2349         imageList->Add(  bitmap9        );      // 9
2350         imageList->Add(  bitmap10       );      // 10
2351         imageList->Add(  bitmap11       );      // 11
2352         _noteBook->SetImageList(imageList);
2353
2354
2355 //EED 15Avril2008       wxPanel *panel_with_wxILPD = CreatePanel_WxILPD( _noteBook );
2356 //EED 15Avril2008    ILPDViewListPatient*       _ilpdViewListPatient    = new ILPDViewListPatient( new ILPDViewWxWindow(_wxILPD) );
2357
2358         wxILPDwithImage *panel_with_wxILPD = new wxILPDwithImage( _noteBook );
2359         panel_with_wxILPD->Configure();
2360         _wxILPD = panel_with_wxILPD->GetWxILPD();
2361
2362         wxProcessingImagesControl *processingCtrl               = new wxProcessingImagesControl(_noteBook);
2363
2364         _noteBook->AddPage( panel_with_wxILPD           , _T("Patient List  >>   ") , true, 0 );
2365         _noteBook->AddPage(new wxPanel(_noteBook,-1)    , _T("   View Image  >>  ") , true, 5 );
2366         _noteBook->AddPage(new wxPanel(_noteBook,-1)    , _T("   MPR      ")             , true, 11 );
2367         _noteBook->AddPage(processingCtrl               , _T("   Processing      ") , true, 8 );
2368         _noteBook->SetSelection(0);
2369
2370
2371         Connect(_noteBook->GetId() , wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING  , (wxObjectEventFunction) &wxMaracasNoteBookPatientLstVoi::OnChangePageToVOI );
2372         Connect(_noteBook->GetId() , wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED   , (wxObjectEventFunction) &wxMaracasNoteBookPatientLstVoi::OnChangePage );
2373
2374         wxStaticText *title=new wxStaticText(this,-1,_T("Load Patient Image "));
2375
2376 // It doesn't works in linux
2377 //      wxFont font(18,wxDEFAULT  , wxITALIC, wxBOLD);
2378 //      title->SetFont(font);
2379
2380 //EEDxx2.6
2381 //      wxNotebookSizer *nbs = new wxNotebookSizer( _noteBook );
2382
2383 // --
2384         wxButton *btnReadWriteConfig    = new wxButton(this,-1,_T("Read-Write Config"));
2385         Connect(btnReadWriteConfig->GetId() ,  wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxMaracasNoteBookPatientLstVoi::OnReadWriteConf_Maracas );
2386         wxButton *btnHelp                               = new wxButton(this,-1,_T("Help"));
2387         wxButton *btnClose                              = new wxButton(this,-1,_T("Close"))
2388                 ;
2389     wxBoxSizer *sizerB                          = new wxBoxSizer(wxHORIZONTAL);
2390         sizerB->Add( btnReadWriteConfig , 0, wxALIGN_RIGHT, 10);
2391         sizerB->Add( btnHelp                    , 0, wxALIGN_RIGHT, 10);
2392         sizerB->Add( btnClose                   , 0, wxALIGN_RIGHT, 10);
2393         
2394
2395     wxBoxSizer *sizer= new wxBoxSizer(wxVERTICAL);
2396         sizer->Add( sizerB              , 0, wxALIGN_RIGHT, 10);
2397         sizer->Add( title               , 0, wxEXPAND | wxALIGN_RIGHT, 10);
2398
2399         sizer->Add( _noteBook   , 3, wxGROW|wxALL, 10 );
2400
2401         this->SetSizer(sizer);
2402         this->Layout(); 
2403
2404 //EEDxx2.6
2405 //      FitInside();
2406
2407
2408 //      ConfigureVTK();
2409 }
2410 //----------------------------------------------------------------------------
2411 wxMaracasNoteBookPatientLstVoi::~wxMaracasNoteBookPatientLstVoi()
2412 {
2413
2414 //EED 15Avril2008               if (_vtkbasedata!=NULL)         {       delete  _vtkbasedata;           }
2415 //EED 15Avril2008           if (_wxvtk2Dbaseview!=NULL) {       delete  _wxvtk2Dbaseview;       }
2416
2417         if (_mar2!=NULL) 
2418         {
2419 //              delete _mar2;
2420         }
2421
2422 }
2423
2424
2425
2426
2427 //----------------------------------------------------------------------------
2428 void wxMaracasNoteBookPatientLstVoi::SetMarInterface(marInterface *mar)
2429 {
2430         _mar=mar;
2431 }
2432
2433
2434
2435 //----------------------------------------------------------------------------
2436
2437 void wxMaracasNoteBookPatientLstVoi::CreateMPRPanel()
2438 {
2439         wxBusyCursor wait;
2440         //  Create panel
2441         if (_wxMaracasMPR!=NULL)
2442         {
2443                 delete _wxMaracasMPR;
2444 //              delete _mar2;
2445         }
2446
2447         int voi[ 6 ];
2448         _wxMaracasImageBrowser02->ForceToFinisReadActiveImages( );
2449         _wxMaracasImageBrowser02->GetROI( voi );
2450         _mar->_experiment->setVOI( voi );
2451         _mar2=new marInterface();
2452
2453         _mar2->_parameters->setRescaleSlope( _mar->_parameters->getRescaleSlope() );
2454         _mar2->_parameters->setRescaleIntercept( _mar->_parameters->getRescaleIntercept() );
2455
2456
2457         double spcOriginalImage[3];
2458         spcOriginalImage[0]=_mar->_parameters->getDoubleParam(marParameters::e_voxel_x_dimension);
2459         spcOriginalImage[1]=_mar->_parameters->getDoubleParam(marParameters::e_voxel_y_dimension);
2460         spcOriginalImage[2]=_mar->_parameters->getDoubleParam(marParameters::e_voxel_z_dimension);
2461
2462 //EEDx1
2463 //      _mar2->_parameters->setDoubleParam( marParameters::e_voxel_x_dimension, _mar->_parameters->getDoubleParam(marParameters::e_voxel_x_dimension) );
2464         _mar2->_parameters->setIntParam( marParameters::e_voxel_type, marParameters::VOX_TYPE_MINIMUM );
2465         _mar2->_parameters->setDoubleParam( marParameters::e_voxel_x_dimension, spcOriginalImage[0] );
2466         _mar2->_parameters->setDoubleParam( marParameters::e_voxel_y_dimension, spcOriginalImage[1] );
2467         _mar2->_parameters->setDoubleParam( marParameters::e_voxel_z_dimension, spcOriginalImage[2] );
2468
2469         _mar->_experiment->getVOI( voi );
2470         _mar2->_experiment->setVOI( voi );
2471         _mar2->SetDicom(_mar->_dicom);
2472         _mar2->initExperiment( );
2473
2474         vtkImageData *imagedata;
2475         imagedata = _mar2->_experiment->getDynData( )->getVolume( )->castVtk();
2476         imagedata->Update(); 
2477
2478         marImageData *marimagedata =  new marImageData(imagedata);
2479         marimagedata->SetSpcOriginal(spcOriginalImage);
2480         marimagedata->SetVoiOriginal(voi);
2481
2482         _wxMaracasMPR = new wxMaracasMPR( _noteBook->GetPage(2), marimagedata , _mar2->_parameters->getVoxelSize( ) );
2483         _wxMaracasMPR->ConfigureVTK();
2484
2485         wxBoxSizer *sizer= new wxBoxSizer(wxHORIZONTAL);
2486         sizer->Add( _wxMaracasMPR , 1, wxALL|wxGROW, 0);        
2487         _noteBook->GetPage(2)->SetAutoLayout(true);
2488         _noteBook->GetPage(2)->SetSizer(sizer);
2489         _noteBook->GetPage(2)->Layout();        
2490 }
2491
2492
2493
2494
2495 //----------------------------------------------------------------------------
2496 void wxMaracasNoteBookPatientLstVoi::OnChangePage(wxNotebookEvent& event)
2497 {
2498         vector <string*> lstStringFileName;
2499         if ( (_noteBook->GetSelection()==2) && event.GetOldSelection()==1 )
2500         {
2501                 _wxILPD->GetLstImageFiles(&lstStringFileName);
2502                 if (lstStringFileName.size()!=0)
2503                 {
2504                         int voi[6];
2505                         _wxMaracasImageBrowser02->GetROI( voi );
2506                         if ( (_backStringFirstFile2!=*(lstStringFileName[0])) || 
2507                                  ( _voiBack[0]!=voi[0]) ||  ( _voiBack[1]!=voi[1]) || ( _voiBack[2]!=voi[2]) || 
2508                                  ( _voiBack[3]!=voi[3]) ||  ( _voiBack[4]!=voi[4]) || ( _voiBack[5]!=voi[5])   )
2509                         {
2510                                 _backStringFirstFile2=*(lstStringFileName[0]);
2511                                 _wxMaracasImageBrowser02->GetROI( _voiBack );
2512                                 CreateMPRPanel();
2513                         }
2514                 }
2515
2516         } else {
2517                 if ( (_noteBook->GetSelection()==2) && event.GetOldSelection()!=1 )
2518                 {
2519                         wxMessageDialog msg(this, _T("Before this, you have to select the VOI in View image module.."), _T("Message box"), wxOK );
2520                         msg.ShowModal();
2521                         _noteBook->SetSelection(1);
2522                 }
2523
2524         }
2525
2526 //      Refresh();
2527         _wxILPD->Refresh();
2528 }
2529 //----------------------------------------------------------------------------
2530 void wxMaracasNoteBookPatientLstVoi::OnChangePageToVOI(wxNotebookEvent& event)
2531 {
2532         //event.Skip();
2533
2534         if (_noteBook->GetSelection()==0){
2535
2536                 FILE *ff;
2537                 bool okFirst=true;
2538         //      bool okAllFileExists = true;
2539         //      int i;
2540                 string msgLstFile="";
2541
2542
2543                 //
2544         //EED 4 Oct 2006
2545                 if (_wxILPD->GetTypeOfReadFiles()==0)
2546                 {
2547                         if (_marGdcmDicomILPD==NULL)
2548                         {
2549                                 _marGdcmDicomILPD = new marGdcmDicomILPD( _mar->_parameters );
2550                         }
2551                         _mar->SetDicom(_marGdcmDicomILPD);
2552                 }
2553
2554                 //
2555         //EED 4 Oct 2006
2556                 if (_wxILPD->GetTypeOfReadFiles()==2)
2557                 {
2558
2559                         if ((_wxILPD->GetSubTypeOfReadFiles()==0) &&(_marRAWFiles==NULL))
2560                         {
2561                                 _marRAWFiles = new marRAWFiles( _mar->_parameters );
2562                                 _mar->SetDicom(_marRAWFiles);
2563                         }
2564
2565                         if ((_wxILPD->GetSubTypeOfReadFiles()==100) &&(_marGdcmDicomILPD==NULL))
2566                         {
2567                                 _marGdcmDicomILPD = new marGdcmDicomILPD( _mar->_parameters );
2568                                 _mar->SetDicom(_marGdcmDicomILPD);
2569                         }
2570
2571                         if ((_wxILPD->GetSubTypeOfReadFiles()==200) &&(_marRAW2Files==NULL))
2572                         {
2573                                 _marRAW2Files = new marRAW2Files( _mar->_parameters );
2574                                 _mar->SetDicom(_marRAW2Files);
2575                         }
2576                         if ((_wxILPD->GetSubTypeOfReadFiles()==300) &&(_marRAW2AsciiFiles==NULL))
2577                         {
2578                                 _marRAW2AsciiFiles = new marRAW2AsciiFiles( _mar->_parameters );
2579                                 _mar->SetDicom(_marRAW2AsciiFiles);
2580                         }
2581
2582                 }
2583
2584                 //
2585
2586                 if (_wxILPD->GetTypeOfSelection() == 3)
2587                 {
2588                         wxBusyCursor wait;
2589                         vector <string*> *lstStringFileName;
2590                         _mar->_dicom->CleanListImages();
2591                         lstStringFileName = _mar->_dicom->GetListImages( );
2592                         _wxILPD->GetLstImageFiles(lstStringFileName);
2593                         if (lstStringFileName->size()!=0)
2594                         {
2595
2596         //EED 9 oct 2006
2597         //                      marGdcmDicomILPD *margdcmdicomILPD = (marGdcmDicomILPD*)_mar->_dicom;
2598         //                      margdcmdicomILPD->SetListImages( &lstStringFileName );
2599
2600
2601                                 std::string *tmpStr=(*lstStringFileName)[0];
2602                                 if ( _backStringFirstFile!=*tmpStr )  
2603                                 {
2604                                         if (_wxILPD->GetTypeOfReadFiles()==0)
2605                                         {
2606                                                 _backStringFirstFile=*tmpStr;
2607                                         } else {
2608                                                 _backStringFirstFile="-1";
2609                                         }
2610                                         _noteBook->SetPageImage(1, 4);  // VOI Button Blue
2611                                         _noteBook->SetPageImage(2, 9);  // MPR Button Blue
2612                                         _noteBook->SetPageImage(3, 6);  // Processing Button Blue
2613
2614         /*
2615                                         // Verifying that the list of files exist
2616                                         for( i=0 ; i<lstStringFileName.size() ; i++ )
2617                                         {
2618                                                 ff = fopen(lstStringFileName[i]->c_str(),"r");  
2619                                                 if (ff!=NULL)
2620                                                 {
2621                                                         fclose(ff);
2622                                                 } else {
2623                                                         if (i==0)
2624                                                         {
2625                                                                 okFirst=false;
2626                                                                 break;
2627                                                         }
2628                                                         okAllFileExists = false;
2629                                                         msgLstFile = msgLstFile + lstStringFileName[i]->c_str()+ "\n";
2630                                                 }
2631                                         }
2632                                         if ((okAllFileExists == false) && (okFirst==true))
2633                                         {
2634                                                 wxDialog *dialog = new wxDialog( this , -1, wxString("The following files doesn't exist:"), wxDefaultPosition, wxSize(550,300),  wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER );
2635                                                 
2636                                                 wxTextCtrl *textCtrl = new wxTextCtrl(dialog, -1, msgLstFile.c_str() ,wxDefaultPosition , wxSize(100,100) , wxTE_MULTILINE | wxTE_READONLY );
2637                                                 textCtrl->SetSelection(0,0);
2638
2639                                                 wxBoxSizer *sizer       = new wxBoxSizer(wxVERTICAL  );
2640                                                 sizer->Add( textCtrl , 1, wxALL|wxEXPAND, 0);
2641                                                 dialog->SetAutoLayout(true);
2642                                                 dialog->SetSizer( sizer );      // use the sizer for layout
2643                                                 dialog->Layout(); 
2644                                                 dialog->FitInside();
2645                                                 dialog->ShowModal();
2646                                         }
2647         */
2648
2649                                         ff = fopen((*lstStringFileName)[0]->c_str(),"r");       
2650                                         if (ff!=NULL)
2651                                         {
2652                                                 fclose(ff);
2653                                         } else {
2654                                                 okFirst=false;
2655                                                 msgLstFile = msgLstFile + (*lstStringFileName)[0]->c_str()+ "\n";
2656                                         }
2657
2658                                         if (okFirst == false)
2659                                         {
2660                                                 msgLstFile = "The series is incomplete or does not exists.";
2661                                                 wxMessageDialog msgBox(this, wxString(msgLstFile.c_str(), wxConvUTF8), _T("Read file ERROR"), wxOK);
2662                                                 msgBox.ShowModal();
2663                                                 _backStringFirstFile="";
2664                                                 event.Veto();
2665                                         } else {
2666
2667                                                 //  Create panel
2668                                                 if (_wxMaracasImageBrowser02!=NULL)
2669                                                 {
2670                                                         delete _wxMaracasImageBrowser02;
2671                                                 }
2672                                                 _wxMaracasImageBrowser02 = new wxMaracasImageBrowser02( _noteBook->GetPage(1), _mar->_dicom, _mar->_parameters );
2673         //                                      _wxMaracasImageBrowser02->SetSize(600,600);     
2674
2675
2676                                                 _mar->_dicom->loadActualSerie( NULL/*this->_progressGauge*/ );
2677                                                 vtkImageData *dummy = _mar->_dicom->getVolume( )->castVtk();
2678                                                 _wxMaracasImageBrowser02->LoadData( new marImageData(dummy) );
2679                                                 _wxMaracasImageBrowser02->Start();
2680
2681                                                 wxBoxSizer *sizer= new wxBoxSizer(wxHORIZONTAL);
2682                                                 sizer->Add( _wxMaracasImageBrowser02 , 1, wxALL|wxGROW, 0);     
2683         //                                      _noteBook->GetPage(1)->SetAutoLayout(true);
2684                                                 _noteBook->GetPage(1)->SetSizer(sizer);
2685                                                 _noteBook->GetPage(1)->Layout();
2686         //                                      _wxMaracasImageBrowser02->Refresh();
2687         //                                      _wxMaracasImageBrowser02->Update();
2688         //EEDxx2.4
2689         //                                      _noteBook->GetPage(1)->FitInside();     
2690
2691                                                 
2692                                                 wxCommandEvent ev(wxEVT_COMMAND_MENU_SELECTED,20002);
2693                                                 this->ProcessEvent( ev );
2694
2695                                         }
2696
2697                                 }  // _backStringFirstFile
2698
2699                         } // if lstStringFileName.size
2700                 } else {
2701                         if (_wxMaracasImageBrowser02==NULL)
2702                         {
2703                                 wxMessageDialog msg(this, _T("You have to select a serie befor run this option.."), _T("Message box"), wxOK );
2704                                 msg.ShowModal();
2705                                 event.Veto();
2706                         }
2707                 }
2708         } //_noteBook->GetSelection()==0
2709 }
2710
2711 //----------------------------------------------------------------------------
2712 wxMaracasImageBrowser02* wxMaracasNoteBookPatientLstVoi::GetWxMaracasImageBrowser02()
2713 {
2714         return _wxMaracasImageBrowser02;
2715 }
2716
2717 //----------------------------------------------------------------------------
2718
2719 wxILPD  *wxMaracasNoteBookPatientLstVoi::GetWxILPD()
2720 {
2721         return _wxILPD;
2722 }
2723
2724 //----------------------------------------------------------------------------
2725 wxNotebook *wxMaracasNoteBookPatientLstVoi::GetNoteBook()
2726 {
2727         return this->_noteBook;
2728 }
2729
2730 //----------------------------------------------------------------------------
2731
2732 void wxMaracasNoteBookPatientLstVoi::OnReadWriteConf_Maracas(wxCommandEvent& event)
2733 {
2734         string parentFile;
2735         if (this->_noteBook->GetSelection()==0) // Read DICOM images
2736         {
2737                 parentFile="NULL";
2738         }
2739         if (this->_noteBook->GetSelection()==1)  // VOI
2740         {
2741                 parentFile=_RWCM_namefileReadImages;
2742         }
2743         if (parentFile!="")
2744         {
2745                 _wxreadwriteconf = new wxReadWriteConf(this,parentFile);
2746                 _wxreadwriteconf->ShowModal();
2747                 _wxreadwriteconf=NULL;
2748         } else {
2749                 wxMessageDialog(this,_T("No parent file defined..."),_T("Warning.."), wxOK).ShowModal();
2750         }
2751 }
2752
2753
2754
2755 //----------------------------------------------------------------------------
2756 void wxMaracasNoteBookPatientLstVoi::Persistence_Read_Images()
2757 {
2758         string name; 
2759         char tmp[255];
2760         _RWCM_namefileReadImages        = _wxreadwriteconf->GetNameReadFile();
2761         string directory        = _wxreadwriteconf->GetWorkDirectory();
2762         string file=directory + "/" + _RWCM_namefileReadImages;
2763         if (_RWCM_namefileReadImages!=""){
2764                 FILE *ff;
2765                 ff=fopen(file.c_str(),"r");
2766                 fscanf(ff,"%s ",tmp); // MaracasInfo
2767                 fscanf(ff,"%s ",tmp); // NameFileParent
2768                 fscanf(ff,"%s ",tmp); // xxxxxxxx
2769                 fscanf(ff,"%s ",tmp); // TypeOfReadFile
2770                 fscanf(ff,"%s ",tmp); // xxxx
2771                 int typeOfReadFile = atoi(tmp);
2772                 fscanf(ff,"%s ",tmp); // SubTypeOfReadFile
2773                 fscanf(ff,"%s ",tmp); // xxxx
2774                 int subTypeOfReadFile = atoi(tmp);
2775                 fscanf(ff,"%s ",tmp); // DirectoryManualFiles
2776                 fscanf(ff,"%s ",tmp); // xxxx
2777                 string  directory= tmp;
2778                 fscanf(ff,"%s ",tmp); // NameManualFileList
2779                 fscanf(ff,"%s ",tmp); // xxxx
2780                 string  namefilelist= tmp;
2781                         
2782                 _wxILPD->SetTypeOfReadFiles(typeOfReadFile);
2783                 _wxILPD->SetSubTypeOfReadFiles(subTypeOfReadFile);
2784                 _wxILPD->SetNameManualFileList(namefilelist);
2785                 _wxILPD->SetDirectoryManualFileList(directory);
2786
2787                 _wxILPD->RefreshManualListFile(true);
2788                 _noteBook->SetSelection(0);
2789         }
2790 }
2791
2792 //----------------------------------------------------------------------------
2793
2794 string wxMaracasNoteBookPatientLstVoi::GetRWCM_namefileVOI()
2795 {
2796         return _RWCM_namefileVOI;
2797 }
2798
2799 //----------------------------------------------------------------------------
2800 void wxMaracasNoteBookPatientLstVoi::Persistence_Read_VOI()
2801 {
2802         int voi[6];
2803         string name; 
2804         char tmp[255];
2805         _RWCM_namefileVOI       = _wxreadwriteconf->GetNameReadFile();
2806         string directory        = _wxreadwriteconf->GetWorkDirectory();
2807         string file=directory + "/" + _RWCM_namefileVOI;
2808         if (_RWCM_namefileVOI!=""){
2809                 FILE *ff;
2810                 ff=fopen(file.c_str(),"r");
2811                 fscanf(ff,"%s ",tmp); // MaracasInfo
2812                 fscanf(ff,"%s ",tmp); // NameFileParent
2813                 fscanf(ff,"%s ",tmp); // xxxxxxxx
2814
2815                 fscanf(ff,"%s ",tmp); // voi_x 
2816                 fscanf(ff,"%s ",tmp); // xMin
2817                 voi[0] = atoi(tmp);
2818                 fscanf(ff,"%s ",tmp); // xMax
2819                 voi[1] = atoi(tmp);
2820
2821                 fscanf(ff,"%s ",tmp); // voi_y 
2822                 fscanf(ff,"%s ",tmp); // yMin
2823                 voi[2] = atoi(tmp);
2824                 fscanf(ff,"%s ",tmp); // yMax
2825                 voi[3] = atoi(tmp);
2826
2827                 fscanf(ff,"%s ",tmp); // voi_z 
2828                 fscanf(ff,"%s ",tmp); // zMin
2829                 voi[4] = atoi(tmp);
2830                 fscanf(ff,"%s ",tmp); // zMax
2831                 voi[5] = atoi(tmp);
2832                 fclose(ff);
2833
2834                 _wxMaracasImageBrowser02->SetROI(voi);
2835                 _wxMaracasImageBrowser02->Refresh();
2836
2837
2838         }
2839 }
2840
2841 //----------------------------------------------------------------------------
2842 void wxMaracasNoteBookPatientLstVoi::OnPersistence_Read(wxCommandEvent& event)
2843 {
2844         if (_wxreadwriteconf!=NULL)
2845         {
2846                 if (this->_noteBook->GetSelection()==0)  // Read Configuration Images
2847                 {
2848                         Persistence_Read_Images();
2849                 }
2850                 if (this->_noteBook->GetSelection()==1)  // Read Configuration Images
2851                 {
2852                         Persistence_Read_VOI();
2853                 }
2854         }
2855 }
2856 //----------------------------------------------------------------------------
2857 void wxMaracasNoteBookPatientLstVoi::Persistence_Write_Images_ManualReadFileList()
2858 {
2859         if (_wxreadwriteconf!=NULL)
2860         {
2861                 _RWCM_namefileReadImages        = _wxreadwriteconf->GetNameWriteFile();
2862                 if (_RWCM_namefileReadImages!=""){
2863                         string name,namedir; 
2864                         _RWCM_namefileReadImages        = _RWCM_namefileReadImages + ".MaracasInfo";
2865                         namedir         = _wxreadwriteconf->GetWorkDirectory();
2866                         name            = namedir + "/" + _RWCM_namefileReadImages   ;
2867                         FILE *ff=fopen(name.c_str(),"w");
2868                         fprintf(ff,"MaracasInfo \n");
2869                         fprintf(ff,"NameFileParent %s \n",_wxreadwriteconf->GetParentFile().c_str() );
2870
2871                         int typefile;
2872                         int subtypefile;
2873                         string directory;
2874                         string namefilelist;
2875
2876                         typefile                = _wxILPD->GetTypeOfReadFiles();
2877                         subtypefile             = _wxILPD->GetSubTypeOfReadFiles();
2878                         namefilelist    = _wxILPD->GetNameManualFileList();
2879                         directory               = _wxILPD->GetDirectoryManualFileList();
2880
2881                         if (namefilelist=="")
2882                         {
2883                                 namefilelist="<void>";
2884                         }
2885                         if (directory=="")
2886                         {
2887                                 directory="<void>";
2888                         }
2889
2890                         fprintf(ff,"TypeOfReadFiles %d\n", typefile );
2891                         fprintf(ff,"SubTypeOfReadFiles %d\n", subtypefile );
2892                         fprintf(ff,"DirectoryManualFileList %s\n", directory.c_str() );
2893                         fprintf(ff,"NameManualFileList %s\n", namefilelist.c_str() );
2894
2895                         fclose(ff);
2896                 }
2897         }
2898 }
2899
2900
2901 void wxMaracasNoteBookPatientLstVoi::Persistence_Write_Images_Database()
2902 {
2903         std::string nameDirectory       = _wxreadwriteconf->GetWorkDirectory();
2904         std::string nameFile            = _wxreadwriteconf->GetNameWriteFile();
2905         if (_wxreadwriteconf!=NULL)
2906         {
2907                 // Create .maracas file (list of DICOM files)
2908                 std::string nameFileMaracas = nameDirectory+"/"+nameFile+".maracas";
2909                 FILE *ff =fopen(nameFileMaracas.c_str(),"w+");
2910                 fprintf(ff,"MaracasType 100\n");
2911                 fprintf(ff,"Directory --\n");
2912                 std::vector <string *> lst;
2913                 this->_wxILPD->GetLstImageFiles( &lst );
2914                 int i,size=lst.size();
2915                 for (i=0;i<size;i++)
2916                 {
2917                         fprintf(ff,"%s\n",lst[i]->c_str());
2918                 }
2919                 fclose(ff);
2920
2921                 // Creating .MaracasInfo
2922                 std::string nameFileMaracasInfo = nameDirectory+"/"+nameFile+".MaracasInfo";
2923                 FILE *fileInfo =fopen(nameFileMaracasInfo.c_str(),"w+");
2924                         fprintf(fileInfo,"MaracasInfo\n");
2925                         fprintf(fileInfo,"NameFileParent NULL\n");
2926                         fprintf(fileInfo,"TypeOfReadFiles 2\n");
2927                         fprintf(fileInfo,"SubTypeOfReadFiles 100\n");
2928                         fprintf(fileInfo,"DirectoryManualFileList %s\n",nameDirectory.c_str());
2929                         fprintf(fileInfo,"NameManualFileList %s\n",nameFileMaracas.c_str());
2930                 fclose(fileInfo);
2931
2932         }
2933 }
2934
2935
2936 //----------------------------------------------------------------------------
2937 void wxMaracasNoteBookPatientLstVoi::Persistence_Write_VOI()
2938 {
2939         if (_wxreadwriteconf!=NULL)
2940         {
2941                 string name,namedir; 
2942                 _RWCM_namefileVOI       = _wxreadwriteconf->GetNameWriteFile();
2943                 if (_RWCM_namefileVOI!=""){
2944                         _RWCM_namefileVOI = _RWCM_namefileVOI + ".MaracasInfo" ;
2945                         namedir         = _wxreadwriteconf->GetWorkDirectory();
2946                         name            = namedir + "/" + _RWCM_namefileVOI ;
2947                         FILE *ff=fopen(name.c_str(),"w");
2948                         fprintf(ff,"MaracasInfo \n");
2949                         fprintf(ff,"NameFileParent %s \n",_wxreadwriteconf->GetParentFile().c_str() );
2950
2951                         int voi[6];
2952                         _wxMaracasImageBrowser02->GetROI(voi);
2953
2954                         fprintf(ff,"VOI_X %d %d\n", voi[0],voi[1] );
2955                         fprintf(ff,"VOI_Y %d %d\n", voi[2],voi[3] );
2956                         fprintf(ff,"VOI_Z %d %d\n", voi[4],voi[5] );
2957                         fclose(ff);
2958                 }
2959         }
2960 }
2961 //----------------------------------------------------------------------------
2962 void wxMaracasNoteBookPatientLstVoi::OnPersistence_Write(wxCommandEvent& event)
2963 {
2964         if (_wxreadwriteconf!=NULL)
2965         {
2966                 if (this->_noteBook->GetSelection()==0)  // Write Configuration Images
2967                 {
2968 // EED 09 nov 2007
2969                         if (this->_wxILPD->GetNotebook()->GetSelection()==0)
2970                         {
2971                                 Persistence_Write_Images_Database();
2972                         } 
2973                         if (this->_wxILPD->GetNotebook()->GetSelection()==1)
2974                         {
2975                                 Persistence_Write_Images_Database();
2976                         } 
2977                         if (this->_wxILPD->GetNotebook()->GetSelection()==2)
2978                         {
2979                                 Persistence_Write_Images_ManualReadFileList();
2980                         } 
2981                 }
2982                 if (this->_noteBook->GetSelection()==1)  // Write ConfigurationImages
2983                 {
2984                         Persistence_Write_VOI();
2985                 }
2986         }
2987 }
2988
2989
2990 //----------------------------------------------------------------------------
2991 //----------------------------------------------------------------------------
2992 //----------------------------------------------------------------------------
2993
2994
2995 BEGIN_EVENT_TABLE(wxMaracasNoteBookIRMQuantification , wxPanel)
2996 // Borrame
2997 //    EVT_MENU(MDI_CHILD_QUIT, MyChild::OnQuit)
2998 //    EVT_MENU(MDI_REFRESH, MyChild::OnRefresh)
2999 //    EVT_MENU(MDI_CHANGE_TITLE, MyChild::OnChangeTitle)
3000 //    EVT_MENU(MDI_CHANGE_POSITION, MyChild::OnChangePosition)
3001 //    EVT_MENU(MDI_CHANGE_SIZE, MyChild::OnChangeSize)
3002 //      EVT_MENU(20001, wxMaracasNoteBookIRMQuantification::OnSelectPatientStudySerieImage)
3003
3004 //    EVT_SIZE(MyChild::OnSize)
3005 //    EVT_MOVE(MyChild::OnMove)
3006
3007 //    EVT_CLOSE(wxMaracasPatientLstVoiChiFra::OnClose)
3008         EVT_TOOL(wxSurfaceWidget::ID_BUTTON_NEW_AXIS    , wxMaracasNoteBookIRMQuantification::OnNewAxis                 )
3009         EVT_TOOL(wxSurfaceWidget::ID_BUTTON_DELETE_AXIS , wxMaracasNoteBookIRMQuantification::OnDeleteAxis              )
3010         EVT_TOOL(ID_TOOLBAR_PLANS                                               , wxMaracasNoteBookIRMQuantification::OnQuantification  )
3011 END_EVENT_TABLE()
3012
3013 wxMaracasNoteBookIRMQuantification::wxMaracasNoteBookIRMQuantification(wxWindow *parent,marInterface *mar)
3014        : wxPanel(parent, -1)
3015 {
3016 printf("EED wxMaracasNoteBookIRMQuantification::wxMaracasNoteBookIRMQuantification  1 \n");
3017         _existAxis                                      = false;
3018         _wxmaracasquantification        = NULL;
3019
3020         _noteBook = new wxNotebook(this, -1);
3021         _noteBook->SetSize(750,300);
3022
3023         wxBitmap mask= wxBITMAP( TOOLBAR_V2_sm_mask );
3024
3025         wxBitmap bitmap0        = wxBITMAP( TOOLBAR_V2_sm_bl_AxisExtraction );
3026         wxBitmap bitmap1        = wxBITMAP( TOOLBAR_V2_sm_bl_Quantification );
3027         wxBitmap bitmap2        = wxBITMAP( TOOLBAR_V2_sm_tr_Quantification );
3028         
3029         bitmap0.SetMask(new wxMask( mask ));
3030         bitmap1.SetMask(new wxMask( mask ));
3031         bitmap2.SetMask(new wxMask( mask ));
3032
3033
3034         wxImageList *imageList = new wxImageList(50,50);
3035         imageList->Add( bitmap0 );  // 0
3036         imageList->Add( bitmap1 );  // 1
3037         imageList->Add( bitmap2 );  // 2
3038         _noteBook->SetImageList(imageList);
3039
3040 printf("EED wxMaracasNoteBookIRMQuantification::wxMaracasNoteBookIRMQuantification  2 \n");
3041
3042 //      _mar=mar
3043 //      _mar->initExperiment( );
3044
3045         _mar=new marInterface();
3046         _mar->_parameters->setRescaleSlope( mar->_parameters->getRescaleSlope() );
3047         _mar->_parameters->setRescaleIntercept( mar->_parameters->getRescaleIntercept() );
3048         _mar->_parameters->setIntParam( marParameters::e_voxel_type, marParameters::VOX_TYPE_MINIMUM );
3049         _mar->_parameters->setDoubleParam( marParameters::e_voxel_x_dimension, mar->_parameters->getDoubleParam(marParameters::e_voxel_x_dimension) );
3050         _mar->_parameters->setDoubleParam( marParameters::e_voxel_y_dimension, mar->_parameters->getDoubleParam(marParameters::e_voxel_y_dimension) );
3051         _mar->_parameters->setDoubleParam( marParameters::e_voxel_z_dimension, mar->_parameters->getDoubleParam(marParameters::e_voxel_z_dimension) );
3052         int voi[6];
3053         mar->_experiment->getVOI( voi );
3054         _mar->_experiment->setVOI( voi );
3055         _mar->SetDicom(mar->_dicom);
3056         _mar->initExperiment( );
3057
3058 printf("EED wxMaracasNoteBookIRMQuantification::wxMaracasNoteBookIRMQuantification  2.1 \n");
3059         _wxmaracas3dbrowser = new wxMaracas3DBrowser( _noteBook, _mar, -1,ID_TOOLBAR_PLANS );
3060 printf("EED wxMaracasNoteBookIRMQuantification::wxMaracasNoteBookIRMQuantification  2.2 \n");
3061         _wxmaracas3dbrowser->LoadData( );
3062
3063 //      _wxmaracasquantification = new wxMaracasQuantification( _noteBook , _mar , -1 );
3064
3065         wxPanel *ttt = new wxPanel(_noteBook,-1);
3066 //      _wxmaracasquantification = new wxMaracasQuantification( ttt , _mar , -1 );
3067
3068
3069 printf("EED wxMaracasNoteBookIRMQuantification::wxMaracasNoteBookIRMQuantification  3 \n");
3070
3071         _noteBook->AddPage(_wxmaracas3dbrowser,_T("Axis Extraction IRM >>   ")  , true , 0 );
3072         _noteBook->AddPage(ttt,_T("Quantification IRM   ")                      , true , 2 );
3073
3074
3075         _noteBook->SetSelection(0);
3076
3077         Connect(_noteBook->GetId() , wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING  , (wxObjectEventFunction) &wxMaracasNoteBookIRMQuantification::OnChangePageQuantification );
3078         Connect(_noteBook->GetId() , wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED   , (wxObjectEventFunction) &wxMaracasNoteBookIRMQuantification::OnChangePage );
3079
3080
3081         wxStaticText *title=new wxStaticText(this,-1,_T("IRM Quantification"));
3082
3083 // It doesn't works in linux
3084 //      wxFont font(18,wxDEFAULT  , wxITALIC, wxBOLD);
3085 //      title->SetFont(font);
3086
3087     wxBoxSizer *sizer= new wxBoxSizer(wxVERTICAL);
3088         sizer->Add( title               , 0, wxEXPAND | wxALIGN_RIGHT, 10);
3089         sizer->Add( _noteBook   , 1, wxGROW, 10 );
3090
3091         sizer->SetSizeHints( this );   // set size hints to honour minimum size
3092         this->SetAutoLayout(true);
3093         this->SetSizer(sizer);
3094         this->Layout(); 
3095
3096 //EEDxx2.4
3097 //      FitInside();
3098 printf("EED wxMaracasNoteBookIRMQuantification::wxMaracasNoteBookIRMQuantification  4 \n");
3099
3100 }
3101 //----------------------------------------------------------------------------
3102 wxMaracasNoteBookIRMQuantification::~wxMaracasNoteBookIRMQuantification()
3103 {
3104 //EEDx15
3105 //      delete _wxmaracas3dbrowser;
3106 //      delete _wxmaracasquantification;
3107 }
3108
3109 //----------------------------------------------------------------------------
3110 void wxMaracasNoteBookIRMQuantification::OnQuantification(wxCommandEvent & event)
3111 {
3112         _noteBook->SetSelection(1);
3113 }
3114
3115 //----------------------------------------------------------------------------
3116 void wxMaracasNoteBookIRMQuantification::OnChangePage(wxNotebookEvent& event)
3117 {
3118         if (_noteBook->GetSelection()==1){
3119                 if (_wxmaracasquantification!=NULL)
3120                 {
3121 //EEDx12
3122                         delete _wxmaracasquantification;
3123 //                      _wxmaracasquantification->Close();
3124                 }
3125                 _wxmaracasquantification = new wxMaracasQuantification( _noteBook->GetPage(1) , _mar , -1 );
3126                 _wxmaracasquantification->LoadData( );
3127                 wxBoxSizer *sizer= new wxBoxSizer(wxHORIZONTAL);
3128                 sizer->Add( _wxmaracasquantification , 1, wxALL|wxEXPAND, 0);   
3129                 _noteBook->GetPage(1)->SetAutoLayout(true);
3130                 _noteBook->GetPage(1)->SetSizer(sizer);
3131                 _noteBook->GetPage(1)->Layout();                
3132         }
3133 }
3134 //----------------------------------------------------------------------------
3135 void wxMaracasNoteBookIRMQuantification::OnChangePageQuantification(wxNotebookEvent& event)
3136 {
3137         if (_noteBook->GetSelection()==0){
3138                 if (_existAxis == false )
3139                 {
3140                         wxMessageDialog msg(this, _T("You have to extract the axis befor run this option.."), _T("Message box"), wxOK );
3141                         msg.ShowModal();
3142                         event.Veto();
3143                 }
3144         }
3145         Refresh();
3146 }
3147
3148 //----------------------------------------------------------------------------
3149 void wxMaracasNoteBookIRMQuantification::OnNewAxis(wxCommandEvent &WXUNUSED(event))
3150 {
3151         _existAxis=true;
3152         _noteBook->SetPageImage(1, 1);
3153 }
3154
3155 //----------------------------------------------------------------------------
3156 void wxMaracasNoteBookIRMQuantification::OnDeleteAxis(wxCommandEvent &WXUNUSED(event))
3157 {
3158         _existAxis=false;
3159         _noteBook->SetPageImage(1, 2);
3160 }
3161
3162
3163
3164 //----------------------------------------------------------------------------
3165 //----------------------------------------------------------------------------
3166 //----------------------------------------------------------------------------
3167
3168
3169 BEGIN_EVENT_TABLE(wxMaracasNoteBookCTQuantification , wxPanel)
3170 // Borrame
3171 //    EVT_MENU(MDI_CHILD_QUIT, MyChild::OnQuit)
3172 //    EVT_MENU(MDI_REFRESH, MyChild::OnRefresh)
3173 //    EVT_MENU(MDI_CHANGE_TITLE, MyChild::OnChangeTitle)
3174 //    EVT_MENU(MDI_CHANGE_POSITION, MyChild::OnChangePosition)
3175 //    EVT_MENU(MDI_CHANGE_SIZE, MyChild::OnChangeSize)
3176 //      EVT_MENU(20001, wxMaracasNoteBookIRMQuantification::OnSelectPatientStudySerieImage)
3177
3178 //    EVT_SIZE(MyChild::OnSize)
3179 //    EVT_MOVE(MyChild::OnMove)
3180
3181 //    EVT_CLOSE(wxMaracasPatientLstVoiChiFra::OnClose)
3182 //      EVT_TOOL(wxSurfaceWidget::ID_BUTTON_NEW_AXIS,   wxMaracasNoteBookIRMQuantification::OnNewAxis                   )
3183 //      EVT_TOOL(wxSurfaceWidget::ID_BUTTON_DELETE_AXIS,wxMaracasNoteBookIRMQuantification::OnDeleteAxis                )
3184         EVT_TOOL(20005,wxMaracasNoteBookCTQuantification::OnQuantification)
3185
3186         EVT_MENU(30001, wxMaracasNoteBookCTQuantification::OnPersistence_Write)
3187         EVT_MENU(30002, wxMaracasNoteBookCTQuantification::OnPersistence_Read)
3188
3189
3190 END_EVENT_TABLE()
3191
3192
3193 wxMaracasNoteBookCTQuantification::wxMaracasNoteBookCTQuantification(wxWindow *parent,
3194                                                                                                                                          marInterface *mar,
3195                                                                                                                                          string namefileParentRWCM)
3196        : wxPanel(parent, -1)
3197 {
3198 printf(" EED wxMaracasNoteBookCTQuantification::wxMaracasNoteBookCTQuantification 01\n ");
3199         _namefileParentRWCM = namefileParentRWCM;
3200         _readyQuantification=false;
3201         _wxMaracasProcessingCT=NULL;
3202         _wxmaracasquantification_ct=NULL;
3203
3204         _noteBook = new wxNotebook(this, -1);
3205 //      _noteBook->SetSize(550,300);
3206
3207         wxBitmap mask= wxBITMAP( TOOLBAR_V2_sm_mask );
3208
3209         wxBitmap bitmap0        = wxBITMAP( TOOLBAR_V2_sm_bl_MPR );
3210         wxBitmap bitmap1        = wxBITMAP( TOOLBAR_V2_sm_bl_ProcessingCT );
3211         wxBitmap bitmap2        = wxBITMAP( TOOLBAR_V2_sm_bl_Quantification );
3212         wxBitmap bitmap3        = wxBITMAP( TOOLBAR_V2_sm_tr_Quantification );
3213
3214         bitmap0.SetMask(new wxMask( mask ));
3215         bitmap1.SetMask(new wxMask( mask ));
3216         bitmap2.SetMask(new wxMask( mask ));
3217         bitmap3.SetMask(new wxMask( mask ));
3218
3219         wxImageList *imageList = new wxImageList(50,50);
3220         imageList->Add( bitmap0 );  // 0
3221         imageList->Add( bitmap1 );  // 1
3222         imageList->Add( bitmap2 );  // 2
3223         imageList->Add( bitmap3 );  // 3
3224         _noteBook->SetImageList(imageList);
3225
3226
3227         double spcOriginalImage[3];
3228         spcOriginalImage[0]=mar->_parameters->getDoubleParam(marParameters::e_voxel_x_dimension);
3229         spcOriginalImage[1]=mar->_parameters->getDoubleParam(marParameters::e_voxel_y_dimension);
3230         spcOriginalImage[2]=mar->_parameters->getDoubleParam(marParameters::e_voxel_z_dimension);
3231
3232
3233 //      _mar=mar;
3234         _mar=new marInterfaceCT();
3235
3236         _mar->_parameters->setRescaleSlope( mar->_parameters->getRescaleSlope() );
3237         _mar->_parameters->setRescaleIntercept( mar->_parameters->getRescaleIntercept() );
3238         _mar->_parameters->setIntParam( marParameters::e_voxel_type, marParameters::VOX_TYPE_MINIMUM );
3239
3240
3241         _mar->_parameters->setDoubleParam( marParameters::e_voxel_x_dimension, spcOriginalImage[0] );
3242         _mar->_parameters->setDoubleParam( marParameters::e_voxel_y_dimension, spcOriginalImage[1] );
3243         _mar->_parameters->setDoubleParam( marParameters::e_voxel_z_dimension, spcOriginalImage[2] );
3244 //EEDx4
3245
3246         int voi[6];
3247         mar->_experiment->getVOI( voi );
3248         _mar->setVOI( voi );
3249         _mar->SetDicom(mar->_dicom);
3250
3251         _mar->initExperiment( );
3252
3253         vtkImageData *imagedata;
3254         imagedata = _mar->GetExperiment()->getDynData( )->getVolume( )->castVtk();
3255         imagedata->Update(); 
3256         marImageData *marimagedata = new marImageData(imagedata);
3257         marimagedata->SetSpcOriginal(spcOriginalImage);
3258         marimagedata->SetVoiOriginal(voi);
3259
3260         _wxMaracasMPR = new wxMaracasMPR( _noteBook, marimagedata ,_mar->_parameters->getVoxelSize() );
3261         _wxMaracasMPR->ConfigureVTK();
3262
3263         _noteBook->AddPage(_wxMaracasMPR,_T("Choose a position  >>   "), true, 0 );
3264
3265         _noteBook->AddPage(new wxPanel(_noteBook,-1),_T("Processing CT >>  "), true, 1 );
3266         _noteBook->AddPage(new wxPanel(_noteBook,-1),_T("Quantification  CT  "), true, 3 );
3267         _noteBook->SetSelection(0);
3268
3269
3270         Connect(_noteBook->GetId() , wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING  , (wxObjectEventFunction) &wxMaracasNoteBookCTQuantification::OnChangePageQuantification );
3271         Connect(_noteBook->GetId() , wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED   , (wxObjectEventFunction) &wxMaracasNoteBookCTQuantification::OnChangePage );
3272
3273         wxButton *btnReadWriteConfig    = new wxButton(this,-1,_T("Read-Write Config"));
3274         Connect(btnReadWriteConfig->GetId() ,  wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxMaracasNoteBookCTQuantification::OnReadWriteConf_Maracas );
3275         wxButton *btnHelp                               = new wxButton(this,-1,_T("Help"));
3276         wxButton *btnClose                              = new wxButton(this,-1,_T("Close"));
3277
3278     wxBoxSizer *sizerB                          = new wxBoxSizer(wxHORIZONTAL);
3279         sizerB->Add( btnReadWriteConfig , 0, wxALIGN_RIGHT, 10);
3280         sizerB->Add( btnHelp                    , 0, wxALIGN_RIGHT, 10);
3281         sizerB->Add( btnClose                   , 0, wxALIGN_RIGHT, 10);
3282
3283
3284
3285
3286
3287         wxStaticText *title=new wxStaticText(this,-1,_T("CT Quantification"));
3288
3289 // It doesn't works in linux
3290 //      wxFont font(18,wxDEFAULT  , wxITALIC, wxBOLD);
3291 //      title->SetFont(font);
3292
3293     wxBoxSizer *sizer= new wxBoxSizer(wxVERTICAL);
3294         sizer->Add( sizerB              , 0, wxALIGN_RIGHT, 10);
3295         sizer->Add( title               , 0, wxGROW | wxALIGN_RIGHT, 10);
3296         sizer->Add( _noteBook   , 1, wxALL | wxGROW, 10 );
3297
3298 //EEDxx2.4
3299 //      FitInside();
3300
3301 //      sizer->SetSizeHints( this );   // set size hints to honour minimum size
3302         this->SetSizer(sizer);
3303         this->SetAutoLayout(true);
3304         this->Layout(); 
3305 // EED 29 Juin 2007
3306 /*
3307 */
3308 printf(" EED wxMaracasNoteBookCTQuantification::wxMaracasNoteBookCTQuantification 02\n ");
3309 }
3310
3311 //----------------------------------------------------------------------------
3312
3313 wxMaracasNoteBookCTQuantification::~wxMaracasNoteBookCTQuantification()
3314 {
3315 }
3316
3317
3318 //----------------------------------------------------------------------------
3319 void wxMaracasNoteBookCTQuantification::OnChangePage(wxNotebookEvent& event)
3320 {
3321         if (_noteBook->GetSelection()==1){
3322                 wxBusyCursor wait;
3323                 if (_wxMaracasProcessingCT!=NULL)
3324                 {
3325                         delete _wxMaracasProcessingCT;
3326                 }
3327                 vtkMPRBaseData *vtkmprbaseData = _wxMaracasMPR->GetVtkMPRBaseData();
3328                 marImageData *marimagedata = vtkmprbaseData->GetMarImageData();
3329         //      _mar->initExperiment( );
3330                 int     x = (int)vtkmprbaseData->GetX();
3331                 int     y = (int)vtkmprbaseData->GetY();
3332                 int     z = (int)vtkmprbaseData->GetZ();
3333 printf("EED wxMaracasNoteBookCTQuantification::OnChangePage \n ");
3334                 _wxMaracasProcessingCT = new wxMaracasProcessingCT(_noteBook->GetPage(1), _mar);
3335                 _wxMaracasProcessingCT->ConfigureVTK(marimagedata, x , y , z );
3336                 wxBoxSizer *sizer= new wxBoxSizer(wxHORIZONTAL);
3337                 sizer->Add( _wxMaracasProcessingCT , 1, wxALL|wxGROW, 0);       
3338                 _noteBook->GetPage(1)->SetAutoLayout(true);
3339                 _noteBook->GetPage(1)->SetSizer(sizer);
3340                 _noteBook->GetPage(1)->Layout();        
3341         }
3342         if (_noteBook->GetSelection()==2) {
3343                 if (_readyQuantification==true)
3344                 {
3345                         if (_wxmaracasquantification_ct!=NULL)
3346                         {
3347                                 delete _wxmaracasquantification_ct;
3348                         }
3349                         _wxmaracasquantification_ct = new wxMaracasQuantificationCT(_noteBook->GetPage(2), _mar, -1 );
3350                         _wxmaracasquantification_ct->LoadData( );
3351                         wxBoxSizer *sizer= new wxBoxSizer(wxHORIZONTAL);
3352                         sizer->Add( _wxmaracasquantification_ct , 1, wxALL|wxGROW, 0);  
3353                         _noteBook->GetPage(2)->SetAutoLayout(true);
3354                         _noteBook->GetPage(2)->SetSizer(sizer);
3355                         _noteBook->GetPage(2)->Layout();        
3356                 } else {
3357                         wxMessageDialog msg(this, _T("You have to extract the axis befor run this option.."), _T("Message box"), wxOK );
3358                         msg.ShowModal();
3359                 }
3360         }
3361
3362         if ((_noteBook->GetSelection()==0) || (_noteBook->GetSelection()==1) ) {
3363                 _readyQuantification=false;
3364                 _noteBook->SetPageImage(2, 3);
3365         }
3366
3367         Refresh();
3368 }
3369 //----------------------------------------------------------------------------
3370 void wxMaracasNoteBookCTQuantification::OnChangePageQuantification(wxNotebookEvent& event)
3371 {
3372 /*
3373         if (event.GetSelection()==1) {
3374                 if (_readyQuantification==false)
3375                 {
3376                         wxMessageDialog msg(this, "You have to extract the axis befor run this option..", "Message box", wxOK );
3377                         msg.ShowModal();
3378                         event.Veto();
3379                 }
3380         }
3381 */
3382 }
3383 //----------------------------------------------------------------------------
3384 void wxMaracasNoteBookCTQuantification::OnQuantification(wxCommandEvent& event)
3385 {
3386         _readyQuantification=true;
3387         _noteBook->SetPageImage(2, 2);
3388 }
3389
3390 //----------------------------------------------------------------------------
3391
3392 void wxMaracasNoteBookCTQuantification::OnReadWriteConf_Maracas(wxCommandEvent& event)
3393 {
3394         string parentFile;
3395         if (this->_noteBook->GetSelection()==0)  // Read 3D Point MPR
3396         {
3397                 parentFile=_namefileParentRWCM;
3398         }
3399         if (this->_noteBook->GetSelection()==1)  // Read Preprocessing
3400         {
3401                 parentFile=_RWCM_namefileMPR;
3402         }
3403         if (this->_noteBook->GetSelection()==2)  // Read Contour Quantification
3404         {
3405                 parentFile=_RWCM_namefileProcessingCT;
3406         }
3407
3408
3409         if (parentFile!="")
3410         {
3411                 _wxreadwriteconf = new wxReadWriteConf(this,parentFile);
3412                 _wxreadwriteconf->ShowModal();
3413                 _wxreadwriteconf=NULL;
3414         } else {
3415                 wxMessageDialog(this,_T("No parent file defined..."),_T("Warning.."), wxOK).ShowModal();
3416         }
3417
3418 }
3419
3420 //----------------------------------------------------------------------------
3421 void wxMaracasNoteBookCTQuantification::Persistence_Read_MPR()
3422 {
3423         _RWCM_namefileMPR       = _wxreadwriteconf->GetNameReadFile();
3424         if (_RWCM_namefileMPR!=""){
3425                 double x,y,z;
3426                 string name; 
3427                 char tmp[255];
3428                 string directory        = _wxreadwriteconf->GetWorkDirectory();
3429                 string file=directory + "/" + _RWCM_namefileMPR;
3430                 FILE *ff;
3431                 ff=fopen(file.c_str(),"r");
3432                 fscanf(ff,"%s ",tmp); // MaracasInfo
3433                 fscanf(ff,"%s ",tmp); // NameFileParent
3434                 fscanf(ff,"%s ",tmp); // xxxxxxxx
3435
3436                 fscanf(ff,"%s ",tmp); // positionX 
3437                 fscanf(ff,"%s ",tmp); // x
3438                 x = atof(tmp);
3439
3440                 fscanf(ff,"%s ",tmp); // positionY 
3441                 fscanf(ff,"%s ",tmp); // y
3442                 y = atof(tmp);
3443
3444                 fscanf(ff,"%s ",tmp); // positionZ 
3445                 fscanf(ff,"%s ",tmp); // z
3446                 z = atof(tmp);
3447
3448                 fclose(ff);
3449
3450                 _wxMaracasMPR->GetVtkMPRBaseData()->SetX(x);
3451                 _wxMaracasMPR->GetVtkMPRBaseData()->SetY(y);
3452                 _wxMaracasMPR->GetVtkMPRBaseData()->SetZ(z);
3453                 _wxMaracasMPR->RefreshView();
3454         }
3455
3456 }
3457 //----------------------------------------------------------------------------
3458 void wxMaracasNoteBookCTQuantification::Persistence_Read_ProcessingCT()
3459 {
3460         _RWCM_namefileProcessingCT      = _wxreadwriteconf->GetNameReadFile();
3461         if (_RWCM_namefileProcessingCT!=""){
3462                 int min,max;
3463                 string name; 
3464                 char tmp[255];
3465                 string directory        = _wxreadwriteconf->GetWorkDirectory();
3466                 string file=directory + "/" + _RWCM_namefileProcessingCT;
3467                 FILE *ff;
3468                 ff=fopen(file.c_str(),"r");
3469                 fscanf(ff,"%s ",tmp); // MaracasInfo
3470                 fscanf(ff,"%s ",tmp); // NameFileParent
3471                 fscanf(ff,"%s ",tmp); // xxxxxxxx
3472
3473                 fscanf(ff,"%s ",tmp); // Threshold_min 
3474                 fscanf(ff,"%s ",tmp); // min
3475                 min = atoi(tmp);
3476
3477                 fscanf(ff,"%s ",tmp); // Threshold_max 
3478                 fscanf(ff,"%s ",tmp); // max
3479                 max = atoi(tmp);
3480
3481                 _wxMaracasProcessingCT->SetThreshold(min,max);
3482                 _wxMaracasProcessingCT->Refresh();
3483
3484                 fclose(ff);
3485
3486         }
3487
3488 }
3489
3490 //----------------------------------------------------------------------------
3491 void wxMaracasNoteBookCTQuantification::Persistence_Read_ContourQauntificationCT()
3492 {
3493         _RWCM_namefileContourQuantificationCT   = _wxreadwriteconf->GetNameReadFile();
3494         if (_RWCM_namefileContourQuantificationCT!=""){
3495                 string name; 
3496                 char tmp[255];
3497                 string directory        = _wxreadwriteconf->GetWorkDirectory();
3498                 string file=directory + "/" + _RWCM_namefileContourQuantificationCT;
3499                 FILE *ff;
3500                 ff=fopen(file.c_str(),"r");
3501                 fscanf(ff,"%s ",tmp); // MaracasInfo
3502                 fscanf(ff,"%s ",tmp); // NameFileParent
3503                 fscanf(ff,"%s ",tmp); // xxxxxxxx
3504
3505
3506         // Read Data
3507     // Set Data
3508                 fscanf(ff,"%s ",tmp); // Slice
3509                 fscanf(ff,"%s ",tmp); // xxxxxxxx
3510                 int slice = atoi(tmp);
3511                 this->_wxmaracasquantification_ct->SetActualSlice(slice);
3512     // Refresh
3513
3514                 fclose(ff);
3515
3516         }
3517 }
3518
3519 //----------------------------------------------------------------------------
3520 void wxMaracasNoteBookCTQuantification::OnPersistence_Read(wxCommandEvent& event)
3521 {
3522         if (this->_noteBook->GetSelection()==0)  // Read 3D Point MPR
3523         {
3524                 Persistence_Read_MPR();
3525         }
3526         if (this->_noteBook->GetSelection()==1)  // Read Preprocessing
3527         {
3528                 Persistence_Read_ProcessingCT();
3529         }
3530         if (this->_noteBook->GetSelection()==2)  // Read Contour quantification
3531         {
3532                 Persistence_Read_ContourQauntificationCT();
3533         }
3534 }
3535 //----------------------------------------------------------------------------
3536 void wxMaracasNoteBookCTQuantification::Persistence_Write_MPR()
3537 {
3538
3539         if (_wxreadwriteconf!=NULL)
3540         {
3541                 _RWCM_namefileMPR       = _wxreadwriteconf->GetNameWriteFile();
3542                 if (_RWCM_namefileMPR!=""){
3543                         string name,namedir; 
3544                         _RWCM_namefileMPR       =_RWCM_namefileMPR + ".MaracasInfo";
3545                         namedir         = _wxreadwriteconf->GetWorkDirectory();
3546                         name            = namedir + "/" + _RWCM_namefileMPR  ;
3547                         FILE *ff=fopen(name.c_str(),"w");
3548                         fprintf(ff,"MaracasInfo \n");
3549                         fprintf(ff,"NameFileParent %s \n",_wxreadwriteconf->GetParentFile().c_str() );
3550
3551
3552                         double x = _wxMaracasMPR->GetVtkMPRBaseData()->GetX();
3553                         double y = _wxMaracasMPR->GetVtkMPRBaseData()->GetY();
3554                         double z = _wxMaracasMPR->GetVtkMPRBaseData()->GetZ();
3555
3556                         fprintf(ff,"positionX %f\n", x);
3557                         fprintf(ff,"positionY %f\n", y);
3558                         fprintf(ff,"positionZ %f\n", z);
3559                         fclose(ff);
3560                 }
3561         }
3562
3563
3564
3565 }
3566 //----------------------------------------------------------------------------
3567 void wxMaracasNoteBookCTQuantification::Persistence_Write_ProcessingCT()
3568 {
3569         if (_wxreadwriteconf!=NULL)
3570         {
3571                 _RWCM_namefileProcessingCT      = _wxreadwriteconf->GetNameWriteFile();
3572                 if (_RWCM_namefileProcessingCT!=""){
3573                         string name,namedir; 
3574                         _RWCM_namefileProcessingCT = _RWCM_namefileProcessingCT + ".MaracasInfo";
3575                         namedir         = _wxreadwriteconf->GetWorkDirectory();
3576                         name            = namedir + "/" + _RWCM_namefileProcessingCT ;
3577                         FILE *ff=fopen(name.c_str(),"w");
3578                         fprintf(ff,"MaracasInfo \n");
3579                         fprintf(ff,"NameFileParent %s \n",_wxreadwriteconf->GetParentFile().c_str() );
3580
3581                         int min,max;
3582                         _wxMaracasProcessingCT->GetThreshold(&min,&max);
3583
3584                         fprintf(ff,"Threshold_Min %d\n", min);
3585                         fprintf(ff,"Threshold_Max %d\n", max);
3586
3587                         fclose(ff);
3588                 }
3589         }
3590
3591 }
3592 //----------------------------------------------------------------------------
3593 void wxMaracasNoteBookCTQuantification::Persistence_Write_ContourQuantificationCT()
3594 {
3595         if (_wxreadwriteconf!=NULL)
3596         {
3597                 _RWCM_namefileContourQuantificationCT   = _wxreadwriteconf->GetNameWriteFile();
3598                 if (_RWCM_namefileContourQuantificationCT!=""){
3599                         string name,namedir; 
3600                         _RWCM_namefileContourQuantificationCT = _RWCM_namefileContourQuantificationCT + ".MaracasInfo";
3601                         namedir         = _wxreadwriteconf->GetWorkDirectory();
3602                         name            = namedir + "/" + _RWCM_namefileContourQuantificationCT ;
3603                         FILE *ff=fopen(name.c_str(),"w");
3604                         fprintf(ff,"MaracasInfo \n");
3605                         fprintf(ff,"NameFileParent %s \n",_wxreadwriteconf->GetParentFile().c_str() );
3606         
3607                 // Get Data information 
3608                 // Write Data 
3609                         fprintf(ff,"Slice %d\n", this->_wxmaracasquantification_ct->GetActualSlice() );
3610
3611                         fclose(ff);
3612                 }
3613         }
3614
3615 }
3616 //----------------------------------------------------------------------------
3617 void wxMaracasNoteBookCTQuantification::OnPersistence_Write(wxCommandEvent& event)
3618 {
3619         if (this->_noteBook->GetSelection()==0)  // Write 3D Point MPR
3620         {
3621                 Persistence_Write_MPR();
3622         }
3623         if (this->_noteBook->GetSelection()==1)  // Write Preprocessing
3624         {
3625                 Persistence_Write_ProcessingCT();
3626         }
3627         if (this->_noteBook->GetSelection()==2)  // Write Contour Quantification
3628         {
3629                 Persistence_Write_ContourQuantificationCT();
3630         }
3631 }
3632
3633
3634 //----------------------------------------------------------------------------
3635 //----------------------------------------------------------------------------
3636 //----------------------------------------------------------------------------
3637
3638
3639 BEGIN_EVENT_TABLE(wxMaracasNoteBookVascularTreeExtraction , wxPanel)
3640 // Borrame
3641 //    EVT_MENU(MDI_CHILD_QUIT, MyChild::OnQuit)
3642 //    EVT_MENU(MDI_REFRESH, MyChild::OnRefresh)
3643 //    EVT_MENU(MDI_CHANGE_TITLE, MyChild::OnChangeTitle)
3644 //    EVT_MENU(MDI_CHANGE_POSITION, MyChild::OnChangePosition)
3645 //    EVT_MENU(MDI_CHANGE_SIZE, MyChild::OnChangeSize)
3646 //      EVT_MENU(20001, wxMaracasNoteBookIRMQuantification::OnSelectPatientStudySerieImage)
3647
3648 //    EVT_SIZE(MyChild::OnSize)
3649 //    EVT_MOVE(MyChild::OnMove)
3650
3651 //    EVT_CLOSE(wxMaracasPatientLstVoiChiFra::OnClose)
3652 //      EVT_TOOL(wxSurfaceWidget::ID_BUTTON_NEW_AXIS,   wxMaracasNoteBookIRMQuantification::OnNewAxis                   )
3653 //      EVT_TOOL(wxSurfaceWidget::ID_BUTTON_DELETE_AXIS,wxMaracasNoteBookIRMQuantification::OnDeleteAxis                )
3654 //      EVT_TOOL(20005,wxMaracasNoteBookVascularTreeExtraction::OnQuantification)
3655
3656 END_EVENT_TABLE()
3657
3658
3659 wxMaracasNoteBookVascularTreeExtraction::wxMaracasNoteBookVascularTreeExtraction(wxWindow *parent,marInterface *mar)
3660        : wxPanel(parent, -1)
3661 {
3662
3663         _noteBook = new wxNotebook(this, -1);
3664         _noteBook->SetSize(550,300);
3665
3666         wxBitmap mask= wxBITMAP( TOOLBAR_V2_sm_mask );
3667         wxBitmap bitmap0        = wxBITMAP( TOOLBAR_V2_sm_bl_TreeExtraction_JF_MH );
3668         bitmap0.SetMask(new wxMask( mask ));
3669
3670
3671         wxImageList *imageList = new wxImageList(50,50);
3672         imageList->Add( bitmap0 );  // 0
3673         _noteBook->SetImageList(imageList);
3674
3675 //      _mar=mar;
3676
3677         _mar=new marInterface();
3678         _mar->_parameters->setRescaleSlope( mar->_parameters->getRescaleSlope() );
3679         _mar->_parameters->setRescaleIntercept( mar->_parameters->getRescaleIntercept() );
3680         _mar->_parameters->setIntParam( marParameters::e_voxel_type, marParameters::VOX_TYPE_MINIMUM );
3681         _mar->_parameters->setDoubleParam( marParameters::e_voxel_x_dimension, mar->_parameters->getDoubleParam(marParameters::e_voxel_x_dimension) );
3682         _mar->_parameters->setDoubleParam( marParameters::e_voxel_y_dimension, mar->_parameters->getDoubleParam(marParameters::e_voxel_y_dimension) );
3683         _mar->_parameters->setDoubleParam( marParameters::e_voxel_z_dimension, mar->_parameters->getDoubleParam(marParameters::e_voxel_z_dimension) );
3684
3685         int voi[6];
3686         mar->_experiment->getVOI( voi );
3687         _mar->_experiment->setVOI( voi );
3688         _mar->SetDicom(mar->_dicom);
3689
3690         _mar->initExperiment( );
3691
3692         vtkImageData *marImageData;
3693         marImageData = _mar->_experiment->getDynData( )->getVolume( )->castVtk();
3694         marImageData->Update(); 
3695
3696         _wxMaracasEmptyPanel_2 = new wxMaracasEmptyPanel_2(_noteBook,_mar);
3697         _wxMaracasEmptyPanel_2->ConfigureVTK();
3698
3699
3700         _wxMaracasPathology_01 = new wxMaracasPathology_01(_noteBook,_mar);
3701         _wxMaracasPathology_01->ConfigureVTK();
3702
3703
3704         _noteBook->AddPage(_wxMaracasEmptyPanel_2,_T("Tree Extraction  "), true, 0 );
3705         _noteBook->AddPage(_wxMaracasPathology_01,_T("Pathology  "), true, 0 );
3706         _noteBook->SetSelection(0);
3707
3708         Connect(_noteBook->GetId() , wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING  , (wxObjectEventFunction) &wxMaracasNoteBookVascularTreeExtraction::OnChangePageQuantification );
3709         Connect(_noteBook->GetId() , wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED   , (wxObjectEventFunction) &wxMaracasNoteBookVascularTreeExtraction::OnChangePage );
3710
3711         wxStaticText *title=new wxStaticText(this,-1,_T("Vascular Tree Extraction"));
3712
3713 // It doesn't works in linux
3714 //      wxFont font(18,wxDEFAULT  , wxITALIC, wxBOLD);
3715 //      title->SetFont(font);
3716
3717     wxBoxSizer *sizer= new wxBoxSizer(wxVERTICAL);
3718         sizer->Add( title               , 0, wxEXPAND | wxALIGN_RIGHT, 10);
3719         sizer->Add( _noteBook   , 1, wxGROW, 10 );
3720
3721 //EEDxx2.4
3722 //      FitInside();
3723
3724         sizer->SetSizeHints( this );   // set size hints to honour minimum size
3725         this->SetSizer(sizer);
3726         this->SetAutoLayout(true);
3727         this->Layout(); 
3728
3729 }
3730 //----------------------------------------------------------------------------
3731 wxMaracasNoteBookVascularTreeExtraction::~wxMaracasNoteBookVascularTreeExtraction()
3732 {
3733 }
3734
3735
3736 //----------------------------------------------------------------------------
3737 void wxMaracasNoteBookVascularTreeExtraction::OnChangePage(wxNotebookEvent& event)
3738 {
3739         Refresh();
3740 }
3741 //----------------------------------------------------------------------------
3742 void wxMaracasNoteBookVascularTreeExtraction::OnChangePageQuantification(wxNotebookEvent& event)
3743 {
3744 }
3745
3746
3747
3748 //----------------------------------------------------------------------------
3749 //----------------------------------------------------------------------------
3750 //----------------------------------------------------------------------------
3751
3752
3753 BEGIN_EVENT_TABLE(wxMaracasNoteBookSTLFormat , wxPanel)
3754 // Borrame
3755 //    EVT_MENU(MDI_CHILD_QUIT, MyChild::OnQuit)
3756 //    EVT_MENU(MDI_REFRESH, MyChild::OnRefresh)
3757 //    EVT_MENU(MDI_CHANGE_TITLE, MyChild::OnChangeTitle)
3758 //    EVT_MENU(MDI_CHANGE_POSITION, MyChild::OnChangePosition)
3759 //    EVT_MENU(MDI_CHANGE_SIZE, MyChild::OnChangeSize)
3760 //      EVT_MENU(20001, wxMaracasNoteBookIRMQuantification::OnSelectPatientStudySerieImage)
3761
3762 //    EVT_SIZE(MyChild::OnSize)
3763 //    EVT_MOVE(MyChild::OnMove)
3764
3765 //    EVT_CLOSE(wxMaracasPatientLstVoiChiFra::OnClose)
3766         EVT_TOOL(wxSurfaceWidget::ID_BUTTON_NEW_AXIS,   wxMaracasNoteBookSTLFormat::OnNewAxis                   )
3767         EVT_TOOL(wxSurfaceWidget::ID_BUTTON_DELETE_AXIS,wxMaracasNoteBookSTLFormat::OnDeleteAxis                )
3768 //      EVT_TOOL(20005,wxMaracasNoteBookVascularTreeExtraction::OnQuantification)
3769
3770
3771
3772 END_EVENT_TABLE()
3773
3774
3775 wxMaracasNoteBookSTLFormat::wxMaracasNoteBookSTLFormat(wxWindow *parent,marInterface *mar)
3776        : wxPanel(parent, -1)
3777 {
3778 printf("EED wxMaracasNoteBookSTLFormat::wxMaracasNoteBookSTLFormat 01 \n");
3779         _noteBook_general = new wxNotebook(this, -1);
3780         _noteBook_general->SetSize(550,300);
3781         wxImageList *imageList = new wxImageList(50,50);
3782
3783         wxBitmap mask= wxBITMAP( TOOLBAR_V2_sm_mask );
3784
3785         wxBitmap bitmap0        = wxBITMAP( TOOLBAR_V2_sm_bl_STLFormat );
3786         bitmap0.SetMask(new wxMask( mask ));
3787
3788
3789         imageList->Add(  bitmap0 );  // 0
3790         _noteBook_general->SetImageList(imageList);
3791
3792 //      wxPanel *panel01 = CreateSTLFormat_01( _noteBook_general , mar );
3793 //      wxPanel *panel02 = CreateSTLFormat_02( _noteBook_general , mar );
3794         wxPanel *panel03 = CreateSTLFormat_03( _noteBook_general , mar );
3795
3796 //      _noteBook_general->AddPage( panel01 , _T("STL Format 01  "), true, 0 );
3797 //      _noteBook_general->AddPage( panel02 , _T("STL Format 02 " ), true, 0 );
3798         _noteBook_general->AddPage( panel03 , _T("STL Format 03 ") , true, 0 );
3799         _noteBook_general->SetSelection(0);
3800
3801
3802         wxStaticText *title=new wxStaticText(this,-1,_T("STL Format"));
3803
3804 // It doesn't works in linux
3805 //      wxFont font(18,wxDEFAULT  , wxITALIC, wxBOLD);
3806 //      title->SetFont(font);
3807
3808     wxBoxSizer *sizer= new wxBoxSizer(wxVERTICAL);
3809         sizer->Add( title               , 0, wxEXPAND | wxALIGN_RIGHT, 10);
3810         sizer->Add( _noteBook_general   , 1, wxGROW, 10 );
3811
3812 //EEDxx2.4
3813 //      FitInside();
3814
3815         sizer->SetSizeHints( this );   // set size hints to honour minimum size
3816         this->SetSizer(sizer);
3817         this->SetAutoLayout(true);
3818         this->Layout(); 
3819 printf("EED wxMaracasNoteBookSTLFormat::wxMaracasNoteBookSTLFormat 02 \n");
3820 }
3821
3822
3823 //----------------------------------------------------------------------------
3824
3825 wxMaracasNoteBookSTLFormat::~wxMaracasNoteBookSTLFormat()
3826 {
3827 }
3828
3829
3830 //----------------------------------------------------------------------------
3831
3832 wxPanel *wxMaracasNoteBookSTLFormat::CreateSTLFormat_01(wxWindow *parent,marInterface *mar)
3833 {
3834
3835         wxSTLWidget_02 *stlWidget = new wxSTLWidget_02(parent,mar);
3836         stlWidget->ConfigureVTK();
3837
3838         return stlWidget;
3839 }
3840
3841
3842 //----------------------------------------------------------------------------
3843
3844 wxPanel *wxMaracasNoteBookSTLFormat::CreateSTLFormat_02(wxWindow *parent,marInterface *mar)
3845 {
3846         wxPanel *panel = new wxPanel(parent,-1);
3847
3848         _existAxis=false;
3849         _wxmaracassurfaceSTLwidget=NULL;
3850
3851         _noteBook_01 = new wxNotebook(panel, -1);
3852         _noteBook_01->SetSize(550,300);
3853
3854         wxImageList *imageList = new wxImageList(50,50);
3855         imageList->Add(  wxBITMAP( TOOLBAR_V2_sm_bl_AxisExtraction      ) );  // 0
3856         imageList->Add(  wxBITMAP( TOOLBAR_V2_sm_bl_STLFormat           ) );  // 1
3857         imageList->Add(  wxBITMAP( TOOLBAR_V2_sm_tr_STLFormat           ) );  // 2
3858         _noteBook_01->SetImageList(imageList);
3859
3860 //      _mar=mar;
3861
3862         _mar=new marInterface();
3863         _mar->_parameters->setRescaleSlope( mar->_parameters->getRescaleSlope() );
3864         _mar->_parameters->setRescaleIntercept( mar->_parameters->getRescaleIntercept() );
3865         _mar->_parameters->setIntParam( marParameters::e_voxel_type, marParameters::VOX_TYPE_MINIMUM );
3866         _mar->_parameters->setDoubleParam( marParameters::e_voxel_x_dimension, mar->_parameters->getDoubleParam(marParameters::e_voxel_x_dimension) );
3867         _mar->_parameters->setDoubleParam( marParameters::e_voxel_y_dimension, mar->_parameters->getDoubleParam(marParameters::e_voxel_y_dimension) );
3868         _mar->_parameters->setDoubleParam( marParameters::e_voxel_z_dimension, mar->_parameters->getDoubleParam(marParameters::e_voxel_z_dimension) );
3869         int voi[6];
3870         mar->_experiment->getVOI( voi );
3871         _mar->_experiment->setVOI( voi );
3872         _mar->SetDicom(mar->_dicom);
3873
3874         _mar->initExperiment( );
3875
3876         vtkImageData *marImageData;
3877         marImageData = _mar->_experiment->getDynData( )->getVolume( )->castVtk();
3878         marImageData->Update(); 
3879
3880         _wxmaracas3dbrowser = new wxMaracas3DBrowser( _noteBook_01, _mar, -1,ID_TOOLBAR_PLANS );
3881         _wxmaracas3dbrowser->LoadData( );
3882
3883         _noteBook_01->AddPage(_wxmaracas3dbrowser,_T("Axis Extraction  >>  "), true, 0 );
3884         _noteBook_01->AddPage(new wxPanel(_noteBook_01,-1),_T("STL"), true, 2 );
3885         _noteBook_01->SetSelection(0);
3886
3887         Connect(_noteBook_01->GetId() , wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING  , (wxObjectEventFunction) &wxMaracasNoteBookSTLFormat::OnChangePageSTLFormat );
3888         Connect(_noteBook_01->GetId() , wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED   , (wxObjectEventFunction) &wxMaracasNoteBookSTLFormat::OnChangePage );
3889
3890         wxStaticText *title=new wxStaticText(panel,-1,_T(" STL - 01 (MATHIEU)   "));
3891
3892 // It doesn't works in linux
3893 //      wxFont font(18,wxDEFAULT  , wxITALIC, wxBOLD);
3894 //      title->SetFont(font);
3895
3896     wxBoxSizer *sizer= new wxBoxSizer(wxVERTICAL);
3897         sizer->Add( title                       , 0, wxEXPAND | wxALIGN_RIGHT, 10);
3898         sizer->Add( _noteBook_01        , 1, wxGROW , 10 );
3899
3900 //EEDxx2.4
3901 //      FitInside();
3902
3903         sizer->SetSizeHints( panel );   // set size hints to honour minimum size
3904         panel->SetSizer(sizer);
3905         panel->SetAutoLayout(true);
3906         panel->Layout();        
3907
3908         return panel;
3909 }
3910
3911 //----------------------------------------------------------------------------
3912
3913 wxPanel *wxMaracasNoteBookSTLFormat::CreateSTLFormat_03(wxWindow *parent,marInterface *mar)
3914 {
3915
3916         wxSTLWidget_03 *stlWidget = new wxSTLWidget_03(parent,mar);
3917         stlWidget->ConfigureVTK();
3918
3919         return stlWidget;
3920 }
3921
3922
3923 //----------------------------------------------------------------------------
3924
3925 void wxMaracasNoteBookSTLFormat::OnChangePage(wxNotebookEvent& event)
3926 {
3927         if (_noteBook_01->GetSelection()==1){
3928                 if (_wxmaracassurfaceSTLwidget!=NULL)
3929                 {
3930                         delete _wxmaracassurfaceSTLwidget;
3931                 }
3932                 _wxmaracassurfaceSTLwidget = new wxSurfaceSTLWidget( _noteBook_01->GetPage(1) );
3933                 _wxmaracassurfaceSTLwidget->ShowMARACASData( _mar );
3934                 wxBoxSizer *sizer= new wxBoxSizer(wxHORIZONTAL);
3935                 sizer->Add( _wxmaracassurfaceSTLwidget , 1, wxALL|wxEXPAND, 0); 
3936                 _noteBook_01->GetPage(1)->SetAutoLayout(true);
3937                 _noteBook_01->GetPage(1)->SetSizer(sizer);
3938                 _noteBook_01->GetPage(1)->Layout();             
3939         }
3940         Refresh();
3941 }
3942
3943 //----------------------------------------------------------------------------
3944
3945 void wxMaracasNoteBookSTLFormat::OnChangePageSTLFormat(wxNotebookEvent& event)
3946 {
3947         if (_noteBook_01->GetSelection()==0){
3948                 if (_existAxis == false )
3949                 {
3950                         wxMessageDialog msg(this, _T("You have to extract the axis befor run this option.."), _T("Message box"), wxOK );
3951                         msg.ShowModal();
3952                         event.Veto();
3953                 }
3954         }
3955         Refresh();
3956 }
3957
3958 //----------------------------------------------------------------------------
3959
3960 void wxMaracasNoteBookSTLFormat::OnNewAxis(wxCommandEvent &WXUNUSED(event))
3961 {
3962         _existAxis=true;
3963         _noteBook_01->SetPageImage(1, 1);
3964 }
3965
3966 //----------------------------------------------------------------------------
3967 void wxMaracasNoteBookSTLFormat::OnDeleteAxis(wxCommandEvent &WXUNUSED(event))
3968 {
3969         _existAxis=false;
3970         _noteBook_01->SetPageImage(1, 2);
3971 }
3972
3973
3974 //----------------------------------------------------------------------------
3975 //----------------------------------------------------------------------------
3976 //----------------------------------------------------------------------------
3977
3978
3979 BEGIN_EVENT_TABLE(wxMaracasNoteBookTests , wxPanel)
3980 // Borrame
3981 //    EVT_MENU(MDI_CHILD_QUIT, MyChild::OnQuit)
3982 //    EVT_MENU(MDI_REFRESH, MyChild::OnRefresh)
3983 //    EVT_MENU(MDI_CHANGE_TITLE, MyChild::OnChangeTitle)
3984 //    EVT_MENU(MDI_CHANGE_POSITION, MyChild::OnChangePosition)
3985 //    EVT_MENU(MDI_CHANGE_SIZE, MyChild::OnChangeSize)
3986 //      EVT_MENU(20001, wxMaracasNoteBookIRMQuantification::OnSelectPatientStudySerieImage)
3987
3988 //    EVT_SIZE(MyChild::OnSize)
3989 //    EVT_MOVE(MyChild::OnMove)
3990
3991 //    EVT_CLOSE(wxMaracasPatientLstVoiChiFra::OnClose)
3992 //      EVT_TOOL(wxSurfaceWidget::ID_BUTTON_NEW_AXIS,   wxMaracasNoteBookTests::OnNewAxis                       )
3993 //      EVT_TOOL(wxSurfaceWidget::ID_BUTTON_DELETE_AXIS,wxMaracasNoteBookTests::OnDeleteAxis            )
3994 //      EVT_TOOL(20005,wxMaracasNoteBookVascularTreeExtraction::OnQuantification)
3995
3996
3997
3998 END_EVENT_TABLE()
3999
4000
4001 wxMaracasNoteBookTests::wxMaracasNoteBookTests(wxWindow *parent,marInterface *mar)
4002        : wxPanel(parent, -1)
4003 {
4004         wxBusyCursor wait;
4005
4006         _noteBook = new wxNotebook(this, -1);
4007         _noteBook->SetSize(550,300);
4008
4009
4010         wxBitmap mask= wxBITMAP( TOOLBAR_V2_sm_mask );
4011
4012         wxBitmap bitmap0        = wxBITMAP( TOOLBAR_V2_sm_bl_Processing );
4013         wxBitmap bitmap1        = wxBITMAP( TOOLBAR_V2_sm_bl_Processing );
4014
4015         bitmap0.SetMask(new wxMask( mask ));
4016         bitmap1.SetMask(new wxMask( mask ));
4017
4018         wxImageList *imageList = new wxImageList(50,50);
4019         imageList->Add( bitmap0 );  // 0
4020         imageList->Add( bitmap1 );  // 1
4021         _noteBook->SetImageList(imageList);
4022
4023
4024         _mar=new marInterface();
4025         _mar->_parameters->setRescaleSlope( mar->_parameters->getRescaleSlope() );
4026         _mar->_parameters->setRescaleIntercept( mar->_parameters->getRescaleIntercept() );
4027         _mar->_parameters->setIntParam( marParameters::e_voxel_type, marParameters::VOX_TYPE_MINIMUM );
4028         _mar->_parameters->setDoubleParam( marParameters::e_voxel_x_dimension, mar->_parameters->getDoubleParam(marParameters::e_voxel_x_dimension) );
4029         _mar->_parameters->setDoubleParam( marParameters::e_voxel_y_dimension, mar->_parameters->getDoubleParam(marParameters::e_voxel_y_dimension) );
4030         _mar->_parameters->setDoubleParam( marParameters::e_voxel_z_dimension, mar->_parameters->getDoubleParam(marParameters::e_voxel_z_dimension) );
4031         int voi[6];
4032         mar->_experiment->getVOI( voi );
4033         _mar->_experiment->setVOI( voi );
4034         _mar->SetDicom(mar->_dicom);
4035
4036         _mar->initExperiment( );
4037
4038         vtkImageData *vtkimagedata;
4039         vtkimagedata = _mar->_experiment->getDynData( )->getVolume( )->castVtk();
4040         vtkimagedata->Update(); 
4041         marImageData *marimagedata = new marImageData(vtkimagedata);
4042
4043         // --
4044 //      _wxmanualcontourpanel = new wxMaracas_ManualContour_Panel( _noteBook  );
4045 //      _wxmanualcontourpanel->ConfigureVTK( marimagedata );
4046 //      _noteBook->AddPage(_wxmanualcontourpanel,_T(" Manual Contour "), true, 0 );
4047
4048
4049         // --
4050         _wxMaracasEmptyPanel_3 = new wxMaracasEmptyPanel_3( _noteBook  );
4051         _wxMaracasEmptyPanel_3->ConfigureVTK( marimagedata );
4052         _noteBook->AddPage(_wxMaracasEmptyPanel_3,_T(" 2 contornos Maria Alejandra "), true, 0 );
4053
4054         // --
4055         _noteBook->AddPage(new wxPanel(_noteBook,-1),_T("?? "), true, 1 );
4056
4057         // --
4058         _wxMaracas_ManualTree_MPR = new wxMaracas_ManualTree_MPR( _noteBook, marimagedata , _mar->_parameters->getVoxelSize());
4059         _wxMaracas_ManualTree_MPR->ConfigureVTK();
4060         _noteBook->AddPage(_wxMaracas_ManualTree_MPR,_T("Manual Tree  E.Davila  "), true, 1 );
4061
4062
4063         // --
4064         _wxMaracas_ManualSegmentation_MPR = new wxMaracas_ManualSegmentation_MPR( _noteBook, marimagedata , _mar->_parameters->getVoxelSize());
4065         _wxMaracas_ManualSegmentation_MPR->ConfigureVTK();
4066         _noteBook->AddPage(_wxMaracas_ManualSegmentation_MPR,_T("Manual Segmentation Diego  "), true, 1 );
4067
4068         // --
4069         _wxMaracas_SegmentationFM3D = new wxMaracas_SegmentationFM3D( _noteBook, marimagedata , _mar->_parameters->getVoxelSize());
4070         _wxMaracas_SegmentationFM3D->ConfigureVTK();
4071         _noteBook->AddPage(_wxMaracas_SegmentationFM3D,_T("Segmentation FM3D Diego  "), true, 1 );
4072
4073
4074
4075         // --
4076 //EED 4 oct 2006 information pour Loic
4077 //      _wxMaracasEmptyPanel_4 = new wxMaracasEmptyPanel_4( _noteBook );
4078 //      _wxMaracasEmptyPanel_4->ConfigureVTK(  );
4079 //      _noteBook->AddPage(_wxMaracasEmptyPanel_4,"Loic", true, 1 );
4080
4081         _noteBook->SetSelection(0);
4082         Connect(_noteBook->GetId() , wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING  , (wxObjectEventFunction) &wxMaracasNoteBookTests::OnChangePageTests );
4083         Connect(_noteBook->GetId() , wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED   , (wxObjectEventFunction) &wxMaracasNoteBookTests::OnChangePage );
4084
4085         wxStaticText *title=new wxStaticText(this,-1,_T("Tests..."));
4086
4087 // It doesn't works in linux
4088 //      wxFont font(18,wxDEFAULT  , wxITALIC, wxBOLD);
4089 //      title->SetFont(font);
4090
4091     wxBoxSizer *sizer= new wxBoxSizer(wxVERTICAL);
4092         sizer->Add( title               , 0, wxEXPAND | wxALIGN_RIGHT, 10);
4093         sizer->Add( _noteBook   , 1, wxGROW, 10 );
4094
4095 //EEDxx2.4
4096 //      FitInside();
4097
4098         sizer->SetSizeHints( this );   // set size hints to honour minimum size
4099         this->SetSizer(sizer);
4100         this->SetAutoLayout(true);
4101         this->Layout(); 
4102
4103 }
4104 //----------------------------------------------------------------------------
4105 wxMaracasNoteBookTests::~wxMaracasNoteBookTests()
4106 {
4107 }
4108
4109 //----------------------------------------------------------------------------
4110 void wxMaracasNoteBookTests::OnChangePage(wxNotebookEvent& event)
4111 {
4112         Refresh();
4113 }
4114
4115 //----------------------------------------------------------------------------
4116 void wxMaracasNoteBookTests::OnChangePageTests(wxNotebookEvent& event)
4117 {
4118         Refresh();
4119 }
4120
4121
4122 //----------------------------------------------------------------------------
4123 //----------------------------------------------------------------------------
4124 //----------------------------------------------------------------------------
4125
4126
4127 BEGIN_EVENT_TABLE(wxMaracasNoteBookManualRegistration , wxPanel)
4128 //
4129 END_EVENT_TABLE()
4130
4131
4132 wxMaracasNoteBookManualRegistration::wxMaracasNoteBookManualRegistration(wxWindow *parent,marInterface *mar)
4133        : wxPanel(parent, -1)
4134 {
4135         wxBusyCursor wait;
4136
4137         _noteBook = new wxNotebook(this, -1);
4138         _noteBook->SetSize(550,300);
4139
4140
4141         wxBitmap mask= wxBITMAP( TOOLBAR_V2_sm_mask );
4142
4143         wxBitmap bitmap0        = wxBITMAP( TOOLBAR_V2_sm_bl_Processing );
4144         wxBitmap bitmap1        = wxBITMAP( TOOLBAR_V2_sm_bl_Processing );
4145
4146         bitmap0.SetMask(new wxMask( mask ));
4147         bitmap1.SetMask(new wxMask( mask ));
4148
4149         wxImageList *imageList = new wxImageList(50,50);
4150         imageList->Add( bitmap0 );  // 0
4151         imageList->Add( bitmap1 );  // 1
4152         _noteBook->SetImageList(imageList);
4153
4154
4155         _mar=new marInterface();
4156         _mar->_parameters->setRescaleSlope( mar->_parameters->getRescaleSlope() );
4157         _mar->_parameters->setRescaleIntercept( mar->_parameters->getRescaleIntercept() );
4158         _mar->_parameters->setIntParam( marParameters::e_voxel_type, marParameters::VOX_TYPE_MINIMUM );
4159         _mar->_parameters->setDoubleParam( marParameters::e_voxel_x_dimension, mar->_parameters->getDoubleParam(marParameters::e_voxel_x_dimension) );
4160         _mar->_parameters->setDoubleParam( marParameters::e_voxel_y_dimension, mar->_parameters->getDoubleParam(marParameters::e_voxel_y_dimension) );
4161         _mar->_parameters->setDoubleParam( marParameters::e_voxel_z_dimension, mar->_parameters->getDoubleParam(marParameters::e_voxel_z_dimension) );
4162         int voi[6];
4163         mar->_experiment->getVOI( voi );
4164         _mar->_experiment->setVOI( voi );
4165         _mar->SetDicom(mar->_dicom);
4166
4167         _mar->initExperiment( );
4168
4169         vtkImageData *imagedata;
4170         imagedata = _mar->_experiment->getDynData( )->getVolume( )->castVtk();
4171         imagedata->Update(); 
4172         marImageData *marimagedata=new marImageData(imagedata);
4173
4174         _wxmanualregistration3D = new wxManualRegistration3D(_noteBook,marimagedata);
4175         _wxmanualregistration3D->ConfigureVTK();
4176         _noteBook->AddPage( _wxmanualregistration3D , _T("Manual registration 3D") , true, 0 );
4177
4178         _noteBook->SetSelection(0);
4179         Connect(_noteBook->GetId() , wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING  , (wxObjectEventFunction) &wxMaracasNoteBookTests::OnChangePageTests );
4180         Connect(_noteBook->GetId() , wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED   , (wxObjectEventFunction) &wxMaracasNoteBookTests::OnChangePage );
4181
4182         wxStaticText *title=new wxStaticText(this,-1,_T("Manual registration"));
4183
4184 // It doesn't works in linux
4185 //      wxFont font(18,wxDEFAULT  , wxITALIC, wxBOLD);
4186 //      title->SetFont(font);
4187
4188     wxBoxSizer *sizer= new wxBoxSizer(wxVERTICAL);
4189         sizer->Add( title               , 0, wxEXPAND | wxALIGN_RIGHT, 10);
4190         sizer->Add( _noteBook   , 1, wxGROW, 10 );
4191
4192         sizer->SetSizeHints( this );   // set size hints to honour minimum size
4193         this->SetSizer(sizer);
4194         this->SetAutoLayout(true);
4195         this->Layout(); 
4196
4197 }
4198 //----------------------------------------------------------------------------
4199 wxMaracasNoteBookManualRegistration::~wxMaracasNoteBookManualRegistration()
4200 {
4201 }
4202
4203 //----------------------------------------------------------------------------
4204 void wxMaracasNoteBookManualRegistration::OnChangePage(wxNotebookEvent& event)
4205 {
4206         Refresh();
4207 }
4208
4209 //----------------------------------------------------------------------------
4210 void wxMaracasNoteBookManualRegistration::OnChangePageTests(wxNotebookEvent& event)
4211 {
4212         Refresh();
4213 }
4214
4215 //----------------------------------------------------------------------------
4216 bool wxMaracasNoteBookManualRegistration::GetIfSecondVolumeExist()
4217 {
4218         return _wxmanualregistration3D->GetIfSecondVolumeExist();
4219 }
4220 //----------------------------------------------------------------------------
4221 void wxMaracasNoteBookManualRegistration::GenerateSecondVolume(marInterface *mar)
4222 {
4223         _marB=new marInterface();
4224         _marB->_parameters->setRescaleSlope( mar->_parameters->getRescaleSlope() );
4225         _marB->_parameters->setRescaleIntercept( mar->_parameters->getRescaleIntercept() );
4226         _marB->_parameters->setIntParam( marParameters::e_voxel_type, marParameters::VOX_TYPE_MINIMUM );
4227         _marB->_parameters->setDoubleParam( marParameters::e_voxel_x_dimension, mar->_parameters->getDoubleParam(marParameters::e_voxel_x_dimension) );
4228         _marB->_parameters->setDoubleParam( marParameters::e_voxel_y_dimension, mar->_parameters->getDoubleParam(marParameters::e_voxel_y_dimension) );
4229         _marB->_parameters->setDoubleParam( marParameters::e_voxel_z_dimension, mar->_parameters->getDoubleParam(marParameters::e_voxel_z_dimension) );
4230         int voi[6];
4231         mar->_experiment->getVOI( voi );
4232         _marB->_experiment->setVOI( voi );
4233         _marB->SetDicom(mar->_dicom);
4234
4235         _marB->initExperiment( );
4236
4237         vtkImageData *vtkimagedata;
4238         vtkimagedata = _marB->_experiment->getDynData( )->getVolume( )->castVtk();
4239         vtkimagedata->Update(); 
4240         _wxmanualregistration3D->AddSecondVolume(new marImageData(vtkimagedata));
4241 }