--- /dev/null
+ADD_SUBDIRECTORY(Viewers)
+ADD_SUBDIRECTORY(VolumeRenderer)
--- /dev/null
+#----------------------------------------------------------------------------
+# USER! : SET THE NAME OF YOUR LIBRARY
+# (Replace 'MyLib' by your own library name)
+
+#############################
+SET ( LIBRARY_NAME GUIQtViewers )
+#############################
+
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+# 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/Viewers/*.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}
+ QVTK
+ GUIQtVolumeRenderer
+ KernelViewerWidgets
+ # 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 :
+
+ 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 "qtvtkviewer.h"
+
+QtVTKViewer::QtVTKViewer(QWidget* parent)
+ : QVTKWidget(parent)
+{
+
+
+ this->GetRenderWindow()->AddRenderer(vtkRenderer::New());
+ this->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->SetBackground(0,0,0);
+
+ SuperImagePlaneWidget::initialize(this->GetRenderWindow()->GetInteractor());
+
+ this->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->ResetCamera();
+
+
+ _rayorigin[0] = 0;
+ _rayorigin[1] = 0;
+ _rayorigin[2] = 0;
+ _rayorigin[3] = 0;
+
+ _imageindex[0] = 0;
+ _imageindex[1] = 0;
+ _imageindex[2] = 0;
+
+}
+
+void QtVTKViewer::mouseMoveEvent(QMouseEvent* event){
+ int x=0, y=0;
+
+ QVTKWidget::mouseMoveEvent(event);
+
+ x = event->pos().x();
+ y = this->size().height() - event->pos().y();
+
+#ifdef debug
+ std::cout<<"X= "<<x<<" Y= "<<y<<std::endl;
+#endif
+
+
+ this->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->SetDisplayPoint(x, y, 0);
+ this->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->DisplayToWorld();
+ this->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetWorldPoint(_rayorigin);
+#ifdef debug
+ std::cout<<"X= "<<x<<" Y= "<<y<<std::endl;
+ std::cout<<"X= "<<_rayorigin[0]<<" Y= "<<_rayorigin[1]<<" Z= "<<_rayorigin[2]<<" R= "<<_rayorigin[3]<<std::endl;
+#endif
+
+
+
+
+
+}
+
+void QtVTKViewer::mousePressEvent(QMouseEvent* event){
+ QVTKWidget::mousePressEvent(event);
+ vtkImagePlaneWidget * temp = 0;
+ if(_xwidget->GetCursorDataStatus()==1){
+ temp = _xwidget;
+ }else if(_ywidget->GetCursorDataStatus()==1){
+ temp = _ywidget;
+ }else if(_zwidget->GetCursorDataStatus()==1){
+ temp = _zwidget;
+ }
+
+ if(temp){
+ _imageindex[0]=temp->GetCurrentCursorPosition()[0];
+ _imageindex[1]=temp->GetCurrentCursorPosition()[1];
+ _imageindex[2]=temp->GetCurrentCursorPosition()[2];
+#ifdef debug
+ std::cout<<"X= "<<_imageindex[0]<<" Y= "<<_imageindex[1]<<" Z= "<<_imageindex[2]<<std::endl;
+#endif
+ }
+}
--- /dev/null
+#ifndef QTVTKVIEWER_H
+#define QTVTKVIEWER_H
+
+
+#include <QWidget>
+#include <QMouseEvent>
+
+#include "QVTKWidget.h"
+#include "imageplanewidget.h"
+
+class QtVTKViewer : public QVTKWidget, public ImagePlaneWidget
+{
+
+public:
+
+ QtVTKViewer(QWidget* parent);
+
+ typedef ImagePlaneWidget SuperImagePlaneWidget;
+
+private:
+
+ void invariant();
+
+ /**
+ * @brief double _imageindex contains the current point on the image selected by the user, can be used to perform segmentation algorithms on the image i.e the seed for regiongrowing
+ *
+ */
+ double _imageindex[3];
+ /**
+ * @brief double _rayorigin contains the origin position of the clicked performed by the user, can be used to perform ray intersection algorithms i.e
+ * finding an object in the scene
+ *
+ */
+ double _rayorigin[4];
+
+protected:
+ // overloaded mouse press handler
+ virtual void mousePressEvent(QMouseEvent* event);
+ // overloaded mouse move handler
+ virtual void mouseMoveEvent(QMouseEvent* event);
+ // overloaded mouse release handler
+ //virtual void mouseReleaseEvent(QMouseEvent* event);
+
+};
+
+#endif // QTVTKVIEWER_H
--- /dev/null
+#include "qtvtkviewerwidget.h"
+#include "ui_qtvtkviewerwidget.h"
+
+
+
+QtVTKViewerWidget::QtVTKViewerWidget(QWidget *parent) :
+ QWidget(parent)
+{
+ setupUi(this);
+
+
+ this->m_VolumeRender->SetRenderer(this->getRenderer());
+}
+
+QtVTKViewerWidget::~QtVTKViewerWidget()
+{
+
+}
+
+vtkRenderer* QtVTKViewerWidget::getRenderer(){
+ return this->_qtvtkviewer->GetRenderWindow()->GetRenderers()->GetFirstRenderer();
+}
+
+void QtVTKViewerWidget::setImage(vtkImageData* img){
+ this->_qtvtkviewer->setImage(img);
+ this->m_VolumeRender->SetImageData(img);
+}
+
+void QtVTKViewerWidget::SetLookupTable(vtkLookupTable *lookuptable){
+ this->_qtvtkviewer->SetLookupTable(lookuptable);
+ this->m_VolumeRender->SetLookUpTable(lookuptable);
+}
+
+void QtVTKViewerWidget::on_checkBoxShowPlanes_clicked(){
+
+ this->_qtvtkviewer->showPlanes(checkBoxShowPlanes->isChecked());
+}
--- /dev/null
+#ifndef QTVTKVIEWERWIDGET_H
+#define QTVTKVIEWERWIDGET_H
+
+#include <QWidget>
+
+#include "ui_qtvtkviewerwidget.h"
+
+#include "qtvtkviewer.h"
+
+#include "vtkRenderer.h"
+#include <vtkLookupTable.h>
+
+namespace Ui {
+ class QtVTKViewerWidget;
+}
+
+class QtVTKViewerWidget : public QWidget, Ui_QtVTKViewerWidget
+{
+ Q_OBJECT
+
+public:
+ QtVTKViewerWidget(QWidget *parent = 0);
+ ~QtVTKViewerWidget();
+
+ vtkRenderer* getRenderer();
+
+ void setImage(vtkImageData* img);
+
+ void SetLookupTable(vtkLookupTable *lookuptable);
+
+private slots:
+ void on_checkBoxShowPlanes_clicked();
+
+};
+
+#endif // QTVTKVIEWERWIDGET_H
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>QtVTKViewerWidget</class>
+ <widget class="QWidget" name="QtVTKViewerWidget">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>626</width>
+ <height>624</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="font">
+ <font>
+ <pointsize>14</pointsize>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>Viewer Controls</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="checkBoxShowPlanes">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Show Planes</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="tristate">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QtVolumeRendererPanel" name="m_VolumeRender" native="true"/>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QtVTKViewer" name="_qtvtkviewer" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>QtVTKViewer</class>
+ <extends>QWidget</extends>
+ <header>qtvtkviewer.h</header>
+ <container>1</container>
+ </customwidget>
+ <customwidget>
+ <class>QtVolumeRendererPanel</class>
+ <extends>QWidget</extends>
+ <header>qtvolumerendererpanel.h</header>
+ <container>1</container>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
--- /dev/null
+#----------------------------------------------------------------------------
+# USER! : SET THE NAME OF YOUR LIBRARY
+# (Replace 'MyLib' by your own library name)
+
+#############################
+SET ( LIBRARY_NAME GUIQtVolumeRenderer )
+#############################
+
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+# 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}
+ QVTK
+ KernelVolumeRenderer
+ # 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 :
+
+ 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 "qtvolumerenderer.h"
+#include "ui_qtvolumerenderer.h"
+
+QtVolumeRenderer::QtVolumeRenderer(QWidget *parent) :
+ QWidget(parent),
+ ui(new Ui::QtVolumeRenderer)
+{
+ ui->setupUi(this);
+}
+
+QtVolumeRenderer::~QtVolumeRenderer()
+{
+ delete ui;
+}
--- /dev/null
+#ifndef QTVOLUMERENDERER_H
+#define QTVOLUMERENDERER_H
+
+#include <QWidget>
+
+namespace Ui {
+ class QtVolumeRenderer;
+}
+
+class QtVolumeRenderer : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit QtVolumeRenderer(QWidget *parent = 0);
+ ~QtVolumeRenderer();
+
+private:
+ Ui::QtVolumeRenderer *ui;
+};
+
+#endif // QTVOLUMERENDERER_H
--- /dev/null
+<?xml version='1.0'?>
+<ui version="4.0">
+ <author/>
+ <comment/>
+ <exportmacro/>
+ <class>QtVolumeRenderer</class>
+ <widget class="QWidget" name="QtVolumeRenderer">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>480</width>
+ <height>640</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ </widget>
+ <pixmapfunction/>
+ <connections/>
+</ui>
--- /dev/null
+#include "qtvolumerendererpanel.h"
+#include "ui_qtvolumerendererpanel.h"
+
+QtVolumeRendererPanel::QtVolumeRendererPanel(QWidget *parent) :
+ QWidget(parent),
+ ui(new Ui::QtVolumeRendererPanel)
+{
+ ui->setupUi(this);
+ m_volrenddata = 0;
+ m_ImageData = 0;
+ m_Render = 0;
+}
+
+QtVolumeRendererPanel::~QtVolumeRendererPanel()
+{
+ delete ui;
+}
+
+void QtVolumeRendererPanel::on_checkBoxShowVolume_clicked(bool checked)
+{
+ if(checked){
+ invariant();
+ m_volrenddata = new VolumeRendererManagerData(m_ImageData, m_Render);
+ }else{
+ delete m_volrenddata;
+ m_volrenddata = 0;
+ }
+}
+
+void QtVolumeRendererPanel::invariant(){
+ if(!m_ImageData){
+ cout<<"Image data not set"<<endl;
+ throw "Image data not set";
+ }
+ if(!m_Render){
+ cout<<"renderer not initialized"<<endl;
+ throw "renderer not initialized";
+ }
+}
+
+void QtVolumeRendererPanel::on_opacitySlider_valueChanged(int value)
+{
+ if(m_volrenddata){
+
+ }
+}
--- /dev/null
+#ifndef QTVOLUMERENDERERPANEL_H
+#define QTVOLUMERENDERERPANEL_H
+
+#include <QWidget>
+
+#include "volumerenderermanagerdata.h"
+
+namespace Ui {
+ class QtVolumeRendererPanel;
+}
+
+class QtVolumeRendererPanel : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit QtVolumeRendererPanel(QWidget *parent = 0);
+ ~QtVolumeRendererPanel();
+
+ /*
+ * set the image data to the volume renderer
+ */
+ void SetImageData(vtkImageData* img){
+ m_ImageData = img;
+ }
+
+ /**
+ */
+ void SetRenderer(vtkRenderer* render){
+ m_Render = render;
+ }
+
+
+ void SetLookUpTable(vtkLookupTable *lookuptable){
+ m_Lookuptable = lookuptable;
+ }
+
+private slots:
+ void on_checkBoxShowVolume_clicked(bool checked);
+
+ void on_opacitySlider_valueChanged(int value);
+
+private:
+ Ui::QtVolumeRendererPanel *ui;
+ void invariant();
+
+protected:
+ VolumeRendererManagerData* m_volrenddata;
+ vtkImageData* m_ImageData;
+ vtkRenderer* m_Render;
+ vtkLookupTable* m_Lookuptable;
+};
+
+#endif // QTVOLUMERENDERERPANEL_H
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>QtVolumeRendererPanel</class>
+ <widget class="QWidget" name="QtVolumeRendererPanel">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>432</width>
+ <height>360</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Volume Rendering Controls</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolBox" name="toolBox">
+ <property name="currentIndex">
+ <number>1</number>
+ </property>
+ <widget class="QWidget" name="page">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>414</width>
+ <height>257</height>
+ </rect>
+ </property>
+ <attribute name="label">
+ <string>Add/Remove</string>
+ </attribute>
+ <widget class="QCheckBox" name="checkBoxShowVolume">
+ <property name="geometry">
+ <rect>
+ <x>50</x>
+ <y>40</y>
+ <width>121</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Show Volume</string>
+ </property>
+ </widget>
+ </widget>
+ <widget class="QWidget" name="page_2">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>414</width>
+ <height>257</height>
+ </rect>
+ </property>
+ <attribute name="label">
+ <string>Opacity</string>
+ </attribute>
+ <widget class="QSlider" name="opacitySlider">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>10</y>
+ <width>141</width>
+ <height>21</height>
+ </rect>
+ </property>
+ <property name="toolTip">
+ <string>Changes the opacity of the volume rendered</string>
+ </property>
+ <property name="inputMethodHints">
+ <set>Qt::ImhPreferLowercase</set>
+ </property>
+ <property name="maximum">
+ <number>100</number>
+ </property>
+ <property name="value">
+ <number>100</number>
+ </property>
+ <property name="tracking">
+ <bool>true</bool>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="invertedAppearance">
+ <bool>false</bool>
+ </property>
+ <property name="invertedControls">
+ <bool>false</bool>
+ </property>
+ <property name="tickPosition">
+ <enum>QSlider::TicksAbove</enum>
+ </property>
+ </widget>
+ <zorder>opacitySlider</zorder>
+ <zorder>label</zorder>
+ </widget>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
--- /dev/null
+ #----------------------------------------------------------------------------
+# USER! : SET THE NAME OF YOUR LIBRARY
+# (Replace 'MyLib' by your own library name)
+
+#############################
+SET ( LIBRARY_NAME GUIWxVolumeRenderer )
+#############################
+
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+# 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}
+ KernelVolumeRenderer
+
+ # 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 :
+
+ 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 "wxMaracasMultipleVolumeRendererPanel.h"
+#include "wxMaracasMultipleVolumeRendererView.h"
+#include "wxMaracas_N_ViewersWidget.h"
+#include "wxMaracasDialog_NViewers.h"
+#include "wxMaracasRendererView.h"
+
+#include <wx/colordlg.h>
+
+#include "vtkImageData.h"
+#include "vtkRenderer.h"
+
+#include <OpenImage.xpm>
+#include <Add.xpm>
+#include "Color.xpm"
+#include <vector>
+//#include <vtkImageCast.h>
+/**
+** Implementation of viewProp3D
+**/
+
+/**
+** Class constructor
+**/
+wxMaracasMultipleVolumeRendererPanel::wxMaracasMultipleVolumeRendererPanel(wxWindow* parent,int propid, vtkImageData* img, bool _isComplexBox)
+: wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize)
+{
+ _propid = propid;
+ isComplexBox = _isComplexBox;
+
+ createControls(img);
+}
+
+/**
+** Class destructor
+**/
+wxMaracasMultipleVolumeRendererPanel::~wxMaracasMultipleVolumeRendererPanel(){
+
+ //if(isComplexBox)
+ //((wxMaracasRenderTabbedPanel*)(wxMaracasRendererView::getInstance())->getTabbedPanel())->deleteVolume(_propid);
+ //else
+ //wxMaracasMultipleVolumeRendererView::getInstance()->deleteVolume(_propid);
+ delete mwxwidget;
+}
+
+/**
+** Sets panel elements
+**/
+void wxMaracasMultipleVolumeRendererPanel::createControls(vtkImageData* img){
+
+ wxFlexGridSizer* sizerirmprop = new wxFlexGridSizer(3);
+
+ if(!isComplexBox)
+ {
+// wxStaticText* label = new wxStaticText(this, -1, wxString(_T("")));
+// wxStaticText* label2 = new wxStaticText(this, -1, wxString(_T("")));
+
+
+ checkbox = new wxCheckBox(this,-1,wxString(_T("Show Actor")));
+ Connect(checkbox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&wxMaracasMultipleVolumeRendererPanel::onCheckBoxChange);
+ checkbox->SetValue(true);
+
+ wxString choices[] = {_T("Composite"), _T("MIP")};
+ _radiobox = new wxRadioBox(this, -1, wxString(_T("Function")), wxDefaultPosition, wxDefaultSize, 2, choices);
+ Connect(_radiobox->GetId(), wxEVT_COMMAND_RADIOBOX_SELECTED, (wxObjectEventFunction)&wxMaracasMultipleVolumeRendererPanel::onRadioBoxSelectFunction);
+
+ sizerirmprop->Add(checkbox,wxFIXED_MINSIZE);
+ sizerirmprop->AddSpacer(5);
+ sizerirmprop->Add(_radiobox,wxFIXED_MINSIZE);
+ //sizerirmprop->Add(label2,wxFIXED_MINSIZE);
+ }
+ //wxBitmap bitmap(Color_xpm);
+ //_colorchoose = new wxBitmapButton(this, -1, bitmap,wxDefaultPosition,wxSize(30,30));
+ //Connect(_colorchoose->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasMultipleVolumeRendererPanel::onColorChange);
+
+ mwxwidget = new HistogramDialogComboBox(this);
+ mwxwidget->setImageData(img);
+ //mwxwidget->PushEventHandler(this);
+ Connect(mwxwidget->GetId(), wxEVT_COMMAND_COMBOBOX_SELECTED, (wxObjectEventFunction)&wxMaracasMultipleVolumeRendererPanel::onColorChange);
+ sizerirmprop->Add(mwxwidget,wxFIXED_MINSIZE);
+
+ wxBitmap bitmap0(Add_xpm);
+ _viewimage = new wxBitmapButton(this, -1, bitmap0, wxDefaultPosition, wxSize(30,30));
+ Connect(_viewimage->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasMultipleVolumeRendererPanel::onViewImage);
+ sizerirmprop->Add(_viewimage,wxFIXED_MINSIZE);
+
+ //std::string iconsdir = wxMaracasMultipleVolumeRendererView::getInstance()->getPath();
+ //iconsdir+="/data/Icons/Add.xmp";
+ //wxBitmap* bitmap = new wxBitmap(wxString(iconsdir.c_str(),wxConvUTF8), wxBITMAP_TYPE_XPM);
+
+ this->SetSizer(sizerirmprop, true);
+ this->SetAutoLayout( true );
+
+ //_frame = new wxFrame(this, 10, _T("Configure Transfer Functions"));
+
+ /*wxButton* button1 = new wxButton(_frame,20,_T("OK"));
+ Connect(button1->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasMultipleVolumeRendererPanel::onOK);
+ wxButton* button2 = new wxButton(_frame,30,_T("Cancel") );
+ Connect(button2->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasMultipleVolumeRendererPanel::onCancel);
+ wxButton* button3 = new wxButton(_frame,40,_T("Update"));
+ Connect(button3->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasMultipleVolumeRendererPanel::onUpdate); */
+
+ /*mwxwidget->erasePointsTransferenceFunction();
+ double range[2];
+ img->GetScalarRange(range);
+ double max = range[1];
+
+
+ //X
+ mwxwidget->addPointToTransferenceFunction(max * 0/2,0.0);
+ mwxwidget->addPointToTransferenceFunction(max * 1/2,100.0);
+ mwxwidget->addPointToTransferenceFunction(max * 2/2,100.0);
+
+ mwxwidget->addColorPoint(max*0/4,(int)(0.0*255),(int)(0.0*255),(int)(0.0*255));
+ mwxwidget->addColorPoint(max*1/4,(int)(1.0*255),(int)(0.0*255),(int)(0.0*255));
+ mwxwidget->addColorPoint(max*2/4,(int)(0.0*255),(int)(0.0*255),(int)(1.0*255));
+ mwxwidget->addColorPoint(max*3/4,(int)(0.0*255),(int)(1.0*255),(int)(0.0*255));
+ mwxwidget->addColorPoint(max*4/4,(int)(0.0*255),(int)(0.0*255),(int)(0.2*255)); */
+
+ /*wxBoxSizer* boxSizer0 = new wxBoxSizer(wxHORIZONTAL);
+ boxSizer0->Add(mwxwidget, 4, wxGROW);
+
+ wxBoxSizer* boxSizer = new wxBoxSizer(wxHORIZONTAL);
+ boxSizer->AddSpacer(40);
+ boxSizer->Add(button1, wxCENTER);
+ boxSizer->AddSpacer(40);
+ boxSizer->Add(button2, wxCENTER);
+ boxSizer->AddSpacer(40);
+ boxSizer->Add(button3, wxCENTER);
+
+ wxBoxSizer* boxsizer2 = new wxBoxSizer(wxVERTICAL);
+ boxsizer2->Add(boxSizer0,1,wxEXPAND);
+ boxsizer2->Add(boxSizer,0,wxCENTER);
+
+ _frame->SetAutoLayout(true);
+
+
+ _frame->SetSizer(boxsizer2);
+
+ _frame->Refresh();
+ _frame->Update();*/
+ //mwxwidget->SetFunctions(wxMaracasMultipleVolumeRendererView::getInstance()->GetTransferFunction(getPropId()),
+ // wxMaracasMultipleVolumeRendererView::getInstance()->GetColorFunction(getPropId()));
+ mwxwidget->Refresh();
+}
+
+/**
+**
+**/
+void wxMaracasMultipleVolumeRendererPanel::onOK(wxCommandEvent& event){
+ updateVolume();
+ //_frame->Show(false);
+}
+
+/**
+**
+**/
+void wxMaracasMultipleVolumeRendererPanel::onCancel(wxCommandEvent& event){
+ //_frame->Show(false);
+}
+
+/**
+**
+**/
+void wxMaracasMultipleVolumeRendererPanel::onUpdate(wxCommandEvent& event){
+ updateVolume();
+}
+
+/**
+**
+**/
+void wxMaracasMultipleVolumeRendererPanel::updateVolume(){
+ std::vector<double> greylevelcolors;
+ std::vector<double> red;
+ std::vector<double> green;
+ std::vector<double> blue;
+
+ std::vector<double> greylevel;
+ std::vector<double> values;
+
+ mwxwidget->GetValuesColorPointsFunction(greylevelcolors, red, green, blue);
+ mwxwidget->GetValuesPointsFunction(greylevel, values);
+
+ if(this->isComplexBox)
+ {
+ ( (wxMaracasRendererView::getInstance())->getTabbedPanel(this->_propid) )->SetValuesColorPointsFunction(this->_propid,greylevelcolors, red, green, blue);
+ ( (wxMaracasRendererView::getInstance())->getTabbedPanel(this->_propid) )->SetValuesPointsFunction(this->_propid, greylevel, values);
+ }
+ else
+ {
+ wxMaracasMultipleVolumeRendererView::getInstance()->SetValuesColorPointsFunction(this->_propid, greylevelcolors, red, green, blue);
+ wxMaracasMultipleVolumeRendererView::getInstance()->SetValuesPointsFunction(this->_propid, greylevel, values);
+ }
+}
+
+/**
+** Updates the volume visualization
+**/
+void wxMaracasMultipleVolumeRendererPanel::onColorChange(wxCommandEvent& event){
+
+ //if(mwxwidget->ShowModal()==wxID_OK){
+ updateVolume();
+ // mwxwidget->Show(false);
+ //}
+}
+
+/**
+**
+**/
+void wxMaracasMultipleVolumeRendererPanel::onViewImage(wxCommandEvent& event)
+{
+ vtkImageData* img;
+ std::vector<int> type;
+ type.push_back(6);
+
+ wxFrame* frame = new wxFrame(this, -1, wxString(_T("Volume Visualization")));
+ frame->SetSize(wxDefaultSize);
+
+ if(this->isComplexBox)
+ {
+ img = (wxMaracasRendererView::getInstance())->getTabbedPanel(_propid)->getVolImage();
+ }
+ else
+ {
+ img = wxMaracasMultipleVolumeRendererView::getInstance()->getVolumeRenderManager()->getImageData();
+ }
+
+ // wxMaracas_N_ViewersWidget* viewer = new wxMaracas_N_ViewersWidget(frame, img, &type);
+ new wxMaracas_N_ViewersWidget(frame, img, &type);
+ frame->Show();
+}
+
+/**
+**
+**/
+void wxMaracasMultipleVolumeRendererPanel::onCheckBoxChange(wxCommandEvent& event){
+ if(this->isComplexBox)
+ ( (wxMaracasRendererView::getInstance())->getTabbedPanel(this->_propid) )->addRemoveActorV(this->getPropId(), checkbox->GetValue());
+ else
+ wxMaracasMultipleVolumeRendererView::getInstance()->addRemoveActor(this->getPropId(), checkbox->GetValue());
+}
+
+/**
+** Gets the propId
+**/
+int wxMaracasMultipleVolumeRendererPanel::getPropId(){
+ return _propid;
+}
+
+void wxMaracasMultipleVolumeRendererPanel::onRadioBoxSelectFunction(wxCommandEvent& event){
+
+ wxMaracasMultipleVolumeRendererView::getInstance()->changeCompositeMIPFunction(this->getPropId(), _radiobox->GetSelection());
+}
+
+/**
+** Carolina Perez: Recently added method
+**/
+HistogramDialogComboBox* wxMaracasMultipleVolumeRendererPanel::getMwxwidget()
+{
+ return mwxwidget;
+}
+
--- /dev/null
+#ifndef wxMaracasMultipleVolumeRendererPanel_H_
+#define wxMaracasMultipleVolumeRendererPanel_H_
+
+#include <wx/wx.h>
+#include "HistogramDialogComboBox.h"
+
+class wxMaracasMultipleVolumeRendererPanel : public wxPanel{
+
+public:
+ wxMaracasMultipleVolumeRendererPanel(wxWindow* parent, int propid, vtkImageData* img, bool _isComplexBox);
+ ~wxMaracasMultipleVolumeRendererPanel();
+ void createControls(vtkImageData* img);
+ void onCheckBoxChange(wxCommandEvent& event);
+ void onColorChange(wxCommandEvent& event);
+ void onOK(wxCommandEvent& event);
+ void onCancel(wxCommandEvent& event);
+ void onUpdate(wxCommandEvent& event);
+ void onViewImage(wxCommandEvent& event);
+ void onRadioBoxSelectFunction(wxCommandEvent& event);
+
+ void updateVolume();
+ int getPropId();
+ HistogramDialogComboBox* getMwxwidget();
+
+private:
+ wxCheckBox* checkbox;
+ wxRadioBox* _radiobox;
+ wxBitmapButton* _viewimage;
+
+ int _propid;
+
+ bool first;
+
+ HistogramDialogComboBox* mwxwidget;
+ //wxFrame* _frame;
+
+ //-- added for complex box --//
+ bool isComplexBox;
+};
+
+#endif /*wxMaracasMultipleVolumeRendererPanel_H_*/
--- /dev/null
+/*=========================================================================
+
+ Program: wxMaracas
+ Module: $RCSfile: wxMaracasMultipleVolumeRendererView.cxx,v $
+ Language: C++
+ Date: $Date: 2011/05/31 18:58:10 $
+ 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 "wxMaracasMultipleVolumeRendererView.h"
+
+
+#include <wx/colordlg.h>
+#include <wx/bmpbuttn.h>
+
+#include <OpenImage.xpm>
+#include <Color.xpm>
+
+wxMaracasMultipleVolumeRendererView* wxMaracasMultipleVolumeRendererView::instance=NULL;
+
+wxMaracasMultipleVolumeRendererView::wxMaracasMultipleVolumeRendererView( wxWindow* parent,std::string path)
+: wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize){
+
+ wxauimanager = new wxAuiManager(this);
+
+ _path = path;
+
+ volmanager = new VolumeRendererManager();
+ std::string iconsdir = path;
+ iconsdir+="/data/Icons";
+ this->_toolb = new ToolBarMultipleVolumeRenderer(this,iconsdir);
+ wxStaticText* txt = new wxStaticText(this, -1, wxString(_T(" Volume Rendering ")));
+ wxAuiPaneInfo paneinfo;
+ wxauimanager->AddPane(txt,paneinfo.ToolbarPane().Top());
+ wxauimanager->AddPane(_toolb,paneinfo.ToolbarPane().Top());
+
+ wxauimanager->Update();
+
+}
+wxMaracasMultipleVolumeRendererView::~wxMaracasMultipleVolumeRendererView( ){
+
+ delete _toolb;
+}
+
+std::string wxMaracasMultipleVolumeRendererView::getPath(){
+ return _path;
+}
+
+wxMaracasMultipleVolumeRendererView* wxMaracasMultipleVolumeRendererView::getInstance(wxWindow* parent,std::string path){
+ if(instance==NULL)
+{
+ instance = new wxMaracasMultipleVolumeRendererView(parent,path);
+ }
+ return instance;
+}
+
+wxMaracasMultipleVolumeRendererView* wxMaracasMultipleVolumeRendererView::getInstance(){
+ return instance;
+}
+
+void wxMaracasMultipleVolumeRendererView::changeCompositeMIPFunction(int id, int function){
+ try{
+ volmanager->changeCompositeMIPFunction(id, function);
+ }
+ catch(char* str){
+ std::cout << "Exception : " << str << '\n';
+ wxMessageDialog* diag = new wxMessageDialog(this, wxString( str,wxConvUTF8 ), wxString( str,wxConvUTF8 ), wxICON_ERROR);
+ diag->ShowModal();
+ }
+}
+
+void wxMaracasMultipleVolumeRendererView::setRenderer(vtkRenderer* renderer){
+ volmanager->setRenderer(renderer);
+}
+
+void wxMaracasMultipleVolumeRendererView::addRemoveActor(int id, bool addremove){
+ try{
+ volmanager->addRemoveActor(id, addremove);
+ }
+ catch(char* str){
+ std::cout << "Exception : " << str << '\n';
+ wxMessageDialog* diag = new wxMessageDialog(this, wxString( str,wxConvUTF8 ), wxString( str,wxConvUTF8 ), wxICON_ERROR);
+ diag->ShowModal();
+ }
+
+}
+
+void wxMaracasMultipleVolumeRendererView::onLoadImageFile(){
+
+ wxString mhd(_T("mhd"));
+
+ wxFileDialog* fildial = new wxFileDialog(this, wxString(_T("Select a MHD file")),wxString(_T("")),
+ wxString(_T("")),wxString(_T("MHD files (*.mhd)|*.mhd")) );
+
+ if(fildial->ShowModal()==wxID_OK){
+ wxString filename = fildial->GetFilename();
+ wxString pathfile(fildial->GetDirectory() + _T("/") + filename);
+ if(filename.EndsWith(mhd)){
+ loadVolume(pathfile,filename);
+ }
+ }
+ delete fildial;
+
+}
+
+void wxMaracasMultipleVolumeRendererView::addVolumeViewPanel(wxMaracasMultipleVolumeRendererPanel* irmview, std::string dataname){
+
+ wxString s(dataname.c_str(),wxConvUTF8 );
+ wxAuiPaneInfo paneinfo;
+ wxauimanager->AddPane(irmview, paneinfo.DefaultPane().Centre().DestroyOnClose().Caption(s));
+ wxauimanager->Update();
+}
+
+void wxMaracasMultipleVolumeRendererView::addVolume(vtkImageData* img, std::string dataname){
+
+ try{
+ int id = volmanager->addVolume(-1, img,dataname);
+ if(id!=-1){
+ wxMaracasMultipleVolumeRendererPanel* controlpan = new wxMaracasMultipleVolumeRendererPanel(this, id,img, false);
+ addVolumeViewPanel(controlpan, dataname);
+ controlpan->updateVolume();
+ }
+ }catch(char* str){
+ std::cout << "Exception : " << str << '\n';
+ wxMessageDialog* diag = new wxMessageDialog(this, wxString(str,wxConvUTF8 ), wxString(str,wxConvUTF8 ), wxICON_ERROR);
+ diag->ShowModal();
+ }
+}
+
+void wxMaracasMultipleVolumeRendererView::loadVolume(wxString filename, wxString dataname){
+
+ std::string s = std::string(filename.mb_str());
+ vtkImageData* img = volmanager->getImageData(s);
+ imgVect.push_back(img);
+
+ if(img!=NULL){
+ s = std::string(dataname.mb_str());
+ addVolume(img, s);
+ }
+}
+
+void wxMaracasMultipleVolumeRendererView::deleteVolume(int volid)
+{
+ try{
+ volmanager->deleteActor(volid);
+ }
+
+ catch(char* str){
+ std::cout << "Exception : " << str << '\n';
+ wxMessageDialog* diag = new wxMessageDialog(this, wxString(str,wxConvUTF8 ), wxString(str,wxConvUTF8 ), wxICON_ERROR);
+ diag->ShowModal();
+ }
+}
+
+void wxMaracasMultipleVolumeRendererView::SetValuesColorPointsFunction(int volid, std::vector<double> greylevelcolors,std::vector<double> red,std::vector<double> green,std::vector<double> blue)
+{
+ volmanager->setVolumeColor(volid, greylevelcolors, red, green, blue);
+}
+void wxMaracasMultipleVolumeRendererView::SetValuesPointsFunction(int volid, std::vector<double> greylevel, std::vector<double> values)
+{
+ volmanager->setVolumeOpacity(volid, greylevel, values);
+}
+
+vtkPiecewiseFunction* wxMaracasMultipleVolumeRendererView::GetTransferFunction(int volumeid)
+{
+ return volmanager->GetTransferFunction(volumeid);
+}
+vtkColorTransferFunction* wxMaracasMultipleVolumeRendererView::GetColorFunction(int volumeid)
+{
+ return volmanager->GetColorFunction(volumeid);
+}
+
+std::vector<vtkImageData*> wxMaracasMultipleVolumeRendererView::GetOutputImages(){
+ return imgVect;
+}
+
+VolumeRendererManager* wxMaracasMultipleVolumeRendererView::getVolumeRenderManager()
+{
+ return volmanager;
+}
+
+/**
+**
+**/
+
+ToolBarMultipleVolumeRenderer::ToolBarMultipleVolumeRenderer(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 ToolBarEventHandlerMultipleVolumeRenderer();
+ this->SetEventHandler(_evthand);
+
+}
+
+ToolBarMultipleVolumeRenderer::~ToolBarMultipleVolumeRenderer(void){
+}
+
+ToolBarEventHandlerMultipleVolumeRenderer::ToolBarEventHandlerMultipleVolumeRenderer()
+: wxEvtHandler(){
+}
+ToolBarEventHandlerMultipleVolumeRenderer::~ToolBarEventHandlerMultipleVolumeRenderer(){
+}
+
+void ToolBarEventHandlerMultipleVolumeRenderer::onLoadImageFile(wxCommandEvent& event){
+ wxMaracasMultipleVolumeRendererView::getInstance()->onLoadImageFile();
+}
+
+
+
+BEGIN_EVENT_TABLE(ToolBarEventHandlerMultipleVolumeRenderer, wxEvtHandler)
+ EVT_MENU(1, ToolBarEventHandlerMultipleVolumeRenderer::onLoadImageFile)
+END_EVENT_TABLE()
+
+
--- /dev/null
+/*=========================================================================
+
+ Program: wxMaracas
+ Module: $RCSfile: wxMaracasMultipleVolumeRendererView.h,v $
+ Language: C++
+ Date: $Date: 2011/05/31 18:58:10 $
+ 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 __wxMaracasMultipleVolumeRendererViewPanelH__
+#define __wxMaracasMultipleVolumeRendererViewPanelH__
+
+#include <vector>
+#include <wx/wx.h>
+#include "wx/aui/aui.h"
+#include <iostream>
+#include "marTypes.h"
+#include "vtkProp3D.h"
+
+#include "volumerenderermanager.h"
+#include "wxMaracasMultipleVolumeRendererPanel.h"
+
+
+
+class creaMaracasVisu_EXPORT wxMaracasMultipleVolumeRendererView : public wxPanel
+{
+
+public:
+ wxMaracasMultipleVolumeRendererView( wxWindow* parent, std::string path);
+ ~wxMaracasMultipleVolumeRendererView( );
+
+ static wxMaracasMultipleVolumeRendererView* getInstance(wxWindow* parent,std::string path="");
+
+ static wxMaracasMultipleVolumeRendererView* getInstance();
+
+ void setRenderer(vtkRenderer* renderer);
+
+ void addVolume(vtkImageData* img, std::string dataname="");
+
+ void loadVolume(wxString filename, wxString dataname);
+
+ void onLoadImageFile();
+
+ void addVolumeRendererPanel(wxMaracasMultipleVolumeRendererPanel* irmview, std::string dataname="");
+
+ std::string getPath();
+
+ void deleteVolume(int volid);
+
+ void addRemoveActor(int id, bool remove);
+
+ void SetValuesColorPointsFunction(int volid, std::vector<double> greylevelcolors,std::vector<double> red,std::vector<double> green,std::vector<double> blue);
+ void SetValuesPointsFunction(int volid, std::vector<double> greylevel, std::vector<double> values);
+
+ void addVolumeViewPanel(wxMaracasMultipleVolumeRendererPanel* irmview, std::string dataname);
+
+ vtkPiecewiseFunction* GetTransferFunction(int volumeid);
+ vtkColorTransferFunction* GetColorFunction(int volumeid);
+
+ std::vector<vtkImageData*> GetOutputImages();
+
+ void changeCompositeMIPFunction(int id, int function);
+
+ VolumeRendererManager* getVolumeRenderManager();
+
+private:
+ static wxMaracasMultipleVolumeRendererView* instance;
+
+ VolumeRendererManager* volmanager;
+ wxAuiManager* wxauimanager;
+ wxToolBar* _toolb;
+
+ std::string _path;
+ std::vector<vtkImageData*> imgVect;
+};
+
+class ToolBarEventHandlerMultipleVolumeRenderer : public wxEvtHandler{
+
+ public:
+ ToolBarEventHandlerMultipleVolumeRenderer();
+ ~ToolBarEventHandlerMultipleVolumeRenderer();
+
+ void onLoadImageFile(wxCommandEvent& event);
+
+ private:
+
+ DECLARE_EVENT_TABLE()
+ };
+
+class ToolBarMultipleVolumeRenderer : public wxToolBar{
+
+
+public:
+ ToolBarMultipleVolumeRenderer(wxWindow * parent,std::string iconsdir);
+ ~ToolBarMultipleVolumeRenderer(void);
+
+
+private:
+
+ ToolBarEventHandlerMultipleVolumeRenderer* _evthand;
+
+};
+
+#endif
+
--- /dev/null
+#----------------------------------------------------------------------------
+# USER! : SET THE NAME OF YOUR LIBRARY
+# (Replace 'MyLib' by your own library name)
+
+#############################
+SET ( LIBRARY_NAME ITKVTKImport )
+#############################
+
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+# 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}
+
+ ${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 :
+
+
+ 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
+#ifndef __ITKToVTKImageImport_h_
+#define __ITKToVTKImageImport_h_
+
+#include "itkImage.h"
+#include "itkVTKImageImport.h"
+#include "itkVTKImageExport.h"
+
+#include "vtkImageData.h"
+#include "vtkImageImport.h"
+#include "vtkImageExport.h"
+
+#define DIM 3
+#define TRY_CLAUSE_ITK try{
+#define CATCH_CLAUSE_ITK }catch(itk::ExceptionObject &e){ \
+ std::cout<<e<<std::endl; \
+ std::string ex = e.GetDescription();}\
+
+//------------------------------------------------------------------------------------------------------------
+// Includes
+//------------------------------------------------------------------------------------------------------------
+template<typename TypeImage,unsigned int dim>
+class ITKToVTKImageImport {
+
+//------------------------------------------------------------------------------------------------------------
+// Constructors & Destructors
+//------------------------------------------------------------------------------------------------------------
+public:
+ /* !!!!!some type definitions!!!!!!
+ */
+ /*
+ * type definition for the itk image that is going to be use
+ */
+ typedef itk::Image<TypeImage,dim> itkImageType;
+ /*
+ * type definition for the itk image import
+ */
+ typedef itk::VTKImageImport<itkImageType> ImageImportType;
+ /*
+ * type definition for the pointer of the image import
+ */
+ typedef typename ImageImportType::Pointer ImageImportPointer;
+ /*
+ * type definition for the itk image import
+ */
+ typedef itk::VTKImageExport<itkImageType> ImageExportType;
+ /*
+ * type definition for the pointer of the image import
+ */
+ typedef typename ImageExportType::Pointer ImageExportPointer;
+ /**
+ ** Default constructor, allocates the vtkImageExport and itkImageImport
+ ** Connects the pipelines and set them ready to be use
+ **/
+ ITKToVTKImageImport(){
+
+ vtkimageexport = vtkImageExport::New();
+ imageimportpointer = ImageImportType::New();
+
+ imageimportpointer->SetUpdateInformationCallback(vtkimageexport->GetUpdateInformationCallback());
+ imageimportpointer->SetPipelineModifiedCallback(vtkimageexport->GetPipelineModifiedCallback());
+ imageimportpointer->SetWholeExtentCallback(vtkimageexport->GetWholeExtentCallback());
+ imageimportpointer->SetSpacingCallback(vtkimageexport->GetSpacingCallback());
+ imageimportpointer->SetOriginCallback(vtkimageexport->GetOriginCallback());
+ imageimportpointer->SetScalarTypeCallback(vtkimageexport->GetScalarTypeCallback());
+ imageimportpointer->SetNumberOfComponentsCallback(vtkimageexport->GetNumberOfComponentsCallback());
+ imageimportpointer->SetPropagateUpdateExtentCallback(vtkimageexport->GetPropagateUpdateExtentCallback());
+ imageimportpointer->SetUpdateDataCallback(vtkimageexport->GetUpdateDataCallback());
+ imageimportpointer->SetDataExtentCallback(vtkimageexport->GetDataExtentCallback());
+ imageimportpointer->SetBufferPointerCallback(vtkimageexport->GetBufferPointerCallback());
+ imageimportpointer->SetCallbackUserData(vtkimageexport->GetCallbackUserData());
+
+
+ imageexportpointer = ImageExportType::New();
+ vtkimageimport = vtkImageImport::New();
+
+ vtkimageimport->SetUpdateInformationCallback(imageexportpointer->GetUpdateInformationCallback());
+ vtkimageimport->SetPipelineModifiedCallback(imageexportpointer->GetPipelineModifiedCallback());
+ vtkimageimport->SetWholeExtentCallback(imageexportpointer->GetWholeExtentCallback());
+ vtkimageimport->SetSpacingCallback(imageexportpointer->GetSpacingCallback());
+ vtkimageimport->SetOriginCallback(imageexportpointer->GetOriginCallback());
+ vtkimageimport->SetScalarTypeCallback(imageexportpointer->GetScalarTypeCallback());
+ vtkimageimport->SetNumberOfComponentsCallback(imageexportpointer->GetNumberOfComponentsCallback());
+ vtkimageimport->SetPropagateUpdateExtentCallback(imageexportpointer->GetPropagateUpdateExtentCallback());
+ vtkimageimport->SetUpdateDataCallback(imageexportpointer->GetUpdateDataCallback());
+ vtkimageimport->SetDataExtentCallback(imageexportpointer->GetDataExtentCallback());
+ vtkimageimport->SetBufferPointerCallback(imageexportpointer->GetBufferPointerCallback());
+ vtkimageimport->SetCallbackUserData(imageexportpointer->GetCallbackUserData());
+
+ }
+
+
+ ~ITKToVTKImageImport(){
+ /*std::cout<<"delete ~ITKToVTKImageImport(){"<<std::endl;*/
+ vtkimageimport->Delete();
+ vtkimageexport->Delete();
+ }
+ /*
+ * set the vtkImage data to connect to itk pipeline
+ */
+ void setVTKImage(vtkImageData* img) {
+ vtkimageexport->SetInput( img );
+ vtkimageexport->Update();
+ imageimportpointer->Update();
+ }
+ /*
+ *
+ */
+ itk::Image<TypeImage,dim>* getITKImage() {
+ if(vtkimageexport->GetInput()==0){
+ throw "Image not set to get the ItkImage, set the VtkImage before.\0";
+ }
+ return imageimportpointer->GetOutput();
+ }
+
+ /*
+ * Get the vtkImageData from the itk image
+ */
+ vtkImageData* GetOutputVTKImageDataImport() {
+ return vtkimageimport->GetOutput();
+ }
+ /*
+ * set the vtkImage data to connect to itk pipeline
+ */
+ void setITKImage(itkImageType* img) {
+ //std::cout<<"image pointer setITKImage"<<img<<std::endl;
+ imageexportpointer->SetInput(img);
+ imageexportpointer->Update();
+ vtkimageimport->Update();
+ }
+
+//------------------------------------------------------------------------------------------------------------
+// Attributes
+//------------------------------------------------------------------------------------------------------------
+private:
+
+
+
+ /*
+ * Pointer to vtkImageExport
+ */
+ vtkImageExport * vtkimageexport;
+ /*
+ * itk::VTKImageImport pointer
+ */
+ ImageImportPointer imageimportpointer;
+ /*
+ * Pointer to vtkImageExport
+ */
+ vtkImageImport * vtkimageimport;
+ /*
+ * Pointer to Export the itk image into vtk
+ */
+ ImageExportPointer imageexportpointer;
+};
+#endif
--- /dev/null
+#ifndef __ITKToVTKImageImport_h_
+#define __ITKToVTKImageImport_h_
+
+#include "itkImage.h"
+#include "itkVTKImageImport.h"
+#include "itkVTKImageExport.h"
+#include <itkProcessObject.h>
+
+#include "vtkImageData.h"
+#include "vtkImageImport.h"
+#include "vtkImageExport.h"
+
+#define DIM 3
+#define TRY_CLAUSE_ITK try{
+#define CATCH_CLAUSE_ITK }catch(itk::ExceptionObject &e){ \
+ std::cout<<e<<std::endl; \
+ std::string ex = e.GetDescription();}\
+
+namespace itk{
+
+//------------------------------------------------------------------------------------------------------------
+// Includes
+//------------------------------------------------------------------------------------------------------------
+template<typename TypeImage>
+class ITK_EXPORT ITKToVTKImageImport :
+public ProcessObject
+{
+
+ public:
+
+ /** Standard class typedefs. */
+ typedef ITKToVTKImageImport Self;
+
+ /** Standard "Superclass" typedef */
+ typedef ProcessObject Superclass;
+
+ /** Smart pointer typedef support. */
+ typedef SmartPointer<Self> Pointer;
+ typedef SmartPointer<const Self> ConstPointer;
+
+ /** Method for creation through the object factory. */
+ itkNewMacro(Self);
+
+ /** Run-time type information (and related methods). */
+ itkTypeMacro( ITKToVTKImageImport, ProcessObject );
+
+ /** InputImageType typedef support. */
+ typedef TypeImage InputImageType;
+ typedef typename InputImageType::Pointer InputImagePointerType;
+ typedef typename InputImageType::PixelType PixelType;
+ typedef typename InputImageType::IndexType IndexType;
+
+ /*
+ * type definition for the itk image import
+ */
+ typedef itk::VTKImageImport<InputImageType> ImageImportType;
+
+ typedef typename ImageImportType::Pointer ImageImportPointer;
+ /*
+ * type definition for the itk image import
+ */
+ typedef itk::VTKImageExport<InputImageType> ImageExportType;
+ /*
+ * type definition for the pointer of the image import
+ */
+ typedef typename ImageExportType::Pointer ImageExportPointer;
+
+ /*
+ * set the vtkImage data to connect to itk pipeline
+ */
+ void SetVTKImage(vtkImageData* img);
+
+ /*
+ * Get the vtkImageData from the itk image
+ */
+ vtkImageData* GetOutputVTKImage();
+
+
+ void SetITKImage(InputImagePointerType itkimage);
+ /*
+ *
+ */
+ InputImagePointerType GetOutputITKImage() ;
+
+//------------------------------------------------------------------------------------------------------------
+// Attributes
+//------------------------------------------------------------------------------------------------------------
+protected:
+ /**
+ ** Default constructor, allocates the vtkImageExport and itkImageImport
+ ** Connects the pipelines and set them ready to be use
+ **/
+ ITKToVTKImageImport();
+ ~ITKToVTKImageImport();
+
+
+private:
+
+
+ vtkImageData* m_VTKImage;
+
+ InputImagePointerType m_ITKImage;
+
+ /*
+ * Pointer to vtkImageExport
+ */
+ vtkImageExport * vtkimageexport;
+ /*
+ * itk::VTKImageImport pointer
+ */
+ ImageImportPointer imageimportpointer;
+ /*
+ * Pointer to vtkImageExport
+ */
+ vtkImageImport * vtkimageimport;
+ /*
+ * Pointer to Export the itk image into vtk
+ */
+ ImageExportPointer imageexportpointer;
+};
+
+}
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "itktovtkimageimport.txx"
+#endif
+
+
+#endif
--- /dev/null
+#ifndef __ITKToVTKImageImport_TXX
+#define __ITKToVTKImageImport_TXX
+
+
+namespace itk{
+
+/**
+** Default constructor, allocates the vtkImageExport and itkImageImport
+** Connects the pipelines and set them ready to be use
+**/
+template<typename TypeImage>
+ITKToVTKImageImport<TypeImage>::ITKToVTKImageImport(){
+
+ vtkimageexport = vtkImageExport::New();
+ imageimportpointer = ImageImportType::New();
+
+ imageimportpointer->SetUpdateInformationCallback(vtkimageexport->GetUpdateInformationCallback());
+ imageimportpointer->SetPipelineModifiedCallback(vtkimageexport->GetPipelineModifiedCallback());
+ imageimportpointer->SetWholeExtentCallback(vtkimageexport->GetWholeExtentCallback());
+ imageimportpointer->SetSpacingCallback(vtkimageexport->GetSpacingCallback());
+ imageimportpointer->SetOriginCallback(vtkimageexport->GetOriginCallback());
+ imageimportpointer->SetScalarTypeCallback(vtkimageexport->GetScalarTypeCallback());
+ imageimportpointer->SetNumberOfComponentsCallback(vtkimageexport->GetNumberOfComponentsCallback());
+ imageimportpointer->SetPropagateUpdateExtentCallback(vtkimageexport->GetPropagateUpdateExtentCallback());
+ imageimportpointer->SetUpdateDataCallback(vtkimageexport->GetUpdateDataCallback());
+ imageimportpointer->SetDataExtentCallback(vtkimageexport->GetDataExtentCallback());
+ imageimportpointer->SetBufferPointerCallback(vtkimageexport->GetBufferPointerCallback());
+ imageimportpointer->SetCallbackUserData(vtkimageexport->GetCallbackUserData());
+
+
+ imageexportpointer = ImageExportType::New();
+ vtkimageimport = vtkImageImport::New();
+
+ vtkimageimport->SetUpdateInformationCallback(imageexportpointer->GetUpdateInformationCallback());
+ vtkimageimport->SetPipelineModifiedCallback(imageexportpointer->GetPipelineModifiedCallback());
+ vtkimageimport->SetWholeExtentCallback(imageexportpointer->GetWholeExtentCallback());
+ vtkimageimport->SetSpacingCallback(imageexportpointer->GetSpacingCallback());
+ vtkimageimport->SetOriginCallback(imageexportpointer->GetOriginCallback());
+ vtkimageimport->SetScalarTypeCallback(imageexportpointer->GetScalarTypeCallback());
+ vtkimageimport->SetNumberOfComponentsCallback(imageexportpointer->GetNumberOfComponentsCallback());
+ vtkimageimport->SetPropagateUpdateExtentCallback(imageexportpointer->GetPropagateUpdateExtentCallback());
+ vtkimageimport->SetUpdateDataCallback(imageexportpointer->GetUpdateDataCallback());
+ vtkimageimport->SetDataExtentCallback(imageexportpointer->GetDataExtentCallback());
+ vtkimageimport->SetBufferPointerCallback(imageexportpointer->GetBufferPointerCallback());
+ vtkimageimport->SetCallbackUserData(imageexportpointer->GetCallbackUserData());
+
+}
+
+
+template<typename TypeImage >
+ITKToVTKImageImport<TypeImage>::~ITKToVTKImageImport(){
+ /*std::cout<<"delete ~ITKToVTKImageImport(){"<<std::endl;*/
+ vtkimageimport->Delete();
+ vtkimageexport->Delete();
+}
+/*
+* set the vtkImage data to connect to itk pipeline
+*/
+template<typename TypeImage>
+void ITKToVTKImageImport<TypeImage>::SetVTKImage(vtkImageData* img) {
+ vtkimageexport->SetInput( img );
+ vtkimageexport->Update();
+ imageimportpointer->Update();
+}
+
+/*
+*
+*/
+template<typename TypeImage>
+typename ITKToVTKImageImport<TypeImage>::InputImagePointerType ITKToVTKImageImport<TypeImage>::GetOutputITKImage() {
+ if(vtkimageexport->GetInput()==0){
+ throw "Image not set to get the ItkImage, set the VtkImage before.\0";
+ }
+ return imageimportpointer->GetOutput();
+}
+
+/*
+* Get the vtkImageData from the itk image
+*/
+template<typename TypeImage >
+vtkImageData* ITKToVTKImageImport<TypeImage >::GetOutputVTKImage() {
+ return vtkimageimport->GetOutput();
+}
+/*
+* set the vtkImage data to connect to itk pipeline
+*/
+template<typename TypeImage>
+void ITKToVTKImageImport<TypeImage >::SetITKImage(InputImagePointerType itkimage){
+ //std::cout<<"image pointer setITKImage"<<img<<std::endl;
+
+ m_ITKImage = itkimage;
+ imageexportpointer->SetInput(itkimage);
+ imageexportpointer->Update();
+ vtkimageimport->Update();
+
+}
+
+}
+#endif
--- /dev/null
+#ifndef ITKVTKCOLORTRANSFERFUNCTION_H
+#define ITKVTKCOLORTRANSFERFUNCTION_H
+
+
+#include <itkProcessObject.h>
+
+#include <vtkColorTransferFunction.h>
+
+#include <itkRGBToLuminanceImageFilter.h>
+#include <itkImageRegionConstIterator.h>
+
+namespace itk{
+
+template< class TypeImage>
+class VTKColorTransferFunction :
+public ProcessObject
+{
+
+ public:
+
+ /** Standard class typedefs. */
+ typedef VTKColorTransferFunction Self;
+
+ /** Standard "Superclass" typedef */
+ typedef ProcessObject Superclass;
+
+ /** Smart pointer typedef support. */
+ typedef SmartPointer<Self> Pointer;
+ typedef SmartPointer<const Self> ConstPointer;
+
+ /** Method for creation through the object factory. */
+ itkNewMacro(Self);
+
+ /** Run-time type information (and related methods). */
+ itkTypeMacro( VTKColorTransferFunction, ProcessObject );
+
+ /** InputImageType typedef support. */
+ typedef TypeImage InputImageType;
+ typedef typename InputImageType::Pointer InputImagePointerType;
+ typedef typename InputImageType::PixelType PixelType;
+ typedef typename InputImageType::IndexType IndexType;
+
+
+ /**
+ * set the rgb image to create the transfer function
+ */
+ itkSetMacro(Input, InputImagePointerType)
+ /**
+ * set the rgb image to create the transfer function
+ */
+ itkGetConstMacro(Input, InputImagePointerType)
+
+ /**
+ get the color transfer created from the image
+ */
+ itkGetMacro(Output, vtkColorTransferFunction*)
+
+ virtual void Update();
+
+protected:
+ VTKColorTransferFunction();
+ ~VTKColorTransferFunction();
+
+ virtual void GenerateData ();
+
+ virtual void GenerateOutputInformation();
+
+private:
+ vtkColorTransferFunction* m_Output;
+ InputImagePointerType m_Input;
+};
+
+}
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "itkvtkcolortransferfunction.txx"
+#endif
+
+#endif // ITKVTKCOLORTRANSFERFUNCTION_H
--- /dev/null
+#ifndef ITKVTKCOLORTRANSFERFUNCTION_TXX
+#define ITKVTKCOLORTRANSFERFUNCTION_TXX
+
+namespace itk{
+
+
+template< class TypeImage>
+VTKColorTransferFunction<TypeImage>::VTKColorTransferFunction()
+{
+
+}
+
+template< class TypeImage>
+VTKColorTransferFunction<TypeImage>::~VTKColorTransferFunction()
+{
+ m_Output->Delete();
+}
+
+template< class TypeImage>
+void VTKColorTransferFunction<TypeImage>::Update(){
+ GenerateOutputInformation();
+ GenerateData();
+}
+
+template< class TypeImage>
+void VTKColorTransferFunction<TypeImage>::GenerateOutputInformation(){
+ m_Output = vtkColorTransferFunction::New();
+}
+
+
+
+template< class TypeImage>
+void VTKColorTransferFunction<TypeImage>::GenerateData(){
+
+
+
+ InputImagePointerType imagergb = this->GetInput();
+
+ if(!imagergb){
+ itkExceptionMacro(<<"Set the image first!");
+ }
+
+
+ typedef itk::ImageRegionConstIterator< InputImageType > rgbiteratorType;
+ rgbiteratorType rgbit(imagergb, imagergb->GetLargestPossibleRegion());
+
+
+ rgbit.GoToBegin();
+
+
+ m_Output->RemoveAllPoints ();
+
+
+ while(!rgbit.IsAtEnd()){
+
+
+ typename InputImageType::PixelType::ComponentType lum = 0.299*rgbit.Get()[0] + 0.587*rgbit.Get()[1] + 0.114*rgbit.Get()[2];
+
+ m_Output->AddRGBPoint(lum, rgbit.Get()[0]/255.0, rgbit.Get()[1]/255.0, rgbit.Get()[2]/255.0);
+
+ ++rgbit;
+
+ }
+
+
+
+
+}
+
+}
+#endif
--- /dev/null
+ADD_SUBDIRECTORY(ViewerWidgets)
+ADD_SUBDIRECTORY(VolumeRenderer)
--- /dev/null
+#----------------------------------------------------------------------------
+# USER! : SET THE NAME OF YOUR LIBRARY
+# (Replace 'MyLib' by your own library name)
+
+#############################
+SET ( LIBRARY_NAME KernelViewerWidgets )
+#############################
+
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+# 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}
+ #${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 :
+
+
+ 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 "imageplanewidget.h"
+
+ImagePlaneWidget::ImagePlaneWidget()
+{
+ _img = 0;
+ _xwidget = 0;
+ _ywidget = 0;
+ _zwidget = 0;
+}
+
+void ImagePlaneWidget::initialize(vtkRenderWindowInteractor* interactor){
+ // Plane widget
+ _xwidget = vtkImagePlaneWidget::New( );
+ _ywidget = vtkImagePlaneWidget::New( );
+ _zwidget = vtkImagePlaneWidget::New( );
+
+
+ _xwidget->SetInteractor( interactor );
+ _ywidget->SetInteractor( interactor );
+ _zwidget->SetInteractor( interactor );
+}
+
+
+void ImagePlaneWidget::setImage(vtkImageData* img){
+ _img = img;
+ this->invariant();
+
+ int *dims = _img->GetDimensions( );
+ unsigned int sliceX = dims[0]/2;
+ unsigned int sliceY = dims[1]/2;
+ unsigned int sliceZ = dims[2]/2;
+
+ // Set input X,Y and Z plane
+ _xwidget->Off( );
+ _xwidget->SetInput( _img );
+ _xwidget->SetPlaneOrientationToXAxes( );
+ _xwidget->SetSliceIndex( sliceX );
+ //_xwidget->TextureInterpolateOff();
+ _xwidget->SetResliceInterpolateToLinear();
+ _xwidget->On( );
+ _xwidget->DisplayTextOn();
+
+
+ _ywidget->Off( );
+ _ywidget->SetInput( _img );
+ _ywidget->SetPlaneOrientationToYAxes( );
+ _ywidget->SetSliceIndex( sliceY );
+ //_ywidget->TextureInterpolateOff();
+ _ywidget->SetResliceInterpolateToLinear();
+ _ywidget->DisplayTextOn();
+ _ywidget->On( );
+
+ _zwidget->Off( );
+ _zwidget->SetInput( _img );
+ _zwidget->SetPlaneOrientationToZAxes( );
+ _zwidget->SetSliceIndex( sliceZ );
+ //_zwidget->TextureInterpolateOff();
+ _zwidget->SetResliceInterpolateToLinear();
+ _zwidget->DisplayTextOn();
+ _zwidget->On( );
+}
+
+void ImagePlaneWidget::SetLookupTable(vtkLookupTable *lookuptable){
+ this->invariant();
+ _xwidget->SetLookupTable(lookuptable);
+ _ywidget->SetLookupTable(lookuptable);
+ _zwidget->SetLookupTable(lookuptable);
+}
+
+void ImagePlaneWidget::showPlanes(bool show){
+ this->invariant();
+ if(show){
+ _xwidget->On();
+ _ywidget->On();
+ _zwidget->On();
+ }else{
+ _xwidget->Off();
+ _ywidget->Off();
+ _zwidget->Off();
+ }
+}
+
+
+void ImagePlaneWidget::invariant(){
+ if(_img == NULL){
+ throw "Image data is not initialized";
+ }
+ if(!_xwidget ||!_ywidget || !_zwidget){
+ throw "The widgets are not initialized";
+ }
+}
--- /dev/null
+#ifndef IMAGEPLANEWIDGET_H
+#define IMAGEPLANEWIDGET_H
+
+
+#include "vtkRenderWindow.h"
+#include "vtkRendererCollection.h"
+#include "vtkImagePlaneWidget.h"
+#include "vtkImageData.h"
+
+class ImagePlaneWidget
+{
+public:
+ ImagePlaneWidget();
+
+ virtual void setImage(vtkImageData* img);
+
+ virtual void SetLookupTable(vtkLookupTable *lookuptable);
+
+ virtual void showPlanes(bool show);
+
+ void initialize(vtkRenderWindowInteractor* interactor);
+protected:
+
+ vtkImageData* _img;
+ vtkImagePlaneWidget* _xwidget;
+ vtkImagePlaneWidget* _ywidget;
+ vtkImagePlaneWidget* _zwidget;
+private:
+ void invariant();
+};
+
+#endif // IMAGEPLANEWIDGET_H
--- /dev/null
+#----------------------------------------------------------------------------
+# USER! : SET THE NAME OF YOUR LIBRARY
+# (Replace 'MyLib' by your own library name)
+
+#############################
+SET ( LIBRARY_NAME KernelVolumeRenderer )
+#############################
+
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+# 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}
+ #${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 :
+
+
+ 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 "volumerenderermanager.h"
+
+/*=========================================================================
+
+ Program: wxMaracas
+ Module: $RCSfile: volumerenderermanager.cxx,v $
+ Language: C++
+ Date: $Date: 2011/05/31 19:03:03 $
+ 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 <vtkMetaImageReader.h>
+#include <vtkImageCast.h>
+/**
+** Start of the manager class
+**/
+VolumeRendererManager::VolumeRendererManager(){
+ _renderer = NULL;
+ _idCount=0;
+}
+VolumeRendererManager::~VolumeRendererManager(){
+}
+
+/**
+** Sets the renderer to manage the prop3D from the view
+**/
+void VolumeRendererManager::setRenderer(vtkRenderer* renderer){
+ _renderer = renderer;
+}
+
+/**
+** Gets the renderer which manage the prop3D from the view
+**/
+vtkRenderer* VolumeRendererManager::getRenderer(){
+ return _renderer;
+}
+
+/**
+** Updates Volume
+**/
+void VolumeRendererManager::Update(int ppid){
+ VolumeRendererManagerData* data = this->getViewData(ppid);
+ data->Update();
+ _renderer->Render();
+}
+
+/**
+** Adds a prop3D to the manager and returns the identifier
+**/
+int VolumeRendererManager::addVolume(int idTP, vtkImageData* vol, std::string dataname) throw(char*){
+ checkInvariant();
+ image = vol;
+ if(vol != NULL){
+ VolumeRendererManagerData* data = new VolumeRendererManagerData(vol, dataname);
+ prop3Dvect.push_back(data);
+ _renderer->AddActor(data->getProp3D());
+ if(idTP == -1)
+ {
+ data->setId(_idCount);
+ _idCount++;
+ }
+ else
+ {
+ data->setId(idTP);
+ }
+ printf("VolumeRendererManager::addVolume->idVolumeRenderer: %i\n", data->getId());
+ return data->getId();
+ }else{
+ throw "Check mhd imagefile file or input";
+ }
+ return -1;
+}
+/**
+** adds or removes an actor depending of the bool value
+**/
+
+void VolumeRendererManager::addRemoveActor(int propid, bool addremove) throw(char*){
+ checkInvariant();
+
+ VolumeRendererManagerData* 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 VolumeRendererManager::setVolumeOpacity(int propid, std::vector<double> greylevel,std::vector<double> value) throw(char*){
+ checkInvariant();
+
+ this->getViewData(propid)->setVolumeOpacity(greylevel, value);
+
+ _renderer->Render();
+
+}
+
+/**
+** Set Volume Color
+**/
+void VolumeRendererManager::setVolumeColor(int volid, std::vector<double> greylevel,
+ std::vector<double> red,
+ std::vector<double> green,
+ std::vector<double> blue)throw(char*){
+ checkInvariant();
+
+ this->getViewData(volid)->setVolumeColor(greylevel, red, green, blue);
+
+ _renderer->Render();
+}
+
+vtkImageData* VolumeRendererManager::getImageData(std::string filename){
+ if(filename.compare("")!= 0){
+
+ vtkMetaImageReader* reader = vtkMetaImageReader::New();
+ reader->SetFileName(filename.c_str());
+ reader->Update();
+ vtkImageData* img = reader->GetOutput();
+
+ vtkImageCast* cast = vtkImageCast::New();
+ cast->SetInput(img);
+ cast->SetOutputScalarTypeToUnsignedShort();
+ cast->Update();
+ //reader->Delete();
+ //img->Delete();
+ return cast->GetOutput();
+ //return img;
+ }
+ return NULL;
+}
+
+vtkImageData* VolumeRendererManager::getImageData(){
+ return image;
+}
+
+void VolumeRendererManager::checkInvariant() throw(char*){
+ if(this->_renderer==NULL){
+ throw "Renderer not set";
+ }
+}
+
+VolumeRendererManagerData* VolumeRendererManager::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;
+}
+
+void VolumeRendererManager::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){
+ VolumeRendererManagerData* 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";
+ }
+
+}
+
+vtkPiecewiseFunction* VolumeRendererManager::GetTransferFunction(int volumeid){
+ return getViewData(volumeid)->GetTransferFunction();
+}
+vtkColorTransferFunction* VolumeRendererManager::GetColorFunction(int volumeid){
+
+ return getViewData(volumeid)->GetColorFunction();
+}
+
+void VolumeRendererManager::changeCompositeMIPFunction(int id, int function) throw (char *){
+ getViewData(id)->changeCompositeMIPFunction(function);
+}
--- /dev/null
+
+/*=========================================================================
+
+ Program: wxMaracas
+ Module: $RCSfile: volumerenderermanager.h,v $
+ Language: C++
+ Date: $Date: 2011/05/31 19:03:03 $
+ 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 __VolumeRendererManagerH__
+#define __VolumeRendererManagerH__
+
+#include <iostream>
+#include <vector>
+#include <vtkMatrix4x4.h>
+
+#include "volumerenderermanagerdata.h"
+
+
+class VolumeRendererManager {
+
+public:
+ VolumeRendererManager();
+ ~VolumeRendererManager();
+
+ /**
+ ** Sets the renderer to manage the prop3D from the view
+ **/
+ void setRenderer(vtkRenderer* renderer);
+
+ /**
+ ** Gets the renderer to manage the prop3D from the view
+ **/
+ vtkRenderer* getRenderer();
+
+ /**
+ ** Adds a volume
+ **/
+ int addVolume(int idTP, vtkImageData* img, std::string dataname) throw (char*);
+
+ /**
+ ** loads a prop3D from a nSTL file
+ **/
+ vtkProp3D* getVolume(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*);
+
+ /**
+ ** Check if the variables are setted correctly
+ **/
+ void checkInvariant()throw(char*);
+
+ /**
+ ** Set Volume Opacity
+ **/
+ void setVolumeOpacity(int propid, std::vector<double> greylevel,std::vector<double> value) throw(char*);
+ /**
+ ** Set Volume Color
+ **/
+ void setVolumeColor(int volid, std::vector<double> greylevel,
+ std::vector<double> red,
+ std::vector<double> green,
+ std::vector<double> blue)throw(char*);
+
+ /**
+ ** Given an id search the data in the vector
+ **/
+ VolumeRendererManagerData* getViewData(int id)throw(char*);
+
+ void changeCompositeMIPFunction(int id, int function) throw (char *);
+
+ /**
+ ** Deletes given actor
+ **/
+ void deleteActor(int volumeid)throw (char *);
+
+ /**
+ ** Updates given volume
+ **/
+ void Update(int propid);
+
+ vtkPiecewiseFunction* GetTransferFunction(int volumeid);
+ vtkColorTransferFunction* GetColorFunction(int volumeid);
+private:
+ std::vector<VolumeRendererManagerData*> prop3Dvect;
+
+ vtkRenderer* _renderer;
+ vtkImageData* image;
+
+ int _idCount;
+
+
+
+
+};
+
+#endif
--- /dev/null
+
+#include "volumerenderermanagerdata.h"
+
+/********************************************************************************************
+** Start of data viewmanagerData
+*********************************************************************************************/
+
+VolumeRendererManagerData::VolumeRendererManagerData(vtkImageData* vol, std::string dataname){
+
+ Initialize(vol, dataname);
+
+
+}
+
+VolumeRendererManagerData::VolumeRendererManagerData(vtkImageData* vol, vtkRenderer* render, std::string dataname){
+
+ Initialize(vol, dataname);
+ render->AddActor(this->getProp3D());
+}
+
+void VolumeRendererManagerData::Initialize(vtkImageData* vol, std::string dataname){
+ _vol = vol;
+ _dataname = dataname;
+
+ _tfun = vtkPiecewiseFunction::New();
+ _ctfun = vtkColorTransferFunction::New();
+
+ _volumePlanes = vtkPlanes::New();
+ _compositeFunction = vtkVolumeRayCastCompositeFunction::New();
+ _MIPFunction = vtkVolumeRayCastMIPFunction::New();
+
+ _volumeMapper = vtkVolumeRayCastMapper::New();
+ _volumeMapper->SetVolumeRayCastFunction(_compositeFunction);
+ _volumeMapper->SetClippingPlanes( _volumePlanes );
+ _volumeMapper->AutoAdjustSampleDistancesOn();
+ _volumeProperty = vtkVolumeProperty::New();
+ _volumeProperty->SetInterpolationTypeToLinear();
+ //_volumeProperty->ShadeOn();
+ _volumeProperty->DisableGradientOpacityOn();
+ _volumeProperty->SetColor(_ctfun);
+ _volumeProperty->SetScalarOpacity(_tfun );
+
+ _newvol = vtkVolume::New();
+ _newvol->SetMapper(_volumeMapper );
+ _newvol->SetProperty(_volumeProperty );
+ _volumeMapper->SetInput( _vol );
+ _volumeMapper->Update();
+ _newvol->Update();
+}
+
+
+VolumeRendererManagerData::~VolumeRendererManagerData(){
+
+ _tfun->Delete();
+ _ctfun->Delete();
+ _volumePlanes->Delete();
+ _compositeFunction->Delete();
+ _volumeMapper->Delete();
+ _volumeProperty->Delete();
+ _newvol->Delete();
+
+}
+/**
+** Set Volume Color
+**/
+void VolumeRendererManagerData::setVolumeColor(std::vector<double>& greylevelcolors,
+ std::vector<double>& red,
+ std::vector<double>& green,
+ std::vector<double>& blue)
+{
+
+ _ctfun->RemoveAllPoints();
+ for(int i = 0; i < greylevelcolors.size();i++){
+ _ctfun->AddRGBPoint(greylevelcolors[i], red[i],green[i], blue[i]);
+ //std::cout<<"VolumeRendererManagerData::setVolumeColor "<<greylevelcolors[i]<<" "<<red[i]<<" "<<green[i]<<" "<<blue[i]<<std::endl;
+ }
+ _newvol->Update();
+}
+
+/**
+** Volume Opacity
+**/
+void VolumeRendererManagerData::setVolumeOpacity(std::vector<double> greylevel,std::vector<double> value){
+
+ _tfun->RemoveAllPoints();
+ for(int i = 0; i < greylevel.size();i++){
+ _tfun->AddPoint(greylevel[i], value[i]);
+ //std::cout<<"VolumeRendererManagerData::setVolumeOpacity "<<greylevel[i]<<" "<< value[i]<<std::endl;
+ }
+ _newvol->Update();
+}
+
+/**
+** Check if the variables are setted correctly
+**/
+void VolumeRendererManagerData::checkInvariant()throw (char *){
+ if(!_compositeFunction){
+ throw "No composite function initialized";
+ }
+ if(!_MIPFunction){
+ throw "No MIP function initialized";
+ }
+ if(!_volumeMapper){
+ throw "No volume mapper initialized";
+ }
+}
+
+/**
+** Check if the variables are setted correctly
+**/
+void VolumeRendererManagerData::Update(){
+ _newvol->Update();
+}
+/**
+** get the prop3D
+**/
+vtkProp3D* VolumeRendererManagerData::getProp3D(){
+ return this->_newvol;
+}
+/**
+** return the id from the daat
+**/
+int VolumeRendererManagerData::getId(){
+ return _id;
+}
+/**
+** set data id
+**/
+void VolumeRendererManagerData::setId(int propid){
+ _id = propid;
+}
+
+/**
+** Get the filanme
+**/
+std::string VolumeRendererManagerData::getDataname(){
+ return _dataname;
+}
+/**
+** Set the filanme
+**/
+void VolumeRendererManagerData::setDataname(std::string dataname){
+ _dataname = dataname;
+}
+
+void VolumeRendererManagerData::changeCompositeMIPFunction(int function) throw (char *){
+ checkInvariant();
+ if(function == 0){
+ _volumeMapper->SetVolumeRayCastFunction(_compositeFunction);
+ }else{
+ _volumeMapper->SetVolumeRayCastFunction(_MIPFunction);
+ }
+
+}
+
+void VolumeRendererManagerData::SetLookupTable(vtkLookupTable* lookuptable){
+ _ctfun->RemoveAllPoints();
+ _ctfun->DeepCopy((vtkColorTransferFunction*)lookuptable);
+}
--- /dev/null
+
+#ifndef VolumeRendererManagerData_H_
+#define VolumeRendererManagerData_H_
+
+#include <vtkVolumeRayCastCompositeFunction.h>
+#include <vtkPlanes.h>
+#include <vtkVolumeRayCastMapper.h>
+#include <vtkVolumeProperty.h>
+#include <vtkVolume.h>
+#include <vtkPiecewiseFunction.h>
+#include <vtkColorTransferFunction.h>
+#include <vtkImageData.h>
+#include <vtkProp3D.h>
+#include <vtkRenderer.h>
+#include <vtkVolumeRayCastMIPFunction.h>
+#include <vtkLookupTable.h>
+#include <vector>
+
+
+class VolumeRendererManagerData {
+
+public:
+ VolumeRendererManagerData(vtkImageData* vol, std::string dataname="");
+ VolumeRendererManagerData(vtkImageData* vol, vtkRenderer* render, std::string dataname="");
+ ~VolumeRendererManagerData();
+
+ /**
+ ** Check if the variables are setted correctly
+ **/
+ void checkInvariant()throw (char *);
+
+ /**
+ ** Updates volume
+ **/
+ void Update();
+
+ /**
+ ** 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);
+
+ /**
+ ** Set Volume Color
+ **/
+ void setVolumeColor(std::vector<double>& greylevel,
+ std::vector<double>& red,
+ std::vector<double>& green,
+ std::vector<double>& blue);
+
+ /**
+ ** Volume Opacity
+ **/
+ void setVolumeOpacity(std::vector<double> greylevel,std::vector<double> value);
+
+ vtkPiecewiseFunction* GetTransferFunction(){
+ return _tfun;
+ }
+
+ vtkColorTransferFunction* GetColorFunction(){
+ return _ctfun;
+ }
+
+ void changeCompositeMIPFunction(int function) throw (char *);
+
+ void SetLookupTable(vtkLookupTable* lookuptable);
+
+protected:
+ /**
+ * Prop 3D (data actor)
+ */
+ vtkImageData* _vol;
+ /**
+ * Dataname given by the user (ex. filename)
+ **/
+ std::string _dataname;
+
+
+private:
+
+ /*
+ * id of the data
+ */
+ int _id;
+
+ vtkVolumeRayCastCompositeFunction *_compositeFunction;
+ vtkPlanes *_volumePlanes;
+ vtkVolumeRayCastMapper *_volumeMapper;
+ vtkVolumeProperty *_volumeProperty;
+ vtkVolume *_newvol;
+ vtkPiecewiseFunction* _tfun;
+ vtkColorTransferFunction* _ctfun;
+ vtkVolumeRayCastMIPFunction* _MIPFunction;
+
+ void Initialize(vtkImageData* vol, std::string dataname);
+
+
+};
+
+#endif /*VolumeRendererManagerData_H_*/