1 /*=========================================================================
4 Module: $RCSfile: wxMaracasFrame.cxx,v $
6 Date: $Date: 2008/10/31 16:32:10 $
7 Version: $Revision: 1.1 $
9 Copyright: (c) 2002, 2003
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.
16 =========================================================================*/
18 // PS -> #include "wxMaracasDataBrowser.h"
19 #include "wxMaracasParametersDialog.h"
20 #include "wxMaracasImageBrowser.h"
21 #include "wxMaracasHelpDialog.h"
22 #include "wxMaracasFrame.h"
23 #include "marDictionary.h"
26 #include <wx/toolbar.h>
27 #include <wx/dialog.h>
28 #include <wx/colordlg.h>
29 // ----------------------------------------------------------------------------
30 // Maracas "logic world" headers
31 // ----------------------------------------------------------------------------
35 # include "res/bitmaps/connect.xpm"
36 # include "res/bitmaps/params.xpm"
37 # include "res/bitmaps/imagebrowser.xpm"
38 # include "res/bitmaps/3D.xpm"
39 # include "res/bitmaps/plans.xpm"
40 # include "res/bitmaps/quant.xpm"
41 # include "res/bitmaps/rotate.xpm"
42 # include "res/bitmaps/bright.xpm"
43 # include "res/bitmaps/pan.xpm"
44 # include "res/bitmaps/zoom.xpm"
45 # include "res/bitmaps/clear.xpm"
46 # include "res/bitmaps/intensity.xpm"
47 # include "res/bitmaps/help.xpm"
48 # include "res/bitmaps/creatis_logo.xpm"
49 # include "res/icons/maracas.xpm"
52 BEGIN_EVENT_TABLE( wxMaracasFrame, wxFrame )
53 // PS -> EVT_MENU( ID_TOOLBAR_DATA_BROWSER, wxMaracasFrame::OnLoadPatientData )
54 EVT_MENU( ID_TOOLBAR_PARAMETERS, wxMaracasFrame::OnParameters )
55 // PS -> EVT_MENU( ID_TOOLBAR_IMAGE_BROWSER, wxMaracasFrame::OnLoadImageData )
56 EVT_MENU( ID_TOOLBAR_3D_BROWSER, wxMaracasFrame::OnStartExperiment )
57 // PS -> EVT_MENU( ID_TOOLBAR_HELP, wxMaracasFrame::OnHelp )
58 EVT_MENU( ID_TOOLBAR_PLANS, wxMaracasFrame::OnQuant )
60 // EED : This is not top !!!!!!!!!!!
61 EVT_TOOL( 19999, wxMaracasFrame::OnRegenerateAll )
62 EVT_TOOL( 19998, wxMaracasFrame::OnRegenerateSplineAxe )
63 EVT_TOOL( 19997, wxMaracasFrame::OnCleanContours )
64 EVT_TOOL( 19996, wxMaracasFrame::OnRegenerateSignal )
67 EVT_CLOSE( wxMaracasFrame::OnQuit )
69 EVT_TOOL(wxSurfaceWidget::ID_BUTTON_NEW_AXIS, wxMaracasFrame::OnNewAxis )
70 EVT_TOOL(wxSurfaceWidget::ID_BUTTON_DELETE_AXIS, wxMaracasFrame::OnDeleteAxis )
73 //----------------------------------------------------------------------------
74 wxMaracasFrame::wxMaracasFrame( wxFrame *parent, wxWindowID id,
75 marInterface *mar,marSimpleDicom *simpleDicom, char *dictionaryFileName,
76 const wxString& title, const wxPoint& pos,
77 const wxSize& size, long style)
78 : wxFrame( parent, id, title, pos, size, style)
81 _marSimpleDicom = simpleDicom;
82 _wxmaracasquantification = NULL;
83 _wxmaracas3dbrowser = NULL;
85 marDictionary marDict;
86 // marDict.LoadDictionary_French();
87 marDict.LoadDictionary_English();
88 // marDict.LoadDictionary_Japanese();
92 if (!marDict.LoadDictionaryFile(dictionaryFileName)){
93 wxMessageBox( "Error: File(s) marDict.txt not found...",
94 "DxMM : MARACAS", wxOK | wxCENTRE | wxICON_ERROR , this);
99 vtkObject *a = vtkObject::New();
100 a->GlobalWarningDisplayOff();
103 // At the begining, there were nothing, just a window...
104 _actual_panel = NULL;
106 // And the programmer said: let there be a status bar
107 this->CreateStatusBar( );
109 this->GetStatusBar()->SetFieldsCount( 2 );
111 this->GetStatusBar()->GetFieldRect(1, rect);
114 //_progressGauge = new wxGauge( this->GetStatusBar(), -1, 100);
115 // _progressGauge = new wxGauge( this->GetStatusBar(), -1, 50,
116 // rect.GetPosition(), rect.GetSize());
117 this->GetStatusBar()->Show();
118 this->PositionStatusBar();
120 // And an icon (to be unique)
121 //TODO change the icon to the real one!
122 this->SetIcon( wxICON( maracas_icon ) );
124 // And a toolbar (for dummy users)
125 this->RecreateToolbar( );
128 //----------------------------------------------------------------------------
129 void wxMaracasFrame::RecreateToolbar( )
131 wxToolBar* toolBar = this->GetToolBar( );
133 this->SetToolBar( NULL );
135 toolBar = this->CreateToolBar( TOOLBAR_STYLE, ID_TOOLBAR );
138 wxBitmap toolBarBitmaps[ 22+1 ];
141 * wxBitmap vs. wxBITMAP -> add _xpm at the end of the file
143 toolBarBitmaps[ 0 ] = wxBITMAP( toolbar_connect );
144 toolBarBitmaps[ 4 ] = wxBITMAP( toolbar_params );
145 toolBarBitmaps[ 7 ] = wxBITMAP( toolbar_imagebrowser );
146 toolBarBitmaps[ 9 ] = wxBITMAP( toolbar_triD );
148 toolBarBitmaps[ 10 ] = wxBITMAP( toolbar_plans );
149 toolBarBitmaps[ 11 ] = wxBITMAP( toolbar_quant );
150 toolBarBitmaps[ 12 ] = wxBITMAP( toolbar_rotate );
151 toolBarBitmaps[ 13 ] = wxBITMAP( toolbar_bright );
152 toolBarBitmaps[ 14 ] = wxBITMAP( toolbar_pan );
153 toolBarBitmaps[ 15 ] = wxBITMAP( toolbar_zoom );
154 toolBarBitmaps[ 16 ] = wxBITMAP( toolbar_clear );
155 toolBarBitmaps[ 17 ] = wxBITMAP( toolbar_intensity );
156 toolBarBitmaps[ 20 ] = wxBITMAP( toolbar_help );
157 toolBarBitmaps[ 22 ] = wxBITMAP( creatis_logo );
160 toolBarBitmaps[ 1 ] = wxBitmap( toolbar_loadexp );
161 toolBarBitmaps[ 2 ] = wxBitmap( toolbar_save );
162 toolBarBitmaps[ 3 ] = wxBitmap( toolbar_excel );
163 toolBarBitmaps[ 5 ] = wxBitmap( toolbar_wizard );
164 toolBarBitmaps[ 6 ] = wxBitmap( toolbar_back );
165 toolBarBitmaps[ 8 ] = wxBitmap( toolbar_subtract );
167 toolBarBitmaps[ 18 ] = wxBitmap( toolbar_linear );
168 toolBarBitmaps[ 19 ] = wxBitmap( toolbar_area );
170 // Set size & margins
171 toolBar->SetMargins( 4, 4 );
173 toolBar->SetToolBitmapSize( wxSize( toolBarBitmaps[ 4 ].GetWidth( ), toolBarBitmaps[ 4 ].GetHeight( ) ) );
175 // PS -> toolBar->SetToolBitmapSize( wxSize( toolBarBitmaps[ 0 ].GetWidth( ), toolBarBitmaps[ 0 ].GetHeight( ) ) );
179 // PS -> #ifndef DXMM
180 // PS -> toolBar->AddTool( ID_TOOLBAR_DATA_BROWSER, toolBarBitmaps[ 0 ], "Patient data", "Load patient data: studies & series" );
181 // PS -> toolBar->AddSeparator( );
182 // PS -> toolBar->AddTool( ID_TOOLBAR_IMAGE_BROWSER, toolBarBitmaps[ 7 ], "Load image data", "Load DICOM images from disk" );
183 // PS -> toolBar->AddSeparator( );
185 toolBar->AddTool( ID_TOOLBAR_3D_BROWSER, toolBarBitmaps[ 9 ], _T("Start 3D"), _T("Load 3D representation") );
186 toolBar->AddSeparator( );
187 toolBar->AddTool( ID_TOOLBAR_PLANS, toolBarBitmaps[ 10 ], _T("Plan"), _T("Planes") );
188 toolBar->AddSeparator( );
189 // toolBar->AddTool( ID_TOOLBAR_QUANT, toolBarBitmaps[ 11 ], "Quant", "Quant" );
190 // toolBar->AddSeparator( );
191 //The following has been commented out temporarlily
193 toolBar->AddTool( ID_TOOLBAR_ROTATE, toolBarBitmaps[ 12 ], "Rotate", "Rotate" );
194 toolBar->AddSeparator( );
195 toolBar->AddTool( ID_TOOLBAR_BRIGHT, toolBarBitmaps[ 13 ], "Bright", "Bright" );
196 toolBar->AddSeparator( );
197 toolBar->AddTool( ID_TOOLBAR_PAN, toolBarBitmaps[ 14 ], "Pan", "Pan" );
198 toolBar->AddSeparator( );
199 toolBar->AddTool( ID_TOOLBAR_ZOOM, toolBarBitmaps[ 15 ], "Zoom", "Zoom" );
200 toolBar->AddSeparator( );
201 toolBar->AddTool( ID_TOOLBAR_CLEAR, toolBarBitmaps[ 16 ], "Clear", "Clear" );
202 toolBar->AddSeparator( );
203 toolBar->AddTool( ID_TOOLBAR_INTENSITY, toolBarBitmaps[ 17 ], "Intensity", "Intensity" );
204 toolBar->AddSeparator( );*/
205 toolBar->AddTool( ID_TOOLBAR_PARAMETERS, toolBarBitmaps[ 4 ], _T("Parameters"), _T("Load parameters for modifying") );
206 //toolBar->AddTool( ID_TOOLBAR_HELP, toolBarBitmaps[ 20 ], "Help", "Help" );
207 toolBar->AddSeparator( );
209 wxBitmapButton *btnCreatisLogo = new wxBitmapButton(toolBar,-1,toolBarBitmaps[ 22 ] );
210 btnCreatisLogo->SetSize(81+10,20+10);
211 btnCreatisLogo->SetBackgroundColour(wxColour(0,0,153));
212 Connect(btnCreatisLogo->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxMaracasFrame::OnAboutCreatis );
214 toolBar->AddControl(btnCreatisLogo);
219 toolBar->SetRows( 1 );
220 toolBar->EnableTool(ID_TOOLBAR_3D_BROWSER, true);
221 toolBar->EnableTool(ID_TOOLBAR_PLANS, false);
222 toolBar->EnableTool(ID_TOOLBAR_QUANT, false);
225 //----------------------------------------------------------------------------
226 void wxMaracasFrame::OnAboutCreatis( wxCommandEvent& event ){
227 wxMaracasHelpDialog *dlg = new wxMaracasHelpDialog(this, -1, "Creatis", wxPoint(200,200), wxDefaultSize, wxDEFAULT_DIALOG_STYLE);
232 //----------------------------------------------------------------------------
233 void wxMaracasFrame::OnQuit( wxCloseEvent& event ){
236 if (_mar!=NULL) { delete _mar; }
238 marDictionary marDict;
239 marDict.FreeDictionary();
242 // this->Show(FALSE);
246 //----------------------------------------------------------------------------
247 // PS -> void wxMaracasFrame::OnLoadPatientData( wxCommandEvent& event )
249 // PS -> wxBusyCursor wait;
250 // PS -> wxToolBar* toolBar = this->GetToolBar( );
251 // PS -> //Disabling tool
252 // PS -> //wxToolBar::EnableTool This function should only be called after Realize.
253 // PS -> toolBar->EnableTool(ID_TOOLBAR_IMAGE_BROWSER, false);
254 // PS -> toolBar->EnableTool(ID_TOOLBAR_3D_BROWSER, true);
255 // PS -> toolBar->EnableTool(ID_TOOLBAR_PLANS, true);
256 // PS -> toolBar->EnableTool(ID_TOOLBAR_QUANT, false);
258 // PS -> // Create panel
259 // PS -> if( _actual_panel != NULL ) delete _actual_panel;
260 // PS -> wxMaracasDataBrowser* pnl = new wxMaracasDataBrowser( this, _mar, -1 );
262 // PS -> _actual_panel = pnl;
264 // PS -> // cf.: http://www.wxwindows.org/manuals/2.4.0/wx490.htm
265 // PS -> // Force a resize. This should probably be replaced by a call to a wxFrame
266 // PS -> // function that lays out default decorations and the remaining content window.
267 // PS -> wxSizeEvent myevent(wxSize(-1, -1), this->GetId());
268 // PS -> this->OnSize(myevent);
269 // PS -> this->Show(true);
271 // PS -> // Load panel data
272 // PS -> pnl->LoadData( );
273 // PS -> //this->GetToolBar()->EnableTool(ID_TOOLBAR_3D_BROWSER, false);
275 //----------------------------------------------------------------------------
276 void wxMaracasFrame::OnParameters( wxCommandEvent& event )
280 wxWindowDC *wxwindc =new wxWindowDC(this);
282 wxwindc->GetSize(&w, &h);
283 wxBitmap *wxbitmap =new wxBitmap(w, h);
284 wxMemoryDC *wxmemorydc = new wxMemoryDC();
286 wxmemorydc->SelectObject(*wxbitmap);
287 wxmemorydc->Blit(0,0,w,h,wxwindc,0,0);
289 wxbitmap->SaveFile("c:/tmp/MaracasPlamavic.bmp", wxBITMAP_TYPE_BMP );
295 wxMaracasParametersDialog *d = new wxMaracasParametersDialog( this, _mar );
299 if (d->IfInitContour()==true){
302 if (d->GetInitContour()==true){
304 wxmaracasquantification;
305 if (wxmaracas3dbrowser!=NULL){
309 //----------------------------------------------------------------------------
310 // PS -> void wxMaracasFrame::OnLoadImageData( wxCommandEvent& event )
312 // PS -> wxBusyCursor wait;
314 // PS -> // Create panel
315 // PS -> if( _actual_panel != NULL ) delete _actual_panel;
316 // PS -> wxMaracasImageBrowser* pnl = new wxMaracasImageBrowser( this, _mar, -1 );
319 // PS -> _actual_panel = pnl;
321 // PS -> // Load panel data
322 // PS -> wxSizeEvent myevent(wxSize(-1, -1), this->GetId());
323 // PS -> this->OnSize(myevent);
324 // PS -> //this->Show(true);
326 // PS -> //wxDialog dialog(this, -1, "coucou");
327 // PS -> //dialog.ShowModal();
328 // PS -> //dialog.Show(true);
329 // PS -> //wxGauge gauge( this, -1, 50);
332 // PS -> AS a first step I'll pass a wxGauge as parameter this doesn't
333 // PS -> sound very good, should use EVT_TIMER instead...
335 // PS -> _mar->_dicom->loadActualSerie( this->_progressGauge );
336 // PS -> vtkImageData *dummy = _mar->_dicom->getVolume( )->castVtk();
337 // PS -> //float range[2];
338 // PS -> //dummy->GetScalarRange( range );
340 // PS -> pnl->LoadData( dummy );
341 // PS -> //_view_image->ConstructVTK( (vtkImageData *)_mar->_dicom->getVolume( ));
342 // PS -> //^ this is not working ??? I don't understand why, some VTK pipeline mystery
344 // PS -> this->GetToolBar()->EnableTool(ID_TOOLBAR_IMAGE_BROWSER, false);
345 // PS -> this->GetToolBar()->EnableTool(ID_TOOLBAR_3D_BROWSER, true);
346 // PS -> //Add patient name to the frame title
347 // PS -> this->SetTitle( "Patient Name : " + _mar->_dicom->GetPatientName() );
349 //----------------------------------------------------------------------------
350 void wxMaracasFrame::OnStartExperiment( wxCommandEvent& event )
356 // PS -> #ifndef DXMM
357 // PS -> ((wxMaracasImageBrowser*)_actual_panel )->GetROI( voi );
360 _marSimpleDicom->loadActualSerie( this->_progressGauge );
361 _mar->_dicom->SetVolume( _marSimpleDicom->getVolume() );
365 voi[1] = (_mar->_dicom->getVolume( )->getXdim( ))-1;
367 voi[3] = (_mar->_dicom->getVolume( )->getYdim( ))-1;
369 voi[5] = (_mar->_dicom->getVolume( )->getZdim( ))-1;
372 _mar->_experiment->setVOI( voi );
373 _mar->initExperiment( );
377 _wxmaracas3dbrowser = new wxMaracas3DBrowser( this, _mar, -1 ,ID_TOOLBAR_PLANS);
380 _actual_panel = _wxmaracas3dbrowser;
382 wxSizeEvent myevent(wxSize(-1, -1), this->GetId());
383 this->OnSize(myevent);
387 _wxmaracas3dbrowser->LoadData( );
389 // PS -> #ifndef DXMM
390 // PS -> this->GetToolBar()->EnableTool(ID_TOOLBAR_IMAGE_BROWSER, true);
391 // PS -> this->GetToolBar()->EnableTool(ID_TOOLBAR_3D_BROWSER, false);
393 this->GetToolBar()->EnableTool(ID_TOOLBAR_PLANS, false);
394 this->GetToolBar()->EnableTool(ID_TOOLBAR_3D_BROWSER, false);
395 this->GetToolBar()->EnableTool(ID_TOOLBAR_QUANT, false);
398 //----------------------------------------------------------------------------
399 // PS -> void wxMaracasFrame::OnHelp (wxCommandEvent& event )
401 // PS -> wxMaracasHelpDialog* help = new wxMaracasHelpDialog(this, -1);
403 // PS -> help->ShowModal();
406 //----------------------------------------------------------------------------
407 void wxMaracasFrame::DeletePanels ( ){
408 if (_wxmaracasquantification!=NULL){
409 delete _wxmaracasquantification;
410 _wxmaracasquantification=NULL;
412 if (_wxmaracas3dbrowser!=NULL){
413 delete _wxmaracas3dbrowser;
414 _wxmaracas3dbrowser=NULL;
417 //----------------------------------------------------------------------------
418 void wxMaracasFrame::OnQuant (wxCommandEvent& event ){
422 if (_wxmaracas3dbrowser!=NULL){
423 isovalue = _wxmaracas3dbrowser->GetIsovalue();
424 opacity = _wxmaracas3dbrowser->GetOpacity();
428 _wxmaracasquantification = new wxMaracasQuantification( this, _mar, -1 );
429 _actual_panel = _wxmaracasquantification;
431 wxSizeEvent myevent(wxSize(-1, -1), this->GetId());
432 this->OnSize(myevent);
436 _wxmaracasquantification->LoadData( );
437 _wxmaracasquantification->SetSlider_Isovalue_Opacity(isovalue,opacity);
438 this->GetToolBar()->EnableTool(ID_TOOLBAR_PLANS, false);
439 this->GetToolBar()->EnableTool(ID_TOOLBAR_3D_BROWSER, true);
441 //----------------------------------------------------------------------------
442 void wxMaracasFrame::OnNewAxis(wxCommandEvent &WXUNUSED(event))
444 this->GetToolBar()->EnableTool(ID_TOOLBAR_PLANS, true);
445 this->GetToolBar()->EnableTool(ID_TOOLBAR_3D_BROWSER, false);
446 this->GetToolBar()->EnableTool(ID_TOOLBAR_QUANT, true);
448 //----------------------------------------------------------------------------
449 void wxMaracasFrame::OnDeleteAxis(wxCommandEvent &WXUNUSED(event))
451 this->GetToolBar()->EnableTool(ID_TOOLBAR_PLANS, false);
452 this->GetToolBar()->EnableTool(ID_TOOLBAR_3D_BROWSER, false);
453 this->GetToolBar()->EnableTool(ID_TOOLBAR_QUANT, false);
455 //----------------------------------------------------------------------------
456 void wxMaracasFrame::OnRegenerateAll( wxCommandEvent& event ){
457 if (_wxmaracas3dbrowser!=NULL) { _wxmaracas3dbrowser->RegenerateAll(true); }
458 if (_wxmaracasquantification!=NULL) { _wxmaracasquantification->RegenerateAll(true);}
460 //----------------------------------------------------------------------------
461 void wxMaracasFrame::OnRegenerateSplineAxe( wxCommandEvent& event ){
462 if (_wxmaracas3dbrowser!=NULL) { _wxmaracas3dbrowser->RegenerateAll(false); }
463 if (_wxmaracasquantification!=NULL) { _wxmaracasquantification->RegenerateAll(false); }
465 //----------------------------------------------------------------------------
466 void wxMaracasFrame::OnCleanContours( wxCommandEvent& event ){
467 if (_wxmaracasquantification!=NULL) { _wxmaracasquantification->CleanContours(); }
469 //----------------------------------------------------------------------------
470 void wxMaracasFrame::OnRegenerateSignal( wxCommandEvent& event ){
471 if (_wxmaracasquantification!=NULL) { _wxmaracasquantification->RegenerateSignal(); }
473 //----------------------------------------------------------------------------