]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Fix for the bug #255: VTK viewer is not updated after modification of objects.
authorrkv <rkv@opencascade.com>
Mon, 23 Dec 2013 10:42:38 +0000 (10:42 +0000)
committerrkv <rkv@opencascade.com>
Mon, 23 Dec 2013 10:42:38 +0000 (10:42 +0000)
22 files changed:
src/HYDROGUI/HYDROGUI_BathymetryBoundsOp.cxx
src/HYDROGUI/HYDROGUI_CalculationOp.cxx
src/HYDROGUI/HYDROGUI_ChannelOp.cxx
src/HYDROGUI/HYDROGUI_DeleteOp.cxx
src/HYDROGUI/HYDROGUI_GeoreferencementOp.cxx
src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx
src/HYDROGUI/HYDROGUI_ImportGeomObjectOp.cxx
src/HYDROGUI/HYDROGUI_ImportObstacleFromFileOp.cxx
src/HYDROGUI/HYDROGUI_ImportProfilesOp.cxx
src/HYDROGUI/HYDROGUI_Module.cxx
src/HYDROGUI/HYDROGUI_Module.h
src/HYDROGUI/HYDROGUI_Poly3DOp.cxx
src/HYDROGUI/HYDROGUI_PolylineOp.cxx
src/HYDROGUI/HYDROGUI_ProfileOp.cxx
src/HYDROGUI/HYDROGUI_SetColorOp.cxx
src/HYDROGUI/HYDROGUI_StreamOp.cxx
src/HYDROGUI/HYDROGUI_UpdateObjectOp.cxx
src/HYDROGUI/HYDROGUI_VTKPrs.cxx
src/HYDROGUI/HYDROGUI_VTKPrs.h
src/HYDROGUI/HYDROGUI_VTKPrsBathymetry.cxx
src/HYDROGUI/HYDROGUI_VTKPrsDisplayer.cxx
src/HYDROGUI/HYDROGUI_VTKPrsShape.cxx

index 35540e01961c1191d1df8600daa5c0481e47c450..cf042190c10bbab4b2780124e18143c6ec38c38a 100644 (file)
@@ -23,6 +23,7 @@
 #include <HYDROGUI_BathymetryBoundsOp.h>
 #include <HYDROGUI_Tool.h>
 #include <HYDROGUI_UpdateFlags.h>
+#include <HYDROGUI_Module.h>
 
 HYDROGUI_BathymetryBoundsOp::HYDROGUI_BathymetryBoundsOp( HYDROGUI_Module* theModule )
 : HYDROGUI_Operation( theModule )
