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: wxMaracasMultipleVolumeRendererView.cxx,v $
31 Date: $Date: 2012/11/15 14:15:43 $
32 Version: $Revision: 1.2 $
34 Copyright: (c) 2002, 2003
37 This software is distributed WITHOUT ANY WARRANTY; without even
38 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
39 PURPOSE. See the above copyright notice for more information.
41 =========================================================================*/
45 // EOF - wxMaracasMPR.cxx
47 #include "wxMaracasMultipleVolumeRendererView.h"
50 #include <wx/colordlg.h>
51 #include <wx/bmpbuttn.h>
53 #include <OpenImage.xpm>
56 wxMaracasMultipleVolumeRendererView* wxMaracasMultipleVolumeRendererView::instance=NULL;
58 wxMaracasMultipleVolumeRendererView::wxMaracasMultipleVolumeRendererView( wxWindow* parent,std::string path)
59 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize){
61 wxauimanager = new wxAuiManager(this);
65 volmanager = new VolumeRendererManager();
66 std::string iconsdir = path;
67 iconsdir+="/data/Icons";
68 this->_toolb = new ToolBarMultipleVolumeRenderer(this,iconsdir);
69 wxStaticText* txt = new wxStaticText(this, -1, wxString(_T(" Volume Rendering ")));
70 wxAuiPaneInfo paneinfo;
71 wxauimanager->AddPane(txt,paneinfo.ToolbarPane().Top());
72 wxauimanager->AddPane(_toolb,paneinfo.ToolbarPane().Top());
74 wxauimanager->Update();
77 wxMaracasMultipleVolumeRendererView::~wxMaracasMultipleVolumeRendererView( ){
82 std::string wxMaracasMultipleVolumeRendererView::getPath(){
86 wxMaracasMultipleVolumeRendererView* wxMaracasMultipleVolumeRendererView::getInstance(wxWindow* parent,std::string path){
89 instance = new wxMaracasMultipleVolumeRendererView(parent,path);
94 wxMaracasMultipleVolumeRendererView* wxMaracasMultipleVolumeRendererView::getInstance(){
98 void wxMaracasMultipleVolumeRendererView::changeCompositeMIPFunction(int id, int function){
100 volmanager->changeCompositeMIPFunction(id, function);
103 std::cout << "Exception : " << str << '\n';
104 wxMessageDialog* diag = new wxMessageDialog(this, wxString( str,wxConvUTF8 ), wxString( str,wxConvUTF8 ), wxICON_ERROR);
109 void wxMaracasMultipleVolumeRendererView::setRenderer(vtkRenderer* renderer){
110 volmanager->setRenderer(renderer);
113 void wxMaracasMultipleVolumeRendererView::addRemoveActor(int id, bool addremove){
115 volmanager->addRemoveActor(id, addremove);
118 std::cout << "Exception : " << str << '\n';
119 wxMessageDialog* diag = new wxMessageDialog(this, wxString( str,wxConvUTF8 ), wxString( str,wxConvUTF8 ), wxICON_ERROR);
125 void wxMaracasMultipleVolumeRendererView::onLoadImageFile(){
127 wxString mhd(_T("mhd"));
129 wxFileDialog* fildial = new wxFileDialog(this, wxString(_T("Select a MHD file")),wxString(_T("")),
130 wxString(_T("")),wxString(_T("MHD files (*.mhd)|*.mhd")) );
132 if(fildial->ShowModal()==wxID_OK){
133 wxString filename = fildial->GetFilename();
134 wxString pathfile(fildial->GetDirectory() + _T("/") + filename);
135 if(filename.EndsWith(mhd)){
136 loadVolume(pathfile,filename);
143 void wxMaracasMultipleVolumeRendererView::addVolumeViewPanel(wxMaracasMultipleVolumeRendererPanel* irmview, std::string dataname){
145 wxString s(dataname.c_str(),wxConvUTF8 );
146 wxAuiPaneInfo paneinfo;
147 wxauimanager->AddPane(irmview, paneinfo.DefaultPane().Centre().DestroyOnClose().Caption(s));
148 wxauimanager->Update();
151 void wxMaracasMultipleVolumeRendererView::addVolume(vtkImageData* img, std::string dataname){
154 int id = volmanager->addVolume(-1, img,dataname);
156 wxMaracasMultipleVolumeRendererPanel* controlpan = new wxMaracasMultipleVolumeRendererPanel(this, id,img, false);
157 addVolumeViewPanel(controlpan, dataname);
158 controlpan->updateVolume();
161 std::cout << "Exception : " << str << '\n';
162 wxMessageDialog* diag = new wxMessageDialog(this, wxString(str,wxConvUTF8 ), wxString(str,wxConvUTF8 ), wxICON_ERROR);
167 void wxMaracasMultipleVolumeRendererView::loadVolume(wxString filename, wxString dataname){
169 std::string s = std::string(filename.mb_str());
170 vtkImageData* img = volmanager->getImageData(s);
171 imgVect.push_back(img);
174 s = std::string(dataname.mb_str());
179 void wxMaracasMultipleVolumeRendererView::deleteVolume(int volid)
182 volmanager->deleteActor(volid);
186 std::cout << "Exception : " << str << '\n';
187 wxMessageDialog* diag = new wxMessageDialog(this, wxString(str,wxConvUTF8 ), wxString(str,wxConvUTF8 ), wxICON_ERROR);
192 void wxMaracasMultipleVolumeRendererView::SetValuesColorPointsFunction(int volid, std::vector<double> greylevelcolors,std::vector<double> red,std::vector<double> green,std::vector<double> blue)
194 volmanager->setVolumeColor(volid, greylevelcolors, red, green, blue);
196 void wxMaracasMultipleVolumeRendererView::SetValuesPointsFunction(int volid, std::vector<double> greylevel, std::vector<double> values)
198 volmanager->setVolumeOpacity(volid, greylevel, values);
201 vtkPiecewiseFunction* wxMaracasMultipleVolumeRendererView::GetTransferFunction(int volumeid)
203 return volmanager->GetTransferFunction(volumeid);
205 vtkColorTransferFunction* wxMaracasMultipleVolumeRendererView::GetColorFunction(int volumeid)
207 return volmanager->GetColorFunction(volumeid);
210 std::vector<vtkImageData*> wxMaracasMultipleVolumeRendererView::GetOutputImages(){
214 VolumeRendererManager* wxMaracasMultipleVolumeRendererView::getVolumeRenderManager()
223 ToolBarMultipleVolumeRenderer::ToolBarMultipleVolumeRenderer(wxWindow * parent,std::string iconsdir)
224 : wxToolBar(parent, -1, wxDefaultPosition, wxDefaultSize)
228 std::string iconfil = iconsdir;
230 //iconfil+= "/OpenImage.png";
231 //wxBitmap* bitmap0 = new wxBitmap(wxString(iconfil.c_str(),wxConvUTF8), wxBITMAP_TYPE_PNG);
232 wxBitmap bitmap0(OpenImage_xpm);
233 this->AddTool(1, wxString(_T("test")),bitmap0, NULL, wxITEM_NORMAL, wxString(_T("Open File")));
235 /*iconfil+= "/Open.png";
236 wxBitmap* bitmap2 = new wxBitmap(wxString(iconfil.c_str(),wxConvUTF8), wxBITMAP_TYPE_PNG);
237 this->AddTool(2, wxString(_T("test")),*bitmap2); */
239 /*iconfil = iconsdir;
240 iconfil+= "/Open.png";
241 wxBitmap* bitmap30 = new wxBitmap(wxString(iconfil.c_str(),wxConvUTF8), wxBITMAP_TYPE_PNG);
242 this->AddTool(30, wxString(_T("test")),*bitmap30);*/
246 _evthand = new ToolBarEventHandlerMultipleVolumeRenderer();
247 this->SetEventHandler(_evthand);
251 ToolBarMultipleVolumeRenderer::~ToolBarMultipleVolumeRenderer(void){
254 ToolBarEventHandlerMultipleVolumeRenderer::ToolBarEventHandlerMultipleVolumeRenderer()
257 ToolBarEventHandlerMultipleVolumeRenderer::~ToolBarEventHandlerMultipleVolumeRenderer(){
260 void ToolBarEventHandlerMultipleVolumeRenderer::onLoadImageFile(wxCommandEvent& event){
261 wxMaracasMultipleVolumeRendererView::getInstance()->onLoadImageFile();
266 BEGIN_EVENT_TABLE(ToolBarEventHandlerMultipleVolumeRenderer, wxEvtHandler)
267 EVT_MENU(1, ToolBarEventHandlerMultipleVolumeRenderer::onLoadImageFile)