]> Creatis software - cpPlugins.git/commitdiff
MPR objects and interactors updated.
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Mon, 26 Oct 2015 15:27:59 +0000 (10:27 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Mon, 26 Oct 2015 15:27:59 +0000 (10:27 -0500)
appli/ImageMPR/ImageMPR.cxx
lib/cpPlugins/Interface/BaseMPRWindow.cxx
lib/cpPlugins/Interface/BaseMPRWindow.h
lib/cpPlugins/Interface/Mesh.cxx
lib/cpPlugins/Interface/Mesh.h
lib/cpPlugins/Interface/ParametersQtDialog.cxx
lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.cxx

index 133060315c0ef51e7334e63ae97aa6b8ed23625d..a83a5d6b7898c3651f289ccd03eaa3aeb98ec877 100644 (file)
@@ -186,8 +186,12 @@ _execPlugin( )
         err = filter->Update( );
         this->_Unblock( );
         TPlugins::TMesh::Pointer mesh =
-          filter->GetOutput< TPlugins::TMesh >( "Input" );
-        mesh->Print( std::cout );
+          filter->GetOutput< TPlugins::TMesh >( "Output" );
+        this->m_Meshes.push_back( mesh );
+        mesh->CreateVTKActor( );
+        vtkActor* actor = mesh->GetVTKActor( );
+        if( actor != NULL )
+          this->m_UI->MPR->Add3DActor( actor );
 
       } // fi
 
index 90100a110419e5b6b5b9c09695f4fd2f77411fe7..230c961822aed4f3c42a3d13b2e87ebf917fb78d 100644 (file)
@@ -2,6 +2,8 @@
 
 #ifdef cpPlugins_Interface_QT4
 
+#include <vtkRendererCollection.h>
+
 // -------------------------------------------------------------------------
 cpPlugins::Interface::BaseMPRWindow::
 BaseMPRWindow( QWidget* parent )
@@ -96,6 +98,18 @@ ClearAll( )
   */
 }
 
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::BaseMPRWindow::
+Add3DActor( vtkProp3D* prop )
+{
+  vtkRenderer* ren =
+    this->m_WVTK->GetRenderWindow( )->GetRenderers( )->GetFirstRenderer( );
+  if( ren == NULL )
+    return;
+  ren->AddActor( prop );
+  this->m_WVTK->GetRenderWindow( )->Render( );
+}
+
 #endif // cpPlugins_Interface_QT4
 
 // eof - $RCSfile$
index 877e4c74c61a264754ae62383effcddc25075075..078e0288019ebd1c31c4ffb24bbb4c6caf52bd13 100644 (file)
@@ -41,7 +41,7 @@ namespace cpPlugins
       explicit BaseMPRWindow( QWidget* parent = 0 );
       virtual ~BaseMPRWindow( );
 
-      // Somme visualization accessors
+      // Some visualization accessors
       bool ShowImage( vtkImageData* image );
       bool ShowImage( vtkImageData* image, double r, double g, double b );
       bool ShowMesh( vtkPolyData* mesh );
@@ -49,6 +49,9 @@ namespace cpPlugins
       double GetLevel( ) const;
       void ClearAll( );
 
+      // Some more visualization (3D)
+      void Add3DActor( vtkProp3D* prop );
+
     protected:
       vtkSmartPointer< TMPRObjects > m_MPRObjects;
 
index 2866967ae73376e7a4a508aa911ab5a1274e3f0b..829c1f53417839f1c41aa9ef3fea1bbdf3f4ab4f 100644 (file)
@@ -31,16 +31,27 @@ CreateVTKActor( )
     double range[ 2 ];
     pd->GetScalarRange( range );
 
+    this->m_Normals = vtkSmartPointer< vtkPolyDataNormals >::New( );
+    this->m_Stripper = vtkSmartPointer< vtkStripper >::New( );
     this->m_Mapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
-    this->m_Actor = vtkSmartPointer< vtkActor >::New( );
-    this->m_Mapper->SetInputData( pd );
+    this->m_Actor = vtkSmartPointer< vtkQuadricLODActor >::New( );
+
+    this->m_Normals->SetInputData( pd );
+    this->m_Normals->SetFeatureAngle( 60.0 );
+    this->m_Stripper->SetInputConnection( this->m_Normals->GetOutputPort( ) );
+    this->m_Mapper->SetInputConnection( this->m_Stripper->GetOutputPort( ) );
     this->m_Mapper->UseLookupTableScalarRangeOff( );
     this->m_Mapper->SetScalarRange(
       range[ 0 ], ( ( range[ 1 ] - range[ 0 ] ) * 0.75 ) + range[ 0 ]
       );
     this->m_Actor->SetMapper( this->m_Mapper );
+    this->m_Actor->DeferLODConstructionOff( );
     this->Modified( );
 