@@ -53,8 +54,10 @@ bool HYDROGUI_BathymetryBoundsOp::processApply( int& theUpdateFlags, QString& th
 {
   bool isOK = myBath->CreateBoundaryPolyline();
   theUpdateFlags = 0;
-  if( isOK )
-    theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced;
+  if( isOK ) {
+    module()->setIsToUpdate( myBath );
+    theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
+  }
   else
     theErrorMsg = tr( "CANNOT_CREATE_BOUNDARY_POLYLINE" );
   return isOK;
index 9ebcae43c9d47725d0ba35ac81e05eef135e21cc..aead39e1fb0abb6ba1e696d386d9fb4e073d1178 100644 (file)
@@ -505,7 +505,7 @@ bool HYDROGUI_CalculationOp::processApply( int&     theUpdateFlags,
   if ( !aPanel )
     return false;
 
-  theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced;
+  theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer | UF_VTK_Forced | UF_VTK_Init;
 
   return true;
 }
index 0149a1c85d108641db29e1eaad2bc99a64112ca8..2f7074aee2ba45c64ee628fa4ef485adf99c79b6 100644 (file)
@@ -169,7 +169,9 @@ bool HYDROGUI_ChannelOp::processApply( int& theUpdateFlags,
   if( !myIsEdit )
     module()->setObjectVisible( HYDROGUI_Tool::GetActiveOCCViewId( module() ), myEditedObject, true );
 
-  theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced;
+  module()->setIsToUpdate( myEditedObject );
+
+  theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
 
   return true;
 }
index f7534146b158ff6574618747c28d9b8718efc00e..da2cd3739a300c4b2c0dc1001bc9544ca57c5c91 100644 (file)
@@ -118,6 +118,6 @@ void HYDROGUI_DeleteOp::startOperation()
 
   commitDocOperation();
 
-  module()->update( UF_Model | UF_Viewer | UF_OCCViewer );
+  module()->update( UF_Model | UF_Viewer | UF_OCCViewer | UF_VTKViewer );
   commit();
 }
index a3b5295ee8a85108ec46ab0aa04ebbcbd53e2a5c..a88a3e5719f7765fbf46418c681954b27ac37173 100644 (file)
@@ -117,7 +117,7 @@ HYDROGUI_InputPanel* HYDROGUI_GeoreferencementOp::createInputPanel() const
 bool HYDROGUI_GeoreferencementOp::processApply( int& theUpdateFlags,
                                                 QString& theErrorMsg )
 {
-  theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced;
+  theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer | UF_VTK_Forced | UF_VTK_Init;
 
   return store( theErrorMsg );
 }
index aa0e89cfa1e7dc13975d0a416a0e2400caffd5b5..d59e7d102cbc9e29ab4cf17f422638fefe028469 100644 (file)
@@ -229,7 +229,9 @@ bool HYDROGUI_ImmersibleZoneOp::processApply( int& theUpdateFlags,
   if( !myIsEdit )
     module()->setObjectVisible( HYDROGUI_Tool::GetActiveOCCViewId( module() ), aZoneObj, true );
 
-  theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced;
+  module()->setIsToUpdate( aZoneObj );
+
+  theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
 
   return true;
 }
index 8715e91892218fb6aea602f57c3a7ce6b251bd9a..a454cd985c7b5d30393d8eaf06fa7ac81aa6b2d0 100644 (file)
@@ -261,7 +261,8 @@ bool HYDROGUI_ImportGeomObjectOp::processApply( int& theUpdateFlags,
       // Check operation status
       if ( anIsOk ) {
         anObject->Update();
-        theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced;
+        module()->setIsToUpdate( anObject );
+        theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
       }
     }
   }
index d51c0985dee093535a7e33b52be13610d94ecca6..301e826d7e3088d3bf0baaf83ffec34057e64f55 100644 (file)
@@ -174,7 +174,8 @@ bool HYDROGUI_ImportObstacleFromFileOp::processApply( int& theUpdateFlags,
 
       // Set operation status
       anIsOk = true;
-      theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced;;
+      module()->setIsToUpdate( anObstacle );
+      theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
     } else {
       theErrorMsg = tr( "BAD_IMPORTED_OBSTACLE_FILE" ).arg( aFileName );
     }
index e41732b2fa0eced39bb63ebd4f2916990ebbf5ba..10f162361a358fd7a9cd9263c298aa2de660e561 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "HYDROGUI_DataModel.h"
 #include "HYDROGUI_Module.h"
+#include "HYDROGUI_UpdateFlags.h"
 
 #include <HYDROData_Profile.h>
 
@@ -88,7 +89,7 @@ bool HYDROGUI_ImportProfilesOp::processApply( int& theUpdateFlags,
     abort();
   }
 
-  theUpdateFlags = UF_Model;
+  theUpdateFlags = UF_Model | UF_VTKViewer | UF_VTK_Forced | UF_VTK_Init;
 
   return aRes;
 }
index dfcc1921cd8442c5cde5a0503305d7cd17acc3ac..adf9b38c69704aa8b002c701f34818df0c166b64 100644 (file)
@@ -834,6 +834,42 @@ void HYDROGUI_Module::setObjectVisible( const int theViewId,
   }
 }
 
