wxMaracasApp.cxx

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003  Program:   wxMaracas
00004  Module:    $RCSfile: wxMaracasApp.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 
00018 
00975 // ----------------------------------------------------------------------------
00976 // wx headers
00977 // ----------------------------------------------------------------------------
00978 #include "wx/wxprec.h"
00979 
00980 #ifndef WX_PRECOMP
00981 #   include <wx/wx.h>
00982 #endif
00983 
00984 // ----------------------------------------------------------------------------
00985 // Local headers
00986 // ----------------------------------------------------------------------------
00987 #include "wxMaracasApp.h"
00988 #include "wxMaracasFrame.h"
00989 #include <wx/log.h>
00990 
00991 
00992 #ifdef __WXGTK__
00993 # include <locale.h>
00994 #endif
00995 
00996 // ----------------------------------------------------------------------------
00997 // This macro implements the entry point (main function) for the application
00998 // ----------------------------------------------------------------------------
00999 IMPLEMENT_APP( wxMaracasApp );
01000 
01001 // ----------------------------------------------------------------------------
01002 // The `main program' equivalent, creating the windows and returning the
01003 // main frame
01004 bool wxMaracasApp::OnInit( )
01005 {
01006 #ifdef __WXGTK__
01007         //See http://www.wxwindows.org/faqgtk.htm#locale
01008         setlocale(LC_NUMERIC, "C");
01009 #endif
01010 
01011 
01012 // PS -> #ifndef DXMM
01013 // PS ->        // GO !
01014 // PS ->        SetExitOnFrameDelete(true);
01015 // PS ->        m_pFrame->Show( true );
01016 // PS -> #else
01017         SetExitOnFrameDelete(false);
01018 // PS -> #endif
01019 
01020         return( true );
01021 }
01022 // ----------------------------------------------------------------------------
01023 int wxMaracasApp::OnExit(){
01024         if (Initialized())
01025         {
01026                 initialized=false;
01027 //              delete  _mar;
01028                 m_pFrame->Destroy();
01029         }
01030         ProcessIdle();
01031 
01032 //EEDxx2.4 DEBuG
01033 //      wxLogDebug("----------- Exiting application");
01034 //      wxLogDebug("---------------------------------------------------");
01035 
01036         return true;
01037 }
01038 
01039 // ----------------------------------------------------------------------------
01040 void wxMaracasApp::Run(){
01041 
01042         m_pFrame->Show( true );
01043         wxCommandEvent cmdEvt=wxCommandEvent();
01044         m_pFrame->OnStartExperiment(cmdEvt);
01045         m_pFrame->Maximize(true);
01046 
01047 //EEDxx2.4 DEBuG
01048 //      wxLogDebug("----------- Running application");
01049 }
01050 
01051 // ----------------------------------------------------------------------------
01052 void wxMaracasApp::Reset(){
01053         // TODO : we can make it more nicely
01054 //EEDxx2.4 DEBuG
01055 //      wxLogDebug("---------------------------------------------------");
01056 //      wxLogDebug("----------- Reseting application");
01057 //      wxLogDebug("---------------------------------------------------");
01058         //OnExit();
01059 //      OnInit();
01060         Initialize();
01061 }
01062 
01063 // ----------------------------------------------------------------------------
01064 void wxMaracasApp::Initialize(){
01065 #ifdef __WXDEBUG__
01066         //static wxLogWindow * myLogWindow=new wxLogWindow(NULL,"Log Window",false,false);
01067         static wxLogWindow * myLogWindow=new wxLogWindow(NULL,"Log Window",true,false);
01068         wxLog::SetActiveTarget(myLogWindow);
01069         myLogWindow->ClearTraceMasks();
01070 #endif
01071 //EEDxx2.4 DEBuG
01072 //      wxLogDebug("---------------------------------------------------");
01073 //      wxLogDebug("----------- Initialising application");
01074 
01075 
01076         int nSize=_MAX_PATH;
01077         LPTSTR lpFilename=(LPTSTR) (new char[nSize]);
01078         GetModuleFileName(NULL,lpFilename,nSize);
01079         
01080         wxString moduleFileName(lpFilename);
01081 
01082         wxString paramFileName=moduleFileName.BeforeLast('\\')
01083                 +wxString('\\')
01084                 +wxString(MAR_DEFAULT_FILE_PARAMETERS);
01085 
01086         wxString dictionaryFileName=moduleFileName.BeforeLast('\\')
01087                 +wxString('\\')
01088                 +wxString(MAR_DEFAULT_FILE_DICTIONARY);
01089 
01090         // Initialize MARACAS
01091 
01092 
01093         _mar = new marInterface();
01094         _mar->SetParamFileName(paramFileName.c_str());
01095         _mar->loadParameters();
01096         _marSimpleDicom = new marSimpleDicom( _mar->_parameters );
01097         _mar->SetDicom(_marSimpleDicom);
01098 
01099 
01100 
01101         // Create the main frame window
01102         m_pFrame = new wxMaracasFrame( ( wxFrame* )NULL,  -1 , _mar , _marSimpleDicom ,(const char*)dictionaryFileName.mb_str());
01103 
01104                 
01105         m_pFrame->Maximize( );
01106         this->SetTopWindow( m_pFrame );
01107         _mar->saveParameters( );
01108 
01109         initialized=true;
01110         SetExitOnFrameDelete(false);
01111 }
01112 
01113 // ----------------------------------------------------------------------------
01114 bool wxMaracasApp::Initialized(){
01115         return initialized;
01116 }
01117 // PS -> #endif
01118 
01119 void wxMaracasApp::ShowFrame(int cmdShow)
01120 {
01121 //EEDxx2.4 DEBuG
01122 //      wxLogDebug("----------- Show Frame");
01123         if (Initialized())
01124         {
01125                 if ( SHOW_WINDOW_MINIMIZED == cmdShow )
01126                 {
01127                         m_pFrame->Iconize();
01128                 }
01129                 else if ( SHOW_WINDOW_RESTORE == cmdShow )
01130                 {
01131                         m_pFrame->Maximize(false);
01132                         m_pFrame->Raise();
01133                 }
01134                 else if (SW_NORMAL == cmdShow )
01135                 {
01136                         m_pFrame->Raise();
01137                 }
01138                 else if ( SHOW_WINDOW_MAXIMIZED == cmdShow )
01139                 {
01140                         m_pFrame->Maximize(true);
01141                         m_pFrame->Raise();
01142                 }
01143                 else
01144                 {
01145                         m_pFrame->Raise();
01146                 }
01147         }
01148 }
01149 
01150 
01151 void wxMaracasApp::SetVolumeData(int dimX, int dimY, int dimZ, 
01152                                                                  float spacingX,float spacingY, float spacingZ, 
01153                                                                  float rescaleSlope, float rescaleIntercept,
01154                                                                  unsigned short *pixels)
01155 {
01156         if (Initialized())
01157         {
01158                 _marSimpleDicom->SetInvestSliceOrder( _mar->_parameters->getInvestSliceOrder() );
01159                 _marSimpleDicom->SetVolumeData(dimX, dimY, dimZ,
01160                                                                            spacingX, spacingY, spacingZ,
01161                                                                            rescaleSlope, rescaleIntercept,
01162                                                                            pixels);
01163         }
01164 }
01165 
01166 wxBitmap*       wxMaracasApp::GetSnapshot(){
01167         wxWindowDC *wxwindc = new wxWindowDC(m_pFrame);
01168         wxCoord w, h;
01169         wxwindc->GetSize(&w, &h);
01170         wxBitmap *wxbitmap      = new wxBitmap(w, h);
01171 
01172         wxMemoryDC *wxmemorydc = new wxMemoryDC();
01173         wxmemorydc->SelectObject(*wxbitmap);
01174         wxmemorydc->Blit(0,0,w,h,wxwindc,0,0);
01175 
01176         delete wxwindc;
01177         delete wxmemorydc;
01178 
01179         return wxbitmap;
01180 }

Generated on 18 Mar 2010 for creaMaracasVisu_lib by  doxygen 1.6.1