]> SALOME platform Git repositories - modules/geom.git/blobdiff - src/GEOMGUI/GEOM_Displayer.cxx
Salome HOME
Additional changes for issue 0020830: redesign methods of the SALOME View / Displayer...
[modules/geom.git] / src / GEOMGUI / GEOM_Displayer.cxx
index bc04035797124a3779c5fac364dd521fd68ad43c..063cb70af9febf34309832cb9d4e429e4767bf7b 100644 (file)
@@ -37,7 +37,6 @@
 #include <GEOM_OCCFilter.h>
 
 #include <GEOM_Actor.h>
-#include <GEOM_AssemblyBuilder.h>
 #include <GEOM_AISShape.hxx>
 #include <GEOM_AISVector.hxx>
 #include <GEOM_AISTrihedron.hxx>
@@ -84,6 +83,7 @@
 #include <TopTools_MapOfShape.hxx>
 #include <TopTools_ListOfShape.hxx>
 #include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopoDS.hxx>
 
 // VTK Includes
 #include <vtkActorCollection.h>
@@ -343,9 +343,9 @@ void GEOM_Displayer::Display( const Handle(SALOME_InteractiveObject)& theIO,
 
     if ( prs )
     {
-      vf->BeforeDisplay( this );
+      vf->BeforeDisplay( this, prs );
       vf->Display( prs );
-      vf->AfterDisplay( this );
+      vf->AfterDisplay( this, prs );
 
       if ( updateViewer )
         vf->Repaint();
@@ -399,7 +399,9 @@ void GEOM_Displayer::Erase( const Handle(SALOME_InteractiveObject)& theIO,
   if ( vf ) {
     SALOME_Prs* prs = vf->CreatePrs( theIO->getEntry() );
     if ( prs ) {
+      vf->BeforeErase( this, prs );
       vf->Erase( prs, forced );
+      vf->AfterErase( this, prs );
       if ( updateViewer )
         vf->Repaint();
       delete prs;  // delete presentation because displayer is its owner
@@ -662,7 +664,7 @@ void GEOM_Displayer::Update( SALOME_OCCPrs* prs )
          QStringList uv =  anIsos.split(DIGIT_SEPARATOR);
          anUIsoNumber = uv[0].toInt();
          aVIsoNumber = uv[1].toInt();
-         AISShape->SetTransparency(aPropMap.value(TRANSPARENCY_PROP).toDouble());
+         //AISShape->SetTransparency(aPropMap.value(TRANSPARENCY_PROP).toDouble());
        } else {
          anUIsoNumber = aResMgr->integerValue("OCCViewer", "iso_number_u", 1);
          aVIsoNumber  = aResMgr->integerValue("OCCViewer", "iso_number_v", 1);
@@ -980,17 +982,24 @@ void GEOM_Displayer::Update( SALOME_VTKPrs* prs )
     theActors->AddItem( aTrh );
   }
   else {
-    theActors = GEOM_AssemblyBuilder::BuildActors( myShape, 0, 0, Standard_True, myType == GEOM_VECTOR );
+    PropMap aDefPropMap = getDefaultPropepryMap(SVTK_Viewer::Type());
+
     QString anEntry;
     if(!myIO.IsNull()) {
       aMgrId = getViewManagerId(myViewFrame);
       anEntry = myIO->getEntry();
     }
     useStudy = !anEntry.isEmpty() && aMgrId != -1;
+
+    
+    theActors = vtkActorCollection::New();
+    GEOM_Actor* aGeomActor = GEOM_Actor::New();
+    aGeomActor->SetShape(myShape,aDefPropMap.value(DEFLECTION_COEFF_PROP).toDouble(),myType == GEOM_VECTOR);
+    theActors->AddItem(aGeomActor);
+    aGeomActor->Delete();
     
     if(useStudy){
       aPropMap = aStudy->getObjectPropMap(aMgrId,anEntry);
-      PropMap aDefPropMap = getDefaultPropepryMap(SVTK_Viewer::Type());
       bool isDiff = MergePropertyMaps(aPropMap, aDefPropMap);
       if(isDiff)
        aStudy->setObjectPropMap(aMgrId,anEntry,aPropMap);
@@ -1048,8 +1057,7 @@ void GEOM_Displayer::Update( SALOME_VTKPrs* prs )
          aGeomGActor->SetOpacity(1.0 - aPropMap.value(TRANSPARENCY_PROP).toDouble());
          aGeomGActor->SetVectorMode(aPropMap.value(VECTOR_MODE_PROP).toInt());
          aGeomGActor->setDisplayMode(aPropMap.value(DISPLAY_MODE_PROP).toInt());
-         //VSR: do not set deflection until OCC2VTK algo is not improved (to keep performance)
-         //aGeomGActor->SetDeflection(aPropMap.value(DEFLECTION_COEFF_PROP).toDouble(), aGeomGActor->GetIsRelative());
+         aGeomGActor->SetDeflection(aPropMap.value(DEFLECTION_COEFF_PROP).toDouble()); 
 
          vtkFloatingPointType aColor[3] = {1.,0.,0.};
          if(aPropMap.contains(COLOR_PROP)) {
@@ -1423,7 +1431,7 @@ void GEOM_Displayer::LocalSelection( const SALOME_ListIO& theIOList, const int t
  *  [ Reimplemented from SALOME_Displayer ]
  */
 //=================================================================
-void GEOM_Displayer::BeforeDisplay( SALOME_View* v, const SALOME_OCCViewType& )
+void GEOM_Displayer::BeforeDisplay( SALOME_View* v, const SALOME_OCCPrs* )
 {
   SOCC_Viewer* vf = dynamic_cast<SOCC_Viewer*>( v );
   if ( vf )
@@ -1437,11 +1445,35 @@ void GEOM_Displayer::BeforeDisplay( SALOME_View* v, const SALOME_OCCViewType& )
   }
 }
 
-void GEOM_Displayer::AfterDisplay( SALOME_View*, const SALOME_OCCViewType& )
+void GEOM_Displayer::AfterDisplay( SALOME_View* v, const SALOME_OCCPrs* p )
 {
+  SalomeApp_Study* aStudy = getStudy();
+  if (!aStudy) return;
+  SOCC_Viewer* vf = dynamic_cast<SOCC_Viewer*>( v );
+  if ( vf && !p->IsNull() ) {
+    int aMgrId = getViewManagerId( vf );
+    Handle(AIS_InteractiveContext) ic = vf->getAISContext();
+    const SOCC_Prs* prs = dynamic_cast<const SOCC_Prs*>( p );
+    if ( !ic.IsNull() && prs ) {
+      AIS_ListOfInteractive objects;
+      prs->GetObjects( objects );
+      AIS_ListIteratorOfListOfInteractive it( objects );
+      while( it.More() ) {
+        Handle(GEOM_AISShape) sh = Handle(GEOM_AISShape)::DownCast( it.Value() );
+       if ( sh.IsNull() ) continue;
+       Handle(SALOME_InteractiveObject) IO = sh->getIO();
+       if ( IO.IsNull() ) continue;
+       PropMap aPropMap = aStudy->getObjectPropMap( aMgrId, IO->getEntry() );
+       if ( aPropMap.contains( TRANSPARENCY_PROP ) ) {
+         double transparency = aPropMap.value(TRANSPARENCY_PROP).toDouble();
+         ic->SetTransparency( sh, transparency, true );
+         it.Next();
+       }
+      }
+    }
+  }
 }
 
-
 //=================================================================
 /*!
  *  GEOM_Displayer::SetColor
@@ -1691,12 +1723,13 @@ PropMap GEOM_Displayer::getDefaultPropepryMap(const QString& viewer_type){
     
   //7. Deflection Coeff
   double aDC;
-  //rnv: Currently deflection coefficient is not supported by VTK viewer.
+
   if(viewer_type == SOCC_Viewer::Type()) {
     aDC = aResMgr->doubleValue("Geometry", "deflection_coeff", 0.001);
   } else if( viewer_type==SVTK_Viewer::Type()) {
-    aDC = 0.0;
+    aDC = 0.001;
   }
+
   aDefaultMap.insert( DEFLECTION_COEFF_PROP , aDC);
 
   return aDefaultMap;