+void HYDROGUI_Module::setIsToUpdate( const Handle(HYDROData_Entity)& theObject,
+                                     const bool theState )
+{
+  if( !theObject.IsNull() )
+  {
+    // Process OCC shapes
+    ViewId2ListOfShapes::const_iterator aShapesMapIter( myShapesMap.begin() );
+    while( aShapesMapIter != myShapesMap.end() )
+    {
+      const ListOfShapes& aShapesList = aShapesMapIter.value();
+      foreach ( HYDROGUI_Shape* aShape, aShapesList )
+      {
+        if ( aShape && IsEqual( aShape->getObject(), theObject ) )
+        {
+          aShape->setIsToUpdate( theState );
+        }
+      }
+      aShapesMapIter++;
+    }
+    // Process VTK shapes
+    ViewId2ListOfVTKPrs::const_iterator aVTKPrsMapIter( myVTKPrsMap.begin() );
+    while( aVTKPrsMapIter != myVTKPrsMap.end() )
+    {
+      const ListOfVTKPrs& aShapesList = aVTKPrsMapIter.value();
+      foreach ( HYDROGUI_VTKPrs* aShape, aShapesList )
+      {
+        if ( aShape && IsEqual( aShape->getObject(), theObject ) )
+        {
+          aShape->setIsToUpdate( theState );
+        }
+      }
+      aVTKPrsMapIter++;
+    }
+  }
+}
+
 /////////////////// OCC SHAPES PROCESSING
 HYDROGUI_Shape* HYDROGUI_Module::getObjectShape( const int                       theViewId,
                                                  const Handle(HYDROData_Entity)& theObject ) const
index 3f46027b1b7493f657eb959c60227496a015dce8..f7957e9c8c2b01c1695ef000afdecdf94c0bc135 100644 (file)
@@ -125,7 +125,14 @@ public:
   void                            setObjectVisible( const int theViewId,
                                                     const Handle(HYDROData_Entity)& theObject,
                                                     const bool theState );
-
+  /** 
+   * Set IsToUpdate flag for all presentations of the given object to recompute them during 
+   * the next viewer(s) updating.
+   * @param theObject the data model object
+   * @param theState  the flag to set for object's presentations, it's true by default.
+   */
+  void                            setIsToUpdate( const Handle(HYDROData_Entity)& theObject,
+                                                 const bool theState = true );
   HYDROGUI_Shape*                 getObjectShape( const int                       theViewId,
                                                   const Handle(HYDROData_Entity)& theObject ) const;
   void                            setObjectShape( const int                       theViewId,
@@ -143,6 +150,7 @@ public:
   void                            removeViewVTKPrs( const int                      theViewId );
   void                            removeObjectVTKPrs( const int                      theViewId,
                                                      const Handle(HYDROData_Entity)& theObject );
+
   /**
    * Update global imposed range of Z values for the given VTK viewer id
    */
index 6235cda26341ce2edc0f00d1d8676c2ca512e205..8259381af1ee2d4767cf1fdd1a0842c11ec95a49 100644 (file)
@@ -184,7 +184,8 @@ bool HYDROGUI_Poly3DOp::processApply( int& theUpdateFlags,
     module()->setObjectVisible( aViewId, aProfile, false );
     module()->setObjectVisible( aViewId, aResult, true );
   }
+  module()->setIsToUpdate( aResult );
 
-  theUpdateFlags = UF_Model | UF_Viewer | UF_GV_Forced | UF_OCCViewer | UF_OCC_Forced;
+  theUpdateFlags = UF_Model | UF_Viewer | UF_GV_Forced | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
   return true;
 }
