Salome HOME
0020943: EDF 1463 SMESH: additional fonctionnality to the feature 20749
[modules/smesh.git] / src / OBJECT / SMESH_PreviewActorsCollection.cxx
index 59238dcf16f6ef674f3b3412a2c5e4104789f865..b905f02367735c39990b15bba42e283c60074996 100644 (file)
@@ -1,7 +1,4 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
-//
-//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 //  This library is free software; you can redistribute it and/or
 //  modify it under the terms of the GNU Lesser General Public
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 //  SMESH OBJECT : interactive object for SMESH visualization
 //  File   : SMESH_PreviewActorsCollection.cxx
 //  Author : 
 //  Module : SMESH
 //
-
 #include "SMESH_PreviewActorsCollection.h"
 
 #include "utilities.h"
@@ -38,7 +35,6 @@
 
 // VTK includes
 #include <vtkUnstructuredGrid.h>
-#include <vtkScalarBarActor.h>
 #include <vtkPlane.h>
 #include <vtkRenderer.h>
 #include <vtkProperty.h>
@@ -78,6 +74,10 @@ SMESH_PreviewActorsCollection
   if (myRenderer)
     RemoveFromRender(myRenderer);
 
+  QMap<int, GEOM_Actor*>::iterator iter = myMapOfActors.begin();
+  for ( ; iter != myMapOfActors.end(); ++iter )
+    if ( GEOM_Actor* anActor = iter.value() )
+      anActor->Delete();
   myMapOfActors.clear();
 }
 
@@ -99,26 +99,26 @@ bool SMESH_PreviewActorsCollection::Init( const TopoDS_Shape& theShape, TopAbs_S
   TopExp_Explorer exp( theShape, theType );
   for ( ; exp.More(); exp.Next() ) {
     int index = myMapOfShapes.FindIndex( exp.Current() );
-    if ( index ) { 
+    if ( index && !myMapOfActors.contains( index ) ) { 
       // create actor if the index is present
-      if ( GEOM_Actor* anActor = createActor( exp.Current() )) {
-       // Create new entry for actor
-       QString aString = theEntry;
-       aString += QString("_%1").arg( index ); // add index to actor entry
-
-       // Create interactive object
-       Handle( SALOME_InteractiveObject ) anIO = new SALOME_InteractiveObject();
-       anIO->setEntry( aString.toLatin1().constData() );
-
-       // Init Actor
-       anActor->SetVectorMode( true );
-       anActor->setIO( anIO );
-       anActor->SetSelector( mySelector );
-       anActor->SetPickable( true );
-       anActor->SetResolveCoincidentTopology( true );
-
-       // Add Actor to the Actors Map
-       myMapOfActors.insert(index, anActor);
+      if ( GEOM_Actor* anActor = createActor( exp.Current().Oriented(TopAbs_FORWARD))) {
+        // Create new entry for actor
+        QString aString = theEntry;
+        aString += QString("_%1").arg( index ); // add index to actor entry
+
+        // Create interactive object
+        Handle( SALOME_InteractiveObject ) anIO = new SALOME_InteractiveObject();
+        anIO->setEntry( aString.toLatin1().constData() );
+
+        // Init Actor
+        anActor->SetVectorMode( theType==TopAbs_EDGE );
+        anActor->setIO( anIO );
+        anActor->SetSelector( mySelector );
+        anActor->SetPickable( true );
+        anActor->SetResolveCoincidentTopology( true );
+
+        // Add Actor to the Actors Map
+        myMapOfActors.insert(index, anActor);
       }
     }
   }
@@ -133,25 +133,25 @@ GEOM_Actor* SMESH_PreviewActorsCollection::createActor(const TopoDS_Shape& shape
   actor->SetShape(shape,0,0);
 
   //Color Properties
-  /*   
-       vtkProperty* aProp = vtkProperty::New();
-       vtkProperty* aHLProp = vtkProperty::New();
-       vtkProperty* aPHLProp = vtkProperty::New();
-       
-       aProp->SetColor( 255, 0, 0);
-       actor->SetProperty(aProp);
-
-       aHLProp->SetColor( 255, 255, 255);
-       actor->SetHighlightProperty(aHLProp);
-
-       aPHLProp->SetColor( 155, 155, 155);
-       aPHLProp->SetLineWidth ( 3 );
-       aPHLProp->SetOpacity ( 0.75 );
-       actor->SetPreHighlightProperty(aPHLProp);
-
-       aProp->Delete();
-       aHLProp->Delete();
-       aPHLProp->Delete();
+  /*    
+        vtkProperty* aProp = vtkProperty::New();
+        vtkProperty* aHLProp = vtkProperty::New();
+        vtkProperty* aPHLProp = vtkProperty::New();
+        
+        aProp->SetColor( 255, 0, 0);
+        actor->SetProperty(aProp);
+
+        aHLProp->SetColor( 255, 255, 255);
+        actor->SetHighlightProperty(aHLProp);
+
+        aPHLProp->SetColor( 155, 155, 155);
+        aPHLProp->SetLineWidth ( 3 );
+        aPHLProp->SetOpacity ( 0.75 );
+        actor->SetPreHighlightProperty(aPHLProp);
+
+        aProp->Delete();
+        aHLProp->Delete();
+        aPHLProp->Delete();
   */
 
   return actor;