X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FmaracasVisuLib%2Fsrc%2Finterface%2FwxWindows%2Fwidgets%2FwxMaracasIRMView.cxx;h=f0d135c07ad67331b497bc839146ef74e9f64251;hb=52134c6f15827d0ae9ea8cf0ffaa15867ab87dcc;hp=dba00aaf5bfb70c7cf363ce522d6bdf5cf553d52;hpb=a8d9eafedaa4430f1b67ffe5b8ca6c925c84f866;p=creaMaracasVisu.git diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasIRMView.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasIRMView.cxx index dba00aa..f0d135c 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasIRMView.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasIRMView.cxx @@ -3,8 +3,8 @@ Program: wxMaracas Module: $RCSfile: wxMaracasIRMView.cxx,v $ Language: C++ - Date: $Date: 2009/05/29 13:39:56 $ - Version: $Revision: 1.9 $ + Date: $Date: 2009/06/16 13:25:58 $ + Version: $Revision: 1.11 $ Copyright: (c) 2002, 2003 License: @@ -32,20 +32,20 @@ wxMaracasIRMView* wxMaracasIRMView::instance=NULL; -wxMaracasIRMView::wxMaracasIRMView( wxWindow* parent,std::string path) -: wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize){ - - irmmanager = new wxMaracasIRMViewManager(); +wxMaracasIRMView::wxMaracasIRMView( wxWindow* parent,std::string path) +: wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize){ - wxauimanager = new wxAuiManager(this); + irmmanager = new wxMaracasIRMViewManager(); + + wxauimanager = new wxAuiManager(this); _path = path; std::string iconsdir = path; iconsdir+="/data/Icons"; - wxToolBar* toolbar = new ToolBar(this,iconsdir); - wxAuiPaneInfo paneinfo; - wxauimanager->AddPane(toolbar,paneinfo.ToolbarPane().Top()); + this->_toolb = new ToolBar(this,iconsdir); + wxAuiPaneInfo paneinfo; + wxauimanager->AddPane(_toolb,paneinfo.ToolbarPane().Top()); wxauimanager->Update(); createFileChooser(); @@ -54,6 +54,7 @@ wxMaracasIRMView::wxMaracasIRMView( wxWindow* parent,std::string path) } wxMaracasIRMView::~wxMaracasIRMView( ){ + delete _toolb; } @@ -64,7 +65,7 @@ std::string wxMaracasIRMView::getPath(){ void wxMaracasIRMView::createFileChooser(){ - + } wxMaracasIRMView* wxMaracasIRMView::getInstance(wxWindow* parent,std::string path){ @@ -90,7 +91,7 @@ void wxMaracasIRMView::changeOpacity(int _propid, int value){ irmmanager->changeOpacity(_propid,value); } -void wxMaracasIRMView::changeIsoValue(int propid, double value){ +void wxMaracasIRMView::changeIsoValue(int propid, double value){ irmmanager->changeIsoValue(propid, value); } @@ -118,10 +119,10 @@ void wxMaracasIRMView::onLoadImageFile(){ if(fildial->ShowModal()==wxID_OK){ wxString filename = fildial->GetFilename(); - wxString pathfile(fildial->GetDirectory() + _T("/") + filename); - + wxString pathfile(fildial->GetDirectory() + _T("/") + filename); + - if(filename.EndsWith(mhd)){ + if(filename.EndsWith(mhd)){ loadPropMHD(pathfile,filename); }else if(filename.EndsWith(stl)){ loadProp3D(pathfile,filename); @@ -130,24 +131,24 @@ void wxMaracasIRMView::onLoadImageFile(){ delete fildial; } -void wxMaracasIRMView::loadPropMHD(wxString filename, wxString dataname){ - +void wxMaracasIRMView::loadPropMHD(wxString filename, wxString dataname){ + std::string s = std::string(filename.mb_str()); vtkImageData* img = irmmanager->getImageData(s); if(img!=NULL){ s = std::string(dataname.mb_str()); addPropMHD(img, s); } - - + + } void wxMaracasIRMView::addPropMHD(vtkImageData* imgdata, std::string dataname){ try{ - int id = irmmanager->addPropMHD(imgdata,dataname); + int id = irmmanager->addPropMHD(imgdata,dataname); if(id!=-1){ - + wxMaracasIRMViewPanel* controlpan = new wxMaracasIRMViewProp3DMHD(this, id); int maxiso = irmmanager->getMaxIsoValue(id); ((wxMaracasIRMViewProp3DMHD*)controlpan)->createControls(maxiso); @@ -163,7 +164,7 @@ void wxMaracasIRMView::addPropMHD(vtkImageData* imgdata, std::string dataname){ } } -void wxMaracasIRMView::loadProp3D(wxString filename, wxString dataname){ +void wxMaracasIRMView::loadProp3D(wxString filename, wxString dataname){ std::string s = std::string(filename.mb_str()); vtkProp3D* prop3D = irmmanager->getProp3D(s); if(prop3D != NULL){ @@ -172,9 +173,9 @@ void wxMaracasIRMView::loadProp3D(wxString filename, wxString dataname){ }else{ //TODO msj to the user indicating error in file } - - - + + + } void wxMaracasIRMView::addProp3D(vtkProp3D* prop3D, std::string dataname){ @@ -187,25 +188,25 @@ void wxMaracasIRMView::addProp3D(vtkProp3D* prop3D, std::string dataname){ }catch(char* str){ std::cout << "Exception : " << str << '\n'; wxMessageDialog* diag = new wxMessageDialog(this, wxString(str,wxConvUTF8 ), wxString(str,wxConvUTF8 ), wxICON_ERROR); - diag->ShowModal(); + diag->ShowModal(); } - + } void wxMaracasIRMView::addIRMViewPanel(wxMaracasIRMViewPanel* irmview, std::string dataname){ wxString s(dataname.c_str(),wxConvUTF8 ); - wxAuiPaneInfo paneinfo; + wxAuiPaneInfo paneinfo; wxauimanager->AddPane(irmview, paneinfo.DefaultPane().Centre().DestroyOnClose().Caption(s)); wxauimanager->Update(); - - + + } void wxMaracasIRMView::deleteActor(int propid){ try{ irmmanager->deleteActor(propid); }catch(char* e){ - + } } @@ -219,7 +220,7 @@ void wxMaracasIRMView::deleteActor(int propid){ ToolBar::ToolBar(wxWindow * parent,std::string iconsdir) : wxToolBar(parent, -1, wxDefaultPosition, wxDefaultSize) -{ +{ std::string iconfil = iconsdir; @@ -227,33 +228,41 @@ ToolBar::ToolBar(wxWindow * parent,std::string iconsdir) //iconfil+= "/OpenImage.png"; //wxBitmap* bitmap0 = new wxBitmap(wxString(iconfil.c_str(),wxConvUTF8), wxBITMAP_TYPE_PNG); wxBitmap bitmap0(OpenImage_xpm); - this->AddTool(0, wxString(_T("test")),bitmap0); + this->AddTool(1, wxString(_T("test")),bitmap0); /*iconfil+= "/Open.png"; wxBitmap* bitmap2 = new wxBitmap(wxString(iconfil.c_str(),wxConvUTF8), wxBITMAP_TYPE_PNG); - this->AddTool(2, wxString(_T("test")),*bitmap2); */ + this->AddTool(2, wxString(_T("test")),*bitmap2); */ /*iconfil = iconsdir; iconfil+= "/Open.png"; wxBitmap* bitmap30 = new wxBitmap(wxString(iconfil.c_str(),wxConvUTF8), wxBITMAP_TYPE_PNG); this->AddTool(30, wxString(_T("test")),*bitmap30);*/ - + this->Realize(); - - + + _evthand = new ToolBarEventHandler(); + this->SetEventHandler(_evthand); + } ToolBar::~ToolBar(void){ } -void ToolBar::onLoadImageFile(wxCommandEvent& event){ + +ToolBarEventHandler::ToolBarEventHandler() +: wxEvtHandler(){ +} +ToolBarEventHandler::~ToolBarEventHandler(){ +} + +void ToolBarEventHandler::onLoadImageFile(wxCommandEvent& event){ wxMaracasIRMView::getInstance()->onLoadImageFile(); } -BEGIN_EVENT_TABLE(ToolBar, wxToolBar) - EVT_MENU(0, ToolBar::onLoadImageFile) - +BEGIN_EVENT_TABLE(ToolBarEventHandler, wxEvtHandler) + EVT_MENU(1, ToolBarEventHandler::onLoadImageFile) END_EVENT_TABLE()