]> Creatis software - cpPlugins.git/blobdiff - lib/cpExtensions/QT/SimpleMPRWidget.cxx
...
[cpPlugins.git] / lib / cpExtensions / QT / SimpleMPRWidget.cxx
index 62b92961f849085c0d37804565a73641544f6d4b..4ccd631f7d31ec4b704392312c600fca77fea032 100644 (file)
@@ -2,54 +2,73 @@
 
 #ifdef cpExtensions_QT4
 
-#include <cpExtensions/ui_SimpleMPRWidget.h>
+#include <cpExtensions/QT/ui_SimpleMPRWidget.h>
+#include <cpExtensions/QT/ImageWidget.h>
+#include <cpExtensions/QT/MPR3DWidget.h>
+#include <cpExtensions/QT/MPRInteractionCommand.h>
+#include <cpExtensions/QT/ConfigurationChooser.h>
 
-#include <vtkProperty.h>
-#include <vtkRendererCollection.h>
-
-double cpExtensions::QT::SimpleMPRWidget::
-cm_Colors[ 8 ][ 3 ] =
-{
-  { 1.0, 0.0, 0.0 },
-  { 0.0, 1.0, 0.0 },
-  { 0.0, 0.0, 1.0 },
-  { 0.0, 1.0, 1.0 },
-  { 1.0, 0.0, 1.0 },
-  { 1.0, 1.0, 0.0 },
-  { 1.0, 0.5, 0.0 },
-  { 1.0, 0.0, 0.5 }
-};
+#include <vtkImageData.h>
+#include <vtkPolyData.h>
+#include <vtkProp.h>
+#include <vtkPropCollection.h>
 
 // -------------------------------------------------------------------------
 cpExtensions::QT::SimpleMPRWidget::
-SimpleMPRWidget( QWidget* parent )
-  : QWidget( parent ),
+SimpleMPRWidget( QWidget* parent, Qt::WindowFlags f )
+  : Superclass( parent, f ),
+    Superclass2( ),
     m_UI( new Ui::SimpleMPRWidget ),
