FIND_PACKAGE(VTK REQUIRED)
INCLUDE(${VTK_USE_FILE})
+IF(BUILD_EXAMPLES)
+ OPTION(USE_QT4 "Build Qt4-based examples" OFF)
+ IF(USE_QT4)
+ FIND_PACKAGE(Qt4 REQUIRED)
+ INCLUDE(${QT_USE_FILE})
+ ENDIF(USE_QT4)
+ENDIF(BUILD_EXAMPLES)
+
## ================================================
## = Do not allow to build inside the source tree =
## ================================================
IF(BUILD_EXAMPLES)
SUBDIRS(
examples
+ ImageMPR
)
ENDIF(BUILD_EXAMPLES)
--- /dev/null
+IF(USE_QT4)
+
+ ## ====================================================
+ ## = Source code, user interafaces and resources here =
+ ## ====================================================
+
+ SET(App_NAME "ImageMPR")
+ SET(App_SOURCE_DIR "${PROJECT_SOURCE_DIR}/appli/${App_NAME}")
+ SET(App_BINARY_DIR "${PROJECT_BINARY_DIR}/appli/${App_NAME}")
+
+ SET(
+ App_QT_SOURCES
+ ImageMPR.cxx
+ )
+ SET(
+ App_SOURCES
+ main.cxx
+ )
+ SET(
+ App_QT_HEADERS
+ ImageMPR.h
+ )
+ SET(
+ App_HEADERS
+ )
+ FILE(GLOB App_QT_UI "${App_SOURCE_DIR}/*.ui")
+ FILE(GLOB App_QT_RES "${App_SOURCE_DIR}/*.qrc")
+
+ ## =====================
+ ## = Compilation rules =
+ ## =====================
+
+ INCLUDE_DIRECTORIES(
+ ${App_BINARY_DIR}
+ )
+
+ QT4_WRAP_UI(App_QT_UI_Headers ${App_QT_UI})
+ QT4_WRAP_CPP(App_QT_HEADERS_MOC_SOURCES ${App_QT_HEADERS})
+ QT4_ADD_RESOURCES(App_QT_RES_SOURCES ${App_QT_RES})
+
+ SET(GUI_TYPE "")
+ IF(WIN32)
+ SET(GUI_TYPE WIN32)
+ ENDIF(WIN32)
+ IF(APPLE)
+ SET(GUI_TYPE MACOSX_BUNDLE)
+ ENDIF(APPLE)
+
+ ADD_EXECUTABLE(
+ ${App_NAME}
+ ${GUI_TYPE}
+ ${App_QT_UI_Headers}
+ ${App_SOURCES}
+ ${App_QT_SOURCES}
+ ${App_QT_HEADERS_MOC_SOURCES}
+ ${App_QT_RES_SOURCES}
+ )
+ TARGET_LINK_LIBRARIES(
+ ${App_NAME}
+ cpPlugins_Interface
+ )
+ENDIF(USE_QT4)
+
+## eof - $RCSfile$
--- /dev/null
+#include "ImageMPR.h"
+#include "ui_ImageMPR.h"
+
+#include <vtkRenderWindow.h>
+
+#include <QFileDialog>
+#include <QMessageBox>
+
+/*
+#include <algorithm>
+#include <cctype>
+#include <fstream>
+
+#include <vtkAnnotatedCubeActor.h>
+#include <vtkAxesActor.h>
+#include <vtkPropAssembly.h>
+#include <vtkProperty.h>
+
+#include <cpPlugins/Interface/Image.h>
+
+// -------------------------------------------------------------------------
+#define IDMS_QT_ACTION( name ) \
+ QObject::connect( \
+ this->m_UI->action##name, SIGNAL( triggered( ) ), \
+ this, SLOT( _triggered_action##name( ) ) \
+ )
+*/
+
+// -------------------------------------------------------------------------
+ImageMPR::ImageMPR( QWidget* parent )
+ : QMainWindow( parent ),
+ m_UI( new Ui::ImageMPR ),
+ m_InputImage( NULL )
+{
+ this->m_UI->setupUi( this );
+
+ // Create and associate renderers
+ this->m_3DRenderer = vtkSmartPointer< vtkRenderer >::New( );
+ this->m_XPlaneRenderer = vtkSmartPointer< vtkRenderer >::New( );
+ this->m_YPlaneRenderer = vtkSmartPointer< vtkRenderer >::New( );
+ this->m_ZPlaneRenderer = vtkSmartPointer< vtkRenderer >::New( );
+ this->m_3DRenderer->SetBackground( 0.2, 0.2, 0.2 );
+ this->m_XPlaneRenderer->SetBackground( 0.1, 0.3, 0.8 );
+ this->m_YPlaneRenderer->SetBackground( 0.1, 0.3, 0.8 );
+ this->m_ZPlaneRenderer->SetBackground( 0.1, 0.3, 0.8 );
+ this->m_UI->m_3DVTK->GetRenderWindow( )->
+ AddRenderer( this->m_3DRenderer );
+ this->m_UI->m_XPlaneVTK->GetRenderWindow( )->
+ AddRenderer( this->m_XPlaneRenderer );
+ this->m_UI->m_YPlaneVTK->GetRenderWindow( )->
+ AddRenderer( this->m_YPlaneRenderer );
+ this->m_UI->m_ZPlaneVTK->GetRenderWindow( )->
+ AddRenderer( this->m_ZPlaneRenderer );
+
+ // Configure MPR actors
+ this->m_MPRActors = vtkSmartPointer< TMPRActors >::New( );
+
+ // Prepare interaction
+ this->m_XStyle = vtkSmartPointer< TStyle >::New( );
+ this->m_YStyle = vtkSmartPointer< TStyle >::New( );
+ this->m_ZStyle = vtkSmartPointer< TStyle >::New( );
+ this->m_XStyle->
+ Configure( this->m_MPRActors->GetSliceActors( 0 ), this->m_MPRActors );
+ this->m_YStyle->
+ Configure( this->m_MPRActors->GetSliceActors( 1 ), this->m_MPRActors );
+ this->m_ZStyle->
+ Configure( this->m_MPRActors->GetSliceActors( 2 ), this->m_MPRActors );
+ this->m_XStyle->
+ SetInteractor( this->m_UI->m_XPlaneVTK->GetInteractor( ), 0 );
+ this->m_YStyle->
+ SetInteractor( this->m_UI->m_YPlaneVTK->GetInteractor( ), 1 );
+ this->m_ZStyle->
+ SetInteractor( this->m_UI->m_ZPlaneVTK->GetInteractor( ), 2 );
+ this->m_XStyle->SetModeToNavigation( );
+ this->m_YStyle->SetModeToNavigation( );
+ this->m_ZStyle->SetModeToNavigation( );
+
+ QObject::connect(
+ this->m_UI->actionOpenPlugins, SIGNAL( triggered( ) ),
+ this, SLOT( _triggered_actionOpenPlugins( ) )
+ );
+ QObject::connect(
+ this->m_UI->actionOpenInputImage, SIGNAL( triggered( ) ),
+ this, SLOT( _triggered_actionOpenInputImage( ) )
+ );
+
+ // Start: load all disponible plugins
+ this->_triggered_actionOpenPlugins( );
+}
+
+// -------------------------------------------------------------------------
+ImageMPR::
+~ImageMPR( )
+{
+ // Close all connections
+ this->m_Plugins.UnloadAll( );
+
+ // Delete objects
+ delete this->m_UI;
+ if( this->m_InputImage != NULL ) delete this->m_InputImage;
+}
+
+// -------------------------------------------------------------------------
+void ImageMPR::
+_triggered_actionOpenPlugins( )
+{
+ // Show dialog and check if it was accepted
+ QFileDialog dialog( this );
+ dialog.setFileMode( QFileDialog::ExistingFile );
+ dialog.setDirectory( "." );
+ dialog.setNameFilter(
+ tr( "Plugins file (*.so);;All files (*)" )
+ );
+ dialog.setDefaultSuffix( tr( "so" ) );
+ if( !( dialog.exec( ) ) )
+ return;
+
+ std::string fname = dialog.selectedFiles( ).at( 0 ).toStdString( );
+ this->m_Plugins.UnloadAll( );
+ if( !( this->m_Plugins.Load( fname ) ) )
+ {
+ QMessageBox::critical(
+ this,
+ tr( "Ignoring plugin" ),
+ tr( fname.c_str( ) )
+ );
+ this->m_Plugins.UnloadAll( );
+ return;
+
+ } // fi
+
+ this->m_BaseClasses[ "ImageReader" ] =
+ "cpPlugins::Plugins::ImageReader";
+ this->m_BaseClasses[ "ImageSeriesReader" ] =
+ "cpPlugins::Plugins::ImageSeriesReader";
+}
+
+// -------------------------------------------------------------------------
+void ImageMPR::
+_triggered_actionOpenInputImage( )
+{
+ // Show dialog and check if it was accepted
+ QFileDialog dialog( this );
+ dialog.setFileMode( QFileDialog::ExistingFiles );
+ dialog.setDirectory( tr( "." ) );
+ dialog.setNameFilter(
+ tr( "Medical image files (*.mhd *.bin *.dcm);;All files (*)" )
+ );
+ dialog.setDefaultSuffix( tr( "mhd" ) );
+ if( !( dialog.exec( ) ) )
+ return;
+
+ if( this->m_InputImage != NULL )
+ delete this->m_InputImage;
+ this->m_InputImage = NULL;
+ unsigned int nFiles = dialog.selectedFiles( ).size( );
+ if( nFiles == 1 )
+ {
+ std::string fname = dialog.selectedFiles( ).at( 0 ).toStdString( );
+
+ TPlugin* reader =
+ dynamic_cast< TPlugin* >(
+ this->m_Plugins.CreateObject( this->m_BaseClasses[ "ImageReader" ] )
+ );
+
+ TParameters reader_params = reader->GetDefaultParameters( );
+ reader_params[ "FileName" ].second = fname;
+ reader_params[ "PixelType" ].second = "short";
+ reader_params[ "ImageDimension" ].second = "3";
+ reader_params[ "IsColorImage" ].second = "0";
+ reader->SetParameters( reader_params );
+ std::string err = reader->Update( );
+
+ if( err == "" )
+ {
+ this->m_InputImage =
+ dynamic_cast< TPluginImage* >( reader->GetOutput( 0 ) );
+ reader->DisconnectOutputs( );
+ }
+ else
+ QMessageBox::critical(
+ this,
+ tr( "Error reading single image" ),
+ tr( err.c_str( ) )
+ );
+ delete reader;
+ }
+ else if( nFiles > 1 )
+ {
+ /* TODO
+ if( this->m_ImageSeriesReaderClassName == "" )
+ {
+ QMessageBox::critical(
+ this,
+ tr( "No plugin to read an image series found!" ),
+ tr( "No plugin to read an image series found!" )
+ );
+ return( ret );
+
+ } // fi
+ std::string fname = dialog.selectedFiles( ).at( 0 ).toStdString( );
+ this->m_LastOpenedFile = fname;
+ return( ret );
+ */
+
+ } // fi
+
+ if( this->m_InputImage != NULL )
+ {
+ this->m_MPRActors->SetInputData( this->m_InputImage->GetVTKImageData( ) );
+ this->m_MPRActors->PushDataInto(
+ this->m_XPlaneRenderer,
+ this->m_YPlaneRenderer,
+ this->m_ZPlaneRenderer,
+ this->m_3DRenderer
+ );
+
+ // Reset all cameras
+ this->m_3DRenderer->ResetCamera( );
+ this->m_XPlaneRenderer->ResetCamera( );
+ this->m_YPlaneRenderer->ResetCamera( );
+ this->m_ZPlaneRenderer->ResetCamera( );
+
+ // Ok, start!
+ this->m_UI->m_3DVTK->GetRenderWindow( )->Render( );
+ this->m_UI->m_XPlaneVTK->GetRenderWindow( )->Render( );
+ this->m_UI->m_YPlaneVTK->GetRenderWindow( )->Render( );
+ this->m_UI->m_ZPlaneVTK->GetRenderWindow( )->Render( );
+
+ } // fi
+}
+
+// eof - $RCSfile$
--- /dev/null
+#ifndef __IMAGEMPR__H__
+#define __IMAGEMPR__H__
+
+// Standard stuff
+#include <map>
+#include <string>
+
+// Qt stuff
+#include <QMainWindow>
+
+// vtk stuff
+#include <vtkRenderer.h>
+#include <vtkSmartPointer.h>
+
+// Plugins interface
+#include <cpPlugins/Interface/Interface.h>
+#include <cpPlugins/Interface/ProcessObject.h>
+#include <cpPlugins/Interface/Image.h>
+#include <cpPlugins/Interface/DataObject.h>
+#include <cpPlugins/Extensions/Visualization/MPRActors.h>
+#include <cpPlugins/Extensions/Visualization/ImageInteractorStyle.h>
+
+
+/*
+ #include <vtkOrientationMarkerWidget.h>
+
+// Local stuff
+#include "InteractorStyleImage.h"
+#include "VolumeActors.h"
+
+
+ #include <itkImage.h>
+ #include <itkImageToVTKImageFilter.h>
+
+ #include <cpm/DataStructures/QuadEdgeMesh.h>
+
+ #include <cpm/VTK/MeshMapper.h>
+ #include <cpm/Algorithms/QuadEdge/MeshPlaneCutterFilter.h>
+*/
+
+// -------------------------------------------------------------------------
+namespace Ui
+{
+ class ImageMPR;
+}
+
+// -------------------------------------------------------------------------
+/**
+ */
+class ImageMPR
+ : public QMainWindow
+{
+ Q_OBJECT;
+
+public:
+ // Plugins types
+ typedef cpPlugins::Interface::Interface TPluginsInterface;
+ typedef cpPlugins::Interface::Object TPluginObject;
+ typedef cpPlugins::Interface::DataObject TPluginData;
+ typedef cpPlugins::Interface::Image TPluginImage;
+ typedef cpPlugins::Interface::ProcessObject TPlugin;
+ typedef TPlugin::TParameters TParameters;
+
+ typedef std::map< std::string, std::string > TStringMap;
+ typedef cpPlugins::Extensions::Visualization::MPRActors TMPRActors;
+ typedef cpPlugins::Extensions::Visualization::ImageInteractorStyle TStyle;
+
+
+public:
+ explicit ImageMPR( QWidget* parent = 0 );
+ virtual ~ImageMPR( );
+
+private slots:
+ void _triggered_actionOpenPlugins( );
+ void _triggered_actionOpenInputImage( );
+
+private:
+ Ui::ImageMPR* m_UI;
+
+ // Plugins objects
+ TPluginsInterface m_Plugins;
+
+ // Needed object from plugins
+ TStringMap m_BaseClasses;
+
+ // Real data
+ TPluginImage* m_InputImage;
+
+ // Visualization stuff
+ vtkSmartPointer< vtkRenderer > m_3DRenderer;
+ vtkSmartPointer< vtkRenderer > m_XPlaneRenderer;
+ vtkSmartPointer< vtkRenderer > m_YPlaneRenderer;
+ vtkSmartPointer< vtkRenderer > m_ZPlaneRenderer;
+ vtkSmartPointer< TMPRActors > m_MPRActors;
+ vtkSmartPointer< TStyle > m_XStyle;
+ vtkSmartPointer< TStyle > m_YStyle;
+ vtkSmartPointer< TStyle > m_ZStyle;
+
+ /* TODO
+ vtkSmartPointer< idms::VolumeActors > m_ImageActors;
+ vtkSmartPointer< vtkOrientationMarkerWidget > m_3DOrientationWidget;
+ */
+
+ /*
+ TTriangulation::Pointer m_Mesh;
+ vtkSmartPointer< TTriangulationMapper > m_MeshMapper;
+ vtkSmartPointer< vtkActor > m_MeshActor;
+ TCutter::Pointer m_ZCutter;
+ */
+};
+
+#endif // __IMAGEMPR__H__
+
+// eof - $RCSfile$
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ImageMPR</class>
+ <widget class="QMainWindow" name="ImageMPR">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>718</width>
+ <height>706</height>
+ </rect>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>718</width>
+ <height>706</height>
+ </size>
+ </property>
+ <property name="windowTitle">
+ <string>Interactive deformable mesh segmentation (v0.1)</string>
+ </property>
+ <widget class="QWidget" name="centralWidget">
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QSplitter" name="splitter_4">
+ <property name="minimumSize">
+ <size>
+ <width>700</width>
+ <height>400</height>
+ </size>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <widget class="QSplitter" name="splitter_3">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <widget class="QSplitter" name="splitter">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <widget class="QVTKWidget" name="m_YPlaneVTK">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>200</width>
+ <height>200</height>
+ </size>
+ </property>
+ </widget>
+ <widget class="QVTKWidget" name="m_XPlaneVTK">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>200</width>
+ <height>200</height>
+ </size>
+ </property>
+ </widget>
+ </widget>
+ <widget class="QSplitter" name="splitter_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <widget class="QVTKWidget" name="m_ZPlaneVTK">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>200</width>
+ <height>200</height>
+ </size>
+ </property>
+ </widget>
+ <widget class="QVTKWidget" name="m_3DVTK">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>200</width>
+ <height>200</height>
+ </size>
+ </property>
+ </widget>
+ </widget>
+ </widget>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QMenuBar" name="menuBar">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>718</width>
+ <height>27</height>
+ </rect>
+ </property>
+ <widget class="QMenu" name="menuFile">
+ <property name="title">
+ <string>&File</string>
+ </property>
+ <addaction name="actionOpenPlugins"/>
+ <addaction name="separator"/>
+ <addaction name="actionOpenInputImage"/>
+ <addaction name="separator"/>
+ <addaction name="actionExit"/>
+ </widget>
+ <addaction name="menuFile"/>
+ </widget>
+ <action name="actionOpenInputImage">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Open image</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+O</string>
+ </property>
+ </action>
+ <action name="actionOpenPlugins">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Open plugins</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+P</string>
+ </property>
+ </action>
+ <action name="actionExit">
+ <property name="text">
+ <string>Exit</string>
+ </property>
+ </action>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <customwidgets>
+ <customwidget>
+ <class>QVTKWidget</class>
+ <extends>QWidget</extends>
+ <header>QVTKWidget.h</header>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>actionExit</sender>
+ <signal>triggered()</signal>
+ <receiver>ImageMPR</receiver>
+ <slot>close()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>378</x>
+ <y>235</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
--- /dev/null
+#include "ImageMPR.h"
+#include <cstdlib>
+#include <QApplication>
+
+// -------------------------------------------------------------------------
+int main( int argc, char* argv[] )
+{
+ ::setenv( "LC_NUMERIC", "POSIX", 1 );
+ QApplication a( argc, argv );
+ ImageMPR w;
+ w.show( );
+
+ return( a.exec( ) );
+}
+
+// -------------------------------------------------------------------------
+#ifdef _WIN32
+
+#include <memory>
+#include <vector>
+#include <windows.h>
+#include <shellapi.h>
+
+/**
+ */
+class Win32CommandLineConverter
+{
+private:
+ std::unique_ptr< char*[ ] > argv_;
+ std::vector< std::unique_ptr< char[ ] > > storage_;
+
+public:
+ Win32CommandLineConverter( )
+ {
+ LPWSTR cmd_line = GetCommandLineW( );
+ int argc;
+ LPWSTR* w_argv = CommandLineToArgvW( cmd_line, &argc );
+ argv_ = std::unique_ptr< char*[ ] >( new char*[ argc ] );
+ storage_.reserve( argc );
+ for( int i = 0; i < argc; ++i )
+ {
+ storage_.push_back( ConvertWArg( w_argv[ i ] ) );
+ argv_[ i ] = storage_.back( ).get( );
+
+ } // rof
+ LocalFree( w_argv );
+ }
+ int argc( ) const
+ {
+ return( static_cast< int >(storage_.size( ) ) );
+ }
+ char** argv( ) const
+ {
+ return( argv_.get( ) );
+ }
+ static std::unique_ptr< char[ ] > ConvertWArg( LPWSTR w_arg )
+ {
+ int size = WideCharToMultiByte(
+ CP_UTF8, 0, w_arg, -1, nullptr, 0, nullptr, nullptr
+ );
+ std::unique_ptr< char[ ] > ret( new char[ size ] );
+ WideCharToMultiByte(
+ CP_UTF8, 0, w_arg, -1, ret.get( ), size, nullptr, nullptr
+ );
+ return( ret );
+ }
+};
+
+int CALLBACK WinMain(
+ HINSTANCE hInstance,
+ HINSTANCE hPrevInstance,
+ LPSTR lpCmdLine,
+ int nCmdShow
+ )
+{
+ Win32CommandLineConverter cmd_line;
+ return( main( cmd_line.argc( ), cmd_line.argv( ) ) );
+}
+
+#endif
+
+// eof - $RCSfile$
example_ReadQuadEdgeMeshWithoutPlugins
example_RenderQuadEdgeMesh
example_RenderQuadEdgeMeshWithoutPlugins
+ example_MPR
)
FOREACH(prog ${EXAMPLES_PROGRAMS})
--- /dev/null
+#include <cstdlib>
+#include <iostream>
+#include <string>
+
+#include <cpPlugins/Interface/Interface.h>
+#include <cpPlugins/Interface/ProcessObject.h>
+#include <cpPlugins/Interface/Image.h>
+#include <cpPlugins/Extensions/Visualization/MPRActors.h>
+
+#include <vtkActor.h>
+#include <vtkCallbackCommand.h>
+#include <vtkProperty.h>
+#include <vtkRenderer.h>
+#include <vtkRenderWindow.h>
+#include <vtkRenderWindowInteractor.h>
+#include <vtkSmartPointer.h>
+
+int main( int argc, char* argv[] )
+{
+ if( argc < 4 )
+ {
+ std::cerr
+ << "Usage: " << argv[ 0 ]
+ << " plugins_file"
+ << " input_image"
+ << " pixel_type" << std::endl;
+ return( 1 );
+
+ } // fi
+ std::string plugins_file = argv[ 1 ];
+ std::string input_image_file = argv[ 2 ];
+ std::string pixel_type = argv[ 3 ];
+
+ // Create interface
+ typedef cpPlugins::Interface::Interface TInterface;
+ typedef TInterface::TClasses TClasses;
+
+ TInterface plugins;
+ plugins.Load( plugins_file );
+
+ // Create objects
+ typedef cpPlugins::Interface::ProcessObject TProcessObject;
+ typedef TProcessObject::TParameters TParameters;
+ cpPlugins::Interface::ProcessObject* reader;
+
+ reader =
+ dynamic_cast< TProcessObject* >(
+ plugins.CreateObject( "cpPlugins::Plugins::ImageReader" )
+ );
+ if( reader == NULL )
+ {
+ std::cerr << "No suitable reader found in plugins." << std::endl;
+ return( 1 );
+
+ } // fi
+
+ // Configure reader
+ TParameters reader_params = reader->GetDefaultParameters( );
+ reader_params[ "FileName" ].second = input_image_file;
+ reader_params[ "PixelType" ].second = pixel_type;
+ reader_params[ "ImageDimension" ].second = "3";
+ reader->SetParameters( reader_params );
+
+ // Execute reader
+ std::string msg = reader->Update( );
+
+ if( msg != "" )
+ std::cerr << "ERROR: " << msg << std::endl;
+
+ // Visualization stuff
+ vtkSmartPointer< vtkRenderWindow > window =
+ vtkSmartPointer< vtkRenderWindow >::New( );
+
+ vtkSmartPointer< vtkRenderWindowInteractor > interactor =
+ vtkSmartPointer< vtkRenderWindowInteractor >::New( );
+
+ interactor->SetRenderWindow( window );
+
+ // Renderers
+ vtkSmartPointer< vtkRenderer > xrenderer =
+ vtkSmartPointer< vtkRenderer >::New( );
+ vtkSmartPointer< vtkRenderer > yrenderer =
+ vtkSmartPointer< vtkRenderer >::New( );
+ vtkSmartPointer< vtkRenderer > zrenderer =
+ vtkSmartPointer< vtkRenderer >::New( );
+ vtkSmartPointer< vtkRenderer > wrenderer =
+ vtkSmartPointer< vtkRenderer >::New( );
+
+ xrenderer->SetBackground( 0.7, 0.5, 0.5 );
+ yrenderer->SetBackground( 0.5, 0.7, 0.5 );
+ zrenderer->SetBackground( 0.5, 0.5, 0.7 );
+ wrenderer->SetBackground( 0.5, 0.5, 0.5 );
+
+ xrenderer->SetViewport( 0, 0, 0.5, 0.5 );
+ yrenderer->SetViewport( 0, 0.5, 0.5, 1 );
+ zrenderer->SetViewport( 0.5, 0, 1, 0.5 );
+ wrenderer->SetViewport( 0.5, 0.5, 1, 1 );
+
+ window->AddRenderer( xrenderer );
+ window->AddRenderer( yrenderer );
+ window->AddRenderer( zrenderer );
+ window->AddRenderer( wrenderer );
+
+ // Create actors
+ typedef cpPlugins::Extensions::Visualization::MPRActors TMPRActors;
+ vtkSmartPointer< TMPRActors > mprActors =
+ vtkSmartPointer< TMPRActors >::New( );
+ mprActors->SetInputData(
+ dynamic_cast< cpPlugins::Interface::Image* >( reader->GetOutput( 0 ) )->
+ GetVTKImageData( )
+ );
+ mprActors->PushDataInto( xrenderer, yrenderer, zrenderer, wrenderer );
+
+ // Begin interaction
+ xrenderer->ResetCamera( );
+ yrenderer->ResetCamera( );
+ zrenderer->ResetCamera( );
+ wrenderer->ResetCamera( );
+ window->Render( );
+ interactor->Start( );
+
+ // Free memory
+ delete reader;
+
+ return( 0 );
+}
+
+// eof - $RCSfile$
FILE(GLOB LIB_SOURCES_CPP "*.cpp")
FILE(GLOB LIB_SOURCES_CXX "*.cxx")
-FILE(GLOB LIB_DataStructures_HEADERS_H "*.h")
-FILE(GLOB LIB_DataStructures_HEADERS_HPP "*.hpp")
-FILE(GLOB LIB_DataStructures_HEADERS_HXX "*.hxx")
-FILE(GLOB LIB_DataStructures_SOURCES_C "*.c")
-FILE(GLOB LIB_DataStructures_SOURCES_CPP "*.cpp")
-FILE(GLOB LIB_DataStructures_SOURCES_CXX "*.cxx")
-
-FILE(GLOB LIB_IO_HEADERS_H "*.h")
-FILE(GLOB LIB_IO_HEADERS_HPP "*.hpp")
-FILE(GLOB LIB_IO_HEADERS_HXX "*.hxx")
-FILE(GLOB LIB_IO_SOURCES_C "*.c")
-FILE(GLOB LIB_IO_SOURCES_CPP "*.cpp")
-FILE(GLOB LIB_IO_SOURCES_CXX "*.cxx")
-
-FILE(GLOB LIB_Visualization_HEADERS_H "*.h")
-FILE(GLOB LIB_Visualization_HEADERS_HPP "*.hpp")
-FILE(GLOB LIB_Visualization_HEADERS_HXX "*.hxx")
-FILE(GLOB LIB_Visualization_SOURCES_C "*.c")
-FILE(GLOB LIB_Visualization_SOURCES_CPP "*.cpp")
-FILE(GLOB LIB_Visualization_SOURCES_CXX "*.cxx")
+FILE(GLOB LIB_DataStructures_HEADERS_H "DataStructures/*.h")
+FILE(GLOB LIB_DataStructures_HEADERS_HPP "DataStructures/*.hpp")
+FILE(GLOB LIB_DataStructures_HEADERS_HXX "DataStructures/*.hxx")
+FILE(GLOB LIB_DataStructures_SOURCES_C "DataStructures/*.c")
+FILE(GLOB LIB_DataStructures_SOURCES_CPP "DataStructures/*.cpp")
+FILE(GLOB LIB_DataStructures_SOURCES_CXX "DataStructures/*.cxx")
+
+FILE(GLOB LIB_IO_HEADERS_H "IO/*.h")
+FILE(GLOB LIB_IO_HEADERS_HPP "IO/*.hpp")
+FILE(GLOB LIB_IO_HEADERS_HXX "IO/*.hxx")
+FILE(GLOB LIB_IO_SOURCES_C "IO/*.c")
+FILE(GLOB LIB_IO_SOURCES_CPP "IO/*.cpp")
+FILE(GLOB LIB_IO_SOURCES_CXX "IO/*.cxx")
+
+FILE(GLOB LIB_Visualization_HEADERS_H "Visualization/*.h")
+FILE(GLOB LIB_Visualization_HEADERS_HPP "Visualization/*.hpp")
+FILE(GLOB LIB_Visualization_HEADERS_HXX "Visualization/*.hxx")
+FILE(GLOB LIB_Visualization_SOURCES_C "Visualization/*.c")
+FILE(GLOB LIB_Visualization_SOURCES_CPP "Visualization/*.cpp")
+FILE(GLOB LIB_Visualization_SOURCES_CXX "Visualization/*.cxx")
## =====================
## = Compilation rules =
## =====================
-## TODO: no instantiated code at the moment
-# ADD_LIBRARY(
-# ${LIBRARY_NAME}
-# SHARED
-# ${LIB_SOURCES_C}
-# ${LIB_SOURCES_CPP}
-# ${LIB_SOURCES_CXX}
-# )
-# GENERATE_EXPORT_HEADER(
-# ${LIBRARY_NAME}
-# BASE_NAME ${LIBRARY_NAME}
-# EXPORT_MACRO_NAME ${LIBRARY_NAME}_EXPORT
-# EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/lib/cpPlugins/Interface/${LIBRARY_NAME}_Export.h
-# STATIC_DEFINE ${LIBRARY_NAME}_BUILT_AS_STATIC
-# )
-# TARGET_LINK_LIBRARIES(
-# ${LIBRARY_NAME}
-# cpPlugins_Pluma
-# ${ITK_LIBRARIES}
-# ${VTK_LIBRARIES}
-# )
+ADD_LIBRARY(
+ ${LIBRARY_NAME}
+ SHARED
+ ${LIB_SOURCES_C}
+ ${LIB_SOURCES_CPP}
+ ${LIB_SOURCES_CXX}
+ ${LIB_DataStructures_SOURCES_C}
+ ${LIB_DataStructures_SOURCES_CPP}
+ ${LIB_DataStructures_SOURCES_CXX}
+ ${LIB_IO_SOURCES_C}
+ ${LIB_IO_SOURCES_CPP}
+ ${LIB_IO_SOURCES_CXX}
+ ${LIB_Visualization_SOURCES_C}
+ ${LIB_Visualization_SOURCES_CPP}
+ ${LIB_Visualization_SOURCES_CXX}
+ )
+GENERATE_EXPORT_HEADER(
+ ${LIBRARY_NAME}
+ BASE_NAME ${LIBRARY_NAME}
+ EXPORT_MACRO_NAME ${LIBRARY_NAME}_EXPORT
+ EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/lib/cpPlugins/Extensions/${LIBRARY_NAME}_Export.h
+ STATIC_DEFINE ${LIBRARY_NAME}_BUILT_AS_STATIC
+ )
+TARGET_LINK_LIBRARIES(
+ ${LIBRARY_NAME}
+ ${ITK_LIBRARIES}
+ ${VTK_LIBRARIES}
+ )
## eof - $RCSfile$
--- /dev/null
+#include <cpPlugins/Extensions/Visualization/ImageInteractorStyle.h>
+
+#include <vtkAnnotatedCubeActor.h>
+#include <vtkAxesActor.h>
+#include <vtkCamera.h>
+#include <vtkCommand.h>
+#include <vtkPropAssembly.h>
+#include <vtkProperty.h>
+#include <vtkRendererCollection.h>
+#include <vtkRenderWindow.h>
+#include <vtkRenderWindowInteractor.h>
+
+#include <cpPlugins/Extensions/Visualization/ImageSliceActors.h>
+#include <cpPlugins/Extensions/Visualization/MPRActors.h>
+
+// -------------------------------------------------------------------------
+const int cpPlugins::Extensions::Visualization::
+ImageInteractorStyle::SliceEvent = vtkCommand::UserEvent + 1;
+
+// -------------------------------------------------------------------------
+cpPlugins::Extensions::Visualization::ImageInteractorStyle::
+Self* cpPlugins::Extensions::Visualization::ImageInteractorStyle::
+New( )
+{
+ return( new Self( ) );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
+Configure( ImageSliceActors* slice_actors, MPRActors* mpr_actors )
+{
+ this->m_SliceActors = slice_actors;
+ this->m_MPRActors = mpr_actors;
+ this->SetModeToNavigation( );
+ this->PropPicker->AddPickList( slice_actors->GetImageActor( ) );
+ this->Modified( );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
+SetModeToNavigation( )
+{
+ this->Mode = Self::NavigationMode;
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
+SetModeToDeformation( )
+{
+ this->Mode = Self::DeformationMode;
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
+SetInteractor( vtkRenderWindowInteractor* interactor, const int& axis )
+{
+ this->Superclass::SetInteractor( interactor );
+ this->OrientationWidget->SetInteractor( interactor );
+ interactor->SetInteractorStyle( this );
+ if( interactor == NULL )
+ return;
+
+ // TODO: interactor->SetPicker( this->PropPicker );
+
+ // Get camera, avoiding segfaults
+ vtkRenderer* ren =
+ interactor->GetRenderWindow( )->GetRenderers( )->GetFirstRenderer( );
+ if( ren == NULL )
+ return;
+ vtkCamera* cam = ren->GetActiveCamera( );
+ if( cam == NULL )
+ return;
+
+ // Parallel projections are better when displaying 2D images
+ cam->ParallelProjectionOn( );
+ cam->SetFocalPoint( double( 0 ), double( 0 ), double( 0 ) );
+ if( axis == 0 )
+ {
+ cam->SetPosition( double( 1 ), double( 0 ), double( 0 ) );
+ cam->SetViewUp ( double( 0 ), double( 1 ), double( 0 ) );
+ }
+ else if( axis == 1 )
+ {
+ cam->SetPosition( double( 0 ), double( 1 ), double( 0 ) );
+ cam->SetViewUp ( double( 0 ), double( 0 ), double( -1 ) );
+ }
+ else // if( axis == 2 )
+ {
+ cam->SetPosition( double( 0 ), double( 0 ), double( 1 ) );
+ cam->SetViewUp ( double( 0 ), double( 1 ), double( 0 ) );
+
+ } // fi
+ ren->ResetCamera( );
+
+ // Enable 2D orientation widget
+ this->OrientationWidget->SetEnabled( 1 );
+ this->OrientationWidget->InteractiveOff( );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
+OnMouseMove( )
+{
+ std::cout << "moumov" << std::endl;
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
+OnLeftButtonDown( )
+{
+ std::cout << "leftdown" << std::endl;
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
+OnLeftButtonUp( )
+{
+ std::cout << "leftup" << std::endl;
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
+OnMiddleButtonDown( )
+{
+ std::cout << "middown" << std::endl;
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
+OnMiddleButtonUp( )
+{
+ std::cout << "midup" << std::endl;
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
+OnRightButtonDown( )
+{
+ std::cout << "ridown" << std::endl;
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
+OnRightButtonUp( )
+{
+ std::cout << "riup" << std::endl;
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
+OnMouseWheelForward( )
+{
+ std::cout << "whfwd" << std::endl;
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
+OnMouseWheelBackward( )
+{
+ std::cout << "whbwd" << std::endl;
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
+OnChar( )
+{
+ std::cout << "char" << std::endl;
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
+Rotate( )
+{
+ std::cout << "Rotate" << std::endl;
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
+Pan( )
+{
+ std::cout << "pan" << std::endl;
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
+Spin( )
+{
+ std::cout << "spin" << std::endl;
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
+Zoom( )
+{
+ std::cout << "Zoom" << std::endl;
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
+WindowLevel( )
+{
+ std::cout << "wl" << std::endl;
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
+Pick( )
+{
+ std::cout << "Pick" << std::endl;
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
+Slice( )
+{
+ std::cout << "Slice" << std::endl;
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
+StartWindowLevel( )
+{
+ std::cout << "swl" << std::endl;
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
+EndWindowLevel( )
+{
+ std::cout << "ewl" << std::endl;
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
+StartPick( )
+{
+ std::cout << "sp" << std::endl;
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
+EndPick( )
+{
+ std::cout << "ep" << std::endl;
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
+StartSlice( )
+{
+ std::cout << "ss" << std::endl;
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
+EndSlice( )
+{
+ std::cout << "es" << std::endl;
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Extensions::Visualization::ImageInteractorStyle::
+ImageInteractorStyle( )
+ : Superclass( ),
+ Mode( Self::NavigationMode ),
+ m_SliceActors( NULL ),
+ m_MPRActors( NULL )
+{
+ // Orientation marks
+ vtkSmartPointer< vtkAnnotatedCubeActor > cube =
+ vtkSmartPointer< vtkAnnotatedCubeActor >::New( );
+ cube->GetCubeProperty( )->SetColor( 0.9, 0.7, 0.2 );
+ cube->GetTextEdgesProperty( )->SetLineWidth( 1 );
+ cube->GetTextEdgesProperty( )->SetDiffuse( 0 );
+ cube->GetTextEdgesProperty( )->SetAmbient( 1 );
+ cube->GetTextEdgesProperty( )->SetColor( 0.18, 0.28, 0.23 );
+ cube->GetXPlusFaceProperty( )->SetColor( 1, 0, 0 );
+ cube->GetXPlusFaceProperty( )->SetInterpolationToFlat( );
+ cube->GetXMinusFaceProperty( )->SetColor( 1, 0, 0 );
+ cube->GetXMinusFaceProperty( )->SetInterpolationToFlat( );
+ cube->GetYPlusFaceProperty( )->SetColor( 0, 1, 0 );
+ cube->GetYPlusFaceProperty( )->SetInterpolationToFlat( );
+ cube->GetYMinusFaceProperty( )->SetColor( 0, 1, 0 );
+ cube->GetYMinusFaceProperty( )->SetInterpolationToFlat( );
+ cube->GetZPlusFaceProperty( )->SetColor( 0, 0, 1 );
+ cube->GetZPlusFaceProperty( )->SetInterpolationToFlat( );
+ cube->GetZMinusFaceProperty( )->SetColor( 0, 0, 1 );
+ cube->GetZMinusFaceProperty( )->SetInterpolationToFlat( );
+
+ vtkSmartPointer< vtkAxesActor > axes =
+ vtkSmartPointer< vtkAxesActor >::New( );
+ axes->AxisLabelsOff( );
+ axes->SetShaftTypeToCylinder( );
+ axes->SetTotalLength( 2, 2, 2 );
+
+ vtkSmartPointer< vtkPropAssembly > actors =
+ vtkSmartPointer< vtkPropAssembly >::New( );
+ actors->AddPart( cube );
+ actors->AddPart( axes );
+
+ this->OrientationWidget =
+ vtkSmartPointer< vtkOrientationMarkerWidget >::New( );
+ this->OrientationWidget->SetOutlineColor( 0.93, 0.57, 0.13 );
+ this->OrientationWidget->SetOrientationMarker( actors );
+ this->OrientationWidget->SetViewport( 0.0, 0.0, 0.2, 0.2 );
+
+ this->PropPicker = vtkSmartPointer< vtkPropPicker >::New( );
+ this->PropPicker->PickFromListOn( );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Extensions::Visualization::ImageInteractorStyle::
+~ImageInteractorStyle( )
+{
+ std::cout << "destructor" << std::endl;
+}
+
+// -------------------------------------------------------------------------
+bool cpPlugins::Extensions::Visualization::ImageInteractorStyle::
+_PickPosition( double pos[ 3 ] )
+{
+ std::cout << "pickpos" << std::endl;
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
+_UpdateCursor( )
+{
+ std::cout << "upcur" << std::endl;
+}
+
+// eof - $RCSfile$
--- /dev/null
+#ifndef __CPPLUGINS__EXTENSIONS__VISUALIZATION__IMAGEINTERACTORSTYLE__H__
+#define __CPPLUGINS__EXTENSIONS__VISUALIZATION__IMAGEINTERACTORSTYLE__H__
+
+#include <vtkInteractorStyleImage.h>
+#include <vtkOrientationMarkerWidget.h>
+#include <vtkPropPicker.h>
+#include <vtkSmartPointer.h>
+
+/* TODO
+ #include <vtkInteractorStyleImage.h>
+ #include <vtkLineWidget2.h>
+ #include <vtkLineRepresentation.h>
+ #include <vtkPlane.h>
+ class vtkImageData;
+*/
+
+namespace cpPlugins
+{
+ namespace Extensions
+ {
+ namespace Visualization
+ {
+ class ImageSliceActors;
+ class MPRActors;
+
+ /**
+ */
+ class ImageInteractorStyle
+ : public vtkInteractorStyleImage
+ {
+ public:
+ typedef ImageInteractorStyle Self;
+
+ enum InteractionMode
+ {
+ NavigationMode = 0,
+ DeformationMode
+ };
+
+ public:
+ vtkTypeMacro( ImageInteractorStyle, vtkInteractorStyleImage );
+
+ public:
+ static Self* New( );
+
+ void Configure(
+ ImageSliceActors* slice_actors,
+ MPRActors* mpr_actors = NULL
+ );
+
+ void SetModeToNavigation( );
+ void SetModeToDeformation( );
+ virtual void SetInteractor(
+ vtkRenderWindowInteractor* interactor, const int& axis
+ );
+
+ // Description:
+ // Event bindings controlling the effects of pressing mouse buttons
+ // or moving the mouse.
+ virtual void OnMouseMove( );
+ virtual void OnLeftButtonDown( );
+ virtual void OnLeftButtonUp( );
+ virtual void OnMiddleButtonDown( );
+ virtual void OnMiddleButtonUp( );
+ virtual void OnRightButtonDown( );
+ virtual void OnRightButtonUp( );
+ virtual void OnMouseWheelForward( );
+ virtual void OnMouseWheelBackward( );
+
+ // Description:
+ // Override the "fly-to" (f keypress) for images.
+ virtual void OnChar( );
+
+ // These methods for the different interactions in different modes
+ // are overridden in subclasses to perform the correct motion. Since
+ // they might be called from OnTimer, they do not have mouse coord
+ // parameters (use interactor's GetEventPosition and
+ // GetLastEventPosition)
+ virtual void Rotate( );
+ virtual void Pan( );
+ virtual void Spin( );
+ virtual void Zoom( );
+ virtual void WindowLevel( );
+ virtual void Pick( );
+ virtual void Slice( );
+
+ // Interaction mode entry points used internally.
+ virtual void StartWindowLevel( );
+ virtual void EndWindowLevel( );
+ virtual void StartPick( );
+ virtual void EndPick( );
+ virtual void StartSlice( );
+ virtual void EndSlice( );
+
+ protected:
+ ImageInteractorStyle( );
+ virtual ~ImageInteractorStyle( );
+
+ bool _PickPosition( double pos[ 3 ] );
+ void _UpdateCursor( );
+
+ private:
+ // Purposely not implemented
+ ImageInteractorStyle( const Self& );
+ Self& operator=( const Self& );
+
+ protected:
+ Self::InteractionMode Mode;
+
+ ImageSliceActors* m_SliceActors;
+ MPRActors* m_MPRActors;
+
+ vtkSmartPointer< vtkOrientationMarkerWidget > OrientationWidget;
+ vtkSmartPointer< vtkPropPicker > PropPicker;
+
+ public:
+ static const int SliceEvent;
+ };
+
+ } // ecapseman
+
+ } // ecapseman
+
+} // ecapseman
+
+#endif // __CPPLUGINS__EXTENSIONS__VISUALIZATION__IMAGEINTERACTORSTYLE__H__
+
+// eof - $RCSfile$
--- /dev/null
+#include <cpPlugins/Extensions/Visualization/ImageSliceActors.h>
+
+#include <vtkAlgorithmOutput.h>
+#include <vtkCellArray.h>
+#include <vtkInformation.h>
+#include <vtkPlane.h>
+#include <vtkPoints.h>
+#include <vtkProperty.h>
+#include <vtkStreamingDemandDrivenPipeline.h>
+#include <vtkTextProperty.h>
+
+// -------------------------------------------------------------------------
+cpPlugins::Extensions::Visualization::ImageSliceActors*
+cpPlugins::Extensions::Visualization::ImageSliceActors::
+New( )
+{
+ return( new Self( ) );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::ImageSliceActors::
+SetInputConnection( vtkAlgorithmOutput* aout, int axis )
+{
+ this->InputAlgorithm = aout;
+ this->SliceMapper->SetInputConnection( aout );
+ this->SliceMapper->SetOrientation( axis );
+ this->SliceMapper->Update( );
+ this->SetSliceNumber( this->SliceMapper->GetSliceNumber( ) );
+ this->ImageActor->SetMapper( this->SliceMapper );
+ this->ImageActor->Modified( );
+ this->Modified( );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::ImageSliceActors::
+SetSegmentationConnection( vtkAlgorithmOutput* aout )
+{
+ this->SegmentationAlgorithm = aout;
+ this->SegmentationSliceMapper->SetInputConnection( aout );
+ this->SegmentationSliceMapper->
+ SetOrientation( this->SliceMapper->GetOrientation( ) );
+ this->SegmentationSliceMapper->
+ SetSliceNumber( this->SliceMapper->GetSliceNumber( ) );
+ this->SegmentationActor->SetMapper( this->SegmentationSliceMapper );
+ this->SegmentationActor->Modified( );
+ this->Modified( );
+}
+
+// -------------------------------------------------------------------------
+int cpPlugins::Extensions::Visualization::ImageSliceActors::
+GetAxis( ) const
+{
+ return( this->SliceMapper->GetOrientation( ) );
+}
+
+// -------------------------------------------------------------------------
+int cpPlugins::Extensions::Visualization::ImageSliceActors::
+GetSliceNumber( ) const
+{
+ return( this->SliceMapper->GetSliceNumber( ) );
+}
+
+// -------------------------------------------------------------------------
+int cpPlugins::Extensions::Visualization::ImageSliceActors::
+GetSliceNumberMinValue( ) const
+{
+ return( this->SliceMapper->GetSliceNumberMinValue( ) );
+}
+
+// -------------------------------------------------------------------------
+int cpPlugins::Extensions::Visualization::ImageSliceActors::
+GetSliceNumberMaxValue( ) const
+{
+ return( this->SliceMapper->GetSliceNumberMaxValue( ) );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::ImageSliceActors::
+SetSliceNumber( const int& slice )
+{
+ if( this->InputAlgorithm == NULL )
+ return;
+ this->SliceMapper->SetSliceNumber( slice );
+ this->SliceMapper->Update( );
+
+ if( this->SegmentationAlgorithm != NULL )
+ {
+ this->SegmentationSliceMapper->SetSliceNumber( slice );
+ this->SegmentationSliceMapper->Update( );
+
+ } // fi
+
+ // Compute plane
+ vtkAlgorithm* algo = this->SliceMapper->GetInputAlgorithm( );
+ vtkInformation* info = algo->GetOutputInformation( 0 );
+ int ext[ 6 ];
+ double ori[ 3 ], spac[ 3 ], pos[ 3 ];
+ info->Get( vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT( ), ext );
+ info->Get( vtkDataObject::ORIGIN( ), ori );
+ info->Get( vtkDataObject::SPACING( ), spac );
+ this->SliceMapper->GetSlicePlane( )->GetOrigin( pos );
+
+ // Prevent obscuring voxels by offsetting the plane geometry
+ double xbnds[ ] =
+ {
+ ori[ 0 ] + ( spac[ 0 ] * double( ext[ 0 ] ) ),
+ ori[ 0 ] + ( spac[ 0 ] * double( ext[ 1 ] ) )
+ };
+ double ybnds[ ] =
+ {
+ ori[ 1 ] + ( spac[ 1 ] * double( ext[ 2 ] ) ),
+ ori[ 1 ] + ( spac[ 1 ] * double( ext[ 3 ] ) )
+ };
+ double zbnds[ ] =
+ {
+ ori[ 2 ] + ( spac[ 2 ] * double( ext[ 4 ] ) ),
+ ori[ 2 ] + ( spac[ 2 ] * double( ext[ 5 ] ) )
+ };
+
+ if( spac[ 0 ] < double( 0 ) )
+ {
+ double t = xbnds[ 0 ];
+ xbnds[ 0 ] = xbnds[ 1 ];
+ xbnds[ 1 ] = t;
+
+ } // fi
+ if( spac[ 1 ] < double( 0 ) )
+ {
+ double t = ybnds[ 0 ];
+ ybnds[ 0 ] = ybnds[ 1 ];
+ ybnds[ 1 ] = t;
+
+ } // fi
+ if( spac[ 2 ] < double( 0 ) )
+ {
+ double t = zbnds[ 0 ];
+ zbnds[ 0 ] = zbnds[ 1 ];
+ zbnds[ 1 ] = t;
+
+ } // fi
+
+ int axis = this->SliceMapper->GetOrientation( );
+ this->PlaneActor->GetProperty( )->SetRepresentationToWireframe( );
+ this->PlaneActor->GetProperty( )->SetLineWidth( 2 );
+ vtkPoints* plane_points = this->PlaneSource->GetPoints( );
+ if( axis == 0 ) // YZ, x-normal
+ {
+ plane_points->SetPoint( 0, pos[ 0 ], ybnds[ 0 ], zbnds[ 0 ] );
+ plane_points->SetPoint( 1, pos[ 0 ], ybnds[ 1 ], zbnds[ 0 ] );
+ plane_points->SetPoint( 2, pos[ 0 ], ybnds[ 1 ], zbnds[ 1 ] );
+ plane_points->SetPoint( 3, pos[ 0 ], ybnds[ 0 ], zbnds[ 1 ] );
+ this->PlaneActor->GetProperty( )->SetColor( 1, 0, 0 );
+ }
+ else if( axis == 1 ) // ZX, y-normal
+ {
+ plane_points->SetPoint( 0, xbnds[ 0 ], pos[ 1 ], zbnds[ 0 ] );
+ plane_points->SetPoint( 1, xbnds[ 0 ], pos[ 1 ], zbnds[ 1 ] );
+ plane_points->SetPoint( 2, xbnds[ 1 ], pos[ 1 ], zbnds[ 1 ] );
+ plane_points->SetPoint( 3, xbnds[ 1 ], pos[ 1 ], zbnds[ 0 ] );
+ this->PlaneActor->GetProperty( )->SetColor( 0, 1, 0 );
+ }
+ else // XY, z-normal
+ {
+ plane_points->SetPoint( 0, xbnds[ 0 ], ybnds[ 0 ], pos[ 2 ] );
+ plane_points->SetPoint( 1, xbnds[ 1 ], ybnds[ 0 ], pos[ 2 ] );
+ plane_points->SetPoint( 2, xbnds[ 1 ], ybnds[ 1 ], pos[ 2 ] );
+ plane_points->SetPoint( 3, xbnds[ 0 ], ybnds[ 1 ], pos[ 2 ] );
+ this->PlaneActor->GetProperty( )->SetColor( 0, 0, 1 );
+
+ } // fi
+ this->PlaneSource->Modified( );
+ this->PlaneMapper->Modified( );
+ this->PlaneActor->Modified( );
+ this->Modified( );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::ImageSliceActors::
+UpdateText( const double& w, const double& l )
+{
+ char axis;
+ int axId = this->SliceMapper->GetOrientation( );
+ if ( axId == 0 ) axis = 'X';
+ else if( axId == 1 ) axis = 'Y';
+ else if( axId == 2 ) axis = 'Z';
+
+ std::sprintf(
+ this->TextBuffer, "Axis: %c (%d)\nWin/Lev: %.2f/%.2f",
+ axis, this->SliceMapper->GetSliceNumber( ), w, l
+ );
+ this->TextActor->SetInput( this->TextBuffer );
+ this->TextActor->Modified( );
+ this->Modified( );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Extensions::Visualization::ImageSliceActors::
+ImageSliceActors( )
+ : Superclass( ),
+ InputAlgorithm( NULL ),
+ SegmentationAlgorithm( NULL )
+{
+ this->SliceMapper = vtkSmartPointer< vtkImageSliceMapper >::New( );
+ this->SegmentationSliceMapper =
+ vtkSmartPointer< vtkImageSliceMapper >::New( );
+ this->PlaneSource = vtkSmartPointer< vtkPolyData >::New( );
+ this->PlaneMapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
+ this->ImageActor = vtkSmartPointer< vtkImageActor >::New( );
+ this->SegmentationActor = vtkSmartPointer< vtkImageActor >::New( );
+ this->TextActor = vtkSmartPointer< vtkTextActor >::New( );
+ this->PlaneActor = vtkSmartPointer< vtkActor >::New( );
+
+ this->ImageActorIndex = this->GetNumberOfItems( );
+ this->SegmentationActorIndex = this->ImageActorIndex + 1;
+ this->TextActorIndex = this->ImageActorIndex + 2;
+ this->PlaneActorIndex = this->ImageActorIndex + 3;
+ this->AddItem( this->ImageActor );
+ this->AddItem( this->SegmentationActor );
+ this->AddItem( this->TextActor );
+ this->AddItem( this->PlaneActor );
+
+ // Configuration
+ vtkSmartPointer< vtkPoints > plane_points =
+ vtkSmartPointer< vtkPoints >::New( );
+ vtkSmartPointer< vtkCellArray > plane_lines =
+ vtkSmartPointer< vtkCellArray >::New( );
+
+ plane_points->InsertNextPoint( 0, 0, 0 );
+ plane_points->InsertNextPoint( 0, 1, 0 );
+ plane_points->InsertNextPoint( 1, 1, 0 );
+ plane_points->InsertNextPoint( 1, 0, 0 );
+ plane_lines->InsertNextCell( 5 );
+ plane_lines->InsertCellPoint( 0 );
+ plane_lines->InsertCellPoint( 1 );
+ plane_lines->InsertCellPoint( 2 );
+ plane_lines->InsertCellPoint( 3 );
+ plane_lines->InsertCellPoint( 0 );
+ this->PlaneSource->SetPoints( plane_points );
+ this->PlaneSource->SetLines( plane_lines );
+
+ this->PlaneMapper->SetInputData( this->PlaneSource );
+ this->PlaneActor->SetMapper( this->PlaneMapper );
+
+ this->TextActor->SetTextScaleModeToNone( );
+ vtkTextProperty* textprop = this->TextActor->GetTextProperty( );
+ textprop->SetColor( 1, 1, 1 );
+ textprop->SetFontFamilyToCourier( );
+ textprop->SetFontSize( 18 );
+ textprop->BoldOff( );
+ textprop->ItalicOff( );
+ textprop->ShadowOff( );
+ textprop->SetJustificationToLeft( );
+ textprop->SetVerticalJustificationToBottom( );
+ vtkCoordinate* coord = this->TextActor->GetPositionCoordinate( );
+ coord->SetCoordinateSystemToNormalizedViewport( );
+ coord->SetValue( 0.01, 0.01 );
+
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Extensions::Visualization::ImageSliceActors::
+~ImageSliceActors( )
+{
+}
+
+// eof - $RCSfile$
--- /dev/null
+#ifndef __CPPLUGINS__EXTENSIONS__VISUALIZATION__IMAGESLICEACTORS__H__
+#define __CPPLUGINS__EXTENSIONS__VISUALIZATION__IMAGESLICEACTORS__H__
+
+#include <cpPlugins/Extensions/cpPlugins_Extensions_Export.h>
+
+#include <vtkActor.h>
+#include <vtkImageActor.h>
+#include <vtkImageSliceMapper.h>
+#include <vtkPolyData.h>
+#include <vtkPolyDataMapper.h>
+#include <vtkPropCollection.h>
+#include <vtkSmartPointer.h>
+#include <vtkTextActor.h>
+
+// -------------------------------------------------------------------------
+#define cpPlugins_ImageSliceActors( name, type ) \
+ inline type* Get##name##Actor( ) const \
+ { \
+ return( \
+ dynamic_cast< type* >( \
+ const_cast< Self* >( this )-> \
+ GetItemAsObject( this->name##ActorIndex ) \
+ ) \
+ ); \
+ }
+
+class vtkAlgorithmOutput;
+
+namespace cpPlugins
+{
+ namespace Extensions
+ {
+ namespace Visualization
+ {
+ /**
+ */
+ class cpPlugins_Extensions_EXPORT ImageSliceActors
+ : public vtkPropCollection
+ {
+ public:
+ typedef ImageSliceActors Self;
+
+ public:
+ vtkTypeMacro( ImageSliceActors, vtkPropCollection );
+
+ cpPlugins_ImageSliceActors( Image, vtkImageActor );
+ cpPlugins_ImageSliceActors( Segmentation, vtkImageActor );
+ cpPlugins_ImageSliceActors( Text, vtkTextActor );
+ cpPlugins_ImageSliceActors( Plane, vtkActor );
+
+ public:
+ // Creation
+ static ImageSliceActors* New( );
+
+ void SetInputConnection( vtkAlgorithmOutput* aout, int axis );
+ void SetSegmentationConnection( vtkAlgorithmOutput* aout );
+
+ int GetAxis( ) const;
+ int GetSliceNumber( ) const;
+ int GetSliceNumberMinValue( ) const;
+ int GetSliceNumberMaxValue( ) const;
+ void SetSliceNumber( const int& slice );
+ void UpdateText( const double& w, const double& l );
+
+ protected:
+ ImageSliceActors( );
+ virtual ~ImageSliceActors( );
+
+ private:
+ // Purposely not implemented
+ ImageSliceActors( const Self& );
+ Self& operator=( const Self& );
+
+ protected:
+ vtkAlgorithmOutput* InputAlgorithm;
+ vtkAlgorithmOutput* SegmentationAlgorithm;
+
+ vtkSmartPointer< vtkImageSliceMapper > SliceMapper;
+ vtkSmartPointer< vtkImageSliceMapper > SegmentationSliceMapper;
+ vtkSmartPointer< vtkPolyData > PlaneSource;
+ vtkSmartPointer< vtkPolyDataMapper > PlaneMapper;
+ char TextBuffer[ 512 ];
+
+ vtkSmartPointer< vtkImageActor > ImageActor;
+ vtkSmartPointer< vtkImageActor > SegmentationActor;
+ vtkSmartPointer< vtkTextActor > TextActor;
+ vtkSmartPointer< vtkActor > PlaneActor;
+
+ unsigned int ImageActorIndex;
+ unsigned int SegmentationActorIndex;
+ unsigned int TextActorIndex;
+ unsigned int PlaneActorIndex;
+ };
+
+ } // ecapseman
+
+ } // ecapseman
+
+} // ecapseman
+
+#endif // __CPPLUGINS__EXTENSIONS__VISUALIZATION__IMAGESLICEACTORS__H__
+
+// eof - $RCSfile$
--- /dev/null
+#include <cpPlugins/Extensions/Visualization/MPRActors.h>
+
+#include <vtkImageData.h>
+#include <vtkOutlineSource.h>
+#include <vtkPolyDataMapper.h>
+#include <vtkProperty.h>
+#include <vtkRenderer.h>
+
+// -------------------------------------------------------------------------
+cpPlugins::Extensions::Visualization::MPRActors*
+cpPlugins::Extensions::Visualization::MPRActors::
+New( )
+{
+ return( new Self( ) );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Extensions::Visualization::
+ImageSliceActors* cpPlugins::Extensions::Visualization::MPRActors::
+GetSliceActors( const int& i ) const
+{
+ if( i < 3 )
+ return( this->Slices[ i ] );
+ else
+ return( NULL );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::MPRActors::
+SetInputData( vtkImageData* image )
+{
+ if( image == NULL )
+ return;
+
+ this->Image = image;
+
+ this->ImageToWindowLevel->SetInputData( this->Image );
+ this->ResetWindowLevel( );
+ this->ImageToWindowLevel->Update( );
+
+ for( int i = 0; i < 3; ++i )
+ {
+ Slices[ i ]->SetInputConnection(
+ this->ImageToWindowLevel->GetOutputPort( ), i
+ );
+ Slices[ i ]->UpdateText( this->GetWindow( ), this->GetLevel( ) );
+
+ } // rof
+
+ // Create 3D outline
+ vtkSmartPointer< vtkOutlineSource > img_ol =
+ vtkSmartPointer< vtkOutlineSource >::New( );
+ img_ol->SetBounds( this->Image->GetBounds( ) );
+
+ vtkSmartPointer< vtkPolyDataMapper > img_ol_mapper =
+ vtkSmartPointer< vtkPolyDataMapper >::New( );
+ img_ol_mapper->SetInputConnection( img_ol->GetOutputPort( ) );
+ this->ImageOutlineActor->SetMapper( img_ol_mapper );
+ this->ImageOutlineActor->GetProperty( )->SetColor( 1, 1, 1 );
+ this->ImageOutlineActor->GetProperty( )->SetLineWidth( 1 );
+
+ this->ImageOutlineActorIndex = this->GetNumberOfItems( );
+ this->AddItem( this->ImageOutlineActor );
+
+ /*
+ // Cursor radius
+ double spac[ 3 ];
+ image->GetSpacing( spac );
+ double radius = spac[ 0 ];
+ radius = ( spac[ 1 ] < radius )? spac[ 1 ]: radius;
+ radius = ( spac[ 2 ] < radius )? spac[ 2 ]: radius;
+ radius *= double( 6 );
+ this->Cursor->SetRadius( radius );
+ this->CursorMapper->Modified( );
+ this->CursorActor->Modified( );
+
+ // Plane actors
+ for( int a = 0; a < 3; ++a )
+ {
+ // Configure actors
+ this->Planes[ a ].Configure( this->ImageToWindowLevel->GetOutputPort( ), a );
+ this->Planes[ a ].ConfigureRegion( this->Region->GetOutputPort( ) );
+ this->Planes[ a ].UpdateText( this->GetWindow( ), this->GetLevel( ) );
+
+ // Add them to renderer
+ vtkRenderer* ren = this->Interactors[ a ]->GetRenderWindow( )->
+ GetRenderers( )->GetFirstRenderer( );
+ if( ren == NULL )
+ vtkErrorMacro( "At least one interactor doesn't have a valid renderer" );
+ ren->AddActor( this->Planes[ a ].ImageActor );
+ ren->AddActor( this->Planes[ a ].TextActor );
+
+ for( int i = 0; i < 3; ++i )
+ this->Interactors[ a ]->GetRenderWindow( )->
+ GetRenderers( )->GetFirstRenderer( )->
+ AddActor( this->Planes[ i ].PlaneActor );
+
+ } // rof
+ */
+ // Keep track into collection
+/*
+ this->XPlaneIndex = this->GetNumberOfItems( );
+ this->AddItem( this->Planes[ 0 ].ImageActor.GetPointer( ) );
+ this->XTextIndex = this->GetNumberOfItems( );
+ this->AddItem( this->Planes[ 0 ].TextActor.GetPointer( ) );
+ this->XBoundsIndex = this->GetNumberOfItems( );
+ this->AddItem( this->Planes[ 0 ].PlaneActor.GetPointer( ) );
+
+ this->YPlaneIndex = this->GetNumberOfItems( );
+ this->AddItem( this->Planes[ 1 ].ImageActor.GetPointer( ) );
+ this->YTextIndex = this->GetNumberOfItems( );
+ this->AddItem( this->Planes[ 1 ].TextActor.GetPointer( ) );
+ this->YBoundsIndex = this->GetNumberOfItems( );
+ this->AddItem( this->Planes[ 1 ].PlaneActor.GetPointer( ) );
+
+ this->ZPlaneIndex = this->GetNumberOfItems( );
+ this->AddItem( this->Planes[ 2 ].ImageActor.GetPointer( ) );
+ this->ZTextIndex = this->GetNumberOfItems( );
+ this->AddItem( this->Planes[ 2 ].TextActor.GetPointer( ) );
+ this->ZBoundsIndex = this->GetNumberOfItems( );
+ this->AddItem( this->Planes[ 2 ].PlaneActor.GetPointer( ) );
+*/
+ // Initialize slice visualization
+ this->ResetSlices( );
+
+ /*
+ #error CONTOUR_WIDGET <- ACA VOY
+ static vtkSmartPointer<vtkOrientedGlyphContourRepresentation> contourRep =
+ vtkSmartPointer<vtkOrientedGlyphContourRepresentation>::New();
+ static vtkSmartPointer<vtkContourWidget> contourWidget =
+ vtkSmartPointer<vtkContourWidget>::New();
+ contourWidget->SetInteractor( zi );
+ contourWidget->SetRepresentation( contourRep );
+ contourWidget->On( );
+ */
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::MPRActors::
+SetSegmentationData( vtkImageData* segmentation )
+{
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::MPRActors::
+PushDataInto( vtkRenderer* x, vtkRenderer* y, vtkRenderer* z, vtkRenderer* w )
+{
+ vtkRenderer* rends[] = { x, y, z };
+ for( int i = 0; i < 3; ++i )
+ {
+ if( rends[ i ] != NULL )
+ {
+ rends[ i ]->AddActor( this->Slices[ i ]->GetImageActor( ) );
+ rends[ i ]->AddActor( this->Slices[ i ]->GetTextActor( ) );
+ for( int j = 0; j < 3; ++j )
+ rends[ i ]->AddActor( this->Slices[ j ]->GetPlaneActor( ) );
+ if( this->Segmentation != NULL )
+ rends[ i ]->AddActor( this->Slices[ i ]->GetSegmentationActor( ) );
+ if( w != NULL )
+ w->AddActor( this->Slices[ i ]->GetPlaneActor( ) );
+
+ } // fi
+
+ } // rof
+
+ if( w != NULL )
+ {
+ w->AddActor( this->ImageOutlineActor );
+
+ } // fi
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::MPRActors::
+PopDataFrom( vtkRenderer* x, vtkRenderer* y, vtkRenderer* z, vtkRenderer* w )
+{
+}
+
+// -------------------------------------------------------------------------
+double cpPlugins::Extensions::Visualization::MPRActors::
+GetMinWindow( ) const
+{
+ return( double( 0 ) );
+}
+
+// -------------------------------------------------------------------------
+double cpPlugins::Extensions::Visualization::MPRActors::
+GetMaxWindow( ) const
+{
+ if( this->Image == NULL )
+ return( double( 0 ) );
+
+ double range[ 2 ];
+ this->Image->GetScalarRange( range );
+ return( range[ 1 ] - range[ 0 ] );
+}
+
+// -------------------------------------------------------------------------
+double cpPlugins::Extensions::Visualization::MPRActors::
+GetMinLevel( ) const
+{
+ if( this->Image == NULL )
+ return( double( 0 ) );
+
+ double range[ 2 ];
+ this->Image->GetScalarRange( range );
+ return( range[ 0 ] );
+}
+
+// -------------------------------------------------------------------------
+double cpPlugins::Extensions::Visualization::MPRActors::
+GetMaxLevel( ) const
+{
+ if( this->Image == NULL )
+ return( double( 0 ) );
+
+ double range[ 2 ];
+ this->Image->GetScalarRange( range );
+ return( range[ 1 ] );
+}
+
+// -------------------------------------------------------------------------
+double cpPlugins::Extensions::Visualization::MPRActors::
+GetWindow( ) const
+{
+ if( this->Image != NULL )
+ return( this->ImageToWindowLevel->GetWindow( ) );
+ else
+ return( 0 );
+}
+
+// -------------------------------------------------------------------------
+double cpPlugins::Extensions::Visualization::MPRActors::
+GetLevel( ) const
+{
+ if( this->Image != NULL )
+ return( this->ImageToWindowLevel->GetLevel( ) );
+ else
+ return( 0 );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::MPRActors::
+SetWindow( const double& w )
+{
+ if( this->Image != NULL )
+ this->ImageToWindowLevel->SetWindow( w );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::MPRActors::
+SetLevel( const double& l )
+{
+ if( this->Image != NULL )
+ this->ImageToWindowLevel->SetLevel( l );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::MPRActors::
+SetWindowLevel( const double& w, const double& l )
+{
+ this->ImageToWindowLevel->SetWindow( w );
+ this->ImageToWindowLevel->SetLevel( l );
+ for( int i = 0; i < 3; ++i )
+ this->Slices[ i ]->UpdateText( w, l );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::MPRActors::
+ResetWindowLevel( )
+{
+ double range[ 2 ];
+ this->Image->GetScalarRange( range );
+ this->SetWindowLevel(
+ range[ 1 ] - range[ 0 ],
+ ( ( range[ 1 ] + range[ 0 ] ) / double( 2 ) ) + range[ 0 ]
+ );
+}
+
+// -------------------------------------------------------------------------
+vtkPlane* cpPlugins::Extensions::Visualization::MPRActors::
+GetSlicePlane( const int& axis ) const
+{
+}
+
+// -------------------------------------------------------------------------
+int cpPlugins::Extensions::Visualization::MPRActors::
+GetSliceNumberMinValue( const int& axis ) const
+{
+}
+
+// -------------------------------------------------------------------------
+int cpPlugins::Extensions::Visualization::MPRActors::
+GetSliceNumberMaxValue( const int& axis ) const
+{
+}
+
+// -------------------------------------------------------------------------
+int cpPlugins::Extensions::Visualization::MPRActors::
+GetSlice( const int& axis ) const
+{
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::MPRActors::
+SetSlice( const int& axis, const int& slice )
+{
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::MPRActors::
+SetSlice( const int& axis, const double& slice )
+{
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::MPRActors::
+ResetSlices( )
+{
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::MPRActors::
+GetImageBounds( double bounds[ 6 ] ) const
+{
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Extensions::Visualization::MPRActors::
+MPRActors( )
+ : Superclass( ),
+ Image( NULL ),
+ Segmentation( NULL )
+{
+ this->ImageToWindowLevel =
+ vtkSmartPointer< vtkImageMapToWindowLevelColors >::New( );
+ this->SegmentationToColors = vtkSmartPointer< vtkImageMapToColors >::New( );
+ this->ImageOutlineActor = vtkSmartPointer< vtkActor >::New( );
+ this->Slices[ 0 ] = vtkSmartPointer< TSlice >::New( );
+ this->Slices[ 1 ] = vtkSmartPointer< TSlice >::New( );
+ this->Slices[ 2 ] = vtkSmartPointer< TSlice >::New( );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Extensions::Visualization::MPRActors::
+~MPRActors( )
+{
+}
+
+// eof - $RCSfile$
--- /dev/null
+#ifndef __CPPLUGINS__EXTENSIONS__VISUALIZATION__MPRACTORS__H__
+#define __CPPLUGINS__EXTENSIONS__VISUALIZATION__MPRACTORS__H__
+
+#include <cpPlugins/Extensions/cpPlugins_Extensions_Export.h>
+#include <cpPlugins/Extensions/Visualization/ImageSliceActors.h>
+
+#include <vtkActor.h>
+#include <vtkImageMapToColors.h>
+#include <vtkImageMapToWindowLevelColors.h>
+
+class vtkRenderer;
+
+namespace cpPlugins
+{
+ namespace Extensions
+ {
+ namespace Visualization
+ {
+ /**
+ */
+ class cpPlugins_Extensions_EXPORT MPRActors
+ : public vtkPropCollection
+ {
+ public:
+ typedef MPRActors Self;
+
+ public:
+ vtkTypeMacro( MPRActors, vtkPropCollection );
+
+ cpPlugins_ImageSliceActors( ImageOutline, vtkImageActor );
+
+ public:
+ // Creation
+ static MPRActors* New( );
+
+ ImageSliceActors* GetSliceActors( const int& i ) const;
+ void SetInputData( vtkImageData* image );
+ void SetSegmentationData( vtkImageData* segmentation );
+
+ void PushDataInto(
+ vtkRenderer* x,
+ vtkRenderer* y,
+ vtkRenderer* z,
+ vtkRenderer* w
+ );
+ void PopDataFrom(
+ vtkRenderer* x,
+ vtkRenderer* y,
+ vtkRenderer* z,
+ vtkRenderer* w
+ );
+
+ // Window/Level
+ double GetMinWindow( ) const;
+ double GetMaxWindow( ) const;
+ double GetMinLevel( ) const;
+ double GetMaxLevel( ) const;
+ double GetWindow( ) const;
+ double GetLevel( ) const;
+ void SetWindow( const double& w );
+ void SetLevel( const double& l );
+ void SetWindowLevel( const double& w, const double& l );
+ void ResetWindowLevel( );
+
+ // Slice access
+ vtkPlane* GetSlicePlane( const int& axis ) const;
+ int GetSliceNumberMinValue( const int& axis ) const;
+ int GetSliceNumberMaxValue( const int& axis ) const;
+ int GetSlice( const int& axis ) const;
+ void SetSlice( const int& axis, const int& slice );
+ void SetSlice( const int& axis, const double& slice );
+ void ResetSlices( );
+
+ // General accessors
+ void GetImageBounds( double bounds[ 6 ] ) const;
+
+ protected:
+ MPRActors( );
+ virtual ~MPRActors( );
+
+ private:
+ // Purposely not implemented
+ MPRActors( const Self& );
+ Self& operator=( const Self& );
+
+ protected:
+ vtkImageData* Image;
+ vtkImageData* Segmentation;
+
+ vtkSmartPointer< vtkImageMapToWindowLevelColors > ImageToWindowLevel;
+ vtkSmartPointer< vtkImageMapToColors > SegmentationToColors;
+
+ vtkSmartPointer< vtkActor > ImageOutlineActor;
+
+ typedef cpPlugins::Extensions::Visualization::ImageSliceActors TSlice;
+ vtkSmartPointer< TSlice > Slices[ 3 ];
+
+ unsigned int ImageOutlineActorIndex;
+ };
+
+ } // ecapseman
+
+ } // ecapseman
+
+} // ecapseman
+
+#endif // __CPPLUGINS__EXTENSIONS__VISUALIZATION__MPRACTORS__H__
+
+// eof - $RCSfile$
TARGET_LINK_LIBRARIES(
${LIBRARY_NAME}
cpPlugins_Pluma
- ${ITK_LIBRARIES}
- ${VTK_LIBRARIES}
+ cpPlugins_Extensions
)
## eof - $RCSfile$