]> Creatis software - cpPlugins.git/commitdiff
Windows compilation is broken.
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Tue, 24 May 2016 00:29:26 +0000 (19:29 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Tue, 24 May 2016 00:29:26 +0000 (19:29 -0500)
14 files changed:
appli/PipelineEditor/PipelineEditor.cxx
lib/cpExtensions/QT/SimpleMPRWidget.cxx
lib/cpExtensions/QT/SimpleMPRWidget.h
lib/cpExtensions/Visualization/ImageSliceActors.cxx
lib/cpExtensions/Visualization/ImageSliceActors.h
lib/cpPipelineEditor/Block.cxx
lib/cpPipelineEditor/Block.h
lib/cpPipelineEditor/Port.cxx
lib/cpPlugins/CMakeLists.txt
lib/cpPlugins/DataObject.cxx
lib/cpPlugins/DataObject.h
lib/cpPlugins/DataObjectVisualizationQtDialog.cxx [new file with mode: 0644]
lib/cpPlugins/DataObjectVisualizationQtDialog.h [new file with mode: 0644]
lib/cpPlugins/Mesh.cxx

index b61cd14cbc5155b9c2e830ac8b5a6b216893d3af..a4cd75e79a82be20ef74ed1d545da061eda89417 100644 (file)
@@ -87,26 +87,44 @@ _ShowFilterOutput(
   auto filter = this->m_Workspace.GetFilter( filter_name );
   if( filter != NULL )
   {
-    auto id = filter->GetOutputData< vtkImageData >( output_name );
-    auto md = filter->GetOutputData< vtkPolyData >( output_name );
-    if( id != NULL )
+    auto out = filter->GetOutput( output_name );
+    if( out != NULL )
     {
-      this->_Block( );
-      this->m_UI->Viewer->Clear( );
-      this->m_UI->Viewer->SetMainImage( id );
-      this->_UnBlock( );
-    }
-    else if( md != NULL )
-    {
-      this->_Block( );
-      this->m_UI->Viewer->AddMesh( md );
-      this->_UnBlock( );
+      auto id = out->GetVTK< vtkImageData >( );
+      auto md = out->GetVTK< vtkPolyData >( );
+      if( id != NULL )
+      {
+        this->_Block( );
+        this->m_UI->Viewer->Clear( );
+        this->m_UI->Viewer->SetMainImage( id );
+        auto actors = this->m_UI->Viewer->GetMainImageActors( );
+        out->ClearVTKActors( );
+        for( auto aIt = actors.begin( ); aIt != actors.end( ); ++aIt )
+          out->AddVTKActor( aIt->first, aIt->second );
+        this->_UnBlock( );
+      }
+      else if( md != NULL )
+      {
+        this->_Block( );
+        this->m_UI->Viewer->AddMesh( md );
+        out->AddVTKActor(
+          this->m_UI->Viewer->GetActor( md ),
+          this->m_UI->Viewer->GetRenderer( 3 )
+          );
+        this->_UnBlock( );
+      }
+      else
+        QMessageBox::critical(
+          this,
+          QMessageBox::tr( "Error showing data" ),
+          QMessageBox::tr( "No known VTK conversion!" )
+          );
     }
     else
       QMessageBox::critical(
         this,
         QMessageBox::tr( "Error showing data" ),
-        QMessageBox::tr( "No known VTK conversion!" )
+        QMessageBox::tr( "Unknown port name." )
         );
   }
   else
index 0cede9d8e5f167a3207e92f922efe738561faea5..ab47c28a32e0e354b1e4a0dafcd57ac0ad852c80 100644 (file)
@@ -149,6 +149,41 @@ GetInteractor( unsigned int i )
     return( NULL );
 }
 
+// -------------------------------------------------------------------------
+vtkRenderer* cpExtensions::QT::SimpleMPRWidget::
+GetRenderer( unsigned int i )
+{
+  if( i < 4 )
+    return( this->m_Renderers[ i ] );
+  else
+    return( NULL );
+}
+
+// -------------------------------------------------------------------------
+std::vector< std::pair< vtkImageActor*, vtkRenderer* > >
+cpExtensions::QT::SimpleMPRWidget::
+GetMainImageActors( )
+{
+  std::vector< std::pair< vtkImageActor*, vtkRenderer* > > actors;
+  for( unsigned int i = 0; i < 3; ++i )
+  {
+    actors.push_back(
+      std::pair< vtkImageActor*, vtkRenderer* >(
+        this->m_2DSlices[ i ]->GetImageActor( ),
+        this->m_Renderers[ i ]
+        )
+      );
+    actors.push_back(
+      std::pair< vtkImageActor*, vtkRenderer* >(
+        this->m_3DSlices[ i ]->GetImageActor( ),
+        this->m_Renderers[ 3 ]
+        )
+      );
+
+  } // rof
+  return( actors );
+}
+
 // -------------------------------------------------------------------------
 vtkActor* cpExtensions::QT::SimpleMPRWidget::
 GetActor( vtkPolyData* mesh )
index f6d90f094aba7120ba7d29370eb2fbb1a071b38e..d5f33539fe0fb5cd29a0437fa32f65d55f3cc8ca 100644 (file)
@@ -100,7 +100,9 @@ namespace cpExtensions
 
       // Visual objects
       vtkRenderWindowInteractor* GetInteractor( unsigned int i );
-
+      vtkRenderer* GetRenderer( unsigned int i );
+      std::vector< std::pair< vtkImageActor*, vtkRenderer* > >
+        GetMainImageActors( );
       vtkActor* GetActor( vtkPolyData* mesh );
 
     private slots:
index d6542efbd25152f0870fa8b2a2645827d67407c4..2254ac9501169b8a7e729dc8c684a1c559a04ec5 100644 (file)
@@ -92,6 +92,20 @@ GetInputData( )
     return( NULL );
 }
 
