#include "ui_PipelineEditor.h"
#include <cpPipelineEditor/Editor.h>
+#include <cpExtensions/QT/PropertyWidget.h>
#include <QMessageBox>
+#include <vtkRenderWindowInteractor.h>
// -------------------------------------------------------------------------
PipelineEditor::
this,
SLOT( _ShowFilterOutput( const std::string&, const std::string& ) )
);
+ this->connect(
+ this->m_UI->Canvas->editor( ),
+ SIGNAL( hideFilterOutput( const std::string&, const std::string& ) ),
+ this,
+ SLOT( _HideFilterOutput( const std::string&, const std::string& ) )
+ );
+ this->connect(
+ this->m_UI->Canvas->editor( ),
+ SIGNAL( visualPropertiesFilterOutput( const std::string&, const std::string& ) ),
+ this,
+ SLOT( _PropertiesFilterOutput( const std::string&, const std::string& ) )
+ );
}
// -------------------------------------------------------------------------
} // fi
}
+// -------------------------------------------------------------------------
+void PipelineEditor::
+_HideFilterOutput(
+ const std::string& filter_name, const std::string& output_name
+ )
+{
+ // Get output
+ auto filter = this->m_Workspace.GetFilter( filter_name );
+ if( filter != NULL )
+ {
+ auto output = filter->GetOutputData( output_name );
+ if( output != NULL )
+ {
+ std::string data_name = output_name + "@" + filter_name;
+ this->m_UI->Viewer->HideData( data_name );
+
+ } // fi
+
+ } // fi
+}
+
+// -------------------------------------------------------------------------
+void PipelineEditor::
+_PropertiesFilterOutput(
+ const std::string& filter_name, const std::string& output_name
+ )
+{
+ // Get output
+ auto filter = this->m_Workspace.GetFilter( filter_name );
+ if( filter != NULL )
+ {
+ auto output = filter->GetOutputData( output_name );
+ if( output != NULL )
+ {
+ std::string data_name = output_name + "@" + filter_name;
+ auto prop = this->m_UI->Viewer->GetProp( data_name );
+
+ cpExtensions::QT::PropertyWidget* wdg =
+ new cpExtensions::QT::PropertyWidget( NULL );
+ wdg->SetProp( prop );
+ wdg->SetRenderWindow( this->m_UI->Viewer->GetInteractor( 3 )->GetRenderWindow( ) );
+ wdg->show( );
+ }
+ else
+ QMessageBox::critical(
+ this,
+ QMessageBox::tr( "Error showing data" ),
+ QMessageBox::tr( "No known VTK conversion!" )
+ );
+
+ } // fi
+}
+
// eof - $RCSfile$
void _ShowFilterOutput(
const std::string& filter_name, const std::string& output_name
);
+ void _HideFilterOutput(
+ const std::string& filter_name, const std::string& output_name
+ );
+ void _PropertiesFilterOutput(
+ const std::string& filter_name, const std::string& output_name
+ );
private:
Ui::PipelineEditor* m_UI;
SET(
examples_SOURCES
example_KalmanVelocity
+ example_ImageSlice
)
FOREACH(example ${examples_SOURCES})
--- /dev/null
+#include <vtkPNGReader.h>
+#include <vtkRenderer.h>
+#include <vtkRenderWindow.h>
+#include <vtkRenderWindowInteractor.h>
+#include <vtkSmartPointer.h>
+
+#include <cpExtensions/Visualization/ImageSliceActors.h>
+
+int main( int argc, char* argv[] )
+{
+ if( argc < 2 )
+ {
+ std::cerr << "Usage: " << argv[ 0 ] << " input_image.png" << std::endl;
+ return( 1 );
+
+ } // fi
+
+ // Read a test image
+ vtkSmartPointer< vtkPNGReader > reader =
+ vtkSmartPointer< vtkPNGReader >::New( );
+ reader->SetFileName( argv[ 1 ] );
+ reader->Update( );
+
+ // Prepate slice objects
+ vtkSmartPointer< cpExtensions::Visualization::ImageSliceActors > actors =
+ vtkSmartPointer< cpExtensions::Visualization::ImageSliceActors >::New( );
+ actors->SetInputConnection( reader->GetOutputPort( ) );
+
+ // Prepare scene
+ vtkSmartPointer< vtkRenderer > ren =
+ vtkSmartPointer< vtkRenderer >::New( );
+ ren->SetBackground( 0, 0, 0 );
+ actors->PushInto( ren );
+
+ vtkSmartPointer< vtkRenderWindow > win =
+ vtkSmartPointer< vtkRenderWindow >::New( );
+ win->AddRenderer( ren );
+ win->SetSize( 300, 300 );
+
+ vtkSmartPointer< vtkRenderWindowInteractor > iren =
+ vtkSmartPointer< vtkRenderWindowInteractor >::New( );
+ iren->SetRenderWindow( win );
+ iren->SetInteractorStyle( actors->GetStyle( ) );
+
+ iren->Initialize( );
+ ren->ResetCamera( );
+ iren->Start( );
+
+ return( 0 );
+}
+
+// eof - $RCSfile$
example_LoadPluginsDirectory
example_ReadWriteImage
example_ReadWriteImageWithWorkspace
+ example_ShowImage
)
FOREACH(example ${examples_SOURCES})
ADD_EXECUTABLE(${example} ${example}.cxx)
- TARGET_LINK_LIBRARIES(${example} cpPlugins)
+ TARGET_LINK_LIBRARIES(${example} cpExtensions cpPlugins)
ENDFOREACH(example)
+IF(USE_QT4)
+ SUBDIRS(
+ QT
+ )
+ENDIF(USE_QT4)
+
## eof - $RCSfile$
--- /dev/null
+SUBDIRS(
+ example_MPRViewer
+ )
+## eof - $RCSfile$
--- /dev/null
+SET(app_NAME "example_MPRViewer")
+
+INCLUDE_DIRECTORIES(
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ )
+
+## ====================================================
+## = Source code, user interafaces and resources here =
+## ====================================================
+
+SET(
+ app_SOURCES
+ ${CMAKE_CURRENT_SOURCE_DIR}/example_MPRViewer.cxx
+ ${CMAKE_CURRENT_SOURCE_DIR}/main.cxx
+ )
+
+SET(
+ app_HEADERS
+ ${CMAKE_CURRENT_SOURCE_DIR}/example_MPRViewer.h
+ )
+
+SET(
+ app_UI
+ ${CMAKE_CURRENT_SOURCE_DIR}/example_MPRViewer.ui
+ )
+
+## =====================
+## = Compilation rules =
+## =====================
+
+QT4_WRAP_UI(app_UI_HEADERS ${app_UI})
+QT4_WRAP_CPP(app_MOC_SOURCES ${app_HEADERS})
+
+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_HEADERS}
+ ${app_UI_HEADERS}
+ ${app_SOURCES}
+ ${app_MOC_SOURCES}
+ )
+TARGET_LINK_LIBRARIES(
+ ${app_NAME}
+ cpExtensions
+ cpPlugins
+ )
+
+## eof - $RCSfile$
--- /dev/null
+#include "example_MPRViewer.h"
+#include "ui_example_MPRViewer.h"
+
+#include <QMessageBox>
+#include <vtkImageData.h>
+
+// -------------------------------------------------------------------------
+example_MPRViewer::
+example_MPRViewer( int argc, char* argv[], QWidget* parent )
+ : Superclass( parent ),
+ m_UI( new Ui::example_MPRViewer )
+{
+ this->m_UI->setupUi( this );
+
+ if( argc < 2 )
+ {
+ QMessageBox::critical(
+ this,
+ QMessageBox::tr( "Error" ),
+ QMessageBox::tr( "Give some input image(s)." )
+ );
+ std::exit( 1 );
+
+ } // fi
+
+ // Create reader
+ this->m_Interface.GuessAccesiblePlugins( );
+ try
+ {
+ this->m_Reader = this->m_Interface.Create( "IO", "ImageReader" );
+ if( this->m_Reader.IsNull( ) )
+ {
+ QMessageBox::critical(
+ this,
+ QMessageBox::tr( "Error" ),
+ QMessageBox::tr( "\"IO::ImageReader\" creation failed." )
+ );
+ std::exit( 1 );
+
+ } // fi
+
+ // Configure filters
+ auto reader_params = this->m_Reader->GetParameters( );
+ for( int i = 1; i < argc; ++i )
+ reader_params->AddToOpenFileNameList( "FileNames", argv[ i ] );
+ this->m_Reader->Update( );
+ }
+ catch( itk::ExceptionObject& err1 )
+ {
+ QMessageBox::critical(
+ this,
+ QMessageBox::tr( "Error" ),
+ QMessageBox::tr( err1.GetDescription( ) )
+ );
+ std::exit( 1 );
+ }
+ catch( std::exception& err2 )
+ {
+ QMessageBox::critical(
+ this,
+ QMessageBox::tr( "Error" ),
+ QMessageBox::tr( err2.what( ) )
+ );
+ std::exit( 1 );
+
+ } // yrt
+
+ this->m_UI->Viewer->SetMainImage(
+ this->m_Reader->GetOutputData( "Output" )->GetVTK< vtkImageData >( )
+ );
+}
+
+// -------------------------------------------------------------------------
+example_MPRViewer::
+~example_MPRViewer( )
+{
+}
+
+// eof - $RCSfile$
--- /dev/null
+#ifndef __EXAMPLE_MPRVIEWER__H__
+#define __EXAMPLE_MPRVIEWER__H__
+
+#include <QMainWindow>
+#include <cpPlugins/Interface.h>
+
+// -------------------------------------------------------------------------
+namespace Ui
+{
+ class example_MPRViewer;
+}
+
+// -------------------------------------------------------------------------
+/**
+ */
+class example_MPRViewer
+ : public QMainWindow
+{
+ Q_OBJECT;
+
+public:
+ typedef example_MPRViewer Self;
+ typedef QMainWindow Superclass;
+
+public:
+ explicit example_MPRViewer(
+ int argc, char* argv[],
+ QWidget* parent = NULL
+ );
+ virtual ~example_MPRViewer( );
+
+private:
+ Ui::example_MPRViewer* m_UI;
+ cpPlugins::Interface m_Interface;
+ cpPlugins::ProcessObject::Pointer m_Reader;
+};
+
+#endif // __CPEXAMPLE_MPRVIEWER__H__
+
+// eof - $RCSfile$
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>example_MPRViewer</class>
+ <widget class="QMainWindow" name="example_MPRViewer">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>800</width>
+ <height>600</height>
+ </rect>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>800</width>
+ <height>600</height>
+ </size>
+ </property>
+ <property name="windowTitle">
+ <string>MainWindow</string>
+ </property>
+ <widget class="QWidget" name="MainWidget">
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="cpExtensions::QT::SimpleMPRWidget" name="Viewer" native="true">
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>200</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>cpExtensions::QT::SimpleMPRWidget</class>
+ <extends>QWidget</extends>
+ <header location="global">cpExtensions/QT/SimpleMPRWidget.h</header>
+ <container>1</container>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
--- /dev/null
+#include "example_MPRViewer.h"
+#include <cstdlib>
+#include <QApplication>
+
+// -------------------------------------------------------------------------
+int main( int argc, char* argv[] )
+{
+ QApplication a( argc, argv );
+ example_MPRViewer w( argc, argv );
+ 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$
--- /dev/null
+#include <iostream>
+
+#include <cpExtensions/Visualization/ImageSliceActors.h>
+#include <cpPlugins/Interface.h>
+
+#include <vtkImageData.h>
+#include <vtkRenderer.h>
+#include <vtkRenderWindow.h>
+#include <vtkRenderWindowInteractor.h>
+#include <vtkSmartPointer.h>
+
+int main( int argc, char* argv[] )
+{
+ if( argc < 2 )
+ {
+ std::cerr
+ << "Usage: " << argv[ 0 ]
+ << " input_image(s)" << std::endl;
+ return( 1 );
+
+ } // fi
+
+ // Load interface
+ cpPlugins::Interface interface;
+ interface.GuessAccesiblePlugins( );
+
+ // Create filters
+ cpPlugins::ProcessObject::Pointer reader;
+ try
+ {
+ reader = interface.Create( "IO", "ImageReader" );
+ if( reader.IsNull( ) )
+ {
+ std::cerr
+ << "\"IO::ImageReader\" creation failed."
+ << std::endl;
+ return( 1 );
+
+ } // fi
+
+ // Configure filters
+ auto reader_params = reader->GetParameters( );
+ for( int i = 1; i < argc; ++i )
+ reader_params->AddToOpenFileNameList( "FileNames", argv[ i ] );
+ reader->Update( );
+ }
+ catch( itk::ExceptionObject& err1 )
+ {
+ std::cerr << "Error: " << err1.GetDescription( ) << std::endl;
+ return( 1 );
+ }
+ catch( std::exception& err2 )
+ {
+ std::cerr << "Error: " << err2.what( ) << std::endl;
+ return( 1 );
+
+ } // yrt
+
+ // Prepate slice objects
+ vtkSmartPointer< cpExtensions::Visualization::ImageSliceActors > actors =
+ vtkSmartPointer< cpExtensions::Visualization::ImageSliceActors >::New( );
+ actors->SetInputData(
+ reader->GetOutputData( "Output" )->GetVTK< vtkImageData >( ), 1
+ );
+
+ // Prepare scene
+ vtkSmartPointer< vtkRenderer > ren =
+ vtkSmartPointer< vtkRenderer >::New( );
+ ren->SetBackground( 0, 0, 0 );
+ actors->PushInto( ren );
+
+ vtkSmartPointer< vtkRenderWindow > win =
+ vtkSmartPointer< vtkRenderWindow >::New( );
+ win->AddRenderer( ren );
+ win->SetSize( 500, 500 );
+
+ vtkSmartPointer< vtkRenderWindowInteractor > iren =
+ vtkSmartPointer< vtkRenderWindowInteractor >::New( );
+ iren->SetRenderWindow( win );
+ iren->SetInteractorStyle( actors->GetStyle( ) );
+
+ iren->Initialize( );
+ ren->Render( );
+ ren->ResetCamera( );
+ iren->Start( );
+
+ // Ok finish
+ return( 0 );
+}
+
+// eof - $RCSfile$
)
ENDIF(USE_QT4)
-
## =====================
## = Compilation rules =
## =====================
#include <cpExtensions/Interaction/ImageInteractorStyle.h>
+#include <vtkCamera.h>
#include <vtkCommand.h>
#include <vtkImageActor.h>
+#include <vtkImageMapper3D.h>
+#include <vtkImageSliceMapper.h>
#include <vtkPropCollection.h>
#include <vtkProperty.h>
#include <vtkRenderWindowInteractor.h>
+#include <vtkRenderer.h>
// -------------------------------------------------------------------------
-cpExtensions::Interaction::ImageInteractorStyle::TSeedWidget::
-TSeedWidget( vtkRenderWindowInteractor* interactor, vtkImageActor* actor )
-{
- this->Placer = vtkSmartPointer< vtkImageActorPointPlacer >::New( );
- this->Handle = vtkSmartPointer< vtkPointHandleRepresentation3D >::New( );
- this->Representation = vtkSmartPointer< vtkSeedRepresentation >::New( );
- this->Widget = vtkSmartPointer< SeedWidget >::New( );
-
- this->Placer->SetImageActor( actor );
- this->Handle->GetProperty( )->SetColor( 1, 0, 0 );
- this->Handle->SetPointPlacer( this->Placer );
- this->Representation->SetHandleRepresentation( this->Handle );
- this->Widget->SetRepresentation( this->Representation );
- this->Widget->SetInteractor( interactor );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Interaction::ImageInteractorStyle::TSeedWidget::
-On( )
-{
- this->Widget->On( );
-}
+/* TODO
+ cpExtensions::Interaction::ImageInteractorStyle::TSeedWidget::
+ TSeedWidget( vtkRenderWindowInteractor* interactor, vtkImageActor* actor )
+ {
+ this->Placer = vtkSmartPointer< vtkImageActorPointPlacer >::New( );
+ this->Handle = vtkSmartPointer< vtkPointHandleRepresentation3D >::New( );
+ this->Representation = vtkSmartPointer< vtkSeedRepresentation >::New( );
+ this->Widget = vtkSmartPointer< SeedWidget >::New( );
-// -------------------------------------------------------------------------
-void cpExtensions::Interaction::ImageInteractorStyle::TSeedWidget::
-Off( )
-{
- this->Widget->Off( );
-}
+ this->Placer->SetImageActor( actor );
+ this->Handle->GetProperty( )->SetColor( 1, 0, 0 );
+ this->Handle->SetPointPlacer( this->Placer );
+ this->Representation->SetHandleRepresentation( this->Handle );
+ this->Widget->SetRepresentation( this->Representation );
+ this->Widget->SetInteractor( interactor );
+ }
+
+ // -------------------------------------------------------------------------
+ void cpExtensions::Interaction::ImageInteractorStyle::TSeedWidget::
+ On( )
+ {
+ this->Widget->On( );
+ }
+
+ // -------------------------------------------------------------------------
+ void cpExtensions::Interaction::ImageInteractorStyle::TSeedWidget::
+ Off( )
+ {
+ this->Widget->Off( );
+ }
+*/
// -------------------------------------------------------------------------
cpExtensions::Interaction::ImageInteractorStyle::
return( new Self );
}
+// -------------------------------------------------------------------------
+void cpExtensions::Interaction::ImageInteractorStyle::
+SetCurrentRenderer( vtkRenderer* r )
+{
+ this->Superclass::SetCurrentRenderer( r );
+
+ if( !( this->m_Configured ) )
+ {
+ auto lst = this->m_PropPicker->GetPickList( );
+ if( lst == NULL )
+ return;
+ if( lst->GetNumberOfItems( ) == 1 )
+ {
+ auto actor = dynamic_cast< vtkImageActor* >( lst->GetItemAsObject( 0 ) );
+ if( actor != NULL )
+ {
+ this->_ConfigureCamera( actor );
+ this->Modified( );
+
+ } // fi
+
+ } // fi
+
+ } // fi
+}
+
// -------------------------------------------------------------------------
void cpExtensions::Interaction::ImageInteractorStyle::
AssociateImageActor( vtkImageActor* actor )
{
if( actor != NULL )
{
+ // Update picker
+ this->m_PropPicker->GetPickList( )->RemoveAllItems( );
this->m_PropPicker->AddPickList( actor );
+ this->m_Configured = false;
+ this->_ConfigureCamera( actor );
+
+ // Ok, done
this->Modified( );
} // fi
}
// -------------------------------------------------------------------------
+/*
void cpExtensions::Interaction::ImageInteractorStyle::
SeedWidgetOn( )
{
} // fi
}
+*/
// -------------------------------------------------------------------------
+/*
void cpExtensions::Interaction::ImageInteractorStyle::
SetSeedWidgetCommand( vtkCommand* cmd )
{
void cpExtensions::Interaction::ImageInteractorStyle::
GetSeedAsIndex( unsigned int id, int idx[ 3 ] ) const
{
- /* TODO
if( this->m_SeedWidget != NULL )
this->m_SeedWidget->Representation->GetSeedWorldPosition( id, pos );
- */
}
+*/
// -------------------------------------------------------------------------
cpExtensions::Interaction::ImageInteractorStyle::
ImageInteractorStyle( )
: Superclass( ),
- m_SeedWidget( NULL )
+ m_Configured( false )
+ /*
+ ,
+ m_SeedWidget( NULL )
+ */
{
this->m_PropPicker = vtkSmartPointer< vtkPropPicker >::New( );
this->m_PropPicker->PickFromListOn( );
cpExtensions::Interaction::ImageInteractorStyle::
~ImageInteractorStyle( )
{
- if( this->m_SeedWidget != NULL ) delete this->m_SeedWidget;
+ // if( this->m_SeedWidget != NULL ) delete this->m_SeedWidget;
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Interaction::ImageInteractorStyle::
+_ConfigureCamera( vtkImageActor* actor )
+{
+ if( this->CurrentRenderer != NULL )
+ {
+ // Update camera
+ auto camera = this->CurrentRenderer->GetActiveCamera( );
+ auto mapper = dynamic_cast< vtkImageSliceMapper* >( actor->GetMapper( ) );
+ if( mapper != NULL && camera != NULL )
+ {
+ double bounds[ 6 ];
+ actor->GetBounds( bounds );
+ camera->ParallelProjectionOn( );
+ camera->SetFocalPoint( double( 0 ), double( 0 ), double( 0 ) );
+ int orientation = mapper->GetOrientation( );
+ switch( orientation )
+ {
+ case 0:
+ {
+ camera->SetPosition( double( 1 ), double( 0 ), double( 0 ) );
+ camera->SetViewUp ( double( 0 ), double( 1 ), double( 0 ) );
+ }
+ break;
+ case 1:
+ {
+ camera->SetPosition( double( 0 ), double( 1 ), double( 0 ) );
+ camera->SetViewUp ( double( 0 ), double( 0 ), double( -1 ) );
+ }
+ break;
+ case 2:
+ {
+ camera->SetPosition( double( 0 ), double( 0 ), double( 1 ) );
+ camera->SetViewUp ( double( 0 ), double( 1 ), double( 0 ) );
+ }
+ break;
+ default:
+ break;
+ } // hctiws
+ this->CurrentRenderer->ResetCamera( );
+ this->m_Configured = true;
+
+ } // fi
+
+ } // fi
}
// -------------------------------------------------------------------------
#include <vector>
-#include <vtkSmartPointer.h>
-#include <vtkImageActorPointPlacer.h>
#include <vtkPropPicker.h>
-#include <vtkPointHandleRepresentation3D.h>
-#include <vtkSeedRepresentation.h>
-#include <cpExtensions/Interaction/SeedWidget.h>
+#include <vtkSmartPointer.h>
+/* TODO
+ #include <vtkImageActorPointPlacer.h>
+ #include <vtkPointHandleRepresentation3D.h>
+ #include <vtkSeedRepresentation.h>
+ #include <cpExtensions/Interaction/SeedWidget.h>
+*/
// Forward definitions
class vtkCommand;
typedef Superclass::TLeaveCommand TLeaveCommand;
// Widgets
- struct TSeedWidget
- {
- vtkSmartPointer< vtkImageActorPointPlacer > Placer;
- vtkSmartPointer< vtkPointHandleRepresentation3D > Handle;
- vtkSmartPointer< vtkSeedRepresentation > Representation;
- vtkSmartPointer< SeedWidget > Widget;
-
- TSeedWidget(
- vtkRenderWindowInteractor* interactor, vtkImageActor* actor
- );
- void On( );
- void Off( );
- };
+ /* TODO
+ struct TSeedWidget
+ {
+ vtkSmartPointer< vtkImageActorPointPlacer > Placer;
+ vtkSmartPointer< vtkPointHandleRepresentation3D > Handle;
+ vtkSmartPointer< vtkSeedRepresentation > Representation;
+ vtkSmartPointer< SeedWidget > Widget;
+
+ TSeedWidget(
+ vtkRenderWindowInteractor* interactor, vtkImageActor* actor
+ );
+ void On( );
+ void Off( );
+ };
+ */
public:
static Self* New( );
+ virtual void SetCurrentRenderer( vtkRenderer* r ) VTK_OVERRIDE;
+
// Data for local picker
virtual void AssociateImageActor( vtkImageActor* actor );
// Widgets
- void SeedWidgetOn( );
- void SeedWidgetOff( );
- void SetSeedWidgetCommand( vtkCommand* cmd );
- unsigned int GetNumberOfSeeds( ) const;
- void GetSeedAsPoint( unsigned int id, double pos[ 3 ] ) const;
- void GetSeedAsIndex( unsigned int id, int pos[ 3 ] ) const;
+ /* TODO
+ void SeedWidgetOn( );
+ void SeedWidgetOff( );
+ void SetSeedWidgetCommand( vtkCommand* cmd );
+ unsigned int GetNumberOfSeeds( ) const;
+ void GetSeedAsPoint( unsigned int id, double pos[ 3 ] ) const;
+ void GetSeedAsIndex( unsigned int id, int pos[ 3 ] ) const;
+ */
protected:
ImageInteractorStyle( );
virtual ~ImageInteractorStyle( );
+ void _ConfigureCamera( vtkImageActor* actor );
virtual bool _PickPosition( int idx[ 2 ], double pos[ 3 ] );
private:
Self& operator=( const Self& );
protected:
+ bool m_Configured;
vtkSmartPointer< vtkPropPicker > m_PropPicker;
-
- TSeedWidget* m_SeedWidget;
+ /* TODO
+ TSeedWidget* m_SeedWidget;
+ */
};
} // ecapseman
--- /dev/null
+#include <cpExtensions/QT/PropertyWidget.h>
+
+#ifdef cpExtensions_QT4
+
+#include <QColorDialog>
+#include <vtkActor.h>
+#include <vtkMapper.h>
+#include <vtkProp.h>
+#include <vtkProperty.h>
+#include <vtkRenderWindow.h>
+
+#include <cpExtensions/ui_PropertyWidget.h>
+
+// -------------------------------------------------------------------------
+cpExtensions::QT::PropertyWidget::
+PropertyWidget( QWidget* parent )
+ : QWidget( parent ),
+ m_UI( new Ui::PropertyWidget ),
+ m_Prop( NULL ),
+ m_Window( NULL )
+{
+ this->m_UI->setupUi( this );
+ this->connect(
+ this->m_UI->m_Color, SIGNAL( clicked( ) ),
+ this, SLOT( _Color( ) )
+ );
+ this->connect(
+ this->m_UI->m_Opacity, SIGNAL( valueChanged( int ) ),
+ this, SLOT( _Opacity( int ) )
+ );
+ this->connect(
+ this->m_UI->m_LineWidth, SIGNAL( valueChanged( double ) ),
+ this, SLOT( _LineWidth( double ) )
+ );
+ this->connect(
+ this->m_UI->m_PointSize, SIGNAL( valueChanged( double ) ),
+ this, SLOT( _PointSize( double ) )
+ );
+}
+
+// -------------------------------------------------------------------------
+cpExtensions::QT::PropertyWidget::
+~PropertyWidget( )
+{
+ delete this->m_UI;
+}
+
+// -------------------------------------------------------------------------
+vtkProp* cpExtensions::QT::PropertyWidget::
+GetProp( )
+{
+ return( this->m_Prop );
+}
+
+// -------------------------------------------------------------------------
+vtkRenderWindow* cpExtensions::QT::PropertyWidget::
+GetRenderWindow( )
+{
+ return( this->m_Window );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::QT::PropertyWidget::
+SetProp( vtkProp* p )
+{
+ this->m_Prop = p;
+ if( this->m_Prop == NULL )
+ return;
+
+ auto actor = dynamic_cast< vtkActor* >( this->m_Prop );
+ if( actor == NULL )
+ return;
+
+ double opacity = actor->GetProperty( )->GetOpacity( );
+ double lw = actor->GetProperty( )->GetLineWidth( );
+ double ps = actor->GetProperty( )->GetPointSize( );
+ opacity *= this->m_UI->m_Opacity->maximum( );
+
+ this->m_UI->m_Opacity->setValue( opacity );
+ this->m_UI->m_LineWidth->setValue( lw );
+ this->m_UI->m_PointSize->setValue( ps );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::QT::PropertyWidget::
+SetRenderWindow( vtkRenderWindow* w )
+{
+ this->m_Window = w;
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::QT::PropertyWidget::
+_Color( )
+{
+ if( this->m_Prop == NULL )
+ return;
+
+ auto actor = dynamic_cast< vtkActor* >( this->m_Prop );
+ if( actor == NULL )
+ return;
+
+ double rgb[ 3 ];
+ actor->GetProperty( )->GetColor( rgb );
+ QColor color =
+ QColorDialog::getColor(
+ QColor( rgb[ 0 ] * 255, rgb[ 1 ] * 255, rgb[ 2 ] * 255 ),
+ this,
+ "Select Color",
+ QColorDialog::DontUseNativeDialog
+ );
+ if( color.isValid( ) )
+ {
+ rgb[ 0 ] = double( color.red( ) ) / double( 255 );
+ rgb[ 1 ] = double( color.green( ) ) / double( 255 );
+ rgb[ 2 ] = double( color.blue( ) ) / double( 255 );
+ actor->GetMapper( )->ScalarVisibilityOff( );
+ actor->GetProperty( )->SetColor( rgb );
+ actor->Modified( );
+ if( this->m_Window != NULL )
+ this->m_Window->Render( );
+
+ } // fi
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::QT::PropertyWidget::
+_Opacity( int o )
+{
+ if( this->m_Prop == NULL )
+ return;
+
+ auto actor = dynamic_cast< vtkActor* >( this->m_Prop );
+ if( actor == NULL )
+ return;
+ double v = double( o ) / double( this->m_UI->m_Opacity->maximum( ) );
+ actor->GetProperty( )->SetOpacity( v );
+ actor->Modified( );
+ if( this->m_Window != NULL )
+ this->m_Window->Render( );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::QT::PropertyWidget::
+_LineWidth( double lw )
+{
+ if( this->m_Prop == NULL )
+ return;
+
+ auto actor = dynamic_cast< vtkActor* >( this->m_Prop );
+ if( actor == NULL )
+ return;
+ actor->GetProperty( )->SetLineWidth( lw );
+ actor->Modified( );
+ if( this->m_Window != NULL )
+ this->m_Window->Render( );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::QT::PropertyWidget::
+_PointSize( double ps )
+{
+ if( this->m_Prop == NULL )
+ return;
+
+ auto actor = dynamic_cast< vtkActor* >( this->m_Prop );
+ if( actor == NULL )
+ return;
+ actor->GetProperty( )->SetPointSize( ps );
+ actor->Modified( );
+ if( this->m_Window != NULL )
+ this->m_Window->Render( );
+}
+
+#endif // cpExtensions_QT4
+
+// eof - $RCSfile$
--- /dev/null
+#ifndef __CPEXTENSIONS__QT__PROPERTYWIDGET__H__
+#define __CPEXTENSIONS__QT__PROPERTYWIDGET__H__
+
+#include <cpExtensions/Config.h>
+
+#ifdef cpExtensions_QT4
+
+#include <QWidget>
+
+// -------------------------------------------------------------------------
+class vtkProp;
+class vtkRenderWindow;
+
+namespace Ui
+{
+ class PropertyWidget;
+}
+
+// -------------------------------------------------------------------------
+namespace cpExtensions
+{
+ namespace QT
+ {
+ /**
+ */
+ class cpExtensions_EXPORT PropertyWidget
+ : public QWidget
+ {
+ Q_OBJECT;
+
+ public:
+ typedef PropertyWidget Self;
+
+ public:
+ explicit PropertyWidget( QWidget* parent = 0 );
+ virtual ~PropertyWidget( );
+
+ vtkProp* GetProp( );
+ vtkRenderWindow* GetRenderWindow( );
+ void SetProp( vtkProp* p );
+ void SetRenderWindow( vtkRenderWindow* w );
+
+ protected slots:
+ void _Color( );
+ void _Opacity( int o );
+ void _LineWidth( double lw );
+ void _PointSize( double ps );
+
+ protected:
+ Ui::PropertyWidget* m_UI;
+ vtkProp* m_Prop;
+ vtkRenderWindow* m_Window;
+ };
+
+ } // ecapseman
+
+} // ecapseman
+
+#endif // cpExtensions_QT4
+
+#endif // __CPEXTENSIONS__QT__PROPERTYWIDGET__H__
+
+// eof - $RCSfile$
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>PropertyWidget</class>
+ <widget class="QWidget" name="PropertyWidget">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>595</width>
+ <height>125</height>
+ </rect>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>595</width>
+ <height>125</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>595</width>
+ <height>125</height>
+ </size>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QPushButton" name="m_Color">
+ <property name="text">
+ <string>Color</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="minimumSize">
+ <size>
+ <width>54</width>
+ <height>21</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>54</width>
+ <height>21</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Opacity:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSlider" name="m_Opacity">
+ <property name="maximum">
+ <number>100</number>
+ </property>
+ <property name="value">
+ <number>100</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_4">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QLabel" name="label_2">
+ <property name="minimumSize">
+ <size>
+ <width>71</width>
+ <height>21</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>71</width>
+ <height>21</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Line width:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDoubleSpinBox" name="m_LineWidth">
+ <property name="maximum">
+ <double>100.000000000000000</double>
+ </property>
+ <property name="singleStep">
+ <double>1.000000000000000</double>
+ </property>
+ <property name="value">
+ <double>1.000000000000000</double>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <widget class="QLabel" name="label_3">
+ <property name="minimumSize">
+ <size>
+ <width>67</width>
+ <height>21</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>67</width>
+ <height>21</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Point size:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDoubleSpinBox" name="m_PointSize">
+ <property name="maximum">
+ <double>100.000000000000000</double>
+ </property>
+ <property name="singleStep">
+ <double>1.000000000000000</double>
+ </property>
+ <property name="value">
+ <double>1.000000000000000</double>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
#ifdef cpExtensions_QT4
#include <cpExtensions/ui_SimpleMPRWidget.h>
+#include <vtkRenderWindow.h>
-#include <vtkProperty.h>
-#include <vtkRendererCollection.h>
-
-double cpExtensions::QT::SimpleMPRWidget::
-cm_Colors[ 8 ][ 3 ] =
-{
- { 1.0, 0.0, 0.0 },
- { 0.0, 1.0, 0.0 },
- { 0.0, 0.0, 1.0 },
- { 0.0, 1.0, 1.0 },
- { 1.0, 0.0, 1.0 },
- { 1.0, 1.0, 0.0 },
- { 1.0, 0.5, 0.0 },
- { 1.0, 0.0, 0.5 }
-};
+/* TODO
+ #include <vtkProperty.h>
+ #include <vtkRendererCollection.h>
+ double cpExtensions::QT::SimpleMPRWidget::
+ cm_Colors[ 8 ][ 3 ] =
+ {
+ { 1.0, 0.0, 0.0 },
+ { 0.0, 1.0, 0.0 },
+ { 0.0, 0.0, 1.0 },
+ { 0.0, 1.0, 1.0 },
+ { 1.0, 0.0, 1.0 },
+ { 1.0, 1.0, 0.0 },
+ { 1.0, 0.5, 0.0 },
+ { 1.0, 0.0, 0.5 }
+ };
+*/
// -------------------------------------------------------------------------
cpExtensions::QT::SimpleMPRWidget::
SimpleMPRWidget( QWidget* parent )
: QWidget( parent ),
- m_UI( new Ui::SimpleMPRWidget ),
- m_MainImage( "" )
+ m_UI( new Ui::SimpleMPRWidget )
+ /*
+ ,
+ m_MainImage( "" )
+ */
{
this->m_UI->setupUi( this );
this->m_VTK[ 2 ] = this->m_UI->VTK10;
this->m_VTK[ 3 ] = this->m_UI->VTK11;
- this->m_MPRObjects = vtkSmartPointer< TMPRObjects >::New( );
- this->m_MPRObjects->SetRenderWindows(
+ for( unsigned int i = 0; i < 4; ++i )
+ {
+ this->m_Renderers[ i ] = vtkSmartPointer< vtkRenderer >::New( );
+ this->m_VTK[ i ]->GetRenderWindow( )->AddRenderer( this->m_Renderers[ i ] );
+
+ } // rof
+
+ /*
+ this->m_MPRObjects = vtkSmartPointer< TMPRObjects >::New( );
+ this->m_MPRObjects->SetRenderWindows(
this->m_VTK[ 0 ]->GetRenderWindow( ),
this->m_VTK[ 1 ]->GetRenderWindow( ),
this->m_VTK[ 2 ]->GetRenderWindow( ),
this->m_VTK[ 3 ]->GetRenderWindow( )
);
+ */
// Connect slots
QObject::connect(
delete this->m_UI;
}
-// -------------------------------------------------------------------------
-unsigned int cpExtensions::QT::SimpleMPRWidget::
-GetNumberOfData( ) const
-{
- return( this->m_Data.size( ) );
-}
-
-// -------------------------------------------------------------------------
-bool cpExtensions::QT::SimpleMPRWidget::
-AddData(
- vtkImageData* data, const std::string& name,
- const std::string& parent
- )
-{
- if( name == "" )
- return( false );
-
- auto iIt = this->m_Data.find( name );
- if( iIt == this->m_Data.end( ) )
- {
- if( parent != "" )
- {
- auto pIt = this->m_Data.find( parent );
- if( pIt == this->m_Data.end( ) )
- return( false );
-
- } // fi
-
- // Add new data
- this->m_Data[ name ].SetImageData( data );
-
- // Set color
- auto iIt = this->m_Data.find( name );
- if( iIt != this->m_Data.end( ) )
- {
- vtkActor* actor =
- dynamic_cast< vtkActor* >( iIt->second.GetMeshActor( ) );
- if( actor != NULL )
- {
- unsigned int idx = this->m_Data.size( ) % 8;
- actor->GetProperty( )->SetColor(
- Self::cm_Colors[ idx ][ 0 ],
- Self::cm_Colors[ idx ][ 1 ],
- Self::cm_Colors[ idx ][ 2 ]
- );
-
- } // fi
-
- } // fi
-
- // Add to tree view
- // TODO: this->_UpdateTreeItem( name, parent );
- return( true );
- }
- else
- return( false );
-}
-
-// -------------------------------------------------------------------------
-bool cpExtensions::QT::SimpleMPRWidget::
-AddData( vtkPolyData* data, const std::string& name )
-{
- if( name == "" )
- return( false );
-
- auto iIt = this->m_Data.find( name );
- if( iIt == this->m_Data.end( ) )
- {
- // Add new data
- this->m_Data[ name ].SetPolyData( data );
-
- // Set color
- auto iIt = this->m_Data.find( name );
- if( iIt != this->m_Data.end( ) )
- {
- vtkActor* actor =
- dynamic_cast< vtkActor* >( iIt->second.GetMeshActor( ) );
- if( actor != NULL )
- {
- unsigned int idx = this->m_Data.size( ) % 8;
- actor->GetProperty( )->SetColor(
- Self::cm_Colors[ idx ][ 0 ],
- Self::cm_Colors[ idx ][ 1 ],
- Self::cm_Colors[ idx ][ 2 ]
- );
-
- } // fi
-
- } // fi
-
- // Add to tree view
- // TODO: this->_UpdateTreeItem( name, parent );
- return( true );
- }
- else
- return( false );
-}
-
-// -------------------------------------------------------------------------
-const std::string& cpExtensions::QT::SimpleMPRWidget::
-GetMainImage( ) const
-{
- return( this->m_MainImage );
-}
-
-// -------------------------------------------------------------------------
-bool cpExtensions::QT::SimpleMPRWidget::
-SetMainImage( const std::string& name )
-{
- auto iIt = this->m_Data.find( name );
- if( iIt != this->m_Data.end( ) )
- {
- if( iIt->second.Tag == Data::IMAGE )
- {
- this->m_MainImage = name;
- return( true );
- }
- else
- return( false );
- }
- else
- return( false );
-}
-
// -------------------------------------------------------------------------
void cpExtensions::QT::SimpleMPRWidget::
-DeleteData( const std::string& name )
+SetMainImage( vtkImageData* image )
{
- auto iIt = this->m_Data.find( name );
- if( iIt != this->m_Data.end( ) )
+ for( unsigned int i = 0; i < 3; ++i )
{
- this->m_Data.erase( iIt );
-
- // Get children
- std::vector< std::string > to_erase;
- auto tIt = this->m_Tree.begin( );
- for( ; tIt != this->m_Tree.end( ); ++tIt )
- if( tIt->second == name )
- to_erase.push_back( tIt->first );
-
- // Delete from tree
- tIt = this->m_Tree.find( name );
- if( tIt != this->m_Tree.end( ) )
- this->m_Tree.erase( tIt );
-
- // Recursive erase
- auto dIt = to_erase.begin( );
- for( ; dIt != to_erase.end( ); ++dIt )
- this->DeleteData( *dIt );
-
- // Delete from tree widget
- /* TODO
- QTreeWidgetItem* item = this->_FindItemInTree( name );
- if( item != NULL )
- this->m_UI->LoadedData->removeItemWidget( item, 0 );
- */
-
- // Reset main image, just in case
- if( this->m_Data.size( ) == 0 )
- this->m_MainImage = "";
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::QT::SimpleMPRWidget::
-DeleteAllData( )
-{
- this->m_MPRObjects->Clear( );
- this->m_Data.clear( );
- this->m_Tree.clear( );
- // TODO: this->m_UI->LoadedData->clear( );
- this->m_MainImage = "";
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::QT::SimpleMPRWidget::
-SetDataColor(
- const std::string& name, const double& r, const double& g, const double& b
- )
-{
- /*
- auto iIt = this->m_Data.find( name );
- if( iIt == this->m_Data.end( ) )
- return;
-
- if( iIt->second.Tag == Data::IMAGE )
- {
- }
- else if( iIt->second.Tag == Data::MESH )
- {
- } // fi
- */
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::QT::SimpleMPRWidget::
-ShowData( const std::string& name )
-{
- auto iIt = this->m_Data.find( name );
- if( iIt == this->m_Data.end( ) )
- return;
-
- if( iIt->second.Tag == Data::IMAGE )
- {
- if( name == this->m_MainImage )
- this->m_MPRObjects->SetInputImage( iIt->second.Image );
- else
- {
- unsigned int i = ( this->m_MPRObjects->GetNumberOfImages( ) - 1 ) % 8;
- this->m_MPRObjects->AddBinaryImage(
- iIt->second.Image,
- Self::cm_Colors[ i ][ 0 ],
- Self::cm_Colors[ i ][ 1 ],
- Self::cm_Colors[ i ][ 2 ]
- );
- }
- this->m_MPRObjects->Show( );
- }
- else if( iIt->second.Tag == Data::MESH )
- {
- vtkRenderer* ren =
- this->m_VTK[ 3 ]->GetRenderWindow( )->
- GetRenderers( )->GetFirstRenderer( );
- if( ren == NULL )
- return;
- ren->AddActor( iIt->second.GetMeshActor( ) );
- this->m_VTK[ 3 ]->GetRenderWindow( )->Render( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::QT::SimpleMPRWidget::
-HideData( const std::string& name )
-{
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::QT::SimpleMPRWidget::
-SetWindowLevel( const double& w, const double& l )
-{
- this->m_MPRObjects->SetWindowLevel( w, l );
-}
-
-// -------------------------------------------------------------------------
-double cpExtensions::QT::SimpleMPRWidget::
-GetWindow( ) const
-{
- return( this->m_MPRObjects->GetWindow( ) );
-}
-
-// -------------------------------------------------------------------------
-double cpExtensions::QT::SimpleMPRWidget::
-GetLevel( ) const
-{
- return( this->m_MPRObjects->GetLevel( ) );
-}
-
-// -------------------------------------------------------------------------
-vtkRenderWindowInteractor* cpExtensions::QT::SimpleMPRWidget::
-GetInteractor( unsigned int i )
-{
- if( i < 4 )
- {
- if( this->m_VTK[ i ] != NULL )
- return( this->m_VTK[ i ]->GetInteractor( ) );
- else
- return( NULL );
- }
- else
- return( NULL );
-}
-
-// -------------------------------------------------------------------------
-/*
- bool cpExtensions::QT::SimpleMPRWidget::
- ShowImage(
- vtkImageData* image,
- const std::string& name,
- const std::string& parent
- )
- {
- // Update tree view
- QTreeWidgetItem* new_item = this->_UpdateTreeItem( name, parent );
- if( new_item == NULL )
- return( false );
-
- // Associate new data
- this->m_Images[ name ] = image;
- this->m_Tree[ name ] = parent;
-
- // Show image and return
- this->m_MPRObjects->AddImage( image );
- return( true );
- }
-
- // -------------------------------------------------------------------------
- bool cpExtensions::QT::SimpleMPRWidget::
- ShowImage(
- vtkImageData* image,
- const std::string& name,
- const std::string& parent,
- const double& r, const double& g, const double& b
- )
- {
- // Update tree view
- QTreeWidgetItem* new_item = this->_UpdateTreeItem( name, parent );
- if( new_item == NULL )
- return( false );
-
- // Associate new data
- this->m_Images[ name ] = image;
- this->m_Tree[ name ] = parent;
-
- // Show image and return
- this->m_MPRObjects->AddImage( image );
- return( true );
- }
-
- // -------------------------------------------------------------------------
- bool cpExtensions::QT::SimpleMPRWidget::
- ShowMesh(
- vtkPolyData* mesh,
- const std::string& name,
- const std::string& parent
- )
- {
- // Update tree view
- QTreeWidgetItem* new_item = this->_UpdateTreeItem( name, parent );
- if( new_item == NULL )
- return( false );
-
- // Associate new data
- PolyDataActor* actor = new PolyDataActor( mesh );
- this->m_Meshes[ name ] = actor;
- this->m_Tree[ name ] = parent;
-
- // Show mesh
- this->_Add3DActor( actor->Actor );
- return( true );
- }
-
- // -------------------------------------------------------------------------
- bool cpExtensions::QT::SimpleMPRWidget::
- ShowMesh(
- vtkPolyData* mesh,
- const std::string& name,
- const std::string& parent,
- const double& r, const double& g, const double& b
- )
- {
- return false;
- }
-
- // -------------------------------------------------------------------------
- void cpExtensions::QT::SimpleMPRWidget::
- ClearAll( )
- {
- this->m_MPRObjects->ClearAll( );
- this->m_Images.clear( );
- this->m_Meshes.clear( );
- }
-*/
-
-// -------------------------------------------------------------------------
-std::string cpExtensions::QT::SimpleMPRWidget::
-GetSelectedData( ) const
-{
- /* TODO
- QTreeWidgetItem* item = this->m_UI->LoadedData->currentItem( );
- if( item != NULL )
- return( item->text( 0 ).toStdString( ) );
- else
- */
- return( "" );
-}
-
-// -------------------------------------------------------------------------
-/* TODO
-QTreeWidgetItem* cpExtensions::QT::SimpleMPRWidget::
-_FindItemInTree( const std::string& name ) const
-{
- QList< QTreeWidgetItem* > items =
- this->m_UI->LoadedData->findItems(
- name.c_str( ), Qt::MatchExactly | Qt::MatchRecursive
+ this->m_2DSlices[ i ] = vtkSmartPointer< TActors >::New( );
+ this->m_2DSlices[ i ]->SetInputData( image, i );
+ this->m_2DSlices[ i ]->PushInto( this->m_Renderers[ i ] );
+ this->m_VTK[ i ]->GetRenderWindow( )->GetInteractor( )->
+ SetInteractorStyle( this->m_2DSlices[ i ]->GetStyle( ) );
+
+ this->m_3DSlices[ i ] = vtkSmartPointer< TActors >::New( );
+ this->m_3DSlices[ i ]->SetInputData( image, i );
+ this->m_3DSlices[ i ]->PushInto( this->m_Renderers[ 3 ] );
+ this->m_3DSlices[ i ]->SetStyle(
+ dynamic_cast< vtkInteractorStyle* >(
+ this->m_Renderers[ 3 ]->GetRenderWindow( )->
+ GetInteractor( )->GetInteractorStyle( )
+ )
);
- if( items.size( ) > 0 )
- return( items[ 0 ] );
- else
- return( NULL );
-}
-// -------------------------------------------------------------------------
-QTreeWidgetItem* cpExtensions::QT::SimpleMPRWidget::
-_UpdateTreeItem( const std::string& name, const std::string& parent )
-{
- // Update tree view
- QTreeWidgetItem* new_item = NULL;
- if( parent != "" )
+ } // rof
+
+ for( unsigned int i = 0; i < 3; ++i )
{
- QTreeWidgetItem* parent_item = this->_FindItemInTree( parent );
- if( parent_item != NULL )
+ for( unsigned int j = 0; j < 3; ++j )
{
- QTreeWidgetItem* old_item = this->_FindItemInTree( name );
- if( old_item == NULL )
- {
- new_item =
- new QTreeWidgetItem( parent_item, QStringList( name.c_str( ) ) );
- parent_item->setExpanded( true );
+ if( i != j )
+ this->m_2DSlices[ i ]->AssociateSlice( this->m_2DSlices[ j ] );
+ this->m_2DSlices[ i ]->AssociateSlice( this->m_3DSlices[ j ] );
- } // fi
+ } // rof
- } // fi
- }
- else
+ } // rof
+ for( unsigned int i = 0; i < 3; ++i )
{
- new_item = new QTreeWidgetItem(
- ( QTreeWidgetItem* )( NULL ), QStringList( name.c_str( ) )
- );
- this->m_UI->LoadedData->addTopLevelItem( new_item );
-
- } // fi
- return( new_item );
-}
-*/
+ this->m_2DSlices[ i ]->GetStyle( )->
+ SetCurrentRenderer( this->m_Renderers[ i ] );
+ this->m_Renderers[ i ]->ResetCamera( );
+ this->m_VTK[ i ]->GetRenderWindow( )->Render( );
-// -------------------------------------------------------------------------
-/*
- void cpExtensions::QT::SimpleMPRWidget::
- _Add3DActor( vtkProp3D* prop )
- {
- vtkRenderer* ren =
- this->m_VTK[ 3 ]->GetRenderWindow( )->GetRenderers( )->GetFirstRenderer( );
- if( ren == NULL )
- return;
- ren->AddActor( prop );
+ } // rof
+ this->m_Renderers[ 3 ]->ResetCamera( );
this->m_VTK[ 3 ]->GetRenderWindow( )->Render( );
- }
-*/
+}
// -------------------------------------------------------------------------
void cpExtensions::QT::SimpleMPRWidget::
this->m_UI->TopSplitter->setSizes( this->m_UI->BottomSplitter->sizes( ) );
}
-// -------------------------------------------------------------------------
-cpExtensions::QT::SimpleMPRWidget::PolyDataActor::
-PolyDataActor( )
- : Mesh( NULL ),
- Normals( NULL ),
- Stripper( NULL ),
- Mapper( NULL ),
- Actor( NULL )
-{
-}
-
-// -------------------------------------------------------------------------
-cpExtensions::QT::SimpleMPRWidget::PolyDataActor::
-~PolyDataActor( )
-{
- if( this->Actor != NULL ) this->Actor->Delete( );
- if( this->Mapper != NULL ) this->Mapper->Delete( );
- if( this->Stripper != NULL ) this->Stripper->Delete( );
- if( this->Normals != NULL ) this->Normals->Delete( );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::QT::SimpleMPRWidget::PolyDataActor::
-Configure( vtkPolyData* pd )
-{
- if( pd == NULL )
- return;
-
- double range[ 2 ];
- pd->GetScalarRange( range );
-
- this->Normals = vtkPolyDataNormals::New( );
- this->Stripper = vtkStripper::New( );
- this->Mapper = vtkPolyDataMapper::New( );
- this->Actor = vtkQuadricLODActor::New( );
-
- this->Mesh = pd;
- this->Normals->SetInputData( pd );
- this->Normals->SetFeatureAngle( 60.0 );
- this->Stripper->SetInputConnection( this->Normals->GetOutputPort( ) );
- this->Mapper->SetInputConnection( this->Stripper->GetOutputPort( ) );
- this->Mapper->UseLookupTableScalarRangeOff( );
- this->Mapper->SetScalarRange(
- range[ 0 ], ( ( range[ 1 ] - range[ 0 ] ) * 0.75 ) + range[ 0 ]
- );
- this->Actor->SetMapper( this->Mapper );
- this->Actor->GetProperty( )->SetPointSize( 10 );
- this->Actor->DeferLODConstructionOff( );
-}
-
-// -------------------------------------------------------------------------
-cpExtensions::QT::SimpleMPRWidget::Data::
-Data( )
-{
- this->Tag = Data::IMAGE;
- this->Image = NULL;
-}
-
-// -------------------------------------------------------------------------
-cpExtensions::QT::SimpleMPRWidget::Data::
-~Data( )
-{
-}
-
-// -------------------------------------------------------------------------
-cpExtensions::QT::SimpleMPRWidget::
-Data& cpExtensions::QT::SimpleMPRWidget::Data::
-operator=( const Data& data )
-{
- this->Tag = data.Tag;
- if( this->Tag == Data::IMAGE )
- this->Image = data.Image;
- else if( this->Tag == Data::MESH )
- this->Mesh = data.Mesh;
- return( *this );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::QT::SimpleMPRWidget::Data::
-SetImageData( vtkImageData* data )
-{
- this->Tag = Data::IMAGE;
- this->Image = data;
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::QT::SimpleMPRWidget::Data::
-SetPolyData( vtkPolyData* data )
-{
- this->Tag = Data::MESH;
- this->Mesh.Configure( data );
-}
-
-// -------------------------------------------------------------------------
-vtkImageData* cpExtensions::QT::SimpleMPRWidget::Data::
-GetImage( )
-{
- if( this->Tag == Data::IMAGE )
- return( this->Image );
- else
- return( NULL );
-}
-
-// -------------------------------------------------------------------------
-vtkPolyData* cpExtensions::QT::SimpleMPRWidget::Data::
-GetMesh( )
-{
- if( this->Tag == Data::MESH )
- return( this->Mesh.Mesh );
- else
- return( NULL );
-}
-
-// -------------------------------------------------------------------------
-vtkProp* cpExtensions::QT::SimpleMPRWidget::Data::
-GetMeshActor( )
-{
- if( this->Tag == Data::MESH )
- return( this->Mesh.Actor );
- else
- return( NULL );
-}
-
#endif // cpExtensions_QT4
// eof - $RCSfile$
#ifdef cpExtensions_QT4
-#include <map>
-#include <string>
-
#include <QWidget>
+#include <cpExtensions/Visualization/ImageSliceActors.h>
+#include <vtkRenderer.h>
#include <vtkSmartPointer.h>
-#include <vtkImageData.h>
-#include <vtkPolyDataMapper.h>
-#include <vtkPolyDataNormals.h>
-#include <vtkQuadricLODActor.h>
-#include <vtkStripper.h>
-#include <cpExtensions/Visualization/MPRObjects.h>
+/*
+ #include <map>
+ #include <string>
+ #include <vtkSmartPointer.h>
+ #include <vtkImageData.h>
+ #include <vtkPolyDataMapper.h>
+ #include <vtkPolyDataNormals.h>
+ #include <vtkQuadricLODActor.h>
+ #include <vtkStripper.h>
+ #include <cpExtensions/Visualization/MPRObjects.h>
+*/
// -------------------------------------------------------------------------
-class QTreeWidgetItem;
+// TODO: class QTreeWidgetItem;
class QVTKWidget;
namespace Ui
public:
typedef SimpleMPRWidget Self;
- typedef cpExtensions::Visualization::MPRObjects TMPRObjects;
- typedef TMPRObjects::TStyle TStyle;
- typedef TMPRObjects::TMouseCommand TMouseCommand;
- typedef TMPRObjects::TMouseWheelCommand TMouseWheelCommand;
- typedef TMPRObjects::TKeyCommand TKeyCommand;
- typedef TMPRObjects::TVoidCommand TVoidCommand;
- typedef TMPRObjects::TMouseMoveCommand TMouseMoveCommand;
- typedef TMPRObjects::TMouseClickCommand TMouseClickCommand;
- typedef TMPRObjects::TMouseDoubleClickCommand TMouseDoubleClickCommand;
- typedef TMPRObjects::TExposeCommand TExposeCommand;
- typedef TMPRObjects::TConfigureCommand TConfigureCommand;
- typedef TMPRObjects::TEnterCommand TEnterCommand;
- typedef TMPRObjects::TLeaveCommand TLeaveCommand;
+ typedef cpExtensions::Visualization::ImageSliceActors TActors;
+ /* TODO
+ typedef cpExtensions::Visualization::MPRObjects TMPRObjects;
+ typedef TMPRObjects::TStyle TStyle;
+ typedef TMPRObjects::TMouseCommand TMouseCommand;
+ typedef TMPRObjects::TMouseWheelCommand TMouseWheelCommand;
+ typedef TMPRObjects::TKeyCommand TKeyCommand;
+ typedef TMPRObjects::TVoidCommand TVoidCommand;
+ typedef TMPRObjects::TMouseMoveCommand TMouseMoveCommand;
+ typedef TMPRObjects::TMouseClickCommand TMouseClickCommand;
+ typedef TMPRObjects::TMouseDoubleClickCommand TMouseDoubleClickCommand;
+ typedef TMPRObjects::TExposeCommand TExposeCommand;
+ typedef TMPRObjects::TConfigureCommand TConfigureCommand;
+ typedef TMPRObjects::TEnterCommand TEnterCommand;
+ typedef TMPRObjects::TLeaveCommand TLeaveCommand;
+ */
public:
explicit SimpleMPRWidget( QWidget* parent = 0 );
virtual ~SimpleMPRWidget( );
// Data management
- unsigned int GetNumberOfData( ) const;
- bool AddData(
- vtkImageData* data, const std::string& name,
- const std::string& parent
- );
- bool AddData(
- vtkPolyData* data, const std::string& name
- );
- const std::string& GetMainImage( ) const;
- bool SetMainImage( const std::string& name );
- void DeleteData( const std::string& name );
- void DeleteAllData( );
-
- // Some qt accessors
- void SetDataColor(
- const std::string& name,
- const double& r, const double& g, const double& b
- );
- void ShowData( const std::string& name );
- void HideData( const std::string& name );
- void SetWindowLevel( const double& w, const double& l );
- double GetWindow( ) const;
- double GetLevel( ) const;
-
- vtkRenderWindowInteractor* GetInteractor( unsigned int i );
-
- // Visual objects accessors
- std::string GetSelectedData( ) const;
-
+ void SetMainImage( vtkImageData* image );
+
+ /* TODO
+ unsigned int GetNumberOfData( ) const;
+ bool AddData(
+ vtkImageData* data, const std::string& name,
+ const std::string& parent
+ );
+ bool AddData(
+ vtkPolyData* data, const std::string& name
+ );
+ const std::string& GetMainImage( ) const;
+ bool SetMainImage( const std::string& name );
+ void DeleteData( const std::string& name );
+ void DeleteAllData( );
+
+ // Some qt accessors
+ void SetDataColor(
+ const std::string& name,
+ const double& r, const double& g, const double& b
+ );
+ void ShowData( const std::string& name );
+ void HideData( const std::string& name );
+ void SetWindowLevel( const double& w, const double& l );
+ double GetWindow( ) const;
+ double GetLevel( ) const;
+
+ vtkRenderWindowInteractor* GetInteractor( unsigned int i );
+
+ // Visual objects accessors
+ std::string GetSelectedData( ) const;
+ vtkProp* GetProp( const std::string& name );
+ */
+
private slots:
void _SyncBottom( int a, int b );
void _SyncTop( int a, int b );
protected:
- static double cm_Colors[ 8 ][ 3 ];
-
- Ui::SimpleMPRWidget* m_UI;
- vtkSmartPointer< TMPRObjects > m_MPRObjects;
- QVTKWidget* m_VTK[ 4 ];
-
- struct PolyDataActor
- {
- vtkPolyData* Mesh;
- vtkPolyDataNormals* Normals;
- vtkStripper* Stripper;
- vtkPolyDataMapper* Mapper;
- vtkQuadricLODActor* Actor;
-
- PolyDataActor( );
- virtual ~PolyDataActor( );
- void Configure( vtkPolyData* pd );
- };
-
- struct Data
- {
- enum { IMAGE, MESH } Tag;
- vtkImageData* Image;
- PolyDataActor Mesh;
-
- Data( );
- virtual ~Data( );
-
- Data& operator=( const Data& data );
-
- void SetImageData( vtkImageData* data );
- void SetPolyData( vtkPolyData* data );
-
- vtkImageData* GetImage( );
- vtkPolyData* GetMesh( );
- vtkProp* GetMeshActor( );
- };
-
- std::string m_MainImage;
- std::map< std::string, Data > m_Data;
- std::map< std::string, std::string > m_Tree;
+ Ui::SimpleMPRWidget* m_UI;
+ QVTKWidget* m_VTK[ 4 ];
+
+ vtkSmartPointer< vtkRenderer > m_Renderers[ 4 ];
+ vtkSmartPointer< TActors > m_2DSlices[ 3 ];
+ vtkSmartPointer< TActors > m_3DSlices[ 3 ];
+
+ /* TODO
+ static double cm_Colors[ 8 ][ 3 ];
+ vtkSmartPointer< TMPRObjects > m_MPRObjects;
+ struct PolyDataActor
+ {
+ vtkPolyData* Mesh;
+ vtkPolyDataNormals* Normals;
+ vtkStripper* Stripper;
+ vtkPolyDataMapper* Mapper;
+ vtkQuadricLODActor* Actor;
+
+ PolyDataActor( );
+ virtual ~PolyDataActor( );
+ void Configure( vtkPolyData* pd );
+ };
+
+ struct Data
+ {
+ enum { IMAGE, MESH } Tag;
+ vtkImageData* Image;
+ PolyDataActor Mesh;
+ Data( );
+ virtual ~Data( );
+ Data& operator=( const Data& data );
+ void SetImageData( vtkImageData* data );
+ void SetPolyData( vtkPolyData* data );
+ vtkImageData* GetImage( );
+ vtkPolyData* GetMesh( );
+ vtkProp* GetMeshActor( );
+ };
+ std::string m_MainImage;
+ std::map< std::string, Data > m_Data;
+ std::map< std::string, std::string > m_Tree;
+ */
};
} // ecapseman
</customwidgets>
<resources/>
<connections/>
-</ui>
\ No newline at end of file
+</ui>
#include <cpExtensions/Visualization/ImageSliceActors.h>
-#include <cstring>
#include <sstream>
-
-#include <vtkAlgorithmOutput.h>
#include <vtkCamera.h>
-#include <vtkCellArray.h>
#include <vtkImageData.h>
#include <vtkImageProperty.h>
-#include <vtkPoints.h>
#include <vtkProperty.h>
#include <vtkRenderer.h>
-#include <vtkRendererCollection.h>
#include <vtkRenderWindow.h>
-#include <vtkRenderWindowInteractor.h>
#include <vtkTextProperty.h>
// -------------------------------------------------------------------------
-double cpExtensions::Visualization::ImageSliceActors::
-m_PlaneColors[ 3 ][ 3 ] =
-{
- { 1, 0, 0 },
- { 0, 1, 0 },
- { 0, 0, 1 }
-};
-
-// -------------------------------------------------------------------------
-cpExtensions::Visualization::ImageSliceActors*
cpExtensions::Visualization::ImageSliceActors::
+Self* cpExtensions::Visualization::ImageSliceActors::
New( )
{
return( new Self( ) );
}
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-SetAxis( int axis )
-{
- this->m_ImageMapper->SetOrientation( axis );
- this->m_BlenderMapper->SetOrientation( axis );
- this->m_ImageMapper->Update( );
- this->m_BlenderMapper->Update( );
- this->SetSliceNumber( this->GetSliceNumberMinValue( ) );
- this->m_ImageActor->Modified( );
- this->m_BlenderActor->Modified( );
- this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-SetInputConnection( vtkAlgorithmOutput* aout )
-{
- // Get input vtkImageData
- if( aout == NULL )
- return;
-
- // Create mapper and actors
- this->m_ImageMapper->SetInputConnection( aout );
- this->_ConfigureInputImage( );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-SetInputImage( vtkImageData* data )
-{
- // Get input vtkImageData
- if( data == NULL )
- return;
-
- // Create mapper and actors
- this->m_ImageMapper->SetInputData( data );
- this->_ConfigureInputImage( );
-}
-
-// -------------------------------------------------------------------------
-int cpExtensions::Visualization::ImageSliceActors::
-AddBinaryConnection(
- vtkAlgorithmOutput* aout,
- const double& r, const double& g, const double& b
- )
-{
- if( aout == NULL )
- return( -1 );
- this->m_Blender->AddInputConnection( aout );
- this->_ConfigureBinaryImage( r, g, b );
- return( this->m_Blender->GetNumberOfInputs( ) - 1 );
-}
-
-// -------------------------------------------------------------------------
-int cpExtensions::Visualization::ImageSliceActors::
-AddBinaryImage(
- vtkImageData* data,
- const double& r, const double& g, const double& b
- )
-{
- if( data == NULL )
- return( -1 );
- this->m_Blender->AddInputData( data );
- this->_ConfigureBinaryImage( r, g, b );
- return( this->m_Blender->GetNumberOfInputs( ) - 1 );
-}
-
// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageSliceActors::
Clear( )
{
- // Unbind from container
this->RemoveAllItems( );
- // Filters and mappers
- this->m_ImageMapper = vtkSmartPointer< vtkImageSliceMapper >::New( );
- this->m_ImageActor = vtkSmartPointer< vtkImageActor >::New( );
- this->m_Blender = vtkSmartPointer< TBlender >::New( );
- this->m_BlenderMapper = vtkSmartPointer< vtkImageSliceMapper >::New( );
- this->m_BlenderLUT = vtkSmartPointer< vtkLookupTable >::New( );
- this->m_BlenderActor = vtkSmartPointer< vtkImageActor >::New( );
-
- this->m_ImageActor->SetMapper( this->m_ImageMapper );
- this->m_BlenderMapper->
- SetInputConnection( this->m_Blender->GetOutputPort( ) );
-
- this->m_BlenderLUT->SetNumberOfTableValues( 1 );
- this->m_BlenderLUT->SetTableRange( 0, 1 );
- this->m_BlenderLUT->SetTableValue( 0, 0, 0, 0, 0 );
- this->m_BlenderLUT->Build( );
-
- this->m_BlenderActor->SetMapper( this->m_BlenderMapper );
- this->m_BlenderActor->GetProperty( )->SetLookupTable( this->m_BlenderLUT );
- this->m_BlenderActor->GetProperty( )->UseLookupTableScalarRangeOn( );
-
- // White cursor
- vtkSmartPointer< vtkPoints > cursor_points =
- vtkSmartPointer< vtkPoints >::New( );
- vtkSmartPointer< vtkCellArray > cursor_lines =
- vtkSmartPointer< vtkCellArray >::New( );
- cursor_points->InsertNextPoint( 0, 0, 0 );
- cursor_points->InsertNextPoint( 0, 0, 0 );
- cursor_points->InsertNextPoint( 0, 0, 0 );
- cursor_points->InsertNextPoint( 0, 0, 0 );
- cursor_lines->InsertNextCell( 2 );
- cursor_lines->InsertCellPoint( 0 );
- cursor_lines->InsertCellPoint( 1 );
- cursor_lines->InsertNextCell( 2 );
- cursor_lines->InsertCellPoint( 2 );
- cursor_lines->InsertCellPoint( 3 );
-
- this->m_Cursor = vtkSmartPointer< vtkPolyData >::New( );
- this->m_CursorMapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
- this->m_CursorActor = vtkSmartPointer< vtkActor >::New( );
-
- this->m_Cursor->SetPoints( cursor_points );
- this->m_Cursor->SetLines( cursor_lines );
- this->m_CursorMapper->SetInputData( this->m_Cursor );
- this->m_CursorActor->SetMapper( this->m_CursorMapper );
- this->m_CursorActor->GetProperty( )->SetColor( 1, 1, 0 );
- this->m_CursorActor->GetProperty( )->SetLineWidth( 2 );
-
- // Plane intersections
- this->m_Axis1 = vtkSmartPointer< vtkPolyData >::New( );
- this->m_Axis1Mapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
- this->m_Axis1Actor = vtkSmartPointer< vtkActor >::New( );
-
- vtkSmartPointer< vtkPoints > h_points =
- vtkSmartPointer< vtkPoints >::New( );
- vtkSmartPointer< vtkCellArray > h_lines =
- vtkSmartPointer< vtkCellArray >::New( );
- h_points->InsertNextPoint( 0, 0, 0 );
- h_points->InsertNextPoint( 0, 0, 0 );
- h_lines->InsertNextCell( 2 );
- h_lines->InsertCellPoint( 0 );
- h_lines->InsertCellPoint( 1 );
- this->m_Axis1->SetPoints( h_points );
- this->m_Axis1->SetLines( h_lines );
- this->m_Axis1Mapper->SetInputData( this->m_Axis1 );
- this->m_Axis1Actor->SetMapper( this->m_Axis1Mapper );
-
- this->m_Axis2 = vtkSmartPointer< vtkPolyData >::New( );
- this->m_Axis2Mapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
- this->m_Axis2Actor = vtkSmartPointer< vtkActor >::New( );
-
- vtkSmartPointer< vtkPoints > v_points =
- vtkSmartPointer< vtkPoints >::New( );
- vtkSmartPointer< vtkCellArray > v_lines =
- vtkSmartPointer< vtkCellArray >::New( );
- v_points->InsertNextPoint( 0, 0, 0 );
- v_points->InsertNextPoint( 0, 0, 0 );
- v_lines->InsertNextCell( 2 );
- v_lines->InsertCellPoint( 0 );
- v_lines->InsertCellPoint( 1 );
- this->m_Axis2->SetPoints( v_points );
- this->m_Axis2->SetLines( v_lines );
- this->m_Axis2Mapper->SetInputData( this->m_Axis2 );
- this->m_Axis2Actor->SetMapper( this->m_Axis2Mapper );
-
- // Plane
- this->m_Plane = vtkSmartPointer< vtkPolyData >::New( );
- this->m_PlaneMapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
- this->m_PlaneActor = vtkSmartPointer< vtkActor >::New( );
-
- 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->m_Plane->SetPoints( plane_points );
- this->m_Plane->SetLines( plane_lines );
-
- this->m_PlaneMapper->SetInputData( this->m_Plane );
- this->m_PlaneActor->SetMapper( this->m_PlaneMapper );
-
- // Text actor
- this->m_TextActor = vtkSmartPointer< vtkTextActor >::New( );
+ // Main image
+ this->m_Mapper = vtkSmartPointer< vtkImageSliceMapper >::New( );
+ this->m_Actor = vtkSmartPointer< vtkImageActor >::New( );
+ this->m_Actor->SetMapper( this->m_Mapper );
+
+ // Cursor
+ this->m_Cursor.Create( );
+ this->m_Cursor.Actor->GetProperty( )->SetColor( 1, 1, 0 );
+
+ // Text
this->m_TextBuffer[ 0 ] = '\0';
+ this->m_TextActor = vtkSmartPointer< vtkTextActor >::New( );
this->m_TextActor->SetTextScaleModeToNone( );
vtkTextProperty* textprop = this->m_TextActor->GetTextProperty( );
textprop->SetColor( 1, 1, 0 );
textprop->SetVerticalJustificationToBottom( );
vtkCoordinate* coord = this->m_TextActor->GetPositionCoordinate( );
coord->SetCoordinateSystemToNormalizedViewport( );
- coord->SetValue( 0.01, 0.01 );
-}
+ coord->SetValue( 0.01, 0.05 );
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-AssociateSlice( Self* slice )
-{
- this->m_AssociatedSlices.push_back( slice );
- this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-vtkInteractorStyle* cpExtensions::Visualization::ImageSliceActors::
-GetStyle( )
-{
- return( this->m_Style.GetPointer( ) );
-}
-
-// -------------------------------------------------------------------------
-const vtkInteractorStyle* cpExtensions::Visualization::ImageSliceActors::
-GetStyle( ) const
-{
- return( this->m_Style.GetPointer( ) );
-}
-
-// -------------------------------------------------------------------------
-vtkImageData* cpExtensions::Visualization::ImageSliceActors::
-GetInputImage( )
-{
- if( this->m_ImageMapper.GetPointer( ) != NULL )
- return( this->m_ImageMapper->GetInput( ) );
- else
- return( NULL );
-}
-
-// -------------------------------------------------------------------------
-const vtkImageData* cpExtensions::Visualization::ImageSliceActors::
-GetInputImage( ) const
-{
- if( this->m_ImageMapper.GetPointer( ) != NULL )
- return( this->m_ImageMapper->GetInput( ) );
- else
- return( NULL );
+ // Configure style
+ vtkSmartPointer< TStyle > st = vtkSmartPointer< TStyle >::New( );
+ st->SetAssociatedObject( this );
+ st->AddMouseMoveCommand( Self::_MouseMoveCommand, this );
+ st->AddMouseClickCommand( Self::_MouseClickCommand, this );
+ st->AddMouseWheelCommand( Self::_MouseWheelCommand, this );
+ st->AddKeyCommand( Self::_KeyCommand, this );
+ st->AddEnterCommand( Self::_EnterCommand, this );
+ st->AddLeaveCommand( Self::_LeaveCommand, this );
+ this->m_Style = st;
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageSliceActors::
-PushActorsInto( vtkRenderWindow* window, bool force_style )
+SetInputConnection( vtkAlgorithmOutput* aout, int orientation )
{
- this->m_Window = window;
- if( window == NULL )
- return;
- vtkRenderWindowInteractor* rwi = window->GetInteractor( );
- vtkRenderer* renderer = window->GetRenderers( )->GetFirstRenderer( );
- if( rwi == NULL || renderer == NULL )
+ if( aout == NULL )
return;
-
- // Update style
- if( this->m_Style.GetPointer( ) != NULL && force_style )
- rwi->SetInteractorStyle( this->m_Style );
-
- // Update actors
- renderer->AddViewProp( this->m_ImageActor );
- renderer->AddViewProp( this->m_BlenderActor );
- if( force_style )
- {
- renderer->AddViewProp( this->m_CursorActor );
- renderer->AddViewProp( this->m_PlaneActor );
- renderer->AddViewProp( this->m_TextActor );
- renderer->AddViewProp( this->m_Axis1Actor );
- renderer->AddViewProp( this->m_Axis2Actor );
-
- } // fi
-
- // Configure camera
- vtkCamera* camera = renderer->GetActiveCamera( );
- if( camera != NULL && force_style )
- {
- // Parallel projections are better when displaying 2D images
- int axis = this->GetAxis( );
- camera->ParallelProjectionOn( );
- camera->SetFocalPoint( double( 0 ), double( 0 ), double( 0 ) );
- if( axis == 0 )
- {
- camera->SetPosition( double( 1 ), double( 0 ), double( 0 ) );
- camera->SetViewUp ( double( 0 ), double( 0 ), double( 1 ) );
- }
- else if( axis == 1 )
- {
- camera->SetPosition( double( 0 ), double( -1 ), double( 0 ) );
- camera->SetViewUp ( double( 0 ), double( 0 ), double( 1 ) );
- }
- else // if( axis == 2 )
- {
- camera->SetPosition( double( 0 ), double( 0 ), double( -1 ) );
- camera->SetViewUp ( double( 0 ), double( -1 ), double( 0 ) );
-
- } // fi
-
- } // fi
- renderer->ResetCamera( );
+ this->m_Mapper->SetInputConnection( aout );
+ this->_ConfigureInput( orientation );
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageSliceActors::
-PopActorsFrom( vtkRenderWindow* window )
-{
- vtkRenderWindowInteractor* rwi = window->GetInteractor( );
- vtkRenderer* renderer = window->GetRenderers( )->GetFirstRenderer( );
- if( renderer != NULL )
- {
- renderer->RemoveViewProp( this->m_ImageActor );
- renderer->RemoveViewProp( this->m_BlenderActor );
- renderer->RemoveViewProp( this->m_CursorActor );
- renderer->RemoveViewProp( this->m_PlaneActor );
- renderer->RemoveViewProp( this->m_TextActor );
- renderer->RemoveViewProp( this->m_Axis1Actor );
- renderer->RemoveViewProp( this->m_Axis2Actor );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-unsigned int cpExtensions::Visualization::ImageSliceActors::
-GetNumberOfImages( ) const
+SetInputData( vtkImageData* data, int orientation )
{
- return( this->m_Blender->GetNumberOfInputs( ) );
-}
-
-// -------------------------------------------------------------------------
-vtkImageActor* cpExtensions::Visualization::ImageSliceActors::
-GetImageActor( )
-{
- return( this->m_ImageActor );
-}
-
-// -------------------------------------------------------------------------
-const vtkImageActor* cpExtensions::Visualization::ImageSliceActors::
-GetImageActor( ) const
-{
- return( this->m_ImageActor );
-}
-
-// -------------------------------------------------------------------------
-vtkImageActor* cpExtensions::Visualization::ImageSliceActors::
-GetBinaryActor( )
-{
- return( this->m_BlenderActor );
-}
-
-// -------------------------------------------------------------------------
-const vtkImageActor* cpExtensions::Visualization::ImageSliceActors::
-GetBinaryActor( ) const
-{
- return( this->m_BlenderActor );
-}
-
-// -------------------------------------------------------------------------
-vtkTextActor* cpExtensions::Visualization::ImageSliceActors::
-GetTextActor( )
-{
- return( this->m_TextActor );
-}
-
-// -------------------------------------------------------------------------
-const vtkTextActor* cpExtensions::Visualization::ImageSliceActors::
-GetTextActor( ) const
-{
- return( this->m_TextActor );
-}
-
-// -------------------------------------------------------------------------
-vtkActor* cpExtensions::Visualization::ImageSliceActors::
-GetPlaneActor( )
-{
- return( this->m_PlaneActor );
-}
-
-// -------------------------------------------------------------------------
-const vtkActor* cpExtensions::Visualization::ImageSliceActors::
-GetPlaneActor( ) const
-{
- return( this->m_PlaneActor );
-}
-
-// -------------------------------------------------------------------------
-vtkPlane* cpExtensions::Visualization::ImageSliceActors::
-GetPlaneFunction( )
-{
- if( this->m_ImageMapper.GetPointer( ) != NULL )
- return( this->m_ImageMapper->GetSlicePlane( ) );
- else
- return( NULL );
-}
-
-// -------------------------------------------------------------------------
-const vtkPlane* cpExtensions::Visualization::ImageSliceActors::
-GetPlaneFunction( ) const
-{
- if( this->m_ImageMapper.GetPointer( ) != NULL )
- return( this->m_ImageMapper->GetSlicePlane( ) );
- else
- return( NULL );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-SetInterpolate( bool v )
-{
- if( this->m_Interpolate != v )
- {
- this->m_ImageActor->SetInterpolate( v );
- this->m_BlenderActor->SetInterpolate( v );
- this->m_Interpolate = v;
- this->Modified( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-InterpolateOn( )
-{
- this->SetInterpolate( true );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-InterpolateOff( )
-{
- this->SetInterpolate( false );
-}
-
-// -------------------------------------------------------------------------
-double* cpExtensions::Visualization::ImageSliceActors::
-GetDisplayBounds( ) const
-{
- if( this->m_ImageActor.GetPointer( ) != NULL )
- return( this->m_ImageActor->GetDisplayBounds( ) );
- else
- return( NULL );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-GetDisplayBounds( double bounds[ 6 ] ) const
-{
- if( this->m_ImageActor.GetPointer( ) == NULL )
- {
- bounds[ 0 ] = bounds[ 2 ] = bounds[ 4 ] = double( 0 );
- bounds[ 1 ] = bounds[ 3 ] = bounds[ 5 ] = double( -1 );
- }
- else
- this->m_ImageActor->GetDisplayBounds( bounds );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-ResetCursor( )
-{
- if( this->m_ImageMapper.GetPointer( ) != NULL )
- {
- double pos[] =
- {
- this->m_VisibleBounds[ 0 ],
- this->m_VisibleBounds[ 2 ],
- this->m_VisibleBounds[ 4 ]
- };
- this->SetCursor( pos );
- }
- else
- {
- vtkPoints* points = this->m_Cursor->GetPoints( );
- points->SetPoint( 0, 0, 0, 0 );
- points->SetPoint( 1, 0, 0, 0 );
- points->SetPoint( 2, 0, 0, 0 );
- points->SetPoint( 3, 0, 0, 0 );
- this->m_Cursor->Modified( );
- this->m_CursorMapper->Modified( );
- this->m_CursorActor->Modified( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-SetCursor( double pos[ 3 ] )
-{
- if( this->m_ImageMapper.GetPointer( ) == NULL )
+ if( data == NULL )
return;
-
- // Get ordered axes
- int a0 = this->GetAxis( );
- int a1 = ( a0 + 1 ) % 3;
- int a2 = ( a0 + 2 ) % 3;
- int ma0 = a0 << 1;
- int ma1 = a1 << 1;
- int ma2 = a2 << 1;
-
- // Update cross
- double* bounds = this->m_VisibleBounds;
- double p0[ 3 ], p1[ 3 ], p2[ 3 ], p3[ 3 ];
-
- p0[ a2 ] = p1[ a2 ] = pos[ a2 ];
- p2[ a1 ] = p3[ a1 ] = pos[ a1 ];
- p0[ a0 ] = p1[ a0 ] = p2[ a0 ] = p3[ a0 ] = bounds[ ma0 ];
- p0[ a1 ] = bounds[ ma1 ];
- p1[ a1 ] = bounds[ ma1 + 1 ];
- p2[ a2 ] = bounds[ ma2 ];
- p3[ a2 ] = bounds[ ma2 + 1 ];
-
- vtkPoints* points = this->m_Cursor->GetPoints( );
- points->SetPoint( 0, p0 );
- points->SetPoint( 1, p1 );
- points->SetPoint( 2, p2 );
- points->SetPoint( 3, p3 );
- this->m_Cursor->Modified( );
- this->m_CursorMapper->Modified( );
- this->m_CursorActor->Modified( );
+ this->m_Mapper->SetInputData( data );
+ this->_ConfigureInput( orientation );
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageSliceActors::
-ResetAxesCursor( )
+AssociateSlice( Self* slice )
{
- if( this->m_ImageMapper.GetPointer( ) != NULL )
- {
- double pos[] =
- {
- this->m_VisibleBounds[ 0 ],
- this->m_VisibleBounds[ 2 ],
- this->m_VisibleBounds[ 4 ]
- };
- this->SetAxesCursor( pos );
- }
- else
- {
- vtkPoints* points = this->m_Axis1->GetPoints( );
- points->SetPoint( 0, 0, 0, 0 );
- points->SetPoint( 1, 0, 0, 0 );
- this->m_Axis1->Modified( );
- this->m_Axis1Mapper->Modified( );
- this->m_Axis1Actor->Modified( );
-
- points = this->m_Axis2->GetPoints( );
- points->SetPoint( 0, 0, 0, 0 );
- points->SetPoint( 1, 0, 0, 0 );
- this->m_Axis2->Modified( );
- this->m_Axis2Mapper->Modified( );
- this->m_Axis2Actor->Modified( );
-
- } // fi
+ this->m_AssociatedSlices.push_back( slice );
+ this->Modified( );
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageSliceActors::
-SetAxesCursor( double pos[ 3 ] )
-{
- if( this->m_ImageMapper.GetPointer( ) == NULL )
- return;
-
- // Get ordered axes
- int a0 = this->GetAxis( );
- int a1 = ( a0 + 1 ) % 3;
- int a2 = ( a0 + 2 ) % 3;
- int ma0 = a0 << 1;
- int ma1 = a1 << 1;
- int ma2 = a2 << 1;
-
- // Update cross
- double* bounds = this->m_VisibleBounds;
- double p0[ 3 ], p1[ 3 ], p2[ 3 ], p3[ 3 ];
-
- p0[ a2 ] = p1[ a2 ] = pos[ a2 ];
- p2[ a1 ] = p3[ a1 ] = pos[ a1 ];
- p0[ a0 ] = p1[ a0 ] = p2[ a0 ] = p3[ a0 ] = bounds[ ma0 ];
- p0[ a1 ] = bounds[ ma1 ];
- p1[ a1 ] = bounds[ ma1 + 1 ];
- p2[ a2 ] = bounds[ ma2 ];
- p3[ a2 ] = bounds[ ma2 + 1 ];
-
- vtkPoints* points1 = this->m_Axis1->GetPoints( );
- points1->SetPoint( 0, p2 );
- points1->SetPoint( 1, p3 );
-
- vtkPoints* points2 = this->m_Axis2->GetPoints( );
- points2->SetPoint( 0, p0 );
- points2->SetPoint( 1, p1 );
-
- this->m_Axis1->Modified( );
- this->m_Axis1Mapper->Modified( );
- this->m_Axis1Actor->Modified( );
-
- this->m_Axis2->Modified( );
- this->m_Axis2Mapper->Modified( );
- this->m_Axis2Actor->Modified( );
-}
-
-// -------------------------------------------------------------------------
-double cpExtensions::Visualization::ImageSliceActors::
-GetMinWindow( ) const
-{
- return( this->m_WLRange[ 0 ] );
-}
-
-// -------------------------------------------------------------------------
-double cpExtensions::Visualization::ImageSliceActors::
-GetMaxWindow( ) const
+CleanAssociatedSlices( )
{
- return( this->m_WLRange[ 1 ] );
-}
-
-// -------------------------------------------------------------------------
-double cpExtensions::Visualization::ImageSliceActors::
-GetMinLevel( ) const
-{
- return( this->m_WLRange[ 2 ] );
-}
-
-// -------------------------------------------------------------------------
-double cpExtensions::Visualization::ImageSliceActors::
-GetMaxLevel( ) const
-{
- return( this->m_WLRange[ 3 ] );
-}
-
-// -------------------------------------------------------------------------
-double cpExtensions::Visualization::ImageSliceActors::
-GetWindow( ) const
-{
- if( this->m_ImageActor.GetPointer( ) != NULL )
- return( this->m_ImageActor->GetProperty( )->GetColorWindow( ) );
- else
- return( double( 0 ) );
-}
-
-// -------------------------------------------------------------------------
-double cpExtensions::Visualization::ImageSliceActors::
-GetLevel( ) const
-{
- if( this->m_ImageActor.GetPointer( ) != NULL )
- return( this->m_ImageActor->GetProperty( )->GetColorLevel( ) );
- else
- return( double( 0 ) );
+ this->m_AssociatedSlices.clear( );
+ this->Modified( );
}
// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-SetWindow( double w )
+cpExtensions::Interaction::ImageInteractorStyle*
+cpExtensions::Visualization::ImageSliceActors::
+GetStyle( )
{
- if( this->m_ImageActor.GetPointer( ) == NULL )
- return;
- double v = ( w < this->m_WLRange[ 0 ] )? this->m_WLRange[ 0 ]: w;
- v = ( v > this->m_WLRange[ 1 ] )? this->m_WLRange[ 1 ]: v;
- this->m_ImageActor->GetProperty( )->SetColorWindow( v );
+ return( dynamic_cast< TStyle* >( this->m_Style.GetPointer( ) ) );
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageSliceActors::
-SetLevel( double l )
+SetStyle( vtkInteractorStyle* st )
{
- if( this->m_ImageActor.GetPointer( ) == NULL )
- return;
- double v = ( l < this->m_WLRange[ 2 ] )? this->m_WLRange[ 2 ]: l;
- v = ( v > this->m_WLRange[ 3 ] )? this->m_WLRange[ 3 ]: v;
- this->m_ImageActor->GetProperty( )->SetColorLevel( v );
+ this->m_Style = st;
+ this->Modified( );
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageSliceActors::
-SetWindowLevel( double w, double l )
+PushInto( vtkRenderer* ren )
{
- if( this->m_ImageActor.GetPointer( ) == NULL )
- return;
- double a = ( w < this->m_WLRange[ 0 ] )? this->m_WLRange[ 0 ]: w;
- a = ( a > this->m_WLRange[ 1 ] )? this->m_WLRange[ 1 ]: a;
- double b = ( l < this->m_WLRange[ 2 ] )? this->m_WLRange[ 2 ]: l;
- b = ( b > this->m_WLRange[ 3 ] )? this->m_WLRange[ 3 ]: b;
- this->m_ImageActor->GetProperty( )->SetColorWindow( a );
- this->m_ImageActor->GetProperty( )->SetColorLevel( b );
- this->UpdateText( a, b );
+ this->InitTraversal( );
+ vtkProp* prop;
+ while( ( prop = this->GetNextProp( ) ) != NULL )
+ ren->AddViewProp( prop );
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageSliceActors::
-ResetWindowLevel( )
+PopFrom( vtkRenderer* ren )
{
- this->SetWindowLevel(
- this->m_WLRange[ 1 ] * double( 0.5 ),
- ( this->m_WLRange[ 3 ] + this->m_WLRange[ 2 ] ) * double( 0.5 )
- );
-}
-
-// -------------------------------------------------------------------------
-int cpExtensions::Visualization::ImageSliceActors::
-GetAxis( ) const
-{
- if( this->m_ImageMapper.GetPointer( ) != NULL )
- return( this->m_ImageMapper->GetOrientation( ) );
- else
- return( -1 );
+ this->InitTraversal( );
+ vtkProp* prop;
+ while( ( prop = this->GetNextProp( ) ) != NULL )
+ ren->RemoveViewProp( prop );
}
// -------------------------------------------------------------------------
-int cpExtensions::Visualization::ImageSliceActors::
+long cpExtensions::Visualization::ImageSliceActors::
GetSliceNumber( ) const
{
- if( this->m_ImageMapper.GetPointer( ) != NULL )
- return( this->m_ImageMapper->GetSliceNumber( ) );
- else
- return( -1 );
-}
-
-// -------------------------------------------------------------------------
-int cpExtensions::Visualization::ImageSliceActors::
-GetSliceNumberMinValue( ) const
-{
- if( this->m_ImageMapper.GetPointer( ) != NULL )
- return( this->m_ImageMapper->GetSliceNumberMinValue( ) );
- else
- return( -1 );
-}
-
-// -------------------------------------------------------------------------
-int cpExtensions::Visualization::ImageSliceActors::
-GetSliceNumberMaxValue( ) const
-{
- if( this->m_ImageMapper.GetPointer( ) != NULL )
- return( this->m_ImageMapper->GetSliceNumberMaxValue( ) );
+ if( this->m_Mapper.GetPointer( ) != NULL )
+ return( this->m_Mapper->GetSliceNumber( ) );
else
return( -1 );
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageSliceActors::
-SetSliceNumber( const int& slice )
+SetSliceNumber( long slice )
{
- if( this->m_ImageMapper.GetPointer( ) == NULL )
+ if( this->m_Mapper.GetPointer( ) == NULL )
return;
- int axis = this->GetAxis( );
- double prev_pos = this->m_VisibleBounds[ axis << 1 ];
+ // Get orientation
+ int a = this->m_Mapper->GetOrientation( );
- // Update mappers and display bounds
- this->m_ImageMapper->SetSliceNumber( slice );
- this->m_BlenderMapper->SetSliceNumber( slice );
- this->m_ImageMapper->Modified( );
- this->m_BlenderMapper->Modified( );
- this->m_ImageActor->Modified( );
- this->m_BlenderActor->Modified( );
+ // Check extent
+ int ext[ 6 ];
+ this->m_Mapper->GetInput( )->GetExtent( ext );
+ long rs = slice;
+ rs = ( rs > ext[ a << 1 ] )? rs: ext[ a << 1 ];
+ rs = ( rs < ext[ ( a << 1 ) + 1 ] )? rs: ext[ ( a << 1 ) + 1 ];
- // Update display extent (this isn't done automatically)
- this->m_ImageMapper->GetInput( )->GetExtent( this->m_VisibleExtent );
- this->m_VisibleExtent[ axis << 1 ] = slice;
- this->m_VisibleExtent[ ( axis << 1 ) + 1 ] = slice;
- this->m_ImageActor->SetDisplayExtent( this->m_VisibleExtent );
-
- // Prepare plane data
- this->m_ImageMapper->GetBounds( this->m_VisibleBounds );
- double x0[][ 3 ] =
- {
- {
- this->m_VisibleBounds[ 0 ],
- this->m_VisibleBounds[ 2 ],
- this->m_VisibleBounds[ 4 ]
- },
- {
- this->m_VisibleBounds[ 1 ],
- this->m_VisibleBounds[ 3 ],
- this->m_VisibleBounds[ 5 ]
- }
- };
- double p0[ 2 ][ 3 ];
-
- vtkPlane* plane = this->m_ImageMapper->GetSlicePlane( );
- plane->GeneralizedProjectPoint( x0[ 0 ], p0[ 0 ] );
- plane->GeneralizedProjectPoint( x0[ 1 ], p0[ 1 ] );
-
- this->m_VisibleBounds[ 0 ] = p0[ 0 ][ 0 ];
- this->m_VisibleBounds[ 1 ] = p0[ 1 ][ 0 ];
- this->m_VisibleBounds[ 2 ] = p0[ 0 ][ 1 ];
- this->m_VisibleBounds[ 3 ] = p0[ 1 ][ 1 ];
- this->m_VisibleBounds[ 4 ] = p0[ 0 ][ 2 ];
- this->m_VisibleBounds[ 5 ] = p0[ 1 ][ 2 ];
- double* bnds = this->m_VisibleBounds;
-
- // Configure visualization and implicit plane orientation
- this->m_PlaneActor->GetProperty( )->SetRepresentationToWireframe( );
- this->m_PlaneActor->GetProperty( )->SetLineWidth( 3 );
- vtkPoints* plane_points = this->m_Plane->GetPoints( );
- plane_points->SetPoint( 0, bnds[ 0 ], bnds[ 2 ], bnds[ 4 ] );
- plane_points->SetPoint( 2, bnds[ 1 ], bnds[ 3 ], bnds[ 5 ] );
- if( axis == 0 || axis == 2 ) // YZ, x-normal
- {
- plane_points->SetPoint( 1, bnds[ 1 ], bnds[ 2 ], bnds[ 5 ] );
- plane_points->SetPoint( 3, bnds[ 0 ], bnds[ 3 ], bnds[ 4 ] );
- }
- else if( axis == 1 ) // ZX, y-normal
- {
- plane_points->SetPoint( 1, bnds[ 0 ], bnds[ 2 ], bnds[ 5 ] );
- plane_points->SetPoint( 3, bnds[ 1 ], bnds[ 3 ], bnds[ 4 ] );
-
- } // fi
-
- // Set plane colors
- this->m_PlaneActor->GetProperty( )->
- SetColor( this->m_PlaneColors[ axis ] );
- this->m_Axis1Actor->GetProperty( )->
- SetColor( this->m_PlaneColors[ ( axis + 1 ) % 3 ] );
- this->m_Axis2Actor->GetProperty( )->
- SetColor( this->m_PlaneColors[ ( axis + 2 ) % 3 ] );
-
- this->m_Plane->Modified( );
- this->m_PlaneMapper->Modified( );
- this->m_PlaneActor->Modified( );
-
- this->m_Axis1->Modified( );
- this->m_Axis1Mapper->Modified( );
- this->m_Axis1Actor->Modified( );
-
- this->m_Axis2->Modified( );
- this->m_Axis2Mapper->Modified( );
- this->m_Axis2Actor->Modified( );
-
- // Update text
- this->UpdateText( );
-
- // Update camera position
- if( this->m_Window == NULL )
- return;
- vtkRenderer* renderer =
- this->m_Window->GetRenderers( )->GetFirstRenderer( );
- if( renderer == NULL )
- return;
- vtkCamera* camera = renderer->GetActiveCamera( );
- if( camera == NULL )
- return;
- double cam_pos[ 3 ];
- camera->GetPosition( cam_pos );
- cam_pos[ axis ] += this->m_VisibleBounds[ axis << 1 ] - prev_pos;
- camera->SetPosition( cam_pos );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-SetSlice( double* pos )
-{
- vtkImageData* image = this->GetInputImage( );
- if( image == NULL )
- return;
+ // Update pipeline
+ this->m_Mapper->SetSliceNumber( rs );
- int ijk[ 3 ];
- double pcoords[ 3 ];
- image->ComputeStructuredCoordinates( pos, ijk, pcoords );
- this->SetSliceNumber( ijk[ this->GetAxis( ) ] );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-UpdateText( )
-{
- if( this->m_ImageMapper.GetPointer( ) != NULL )
- {
- char axis;
- int axId = this->m_ImageMapper->GetOrientation( );
- if ( axId == 0 ) axis = 'X';
- else if( axId == 1 ) axis = 'Y';
- else if( axId == 2 ) axis = 'Z';
+ // Update display extent (this isn't done automatically)
+ ext[ a << 1 ] = ext[ ( a << 1 ) + 1 ] = rs;
+ this->m_Actor->SetDisplayExtent( ext );
-#if defined(WIN32)
- sprintf_s(
- this->m_TextBuffer, 1024, "Axis: %c (%d)",
- axis, this->m_ImageMapper->GetSliceNumber( )
- );
-#else // defined(WIN32)
- std::sprintf(
- this->m_TextBuffer, "Axis: %c (%d)",
- axis, this->m_ImageMapper->GetSliceNumber( )
- );
-#endif // defined(WIN32)
- }
- else
- this->m_TextBuffer[ 0 ] = '\0';
- this->m_TextActor->SetInput( this->m_TextBuffer );
- this->m_TextActor->Modified( );
+ this->m_Mapper->Modified( );
+ this->m_Actor->Modified( );
+ this->_ConfigureCursor( );
this->Modified( );
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageSliceActors::
-UpdateText( double pos[ 3 ] )
+ShowPixelText( double* pos )
{
- if( this->m_ImageMapper.GetPointer( ) != NULL )
+ if( this->m_Mapper.GetPointer( ) != NULL )
{
char axis;
- int axId = this->m_ImageMapper->GetOrientation( );
+ int axId = this->m_Mapper->GetOrientation( );
if ( axId == 0 ) axis = 'X';
else if( axId == 1 ) axis = 'Y';
else if( axId == 2 ) axis = 'Z';
- int slice = this->GetSliceNumber( );
+ long slice = this->GetSliceNumber( );
- vtkImageData* image = this->GetInputImage( );
+ vtkImageData* image = this->m_Actor->GetInput( );
int ijk[ 3 ];
double pcoords[ 3 ];
image->ComputeStructuredCoordinates( pos, ijk, pcoords );
#if defined(WIN32)
sprintf_s(
- this->m_TextBuffer, 1024, "Axis: %c (%d)\nPixel %s",
+ this->m_TextBuffer, MAX_TEXT_BUFFER, "Axis: %c (%d)\nPixel %s",
axis, slice, str.str( ).c_str( )
);
#else // defined(WIN32)
// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageSliceActors::
-UpdateText( const double& w, const double& l )
+GetScalarRange( double r[ 2 ] ) const
{
- if( this->m_ImageMapper.GetPointer( ) != NULL )
+ r[ 0 ] = this->m_ScalarRange[ 0 ];
+ r[ 1 ] = this->m_ScalarRange[ 1 ];
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::ImageSliceActors::
+SetScalarRange( const double& a, const double& b )
+{
+ this->m_ManualScalarRange = true;
+ this->m_ScalarRange[ 0 ] = a;
+ this->m_ScalarRange[ 1 ] = b;
+ this->SetWindowLevel( 1, 0.5 );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::ImageSliceActors::
+UnsetScalarRange( )
+{
+ auto image = this->m_Actor->GetInput( );
+ if( image != NULL )
{
- char axis;
- int axId = this->m_ImageMapper->GetOrientation( );
- if ( axId == 0 ) axis = 'X';
- else if( axId == 1 ) axis = 'Y';
- else if( axId == 2 ) axis = 'Z';
+ double r[ 2 ];
+ image->GetScalarRange( r );
+ this->SetScalarRange( r[ 0 ], r[ 1 ] );
-#if defined(WIN32)
- sprintf_s(
- this->m_TextBuffer, 1024, "Axis: %c (%d)\nW/L (%.2f/%.2f)",
- axis, this->m_ImageMapper->GetSliceNumber( ), w, l
- );
-#else // defined(WIN32)
- std::sprintf(
- this->m_TextBuffer, "Axis: %c (%d)\nW/L (%.2f/%.2f)",
- axis, this->m_ImageMapper->GetSliceNumber( ), w, l
- );
-#endif // defined(WIN32)
- }
- else
- this->m_TextBuffer[ 0 ] = '\0';
- this->m_TextActor->SetInput( this->m_TextBuffer );
- this->m_TextActor->Modified( );
- this->Modified( );
+ } // fi
+ this->m_ManualScalarRange = false;
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageSliceActors::
-Render( )
+SetWindowLevel( const double& w, const double& l )
{
- if( this->m_Window == NULL )
- return;
- vtkRenderer* renderer =
- this->m_Window->GetRenderers( )->GetFirstRenderer( );
- if( renderer == NULL )
- return;
- renderer->SetAllocatedRenderTime( 1e-3 );
- this->m_Window->Render( );
+ static const double _0 = double( 0 );
+ static const double _1 = double( 1 );
+
+ double rw = ( w < _0 )? _0: ( ( w > _1 )? _1: w );
+ double rl = ( l < _0 )? _0: ( ( l > _1 )? _1: l );
+
+ double d = this->m_ScalarRange[ 1 ] - this->m_ScalarRange[ 0 ];
+ rw *= d;
+ rl *= d;
+ rl += this->m_ScalarRange[ 0 ];
+
+ if( this->m_Actor.GetPointer( ) != NULL )
+ {
+ this->m_Actor->GetProperty( )->SetColorWindow( rw );
+ this->m_Actor->GetProperty( )->SetColorLevel( rl );
+ this->Modified( );
+
+ } // fi
+}
+
+// -------------------------------------------------------------------------
+double cpExtensions::Visualization::ImageSliceActors::
+GetWindow( ) const
+{
+ if( this->m_Actor.GetPointer( ) != NULL )
+ return( this->m_Actor->GetProperty( )->GetColorWindow( ) );
+ else
+ return( double( 0 ) );
+}
+
+// -------------------------------------------------------------------------
+double cpExtensions::Visualization::ImageSliceActors::
+GetLevel( ) const
+{
+ if( this->m_Actor.GetPointer( ) != NULL )
+ return( this->m_Actor->GetProperty( )->GetColorLevel( ) );
+ else
+ return( double( 0 ) );
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageSliceActors::
-ResetCamera( )
+Render( )
{
- if( this->m_Window == NULL )
+ auto ren = this->m_Style->GetCurrentRenderer( );
+ if( ren == NULL )
return;
- vtkRenderer* renderer =
- this->m_Window->GetRenderers( )->GetFirstRenderer( );
- if( renderer == NULL )
+ auto win = ren->GetRenderWindow( );
+ if( win == NULL )
return;
- renderer->ResetCamera( );
+ win->Render( );
}
// -------------------------------------------------------------------------
cpExtensions::Visualization::ImageSliceActors::
ImageSliceActors( )
: Superclass( ),
- m_Window( NULL ),
- m_Interpolate( false )
+ m_ManualScalarRange( false )
{
this->Clear( );
- this->_ConfigureStyle( );
}
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageSliceActors::
-_ConfigureStyle( )
+_ConfigureInput( int orientation )
{
- // Connect this view with a controller
- this->m_Style = vtkSmartPointer< TStyle >::New( );
- this->m_Style->SetAssociatedObject( this );
- this->m_Style->AddMouseMoveCommand( Self::_MouseMoveCommand, this );
- this->m_Style->AddMouseClickCommand( Self::_MouseClickCommand, this );
- this->m_Style->AddMouseWheelCommand( Self::_MouseWheelCommand, this );
- this->m_Style->AddKeyCommand( Self::_KeyCommand, this );
- this->m_Style->AddEnterCommand( Self::_EnterCommand, this );
- this->m_Style->AddLeaveCommand( Self::_LeaveCommand, this );
-}
+ // Prepare main image
+ this->m_Mapper->SetOrientation( orientation );
+ this->m_Mapper->Update( );
+ this->m_Actor->GetProperty( )->SetOpacity( 0.8 );
+ this->m_Actor->Modified( );
+ auto st = this->GetStyle( );
+ if( st != NULL )
+ st->AssociateImageActor( this->m_Actor );
+ this->AddItem( this->m_Actor );
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-_ConfigureInputImage( )
-{
- this->m_ImageMapper->SetOrientation( 0 );
- this->m_ImageMapper->Update( );
+ // Prepare main cursor
+ this->_ConfigureCursor( );
+ this->AddItem( this->m_Cursor.Actor );
- // Create actor
- this->m_ImageActor->SetInterpolate( this->m_Interpolate );
- this->m_ImageActor->Modified( );
+ // Prepare window/level
+ if( !( this->m_ManualScalarRange ) )
+ this->UnsetScalarRange( );
- if( this->m_Style.GetPointer( ) != NULL )
- this->m_Style->AssociateImageActor( this->m_ImageActor );
- this->AddItem( this->m_ImageActor );
+ // Add all other actors
+ this->AddItem( this->m_TextActor );
- this->SetSliceNumber( this->GetSliceNumberMinValue( ) );
- this->ResetCursor( );
- this->Modified( );
+ // Put it in the first slice
+ auto image = this->m_Mapper->GetInput( );
+ int ext[ 6 ];
+ image->GetExtent( ext );
+ this->SetSliceNumber( ext[ orientation << 1 ] );
- // Reset cursors
- this->ResetCursor( );
- this->ResetAxesCursor( );
+ /*
+ if( this->m_Style.GetPointer( ) != NULL )
+ this->AddItem( this->m_Actor );
- // Update window/level ranges
- vtkImageData* data = this->GetInputImage( );
- if( data != NULL )
- {
+ this->SetSliceNumber( this->GetSliceNumberMinValue( ) );
+ this->ResetCursor( );
+ this->Modified( );
+
+ // Reset cursors
+ this->ResetCursor( );
+ this->ResetAxesCursor( );
+
+ // Update window/level ranges
+ vtkImageData* data = this->GetInputImage( );
+ if( data != NULL )
+ {
double r[ 2 ];
data->GetScalarRange( r );
this->m_WLRange[ 0 ] = double( 0 );
this->m_BlenderBase->ShallowCopy( data );
this->m_BlenderBase->AllocateScalars( VTK_UNSIGNED_CHAR, 1 );
std::memset(
- this->m_BlenderBase->GetScalarPointer( ), 0,
- this->m_BlenderBase->GetActualMemorySize( )
- );
+ this->m_BlenderBase->GetScalarPointer( ), 0,
+ this->m_BlenderBase->GetActualMemorySize( )
+ );
this->m_Blender->AddInputData( this->m_BlenderBase );
- } // fi
+ } // fi
+ */
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageSliceActors::
-_ConfigureBinaryImage( const double& r, const double& g, const double& b )
+_ConfigureCursor( )
{
- unsigned int nValues = this->m_BlenderLUT->GetNumberOfTableValues( );
- this->m_BlenderLUT->SetNumberOfTableValues( nValues + 1 );
- this->m_BlenderLUT->SetTableRange( 0, nValues );
- this->m_BlenderLUT->SetTableValue( nValues, r, g, b, 0.5 );
- this->m_BlenderLUT->Build( );
-
- this->m_BlenderLUT->Modified( );
- this->m_Blender->Modified( );
- this->m_Blender->Update( );
-
- this->m_BlenderMapper->Modified( );
- this->m_BlenderActor->Modified( );
+ int a = this->m_Mapper->GetOrientation( );
+ double bounds[ 6 ];
+ this->m_Actor->GetBounds( bounds );
+ bounds[ a << 1 ] += 1e-5;
+ bounds[ ( a << 1 ) + 1 ] += 1e-5;
+
+ this->m_Cursor.Source->SetModelBounds( bounds );
+ this->m_Cursor.Source->AllOn( );
+ this->m_Cursor.Actor->GetProperty( )->SetOpacity( 1 );
+ this->m_Cursor.Actor->GetProperty( )->SetLineWidth( 3 );
+ this->m_Cursor.Modified( );
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageSliceActors::
_MouseMoveCommand(
- void* data, const TStyle::ButtonID& btn, int* idx, double* pos,
+ void* data,
+ const TStyle::ButtonID& btn,
+ int* idx, double* pos,
bool alt, bool ctr, bool sft
)
{
- ImageSliceActors* actors = reinterpret_cast< ImageSliceActors* >( data );
- if( actors == NULL )
+ ImageSliceActors* self = reinterpret_cast< ImageSliceActors* >( data );
+ if( self == NULL )
return;
if( btn == TStyle::ButtonID_None )
{
- // Just show the pixel information
- actors->SetCursor( pos );
- actors->UpdateText( pos );
- actors->Render( );
- }
- else if( btn == TStyle::ButtonID_Left )
- {
- if( !alt && ctr && !sft )
- {
- // Show axes in current renderer
- actors->SetAxesCursor( pos );
- actors->Render( );
-
- // Interactively move slices
- auto i = actors->m_SlicesCommands.begin( );
- for( ; i != actors->m_SlicesCommands.end( ); ++i )
- i->first( pos, actors->GetAxis( ), i->second );
-
- } // fi
+ self->ShowPixelText( pos );
+ self->m_Cursor.Source->SetFocalPoint( pos );
+ self->m_Cursor.Source->Modified( );
+ self->m_Cursor.Modified( );
+ self->Render( );
}
else if( btn == TStyle::ButtonID_Right )
{
if( !alt && !ctr && sft )
{
- // Change image window level
- double bounds[ 6 ];
- actors->m_ImageMapper->GetBounds( bounds );
-
- int a0 = actors->GetAxis( );
+ int a0 = self->m_Mapper->GetOrientation( );
int a1 = ( a0 + 1 ) % 3;
int a2 = ( a0 + 2 ) % 3;
- double dx = pos[ a1 ] - actors->m_StartWindowLevelPos[ a1 ];
- double dy = pos[ a2 ] - actors->m_StartWindowLevelPos[ a2 ];
+ double dx = pos[ a1 ] - self->m_StartMouseEvent[ a1 ];
+ double dy = pos[ a2 ] - self->m_StartMouseEvent[ a2 ];
+ double bounds[ 6 ];
+ self->m_Actor->GetBounds( bounds );
dx /= bounds[ ( a1 << 1 ) + 1 ] - bounds[ a1 << 1 ];
dy /= bounds[ ( a2 << 1 ) + 1 ] - bounds[ a2 << 1 ];
+ double w = self->m_StartWindow + dx;
+ double l = self->m_StartLevel + dy;
+
+ self->SetWindowLevel( w, l );
+ self->Render( );
+ for(
+ auto aIt = self->m_AssociatedSlices.begin( );
+ aIt != self->m_AssociatedSlices.end( );
+ ++aIt
+ )
+ {
+ ( *aIt )->SetWindowLevel( w, l );
+ ( *aIt )->Render( );
- dx *= actors->m_StartWindowLevel[ 0 ];
- dy *= actors->m_StartWindowLevel[ 1 ];
- dx += actors->m_StartWindowLevel[ 0 ];
- dy += actors->m_StartWindowLevel[ 1 ];
- actors->SetWindowLevel( dx, dy );
- actors->Render( );
-
- // Associate objects
- auto i = actors->m_WindowLevelCommands.begin( );
- for( ; i != actors->m_WindowLevelCommands.end( ); ++i )
- i->first( dx, dy, i->second );
+ } // rof
} // fi
// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageSliceActors::
_MouseClickCommand(
- void* data, const TStyle::ButtonID& btn, int* idx, double* pos,
+ void* data,
+ const TStyle::ButtonID& btn,
+ int* idx, double* pos,
bool alt, bool ctr, bool sft
)
{
- ImageSliceActors* actors = reinterpret_cast< ImageSliceActors* >( data );
- if( actors == NULL )
+ ImageSliceActors* self = reinterpret_cast< ImageSliceActors* >( data );
+ if( self == NULL )
return;
- actors->m_StartWindowLevelPos[ 0 ] = pos[ 0 ];
- actors->m_StartWindowLevelPos[ 1 ] = pos[ 1 ];
- actors->m_StartWindowLevelPos[ 2 ] = pos[ 2 ];
- actors->m_StartWindowLevel[ 0 ] = actors->GetWindow( );
- actors->m_StartWindowLevel[ 1 ] = actors->GetLevel( );
+ self->m_StartMouseEvent[ 0 ] = pos[ 0 ];
+ self->m_StartMouseEvent[ 1 ] = pos[ 1 ];
+ self->m_StartMouseEvent[ 2 ] = pos[ 2 ];
+
+ if( btn == TStyle::ButtonID_Right )
+ {
+ if( !alt && !ctr && sft )
+ {
+ double r[ 2 ];
+ self->GetScalarRange( r );
+ double d = r[ 1 ] - r[ 0 ];
+ self->m_StartWindow = self->GetWindow( ) / d;
+ self->m_StartLevel = ( self->GetLevel( ) - r[ 0 ] ) / d;
+
+ } // fi
+
+ } // fi
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageSliceActors::
_MouseWheelCommand(
- void* data, const int& dir,
- bool alt, bool ctr, bool sft
+ void* data,
+ const int& dir, bool alt, bool ctr, bool sft
)
{
- ImageSliceActors* actors = reinterpret_cast< ImageSliceActors* >( data );
- if( actors == NULL )
+ ImageSliceActors* self = reinterpret_cast< ImageSliceActors* >( data );
+ if( self == NULL )
+ return;
+ auto ren = self->m_Style->GetCurrentRenderer( );
+ if( ren == NULL )
+ return;
+ auto cam = ren->GetActiveCamera( );
+ if( cam == NULL )
+ return;
+ auto win = ren->GetRenderWindow( );
+ if( win == NULL )
return;
- if( !alt && !ctr )
+ // Get previous values
+ int a = self->m_Mapper->GetOrientation( );
+ double bounds[ 6 ];
+ self->m_Actor->GetBounds( bounds );
+ double prev_pos = bounds[ a << 1 ];
+
+ // Move slice
+ long slice = self->GetSliceNumber( ) + dir * ( ( sft )? 10: 1 );
+ self->SetSliceNumber( slice );
+ self->m_Actor->GetBounds( bounds );
+
+ // Reset camera
+ double cam_pos[ 3 ];
+ cam->GetPosition( cam_pos );
+ cam_pos[ a ] += bounds[ a << 1 ] - prev_pos;
+ cam->SetPosition( cam_pos );
+
+ // Update text
+ self->ShowPixelText( self->m_Cursor.Source->GetFocalPoint( ) );
+
+ // Update all
+ win->Render( );
+ for(
+ auto aIt = self->m_AssociatedSlices.begin( );
+ aIt != self->m_AssociatedSlices.end( );
+ ++aIt
+ )
{
- int slice = actors->GetSliceNumber( ) + ( dir * ( ( sft )? 10: 1 ) );
- if( slice < actors->GetSliceNumberMinValue( ) )
- slice = actors->GetSliceNumberMinValue( );
- if( slice > actors->GetSliceNumberMaxValue( ) )
- slice = actors->GetSliceNumberMaxValue( );
- actors->SetSliceNumber( slice );
- actors->Render( );
-
- auto a = actors->m_AssociatedSlices.begin( );
- for( ; a != actors->m_AssociatedSlices.end( ); ++a )
- ( *a )->SetSliceNumber( slice );
-
- // Associate objects
- auto i = actors->m_RenderCommands.begin( );
- for( ; i != actors->m_RenderCommands.end( ); ++i )
- i->first( i->second );
+ if( ( *aIt )->m_Mapper->GetOrientation( ) == a )
+ {
+ ( *aIt )->SetSliceNumber( slice );
+ ( *aIt )->Render( );
+
+ } // fi
} // fi
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageSliceActors::
-_KeyCommand( void* data, const char& key )
+_KeyCommand(
+ void* data,
+ const char& key
+ )
{
- ImageSliceActors* actors = reinterpret_cast< ImageSliceActors* >( data );
- if( actors == NULL )
- return;
-
- switch( key )
- {
- case 'r': case 'R':
- {
- actors->ResetCamera( );
- actors->Render( );
-
- // Associate objects
- auto i = actors->m_RenderCommands.begin( );
- for( ; i != actors->m_RenderCommands.end( ); ++i )
- i->first( i->second );
- }
- break;
- case 'w': case 'W':
- {
- actors->ResetWindowLevel( );
- actors->Render( );
-
- // Associate objects
- auto i = actors->m_RenderCommands.begin( );
- for( ; i != actors->m_RenderCommands.end( ); ++i )
- i->first( i->second );
- }
- break;
- default:
- break;
- } // hctiws
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageSliceActors::
_EnterCommand( void* data )
{
- ImageSliceActors* actors = reinterpret_cast< ImageSliceActors* >( data );
- if( actors == NULL )
- return;
-
- actors->ResetCursor( );
- actors->m_CursorActor->VisibilityOn( );
- actors->Render( );
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageSliceActors::
_LeaveCommand( void* data )
{
- ImageSliceActors* actors = reinterpret_cast< ImageSliceActors* >( data );
- if( actors == NULL )
- return;
-
- actors->ResetCursor( );
- actors->m_CursorActor->VisibilityOff( );
- actors->Render( );
}
// eof - $RCSfile$
#include <cpExtensions/cpExtensions_Export.h>
-#include <vtkSmartPointer.h>
+#include <cpExtensions/Interaction/ImageInteractorStyle.h>
#include <vtkActor.h>
+#include <vtkCursor3D.h>
#include <vtkImageActor.h>
#include <vtkImageSliceMapper.h>
-#include <vtkLookupTable.h>
-#include <vtkPlane.h>
-#include <vtkPolyData.h>
#include <vtkPolyDataMapper.h>
#include <vtkPropCollection.h>
#include <vtkTextActor.h>
+#include <vtkSmartPointer.h>
-#include <cpExtensions/Interaction/ImageInteractorStyle.h>
-#include <cpExtensions/Visualization/ImageBlender.h>
+#define MAX_TEXT_BUFFER 1024
-// -------------------------------------------------------------------------
class vtkAlgorithmOutput;
class vtkImageData;
-class vtkLookupTable;
class vtkRenderer;
-// -------------------------------------------------------------------------
namespace cpExtensions
{
namespace Visualization
{
public:
typedef ImageSliceActors Self;
-
typedef cpExtensions::Interaction::ImageInteractorStyle TStyle;
typedef TStyle::TMouseCommand TMouseCommand;
typedef TStyle::TMouseWheelCommand TMouseWheelCommand;
typedef void ( *TWindowLevelCommand )( double, double, void* );
typedef TVoidCommand TRenderCommand;
- typedef cpExtensions::Visualization::ImageBlender TBlender;
+ template< class _TSource >
+ struct SourceActor
+ {
+ vtkSmartPointer< _TSource > Source;
+ vtkSmartPointer< vtkPolyDataMapper > Mapper;
+ vtkSmartPointer< vtkActor > Actor;
+ void Create( )
+ {
+ this->Source = vtkSmartPointer< _TSource >::New( );
+ this->Mapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
+ this->Actor = vtkSmartPointer< vtkActor >::New( );
+ this->Mapper->SetInputConnection( this->Source->GetOutputPort( ) );
+ this->Actor->SetMapper( this->Mapper );
+ }
+ void Modified( )
+ {
+ this->Source->Modified( );
+ this->Mapper->Modified( );
+ this->Actor->Modified( );
+ }
+ };
+
public:
vtkTypeMacro( ImageSliceActors, vtkPropCollection );
cpExtensions_BaseInteractorStyle_Commands( Render );
public:
- // Creation
- static ImageSliceActors* New( );
-
- void SetAxis( int axis );
- void SetInputConnection( vtkAlgorithmOutput* aout );
- void SetInputImage( vtkImageData* data );
- int AddBinaryConnection(
- vtkAlgorithmOutput* aout,
- const double& r, const double& g, const double& b
- );
- int AddBinaryImage(
- vtkImageData* data,
- const double& r, const double& g, const double& b
- );
+ static Self* New( );
+
void Clear( );
+ void SetInputConnection( vtkAlgorithmOutput* aout, int orientation );
+ void SetInputData( vtkImageData* data, int orientation );
void AssociateSlice( Self* slice );
+ void CleanAssociatedSlices( );
- vtkImageData* GetInputImage( );
- const vtkImageData* GetInputImage( ) const;
-
- vtkInteractorStyle* GetStyle( );
- const vtkInteractorStyle* GetStyle( ) const;
-
- void PushActorsInto( vtkRenderWindow* window, bool force_style = true );
- void PopActorsFrom( vtkRenderWindow* window );
- unsigned int GetNumberOfImages( ) const;
+ TStyle* GetStyle( );
+ void SetStyle( vtkInteractorStyle* st );
- vtkImageActor* GetImageActor( );
- const vtkImageActor* GetImageActor( ) const;
- vtkImageActor* GetBinaryActor( );
- const vtkImageActor* GetBinaryActor( ) const;
- vtkTextActor* GetTextActor( );
- const vtkTextActor* GetTextActor( ) const;
- vtkActor* GetPlaneActor( );
- const vtkActor* GetPlaneActor( ) const;
- vtkPlane* GetPlaneFunction( );
- const vtkPlane* GetPlaneFunction( ) const;
+ void PushInto( vtkRenderer* ren );
+ void PopFrom( vtkRenderer* ren );
- void SetInterpolate( bool v );
- void InterpolateOn( );
- void InterpolateOff( );
+ long GetSliceNumber( ) const;
+ void SetSliceNumber( long slice );
- double* GetDisplayBounds( ) const;
- void GetDisplayBounds( double bounds[ 6 ] ) const;
+ void ShowPixelText( double* pos );
- void ResetCursor( );
- void SetCursor( double pos[ 3 ] );
-
- void ResetAxesCursor( );
- void SetAxesCursor( double pos[ 3 ] );
-
- double GetMinWindow( ) const;
- double GetMaxWindow( ) const;
- double GetMinLevel( ) const;
- double GetMaxLevel( ) const;
+ void GetScalarRange( double r[ 2 ] ) const;
+ void SetScalarRange( const double& a, const double& b );
+ void UnsetScalarRange( );
+ void SetWindowLevel( const double& w, const double& l );
double GetWindow( ) const;
double GetLevel( ) const;
- void SetWindow( double w );
- void SetLevel( double l );
- void SetWindowLevel( double w, double l );
- void ResetWindowLevel( );
-
- int GetAxis( ) const;
- int GetSliceNumber( ) const;
- int GetSliceNumberMinValue( ) const;
- int GetSliceNumberMaxValue( ) const;
- void SetSliceNumber( const int& slice );
- void SetSlice( double* pos );
- void UpdateText( );
- void UpdateText( double pos[ 3 ] );
- void UpdateText( const double& w, const double& l );
void Render( );
- void ResetCamera( );
protected:
ImageSliceActors( );
virtual ~ImageSliceActors( );
- void _ConfigureStyle( );
- void _ConfigureInputImage( );
- void _ConfigureBinaryImage(
- const double& r, const double& g, const double& b
- );
+ void _ConfigureInput( int orientation );
+ void _ConfigureCursor( );
// Events
static void _MouseMoveCommand(
Self& operator=( const Self& );
protected:
- static double m_PlaneColors[ 3 ][ 3 ];
-
- vtkSmartPointer< TStyle > m_Style;
- vtkRenderWindow* m_Window;
-
- // Multiple actors
- vtkSmartPointer< vtkImageSliceMapper > m_ImageMapper;
- vtkSmartPointer< vtkImageActor > m_ImageActor;
-
- vtkSmartPointer< vtkImageData > m_BlenderBase;
- vtkSmartPointer< TBlender > m_Blender;
- vtkSmartPointer< vtkImageSliceMapper > m_BlenderMapper;
- vtkSmartPointer< vtkLookupTable > m_BlenderLUT;
- vtkSmartPointer< vtkImageActor > m_BlenderActor;
-
- bool m_Interpolate;
-
- double m_WLRange[ 4 ];
-
- int m_VisibleExtent[ 6 ];
- double m_VisibleBounds[ 6 ];
-
- // Associated slices
- std::vector< Self* > m_AssociatedSlices;
+ // Main image
+ vtkSmartPointer< vtkImageSliceMapper > m_Mapper;
+ vtkSmartPointer< vtkImageActor > m_Actor;
- // Unique objects
- vtkSmartPointer< vtkPolyData > m_Cursor;
- vtkSmartPointer< vtkPolyDataMapper > m_CursorMapper;
- vtkSmartPointer< vtkActor > m_CursorActor;
+ // Secondary slices
+ std::vector< vtkSmartPointer< Self > > m_AssociatedSlices;
- vtkSmartPointer< vtkPolyData > m_Axis1;
- vtkSmartPointer< vtkPolyDataMapper > m_Axis1Mapper;
- vtkSmartPointer< vtkActor > m_Axis1Actor;
+ // Cursor
+ SourceActor< vtkCursor3D > m_Cursor;
- vtkSmartPointer< vtkPolyData > m_Axis2;
- vtkSmartPointer< vtkPolyDataMapper > m_Axis2Mapper;
- vtkSmartPointer< vtkActor > m_Axis2Actor;
+ // Text
+ char m_TextBuffer[ MAX_TEXT_BUFFER ];
+ vtkSmartPointer< vtkTextActor > m_TextActor;
- vtkSmartPointer< vtkPolyData > m_Plane;
- vtkSmartPointer< vtkPolyDataMapper > m_PlaneMapper;
- vtkSmartPointer< vtkActor > m_PlaneActor;
+ // WindowLevel
+ double m_ScalarRange[ 2 ];
+ bool m_ManualScalarRange;
- char m_TextBuffer[ 1024 ];
- vtkSmartPointer< vtkTextActor > m_TextActor;
+ // Style
+ vtkSmartPointer< vtkInteractorStyle > m_Style;
- double m_StartWindowLevelPos[ 3 ];
- double m_StartWindowLevel[ 2 ];
+ // Events-related data
+ double m_StartMouseEvent[ 3 ];
+ double m_StartWindow;
+ double m_StartLevel;
};
} // ecapseman
} // ecapseman
-#endif // __CPEXTENSIONS__VISUALIZATION__IMAGESLICEACTORS__H__
+#endif // __CPEXTENSIONS__VISUALIZATION__IMAGESLICEACTORS__H__
// eof - $RCSfile$
#include <cpExtensions/Visualization/MPRActors.h>
+/*
#include <vtkAlgorithmOutput.h>
#include <vtkImageData.h>
#include <vtkOutlineSource.h>
return;
actors->Render( );
}
+*/
// eof - $RCSfile$
{
/**
*/
+ /*
class cpExtensions_EXPORT MPRActors
: public vtkPropCollection
{
vtkSmartPointer< vtkActor > ImageOutlineActor;
vtkSmartPointer< ImageSliceActors > Slices[ 2 ][ 3 ];
};
+ */
} // ecapseman
#include <cpExtensions/Visualization/MPRObjects.h>
+/*
#include <cmath>
#include <vtkImageData.h>
#include <vtkLookupTable.h>
void cpExtensions::Visualization::MPRObjects::
Hide( )
{
+ this->m_MPRActors->PopActorsFrom(
+ this->m_Windows[ 0 ],
+ this->m_Windows[ 1 ],
+ this->m_Windows[ 2 ],
+ this->m_Windows[ 3 ]
+ );
}
// -------------------------------------------------------------------------
{
}
-
+*/
/*
{
/**
*/
+ /*
class cpExtensions_EXPORT MPRObjects
: public vtkObject
{
vtkSmartPointer< MPRActors > m_MPRActors;
vtkSmartPointer< vtkRenderer > m_Renderers[ 4 ];
};
+ */
} // ecapseman
emit showFilterOutput( filter_name, output_name );\r
}\r
\r
+// -------------------------------------------------------------------------\r
+void cpPipelineEditor::Editor::\r
+hideOutputData(\r
+ const std::string& filter_name, const std::string& output_name\r
+ )\r
+{\r
+ emit hideFilterOutput( filter_name, output_name );\r
+}\r
+\r
+// -------------------------------------------------------------------------\r
+void cpPipelineEditor::Editor::\r
+visualPropertiesOutputData(\r
+ const std::string& filter_name, const std::string& output_name\r
+ )\r
+{\r
+ emit visualPropertiesFilterOutput( filter_name, output_name );\r
+}\r
+\r
// -------------------------------------------------------------------------\r
cpPipelineEditor_Editor_Callback_CODE( ContextMenu )\r
{\r
const std::string& filter_name,\r
const std::string& output_name\r
);\r
+ void hideOutputData(\r
+ const std::string& filter_name,\r
+ const std::string& output_name\r
+ );\r
+ void visualPropertiesOutputData(\r
+ const std::string& filter_name,\r
+ const std::string& output_name\r
+ );\r
\r
signals:\r
void execFilter( const std::string& filter_name );\r
const std::string& filter_name,\r
const std::string& output_name\r
);\r
+ void hideFilterOutput(\r
+ const std::string& filter_name,\r
+ const std::string& output_name\r
+ );\r
+ void visualPropertiesFilterOutput(\r
+ const std::string& filter_name,\r
+ const std::string& output_name\r
+ );\r
\r
private:\r
QGraphicsItem* itemAt( const QPointF& pos );\r
QMenu menu;\r
QAction* showAction = menu.addAction( "Show" );\r
QAction* hideAction = menu.addAction( "Hide" );\r
+ QAction* propertiesAction = menu.addAction( "Properties" );\r
QAction* selectedAction = menu.exec( evt->screenPos( ) );\r
\r
if( selectedAction == showAction )\r
}\r
else if( selectedAction == hideAction )\r
{\r
+ this->m_Block->editor( )->hideOutputData(\r
+ this->m_Block->namePort( ).toStdString( ),\r
+ this->name( ).toStdString( )\r
+ );\r
+ }\r
+ else if( selectedAction == propertiesAction )\r
+ {\r
+ this->m_Block->editor( )->visualPropertiesOutputData(\r
+ this->m_Block->namePort( ).toStdString( ),\r
+ this->name( ).toStdString( )\r
+ );\r
+\r
} // fi\r
}\r
\r
#include <cpPlugins/BaseWidget.h>
+#ifdef cpPlugins_QT4
+
// -------------------------------------------------------------------------
const cpPlugins::BaseWidget::TMPRWidget* cpPlugins::BaseWidget::
GetMPRViewer( ) const
this->m_SingleInteractor = NULL;
}
+#endif // cpPlugins_QT4
+
// eof - $RCSfile$
#ifndef __CPPLUGINS__BASEWIDGET__H__
#define __CPPLUGINS__BASEWIDGET__H__
+#include <cpPlugins/Config.h>
+
+#ifdef cpPlugins_QT4
+
#include <cpPlugins/ProcessObject.h>
// Some forward declarations
} // ecapseman
+#endif // cpPlugins_QT4
+
#endif // __CPPLUGINS__BASEWIDGET__H__
// eof - $RCSfile$
# include <dlfcn.h>
#endif // cpPlugins_SYS_WINDOWS
#include <cpPlugins_dirent.h>
+#include <algorithm>
// -------------------------------------------------------------------------
cpPlugins::Interface::
#include <cpPluginsIO/MeshReader.h>
#include <cpPlugins/Mesh.h>
+#include <algorithm>
#include <cstring>
#include <vtkPolyDataReader.h>
#include <cpPluginsIO/MeshWriter.h>
#include <cpPlugins/Mesh.h>
+#include <algorithm>
#include <cstring>
#include <vtkPolyDataWriter.h>