index 83d3d7ef4ab65adab08ad4a580a7a3c49c68cf8c..dc0d2d6b12f85d497a8e9b55ff765a7cb358faf8 100755 (executable)
@@ -272,6 +272,7 @@ bool HYDROGUI_PolylineOp::processApply( int& theUpdateFlags,
 
   // Update the wire of polyline
   aPolylineObj->Update();
+  module()->setIsToUpdate( aPolylineObj );
 
   // the viewer should be release from the widget before the module update it
   // because it has an opened local context and updated presentation should not be displayed in it
@@ -283,6 +284,7 @@ bool HYDROGUI_PolylineOp::processApply( int& theUpdateFlags,
   // the polyline should be rebuild in all viewers, where it is displayed
   theUpdateFlags |= UF_Viewer | UF_GV_Forced;
   theUpdateFlags |= UF_OCCViewer | UF_OCC_Forced;
+  theUpdateFlags |= UF_VTKViewer;
 
   size_t anActiveViewId = HYDROGUI_Tool::GetActiveGraphicsViewId( module() );
   if ( anActiveViewId == 0 )
index a81c4f7648455244ece0e12d9f06b6697fe9f605..bda67417e629b265e12c3a3345c31629ace59d38 100644 (file)
@@ -234,8 +234,9 @@ bool HYDROGUI_ProfileOp::processApply( int& theUpdateFlags,
 
   // And now we update our edited object
   aProfileObj->Update();
+  module()->setIsToUpdate( aProfileObj );
 
-  theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced;
+  theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
   return true;
 }
 
index 511f56b8bb289c6ea208ffc1ad6cc2522580529e..fa24977fa50617448340f140640f298382b402cf 100644 (file)
@@ -150,7 +150,9 @@ bool HYDROGUI_SetColorOp::processApply( int& theUpdateFlags,
     aPolyObject->SetWireColor( aFirstColor );
   }
 
-  theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced;
+  module()->setIsToUpdate( myEditedObject );
+
+  theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
   
   return true;
 }
index 822175bea726c700120df58211018fe62b41b9a6..bd7085f4efd7aa086b947998ae6fbd69c69bdfdb 100755 (executable)
@@ -188,8 +188,10 @@ bool HYDROGUI_StreamOp::processApply( int& theUpdateFlags,
     module()->setObjectVisible( HYDROGUI_Tool::GetActiveOCCViewId( module() ), myEditedObject, true );
   }
 
+  module()->setIsToUpdate( myEditedObject );
+
   // Set update flags
-  theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced;
+  theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
 
   return true;
 }
index ec2285e5933d30c7324cdf352c94db71b5dc3a6d..c653c10757f24ff15eec887d00aecca459f8fc69 100644 (file)
@@ -56,7 +56,7 @@ void HYDROGUI_UpdateObjectOp::startOperation()
 
   commitDocOperation();
 
-  module()->update( UF_Model | UF_Viewer | UF_GV_Forced | UF_OCCViewer | UF_OCC_Forced );
+  module()->update( UF_Model | UF_Viewer | UF_GV_Forced | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer );
   commit();
 }
 
@@ -79,5 +79,6 @@ void HYDROGUI_UpdateObjectOp::updateObject( const Handle(HYDROData_Entity)& theO
     return;
 
   theObject->Update();
+  module()->setIsToUpdate( theObject );
 }
 
index 671a2cdccf4192d7892f912035c246aafc4762e6..87a86d5cd2aabbf96b8a17fedfc25092afbf4a33 100644 (file)
@@ -56,6 +56,7 @@ HYDROGUI_VTKPrs::~HYDROGUI_VTKPrs()
 //=======================================================================
 void HYDROGUI_VTKPrs::compute()
 {
+  setIsToUpdate( false );
 }
 
 //=======================================================================
index 558d7ba54c120f592c8c232ed6abbd5d4a4c1454..f5a3f86fc8db2ebd2c3cd004d6e0b801c0ffae3d 100644 (file)
 
 #include <SALOME_InteractiveObject.hxx>
 #include <SVTK_Prs.h>
+#include <vtkActorCollection.h>
 
 class vtkMapper;
 