-    m_MainImage( "" )
+    m_MainImageName( "" )
 {
   this->m_UI->setupUi( this );
 
-  // Configure VTK widgets
-  this->m_VTK[ 0 ] = this->m_UI->VTK01;
-  this->m_VTK[ 1 ] = this->m_UI->VTK00;
-  this->m_VTK[ 2 ] = this->m_UI->VTK10;
-  this->m_VTK[ 3 ] = this->m_UI->VTK11;
-
-  this->m_MPRObjects = vtkSmartPointer< TMPRObjects >::New( );
-  this->m_MPRObjects->SetRenderWindows(
-    this->m_VTK[ 0 ]->GetRenderWindow( ),
-    this->m_VTK[ 1 ]->GetRenderWindow( ),
-    this->m_VTK[ 2 ]->GetRenderWindow( ),
-    this->m_VTK[ 3 ]->GetRenderWindow( )
-    );
+  // Prepare default configuration
+  this->m_UI->Q1->hide( );
+  this->m_UI->Q2->hide( );
+  this->m_UI->Q3->hide( );
+  this->m_UI->Q4->hide( );
+  this->m_UI->Q1->close( );
+  this->m_UI->Q2->close( );
+  this->m_UI->Q3->close( );
+  this->m_UI->Q4->close( );
+  delete this->m_UI->Q1;
+  delete this->m_UI->Q2;
+  delete this->m_UI->Q3;
+  delete this->m_UI->Q4;
+  this->m_XImage = new ImageWidget( this );
+  this->m_YImage = new ImageWidget( this );
+  this->m_ZImage = new ImageWidget( this );
+  this->m_3DView = new MPR3DWidget( this );
+  this->m_UI->Q1 = this->m_XImage;
+  this->m_UI->Q2 = this->m_YImage;
+  this->m_UI->Q3 = this->m_ZImage;
+  this->m_UI->Q4 = this->m_3DView;
+  this->Configure( 'y', 'x', 'w', 'z' );
+
+  // Interaction synchronizer
+  unsigned long ev1 = vtkCommand::UserEvent + 1;
+  unsigned long ev2 = vtkCommand::UserEvent + 2;
+  vtkSmartPointer< cpExtensions::QT::MPRInteractionCommand > cmd =
+    vtkSmartPointer< cpExtensions::QT::MPRInteractionCommand >::New( );
+  cmd->AddWidget( this->m_XImage );
+  cmd->AddWidget( this->m_YImage );
+  cmd->AddWidget( this->m_ZImage );
+  cmd->AddWidget( this->m_3DView );
+  this->m_XImage->GetStyle( )->AddObserver( ev1, cmd );
+  this->m_YImage->GetStyle( )->AddObserver( ev1, cmd );
+  this->m_ZImage->GetStyle( )->AddObserver( ev1, cmd );
+  this->m_XImage->GetStyle( )->AddObserver( ev2, cmd );
+  this->m_YImage->GetStyle( )->AddObserver( ev2, cmd );
+  this->m_ZImage->GetStyle( )->AddObserver( ev2, cmd );
 
   // Connect slots
-  QObject::connect(
-    this->m_UI->TopSplitter, SIGNAL( splitterMoved( int, int ) ),
+  this->connect(
+    this->m_UI->Top, SIGNAL( splitterMoved( int, int ) ),
     this, SLOT( _SyncBottom( int, int ) )
     );
-  QObject::connect(
-    this->m_UI->BottomSplitter, SIGNAL( splitterMoved( int, int ) ),
+  this->connect(
+    this->m_UI->Bottom, SIGNAL( splitterMoved( int, int ) ),
     this, SLOT( _SyncTop( int, int ) )
     );
 }
@@ -62,559 +81,546 @@ cpExtensions::QT::SimpleMPRWidget::
 }
 
 // -------------------------------------------------------------------------
-unsigned int cpExtensions::QT::SimpleMPRWidget::
-GetNumberOfData( ) const
+void cpExtensions::QT::SimpleMPRWidget::
+Configure( char q1, char q2, char q3, char q4 )
 {
-  return( this->m_Data.size( ) );
+  // Hide all widgets
+  this->m_UI->Q1->hide( );
+  this->m_UI->Q2->hide( );
+  this->m_UI->Q3->hide( );
+  this->m_UI->Q4->hide( );
+  this->m_UI->Q1->close( );
+  this->m_UI->Q2->close( );
+  this->m_UI->Q3->close( );
+  this->m_UI->Q4->close( );
+
+  // Reorder them
+  if     ( q1 == 'x' ) this->m_UI->Top->addWidget( this->m_XImage );
+  else if( q1 == 'y' ) this->m_UI->Top->addWidget( this->m_YImage );
+  else if( q1 == 'z' ) this->m_UI->Top->addWidget( this->m_ZImage );
+  else if( q1 == 'w' ) this->m_UI->Top->addWidget( this->m_3DView );
+  if     ( q2 == 'x' ) this->m_UI->Top->addWidget( this->m_XImage );
+  else if( q2 == 'y' ) this->m_UI->Top->addWidget( this->m_YImage );
+  else if( q2 == 'z' ) this->m_UI->Top->addWidget( this->m_ZImage );
+  else if( q2 == 'w' ) this->m_UI->Top->addWidget( this->m_3DView );
+  this->m_UI->Top->update( );
+  if     ( q4 == 'x' ) this->m_UI->Bottom->addWidget( this->m_XImage );
+  else if( q4 == 'y' ) this->m_UI->Bottom->addWidget( this->m_YImage );
+  else if( q4 == 'z' ) this->m_UI->Bottom->addWidget( this->m_ZImage );
+  else if( q4 == 'w' ) this->m_UI->Bottom->addWidget( this->m_3DView );
+  if     ( q3 == 'x' ) this->m_UI->Bottom->addWidget( this->m_XImage );
+  else if( q3 == 'y' ) this->m_UI->Bottom->addWidget( this->m_YImage );
+  else if( q3 == 'z' ) this->m_UI->Bottom->addWidget( this->m_ZImage );
+  else if( q3 == 'w' ) this->m_UI->Bottom->addWidget( this->m_3DView );
+  this->m_UI->Bottom->update( );
+
+  // Keep track
+  if     ( q1 == 'x' ) this->m_UI->Q1 = this->m_XImage;
+  else if( q1 == 'y' ) this->m_UI->Q1 = this->m_YImage;
+  else if( q1 == 'z' ) this->m_UI->Q1 = this->m_ZImage;
+  else if( q1 == 'w' ) this->m_UI->Q1 = this->m_3DView;
+  if     ( q2 == 'x' ) this->m_UI->Q2 = this->m_XImage;
+  else if( q2 == 'y' ) this->m_UI->Q2 = this->m_YImage;
+  else if( q2 == 'z' ) this->m_UI->Q2 = this->m_ZImage;
+  else if( q2 == 'w' ) this->m_UI->Q2 = this->m_3DView;
+  if     ( q3 == 'x' ) this->m_UI->Q3 = this->m_XImage;
+  else if( q3 == 'y' ) this->m_UI->Q3 = this->m_YImage;
+  else if( q3 == 'z' ) this->m_UI->Q3 = this->m_ZImage;
+  else if( q3 == 'w' ) this->m_UI->Q3 = this->m_3DView;
+  if     ( q4 == 'x' ) this->m_UI->Q4 = this->m_XImage;
+  else if( q4 == 'y' ) this->m_UI->Q4 = this->m_YImage;
+  else if( q4 == 'z' ) this->m_UI->Q4 = this->m_ZImage;
+  else if( q4 == 'w' ) this->m_UI->Q4 = this->m_3DView;
+
+  // Draw all
+  this->m_UI->Q1->show( );
+  this->m_UI->Q2->show( );
+  this->m_UI->Q3->show( );
+  this->m_UI->Q4->show( );
+  dynamic_cast< RendererWidget* >( this->m_UI->Q1 )->SetQuadrant( 1 );
+  dynamic_cast< RendererWidget* >( this->m_UI->Q2 )->SetQuadrant( 2 );
+  dynamic_cast< RendererWidget* >( this->m_UI->Q3 )->SetQuadrant( 3 );
+  dynamic_cast< RendererWidget* >( this->m_UI->Q4 )->SetQuadrant( 4 );
 }
 
 // -------------------------------------------------------------------------
 bool cpExtensions::QT::SimpleMPRWidget::
-AddData(
-  vtkImageData* data, const std::string& name,
-  const std::string& parent
-  )
+HasImage( ) const
 {
-  if( name == "" )
-    return( false );
+  return( this->m_MainImage.GetPointer( ) != NULL );
+}
 
-  auto iIt = this->m_Data.find( name );
-  if( iIt == this->m_Data.end( ) )
+// -------------------------------------------------------------------------
+void cpExtensions::QT::SimpleMPRWidget::
+SetImage( vtkImageData* image, const std::string& name )
+{
+  if( this->m_MainImageName != "" || image == NULL )
   {
-    if( parent != "" )
-    {
-      auto pIt = this->m_Data.find( parent );
-      if( pIt == this->m_Data.end( ) )
-        return( false );
+    // TODO: Clear visualization
 
-    } // fi
+  } // fi
+  this->m_MainImageName = name;
+  this->m_MainImage = image;
 
-    // Add new data
-    this->m_Data[ name ].SetImageData( data );
+  if( this->m_MainImage != NULL && this->m_MainImageName != "" )
+  {
+    this->m_XImage->SetImage( this->m_MainImage, 0, name );
+    this->m_YImage->SetImage( this->m_MainImage, 1, name );
+    this->m_ZImage->SetImage( this->m_MainImage, 2, name );
+    this->m_3DView->SetImage( this->m_MainImage, name );
 
-    // Set color
-    auto iIt = this->m_Data.find( name );
-    if( iIt != this->m_Data.end( ) )
-    {
-      vtkActor* actor =
-        dynamic_cast< vtkActor* >( iIt->second.GetMeshActor( ) );
-      if( actor != NULL )
-      {
-        unsigned int idx = this->m_Data.size( ) % 8;
-        actor->GetProperty( )->SetColor(
-          Self::cm_Colors[ idx ][ 0 ],
-          Self::cm_Colors[ idx ][ 1 ],
-          Self::cm_Colors[ idx ][ 2 ]
-          );
-
-      } // fi
-
-    } // fi
-
-    // Add to tree view
-    // TODO: this->_UpdateTreeItem( name, parent );
-    return( true );
-  }
-  else
-    return( false );
+  } // fi
 }
 
 // -------------------------------------------------------------------------
 bool cpExtensions::QT::SimpleMPRWidget::
