+++ /dev/null
-/*=========================================================================
-
- Program: wxMaracas
- Module: $RCSfile: wxMaracasIRMView.cxx,v $
- Language: C++
- Date: $Date: 2009/06/16 13:25:58 $
- Version: $Revision: 1.11 $
-
- Copyright: (c) 2002, 2003
- License:
-
- This software is distributed WITHOUT ANY WARRANTY; without even
- the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- PURPOSE. See the above copyright notice for more information.
-
-=========================================================================*/
-
-
-
-// EOF - wxMaracasMPR.cxx
-
-#include "wxMaracasIRMView.h"
-//#include "wxMaracasIRMViewPanel.h"
-#include "wxMaracasIRMViewProp3DMHD.h"
-#include "wxMaracasIRMViewProp3D.h"
-
-#include <wx/colordlg.h>
-#include <wx/bmpbuttn.h>
-
-#include <OpenImage.xpm>
-#include <Color.xpm>
-
-wxMaracasIRMView* wxMaracasIRMView::instance=NULL;
-
-wxMaracasIRMView::wxMaracasIRMView( wxWindow* parent,std::string path)
-: wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize){
-
- irmmanager = new wxMaracasIRMViewManager();
-
- wxauimanager = new wxAuiManager(this);
-
- _path = path;
-
- std::string iconsdir = path;
- iconsdir+="/data/Icons";
- this->_toolb = new ToolBar(this,iconsdir);
- wxAuiPaneInfo paneinfo;
- wxauimanager->AddPane(_toolb,paneinfo.ToolbarPane().Top());
-
- wxauimanager->Update();
- createFileChooser();
-
-
-}
-wxMaracasIRMView::~wxMaracasIRMView( ){
-
- delete _toolb;
-
-}
-
-std::string wxMaracasIRMView::getPath(){
- return _path;
-}
-
-
-
-void wxMaracasIRMView::createFileChooser(){
-
-}
-
-wxMaracasIRMView* wxMaracasIRMView::getInstance(wxWindow* parent,std::string path){
- if(instance==NULL){
- instance = new wxMaracasIRMView(parent,path);
- }
- return instance;
-}
-
-wxMaracasIRMView* wxMaracasIRMView::getInstance(){
- return instance;
-}
-
-void wxMaracasIRMView::setRenderer(vtkRenderer* renderer){
- irmmanager->setRenderer(renderer);
-}
-
-void wxMaracasIRMView::addRemoveActor(int propid, bool addremove){
- irmmanager->addRemoveActor(propid, addremove);
-}
-
-void wxMaracasIRMView::changeOpacity(int _propid, int value){
- irmmanager->changeOpacity(_propid,value);
-}
-
-void wxMaracasIRMView::changeIsoValue(int propid, double value){
- irmmanager->changeIsoValue(propid, value);
-}
-
-void wxMaracasIRMView::changeColor(int propid, double red, double green, double blue){
- try{
- irmmanager->changeColor(propid, red, green, blue);
-
- }catch(char* str){
-
- wxString s( str,wxConvUTF8 );
- wxMessageDialog* diag = new wxMessageDialog(this, s, s, wxICON_ERROR);
- diag->ShowModal();
- delete diag;
-
- }
-}
-
-void wxMaracasIRMView::onLoadImageFile(){
-
- wxString mhd(_T("mhd"));
- wxString stl(_T("stl"));
-
- wxFileDialog* fildial = new wxFileDialog(this, wxString(_T("Select a STL file")),wxString(_T("")),
- wxString(_T("")),wxString(_T("STL files (*.stl)|*.stl|MHD files (*.mhd)|*.mhd")) );
-
- if(fildial->ShowModal()==wxID_OK){
- wxString filename = fildial->GetFilename();
- wxString pathfile(fildial->GetDirectory() + _T("/") + filename);
-
-
- if(filename.EndsWith(mhd)){
- loadPropMHD(pathfile,filename);
- }else if(filename.EndsWith(stl)){
- loadProp3D(pathfile,filename);
- }
- }
- delete fildial;
-
-}
-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);
- if(id!=-1){
-
- wxMaracasIRMViewPanel* controlpan = new wxMaracasIRMViewProp3DMHD(this, id);
- int maxiso = irmmanager->getMaxIsoValue(id);
- ((wxMaracasIRMViewProp3DMHD*)controlpan)->createControls(maxiso);
- addIRMViewPanel(controlpan, dataname);
- }
-
- }catch(char* str){
-
- std::cout << "Exception : " << str << '\n';
- wxMessageDialog* diag = new wxMessageDialog(this, wxString( str,wxConvUTF8 ), wxString( str,wxConvUTF8 ), wxICON_ERROR);
- diag->ShowModal();
-
- }
-}
-
-void wxMaracasIRMView::loadProp3D(wxString filename, wxString dataname){
- std::string s = std::string(filename.mb_str());
- vtkProp3D* prop3D = irmmanager->getProp3D(s);
- if(prop3D != NULL){
- s = std::string(dataname.mb_str() );
- this->addProp3D(prop3D,s);
- }else{
- //TODO msj to the user indicating error in file
- }
-
-
-
-}
-
-void wxMaracasIRMView::addProp3D(vtkProp3D* prop3D, std::string dataname){
- try{
- int id = irmmanager->addProp3D(prop3D,dataname);
- if(id!=-1){
- wxMaracasIRMViewPanel* controlpan = new wxMaracasIRMViewProp3D(this, id);
- addIRMViewPanel(controlpan, dataname);
- }
- }catch(char* str){
- std::cout << "Exception : " << str << '\n';
- wxMessageDialog* diag = new wxMessageDialog(this, wxString(str,wxConvUTF8 ), wxString(str,wxConvUTF8 ), wxICON_ERROR);
- diag->ShowModal();
- }
-
-}
-void wxMaracasIRMView::addIRMViewPanel(wxMaracasIRMViewPanel* irmview, std::string dataname){
-
- wxString s(dataname.c_str(),wxConvUTF8 );
- 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){
-
- }
-}
-
-
-
-
-
-/**
-**
-**/
-
-ToolBar::ToolBar(wxWindow * parent,std::string iconsdir)
-: wxToolBar(parent, -1, wxDefaultPosition, wxDefaultSize)
-{
-
-
- std::string iconfil = iconsdir;
-
- //iconfil+= "/OpenImage.png";
- //wxBitmap* bitmap0 = new wxBitmap(wxString(iconfil.c_str(),wxConvUTF8), wxBITMAP_TYPE_PNG);
- wxBitmap bitmap0(OpenImage_xpm);
- 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); */
-
- /*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){
-}
-
-ToolBarEventHandler::ToolBarEventHandler()
-: wxEvtHandler(){
-}
-ToolBarEventHandler::~ToolBarEventHandler(){
-}
-
-void ToolBarEventHandler::onLoadImageFile(wxCommandEvent& event){
- wxMaracasIRMView::getInstance()->onLoadImageFile();
-}
-
-
-
-BEGIN_EVENT_TABLE(ToolBarEventHandler, wxEvtHandler)
- EVT_MENU(1, ToolBarEventHandler::onLoadImageFile)
-END_EVENT_TABLE()
-
-
+++ /dev/null
-/*=========================================================================
-
- Program: wxMaracas
- Module: $RCSfile: wxMaracasIRMView.h,v $
- Language: C++
- Date: $Date: 2009/06/16 13:25:58 $
- Version: $Revision: 1.6 $
-
- Copyright: (c) 2002, 2003
- License:
-
- This software is distributed WITHOUT ANY WARRANTY; without even
- the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- PURPOSE. See the above copyright notice for more information.
-
-=========================================================================*/
-
-#ifndef __wxMaracasIRMViewPanelH__
-#define __wxMaracasIRMViewPanelH__
-
-#include <vector>
-#include <wx/wx.h>
-#include "wx/aui/aui.h"
-#include <iostream>
-#include "marTypes.h"
-#include "vtkProp3D.h"
-
-#include "wxMaracasIRMViewManager.h"
-#include "wxMaracasIRMViewPanel.h"
-
-
-
-class creaMaracasVisu_EXPORT wxMaracasIRMView : public wxPanel
-{
-
-public:
- wxMaracasIRMView( wxWindow* parent, std::string path);
- ~wxMaracasIRMView( );
-
- static wxMaracasIRMView* getInstance(wxWindow* parent,std::string path="");
-
- static wxMaracasIRMView* getInstance();
-
- void setRenderer(vtkRenderer* renderer);
-
- void changeOpacity(int propid, int value);
-
- void changeIsoValue(int propid, double value);
-
- void addRemoveActor(int propid, bool addremove);
-
- void changeColor(int propid, double red, double green, double blue);
-
- void addProp3D(vtkProp3D* prop3D, std::string dataname="");
-
- void addPropMHD(vtkImageData* imgdata, std::string dataname="");
-
- void loadProp3D(wxString filename, wxString dataname);
-
- void loadPropMHD(wxString filename, wxString dataname);
-
- void onLoadImageFile();
-
- void addIRMViewPanel(wxMaracasIRMViewPanel* irmview, std::string dataname="");
-
- std::string getPath();
-
- void deleteActor(int propid);
-private:
- static wxMaracasIRMView* instance;
-
- wxMaracasIRMViewManager* irmmanager;
-
- wxAuiManager* wxauimanager;
-
- void createFileChooser();
-
- std::string _path;
-
- wxToolBar* _toolb;
-
-};
-
-class ToolBarEventHandler : public wxEvtHandler{
-
- public:
- ToolBarEventHandler();
- ~ToolBarEventHandler();
-
- void onLoadImageFile(wxCommandEvent& event);
-
- private:
-
- DECLARE_EVENT_TABLE()
- };
-
-class ToolBar : public wxToolBar{
-
-
-public:
- ToolBar(wxWindow * parent,std::string iconsdir);
- ~ToolBar(void);
-
-
-private:
-
- ToolBarEventHandler* _evthand;
-
-};
-
-#endif
-
+++ /dev/null
-/*=========================================================================
-
- Program: wxMaracas
- Module: $RCSfile: wxMaracasIRMViewManager.cxx,v $
- Language: C++
- Date: $Date: 2009/05/29 14:25:26 $
- Version: $Revision: 1.6 $
-
- Copyright: (c) 2002, 2003
- License:
-
- This software is distributed WITHOUT ANY WARRANTY; without even
- the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- PURPOSE. See the above copyright notice for more information.
-
-=========================================================================*/
-#include "wxMaracasIRMViewManager.h"
-
-#include "wxMaracasIRMViewManagerDataMhd.h"
-
-/**
-** Start of the manager class
-**/
-wxMaracasIRMViewManager::wxMaracasIRMViewManager(){
- _renderer = NULL;
- _idCount=0;
-}
-wxMaracasIRMViewManager::~wxMaracasIRMViewManager(){
-}
-
-/**
-** Sets the renderer to manage the prop3D from the view
-**/
-void wxMaracasIRMViewManager::setRenderer(vtkRenderer* renderer){
- _renderer = renderer;
-}
-/**
-** Adds a prop3D to the manager and returns the identifier
-**/
-int wxMaracasIRMViewManager::addProp3D(vtkProp3D* prop3D, std::string dataname) throw(char*){
- checkInvariant();
- if(prop3D != NULL){
- wxMaracasIRMViewManagerData* data = new wxMaracasIRMViewManagerData(prop3D, dataname);
- prop3Dvect.push_back(data);
- _renderer->AddActor(data->getProp3D());
- data->setId(_idCount);
- _idCount++;
- return data->getId();
- }else{
- throw "Check vtkProp3D file or input";
- }
- return -1;
-}
-int wxMaracasIRMViewManager::addPropMHD(vtkImageData* imagedata, std::string dataname) throw(char*){
-
- checkInvariant();
- if(imagedata != NULL){
- wxMaracasIRMViewManagerData* data = new wxMaracasIRMViewManagerDataMhd(imagedata, dataname);
- prop3Dvect.push_back(data);
- _renderer->AddActor(data->getProp3D());
- data->setId(_idCount);
- _idCount++;
- return data->getId();
- }else{
- throw "Check ImageData file or input";
- }
- return -1;
-
-}
-/**
-** adds or removes an actor depending of the bool value
-**/
-void wxMaracasIRMViewManager::addRemoveActor(int propid, bool addremove) throw(char*){
- checkInvariant();
-
- wxMaracasIRMViewManagerData* data = this->getViewData(propid);
- if(data->getProp3D()!=NULL){
- if(addremove){
- _renderer->AddViewProp(data->getProp3D());
- }else{
- _renderer->RemoveViewProp(data->getProp3D());
- }
- _renderer->Render();
- }
-
-}
-/**
-** Changes the opacity in a prop3D
-**/
-void wxMaracasIRMViewManager::changeOpacity(int propid, int value) throw(char*){
- checkInvariant();
-
-
- this->getViewData(propid)->changeOpacity(value);
-
- _renderer->Render();
-
-}
-
-/**
-** changes the isovalue in a prop3D
-**/
-void wxMaracasIRMViewManager::changeIsoValue(int propid, double value )throw(char*){
- checkInvariant();
-
- wxMaracasIRMViewManagerData* data = this->getViewData(propid);
-
- //_renderer->RemoveActor(data->getProp3D());
- ((wxMaracasIRMViewManagerDataMhd*)data)->changeIsoValue(value);
- //_renderer->AddActor(data->getProp3D());
-
- _renderer->Render();
-}
-
-vtkProp3D* wxMaracasIRMViewManager:: getProp3D(std::string filename){
- if(filename.compare("")!= 0){
- vtkSTLReader *STLReader=vtkSTLReader::New();
- STLReader->SetFileName(filename.c_str());
- STLReader->Update();
- vtkPolyDataMapper* dataMapper = vtkPolyDataMapper::New();
- dataMapper->SetInput(STLReader->GetOutput());
-
- vtkActor* dataActor = vtkActor::New();
- dataActor->SetMapper(dataMapper);
- dataActor->GetProperty()->SetOpacity(1);
-
- return dataActor;
- }
- return NULL;
-}
-
-vtkImageData* wxMaracasIRMViewManager::getImageData(std::string filename){
- if(filename.compare("")!= 0){
-
-
- vtkMetaImageReader* reader = vtkMetaImageReader::New();
- reader->SetFileName(filename.c_str());
- reader->Update();
- vtkImageData* img = reader->GetOutput();
- //reader->Delete();
- return img;
- }
- return NULL;
-}
-
-void wxMaracasIRMViewManager::checkInvariant() throw(char*){
- if(this->_renderer==NULL){
- throw "Renderer not set";
- }
-}
-
-wxMaracasIRMViewManagerData* wxMaracasIRMViewManager::getViewData(int id) throw(char*){
- int i;
- for(i = 0; i < (int)(prop3Dvect.size());i++){
- if(prop3Dvect[i]->getId() == id){
- return prop3Dvect[i];
- }
- }
- throw "id not found in the data";
-
- return NULL;
-}
-
-int wxMaracasIRMViewManager::getMaxIsoValue(int propid) throw(char*){
-
- return ((wxMaracasIRMViewManagerDataMhd*)this->getViewData(propid))->getMaxGreyLevel();
-
-}
-
-void wxMaracasIRMViewManager::changeColor(int propid, double red, double green, double blue) throw(char*){
- checkInvariant();
- this->getViewData(propid)->changeColor(red, green, blue);
-
- _renderer->Render();
-}
-
-void wxMaracasIRMViewManager::deleteActor(int propid) throw (char *){
- checkInvariant();
-
- this->addRemoveActor(propid, false);
-
- int i,n;
- bool exit = false;
- for(i = 0; i < (int)(prop3Dvect.size())&&!exit;i++){
- if(prop3Dvect[i]->getId() == propid){
- n=i;
- exit = true;
- }
- }
- if(exit){
- wxMaracasIRMViewManagerData* data = prop3Dvect[n];
- int j;
- for(j = i; j < (int)(prop3Dvect.size())-1;j++){
- prop3Dvect[j] = prop3Dvect[j+1];
- }
- delete data;
- prop3Dvect.pop_back();
- }else{
- throw "id not found in the data";
- }
-
-
-
-
-}
-
-
+++ /dev/null
-/*=========================================================================
-
- Program: wxMaracas
- Module: $RCSfile: wxMaracasIRMViewManager.h,v $
- Language: C++
- Date: $Date: 2009/05/14 13:54:35 $
- Version: $Revision: 1.5 $
-
- Copyright: (c) 2002, 2003
- License:
-
- This software is distributed WITHOUT ANY WARRANTY; without even
- the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- PURPOSE. See the above copyright notice for more information.
-
-=========================================================================*/
-
-
-
-
-#ifndef __wxMaracasIRMViewManagerH__
-#define __wxMaracasIRMViewManagerH__
-
-#include <iostream>
-#include <vector>
-
-#include "wxMaracasIRMViewManagerData.h"
-
-
-class wxMaracasIRMViewManager {
-
-public:
- wxMaracasIRMViewManager();
- ~wxMaracasIRMViewManager();
-
- /**
- ** Sets the renderer to manage the prop3D from the view
- **/
- void setRenderer(vtkRenderer* renderer);
- /**
- ** Adds a prop3D to the manager and returns the identifier
- **/
- int addProp3D(vtkProp3D* prop3D, std::string dataname) throw (char*);
- /**
- ** Adds a prop3D to the manager and returns the identifier
- **/
- int addPropMHD(vtkImageData* imagedata, std::string dataname) throw(char*);
- /**
- ** Changes the opacity in a prop3D
- **/
- void changeOpacity(int propid, int value)throw(char*);
-
- /**
- ** changes the isovalue in a prop3D
- **/
- void changeIsoValue(int propid, double value)throw(char*);
-
- /**
- ** loads a prop3D from a nSTL file
- **/
- vtkProp3D* getProp3D(std::string filename);
-
- /**
- ** loads a MHD file to convert it into an actor
- **/
- vtkImageData* getImageData(std::string filename);
-
- /**
- ** adds or removes an actor depending of the bool value
- **/
- void addRemoveActor(int propid, bool addremove)throw(char*);
- /**
- ** Check if the variables are setted correctly
- **/
- void checkInvariant()throw(char*);
-
- /**
- ** Given an id search the data in the vector
- **/
- wxMaracasIRMViewManagerData* getViewData(int id)throw(char*);
-
- /**
- ** Given the id, return the max iso value from the imagedata
- **/
- int getMaxIsoValue(int propid)throw(char*);
-
-
- /**
- ** Changes the color of the actor
- **/
- void changeColor(int propid, double red, double green, double blue) throw(char*);
-
- void deleteActor(int propid)throw (char *);
-
-private:
- std::vector<wxMaracasIRMViewManagerData*> prop3Dvect;
-
- vtkRenderer* _renderer;
-
- int _idCount;
-
-
-
-
-};
-
-#endif
+++ /dev/null
-
-#include "wxMaracasIRMViewManagerData.h"
-
-/********************************************************************************************
-** Start of data viewmanagerData
-*********************************************************************************************/
-
-wxMaracasIRMViewManagerData::wxMaracasIRMViewManagerData(vtkProp3D* prop3Dvect, std::string dataname){
-
- _prop3D = prop3Dvect;
- _dataname = dataname;
-
-}
-
-
-wxMaracasIRMViewManagerData::~wxMaracasIRMViewManagerData(){
-
- _prop3D->Delete();
-}
-
-/**
-** Adds a prop3D to the world of the application
-**/
-void wxMaracasIRMViewManagerData::setProp3D(vtkProp3D* prop3D){
- _prop3D = prop3D;
-}
-/**
-** Changes the opacity in a prop3D
-**/
-void wxMaracasIRMViewManagerData::changeOpacity(int value){
- std::cout<<"chage op"<<value<<std::endl;
- vtkActor* actor = (vtkActor*)this->_prop3D;
- actor->GetProperty()->SetOpacity((double)value/100.0);
-
-
-
-}
-void wxMaracasIRMViewManagerData::changeColor(double red, double green, double blue){
- std::cout<<"chage col"<<red<<green<<blue<<std::endl;
- vtkActor* actor = (vtkActor*)this->_prop3D;
- actor->GetProperty()->SetColor(red,green,blue);
-}
-/**
-** Check if the variables are setted correctly
-**/
-void wxMaracasIRMViewManagerData::checkInvariant(){
-
-}
-/**
-** get the prop3D
-**/
-vtkProp3D* wxMaracasIRMViewManagerData::getProp3D(){
- return this->_prop3D;
-}
-/**
-** return the id from the daat
-**/
-int wxMaracasIRMViewManagerData::getId(){
- return _id;
-}
-/**
-** set data id
-**/
-void wxMaracasIRMViewManagerData::setId(int propid){
- _id = propid;
-}
-
-/**
-** Get the filanme
-**/
-std::string wxMaracasIRMViewManagerData::getDataname(){
- return _dataname;
-}
-/**
-** Set the filanme
-**/
-void wxMaracasIRMViewManagerData::setDataname(std::string dataname){
- _dataname = dataname;
-}
-
+++ /dev/null
-#ifndef WXMARACASIRMVIEWMANAGERDATA_H_
-#define WXMARACASIRMVIEWMANAGERDATA_H_
-
-#include "vtkProp3D.h"
-#include "vtkRenderer.h"
-#include "vtkSTLReader.h"
-#include "vtkPolyDataMapper.h"
-#include "vtkActor.h"
-#include "vtkProperty.h"
-
-
-
-class wxMaracasIRMViewManagerData {
-
-public:
- wxMaracasIRMViewManagerData(vtkProp3D* _prop3Dvect, std::string dataname="");
- ~wxMaracasIRMViewManagerData();
-
- /**
- ** Adds a prop3D to the world of the application
- **/
- void setProp3D(vtkProp3D* prop3D);
- /**
- ** Changes the opacity in a prop3D
- **/
- void changeOpacity(int value);
- /**
- ** Check if the variables are setted correctly
- **/
- void checkInvariant();
- /**
- ** get the prop3D
- **/
- vtkProp3D* getProp3D();
- /**
- ** return the id from the daat
- **/
- int getId();
- /**
- ** set data id
- **/
- void setId(int propid);
- /**
- ** Get the filanme
- **/
- std::string getDataname();
- /**
- ** Set the filanme
- **/
- void setDataname(std::string dataname);
-
- /**
- ** creates the image
- **/
- void contourExtractor(int isovalue);
-
- /**
- ** Changes the color of the actor
- **/
- void changeColor(double red, double green, double blue);
-
-protected:
- /**
- * Prop 3D (data actor)
- */
- vtkProp3D* _prop3D;
- /**
- * Dataname given by the user (ex. filename)
- **/
- std::string _dataname;
-
-
-private:
-
- /*
- * id of the data
- */
- int _id;
-
-
-};
-
-#endif /*WXMARACASIRMVIEWMANAGERDATA_H_*/
+++ /dev/null
-
-#include "wxMaracasIRMViewManagerDataMhd.h"
-
-wxMaracasIRMViewManagerDataMhd::wxMaracasIRMViewManagerDataMhd(vtkImageData* imagedata, std::string dataname)
-: wxMaracasIRMViewManagerData(NULL, dataname)
-{
-
- this->setVtkImageData(imagedata);
- _dataname = dataname;
-
- _maxgreylevel = getMaxLevel(imagedata);
- _prop3D=NULL;
-
- _cubesFilter = vtkMarchingCubes::New();
- _cleanFilter = vtkCleanPolyData::New();
- _dataMapper = vtkPolyDataMapper::New();
- vtkActor* dataActor = vtkActor::New();
-
- _cubesFilter->SetInput(this->_imagedata);
- _cubesFilter->ComputeGradientsOn ();
- _cubesFilter->ComputeScalarsOn ();
- _cubesFilter->SetNumberOfContours( 1 );
- _cleanFilter->SetInput ( _cubesFilter->GetOutput() );
- _dataMapper->SetInput(_cleanFilter->GetOutput());
- _dataMapper->ScalarVisibilityOff();
- _dataMapper->ImmediateModeRenderingOn();
- dataActor->SetMapper(_dataMapper);
-
- this->_prop3D = dataActor;
-
- this->changeIsoValue(this->_maxgreylevel);
-
-
-}
-
-wxMaracasIRMViewManagerDataMhd::~wxMaracasIRMViewManagerDataMhd(){
- _cubesFilter->Delete();
- _cleanFilter->Delete();
- _dataMapper->Delete();
-}
-
-
-/**
-** changes the isovalue in a prop3D
-**/
-void wxMaracasIRMViewManagerDataMhd::changeIsoValue(double value){
-
-
- _cubesFilter->SetValue(0,value);
- _cubesFilter->Update();
- _cleanFilter->Update();
- _dataMapper->Update();
-
-
-
-}
-int wxMaracasIRMViewManagerDataMhd::getMaxGreyLevel(){
- return _maxgreylevel;
-}
-
-/**
- ** Get's the max grey level of the image
- **/
-int wxMaracasIRMViewManagerDataMhd::getMaxLevel(vtkImageData* img){
-
- int ext[6], i, j, k,max=0;
- img->GetExtent(ext);
-
- for(i = ext[0]; i < ext[1];i++){
- for(j = ext[2]; j < ext[3];j++){
- for(k = ext[4]; k < ext[5];k++){
- unsigned short* ptr = (unsigned short*)img->GetScalarPointer(i,j,k);
- int temp = (int)*ptr;
- if(temp > max){
- max = temp;
- }
- }
- }
- }
- return max;
-
-
-}
-
-/**
-** Sets the VTK image data
-**/
-
-void wxMaracasIRMViewManagerDataMhd::setVtkImageData(vtkImageData* imagedata){
- _imagedata = imagedata;
-}
-
+++ /dev/null
-#ifndef WXMARACASIRMVIEWMANAGERDATAMHD_H_
-#define WXMARACASIRMVIEWMANAGERDATAMHD_H_
-
-
-#include "wxMaracasIRMViewManagerData.h"
-
-#include "vtkMetaImageReader.h"
-#include "vtkMarchingCubes.h"
-#include "vtkCleanPolyData.h"
-#include "vtkImageData.h"
-
-class wxMaracasIRMViewManagerDataMhd : public wxMaracasIRMViewManagerData {
-
-public:
-
- wxMaracasIRMViewManagerDataMhd(vtkImageData* imagedata, std::string dataname="");
- ~wxMaracasIRMViewManagerDataMhd();
-
-
- /**
- ** Adds a prop3D to the world of the application
- **/
- void setVtkImageData(vtkImageData* imagedata);
-
- /**
- ** changes the isovalue in a prop3D
- **/
- void changeIsoValue(double value);
- /**
- ** Check if the variables are setted correctly
- **/
- void checkInvariant();
-
- /**
- ** Returns the grey max level of the image
- **/
-
- int getMaxGreyLevel();
-
- /**
- ** creates the image
- **/
- void contourExtractor(int isovalue);
-
-private:
-
- vtkImageData* _imagedata;
- int _maxgreylevel;
-
- /**
- ** to the image render
- **/
- vtkMarchingCubes* _cubesFilter;
- vtkCleanPolyData* _cleanFilter;
- vtkPolyDataMapper* _dataMapper;
-
- /**
- ** Get's the max grey level of the image
- **/
- int getMaxLevel(vtkImageData* img);
-
-
-
-};
-
-#endif /*WXMARACASIRMVIEWMANAGERDATAMHD_H_*/
+++ /dev/null
-#ifndef WXMARACASIRMVIEWPANEL_H_
-#define WXMARACASIRMVIEWPANEL_H_
-
-#include "wx/wx.h"
-
-class wxMaracasIRMViewPanel : public wxPanel{
-public:
- wxMaracasIRMViewPanel(wxWindow* parent, int propid)
- : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize){
- createPanel();
- _propid = propid;
- }
- //virtual ~wxMaracasIRMViewPanel();
- virtual void createPanel(){
- show = false;
- /*wxBoxSizer* sizerButtons = new wxBoxSizer(wxVERTICAL);
-
- wxButton* b = new wxButton(this, -1, wxString(_T("-")), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT,
- wxDefaultValidator, wxString(_T("-")));
- Connect(b->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasIRMViewPanel::onActionButtonPressedHide);
- wxButton* b1 = new wxButton(this, -1, wxString(_T("-")), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT,
- wxDefaultValidator, wxString(_T("x")));
- Connect(b1->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasIRMViewPanel::onActionButtonPressedEliminate);
-
- sizerButtons->Add(b, wxFIXED_MINSIZE);
- sizerButtons->Add(b1, wxFIXED_MINSIZE);*/
-
- sizercontrols = new wxBoxSizer(wxVERTICAL);
-
- wxBoxSizer* sizerpanel = new wxBoxSizer(wxHORIZONTAL);
-
- //sizerpanel->Add(sizerButtons,wxGROW);
- sizerpanel->Add(sizercontrols,wxGROW);
-
- this->SetSizer(sizerpanel, true);
- this->SetAutoLayout( true );
- }
-
- /**
- ** Adds a new control to the panel (sizer, radiob, etc)
- **/
- virtual void addControl(wxWindow* win){
- if(sizercontrols!=NULL){
- sizercontrols->Add(win, wxGROW);
- }
- }
- /**
- ** Adds a new control to the panel (sizer, radiob, etc)
- **/
- virtual void addControl(wxSizer* sizer){
- if(sizercontrols!=NULL){
- sizercontrols->Add(sizer, wxGROW);
- }
- }
-
- /**
- ** Hides or show the controls in the panel
- **/
- virtual void onActionButtonPressedHide( wxCommandEvent& event ){
- wxList list = sizercontrols->GetChildren();
- int i;
- for(i=0; i<list.size();i++){
- sizercontrols->Show(i,show);
- }
- show = !show;
- sizercontrols->Layout();
- this->Layout();
- }
-
- /**
- ** The user must implement this function to remove the panel from the
- **/
- //virtual void onActionButtonPressedEliminate( wxCommandEvent& event )=0;
-
- /**
- ** The user must implement this function to add the necessary controls to the panel
- **/
- virtual void createControls( )=0;
- /**
- ** returns the id of the panel
- **/
- int getPropId(){
- return _propid;
- }
-
-private:
- wxBoxSizer* sizercontrols;
- bool show;
-protected:
- int _propid;
-
-};
-
-#endif /*WXMARACASIRMVIEWPANEL_H_*/
+++ /dev/null
-#include "wxMaracasIRMViewProp3D.h"
-
-#include <wx/colordlg.h>
-#include "wxMaracasIRMView.h"
-#include "Color.xpm"
-/**
-** Implementation of viewProp3D
-**/
-
-wxMaracasIRMViewProp3D::wxMaracasIRMViewProp3D(wxWindow* parent,int propid)
-:wxMaracasIRMViewPanel(parent, propid){
- createControls();
-}
-
-wxMaracasIRMViewProp3D::~wxMaracasIRMViewProp3D(){
- //wxMaracasIRMView::getInstance()->addRemoveActor(_propid, false);
- wxMaracasIRMView::getInstance()->deleteActor(_propid);
-}
-
-void wxMaracasIRMViewProp3D::createControls(){
-
- wxFlexGridSizer* sizerirmprop = new wxFlexGridSizer(1,1,1);
-
- wxString choices[2];
- choices[0] = wxString(_T("On"));
- choices[1] = wxString(_T("Off"));
- checkbox = new wxCheckBox(this,-1,wxString(_T("Show Actor")));
- Connect(checkbox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&wxMaracasIRMViewProp3D::onCheckBoxChange);
- checkbox->SetValue(true);
-
- sizerirmprop->Add(checkbox,wxFIXED_MINSIZE);
-
- //this->addControl(checkbox);
-
- wxBitmap bitmap(Color_xpm);
- _colorchoose = new wxBitmapButton(this, -1, bitmap,wxDefaultPosition,wxSize(30,30));
- Connect(_colorchoose->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasIRMViewProp3D::onColorChange);
- sizerirmprop->Add(_colorchoose,wxFIXED_MINSIZE);
-
- //sizercolor->Add(checkbox,wxFIXED_MINSIZE);
- //sizercolor->Add(_colorchoose,wxFIXED_MINSIZE);
- //this->addControl(sizercolor);
-
-
- wxStaticText* label = new wxStaticText(this, -1, wxString(_T("Opacity")));
- opacity = new wxSlider(this, -1,100,0,100,wxDefaultPosition,wxDefaultSize,wxSL_HORIZONTAL|wxSL_LABELS);
- Connect(opacity->GetId(), wxEVT_SCROLL_CHANGED, (wxObjectEventFunction)&wxMaracasIRMViewProp3D::onOpacityRelease);
- wxFlexGridSizer* sizeropacity = new wxFlexGridSizer(1,1,1);
- sizeropacity->Add(label,wxFIXED_MINSIZE);
- sizeropacity->Add(opacity,wxFIXED_MINSIZE);
-
- sizerirmprop->Add(sizeropacity,wxFIXED_MINSIZE);
-
- //this->addControl(sizeropacity);
- this->addControl(sizerirmprop);
-
-}
-void wxMaracasIRMViewProp3D::onCheckBoxChange(wxCommandEvent& event){
- wxMaracasIRMView::getInstance()->addRemoveActor(this->getPropId(), checkbox->GetValue());
-}
-void wxMaracasIRMViewProp3D::onColorChange(wxCommandEvent& event){
- wxColourDialog* colourdiag = new wxColourDialog(this);
- if(colourdiag->ShowModal()==wxID_OK){
- wxColour colour = colourdiag->GetColourData().GetColour();
- _colorchoose->SetBackgroundColour(colour);
-
- double r = (double)(colour.Red())/255.0;
- double g = (double)(colour.Green())/255.0;
- double b = (double)(colour.Blue())/255.0;
-
- wxMaracasIRMView::getInstance()->changeColor(this->getPropId(),r,g,b);
- }
- delete colourdiag;
-}
-/*void wxMaracasIRMViewProp3D::onActionButtonPressedEliminate( wxCommandEvent& event ){
-
-}*/
-
-void wxMaracasIRMViewProp3D::onOpacityRelease(wxScrollEvent& event ){
-
- wxMaracasIRMView::getInstance()->changeOpacity(this->getPropId(),opacity->GetValue());
-
-}
-
+++ /dev/null
-#ifndef WXMARACASIRMVIEWPROP3D_H_
-#define WXMARACASIRMVIEWPROP3D_H_
-
-#include "wxMaracasIRMViewPanel.h"
-
-class wxMaracasIRMViewProp3D : public wxMaracasIRMViewPanel{
-public:
- wxMaracasIRMViewProp3D(wxWindow* parent, int propid);
- ~wxMaracasIRMViewProp3D();
- virtual void createControls();
- void onOpacityRelease(wxScrollEvent& event );
- void onCheckBoxChange(wxCommandEvent& event);
- void onColorChange(wxCommandEvent& event);
-
-
-private:
- wxCheckBox* checkbox;
- wxSlider* opacity;
- wxBitmapButton* _colorchoose;
-
-
-};
-
-#endif /*WXMARACASIRMVIEWPROP3D_H_*/
+++ /dev/null
-#include "wxMaracasIRMViewProp3DMHD.h"
-
-#include "wxMaracasIRMView.h"
-/**
-** IRM viewProp3DMHD implementation
-**/
-wxMaracasIRMViewProp3DMHD::wxMaracasIRMViewProp3DMHD(wxWindow* parent, int propid)
-: wxMaracasIRMViewProp3D(parent, propid)
-{
-
-}
-wxMaracasIRMViewProp3DMHD::~wxMaracasIRMViewProp3DMHD(){
- //this->Show(false);
- //wxMaracasIRMView::getInstance()->addRemoveActor(_propid, false);
-}
-void wxMaracasIRMViewProp3DMHD::createControls(int maxisovalue){
-
- wxFlexGridSizer* sizer = new wxFlexGridSizer(1,1,1);
-
- wxStaticText* label = new wxStaticText(this, -1, wxString(_T("IsoValue")));
- sizer->Add(label, wxGROW);
- //this->addControl(label);
- isovalue = new wxSlider(this, -1,maxisovalue,0,maxisovalue,wxDefaultPosition,wxDefaultSize,wxSL_HORIZONTAL|wxSL_LABELS);
- sizer->Add(isovalue, wxGROW);
- //this->addControl(isovalue);
-
- this->addControl(sizer);
- Connect(isovalue->GetId(), wxEVT_SCROLL_CHANGED, (wxObjectEventFunction)&wxMaracasIRMViewProp3DMHD::onIsoValueRelease);
-}
-
-void wxMaracasIRMViewProp3DMHD::onIsoValueRelease(wxScrollEvent& event ){
-
- wxMaracasIRMView::getInstance()->changeIsoValue(this->getPropId(), isovalue->GetValue()/1.0);
-
-}
-
+++ /dev/null
-#ifndef WXMARACASIRMVIEWPROP3DMHD_H_
-#define WXMARACASIRMVIEWPROP3DMHD_H_
-
-#include "wxMaracasIRMViewProp3D.h"
-
-class wxMaracasIRMViewProp3DMHD : public wxMaracasIRMViewProp3D{
-public:
- wxMaracasIRMViewProp3DMHD(wxWindow* parent, int propid);
- ~wxMaracasIRMViewProp3DMHD();
- void onIsoValueRelease(wxScrollEvent& event );
- void createControls(int maxisovalue);
-
-
-private:
- wxSlider* isovalue;
- int _propid;
-
-};
-
-#endif /*WXMARACASIRMVIEWPROP3DMHD_H_*/