wxMaracasApp02.cxx

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003  Program:   wxMaracas
00004  Module:    $RCSfile: wxMaracasApp02.cxx,v $
00005  Language:  C++
00006  Date:      $Date: 2009/05/14 13:54:54 $
00007  Version:   $Revision: 1.1 $
00008 
00009   Copyright: (c) 2002, 2003
00010   License:
00011 
00012    This software is distributed WITHOUT ANY WARRANTY; without even
00013    the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00014    PURPOSE.  See the above copyright notice for more information.
00015 
00016 =========================================================================*/
00017 
00032 // ----------------------------------------------------------------------------
00033 // wx headers
00034 // ----------------------------------------------------------------------------
00035 #include "wx/wxprec.h"
00036 #include <wx/datetime.h>
00037 #ifndef WX_PRECOMP
00038 #   include <wx/wx.h>
00039 #endif
00040 
00041 #include <wx/log.h>
00042 
00043 
00044 // ----------------------------------------------------------------------------
00045 // Local headers
00046 // ----------------------------------------------------------------------------
00047 
00048 #include <vtkDebugLeaks.h> 
00049 
00050 
00051 #include "wxMaracasFrame02.h"
00052 #include "wxMaracasApp02.h"
00053 #include "marGdcmDicom.h"
00054 
00055 
00056 #ifdef __WXGTK__
00057 # include <locale.h>
00058 #endif
00059 
00060 
00061 
00062 
00063 //EED
00064 // http://lists.wxwidgets.org/archive/wx-dev/msg30449.html
00065 wxString getExecutablePath()
00066 {
00067     char buf[512];
00068     char* slash;
00069 
00070 #if defined(WIN32)
00071     GetModuleFileName(NULL, buf, 511);
00072     slash = strrchr(buf, '\\');
00073     if (slash)
00074     {
00075         *slash = 0;
00076     }
00077 #elif defined(__LINUX__)
00078     int res;
00079     res = readlink("/proc/self/exe", buf, 512);
00080     if (res == -1)
00081         return _T("");
00082     buf[res] = 0;
00083     slash = strrchr(buf, '/');
00084     if (slash)
00085     {
00086         *slash = 0;
00087     }
00088 #else
00089     return "";
00090 #endif
00091 
00092     return wxString(buf, wxConvUTF8 );
00093 }
00094 
00095 
00096 
00097 
00098 
00099 // ----------------------------------------------------------------------------
00100 // This macro implements the entry point (main function) for the application
00101 // ----------------------------------------------------------------------------
00102 IMPLEMENT_APP( wxMaracasApp02 );
00103 
00104 
00105 // ----------------------------------------------------------------------------
00106 // The `main program' equivalent, creating the windows and returning the
00107 // main frame
00108 bool wxMaracasApp02::OnInit( )
00109 {
00110 #ifdef __WXGTK__
00111         //See http://www.wxwindows.org/faqgtk.htm#locale
00112         setlocale(LC_NUMERIC, "C");
00113 #endif
00114 /*
00115 #ifdef __WXDEBUG__
00116         //static wxLogWindow * myLogWindow=new wxLogWindow(NULL,"Log Window",false,false);
00117         static wxLogWindow * myLogWindow=new wxLogWindow(NULL,"Log Window",true,false);
00118         wxLog::SetActiveTarget(myLogWindow);
00119         myLogWindow->ClearTraceMasks();
00120 #endif
00121         wxLogDebug("---------------------------------------------------");
00122         wxLogDebug("----------- Initialising application");
00123 */
00124 //      int nSize=_MAX_PATH;
00125 //      LPTSTR lpFilename=(LPTSTR) (new char[nSize]);
00126 //      GetModuleFileName(NULL,lpFilename,nSize);
00127 //      wxString moduleFileName( lpFilename );
00128 
00129         wxString moduleFileName = getExecutablePath();
00130 
00131         wxString paramFileName=moduleFileName.BeforeLast( wxChar(92) )   // caracter '\'
00132                 +wxString( wxChar(92) )
00133                 +wxString( MAR_DEFAULT_FILE_PARAMETERS , wxConvUTF8 );
00134         wxString dictionaryFileName=moduleFileName.BeforeLast( wxChar(92) )
00135                 +wxString( wxChar(92) )
00136                 +wxString( MAR_DEFAULT_FILE_DICTIONARY, wxConvUTF8 );
00137 
00138         // Initialize MARACAS
00139         _mar = new marInterface();
00140 
00141         _mar->SetParamFileName( (const char*)(paramFileName.mb_str()) );
00142         _mar->loadParameters();
00143 
00144 /*
00145         // Initialize MARACASCT
00146         _marCT = new marInterfaceCT();
00147         _marCT->SetParamFileName(paramFileName.c_str());
00148         _marCT->loadParameters();
00149 */
00150 
00151 // EED ILPD
00152 
00153 //EED 4 oct 2006
00154 //      _mar->SetDicom( new marGdcmDicomILPD( _mar->_parameters ) );
00155 
00156         //      _marCT->SetDicom( new marGdcmDicomILPD( _marCT->getParameters() ) );
00157 //      _mar->SetDicom( new marGdcmDicom( _mar->_parameters ) );
00158 
00159 /*
00160 //--
00161         // Create the main frame window 
00162         wxMaracasFrame02* frame = new wxMaracasFrame02( ( wxFrame* )NULL,  -1 , _mar, _marCT, (const char*)dictionaryFileName.mb_str());
00163         frame->Show( true );
00164         frame->Maximize( );
00165         this->SetTopWindow( frame );
00166 
00167 
00168         //If no dir was set for DICOM force user to set it !
00169         wxString dirHome = _mar->_parameters->getStringParam(
00170                 marParameters::e_dicom_images_directory );
00171         if( dirHome == "NO_DIRECTORY" || dirHome == "")
00172         {
00173 //              _mar->_parameters->setStringParam(
00174 //                      marParameters::e_dicom_images_directory, "c:\\temp" );
00175                 
00176                 wxDirDialog dialog( frame, "Choose a DICOM directory...",
00177                         ( !dirHome.IsEmpty( ) )? dirHome: wxGetHomeDir( ) );
00178 
00179                 if( dialog.ShowModal( ) == wxID_OK )
00180                 {
00181                         _mar->_parameters->setStringParam(
00182                                 marParameters::e_dicom_images_directory, dialog.GetPath( ) );
00183                         _marCT->getParameters()->setStringParam(
00184                                 marParameters::e_dicom_images_directory, dialog.GetPath( ) );
00185 
00186                         
00187                 }
00188                 
00189         }
00190         else
00191         {
00192                 _marCT->getParameters()->setStringParam(
00193                         marParameters::e_dicom_images_directory, dirHome );
00194 
00195         }
00196 
00197 
00198         wxCommandEvent cmd;
00199         frame->OnLoadPatientData( cmd );
00200         _mar->saveParameters( );
00201         _marCT->saveParameters( );
00202 //EED   initialized=true;
00203 
00204 
00205 // PS -> #ifndef DXMM
00206 // PS ->        // GO !
00207 // PS ->        SetExitOnFrameDelete(true);
00208 // PS ->        m_pFrame->Show( true );
00209 // PS -> #else
00210 //      SetExitOnFrameDelete(true);
00211 // PS -> #endif
00212 //--
00213 */
00214 
00215 //--    
00216 
00217         string tmpstring = (const char*) (dictionaryFileName.mb_str());
00218         wxMaracasFrame03 *frame03 = new wxMaracasFrame03( (wxFrame*) NULL,  -1 , _mar, (char*)tmpstring.c_str() );
00219         frame03->SetTitle(_T("Maracas - Evaluation version 1 July 2008 - Use limited to the research team - (Creatis-LRMN,Uniandes)"));
00220 
00221         frame03->Show( true );
00222         frame03->Maximize( );
00223         this->SetTopWindow( frame03 );
00224 //--
00225 
00226 /*
00227         wxDateTime date;
00228         int year=date.GetCurrentYear();
00229         int month=date.GetCurrentMonth()+1;
00230         if (!((year==2006) && (month==01)))     
00231         {
00232                 wxMessageDialog msg(frame03, "ERROR EED:1010", "Message box", wxOK );
00233                 msg.ShowModal();
00234                 return  false;
00235         }
00236 */
00237 
00238         return( true );
00239 }
00240 // ----------------------------------------------------------------------------
00241 int wxMaracasApp02::OnExit(){
00242 
00243 
00244         if (_mar!=NULL) { delete _mar; }
00245 
00246 
00247 //EED   vtkDebugLeaks::PrintCurrentLeaks  (    ) ;
00248 
00249         return true;
00250 
00251 }
00252 
00253 // EOF - wxMaracasApp02.cxx

Generated on 18 Mar 2010 for creaMaracasVisu_lib by  doxygen 1.6.1