From 107144983fb7d178ad07ccfd1b7c703671eb09aa Mon Sep 17 00:00:00 2001 From: Leonardo Florez-Valencia Date: Sun, 12 Jun 2016 21:07:04 -0500 Subject: [PATCH] ... --- lib/cpPlugins/ActorAxesProperties.cxx | 42 ++++++++++++++++++++++----- lib/cpPlugins/ProcessObject.cxx | 24 --------------- lib/cpPlugins/ProcessObject.h | 7 +++-- lib/cpPlugins/ProcessObject.hxx | 24 +++++++++++++++ 4 files changed, 64 insertions(+), 33 deletions(-) diff --git a/lib/cpPlugins/ActorAxesProperties.cxx b/lib/cpPlugins/ActorAxesProperties.cxx index 9de5081..373f2e2 100644 --- a/lib/cpPlugins/ActorAxesProperties.cxx +++ b/lib/cpPlugins/ActorAxesProperties.cxx @@ -5,9 +5,11 @@ #include #include +#include #include #include -#include +#include +#include // ------------------------------------------------------------------------- cpPlugins::ActorAxesProperties:: @@ -55,7 +57,7 @@ _updateWidgets( ) std::string ytext( actor->GetYAxisLabelText( ) ); std::string ztext( actor->GetZAxisLabelText( ) ); double scale = actor->GetScale( )[ 0 ]; - auto prop = actor->GetXAxisCaptionActor2D( )->GetProperty( ); + auto prop = actor->GetXAxisCaptionActor2D( )->GetCaptionTextProperty( ); double rgb[ 3 ]; prop->GetColor( rgb ); rgb[ 0 ] *= double( 255 ); @@ -102,11 +104,35 @@ _updateWidgets( ) void cpPlugins::ActorAxesProperties:: _Scale( double v ) { + itk::Vector< double, 3 > x, y, z; auto aIt = this->m_Actors.begin( ); for( ; aIt != this->m_Actors.end( ); ++aIt ) { auto ma = dynamic_cast< vtkAxesActor* >( aIt->GetPointer( ) ); - ma->SetScale( v ); + auto matrix = ma->GetUserMatrix( ); + for( unsigned int d = 0; d < 3; ++d ) + { + x[ d ] = matrix->GetElement( d, 0 ); + y[ d ] = matrix->GetElement( d, 1 ); + z[ d ] = matrix->GetElement( d, 2 ); + + } // rof + auto nx = x.GetNorm( ); + auto ny = y.GetNorm( ); + auto nz = z.GetNorm( ); + if( nx > double( 0 ) ) x /= nx; + if( ny > double( 0 ) ) y /= ny; + if( nz > double( 0 ) ) z /= nz; + x *= v; + y *= v; + z *= v; + for( unsigned int d = 0; d < 3; ++d ) + { + matrix->SetElement( d, 0, x[ d ] ); + matrix->SetElement( d, 1, y[ d ] ); + matrix->SetElement( d, 2, z[ d ] ); + + } // rof ma->Modified( ); } // rof @@ -160,14 +186,16 @@ _TextColor( ) rgb[ 0 ] = double( color.red( ) ) / double( 255 ); rgb[ 1 ] = double( color.green( ) ) / double( 255 ); rgb[ 2 ] = double( color.blue( ) ) / double( 255 ); - auto aIt = this->m_Actors.begin( ); for( ; aIt != this->m_Actors.end( ); ++aIt ) { auto ma = dynamic_cast< vtkAxesActor* >( aIt->GetPointer( ) ); - ma->GetXAxisCaptionActor2D( )->GetProperty( )->SetColor( rgb ); - ma->GetYAxisCaptionActor2D( )->GetProperty( )->SetColor( rgb ); - ma->GetZAxisCaptionActor2D( )->GetProperty( )->SetColor( rgb ); + ma->GetXAxisCaptionActor2D( )->GetCaptionTextProperty( )->SetColor( rgb ); + ma->GetYAxisCaptionActor2D( )->GetCaptionTextProperty( )->SetColor( rgb ); + ma->GetZAxisCaptionActor2D( )->GetCaptionTextProperty( )->SetColor( rgb ); + ma->GetXAxisCaptionActor2D( )->Modified( ); + ma->GetYAxisCaptionActor2D( )->Modified( ); + ma->GetZAxisCaptionActor2D( )->Modified( ); ma->Modified( ); } // rof diff --git a/lib/cpPlugins/ProcessObject.cxx b/lib/cpPlugins/ProcessObject.cxx index 12c9bb6..1355ff9 100644 --- a/lib/cpPlugins/ProcessObject.cxx +++ b/lib/cpPlugins/ProcessObject.cxx @@ -94,30 +94,6 @@ GetOutputPort( const std::string& id ) const return( i->second ); } -// ------------------------------------------------------------------------- -cpPlugins:: -DataObject* cpPlugins::ProcessObject:: -GetInput( const std::string& id ) -{ - auto i = this->m_Inputs.find( id ); - if( i != this->m_Inputs.end( ) ) - return( dynamic_cast< DataObject* >( i->second.GetPointer( ) ) ); - else - return( NULL ); -} - -// ------------------------------------------------------------------------- -const cpPlugins:: -DataObject* cpPlugins::ProcessObject:: -GetInput( const std::string& id ) const -{ - auto i = this->m_Inputs.find( id ); - if( i != this->m_Inputs.end( ) ) - return( dynamic_cast< const DataObject* >( i->second.GetPointer( ) ) ); - else - return( NULL ); -} - // ------------------------------------------------------------------------- bool cpPlugins::ProcessObject:: SetInputPort( const std::string& id, const OutputPort& port ) diff --git a/lib/cpPlugins/ProcessObject.h b/lib/cpPlugins/ProcessObject.h index 1345e3b..07817ee 100644 --- a/lib/cpPlugins/ProcessObject.h +++ b/lib/cpPlugins/ProcessObject.h @@ -46,8 +46,11 @@ namespace cpPlugins OutputPort& GetOutputPort( const std::string& id ); const OutputPort& GetOutputPort( const std::string& id ) const; - DataObject* GetInput( const std::string& id ); - const DataObject* GetInput( const std::string& id ) const; + template< class _TType = DataObject > + inline _TType* GetInput( const std::string& id ); + + template< class _TType = DataObject > + inline const _TType* GetInput( const std::string& id ) const; template< class _TType = DataObject > inline _TType* GetOutput( const std::string& id ); diff --git a/lib/cpPlugins/ProcessObject.hxx b/lib/cpPlugins/ProcessObject.hxx index 93d62bb..9be2675 100644 --- a/lib/cpPlugins/ProcessObject.hxx +++ b/lib/cpPlugins/ProcessObject.hxx @@ -1,6 +1,30 @@ #ifndef __CPPLUGINS__PROCESSOBJECT__HXX__ #define __CPPLUGINS__PROCESSOBJECT__HXX__ +// ------------------------------------------------------------------------- +template< class _TType > +_TType* cpPlugins::ProcessObject:: +GetInput( const std::string& id ) +{ + auto i = this->m_Inputs.find( id ); + if( i != this->m_Inputs.end( ) ) + return( dynamic_cast< _TType* >( i->second.GetPointer( ) ) ); + else + return( NULL ); +} + +// ------------------------------------------------------------------------- +template< class _TType > +const _TType* cpPlugins::ProcessObject:: +GetInput( const std::string& id ) const +{ + auto i = this->m_Inputs.find( id ); + if( i != this->m_Inputs.end( ) ) + return( dynamic_cast< const _TType* >( i->second.GetPointer( ) ) ); + else + return( NULL ); +} + // ------------------------------------------------------------------------- template< class _TType > _TType* cpPlugins::ProcessObject:: -- 2.45.1