1 /*=========================================================================
4 Module: $RCSfile: wxMaracasApp02.cxx,v $
6 Date: $Date: 2008/10/31 16:32:09 $
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 =========================================================================*/
19 * \mainpage wxMaracas version wxWindows + gdcm
21 * \section intro Introduction
23 * This is the introduction.
25 * \section install Installation
27 * \subsection step1 Step 1: Opening the box
32 // ----------------------------------------------------------------------------
34 // ----------------------------------------------------------------------------
35 #include "wx/wxprec.h"
36 #include <wx/datetime.h>
44 // ----------------------------------------------------------------------------
46 // ----------------------------------------------------------------------------
48 #include <vtkDebugLeaks.h>
51 #include "wxMaracasFrame02.h"
52 #include "wxMaracasApp02.h"
53 #include "marGdcmDicom.h"
64 // http://lists.wxwidgets.org/archive/wx-dev/msg30449.html
65 wxString getExecutablePath()
71 GetModuleFileName(NULL, buf, 511);
72 slash = strrchr(buf, '\\');
77 #elif defined(__LINUX__)
79 res = readlink("/proc/self/exe", buf, 512);
83 slash = strrchr(buf, '/');
92 return wxString(buf, wxConvUTF8 );
99 // ----------------------------------------------------------------------------
100 // This macro implements the entry point (main function) for the application
101 // ----------------------------------------------------------------------------
102 IMPLEMENT_APP( wxMaracasApp02 );
105 // ----------------------------------------------------------------------------
106 // The `main program' equivalent, creating the windows and returning the
108 bool wxMaracasApp02::OnInit( )
111 //See http://www.wxwindows.org/faqgtk.htm#locale
112 setlocale(LC_NUMERIC, "C");
116 //static wxLogWindow * myLogWindow=new wxLogWindow(NULL,"Log Window",false,false);
117 static wxLogWindow * myLogWindow=new wxLogWindow(NULL,"Log Window",true,false);
118 wxLog::SetActiveTarget(myLogWindow);
119 myLogWindow->ClearTraceMasks();
121 wxLogDebug("---------------------------------------------------");
122 wxLogDebug("----------- Initialising application");
124 // int nSize=_MAX_PATH;
125 // LPTSTR lpFilename=(LPTSTR) (new char[nSize]);
126 // GetModuleFileName(NULL,lpFilename,nSize);
127 // wxString moduleFileName( lpFilename );
129 wxString moduleFileName = getExecutablePath();
131 wxString paramFileName=moduleFileName.BeforeLast( wxChar(92) ) // caracter '\'
132 +wxString( wxChar(92) )
133 +wxString( MAR_DEFAULT_FILE_PARAMETERS , wxConvUTF8 );
134 wxString dictionaryFileName=moduleFileName.BeforeLast( wxChar(92) )
135 +wxString( wxChar(92) )
136 +wxString( MAR_DEFAULT_FILE_DICTIONARY, wxConvUTF8 );
138 // Initialize MARACAS
139 _mar = new marInterface();
141 _mar->SetParamFileName( (const char*)(paramFileName.mb_str()) );
142 _mar->loadParameters();
145 // Initialize MARACASCT
146 _marCT = new marInterfaceCT();
147 _marCT->SetParamFileName(paramFileName.c_str());
148 _marCT->loadParameters();
154 // _mar->SetDicom( new marGdcmDicomILPD( _mar->_parameters ) );
156 // _marCT->SetDicom( new marGdcmDicomILPD( _marCT->getParameters() ) );
157 // _mar->SetDicom( new marGdcmDicom( _mar->_parameters ) );
161 // Create the main frame window
162 wxMaracasFrame02* frame = new wxMaracasFrame02( ( wxFrame* )NULL, -1 , _mar, _marCT, (const char*)dictionaryFileName.mb_str());
165 this->SetTopWindow( frame );
168 //If no dir was set for DICOM force user to set it !
169 wxString dirHome = _mar->_parameters->getStringParam(
170 marParameters::e_dicom_images_directory );
171 if( dirHome == "NO_DIRECTORY" || dirHome == "")
173 // _mar->_parameters->setStringParam(
174 // marParameters::e_dicom_images_directory, "c:\\temp" );
176 wxDirDialog dialog( frame, "Choose a DICOM directory...",
177 ( !dirHome.IsEmpty( ) )? dirHome: wxGetHomeDir( ) );
179 if( dialog.ShowModal( ) == wxID_OK )
181 _mar->_parameters->setStringParam(
182 marParameters::e_dicom_images_directory, dialog.GetPath( ) );
183 _marCT->getParameters()->setStringParam(
184 marParameters::e_dicom_images_directory, dialog.GetPath( ) );
192 _marCT->getParameters()->setStringParam(
193 marParameters::e_dicom_images_directory, dirHome );
199 frame->OnLoadPatientData( cmd );
200 _mar->saveParameters( );
201 _marCT->saveParameters( );
202 //EED initialized=true;
205 // PS -> #ifndef DXMM
207 // PS -> SetExitOnFrameDelete(true);
208 // PS -> m_pFrame->Show( true );
210 // SetExitOnFrameDelete(true);
217 string tmpstring = (const char*) (dictionaryFileName.mb_str());
218 wxMaracasFrame03 *frame03 = new wxMaracasFrame03( (wxFrame*) NULL, -1 , _mar, (char*)tmpstring.c_str() );
219 frame03->SetTitle(_T("Maracas - Evaluation version 1 July 2008 - Use limited to the research team - (Creatis-LRMN,Uniandes)"));
221 frame03->Show( true );
222 frame03->Maximize( );
223 this->SetTopWindow( frame03 );
228 int year=date.GetCurrentYear();
229 int month=date.GetCurrentMonth()+1;
230 if (!((year==2006) && (month==01)))
232 wxMessageDialog msg(frame03, "ERROR EED:1010", "Message box", wxOK );
240 // ----------------------------------------------------------------------------
241 int wxMaracasApp02::OnExit(){
244 if (_mar!=NULL) { delete _mar; }
247 //EED vtkDebugLeaks::PrintCurrentLeaks ( ) ;
253 // EOF - wxMaracasApp02.cxx