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()
98 long result = GetModuleFileName(NULL, buf2, 511);
99 int ret = wcstombs ( buf, buf2, sizeof(pname) );
100 // GetModuleFileName(NULL, buf, 511);
102 slash = strrchr(buf, '\\');
107 #elif defined(__LINUX__)
109 res = readlink("/proc/self/exe", buf, 512);
113 slash = strrchr(buf, '/');
122 return wxString(buf, wxConvUTF8 );
129 // ----------------------------------------------------------------------------
130 // This macro implements the entry point (main function) for the application
131 // ----------------------------------------------------------------------------
132 IMPLEMENT_APP( wxMaracasApp02 );
135 // ----------------------------------------------------------------------------
136 // The `main program' equivalent, creating the windows and returning the
138 bool wxMaracasApp02::OnInit( )
141 //See http://www.wxwindows.org/faqgtk.htm#locale
142 setlocale(LC_NUMERIC, "C");
146 //static wxLogWindow * myLogWindow=new wxLogWindow(NULL,"Log Window",false,false);
147 static wxLogWindow * myLogWindow=new wxLogWindow(NULL,"Log Window",true,false);
148 wxLog::SetActiveTarget(myLogWindow);
149 myLogWindow->ClearTraceMasks();
151 wxLogDebug("---------------------------------------------------");
152 wxLogDebug("----------- Initialising application");
154 // int nSize=_MAX_PATH;
155 // LPTSTR lpFilename=(LPTSTR) (new char[nSize]);
156 // GetModuleFileName(NULL,lpFilename,nSize);
157 // wxString moduleFileName( lpFilename );
159 wxString moduleFileName = getExecutablePath();
161 wxString paramFileName=moduleFileName.BeforeLast( wxChar(92) ) // caracter '\'
162 +wxString( wxChar(92) )
163 +wxString( MAR_DEFAULT_FILE_PARAMETERS , wxConvUTF8 );
164 wxString dictionaryFileName=moduleFileName.BeforeLast( wxChar(92) )
165 +wxString( wxChar(92) )
166 +wxString( MAR_DEFAULT_FILE_DICTIONARY, wxConvUTF8 );
168 // Initialize MARACAS
169 _mar = new marInterface();
171 _mar->SetParamFileName( (const char*)(paramFileName.mb_str()) );
172 _mar->loadParameters();
175 // Initialize MARACASCT
176 _marCT = new marInterfaceCT();
177 _marCT->SetParamFileName(paramFileName.c_str());
178 _marCT->loadParameters();
184 // _mar->SetDicom( new marGdcmDicomILPD( _mar->_parameters ) );
186 // _marCT->SetDicom( new marGdcmDicomILPD( _marCT->getParameters() ) );
187 // _mar->SetDicom( new marGdcmDicom( _mar->_parameters ) );
191 // Create the main frame window
192 wxMaracasFrame02* frame = new wxMaracasFrame02( ( wxFrame* )NULL, -1 , _mar, _marCT, (const char*)dictionaryFileName.mb_str());
195 this->SetTopWindow( frame );
198 //If no dir was set for DICOM force user to set it !
199 wxString dirHome = _mar->_parameters->getStringParam(
200 marParameters::e_dicom_images_directory );
201 if( dirHome == "NO_DIRECTORY" || dirHome == "")
203 // _mar->_parameters->setStringParam(
204 // marParameters::e_dicom_images_directory, "c:\\temp" );
206 wxDirDialog dialog( frame, "Choose a DICOM directory...",
207 ( !dirHome.IsEmpty( ) )? dirHome: wxGetHomeDir( ) );
209 if( dialog.ShowModal( ) == wxID_OK )
211 _mar->_parameters->setStringParam(
212 marParameters::e_dicom_images_directory, dialog.GetPath( ) );
213 _marCT->getParameters()->setStringParam(
214 marParameters::e_dicom_images_directory, dialog.GetPath( ) );
222 _marCT->getParameters()->setStringParam(
223 marParameters::e_dicom_images_directory, dirHome );
229 frame->OnLoadPatientData( cmd );
230 _mar->saveParameters( );
231 _marCT->saveParameters( );
232 //EED initialized=true;
235 // PS -> #ifndef DXMM
237 // PS -> SetExitOnFrameDelete(true);
238 // PS -> m_pFrame->Show( true );
240 // SetExitOnFrameDelete(true);
247 string tmpstring = (const char*) (dictionaryFileName.mb_str());
248 wxMaracasFrame03 *frame03 = new wxMaracasFrame03( (wxFrame*) NULL, -1 , _mar, (char*)tmpstring.c_str() );
249 frame03->SetTitle(_T("Maracas - Evaluation version 1 July 2008 - Use limited to the research team - (Creatis-LRMN,Uniandes)"));
251 frame03->Show( true );
252 frame03->Maximize( );
253 this->SetTopWindow( frame03 );
258 int year=date.GetCurrentYear();
259 int month=date.GetCurrentMonth()+1;
260 if (!((year==2006) && (month==01)))
262 wxMessageDialog msg(frame03, "ERROR EED:1010", "Message box", wxOK );
270 // ----------------------------------------------------------------------------
271 int wxMaracasApp02::OnExit(){
274 if (_mar!=NULL) { delete _mar; }
277 //EED vtkDebugLeaks::PrintCurrentLeaks ( ) ;
283 // EOF - wxMaracasApp02.cxx