-AddData( vtkPolyData* data, const std::string& name )
+Add( vtkDataSet* data, const std::string& name )
 {
-  if( name == "" )
-    return( false );
+  bool success = true;
+  auto image = dynamic_cast< vtkImageData* >( data );
+  auto pdata = dynamic_cast< vtkPolyData* >( data );
 
-  auto iIt = this->m_Data.find( name );
-  if( iIt == this->m_Data.end( ) )
+  if( image != NULL )
   {
-    // Add new data
-    this->m_Data[ name ].SetPolyData( data );
-
-    // Set color
-    auto iIt = this->m_Data.find( name );
-    if( iIt != this->m_Data.end( ) )
+    if( this->m_MainImageName != "" )
     {
-      vtkActor* actor =
-        dynamic_cast< vtkActor* >( iIt->second.GetMeshActor( ) );
-      if( actor != NULL )
-      {
-        unsigned int idx = this->m_Data.size( ) % 8;
-        actor->GetProperty( )->SetColor(
-          Self::cm_Colors[ idx ][ 0 ],
-          Self::cm_Colors[ idx ][ 1 ],
-          Self::cm_Colors[ idx ][ 2 ]
-          );
-
-      } // fi
-
-    } // fi
-
-    // Add to tree view
-    // TODO: this->_UpdateTreeItem( name, parent );
-    return( true );
+      this->m_XImage->Add( image, name );
+      this->m_YImage->Add( image, name );
+      this->m_ZImage->Add( image, name );
+      // TODO: this->m_3DView->Add( image, name );
+    }
+    else
+      this->SetImage( image, name );
   }
+  else if( pdata != NULL )
+    this->m_3DView->Add( pdata, name );
   else
-    return( false );
+    success = false;
+  return( success );
 }
 
 // -------------------------------------------------------------------------
-const std::string& cpExtensions::QT::SimpleMPRWidget::
-GetMainImage( ) const
+cpExtensions::QT::SimpleMPRWidget::
+TProps cpExtensions::QT::SimpleMPRWidget::
+GetViewProps( const std::string& name ) const
 {
-  return( this->m_MainImage );
+/*
+  auto x = this->m_XImage->GetViewProps( name );
+  auto y = this->m_YImage->GetViewProps( name );
+  auto z = this->m_ZImage->GetViewProps( name );
+  auto w = this->m_3DView->GetViewProps( name );
+
+  TProps props;
+  if( x != NULL ) props.insert( x );
+  if( y != NULL ) props.insert( y );
+  if( z != NULL ) props.insert( z );
+  if( w != NULL ) props.insert( w );
+  return( props );
+*/
+  TProps props;
+  return( props );
 }
 
 // -------------------------------------------------------------------------
-bool cpExtensions::QT::SimpleMPRWidget::
-SetMainImage( const std::string& name )
+cpExtensions::QT::SimpleMPRWidget::
+TProps cpExtensions::QT::SimpleMPRWidget::
+GetImageProps( ) const
 {
-  auto iIt = this->m_Data.find( name );
-  if( iIt != this->m_Data.end( ) )
-  {
-    if( iIt->second.Tag == Data::IMAGE )
-    {
-      this->m_MainImage = name;
-      return( true );
-    }
-    else
-      return( false );
-  }
-  else
-    return( false );
+  return( this->GetViewProps( this->m_MainImageName ) );
 }
 
 // -------------------------------------------------------------------------