+// -------------------------------------------------------------------------
+vtkImageActor* cpExtensions::Visualization::ImageSliceActors::
+GetImageActor( )
+{
+  return( this->m_Actor.GetPointer( ) );
+}
+
+// -------------------------------------------------------------------------
+const vtkImageActor* cpExtensions::Visualization::ImageSliceActors::
+GetImageActor( ) const
+{
+  return( this->m_Actor.GetPointer( ) );
+}
+
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::ImageSliceActors::
 AddMesh( vtkPolyData* mesh )
index 7ff8838cc3fc83b540e20766a3503a3111060f8f..075c6ec0edabea6a31daff54e18a7d7322338d62 100644 (file)
@@ -85,6 +85,9 @@ namespace cpExtensions
       void SetInputData( vtkImageData* data, int orientation );
       vtkImageData* GetInputData( );
 
+      vtkImageActor* GetImageActor( );
+      const vtkImageActor* GetImageActor( ) const;
+
       void AddMesh( vtkPolyData* mesh );
 
       void AssociateSlice( Self* slice );
index cd32453cb0c8299d9ec78cdfb7102360b3894c7d..07fdfb9504bb82eacb89239cf13dc6c8b539a6af 100644 (file)
@@ -61,6 +61,22 @@ cpPipelineEditor::Block::
 {\r
 }\r
 \r
+// -------------------------------------------------------------------------\r
+cpPipelineEditor::Block::\r
+TFilter* cpPipelineEditor::Block::\r
+filter( )\r
+{\r
+  return( this->m_Filter );\r
+}\r
+\r
+// -------------------------------------------------------------------------\r
+const cpPipelineEditor::Block::\r
+TFilter* cpPipelineEditor::Block::\r
+filter( ) const\r
+{\r
+  return( this->m_Filter );\r
+}\r
+\r
 // -------------------------------------------------------------------------\r
 cpPipelineEditor::Editor* cpPipelineEditor::Block::\r
 editor( )\r
index 2ace7b78abb5020c5aecb2f72583877d3b422636..6ee84f662a91c49ac0cab0794b8d3c34e9d360e3 100644 (file)
@@ -32,6 +32,9 @@ namespace cpPipelineEditor
       );\r
     virtual ~Block( );\r
 \r
+    TFilter* filter( );\r
+    const TFilter* filter( ) const;\r
+\r
     Editor* editor( );\r
     const Editor* editor( ) const;\r
     void setEditor( Editor* editor );\r
index 1eb2c78c637ee0b99dbdb220caa1ed23dfe485d1..b0278eaecf1524078fc92462ed445170953c42e7 100644 (file)
@@ -3,6 +3,8 @@
 #include "Block.h"\r
 #include "Editor.h"\r
 \r
+#include <cpPlugins/DataObjectVisualizationQtDialog.h>\r
+\r
 #include <QGraphicsScene>\r
 #include <QGraphicsSceneContextMenuEvent>\r
 #include <QFontMetrics>\r
@@ -294,10 +296,19 @@ contextMenuEvent( QGraphicsSceneContextMenuEvent* evt )
   }\r
   else if( selectedAction == propertiesAction )\r
   {\r
-    this->m_Block->editor( )->visualPropertiesOutputData(\r
-      this->m_Block->namePort( ).toStdString( ),\r
-      this->name( ).toStdString( )\r
-      );\r
+    auto filter = this->m_Block->filter( );\r
+    auto name = this->name( ).toStdString( );\r
+    if( filter != NULL )\r
+    {\r
+      auto output = filter->GetOutput( name );\r
+      if( output != NULL )\r
+      {\r
+        auto dlg = output->CreateQtDialog( );\r
+        dlg->exec( );\r
+\r
+      } // fi\r
+\r
+    } // fi\r
 \r
   } // fi\r
 }\r