+    /*
+      TODO: vtkQuadricLODActor : AllocatedRenderTime
+    */
+
   } // fi
 }
 
index 0eb76ed4cbe8cfc96dc99057e7bbb462df63b56d..b2fe92302d84c810a20276a0e784320eb5f02f29 100644 (file)
@@ -5,8 +5,10 @@
 #include <cpPlugins/Interface/DataObject.h>
 
 #include <vtkSmartPointer.h>
-#include <vtkActor.h>
+#include <vtkQuadricLODActor.h>
 #include <vtkPolyDataMapper.h>
+#include <vtkPolyDataNormals.h>
+#include <vtkStripper.h>
 
 namespace cpPlugins
 {
@@ -50,8 +52,10 @@ namespace cpPlugins
       Self& operator=( const Self& );
 
     protected:
-      vtkSmartPointer< vtkActor >          m_Actor;
-      vtkSmartPointer< vtkPolyDataMapper > m_Mapper;
+      vtkSmartPointer< vtkPolyDataNormals > m_Normals;
+      vtkSmartPointer< vtkStripper >        m_Stripper;
+      vtkSmartPointer< vtkPolyDataMapper >  m_Mapper;
+      vtkSmartPointer< vtkQuadricLODActor > m_Actor;
     };
 
   } // ecapseman
