SUBDIRS(lib)
SUBDIRS(bbtk)
SUBDIRS(install)
+
+
+
+
+SET(INPUT_DATA_DIR ${PROJECT_SOURCE_DIR}/data)
+FILE(GLOB CONFIGURE_DATA_FILES *.*)
+IF(WIN32)
+ SET(OUTPUT_DATA_DIR ${PROJECT_BINARY_DIR}/Debug/data)
+ CREA_CPDIR(${INPUT_DATA_DIR} ${OUTPUT_DATA_DIR})
+ SET(OUTPUT_DATA_DIR ${PROJECT_BINARY_DIR}/Release/data)
+ CREA_CPDIR(${INPUT_DATA_DIR} ${OUTPUT_DATA_DIR})
+ SET(OUTPUT_DATA_DIR ${PROJECT_BINARY_DIR}/RelWithDebInfo/data)
+ CREA_CPDIR(${INPUT_DATA_DIR} ${OUTPUT_DATA_DIR})
+ELSE(WIN32)
+ SET(OUTPUT_DATA_DIR ${PROJECT_BINARY_DIR}/data)
+ CREA_CPDIR(${INPUT_DATA_DIR} ${OUTPUT_DATA_DIR})
+ENDIF(WIN32)
\ No newline at end of file
std::vector<vtkProp3D*> tempvect;
int i;
+
+
if(irmview != NULL){
vtkRenderer* renderer = bbGetInputRenderer();
irmview->setRenderer(renderer);
}
void IRMViewer::CreateWidget(wxWindow* parent)
{
- wxMaracasIRMView* irmview = wxMaracasIRMView::getInstance(parent);
+ char currentPath[_MAX_PATH];
+ HMODULE hand = GetModuleHandle("bbcreaMaracasVisu");
+ GetModuleFileName(hand, currentPath, _MAX_PATH);
+
+ std::string path = currentPath;
+
+ path = path.substr(0,path.find_last_of("\\"));
+ std::cout << "Your application's directory is: " << path;
+
+ wxMaracasIRMView* irmview = wxMaracasIRMView::getInstance(parent,path);
+ //GetDllDirectory(_MAX_PATH, currentPath);
+ //std::cout << "Your application's directory is: " << GetDllDirectory(_MAX_PATH, currentPath)<<std::endl;
bbSetOutputWidget(irmview);
SET(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_MINOR_VERSION})
SET(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_BUILD_VERSION})
-
+SET(DATA_DIR ${PROJECT_SOURCE_DIR}/data )
+FILE(GLOB DATA_FILES "${DATA_DIR}/*.*")
+FOREACH( iLST ${DATA_FILES} )
+ INSTALL(
+ FILES ${iLST}
+ DESTINATION bin/data
+ )
+ENDFOREACH(iLST)
+SET(DATA_DIR ${PROJECT_SOURCE_DIR}/data/Icons )
+FILE(GLOB DATA_FILES "${DATA_DIR}/*.*")
+FOREACH( iLST ${DATA_FILES} )
+ INSTALL(
+ FILES ${iLST}
+ DESTINATION bin/data/Icons
+ )
+ENDFOREACH(iLST)
#SET(CPACK_PACKAGE_INSTALL_DIRECTORY "CreaTools\\\\creaMaracasVisu-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
Program: wxMaracas
Module: $RCSfile: wxMaracasIRMView.cxx,v $
Language: C++
- Date: $Date: 2009/04/01 16:16:59 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2009/04/09 13:58:38 $
+ Version: $Revision: 1.2 $
Copyright: (c) 2002, 2003
License:
=========================================================================*/
+
// EOF - wxMaracasMPR.cxx
#include "wxMaracasIRMView.h"
-wxMaracasIRMView* wxMaracasIRMView::instance=NULL;
+#include <wx/colordlg.h>
+#include <wx/bmpbuttn.h>
-wxMaracasIRMView::wxMaracasIRMView( wxWindow* parent)
-: wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize){
+wxMaracasIRMView* wxMaracasIRMView::instance=NULL;
- //createControls();
+wxMaracasIRMView::wxMaracasIRMView( wxWindow* parent,std::string path)
+: wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize){
+
irmmanager = new wxMaracasIRMViewManager();
wxauimanager = new wxAuiManager(this);
- std::string iconsdir = "/";//defaultdir;
- iconsdir+= "/Icons";
+ _path = path;
+
+ std::string iconsdir = path;
+ iconsdir+="/Data/Icons";
wxToolBar* toolbar = new ToolBar(this,iconsdir);
wxAuiPaneInfo paneinfo;
wxauimanager->AddPane(toolbar,paneinfo.ToolbarPane().Top());
wxauimanager->Update();
createFileChooser();
+
}
wxMaracasIRMView::~wxMaracasIRMView( ){
}
-void wxMaracasIRMView::loadProp3D(){
-
- wxFileDialog* fildial = new wxFileDialog(this, wxString(_T("Select a STL file")),wxString(_T("")),
- wxString(_T("")),wxString(_T("*.stl")));
- if(fildial->ShowModal()==wxID_OK){
-
- wxString filename(fildial->GetDirectory() + "/"+fildial->GetFilename() );
- vtkProp3D* prop3D = irmmanager->getProp3D(filename.c_str());
- if(prop3D != NULL){
- this->addProp3D(prop3D);
- }
-
- }
- delete fildial;
-
+std::string wxMaracasIRMView::getPath(){
+ return _path;
}
+
+
void wxMaracasIRMView::createFileChooser(){
}
-wxMaracasIRMView* wxMaracasIRMView::getInstance(wxWindow* parent){
+wxMaracasIRMView* wxMaracasIRMView::getInstance(wxWindow* parent,std::string path){
if(instance==NULL){
- instance = new wxMaracasIRMView(parent);
+ instance = new wxMaracasIRMView(parent,path);
}
return instance;
}
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, int value){
+void wxMaracasIRMView::changeIsoValue(int propid, int 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){
+
+ std::cout << "Exception : " << str << '\n';
+ wxMessageDialog* diag = new wxMessageDialog(this, wxString(str), wxString(str), wxICON_ERROR);
+ diag->ShowModal();
+ }
}
-void wxMaracasIRMView::addProp3D(vtkProp3D* prop3D){
- int id = irmmanager->addProp3D(prop3D);
- if(id!=-1){
- wxMaracasIRMViewProp3D* controlpan = new wxMaracasIRMViewProp3D(this, id);
- wxAuiPaneInfo paneinfo;
- wxauimanager->AddPane(controlpan);
+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("")),"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){
+
+ vtkImageData* img = irmmanager->getImageData(filename.c_str());
+ if(img!=NULL){
+ addPropMHD(img, dataname.c_str());
}
+
+
+}
+
+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), wxString(str), wxICON_ERROR);
+ diag->ShowModal();
+
+ }
+}
+
+void wxMaracasIRMView::loadProp3D(wxString filename, wxString dataname){
+
+ vtkProp3D* prop3D = irmmanager->getProp3D(filename.c_str());
+ if(prop3D != NULL){
+ this->addProp3D(prop3D,dataname.c_str());
+ }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), wxString(str), wxICON_ERROR);
+ diag->ShowModal();
+ }
+
+}
+void wxMaracasIRMView::addIRMViewPanel(wxMaracasIRMViewPanel* irmview, std::string dataname){
+
+ wxString s(dataname.c_str());
+ wxAuiPaneInfo paneinfo;
+ wxauimanager->AddPane(irmview, paneinfo.DefaultPane().Centre().DestroyOnClose().Caption(s));
+ wxauimanager->Update();
+
}
/**
**/
wxMaracasIRMViewProp3D::wxMaracasIRMViewProp3D(wxWindow* parent,int propid)
-:wxMaracasIRMViewPanel(parent){
- createControls();
- this->_propid = propid;
+:wxMaracasIRMViewPanel(parent, propid){
+ createControls();
}
wxMaracasIRMViewProp3D::~wxMaracasIRMViewProp3D(){
+ wxMaracasIRMView::getInstance()->addRemoveActor(_propid, false);
}
void wxMaracasIRMViewProp3D::createControls(){
wxString choices[2];
choices[0] = "On";
choices[1] = "Off";
- radiob = new wxRadioBox(this,-1,wxString(_T("Actor")),wxDefaultPosition,wxDefaultSize,2,choices,1,wxRA_SPECIFY_COLS);
- this->addControl(radiob);
- Connect(radiob->GetId(), wxEVT_COMMAND_RADIOBOX_SELECTED, (wxObjectEventFunction)&wxMaracasIRMViewProp3D::onRadioBoxChange);
-
+ checkbox = new wxCheckBox(this,-1,wxString(_T("Show Actor")));
+ this->addControl(checkbox);
+ Connect(checkbox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&wxMaracasIRMViewProp3D::onCheckBoxChange);
+ checkbox->SetValue(true);
+
+ wxBoxSizer* sizercolor = new wxBoxSizer(wxVERTICAL);
+ std::string iconfile = wxMaracasIRMView::getInstance()->getPath();
+ iconfile+= "/Data/Icons/Color.png";
+ wxBitmap* bitmap = new wxBitmap(wxString(iconfile.c_str(),wxConvUTF8), wxBITMAP_TYPE_PNG);
+ _colorchoose = new wxBitmapButton(this, -1, *bitmap);
+ sizercolor->Add(_colorchoose,wxFIXED_MINSIZE);
+ Connect(_colorchoose->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasIRMViewProp3D::onColorChange);
+
+ this->addControl(sizercolor);
+
- opacity = new wxSlider(this, -1,0,0,100);
- this->addControl(opacity);
+ wxBoxSizer* sizeropacity = new wxBoxSizer(wxVERTICAL);
+ wxStaticText* label = new wxStaticText(this, -1, wxString(_T("Opacity")));
+ sizeropacity->Add(label,wxFIXED_MINSIZE);
+ opacity = new wxSlider(this, -1,100,0,100,wxDefaultPosition,wxDefaultSize,wxSL_HORIZONTAL|wxSL_LABELS);
+ sizeropacity->Add(opacity,wxFIXED_MINSIZE);
Connect(opacity->GetId(), wxEVT_SCROLL_CHANGED, (wxObjectEventFunction)&wxMaracasIRMViewProp3D::onOpacityRelease);
- isovalue = new wxSlider(this, -1,0,0,100);
+ this->addControl(sizeropacity);
+
+
+ /*isovalue = new wxSlider(this, -1,0,0,100);
this->addControl(isovalue);
- Connect(isovalue->GetId(), wxEVT_SCROLL_CHANGED, (wxObjectEventFunction)&wxMaracasIRMViewProp3D::onIsoValueRelease);
+ Connect(isovalue->GetId(), wxEVT_SCROLL_CHANGED, (wxObjectEventFunction)&wxMaracasIRMViewProp3D::onIsoValueRelease); */
}
-void wxMaracasIRMViewProp3D::onRadioBoxChange(wxCommandEvent& event){
-
+void wxMaracasIRMViewProp3D::onCheckBoxChange(wxCommandEvent& event){
+ wxMaracasIRMView::getInstance()->addRemoveActor(this->getPropId(), checkbox->GetValue());
}
-void wxMaracasIRMViewProp3D::onActionButtonPressedEliminate( wxCommandEvent& event ){
-
+void wxMaracasIRMViewProp3D::onColorChange(wxCommandEvent& event){
+ wxColourDialog* colourdiag = new wxColourDialog(this);
+ if(colourdiag->ShowModal()==wxID_OK){
+ wxColour colour = colourdiag->GetColourData().GetColour();
+ _colorchoose->SetBackgroundColour(colour);
+
+ float r = colour.Red()/255;
+ float g = colour.Green()/255;
+ float b = colour.Blue()/255;
+
+ wxMaracasIRMView::getInstance()->changeColor(this->getPropId(),r,g,b);
+ }
+ delete colourdiag;
}
+/*void wxMaracasIRMViewProp3D::onActionButtonPressedEliminate( wxCommandEvent& event ){
+
+}*/
void wxMaracasIRMViewProp3D::onOpacityRelease(wxScrollEvent& event ){
- wxMaracasIRMView::getInstance()->changeOpacity(_propid,opacity->GetValue());
+ wxMaracasIRMView::getInstance()->changeOpacity(this->getPropId(),opacity->GetValue());
+
+}
+
+
+/**
+** IRM viewProp3DMHD implementation
+**/
+wxMaracasIRMViewProp3DMHD::wxMaracasIRMViewProp3DMHD(wxWindow* parent, int propid)
+: wxMaracasIRMViewProp3D(parent, propid)
+{
+
+}
+wxMaracasIRMViewProp3DMHD::~wxMaracasIRMViewProp3DMHD(){
}
+void wxMaracasIRMViewProp3DMHD::createControls(int maxisovalue){
-void wxMaracasIRMViewProp3D::onIsoValueRelease(wxScrollEvent& event ){
+ wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
- wxMaracasIRMView::getInstance()->changeIsoValue(_propid,isovalue->GetValue());
+ 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());
+
+}
/**
**
**/
std::string iconfil = iconsdir;
- iconfil+= "/Open.png";
+ iconfil+= "/OpenImage.png";
+ wxBitmap* bitmap0 = new wxBitmap(wxString(iconfil.c_str(),wxConvUTF8), wxBITMAP_TYPE_PNG);
+ this->AddTool(0, 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();
ToolBar::~ToolBar(void){
}
+void ToolBar::onLoadImageFile(wxCommandEvent& event){
+ wxMaracasIRMView::getInstance()->onLoadImageFile();
+}
-void ToolBar::onLoadConfig(wxCommandEvent& event){
- wxMaracasIRMView::getInstance()->loadProp3D();
-}
BEGIN_EVENT_TABLE(ToolBar, wxToolBar)
- EVT_MENU(2, ToolBar::onLoadConfig)
+ EVT_MENU(0, ToolBar::onLoadImageFile)
+
END_EVENT_TABLE()
Program: wxMaracas
Module: $RCSfile: wxMaracasIRMView.h,v $
Language: C++
- Date: $Date: 2009/04/01 16:16:59 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2009/04/09 13:58:38 $
+ Version: $Revision: 1.2 $
Copyright: (c) 2002, 2003
License:
=========================================================================*/
+#ifndef __wxMaracasIRMViewPanelH__
+#define __wxMaracasIRMViewPanelH__
-#ifndef __wxMaracasIRMViewH__
-#define __wxMaracasIRMViewH__
-
-
+#include <vector>
#include <wx/wx.h>
#include "wx/aui/aui.h"
-
#include <iostream>
-
#include "marTypes.h"
-
#include "vtkProp3D.h"
#include "wxMaracasIRMViewManager.h"
-class creaMaracasVisu_EXPORT wxMaracasIRMView : public wxPanel
-{
-
-public:
- wxMaracasIRMView( wxWindow* parent);
- ~wxMaracasIRMView( );
-
- static wxMaracasIRMView* getInstance(wxWindow* parent);
-
- static wxMaracasIRMView* getInstance();
-
- void setRenderer(vtkRenderer* renderer);
-
- void changeOpacity(int _propid, int value);
-
- void changeIsoValue(int _propid, int value);
-
-
-
- void addProp3D(vtkProp3D* prop3D);
-
-
- void loadProp3D();
-
-private:
- static wxMaracasIRMView* instance;
-
- wxMaracasIRMViewManager* irmmanager;
-
- wxAuiManager* wxauimanager;
-
- void createFileChooser();
-};
-
-#endif // __wxMaracasIRMViewH__
-
-// EOF - wxMaracasIRMView.h
-
-#ifndef __wxMaracasIRMViewPanelH__
-#define __wxMaracasIRMViewPanelH__
-
class wxMaracasIRMViewPanel : public wxPanel{
public:
- wxMaracasIRMViewPanel(wxWindow* parent)
+ 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);
+ /*wxBoxSizer* sizerButtons = new wxBoxSizer(wxVERTICAL);
wxButton* b = new wxButton(this, -1, wxString(_T("-")), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT,
wxDefaultValidator, wxString(_T("-")));
Connect(b1->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasIRMViewPanel::onActionButtonPressedEliminate);
sizerButtons->Add(b, wxFIXED_MINSIZE);
- sizerButtons->Add(b1, wxFIXED_MINSIZE);
+ sizerButtons->Add(b1, wxFIXED_MINSIZE);*/
sizercontrols = new wxBoxSizer(wxVERTICAL);
wxBoxSizer* sizerpanel = new wxBoxSizer(wxHORIZONTAL);
- sizerpanel->Add(sizerButtons,wxGROW);
+ //sizerpanel->Add(sizerButtons,wxGROW);
sizerpanel->Add(sizercontrols,wxGROW);
this->SetSizer(sizerpanel, true);
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
/**
** The user must implement this function to remove the panel from the
**/
- virtual void onActionButtonPressedEliminate( wxCommandEvent& event )=0;
+ //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
-#ifndef __wxMaracasIRMViewPanelProp3DH__
-#define __wxMaracasIRMViewPanelProp3DH__
+
+
+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, int 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();
+
+private:
+ static wxMaracasIRMView* instance;
+
+ wxMaracasIRMViewManager* irmmanager;
+
+ wxAuiManager* wxauimanager;
+
+ void createFileChooser();
+
+ std::string _path;
+};
+
+
class wxMaracasIRMViewProp3D : public wxMaracasIRMViewPanel{
public:
wxMaracasIRMViewProp3D(wxWindow* parent, int propid);
~wxMaracasIRMViewProp3D();
- void createControls();
- void onActionButtonPressedEliminate( wxCommandEvent& event );
- void onOpacityRelease(wxScrollEvent& event );
- void onIsoValueRelease(wxScrollEvent& event );
- void onRadioBoxChange(wxCommandEvent& event);
+ virtual void createControls();
+ void onOpacityRelease(wxScrollEvent& event );
+ void onCheckBoxChange(wxCommandEvent& event);
+ void onColorChange(wxCommandEvent& event);
private:
- wxRadioBox* radiob;
- wxSlider* opacity;
- wxSlider* isovalue;
- int _propid;
+ wxCheckBox* checkbox;
+ wxSlider* opacity;
+ wxBitmapButton* _colorchoose;
+
};
-#endif
-#pragma once
-#ifndef __ToolBar__
-#define __ToolBar__
-#include <vector>
+class wxMaracasIRMViewProp3DMHD : public wxMaracasIRMViewProp3D{
+public:
+ wxMaracasIRMViewProp3DMHD(wxWindow* parent, int propid);
+ ~wxMaracasIRMViewProp3DMHD();
+ void onIsoValueRelease(wxScrollEvent& event );
+ void createControls(int maxisovalue);
+
+
+private:
+ wxSlider* isovalue;
+ int _propid;
+
+};
-#include <wx/wx.h>
public:
- ToolBar(wxWindow * parent,std::string iconsdir="C:/Creatis/creaAppli/Development/creaPipeline/Data/Icons/");
+ ToolBar(wxWindow * parent,std::string iconsdir);
~ToolBar(void);
- void onExecPipeline(wxCommandEvent& event);
-
- void onLoadConfig(wxCommandEvent& event);
+ void onLoadImageFile(wxCommandEvent& event);
private:
Program: wxMaracas
Module: $RCSfile: wxMaracasIRMViewManager.cxx,v $
Language: C++
- Date: $Date: 2009/04/01 16:16:59 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2009/04/09 13:58:38 $
+ Version: $Revision: 1.2 $
Copyright: (c) 2002, 2003
License:
**/
wxMaracasIRMViewManager::wxMaracasIRMViewManager(){
_renderer = NULL;
+ _idCount=0;
}
wxMaracasIRMViewManager::~wxMaracasIRMViewManager(){
}
/**
** Adds a prop3D to the manager and returns the identifier
**/
-int wxMaracasIRMViewManager::addProp3D(vtkProp3D* prop3D){
+int wxMaracasIRMViewManager::addProp3D(vtkProp3D* prop3D, std::string dataname) throw(...){
+ checkInvariant();
if(prop3D != NULL){
- prop3Dvect.push_back(prop3D);
-
- if(_renderer!=NULL){
- _renderer->AddActor(prop3D);
- }else{
- throw "Imposible to add actor, check renderer";
- }
-
+ 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){
- return prop3Dvect.size()-1;
+ checkInvariant();
+ if(imagedata != NULL){
+ wxMaracasIRMViewManagerData* data = new wxMaracasIRMViewManagerData(imagedata, dataname);
+ prop3Dvect.push_back(data);
+ _renderer->AddActor(data->getProp3D());
+ data->setId(_idCount);
+ _idCount++;
+ return data->getId();
}else{
- return -1;
+ throw "Check ImageData file or input";
}
+ return -1;
+
}
/**
-** Changes the opacity in a prop3D
+** adds or removes an actor depending of the bool value
**/
-void wxMaracasIRMViewManager::changeOpacity(int propid, int value){
- if(propid < prop3Dvect.size()){
- vtkActor* actor = (vtkActor*)prop3Dvect[propid];
- actor->GetProperty()->SetOpacity((double)value/100.0);
+void wxMaracasIRMViewManager::addRemoveActor(int propid, bool addremove) throw(...){
+ 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(...){
+ checkInvariant();
+
+
+ this->getViewData(propid)->changeOpacity(value);
+
+ _renderer->Render();
+
}
/**
** changes the isovalue in a prop3D
**/
-void wxMaracasIRMViewManager::changeIsoValue(int propid, int value){
- if(propid<prop3Dvect.size()){
+void wxMaracasIRMViewManager::changeIsoValue(int propid, int value )throw (...){
+ checkInvariant();
- }
+ wxMaracasIRMViewManagerData* data = this->getViewData(propid);
+
+ _renderer->RemoveViewProp(data->getProp3D());
+ data->changeIsoValue(value);
+ _renderer->AddViewProp(data->getProp3D());
+
+ _renderer->Render();
}
vtkProp3D* wxMaracasIRMViewManager:: getProp3D(std::string filename){
}
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(...){
+ if(this->_renderer==NULL){
+ throw "Renderer not set";
+ }
+}
+
+wxMaracasIRMViewManagerData* wxMaracasIRMViewManager::getViewData(int id) throw(...){
+ int i;
+ for(i = 0; i < 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){
+
+ return this->getViewData(propid)->getMaxGreyLevel();
+
+}
+
+void wxMaracasIRMViewManager::changeColor(int propid, double red, double green, double blue) throw (...){
+ checkInvariant();
+ this->getViewData(propid)->changeColor(red, green, blue);
+
+}
+
+/********************************************************************************************
+** Start of data viewmanagerData
+*********************************************************************************************/
+
+wxMaracasIRMViewManagerData::wxMaracasIRMViewManagerData(vtkProp3D* prop3Dvect, std::string dataname){
+
+ _prop3D = prop3Dvect;
+ _dataname = dataname;
+ _maxgreylevel=-1;
+}
+wxMaracasIRMViewManagerData::wxMaracasIRMViewManagerData(vtkImageData* imagedata, std::string dataname){
+
+ this->setVtkImageData(imagedata);
+ _dataname = dataname;
+
+ _maxgreylevel = getMaxLevel(imagedata);
+ _prop3D=NULL;
+
+ this->changeIsoValue(this->_maxgreylevel);
+}
+/**
+** changes the isovalue in a prop3D
+**/
+void wxMaracasIRMViewManagerData::changeIsoValue(int value){
+
+
+ if(_prop3D!=NULL){
+ _prop3D->Delete();
+ _polydata->Delete();
+ _dataMapper->Delete();
+ }
+
+ vtkMarchingCubes *cubesFilter = vtkMarchingCubes::New();
+ cubesFilter->SetInput(this->_imagedata);
+ cubesFilter->SetValue(0,value);
+ cubesFilter->ComputeGradientsOn ();
+ cubesFilter->ComputeScalarsOn ();
+ cubesFilter->SetNumberOfContours( 1 );
+
+ // Unir puntos duplicados y remover primitivas degeneradas
+ vtkCleanPolyData *cleanFilter = vtkCleanPolyData::New();
+ cleanFilter->SetInput ( cubesFilter->GetOutput() );
+ cleanFilter->Update();
+
+ _polydata = vtkPolyData::New();
+ _polydata->DeepCopy(cleanFilter->GetOutput());
+
+ cubesFilter->Delete();
+ cleanFilter->Delete();
+
+
+ _dataMapper = vtkPolyDataMapper::New();
+ _dataMapper->SetInput(_polydata);
+
+ vtkActor* dataActor = vtkActor::New();
+ dataActor->SetMapper(_dataMapper);
+ _prop3D = dataActor;
+
+
+}
+int wxMaracasIRMViewManagerData::getMaxGreyLevel(){
+ return _maxgreylevel;
+}
+wxMaracasIRMViewManagerData::~wxMaracasIRMViewManagerData(){
+}
+/**
+** Adds a prop3D to the world of the application
+**/
+/**
+ ** Get's the max grey level of the image
+ **/
+int wxMaracasIRMViewManagerData::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;
+
+
+}
+void wxMaracasIRMViewManagerData::setVtkImageData(vtkImageData* imagedata){
+ _imagedata = imagedata;
+}
+/**
+** 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){
+ vtkActor* actor = (vtkActor*)_prop3D;
+ actor->GetProperty()->SetOpacity((double)value/100.0);
+}
+
+/**
+** Check if the variables are setted correctly
+**/
+void wxMaracasIRMViewManagerData::checkInvariant(){
+
+}
+/**
+** get the prop3D
+**/
+vtkProp3D* wxMaracasIRMViewManagerData::getProp3D(){
+ return _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;
+}
+
+void wxMaracasIRMViewManagerData::changeColor(double red, double green, double blue){
+ vtkActor* actor = (vtkActor*)_prop3D;
+ actor->GetProperty()->SetColor(red,green,blue);
+}
Program: wxMaracas
Module: $RCSfile: wxMaracasIRMViewManager.h,v $
Language: C++
- Date: $Date: 2009/04/01 16:16:59 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2009/04/09 13:58:38 $
+ Version: $Revision: 1.2 $
Copyright: (c) 2002, 2003
License:
#include "vtkPolyDataMapper.h"
#include "vtkActor.h"
#include "vtkProperty.h"
+#include "vtkMetaImageReader.h"
+#include "vtkMarchingCubes.h"
+#include "vtkCleanPolyData.h"
+#include "vtkImageData.h"
+
+
+
+
+class wxMaracasIRMViewManagerData {
+
+public:
+ wxMaracasIRMViewManagerData(vtkProp3D* _prop3Dvect, std::string dataname="");
+ wxMaracasIRMViewManagerData(vtkImageData* imagedata, std::string dataname="");
+ ~wxMaracasIRMViewManagerData();
+
+
+ /**
+ ** Adds a prop3D to the world of the application
+ **/
+ void setVtkImageData(vtkImageData* imagedata);
+ /**
+ ** Adds a prop3D to the world of the application
+ **/
+ void setProp3D(vtkProp3D* prop3D);
+ /**
+ ** Changes the opacity in a prop3D
+ **/
+ void changeOpacity(int value);
+ /**
+ ** changes the isovalue in a prop3D
+ **/
+ void changeIsoValue(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);
+ /**
+ ** Returns the grey max level of the image
+ **/
+
+ int getMaxGreyLevel();
+
+ /**
+ ** creates the image
+ **/
+ void contourExtractor(int isovalue);
+
+ /**
+ ** Changes the color of the actor
+ **/
+ void changeColor(double red, double green, double blue);
+
+private:
+ vtkProp3D* _prop3D;
+ vtkImageData* _imagedata;
+ int _id;
+ std::string _dataname;
+ int _maxgreylevel;
+
+ /**
+ **
+ **/
+ vtkPolyDataMapper* _dataMapper;
+ vtkPolyData* _polydata;
+ /**
+ ** Get's the max grey level of the image
+ **/
+ int getMaxLevel(vtkImageData* img);
+
+
+
+};
class wxMaracasIRMViewManager {
/**
** Adds a prop3D to the manager and returns the identifier
**/
- int addProp3D(vtkProp3D* prop3D);
+ int addProp3D(vtkProp3D* prop3D, std::string dataname);
+ /**
+ ** Adds a prop3D to the manager and returns the identifier
+ **/
+ int addPropMHD(vtkImageData* imagedata, std::string dataname);
/**
** Changes the opacity in a prop3D
**/
** 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);
+ /**
+ ** Check if the variables are setted correctly
+ **/
+ void checkInvariant();
+
+ /**
+ ** Given an id search the data in the vector
+ **/
+ wxMaracasIRMViewManagerData* getViewData(int id);
+
+ /**
+ ** Given the id, return the max iso value from the imagedata
+ **/
+ int getMaxIsoValue(int propid);
+
+
+ /**
+ ** Changes the color of the actor
+ **/
+ void changeColor(int propid, double red, double green, double blue);
private:
- std::vector<vtkProp3D*> prop3Dvect;
+ std::vector<wxMaracasIRMViewManagerData*> prop3Dvect;
vtkRenderer* _renderer;
+ int _idCount;
+
+
+
};
+
#endif