1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 # This software is governed by the CeCILL-B license under French law and
10 # abiding by the rules of distribution of free software. You can use,
11 # modify and/ or redistribute the software under the terms of the CeCILL-B
12 # license as circulated by CEA, CNRS and INRIA at the following URL
13 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 # or in the file LICENSE.txt.
16 # As a counterpart to the access to the source code and rights to copy,
17 # modify and redistribute granted by the license, users are provided only
18 # with a limited warranty and the software's author, the holder of the
19 # economic rights, and the successive licensors have only limited
22 # The fact that you are presently reading this means that you have had
23 # knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
26 /*=========================================================================
29 Module: $RCSfile: wxMaracasRendererView.cxx,v $
32 =========================================================================*/
34 #include "wxMaracasRendererView.h"
36 #include <wx/colordlg.h>
37 #include <wx/bmpbuttn.h>
39 #include <OpenImage.xpm>
42 wxMaracasRendererView* wxMaracasRendererView::instance=NULL;
47 wxMaracasRendererView::wxMaracasRendererView(wxWindow* parent,std::string path)
48 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize){
50 wxauimanager = new wxAuiManager(this);
55 std::string iconsdir = path;
56 iconsdir+="/data/Icons";
57 this->_toolb = new ToolBarRenderer(this,iconsdir);
58 wxStaticText* txt = new wxStaticText(this, -1, wxString(_T(" Open File ")));
59 wxAuiPaneInfo paneinfo;
60 wxauimanager->AddPane(txt,paneinfo.ToolbarPane().Top());
61 wxauimanager->AddPane(_toolb,paneinfo.ToolbarPane().Top());
63 wxauimanager->Update();
69 wxMaracasRendererView::~wxMaracasRendererView( )
75 ** Gets class instance correponding to given parameters
77 wxMaracasRendererView* wxMaracasRendererView::getInstance(wxWindow* parent,std::string path)
81 instance = new wxMaracasRendererView(parent,path);
89 wxMaracasRendererView* wxMaracasRendererView::getInstance()
95 ** Gets path for the given panel
97 std::string wxMaracasRendererView::getPath()
103 ** Returns internal panel
105 wxMaracasRenderTabbedPanel* wxMaracasRendererView::getTabbedPanel(int id) throw(char*)
108 for(i = 0; i < (int)tabsVector.size(); i++)
110 if(tabsVector[i]->getPropIdV() == id)
111 return tabsVector[i];
113 throw "id not found";
121 void wxMaracasRendererView::setRenderer(vtkRenderer* renderer)
123 _renderer = renderer;
126 void wxMaracasRendererView::setVtkBaseView(wxVtk3DBaseView* vbv)
132 ** Called when an image file is opened
134 void wxMaracasRendererView::onLoadImageFile()
136 wxString mhd(_T("mhd"));
138 wxFileDialog* fildial = new wxFileDialog(this, wxString(_T("Select a MHD file")), wxString(_T("")),
139 wxString(_T("")), wxString(_T("MHD files (*.mhd)|*.mhd")) );
141 if(fildial->ShowModal()==wxID_OK)
143 wxString filename = fildial->GetFilename();
144 files.push_back( std::string(filename.mb_str()) );
145 wxString pathfile(fildial->GetDirectory() + _T("/") + filename);
147 if(filename.EndsWith(mhd))
149 std::string sPath = std::string(pathfile.mb_str());
150 std::string sFileName = std::string(filename.mb_str());
151 printf("wxMaracasRendererView::onLoadImageFile->Opening file... \n");
152 addVolumes(NULL, sPath, sFileName);
158 ** Constructs and adds internal panel
160 void wxMaracasRendererView::addPanels(wxMaracasRenderTabbedPanel* wxtabs, vtkImageData* img, std::string pathfile, std::string filename)
162 wxString s(filename.c_str(),wxConvUTF8);
164 wxtabs->createControls(img, pathfile, filename);
166 wxAuiPaneInfo paneinfo;
167 wxauimanager->AddPane(wxtabs, paneinfo.DefaultPane().Centre().DestroyOnClose().Caption(s));
168 wxauimanager->Update();
172 ** Returns internal panel
174 void wxMaracasRendererView::addVolumes(vtkImageData* img, std::string pathfile, std::string filename)
176 wxMaracasRenderTabbedPanel* wxtabs = new wxMaracasRenderTabbedPanel(this, _idCount, baseView);
177 wxtabs->setRenderer(_renderer);
179 tabsVector.push_back(wxtabs);
180 addPanels(wxtabs, img, pathfile, filename);
185 ** Deletes current volume
187 void wxMaracasRendererView::deleteVolume(int volid)
190 getTabbedPanel(volid)->deleteVolume(volid);
194 ** Gets opened file names
196 std::vector<std::string> wxMaracasRendererView::getFiles()
204 ToolBarRenderer::ToolBarRenderer(wxWindow * parent,std::string iconsdir)
205 : wxToolBar(parent, -1, wxDefaultPosition, wxDefaultSize)
207 std::string iconfil = iconsdir;
209 //iconfil+= "/OpenImage.png";
210 //wxBitmap* bitmap0 = new wxBitmap(wxString(iconfil.c_str(),wxConvUTF8), wxBITMAP_TYPE_PNG);
211 wxBitmap bitmap0(OpenImage_xpm);
212 this->AddTool(1, wxString(_T("test")),bitmap0, NULL, wxITEM_NORMAL, wxString(_T("Open File")));
216 _evthand = new ToolBarEventHandlerRenderer();
217 this->SetEventHandler(_evthand);
221 ToolBarRenderer::~ToolBarRenderer(void){
224 ToolBarEventHandlerRenderer::ToolBarEventHandlerRenderer()
227 ToolBarEventHandlerRenderer::~ToolBarEventHandlerRenderer(){
230 void ToolBarEventHandlerRenderer::onLoadImageFile(wxCommandEvent& event){
231 wxMaracasRendererView::getInstance()->onLoadImageFile();
235 BEGIN_EVENT_TABLE(ToolBarEventHandlerRenderer, wxEvtHandler)
236 EVT_MENU(1, ToolBarEventHandlerRenderer::onLoadImageFile)