1 /*=========================================================================
4 Module: $RCSfile: wxMaracasRendererView.cxx,v $
7 =========================================================================*/
9 #include "wxMaracasRendererView.h"
11 #include <wx/colordlg.h>
12 #include <wx/bmpbuttn.h>
14 #include <OpenImage.xpm>
17 wxMaracasRendererView* wxMaracasRendererView::instance=NULL;
22 wxMaracasRendererView::wxMaracasRendererView(wxWindow* parent,std::string path)
23 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize){
25 wxauimanager = new wxAuiManager(this);
29 std::string iconsdir = path;
30 iconsdir+="/data/Icons";
31 this->_toolb = new ToolBarRenderer(this,iconsdir);
32 wxStaticText* txt = new wxStaticText(this, -1, wxString(_T(" Open File ")));
33 wxAuiPaneInfo paneinfo;
34 wxauimanager->AddPane(txt,paneinfo.ToolbarPane().Top());
35 wxauimanager->AddPane(_toolb,paneinfo.ToolbarPane().Top());
37 wxauimanager->Update();
43 wxMaracasRendererView::~wxMaracasRendererView( )
49 ** Gets class instance correponding to given parameters
51 wxMaracasRendererView* wxMaracasRendererView::getInstance(wxWindow* parent,std::string path)
55 instance = new wxMaracasRendererView(parent,path);
63 wxMaracasRendererView* wxMaracasRendererView::getInstance()
69 ** Gets path for the given panel
71 std::string wxMaracasRendererView::getPath()
77 ** Returns internal panel
79 wxMaracasRenderTabbedPanel* wxMaracasRendererView::getTabbedPanel(int id)throw(char*)
82 for(i = 0; i < (tabsVector.size()); i++)
84 if(tabsVector[i]->getPropIdV() == id)
95 void wxMaracasRendererView::setRenderer(vtkRenderer* renderer)
101 ** Called when an image file is opened
103 void wxMaracasRendererView::onLoadImageFile()
105 wxString mhd(_T("mhd"));
107 wxFileDialog* fildial = new wxFileDialog(this, wxString(_T("Select a MHD file")),wxString(_T("")),
108 wxString(_T("")),wxString(_T("MHD files (*.mhd)|*.mhd")) );
110 if(fildial->ShowModal()==wxID_OK)
112 wxString filename = fildial->GetFilename();
113 files.push_back( std::string(filename.mb_str()) );
114 wxString pathfile(fildial->GetDirectory() + _T("/") + filename);
116 if(filename.EndsWith(mhd))
118 std::string sPath = std::string(pathfile.mb_str());
119 std::string sFileName = std::string(filename.mb_str());
120 addVolumes(NULL, sPath, sFileName);
126 ** Constructs and adds internal panel
128 void wxMaracasRendererView::addPanels(wxMaracasRenderTabbedPanel* wxtabs, vtkImageData* img, std::string pathfile, std::string filename)
130 wxString s(filename.c_str(),wxConvUTF8);
132 wxtabs->createControls(img, pathfile, filename);
134 wxAuiPaneInfo paneinfo;
135 wxauimanager->AddPane(wxtabs, paneinfo.DefaultPane().Centre().DestroyOnClose().Caption(s));
136 wxauimanager->Update();
140 ** Returns internal panel
142 void wxMaracasRendererView::addVolumes(vtkImageData* img, std::string pathfile, std::string filename)
144 wxMaracasRenderTabbedPanel* wxtabs = new wxMaracasRenderTabbedPanel(this);
145 wxtabs->setRenderer(_renderer);
147 tabsVector.push_back(wxtabs);
148 addPanels(wxtabs, img, pathfile, filename);
151 ** Deletes current volume
153 void wxMaracasRendererView::deleteVolume(int volid)
156 getTabbedPanel(volid)->deleteVolume(volid);
160 ** Adds or removes a volume rendering actor
162 void wxMaracasRendererView::addRemoveActorVol(int id, bool addremove)
164 //wxtabs->addRemoveActorV(id, addremove);
168 ** Adds or removes a surface rendering actor
170 void wxMaracasRendererView::addRemoveSurf1Actor(int id, bool addremove)
172 //wxtabs->addRemoveActorSA(id, addremove);
176 ** Adds or removes a surface rendering actor
178 void wxMaracasRendererView::addRemoveSurf2Actor(int id, bool addremove)
180 //wxtabs->addRemoveActorSB(id, addremove);
184 ** Adds or removes a surface rendering actor
186 void wxMaracasRendererView::addRemoveSurf3Actor(int id, bool addremove)
188 //wxtabs->addRemoveActorSC(id, addremove);
192 ** Gets opened file names
194 std::vector<std::string> wxMaracasRendererView::getFiles()
202 ToolBarRenderer::ToolBarRenderer(wxWindow * parent,std::string iconsdir)
203 : wxToolBar(parent, -1, wxDefaultPosition, wxDefaultSize)
205 std::string iconfil = iconsdir;
207 //iconfil+= "/OpenImage.png";
208 //wxBitmap* bitmap0 = new wxBitmap(wxString(iconfil.c_str(),wxConvUTF8), wxBITMAP_TYPE_PNG);
209 wxBitmap bitmap0(OpenImage_xpm);
210 this->AddTool(1, wxString(_T("test")),bitmap0, NULL, wxITEM_NORMAL, wxString(_T("Open File")));
212 /*iconfil+= "/Open.png";
213 wxBitmap* bitmap2 = new wxBitmap(wxString(iconfil.c_str(),wxConvUTF8), wxBITMAP_TYPE_PNG);
214 this->AddTool(2, wxString(_T("test")),*bitmap2); */
216 /*iconfil = iconsdir;
217 iconfil+= "/Open.png";
218 wxBitmap* bitmap30 = new wxBitmap(wxString(iconfil.c_str(),wxConvUTF8), wxBITMAP_TYPE_PNG);
219 this->AddTool(30, wxString(_T("test")),*bitmap30);*/
223 _evthand = new ToolBarEventHandlerRenderer();
224 this->SetEventHandler(_evthand);
228 ToolBarRenderer::~ToolBarRenderer(void){
231 ToolBarEventHandlerRenderer::ToolBarEventHandlerRenderer()
234 ToolBarEventHandlerRenderer::~ToolBarEventHandlerRenderer(){
237 void ToolBarEventHandlerRenderer::onLoadImageFile(wxCommandEvent& event){
238 wxMaracasRendererView::getInstance()->onLoadImageFile();
242 BEGIN_EVENT_TABLE(ToolBarEventHandlerRenderer, wxEvtHandler)
243 EVT_MENU(1, ToolBarEventHandlerRenderer::onLoadImageFile)