]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/ActorPropertiesQtDialog.cxx
...
[cpPlugins.git] / lib / cpPlugins / ActorPropertiesQtDialog.cxx
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