wxMaracasApp.cxx
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00975
00976
00977
00978 #include "wx/wxprec.h"
00979
00980 #ifndef WX_PRECOMP
00981 # include <wx/wx.h>
00982 #endif
00983
00984
00985
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
00998
00999 IMPLEMENT_APP( wxMaracasApp );
01000
01001
01002
01003
01004 bool wxMaracasApp::OnInit( )
01005 {
01006 #ifdef __WXGTK__
01007
01008 setlocale(LC_NUMERIC, "C");
01009 #endif
01010
01011
01012
01013
01014
01015
01016
01017 SetExitOnFrameDelete(false);
01018
01019
01020 return( true );
01021 }
01022
01023 int wxMaracasApp::OnExit(){
01024 if (Initialized())
01025 {
01026 initialized=false;
01027
01028 m_pFrame->Destroy();
01029 }
01030 ProcessIdle();
01031
01032
01033
01034
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
01048
01049 }
01050
01051
01052 void wxMaracasApp::Reset(){
01053
01054
01055
01056
01057
01058
01059
01060 Initialize();
01061 }
01062
01063
01064 void wxMaracasApp::Initialize(){
01065 #ifdef __WXDEBUG__
01066
01067 static wxLogWindow * myLogWindow=new wxLogWindow(NULL,"Log Window",true,false);
01068 wxLog::SetActiveTarget(myLogWindow);
01069 myLogWindow->ClearTraceMasks();
01070 #endif
01071
01072
01073
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
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
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
01118
01119 void wxMaracasApp::ShowFrame(int cmdShow)
01120 {
01121
01122
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 }