--- /dev/null
+ #----------------------------------------------------------------------------
+# USER! : SET THE NAME OF YOUR LIBRARY
+# (Replace 'MyLib' by your own library name)
+
+#############################
+SET ( LIBRARY_NAME BaseSurfaceRenderer )
+#############################
+
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+# CREATES A USER OPTION IN CMAKE
+OPTION ( BUILD_${LIBRARY_NAME} "Build ${LIBRARY_NAME} library ?" ON)
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+IF ( BUILD_${LIBRARY_NAME} )
+#----------------------------------------------------------------------------
+
+ #----------------------------------------------------------------------------
+ # BUILD LIBRARY
+ #----------------------------------------------------------------------------
+
+ #----------------------------------------------------------------------------
+ # LIBRARY HEADERS (TO BE INSTALLED)
+ # EITHER LIST ALL .h, *.txx IN CURRENT DIR USING NEXT LINE:
+
+ FILE(GLOB ${LIBRARY_NAME}_HEADERS *.h *.txx)
+
+ # OR MANUALLY LIST YOUR HEADERS WITH NEXT COMMAND
+ # SET ( ${LIBRARY_NAME}_HEADERS
+ #
+ # )
+ #----------------------------------------------------------------------------
+
+ #----------------------------------------------------------------------------
+ # LIBRARY SOURCES (TO BE COMPILED)
+ # EITHER LIST ALL .cxx, *.cpp, *.cc IN CURRENT DIR USING NEXT LINE:
+
+ FILE(GLOB ${LIBRARY_NAME}_SOURCES *.cxx *.cpp *.cc ${${LIBRARY_NAME}_HEADERS})
+
+ # OR MANUALLY LIST YOUR FILES WITH NEXT COMMAND (WITHOUT EXTENSION)
+ # SET ( ${LIBRARY_NAME}_SOURCES
+ #
+ # )
+ #----------------------------------------------------------------------------
+
+ #----------------------------------------------------------------------------
+ # LIBRARY DEPENDENCIES (LIBRARIES TO LINK WITH)
+ #
+ # USER! : Uncomment the Libraries you need
+ #
+ SET ( ${LIBRARY_NAME}_LINK_LIBRARIES
+ # ${crea_LIBRARIES}
+ # ${WXWIDGETS_LIBRARIES}
+ # ${KWWidgets_LIBRARIES}
+ # ${VTK_LIBRARIES}
+ # ${ITK_LIBRARIES}
+ # ${GDCM_LIBRARIES}
+ # ${BOOST_LIBRARIES}
+ KernelSurfaceRenderer
+
+ # If this library must link against other libraries
+ # USER! : Add here any extra Library you need
+
+ )
+ #----------------------------------------------------------------------------
+
+ #----------------------------------------------------------------------------
+ # MACRO WHICH DOES ALL THE JOB : BUILD AND INSTALL
+
+ # USER! : The default is to create a Dynamic Library.
+ # if you need to create a static library
+ # comment out the following line :
+
+ SET(${LIBRARY_NAME}_INSTALL_TREE_RELATIVE_INCLUDE_PATHS include/creaMaracasVisu)
+ SET(${LIBRARY_NAME}_INSTALL_FOLDER creaMaracasVisu)
+ CREA_ADD_LIBRARY( ${LIBRARY_NAME} )
+ #SET_TARGET_PROPERTIES(${LIBRARY_NAME} PROPERTIES LINKER_LANGUAGE C)
+
+ # and uncomment the 2 lines hereafter:
+
+ # ADD_LIBRARY(${LIBRARY_NAME} STATIC ${${LIBRARY_NAME}_SOURCES})
+ # TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${${LIBRARY_NAME}_LINK_LIBRARIES} )
+
+ #
+ #----------------------------------------------------------------------------
+
+ #---------------------------------------------------------------------------
+ENDIF ( BUILD_${LIBRARY_NAME} )
--- /dev/null
+/*=========================================================================
+
+ Program: wxMaracas
+ Module: $RCSfile: wxMaracasSurfaceRenderingManager.cxx,v $
+ Language: C++
+ Date: $Date: 2011/06/28 16:56:13 $
+ Version: $Revision: 1.1 $
+
+ 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 "wxMaracasSurfaceRenderingManager.h"
+#include "wxMaracasSurfaceRenderingManagerDataMhd.h"
+
+/**
+** Start of the manager class
+**/
+wxMaracasSurfaceRenderingManager::wxMaracasSurfaceRenderingManager(){
+ _renderer = NULL;
+ _interactor = NULL;
+ _idCount=0;
+}
+wxMaracasSurfaceRenderingManager::~wxMaracasSurfaceRenderingManager(){
+}
+
+/**
+** Sets the renderer to manage the prop3D from the surface render
+**/
+void wxMaracasSurfaceRenderingManager::setRenderer(vtkRenderer* renderer){
+ _renderer = renderer;
+}
+
+/**
+** Sets the renderer to manage the prop3D from the surface render
+**/
+void wxMaracasSurfaceRenderingManager::setInteractor(vtkRenderWindowInteractor* interactor){
+ _interactor = interactor;
+}
+
+
+/**
+** Gets the renderer to manage the prop3D from the surface render
+**/
+vtkRenderer* wxMaracasSurfaceRenderingManager::getRenderer(){
+ return _renderer;
+}
+
+/**
+** Updates volume
+**/
+void wxMaracasSurfaceRenderingManager::Update(int pid)throw(char*){
+ wxMaracasSurfaceRenderingManagerData* data = this->getViewData(pid);
+ ((wxMaracasSurfaceRenderingManagerDataMhd*)data)->UpdateSurface();
+ _renderer->Render();
+}
+
+/**
+** Adds a prop3D to the manager and returns the identifier
+**/
+int wxMaracasSurfaceRenderingManager::addProp3D(int idTP, vtkProp3D* prop3D, std::string dataname) throw(char*){
+ checkInvariant();
+ if(prop3D != NULL){
+ wxMaracasSurfaceRenderingManagerData* data = new wxMaracasSurfaceRenderingManagerData(prop3D, dataname, _interactor);
+ prop3Dvect.push_back(data);
+ _renderer->AddActor(data->getProp3D());
+ if(idTP == -1)
+ {
+ data->setId(_idCount);
+ _idCount++;
+ }
+ else
+ {
+ data->setId(idTP);
+ }
+ return data->getId();
+ }else{
+ throw "Check vtkProp3D file or input";
+ }
+ return -1;
+}
+int wxMaracasSurfaceRenderingManager::addPropMHD(int idTP, vtkImageData* imagedata, std::string dataname) throw(char*){
+ checkInvariant();
+ if(imagedata != NULL){
+ image = imagedata;
+ wxMaracasSurfaceRenderingManagerData* data = new wxMaracasSurfaceRenderingManagerDataMhd(imagedata, dataname, _interactor);
+ prop3Dvect.push_back(data);
+ _renderer->AddActor(data->getProp3D());
+ if(idTP == -1)
+ {
+ data->setId(_idCount);
+ _idCount++;
+ }
+ else
+ {
+ data->setId(idTP);
+ }
+ printf("wxMaracasSurfaceRenderingManager::addPropMHD->idSurfaceRender: %i\n", data->getId());
+ return data->getId();
+ }else{
+ throw "Check ImageData file or input";
+ }
+ return -1;
+}
+/**
+** adds or removes an actor depending of the bool value
+**/
+void wxMaracasSurfaceRenderingManager::addRemoveActor(int propid, bool addremove) throw(char*){
+ checkInvariant();
+
+ wxMaracasSurfaceRenderingManagerData* data = this->getViewData(propid);
+ if(data->getProp3D()!=NULL){
+ if(addremove){
+ _renderer->AddViewProp(data->getProp3D());
+ }else{
+ _renderer->RemoveViewProp(data->getProp3D());
+ }
+ _renderer->Render();
+ }
+}
+/**
+** adds or removes the surface box depending of the bool value
+**/
+void wxMaracasSurfaceRenderingManager::addRemoveSurfaceBox(int propid, bool addremove) throw(char*){
+ checkInvariant();
+
+ wxMaracasSurfaceRenderingManagerData* data = this->getViewData(propid);
+ if(data->getProp3D()!=NULL){
+ data->addRemoveSurfaceBox(addremove);
+ /*if(addremove){
+ data->
+ _renderer->AddViewProp(data->getProp3D());
+ }else{
+ _renderer->RemoveViewProp(data->getProp3D());
+ }
+ _renderer->Render();*/
+ }
+
+}
+
+/**
+** Changes the opacity in a prop3D
+**/
+void wxMaracasSurfaceRenderingManager::changeOpacity(int propid, int value) throw(char*){
+ checkInvariant();
+
+
+ this->getViewData(propid)->changeOpacity(value);
+
+ _renderer->Render();
+
+}
+
+/**
+** changes the isovalue in a prop3D
+**/
+void wxMaracasSurfaceRenderingManager::changeIsoValue(int propid, double value ){
+ checkInvariant();
+
+ wxMaracasSurfaceRenderingManagerData* data = this->getViewData(propid);
+
+ //_renderer->RemoveActor(data->getProp3D());
+ ((wxMaracasSurfaceRenderingManagerDataMhd*)data)->changeIsoValue(value);
+ //_renderer->AddActor(data->getProp3D());
+
+ _renderer->Render();
+}
+
+/**
+** changes the isovalue in a prop3D
+**/
+void wxMaracasSurfaceRenderingManager::changeIsoValue(int propid, double min, double max ){
+ checkInvariant();
+
+ wxMaracasSurfaceRenderingManagerData* data = this->getViewData(propid);
+
+ //_renderer->RemoveActor(data->getProp3D());
+ ((wxMaracasSurfaceRenderingManagerDataMhd*)data)->changeIsoValue(min, max);
+ //_renderer->AddActor(data->getProp3D());
+
+ _renderer->Render();
+}
+
+vtkProp3D* wxMaracasSurfaceRenderingManager:: 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* wxMaracasSurfaceRenderingManager::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;
+}
+
+vtkImageData* wxMaracasSurfaceRenderingManager::getImageData(){
+ return image;
+}
+
+void wxMaracasSurfaceRenderingManager::checkInvariant() throw(char*){
+ if(this->_renderer==NULL){
+ throw "Renderer not set";
+ }
+}
+
+wxMaracasSurfaceRenderingManagerData* wxMaracasSurfaceRenderingManager::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 wxMaracasSurfaceRenderingManager::getMaxIsoValue(int propid) throw(char*){
+
+ return ((wxMaracasSurfaceRenderingManagerDataMhd*)this->getViewData(propid))->getMaxGreyLevel();
+
+}
+
+void wxMaracasSurfaceRenderingManager::changeColor(int propid, double red, double green, double blue) throw(char*){
+ checkInvariant();
+ this->getViewData(propid)->changeColor(red, green, blue);
+
+ _renderer->Render();
+}
+
+void wxMaracasSurfaceRenderingManager::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){
+ wxMaracasSurfaceRenderingManagerData* 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";
+ }
+}
+
+void wxMaracasSurfaceRenderingManager::enableBoundingBox(int propid, bool enable){
+ checkInvariant();
+
+ wxMaracasSurfaceRenderingManagerData* data = this->getViewData(propid);
+
+ data->enableBoxWidget(enable);
+}
+void wxMaracasSurfaceRenderingManager::Transform(vtkMatrix4x4* tmatrix){
+
+}
+
+bool wxMaracasSurfaceRenderingManager::interactorSet(){
+ return _interactor? true:false;
+}
+
+void wxMaracasSurfaceRenderingManager::saveProp3DSTL(int propid,const char* filename){
+ checkInvariant();
+
+ wxMaracasSurfaceRenderingManagerData* data = this->getViewData(propid);
+ if(data->getProp3D()!=NULL){
+ data->saveProp3DSTL(filename);
+ }
+}
--- /dev/null
+/*=========================================================================
+
+ Program: wxMaracas
+ Module: $RCSfile: wxMaracasSurfaceRenderingManager.h,v $
+ Language: C++
+ Date: $Date: 2011/06/28 16:56:13 $
+ Version: $Revision: 1.1 $
+
+ 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 __wxMaracasSurfaceRenderingManagerH__
+#define __wxMaracasSurfaceRenderingManagerH__
+
+#include <iostream>
+#include <vector>
+#include <vtkMatrix4x4.h>
+
+#include "wxMaracasSurfaceRenderingManagerData.h"
+
+
+class wxMaracasSurfaceRenderingManager {
+
+public:
+ wxMaracasSurfaceRenderingManager();
+ ~wxMaracasSurfaceRenderingManager();
+
+ /**
+ ** Sets the renderer to manage the prop3D from the surface render
+ **/
+ void setRenderer(vtkRenderer* renderer);
+
+ /**
+ ** Gets the renderer which manages the prop3D from the surface render
+ **/
+ vtkRenderer* getRenderer();
+
+ /**
+ ** Updates surface
+ **/
+ void Update(int pid)throw(char*);
+
+ /**
+ ** Adds a prop3D to the manager and returns the identifier
+ **/
+ int addProp3D(int idTP, vtkProp3D* prop3D, std::string dataname) throw (char*);
+ /**
+ ** Adds a prop3D to the manager and returns the identifier
+ **/
+ int addPropMHD(int idTP, 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);
+
+ void changeIsoValue(int propid, double min, double max );
+
+ /**
+ ** 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);
+
+ /**
+ ** Gets image data asotiated with the rendering manager
+ **/
+ vtkImageData* getImageData();
+
+ /**
+ ** adds or removes an actor depending of the bool value
+ **/
+ void addRemoveActor(int propid, bool addremove)throw(char*);
+ /**
+ **
+ **/
+ void addRemoveSurfaceBox(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
+ **/
+ wxMaracasSurfaceRenderingManagerData* getViewData(int id)throw(char*);
+
+ /**
+ **
+ **/
+ void setInteractor(vtkRenderWindowInteractor* interactor);
+
+ /**
+ ** 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 *);
+
+ void Transform(vtkMatrix4x4* tmatrix);
+
+ bool interactorSet();
+
+
+ void enableBoundingBox(int propid, bool enable);
+
+ void saveProp3DSTL(int propid,const char* filename);
+
+private:
+ std::vector<wxMaracasSurfaceRenderingManagerData*> prop3Dvect;
+
+ vtkRenderer* _renderer;
+ vtkRenderWindowInteractor* _interactor;
+ vtkImageData* image;
+
+ int _idCount;
+
+
+
+
+};
+
+#endif
--- /dev/null
+#----------------------------------------------------------------------------
+# USER! : SET THE NAME OF YOUR LIBRARY
+# (Replace 'MyLib' by your own library name)
+
+#############################
+SET ( LIBRARY_NAME GUIQtSurfaceRenderer )
+#############################
+
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+# CREATES A USER OPTION IN CMAKE
+OPTION ( BUILD_${LIBRARY_NAME} "Build ${LIBRARY_NAME} library ?" ON)
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+IF ( BUILD_${LIBRARY_NAME} )
+#----------------------------------------------------------------------------
+
+ #----------------------------------------------------------------------------
+ # BUILD LIBRARY
+ #----------------------------------------------------------------------------
+
+ #----------------------------------------------------------------------------
+ # LIBRARY HEADERS (TO BE INSTALLED)
+ # EITHER LIST ALL .h, *.txx IN CURRENT DIR USING NEXT LINE:
+
+ FILE(GLOB ${LIBRARY_NAME}_HEADERS "*.h" "*.txx")
+
+ # OR MANUALLY LIST YOUR HEADERS WITH NEXT COMMAND
+ # SET ( ${LIBRARY_NAME}_HEADERS
+ #
+ # )
+ #----------------------------------------------------------------------------
+
+ #----------------------------------------------------------------------------
+ # LIBRARY SOURCES (TO BE COMPILED)
+ # EITHER LIST ALL .cxx, *.cpp, *.cc IN CURRENT DIR USING NEXT LINE:
+
+ FILE(GLOB ${LIBRARY_NAME}_SOURCES *.cxx *.cpp *.cc)
+
+ #SET(qtproject_UIS
+ # main_window.ui
+ #)
+ FILE(GLOB ${LIBRARY_NAME}_UIS "*.ui")
+
+ QT4_WRAP_UI(${LIBRARY_NAME}_UIS_H ${${LIBRARY_NAME}_UIS})
+ QT4_WRAP_CPP(${LIBRARY_NAME}_SOURCES ${${LIBRARY_NAME}_HEADERS})
+
+ # Don't forget to include output directory, otherwise
+ # the UI file won't be wrapped!
+
+ #message(FATAL_ERROR ${CMAKE_CURRENT_BINARY_DIR})
+ #include_directories(${QT_QTUITOOLS_INCLUDE_DIR})
+ #Now add these generated files to the ADD_EXECUTABLE step
+ # If this is NOT done, then the ui_*.h files will not be generated
+ #add_executable(qtproject ${qtproject_SRCS} ${qtproject_UIS_H} )
+
+ FILE(GLOB ${LIBRARY_NAME}_HEADERS "*.h" "*.txx" "${PROJECT_BINARY_DIR}/lib/GUI/Qt/VTK/VolumeRenderer/*.h")
+
+
+ set(${LIBRARY_NAME}_SOURCES ${${LIBRARY_NAME}_SOURCES} ${${LIBRARY_NAME}_UIS_H})
+
+ #FILE(GLOB UIS_NAME RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.ui *.qrc)
+ #FOREACH(UISFILE ${UIS_NAME})
+ # CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${UISFILE} ${CMAKE_BINARY_DIR}/${UISFILE} COPYONLY )
+ #ENDFOREACH(UISFILE)
+
+
+ #CREA_CPDIR(${INPUT_DATA_DIR} ${OUTPUT_DATA_DIR})
+ # OR MANUALLY LIST YOUR FILES WITH NEXT COMMAND (WITHOUT EXTENSION)
+ # SET ( ${LIBRARY_NAME}_SOURCES
+ #
+ # )
+ #----------------------------------------------------------------------------
+
+ #----------------------------------------------------------------------------
+ # LIBRARY DEPENDENCIES (LIBRARIES TO LINK WITH)
+ #
+ # USER! : Uncomment the Libraries you need
+ #
+ SET ( ${LIBRARY_NAME}_LINK_LIBRARIES
+ # ${crea_LIBRARIES}
+ # ${WXWIDGETS_LIBRARIES}
+ # ${KWWidgets_LIBRARIES}
+ # ${VTK_LIBRARIES}
+ # ${ITK_LIBRARIES}
+ # ${GDCM_LIBRARIES}
+ # ${BOOST_LIBRARIES}
+ ${QT_LIBRARIES}
+ BaseSurfaceRenderer
+ # If this library must link against other libraries
+ # USER! : Add here any extra Library you need
+
+ )
+#message(FATAL_ERROR "QT LIBS ${QT_LIBRARIES}")
+ #----------------------------------------------------------------------------
+
+ #----------------------------------------------------------------------------
+ # MACRO WHICH DOES ALL THE JOB : BUILD AND INSTALL
+
+ # USER! : The default is to create a Dynamic Library.
+ # if you need to create a static library
+ # comment out the following line :
+
+ SET(${LIBRARY_NAME}_INSTALL_TREE_RELATIVE_INCLUDE_PATHS include/creaMaracasVisu)
+ SET(${LIBRARY_NAME}_INSTALL_FOLDER creaMaracasVisu)
+ CREA_ADD_LIBRARY( ${LIBRARY_NAME} )
+
+ # and uncomment the 2 lines hereafter:
+
+ # ADD_LIBRARY(${LIBRARY_NAME} STATIC ${${LIBRARY_NAME}_SOURCES})
+ # TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${${LIBRARY_NAME}_LINK_LIBRARIES} )
+ #
+ #----------------------------------------------------------------------------
+
+ #---------------------------------------------------------------------------
+ENDIF ( BUILD_${LIBRARY_NAME} )
+
--- /dev/null
+#include "qtsurfacerendererpanel.h"
+#include "ui_qtsurfacerendererpanel.h"
+
+#include "qfiledialog.h"
+
+#include "qcolordialog.h"
+#include "qmessagebox.h"
+
+#include "Color.xpm"
+#include "Save.xpm"
+
+QtSurfaceRendererPanel::QtSurfaceRendererPanel(QWidget *parent) :
+ QWidget(parent),
+ ui(new Ui::QtSurfaceRendererPanel)
+{
+ ui->setupUi(this);
+
+
+ this->ui->pushButtonColorChooser->setIcon(QIcon(Color_xpm));
+ this->ui->pushButtonSave->setIcon(QIcon(Save_xpm));
+}
+
+QtSurfaceRendererPanel::~QtSurfaceRendererPanel()
+{
+ delete ui;
+}
+void QtSurfaceRendererPanel::SetImageData(vtkImageData* img){
+ this->addPropMHD(0, img, "");
+ this->enableBoundingBox(0, false);
+
+ double *range =img->GetScalarRange();
+
+ this->ui->horizontalSliderMinIso->setRange(range[0], range[1] - 1);
+
+ this->ui->horizontalSliderMaxIso->setRange(range[0] + 1, range[1]);
+}
+
+void QtSurfaceRendererPanel::on_OpacitySlider_valueChanged(int value)
+{
+ try{
+
+ this->ui->lineEditOpacity->setText(QString::number(value));
+
+
+ this->changeOpacity(0, value);
+ }catch(char * e){
+ cout<<e<<endl;
+ QMessageBox::critical(this, tr("Volume Rendering"), tr(e), QMessageBox::Ok);
+ }
+}
+
+void QtSurfaceRendererPanel::on_pushButtonColorChooser_clicked()
+{
+ QColorDialog* qcolor = new QColorDialog(this);
+
+
+
+ if(qcolor->exec()){
+
+ QColor color = qcolor->selectedColor();
+
+ int r = 0, g = 0, b = 0;
+ color.getRgb(&r, &g, &b);
+
+ try{
+
+ this->changeColor(0, r/255.0, g/255.0 ,b/255.0);
+ }catch(char * e){
+ cout<<e<<endl;
+ QMessageBox::critical(this, tr("Surface Rendering"), tr(e), QMessageBox::Ok);
+ }
+ }
+
+
+}
+
+void QtSurfaceRendererPanel::on_checkBox_clicked(bool checked)
+{
+ this->addRemoveActor(0, checked);
+}
+
+void QtSurfaceRendererPanel::on_horizontalSliderMaxIso_valueChanged(int value)
+{
+
+ this->ui->lineEditMaxIso->setText(QString::number(value));
+}
+
+void QtSurfaceRendererPanel::on_horizontalSliderMinIso_valueChanged(int value)
+{
+ this->ui->lineEditMinIso->setText(QString::number(value));
+}
+
+void QtSurfaceRendererPanel::on_horizontalSliderMaxIso_sliderReleased()
+{
+ onIsoValueChanged();
+}
+
+void QtSurfaceRendererPanel::on_horizontalSliderMinIso_sliderReleased()
+{
+ onIsoValueChanged();
+}
+
+void QtSurfaceRendererPanel::onIsoValueChanged(){
+ this->changeIsoValue(0, this->ui->horizontalSliderMinIso->value(), this->ui->horizontalSliderMaxIso->value());
+}
+
+void QtSurfaceRendererPanel::on_pushButtonSave_clicked()
+{
+ QString filename = QFileDialog::getSaveFileName(this,
+ tr("Save STL File"),
+ QDir::currentPath(),
+ tr("STL files (*.stl);") );
+
+ if( !filename.isNull() ){
+ filename.append(".stl");
+ this->saveProp3DSTL(0, filename.toStdString().c_str());
+ }
+
+}
+
+void QtSurfaceRendererPanel::on_checkBoxBoundingBox_clicked(bool checked)
+{
+ this->enableBoundingBox(0, checked);
+
+}
--- /dev/null
+#ifndef QTSURFACERENDERERPANEL_H
+#define QTSURFACERENDERERPANEL_H
+
+#include <QWidget>
+
+#include "wxMaracasSurfaceRenderingManager.h"
+#include "vtkImageData.h"
+
+namespace Ui {
+ class QtSurfaceRendererPanel;
+}
+
+class QtSurfaceRendererPanel : public QWidget, public wxMaracasSurfaceRenderingManager
+{
+ Q_OBJECT
+
+public:
+ explicit QtSurfaceRendererPanel(QWidget *parent = 0);
+ ~QtSurfaceRendererPanel();
+
+ void SetImageData(vtkImageData* img);
+
+private slots:
+
+ void on_OpacitySlider_valueChanged(int value);
+
+ void on_pushButtonColorChooser_clicked();
+
+ void on_checkBox_clicked(bool checked);
+
+ void on_horizontalSliderMaxIso_valueChanged(int value);
+
+ void on_horizontalSliderMinIso_valueChanged(int value);
+
+ void on_horizontalSliderMaxIso_sliderReleased();
+
+ void on_horizontalSliderMinIso_sliderReleased();
+
+ void on_pushButtonSave_clicked();
+
+ void on_checkBoxBoundingBox_clicked(bool checked);
+
+private:
+ Ui::QtSurfaceRendererPanel *ui;
+
+
+ void onIsoValueChanged();
+};
+
+#endif // QTSURFACERENDERERPANEL_H
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>QtSurfaceRendererPanel</class>
+ <widget class="QWidget" name="QtSurfaceRendererPanel">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>145</width>
+ <height>299</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_3">
+ <item row="0" column="0">
+ <widget class="QCheckBox" name="checkBox">
+ <property name="text">
+ <string>Show</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QCheckBox" name="checkBoxBoundingBox">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Box</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QPushButton" name="pushButtonColorChooser">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="toolTip">
+ <string>Choose the color of the actor</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="icon">
+ <iconset>
+ <normaloff>../../../../data/Icons/Color.xpm</normaloff>../../../../data/Icons/Color.xpm</iconset>
+ </property>
+ <property name="iconSize">
+ <size>
+ <width>24</width>
+ <height>24</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QPushButton" name="pushButtonSave">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="icon">
+ <iconset>
+ <normaloff>../../../../data/Icons/Save.xpm</normaloff>../../../../data/Icons/Save.xpm</iconset>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" colspan="2">
+ <widget class="Line" name="line">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0" colspan="2">
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="0" column="0">
+ <widget class="QLabel" name="LabelOpacity">
+ <property name="text">
+ <string>Opacity</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLineEdit" name="lineEditOpacity">
+ <property name="text">
+ <string>100</string>
+ </property>
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" colspan="2">
+ <widget class="QSlider" name="OpacitySlider">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="maximum">
+ <number>100</number>
+ </property>
+ <property name="value">
+ <number>100</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="4" column="0" colspan="2">
+ <widget class="Line" name="line_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0" colspan="2">
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0" colspan="2">
+ <widget class="QLabel" name="labelIsoValue">
+ <property name="midLineWidth">
+ <number>0</number>
+ </property>
+ <property name="text">
+ <string>Iso Values</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Min</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLineEdit" name="lineEditMinIso">
+ <property name="text">
+ <string>0</string>
+ </property>
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" colspan="2">
+ <widget class="QSlider" name="horizontalSliderMinIso">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Max</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QLineEdit" name="lineEditMaxIso">
+ <property name="text">
+ <string>100</string>
+ </property>
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0" colspan="2">
+ <widget class="QSlider" name="horizontalSliderMaxIso">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>100</number>
+ </property>
+ <property name="value">
+ <number>100</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>checkBox</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>checkBoxBoundingBox</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>43</x>
+ <y>18</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>136</x>
+ <y>21</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>checkBox</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>pushButtonColorChooser</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>64</x>
+ <y>22</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>48</x>
+ <y>55</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>checkBox</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>pushButtonSave</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>56</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>216</x>
+ <y>50</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>checkBox</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>OpacitySlider</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>43</x>
+ <y>19</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>73</x>
+ <y>125</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>checkBox</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>horizontalSliderMinIso</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>36</x>
+ <y>15</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>28</x>
+ <y>367</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>checkBox</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>horizontalSliderMaxIso</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>42</x>
+ <y>22</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>92</x>
+ <y>434</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
--- /dev/null
+ #----------------------------------------------------------------------------
+# USER! : SET THE NAME OF YOUR LIBRARY
+# (Replace 'MyLib' by your own library name)
+
+#############################
+SET ( LIBRARY_NAME GUIWxSurfaceRenderer )
+#############################
+
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+# CREATES A USER OPTION IN CMAKE
+OPTION ( BUILD_${LIBRARY_NAME} "Build ${LIBRARY_NAME} library ?" ON)
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+IF ( BUILD_${LIBRARY_NAME} )
+#----------------------------------------------------------------------------
+
+ #----------------------------------------------------------------------------
+ # BUILD LIBRARY
+ #----------------------------------------------------------------------------
+
+ #----------------------------------------------------------------------------
+ # LIBRARY HEADERS (TO BE INSTALLED)
+ # EITHER LIST ALL .h, *.txx IN CURRENT DIR USING NEXT LINE:
+
+ FILE(GLOB ${LIBRARY_NAME}_HEADERS *.h *.txx)
+
+ # OR MANUALLY LIST YOUR HEADERS WITH NEXT COMMAND
+ # SET ( ${LIBRARY_NAME}_HEADERS
+ #
+ # )
+ #----------------------------------------------------------------------------
+
+ #----------------------------------------------------------------------------
+ # LIBRARY SOURCES (TO BE COMPILED)
+ # EITHER LIST ALL .cxx, *.cpp, *.cc IN CURRENT DIR USING NEXT LINE:
+
+ FILE(GLOB ${LIBRARY_NAME}_SOURCES *.cxx *.cpp *.cc ${${LIBRARY_NAME}_HEADERS})
+
+ # OR MANUALLY LIST YOUR FILES WITH NEXT COMMAND (WITHOUT EXTENSION)
+ # SET ( ${LIBRARY_NAME}_SOURCES
+ #
+ # )
+ #----------------------------------------------------------------------------
+
+ #----------------------------------------------------------------------------
+ # LIBRARY DEPENDENCIES (LIBRARIES TO LINK WITH)
+ #
+ # USER! : Uncomment the Libraries you need
+ #
+ SET ( ${LIBRARY_NAME}_LINK_LIBRARIES
+ # ${crea_LIBRARIES}
+ ${WXWIDGETS_LIBRARIES}
+ # ${KWWidgets_LIBRARIES}
+ # ${VTK_LIBRARIES}
+ # ${ITK_LIBRARIES}
+ # ${GDCM_LIBRARIES}
+ # ${BOOST_LIBRARIES}
+ KernelSurfaceRenderer
+
+ # If this library must link against other libraries
+ # USER! : Add here any extra Library you need
+
+ )
+ #----------------------------------------------------------------------------
+
+ #----------------------------------------------------------------------------
+ # MACRO WHICH DOES ALL THE JOB : BUILD AND INSTALL
+
+ # USER! : The default is to create a Dynamic Library.
+ # if you need to create a static library
+ # comment out the following line :
+
+ SET(${LIBRARY_NAME}_INSTALL_TREE_RELATIVE_INCLUDE_PATHS include/creaMaracasVisu)
+ SET(${LIBRARY_NAME}_INSTALL_FOLDER creaMaracasVisu)
+ CREA_ADD_LIBRARY( ${LIBRARY_NAME} )
+ SET_TARGET_PROPERTIES(${LIBRARY_NAME} PROPERTIES LINKER_LANGUAGE C)
+
+ # and uncomment the 2 lines hereafter:
+
+ # ADD_LIBRARY(${LIBRARY_NAME} STATIC ${${LIBRARY_NAME}_SOURCES})
+ # TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${${LIBRARY_NAME}_LINK_LIBRARIES} )
+
+ #
+ #----------------------------------------------------------------------------
+
+ #---------------------------------------------------------------------------
+ENDIF ( BUILD_${LIBRARY_NAME} )
--- /dev/null
+/*=========================================================================
+
+ Program: wxMaracas
+ Module: $RCSfile: wxMaracasSurfaceRendering.cxx,v $
+ Language: C++
+ Date: $Date: 2011/06/28 16:56:16 $
+ Version: $Revision: 1.1 $
+
+ 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 "wxMaracasSurfaceRendering.h"
+#include "wxMaracasSurfaceRenderingProp3DMHD.h"
+#include "wxMaracasSurfaceRenderingProp3D.h"
+
+#include <wx/colordlg.h>
+#include <wx/bmpbuttn.h>
+
+#include <OpenImage.xpm>
+#include <Color.xpm>
+
+wxMaracasSurfaceRendering* wxMaracasSurfaceRendering::instance=NULL;
+
+wxMaracasSurfaceRendering::wxMaracasSurfaceRendering( wxWindow* parent,std::string path)
+: wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize){
+
+ surrendmanager = new wxMaracasSurfaceRenderingManager();
+
+ wxauimanager = new wxAuiManager(this);
+
+ _path = path;
+
+ std::string iconsdir = path;
+ iconsdir+="/data/Icons";
+ this->_toolb = new ToolBar(this,iconsdir);
+
+ wxStaticText* txt = new wxStaticText(this, -1, wxString(_T(" Surface Rendering ")));
+ wxAuiPaneInfo paneinfo;
+ wxauimanager->AddPane(txt,paneinfo.ToolbarPane().Top());
+ wxauimanager->AddPane(_toolb,paneinfo.ToolbarPane().Top());
+
+ wxauimanager->Update();
+ createFileChooser();
+}
+wxMaracasSurfaceRendering::~wxMaracasSurfaceRendering( ){
+ delete _toolb;
+}
+
+std::string wxMaracasSurfaceRendering::getPath(){
+ return _path;
+}
+
+void wxMaracasSurfaceRendering::createFileChooser(){
+
+}
+
+wxMaracasSurfaceRendering* wxMaracasSurfaceRendering::getInstance(wxWindow* parent,std::string path){
+ if(instance==NULL){
+ instance = new wxMaracasSurfaceRendering(parent,path);
+ }
+ return instance;
+}
+
+wxMaracasSurfaceRendering* wxMaracasSurfaceRendering::getInstance(){
+ return instance;
+}
+
+void wxMaracasSurfaceRendering::setRenderer(vtkRenderer* renderer){
+ surrendmanager->setRenderer(renderer);
+}
+
+void wxMaracasSurfaceRendering::setInteractor(vtkRenderWindowInteractor* interactor){
+ surrendmanager->setInteractor(interactor);
+}
+
+void wxMaracasSurfaceRendering::addRemoveActor(int propid, bool addremove){
+ try{
+ surrendmanager->addRemoveActor(propid, addremove);
+ }
+ catch(char* str){
+ std::cout << "Exception : " << str << '\n';
+ wxMessageDialog* diag = new wxMessageDialog(this, wxString(str,wxConvUTF8 ), wxString(str,wxConvUTF8 ), wxICON_ERROR);
+ diag->ShowModal();
+ delete diag;
+ }
+}
+void wxMaracasSurfaceRendering::addRemoveSurfaceBox(int propid, bool addremove){
+ try{
+ surrendmanager->addRemoveSurfaceBox(propid, addremove);
+ }
+ catch(char* str){
+ std::cout << "Exception : " << str << '\n';
+ wxMessageDialog* diag = new wxMessageDialog(this, wxString(str,wxConvUTF8 ), wxString(str,wxConvUTF8 ), wxICON_ERROR);
+ diag->ShowModal();
+ delete diag;
+ }
+}
+
+
+void wxMaracasSurfaceRendering::changeOpacity(int _propid, int value){
+ try{
+ surrendmanager->changeOpacity(_propid,value);
+ }
+ catch(char* str){
+ std::cout << "Exception : " << str << '\n';
+ wxMessageDialog* diag = new wxMessageDialog(this, wxString(str,wxConvUTF8 ), wxString(str,wxConvUTF8 ), wxICON_ERROR);
+ diag->ShowModal();
+ delete diag;
+ }
+}
+
+void wxMaracasSurfaceRendering::changeIsoValue(int propid, double value){
+ try{
+ surrendmanager->changeIsoValue(propid, value);
+ }
+ catch(char* str){
+ std::cout << "Exception : " << str << '\n';
+ wxMessageDialog* diag = new wxMessageDialog(this, wxString(str,wxConvUTF8 ), wxString(str,wxConvUTF8 ), wxICON_ERROR);
+ diag->ShowModal();
+ delete diag;
+ }
+}
+
+void wxMaracasSurfaceRendering::changeColor(int propid, double red, double green, double blue){
+ try{
+ surrendmanager->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 wxMaracasSurfaceRendering::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 wxMaracasSurfaceRendering::loadPropMHD(wxString filename, wxString dataname){
+
+ std::string s = std::string(filename.mb_str());
+ vtkImageData* img = surrendmanager->getImageData(s);
+ if(img!=NULL){
+ s = std::string(dataname.mb_str());
+ addPropMHD(img, s);
+ }
+}
+
+void wxMaracasSurfaceRendering::addPropMHD(vtkImageData* imgdata, std::string dataname){
+ try{
+ int id = surrendmanager->addPropMHD(-1, imgdata,dataname);
+ if(id!=-1){
+
+ wxMaracasSurfaceRenderingPanel* controlpan = new wxMaracasSurfaceRenderingProp3DMHD(this, id, false, -1);
+ int maxiso = surrendmanager->getMaxIsoValue(id);
+ ((wxMaracasSurfaceRenderingProp3DMHD*)controlpan)->createControls(maxiso);
+ addSurfaceRenderingPanel(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();
+ delete diag;
+ }
+}
+
+void wxMaracasSurfaceRendering::loadProp3D(wxString filename, wxString dataname){
+ std::string s = std::string(filename.mb_str());
+ vtkProp3D* prop3D = surrendmanager->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 wxMaracasSurfaceRendering::addProp3D(vtkProp3D* prop3D, std::string dataname){
+ try{
+ int id = surrendmanager->addProp3D(-1, prop3D,dataname);
+ if(id!=-1){
+ wxMaracasSurfaceRenderingPanel* controlpan = new wxMaracasSurfaceRenderingProp3D(this, id, false, -1);
+ addSurfaceRenderingPanel(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();
+ delete diag;
+ }
+}
+void wxMaracasSurfaceRendering::addSurfaceRenderingPanel(wxMaracasSurfaceRenderingPanel* surrend, std::string dataname){
+
+ wxString s(dataname.c_str(),wxConvUTF8 );
+ wxAuiPaneInfo paneinfo;
+ wxauimanager->AddPane(surrend, paneinfo.DefaultPane().Centre().DestroyOnClose().Caption(s));
+ wxauimanager->Update();
+}
+
+void wxMaracasSurfaceRendering::deleteActor(int propid){
+ try{
+ surrendmanager->deleteActor(propid);
+ }catch(char* str){
+ //CPR
+ std::cout << "Exception : " << str << '\n';
+ wxMessageDialog* diag = new wxMessageDialog(this, wxString(str,wxConvUTF8 ), wxString(str,wxConvUTF8 ), wxICON_ERROR);
+ diag->ShowModal();
+ delete diag;
+ }
+}
+
+bool wxMaracasSurfaceRendering::interactorSet(){
+ return surrendmanager->interactorSet();
+}
+
+/**
+**
+**/
+
+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, NULL, wxITEM_NORMAL, wxString(_T("Open File")));
+
+ /*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){
+ wxMaracasSurfaceRendering::getInstance()->onLoadImageFile();
+}
+
+
+BEGIN_EVENT_TABLE(ToolBarEventHandler, wxEvtHandler)
+ EVT_MENU(1, ToolBarEventHandler::onLoadImageFile)
+END_EVENT_TABLE()
+
+
--- /dev/null
+/*=========================================================================
+
+ Program: wxMaracas
+ Module: $RCSfile: wxMaracasSurfaceRendering.h,v $
+ Language: C++
+ Date: $Date: 2011/06/28 16:56:16 $
+ Version: $Revision: 1.1 $
+
+ 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 __wxMaracasSurfaceRenderingPanelH__
+#define __wxMaracasSurfaceRenderingPanelH__
+
+#include <vector>
+#include <wx/wx.h>
+#include "wx/aui/aui.h"
+#include <iostream>
+#include "marTypes.h"
+#include "vtkProp3D.h"
+
+#include "wxMaracasSurfaceRenderingManager.h"
+#include "wxMaracasSurfaceRenderingPanel.h"
+
+class creaMaracasVisu_EXPORT wxMaracasSurfaceRendering : public wxPanel
+{
+
+public:
+ wxMaracasSurfaceRendering( wxWindow* parent, std::string path);
+ ~wxMaracasSurfaceRendering( );
+
+ static wxMaracasSurfaceRendering* getInstance(wxWindow* parent,std::string path="");
+
+ static wxMaracasSurfaceRendering* getInstance();
+
+ void setRenderer(vtkRenderer* renderer);
+
+ void setInteractor(vtkRenderWindowInteractor* interactor);
+
+ void changeOpacity(int propid, int value);
+
+ void changeIsoValue(int propid, double value);
+
+ void addRemoveActor(int propid, bool addremove);
+
+ void addRemoveSurfaceBox(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 addSurfaceRenderingPanel(wxMaracasSurfaceRenderingPanel* surrend, std::string dataname="");
+
+ std::string getPath();
+
+ void deleteActor(int propid);
+
+ bool interactorSet();
+
+private:
+ static wxMaracasSurfaceRendering* instance;
+
+ wxMaracasSurfaceRenderingManager* surrendmanager;
+
+ wxAuiManager* wxauimanager;
+
+ wxToolBar* _toolb;
+
+ std::string _path;
+
+ void createFileChooser();
+};
+
+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
+#ifndef WXMARACASSURFACERENDERINGPANEL_H_
+#define WXMARACASSURFACERENDERINGPANEL_H_
+
+#include "wx/wx.h"
+
+class wxMaracasSurfaceRenderingPanel : public wxPanel{
+public:
+ wxMaracasSurfaceRenderingPanel(wxWindow* parent, int propid, bool _isComplexBox, int _panID)
+ : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize){
+ createPanel();
+ isComplexBox = _isComplexBox;
+ panID = _panID;
+ _propid = propid;
+ }
+ //virtual ~wxMaracasSurfaceRenderingPanel();
+ 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)&wxMaracasSurfaceRenderingPanel::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)&wxMaracasSurfaceRenderingPanel::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<(int)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;
+ }
+
+ /**
+ ** Returns the papnel id
+ **/
+ int getPanId(){
+ return panID;
+ }
+
+ /**
+ ** Tells if the panel is used for a complex box
+ **/
+ bool isComplex(){
+ return isComplexBox;
+ }
+
+private:
+ wxBoxSizer* sizercontrols;
+ bool show;
+protected:
+ int _propid;
+
+ //-- Atributes added for complex box --//
+ bool isComplexBox;
+ int panID;
+};
+
+#endif /*WXMARACASSURFACERENDERINGPANEL_H_*/
--- /dev/null
+#include "wxMaracasSurfaceRenderingProp3D.h"
+#include "wxMaracasDialog_NViewers.h"
+
+#include <wx/colordlg.h>
+#include "wxMaracasSurfaceRendering.h"
+#include "wxMaracasRendererView.h"
+
+#include "vtkImageData.h"
+
+#include <OpenImage.xpm>
+#include <Add.xpm>
+#include "Color.xpm"
+
+/**
+** Implementation of viewProp3D
+**/
+wxMaracasSurfaceRenderingProp3D::wxMaracasSurfaceRenderingProp3D(wxWindow* parent, int propid, bool _isComplexBox, int _panID)
+:wxMaracasSurfaceRenderingPanel(parent, propid, _isComplexBox, _panID){
+ createControls();
+}
+
+/**
+** Panel Destructor
+**/
+wxMaracasSurfaceRenderingProp3D::~wxMaracasSurfaceRenderingProp3D(){
+ //wxMaracasSurfaceRendering::getInstance()->addRemoveActor(_propid, false);
+ if(this->isComplex())
+ {
+ //if(this->getPanId() == 1)
+ // ((wxMaracasRenderTabbedPanel*)(wxMaracasRendererView::getInstance())->getTabbedPanel())->addRemoveActorSA(_propid, false);
+ //if(this->getPanId() == 2)
+ // ((wxMaracasRenderTabbedPanel*)(wxMaracasRendererView::getInstance())->getTabbedPanel())->addRemoveActorSB(_propid, false);
+ //if(this->getPanId() == 3)
+ // ((wxMaracasRenderTabbedPanel*)(wxMaracasRendererView::getInstance())->getTabbedPanel())->addRemoveActorSC(_propid, false);
+ }
+ //else
+ //wxMaracasSurfaceRendering::getInstance()->deleteActor(_propid);
+}
+
+/**
+** Constructs the panel. Elements inside may change depending on which tipe of panel construction if being requested
+**/
+void wxMaracasSurfaceRenderingProp3D::createControls(){
+
+ wxFlexGridSizer* sizersurfprop = new wxFlexGridSizer(1);
+
+ if(!isComplexBox)
+ {
+ //wxString choices[2];
+ //choices[0] = wxString(_T("On"));
+ //choices[1] = wxString(_T("Off"));
+ wxFlexGridSizer* checkboxsizer = new wxFlexGridSizer(2);
+
+ checkbox = new wxCheckBox(this,-1,wxString(_T("Show Actor")));
+ Connect(checkbox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&wxMaracasSurfaceRenderingProp3D::onCheckBoxChange);
+ checkbox->SetValue(true);
+ checkboxsizer->Add(checkbox,1, wxGROW);
+
+
+ if(wxMaracasSurfaceRendering::getInstance()->interactorSet()){
+ checkboxsurface = new wxCheckBox(this,-1,wxString(_T("Surface Box")));
+ Connect(checkboxsurface->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&wxMaracasSurfaceRenderingProp3D::onCheckBoxSurfaceChange);
+ checkboxsurface->SetValue(true);
+ checkboxsizer->Add(checkboxsurface,1, wxGROW);
+ }
+
+
+ sizersurfprop->Add(checkboxsizer,1, wxGROW);
+ }
+
+ //this->addControl(checkbox);
+ wxFlexGridSizer* sizerbut = new wxFlexGridSizer(3);
+
+ wxBitmap bitmap(Color_xpm);
+ _colorchoose = new wxBitmapButton(this, -1, bitmap,wxDefaultPosition,wxSize(30,30));
+ Connect(_colorchoose->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasSurfaceRenderingProp3D::onColorChange);
+ sizerbut->Add(_colorchoose,1, wxGROW);
+
+ /*
+ wxBitmap bitmap1(Add_xpm);
+ _viewimage = new wxBitmapButton(this, -1, bitmap1, wxDefaultPosition, wxSize(30,30));
+ Connect(_viewimage->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasSurfaceRenderingProp3D::onViewImage);
+ sizerbut->Add(_viewimage,wxFIXED_MINSIZE);
+ */
+ sizersurfprop->Add(sizerbut,1, wxGROW);
+ //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)&wxMaracasSurfaceRenderingProp3D::onOpacityRelease);
+ wxFlexGridSizer* sizeropacity = new wxFlexGridSizer(1,1,1);
+ sizeropacity->Add(label,1, wxGROW);
+ sizeropacity->Add(opacity,1, wxGROW);
+
+ sizersurfprop->Add(sizeropacity,1, wxGROW);
+
+ this->addControl(sizersurfprop);
+
+}
+
+/**
+** Method called by setting on or off the actor
+**/
+void wxMaracasSurfaceRenderingProp3D::onCheckBoxChange(wxCommandEvent& event){
+ //if(!isComplexBox)
+ wxMaracasSurfaceRendering::getInstance()->addRemoveActor(this->getPropId(), checkbox->GetValue());
+}
+void wxMaracasSurfaceRenderingProp3D::onCheckBoxSurfaceChange(wxCommandEvent& event){
+ //if(!isComplexBox)
+ wxMaracasSurfaceRendering::getInstance()->addRemoveSurfaceBox(this->getPropId(), checkboxsurface->GetValue());
+}
+
+/**
+**
+**/
+void wxMaracasSurfaceRenderingProp3D::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;
+
+ if(this->isComplex()){
+ if(this->getPanId() == 1)
+ ( (wxMaracasRendererView::getInstance())->getTabbedPanel(getPropId()) )->changeColorA(this->getPropId(), r, g, b);
+ if(this->getPanId() == 2)
+ ( (wxMaracasRendererView::getInstance())->getTabbedPanel(getPropId()) )->changeColorB(this->getPropId(), r, g, b);
+ if(this->getPanId() == 3)
+ ( (wxMaracasRendererView::getInstance())->getTabbedPanel(getPropId()) )->changeColorC(this->getPropId(), r, g, b);
+ }
+ else
+ wxMaracasSurfaceRendering::getInstance()->changeColor(this->getPropId(),r,g,b);
+ }
+ delete colourdiag;
+}
+/*void wxMaracasSurfaceRenderingProp3D::onActionButtonPressedEliminate( wxCommandEvent& event ){
+
+}*/
+
+/**
+** Changes the opacity of an actor
+**/
+void wxMaracasSurfaceRenderingProp3D::onOpacityRelease(wxScrollEvent& event ){
+
+ if(this->isComplex()){
+ if(this->getPanId() == 1)
+ ( (wxMaracasRendererView::getInstance())->getTabbedPanel(getPropId()) )->changeOpacityA(this->getPropId(),opacity->GetValue());
+ if(this->getPanId() == 2)
+ ( (wxMaracasRendererView::getInstance())->getTabbedPanel(getPropId()) )->changeOpacityB(this->getPropId(),opacity->GetValue());
+ if(this->getPanId() == 3)
+ ( (wxMaracasRendererView::getInstance())->getTabbedPanel(getPropId()) )->changeOpacityC(this->getPropId(),opacity->GetValue());
+ }
+ else
+ wxMaracasSurfaceRendering::getInstance()->changeOpacity(this->getPropId(),opacity->GetValue());
+
+}
+
+/**Carolina Perez: Method recently added. Not functionalit yet
+** Loads the volume in a separate window
+**/
+void wxMaracasSurfaceRenderingProp3D::onViewImage(wxCommandEvent& event){
+ vtkImageData* img;
+ if(this->isComplexBox){
+ if(this->getPanId() == 1)
+ img = (wxMaracasRendererView::getInstance())->getTabbedPanel(_propid)->getSurfAImage();
+ if(this->getPanId() == 2)
+ img = (wxMaracasRendererView::getInstance())->getTabbedPanel(_propid)->getSurfBImage();
+ if(this->getPanId() == 3)
+ img = (wxMaracasRendererView::getInstance())->getTabbedPanel(_propid)->getSurfCImage();
+
+ std::vector<int> type;
+ type.push_back(6);
+
+ wxMaracasDialog_NViewers* dialog1 = new wxMaracasDialog_NViewers(this, img, &type, wxString(_T("Volume Visualization") ));
+ dialog1->SetSize(730, 700);
+ dialog1->Show();
+ }
+ else{
+ //vtkImageData* img = wxMaracasMultipleVolumeRendererView::getInstance()->getVolImage();
+ }
+}
\ No newline at end of file
--- /dev/null
+#ifndef WXMARACASSURFACERENDERINGPROP3D_H_
+#define WXMARACASSURFACERENDERINGPROP3D_H_
+
+#include "wxMaracasSurfaceRenderingPanel.h"
+//#include "wxMaracasRenderImageManagementPanel.h"
+
+class wxMaracasSurfaceRenderingProp3D : public wxMaracasSurfaceRenderingPanel{
+public:
+ wxMaracasSurfaceRenderingProp3D(wxWindow* parent, int propid, bool _isComplexBox, int _panID);
+ ~wxMaracasSurfaceRenderingProp3D();
+ virtual void createControls();
+ void onOpacityRelease(wxScrollEvent& event);
+ void onCheckBoxChange(wxCommandEvent& event);
+ void onCheckBoxSurfaceChange(wxCommandEvent& event);
+ void onColorChange(wxCommandEvent& event);
+ void onViewImage(wxCommandEvent& event);
+
+
+private:
+ wxCheckBox* checkbox;
+ wxCheckBox* checkboxsurface;
+ wxSlider* opacity;
+ wxBitmapButton* _colorchoose;
+ wxBitmapButton* _viewimage;
+ //wxMaracasRenderImageManagementPanel* dialog;
+};
+
+#endif /*WXMARACASSURFACERENDERINGPROP3D_H_*/
--- /dev/null
+#include "wxMaracasSurfaceRenderingProp3DMHD.h"
+
+#include "wxMaracasSurfaceRendering.h"
+#include "wxMaracasRendererView.h"
+#include <OpenImage.xpm>
+/**
+** SurfaceRenderingProp3DMHD implementation
+**/
+wxMaracasSurfaceRenderingProp3DMHD::wxMaracasSurfaceRenderingProp3DMHD(wxWindow* parent, int propid, bool _isComplexBox, int _panID)
+: wxMaracasSurfaceRenderingProp3D(parent, propid, _isComplexBox, _panID){
+
+}
+wxMaracasSurfaceRenderingProp3DMHD::~wxMaracasSurfaceRenderingProp3DMHD(){
+ //this->Show(false);
+ if(this->isComplex())
+ {
+ //if(this->getPanId() == 1)
+ // ((wxMaracasRenderTabbedPanel*)(wxMaracasRendererView::getInstance())->getTabbedPanel())->addRemoveActorSA(_propid, false);
+ //if(this->getPanId() == 2)
+ // ((wxMaracasRenderTabbedPanel*)(wxMaracasRendererView::getInstance())->getTabbedPanel())->addRemoveActorSB(_propid, false);
+ //if(this->getPanId() == 3)
+ // ((wxMaracasRenderTabbedPanel*)(wxMaracasRendererView::getInstance())->getTabbedPanel())->addRemoveActorSC(_propid, false);
+ }
+ //else
+ //wxMaracasSurfaceRendering::getInstance()->addRemoveActor(_propid, false);
+}
+void wxMaracasSurfaceRenderingProp3DMHD::createControls(int maxisovalue){
+
+ wxFlexGridSizer* sizer = new wxFlexGridSizer(1,1,1);
+
+ wxStaticText* label = new wxStaticText(this, -1, wxString(_T("IsoValue")));
+ sizer->Add(label, 1, wxGROW);
+ //this->addControl(label);
+ isovalue = new wxSlider(this, -1,maxisovalue,0,maxisovalue,wxDefaultPosition,wxDefaultSize,wxSL_HORIZONTAL|wxSL_LABELS);
+ sizer->Add(isovalue, 1, wxGROW);
+ //this->addControl(isovalue);
+
+ this->addControl(sizer);
+ Connect(isovalue->GetId(), wxEVT_SCROLL_CHANGED, (wxObjectEventFunction)&wxMaracasSurfaceRenderingProp3DMHD::onIsoValueRelease);
+
+}
+
+void wxMaracasSurfaceRenderingProp3DMHD::onIsoValueRelease(wxScrollEvent& event )
+{
+ if(this->isComplex())
+ {
+ if(this->getPanId() == 1)
+ ( (wxMaracasRendererView::getInstance())->getTabbedPanel(getPropId()) )->changeIsoValueA(this->getPropId(),isovalue->GetValue()/1.0);
+ if(this->getPanId() == 2)
+ ( (wxMaracasRendererView::getInstance())->getTabbedPanel(getPropId()) )->changeIsoValueB(this->getPropId(),isovalue->GetValue()/1.0);
+ if(this->getPanId() == 3)
+ ( (wxMaracasRendererView::getInstance())->getTabbedPanel(getPropId()) )->changeIsoValueC(this->getPropId(),isovalue->GetValue()/1.0);
+ }
+ else
+ wxMaracasSurfaceRendering::getInstance()->changeIsoValue(this->getPropId(), isovalue->GetValue()/1.0);
+
+}
+
+void wxMaracasSurfaceRenderingProp3DMHD::onViewImage(wxCommandEvent& event){
+
+ //if(mwxwidget->ShowModal()==wxID_OK){
+
+ // mwxwidget->Show(false);
+ //}
+}
+
--- /dev/null
+#ifndef WXMARACASSURFACERENDERINGPROP3DMHD_H_
+#define WXMARACASSURFACERENDERINGPROP3DMHD_H_
+
+#include "wxMaracasSurfaceRenderingProp3D.h"
+
+class wxMaracasSurfaceRenderingProp3DMHD : public wxMaracasSurfaceRenderingProp3D{
+public:
+ wxMaracasSurfaceRenderingProp3DMHD(wxWindow* parent, int propid, bool _isComplexBox, int _panID);
+ ~wxMaracasSurfaceRenderingProp3DMHD();
+ void onIsoValueRelease(wxScrollEvent& event );
+ void createControls(int maxisovalue);
+ void onViewImage(wxCommandEvent& event);
+
+private:
+ wxSlider* isovalue;
+ wxBitmapButton* _viewimage;
+ int _propid;
+
+};
+
+#endif /*WXMARACASSURFACERENDERINGPROP3DMHD_H_*/
--- /dev/null
+#----------------------------------------------------------------------------
+# USER! : SET THE NAME OF YOUR LIBRARY
+# (Replace 'MyLib' by your own library name)
+
+#############################
+SET ( LIBRARY_NAME KernelSurfaceRenderer )
+#############################
+
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+# CREATES A USER OPTION IN CMAKE
+OPTION ( BUILD_${LIBRARY_NAME} "Build ${LIBRARY_NAME} library ?" ON)
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+IF ( BUILD_${LIBRARY_NAME} )
+#----------------------------------------------------------------------------
+
+ #----------------------------------------------------------------------------
+ # BUILD LIBRARY
+ #----------------------------------------------------------------------------
+
+ #----------------------------------------------------------------------------
+ # LIBRARY HEADERS (TO BE INSTALLED)
+ # EITHER LIST ALL .h, *.txx IN CURRENT DIR USING NEXT LINE:
+
+ FILE(GLOB ${LIBRARY_NAME}_HEADERS "*.h" "*.txx")
+
+ # OR MANUALLY LIST YOUR HEADERS WITH NEXT COMMAND
+ # SET ( ${LIBRARY_NAME}_HEADERS
+ #
+ # )
+ #----------------------------------------------------------------------------
+
+ #----------------------------------------------------------------------------
+ # LIBRARY SOURCES (TO BE COMPILED)
+ # EITHER LIST ALL .cxx, *.cpp, *.cc IN CURRENT DIR USING NEXT LINE:
+
+ FILE(GLOB ${LIBRARY_NAME}_SOURCES *.cxx *.cpp *.cc )
+
+ set(${LIBRARY_NAME}_SOURCES ${${LIBRARY_NAME}_SOURCES} ${${LIBRARY_NAME}_HEADERS})
+
+ #SET(qtproject_UIS
+ # main_window.ui
+ #)
+ #FILE(GLOB ${LIBRARY_NAME}_UIS "*.ui")
+
+ #QT4_WRAP_UI(${LIBRARY_NAME}_UIS_H ${${LIBRARY_NAME}_UIS})
+ #QT4_WRAP_CPP(${LIBRARY_NAME}_SOURCES ${${LIBRARY_NAME}_HEADERS})
+
+ # Don't forget to include output directory, otherwise
+ # the UI file won't be wrapped!
+
+ #message(FATAL_ERROR ${CMAKE_CURRENT_BINARY_DIR})
+ #include_directories(${QT_QTUITOOLS_INCLUDE_DIR})
+ #Now add these generated files to the ADD_EXECUTABLE step
+ # If this is NOT done, then the ui_*.h files will not be generated
+ #add_executable(qtproject ${qtproject_SRCS} ${qtproject_UIS_H} )
+
+ #set(${LIBRARY_NAME}_SOURCES ${${LIBRARY_NAME}_SOURCES} ${${LIBRARY_NAME}_UIS_H})
+
+ #FILE(GLOB UIS_NAME RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.ui *.qrc)
+ #FOREACH(UISFILE ${UIS_NAME})
+ # CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${UISFILE} ${CMAKE_BINARY_DIR}/${UISFILE} COPYONLY )
+ #ENDFOREACH(UISFILE)
+
+
+ #CREA_CPDIR(${INPUT_DATA_DIR} ${OUTPUT_DATA_DIR})
+ # OR MANUALLY LIST YOUR FILES WITH NEXT COMMAND (WITHOUT EXTENSION)
+ # SET ( ${LIBRARY_NAME}_SOURCES
+ #
+ # )
+ #----------------------------------------------------------------------------
+
+ #----------------------------------------------------------------------------
+ # LIBRARY DEPENDENCIES (LIBRARIES TO LINK WITH)
+ #
+ # USER! : Uncomment the Libraries you need
+ #
+ SET ( ${LIBRARY_NAME}_LINK_LIBRARIES
+ # ${crea_LIBRARIES}
+ # ${WXWIDGETS_LIBRARIES}
+ # ${KWWidgets_LIBRARIES}
+ ${VTK_LIBRARIES}
+ creaMaracasVisu
+ #${ITK_LIBRARIES}
+ # ${GDCM_LIBRARIES}
+ # ${BOOST_LIBRARIES}
+
+ # If this library must link against other libraries
+ # USER! : Add here any extra Library you need
+
+ )
+#message(FATAL_ERROR "QT LIBS ${QT_LIBRARIES}")
+ #----------------------------------------------------------------------------
+
+ #----------------------------------------------------------------------------
+ # MACRO WHICH DOES ALL THE JOB : BUILD AND INSTALL
+
+ # USER! : The default is to create a Dynamic Library.
+ # if you need to create a static library
+ # comment out the following line :
+
+ SET(${LIBRARY_NAME}_INSTALL_TREE_RELATIVE_INCLUDE_PATHS include/creaMaracasVisu)
+ SET(${LIBRARY_NAME}_INSTALL_FOLDER creaMaracasVisu)
+ CREA_ADD_LIBRARY( ${LIBRARY_NAME})
+SET_TARGET_PROPERTIES(${LIBRARY_NAME} PROPERTIES LINKER_LANGUAGE C)
+
+ # and uncomment the 2 lines hereafter:
+
+ # ADD_LIBRARY(${LIBRARY_NAME} STATIC ${${LIBRARY_NAME}_SOURCES})
+ # TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${${LIBRARY_NAME}_LINK_LIBRARIES} )
+ #
+ #----------------------------------------------------------------------------
+
+ #---------------------------------------------------------------------------
+ENDIF ( BUILD_${LIBRARY_NAME} )
+
--- /dev/null
+
+#include "wxMaracasSurfaceRenderingManagerData.h"
+
+#include <vtkSmartPointer.h>
+#include "vtkSTLWriter.h"
+
+/********************************************************************************************
+** Start of data viewmanagerData
+*********************************************************************************************/
+
+wxMaracasSurfaceRenderingManagerData::wxMaracasSurfaceRenderingManagerData(vtkProp3D* prop3Dvect, std::string dataname, vtkRenderWindowInteractor* interactor){
+
+ _dataMapper = 0;
+ _prop3D = prop3Dvect;
+ _dataname = dataname;
+ _boxWidgetS1=NULL;
+
+ initializeBoxWidget(interactor);
+
+
+
+
+ /*_boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(0) );
+ _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(1) );
+ _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(2) );
+ _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(3) );*/
+}
+
+
+wxMaracasSurfaceRenderingManagerData::~wxMaracasSurfaceRenderingManagerData(){
+
+ _prop3D->Delete();
+ if (_boxWidgetS1!=NULL) { _boxWidgetS1 -> Delete(); }
+}
+
+void wxMaracasSurfaceRenderingManagerData::initializeBoxWidget(vtkRenderWindowInteractor* interactor){
+ if(interactor!= NULL){
+
+ }
+}
+
+/**
+** Adds a prop3D to the world of the application
+**/
+void wxMaracasSurfaceRenderingManagerData::setProp3D(vtkProp3D* prop3D){
+ _prop3D = prop3D;
+}
+
+void wxMaracasSurfaceRenderingManagerData::addRemoveSurfaceBox(bool visible)
+{
+ if(_boxWidgetS1){
+ if (visible==true){
+ _boxWidgetS1->On();
+ } else {
+ _boxWidgetS1->Off();
+ }
+ }
+}
+/**
+** Changes the opacity in a prop3D
+**/
+void wxMaracasSurfaceRenderingManagerData::changeOpacity(int value){
+ std::cout<<"chage op"<<value<<std::endl;
+ vtkActor* actor = (vtkActor*)this->_prop3D;
+ actor->GetProperty()->SetOpacity((double)value/100.0);
+
+
+
+}
+void wxMaracasSurfaceRenderingManagerData::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 wxMaracasSurfaceRenderingManagerData::checkInvariant(){
+
+}
+/**
+** get the prop3D
+**/
+vtkProp3D* wxMaracasSurfaceRenderingManagerData::getProp3D(){
+ return this->_prop3D;
+}
+/**
+** return the id from the daat
+**/
+int wxMaracasSurfaceRenderingManagerData::getId(){
+ return _id;
+}
+/**
+** set data id
+**/
+void wxMaracasSurfaceRenderingManagerData::setId(int propid){
+ _id = propid;
+}
+
+/**
+** Get the filanme
+**/
+std::string wxMaracasSurfaceRenderingManagerData::getDataname(){
+ return _dataname;
+}
+/**
+** Set the filanme
+**/
+void wxMaracasSurfaceRenderingManagerData::setDataname(std::string dataname){
+ _dataname = dataname;
+}
+
+
+
+void wxMaracasSurfaceRenderingManagerData::saveProp3DSTL(const char* filename){
+ if(_dataMapper){
+ vtkSmartPointer<vtkSTLWriter> stlWriter =
+ vtkSmartPointer<vtkSTLWriter>::New();
+ stlWriter->SetFileName(filename);
+ stlWriter->SetInput(_dataMapper->GetInput());
+ stlWriter->SetFileTypeToBinary();
+ stlWriter->Write();
+ }
+}
+
+void wxMaracasSurfaceRenderingManagerData::enableBoxWidget(bool enable){
+
+}
+
+
+
+
--- /dev/null
+#ifndef WXMARACASSURFACERENDERINGMANAGERDATA_H_
+#define WXMARACASSURFACERENDERINGMANAGERDATA_H_
+
+#include "vtkProp3D.h"
+#include "vtkRenderer.h"
+#include "vtkSTLReader.h"
+#include "vtkPolyDataMapper.h"
+#include "vtkActor.h"
+#include "vtkProperty.h"
+#include "vtkBoxWidget.h"
+
+
+
+class wxMaracasSurfaceRenderingManagerData {
+
+public:
+ wxMaracasSurfaceRenderingManagerData(vtkProp3D* _prop3Dvect, std::string dataname="", vtkRenderWindowInteractor* interactor=NULL);
+ ~wxMaracasSurfaceRenderingManagerData();
+
+ /**
+ ** 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);
+
+ /**
+ ** adds or removes the surface box
+ **/
+ void addRemoveSurfaceBox(bool visible);
+
+ void initializeBoxWidget(vtkRenderWindowInteractor* interactor);
+
+ void saveProp3DSTL(const char* filename);
+
+ virtual void enableBoxWidget(bool enable);
+
+protected:
+ vtkPolyDataMapper* _dataMapper;
+ /**
+ * Prop 3D (data actor)
+ */
+ vtkProp3D* _prop3D;
+ /**
+ * Dataname given by the user (ex. filename)
+ **/
+ std::string _dataname;
+
+ /**
+ **
+ **/
+ vtkBoxWidget* _boxWidgetS1;
+private:
+
+ /*
+ * id of the data
+ */
+ int _id;
+
+
+
+
+};
+
+#endif /*WXMARACASSURFACERENDERINGMANAGERDATA_H_*/
--- /dev/null
+
+#include "wxMaracasSurfaceRenderingManagerDataMhd.h"
+
+#include "vtkStripper.h"
+
+
+wxMaracasSurfaceRenderingManagerDataMhd::wxMaracasSurfaceRenderingManagerDataMhd(vtkImageData* imagedata, std::string dataname, vtkRenderWindowInteractor* interactor)
+: wxMaracasSurfaceRenderingManagerData(NULL, dataname)
+{
+
+ this->setVtkImageData(imagedata);
+ _dataname = dataname;
+
+ _maxgreylevel = getMaxLevel(imagedata);
+ _prop3D=NULL;
+
+ _cubesFilter = vtkMarchingCubes::New();
+ _cubesFilter->SetInput(this->_imagedata);
+ _cubesFilter->ComputeGradientsOn ();
+ _cubesFilter->ComputeScalarsOn ();
+ _cubesFilter->SetNumberOfContours( 1 );
+ _cleanFilter = vtkCleanPolyData::New();
+ _cleanFilter->SetInput ( _cubesFilter->GetOutput() );
+
+ _dataMapper = vtkPolyDataMapper::New( );
+ _dataMapper->ScalarVisibilityOff( );
+ _dataMapper->ImmediateModeRenderingOn();
+ vtkActor* dataActor = vtkActor::New();
+
+ //if(_boxWidgetS1){
+ if(interactor){
+ _boxWidgetS1 = vtkBoxWidget::New();
+ _boxWidgetS1->SetInteractor( interactor );
+ _boxWidgetS1->SetPlaceFactor(1.25);
+
+ _boxWidgetS1->SetInput( this->_imagedata );
+ _boxWidgetS1->PlaceWidget();
+ boxSurfaceObserver* observer = boxSurfaceObserver::New();
+
+ vtkStripper* striper = vtkStripper::New();
+ striper->SetInput( _cleanFilter->GetOutput() );
+ //striper->SetInput( _cubesFilter->GetOutput() );
+
+ striper->Update();
+ _boxWidgetS1->SetInput(striper->GetOutput());
+ //_boxWidgetS1->PlaceWidget();
+
+
+ _tissuePlanes = vtkPlanes::New();
+
+ int x1,x2,y1,y2,z1,z2;
+ this->_imagedata->GetExtent(x1,x2,y1,y2,z1,z2);
+ _tissuePlanes->SetBounds (x1,x2,y1,y2,z1,z2);
+
+
+
+ _boxWidgetS1->GetPlanes( _tissuePlanes );
+
+ _tissueClipper = vtkClipPolyData::New();
+ _tissueClipper->SetInput( striper->GetOutput() );
+ _tissueClipper->SetClipFunction( _tissuePlanes );
+ _tissueClipper->InsideOutOn( );
+ _dataMapper->SetInput( _tissueClipper->GetOutput() );
+ observer->SetPlanes( _tissuePlanes );
+ observer->SetActor( dataActor );
+ _boxWidgetS1->AddObserver( vtkCommand::InteractionEvent , observer );
+
+
+ _boxWidgetS1->HandlesOn ();
+ _boxWidgetS1->EnabledOn();
+ }else{
+ _dataMapper->SetInput(_cleanFilter->GetOutput());
+ }
+
+ dataActor->SetMapper(_dataMapper);
+ this->_prop3D = dataActor;
+
+
+
+
+ this->changeIsoValue(this->_maxgreylevel);
+
+
+}
+
+void wxMaracasSurfaceRenderingManagerDataMhd::enableBoxWidget(bool enable){
+
+ if(_boxWidgetS1){
+ if(enable){
+ _boxWidgetS1->EnabledOn();
+ }else{
+ _boxWidgetS1->EnabledOff();
+ }
+ }
+}
+
+
+wxMaracasSurfaceRenderingManagerDataMhd::~wxMaracasSurfaceRenderingManagerDataMhd()
+{
+ _cubesFilter->Delete();
+ _cleanFilter->Delete();
+ _dataMapper->Delete();
+}
+
+void wxMaracasSurfaceRenderingManagerDataMhd::UpdateSurface()
+{
+ _cubesFilter->Update();
+ _cleanFilter->Update();
+ _dataMapper->Update();
+}
+/**
+** changes the isovalue in a prop3D
+**/
+void wxMaracasSurfaceRenderingManagerDataMhd::changeIsoValue(double value){
+
+
+ _cubesFilter->SetValue(0,value);
+ _cubesFilter->Update();
+ _cleanFilter->Update();
+ _dataMapper->Update();
+
+
+
+}
+/**
+** changes the isovalue in a prop3D
+**/
+void wxMaracasSurfaceRenderingManagerDataMhd::changeIsoValue(double min, double max){
+
+
+ _cubesFilter->SetValue(min,max);
+ _cubesFilter->Update();
+ _cleanFilter->Update();
+ _dataMapper->Update();
+
+
+
+}
+int wxMaracasSurfaceRenderingManagerDataMhd::getMaxGreyLevel(){
+ return _maxgreylevel;
+}
+
+/**
+ ** Get's the max grey level of the image
+ **/
+int wxMaracasSurfaceRenderingManagerDataMhd::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 wxMaracasSurfaceRenderingManagerDataMhd::setVtkImageData(vtkImageData* imagedata){
+ _imagedata = imagedata;
+}
+
+
+
+
--- /dev/null
+#ifndef WXMARACASSURFACERENDERINGMANAGERDATAMHD_H_
+#define WXMARACASSURFACERENDERINGMANAGERDATAMHD_H_
+
+
+#include "wxMaracasSurfaceRenderingManagerData.h"
+#include "boxSurfaceObserver.h"
+
+#include "vtkMetaImageReader.h"
+#include "vtkMarchingCubes.h"
+#include "vtkCleanPolyData.h"
+#include "vtkImageData.h"
+#include "vtkClipPolyData.h"
+#include "vtkPlanes.h"
+
+class wxMaracasSurfaceRenderingManagerDataMhd : public wxMaracasSurfaceRenderingManagerData {
+
+public:
+
+ wxMaracasSurfaceRenderingManagerDataMhd(vtkImageData* imagedata, std::string dataname="", vtkRenderWindowInteractor* interactor=0);
+ ~wxMaracasSurfaceRenderingManagerDataMhd();
+
+
+ /**
+ ** Adds a prop3D to the world of the application
+ **/
+ void setVtkImageData(vtkImageData* imagedata);
+
+ /**
+ ** changes the isovalue in a prop3D
+ **/
+ void changeIsoValue(double value);
+ /**
+ ** changes the isovalue in a prop3D
+ **/
+ void changeIsoValue(double min, double max);
+ /**
+ ** 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);
+
+ /**
+ ** Updates surface
+ **/
+ void UpdateSurface();
+
+ virtual void enableBoxWidget(bool enable);
+private:
+
+ vtkImageData* _imagedata;
+ int _maxgreylevel;
+
+ /**
+ ** to the image render
+ **/
+ vtkMarchingCubes* _cubesFilter;
+ vtkCleanPolyData* _cleanFilter;
+ vtkClipPolyData* _tissueClipper;
+ vtkPlanes* _tissuePlanes;
+
+ /**
+ ** Get's the max grey level of the image
+ **/
+ int getMaxLevel(vtkImageData* img);
+
+
+
+};
+
+#endif /*WXMARACASSURFACERENDERINGMANAGERDATAMHD_H_*/