]> Creatis software - cpPlugins.git/commitdiff
...
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Sun, 12 Jun 2016 03:24:44 +0000 (22:24 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Sun, 12 Jun 2016 03:24:44 +0000 (22:24 -0500)
16 files changed:
lib/cpExtensions/QT/SimpleMPRWidget.cxx
lib/cpPlugins/ActorAxesProperties.cxx [new file with mode: 0644]
lib/cpPlugins/ActorAxesProperties.h [new file with mode: 0644]
lib/cpPlugins/ActorAxesProperties.ui [new file with mode: 0644]
lib/cpPlugins/ActorImageProperties.cxx [new file with mode: 0644]
lib/cpPlugins/ActorImageProperties.h [new file with mode: 0644]
lib/cpPlugins/ActorImageProperties.ui [new file with mode: 0644]
lib/cpPlugins/ActorPolyDataProperties.cxx [new file with mode: 0644]
lib/cpPlugins/ActorPolyDataProperties.h [new file with mode: 0644]
lib/cpPlugins/ActorPolyDataProperties.ui [new file with mode: 0644]
lib/cpPlugins/ActorProperties.cxx [new file with mode: 0644]
lib/cpPlugins/ActorProperties.h [new file with mode: 0644]
lib/cpPlugins/ActorPropertiesQtDialog.cxx
lib/cpPlugins/ActorPropertiesQtDialog.h
lib/cpPlugins/CMakeLists.txt
lib/cpPlugins/Image.cxx

index fe67abcb5e93d1669956b969186bb1e99b33ad8d..abe5bcb2ed2cce999bb34f9c50d10f742fa8896b 100644 (file)
@@ -3,6 +3,7 @@
 #ifdef cpExtensions_QT4
 
 #include <cpExtensions/ui_SimpleMPRWidget.h>
+#include <vtkImageProperty.h>
 #include <vtkRenderer.h>
 #include <vtkRenderWindow.h>
 
@@ -130,6 +131,7 @@ SetMainActor( vtkImageActor* actor, const std::string& name )
 {
   this->Clear( );
   vtkImageData* image = NULL;
+  int interp = actor->GetProperty( )->GetInterpolationType( );
   for( unsigned int i = 0; i < 3; ++i )
   {
     this->m_2DSlices[ i ] = vtkSmartPointer< TSliceActors >::New( );
@@ -160,6 +162,10 @@ SetMainActor( vtkImageActor* actor, const std::string& name )
     this->m_NamedActors[ name ].insert(
       this->m_3DSlices[ i ]->GetImageActor( )
       );
+    this->m_2DSlices[ i ]->GetImageActor( )->
+      GetProperty( )->SetInterpolationType( interp );
+    this->m_3DSlices[ i ]->GetImageActor( )->
+      GetProperty( )->SetInterpolationType( interp );
 
   } // rof
   this->_AssociateSlices( );
diff --git a/lib/cpPlugins/ActorAxesProperties.cxx b/lib/cpPlugins/ActorAxesProperties.cxx
new file mode 100644 (file)
index 0000000..9de5081
--- /dev/null
@@ -0,0 +1,181 @@
+#include <cpPlugins/ActorAxesProperties.h>
+
+#ifdef cpPlugins_QT4
+
+#include <cpPlugins/ui_ActorAxesProperties.h>
+
+#include <QColorDialog>
+#include <vtkAxesActor.h>
+#include <vtkCaptionActor2D.h>
+#include <vtkProperty2D.h>
+
+// -------------------------------------------------------------------------
+cpPlugins::ActorAxesProperties::
+ActorAxesProperties( QWidget* parent )
+  : cpPlugins::ActorProperties( parent ),
+    m_UI( new Ui::ActorAxesProperties )
+{
+  this->m_UI->setupUi( this );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::ActorAxesProperties::
+~ActorAxesProperties( )
+{
+  delete this->m_UI;
+}
+
+// -------------------------------------------------------------------------
+bool cpPlugins::ActorAxesProperties::
+addActor( vtkProp* obj )
+{
+  auto actor = dynamic_cast< vtkAxesActor* >( obj );
+  if( actor != NULL )
+  {
+    this->m_Actors.insert( obj );
+    if( this->m_Actors.size( ) == 1 )
+      this->_updateWidgets( );
+    return( true );
+  }
+  else
+    return( false );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::ActorAxesProperties::
+_updateWidgets( )
+{
+  auto actor =
+    dynamic_cast< vtkAxesActor* >( this->m_Actors.begin( )->GetPointer( ) );
+  if( actor == NULL )
+    return;
+
+  // Get properties
+  std::string xtext( actor->GetXAxisLabelText( ) );
+  std::string ytext( actor->GetYAxisLabelText( ) );
+  std::string ztext( actor->GetZAxisLabelText( ) );
+  double scale = actor->GetScale( )[ 0 ];
+  auto prop = actor->GetXAxisCaptionActor2D( )->GetProperty( );
+  double rgb[ 3 ];
+  prop->GetColor( rgb );
+  rgb[ 0 ] *= double( 255 );
+  rgb[ 1 ] *= double( 255 );
+  rgb[ 2 ] *= double( 255 );
+
+  // Set widget values
+  auto palette = this->m_UI->TextColor->palette( );
+  palette.setColor(
+    QPalette::Button, QColor( rgb[ 0 ], rgb[ 1 ], rgb[ 2 ] )
+    );
+  this->m_UI->TextColor->setAutoFillBackground( true );
+  this->m_UI->TextColor->setPalette( palette );
+
+  this->m_UI->XText->setText( xtext.c_str( ) );
+  this->m_UI->YText->setText( ytext.c_str( ) );
+  this->m_UI->ZText->setText( ztext.c_str( ) );
+  this->m_UI->Scale->setValue( scale );
+
+  // Connect stuff
+  this->connect(
+    this->m_UI->Scale, SIGNAL( valueChanged( double ) ),
+    this, SLOT( _Scale( double ) )
+    );
+  this->connect(
+    this->m_UI->XText, SIGNAL( textChanged( const QString& ) ),
+    this, SLOT( _TextChanged( const QString& ) )
+    );
+  this->connect(
+    this->m_UI->YText, SIGNAL( textChanged( const QString& ) ),
+    this, SLOT( _TextChanged( const QString& ) )
+    );
+  this->connect(
+    this->m_UI->ZText, SIGNAL( textChanged( const QString& ) ),
+    this, SLOT( _TextChanged( const QString& ) )
+    );
+  this->connect(
+    this->m_UI->TextColor, SIGNAL( clicked( ) ),
+    this, SLOT( _TextColor( ) )
+    );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::ActorAxesProperties::
+_Scale( double v )
+{
+  auto aIt = this->m_Actors.begin( );
+  for( ; aIt != this->m_Actors.end( ); ++aIt )
+  {
+    auto ma = dynamic_cast< vtkAxesActor* >( aIt->GetPointer( ) );
+    ma->SetScale( v );
+    ma->Modified( );
+
+  } // rof
+  this->_render( );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::ActorAxesProperties::
+_TextChanged( const QString& text )
+{
+  auto obj = this->sender( );
+  auto aIt = this->m_Actors.begin( );
+  auto str = text.toStdString( );
+  for( ; aIt != this->m_Actors.end( ); ++aIt )
+  {
+    auto ma = dynamic_cast< vtkAxesActor* >( aIt->GetPointer( ) );
+    if( obj == this->m_UI->XText )
+      ma->SetXAxisLabelText( str.c_str( ) );
+    else if( obj == this->m_UI->YText )
+      ma->SetYAxisLabelText( str.c_str( ) );
+    else if( obj == this->m_UI->ZText )
+      ma->SetZAxisLabelText( str.c_str( ) );
+    ma->Modified( );
+
+  } // rof
+  this->_render( );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::ActorAxesProperties::
+_TextColor( )
+{
+  if( this->m_Actors.size( ) == 0 )
+    return;
+  QPalette pal = this->m_UI->TextColor->palette( );
+  QColor color =
+    QColorDialog::getColor(
+      pal.color( QPalette::Button ),
+      this,
+      "Select Color",
+      QColorDialog::DontUseNativeDialog
+      );
+  if( color.isValid( ) )
+  {
+    pal.setColor( QPalette::Button, color );
+    this->m_UI->TextColor->setAutoFillBackground( true );
+    this->m_UI->TextColor->setPalette( pal );
+    this->m_UI->TextColor->update( );
+
+    double rgb[ 3 ];
+    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->Modified( );
+
+    } // rof
+    this->_render( );
+
+  } // fi
+}
+
+#endif // cpPlugins_QT4
+
+// eof - $RCSfile$
diff --git a/lib/cpPlugins/ActorAxesProperties.h b/lib/cpPlugins/ActorAxesProperties.h
new file mode 100644 (file)
index 0000000..244b597
--- /dev/null
@@ -0,0 +1,50 @@
+#ifndef __CPPLUGINS__ACTORAXESPROPERTIES__H__
+#define __CPPLUGINS__ACTORAXESPROPERTIES__H__
+
+#include <cpPlugins/ActorProperties.h>
+
+#ifdef cpPlugins_QT4
+
+#include <QWidget>
+
+// -------------------------------------------------------------------------
+namespace Ui
+{
+  class ActorAxesProperties;
+}
+
+// -------------------------------------------------------------------------
+namespace cpPlugins
+{
+  /**
+   */
+  class cpPlugins_EXPORT ActorAxesProperties
+    : public ActorProperties
+  {
+    Q_OBJECT;
+
+  public:
+    explicit ActorAxesProperties( QWidget* parent = 0 );
+    virtual ~ActorAxesProperties( );
+
+    virtual bool addActor( vtkProp* obj ) ITK_OVERRIDE;
+
+  protected:
+    virtual void _updateWidgets( ) ITK_OVERRIDE;
+
+  protected slots:
+    void _Scale( double v );
+    void _TextChanged( const QString& text );
+    void _TextColor( );
+
+  protected:
+    Ui::ActorAxesProperties* m_UI;
+  };
+
+} // ecapseman
+
+#endif // cpPlugins_QT4
+
+#endif // __CPPLUGINS__ACTORAXESPROPERTIES__H__
+
+// eof - $RCSfile$
diff --git a/lib/cpPlugins/ActorAxesProperties.ui b/lib/cpPlugins/ActorAxesProperties.ui
new file mode 100644 (file)
index 0000000..078f1bb
--- /dev/null
@@ -0,0 +1,157 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ActorAxesProperties</class>
+ <widget class="QWidget" name="ActorAxesProperties">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>339</width>
+    <height>223</height>
+   </rect>
+  </property>
+  <property name="minimumSize">
+   <size>
+    <width>339</width>
+    <height>223</height>
+   </size>
+  </property>
+  <property name="maximumSize">
+   <size>
+    <width>339</width>
+    <height>223</height>
+   </size>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout">
+     <item>
+      <widget class="QLabel" name="label">
+       <property name="minimumSize">
+        <size>
+         <width>39</width>
+         <height>17</height>
+        </size>
+       </property>
+       <property name="maximumSize">
+        <size>
+         <width>39</width>
+         <height>17</height>
+        </size>
+       </property>
+       <property name="text">
+        <string>Scale:</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QDoubleSpinBox" name="Scale">
+       <property name="decimals">
+        <number>4</number>
+       </property>
+       <property name="minimum">
+        <double>0.000100000000000</double>
+       </property>
+       <property name="maximum">
+        <double>100000.000000000000000</double>
+       </property>
+       <property name="value">
+        <double>1.000000000000000</double>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_2">
+     <item>
+      <widget class="QLabel" name="label_2">
+       <property name="minimumSize">
+        <size>
+         <width>44</width>
+         <height>17</height>
+        </size>
+       </property>
+       <property name="maximumSize">
+        <size>
+         <width>44</width>
+         <height>17</height>
+        </size>
+       </property>
+       <property name="text">
+        <string>X text:</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QLineEdit" name="XText"/>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_3">
+     <item>
+      <widget class="QLabel" name="label_3">
+       <property name="minimumSize">
+        <size>
+         <width>44</width>
+         <height>17</height>
+        </size>
+       </property>
+       <property name="maximumSize">
+        <size>
+         <width>44</width>
+         <height>17</height>
+        </size>
+       </property>
+       <property name="text">
+        <string>Y text:</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QLineEdit" name="YText"/>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_4">
+     <item>
+      <widget class="QLabel" name="label_4">
+       <property name="minimumSize">
+        <size>
+         <width>43</width>
+         <height>17</height>
+        </size>
+       </property>
+       <property name="maximumSize">
+        <size>
+         <width>43</width>
+         <height>17</height>
+        </size>
+       </property>
+       <property name="text">
+        <string>Z text:</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QLineEdit" name="ZText"/>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <widget class="QPushButton" name="TextColor">
+     <property name="text">
+      <string>Text color</string>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/lib/cpPlugins/ActorImageProperties.cxx b/lib/cpPlugins/ActorImageProperties.cxx
new file mode 100644 (file)
index 0000000..7ff91d0
--- /dev/null
@@ -0,0 +1,245 @@
+#include <cpPlugins/ActorImageProperties.h>
+
+#ifdef cpPlugins_QT4
+
+#include <cpPlugins/ui_ActorImageProperties.h>
+
+#include <vtkImageActor.h>
+#include <vtkImageData.h>
+#include <vtkImageMapper3D.h>
+#include <vtkImageProperty.h>
+
+// -------------------------------------------------------------------------
+cpPlugins::ActorImageProperties::
+ActorImageProperties( QWidget* parent )
+  : cpPlugins::ActorProperties( parent ),
+    m_UI( new Ui::ActorImageProperties )
+{
+  this->m_UI->setupUi( this );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::ActorImageProperties::
+~ActorImageProperties( )
+{
+  delete this->m_UI;
+}
+
+// -------------------------------------------------------------------------
+bool cpPlugins::ActorImageProperties::
+addActor( vtkProp* obj )
+{
+  auto actor = dynamic_cast< vtkImageActor* >( obj );
+  if( actor != NULL )
+  {
+    this->m_Actors.insert( obj );
+    if( this->m_Actors.size( ) == 1 )
+      this->_updateWidgets( );
+    return( true );
+  }
+  else
+    return( false );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::ActorImageProperties::
+_updateWidgets( )
+{
+  auto actor =
+    dynamic_cast< vtkImageActor* >( this->m_Actors.begin( )->GetPointer( ) );
+  if( actor == NULL )
+    return;
+
+  // Get properties
+  auto prop = actor->GetProperty( );
+  auto mapper = actor->GetMapper( );
+  auto image = mapper->GetInput( );
+  double r[ 2 ];
+  image->GetScalarRange( r );
+  double win = prop->GetColorWindow( );
+  double lev = prop->GetColorLevel( );
+  double op = prop->GetOpacity( );
+  int interp = prop->GetInterpolationType( );
+
+  this->m_UI->ValueWindow->setMinimum( 0 );
+  this->m_UI->ValueWindow->setMaximum( r[ 1 ] - r[ 0 ] );
+  this->m_UI->ValueLevel->setMinimum( r[ 0 ] );
+  this->m_UI->ValueLevel->setMaximum( r[ 1 ] );
+  this->m_UI->ValueWindow->setValue( win );
+  this->m_UI->ValueLevel->setValue( lev );
+
+  double w = win / ( r[ 1 ] - r[ 0 ] );
+  double l = ( lev - r[ 0 ] ) / ( r[ 1 ] - r[ 0 ] );
+
+  op *= double( this->m_UI->Opacity->maximum( ) );
+  this->m_UI->Opacity->setValue( int( op ) );
+
+  w *= double( this->m_UI->Window->maximum( ) );
+  this->m_UI->Window->setValue( int( w ) );
+
+  l *= double( this->m_UI->Level->maximum( ) );
+  this->m_UI->Level->setValue( int( l ) );
+
+  if( interp == VTK_CUBIC_INTERPOLATION )
+    this->m_UI->Interpolation->setCurrentIndex( 0 );
+  else if( interp == VTK_LINEAR_INTERPOLATION )
+    this->m_UI->Interpolation->setCurrentIndex( 1 );
+  else if( interp == VTK_NEAREST_INTERPOLATION )
+    this->m_UI->Interpolation->setCurrentIndex( 2 );
+
+  // Connect stuff
+  this->connect(
+    this->m_UI->Opacity, SIGNAL( valueChanged( int ) ),
+    this, SLOT( _Opacity( int ) )
+    );
+  this->connect(
+    this->m_UI->Window, SIGNAL( valueChanged( int ) ),
+    this, SLOT( _Window( int ) )
+    );
+  this->connect(
+    this->m_UI->Level, SIGNAL( valueChanged( int ) ),
+    this, SLOT( _Level( int ) )
+    );
+  this->connect(
+    this->m_UI->ValueWindow, SIGNAL( valueChanged( double ) ),
+    this, SLOT( _Window( double ) )
+    );
+  this->connect(
+    this->m_UI->ValueLevel, SIGNAL( valueChanged( double ) ),
+    this, SLOT( _Level( double ) )
+    );
+  this->connect(
+    this->m_UI->Interpolation, SIGNAL( currentIndexChanged( int ) ),
+    this, SLOT( _Interpolation( int ) )
+    );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::ActorImageProperties::
+_Opacity( int v )
+{
+  double op = double( v ) / double( this->m_UI->Opacity->maximum( ) );
+  auto aIt = this->m_Actors.begin( );
+  for( ; aIt != this->m_Actors.end( ); ++aIt )
+  {
+    auto ma = dynamic_cast< vtkImageActor* >( aIt->GetPointer( ) );
+    ma->GetProperty( )->SetOpacity( op );
+    ma->Modified( );
+
+  } // rof
+  this->_render( );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::ActorImageProperties::
+_Window( int v )
+{
+  double x = this->m_UI->ValueWindow->minimum( );
+  double y = this->m_UI->ValueWindow->maximum( );
+  double z = double( v ) / double( this->m_UI->Window->maximum( ) );
+  double w = ( ( y - x ) * z ) + x;
+  bool prev = this->m_UI->ValueWindow->blockSignals( true );
+  this->m_UI->ValueWindow->setValue( w );
+  this->m_UI->ValueWindow->blockSignals( prev );
+  auto aIt = this->m_Actors.begin( );
+  for( ; aIt != this->m_Actors.end( ); ++aIt )
+  {
+    auto ma = dynamic_cast< vtkImageActor* >( aIt->GetPointer( ) );
+    ma->GetProperty( )->SetColorWindow( w );
+    ma->Modified( );
+
+  } // rof
+  this->_render( );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::ActorImageProperties::
+_Level( int v )
+{
+  double x = this->m_UI->ValueLevel->minimum( );
+  double y = this->m_UI->ValueLevel->maximum( );
+  double z = double( v ) / double( this->m_UI->Level->maximum( ) );
+  double l = ( ( y - x ) * z ) + x;
+  bool prev = this->m_UI->ValueLevel->blockSignals( true );
+  this->m_UI->ValueLevel->setValue( l );
+  this->m_UI->ValueLevel->blockSignals( prev );
+  auto aIt = this->m_Actors.begin( );
+  for( ; aIt != this->m_Actors.end( ); ++aIt )
+  {
+    auto ma = dynamic_cast< vtkImageActor* >( aIt->GetPointer( ) );
+    ma->GetProperty( )->SetColorLevel( l );
+    ma->Modified( );
+
+  } // rof
+  this->_render( );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::ActorImageProperties::
+_Window( double v )
+{
+  auto aIt = this->m_Actors.begin( );
+  for( ; aIt != this->m_Actors.end( ); ++aIt )
+  {
+    auto ma = dynamic_cast< vtkImageActor* >( aIt->GetPointer( ) );
+    ma->GetProperty( )->SetColorWindow( v );
+    ma->Modified( );
+
+  } // rof
+  this->_render( );
+
+  double x = this->m_UI->ValueWindow->minimum( );
+  double y = this->m_UI->ValueWindow->maximum( );
+  double z = ( v - x ) / ( y - x );
+  double w = double( z ) * double( this->m_UI->Window->maximum( ) );
+  bool prev = this->m_UI->Window->blockSignals( true );
+  this->m_UI->Window->setValue( int( w ) );
+  this->m_UI->Window->blockSignals( prev );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::ActorImageProperties::
+_Level( double v )
+{
+  auto aIt = this->m_Actors.begin( );
+  for( ; aIt != this->m_Actors.end( ); ++aIt )
+  {
+    auto ma = dynamic_cast< vtkImageActor* >( aIt->GetPointer( ) );
+    ma->GetProperty( )->SetColorLevel( v );
+    ma->Modified( );
+
+  } // rof
+  this->_render( );
+
+  double x = this->m_UI->ValueLevel->minimum( );
+  double y = this->m_UI->ValueLevel->maximum( );
+  double z = ( v - x ) / ( y - x );
+  double l = double( z ) * double( this->m_UI->Level->maximum( ) );
+  bool prev = this->m_UI->Level->blockSignals( true );
+  this->m_UI->Level->setValue( int( l ) );
+  this->m_UI->Level->blockSignals( prev );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::ActorImageProperties::
+_Interpolation( int v )
+{
+  int interp = VTK_NEAREST_INTERPOLATION;
+  if     ( v == 0 ) interp = VTK_CUBIC_INTERPOLATION;
+  else if( v == 1 ) interp = VTK_LINEAR_INTERPOLATION;
+  else if( v == 2 ) interp = VTK_NEAREST_INTERPOLATION;
+
+  auto aIt = this->m_Actors.begin( );
+  for( ; aIt != this->m_Actors.end( ); ++aIt )
+  {
+    auto ma = dynamic_cast< vtkImageActor* >( aIt->GetPointer( ) );
+    ma->GetProperty( )->SetInterpolationType( interp );
+    ma->Modified( );
+
+  } // rof
+  this->_render( );
+}
+
+#endif // cpPlugins_QT4
+
+// eof - $RCSfile$
diff --git a/lib/cpPlugins/ActorImageProperties.h b/lib/cpPlugins/ActorImageProperties.h
new file mode 100644 (file)
index 0000000..5c55562
--- /dev/null
@@ -0,0 +1,53 @@
+#ifndef __CPPLUGINS__ACTORIMAGEPROPERTIES__H__
+#define __CPPLUGINS__ACTORIMAGEPROPERTIES__H__
+
+#include <cpPlugins/ActorProperties.h>
+
+#ifdef cpPlugins_QT4
+
+#include <QWidget>
+
+// -------------------------------------------------------------------------
+namespace Ui
+{
+  class ActorImageProperties;
+}
+
+// -------------------------------------------------------------------------
+namespace cpPlugins
+{
+  /**
+   */
+  class cpPlugins_EXPORT ActorImageProperties
+    : public ActorProperties
+  {
+    Q_OBJECT;
+
+  public:
+    explicit ActorImageProperties( QWidget* parent = 0 );
+    virtual ~ActorImageProperties( );
+
+    virtual bool addActor( vtkProp* obj ) ITK_OVERRIDE;
+
+  protected:
+    virtual void _updateWidgets( ) ITK_OVERRIDE;
+
+  protected slots:
+    void _Opacity( int v );
+    void _Window( int v );
+    void _Level( int v );
+    void _Window( double v );
+    void _Level( double v );
+    void _Interpolation( int v );
+
+  protected:
+    Ui::ActorImageProperties* m_UI;
+  };
+
+} // ecapseman
+
+#endif // cpPlugins_QT4
+
+#endif // __CPPLUGINS__ACTORIMAGEPROPERTIES__H__
+
+// eof - $RCSfile$
diff --git a/lib/cpPlugins/ActorImageProperties.ui b/lib/cpPlugins/ActorImageProperties.ui
new file mode 100644 (file)
index 0000000..249a055
--- /dev/null
@@ -0,0 +1,215 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ActorImageProperties</class>
+ <widget class="QWidget" name="ActorImageProperties">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>626</width>
+    <height>158</height>
+   </rect>
+  </property>
+  <property name="minimumSize">
+   <size>
+    <width>626</width>
+    <height>158</height>
+   </size>
+  </property>
+  <property name="maximumSize">
+   <size>
+    <width>626</width>
+    <height>158</height>
+   </size>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout">
+     <item>
+      <widget class="QLabel" name="label">
+       <property name="minimumSize">
+        <size>
+         <width>92</width>
+         <height>17</height>
+        </size>
+       </property>
+       <property name="maximumSize">
+        <size>
+         <width>92</width>
+         <height>17</height>
+        </size>
+       </property>
+       <property name="text">
+        <string>Interpolation:</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QComboBox" name="Interpolation">
+       <item>
+        <property name="text">
+         <string>Cubic</string>
+        </property>
+       </item>
+       <item>
+        <property name="text">
+         <string>Linear</string>
+        </property>
+       </item>
+       <item>
+        <property name="text">
+         <string>Nearest</string>
+        </property>
+       </item>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_2">
+     <item>
+      <widget class="QLabel" name="label_2">
+       <property name="minimumSize">
+        <size>
+         <width>59</width>
+         <height>17</height>
+        </size>
+       </property>
+       <property name="maximumSize">
+        <size>
+         <width>59</width>
+         <height>17</height>
+        </size>
+       </property>
+       <property name="text">
+        <string>Window:</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QDoubleSpinBox" name="ValueWindow">
+       <property name="decimals">
+        <number>4</number>
+       </property>
+       <property name="minimum">
+        <double>-100000.000000000000000</double>
+       </property>
+       <property name="maximum">
+        <double>100000.000000000000000</double>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QSlider" name="Window">
+       <property name="minimum">
+        <number>0</number>
+       </property>
+       <property name="maximum">
+        <number>1000</number>
+       </property>
+       <property name="value">
+        <number>0</number>
+       </property>
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_3">
+     <item>
+      <widget class="QLabel" name="label_4">
+       <property name="minimumSize">
+        <size>
+         <width>39</width>
+         <height>17</height>
+        </size>
+       </property>
+       <property name="maximumSize">
+        <size>
+         <width>39</width>
+         <height>17</height>
+        </size>
+       </property>
+       <property name="text">
+        <string>Level:</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QDoubleSpinBox" name="ValueLevel">
+       <property name="decimals">
+        <number>4</number>
+       </property>
+       <property name="minimum">
+        <double>-100000.000000000000000</double>
+       </property>
+       <property name="maximum">
+        <double>100000.000000000000000</double>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QSlider" name="Level">
+       <property name="minimum">
+        <number>0</number>
+       </property>
+       <property name="maximum">
+        <number>1000</number>
+       </property>
+       <property name="value">
+        <number>0</number>
+       </property>
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_4">
+     <item>
+      <widget class="QLabel" name="label_3">
+       <property name="minimumSize">
+        <size>
+         <width>55</width>
+         <height>17</height>
+        </size>
+       </property>
+       <property name="maximumSize">
+        <size>
+         <width>55</width>
+         <height>17</height>
+        </size>
+       </property>
+       <property name="text">
+        <string>Opacity:</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QSlider" name="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>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/lib/cpPlugins/ActorPolyDataProperties.cxx b/lib/cpPlugins/ActorPolyDataProperties.cxx
new file mode 100644 (file)
index 0000000..5fd9fe1
--- /dev/null
@@ -0,0 +1,254 @@
+#include <cpPlugins/ActorPolyDataProperties.h>
+
+#ifdef cpPlugins_QT4
+
+#include <cpPlugins/ui_ActorPolyDataProperties.h>
+#include <QColorDialog>
+#include <vtkActor.h>
+#include <vtkMapper.h>
+#include <vtkProperty.h>
+
+// -------------------------------------------------------------------------
+cpPlugins::ActorPolyDataProperties::
+ActorPolyDataProperties( QWidget* parent )
+  : cpPlugins::ActorProperties( parent ),
+    m_UI( new Ui::ActorPolyDataProperties )
+{
+  this->m_UI->setupUi( this );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::ActorPolyDataProperties::
+~ActorPolyDataProperties( )
+{
+  delete this->m_UI;
+}
+
+// -------------------------------------------------------------------------
+bool cpPlugins::ActorPolyDataProperties::
+addActor( vtkProp* obj )
+{
+  auto actor = dynamic_cast< vtkActor* >( obj );
+  if( actor != NULL )
+  {
+    this->m_Actors.insert( obj );
+    if( this->m_Actors.size( ) == 1 )
+      this->_updateWidgets( );
+    return( true );
+  }
+  else
+    return( false );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::ActorPolyDataProperties::
+_updateWidgets( )
+{
+  auto actor =
+    dynamic_cast< vtkActor* >( this->m_Actors.begin( )->GetPointer( ) );
+  if( actor == NULL )
+    return;
+
+  // Get properties
+  auto mapp = actor->GetMapper( );
+  auto prop = actor->GetProperty( );
+  double rgb[ 3 ];
+  prop->GetColor( rgb );
+  rgb[ 0 ] *= double( 255 );
+  rgb[ 1 ] *= double( 255 );
+  rgb[ 2 ] *= double( 255 );
+  double op = prop->GetOpacity( );
+  double lw = prop->GetLineWidth( );
+  double ps = prop->GetPointSize( );
+  bool sv = ( mapp->GetScalarVisibility( ) == 1 );
+  int rep = prop->GetRepresentation( );
+
+  // Set widget values
+  auto palette = this->m_UI->Color->palette( );
+  palette.setColor(
+    QPalette::Button, QColor( rgb[ 0 ], rgb[ 1 ], rgb[ 2 ] )
+    );
+  this->m_UI->Color->setAutoFillBackground( true );
+  this->m_UI->Color->setPalette( palette );
+
+  op *= double( this->m_UI->Opacity->maximum( ) );
+  this->m_UI->Opacity->setValue( int( op ) );
+  this->m_UI->LineWidth->setValue( int( lw ) );
+  this->m_UI->PointSize->setValue( int( ps ) );
+  this->m_UI->ScalarVisibility->setChecked( sv );
+
+  if( rep == VTK_POINTS )
+    this->m_UI->Representation->setCurrentIndex( 0 );
+  else if( rep == VTK_WIREFRAME )
+    this->m_UI->Representation->setCurrentIndex( 1 );
+  else if( rep == VTK_SURFACE )
+    this->m_UI->Representation->setCurrentIndex( 2 );
+
+  // Connect stuff
+  this->connect(
+    this->m_UI->ScalarVisibility, SIGNAL( stateChanged( int ) ),
+    this, SLOT( _ScalarVisibility( int ) )
+    );
+  this->connect(
+    this->m_UI->Color, SIGNAL( clicked( ) ),
+    this, SLOT( _Color( ) )
+    );
+  this->connect(
+    this->m_UI->Opacity, SIGNAL( valueChanged( int ) ),
+    this, SLOT( _Opacity( int ) )
+    );
+  this->connect(
+    this->m_UI->LineWidth, SIGNAL( valueChanged( int ) ),
+    this, SLOT( _LineWidth( int ) )
+    );
+  this->connect(
+    this->m_UI->PointSize, SIGNAL( valueChanged( int ) ),
+    this, SLOT( _PointSize( int ) )
+    );
+  this->connect(
+    this->m_UI->Representation, SIGNAL( currentIndexChanged( int ) ),
+    this, SLOT( _Representation( int ) )
+    );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::ActorPolyDataProperties::
+_ScalarVisibility( int v )
+{
+  if( this->m_Actors.size( ) == 0 )
+    return;
+  QPalette pal = this->m_UI->Color->palette( );
+  QColor color = pal.color( QPalette::Button );
+  double rgb[ 3 ];
+  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< vtkActor* >( aIt->GetPointer( ) );
+    if( !( this->m_UI->ScalarVisibility->isChecked( ) ) )
+    {
+      ma->GetMapper( )->ScalarVisibilityOff( );
+      ma->GetProperty( )->SetColor( rgb );
+    }
+    else
+      ma->GetMapper( )->ScalarVisibilityOn( );
+    ma->Modified( );
+
+  } // rof
+  this->_render( );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::ActorPolyDataProperties::
+_Color( )
+{
+  if( this->m_Actors.size( ) == 0 )
+    return;
+  QPalette pal = this->m_UI->Color->palette( );
+  QColor color =
+    QColorDialog::getColor(
+      pal.color( QPalette::Button ),
+      this,
+      "Select Color",
+      QColorDialog::DontUseNativeDialog
+      );
+  if( color.isValid( ) )
+  {
+    pal.setColor( QPalette::Button, color );
+    this->m_UI->Color->setAutoFillBackground( true );
+    this->m_UI->Color->setPalette( pal );
+    this->m_UI->Color->update( );
+    this->_ScalarVisibility( 0 );
+
+  } // fi
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::ActorPolyDataProperties::
+_Opacity( int v )
+{
+  double op = double( v ) / double( this->m_UI->Opacity->maximum( ) );
+  auto aIt = this->m_Actors.begin( );
+  for( ; aIt != this->m_Actors.end( ); ++aIt )
+  {
+    auto ma = dynamic_cast< vtkActor* >( aIt->GetPointer( ) );
+    ma->GetProperty( )->SetOpacity( op );
+    ma->Modified( );
+
+  } // rof
+  this->_render( );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::ActorPolyDataProperties::
+_LineWidth( int v )
+{
+  auto aIt = this->m_Actors.begin( );
+  for( ; aIt != this->m_Actors.end( ); ++aIt )
+  {
+    auto ma = dynamic_cast< vtkActor* >( aIt->GetPointer( ) );
+    ma->GetProperty( )->SetLineWidth( v );
+    ma->Modified( );
+
+  } // rof
+  this->_render( );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::ActorPolyDataProperties::
+_PointSize( int v )
+{
+  auto aIt = this->m_Actors.begin( );
+  for( ; aIt != this->m_Actors.end( ); ++aIt )
+  {
+    auto ma = dynamic_cast< vtkActor* >( aIt->GetPointer( ) );
+    ma->GetProperty( )->SetPointSize( v );
+    ma->Modified( );
+
+  } // rof
+  this->_render( );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::ActorPolyDataProperties::
+_Representation( int v )
+{
+  int rep = VTK_POINTS + VTK_WIREFRAME + VTK_SURFACE;
+  if     ( v == 0 ) rep = VTK_POINTS;
+  else if( v == 1 ) rep = VTK_WIREFRAME;
+  else if( v == 2 ) rep = VTK_SURFACE;
+
+    auto aIt = this->m_Actors.begin( );
+    for( ; aIt != this->m_Actors.end( ); ++aIt )
+    {
+      auto ma = dynamic_cast< vtkActor* >( aIt->GetPointer( ) );
+      auto prop = ma->GetProperty( );
+      if( rep != VTK_POINTS && rep != VTK_WIREFRAME && rep != VTK_SURFACE )
+      {
+        double rgb[ 3 ];
+        prop->GetColor( rgb );
+        rgb[ 0 ] = double( 1 ) - rgb[ 0 ];
+        rgb[ 1 ] = double( 1 ) - rgb[ 1 ];
+        rgb[ 2 ] = double( 1 ) - rgb[ 2 ];
+        prop->SetRepresentation( VTK_SURFACE );
+        prop->SetEdgeColor( rgb );
+        prop->EdgeVisibilityOn( );
+      }
+      else
+      {
+        prop->EdgeVisibilityOff( );
+        prop->SetRepresentation( rep );
+
+      } // fi
+      ma->Modified( );
+
+    } // rof
+  this->_render( );
+}
+
+#endif // cpPlugins_QT4
+
+// eof - $RCSfile$
diff --git a/lib/cpPlugins/ActorPolyDataProperties.h b/lib/cpPlugins/ActorPolyDataProperties.h
new file mode 100644 (file)
index 0000000..457ee50
--- /dev/null
@@ -0,0 +1,53 @@
+#ifndef __CPPLUGINS__ACTORPOLYDATAPROPERTIES__H__
+#define __CPPLUGINS__ACTORPOLYDATAPROPERTIES__H__
+
+#include <cpPlugins/ActorProperties.h>
+
+#ifdef cpPlugins_QT4
+
+#include <QWidget>
+
+// -------------------------------------------------------------------------
+namespace Ui
+{
+  class ActorPolyDataProperties;
+}
+
+// -------------------------------------------------------------------------
+namespace cpPlugins
+{
+  /**
+   */
+  class cpPlugins_EXPORT ActorPolyDataProperties
+    : public ActorProperties
+  {
+    Q_OBJECT;
+
+  public:
+    explicit ActorPolyDataProperties( QWidget* parent = 0 );
+    virtual ~ActorPolyDataProperties( );
+
+    virtual bool addActor( vtkProp* obj ) ITK_OVERRIDE;
+
+  protected:
+    virtual void _updateWidgets( ) ITK_OVERRIDE;
+
+  protected slots:
+    void _ScalarVisibility( int v );
+    void _Color( );
+    void _Opacity( int v );
+    void _LineWidth( int v );
+    void _PointSize( int v );
+    void _Representation( int v );
+
+  protected:
+    Ui::ActorPolyDataProperties* m_UI;
+  };
+
+} // ecapseman
+
+#endif // cpPlugins_QT4
+
+#endif // __CPPLUGINS__ACTORPOLYDATAPROPERTIES__H__
+
+// eof - $RCSfile$
diff --git a/lib/cpPlugins/ActorPolyDataProperties.ui b/lib/cpPlugins/ActorPolyDataProperties.ui
new file mode 100644 (file)
index 0000000..08ec1a8
--- /dev/null
@@ -0,0 +1,233 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ActorPolyDataProperties</class>
+ <widget class="QWidget" name="ActorPolyDataProperties">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>398</width>
+    <height>193</height>
+   </rect>
+  </property>
+  <property name="minimumSize">
+   <size>
+    <width>398</width>
+    <height>193</height>
+   </size>
+  </property>
+  <property name="maximumSize">
+   <size>
+    <width>398</width>
+    <height>193</height>
+   </size>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout">
+     <item>
+      <widget class="QLabel" name="label_4">
+       <property name="minimumSize">
+        <size>
+         <width>107</width>
+         <height>17</height>
+        </size>
+       </property>
+       <property name="maximumSize">
+        <size>
+         <width>107</width>
+         <height>17</height>
+        </size>
+       </property>
+       <property name="text">
+        <string>Representation:</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QComboBox" name="Representation">
+       <item>
+        <property name="text">
+         <string>Points</string>
+        </property>
+       </item>
+       <item>
+        <property name="text">
+         <string>Wireframe</string>
+        </property>
+       </item>
+       <item>
+        <property name="text">
+         <string>Surface</string>
+        </property>
+       </item>
+       <item>
+        <property name="text">
+         <string>Surface with edges</string>
+        </property>
+       </item>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_2">
+     <item>
+      <widget class="QLabel" name="label">
+       <property name="minimumSize">
+        <size>
+         <width>73</width>
+         <height>17</height>
+        </size>
+       </property>
+       <property name="maximumSize">
+        <size>
+         <width>73</width>
+         <height>17</height>
+        </size>
+       </property>
+       <property name="text">
+        <string>Line width:</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QSlider" name="LineWidth">
+       <property name="minimum">
+        <number>1</number>
+       </property>
+       <property name="maximum">
+        <number>10</number>
+       </property>
+       <property name="value">
+        <number>1</number>
+       </property>
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_3">
+     <item>
+      <widget class="QLabel" name="label_2">
+       <property name="minimumSize">
+        <size>
+         <width>68</width>
+         <height>17</height>
+        </size>
+       </property>
+       <property name="maximumSize">
+        <size>
+         <width>68</width>
+         <height>17</height>
+        </size>
+       </property>
+       <property name="text">
+        <string>Point size:</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QSlider" name="PointSize">
+       <property name="minimum">
+        <number>1</number>
+       </property>
+       <property name="maximum">
+        <number>10</number>
+       </property>
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_4">
+     <item>
+      <widget class="QLabel" name="label_3">
+       <property name="minimumSize">
+        <size>
+         <width>55</width>
+         <height>17</height>
+        </size>
+       </property>
+       <property name="maximumSize">
+        <size>
+         <width>55</width>
+         <height>17</height>
+        </size>
+       </property>
+       <property name="text">
+        <string>Opacity:</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QSlider" name="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_5">
+     <item>
+      <widget class="QCheckBox" name="ScalarVisibility">
+       <property name="minimumSize">
+        <size>
+         <width>135</width>
+         <height>22</height>
+        </size>
+       </property>
+       <property name="maximumSize">
+        <size>
+         <width>135</width>
+         <height>22</height>
+        </size>
+       </property>
+       <property name="text">
+        <string>Scalar visibility?</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QPushButton" name="Color">
+       <property name="minimumSize">
+        <size>
+         <width>98</width>
+         <height>27</height>
+        </size>
+       </property>
+       <property name="maximumSize">
+        <size>
+         <width>16777215</width>
+         <height>27</height>
+        </size>
+       </property>
+       <property name="text">
+        <string>Color</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/lib/cpPlugins/ActorProperties.cxx b/lib/cpPlugins/ActorProperties.cxx
new file mode 100644 (file)
index 0000000..eeb2de1
--- /dev/null
@@ -0,0 +1,38 @@
+#include <cpPlugins/ActorProperties.h>
+
+#ifdef cpPlugins_QT4
+
+// -------------------------------------------------------------------------
+cpPlugins::ActorProperties::
+ActorProperties( QWidget* parent )
+  : QWidget( parent )
+{
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::ActorProperties::
+~ActorProperties( )
+{
+}
+
+// -------------------------------------------------------------------------
+bool cpPlugins::ActorProperties::
+addRenderWindow( vtkRenderWindow* win )
+{
+  if( win == NULL )
+    return( false );
+  this->m_Windows.insert( win );
+  return( true );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::ActorProperties::
+_render( )
+{
+  for( auto i = this->m_Windows.begin( ); i != this->m_Windows.end( ); ++i )
+    ( *i )->Render( );
+}
+
+#endif // cpPlugins_QT4
+
+// eof - $RCSfile$
diff --git a/lib/cpPlugins/ActorProperties.h b/lib/cpPlugins/ActorProperties.h
new file mode 100644 (file)
index 0000000..9bf68e4
--- /dev/null
@@ -0,0 +1,60 @@
+#ifndef __CPPLUGINS__ACTORPROPERTIES__H__
+#define __CPPLUGINS__ACTORPROPERTIES__H__
+
+#include <cpPlugins/Config.h>
+
+#ifdef cpPlugins_QT4
+
+#include <set>
+#include <QWidget>
+#include <vtkProp.h>
+#include <vtkRenderWindow.h>
+#include <vtkSmartPointer.h>
+
+// -------------------------------------------------------------------------
+namespace cpPlugins
+{
+  /**
+   */
+  class cpPlugins_EXPORT ActorProperties
+    : public QWidget
+  {
+    Q_OBJECT;
+
+  public:
+    template< class _TObj >
+    struct TCmp
+    {
+      bool operator()(
+        const vtkSmartPointer< _TObj >& a,
+        const vtkSmartPointer< _TObj >& b ) const
+        { return( a.GetPointer( ) < b.GetPointer( ) ); }
+    };
+    typedef vtkSmartPointer< vtkProp >                         TActor;
+    typedef vtkSmartPointer< vtkRenderWindow >                 TRenderWindow;
+    typedef std::set< TActor, TCmp< vtkProp > >                TActors;
+    typedef std::set< TRenderWindow, TCmp< vtkRenderWindow > > TWindows;
+
+  public:
+    explicit ActorProperties( QWidget* parent = 0 );
+    virtual ~ActorProperties( );
+
+    virtual bool addActor( vtkProp* obj ) = 0;
+    bool addRenderWindow( vtkRenderWindow* win );
+    void _render( );
+
+  protected:
+    virtual void _updateWidgets( ) = 0;
+
+  protected:
+    TActors  m_Actors;
+    TWindows m_Windows;
+  };
+
+} // ecapseman
+
+#endif // cpPlugins_QT4
+
+#endif // __CPPLUGINS__ACTORPROPERTIES__H__
+
+// eof - $RCSfile$
index 87b41c69144d7d4fe478cc52a699fd64e8e1fea9..d126c3fedc38b896414e8ee6c06c07dca1a3e932 100644 (file)
@@ -2,25 +2,31 @@
 
 #ifdef cpPlugins_QT4
 
+#include <cpPlugins/ActorAxesProperties.h>
+#include <cpPlugins/ActorImageProperties.h>
+#include <cpPlugins/ActorPolyDataProperties.h>
+
 #include <vtkActor.h>
 #include <vtkAxesActor.h>
 #include <vtkImageActor.h>
-#include <vtkImageData.h>
-#include <vtkImageProperty.h>
-#include <vtkMapper.h>
-#include <vtkProperty.h>
-
-#include <QCheckBox>
-#include <QColorDialog>
-#include <QDoubleSpinBox>
-#include <QPushButton>
-#include <QSlider>
+/*
+  #include <vtkImageData.h>
+  #include <vtkImageProperty.h>
+  #include <vtkMapper.h>
+  #include <vtkProperty.h>
+
+  #include <QCheckBox>
+  #include <QColorDialog>
+  #include <QDoubleSpinBox>
+  #include <QPushButton>
+  #include <QSlider>
+*/
 
 // -------------------------------------------------------------------------
 cpPlugins::ActorPropertiesQtDialog::
 ActorPropertiesQtDialog( QWidget* parent, Qt::WindowFlags f )
   : QDialog( parent, f ),
-    m_WidgetsUpdated( false )
+    m_MainWidget( NULL )
 {
   this->m_Title = new QLabel( this );
   this->m_Title->setText( "Visualization properties" );
@@ -34,52 +40,75 @@ ActorPropertiesQtDialog( QWidget* parent, Qt::WindowFlags f )
 cpPlugins::ActorPropertiesQtDialog::
 ~ActorPropertiesQtDialog( )
 {
-  this->m_Actors.clear( );
-  this->m_Windows.clear( );
-  delete this->m_Title;
-  delete this->m_ToolsLayout;
-  delete this->m_MainLayout;
 }
 
 // -------------------------------------------------------------------------
 bool cpPlugins::ActorPropertiesQtDialog::
 addActor( vtkProp* obj )
 {
-  if( obj == NULL )
-    return( false );
-
-  if( this->m_Actors.size( ) > 0 )
-  {
-    bool     s = this->_addActor< vtkAxesActor >( obj );
-    if( !s ) s = this->_addActor< vtkImageActor >( obj );
-    if( !s ) s = this->_addActor< vtkActor >( obj );
-    return( s );
-  }
-  else
+  if( this->m_MainWidget == NULL )
   {
-    this->m_Actors.insert( obj );
-    this->m_WidgetsUpdated = false;
-    return( true );
+    std::stringstream title;
+    title << "Parameters for an object of class";
+    auto mesh = dynamic_cast< vtkActor* >( obj );
+    auto axes = dynamic_cast< vtkAxesActor* >( obj );
+    auto image = dynamic_cast< vtkImageActor* >( obj );
+    if( mesh != NULL )
+    {
+      title << "\"Mesh\"";
+      this->m_MainWidget = new cpPlugins::ActorPolyDataProperties( this );
+    }
+    else if( axes != NULL )
+    {
+      title << "\"Axes\"";
+      this->m_MainWidget = new cpPlugins::ActorAxesProperties( this );
+    }
+    else if( image != NULL )
+    {
+      title << "\"Image\"";
+      this->m_MainWidget = new cpPlugins::ActorImageProperties( this );
+    }
+    /* TODO
+       else if( axes != NULL )
+    */
+
+    if( this->m_MainWidget != NULL )
+    {
+      this->m_Title->setText( title.str( ).c_str( ) );
+      this->m_ToolsLayout->addWidget( this->m_MainWidget );
+      this->m_Buttons = new QDialogButtonBox( QDialogButtonBox::Ok );
+      this->connect(
+        this->m_Buttons, SIGNAL( accepted( ) ), this, SLOT( accept( ) )
+        );
+      this->connect(
+        this->m_Buttons, SIGNAL( rejected( ) ), this, SLOT( reject( ) )
+        );
+      this->m_ToolsLayout->addWidget( this->m_Buttons );
+
+    } // fi
 
   } // fi
+
+  if( this->m_MainWidget != NULL )
+    return( this->m_MainWidget->addActor( obj ) );
+  else
+    return( false );
 }
 
 // -------------------------------------------------------------------------
 bool cpPlugins::ActorPropertiesQtDialog::
 addRenderWindow( vtkRenderWindow* win )
 {
-  if( win == NULL )
+  if( this->m_MainWidget != NULL && win != NULL )
+    return( this->m_MainWidget->addRenderWindow( win ) );
+  else
     return( false );
-  this->m_Windows.insert( win );
-  this->m_WidgetsUpdated = false;
-  return( true );
 }
 
 // -------------------------------------------------------------------------
 int cpPlugins::ActorPropertiesQtDialog::
 exec( )
 {
-  this->_updateWidgets( );
   int ret = this->QDialog::exec( );
   /* TODO
      if( ret == 1 )
@@ -91,6 +120,7 @@ exec( )
 }
 
 // -------------------------------------------------------------------------
+/* TODO
 void cpPlugins::ActorPropertiesQtDialog::
 _addButtons( )
 {
@@ -134,26 +164,6 @@ _configureForAxes( )
   title << "Parameters for an object of class \"Axes\"";
   this->m_Title->setText( title.str( ).c_str( ) );
 
-  /*
-    vtkAxesActor axes
-    178   axes SetShaftTypeToCylinder
-    179   axes SetXAxisLabelText "x"
-    180   axes SetYAxisLabelText "y"
-    181   axes SetZAxisLabelText "z"
-    182   axes SetTotalLength 1.5 1.5 1.5
-    183   vtkTextProperty tprop
-    184   tprop ItalicOn
-    185   tprop ShadowOn
-    186   tprop SetFontFamilyToTimes
-    187   [ axes GetXAxisCaptionActor2D ] SetCaptionTextProperty tprop
-    188   vtkTextProperty tprop2
-    189   tprop2 ShallowCopy tprop
-    190   [ axes GetYAxisCaptionActor2D ] SetCaptionTextProperty tprop2
-    191   vtkTextProperty tprop3
-    192   tprop3 ShallowCopy tprop
-    193   [ axes GetZAxisCaptionActor2D ] SetCaptionTextProperty tprop3
-  */
-
   return( true );
 }
 
@@ -672,6 +682,7 @@ _color( )
 
   } // fi
 }
+*/
 
 #endif // cpPlugins_QT4
 
index ca45b57f396941775404cd995b42c128db84ab57..394fc6e2b94b12296f875fc90cf3001980a58a01 100644 (file)
@@ -1,23 +1,25 @@
 #ifndef __CPPLUGINS__ACTORPROPERTIESQTDIALOG__H__
 #define __CPPLUGINS__ACTORPROPERTIESQTDIALOG__H__
 
-#include <cpPlugins/Config.h>
+#include <cpPlugins/ActorProperties.h>
 
 #ifdef cpPlugins_QT4
 
-#include <set>
-#include <vtkProp.h>
-#include <vtkRenderWindow.h>
-#include <vtkSmartPointer.h>
-
-#include <QApplication>
 #include <QDialog>
 #include <QDialogButtonBox>
 #include <QGridLayout>
 #include <QLabel>
 #include <QVBoxLayout>
+/*
+  #include <set>
+  #include <vtkProp.h>
+  #include <vtkRenderWindow.h>
+  #include <vtkSmartPointer.h>
+
+  #include <QApplication>
 
-class vtkProp;
+  class vtkProp;
+*/
 
 namespace cpPlugins
 {
@@ -28,20 +30,6 @@ namespace cpPlugins
   {
     Q_OBJECT;
 
-  public:
-    template< class _TObj >
-    struct TCmp
-    {
-      bool operator()(
-        const vtkSmartPointer< _TObj >& a,
-        const vtkSmartPointer< _TObj >& b ) const
-        { return( a.GetPointer( ) < b.GetPointer( ) ); }
-    };
-    typedef vtkSmartPointer< vtkProp >                         TActor;
-    typedef vtkSmartPointer< vtkRenderWindow >                 TRenderWindow;
-    typedef std::set< TActor, TCmp< vtkProp > >                TActors;
-    typedef std::set< TRenderWindow, TCmp< vtkRenderWindow > > TWindows;
-
   public:
     ActorPropertiesQtDialog(
       QWidget* parent = 0, Qt::WindowFlags f = 0
@@ -53,30 +41,32 @@ namespace cpPlugins
     virtual int exec( );
 
   protected:
-    virtual void _addButtons( );
-    virtual void _updateWidgets( );
-
-    virtual bool _configureForAxes( );
-    virtual bool _configureForImage( );
-    virtual bool _configureForMesh( );
-
-    void _setWindow( double w );
-    void _setLevel( double l );
-    void _render( );
-
-    template< class _TActor >
-      inline bool _addActor( vtkProp* obj );
-
-  protected slots:
-    void _boxWindow( double v );
-    void _sldWindow( int v );
-    void _boxLevel( double v );
-    void _sldLevel( int v );
-    void _sldOpacity( int v );
-    void _boxPointSize( int v );
-    void _boxLineWidth( int v );
-    void _scalarVisibility( int v );
-    void _color( );
+    /* TODO
+       virtual void _addButtons( );
+       virtual void _updateWidgets( );
+
+       virtual bool _configureForAxes( );
+       virtual bool _configureForImage( );
+       virtual bool _configureForMesh( );
+
+       void _setWindow( double w );
+       void _setLevel( double l );
+       void _render( );
+
+       template< class _TActor >
+       inline bool _addActor( vtkProp* obj );
+
+       protected slots:
+       void _boxWindow( double v );
+       void _sldWindow( int v );
+       void _boxLevel( double v );
+       void _sldLevel( int v );
+       void _sldOpacity( int v );
+       void _boxPointSize( int v );
+       void _boxLineWidth( int v );
+       void _scalarVisibility( int v );
+       void _color( );
+    */
 
     /* TODO
        virtual void updateParameters( );
@@ -97,9 +87,7 @@ namespace cpPlugins
     */
 
   protected:
-    TActors  m_Actors;
-    TWindows m_Windows;
-    bool m_WidgetsUpdated;
+    cpPlugins::ActorProperties* m_MainWidget;
     QLabel* m_Title;
     QGridLayout* m_MainLayout;
     QVBoxLayout* m_ToolsLayout;
index d06bf100994f3a9efd26c5d227f4cd722e4aaeff..bb3bdb9f2bff1f12d4dcbe9ff5179dd23a0f9bb4 100644 (file)
@@ -29,14 +29,25 @@ FILE(GLOB lib_SOURCES_CXX "*.cxx")
 IF(USE_QT4)
   SET(
     lib_QT_UI
+    ActorAxesProperties.ui
+    ActorImageProperties.ui
+    ActorPolyDataProperties.ui
     )
   SET(
     lib_QT_Headers
+    ActorProperties.h
+    ActorAxesProperties.h
+    ActorImageProperties.h
+    ActorPolyDataProperties.h
     ActorPropertiesQtDialog.h
     ParametersQtDialog.h
     )
   SET(
     lib_QT_Sources
+    ActorProperties.cxx
+    ActorAxesProperties.cxx
+    ActorImageProperties.cxx
+    ActorPolyDataProperties.cxx
     ActorPropertiesQtDialog.cxx
     ParametersQtDialog.cxx
     )
index 4d9cbd83f1bb43c79f3ddffd8d8331fd54935c62..261d966674fc7f54e6dca307acc58174d4d8fc53 100644 (file)
@@ -1,6 +1,7 @@
 #include <cpPlugins/Image.h>
 
 #include <vtkImageActor.h>
+#include <vtkImageProperty.h>
 #include <vtkImageSliceMapper.h>
 
 // -------------------------------------------------------------------------
@@ -53,6 +54,7 @@ _CreateVTKActor( ) const
     vtkImageActor* actor = vtkImageActor::New( );
     mapper->SetInputData( image );
     actor->SetMapper( mapper );
+    actor->GetProperty( )->SetInterpolationTypeToNearest( );
     this->m_Actor = actor;
     mapper->Delete( );