From: Leonardo Florez-Valencia Date: Tue, 27 Oct 2015 22:55:10 +0000 (-0500) Subject: Tree data updated. X-Git-Tag: v0.1~318 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=a02d2e4b730e0a8c7709856c9c47eb7ad19edda0;p=cpPlugins.git Tree data updated. --- diff --git a/appli/ImageMPR/ImageMPR.cxx b/appli/ImageMPR/ImageMPR.cxx index a83a5d6..47c3622 100644 --- a/appli/ImageMPR/ImageMPR.cxx +++ b/appli/ImageMPR/ImageMPR.cxx @@ -15,8 +15,7 @@ ImageMPR:: ImageMPR( QWidget* parent ) : QMainWindow( parent ), m_UI( new Ui::ImageMPR ), - m_Plugins( new TPlugins ), - m_MainImage( NULL ) + m_Plugins( new TPlugins ) { this->m_UI->setupUi( this ); this->m_Plugins->SetWidget( this ); @@ -53,11 +52,19 @@ ImageMPR:: void ImageMPR:: _aOpenImage( ) { - if( this->m_MainImage.IsNotNull( ) ) + // Clear all, since we are loading the main image + if( this->m_Objects.size( ) > 0 ) + { this->m_UI->MPR->ClearAll( ); - if( this->m_Plugins->ReadImage( this->m_MainImage, true ) ) + this->m_Objects.clear( ); + + } // fi + + // Read and show image, if possible + TPlugins::TImage::Pointer image; + if( this->m_Plugins->ReadImage( image, true ) ) { - vtkImageData* vimage = this->m_MainImage->GetVTK< vtkImageData >( ); + vtkImageData* vimage = image->GetVTK< vtkImageData >( ); if( vimage == NULL ) QMessageBox::critical( this, @@ -67,7 +74,11 @@ _aOpenImage( ) ) ); else - this->m_UI->MPR->ShowImage( vimage ); + this->m_UI->MPR->ShowImage( vimage, image->GetName( ) ); + + // Keep a track on a local data tree + this->m_Objects[ image->GetName( ) ] = + TTreeNode( "", image.GetPointer( ) ); } // fi } @@ -76,11 +87,19 @@ _aOpenImage( ) void ImageMPR:: _aOpenDICOMSeries( ) { - if( this->m_MainImage.IsNotNull( ) ) + // Clear all, since we are loading the main image + if( this->m_Objects.size( ) > 0 ) + { this->m_UI->MPR->ClearAll( ); - if( this->m_Plugins->ReadDicomSeries( this->m_MainImage ) ) + this->m_Objects.clear( ); + + } // fi + + // Read and show image, if possible + TPlugins::TImage::Pointer image; + if( this->m_Plugins->ReadDicomSeries( image ) ) { - vtkImageData* vimage = this->m_MainImage->GetVTK< vtkImageData >( ); + vtkImageData* vimage = image->GetVTK< vtkImageData >( ); if( vimage == NULL ) QMessageBox::critical( this, @@ -90,7 +109,11 @@ _aOpenDICOMSeries( ) ) ); else - this->m_UI->MPR->ShowImage( vimage ); + this->m_UI->MPR->ShowImage( vimage, image->GetName( ) ); + + // Keep a track on a local data tree + this->m_Objects[ image->GetName( ) ] = + TTreeNode( "", image.GetPointer( ) ); } // fi } @@ -115,8 +138,10 @@ _aOpenPolyData( ) void ImageMPR:: _aSaveImage( ) { - if( this->m_MainImage.IsNotNull( ) ) + /* + if( this->m_MainImage.IsNotNull( ) ) this->m_Plugins->WriteImage( this->m_MainImage, true ); + */ } // ------------------------------------------------------------------------- @@ -163,6 +188,13 @@ _aShowPlugins( ) void ImageMPR:: _execPlugin( ) { + /* + typedef std::map< std::string, TPlugins::TImage::Pointer > _TImages; + typedef std::map< std::string, TPlugins::TMesh::Pointer > _TMeshes; + + // Get selected data + // std::string data_name = this->m_UI->MPR->GetSelectedData( ); + // Get filter name QAction* action = dynamic_cast< QAction* >( this->sender( ) ); if( action == NULL ) @@ -170,40 +202,124 @@ _execPlugin( ) QMenu* menu = dynamic_cast< QMenu* >( action->parentWidget( ) ); if( menu == NULL ) return; - std::string cate = menu->title( ).toStdString( ); - std::string name = action->text( ).toStdString( ); - std::string err = ""; + std::string filter_cate = menu->title( ).toStdString( ); + std::string filter_name = action->text( ).toStdString( ); + // Create filter TPlugins::TProcessObject::Pointer filter; - if( this->m_Plugins->CreateFilter( filter, name ) ) + if( !( this->m_Plugins->CreateFilter( filter, filter_name ) ) ) + { + QMessageBox::critical( + this, + tr( "Error creating filter" ), + tr( ( + std::string( "No valid filter \"" ) + + filter_name + + std::string( "\"defined." ) + ).c_str( ) ) + ); + return; + + } // fi + + // Assign inputs + std::vector< std::string > inputs_names = filter->GetInputsNames( ); + if( inputs_names.size( ) == 1 ) + { + std::string data_name = this->m_UI->MPR->GetSelectedData( ); + _TImages::iterator iIt = this->m_Images.find( data_name ); + _TImages::iterator mIt = this->m_Meshes.find( data_name ); + filter->SetInput( inputs_names[ 0 ]); + } + else if( inputs_names.size( ) > 1 ) + { + } // fi + + // Get outputs + std::vector< std::string > outputs_names = filter->GetOutputsNames( ); + */ + + /* + + // Choose inputs + if( filter_cate == "ImageToMeshFilter" ) { - if( cate == "ImageToMeshFilter" ) + // Check inputs + _TImages::iterator iIt = this->m_Images.find( data_name ); + if( iIt == this->m_Images.end( ) ) { - if( filter->ExecConfigurationDialog( this ) ) - { - filter->SetInput( "Input", this->m_MainImage ); - this->_Block( ); - err = filter->Update( ); - this->_Unblock( ); - TPlugins::TMesh::Pointer mesh = - filter->GetOutput< TPlugins::TMesh >( "Output" ); - this->m_Meshes.push_back( mesh ); - mesh->CreateVTKActor( ); - vtkActor* actor = mesh->GetVTKActor( ); - if( actor != NULL ) - this->m_UI->MPR->Add3DActor( actor ); + QMessageBox::critical( + this, + tr( "Error creating filter" ), + tr( "No valid input selected." ) + ); + return; - } // fi + } // fi + + // Execute configuration dialog + if( !( filter->ExecConfigurationDialog( this ) ) ) + return; + + // Execute filter + filter->SetInput( "Input", iIt->second ); + this->_Block( ); + std::string filter_err = filter->Update( ); + this->_Unblock( ); + if( filter_err != "" ) + { + QMessageBox::critical( + this, + tr( "Error executing" ), + tr( filter_err.c_str( ) ) + ); + return; } // fi - } - else - QMessageBox::critical( - this, - tr( "Error creating filter" ), - tr( "No valid filter defined." ) + + // Keep and show results + TPlugins::TMesh::Pointer mesh = + filter->GetOutput< TPlugins::TMesh >( "Output" ); + this->m_Meshes[ filter_name ] = mesh; + this->_Block( ); + this->m_UI->MPR->ShowMesh( + mesh->GetVTK< vtkPolyData >( ), + filter_name, + data_name ); + this->_Unblock( ); + } // fi + */ + + /* + if( this->m_Plugins->CreateFilter( filter, name ) ) + { + if( filter->ExecConfigurationDialog( this ) ) + { + filter->SetInput( "Input", this->m_MainImage ); + this->_Block( ); + err = filter->Update( ); + this->_Unblock( ); + TPlugins::TMesh::Pointer mesh = + filter->GetOutput< TPlugins::TMesh >( "Output" ); + this->m_Meshes.push_back( mesh ); + mesh->CreateVTKActor( ); + vtkActor* actor = mesh->GetVTKActor( ); + if( actor != NULL ) + this->m_UI->MPR->Add3DActor( actor ); + + } // fi + + } // fi + } + else + QMessageBox::critical( + this, + tr( "Error creating filter" ), + tr( "No valid filter defined." ) + ); + */ /* if( name == "cpPlugins::BasicFilters::FloodFillImageFilter" ) { diff --git a/appli/ImageMPR/ImageMPR.h b/appli/ImageMPR/ImageMPR.h index 56b4623..c4d43e3 100644 --- a/appli/ImageMPR/ImageMPR.h +++ b/appli/ImageMPR/ImageMPR.h @@ -1,6 +1,7 @@ #ifndef __IMAGEMPR__H__ #define __IMAGEMPR__H__ +#include #include // Qt stuff @@ -175,8 +176,9 @@ private: TPlugins* m_Plugins; // Objects - TPlugins::TImage::Pointer m_MainImage; - std::vector< TPlugins::TMesh::Pointer > m_Meshes; + typedef std::pair< std::string, TPlugins::TDataObject::Pointer > TTreeNode; + typedef std::map< std::string, TTreeNode > TTree; + TTree m_Objects; // Plugins objects /* diff --git a/appli/ImageMPR/ImageMPR.ui b/appli/ImageMPR/ImageMPR.ui index d37cab6..26dfe1e 100644 --- a/appli/ImageMPR/ImageMPR.ui +++ b/appli/ImageMPR/ImageMPR.ui @@ -22,7 +22,14 @@ - + + + + 562 + 406 + + + @@ -182,9 +189,9 @@ - cpPlugins::Interface::BaseMPRWindow - QFrame -
cpPlugins/Interface/BaseMPRWindow.h
+ cpPlugins::Interface::BaseMPRWidget + QWidget +
cpPlugins/Interface/BaseMPRWidget.h
1
diff --git a/appli/examples/CMakeLists.txt b/appli/examples/CMakeLists.txt index 5d197de..02733df 100644 --- a/appli/examples/CMakeLists.txt +++ b/appli/examples/CMakeLists.txt @@ -5,7 +5,6 @@ SET( EXAMPLES_PROGRAMS_ONLY_EXTENSIONS - #example_TestQuadSplitter ) FOREACH(prog ${EXAMPLES_PROGRAMS_ONLY_EXTENSIONS}) diff --git a/appli/examples/example_TestQuadSplitter.cxx b/appli/examples/example_TestQuadSplitter.cxx deleted file mode 100644 index e1c9d1b..0000000 --- a/appli/examples/example_TestQuadSplitter.cxx +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include -#include - -int main( int argc, char* argv[] ) -{ - int ret = 0; -#ifdef cpExtensions_Interface_QT4 - QApplication app( argc, argv ); - - QTextEdit* t1 = new QTextEdit; - QTextEdit* t2 = new QTextEdit; - QTextEdit* t3 = new QTextEdit; - QTextEdit* t4 = new QTextEdit; - - cpExtensions::QT::QuadSplitter quadSplit; - quadSplit.addWidgets( t1, t2, t3, t4 ); - quadSplit.show( ); - ret = app.exec( ); -#endif // cpExtensions_Interface_QT4 - return( ret ); -} - -// eof - $RCSfile$ diff --git a/lib/cpExtensions/Interaction/BaseInteractorStyle.cxx b/lib/cpExtensions/Interaction/BaseInteractorStyle.cxx index a384eb0..7cc7178 100644 --- a/lib/cpExtensions/Interaction/BaseInteractorStyle.cxx +++ b/lib/cpExtensions/Interaction/BaseInteractorStyle.cxx @@ -18,231 +18,6 @@ SetSetDoubleClickDelay( long delay ) Self::_TMouseButtonEvent::MaxDoubleClick = delay; } -// ------------------------------------------------------------------------- -void cpExtensions::Interaction::BaseInteractorStyle:: -AddMouseMoveCommand( TMouseCommand command, void* data ) -{ - if( command != NULL ) - { - this->m_MouseMoveCommands[ command ] = data; - this->Modified( ); - - } // fi -} - -// ------------------------------------------------------------------------- -void cpExtensions::Interaction::BaseInteractorStyle:: -AddMouseClickCommand( TMouseCommand command, void* data ) -{ - if( command != NULL ) - { - this->m_MouseClickCommands[ command ] = data; - this->Modified( ); - - } // fi -} - -// ------------------------------------------------------------------------- -void cpExtensions::Interaction::BaseInteractorStyle:: -AddMouseDoubleClickCommand( TMouseCommand command, void* data ) -{ - if( command != NULL ) - { - this->m_MouseDoubleClickCommands[ command ] = data; - this->Modified( ); - - } // fi -} - -// ------------------------------------------------------------------------- -void cpExtensions::Interaction::BaseInteractorStyle:: -AddMouseWheelCommand( TMouseWheelCommand command, void* data ) -{ - if( command != NULL ) - { - this->m_MouseWheelCommands[ command ] = data; - this->Modified( ); - - } // fi -} - -// ------------------------------------------------------------------------- -void cpExtensions::Interaction::BaseInteractorStyle:: -AddKeyCommand( TKeyCommand command, void* data ) -{ - if( command != NULL ) - { - this->m_KeyCommands[ command ] = data; - this->Modified( ); - - } // fi -} - -// ------------------------------------------------------------------------- -void cpExtensions::Interaction::BaseInteractorStyle:: -AddExposeCommand( TVoidCommand command, void* data ) -{ - if( command != NULL ) - { - this->m_ExposeCommands[ command ] = data; - this->Modified( ); - - } // fi -} - -// ------------------------------------------------------------------------- -void cpExtensions::Interaction::BaseInteractorStyle:: -AddConfigureCommand( TVoidCommand command, void* data ) -{ - if( command != NULL ) - { - this->m_ConfigureCommands[ command ] = data; - this->Modified( ); - - } // fi -} - -// ------------------------------------------------------------------------- -void cpExtensions::Interaction::BaseInteractorStyle:: -AddEnterCommand( TVoidCommand command, void* data ) -{ - if( command != NULL ) - { - this->m_EnterCommands[ command ] = data; - this->Modified( ); - - } // fi -} - -// ------------------------------------------------------------------------- -void cpExtensions::Interaction::BaseInteractorStyle:: -AddLeaveCommand( TVoidCommand command, void* data ) -{ - if( command != NULL ) - { - this->m_LeaveCommands[ command ] = data; - this->Modified( ); - - } // fi -} - -// ------------------------------------------------------------------------- -void cpExtensions::Interaction::BaseInteractorStyle:: -RemoveMouseMoveCommand( TMouseCommand command ) -{ - auto i = this->m_MouseMoveCommands.find( command ); - if( i != this->m_MouseMoveCommands.end( ) ) - { - this->m_MouseMoveCommands.erase( i ); - this->Modified( ); - - } // fi -} - -// ------------------------------------------------------------------------- -void cpExtensions::Interaction::BaseInteractorStyle:: -RemoveMouseClickCommand( TMouseCommand command ) -{ - auto i = this->m_MouseClickCommands.find( command ); - if( i != this->m_MouseClickCommands.end( ) ) - { - this->m_MouseClickCommands.erase( i ); - this->Modified( ); - - } // fi -} - -// ------------------------------------------------------------------------- -void cpExtensions::Interaction::BaseInteractorStyle:: -RemoveMouseDoubleClickCommand( TMouseCommand command ) -{ - auto i = this->m_MouseDoubleClickCommands.find( command ); - if( i != this->m_MouseDoubleClickCommands.end( ) ) - { - this->m_MouseDoubleClickCommands.erase( i ); - this->Modified( ); - - } // fi -} - -// ------------------------------------------------------------------------- -void cpExtensions::Interaction::BaseInteractorStyle:: -RemoveMouseWheelCommand( TMouseWheelCommand command ) -{ - auto i = this->m_MouseWheelCommands.find( command ); - if( i != this->m_MouseWheelCommands.end( ) ) - { - this->m_MouseWheelCommands.erase( i ); - this->Modified( ); - - } // fi -} - -// ------------------------------------------------------------------------- -void cpExtensions::Interaction::BaseInteractorStyle:: -RemoveKeyCommand( TKeyCommand command ) -{ - auto i = this->m_KeyCommands.find( command ); - if( i != this->m_KeyCommands.end( ) ) - { - this->m_KeyCommands.erase( i ); - this->Modified( ); - - } // fi -} - -// ------------------------------------------------------------------------- -void cpExtensions::Interaction::BaseInteractorStyle:: -RemoveExposeCommand( TVoidCommand command ) -{ - auto i = this->m_ExposeCommands.find( command ); - if( i != this->m_ExposeCommands.end( ) ) - { - this->m_ExposeCommands.erase( i ); - this->Modified( ); - - } // fi -} - -// ------------------------------------------------------------------------- -void cpExtensions::Interaction::BaseInteractorStyle:: -RemoveConfigureCommand( TVoidCommand command ) -{ - auto i = this->m_ConfigureCommands.find( command ); - if( i != this->m_ConfigureCommands.end( ) ) - { - this->m_ConfigureCommands.erase( i ); - this->Modified( ); - - } // fi -} - -// ------------------------------------------------------------------------- -void cpExtensions::Interaction::BaseInteractorStyle:: -RemoveEnterCommand( TVoidCommand command ) -{ - auto i = this->m_EnterCommands.find( command ); - if( i != this->m_EnterCommands.end( ) ) - { - this->m_EnterCommands.erase( i ); - this->Modified( ); - - } // fi -} - -// ------------------------------------------------------------------------- -void cpExtensions::Interaction::BaseInteractorStyle:: -RemoveLeaveCommand( TVoidCommand command ) -{ - auto i = this->m_LeaveCommands.find( command ); - if( i != this->m_LeaveCommands.end( ) ) - { - this->m_LeaveCommands.erase( i ); - this->Modified( ); - - } // fi -} - // ------------------------------------------------------------------------- void cpExtensions::Interaction::BaseInteractorStyle:: DelegateTDxEvent( unsigned long event, void* calldata ) @@ -451,172 +226,35 @@ OnRightButtonUp( ) } // ------------------------------------------------------------------------- -void cpExtensions::Interaction::BaseInteractorStyle:: -OnLeftClick( ) -{ - // Get current position on the associated actors - vtkRenderWindowInteractor* rwi = this->GetInteractor( ); - if( rwi == NULL ) - return; - - // Get mouse pointer position - static int idx[ 2 ]; - static double pos[ 3 ]; - if( !( this->_PickPosition( idx, pos ) ) ) - return; - - // Invoke possible events - auto i = this->m_MouseClickCommands.begin( ); - for( ; i != this->m_MouseClickCommands.end( ); ++i ) - i->first( - i->second, - Self::ButtonID_Left, - idx, pos, - rwi->GetAltKey( ) == 1, - rwi->GetControlKey( ) == 1, - rwi->GetShiftKey( ) == 1 - ); -} - -// ------------------------------------------------------------------------- -void cpExtensions::Interaction::BaseInteractorStyle:: -OnLeftDoubleClick( ) -{ - // Get current position on the associated actors - vtkRenderWindowInteractor* rwi = this->GetInteractor( ); - if( rwi == NULL ) - return; - - // Get mouse pointer position - static int idx[ 2 ]; - static double pos[ 3 ]; - if( !( this->_PickPosition( idx, pos ) ) ) - return; - - // Invoke possible events - auto i = this->m_MouseDoubleClickCommands.begin( ); - for( ; i != this->m_MouseDoubleClickCommands.end( ); ++i ) - i->first( - i->second, - Self::ButtonID_Left, - idx, pos, - rwi->GetAltKey( ) == 1, - rwi->GetControlKey( ) == 1, - rwi->GetShiftKey( ) == 1 - ); -} - -// ------------------------------------------------------------------------- -void cpExtensions::Interaction::BaseInteractorStyle:: -OnMiddleClick( ) -{ - // Get current position on the associated actors - vtkRenderWindowInteractor* rwi = this->GetInteractor( ); - if( rwi == NULL ) - return; - - // Get mouse pointer position - static int idx[ 2 ]; - static double pos[ 3 ]; - if( !( this->_PickPosition( idx, pos ) ) ) - return; - - // Invoke possible events - auto i = this->m_MouseClickCommands.begin( ); - for( ; i != this->m_MouseClickCommands.end( ); ++i ) - i->first( - i->second, - Self::ButtonID_Middle, - idx, pos, - rwi->GetAltKey( ) == 1, - rwi->GetControlKey( ) == 1, - rwi->GetShiftKey( ) == 1 - ); -} - -// ------------------------------------------------------------------------- -void cpExtensions::Interaction::BaseInteractorStyle:: -OnMiddleDoubleClick( ) -{ - // Get current position on the associated actors - vtkRenderWindowInteractor* rwi = this->GetInteractor( ); - if( rwi == NULL ) - return; - - // Get mouse pointer position - static int idx[ 2 ]; - static double pos[ 3 ]; - if( !( this->_PickPosition( idx, pos ) ) ) - return; - - // Invoke possible events - auto i = this->m_MouseDoubleClickCommands.begin( ); - for( ; i != this->m_MouseDoubleClickCommands.end( ); ++i ) - i->first( - i->second, - Self::ButtonID_Middle, - idx, pos, - rwi->GetAltKey( ) == 1, - rwi->GetControlKey( ) == 1, - rwi->GetShiftKey( ) == 1 - ); -} - -// ------------------------------------------------------------------------- -void cpExtensions::Interaction::BaseInteractorStyle:: -OnRightClick( ) -{ - // Get current position on the associated actors - vtkRenderWindowInteractor* rwi = this->GetInteractor( ); - if( rwi == NULL ) - return; - - // Get mouse pointer position - static int idx[ 2 ]; - static double pos[ 3 ]; - if( !( this->_PickPosition( idx, pos ) ) ) - return; - - // Invoke possible events - auto i = this->m_MouseClickCommands.begin( ); - for( ; i != this->m_MouseClickCommands.end( ); ++i ) - i->first( - i->second, - Self::ButtonID_Right, - idx, pos, - rwi->GetAltKey( ) == 1, - rwi->GetControlKey( ) == 1, - rwi->GetShiftKey( ) == 1 - ); -} - -// ------------------------------------------------------------------------- -void cpExtensions::Interaction::BaseInteractorStyle:: -OnRightDoubleClick( ) -{ - // Get current position on the associated actors - vtkRenderWindowInteractor* rwi = this->GetInteractor( ); - if( rwi == NULL ) - return; - - // Get mouse pointer position - static int idx[ 2 ]; - static double pos[ 3 ]; - if( !( this->_PickPosition( idx, pos ) ) ) - return; +#define cpExtensions_BaseInteractorStyle_Click( S, T ) \ + void cpExtensions::Interaction::BaseInteractorStyle:: \ + On##S##T( ) \ + { \ + vtkRenderWindowInteractor* rwi = this->GetInteractor( ); \ + if( rwi == NULL ) \ + return; \ + static int idx[ 2 ]; \ + static double pos[ 3 ]; \ + if( !( this->_PickPosition( idx, pos ) ) ) \ + return; \ + auto i = this->m_Mouse##T##Commands.begin( ); \ + for( ; i != this->m_Mouse##T##Commands.end( ); ++i ) \ + i->first( \ + i->second, \ + Self::ButtonID_##S, \ + idx, pos, \ + rwi->GetAltKey( ) == 1, \ + rwi->GetControlKey( ) == 1, \ + rwi->GetShiftKey( ) == 1 \ + ); \ + } - // Invoke possible events - auto i = this->m_MouseDoubleClickCommands.begin( ); - for( ; i != this->m_MouseDoubleClickCommands.end( ); ++i ) - i->first( - i->second, - Self::ButtonID_Right, - idx, pos, - rwi->GetAltKey( ) == 1, - rwi->GetControlKey( ) == 1, - rwi->GetShiftKey( ) == 1 - ); -} +cpExtensions_BaseInteractorStyle_Click( Left, Click ); +cpExtensions_BaseInteractorStyle_Click( Middle, Click ); +cpExtensions_BaseInteractorStyle_Click( Right, Click ); +cpExtensions_BaseInteractorStyle_Click( Left, DoubleClick ); +cpExtensions_BaseInteractorStyle_Click( Middle, DoubleClick ); +cpExtensions_BaseInteractorStyle_Click( Right, DoubleClick ); // ------------------------------------------------------------------------- void cpExtensions::Interaction::BaseInteractorStyle:: @@ -633,84 +271,22 @@ OnChar( ) } // ------------------------------------------------------------------------- -void cpExtensions::Interaction::BaseInteractorStyle:: -OnKeyDown( ) -{ -} - -// ------------------------------------------------------------------------- -void cpExtensions::Interaction::BaseInteractorStyle:: -OnKeyUp( ) -{ -} - -// ------------------------------------------------------------------------- -void cpExtensions::Interaction::BaseInteractorStyle:: -OnKeyPress( ) -{ -} - -// ------------------------------------------------------------------------- -void cpExtensions::Interaction::BaseInteractorStyle:: -OnKeyRelease( ) -{ -} - -// ------------------------------------------------------------------------- -void cpExtensions::Interaction::BaseInteractorStyle:: -OnExpose( ) -{ - vtkRenderWindowInteractor* rwi = this->GetInteractor( ); - if( rwi == NULL ) - return; - - // Invoke possible events - auto i = this->m_ExposeCommands.begin( ); - for( ; i != this->m_ExposeCommands.end( ); ++i ) - i->first( i->second ); -} - -// ------------------------------------------------------------------------- -void cpExtensions::Interaction::BaseInteractorStyle:: -OnConfigure( ) -{ - vtkRenderWindowInteractor* rwi = this->GetInteractor( ); - if( rwi == NULL ) - return; - - // Invoke possible events - auto i = this->m_ConfigureCommands.begin( ); - for( ; i != this->m_ConfigureCommands.end( ); ++i ) - i->first( i->second ); -} - -// ------------------------------------------------------------------------- -void cpExtensions::Interaction::BaseInteractorStyle:: -OnEnter( ) -{ - vtkRenderWindowInteractor* rwi = this->GetInteractor( ); - if( rwi == NULL ) - return; - - // Invoke possible events - auto i = this->m_EnterCommands.begin( ); - for( ; i != this->m_EnterCommands.end( ); ++i ) - i->first( i->second ); -} - -// ------------------------------------------------------------------------- -void cpExtensions::Interaction::BaseInteractorStyle:: -OnLeave( ) -{ - vtkRenderWindowInteractor* rwi = this->GetInteractor( ); - if( rwi == NULL ) - return; +#define cpExtensions_BaseInteractorStyle_Global( N ) \ + void cpExtensions::Interaction::BaseInteractorStyle:: \ + On##N( ) \ + { \ + vtkRenderWindowInteractor* rwi = this->GetInteractor( ); \ + if( rwi == NULL ) \ + return; \ + auto i = this->m_##N##Commands.begin( ); \ + for( ; i != this->m_##N##Commands.end( ); ++i ) \ + i->first( i->second ); \ + } - // Invoke possible events - auto i = this->m_LeaveCommands.begin( ); - for( ; i != this->m_LeaveCommands.end( ); ++i ) - i->first( i->second ); -} +cpExtensions_BaseInteractorStyle_Global( Expose ); +cpExtensions_BaseInteractorStyle_Global( Configure ); +cpExtensions_BaseInteractorStyle_Global( Enter ); +cpExtensions_BaseInteractorStyle_Global( Leave ); // ------------------------------------------------------------------------- void cpExtensions::Interaction::BaseInteractorStyle:: diff --git a/lib/cpExtensions/Interaction/BaseInteractorStyle.h b/lib/cpExtensions/Interaction/BaseInteractorStyle.h index 1501f00..119668b 100644 --- a/lib/cpExtensions/Interaction/BaseInteractorStyle.h +++ b/lib/cpExtensions/Interaction/BaseInteractorStyle.h @@ -15,6 +15,30 @@ * ========================================================================= */ +// ------------------------------------------------------------------------- +#define cpExtensions_BaseInteractorStyle_Commands( C ) \ + protected: \ + std::map< T##C##Command, void* > m_##C##Commands; \ +public: \ + inline void Add##C##Command( T##C##Command c, void* d ) \ + { \ + if( c != NULL ) \ + { \ + this->m_##C##Commands[ c ] = d; \ + this->Modified( ); \ + } \ + } \ + inline void Remove##C##Command( T##C##Command c ) \ + { \ + std::map< T##C##Command, void* >::iterator i = \ + this->m_##C##Commands.find( c ); \ + if( i != this->m_##C##Commands.end( ) ) \ + { \ + this->m_##C##Commands.erase( i ); \ + this->Modified( ); \ + } \ + } + // ------------------------------------------------------------------------- #define BaseInteractorStyle_DIFF_TIME \ std::chrono::duration_cast< std::chrono::milliseconds >( \ @@ -49,31 +73,27 @@ namespace cpExtensions typedef void ( *TMouseWheelCommand )( void*, const int&, bool, bool, bool ); typedef void ( *TKeyCommand )( void*, const char& ); typedef void ( *TVoidCommand )( void* ); - - public: - static void SetSetDoubleClickDelay( long delay ); + typedef TMouseCommand TMouseMoveCommand; + typedef TMouseCommand TMouseClickCommand; + typedef TMouseCommand TMouseDoubleClickCommand; + typedef TVoidCommand TExposeCommand; + typedef TVoidCommand TConfigureCommand; + typedef TVoidCommand TEnterCommand; + typedef TVoidCommand TLeaveCommand; // Associate callbacks for each event - void AddMouseMoveCommand( TMouseCommand command, void* data ); - void AddMouseClickCommand( TMouseCommand command, void* data ); - void AddMouseDoubleClickCommand( TMouseCommand command, void* data ); - void AddMouseWheelCommand( TMouseWheelCommand command, void* data ); - void AddKeyCommand( TKeyCommand command, void* data ); - void AddExposeCommand( TVoidCommand command, void* data ); - void AddConfigureCommand( TVoidCommand command, void* data ); - void AddEnterCommand( TVoidCommand command, void* data ); - void AddLeaveCommand( TVoidCommand command, void* data ); - - void RemoveMouseMoveCommand( TMouseCommand command ); - void RemoveMouseClickCommand( TMouseCommand command ); - void RemoveMouseDoubleClickCommand( TMouseCommand command ); - void RemoveMouseWheelCommand( TMouseWheelCommand command ); - void RemoveKeyCommand( TKeyCommand command ); - void RemoveExposeCommand( TVoidCommand command ); - void RemoveConfigureCommand( TVoidCommand command ); - void RemoveEnterCommand( TVoidCommand command ); - void RemoveLeaveCommand( TVoidCommand command ); + cpExtensions_BaseInteractorStyle_Commands( MouseMove ); + cpExtensions_BaseInteractorStyle_Commands( MouseClick ); + cpExtensions_BaseInteractorStyle_Commands( MouseDoubleClick ); + cpExtensions_BaseInteractorStyle_Commands( MouseWheel ); + cpExtensions_BaseInteractorStyle_Commands( Key ); + cpExtensions_BaseInteractorStyle_Commands( Expose ); + cpExtensions_BaseInteractorStyle_Commands( Configure ); + cpExtensions_BaseInteractorStyle_Commands( Enter ); + cpExtensions_BaseInteractorStyle_Commands( Leave ); + public: + static void SetSetDoubleClickDelay( long delay ); void DelegateTDxEvent( unsigned long event, void* calldata ); // Possible mouse motion events @@ -103,10 +123,10 @@ namespace cpExtensions // Keyboard-related events virtual void OnChar( ); - virtual void OnKeyDown( ); - virtual void OnKeyUp( ); - virtual void OnKeyPress( ); - virtual void OnKeyRelease( ); + virtual void OnKeyDown( ) { } + virtual void OnKeyUp( ) { } + virtual void OnKeyPress( ) { } + virtual void OnKeyRelease( ) { } // Other events virtual void OnExpose( ); @@ -142,17 +162,6 @@ namespace cpExtensions protected: double m_MotionFactor; - // Callbacks - std::map< TMouseCommand, void* > m_MouseMoveCommands; - std::map< TMouseCommand, void* > m_MouseClickCommands; - std::map< TMouseCommand, void* > m_MouseDoubleClickCommands; - std::map< TMouseWheelCommand, void* > m_MouseWheelCommands; - std::map< TKeyCommand, void* > m_KeyCommands; - std::map< TVoidCommand, void* > m_ExposeCommands; - std::map< TVoidCommand, void* > m_ConfigureCommands; - std::map< TVoidCommand, void* > m_EnterCommands; - std::map< TVoidCommand, void* > m_LeaveCommands; - /** * Button events */ diff --git a/lib/cpExtensions/Interaction/ImageInteractorStyle.h b/lib/cpExtensions/Interaction/ImageInteractorStyle.h index 78bf7da..7664c13 100644 --- a/lib/cpExtensions/Interaction/ImageInteractorStyle.h +++ b/lib/cpExtensions/Interaction/ImageInteractorStyle.h @@ -24,6 +24,19 @@ namespace cpExtensions typedef ImageInteractorStyle Self; vtkTypeMacro( ImageInteractorStyle, BaseInteractorStyle ); + // Callbacks types + typedef Superclass::TMouseCommand TMouseCommand; + typedef Superclass::TMouseWheelCommand TMouseWheelCommand; + typedef Superclass::TKeyCommand TKeyCommand; + typedef Superclass::TVoidCommand TVoidCommand; + typedef Superclass::TMouseMoveCommand TMouseMoveCommand; + typedef Superclass::TMouseClickCommand TMouseClickCommand; + typedef Superclass::TMouseDoubleClickCommand TMouseDoubleClickCommand; + typedef Superclass::TExposeCommand TExposeCommand; + typedef Superclass::TConfigureCommand TConfigureCommand; + typedef Superclass::TEnterCommand TEnterCommand; + typedef Superclass::TLeaveCommand TLeaveCommand; + public: static Self* New( ); diff --git a/lib/cpExtensions/QT/QuadSplitter.cxx b/lib/cpExtensions/QT/QuadSplitter.cxx deleted file mode 100644 index 6713180..0000000 --- a/lib/cpExtensions/QT/QuadSplitter.cxx +++ /dev/null @@ -1,63 +0,0 @@ -#include - -#include - -#ifdef cpExtensions_Interface_QT4 - -/** - * Inspired by: - * https://forum.qt.io/topic/7144/quad-splitter-windows-an-implementation/2 - */ - -// ------------------------------------------------------------------------- -cpExtensions::QT::QuadSplitter:: -QuadSplitter( QWidget* parent ) - : QSplitter( parent ) -{ - this->setOrientation( Qt::Vertical ); - this->addWidget( &this->m_Upper ); - this->addWidget( &this->m_Bottom ); - - QObject::connect( - &( this->m_Upper ), SIGNAL( splitterMoved( int, int ) ), - this, SLOT( _SyncBottom( int, int ) ) - ); - QObject::connect( - &( this->m_Bottom ), SIGNAL( splitterMoved( int, int ) ), - this, SLOT( _SyncUpper( int, int ) ) - ); -} - -// ------------------------------------------------------------------------- -cpExtensions::QT::QuadSplitter:: -~QuadSplitter( ) -{ -} - -// ------------------------------------------------------------------------- -void cpExtensions::QT::QuadSplitter:: -addWidgets( QWidget* a, QWidget* b, QWidget* c, QWidget* d ) -{ - this->m_Upper.addWidget( a ); - this->m_Upper.addWidget( b ); - this->m_Bottom.addWidget( c ); - this->m_Bottom.addWidget( d ); -} - -// ------------------------------------------------------------------------- -void cpExtensions::QT::QuadSplitter:: -_SyncBottom( int a, int b ) -{ - this->m_Bottom.setSizes( this->m_Upper.sizes( ) ); -} - -// ------------------------------------------------------------------------- -void cpExtensions::QT::QuadSplitter:: -_SyncUpper( int a, int b ) -{ - this->m_Upper.setSizes( this->m_Bottom.sizes( ) ); -} - -#endif // cpExtensions_Interface_QT4 - -// eof - $RCSfile$ diff --git a/lib/cpExtensions/QT/QuadSplitter.h b/lib/cpExtensions/QT/QuadSplitter.h deleted file mode 100644 index 7c27509..0000000 --- a/lib/cpExtensions/QT/QuadSplitter.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef __CPEXTENSIONS__QT__QUADSPLITTER__H__ -#define __CPEXTENSIONS__QT__QUADSPLITTER__H__ - -#include -#include - -#ifdef cpExtensions_Interface_QT4 - -/** - * Inspired by: - * https://forum.qt.io/topic/7144/quad-splitter-windows-an-implementation/2 - */ - -#include - -namespace cpExtensions -{ - namespace QT - { - /** - */ - class cpExtensions_EXPORT QuadSplitter - : public QSplitter - { - Q_OBJECT; - - public: - QuadSplitter( QWidget* parent = 0 ); - virtual ~QuadSplitter( ); - - void addWidgets( QWidget* a, QWidget* b, QWidget* c, QWidget* d ); - - private slots: - void _SyncBottom( int a, int b ); - void _SyncUpper( int a, int b ); - - protected: - QSplitter m_Bottom; - QSplitter m_Upper; - }; - - } // ecapseman - -} // ecapseman - -#endif // cpExtensions_Interface_QT4 - -#endif // __CPEXTENSIONS__QT__QUADSPLITTER__H__ - -// eof - $RCSfile$ diff --git a/lib/cpExtensions/Visualization/ImageSliceActors.cxx b/lib/cpExtensions/Visualization/ImageSliceActors.cxx index 1048121..e3a2ff0 100644 --- a/lib/cpExtensions/Visualization/ImageSliceActors.cxx +++ b/lib/cpExtensions/Visualization/ImageSliceActors.cxx @@ -27,81 +27,6 @@ New( ) return( new Self( ) ); } -// ------------------------------------------------------------------------- -void cpExtensions::Visualization::ImageSliceActors:: -AddSlicesCommand( TSlicesCommand command, void* data ) -{ - if( command != NULL ) - { - this->m_SlicesCommands[ command ] = data; - this->Modified( ); - - } // fi -} - -// ------------------------------------------------------------------------- -void cpExtensions::Visualization::ImageSliceActors:: -AddWindowLevelCommand( TWindowLevelCommand command, void* data ) -{ - if( command != NULL ) - { - this->m_WindowLevelCommands[ command ] = data; - this->Modified( ); - - } // fi -} - -// ------------------------------------------------------------------------- -void cpExtensions::Visualization::ImageSliceActors:: -AddRenderCommand( TVoidCommand command, void* data ) -{ - if( command != NULL ) - { - this->m_RenderCommands[ command ] = data; - this->Modified( ); - - } // fi -} - -// ------------------------------------------------------------------------- -void cpExtensions::Visualization::ImageSliceActors:: -RemoveSlicesCommand( TSlicesCommand command ) -{ - auto i = this->m_SlicesCommands.find( command ); - if( i != this->m_SlicesCommands.end( ) ) - { - this->m_SlicesCommands.erase( i ); - this->Modified( ); - - } // fi -} - -// ------------------------------------------------------------------------- -void cpExtensions::Visualization::ImageSliceActors:: -RemoveWindowLevelCommand( TWindowLevelCommand command ) -{ - auto i = this->m_WindowLevelCommands.find( command ); - if( i != this->m_WindowLevelCommands.end( ) ) - { - this->m_WindowLevelCommands.erase( i ); - this->Modified( ); - - } // fi -} - -// ------------------------------------------------------------------------- -void cpExtensions::Visualization::ImageSliceActors:: -RemoveRenderCommand( TVoidCommand command ) -{ - auto i = this->m_RenderCommands.find( command ); - if( i != this->m_RenderCommands.end( ) ) - { - this->m_RenderCommands.erase( i ); - this->Modified( ); - - } // fi -} - // ------------------------------------------------------------------------- void cpExtensions::Visualization::ImageSliceActors:: AddInputConnection( vtkAlgorithmOutput* aout, int axis ) @@ -1103,10 +1028,17 @@ UpdateText( const double& w, const double& l ) // ------------------------------------------------------------------------- void cpExtensions::Visualization::ImageSliceActors:: -Render( ) +Render( const double& t ) { if( this->m_Window != NULL ) + { + vtkRenderer* renderer = + this->m_Window->GetRenderers( )->GetFirstRenderer( ); + if( renderer != NULL ) + renderer->SetAllocatedRenderTime( t ); this->m_Window->Render( ); + + } // fi } // ------------------------------------------------------------------------- @@ -1236,7 +1168,7 @@ _MouseMoveCommand( // Just show the pixel information actors->SetCursor( pos ); actors->UpdateText( pos ); - actors->Render( ); + actors->Render( 1e-3 ); } else if( btn == TStyle::ButtonID_Left ) { @@ -1246,7 +1178,7 @@ _MouseMoveCommand( auto i = actors->m_SlicesCommands.begin( ); for( ; i != actors->m_SlicesCommands.end( ); ++i ) i->first( pos, actors->GetAxis( ), i->second ); - actors->Render( ); + actors->Render( 1e-3 ); } // fi } @@ -1271,7 +1203,7 @@ _MouseMoveCommand( dx += actors->m_StartWindowLevel[ 0 ]; dy += actors->m_StartWindowLevel[ 1 ]; actors->SetWindowLevel( dx, dy ); - actors->Render( ); + actors->Render( 1e-3 ); // Associate objects auto i = actors->m_WindowLevelCommands.begin( ); @@ -1325,10 +1257,10 @@ _MouseWheelCommand( for( ; a != actors->m_AssociatedSlices.end( ); ++a ) { ( *a )->SetSliceNumber( slice ); - ( *a )->Render( ); + ( *a )->Render( 1e-3 ); } // rof - actors->Render( ); + actors->Render( 1e-3 ); // Associate objects auto i = actors->m_RenderCommands.begin( ); @@ -1351,7 +1283,7 @@ _KeyCommand( void* data, const char& key ) case 'r': case 'R': { actors->ResetCamera( ); - actors->Render( ); + actors->Render( 1e-3 ); // Associate objects auto i = actors->m_RenderCommands.begin( ); @@ -1362,7 +1294,7 @@ _KeyCommand( void* data, const char& key ) case 'w': case 'W': { actors->ResetWindowLevel( ); - actors->Render( ); + actors->Render( 1e-3 ); // Associate objects auto i = actors->m_RenderCommands.begin( ); @@ -1385,7 +1317,7 @@ _EnterCommand( void* data ) actors->ResetCursor( ); actors->m_CursorActor->VisibilityOn( ); - actors->Render( ); + actors->Render( 1e-3 ); } // ------------------------------------------------------------------------- @@ -1398,7 +1330,7 @@ _LeaveCommand( void* data ) actors->ResetCursor( ); actors->m_CursorActor->VisibilityOff( ); - actors->Render( ); + actors->Render( 1e-3 ); } // eof - $RCSfile$ diff --git a/lib/cpExtensions/Visualization/ImageSliceActors.h b/lib/cpExtensions/Visualization/ImageSliceActors.h index c5165c5..c5113ad 100644 --- a/lib/cpExtensions/Visualization/ImageSliceActors.h +++ b/lib/cpExtensions/Visualization/ImageSliceActors.h @@ -38,30 +38,33 @@ namespace cpExtensions public: typedef ImageSliceActors Self; - typedef cpExtensions::Interaction::BaseInteractorStyle TBaseStyle; typedef cpExtensions::Interaction::ImageInteractorStyle TStyle; + typedef TStyle::TMouseCommand TMouseCommand; + typedef TStyle::TMouseWheelCommand TMouseWheelCommand; + typedef TStyle::TKeyCommand TKeyCommand; + typedef TStyle::TVoidCommand TVoidCommand; + typedef TStyle::TMouseMoveCommand TMouseMoveCommand; + typedef TStyle::TMouseClickCommand TMouseClickCommand; + typedef TStyle::TMouseDoubleClickCommand TMouseDoubleClickCommand; + typedef TStyle::TExposeCommand TExposeCommand; + typedef TStyle::TConfigureCommand TConfigureCommand; + typedef TStyle::TEnterCommand TEnterCommand; + typedef TStyle::TLeaveCommand TLeaveCommand; typedef void ( *TSlicesCommand )( double*, int, void* ); typedef void ( *TWindowLevelCommand )( double, double, void* ); - typedef TBaseStyle::TMouseCommand TMouseCommand; - typedef TBaseStyle::TMouseWheelCommand TMouseWheelCommand; - typedef TBaseStyle::TKeyCommand TKeyCommand; - typedef TBaseStyle::TVoidCommand TVoidCommand; + typedef TVoidCommand TRenderCommand; public: vtkTypeMacro( ImageSliceActors, vtkPropCollection ); + cpExtensions_BaseInteractorStyle_Commands( Slices ); + cpExtensions_BaseInteractorStyle_Commands( WindowLevel ); + cpExtensions_BaseInteractorStyle_Commands( Render ); + public: // Creation static ImageSliceActors* New( ); - void AddSlicesCommand( TSlicesCommand command, void* data ); - void AddWindowLevelCommand( TWindowLevelCommand command, void* data ); - void AddRenderCommand( TVoidCommand command, void* data ); - - void RemoveSlicesCommand( TSlicesCommand command ); - void RemoveWindowLevelCommand( TWindowLevelCommand command ); - void RemoveRenderCommand( TVoidCommand command ); - void AddInputConnection( vtkAlgorithmOutput* aout, int axis = 2 ); void AddInputData( vtkImageData* data, int axis = 2 ); void Clear( ); @@ -125,7 +128,7 @@ namespace cpExtensions void UpdateText( double pos[ 3 ] ); void UpdateText( const double& w, const double& l ); - void Render( ); + void Render( const double& t ); void ResetCamera( ); protected: @@ -139,13 +142,13 @@ namespace cpExtensions // Events static void _MouseMoveCommand( void* data, - const TBaseStyle::ButtonID& btn, + const TStyle::ButtonID& btn, int* idx, double* pos, bool alt, bool ctr, bool sft ); static void _MouseClickCommand( void* data, - const TBaseStyle::ButtonID& btn, + const TStyle::ButtonID& btn, int* idx, double* pos, bool alt, bool ctr, bool sft ); @@ -182,11 +185,6 @@ namespace cpExtensions double m_MinWindow, m_MaxWindow; double m_MinLevel, m_MaxLevel; - // Associated commands - std::map< TSlicesCommand, void* > m_SlicesCommands; - std::map< TWindowLevelCommand, void* > m_WindowLevelCommands; - std::map< TVoidCommand, void* > m_RenderCommands; - // Unique objects vtkSmartPointer< vtkPolyData > m_Cursor; vtkSmartPointer< vtkPolyDataMapper > m_CursorMapper; diff --git a/lib/cpExtensions/Visualization/MPRActors.cxx b/lib/cpExtensions/Visualization/MPRActors.cxx index 150651e..00d27dc 100644 --- a/lib/cpExtensions/Visualization/MPRActors.cxx +++ b/lib/cpExtensions/Visualization/MPRActors.cxx @@ -420,8 +420,8 @@ _SlicesCommand( double* pos, int axis, void* data ) { actors->Slices[ 0 ][ j ]->SetSlice( pos ); actors->Slices[ 1 ][ j ]->SetSlice( pos ); - actors->Slices[ 0 ][ j ]->Render( ); - actors->Slices[ 1 ][ j ]->Render( ); + actors->Slices[ 0 ][ j ]->Render( 1e-3 ); + actors->Slices[ 1 ][ j ]->Render( 1e-3 ); } // fi @@ -435,12 +435,12 @@ _WindowLevelCommand( double window, double level, void* data ) MPRActors* actors = reinterpret_cast< MPRActors* >( data ); if( actors == NULL ) return; - actors->Slices[ 0 ][ 0 ]->Render( ); - actors->Slices[ 0 ][ 1 ]->Render( ); - actors->Slices[ 0 ][ 2 ]->Render( ); - actors->Slices[ 1 ][ 0 ]->Render( ); - actors->Slices[ 1 ][ 1 ]->Render( ); - actors->Slices[ 1 ][ 2 ]->Render( ); + actors->Slices[ 0 ][ 0 ]->Render( 1e-3 ); + actors->Slices[ 0 ][ 1 ]->Render( 1e-3 ); + actors->Slices[ 0 ][ 2 ]->Render( 1e-3 ); + actors->Slices[ 1 ][ 0 ]->Render( 1e-3 ); + actors->Slices[ 1 ][ 1 ]->Render( 1e-3 ); + actors->Slices[ 1 ][ 2 ]->Render( 1e-3 ); } // ------------------------------------------------------------------------- @@ -450,12 +450,12 @@ _RenderCommand( void* data ) MPRActors* actors = reinterpret_cast< MPRActors* >( data ); if( actors == NULL ) return; - actors->Slices[ 0 ][ 0 ]->Render( ); - actors->Slices[ 0 ][ 1 ]->Render( ); - actors->Slices[ 0 ][ 2 ]->Render( ); - actors->Slices[ 1 ][ 0 ]->Render( ); - actors->Slices[ 1 ][ 1 ]->Render( ); - actors->Slices[ 1 ][ 2 ]->Render( ); + actors->Slices[ 0 ][ 0 ]->Render( 1e-3 ); + actors->Slices[ 0 ][ 1 ]->Render( 1e-3 ); + actors->Slices[ 0 ][ 2 ]->Render( 1e-3 ); + actors->Slices[ 1 ][ 0 ]->Render( 1e-3 ); + actors->Slices[ 1 ][ 1 ]->Render( 1e-3 ); + actors->Slices[ 1 ][ 2 ]->Render( 1e-3 ); } // eof - $RCSfile$ diff --git a/lib/cpExtensions/Visualization/MPRActors.h b/lib/cpExtensions/Visualization/MPRActors.h index 01066b4..fe8e43f 100644 --- a/lib/cpExtensions/Visualization/MPRActors.h +++ b/lib/cpExtensions/Visualization/MPRActors.h @@ -16,14 +16,18 @@ namespace cpExtensions public: typedef MPRActors Self; - typedef ImageSliceActors::TBaseStyle TBaseStyle; - typedef ImageSliceActors::TStyle TStyle; - typedef ImageSliceActors::TSlicesCommand TSlicesCommand; - typedef ImageSliceActors::TWindowLevelCommand TWindowLevelCommand; - typedef ImageSliceActors::TMouseCommand TMouseCommand; - typedef ImageSliceActors::TMouseWheelCommand TMouseWheelCommand; - typedef ImageSliceActors::TKeyCommand TKeyCommand; - typedef ImageSliceActors::TVoidCommand TVoidCommand; + typedef ImageSliceActors::TStyle TStyle; + typedef ImageSliceActors::TMouseCommand TMouseCommand; + typedef ImageSliceActors::TMouseWheelCommand TMouseWheelCommand; + typedef ImageSliceActors::TKeyCommand TKeyCommand; + typedef ImageSliceActors::TVoidCommand TVoidCommand; + typedef ImageSliceActors::TMouseMoveCommand TMouseMoveCommand; + typedef ImageSliceActors::TMouseClickCommand TMouseClickCommand; + typedef ImageSliceActors::TMouseDoubleClickCommand TMouseDoubleClickCommand; + typedef ImageSliceActors::TExposeCommand TExposeCommand; + typedef ImageSliceActors::TConfigureCommand TConfigureCommand; + typedef ImageSliceActors::TEnterCommand TEnterCommand; + typedef ImageSliceActors::TLeaveCommand TLeaveCommand; public: vtkTypeMacro( MPRActors, vtkPropCollection ); diff --git a/lib/cpExtensions/Visualization/MPRObjects.cxx b/lib/cpExtensions/Visualization/MPRObjects.cxx index 2a50c62..af0ad41 100644 --- a/lib/cpExtensions/Visualization/MPRObjects.cxx +++ b/lib/cpExtensions/Visualization/MPRObjects.cxx @@ -65,7 +65,7 @@ AddImage( vtkImageData* image ) this->ResetCameras( ); } // fi - this->RenderAll( ); + this->RenderAll( 1e-3 ); } // ------------------------------------------------------------------------- @@ -79,7 +79,7 @@ ClearAll( ) this->m_Windows[ 3 ] ); this->ResetCameras( ); - this->RenderAll( ); + this->RenderAll( 1e-3 ); } // ------------------------------------------------------------------------- @@ -102,20 +102,36 @@ ResetCameras( ) // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRObjects:: -Render( const int& id ) +Render( const int& id, const double& t ) { if( id < 4 ) + { if( this->m_Windows[ id ] != NULL ) + { + if( this->m_Renderers[ id ] != NULL ) + this->m_Renderers[ id ]->SetAllocatedRenderTime( t ); this->m_Windows[ id ]->Render( ); + + } // fi + + } // fi } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRObjects:: -RenderAll( ) +RenderAll( const double& t ) { for( int i = 0; i < 4; ++i ) + { if( this->m_Windows[ i ] != NULL ) + { + if( this->m_Renderers[ i ] != NULL ) + this->m_Renderers[ i ]->SetAllocatedRenderTime( t ); this->m_Windows[ i ]->Render( ); + + } // fi + + } // rof } // ------------------------------------------------------------------------- diff --git a/lib/cpExtensions/Visualization/MPRObjects.h b/lib/cpExtensions/Visualization/MPRObjects.h index 71741ef..8ac1cd2 100644 --- a/lib/cpExtensions/Visualization/MPRObjects.h +++ b/lib/cpExtensions/Visualization/MPRObjects.h @@ -20,14 +20,18 @@ namespace cpExtensions public: typedef MPRObjects Self; - typedef MPRActors::TBaseStyle TBaseStyle; - typedef MPRActors::TStyle TStyle; - typedef MPRActors::TSlicesCommand TSlicesCommand; - typedef MPRActors::TWindowLevelCommand TWindowLevelCommand; - typedef MPRActors::TMouseCommand TMouseCommand; - typedef MPRActors::TMouseWheelCommand TMouseWheelCommand; - typedef MPRActors::TKeyCommand TKeyCommand; - typedef MPRActors::TVoidCommand TVoidCommand; + typedef MPRActors::TStyle TStyle; + typedef MPRActors::TMouseCommand TMouseCommand; + typedef MPRActors::TMouseWheelCommand TMouseWheelCommand; + typedef MPRActors::TKeyCommand TKeyCommand; + typedef MPRActors::TVoidCommand TVoidCommand; + typedef MPRActors::TMouseMoveCommand TMouseMoveCommand; + typedef MPRActors::TMouseClickCommand TMouseClickCommand; + typedef MPRActors::TMouseDoubleClickCommand TMouseDoubleClickCommand; + typedef MPRActors::TExposeCommand TExposeCommand; + typedef MPRActors::TConfigureCommand TConfigureCommand; + typedef MPRActors::TEnterCommand TEnterCommand; + typedef MPRActors::TLeaveCommand TLeaveCommand; public: vtkTypeMacro( MPRObjects, vtkObject ); @@ -45,8 +49,8 @@ namespace cpExtensions void ResetCamera( const int& id ); void ResetCameras( ); - void Render( const int& id ); - void RenderAll( ); + void Render( const int& id, const double& t ); + void RenderAll( const double& t ); vtkRenderer* GetXRenderer( ); vtkRenderer* GetYRenderer( ); vtkRenderer* GetZRenderer( ); diff --git a/lib/cpPlugins/Interface/BaseMPRWidget.cxx b/lib/cpPlugins/Interface/BaseMPRWidget.cxx new file mode 100644 index 0000000..fece6b8 --- /dev/null +++ b/lib/cpPlugins/Interface/BaseMPRWidget.cxx @@ -0,0 +1,245 @@ +#include + +#ifdef cpPlugins_Interface_QT4 + +#include +#include +#include + +// ------------------------------------------------------------------------- +cpPlugins::Interface::BaseMPRWidget:: +BaseMPRWidget( QWidget* parent ) + : QWidget( parent ), + m_UI( new Ui::BaseMPRWidget ) +{ + this->m_UI->setupUi( this ); + + // Configure VTK widgets + this->m_VTK[ 0 ] = this->m_UI->VTK01; + this->m_VTK[ 1 ] = this->m_UI->VTK00; + 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( + this->m_VTK[ 0 ]->GetRenderWindow( ), + this->m_VTK[ 1 ]->GetRenderWindow( ), + this->m_VTK[ 2 ]->GetRenderWindow( ), + this->m_VTK[ 3 ]->GetRenderWindow( ) + ); + + // Connect slots + QObject::connect( + this->m_UI->TopSplitter, SIGNAL( splitterMoved( int, int ) ), + this, SLOT( _SyncBottom( int, int ) ) + ); + QObject::connect( + this->m_UI->BottomSplitter, SIGNAL( splitterMoved( int, int ) ), + this, SLOT( _SyncTop( int, int ) ) + ); +} + +// ------------------------------------------------------------------------- +cpPlugins::Interface::BaseMPRWidget:: +~BaseMPRWidget( ) +{ + delete this->m_UI; + + // Delete polydata actors + std::map< std::string, PolyDataActor* >::iterator mIt = + this->m_Meshes.begin( ); + for( ; mIt != this->m_Meshes.end( ); ++mIt ) + delete mIt->second; + this->m_Meshes.clear( ); +} + +// ------------------------------------------------------------------------- +bool cpPlugins::Interface::BaseMPRWidget:: +ShowImage( + vtkImageData* image, + const std::string& name, + const std::string& parent + ) +{ + // Update tree view + QTreeWidgetItem* new_item = this->_UpdateItem( 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 cpPlugins::Interface::BaseMPRWidget:: +ShowImage( + vtkImageData* image, + const std::string& name, + const std::string& parent, + const double& r, const double& g, const double& b + ) +{ +} + +// ------------------------------------------------------------------------- +bool cpPlugins::Interface::BaseMPRWidget:: +ShowMesh( + vtkPolyData* mesh, + const std::string& name, + const std::string& parent + ) +{ + // Update tree view + QTreeWidgetItem* new_item = this->_UpdateItem( 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 cpPlugins::Interface::BaseMPRWidget:: +ShowMesh( + vtkPolyData* mesh, + const std::string& name, + const std::string& parent, + const double& r, const double& g, const double& b + ) +{ +} + +// ------------------------------------------------------------------------- +void cpPlugins::Interface::BaseMPRWidget:: +ClearAll( ) +{ + /* + this->m_MPRObjects->ClearAll( ); + this->m_Images.clear( ); + this->m_Meshes.clear( ); + */ +} + +// ------------------------------------------------------------------------- +std::string cpPlugins::Interface::BaseMPRWidget:: +GetSelectedData( ) const +{ + QTreeWidgetItem* item = this->m_UI->LoadedData->currentItem( ); + if( item != NULL ) + return( item->text( 0 ).toStdString( ) ); + else + return( "" ); +} + +// ------------------------------------------------------------------------- +QTreeWidgetItem* cpPlugins::Interface::BaseMPRWidget:: +_FindItem( const std::string& name ) const +{ + QList< QTreeWidgetItem* > items = + this->m_UI->LoadedData->findItems( name.c_str( ), Qt::MatchExactly ); + if( items.size( ) > 0 ) + return( items[ 0 ] ); + else + return( NULL ); +} + +// ------------------------------------------------------------------------- +QTreeWidgetItem* cpPlugins::Interface::BaseMPRWidget:: +_UpdateItem( const std::string& name, const std::string& parent ) +{ + // Update tree view + QTreeWidgetItem* new_item = NULL; + if( parent != "" ) + { + QTreeWidgetItem* parent_item = this->_FindItem( parent ); + if( parent_item != NULL ) + { + QTreeWidgetItem* old_item = this->_FindItem( name ); + if( old_item == NULL ) + { + new_item = + new QTreeWidgetItem( parent_item, QStringList( name.c_str( ) ) ); + parent_item->setExpanded( true ); + + } // fi + + } // fi + } + else + { + new_item = new QTreeWidgetItem( + ( QTreeWidgetItem* )( NULL ), QStringList( name.c_str( ) ) + ); + this->m_UI->LoadedData->addTopLevelItem( new_item ); + + } // fi + return( new_item ); +} + +// ------------------------------------------------------------------------- +void cpPlugins::Interface::BaseMPRWidget:: +_Add3DActor( vtkProp3D* prop ) +{ + vtkRenderer* ren = + this->m_VTK[ 3 ]->GetRenderWindow( )->GetRenderers( )->GetFirstRenderer( ); + if( ren == NULL ) + return; + ren->AddActor( prop ); + this->m_VTK[ 3 ]->GetRenderWindow( )->Render( ); +} + +// ------------------------------------------------------------------------- +void cpPlugins::Interface::BaseMPRWidget:: +_SyncBottom( int a, int b ) +{ + this->m_UI->BottomSplitter->setSizes( this->m_UI->TopSplitter->sizes( ) ); +} + +// ------------------------------------------------------------------------- +void cpPlugins::Interface::BaseMPRWidget:: +_SyncTop( int a, int b ) +{ + this->m_UI->TopSplitter->setSizes( this->m_UI->BottomSplitter->sizes( ) ); +} + +// ------------------------------------------------------------------------- +cpPlugins::Interface::BaseMPRWidget::PolyDataActor:: +PolyDataActor( vtkPolyData* pd ) +{ + if( pd == NULL ) + return; + + double range[ 2 ]; + pd->GetScalarRange( range ); + + this->Normals = vtkSmartPointer< vtkPolyDataNormals >::New( ); + this->Stripper = vtkSmartPointer< vtkStripper >::New( ); + this->Mapper = vtkSmartPointer< vtkPolyDataMapper >::New( ); + this->Actor = vtkSmartPointer< vtkQuadricLODActor >::New( ); + + 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->DeferLODConstructionOff( ); +} + +#endif // cpPlugins_Interface_QT4 + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/BaseMPRWidget.h b/lib/cpPlugins/Interface/BaseMPRWidget.h new file mode 100644 index 0000000..9ed62ce --- /dev/null +++ b/lib/cpPlugins/Interface/BaseMPRWidget.h @@ -0,0 +1,133 @@ +#ifndef __CPPLUGINS__INTERFACE__BASEMPRWIDGET__H__ +#define __CPPLUGINS__INTERFACE__BASEMPRWIDGET__H__ + +#include +#include + +#ifdef cpPlugins_Interface_QT4 + +#include +#include + +#include + +#include +#include +#include +#include +#include + +#include + +// ------------------------------------------------------------------------- +class QTreeWidgetItem; +class QVTKWidget; + +namespace Ui +{ + class BaseMPRWidget; +} + +// ------------------------------------------------------------------------- +namespace cpPlugins +{ + namespace Interface + { + /** + */ + class cpPlugins_Interface_EXPORT BaseMPRWidget + : public QWidget + { + Q_OBJECT; + + public: + 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 BaseMPRWidget( QWidget* parent = 0 ); + virtual ~BaseMPRWidget( ); + + // Some visualization accessors + bool ShowImage( + vtkImageData* image, + const std::string& name, + const std::string& parent = "" + ); + bool ShowImage( + vtkImageData* image, + const std::string& name, + const std::string& parent, + const double& r, const double& g, const double& b + ); + bool ShowMesh( + vtkPolyData* mesh, + const std::string& name, + const std::string& parent + ); + bool ShowMesh( + vtkPolyData* mesh, + const std::string& name, + const std::string& parent, + const double& r, const double& g, const double& b + ); + void ClearAll( ); + + // Visual objects accessors + std::string GetSelectedData( ) const; + + protected: + QTreeWidgetItem* _FindItem( const std::string& name ) const; + QTreeWidgetItem* _UpdateItem( + const std::string& name, + const std::string& parent + ); + + void _Add3DActor( vtkProp3D* prop ); + + private slots: + void _SyncBottom( int a, int b ); + void _SyncTop( int a, int b ); + + protected: + Ui::BaseMPRWidget* m_UI; + vtkSmartPointer< TMPRObjects > m_MPRObjects; + + struct PolyDataActor + { + vtkSmartPointer< vtkPolyDataNormals > Normals; + vtkSmartPointer< vtkStripper > Stripper; + vtkSmartPointer< vtkPolyDataMapper > Mapper; + vtkSmartPointer< vtkQuadricLODActor > Actor; + + PolyDataActor( vtkPolyData* pd ); + }; + + std::map< std::string, vtkImageData* > m_Images; + std::map< std::string, PolyDataActor* > m_Meshes; + std::map< std::string, std::string > m_Tree; + + QVTKWidget* m_VTK[ 4 ]; + }; + + } // ecapseman + +} // ecapseman + +#endif // cpPlugins_Interface_QT4 + +#endif // __CPPLUGINS__INTERFACE__BASEMPRWIDGET__H__ + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/BaseMPRWidget.ui b/lib/cpPlugins/Interface/BaseMPRWidget.ui new file mode 100644 index 0000000..8eafb59 --- /dev/null +++ b/lib/cpPlugins/Interface/BaseMPRWidget.ui @@ -0,0 +1,126 @@ + + + BaseMPRWidget + + + + 0 + 0 + 580 + 424 + + + + Form + + + + + + + 562 + 406 + + + + Qt::Horizontal + + + + + 150 + 406 + + + + + 500 + 16777215 + + + + + Data + + + + + + + 406 + 406 + + + + Qt::Vertical + + + + + 406 + 200 + + + + Qt::Horizontal + + + + + 200 + 200 + + + + + + + 200 + 200 + + + + + + + + 406 + 200 + + + + Qt::Horizontal + + + + + 200 + 200 + + + + + + + 200 + 200 + + + + + + + + + + + + QVTKWidget + QWidget +
QVTKWidget.h
+ 1 +
+
+ + +
diff --git a/lib/cpPlugins/Interface/BaseMPRWindow.cxx b/lib/cpPlugins/Interface/BaseMPRWindow.cxx deleted file mode 100644 index 230c961..0000000 --- a/lib/cpPlugins/Interface/BaseMPRWindow.cxx +++ /dev/null @@ -1,115 +0,0 @@ -#include - -#ifdef cpPlugins_Interface_QT4 - -#include - -// ------------------------------------------------------------------------- -cpPlugins::Interface::BaseMPRWindow:: -BaseMPRWindow( QWidget* parent ) - : cpExtensions::QT::QuadSplitter( parent ) -{ - // Configure splitter - this->m_XVTK = new QVTKWidget( this ); - this->m_YVTK = new QVTKWidget( this ); - this->m_ZVTK = new QVTKWidget( this ); - this->m_WVTK = new QVTKWidget( this ); - this->addWidgets( this->m_YVTK, this->m_XVTK, this->m_ZVTK, this->m_WVTK ); - - // Create and associate vtk renderers - this->m_MPRObjects = vtkSmartPointer< TMPRObjects >::New( ); - this->m_MPRObjects->SetRenderWindows( - this->m_XVTK->GetRenderWindow( ), - this->m_YVTK->GetRenderWindow( ), - this->m_ZVTK->GetRenderWindow( ), - this->m_WVTK->GetRenderWindow( ) - ); -} - -// ------------------------------------------------------------------------- -cpPlugins::Interface::BaseMPRWindow:: -~BaseMPRWindow( ) -{ - if( this->m_WVTK != NULL ) delete this->m_WVTK; - if( this->m_ZVTK != NULL ) delete this->m_ZVTK; - if( this->m_YVTK != NULL ) delete this->m_YVTK; - if( this->m_XVTK != NULL ) delete this->m_XVTK; -} - -// ------------------------------------------------------------------------- -bool cpPlugins::Interface::BaseMPRWindow:: -ShowImage( vtkImageData* image ) -{ - bool r = ( image != NULL ); - if( r ) - this->m_MPRObjects->AddImage( image ); - return( r ); -} - -// ------------------------------------------------------------------------- -bool cpPlugins::Interface::BaseMPRWindow:: -ShowImage( vtkImageData* image, double r, double g, double b ) -{ - return( false ); -} - -// ------------------------------------------------------------------------- -bool cpPlugins::Interface::BaseMPRWindow:: -ShowMesh( vtkPolyData* mesh ) -{ - return( false ); -} - -// ------------------------------------------------------------------------- -/* - void cpPlugins::Interface::BaseMPRWindow:: - AddImage( const std::string& name, TImage* image ) - { - this->m_Images[ name ] = image; - vtkImageData* vtk_id = - this->m_Images[ name ]->GetVTK< vtkImageData >( ); - if( vtk_id != NULL ) - this->m_MPRObjects->AddImage( vtk_id ); - } -*/ - -// ------------------------------------------------------------------------- -double cpPlugins::Interface::BaseMPRWindow:: -GetWindow( ) const -{ - return( this->m_MPRObjects->GetWindow( ) ); -} - -// ------------------------------------------------------------------------- -double cpPlugins::Interface::BaseMPRWindow:: -GetLevel( ) const -{ - return( this->m_MPRObjects->GetLevel( ) ); -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::BaseMPRWindow:: -ClearAll( ) -{ - /* - this->m_MPRObjects->ClearAll( ); - this->m_Images.clear( ); - this->m_Meshes.clear( ); - */ -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::BaseMPRWindow:: -Add3DActor( vtkProp3D* prop ) -{ - vtkRenderer* ren = - this->m_WVTK->GetRenderWindow( )->GetRenderers( )->GetFirstRenderer( ); - if( ren == NULL ) - return; - ren->AddActor( prop ); - this->m_WVTK->GetRenderWindow( )->Render( ); -} - -#endif // cpPlugins_Interface_QT4 - -// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/BaseMPRWindow.h b/lib/cpPlugins/Interface/BaseMPRWindow.h deleted file mode 100644 index 078e028..0000000 --- a/lib/cpPlugins/Interface/BaseMPRWindow.h +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef __CPPLUGINS__INTERFACE__BASEMPRWINDOW__H__ -#define __CPPLUGINS__INTERFACE__BASEMPRWINDOW__H__ - -#include -#include - -#ifdef cpPlugins_Interface_QT4 - -#include -#include -#include - -#include -#include -#include - -namespace cpPlugins -{ - namespace Interface - { - /** - */ - class cpPlugins_Interface_EXPORT BaseMPRWindow - : public cpExtensions::QT::QuadSplitter - { - Q_OBJECT; - - public: - typedef cpExtensions::Visualization::MPRObjects TMPRObjects; - - typedef TMPRObjects::TBaseStyle TBaseStyle; - typedef TMPRObjects::TStyle TStyle; - typedef TMPRObjects::TSlicesCommand TSlicesCommand; - typedef TMPRObjects::TWindowLevelCommand TWindowLevelCommand; - typedef TMPRObjects::TMouseCommand TMouseCommand; - typedef TMPRObjects::TMouseWheelCommand TMouseWheelCommand; - typedef TMPRObjects::TKeyCommand TKeyCommand; - typedef TMPRObjects::TVoidCommand TVoidCommand; - - public: - explicit BaseMPRWindow( QWidget* parent = 0 ); - virtual ~BaseMPRWindow( ); - - // Some visualization accessors - bool ShowImage( vtkImageData* image ); - bool ShowImage( vtkImageData* image, double r, double g, double b ); - bool ShowMesh( vtkPolyData* mesh ); - double GetWindow( ) const; - double GetLevel( ) const; - void ClearAll( ); - - // Some more visualization (3D) - void Add3DActor( vtkProp3D* prop ); - - protected: - vtkSmartPointer< TMPRObjects > m_MPRObjects; - - QVTKWidget* m_XVTK; - QVTKWidget* m_YVTK; - QVTKWidget* m_ZVTK; - QVTKWidget* m_WVTK; - }; - - } // ecapseman - -} // ecapseman - -#endif // cpPlugins_Interface_QT4 - -#endif // __CPPLUGINS__INTERFACE__BASEMPRWINDOW__H__ - -// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/CMakeLists.txt b/lib/cpPlugins/Interface/CMakeLists.txt index 115cb44..406f86f 100644 --- a/lib/cpPlugins/Interface/CMakeLists.txt +++ b/lib/cpPlugins/Interface/CMakeLists.txt @@ -20,19 +20,20 @@ FILE(GLOB LIB_SOURCES_CXX "*.cxx") IF(USE_QT4) SET( LIB_QT_UI + BaseMPRWidget.ui ParametersListWidget.ui ) SET( LIB_QT_Headers ParametersListWidget.h ParametersQtDialog.h - BaseMPRWindow.h + BaseMPRWidget.h ) SET( LIB_QT_Sources ParametersListWidget.cxx ParametersQtDialog.cxx - BaseMPRWindow.cxx + BaseMPRWidget.cxx ) SET( LIB_QT_Resources diff --git a/lib/cpPlugins/Interface/Mesh.cxx b/lib/cpPlugins/Interface/Mesh.cxx index 829c1f5..94adb2b 100644 --- a/lib/cpPlugins/Interface/Mesh.cxx +++ b/lib/cpPlugins/Interface/Mesh.cxx @@ -10,71 +10,12 @@ SetVTK( vtkObject* mesh ) this->m_VTKObject = mesh; else this->m_VTKObject = NULL; - this->m_Mapper = NULL; - this->m_Actor = NULL; this->Modified( ); } - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::Mesh:: -CreateVTKActor( ) -{ - vtkPolyData* pd = this->GetVTK< vtkPolyData >( ); - if( - pd != NULL && - ( - this->m_Mapper.GetPointer( ) == NULL || - this->m_Actor.GetPointer( ) == NULL - ) - ) - { - double range[ 2 ]; - pd->GetScalarRange( range ); - - this->m_Normals = vtkSmartPointer< vtkPolyDataNormals >::New( ); - this->m_Stripper = vtkSmartPointer< vtkStripper >::New( ); - this->m_Mapper = vtkSmartPointer< vtkPolyDataMapper >::New( ); - this->m_Actor = vtkSmartPointer< vtkQuadricLODActor >::New( ); - - this->m_Normals->SetInputData( pd ); - this->m_Normals->SetFeatureAngle( 60.0 ); - this->m_Stripper->SetInputConnection( this->m_Normals->GetOutputPort( ) ); - this->m_Mapper->SetInputConnection( this->m_Stripper->GetOutputPort( ) ); - this->m_Mapper->UseLookupTableScalarRangeOff( ); - this->m_Mapper->SetScalarRange( - range[ 0 ], ( ( range[ 1 ] - range[ 0 ] ) * 0.75 ) + range[ 0 ] - ); - this->m_Actor->SetMapper( this->m_Mapper ); - this->m_Actor->DeferLODConstructionOff( ); - this->Modified( ); - - /* - TODO: vtkQuadricLODActor : AllocatedRenderTime - */ - - } // fi -} - -// ------------------------------------------------------------------------- -vtkActor* cpPlugins::Interface::Mesh:: -GetVTKActor( ) -{ - return( this->m_Actor ); -} - -// ------------------------------------------------------------------------- -const vtkActor* cpPlugins::Interface::Mesh:: -GetVTKActor( ) const -{ - return( this->m_Actor ); -} - // ------------------------------------------------------------------------- cpPlugins::Interface::Mesh:: Mesh( ) - : Superclass( ), - m_Mapper( NULL ), - m_Actor( NULL ) + : Superclass( ) { } diff --git a/lib/cpPlugins/Interface/Mesh.h b/lib/cpPlugins/Interface/Mesh.h index b2fe923..92c3c45 100644 --- a/lib/cpPlugins/Interface/Mesh.h +++ b/lib/cpPlugins/Interface/Mesh.h @@ -4,12 +4,6 @@ #include #include -#include -#include -#include -#include -#include - namespace cpPlugins { namespace Interface @@ -38,10 +32,6 @@ namespace cpPlugins virtual void SetVTK( vtkObject* mesh ); - virtual void CreateVTKActor( ); - virtual vtkActor* GetVTKActor( ); - virtual const vtkActor* GetVTKActor( ) const; - protected: Mesh( ); virtual ~Mesh( ); @@ -50,12 +40,6 @@ namespace cpPlugins // Purposely not implemented Mesh( const Self& ); Self& operator=( const Self& ); - - protected: - vtkSmartPointer< vtkPolyDataNormals > m_Normals; - vtkSmartPointer< vtkStripper > m_Stripper; - vtkSmartPointer< vtkPolyDataMapper > m_Mapper; - vtkSmartPointer< vtkQuadricLODActor > m_Actor; }; } // ecapseman diff --git a/lib/cpPlugins/Interface/Plugins.cxx b/lib/cpPlugins/Interface/Plugins.cxx index 30378c2..b9dab29 100644 --- a/lib/cpPlugins/Interface/Plugins.cxx +++ b/lib/cpPlugins/Interface/Plugins.cxx @@ -36,7 +36,7 @@ Plugins( QWidget* widget ) cpPlugins::Interface::Plugins:: ~Plugins( ) { - this->m_Interface.UnloadAll( ); + // TODO: this causes a segfault? this->m_Interface.UnloadAll( ); } // ------------------------------------------------------------------------- diff --git a/lib/cpPlugins/Interface/ProcessObject.cxx b/lib/cpPlugins/Interface/ProcessObject.cxx index 9fb4ea7..f639d7f 100644 --- a/lib/cpPlugins/Interface/ProcessObject.cxx +++ b/lib/cpPlugins/Interface/ProcessObject.cxx @@ -45,6 +45,28 @@ GetNumberOfOutputs( ) const return( this->m_Outputs.size( ) ); } +// ------------------------------------------------------------------------- +std::vector< std::string > cpPlugins::Interface::ProcessObject:: +GetInputsNames( ) const +{ + std::vector< std::string > r; + auto dIt = this->m_Inputs.begin( ); + for( ; dIt != this->m_Inputs.end( ); ++dIt ) + r.push_back( dIt->first ); + return( r ); +} + +// ------------------------------------------------------------------------- +std::vector< std::string > cpPlugins::Interface::ProcessObject:: +GetOutputsNames( ) const +{ + std::vector< std::string > r; + auto dIt = this->m_Outputs.begin( ); + for( ; dIt != this->m_Outputs.end( ); ++dIt ) + r.push_back( dIt->first ); + return( r ); +} + // ------------------------------------------------------------------------- void cpPlugins::Interface::ProcessObject:: SetInput( const std::string& id, cpPlugins::Interface::DataObject* dobj ) diff --git a/lib/cpPlugins/Interface/ProcessObject.h b/lib/cpPlugins/Interface/ProcessObject.h index 53b784f..5fc98f3 100644 --- a/lib/cpPlugins/Interface/ProcessObject.h +++ b/lib/cpPlugins/Interface/ProcessObject.h @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -60,6 +61,9 @@ namespace cpPlugins virtual unsigned int GetNumberOfInputs( ) const; virtual unsigned int GetNumberOfOutputs( ) const; + virtual std::vector< std::string > GetInputsNames( ) const; + virtual std::vector< std::string > GetOutputsNames( ) const; + virtual void SetInput( const std::string& id, DataObject* dobj ); virtual std::string Update( );