-void cpExtensions::QT::SimpleMPRWidget::
-DeleteData( const std::string& name )
+vtkRenderWindowInteractor* cpExtensions::QT::SimpleMPRWidget::
+GetXInteractor( )
 {
-  auto iIt = this->m_Data.find( name );
-  if( iIt != this->m_Data.end( ) )
-  {
-    this->m_Data.erase( iIt );
-
-    // Get children
-    std::vector< std::string > to_erase;
-    auto tIt = this->m_Tree.begin( );
-    for( ; tIt != this->m_Tree.end( ); ++tIt )
-      if( tIt->second == name )
-        to_erase.push_back( tIt->first );
-
-    // Delete from tree
-    tIt = this->m_Tree.find( name );
-    if( tIt != this->m_Tree.end( ) )
-      this->m_Tree.erase( tIt );
-
-    // Recursive erase
-    auto dIt = to_erase.begin( );
-    for( ; dIt != to_erase.end( ); ++dIt )
-      this->DeleteData( *dIt );
-
-    // Delete from tree widget
-    /* TODO
-       QTreeWidgetItem* item = this->_FindItemInTree( name );
-       if( item != NULL )
-       this->m_UI->LoadedData->removeItemWidget( item, 0 );
-    */
-
-    // Reset main image, just in case
-    if( this->m_Data.size( ) == 0 )
-      this->m_MainImage = "";
+  return( this->m_XImage->GetInteractor( ) );
+}
 
-  } // fi
+// -------------------------------------------------------------------------
+const vtkRenderWindowInteractor* cpExtensions::QT::SimpleMPRWidget::
+GetXInteractor( ) const
+{
+  return( this->m_XImage->GetInteractor( ) );
 }
 
 // -------------------------------------------------------------------------
-void cpExtensions::QT::SimpleMPRWidget::
-DeleteAllData( )
+vtkRenderWindowInteractor* cpExtensions::QT::SimpleMPRWidget::
+GetYInteractor( )
 {
-  this->m_MPRObjects->Clear( );
-  this->m_Data.clear( );
-  this->m_Tree.clear( );
-  // TODO: this->m_UI->LoadedData->clear( );
-  this->m_MainImage = "";
+  return( this->m_YImage->GetInteractor( ) );
 }
 
 // -------------------------------------------------------------------------
