]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Interface/SimpleMPRWidget.cxx
...
[cpPlugins.git] / lib / cpPlugins / Interface / SimpleMPRWidget.cxx
index 790688386333477bfd2a8ef777eecf24229f731d..3c97e409247be31045733b9ed15812b6200ccb42 100644 (file)
@@ -7,6 +7,8 @@
 #include <cpPlugins/Interface/Image.h>
 #include <cpPlugins/Interface/Mesh.h>
 // TODO: #include <QTreeWidgetItem>
+
+#include <vtkProperty.h>
 #include <vtkRendererCollection.h>
 
 double cpPlugins::Interface::SimpleMPRWidget::
@@ -94,6 +96,25 @@ AddData(
     // Add new data
     this->m_Data[ name ].SetSourceDataObject( data );
 
+    // 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 );
@@ -225,14 +246,14 @@ ShowData( const std::string& name )
   }
   else if( iIt->second.Tag == Data::MESH )
   {
-    /* TODO
-       vtkRenderer* ren =
-       this->m_VTK[ 3 ]->GetRenderWindow( )->GetRenderers( )->GetFirstRenderer( );
-       if( ren == NULL )
-       return;
-       ren->AddActor( iIt->second.GetMeshActor( ) );
-       this->m_VTK[ 3 ]->GetRenderWindow( )->Render( );
-    */
+    vtkRenderer* ren =
+      this->m_VTK[ 3 ]->GetRenderWindow( )->
+      GetRenderers( )->GetFirstRenderer( );
+    if( ren == NULL )
+      return;
+    ren->AddActor( iIt->second.GetMeshActor( ) );
+    this->m_VTK[ 3 ]->GetRenderWindow( )->Render( );
+
   } // fi
 }