index e28a086e2e1f069bf9c017e8851da56040ffdca5..8a012b646ef59f41da7d9ea03853ded410808426 100644 (file)
@@ -41,8 +41,8 @@ cpPlugins::Interface::ParametersQtDialog::
 ~ParametersQtDialog( )
 {
   delete this->m_Title;
-  delete this->m_MainLayout;
   delete this->m_ToolsLayout;
+  delete this->m_MainLayout;
 
   for( unsigned int i = 0; i < this->m_Widgets.size( ); ++i )
     this->m_Widgets[ i ]->Delete( );
@@ -221,7 +221,97 @@ show( )
 void cpPlugins::Interface::ParametersQtDialog::
 syncParameters( )
 {
-  std::cout << "TODO: SyncParameters" << std::endl;
+  if( this->m_Parameters == NULL )
+    return;
+
+  // Get values
+  std::vector< std::string > names;
+  this->m_Parameters->GetNames( names );
+  std::vector< std::string >::const_iterator nIt = names.begin( );
+  for( ; nIt != names.end( ); ++nIt )
+  {
+    Parameters::Type pt = this->m_Parameters->GetType( *nIt );
+
+    if( pt == Parameters::String )
+    {
+      QLineEdit* v = this->findChild< QLineEdit* >( nIt->c_str( ) );
+      if( v != NULL )
+        this->m_Parameters->SetString( *nIt, v->text( ).toStdString( ) );
+    }
+    else if( pt == Parameters::Bool )
+    {
+      QCheckBox* v = this->findChild< QCheckBox* >( nIt->c_str( ) );
+      if( v != NULL )
+        this->m_Parameters->SetBool( *nIt, v->isChecked( ) );
+    }
+    else if( pt == Parameters::Uint )
+    {
+      QSpinBox* v = this->findChild< QSpinBox* >( nIt->c_str( ) );
+      if( v != NULL )
+        this->m_Parameters->SetUint( *nIt, v->value( ) );
+    }
+    else if( pt == Parameters::Int )
+    {
+      QSpinBox* v = this->findChild< QSpinBox* >( nIt->c_str( ) );
+      if( v != NULL )
+        this->m_Parameters->SetInt( *nIt, v->value( ) );
+    }
+    else if( pt == Parameters::Real )
+    {
+      QDoubleSpinBox* v = this->findChild< QDoubleSpinBox* >( nIt->c_str( ) );
+      if( v != NULL )
+        this->m_Parameters->SetReal( *nIt, v->value( ) );
+    }
+    else if(
+      pt == Parameters::StringList ||
+      pt == Parameters::IntList ||
+      pt == Parameters::UintList ||
+      pt == Parameters::RealList
+      )
+    {
+      cpPlugins::Interface::ParametersListWidget* lst =
+        this->findChild< cpPlugins::Interface::ParametersListWidget* >(
+          nIt->c_str( )
+          );
+      if( lst != NULL )
+      {
+        if( pt == Parameters::StringList )
+        {
+          this->m_Parameters->ClearStringList( *nIt );
+          std::vector< std::string > values = lst->GetStringValues( );
+          for( int r = 0; r < values.size( ); ++r )
+            this->m_Parameters->AddToStringList( *nIt, values[ r ] );
+        }
+        else if( pt == Parameters::IntList )
+        {
+          this->m_Parameters->ClearIntList( *nIt );
+          std::vector< int > values = lst->GetIntValues( );
+          for( int r = 0; r < values.size( ); ++r )
+            this->m_Parameters->AddToIntList( *nIt, values[ r ] );
+        }
+        else if( pt == Parameters::UintList )
+        {
+          this->m_Parameters->ClearUintList( *nIt );
+          std::vector< unsigned int > values = lst->GetUintValues( );
+          for( int r = 0; r < values.size( ); ++r )
+            this->m_Parameters->AddToUintList( *nIt, values[ r ] );
+        }
+        else if( pt == Parameters::RealList )
+        {
+          this->m_Parameters->ClearRealList( *nIt );
+          std::vector< double > values = lst->GetDoubleValues( );
+          for( int r = 0; r < values.size( ); ++r )
+            this->m_Parameters->AddToRealList( *nIt, values[ r ] );
+
+        } // fi
+
+      } // fi
+    }
+    else if( pt == Parameters::Point || pt == Parameters::Index )
+    {
+    } // fi
+
+  } // rof
 }
 
 
@@ -248,148 +338,6 @@ syncParameters( )
    };
 */
 /*
-  bool cpPlugins::Interface::
-  ParametersQtDialog(
-  Parameters* parameters, const std::string& title, QWidget* parent
-  )
-  {
-  // Create dialog with a simple layout
-  QDialog* dlg = new QDialog( parent );
-  dlg->setWindowFlags( Qt::FramelessWindowHint );
-  dlg->setWindowFlags( Qt::WindowTitleHint );
-  QGridLayout* gridLayout = new QGridLayout( dlg );
-  QVBoxLayout* verticalLayout = new QVBoxLayout( );
-
-  // Put a title
-  QLabel* dlg_title = new QLabel( dlg );
-  dlg_title->setText( title.c_str( ) );
-  verticalLayout->addWidget( dlg_title );
-
-  // Put values
-  std::vector< std::string > names;
-  this->m_Parameters->GetNames( names );
-  std::vector< std::string >::const_iterator nIt = names.begin( );
-  for( ; nIt != names.end( ); ++nIt )
-  {
-  Parameters::Type pt = this->m_Parameters->GetType( *nIt );
-
-  QWidget* w_input = NULL;
-  if( pt == Parameters::String )
-  {
-  QLineEdit* v_string = new QLineEdit( dlg );
-  v_string->setText( "Enter some text!!!" );
-  w_input = v_string;
-  }
-  else if( pt == Parameters::Bool )
-  {
-  QCheckBox* v_bool = new QCheckBox( dlg );
-  v_bool->setText( "[ON/OFF]" );
-  v_bool->setChecked( this->m_Parameters->GetBool( *nIt ) );
-  w_input = v_bool;
-  }
-  else if( pt == Parameters::Uint )
-  {
-  QSpinBox* v_uint = new QSpinBox( dlg );
-  v_uint->setMinimum( 0 );
-  v_uint->setMaximum( std::numeric_limits< int >::max( ) );
-  v_uint->setValue( this->m_Parameters->GetUint( *nIt ) );
-  w_input = v_uint;
-  }
-  else if( pt == Parameters::Int )
-  {
-  QSpinBox* v_int = new QSpinBox( dlg );
-  v_int->setMinimum( -std::numeric_limits< int >::max( ) );
-  v_int->setMaximum(  std::numeric_limits< int >::max( ) );
-  v_int->setValue( this->m_Parameters->GetInt( *nIt ) );
-  w_input = v_int;
-  }
-  else if( pt == Parameters::Real )
-  {
-  QDoubleSpinBox* v_double = new QDoubleSpinBox( dlg );
-  v_double->setDecimals( 3 );
-  v_double->setMinimum( -std::numeric_limits< double >::max( ) );
-  v_double->setMaximum(  std::numeric_limits< double >::max( ) );
-  v_double->setValue( this->m_Parameters->GetReal( *nIt ) );
-  w_input = v_double;
-  }
-  else if(
-  pt == Parameters::StringList ||
-  pt == Parameters::IntList ||
-  pt == Parameters::UintList ||
-  pt == Parameters::RealList
-  )
-  {
-  cpPlugins::Interface::ParametersListWidget* l_double =
-  new cpPlugins::Interface::ParametersListWidget( *nIt, dlg );
-  w_input = l_double;
-
-  } // fi
-
-    // Ok, a representation was created
-    if( w_input != NULL )
-    {
-    w_input->setObjectName( QString( nIt->c_str( ) ) );
-
-    QHBoxLayout* horizontalLayout = new QHBoxLayout( );
-    QLabel* label = new QLabel( dlg );
-    label->setText( QString( nIt->c_str( ) ) );
-    horizontalLayout->addWidget( label );
-    horizontalLayout->addWidget( w_input );
-    verticalLayout->addLayout( horizontalLayout );
-
-    } // fi
-
-    } // rof
-
-    // Add buttons
-    QDialogButtonBox* bb = new QDialogButtonBox(
-    QDialogButtonBox::Ok | QDialogButtonBox::Cancel
-    );
-    QObject::connect( bb, SIGNAL( accepted( ) ), dlg, SLOT( accept( ) ) );
-    QObject::connect( bb, SIGNAL( rejected( ) ), dlg, SLOT( reject( ) ) );
-    verticalLayout->addWidget( bb );
-    gridLayout->addLayout( verticalLayout, 0, 0, 1, 1 );
-
-    // Execute
-    QMetaObject::connectSlotsByName( dlg );
-    if( !( dlg->exec( ) ) )
-    return( false );
-
-    // Get values back
-    nIt = names.begin( );
-    for( ; nIt != names.end( ); ++nIt )
-    {
-    Parameters::Type pt = this->m_Parameters->GetType( *nIt );
-    if( pt == Parameters::String )
-    {
-    QLineEdit* v_string = dlg->findChild< QLineEdit* >( nIt->c_str( ) );
-    if( v_string != NULL )
-    this->m_Parameters->SetString( *nIt, v_string->text( ).toStdString( ) );
-    }
-    else if( pt == Parameters::Bool )
-    {
-    QCheckBox* v_bool = dlg->findChild< QCheckBox* >( nIt->c_str( ) );
-    if( v_bool != NULL )
-    this->m_Parameters->SetBool( *nIt, v_bool->isChecked( ) );
-    }
-    else if( pt == Parameters::Uint )
-    {
-    QSpinBox* v_uint = dlg->findChild< QSpinBox* >( nIt->c_str( ) );
-    if( v_uint != NULL )
-    this->m_Parameters->SetUint( *nIt, v_uint->value( ) );
-    }
-    else if( pt == Parameters::Int )
-    {
-    QSpinBox* v_int = dlg->findChild< QSpinBox* >( nIt->c_str( ) );
-    if( v_int != NULL )
-    this->m_Parameters->SetInt( *nIt, v_int->value( ) );
-    }
-    else if( pt == Parameters::Real )
-    {
-    QDoubleSpinBox* v_double =
-    dlg->findChild< QDoubleSpinBox* >( nIt->c_str( ) );
-    if( v_double != NULL )
-    this->m_Parameters->SetReal( *nIt, v_double->value( ) );
     }
     else if(
     pt == Parameters::StringList ||
@@ -398,33 +346,33 @@ syncParameters( )
     pt == Parameters::RealList
     )
     {
-    cpPlugins::Interface::ParametersListWidget* l_double =
-    dlg->findChild< cpPlugins::Interface::ParametersListWidget* >(
+    cpPlugins::Interface::ParametersListWidget* lst =
+    this->findChild< cpPlugins::Interface::ParametersListWidget* >(
     nIt->c_str( )
     );
-    if( l_double != NULL )
+    if( lst != NULL )
     {
     if( pt == Parameters::StringList )
     {
-    std::vector< std::string > values = l_double->GetStringValues( );
+    std::vector< std::string > values = lst->GetStringValues( );
     for( int r = 0; r < values.size( ); ++r )
     this->m_Parameters->AddToStringList( *nIt, values[ r ] );
     }
     else if( pt == Parameters::IntList )
     {
-    std::vector< int > values = l_double->GetIntValues( );
+    std::vector< int > values = lst->GetIntValues( );
     for( int r = 0; r < values.size( ); ++r )
     this->m_Parameters->AddToIntList( *nIt, values[ r ] );
     }
     else if( pt == Parameters::UintList )
     {
-    std::vector< unsigned int > values = l_double->GetUintValues( );
+    std::vector< unsigned int > values = lst->GetUintValues( );
     for( int r = 0; r < values.size( ); ++r )
     this->m_Parameters->AddToUintList( *nIt, values[ r ] );
     }
     else if( pt == Parameters::RealList )
     {
-    std::vector< double > values = l_double->GetDoubleValues( );
+    std::vector< double > values = lst->GetDoubleValues( );
     for( int r = 0; r < values.size( ); ++r )
     this->m_Parameters->AddToRealList( *nIt, values[ r ] );
 
index 22ed81efd955f7a6bb888c33ab379521daf8b3f0..625838c08f6d8d353e139069e713a9b230d98586 100644 (file)
@@ -54,10 +54,7 @@ _GenerateData( )
     mc->ComputeNormalsOff( );
     mc->SetInputData( vtk_image );
     for( unsigned int i = 0; i < values.size( ); ++i )
-    {
-      std::cout << i << " " << values[ i ] << std::endl;
       mc->SetValue( i, values[ i ] );
-    }
     mc->Update( );
     pd = mc->GetOutput( );
   }