#SET(USE_GDCM_VTK ON)
SET(USE_WXWIDGETS ON)
SET(USE_VTK ON)
-SET(USE_ITK ON)
SET(USE_BOOST ON)
OPTION(QT_USE_QTUITOOLS "QT_USE_QTUITOOLS" OFF)
IF(QT_USE_QTUITOOLS)
- SET(USE_QT4 ON)
+ SET(USE_QT4 ON)
ELSE(QT_USE_QTUITOOLS)
SET(USE_QT4 OFF)
ENDIF(QT_USE_QTUITOOLS)
//----------------------------------------------------------------------
-// File: ann_sample.cpp
-// Programmer: Sunil Arya and David Mount
-// Last modified: 03/04/98 (Release 0.1)
-// Description: Sample program for ANN
-//----------------------------------------------------------------------
-// Copyright (c) 1997-2005 University of Maryland and Sunil Arya and
-// David Mount. All Rights Reserved.
-//
-// This software and related documentation is part of the Approximate
-// Nearest Neighbor Library (ANN). This software is provided under
-// the provisions of the Lesser GNU Public License (LGPL). See the
-// file ../ReadMe.txt for further information.
-//
-// The University of Maryland (U.M.) and the authors make no
-// representations about the suitability or fitness of this software for
-// any purpose. It is provided "as is" without express or implied
-// warranty.
+// File: qtvtkviewer.cxx
+// Programmer: Prieto
+// Last modified: 25/08/11 (Release 0.1)
+// Description: Sample program fro qtvtkviewer
//----------------------------------------------------------------------
#include "qtvtkviewerwidget.h"
#include "iostream"
-
-#include "OpenImageDialog.h"
+#include "vtkMetaImageReader.h"
+//#include "OpenImageDialog.h"
using namespace std;
-using namespace creaMaracasVisuKernel;
-
+//using namespace creaMaracasVisuKernel;
int main(int argc, char **argv)
{
vtkImageData* img = 0;
- if (argc < 2){
+ /*if (argc < 2){
OpenImageDialog open(true);
img = open.getImageData();
<< std::endl ;
return EXIT_FAILURE;
}
- }else{
+ }else*/
+ if(argc==2){
std::string inputFilename = argv[1];
vtkMetaImageReader* reader = vtkMetaImageReader::New();
reader->SetFileName(inputFilename.c_str());
reader->Update();
img = reader->GetOutput();
-
}
mainwindow->show();
- viewer->setImage(img);
+ if(img)
+ viewer->setImage(img);
//viewer->SetLookupTable((vtkLookupTable*)colortransfer);
-
-
-
return app.exec();
}
Program: wxMaracas
Module: $RCSfile: wxMaracasSurfaceRenderingManager.cxx,v $
Language: C++
- Date: $Date: 2011/06/28 16:56:13 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2011/10/05 16:26:55 $
+ Version: $Revision: 1.2 $
Copyright: (c) 2002, 2003
License:
#include "wxMaracasSurfaceRenderingManager.h"
#include "wxMaracasSurfaceRenderingManagerDataMhd.h"
+
+#include "vtkPLYReader.h"
+#include "vtkSmartPointer.h"
+
/**
** Start of the manager class
**/
** Adds a prop3D to the manager and returns the identifier
**/
int wxMaracasSurfaceRenderingManager::addProp3D(int idTP, vtkProp3D* prop3D, std::string dataname) throw(char*){
- checkInvariant();
+ //checkInvariant();
if(prop3D != NULL){
wxMaracasSurfaceRenderingManagerData* data = new wxMaracasSurfaceRenderingManagerData(prop3D, dataname, _interactor);
prop3Dvect.push_back(data);
}
int wxMaracasSurfaceRenderingManager::addPropMHD(int idTP, vtkImageData* imagedata, std::string dataname) throw(char*){
checkInvariant();
- if(imagedata != NULL){
+ if(imagedata != NULL){
image = imagedata;
wxMaracasSurfaceRenderingManagerData* data = new wxMaracasSurfaceRenderingManagerDataMhd(imagedata, dataname, _interactor);
prop3Dvect.push_back(data);
void wxMaracasSurfaceRenderingManager::addRemoveActor(int propid, bool addremove) throw(char*){
checkInvariant();
- wxMaracasSurfaceRenderingManagerData* data = this->getViewData(propid);
- if(data->getProp3D()!=NULL){
+ wxMaracasSurfaceRenderingManagerData* data = this->getViewData(propid);
+ if(data && data->getProp3D()!=NULL){
if(addremove){
_renderer->AddViewProp(data->getProp3D());
}else{
_renderer->RemoveViewProp(data->getProp3D());
}
_renderer->Render();
- }
+ }else {
+ if(addremove && propid == 0 && image){
+ addPropMHD(0, image, "id0");
+ }
+ return;
+ }
}
/**
** adds or removes the surface box depending of the bool value
vtkProp3D* wxMaracasSurfaceRenderingManager:: getProp3D(std::string filename){
if(filename.compare("")!= 0){
- vtkSTLReader *STLReader=vtkSTLReader::New();
+
+ vtkSmartPointer<vtkPolyData> polydata = vtkSmartPointer<vtkPolyData>::New();
+ std::string ext = filename.substr(filename.find_last_of("."), 4);
+ if(ext.compare(STL)==0){
+ vtkSmartPointer<vtkSTLReader> STLReader=vtkSmartPointer<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;
+ polydata->DeepCopy(STLReader->GetOutput());
+
+ }else if(ext.compare(PLY)==0){
+ vtkSmartPointer<vtkPLYReader> plyreader =vtkSmartPointer<vtkPLYReader>::New();
+ plyreader->SetFileName(filename.c_str());
+ plyreader->Update();
+ polydata->DeepCopy(plyreader->GetOutput());
+ }
+
+ vtkSmartPointer<vtkPolyDataMapper> dataMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
+ dataMapper->SetInput(polydata);
+
+ vtkActor* dataActor = vtkActor::New();
+ dataActor->SetMapper(dataMapper);
+ dataActor->GetProperty()->SetOpacity(1);
+ return dataActor;
}
return NULL;
}
return image;
}
+void wxMaracasSurfaceRenderingManager::setImageData(vtkImageData* img){
+ image = img;
+}
+
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";
+ for(i = 0; i < (int)(prop3Dvect.size());i++){
+ if(prop3Dvect[i]->getId() == id){
+ return prop3Dvect[i];
+ }
+ }
+ return 0;
+#ifndef USE_QT
+ throw "id not found in the data";
+#else
+ return NULL;
+#endif
+
- return NULL;
}
int wxMaracasSurfaceRenderingManager::getMaxIsoValue(int propid) throw(char*){
delete data;
prop3Dvect.pop_back();
}else{
+#ifndef USE_QT
+ throw "id not found in the data";
+#endif
- throw "id not found in the data";
}
}
wxMaracasSurfaceRenderingManagerData* data = this->getViewData(propid);
- data->enableBoxWidget(enable);
+ if(data)
+ data->enableBoxWidget(enable);
}
void wxMaracasSurfaceRenderingManager::Transform(vtkMatrix4x4* tmatrix){
data->saveProp3DSTL(filename);
}
}
+
+void wxMaracasSurfaceRenderingManager::loadProp3DSTL(const char* filename){
+ this->addProp3D(-1, this->getProp3D(filename), filename);
+}
Program: wxMaracas
Module: $RCSfile: wxMaracasSurfaceRenderingManager.h,v $
Language: C++
- Date: $Date: 2011/06/28 16:56:13 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2011/10/05 16:26:55 $
+ Version: $Revision: 1.2 $
Copyright: (c) 2002, 2003
License:
#include "wxMaracasSurfaceRenderingManagerData.h"
+
+
class wxMaracasSurfaceRenderingManager {
public:
**/
vtkImageData* getImageData();
+ virtual void setImageData(vtkImageData* img);
+
/**
** adds or removes an actor depending of the bool value
**/
void enableBoundingBox(int propid, bool enable);
void saveProp3DSTL(int propid,const char* filename);
+
+ void loadProp3DSTL(const char* filename);
+
+
private:
std::vector<wxMaracasSurfaceRenderingManagerData*> prop3Dvect;
#include "volumerendererdata.h"
#include "vtkObjectFactory.h"
-vtkCxxRevisionMacro(VolumeRendererData, "$Revision: 1.6 $");
+vtkCxxRevisionMacro(VolumeRendererData, "$Revision: 1.7 $");
vtkStandardNewMacro(VolumeRendererData);
VolumeRendererData::VolumeRendererData()
{
- VolRendData = 0;
+ VolRendManager = 0;
ImageData = 0;
Renderer = 0;
Interactor = 0;
+ LookUpTable = 0;
+ //ImageDataSeparateComponents = false;
}
void VolumeRendererData::ShowVolume(bool checked){
- if(checked){
- // invariant();
- //cout<<"JPRG::VolumeRendererData::ShowVolume"<<endl;
- if(VolRendData==NULL)
- {
- VolRendData = new VolumeRendererManagerData(ImageData, true);
+
+ try{
+ if(checked){
+ invariant();
+ cout<<"JPRG::VolumeRendererData::ShowVolume"<<endl;
+ if(!VolRendManager){
+ VolRendManager = new VolumeRendererManager();
+ VolRendManager->addVolume(ImageData, Interactor);
+ }
+ if(LookUpTable)
+ VolRendManager->SetLookupTable(LookUpTable);
+ vector< vtkProp3D* > props = VolRendManager->getProps3D();
+ for(unsigned i = 0; i < props.size(); i++){
+ Renderer->AddActor(props[i]);
+ }
+
+ }else{
+ vector< vtkProp3D* > props = VolRendManager->getProps3D();
+ for(unsigned i = 0; i < props.size(); i++){
+ Renderer->RemoveActor(props[i]);
}
- VolRendData->SetLookupTable(LookUpTable);
- Renderer->AddActor(VolRendData->getProp3D());
- }else{
- Renderer->RemoveActor(VolRendData->getProp3D());
- // VolRendData->Delete();
- // VolRendData = 0;
+ delete VolRendManager;
+ VolRendManager = 0;
+ }
+ }catch(char* e){
+ cout<<"Exception in: "<<e<<endl;
+ }catch(exception e){
+ cout<<"Exception in: "<<e.what()<<endl;
}
+
}
void VolumeRendererData::invariant(){
void VolumeRendererData::OpacityChanged(vector<double> greyvalues, vector<double> values){
//invariant();
- if(VolRendData==NULL)
- {
- VolRendData = new VolumeRendererManagerData(ImageData, true);
+ if(VolRendManager==NULL)
+ {
+ ShowVolume(true);
}
- VolRendData->SetLookupTable(LookUpTable);
- VolRendData->setVolumeOpacity(greyvalues,values);
+ VolRendManager->setVolumeOpacity(greyvalues,values);
}
void VolumeRendererData::BoundingBoxChanged(bool checked){
// invariant();
- if(VolRendData==NULL)
+ if(VolRendManager==NULL)
{
- VolRendData = new VolumeRendererManagerData(ImageData, true);
- VolRendData->SetLookupTable(LookUpTable);
+ ShowVolume(true);
}
- if(VolRendData && Interactor){
+ if(VolRendManager && Interactor){
if(checked){
- VolRendData->EnableBoundingBox(Interactor);
+ VolRendManager->EnableBoundingBox(Interactor);
}else{
- VolRendData->DisableBoundingBox();
+ VolRendManager->DisableBoundingBox();
}
}
}
void VolumeRendererData::changeCompositeMIPFunction(int function){
invariant();
- if(VolRendData)
- VolRendData->changeCompositeMIPFunction(function);
+ if(VolRendManager)
+ VolRendManager->changeCompositeMIPFunction(0, function);
+}
+
+/**
+ changes the interoplation type of the volume
+ type = 0 linear
+ type = 1 nearest
+ */
+void VolumeRendererData::changeInterpolationType(int type){
+ invariant();
+ if(VolRendManager)
+ VolRendManager->changeInterpolationType(type);
}
#define VOLUMERENDERERDATA_H
-#include "volumerenderermanagerdata.h"
+#include "volumerenderermanager.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkObject.h"
vtkTypeRevisionMacro(VolumeRendererData,vtkObject);
//
- vtkSetObjectMacro(ImageData, vtkImageData)
- vtkSetObjectMacro(Renderer, vtkRenderer)
- vtkSetObjectMacro(LookUpTable, vtkLookupTable)
- vtkSetObjectMacro(Interactor, vtkRenderWindowInteractor)
+ vtkSetObjectMacro(ImageData, vtkImageData);
+ //vtkSetMacro(ImageDataSeparateComponents, bool);
+
+ vtkSetObjectMacro(Renderer, vtkRenderer);
+ vtkSetObjectMacro(LookUpTable, vtkLookupTable);
+ vtkSetObjectMacro(Interactor, vtkRenderWindowInteractor);
+
+
+
void BoundingBoxChanged(bool checked);
void ShowVolume(bool enable);
void OpacityChanged(vector<double> greyvalues, vector<double> values);
+ /**
+ chages the ray cast function type
+ function = 0 composite
+ function = 1 MIP (maximum intensity pixel)
+ */
void changeCompositeMIPFunction(int function);
+ /**
+ changes the interoplation type of the volume
+ type = 0 linear
+ type = 1 nearest
+ */
+ void changeInterpolationType(int type);
+
protected:
VolumeRendererData();
- VolumeRendererManagerData* VolRendData;
+ VolumeRendererManager* VolRendManager;
vtkImageData* ImageData;
vtkRenderer* Renderer;
vtkLookupTable* LookUpTable;
vtkRenderWindowInteractor* Interactor;
+// bool ImageDataSeparateComponents;
+
+
private:
void invariant();
# 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")
+ FILE(GLOB ${LIBRARY_NAME}_HEADERS "*.h" "*.txx" "${PROJECT_BINARY_DIR}/lib/GUI/Qt/VTK/SurfaceRenderer/*.h")
set(${LIBRARY_NAME}_SOURCES ${${LIBRARY_NAME}_SOURCES} ${${LIBRARY_NAME}_UIS_H})
--- /dev/null
+#include "qtsurfacerenderer.h"
+#include "ui_qtsurfacerenderer.h"
+
+
+#include <qtsurfacerendererpanel.h>
+
+QtSurfaceRenderer::QtSurfaceRenderer(QWidget *parent) :
+ QWidget(parent),
+ ui(new Ui::QtSurfaceRenderer)
+{
+ ui->setupUi(this);
+
+ this->ui->tabWidgetSurface->removeTab(1);
+ this->ui->tabWidgetSurface->removeTab(0);
+
+
+ QtSurfaceRendererPanel* surfacepanel = new QtSurfaceRendererPanel(this);
+ this->ui->tabWidgetSurface->addTab(surfacepanel, QString("Surface Rendering"));
+
+ Renderer = 0;
+ Interactor = 0;
+}
+
+QtSurfaceRenderer::~QtSurfaceRenderer()
+{
+ delete ui;
+}
+
+void QtSurfaceRenderer::SetImageData(vtkImageData* img){
+ this->ui->tabWidgetSurface->setCurrentIndex(0);
+ QtSurfaceRendererPanel* surfacepanel = (QtSurfaceRendererPanel*)this->ui->tabWidgetSurface->currentWidget();
+ surfacepanel->setInteractor(Interactor);
+ surfacepanel->setRenderer(Renderer);
+ surfacepanel->setImageData(img);
+}
+
+void QtSurfaceRenderer::on_pushbuttonAddTab_clicked()
+{
+
+ QtSurfaceRendererPanel* surfacepanel = new QtSurfaceRendererPanel(this);
+ surfacepanel->setRenderer(Renderer);
+ surfacepanel->setInteractor(Interactor);
+
+ this->ui->tabWidgetSurface->addTab(surfacepanel, QString("Surface Rendering"));
+}
+
+void QtSurfaceRenderer::on_tabWidgetSurface_tabCloseRequested(int index)
+{
+ if(index != 0){
+
+ QtSurfaceRendererPanel* surfacepanel = (QtSurfaceRendererPanel*)this->ui->tabWidgetSurface->currentWidget();
+ surfacepanel->enableBoundingBox(0, false);
+ surfacepanel->deleteActor(0);
+
+ this->ui->tabWidgetSurface->removeTab(index);
+ }
+}
+
--- /dev/null
+#ifndef QTSURFACERENDERER_H
+#define QTSURFACERENDERER_H
+
+#include <QWidget>
+#include "wxMaracasSurfaceRenderingManager.h"
+
+namespace Ui {
+ class QtSurfaceRenderer;
+}
+
+class QtSurfaceRenderer : public QWidget,public vtkObject
+{
+ Q_OBJECT
+
+public:
+ explicit QtSurfaceRenderer(QWidget *parent = 0);
+
+ ~QtSurfaceRenderer();
+
+ vtkSetMacro(Renderer, vtkRenderer*);
+ vtkSetMacro(Interactor, vtkRenderWindowInteractor*);
+
+ void SetImageData(vtkImageData* img);
+private slots:
+ void on_pushbuttonAddTab_clicked();
+
+ void on_tabWidgetSurface_tabCloseRequested(int index);
+
+
+private:
+ Ui::QtSurfaceRenderer *ui;
+
+ vtkRenderer* Renderer;
+ vtkRenderWindowInteractor* Interactor;
+};
+
+#endif // QTSURFACERENDERER_H
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>QtSurfaceRenderer</class>
+ <widget class="QWidget" name="QtSurfaceRenderer">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>266</width>
+ <height>454</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QPushButton" name="pushbuttonAddTab">
+ <property name="text">
+ <string>+</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QTabWidget" name="tabWidgetSurface">
+ <property name="currentIndex">
+ <number>0</number>
+ </property>
+ <property name="elideMode">
+ <enum>Qt::ElideNone</enum>
+ </property>
+ <property name="tabsClosable">
+ <bool>true</bool>
+ </property>
+ <widget class="QWidget" name="tab">
+ <attribute name="title">
+ <string>SN</string>
+ </attribute>
+ <zorder>pushbuttonAddTab</zorder>
+ </widget>
+ <widget class="QWidget" name="tab_2">
+ <attribute name="title">
+ <string>SN2</string>
+ </attribute>
+ </widget>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
#include "Color.xpm"
#include "Save.xpm"
+#include "OpenImage.xpm"
QtSurfaceRendererPanel::QtSurfaceRendererPanel(QWidget *parent) :
QWidget(parent),
this->ui->pushButtonColorChooser->setIcon(QIcon(Color_xpm));
this->ui->pushButtonSave->setIcon(QIcon(Save_xpm));
+ this->ui->pushButtonOpen->setIcon(QIcon(OpenImage_xpm));
}
QtSurfaceRendererPanel::~QtSurfaceRendererPanel()
-{
+{
delete ui;
}
-void QtSurfaceRendererPanel::SetImageData(vtkImageData* img){
- this->addPropMHD(0, img, "");
- this->enableBoundingBox(0, false);
-
+void QtSurfaceRendererPanel::setImageData(vtkImageData* img){
double *range =img->GetScalarRange();
- this->ui->horizontalSliderMinIso->setRange(range[0], range[1] - 1);
+ this->ui->horizontalSliderMinIso->setRange(range[0], range[1]);
- this->ui->horizontalSliderMaxIso->setRange(range[0] + 1, range[1]);
+ this->ui->horizontalSliderMaxIso->setRange(range[0], range[1]);
+
+ wxMaracasSurfaceRenderingManager::setImageData(img);
}
void QtSurfaceRendererPanel::on_OpacitySlider_valueChanged(int value)
void QtSurfaceRendererPanel::on_checkBox_clicked(bool checked)
{
this->addRemoveActor(0, checked);
+ if(!checked){
+ this->ui->checkBoxBoundingBox->setCheckState(Qt::Unchecked);
+ this->on_checkBoxBoundingBox_clicked(false);
+ }
}
void QtSurfaceRendererPanel::on_horizontalSliderMaxIso_valueChanged(int value)
void QtSurfaceRendererPanel::on_pushButtonSave_clicked()
{
QString filename = QFileDialog::getSaveFileName(this,
- tr("Save STL File"),
+ tr("Save Mesh File"),
QDir::currentPath(),
- tr("STL files (*.stl);") );
+ tr("Mesh files (*.stl *.ply)") );
if( !filename.isNull() ){
- filename.append(".stl");
+ //filename.append(".stl");
this->saveProp3DSTL(0, filename.toStdString().c_str());
}
this->enableBoundingBox(0, checked);
}
+
+void QtSurfaceRendererPanel::on_pushButtonOpen_clicked(bool checked)
+{
+
+}
+
+void QtSurfaceRendererPanel::on_pushButtonOpen_clicked()
+{
+ QString filename = QFileDialog::getOpenFileName(this, tr("Load Mesh File"), QDir::currentPath(), tr("Mesh files (*.stl *.ply)"));
+
+ if(!filename.isNull()){
+ this->loadProp3DSTL(filename.toStdString().c_str());
+ }
+}
explicit QtSurfaceRendererPanel(QWidget *parent = 0);
~QtSurfaceRendererPanel();
- void SetImageData(vtkImageData* img);
-
+ virtual void setImageData(vtkImageData* img);
private slots:
void on_OpacitySlider_valueChanged(int value);
void on_checkBoxBoundingBox_clicked(bool checked);
+ void on_pushButtonOpen_clicked(bool checked);
+
+ void on_pushButtonOpen_clicked();
+
+
private:
Ui::QtSurfaceRendererPanel *ui;
<rect>
<x>0</x>
<y>0</y>
- <width>145</width>
+ <width>197</width>
<height>299</height>
</rect>
</property>
</property>
</widget>
</item>
- <item row="0" column="1">
+ <item row="0" column="2">
<widget class="QCheckBox" name="checkBoxBoundingBox">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
- <item row="2" column="0" colspan="2">
+ <item row="1" column="2">
+ <widget class="QPushButton" name="pushButtonOpen">
+ <property name="text">
+ <string/>
+ </property>
+ <property name="icon">
+ <iconset>
+ <normaloff>../../../../data/Icons/OpenImage.xpm</normaloff>../../../../data/Icons/OpenImage.xpm</iconset>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" colspan="3">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
- <item row="3" column="0" colspan="2">
+ <item row="3" column="0" colspan="3">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="LabelOpacity">
</item>
</layout>
</item>
- <item row="4" column="0" colspan="2">
+ <item row="4" column="0" colspan="3">
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
- <item row="5" column="0" colspan="2">
+ <item row="5" column="0" colspan="3">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="labelIsoValue">
# 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} )
#include "qtvtkviewer.h"
+#include "vtkImageMapToColors.h"
+
QtVTKViewer::QtVTKViewer(QWidget* parent)
: QVTKWidget(parent)
{
this->GetRenderWindow()->AddRenderer(vtkRenderer::New());
- this->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->SetBackground(0,0,0);
+ this->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->SetBackground(1,1,1);
SuperImagePlaneWidget::initialize(this->GetRenderWindow()->GetInteractor());
#endif
}
}
+
+void QtVTKViewer::SetOutputFormatToRGBA(){
+ _xwidget->GetColorMap()->SetOutputFormatToRGBA();
+ _ywidget->GetColorMap()->SetOutputFormatToRGBA();
+ _zwidget->GetColorMap()->SetOutputFormatToRGBA();
+}
typedef ImagePlaneWidget SuperImagePlaneWidget;
+ void SetOutputFormatToRGBA();
private:
void invariant();
* finding an object in the scene
*
*/
- double _rayorigin[4];
+ double _rayorigin[4];
protected:
// overloaded mouse press handler
QtVTKViewerWidget::QtVTKViewerWidget(QWidget *parent) :
- QWidget(parent)
+ QWidget(parent),
+ ui(new Ui::QtVTKViewerWidget)
{
- setupUi(this);
+ ui->setupUi(this);
+
+ ui->m_VolumeRender->SetRenderer(this->getRenderer());
+ ui->m_VolumeRender->SetInteractor(ui->_qtvtkviewer->GetRenderWindow()->GetInteractor());
+
+ ui->m_SurfaceRender->SetRenderer(this->getRenderer());
+ ui->m_SurfaceRender->SetInteractor(ui->_qtvtkviewer->GetRenderWindow()->GetInteractor());
- this->m_VolumeRender->SetRenderer(this->getRenderer());
- this->m_VolumeRender->SetInteractor(this->_qtvtkviewer->GetRenderWindow()->GetInteractor());
- this->m_SurfaceRender->setRenderer(this->getRenderer());
- this->m_SurfaceRender->setInteractor(this->_qtvtkviewer->GetRenderWindow()->GetInteractor());
}
QtVTKViewerWidget::~QtVTKViewerWidget()
}
vtkRenderer* QtVTKViewerWidget::getRenderer(){
- return this->_qtvtkviewer->GetRenderWindow()->GetRenderers()->GetFirstRenderer();
+ return ui->_qtvtkviewer->GetRenderWindow()->GetRenderers()->GetFirstRenderer();
}
void QtVTKViewerWidget::setImage(vtkImageData* img){
- this->_qtvtkviewer->setImage(img);
- this->m_VolumeRender->SetImageData(img);
- this->m_SurfaceRender->SetImageData(img);
+
+
+ ui->_qtvtkviewer->setImage(img);
+ ui->m_VolumeRender->SetImageData(img);
+ ui->m_SurfaceRender->SetImageData(img);
+
+ int *extent = img->GetExtent();
+
+
+ ui->horizontalSliderX->setRange(extent[0], extent[1]);
+ ui->horizontalSliderY->setRange(extent[2], extent[3]);
+ ui->horizontalSliderZ->setRange(extent[4], extent[5]);
+
}
void QtVTKViewerWidget::SetLookupTable(vtkLookupTable *lookuptable){
- this->_qtvtkviewer->SetLookupTable(lookuptable);
- this->m_VolumeRender->SetLookUpTable(lookuptable);
+
+ ui->_qtvtkviewer->SetLookupTable(lookuptable);
+ ui->m_VolumeRender->SetLookUpTable(lookuptable);
}
void QtVTKViewerWidget::on_checkBoxShowPlanes_clicked(){
- this->_qtvtkviewer->showPlanes(checkBoxShowPlanes->isChecked());
+ ui->_qtvtkviewer->showPlanes(ui->checkBoxShowPlanes->isChecked());
+}
+
+void QtVTKViewerWidget::SetOutputFormatToRGBA(){
+ ui->_qtvtkviewer->SetOutputFormatToRGBA();
+}
+
+void QtVTKViewerWidget::on_checkBoxShowImageActor_clicked(bool checked)
+{
+ if(!(ui->_qtvtkviewer->showImageActors(checked))){
+ ui->checkBoxShowImageActor->setCheckState(Qt::Unchecked);
+ }
+}
+
+void QtVTKViewerWidget::on_horizontalSliderX_valueChanged(int value)
+{
+
+ ui->lineEditX->setText(QString::number(value));
+ ui->_qtvtkviewer->setSliceXImageActor(value);
+
+}
+
+void QtVTKViewerWidget::on_horizontalSliderY_valueChanged(int value)
+{
+ ui->lineEditY->setText(QString::number(value));
+ ui->_qtvtkviewer->setSliceYImageActor(value);
+}
+
+void QtVTKViewerWidget::on_horizontalSliderZ_valueChanged(int value)
+{
+ ui->lineEditZ->setText(QString::number(value));
+ ui->_qtvtkviewer->setSliceZImageActor(value);
}
class QtVTKViewerWidget;
}
-class QtVTKViewerWidget : public QWidget, Ui_QtVTKViewerWidget
+class QtVTKViewerWidget : public QWidget
{
Q_OBJECT
void SetLookupTable(vtkLookupTable *lookuptable);
+ void SetOutputFormatToRGBA();
+
private slots:
void on_checkBoxShowPlanes_clicked();
+ void on_checkBoxShowImageActor_clicked(bool checked);
+
+ void on_horizontalSliderX_valueChanged(int value);
+
+ void on_horizontalSliderY_valueChanged(int value);
+
+ void on_horizontalSliderZ_valueChanged(int value);
+
+private:
+ Ui::QtVTKViewerWidget *ui;
+ bool _firstset;
+
};
#endif // QTVTKVIEWERWIDGET_H
</sizepolicy>
</property>
<property name="currentIndex">
- <number>2</number>
+ <number>0</number>
</property>
<widget class="QWidget" name="page">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
- <width>98</width>
- <height>28</height>
+ <width>155</width>
+ <height>505</height>
</rect>
</property>
<attribute name="label">
<string>Image Widget</string>
</attribute>
- <widget class="QCheckBox" name="checkBoxShowPlanes">
- <property name="enabled">
- <bool>true</bool>
- </property>
+ <widget class="QWidget" name="">
<property name="geometry">
<rect>
- <x>10</x>
+ <x>0</x>
<y>20</y>
- <width>111</width>
- <height>22</height>
+ <width>201</width>
+ <height>246</height>
</rect>
</property>
- <property name="text">
- <string>Show Planes</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- <property name="tristate">
- <bool>false</bool>
- </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <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>
+ <layout class="QFormLayout" name="formLayout">
+ <item row="0" column="0" colspan="2">
+ <widget class="QCheckBox" name="checkBoxShowImageActor">
+ <property name="text">
+ <string>Show Image Actor</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <spacer name="horizontalSpacer_4">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>18</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="1" column="1">
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="labelx">
+ <property name="text">
+ <string>X slice =</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="0" column="2">
+ <widget class="QLineEdit" name="lineEditX"/>
+ </item>
+ <item row="1" column="0" colspan="3">
+ <widget class="QSlider" name="horizontalSliderX">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Y slice =</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="2" column="2">
+ <widget class="QLineEdit" name="lineEditY"/>
+ </item>
+ <item row="3" column="0" colspan="3">
+ <widget class="QSlider" name="horizontalSliderY">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Z slice =</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <spacer name="horizontalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="4" column="2">
+ <widget class="QLineEdit" name="lineEditZ"/>
+ </item>
+ <item row="5" column="0" colspan="3">
+ <widget class="QSlider" name="horizontalSliderZ">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ </layout>
</widget>
</widget>
<widget class="QWidget" name="page_2">
<rect>
<x>0</x>
<y>0</y>
- <width>98</width>
- <height>28</height>
+ <width>155</width>
+ <height>505</height>
</rect>
</property>
<attribute name="label">
<x>0</x>
<y>0</y>
<width>181</width>
- <height>121</height>
+ <height>221</height>
</rect>
</property>
<property name="sizePolicy">
<attribute name="label">
<string>Surface Rendering</string>
</attribute>
- <widget class="QtSurfaceRendererPanel" name="m_SurfaceRender" native="true">
+ <widget class="QtSurfaceRenderer" name="m_SurfaceRender" native="true">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
- <width>151</width>
- <height>271</height>
+ <width>221</width>
+ <height>381</height>
</rect>
</property>
</widget>
<verstretch>0</verstretch>
</sizepolicy>
</property>
+ <zorder>toolBox</zorder>
+ <zorder>toolBox</zorder>
+ <zorder>toolBox</zorder>
</widget>
</item>
</layout>
<container>1</container>
</customwidget>
<customwidget>
- <class>QtSurfaceRendererPanel</class>
+ <class>QtSurfaceRenderer</class>
<extends>QWidget</extends>
- <header location="global">qtsurfacerendererpanel.h</header>
+ <header location="global">qtsurfacerenderer.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
- <connections/>
+ <connections>
+ <connection>
+ <sender>checkBoxShowImageActor</sender>
+ <signal>clicked(bool)</signal>
+ <receiver>horizontalSliderX</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>81</x>
+ <y>132</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>81</x>
+ <y>182</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>checkBoxShowImageActor</sender>
+ <signal>clicked(bool)</signal>
+ <receiver>horizontalSliderY</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>128</x>
+ <y>122</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>124</x>
+ <y>236</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>checkBoxShowImageActor</sender>
+ <signal>clicked(bool)</signal>
+ <receiver>horizontalSliderZ</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>48</x>
+ <y>120</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>87</x>
+ <y>297</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
</ui>
{
try{
ShowVolume(checked);
- on_opacitySlider_valueChanged(this->ui->opacitySlider->value());
+ //JCP 27/09/12
+ //on_opacitySlider_valueChanged(this->ui->opacitySlider->value());
}catch(char * e){
cout<<e<<endl;
QMessageBox::critical(this, tr("Volume Rendering"), tr(e), QMessageBox::Ok);
+ }catch(exception e){
+ cout<<e.what()<<endl;
+ QMessageBox::critical(this, tr("Volume Rendering"), tr(e.what()), QMessageBox::Ok);
}
}
double* range = ImageData->GetScalarRange();
vector<double> greylevel;
- greylevel.push_back(range[0]);
+ greylevel.push_back(0);
+ greylevel.push_back(1);
greylevel.push_back(range[1]);
vector<double> vectvalue;
+ vectvalue.push_back(0);
vectvalue.push_back(value/100.0);
vectvalue.push_back(value/100.0);
this->changeCompositeMIPFunction(0);
}
}
+
+void QtVolumeRendererPanel::on_radioButtonLinear_clicked(bool checked)
+{
+ if(checked){
+ this->changeInterpolationType(0);
+ }
+}
+
+void QtVolumeRendererPanel::on_radioButtonNearest_clicked(bool checked)
+{
+ if(checked){
+ this->changeInterpolationType(1);
+ }
+}
+
+void QtVolumeRendererPanel::on_radioButtonMinIP_clicked(bool checked)
+{
+ if(checked){
+ this->changeCompositeMIPFunction(2);
+ }
+}
void on_radioButtonComposite_clicked(bool checked);
+ void on_radioButtonLinear_clicked(bool checked);
+
+ void on_radioButtonNearest_clicked(bool checked);
+
+ void on_radioButtonMinIP_clicked(bool checked);
+
private:
Ui::QtVolumeRendererPanel *ui;
void invariant();
<rect>
<x>0</x>
<y>0</y>
- <width>186</width>
- <height>137</height>
+ <width>275</width>
+ <height>213</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
+ <layout class="QGridLayout" name="gridLayout_4">
+ <item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="checkBoxShowVolume">
</item>
</layout>
</item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_2">
- <item>
+ <item row="1" column="0">
+ <layout class="QGridLayout" name="gridLayout_3">
+ <item row="0" column="0" colspan="2">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Ray Cast Function</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
<widget class="QRadioButton" name="radioButtonComposite">
+ <property name="toolTip">
+ <string>Change the Ray Cast Function To Composite (All)</string>
+ </property>
<property name="text">
<string>Composite</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
+ <property name="autoExclusive">
+ <bool>true</bool>
+ </property>
<attribute name="buttonGroup">
<string>buttonGroup</string>
</attribute>
</widget>
</item>
- <item>
+ <item row="1" column="1">
<widget class="QRadioButton" name="radioButtonMIP">
+ <property name="toolTip">
+ <string>Change the Ray Cast Function To Maximum Intensity Pixel</string>
+ </property>
<property name="text">
- <string>MIP </string>
+ <string>MaxIP </string>
</property>
<property name="checked">
<bool>false</bool>
</property>
+ <property name="autoExclusive">
+ <bool>true</bool>
+ </property>
<attribute name="buttonGroup">
<string>buttonGroup</string>
</attribute>
</widget>
</item>
+ <item row="1" column="2">
+ <widget class="QRadioButton" name="radioButtonMinIP">
+ <property name="toolTip">
+ <string>Change the Ray Cast Function To Minimum Intensity Pixel</string>
+ </property>
+ <property name="text">
+ <string>MinIP</string>
+ </property>
+ <property name="autoExclusive">
+ <bool>true</bool>
+ </property>
+ <attribute name="buttonGroup">
+ <string>buttonGroup</string>
+ </attribute>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="2" column="0">
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Interpolation</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QRadioButton" name="radioButtonLinear">
+ <property name="text">
+ <string>Linear</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <attribute name="buttonGroup">
+ <string>buttonGroup_2</string>
+ </attribute>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QRadioButton" name="radioButtonNearest">
+ <property name="text">
+ <string>Nearest</string>
+ </property>
+ <attribute name="buttonGroup">
+ <string>buttonGroup_2</string>
+ </attribute>
+ </widget>
+ </item>
</layout>
</item>
- <item>
+ <item row="3" column="0">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
- <x>57</x>
- <y>21</y>
+ <x>134</x>
+ <y>93</y>
</hint>
<hint type="destinationlabel">
- <x>110</x>
- <y>25</y>
+ <x>524</x>
+ <y>93</y>
</hint>
</hints>
</connection>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
- <x>61</x>
- <y>30</y>
+ <x>134</x>
+ <y>93</y>
</hint>
<hint type="destinationlabel">
- <x>57</x>
- <y>126</y>
+ <x>77</x>
+ <y>626</y>
</hint>
</hints>
</connection>
<connection>
<sender>checkBoxShowVolume</sender>
<signal>toggled(bool)</signal>
- <receiver>radioButtonComposite</receiver>
+ <receiver>radioButtonLinear</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
- <x>41</x>
- <y>23</y>
+ <x>134</x>
+ <y>93</y>
</hint>
<hint type="destinationlabel">
- <x>36</x>
- <y>54</y>
+ <x>29</x>
+ <y>495</y>
</hint>
</hints>
</connection>
<connection>
<sender>checkBoxShowVolume</sender>
<signal>toggled(bool)</signal>
- <receiver>radioButtonMIP</receiver>
+ <receiver>radioButtonNearest</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
- <x>69</x>
- <y>16</y>
+ <x>134</x>
+ <y>93</y>
</hint>
<hint type="destinationlabel">
- <x>143</x>
- <y>46</y>
+ <x>532</x>
+ <y>495</y>
</hint>
</hints>
</connection>
</connections>
<buttongroups>
+ <buttongroup name="buttonGroup_2"/>
<buttongroup name="buttonGroup">
<property name="exclusive">
<bool>true</bool>
#include <vtkSmartPointer.h>
#include "vtkSTLWriter.h"
+#include "vtkPLYWriter.h"
/********************************************************************************************
** Start of data viewmanagerData
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();
+
+ std::string filena(filename);
+ std::string ext = filena.substr(filena.find_last_of("."), 4);
+ if(ext.compare(PLY) == 0){
+ vtkSmartPointer<vtkPLYWriter> plywriter =
+ vtkSmartPointer<vtkPLYWriter>::New();
+ plywriter->SetFileName(filename);
+ plywriter->SetInput(_dataMapper->GetInput());
+ plywriter->Write();
+ }else if(ext.compare(PLY) == 0){
+ vtkSmartPointer<vtkSTLWriter> stlWriter =
+ vtkSmartPointer<vtkSTLWriter>::New();
+ stlWriter->SetFileName(filename);
+ stlWriter->SetInput(_dataMapper->GetInput());
+ stlWriter->SetFileTypeToBinary();
+ stlWriter->Write();
+ }else{
+ cout<<"unsupported format"<<endl;
+ }
}
}
#include "vtkBoxWidget.h"
+#define PLY ".ply"
+#define STL ".stl"
+
class wxMaracasSurfaceRenderingManagerData {
_boxWidgetS1->HandlesOn ();
- _boxWidgetS1->EnabledOn();
+ _boxWidgetS1->EnabledOff();
}else{
_dataMapper->SetInput(_cleanFilter->GetOutput());
}
}else{
_boxWidgetS1->EnabledOff();
}
+ }else{
+ cout<<"box widget not initialized!"<<endl;
}
}
#include "imageplanewidget.h"
+#include "vtkSmartPointer.h"
+#include "vector"
+#include "vtkImageActor.h"
+#include "vtkImageAppendComponents.h"
+#include "vtkRenderWindowInteractor.h"
+
+using namespace std;
+
ImagePlaneWidget::ImagePlaneWidget()
{
_img = 0;
_xwidget = 0;
_ywidget = 0;
_zwidget = 0;
+ m_Interactor = 0;
+ _imageactorx = 0;
+ _imageactory = 0;
+ _imageactorz = 0;
}
void ImagePlaneWidget::initialize(vtkRenderWindowInteractor* interactor){
+ m_Interactor = interactor;
// Plane widget
_xwidget = vtkImagePlaneWidget::New( );
_ywidget = vtkImagePlaneWidget::New( );
_xwidget->SetInteractor( interactor );
_ywidget->SetInteractor( interactor );
_zwidget->SetInteractor( interactor );
+
}
+bool ImagePlaneWidget::showImageActors(bool show){
+ if(show && m_Interactor){
+ if(!_imageactorx){
+ initializeImageActors();
+ }
+ m_Interactor->GetRenderWindow ()->GetRenderers ()->GetFirstRenderer ()->AddViewProp(_imageactorx);
+ m_Interactor->GetRenderWindow ()->GetRenderers ()->GetFirstRenderer ()->AddViewProp(_imageactory);
+ m_Interactor->GetRenderWindow ()->GetRenderers ()->GetFirstRenderer ()->AddViewProp(_imageactorz);
+ return true;
+ }else if(_imageactorx){
+ m_Interactor->GetRenderWindow ()->GetRenderers ()->GetFirstRenderer ()->RemoveViewProp(_imageactorx);
+ m_Interactor->GetRenderWindow ()->GetRenderers ()->GetFirstRenderer ()->RemoveViewProp(_imageactory);
+ m_Interactor->GetRenderWindow ()->GetRenderers ()->GetFirstRenderer ()->RemoveViewProp(_imageactorz);
+ return true;
+ }
+
+ return false;
+}
+
+void ImagePlaneWidget::initializeImageActors(){
+
+ int *w_ext = _img->GetWholeExtent();
+ //cout<<w_ext[0]<<" "<<w_ext[1]<<" "<<w_ext[2]<<" "<<w_ext[3]<<" "<<w_ext[4]<<" "<<w_ext[5]<<" "<<endl;
+ _imageactorx = vtkImageActor::New();
+ _imageactorx->SetInput(_img);
+ xslice = (w_ext[4] + w_ext[5])/2;
+ _imageactorx->SetDisplayExtent(w_ext[0], w_ext[1], w_ext[2], w_ext[3], xslice, xslice);
+
+ _imageactory = vtkImageActor::New();
+ _imageactory->SetInput(_img);
+ yslice = (w_ext[2] + w_ext[3])/2;
+ _imageactory->SetDisplayExtent(w_ext[0], w_ext[1], yslice, yslice, w_ext[4], w_ext[5]);
+
+ _imageactorz = vtkImageActor::New();
+ _imageactorz->SetInput(_img);
+ zslice = (w_ext[0] + w_ext[1])/2;
+ _imageactorz->SetDisplayExtent(zslice, zslice, w_ext[2], w_ext[3], w_ext[4], w_ext[5]);
+
+
+}
void ImagePlaneWidget::setImage(vtkImageData* img){
_img = img;
throw "The widgets are not initialized";
}
}
+
+
+void ImagePlaneWidget::setSliceXImageActor(int value){
+ int *w_ext = _img->GetWholeExtent();
+ xslice = value;
+ _imageactorx->SetDisplayExtent(w_ext[0], w_ext[1], w_ext[2], w_ext[3], xslice, xslice);
+ m_Interactor->Render();
+}
+void ImagePlaneWidget::setSliceYImageActor(int value){
+ int *w_ext = _img->GetWholeExtent();
+ yslice = value;
+ _imageactory->SetDisplayExtent(w_ext[0], w_ext[1], yslice, yslice, w_ext[4], w_ext[5]);
+ m_Interactor->Render();
+}
+void ImagePlaneWidget::setSliceZImageActor(int value){
+ int *w_ext = _img->GetWholeExtent();
+ zslice = value;
+ _imageactorz->SetDisplayExtent(zslice, zslice, w_ext[2], w_ext[3], w_ext[4], w_ext[5]);
+ m_Interactor->Render();
+}
#include "vtkImagePlaneWidget.h"
#include "vtkImageData.h"
#include "vtkColorTransferFunction.h"
+#include "vtkImageViewer2.h"
+#include "vtkSmartPointer.h"
class ImagePlaneWidget
{
virtual void SetColorTable(vtkColorTransferFunction *lookuptable);
- virtual void showPlanes(bool show);
+ virtual void showPlanes(bool show);
- void initialize(vtkRenderWindowInteractor* interactor);
+ virtual bool showImageActors(bool show);
+
+ void setSliceXImageActor(int value);
+ void setSliceYImageActor(int value);
+ void setSliceZImageActor(int value);
protected:
vtkImageData* _img;
vtkImagePlaneWidget* _xwidget;
vtkImagePlaneWidget* _ywidget;
vtkImagePlaneWidget* _zwidget;
+ vtkImageActor * _imageactorx;
+ vtkImageActor* _imageactory;
+ vtkImageActor* _imageactorz;
+
+ int xslice;
+ int yslice;
+ int zslice;
+
+ void initialize(vtkRenderWindowInteractor* interactor);
+
+ void initializeImageActors();
+
private:
void invariant();
+
+ vtkRenderWindowInteractor* m_Interactor;
+
};
#endif // IMAGEPLANEWIDGET_H
Program: wxMaracas
Module: $RCSfile: volumerenderermanager.cxx,v $
Language: C++
- Date: $Date: 2011/05/31 19:03:03 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2011/10/05 16:27:04 $
+ Version: $Revision: 1.2 $
Copyright: (c) 2002, 2003
License:
#include <vtkMetaImageReader.h>
#include <vtkImageCast.h>
+
+#include "vtkImageLuminance.h"
+#include "vtkImageAppendComponents.h"
+#include "vtkSmartPointer.h"
+
+#include <map>
+
+using namespace std;
+
/**
** Start of the manager class
**/
_idCount=0;
}
VolumeRendererManager::~VolumeRendererManager(){
+ _renderer = 0;
+ _idCount=0;
+ image = 0;
+ for(unsigned i = 0; i < prop3Dvect.size();i++){
+ prop3Dvect[i]->Delete();
+ }
+ prop3Dvect.clear();
}
/**
_renderer->Render();
}
+/**
+* @pre The image can have one or multiple components per voxel, and volume rendering is performed seprately over the
+ three of them. If the image has multiple components and the separate components flag is set to false, then
+ the vtkImageAppendComponents is used to create a single image.
+* @post The volume rendering is performed over the image vol
+* @param vtkImageData* the image volume
+* @param bool separatecomponents, if the image has multiple components, then a mapper is used for each of the channels
+ if this flag is set to false and the volume has multiple components, vtkImageAppendComponents is used to create
+ a single representation of the image.
+*/
+int VolumeRendererManager::addVolume(vtkImageData* img, vtkRenderWindowInteractor* interactor, bool independentcomponents){
+ if(img->GetNumberOfScalarComponents() > 1 && !independentcomponents){
+
+
+ image = img;
+
+
+ vtkSmartPointer< vtkImageLuminance > luminance = vtkSmartPointer< vtkImageLuminance >::New();
+ luminance->SetInput(img);
+ luminance->Update();
+
+ vtkSmartPointer< vtkImageAppendComponents > append = vtkSmartPointer< vtkImageAppendComponents >::New();
+ append->SetInput(0, img);
+ append->SetInput(1, luminance->GetOutput());
+ append->Update();
+
+
+
+ VolumeRendererManagerData* data = new VolumeRendererManagerData(append->GetOutput(), true);
+ data->SetIndependentComponents(independentcomponents);
+
+
+ prop3Dvect.push_back(data);
+
+ data->setId(_idCount);
+ _idCount++;
+
+ return _idCount-1;
+
+
+ /*image = img;
+
+ vector< vtkImageData* > vectimg;
+ GetImages(img, vectimg);
+ vtkBoxWidget* boxw = 0;
+ for(unsigned i = 0; i < vectimg.size(); i++){
+ VolumeRendererManagerData* data = new VolumeRendererManagerData(vectimg[i], "");
+
+ vtkColorTransferFunction* colorf = data->GetColorFunction();
+ colorf->RemoveAllPoints();
+ double r = 0, g = 0, b = 0;
+ for(unsigned j = 0; j < 255; j++){
+
+ if(i == 0){
+ r = j/255.0;
+ g = 0;
+ b = 0;
+ }else if(i == 1){
+ r = 0;
+ g = j/255.0;
+ b = 0;
+ }else if(i == 2){
+ r = 0;
+ g = 0;
+ b = j/255.0;
+ }
+
+ colorf->AddRGBPoint(j, r, g, b);
+ }
+
+ prop3Dvect.push_back(data);
+
+ data->setId(_idCount);
+ _idCount++;
+
+ if(!boxw){
+ EnableBoundingBox(interactor, data->getId());
+ DisableBoundingBox(data->getId());
+ boxw = data->GetBoxWidget();
+ }else{
+ data->SetBoxWidget(boxw);
+ }
+ }
+
+ boxw->RemoveAllObservers();
+
+ vtkBoxWidgetCallback *callback = vtkBoxWidgetCallback::New();
+
+ for(unsigned i = 0; i < prop3Dvect.size(); i++){
+ VolumeRendererManagerData* data = prop3Dvect[i];
+ callback->AddMapper(data->GetVolumeMapper());
+ }
+
+ boxw->AddObserver(vtkCommand::InteractionEvent, callback);
+ callback->Delete();
+
+ return _idCount-1;*/
+
+ /*vtkImageData* imgshort = 0;
+ imgshort = vtkImageData::New();
+ imgshort->SetNumberOfScalarComponents(1);
+ imgshort->SetExtent(img->GetExtent());
+ imgshort->SetSpacing(img->GetSpacing());
+ imgshort->SetOrigin(img->GetOrigin());
+ imgshort->SetScalarTypeToUnsignedShort();
+ imgshort->AllocateScalars();
+ GetImageDouble(img, imgshort);
+
+ VolumeRendererManagerData* data = new VolumeRendererManagerData(imgshort, "");
+
+ vtkColorTransferFunction* colorf = data->GetColorFunction();
+ colorf->RemoveAllPoints();
+
+ map< unsigned short, vector< double > > colormap;
+
+ int *extent = img->GetExtent();
+
+ for(unsigned i = extent[0]; i < extent[1]; i++){
+ for(unsigned j = extent[2]; j < extent[3]; j++){
+ for(unsigned k = extent[4]; k < extent[5]; k++){
+
+ unsigned char *imgpoint = ((unsigned char*)img->GetScalarPointer(i, j, k));
+ double temp = (double)(0.299*imgpoint[0] + 0.587*imgpoint[1] + 0.114*imgpoint[2]);
+ unsigned short val = temp*255.0;
+
+ vector< double > rgb;
+ rgb.push_back(0.299*imgpoint[0]);
+ rgb.push_back(0.587*imgpoint[1]);
+ rgb.push_back(0.114*imgpoint[2]);
+
+ colormap[val] = rgb;
+ }
+ }
+ }
+
+
+
+ map< unsigned short, vector< double > >::iterator it;
+ for(it = colormap.begin(); it != colormap.end(); ++it){
+
+ colorf->AddRGBPoint((*it).first, (*it).second[0] / 255.0, (*it).second[1] / 255.0, (*it).second[2] / 255.0);
+ }
+
+ prop3Dvect.push_back(data);
+
+ data->setId(_idCount);
+ EnableBoundingBox(interactor, data->getId());
+ DisableBoundingBox(data->getId());
+ _idCount++;*/
+
+
+ }else{
+ image = img;
+
+ VolumeRendererManagerData* data = new VolumeRendererManagerData(img, "");
+ prop3Dvect.push_back(data);
+
+
+ data->setId(_idCount);
+ _idCount++;
+
+ EnableBoundingBox(interactor, data->getId());
+ DisableBoundingBox(data->getId());
+
+
+
+ return data->getId();
+
+ }
+}
+
+/**
+ * @pre the image is not null and has more than one scalar component
+ * @post Each component in the image is put in a single image
+ * @param vtkImageData* img, multiple component image i.e. an image of vectors like an rgb
+ * @return vtkImageData* double type image
+ */
+void VolumeRendererManager::GetImageDouble(vtkImageData* img, vtkImageData* imgushort){
+
+
+ int *extent = img->GetExtent();
+
+ for(unsigned i = extent[0]; i < extent[1]; i++){
+ for(unsigned j = extent[2]; j < extent[3]; j++){
+ for(unsigned k = extent[4]; k < extent[5]; k++){
+ if(img->GetScalarType() == VTK_UNSIGNED_CHAR){
+ unsigned char *imgpoint = ((unsigned char*)img->GetScalarPointer(i, j, k));
+
+ unsigned short *vectimgpoint = (unsigned short*)imgushort->GetScalarPointer(i, j, k);
+ double temp = (double)(0.299*imgpoint[0] + 0.587*imgpoint[1] + 0.114*imgpoint[2]);
+ *vectimgpoint = temp*255.0;
+
+ }
+ }
+ }
+ }
+}
+
+/**
+ * @pre the image is not null and has more than one scalar component
+ * @post Each component in the image is separated to form a different image
+ * @param vtkImageData* img, multiple component image i.e. an image of vectors like an rgb
+ * @return vector<vtkImageData* > a vector of images, one for each component
+ */
+void VolumeRendererManager::GetImages(vtkImageData* img, vector<vtkImageData* >& vectimg){
+
+ for(unsigned i = 0; i < img->GetNumberOfScalarComponents(); i++){
+ vectimg.push_back(vtkImageData::New());
+ vectimg[i]->SetNumberOfScalarComponents(1);
+ vectimg[i]->SetExtent(img->GetExtent());
+ vectimg[i]->SetSpacing(img->GetSpacing());
+ vectimg[i]->SetOrigin(img->GetOrigin());
+ vectimg[i]->SetScalarType(img->GetScalarType());
+ vectimg[i]->AllocateScalars();
+ }
+
+ int *extent = img->GetExtent();
+
+ for(unsigned i = extent[0]; i < extent[1]; i++){
+ for(unsigned j = extent[2]; j < extent[3]; j++){
+ for(unsigned k = extent[4]; k < extent[5]; k++){
+ if(img->GetScalarType() == VTK_UNSIGNED_CHAR){
+ unsigned char *imgpoint = ((unsigned char*)img->GetScalarPointer(i, j, k));
+
+ for(unsigned l = 0; l < vectimg.size(); l++){
+ unsigned char *vectimgpoint = (unsigned char*)vectimg[l]->GetScalarPointer(i, j, k);
+ *vectimgpoint = imgpoint[l];
+ }
+ }else if(img->GetScalarType() == VTK_CHAR){
+ char *imgpoint = ((char*)img->GetScalarPointer(i, j, k));
+
+ for(unsigned l = 0; l < vectimg.size(); l++){
+ char *vectimgpoint = ( char*)vectimg[l]->GetScalarPointer(i, j, k);
+ *vectimgpoint = imgpoint[l];
+ }
+ }else if(img->GetScalarType() == VTK_UNSIGNED_SHORT){
+ unsigned short *imgpoint = ((unsigned short*)img->GetScalarPointer(i, j, k));
+
+ for(unsigned l = 0; l < vectimg.size(); l++){
+ unsigned short *vectimgpoint = (unsigned short*)vectimg[l]->GetScalarPointer(i, j, k);
+ *vectimgpoint = imgpoint[l];
+ }
+ }else if(img->GetScalarType() == VTK_SHORT){
+ short *imgpoint = ((short*)img->GetScalarPointer(i, j, k));
+
+ for(unsigned l = 0; l < vectimg.size(); l++){
+ short *vectimgpoint = ( short*)vectimg[l]->GetScalarPointer(i, j, k);
+ *vectimgpoint = imgpoint[l];
+ }
+ }
+ }
+ }
+ }
+}
+
/**
** Adds a prop3D to the manager and returns the identifier
**/
}
void VolumeRendererManager::changeCompositeMIPFunction(int id, int function) throw (char *){
+ if(id == -1){
+ for(unsigned i = 0; i < prop3Dvect.size(); i++)
+ prop3Dvect[i]->changeCompositeMIPFunction(function);
+ }else{
getViewData(id)->changeCompositeMIPFunction(function);
+ }
+}
+
+/**
+ Changes the interpolation of the volume rendering.
+ type == 0 for linear interpolation
+ type == 1 for nearest interpolation
+ */
+void VolumeRendererManager::changeInterpolationType(int type, int propid){
+ if(propid == -1){
+ for(unsigned i = 0; i < prop3Dvect.size(); i++)
+ prop3Dvect[i]->changeInterpolationType(type);
+ }else{
+ getViewData(propid)->changeInterpolationType(type);
+ }
+}
+
+/**
+ * Set the lookuptable to the volumes in memory
+ * if the id is set then it only changes the lookup table for a specific volume
+ */
+void VolumeRendererManager::SetLookupTable(vtkLookupTable* lookup, int id){
+ if(id == -1){
+ for(unsigned i = 0; i < prop3Dvect.size(); i++)
+ prop3Dvect[i]->SetLookupTable(lookup);
+ }else{
+ getViewData(id)->SetLookupTable(lookup);
+ }
+
+}
+
+/**
+ * @returns all the props3D in this manager
+*/
+vector< vtkProp3D* > VolumeRendererManager::getProps3D(){
+
+ vector< vtkProp3D* > propvects;
+ for(unsigned i = 0; i < prop3Dvect.size(); i++){
+ propvects.push_back(prop3Dvect[i]->getProp3D());
+ }
+ return propvects;
+}
+
+/**
+ * @param std::vector<double> greylevel, the corresponding greylevel in the image
+ * @param std::vector<double> value, the corresponding value for the opacity
+ * @param int propid, the correspoding id, by default it applies the changes to the first volume in the array
+ */
+void VolumeRendererManager::setVolumeOpacity(std::vector<double> greylevel, std::vector<double> value, int propid){
+ if(propid == -1){
+ for(unsigned i = 0; i < prop3Dvect.size(); i++)
+ prop3Dvect[i]->setVolumeOpacity(greylevel, value);
+ }else{
+ getViewData(propid)->setVolumeOpacity(greylevel, value);
+ }
+}
+
+void VolumeRendererManager::EnableBoundingBox(vtkRenderWindowInteractor* interactor, int propid){
+ if(propid == -1){
+ for(unsigned i = 0; i < prop3Dvect.size(); i++)
+ prop3Dvect[i]->EnableBoundingBox(interactor);
+ }else{
+ getViewData(propid)->EnableBoundingBox(interactor);
+ }
+}
+
+void VolumeRendererManager::DisableBoundingBox(int propid){
+
+ if(propid == -1){
+ for(unsigned i = 0; i < prop3Dvect.size(); i++)
+ prop3Dvect[i]->DisableBoundingBox();
+ }else{
+ getViewData(propid)->DisableBoundingBox();
+ }
}
Program: wxMaracas
Module: $RCSfile: volumerenderermanager.h,v $
Language: C++
- Date: $Date: 2011/05/31 19:03:03 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2011/10/05 16:27:04 $
+ Version: $Revision: 1.2 $
Copyright: (c) 2002, 2003
License:
**/
int addVolume(int idTP, vtkImageData* img, std::string dataname) throw (char*);
+ /**
+ * @pre The image can have one or multiple components per voxel, and volume rendering is performed seprately over the
+ three of them. If the image has multiple components and the separate components flag is set to false, then
+ the vtkImageAppendComponents is used to create a single image.
+ * @post The volume rendering is performed over the image vol
+ * @param vtkImageData* the image volume
+ * @param bool independentcomponents, if the image has multiple components, the mapper will be created either for managing
+ an rgb image plus a luminance channel (the luminance will be calculated using the luminance image filter)
+ to control the opacity or to manage the multiple components in a single image
+ */
+ int addVolume(vtkImageData* img, vtkRenderWindowInteractor* interactor, bool independentcomponents = false);
+
/**
** loads a prop3D from a nSTL file
**/
vtkPiecewiseFunction* GetTransferFunction(int volumeid);
vtkColorTransferFunction* GetColorFunction(int volumeid);
+
+
+ /**
+ Changes the interpolation of the volume rendering.
+ type == 0 for linear interpolation
+ type == 1 for nearest interpolation
+ */
+ void changeInterpolationType(int type, int propid = -1);
+
+ /**
+ * Set the lookuptable to the volumes in memory
+ * if the id is set then it only changes the lookup table for a specific volume
+ */
+ void SetLookupTable(vtkLookupTable* lookup, int id = -1);
+
+ /**
+ * @returns all the props3D in this manager
+ */
+ vector< vtkProp3D* > getProps3D();
+
+ /**
+ * @param std::vector<double> greylevel, the corresponding greylevel in the image
+ * @param std::vector<double> value, the corresponding value for the opacity
+ * @param int propid, the correspoding id, by default it applies the changes to the first volume in the array
+ */
+ void setVolumeOpacity(std::vector<double> greylevel, std::vector<double> value, int propid = -1);
+
+
+ void EnableBoundingBox(vtkRenderWindowInteractor* interactor, int propid = -1);
+
+ void DisableBoundingBox(int propid = -1);
private:
std::vector<VolumeRendererManagerData*> prop3Dvect;
int _idCount;
+ /**
+ * @pre the image is not null and has more than one scalar component
+ * @post Each component in the image is separated to form a different image
+ * @param vtkImageData* img, multiple component image i.e. an image of vectors like an rgb
+ * @return vector<vtkImageData* > a vector of images, one for each component
+ */
+ void GetImages(vtkImageData* img, vector<vtkImageData* >& images);
+
+ /**
+ * @pre the image is not null and has more than one scalar component
+ * @post Each component in the image is put in a single image
+ * @param vtkImageData* img, multiple component image i.e. an image of vectors like an rgb
+ * @return vtkImageData* double type image
+ */
+ void GetImageDouble(vtkImageData* img, vtkImageData* imgdouble);
#include "boxSurfaceObserver.h"
#include "vtkProperty.h"
+#include <vtkVolumeRayCastMapper.h>
+
+#if VTK_MAJOR_VERSION >= 5
+ #if VTK_MINOR_VERSION >= 6
+ #include "vtkGPUVolumeRayCastMapper.h"
+ #endif
+#endif
using namespace std;
+VolumeRendererManagerData::VolumeRendererManagerData(vtkImageData* vol, bool usegpu){
+ Initialize(vol, "", usegpu);
+}
+
VolumeRendererManagerData::VolumeRendererManagerData(vtkImageData* vol, std::string dataname){
Initialize(vol, dataname);
}
-VolumeRendererManagerData::VolumeRendererManagerData(vtkImageData* vol, bool usegpu, std::string dataname){
- Initialize(vol, dataname, usegpu);
-}
-
void VolumeRendererManagerData::Initialize(vtkImageData* vol, std::string dataname, bool usegpu){
+ _id = 0;
_vol = vol;
_dataname = dataname;
- _tfun = vtkPiecewiseFunction::New();
- _ctfun = vtkColorTransferFunction::New();
_volumePlanes = vtkPlanes::New();
_volumeProperty = vtkVolumeProperty::New();
_volumeProperty->SetInterpolationTypeToLinear();
//_volumeProperty->ShadeOn();
- _volumeProperty->DisableGradientOpacityOn();
- _volumeProperty->SetColor(_ctfun);
+ _volumeProperty->DisableGradientOpacityOn();
+ _tfun = vtkPiecewiseFunction::New();
_volumeProperty->SetScalarOpacity(_tfun );
-
+ _ctfun = vtkColorTransferFunction::New();
_newvol = vtkVolume::New();
- _newvol->SetProperty(_volumeProperty );
+ _newvol->SetProperty(_volumeProperty );
+
- _volumeMapper = 0;
- _volumeMappergpu = 0;
_compositeFunction = 0;
_MIPFunction = 0;
- _boxWidgetS1 = 0;
+
+ BoxWidget = 0;
/* EED9Juin2011
if(usegpu && _vol->GetDataDimension() > 2){
}
*/
- vtkVolumeMapper *volMapperTmp;
- if(usegpu && _vol->GetDataDimension() > 2){
- #if (VTK_MAYOR_VERSION>=5 && VTK_MINOR_VERSION>=6)
- _volumeMappergpu = vtkGPUVolumeRayCastMapper::New();
- _volumeMappergpu->AutoAdjustSampleDistancesOn();
- volMapperTmp = _volumeMappergpu;
- #else
- _compositeFunction = vtkVolumeRayCastCompositeFunction::New();
- _MIPFunction = vtkVolumeRayCastMIPFunction::New();
- _volumeMapper = vtkVolumeRayCastMapper::New();
- _volumeMapper->SetVolumeRayCastFunction(_compositeFunction);
- _volumeMapper->AutoAdjustSampleDistancesOn();
- volMapperTmp = _volumeMapper;
- #endif
- }else{
- _compositeFunction = vtkVolumeRayCastCompositeFunction::New();
- _MIPFunction = vtkVolumeRayCastMIPFunction::New();
- _volumeMapper = vtkVolumeRayCastMapper::New();
- _volumeMapper->SetVolumeRayCastFunction(_compositeFunction);
- _volumeMapper->AutoAdjustSampleDistancesOn();
- volMapperTmp = _volumeMapper;
- }
+ VolumeMapper = 0;
+#if VTK_MAJOR_VERSION >= 5
+ #if VTK_MINOR_VERSION >= 6
+ vtkGPUVolumeRayCastMapper * volumeMappergpu = vtkGPUVolumeRayCastMapper::New();
+ volumeMappergpu->AutoAdjustSampleDistancesOn();
+ VolumeMapper = volumeMappergpu;
+ #endif
+#else
+
+ _volumeProperty->SetColor(_ctfun);
+
+
+ _compositeFunction = vtkVolumeRayCastCompositeFunction::New();
+ _MIPFunction = vtkVolumeRayCastMIPFunction::New();
+ vtkVolumeRayCastMapper* volumeMapper = vtkVolumeRayCastMapper::New();
+ volumeMapper->SetVolumeRayCastFunction(_compositeFunction);
+ volumeMapper->AutoAdjustSampleDistancesOn();
+ VolumeMapper = volumeMapper;
+#endif
- volMapperTmp->SetClippingPlanes( _volumePlanes );
- _newvol->SetMapper(volMapperTmp );
- volMapperTmp->SetInput( _vol );
- volMapperTmp->Update();
+
+ VolumeMapper->SetClippingPlanes( _volumePlanes );
+ _newvol->SetMapper(VolumeMapper );
+ VolumeMapper->SetInput( _vol );
+ VolumeMapper->Update();
_newvol->Update();
}
_compositeFunction->Delete();
if(_MIPFunction)
_MIPFunction->Delete();
- if(_volumeMapper)
- _volumeMapper->Delete();
- if(_volumeMappergpu)
- _volumeMappergpu->Delete();
- if(_boxWidgetS1){
+ if(VolumeMapper)
+ VolumeMapper->Delete();
+
+ if(BoxWidget){
DisableBoundingBox();
}
}
+void VolumeRendererManagerData::SetIndependentComponents(bool independent){
+
+ if(!independent){
+ _volumeProperty->IndependentComponentsOff();
+ }else{
+ _volumeProperty->IndependentComponentsOn();
+ }
+}
void VolumeRendererManagerData::EnableBoundingBox(vtkRenderWindowInteractor* interactor)
{
//EED9Juin2011 if(_volumeMappergpu){
- if(_boxWidgetS1==NULL){
- _boxWidgetS1 = vtkBoxWidget::New();
- _boxWidgetS1->SetInteractor( interactor );
- _boxWidgetS1->SetPlaceFactor(1.01);
- _boxWidgetS1->SetInput( _vol );
- _boxWidgetS1->InsideOutOn();
- _boxWidgetS1->PlaceWidget();
+ if(!BoxWidget){
+ BoxWidget = vtkBoxWidget::New();
+ BoxWidget->SetInteractor( interactor );
+ BoxWidget->SetPlaceFactor(1.01);
+
+ BoxWidget->SetInput( _vol );
+ BoxWidget->InsideOutOn();
+ BoxWidget->PlaceWidget();
+
vtkBoxWidgetCallback *callback = vtkBoxWidgetCallback::New();
- if (_volumeMapper!=0){
- callback->SetMapper(_volumeMapper);
- } else {
- callback->SetMapper(_volumeMappergpu);
- }
- _boxWidgetS1->AddObserver(vtkCommand::InteractionEvent, callback);
+ callback->SetMapper(VolumeMapper);
+
+
+ BoxWidget->AddObserver(vtkCommand::InteractionEvent, callback);
callback->Delete();
- _boxWidgetS1->EnabledOn();
- _boxWidgetS1->GetSelectedFaceProperty()->SetOpacity(0.0);
+
+ BoxWidget->EnabledOn();
+ BoxWidget->GetSelectedFaceProperty()->SetOpacity(0.0);
+
cout<<"JPRG::VolumeRendererManagerData::EnableBoundingBox::CREATE"<<endl;
+
}else{
+
+ BoxWidget->EnabledOn();
+
cout<<"JPRG::VolumeRendererManagerData::EnableBoundingBox"<<endl;
- _boxWidgetS1->EnabledOn();
+
}
//EED9Juin2011 }
}
void VolumeRendererManagerData::DisableBoundingBox(){
- if(_boxWidgetS1){
+
+ if(BoxWidget){
+ BoxWidget->EnabledOff();
+ //BoxWidget->Delete();
+ //BoxWidget = 0;
+
cout<<"JPRG::VolumeRendererManagerData::DisableBoundingBox"<<endl;
- _boxWidgetS1->EnabledOff();
- //_boxWidgetS1->Delete();
- //_boxWidgetS1 = 0;
+
+
}
}
if(!_MIPFunction){
throw "No MIP function initialized";
}
- if(!_volumeMapper && !_volumeMappergpu){
+ if(!VolumeMapper){
throw "No volume mapper initialized";
}
}
}
void VolumeRendererManagerData::changeCompositeMIPFunction(int function){
- checkInvariant();
- if(_volumeMapper){
+ //checkInvariant();
+ if(VolumeMapper){
+#if VTK_MAJOR_VERSION >= 5
+ #if VTK_MINOR_VERSION >= 6
+ if(dynamic_cast<vtkVolumeRayCastMapper*>(VolumeMapper)){
+ vtkVolumeRayCastMapper* volumemapper = dynamic_cast<vtkVolumeRayCastMapper*>(VolumeMapper);
+ if(function == 0){
+ volumemapper->SetVolumeRayCastFunction(_compositeFunction);
+ }else{
+ volumemapper->SetVolumeRayCastFunction(_MIPFunction);
+ }
+ }else if(dynamic_cast<vtkGPUVolumeRayCastMapper*>(VolumeMapper)){
+ vtkGPUVolumeRayCastMapper* volumemapper = dynamic_cast<vtkGPUVolumeRayCastMapper*>(VolumeMapper);
+ if(function == 0){
+ volumemapper->SetBlendModeToComposite();
+ }else if(function == 1){
+ volumemapper->SetBlendModeToMaximumIntensity();
+ }else if(function == 2){
+ volumemapper->SetBlendModeToMinimumIntensity();
+ }
+ }
+ #endif
+#else
+ vtkGPUVolumeRayCastMapper* volumemapper = dynamic_cast<vtkGPUVolumeRayCastMapper*>(VolumeMapper);
if(function == 0){
- _volumeMapper->SetVolumeRayCastFunction(_compositeFunction);
- }else{
- _volumeMapper->SetVolumeRayCastFunction(_MIPFunction);
+ volumemapper->SetBlendModeToComposite();
+ }else if(function == 1){
+ volumemapper->SetBlendModeToMaximumIntensity();
+ }else if(function == 2){
+ volumemapper->SetBlendModeToMinimumIntensity();
}
+#endif
}
}
void VolumeRendererManagerData::SetLookupTable(vtkLookupTable* lookuptable){
- _ctfun->RemoveAllPoints();
- vtkColorTransferFunction* colort = (vtkColorTransferFunction*)lookuptable;
- for(int i = 0; i < colort->GetSize(); i++){
- double val[6];
- colort->GetNodeValue(i, val);
- cout<< "JPRG::VolumeRendererManagerData::SetLookupTable::"<<val[0]<<" "<< val[1]<<" "<<val[2]<<" "<< val[3]<<endl;
- _ctfun->AddRGBPoint(val[0], val[1], val[2], val[3]);
- }
- _newvol->Update();
+ if(lookuptable){
+ _ctfun->RemoveAllPoints();
+ vtkColorTransferFunction* colort = (vtkColorTransferFunction*)lookuptable;
+ for(int i = 0; i < colort->GetSize(); i++){
+ double val[6];
+ colort->GetNodeValue(i, val);
+ cout<< "JPRG::VolumeRendererManagerData::SetLookupTable::"<<val[0]<<" "<< val[1]<<" "<<val[2]<<" "<< val[3]<<endl;
+ _ctfun->AddRGBPoint(val[0], val[1], val[2], val[3]);
+ }
+ _newvol->Update();
+ }
+
+}
+
+void VolumeRendererManagerData::changeInterpolationType(int type){
+ //checkInvariant();
+ if(type == 0){
+ _volumeProperty->SetInterpolationTypeToLinear();
+ }else if(type == 1){
+ _volumeProperty->SetInterpolationTypeToNearest();
+ }
+}
+
+void VolumeRendererManagerData::SetColorTransferFunction(int i, vtkColorTransferFunction* colorf){
+
+ _volumeProperty->SetColor(i, colorf);
}
#include <vtkVolumeRayCastCompositeFunction.h>
#include <vtkPlanes.h>
#include <vtkVolumeMapper.h>
-#include <vtkVolumeRayCastMapper.h>
+
#include <vtkVolumeProperty.h>
#include <vtkVolume.h>
#include <vtkPiecewiseFunction.h>
#include <vtkBoxWidget.h>
#include <vtkAbstractMapper.h>
-#if (VTK_MAYOR_VERSION>=5 && VTK_MINOR_VERSION>=6)
- #include <vtkGPUVolumeRayCastMapper.h>
-#endif
-
#include <vector>
+using namespace std;
// Callback for moving the planes from the box widget to the mapper
class vtkBoxWidgetCallback : public vtkCommand
virtual void Execute(vtkObject *caller, unsigned long, void*)
{
vtkBoxWidget *widget = reinterpret_cast<vtkBoxWidget*>(caller);
- if (this->Mapper)
- {
- vtkPlanes *planes = vtkPlanes::New();
- widget->GetPlanes(planes);
- this->Mapper->SetClippingPlanes(planes);
- planes->Delete();
- }
+ vtkPlanes *planes = vtkPlanes::New();
+ widget->GetPlanes(planes);
+ for(unsigned i = 0; i< VectorMapper.size(); i++){
+ VectorMapper[i]->SetClippingPlanes(planes);
+ }
+ planes->Delete();
}
void SetMapper(vtkAbstractMapper* m)
- { this->Mapper = m; }
+ { if(VectorMapper.size() == 0){
+ VectorMapper.push_back(m);
+ }else{
+ VectorMapper[0] = m;
+ }
+ }
+
+ void AddMapper(vtkAbstractMapper* m){
+ VectorMapper.push_back(m);
+ }
protected:
vtkBoxWidgetCallback()
- { this->Mapper = 0; }
+ { }
- //vtkVolumeRayCastMapper *Mapper;
- vtkAbstractMapper *Mapper;
+ vector< vtkAbstractMapper* > VectorMapper;
};
public:
VolumeRendererManagerData(vtkImageData* vol, std::string dataname="");
VolumeRendererManagerData(vtkImageData* vol, vtkRenderer* render, std::string dataname="");
- VolumeRendererManagerData(vtkImageData* vol, bool usegpu, std::string dataname="");
+ VolumeRendererManagerData(vtkImageData* vol, bool usegpu);
+
+
~VolumeRendererManagerData();
/**
void EnableBoundingBox(vtkRenderWindowInteractor* interactor);
void DisableBoundingBox();
+
+ /**
+ changes the interoplation type of the volume
+ type = 0 linear
+ type = 1 nearest
+ */
+ void changeInterpolationType(int type);
+
+
+ vtkGetMacro(BoxWidget, vtkBoxWidget*);
+ vtkSetMacro(BoxWidget, vtkBoxWidget*);
+
+ vtkGetMacro(VolumeMapper, vtkVolumeMapper*);
+ vtkSetMacro(VolumeMapper, vtkVolumeMapper*);
+
+ void SetColorTransferFunction(int i, vtkColorTransferFunction* colorf);
+
+ void SetIndependentComponents(bool independent);
protected:
/**
* Prop 3D (data actor)
int _id;
vtkVolumeRayCastCompositeFunction *_compositeFunction;
- vtkPlanes *_volumePlanes;
- vtkVolumeRayCastMapper *_volumeMapper;
-
-
-#if (VTK_MAYOR_VERSION>=5 && VTK_MINOR_VERSION>=6)
- vtkGPUVolumeRayCastMapper *_volumeMappergpu;
-#else
- vtkVolumeRayCastMapper *_volumeMappergpu;
-#endif
-
+ vtkPlanes *_volumePlanes;
vtkVolumeProperty *_volumeProperty;
vtkVolume *_newvol;
/**
** boxwidget to control the volume
**/
- vtkBoxWidget* _boxWidgetS1;
+ vtkBoxWidget* BoxWidget;
+ vtkVolumeMapper *VolumeMapper;
void Initialize(vtkImageData* vol, std::string dataname, bool usegpu = false);
# Sets the settings for macro CREA_ADVANCED_INSTALL_LIBRARY_FOR_CMAKE
SET(${LIBRARY_NAME}_INSTALL_FOLDER ${LIBRARY_NAME})
+
SET(${LIBRARY_NAME}_LIBRARIES ${LIBRARY_NAME}
- BaseVolumeRenderer
- BaseSurfaceRenderer
- GUIWxSurfaceRenderer
- GUIWxVolumeRenderer
- KernelViewerWidgets
- KernelVolumeRenderer
- KernelSurfaceRenderer )
+ KernelVolumeRenderer
+ KernelViewerWidgets
+ KernelSurfaceRenderer
+ BaseVolumeRenderer
+ BaseSurfaceRenderer
+ )
+
+# SET(${LIBRARY_NAME}_LIBRARIES ${LIBRARY_NAME}
+# BaseVolumeRenderer
+# BaseSurfaceRenderer
+# GUIWxSurfaceRenderer
+# GUIWxVolumeRenderer
+# KernelViewerWidgets
+# KernelVolumeRenderer
+# KernelSurfaceRenderer )
+
# FILE(RELATIVE_PATH
# ${LIBRARY_NAME}_BUILD_TREE_RELATIVE_INCLUDE_PATHS
** Start of data viewmanagerData
*********************************************************************************************/
+using namespace std;
+
PlanesOperations::PlanesOperations()
{
}
return vectnorm;
}
-double* PlanesOperations::makeVector(double podouble0[3], double podouble1[3])
+double* PlanesOperations::makeVector(double *podouble0, double *podouble1)
{
double *vect;
vect = new double[3];
return vect;
}
+void PlanesOperations::getCrossProduct(double* vect0,double* vect1, double* vectres){
+ vectres[0] = vect0[1]*vect1[2]-(vect0[2]*vect1[1]);
+ vectres[1] = -(vect0[0]*vect1[2]-(vect0[2]*vect1[0]));
+ vectres[2] = vect0[0]*vect1[1]-(vect0[1]*vect1[0]);
+}
+
+void PlanesOperations::getNormal(double* vect, double* vectnorm){
+
+ double mag = getMagnitud(vect);
+
+ if(mag!=0){
+ vectnorm[0] = vect[0]/mag;
+ vectnorm[1] = vect[1]/mag;
+ vectnorm[2] = vect[2]/mag;
+ }else{
+ vectnorm[0] = 0;
+ vectnorm[1] = 0;
+ vectnorm[2] = 0;
+ }
+}
+
+void PlanesOperations::makeVector(double* podouble0, double* podouble1, double* vectres){
+ vectres[0] = podouble1[0] - podouble0[0];
+ vectres[1] = podouble1[1] - podouble0[1];
+ vectres[2] = podouble1[2] - podouble0[2];
+}
+
double PlanesOperations::getDotProduct(double* vect0,double* vect1){
return vect0[0]*vect1[0] + vect0[1]*vect1[1] + vect0[2]*vect1[2];
}
+void PlanesOperations::addVectors(double* vect0, double* vect1, double*vectres){
+
+ vectres[0]= vect0[0] + vect1[0];
+ vectres[1]= vect0[1] + vect1[1];
+ vectres[2]= vect0[2] + vect1[2];
+}
+
+void PlanesOperations::scalarVector(double* vect0, double scalar, double*vectres){
+
+ vectres[0]= vect0[0]*scalar;
+ vectres[1]= vect0[1]*scalar;
+ vectres[2]= vect0[2]*scalar;
+}
+
+vector<double> PlanesOperations::getCrossProduct(vector<double> vect0,vector<double> vect1){
+
+ vector<double> vectCross;
+
+ for(unsigned i = 0; i < vect0.size(); i++){
+
+ unsigned ii = (i + 1 == vect0.size())? 0: i + 1;
+ unsigned iii = (ii + 1 == vect0.size())? 0: ii + 1;
+
+ vectCross.push_back( vect0[ii]*vect1[iii]- vect0[iii]*vect1[ii] );
+
+ }
+ return vectCross;
+
+}
+double PlanesOperations::getDotProduct(vector<double> vect0,vector<double> vect1){
+
+ double sum = 0;
+
+ for(unsigned i = 0; i < vect0.size(); i++) sum += vect0[i]*vect1[i];
+
+ return sum;
+}
+vector<double> PlanesOperations::getNormal(vector<double> vect){
+ vector<double> vectnorm;
+ double mag = getMagnitud(vect);
+
+ for(unsigned i = 0; i < vect.size(); i++){
+
+ if(mag != 0){
+ vectnorm.push_back(vect[i]/mag);
+ }else{
+ vectnorm.push_back(0);
+ }
+ }
+ return vectnorm;
+}
+double PlanesOperations::getMagnitud(vector<double> vect){
+ double mag = 0;
+
+ for(unsigned i = 0; i < vect.size(); i++) mag += pow(vect[i], 2);
+
+ mag = sqrt(mag);
+
+ //std::cout<<"mag "<<mag <<std::endl;
+
+ return mag;
+}
+vector<double> PlanesOperations::makeVector(vector<double> podouble0, vector<double> podouble1){
+
+ vector<double> vector;
+
+ for(unsigned i = 0; i < podouble0.size(); i++){
+ vector.push_back(podouble1[i] - podouble0[i]);
+ }
+ return vector;
+}
+
+/**
+* Adds to vectors, the result is in vectres;
+*@param double* vect0, the first vector
+*@param double* vect1, the second vector
+*@param double* vectres, the resulting vector
+*/
+vector<double> PlanesOperations::addVectors(vector<double> vect0, vector<double> vect1){
+ vector<double> vectres;
+ for(unsigned i = 0; i < vect0.size(); i++){
+ vectres.push_back(vect0[i] + vect1[i]);
+ }
+ return vectres;
+}
+
+/**
+* multiply a vector with a given scalar
+*@param double* vect0, the vector
+*@param double scalar, the scalar value
+*@param double* vectres, the resulting vector
+*/
+vector<double> PlanesOperations::scalarVector(vector<double> vect0, double scalar){
+ vector<double> vectres;
+ for(unsigned i = 0; i < vect0.size(); i++){
+ vectres.push_back(vect0[i]*scalar);
+ }
+ return vectres;
+}
+
#include <math.h>
#include <iostream>
+#include <vector>
+
+using namespace std;
class PlanesOperations {
- double* getCrossProduct(double* vect0,double* vect1);
- double getDotProduct(double* vect0,double* vect1);
+ double* getCrossProduct(double* vect0,double* vect1);
+ double getDotProduct(double* vect0,double* vect1);
double* getNormal(double* vect);
double getMagnitud(double* vect);
- double* makeVector(double podouble0[3], double podouble1[3]);
+ double* makeVector(double *podouble0, double* podouble1);
+
+ void getCrossProduct(double* vect0,double* vect1, double* vectres);
+ void getNormal(double* vect, double* vectnorm);
+ void makeVector(double* podouble0, double* podouble1, double* vectres);
+ /**
+ * Adds to vectors, the result is in vectres;
+ *@param double* vect0, the first vector
+ *@param double* vect1, the second vector
+ *@param double* vectres, the resulting vector
+ */
+ void addVectors(double* vect0, double* vect1, double*vectres);
+ /**
+ * multiply a vector with a given scalar
+ *@param double* vect0, the vector
+ *@param double scalar, the scalar value
+ *@param double* vectres, the resulting vector
+ */
+ void scalarVector(double* vect0, double scalar, double*vectres);
+
+ vector<double> getCrossProduct(vector<double> vect0,vector<double> vect1);
+ double getDotProduct(vector<double> vect0,vector<double> vect1);
+ vector<double> getNormal(vector<double> vect);
+ double getMagnitud(vector<double> vect);
+ vector<double> makeVector(vector<double> podouble0, vector<double> podouble1);
+ /**
+ * Adds to vectors, the result is in vectres;
+ *@param double* vect0, the first vector
+ *@param double* vect1, the second vector
+ *@param double* vectres, the resulting vector
+ */
+ vector<double> addVectors(vector<double> vect0, vector<double> vect1);
+ /**
+ * multiply a vector with a given scalar
+ *@param double* vect0, the vector
+ *@param double scalar, the scalar value
+ *@param double* vectres, the resulting vector
+ */
+ vector<double> scalarVector(vector<double> vect0, double scalar);
};