index abf5082506d591b2fa37e626b19186b4a04df673..55ffd24eec6e93e399f05d186889f52e1a0255db 100644 (file)
@@ -32,10 +32,12 @@ IF(USE_QT4)
     )
   SET(
     lib_QT_Headers
+    DataObjectVisualizationQtDialog.h
     ParametersQtDialog.h
     )
   SET(
     lib_QT_Sources
+    DataObjectVisualizationQtDialog.cxx
     ParametersQtDialog.cxx
     )
   SET(
index 06c10df303507912a221779baa13299e5ac0171a..ebfb8b224a7176f4564600347b4d831fa2de7572 100644 (file)
@@ -1,9 +1,11 @@
 #include <cpPlugins/DataObject.h>
 
 #include <cpPlugins/ProcessObject.h>
+#include <cpPlugins/DataObjectVisualizationQtDialog.h>
 #include <itkDataObject.h>
 #include <vtkImageData.h>
 #include <vtkPolyData.h>
+#include <vtkRenderWindow.h>
 
 // -------------------------------------------------------------------------
 cpPlugins::ProcessObject* cpPlugins::DataObject::
@@ -64,6 +66,87 @@ DisconnectFromPipeline( )
   this->Modified( );
 }
 
+// -------------------------------------------------------------------------
+cpPlugins::DataObjectVisualizationQtDialog* cpPlugins::DataObject::
+CreateQtDialog( )
+{
+#ifdef cpPlugins_QT4
+  DataObjectVisualizationQtDialog* dlg = NULL;
+  if( QApplication::instance( ) != NULL )
+  {
+    dlg = new DataObjectVisualizationQtDialog( );
+    dlg->setDataObject( this );
+
+  } // fi
+  return( dlg );
+#else // cpPlugins_QT4  
+  return( NULL );
+#endif // cpPlugins_QT4
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::DataObject::
+AddVTKActor( vtkProp* actor, vtkRenderer* renderer )
+{
+  if( actor != NULL && renderer != NULL )
+  {
+    TDataView v;
+    v.Actor = actor;
+    v.Renderer = renderer;
+    this->m_Actors.insert( v );
+    this->Modified( );
+
+  } // fi
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::DataObject::
+ClearVTKActors( )
+{
+  this->m_Actors.clear( );
+  this->Modified( );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::DataObject::
+RenderVTKActors( )
+{
+  for( auto i = this->m_Actors.begin( ); i != this->m_Actors.end( ); ++i )
+    i->Renderer->GetRenderWindow( )->Render( );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::DataObject::TDataViews::
+iterator cpPlugins::DataObject::
+BeginVTKActors( )
+{
+  return( this->m_Actors.begin( ) );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::DataObject::TDataViews::
+iterator cpPlugins::DataObject::
+EndVTKActors( )
+{
+  return( this->m_Actors.end( ) );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::DataObject::TDataViews::
+const_iterator cpPlugins::DataObject::
+BeginVTKActors( ) const
+{
+  return( this->m_Actors.begin( ) );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::DataObject::TDataViews::
+const_iterator cpPlugins::DataObject::
+EndVTKActors( ) const
+{
+  return( this->m_Actors.end( ) );
+}
+
 // -------------------------------------------------------------------------
 cpPlugins::DataObject::
 DataObject( )
index 279fe761858eb9f30a4de49c830c8594cc7ea3cf..9ff55d8a0cee67db4090c5694e67ea88de329ad4 100644 (file)
@@ -2,11 +2,15 @@
 #define __CPPLUGINS__DATAOBJECT__H__
 
 #include <cpPlugins/Object.h>
+#include <set>
+#include <vtkProp.h>
+#include <vtkRenderer.h>
 
 namespace cpPlugins
 {
   // Some forward declarations
   class ProcessObject;
+  class DataObjectVisualizationQtDialog;
 
   /**
    */
@@ -24,6 +28,15 @@ namespace cpPlugins
     itkTypeMacro( DataObject, Object );
     cpPlugins_Id_Macro( DataObject, Object );
 
+    struct TDataView
+    {
+      vtkSmartPointer< vtkProp >     Actor;
+      vtkSmartPointer< vtkRenderer > Renderer;
+      bool operator<( const TDataView& b ) const
+        { return( this->Actor.GetPointer( ) < b.Actor.GetPointer( ) ); }
+    };
+    typedef std::set< TDataView > TDataViews;
+
   public:
     ProcessObject* GetSource( );
     const ProcessObject* GetSource( ) const;
@@ -31,6 +44,18 @@ namespace cpPlugins
 
     void DisconnectFromPipeline( );
 
+    // Qt dialog creation
+    virtual DataObjectVisualizationQtDialog* CreateQtDialog( );
+
+    // VTK actors
+    virtual void AddVTKActor( vtkProp* actor, vtkRenderer* renderer );
+    virtual void ClearVTKActors( );
+    virtual void RenderVTKActors( );
+    TDataViews::iterator BeginVTKActors( );
+    TDataViews::iterator EndVTKActors( );
+    TDataViews::const_iterator BeginVTKActors( ) const;
+    TDataViews::const_iterator EndVTKActors( ) const;
+
   protected:
     DataObject( );
     virtual ~DataObject( );
@@ -42,6 +67,7 @@ namespace cpPlugins
 
   protected:
     ProcessObject* m_Source;
+    TDataViews     m_Actors;
   };
 
 } // ecapseman
diff --git a/lib/cpPlugins/DataObjectVisualizationQtDialog.cxx b/lib/cpPlugins/DataObjectVisualizationQtDialog.cxx
new file mode 100644 (file)
index 0000000..cd6ca76
--- /dev/null
@@ -0,0 +1,566 @@
+#include <cpPlugins/DataObjectVisualizationQtDialog.h>
+
+#include <vtkImageActor.h>
+#include <vtkImageData.h>
+#include <vtkImageProperty.h>
+#include <vtkMapper.h>
+#include <vtkPolyData.h>
+#include <vtkProperty.h>
+
+#ifdef cpPlugins_QT4
+
+#include <QCheckBox>
+#include <QColorDialog>
+#include <QDoubleSpinBox>
+#include <QPushButton>
+#include <QSlider>
+
+// -------------------------------------------------------------------------
+cpPlugins::DataObjectVisualizationQtDialog::
+DataObjectVisualizationQtDialog( QWidget* parent, Qt::WindowFlags f )
+  : QDialog( parent, f ),
+    m_DataObject( NULL ),
+    m_WidgetsUpdated( false )
+{
+  this->m_Title = new QLabel( this );
+  this->m_Title->setText( "Visualization properties" );
+  this->m_MainLayout = new QGridLayout( this );
+  this->m_ToolsLayout = new QVBoxLayout( );
+  this->m_ToolsLayout->addWidget( this->m_Title );
+  this->m_MainLayout->addLayout( this->m_ToolsLayout, 0, 0, 1, 1 );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::DataObjectVisualizationQtDialog::
+~DataObjectVisualizationQtDialog( )
+{
+  delete this->m_Title;
+  delete this->m_ToolsLayout;
+  delete this->m_MainLayout;
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::DataObject* cpPlugins::DataObjectVisualizationQtDialog::
+getDataObject( ) const
+{
+  return( this->m_DataObject );
+}
+
+// -------------------------------------------------------------------------
+bool cpPlugins::DataObjectVisualizationQtDialog::
+setDataObject( DataObject* obj )
+{
+  if( this->m_DataObject != NULL || obj == NULL )
+    return( false );
+  this->m_DataObject = obj;
+  this->m_WidgetsUpdated = false;
+  return( true );
+}
+
+// -------------------------------------------------------------------------
+int cpPlugins::DataObjectVisualizationQtDialog::
+exec( )
+{
+  this->_updateWidgets( );
+  int ret = this->QDialog::exec( );
+  /* TODO
+     if( ret == 1 )
+     this->updateParameters( );
+     else
+     this->updateView( );
+  */
+  return( ret );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::DataObjectVisualizationQtDialog::
+_addButtons( )
+{
+  // Add buttons
+  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 );
+  // TODO: this->updateView( );
+  this->m_WidgetsUpdated = true;
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::DataObjectVisualizationQtDialog::
+_updateWidgets( )
+{
+  if( this->m_WidgetsUpdated || this->m_DataObject == NULL )
+    return;
+
+  // Set dialog title
+  std::stringstream title;
+  title
+    << "Parameters for an object of class \""
+    << this->m_DataObject->GetClassName( )
+    << "\"";
+  this->m_Title->setText( title.str( ).c_str( ) );
+
+  // Configure particular objects
+  this->_configureForImage( );
+  this->_configureForMesh( );
+
+  // Update values
+  this->_addButtons( );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::DataObjectVisualizationQtDialog::
+_configureForImage( )
+{
+  auto image = this->m_DataObject->GetVTK< vtkImageData >( );
+  auto aIt = this->m_DataObject->BeginVTKActors( );
+  if( image == NULL || aIt == this->m_DataObject->EndVTKActors( ) )
+    return;
+  auto actor = dynamic_cast< vtkImageActor* >( aIt->Actor.GetPointer( ) );
+  if( actor == NULL )
+    return;
+  
+  double r[ 2 ];
+  image->GetScalarRange( r );
+  double w = actor->GetProperty( )->GetColorWindow( );
+  double l = actor->GetProperty( )->GetColorLevel( );
+  double sw = double( 1000 ) * w / ( r[ 1 ] - r[ 0 ] );
+  double sl = double( 1000 ) * ( l - r[ 0 ] ) / ( r[ 1 ] - r[ 0 ] );
+  double op = double( 10 ) * actor->GetProperty( )->GetOpacity( );
+
+  QDoubleSpinBox* win_box = new QDoubleSpinBox( this );
+  win_box->setObjectName( "win_box" );
+  win_box->setDecimals( 3 );
+  win_box->setMinimum( 0 );
+  win_box->setMaximum( r[ 1 ] - r[ 0 ] );
+  win_box->setValue( w );
+  win_box->connect(
+    win_box, SIGNAL( valueChanged( double ) ),
+    this, SLOT( _boxWindow( double ) )
+    );
+
+  QSlider* win_sld = new QSlider( Qt::Horizontal, this );
+  win_sld->setObjectName( "win_sld" );
+  win_sld->setRange( 0, 1000 );
+  win_sld->setValue( ( unsigned int )( sw ) );
+  win_sld->connect(
+    win_sld, SIGNAL( valueChanged( int ) ),
+    this, SLOT( _sldWindow( int ) )
+    );
+
+  QHBoxLayout* win_layout = new QHBoxLayout( );
+  QLabel* win_label = new QLabel( this );
+  win_label->setText( QString( "Window: " ) );
+  win_layout->addWidget( win_label );
+  win_layout->addWidget( win_box );
+  win_layout->addWidget( win_sld );
+  this->m_ToolsLayout->addLayout( win_layout );
+
+  QDoubleSpinBox* lev_box = new QDoubleSpinBox( this );
+  lev_box->setObjectName( "lev_box" );
+  lev_box->setDecimals( 3 );
+  lev_box->setMinimum( r[ 0 ] );
+  lev_box->setMaximum( r[ 1 ] );
+  lev_box->setValue( l );
+  lev_box->connect(
+    lev_box, SIGNAL( valueChanged( double ) ),
+    this, SLOT( _boxLevel( double ) )
+    );
+
+  QSlider* lev_sld = new QSlider( Qt::Horizontal, this );
+  lev_sld->setObjectName( "lev_sld" );
+  lev_sld->setRange( 0, 1000 );
+  lev_sld->setValue( ( unsigned int )( sl ) );
+  lev_sld->connect(
+    lev_sld, SIGNAL( valueChanged( int ) ),
+    this, SLOT( _sldLevel( int ) )
+    );
+
+  QHBoxLayout* lev_layout = new QHBoxLayout( );
+  QLabel* lev_label = new QLabel( this );
+  lev_label->setText( QString( "Level: " ) );
+  lev_layout->addWidget( lev_label );
+  lev_layout->addWidget( lev_box );
+  lev_layout->addWidget( lev_sld );
+  this->m_ToolsLayout->addLayout( lev_layout );
+
+  // Configure generic objects
+  QSlider* op_sld = new QSlider( Qt::Horizontal, this );
+  op_sld->setObjectName( "op_sld" );
+  op_sld->setRange( 0, 10 );
+  op_sld->setValue( ( unsigned int )( op ) );
+  op_sld->connect(
+    op_sld, SIGNAL( valueChanged( int ) ),
+    this, SLOT( _sldOpacity( int ) )
+    );
+
+  QHBoxLayout* op_layout = new QHBoxLayout( );
+  QLabel* op_label = new QLabel( this );
+  op_label->setText( QString( "Opacity: " ) );
+  op_layout->addWidget( op_label );
+  op_layout->addWidget( op_sld );
+  this->m_ToolsLayout->addLayout( op_layout );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::DataObjectVisualizationQtDialog::
+_configureForMesh( )
+{
+  auto mesh = this->m_DataObject->GetVTK< vtkPolyData >( );
+  auto aIt = this->m_DataObject->BeginVTKActors( );
+  if( mesh == NULL || aIt == this->m_DataObject->EndVTKActors( ) )
+    return;
+  auto actor = dynamic_cast< vtkActor* >( aIt->Actor.GetPointer( ) );
+  if( actor == NULL )
+    return;
+
+  QSpinBox* ps_box = new QSpinBox( this );
+  ps_box->setObjectName( "ps_box" );
+  ps_box->setMinimum( 1 );
+  ps_box->setMaximum( 100 );
+  ps_box->setValue( actor->GetProperty( )->GetPointSize( ) );
+  ps_box->connect(
+    ps_box, SIGNAL( valueChanged( int ) ),
+    this, SLOT( _boxPointSize( int ) )
+    );
+
+  QHBoxLayout* ps_layout = new QHBoxLayout( );
+  QLabel* ps_label = new QLabel( this );
+  ps_label->setText( QString( "Point size: " ) );
+  ps_layout->addWidget( ps_label );
+  ps_layout->addWidget( ps_box );
+  this->m_ToolsLayout->addLayout( ps_layout );
+
+  QSpinBox* lw_box = new QSpinBox( this );
+  lw_box->setObjectName( "lw_box" );
+  lw_box->setMinimum( 1 );
+  lw_box->setMaximum( 100 );
+  lw_box->setValue( actor->GetProperty( )->GetLineWidth( ) );
+  lw_box->connect(
+    lw_box, SIGNAL( valueChanged( int ) ),
+    this, SLOT( _boxLineWidth( int ) )
+    );
+
+  QHBoxLayout* lw_layout = new QHBoxLayout( );
+  QLabel* lw_label = new QLabel( this );
+  lw_label->setText( QString( "Line width: " ) );
+  lw_layout->addWidget( lw_label );
+  lw_layout->addWidget( lw_box );
+  this->m_ToolsLayout->addLayout( lw_layout );
+
+  QCheckBox* sv_box = new QCheckBox( this );
+  sv_box->setObjectName( "sv_box" );
+  sv_box->setText( "Scalar visibility: " );
+  sv_box->setChecked( ( actor->GetMapper( )->GetScalarVisibility( ) == 1 ) );
+  sv_box->connect(
+    sv_box, SIGNAL( stateChanged( int ) ),
+    this, SLOT( _scalarVisibility( int ) )
+    );
+
+  QHBoxLayout* sv_layout = new QHBoxLayout( );
+  sv_layout->addWidget( sv_box );
+  this->m_ToolsLayout->addLayout( sv_layout );
+
+  double cr, cg, cb;
+  actor->GetProperty( )->GetColor( cr, cg, cb );
+  cr *= double( 255 );
+  cg *= double( 255 );
+  cb *= double( 255 );
+
+  QPushButton* color_button = new QPushButton( "Color", this );
+  color_button->setObjectName( "color_button" );
+  QPalette color_palette = color_button->palette( );
+  color_palette.setColor( QPalette::Button, QColor( cr, cg, cb ) );
+  color_button->setAutoFillBackground( true );
+  color_button->setPalette( color_palette );
+  color_button->update( );
+  color_button->connect(
+    color_button, SIGNAL( clicked( ) ),
+    this, SLOT( _color( ) )
+    );
+
+  QHBoxLayout* color_layout = new QHBoxLayout( );
+  color_layout->addWidget( color_button );
+  this->m_ToolsLayout->addLayout( color_layout );
+
+  // Configure generic objects
+  QSlider* op_sld = new QSlider( Qt::Horizontal, this );
+  op_sld->setObjectName( "op_sld" );
+  op_sld->setRange( 0, 10 );
+  op_sld->setValue(
+    ( unsigned int )( actor->GetProperty( )->GetOpacity( ) * double( 10 ) )
+    );
+  op_sld->connect(
+    op_sld, SIGNAL( valueChanged( int ) ),
+    this, SLOT( _sldOpacity( int ) )
+    );
+
+  QHBoxLayout* op_layout = new QHBoxLayout( );
+  QLabel* op_label = new QLabel( this );
+  op_label->setText( QString( "Opacity: " ) );
+  op_layout->addWidget( op_label );
+  op_layout->addWidget( op_sld );
+  this->m_ToolsLayout->addLayout( op_layout );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::DataObjectVisualizationQtDialog::
+_setWindow( double w )
+{
+  if( this->m_DataObject == NULL )
+    return;
+  auto aIt = this->m_DataObject->BeginVTKActors( );
+  for( ; aIt != this->m_DataObject->EndVTKActors( ); ++aIt )
+  {
+    auto actor = dynamic_cast< vtkImageActor* >( aIt->Actor.GetPointer( ) );
+    if( actor != NULL )
+    {
+      actor->GetProperty( )->SetColorWindow( w );
+      actor->Modified( );
+
+    } // fi
+
+  } // rof
+  this->_render( );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::DataObjectVisualizationQtDialog::
+_setLevel( double l )
+{
+  if( this->m_DataObject == NULL )
+    return;
+  auto aIt = this->m_DataObject->BeginVTKActors( );
+  for( ; aIt != this->m_DataObject->EndVTKActors( ); ++aIt )
+  {
+    auto actor = dynamic_cast< vtkImageActor* >( aIt->Actor.GetPointer( ) );
+    if( actor != NULL )
+    {
+      actor->GetProperty( )->SetColorLevel( l );
+      actor->Modified( );
+
+    } // fi
+
+  } // rof
+  this->_render( );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::DataObjectVisualizationQtDialog::
+_render( )
+{
+  if( this->m_DataObject == NULL )
+    return;
+  this->m_DataObject->RenderVTKActors( );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::DataObjectVisualizationQtDialog::
+_boxWindow( double v )
+{
+  auto* box = this->findChild< QDoubleSpinBox* >( "win_box" );
+  auto* sld = this->findChild< QSlider* >( "win_sld" );
+  if( box == NULL || sld == NULL )
+    return;
+
+  double min = double( sld->minimum( ) );
+  double max = double( sld->maximum( ) );
+  double vmin = box->minimum( );
+  double vmax = box->maximum( );
+  double s = ( v - vmin ) / ( vmax - vmin );
+  s = ( ( max - min ) * s ) + min;
+
+  bool o = sld->blockSignals( true );
+  sld->setValue( ( unsigned int )( s ) );
+  sld->blockSignals( o );
+  this->_setWindow( v );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::DataObjectVisualizationQtDialog::
+_sldWindow( int v )
+{
+  auto* box = this->findChild< QDoubleSpinBox* >( "win_box" );
+  auto* sld = this->findChild< QSlider* >( "win_sld" );
+  if( box == NULL || sld == NULL )
+    return;
+
+  double min = double( sld->minimum( ) );
+  double max = double( sld->maximum( ) );
+  double vmin = box->minimum( );
+  double vmax = box->maximum( );
+  double s = ( double( v ) - min ) / ( max - min );
+  s = ( ( vmax - vmin ) * s ) + vmin;
+
+  bool o = box->blockSignals( true );
+  box->setValue( s );
+  box->blockSignals( o );
+  this->_setWindow( s );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::DataObjectVisualizationQtDialog::
+_boxLevel( double v )
+{
+  auto* box = this->findChild< QDoubleSpinBox* >( "lev_box" );
+  auto* sld = this->findChild< QSlider* >( "lev_sld" );
+  if( box == NULL || sld == NULL )
+    return;
+
+  double min = double( sld->minimum( ) );
+  double max = double( sld->maximum( ) );
+  double vmin = box->minimum( );
+  double vmax = box->maximum( );
+  double s = ( v - vmin ) / ( vmax - vmin );
+  s = ( ( max - min ) * s ) + min;
+
+  bool o = sld->blockSignals( true );
+  sld->setValue( ( unsigned int )( s ) );
+  sld->blockSignals( o );
+  this->_setLevel( v );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::DataObjectVisualizationQtDialog::
+_sldLevel( int v )
+{
+  auto* box = this->findChild< QDoubleSpinBox* >( "lev_box" );
+  auto* sld = this->findChild< QSlider* >( "lev_sld" );
+  if( box == NULL || sld == NULL )
+    return;
+
+  double min = double( sld->minimum( ) );
+  double max = double( sld->maximum( ) );
+  double vmin = box->minimum( );
+  double vmax = box->maximum( );
+  double s = ( double( v ) - min ) / ( max - min );
+  s = ( ( vmax - vmin ) * s ) + vmin;
+
+  bool o = box->blockSignals( true );
+  box->setValue( s );
+  box->blockSignals( o );
+  this->_setLevel( s );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::DataObjectVisualizationQtDialog::
+_sldOpacity( int v )
+{
+  if( this->m_DataObject == NULL )
+    return;
+  auto* sld = this->findChild< QSlider* >( "op_sld" );
+  if( sld == NULL )
+    return;
+
+  double min = double( sld->minimum( ) );
+  double max = double( sld->maximum( ) );
+  double s = ( double( v ) - min ) / ( max - min );
+
+  auto aIt = this->m_DataObject->BeginVTKActors( );
+  for( ; aIt != this->m_DataObject->EndVTKActors( ); ++aIt )
+  {
+    auto ia = dynamic_cast< vtkImageActor* >( aIt->Actor.GetPointer( ) );
+    auto ma = dynamic_cast< vtkActor* >( aIt->Actor.GetPointer( ) );
+    if( ia != NULL )
+    {
+      ia->GetProperty( )->SetOpacity( s );
+      ia->Modified( );
+    }
+    else if( ma != NULL )
+    {
+      ma->GetProperty( )->SetOpacity( s );
+      ma->Modified( );
+
+    } // fi
+
+  } // rof
+  this->_render( );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::DataObjectVisualizationQtDialog::
+_boxPointSize( int v )
+{
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::DataObjectVisualizationQtDialog::
+_boxLineWidth( int v )
+{
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::DataObjectVisualizationQtDialog::
+_scalarVisibility( int v )
+{
+  if( this->m_DataObject == NULL )
+    return;
+  auto* btn = this->findChild< QPushButton* >( "color_button" );
+  auto* chk = this->findChild< QCheckBox* >( "sv_box" );
+  if( btn == NULL || chk == NULL )
+    return;
+  QPalette pal = btn->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_DataObject->BeginVTKActors( );
+  for( ; aIt != this->m_DataObject->EndVTKActors( ); ++aIt )
+  {
+    auto ma = dynamic_cast< vtkActor* >( aIt->Actor.GetPointer( ) );
+    if( ma != NULL )
+    {
+      if( !( chk->isChecked( ) ) )
+      {
+        ma->GetMapper( )->ScalarVisibilityOff( );
+        ma->GetProperty( )->SetColor( rgb );
+      }
+      else
+        ma->GetMapper( )->ScalarVisibilityOn( );
+      ma->Modified( );
+
+    } // fi
+
+  } // rof
+  this->_render( );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::DataObjectVisualizationQtDialog::
+_color( )
+{
+  if( this->m_DataObject == NULL )
+    return;
+  auto* btn = this->findChild< QPushButton* >( "color_button" );
+  auto* chk = this->findChild< QCheckBox* >( "sv_box" );
+  if( btn == NULL || chk == NULL )
+    return;
+
+  QPalette pal = btn->palette( );
+  QColor color =
+    QColorDialog::getColor(
+      pal.color( QPalette::Button ),
+      this,
+      "Select Color",
+      QColorDialog::DontUseNativeDialog
+      );
+  if( color.isValid( ) )
+  {
+    pal.setColor( QPalette::Button, color );
+    btn->setAutoFillBackground( true );
+    btn->setPalette( pal );
+    btn->update( );
+    this->_scalarVisibility( 0 );
+
+  } // fi
+}
+
+#endif // cpPlugins_QT4
+
+// eof - $RCSfile$
diff --git a/lib/cpPlugins/DataObjectVisualizationQtDialog.h b/lib/cpPlugins/DataObjectVisualizationQtDialog.h
new file mode 100644 (file)
index 0000000..a26b7ba
--- /dev/null
@@ -0,0 +1,94 @@
+#ifndef __CPPLUGINS__DATAOBJECTVISUALIZATIONQTDIALOG__H__
+#define __CPPLUGINS__DATAOBJECTVISUALIZATIONQTDIALOG__H__
+
+#include <cpPlugins/Config.h>
+
+#ifdef cpPlugins_QT4
+
+#include <cpPlugins/DataObject.h>
+
+#include <set>
+
+#include <QApplication>
+#include <QDialog>
+#include <QDialogButtonBox>
+#include <QGridLayout>
+#include <QLabel>
+#include <QVBoxLayout>
+
+namespace cpPlugins
+{
+  /**
+   */
+  class cpPlugins_EXPORT DataObjectVisualizationQtDialog
+    : public QDialog
+  {
+    Q_OBJECT;
+
+  public:
+    DataObjectVisualizationQtDialog(
+      QWidget* parent = 0, Qt::WindowFlags f = 0
+      );
+    virtual ~DataObjectVisualizationQtDialog( );
+
+    DataObject* getDataObject( ) const;
+    virtual bool setDataObject( DataObject* obj );
+
+    virtual int exec( );
+
+  protected:
+    virtual void _addButtons( );
+    virtual void _updateWidgets( );
+
+    virtual void _configureForImage( );
+    virtual void _configureForMesh( );
+
+    void _setWindow( double w );
+    void _setLevel( double l );
+    void _render( );
+
+  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( );
+       virtual void updateView( );
+
+       protected:
+       virtual void _addButtons( );
+       virtual void _updateWidgets( );
+
+       protected slots:
+       virtual void _dlg_OpenSingleFile( );
+       virtual void _dlg_SaveSingleFile( );
+       virtual void _dlg_OpenSinglePath( );
+       virtual void _dlg_OpenMultipleFiles( );
+       virtual void _dlg_AddInt( );
+       virtual void _dlg_AddUint( );
+       virtual void _dlg_AddReal( );
+    */
+
+  protected:
+    DataObject* m_DataObject;
+    bool m_WidgetsUpdated;
+    QLabel* m_Title;
+    QGridLayout* m_MainLayout;
+    QVBoxLayout* m_ToolsLayout;
+    QDialogButtonBox* m_Buttons;
+  };
+
+} // ecapseman
+
+#endif // cpPlugins_QT4
+
+#endif // __CPPLUGINS__DATAOBJECTVISUALIZATIONQTDIALOG__H__
+
+// eof - $RCSfile$
index 054b71ae1b1f17e0f7cfac129f12556613b2b3e0..071a51d631f9aa488b17492a3b53ec86a1dcde52 100644 (file)
@@ -107,6 +107,7 @@ SetVTK( vtkObjectBase* o )
 
   } // fi
 }
+
 // -------------------------------------------------------------------------
 cpPlugins::Mesh::
 Mesh( )