1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 # This software is governed by the CeCILL-B license under French law and
10 # abiding by the rules of distribution of free software. You can use,
11 # modify and/ or redistribute the software under the terms of the CeCILL-B
12 # license as circulated by CEA, CNRS and INRIA at the following URL
13 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 # or in the file LICENSE.txt.
16 # As a counterpart to the access to the source code and rights to copy,
17 # modify and redistribute granted by the license, users are provided only
18 # with a limited warranty and the software's author, the holder of the
19 # economic rights, and the successive licensors have only limited
22 # The fact that you are presently reading this means that you have had
23 # knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
26 /*=========================================================================
29 Module: $RCSfile: wxMaracasFrame.cxx,v $
31 Date: $Date: 2012/11/15 14:14:56 $
32 Version: $Revision: 1.2 $
34 Copyright: (c) 2002, 2003
37 This software is distributed WITHOUT ANY WARRANTY; without even
38 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
39 PURPOSE. See the above copyright notice for more information.
41 =========================================================================*/
43 // PS -> #include "wxMaracasDataBrowser.h"
44 #include "wxMaracasParametersDialog.h"
45 #include "wxMaracasImageBrowser.h"
46 #include "wxMaracasHelpDialog.h"
47 #include "wxMaracasFrame.h"
48 #include "marDictionary.h"
51 #include <wx/toolbar.h>
52 #include <wx/dialog.h>
53 #include <wx/colordlg.h>
54 // ----------------------------------------------------------------------------
55 // Maracas "logic world" headers
56 // ----------------------------------------------------------------------------
60 # include "res/bitmaps/connect.xpm"
61 # include "res/bitmaps/params.xpm"
62 # include "res/bitmaps/imagebrowser.xpm"
63 # include "res/bitmaps/3D.xpm"
64 # include "res/bitmaps/plans.xpm"
65 # include "res/bitmaps/quant.xpm"
66 # include "res/bitmaps/rotate.xpm"
67 # include "res/bitmaps/bright.xpm"
68 # include "res/bitmaps/pan.xpm"
69 # include "res/bitmaps/zoom.xpm"
70 # include "res/bitmaps/clear.xpm"
71 # include "res/bitmaps/intensity.xpm"
72 # include "res/bitmaps/help.xpm"
73 # include "res/bitmaps/creatis_logo.xpm"
74 # include "res/icons/maracas.xpm"
77 BEGIN_EVENT_TABLE( wxMaracasFrame, wxFrame )
78 // PS -> EVT_MENU( ID_TOOLBAR_DATA_BROWSER, wxMaracasFrame::OnLoadPatientData )
79 EVT_MENU( ID_TOOLBAR_PARAMETERS, wxMaracasFrame::OnParameters )
80 // PS -> EVT_MENU( ID_TOOLBAR_IMAGE_BROWSER, wxMaracasFrame::OnLoadImageData )
81 EVT_MENU( ID_TOOLBAR_3D_BROWSER, wxMaracasFrame::OnStartExperiment )
82 // PS -> EVT_MENU( ID_TOOLBAR_HELP, wxMaracasFrame::OnHelp )
83 EVT_MENU( ID_TOOLBAR_PLANS, wxMaracasFrame::OnQuant )
85 // EED : This is not top !!!!!!!!!!!
86 EVT_TOOL( 19999, wxMaracasFrame::OnRegenerateAll )
87 EVT_TOOL( 19998, wxMaracasFrame::OnRegenerateSplineAxe )
88 EVT_TOOL( 19997, wxMaracasFrame::OnCleanContours )
89 EVT_TOOL( 19996, wxMaracasFrame::OnRegenerateSignal )
92 EVT_CLOSE( wxMaracasFrame::OnQuit )
94 EVT_TOOL(wxSurfaceWidget::ID_BUTTON_NEW_AXIS, wxMaracasFrame::OnNewAxis )
95 EVT_TOOL(wxSurfaceWidget::ID_BUTTON_DELETE_AXIS, wxMaracasFrame::OnDeleteAxis )
98 //----------------------------------------------------------------------------
99 wxMaracasFrame::wxMaracasFrame( wxFrame *parent, wxWindowID id,
100 marInterface *mar,marSimpleDicom *simpleDicom, char *dictionaryFileName,
101 const wxString& title, const wxPoint& pos,
102 const wxSize& size, long style)
103 : wxFrame( parent, id, title, pos, size, style)
106 _marSimpleDicom = simpleDicom;
107 _wxmaracasquantification = NULL;
108 _wxmaracas3dbrowser = NULL;
110 marDictionary marDict;
111 // marDict.LoadDictionary_French();
112 marDict.LoadDictionary_English();
113 // marDict.LoadDictionary_Japanese();
117 if (!marDict.LoadDictionaryFile(dictionaryFileName)){
118 wxMessageBox( "Error: File(s) marDict.txt not found...",
119 "DxMM : MARACAS", wxOK | wxCENTRE | wxICON_ERROR , this);
124 vtkObject *a = vtkObject::New();
125 a->GlobalWarningDisplayOff();
128 // At the begining, there were nothing, just a window...
129 _actual_panel = NULL;
131 // And the programmer said: let there be a status bar
132 this->CreateStatusBar( );
134 this->GetStatusBar()->SetFieldsCount( 2 );
136 this->GetStatusBar()->GetFieldRect(1, rect);
139 //_progressGauge = new wxGauge( this->GetStatusBar(), -1, 100);
140 // _progressGauge = new wxGauge( this->GetStatusBar(), -1, 50,
141 // rect.GetPosition(), rect.GetSize());
142 this->GetStatusBar()->Show();
143 this->PositionStatusBar();
145 // And an icon (to be unique)
146 //TODO change the icon to the real one!
147 this->SetIcon( wxICON( maracas_icon ) );
149 // And a toolbar (for dummy users)
150 this->RecreateToolbar( );
153 //----------------------------------------------------------------------------
154 void wxMaracasFrame::RecreateToolbar( )
156 wxToolBar* toolBar = this->GetToolBar( );
158 this->SetToolBar( NULL );
160 toolBar = this->CreateToolBar( TOOLBAR_STYLE, ID_TOOLBAR );
163 wxBitmap toolBarBitmaps[ 22+1 ];
166 * wxBitmap vs. wxBITMAP -> add _xpm at the end of the file
168 toolBarBitmaps[ 0 ] = wxBITMAP( toolbar_connect );
169 toolBarBitmaps[ 4 ] = wxBITMAP( toolbar_params );
170 toolBarBitmaps[ 7 ] = wxBITMAP( toolbar_imagebrowser );
171 toolBarBitmaps[ 9 ] = wxBITMAP( toolbar_triD );
173 toolBarBitmaps[ 10 ] = wxBITMAP( toolbar_plans );
174 toolBarBitmaps[ 11 ] = wxBITMAP( toolbar_quant );
175 toolBarBitmaps[ 12 ] = wxBITMAP( toolbar_rotate );
176 toolBarBitmaps[ 13 ] = wxBITMAP( toolbar_bright );
177 toolBarBitmaps[ 14 ] = wxBITMAP( toolbar_pan );
178 toolBarBitmaps[ 15 ] = wxBITMAP( toolbar_zoom );
179 toolBarBitmaps[ 16 ] = wxBITMAP( toolbar_clear );
180 toolBarBitmaps[ 17 ] = wxBITMAP( toolbar_intensity );
181 toolBarBitmaps[ 20 ] = wxBITMAP( toolbar_help );
182 toolBarBitmaps[ 22 ] = wxBITMAP( creatis_logo );
185 toolBarBitmaps[ 1 ] = wxBitmap( toolbar_loadexp );
186 toolBarBitmaps[ 2 ] = wxBitmap( toolbar_save );
187 toolBarBitmaps[ 3 ] = wxBitmap( toolbar_excel );
188 toolBarBitmaps[ 5 ] = wxBitmap( toolbar_wizard );
189 toolBarBitmaps[ 6 ] = wxBitmap( toolbar_back );
190 toolBarBitmaps[ 8 ] = wxBitmap( toolbar_subtract );
192 toolBarBitmaps[ 18 ] = wxBitmap( toolbar_linear );
193 toolBarBitmaps[ 19 ] = wxBitmap( toolbar_area );
195 // Set size & margins
196 toolBar->SetMargins( 4, 4 );
198 toolBar->SetToolBitmapSize( wxSize( toolBarBitmaps[ 4 ].GetWidth( ), toolBarBitmaps[ 4 ].GetHeight( ) ) );
200 // PS -> toolBar->SetToolBitmapSize( wxSize( toolBarBitmaps[ 0 ].GetWidth( ), toolBarBitmaps[ 0 ].GetHeight( ) ) );
204 // PS -> #ifndef DXMM
205 // PS -> toolBar->AddTool( ID_TOOLBAR_DATA_BROWSER, toolBarBitmaps[ 0 ], "Patient data", "Load patient data: studies & series" );
206 // PS -> toolBar->AddSeparator( );
207 // PS -> toolBar->AddTool( ID_TOOLBAR_IMAGE_BROWSER, toolBarBitmaps[ 7 ], "Load image data", "Load DICOM images from disk" );
208 // PS -> toolBar->AddSeparator( );
210 toolBar->AddTool( ID_TOOLBAR_3D_BROWSER, toolBarBitmaps[ 9 ], _T("Start 3D"), _T("Load 3D representation") );
211 toolBar->AddSeparator( );
212 toolBar->AddTool( ID_TOOLBAR_PLANS, toolBarBitmaps[ 10 ], _T("Plan"), _T("Planes") );
213 toolBar->AddSeparator( );
214 // toolBar->AddTool( ID_TOOLBAR_QUANT, toolBarBitmaps[ 11 ], "Quant", "Quant" );
215 // toolBar->AddSeparator( );
216 //The following has been commented out temporarlily
218 toolBar->AddTool( ID_TOOLBAR_ROTATE, toolBarBitmaps[ 12 ], "Rotate", "Rotate" );
219 toolBar->AddSeparator( );
220 toolBar->AddTool( ID_TOOLBAR_BRIGHT, toolBarBitmaps[ 13 ], "Bright", "Bright" );
221 toolBar->AddSeparator( );
222 toolBar->AddTool( ID_TOOLBAR_PAN, toolBarBitmaps[ 14 ], "Pan", "Pan" );
223 toolBar->AddSeparator( );
224 toolBar->AddTool( ID_TOOLBAR_ZOOM, toolBarBitmaps[ 15 ], "Zoom", "Zoom" );
225 toolBar->AddSeparator( );
226 toolBar->AddTool( ID_TOOLBAR_CLEAR, toolBarBitmaps[ 16 ], "Clear", "Clear" );
227 toolBar->AddSeparator( );
228 toolBar->AddTool( ID_TOOLBAR_INTENSITY, toolBarBitmaps[ 17 ], "Intensity", "Intensity" );
229 toolBar->AddSeparator( );*/
230 toolBar->AddTool( ID_TOOLBAR_PARAMETERS, toolBarBitmaps[ 4 ], _T("Parameters"), _T("Load parameters for modifying") );
231 //toolBar->AddTool( ID_TOOLBAR_HELP, toolBarBitmaps[ 20 ], "Help", "Help" );
232 toolBar->AddSeparator( );
234 wxBitmapButton *btnCreatisLogo = new wxBitmapButton(toolBar,-1,toolBarBitmaps[ 22 ] );
235 btnCreatisLogo->SetSize(81+10,20+10);
236 btnCreatisLogo->SetBackgroundColour(wxColour(0,0,153));
237 Connect(btnCreatisLogo->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxMaracasFrame::OnAboutCreatis );
239 toolBar->AddControl(btnCreatisLogo);
244 toolBar->SetRows( 1 );
245 toolBar->EnableTool(ID_TOOLBAR_3D_BROWSER, true);
246 toolBar->EnableTool(ID_TOOLBAR_PLANS, false);
247 toolBar->EnableTool(ID_TOOLBAR_QUANT, false);
250 //----------------------------------------------------------------------------
251 void wxMaracasFrame::OnAboutCreatis( wxCommandEvent& event ){
252 wxMaracasHelpDialog *dlg = new wxMaracasHelpDialog(this, -1, "Creatis", wxPoint(200,200), wxDefaultSize, wxDEFAULT_DIALOG_STYLE);
257 //----------------------------------------------------------------------------
258 void wxMaracasFrame::OnQuit( wxCloseEvent& event ){
261 if (_mar!=NULL) { delete _mar; }
263 marDictionary marDict;
264 marDict.FreeDictionary();
267 // this->Show(FALSE);
271 //----------------------------------------------------------------------------
272 // PS -> void wxMaracasFrame::OnLoadPatientData( wxCommandEvent& event )
274 // PS -> wxBusyCursor wait;
275 // PS -> wxToolBar* toolBar = this->GetToolBar( );
276 // PS -> //Disabling tool
277 // PS -> //wxToolBar::EnableTool This function should only be called after Realize.
278 // PS -> toolBar->EnableTool(ID_TOOLBAR_IMAGE_BROWSER, false);
279 // PS -> toolBar->EnableTool(ID_TOOLBAR_3D_BROWSER, true);
280 // PS -> toolBar->EnableTool(ID_TOOLBAR_PLANS, true);
281 // PS -> toolBar->EnableTool(ID_TOOLBAR_QUANT, false);
283 // PS -> // Create panel
284 // PS -> if( _actual_panel != NULL ) delete _actual_panel;
285 // PS -> wxMaracasDataBrowser* pnl = new wxMaracasDataBrowser( this, _mar, -1 );
287 // PS -> _actual_panel = pnl;
289 // PS -> // cf.: http://www.wxwindows.org/manuals/2.4.0/wx490.htm
290 // PS -> // Force a resize. This should probably be replaced by a call to a wxFrame
291 // PS -> // function that lays out default decorations and the remaining content window.
292 // PS -> wxSizeEvent myevent(wxSize(-1, -1), this->GetId());
293 // PS -> this->OnSize(myevent);
294 // PS -> this->Show(true);
296 // PS -> // Load panel data
297 // PS -> pnl->LoadData( );
298 // PS -> //this->GetToolBar()->EnableTool(ID_TOOLBAR_3D_BROWSER, false);
300 //----------------------------------------------------------------------------
301 void wxMaracasFrame::OnParameters( wxCommandEvent& event )
305 wxWindowDC *wxwindc =new wxWindowDC(this);
307 wxwindc->GetSize(&w, &h);
308 wxBitmap *wxbitmap =new wxBitmap(w, h);
309 wxMemoryDC *wxmemorydc = new wxMemoryDC();
311 wxmemorydc->SelectObject(*wxbitmap);
312 wxmemorydc->Blit(0,0,w,h,wxwindc,0,0);
314 wxbitmap->SaveFile("c:/tmp/MaracasPlamavic.bmp", wxBITMAP_TYPE_BMP );
320 wxMaracasParametersDialog *d = new wxMaracasParametersDialog( this, _mar );
324 if (d->IfInitContour()==true){
327 if (d->GetInitContour()==true){
329 wxmaracasquantification;
330 if (wxmaracas3dbrowser!=NULL){
334 //----------------------------------------------------------------------------
335 // PS -> void wxMaracasFrame::OnLoadImageData( wxCommandEvent& event )
337 // PS -> wxBusyCursor wait;
339 // PS -> // Create panel
340 // PS -> if( _actual_panel != NULL ) delete _actual_panel;
341 // PS -> wxMaracasImageBrowser* pnl = new wxMaracasImageBrowser( this, _mar, -1 );
344 // PS -> _actual_panel = pnl;
346 // PS -> // Load panel data
347 // PS -> wxSizeEvent myevent(wxSize(-1, -1), this->GetId());
348 // PS -> this->OnSize(myevent);
349 // PS -> //this->Show(true);
351 // PS -> //wxDialog dialog(this, -1, "coucou");
352 // PS -> //dialog.ShowModal();
353 // PS -> //dialog.Show(true);
354 // PS -> //wxGauge gauge( this, -1, 50);
357 // PS -> AS a first step I'll pass a wxGauge as parameter this doesn't
358 // PS -> sound very good, should use EVT_TIMER instead...
360 // PS -> _mar->_dicom->loadActualSerie( this->_progressGauge );
361 // PS -> vtkImageData *dummy = _mar->_dicom->getVolume( )->castVtk();
362 // PS -> //float range[2];
363 // PS -> //dummy->GetScalarRange( range );
365 // PS -> pnl->LoadData( dummy );
366 // PS -> //_view_image->ConstructVTK( (vtkImageData *)_mar->_dicom->getVolume( ));
367 // PS -> //^ this is not working ??? I don't understand why, some VTK pipeline mystery
369 // PS -> this->GetToolBar()->EnableTool(ID_TOOLBAR_IMAGE_BROWSER, false);
370 // PS -> this->GetToolBar()->EnableTool(ID_TOOLBAR_3D_BROWSER, true);
371 // PS -> //Add patient name to the frame title
372 // PS -> this->SetTitle( "Patient Name : " + _mar->_dicom->GetPatientName() );
374 //----------------------------------------------------------------------------
375 void wxMaracasFrame::OnStartExperiment( wxCommandEvent& event )
381 // PS -> #ifndef DXMM
382 // PS -> ((wxMaracasImageBrowser*)_actual_panel )->GetROI( voi );
385 _marSimpleDicom->loadActualSerie( this->_progressGauge );
386 _mar->_dicom->SetVolume( _marSimpleDicom->getVolume() );
390 voi[1] = (_mar->_dicom->getVolume( )->getXdim( ))-1;
392 voi[3] = (_mar->_dicom->getVolume( )->getYdim( ))-1;
394 voi[5] = (_mar->_dicom->getVolume( )->getZdim( ))-1;
397 _mar->_experiment->setVOI( voi );
398 _mar->initExperiment( );
402 _wxmaracas3dbrowser = new wxMaracas3DBrowser( this, _mar, -1 ,ID_TOOLBAR_PLANS);
405 _actual_panel = _wxmaracas3dbrowser;
407 wxSizeEvent myevent(wxSize(-1, -1), this->GetId());
408 this->OnSize(myevent);
412 _wxmaracas3dbrowser->LoadData( );
414 // PS -> #ifndef DXMM
415 // PS -> this->GetToolBar()->EnableTool(ID_TOOLBAR_IMAGE_BROWSER, true);
416 // PS -> this->GetToolBar()->EnableTool(ID_TOOLBAR_3D_BROWSER, false);
418 this->GetToolBar()->EnableTool(ID_TOOLBAR_PLANS, false);
419 this->GetToolBar()->EnableTool(ID_TOOLBAR_3D_BROWSER, false);
420 this->GetToolBar()->EnableTool(ID_TOOLBAR_QUANT, false);
423 //----------------------------------------------------------------------------
424 // PS -> void wxMaracasFrame::OnHelp (wxCommandEvent& event )
426 // PS -> wxMaracasHelpDialog* help = new wxMaracasHelpDialog(this, -1);
428 // PS -> help->ShowModal();
431 //----------------------------------------------------------------------------
432 void wxMaracasFrame::DeletePanels ( ){
433 if (_wxmaracasquantification!=NULL){
434 delete _wxmaracasquantification;
435 _wxmaracasquantification=NULL;
437 if (_wxmaracas3dbrowser!=NULL){
438 delete _wxmaracas3dbrowser;
439 _wxmaracas3dbrowser=NULL;
442 //----------------------------------------------------------------------------
443 void wxMaracasFrame::OnQuant (wxCommandEvent& event ){
447 if (_wxmaracas3dbrowser!=NULL){
448 isovalue = _wxmaracas3dbrowser->GetIsovalue();
449 opacity = _wxmaracas3dbrowser->GetOpacity();
453 _wxmaracasquantification = new wxMaracasQuantification( this, _mar, -1 );
454 _actual_panel = _wxmaracasquantification;
456 wxSizeEvent myevent(wxSize(-1, -1), this->GetId());
457 this->OnSize(myevent);
461 _wxmaracasquantification->LoadData( );
462 _wxmaracasquantification->SetSlider_Isovalue_Opacity(isovalue,opacity);
463 this->GetToolBar()->EnableTool(ID_TOOLBAR_PLANS, false);
464 this->GetToolBar()->EnableTool(ID_TOOLBAR_3D_BROWSER, true);
466 //----------------------------------------------------------------------------
467 void wxMaracasFrame::OnNewAxis(wxCommandEvent &WXUNUSED(event))
469 this->GetToolBar()->EnableTool(ID_TOOLBAR_PLANS, true);
470 this->GetToolBar()->EnableTool(ID_TOOLBAR_3D_BROWSER, false);
471 this->GetToolBar()->EnableTool(ID_TOOLBAR_QUANT, true);
473 //----------------------------------------------------------------------------
474 void wxMaracasFrame::OnDeleteAxis(wxCommandEvent &WXUNUSED(event))
476 this->GetToolBar()->EnableTool(ID_TOOLBAR_PLANS, false);
477 this->GetToolBar()->EnableTool(ID_TOOLBAR_3D_BROWSER, false);
478 this->GetToolBar()->EnableTool(ID_TOOLBAR_QUANT, false);
480 //----------------------------------------------------------------------------
481 void wxMaracasFrame::OnRegenerateAll( wxCommandEvent& event ){
482 if (_wxmaracas3dbrowser!=NULL) { _wxmaracas3dbrowser->RegenerateAll(true); }
483 if (_wxmaracasquantification!=NULL) { _wxmaracasquantification->RegenerateAll(true);}
485 //----------------------------------------------------------------------------
486 void wxMaracasFrame::OnRegenerateSplineAxe( wxCommandEvent& event ){
487 if (_wxmaracas3dbrowser!=NULL) { _wxmaracas3dbrowser->RegenerateAll(false); }
488 if (_wxmaracasquantification!=NULL) { _wxmaracasquantification->RegenerateAll(false); }
490 //----------------------------------------------------------------------------
491 void wxMaracasFrame::OnCleanContours( wxCommandEvent& event ){
492 if (_wxmaracasquantification!=NULL) { _wxmaracasquantification->CleanContours(); }
494 //----------------------------------------------------------------------------
495 void wxMaracasFrame::OnRegenerateSignal( wxCommandEvent& event ){
496 if (_wxmaracasquantification!=NULL) { _wxmaracasquantification->RegenerateSignal(); }
498 //----------------------------------------------------------------------------