-void cpExtensions::QT::SimpleMPRWidget::
-SetDataColor(
-  const std::string& name, const double& r, const double& g, const double& b
-  )
+const vtkRenderWindowInteractor* cpExtensions::QT::SimpleMPRWidget::
+GetYInteractor( ) const
 {
-  /*
-    auto iIt = this->m_Data.find( name );
-    if( iIt == this->m_Data.end( ) )
-    return;
+  return( this->m_YImage->GetInteractor( ) );
+}
 
-    if( iIt->second.Tag == Data::IMAGE )
-    {
-    }
-    else if( iIt->second.Tag == Data::MESH )
-    {
-    } // fi
-  */
+// -------------------------------------------------------------------------
+vtkRenderWindowInteractor* cpExtensions::QT::SimpleMPRWidget::
+GetZInteractor( )
+{
+  return( this->m_ZImage->GetInteractor( ) );
 }
 
 // -------------------------------------------------------------------------
-void cpExtensions::QT::SimpleMPRWidget::
-ShowData( const std::string& name )
+const vtkRenderWindowInteractor* cpExtensions::QT::SimpleMPRWidget::
+GetZInteractor( ) const
 {
-  auto iIt = this->m_Data.find( name );
-  if( iIt == this->m_Data.end( ) )
-    return;
+  return( this->m_ZImage->GetInteractor( ) );
+}
 
-  if( iIt->second.Tag == Data::IMAGE )
-  {
-    if( name == this->m_MainImage )
-      this->m_MPRObjects->SetInputImage( iIt->second.Image );
-    else
-    {
-      unsigned int i = ( this->m_MPRObjects->GetNumberOfImages( ) - 1 ) % 8;
-      this->m_MPRObjects->AddBinaryImage(
-        iIt->second.Image,
-        Self::cm_Colors[ i ][ 0 ],
-        Self::cm_Colors[ i ][ 1 ],
-        Self::cm_Colors[ i ][ 2 ]
-        );
-    }
-    this->m_MPRObjects->Show( );
-  }
-  else if( iIt->second.Tag == Data::MESH )
-  {
-    vtkRenderer* ren =
-      this->m_VTK[ 3 ]->GetRenderWindow( )->
-      GetRenderers( )->GetFirstRenderer( );
-    if( ren == NULL )
-      return;
-    ren->AddActor( iIt->second.GetMeshActor( ) );
-    this->m_VTK[ 3 ]->GetRenderWindow( )->Render( );
+// -------------------------------------------------------------------------
+vtkRenderWindowInteractor* cpExtensions::QT::SimpleMPRWidget::
+GetWInteractor( )
+{
+  return( this->m_3DView->GetInteractor( ) );
+}
 
-  } // fi
+// -------------------------------------------------------------------------
+const vtkRenderWindowInteractor* cpExtensions::QT::SimpleMPRWidget::
+GetWInteractor( ) const
+{
+  return( this->m_3DView->GetInteractor( ) );
+}
+
+// -------------------------------------------------------------------------
+vtkRenderWindow* cpExtensions::QT::SimpleMPRWidget::
+GetXRenderWindow( )
+{
+  return( this->m_XImage->GetRenderWindow( ) );
+}
+
+// -------------------------------------------------------------------------
+const vtkRenderWindow* cpExtensions::QT::SimpleMPRWidget::
+GetXRenderWindow( ) const
+{
+  return( this->m_XImage->GetRenderWindow( ) );
+}
+
+// -------------------------------------------------------------------------
+vtkRenderWindow* cpExtensions::QT::SimpleMPRWidget::
+GetYRenderWindow( )
+{
+  return( this->m_YImage->GetRenderWindow( ) );
+}
+
+// -------------------------------------------------------------------------
+const vtkRenderWindow* cpExtensions::QT::SimpleMPRWidget::
+GetYRenderWindow( ) const
+{
+  return( this->m_YImage->GetRenderWindow( ) );
+}
+
+// -------------------------------------------------------------------------
+vtkRenderWindow* cpExtensions::QT::SimpleMPRWidget::
+GetZRenderWindow( )
+{
+  return( this->m_ZImage->GetRenderWindow( ) );
+}
+
+// -------------------------------------------------------------------------
+const vtkRenderWindow* cpExtensions::QT::SimpleMPRWidget::
+GetZRenderWindow( ) const
+{
+  return( this->m_ZImage->GetRenderWindow( ) );
+}
+
+// -------------------------------------------------------------------------
+vtkRenderWindow* cpExtensions::QT::SimpleMPRWidget::
+GetWRenderWindow( )
+{
+  return( this->m_3DView->GetRenderWindow( ) );
+}
+
+
+// -------------------------------------------------------------------------
+const vtkRenderWindow* cpExtensions::QT::SimpleMPRWidget::
+GetWRenderWindow( ) const
+{
+  return( this->m_3DView->GetRenderWindow( ) );
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::QT::SimpleMPRWidget::
-HideData( const std::string& name )
+ResetCameras( )
 {
+  this->m_XImage->ResetCamera( );
+  this->m_YImage->ResetCamera( );
+  this->m_ZImage->ResetCamera( );
+  this->m_3DView->ResetCamera( );
 }
 
 // -------------------------------------------------------------------------
-vtkRenderWindowInteractor* cpExtensions::QT::SimpleMPRWidget::
-GetInteractor( unsigned int i )
+void cpExtensions::QT::SimpleMPRWidget::
+Render( )
 {
-  if( i < 4 )
-  {
-    if( this->m_VTK[ i ] != NULL )
-      return( this->m_VTK[ i ]->GetInteractor( ) );
-    else
-      return( NULL );
-  }
-  else
-    return( NULL );
+  this->m_XImage->Render( );
+  this->m_YImage->Render( );
+  this->m_ZImage->Render( );
+  this->m_3DView->Render( );
 }
 
 // -------------------------------------------------------------------------
-/*
-  bool cpExtensions::QT::SimpleMPRWidget::
-  ShowImage(
-  vtkImageData* image,
-  const std::string& name,
-  const std::string& parent
-  )
-  {
-  // Update tree view
-  QTreeWidgetItem* new_item = this->_UpdateTreeItem( name, parent );
-  if( new_item == NULL )
-  return( false );
-
-  // Associate new data
-  this->m_Images[ name ] = image;
-  this->m_Tree[ name ] = parent;
-
-  // Show image and return
-  this->m_MPRObjects->AddImage( image );
-  return( true );
-  }
+std::set< std::string > cpExtensions::QT::SimpleMPRWidget::
+GetActorsNames( ) const
+{
+  std::set< std::string > names = this->m_XImage->GetActorsNames( );
+  std::set< std::string > y = this->m_YImage->GetActorsNames( );
+  std::set< std::string > z = this->m_ZImage->GetActorsNames( );
+  std::set< std::string > w = this->m_3DView->GetActorsNames( );
+  names.insert( y.begin( ), y.end( ) );
+  names.insert( z.begin( ), z.end( ) );
+  names.insert( w.begin( ), w.end( ) );
+  return( names );
+}
 
-  // -------------------------------------------------------------------------
-  bool cpExtensions::QT::SimpleMPRWidget::
-  ShowImage(
-  vtkImageData* image,
-  const std::string& name,
-  const std::string& parent,
-  const double& r, const double& g, const double& b
-  )
-  {
-  // Update tree view
-  QTreeWidgetItem* new_item = this->_UpdateTreeItem( name, parent );
-  if( new_item == NULL )
-  return( false );
-
-  // Associate new data
-  this->m_Images[ name ] = image;
-  this->m_Tree[ name ] = parent;
-
-  // Show image and return
-  this->m_MPRObjects->AddImage( image );
-  return( true );
-  }
+// -------------------------------------------------------------------------
+bool cpExtensions::QT::SimpleMPRWidget::
+IsWindowLevelImageActor( const std::string& name ) const
+{
+  return( this->m_XImage->IsWindowLevelImageActor( name ) );
+}
 
-  // -------------------------------------------------------------------------
-  bool cpExtensions::QT::SimpleMPRWidget::
-  ShowMesh(
-  vtkPolyData* mesh,
-  const std::string& name,
-  const std::string& parent
-  )
-  {
-  // Update tree view
-  QTreeWidgetItem* new_item = this->_UpdateTreeItem( name, parent );
-  if( new_item == NULL )
-  return( false );
-
-  // Associate new data
-  PolyDataActor* actor = new PolyDataActor( mesh );
-  this->m_Meshes[ name ] = actor;
-  this->m_Tree[ name ] = parent;
-
-  // Show mesh
-  this->_Add3DActor( actor->Actor );
-  return( true );
-  }
+// -------------------------------------------------------------------------
+bool cpExtensions::QT::SimpleMPRWidget::
+IsLUTImageActor( const std::string& name ) const
+{
+  return( this->m_XImage->IsLUTImageActor( name ) );
+}
 
-  // -------------------------------------------------------------------------
-  bool cpExtensions::QT::SimpleMPRWidget::
-  ShowMesh(
-  vtkPolyData* mesh,
-  const std::string& name,
-  const std::string& parent,
-  const double& r, const double& g, const double& b
-  )
-  {
-  return false;
-  }
+// -------------------------------------------------------------------------
+bool cpExtensions::QT::SimpleMPRWidget::
+Is3DActor( const std::string& name ) const
+{
+  return(
+    this->m_XImage->Is3DActor( name ) || this->m_3DView->Is3DActor( name )
+    );
+}
 
-  // -------------------------------------------------------------------------
-  void cpExtensions::QT::SimpleMPRWidget::
-  ClearAll( )
-  {
-  this->m_MPRObjects->ClearAll( );
-  this->m_Images.clear( );
-  this->m_Meshes.clear( );
-  }
-*/
+// -------------------------------------------------------------------------
+void cpExtensions::QT::SimpleMPRWidget::
+GetScalarRange( const std::string& name, double r[ 2 ] ) const
+{
+  this->m_XImage->GetScalarRange( name, r );
+}
 
 // -------------------------------------------------------------------------
-std::string cpExtensions::QT::SimpleMPRWidget::
-GetSelectedData( ) const
+void cpExtensions::QT::SimpleMPRWidget::
+GetWindowLevel( const std::string& name, double wl[ 2 ] ) const
 {
-  /* TODO
-     QTreeWidgetItem* item = this->m_UI->LoadedData->currentItem( );
-     if( item != NULL )
-     return( item->text( 0 ).toStdString( ) );
-     else
-  */
-  return( "" );
+  this->m_XImage->GetWindowLevel( name, wl );
 }
 
 // -------------------------------------------------------------------------
-/* TODO
-QTreeWidgetItem* cpExtensions::QT::SimpleMPRWidget::
-_FindItemInTree( const std::string& name ) const
+double cpExtensions::QT::SimpleMPRWidget::
+GetWindow( const std::string& name ) const
 {
-  QList< QTreeWidgetItem* > items =
-    this->m_UI->LoadedData->findItems(
-      name.c_str( ), Qt::MatchExactly | Qt::MatchRecursive
-      );
-  if( items.size( ) > 0 )
-    return( items[ 0 ] );
-  else
-    return( NULL );
+  return( this->m_XImage->GetWindow( name ) );
 }
 
 // -------------------------------------------------------------------------
-QTreeWidgetItem* cpExtensions::QT::SimpleMPRWidget::
-_UpdateTreeItem( const std::string& name, const std::string& parent )
+double cpExtensions::QT::SimpleMPRWidget::
+GetLevel( const std::string& name ) const
 {
-  // Update tree view
-  QTreeWidgetItem* new_item = NULL;
-  if( parent != "" )
-  {
-    QTreeWidgetItem* parent_item = this->_FindItemInTree( parent );
-    if( parent_item != NULL )
-    {
-      QTreeWidgetItem* old_item = this->_FindItemInTree( name );
-      if( old_item == NULL )
-      {
-        new_item =
-          new QTreeWidgetItem( parent_item, QStringList( name.c_str( ) ) );
-        parent_item->setExpanded( true );
+  return( this->m_XImage->GetLevel( name ) );
+}
 
-      } // fi
+// -------------------------------------------------------------------------
+char cpExtensions::QT::SimpleMPRWidget::
+GetImageInterpolation( const std::string& name ) const
+{
+  return( this->m_XImage->GetImageInterpolation( name ) );
+}
 
-    } // fi
-  }
-  else
-  {
-    new_item = new QTreeWidgetItem(
-      ( QTreeWidgetItem* )( NULL ), QStringList( name.c_str( ) )
-      );
-    this->m_UI->LoadedData->addTopLevelItem( new_item );
+// -------------------------------------------------------------------------
+void cpExtensions::QT::SimpleMPRWidget::
+GetColor( const std::string& name, double& r, double& g, double& b ) const
+{
+  this->m_XImage->GetColor( name, r, g, b );
+}
 
-  } // fi
-  return( new_item );
+// -------------------------------------------------------------------------
+double cpExtensions::QT::SimpleMPRWidget::
+GetOpacity( const std::string& name ) const
+{
+  return( this->m_XImage->GetOpacity( name ) );
 }
-*/
 
 // -------------------------------------------------------------------------
-/*
-  void cpExtensions::QT::SimpleMPRWidget::
-  _Add3DActor( vtkProp3D* prop )
-  {
-  vtkRenderer* ren =
-  this->m_VTK[ 3 ]->GetRenderWindow( )->GetRenderers( )->GetFirstRenderer( );
-  if( ren == NULL )
-  return;
-  ren->AddActor( prop );
-  this->m_VTK[ 3 ]->GetRenderWindow( )->Render( );
-  }
-*/
+double cpExtensions::QT::SimpleMPRWidget::
+GetPointSize( const std::string& name ) const
+{
+  return( this->m_XImage->GetPointSize( name ) );
+}
+
+// -------------------------------------------------------------------------
+double cpExtensions::QT::SimpleMPRWidget::
+GetLineWidth( const std::string& name ) const
+{
+  return( this->m_XImage->GetLineWidth( name ) );
+}
+
+// -------------------------------------------------------------------------
+int cpExtensions::QT::SimpleMPRWidget::
+GetRepresentation( const std::string& name ) const
+{
+  return( this->m_XImage->GetRepresentation( name ) );
+}
 
 // -------------------------------------------------------------------------
 void cpExtensions::QT::SimpleMPRWidget::
-_SyncBottom( int a, int b )
+SetScalarRange( const std::string& name, double r[ 2 ] )
 {
-  this->m_UI->BottomSplitter->setSizes( this->m_UI->TopSplitter->sizes( ) );
+  this->m_XImage->SetScalarRange( name, r );
+  this->m_YImage->SetScalarRange( name, r );
+  this->m_ZImage->SetScalarRange( name, r );
+  this->m_3DView->SetScalarRange( name, r );
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::QT::SimpleMPRWidget::
-_SyncTop( int a, int b )
+SetScalarRange( const std::string& name, double min, double max )
 {
-  this->m_UI->TopSplitter->setSizes( this->m_UI->BottomSplitter->sizes( ) );
+  this->m_XImage->SetScalarRange( name, min, max );
+  this->m_YImage->SetScalarRange( name, min, max );
+  this->m_ZImage->SetScalarRange( name, min, max );
+  this->m_3DView->SetScalarRange( name, min, max );
 }
 
 // -------------------------------------------------------------------------
-cpExtensions::QT::SimpleMPRWidget::PolyDataActor::
-PolyDataActor( )
-  : Mesh( NULL ),
-    Normals( NULL ),
-    Stripper( NULL ),
-    Mapper( NULL ),
-    Actor( NULL )
+void cpExtensions::QT::SimpleMPRWidget::
+SetWindowLevel( const std::string& name, double wl[ 2 ] )
 {
+  this->m_XImage->SetWindowLevel( name, wl );
+  this->m_YImage->SetWindowLevel( name, wl );
+  this->m_ZImage->SetWindowLevel( name, wl );
+  this->m_3DView->SetWindowLevel( name, wl );
 }
 
 // -------------------------------------------------------------------------
-cpExtensions::QT::SimpleMPRWidget::PolyDataActor::
-~PolyDataActor( )
+void cpExtensions::QT::SimpleMPRWidget::
+SetWindowLevel( const std::string& name, double w, double l )
 {
-  if( this->Actor != NULL )    this->Actor->Delete( );
-  if( this->Mapper != NULL )   this->Mapper->Delete( );
-  if( this->Stripper != NULL ) this->Stripper->Delete( );
-  if( this->Normals != NULL )  this->Normals->Delete( );
+  this->m_XImage->SetWindowLevel( name, w, l );
+  this->m_YImage->SetWindowLevel( name, w, l );
+  this->m_ZImage->SetWindowLevel( name, w, l );
+  this->m_3DView->SetWindowLevel( name, w, l );
 }
 
 // -------------------------------------------------------------------------
-void cpExtensions::QT::SimpleMPRWidget::PolyDataActor::
-Configure( vtkPolyData* pd )
+void cpExtensions::QT::SimpleMPRWidget::
+SetWindow( const std::string& name, double w )
 {
-  if( pd ==  NULL )
-    return;
+  this->m_XImage->SetWindow( name, w );
+  this->m_YImage->SetWindow( name, w );
+  this->m_ZImage->SetWindow( name, w );
+  this->m_3DView->SetWindow( name, w );
+}
 
-  double range[ 2 ];
-  pd->GetScalarRange( range );
+// -------------------------------------------------------------------------
+void cpExtensions::QT::SimpleMPRWidget::
+SetLevel( const std::string& name, double l )
+{
+  this->m_XImage->SetLevel( name, l );
+  this->m_YImage->SetLevel( name, l );
+  this->m_ZImage->SetLevel( name, l );
+  this->m_3DView->SetLevel( name, l );
+}
 
-  this->Normals = vtkPolyDataNormals::New( );
-  this->Stripper = vtkStripper::New( );
-  this->Mapper = vtkPolyDataMapper::New( );
-  this->Actor = vtkQuadricLODActor::New( );
+// -------------------------------------------------------------------------
+void cpExtensions::QT::SimpleMPRWidget::
+SetImageInterpolation( const std::string& name, char i )
+{
+  this->m_XImage->SetImageInterpolation( name, i );
+  this->m_YImage->SetImageInterpolation( name, i );
+  this->m_ZImage->SetImageInterpolation( name, i );
+  this->m_3DView->SetImageInterpolation( name, i );
+}
 
-  this->Mesh = pd;
-  this->Normals->SetInputData( pd );
-  this->Normals->SetFeatureAngle( 60.0 );
-  this->Stripper->SetInputConnection( this->Normals->GetOutputPort( ) );
-  this->Mapper->SetInputConnection( this->Stripper->GetOutputPort( ) );
-  this->Mapper->UseLookupTableScalarRangeOff( );
-  this->Mapper->SetScalarRange(
-    range[ 0 ], ( ( range[ 1 ] - range[ 0 ] ) * 0.75 ) + range[ 0 ]
-    );
-  this->Actor->SetMapper( this->Mapper );
-  this->Actor->DeferLODConstructionOff( );
+// -------------------------------------------------------------------------
+void cpExtensions::QT::SimpleMPRWidget::
+SetColor( const std::string& name, double r, double g, double b )
+{
+  this->m_XImage->SetColor( name, r, g, b );
+  this->m_YImage->SetColor( name, r, g, b );
+  this->m_ZImage->SetColor( name, r, g, b );
+  this->m_3DView->SetColor( name, r, g, b );
 }
 
 // -------------------------------------------------------------------------
-cpExtensions::QT::SimpleMPRWidget::Data::
-Data( )
+void cpExtensions::QT::SimpleMPRWidget::
+SetOpacity( const std::string& name, double o )
 {
-  this->Tag = Data::IMAGE;
-  this->Image = NULL;
+  this->m_XImage->SetOpacity( name, o );
+  this->m_YImage->SetOpacity( name, o );
+  this->m_ZImage->SetOpacity( name, o );
+  this->m_3DView->SetOpacity( name, o );
 }
 
 // -------------------------------------------------------------------------
-cpExtensions::QT::SimpleMPRWidget::Data::
-~Data( )
+void cpExtensions::QT::SimpleMPRWidget::
+SetPointSize( const std::string& name, double s )
 {
+  this->m_XImage->SetPointSize( name, s );
+  this->m_YImage->SetPointSize( name, s );
+  this->m_ZImage->SetPointSize( name, s );
+  this->m_3DView->SetPointSize( name, s );
 }
 
 // -------------------------------------------------------------------------
-cpExtensions::QT::SimpleMPRWidget::
-Data& cpExtensions::QT::SimpleMPRWidget::Data::
-operator=( const Data& data )
+void cpExtensions::QT::SimpleMPRWidget::
+SetLineWidth( const std::string& name, double w )
 {
-  this->Tag = data.Tag;
-  if( this->Tag == Data::IMAGE )
-    this->Image = data.Image;
-  else if( this->Tag == Data::MESH )
-    this->Mesh = data.Mesh;
-  return( *this );
+  this->m_XImage->SetLineWidth( name, w );
+  this->m_YImage->SetLineWidth( name, w );
+  this->m_ZImage->SetLineWidth( name, w );
+  this->m_3DView->SetLineWidth( name, w );
 }
 
 // -------------------------------------------------------------------------
-void cpExtensions::QT::SimpleMPRWidget::Data::
-SetImageData( vtkImageData* data )
+void cpExtensions::QT::SimpleMPRWidget::
+SetRepresentationToPoints( const std::string& name )
 {
-  this->Tag = Data::IMAGE;
-  this->Image = data;
+  this->m_XImage->SetRepresentationToPoints( name );
+  this->m_YImage->SetRepresentationToPoints( name );
+  this->m_ZImage->SetRepresentationToPoints( name );
+  this->m_3DView->SetRepresentationToPoints( name );
 }
 
 // -------------------------------------------------------------------------
-void cpExtensions::QT::SimpleMPRWidget::Data::
-SetPolyData( vtkPolyData* data )
+void cpExtensions::QT::SimpleMPRWidget::
+SetRepresentationToSurface( const std::string& name )
 {
-  this->Tag = Data::MESH;
-  this->Mesh.Configure( data );
+  this->m_XImage->SetRepresentationToSurface( name );
+  this->m_YImage->SetRepresentationToSurface( name );
+  this->m_ZImage->SetRepresentationToSurface( name );
+  this->m_3DView->SetRepresentationToSurface( name );
 }
 
 // -------------------------------------------------------------------------
-vtkImageData* cpExtensions::QT::SimpleMPRWidget::Data::
-GetImage( )
+void cpExtensions::QT::SimpleMPRWidget::
+SetRepresentationToWireframe( const std::string& name )
 {
-  if( this->Tag == Data::IMAGE )
-    return( this->Image );
-  else
-    return( NULL );
+  this->m_XImage->SetRepresentationToWireframe( name );
+  this->m_YImage->SetRepresentationToWireframe( name );
+  this->m_ZImage->SetRepresentationToWireframe( name );
+  this->m_3DView->SetRepresentationToWireframe( name );
 }
 
 // -------------------------------------------------------------------------
-vtkPolyData* cpExtensions::QT::SimpleMPRWidget::Data::
-GetMesh( )
+void cpExtensions::QT::SimpleMPRWidget::
+_SyncBottom( int a, int b )
 {
-  if( this->Tag == Data::MESH )
-    return( this->Mesh.Mesh );
-  else
-    return( NULL );
+  this->m_UI->Bottom->setSizes( this->m_UI->Top->sizes( ) );
 }
 
 // -------------------------------------------------------------------------
-vtkProp* cpExtensions::QT::SimpleMPRWidget::Data::
-GetMeshActor( )
+void cpExtensions::QT::SimpleMPRWidget::
+_SyncTop( int a, int b )
 {
-  if( this->Tag == Data::MESH )
-    return( this->Mesh.Actor );
-  else
-    return( NULL );
+  this->m_UI->Top->setSizes( this->m_UI->Bottom->sizes( ) );
 }
 
 #endif // cpExtensions_QT4