+template <class ActorType> ActorType* getActor(SVTK_Prs* thePrs);
+
+/**
+ * Get a VTK actor of the given presentation. Create a new one if there is no actor yet.
+ */
+template <class ActorType>
+ActorType* getActor(SVTK_Prs* thePrs)
+{
+  ActorType* anActor = 0;
+  vtkActorCollection* aContent = thePrs->GetObjects();
+  if ( aContent )
+  {
+    // Remove old actor because of the problem of GEOM_Actor updating.
+    //anActor = dynamic_cast<ActorType*>( aContent->GetLastActor() );
+    aContent->RemoveAllItems();
+  }
+  if ( !anActor )
+  {
+    anActor = ActorType::New();
+    thePrs->AddObject( anActor );
+    anActor->Delete();
+  }
+  return anActor;
+}
+
+
 /*
   Class       : HYDROGUI_VTKPrs
   Description : Base class for all HYDRO presentation in VTK viewer
index 31817f2c4b09d4e5245763f62d778ea4b04caba1..5b7a850be4cb5d9ede0d6660454d4bd3bea06979 100644 (file)
@@ -67,6 +67,8 @@ HYDROGUI_VTKPrsBathymetry::~HYDROGUI_VTKPrsBathymetry()
 //================================================================
 void HYDROGUI_VTKPrsBathymetry::compute()
 {
+  HYDROGUI_VTKPrs::compute();
+
   if ( !getObject().IsNull() )
   {
     Handle(HYDROData_Bathymetry) aBathymetry = Handle(HYDROData_Bathymetry)::DownCast( getObject() );
@@ -141,12 +143,11 @@ void HYDROGUI_VTKPrsBathymetry::compute()
 
       myMapper->SetInputData( aVertexGrid );
       
-      SALOME_Actor* anActor = SALOME_Actor::New();
+      SALOME_Actor* anActor = getActor<SALOME_Actor>(this);
       anActor->SetMapper( myMapper.GetPointer() );
       anActor->setIO( getIO() );
       AddObject( anActor );
 
-      anActor->Delete();
       aVertexGrid->Delete();
       aZValues->Delete();
     }
index 94d0d405972527c74849cca6030e536cece42ea7..d4317fcd46887b389b71c6fd9b411d4635e2820e 100644 (file)
@@ -200,6 +200,12 @@ void HYDROGUI_VTKPrsDisplayer::Display( const HYDROData_SequenceOfObjects& theOb
         bool anIsInserted = ( aPrs != 0 );
         if( anIsVisible && ( !aPrs || aPrs->getIsToUpdate() || theIsForced ) )
         {
+          // Erase the presentation in the view because of the problem with GEOM_Actor upadting on second SetShape.
+          if ( aPrs )
+          {
+            aViewer->Erase( aPrs, true );
+          }
+          // Update the presentation
           if( HYDROGUI_VTKPrsDriver* aDriver = getDriver( (size_t)aViewer, anObj ) )
           {
             if( aDriver->Update( anObj, aPrs ) && aPrs && !anIsInserted )
index c1a20685c7c094d8a0af5bf2e0d06d90e54adb07..168fd3ad2bce46bb4abe0398a77e0d5634b0d09e 100644 (file)
@@ -88,22 +88,18 @@ HYDROGUI_VTKPrsShape::~HYDROGUI_VTKPrsShape()
 //================================================================
 void HYDROGUI_VTKPrsShape::compute()
 {
+  HYDROGUI_VTKPrs::compute();
+
   if ( !getObject().IsNull() )
   {
     buildShape();
 
     if ( !myTopoShape.IsNull() )
     {
-      HYDROGUI_Actor* anActor = HYDROGUI_Actor::New();
+      HYDROGUI_Actor* anActor = getActor<HYDROGUI_Actor>(this);
       anActor->SetShape( myTopoShape, VTK_MIN_DEFLECTION );
       anActor->setDisplayMode( myDisplayMode );
       anActor->setIO( getIO() );
-      AddObject( anActor );
-
-      //double bounds[6];
-      //anActor->GetBounds( bounds );
-
-      anActor->Delete();
     }
   }
 }