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: wxMaracasApp02.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 =========================================================================*/
44 * \mainpage wxMaracas version wxWindows
46 * \section intro Introduction
48 * This is the introduction.
50 * \section install Installation
52 * \subsection step1 Step 1: Opening the box
57 // ----------------------------------------------------------------------------
59 // ----------------------------------------------------------------------------
60 #include "wx/wxprec.h"
61 #include <wx/datetime.h>
69 // ----------------------------------------------------------------------------
71 // ----------------------------------------------------------------------------
73 #include <vtkDebugLeaks.h>
76 #include "wxMaracasFrame02.h"
77 #include "wxMaracasApp02.h"
78 #include "marGdcmDicom.h"
89 // http://lists.wxwidgets.org/archive/wx-dev/msg30449.html
90 wxString getExecutablePath()
96 GetModuleFileName(NULL, buf, 511);
97 slash = strrchr(buf, '\\');
102 #elif defined(__LINUX__)
104 res = readlink("/proc/self/exe", buf, 512);
108 slash = strrchr(buf, '/');
117 return wxString(buf, wxConvUTF8 );
124 // ----------------------------------------------------------------------------
125 // This macro implements the entry point (main function) for the application
126 // ----------------------------------------------------------------------------
127 IMPLEMENT_APP( wxMaracasApp02 );
130 // ----------------------------------------------------------------------------
131 // The `main program' equivalent, creating the windows and returning the
133 bool wxMaracasApp02::OnInit( )
136 //See http://www.wxwindows.org/faqgtk.htm#locale
137 setlocale(LC_NUMERIC, "C");
141 //static wxLogWindow * myLogWindow=new wxLogWindow(NULL,"Log Window",false,false);
142 static wxLogWindow * myLogWindow=new wxLogWindow(NULL,"Log Window",true,false);
143 wxLog::SetActiveTarget(myLogWindow);
144 myLogWindow->ClearTraceMasks();
146 wxLogDebug("---------------------------------------------------");
147 wxLogDebug("----------- Initialising application");
149 // int nSize=_MAX_PATH;
150 // LPTSTR lpFilename=(LPTSTR) (new char[nSize]);
151 // GetModuleFileName(NULL,lpFilename,nSize);
152 // wxString moduleFileName( lpFilename );
154 wxString moduleFileName = getExecutablePath();
156 wxString paramFileName=moduleFileName.BeforeLast( wxChar(92) ) // caracter '\'
157 +wxString( wxChar(92) )
158 +wxString( MAR_DEFAULT_FILE_PARAMETERS , wxConvUTF8 );
159 wxString dictionaryFileName=moduleFileName.BeforeLast( wxChar(92) )
160 +wxString( wxChar(92) )
161 +wxString( MAR_DEFAULT_FILE_DICTIONARY, wxConvUTF8 );
163 // Initialize MARACAS
164 _mar = new marInterface();
166 _mar->SetParamFileName( (const char*)(paramFileName.mb_str()) );
167 _mar->loadParameters();
170 // Initialize MARACASCT
171 _marCT = new marInterfaceCT();
172 _marCT->SetParamFileName(paramFileName.c_str());
173 _marCT->loadParameters();
179 // _mar->SetDicom( new marGdcmDicomILPD( _mar->_parameters ) );
181 // _marCT->SetDicom( new marGdcmDicomILPD( _marCT->getParameters() ) );
182 // _mar->SetDicom( new marGdcmDicom( _mar->_parameters ) );
186 // Create the main frame window
187 wxMaracasFrame02* frame = new wxMaracasFrame02( ( wxFrame* )NULL, -1 , _mar, _marCT, (const char*)dictionaryFileName.mb_str());
190 this->SetTopWindow( frame );
193 //If no dir was set for DICOM force user to set it !
194 wxString dirHome = _mar->_parameters->getStringParam(
195 marParameters::e_dicom_images_directory );
196 if( dirHome == "NO_DIRECTORY" || dirHome == "")
198 // _mar->_parameters->setStringParam(
199 // marParameters::e_dicom_images_directory, "c:\\temp" );
201 wxDirDialog dialog( frame, "Choose a DICOM directory...",
202 ( !dirHome.IsEmpty( ) )? dirHome: wxGetHomeDir( ) );
204 if( dialog.ShowModal( ) == wxID_OK )
206 _mar->_parameters->setStringParam(
207 marParameters::e_dicom_images_directory, dialog.GetPath( ) );
208 _marCT->getParameters()->setStringParam(
209 marParameters::e_dicom_images_directory, dialog.GetPath( ) );
217 _marCT->getParameters()->setStringParam(
218 marParameters::e_dicom_images_directory, dirHome );
224 frame->OnLoadPatientData( cmd );
225 _mar->saveParameters( );
226 _marCT->saveParameters( );
227 //EED initialized=true;
230 // PS -> #ifndef DXMM
232 // PS -> SetExitOnFrameDelete(true);
233 // PS -> m_pFrame->Show( true );
235 // SetExitOnFrameDelete(true);
242 string tmpstring = (const char*) (dictionaryFileName.mb_str());
243 wxMaracasFrame03 *frame03 = new wxMaracasFrame03( (wxFrame*) NULL, -1 , _mar, (char*)tmpstring.c_str() );
244 frame03->SetTitle(_T("Maracas - Evaluation version 1 July 2008 - Use limited to the research team - (Creatis-LRMN,Uniandes)"));
246 frame03->Show( true );
247 frame03->Maximize( );
248 this->SetTopWindow( frame03 );
253 int year=date.GetCurrentYear();
254 int month=date.GetCurrentMonth()+1;
255 if (!((year==2006) && (month==01)))
257 wxMessageDialog msg(frame03, "ERROR EED:1010", "Message box", wxOK );
265 // ----------------------------------------------------------------------------
266 int wxMaracasApp02::OnExit(){
269 if (_mar!=NULL) { delete _mar; }
272 //EED vtkDebugLeaks::PrintCurrentLeaks ( ) ;
278 // EOF - wxMaracasApp02.cxx