#include #ifdef cpExtensions_QT4 #include #include #include #include #include #include #include // ------------------------------------------------------------------------- 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$