]> OCCT Git - occt.git/commitdiff
0031653: Visualization, V3d_View - get rid of Computed Mode
authorkgv <kgv@opencascade.com>
Wed, 8 Dec 2021 10:58:22 +0000 (13:58 +0300)
committerkgv <kgv@opencascade.com>
Mon, 13 Dec 2021 15:34:48 +0000 (18:34 +0300)
src/Graphic3d/Graphic3d_CView.cxx
src/Graphic3d/Graphic3d_CView.hxx
src/V3d/V3d_View.cxx
src/V3d/V3d_View.hxx

index a97efe8692259193ad7fff85579f2de83e65a821..91544a662bbe903a8bce458fb2c216764c464cc9 100644 (file)
@@ -140,11 +140,10 @@ void Graphic3d_CView::Remove()
     return;
   }
 
-  Graphic3d_MapOfStructure aDisplayedStructs (myStructsDisplayed);
-
-  for (Graphic3d_MapIteratorOfMapOfStructure aStructIter (aDisplayedStructs); aStructIter.More(); aStructIter.Next())
+  Graphic3d_ViewStructureMap aDisplayedStructs (myStructsDisplayed);
+  for (Graphic3d_ViewStructureMap::Iterator aStructIter (aDisplayedStructs); aStructIter.More(); aStructIter.Next())
   {
-    Erase (aStructIter.Value());
+    Erase (aStructIter.Key());
   }
 
   myStructsToCompute.Clear();
@@ -175,7 +174,7 @@ void Graphic3d_CView::SetComputedMode (const Standard_Boolean theMode)
   myIsInComputedMode = theMode;
   if (!myIsInComputedMode)
   {
-    for (Graphic3d_MapOfStructure::Iterator aStructIter (myStructsDisplayed); aStructIter.More(); aStructIter.Next())
+    for (Graphic3d_ViewStructureMap::Iterator aStructIter (myStructsDisplayed); aStructIter.More(); aStructIter.Next())
     {
       const Handle(Graphic3d_Structure)& aStruct  = aStructIter.Key();
       const Graphic3d_TypeOfAnswer        anAnswer = acceptDisplay (aStruct->Visual());
@@ -196,7 +195,7 @@ void Graphic3d_CView::SetComputedMode (const Standard_Boolean theMode)
     return;
   }
 
-  for (Graphic3d_MapOfStructure::Iterator aDispStructIter (myStructsDisplayed); aDispStructIter.More(); aDispStructIter.Next())
+  for (Graphic3d_ViewStructureMap::Iterator aDispStructIter (myStructsDisplayed); aDispStructIter.More(); aDispStructIter.Next())
   {
     Handle(Graphic3d_Structure) aStruct  = aDispStructIter.Key();
     const Graphic3d_TypeOfAnswer anAnswer = acceptDisplay (aStruct->Visual());
@@ -390,7 +389,7 @@ void Graphic3d_CView::InvalidateZLayerBoundingBox (const Graphic3d_ZLayerId theL
 // =======================================================================
 void Graphic3d_CView::DisplayedStructures (Graphic3d_MapOfStructure& theStructures) const
 {
-  for (Graphic3d_MapOfStructure::Iterator aStructIter (myStructsDisplayed); aStructIter.More(); aStructIter.Next())
+  for (Graphic3d_ViewStructureMap::Iterator aStructIter (myStructsDisplayed); aStructIter.More(); aStructIter.Next())
   {
     theStructures.Add (aStructIter.Key());
   }
@@ -575,7 +574,7 @@ void Graphic3d_CView::Compute()
   // Remove structures that were calculated for the previous orientation.
   // Recalculation of new structures.
   NCollection_Sequence<Handle(Graphic3d_Structure)> aStructsSeq;
-  for (Graphic3d_MapOfStructure::Iterator aStructIter (myStructsDisplayed); aStructIter.More(); aStructIter.Next())
+  for (Graphic3d_ViewStructureMap::Iterator aStructIter (myStructsDisplayed); aStructIter.More(); aStructIter.Next())
   {
     const Graphic3d_TypeOfAnswer anAnswer = acceptDisplay (aStructIter.Key()->Visual());
     if (anAnswer == Graphic3d_TOA_COMPUTE)
@@ -677,9 +676,11 @@ void Graphic3d_CView::Display (const Handle(Graphic3d_Structure)& theStructure)
     anAnswer = Graphic3d_TOA_YES;
   }
 
+  const Standard_Integer anOldExtent = myStructsDisplayed.Extent();
   if (anAnswer == Graphic3d_TOA_YES)
   {
-    if (!myStructsDisplayed.Add (theStructure))
+    const Standard_Integer aPrsIndex = myStructsDisplayed.Add (theStructure, Handle(Graphic3d_Structure)());
+    if (aPrsIndex <= anOldExtent)
     {
       return;
     }
@@ -701,7 +702,8 @@ void Graphic3d_CView::Display (const Handle(Graphic3d_Structure)& theStructure)
     if (anOldStruct->HLRValidation())
     {
       // Case COMPUTED valid, to be displayed
-      if (!myStructsDisplayed.Add (theStructure))
+      const Standard_Integer aPrsIndex = myStructsDisplayed.Add (theStructure, Handle(Graphic3d_Structure)());
+      if (aPrsIndex <= anOldExtent)
       {
         return;
       }
@@ -722,7 +724,8 @@ void Graphic3d_CView::Display (const Handle(Graphic3d_Structure)& theStructure)
       if (aNewIndex != 0)
       {
         // Case of COMPUTED invalid, WITH a valid of replacement; to be displayed
-        if (!myStructsDisplayed.Add (theStructure))
+        const Standard_Integer aPrsIndex = myStructsDisplayed.Add (theStructure, Handle(Graphic3d_Structure)());
+        if (aPrsIndex <= anOldExtent)
         {
           return;
         }
@@ -797,7 +800,7 @@ void Graphic3d_CView::Display (const Handle(Graphic3d_Structure)& theStructure)
     return;
   }
 
-  myStructsDisplayed.Add (theStructure);
+  const Standard_Integer aPrsIndex = myStructsDisplayed.Add (theStructure, Handle(Graphic3d_Structure)());
   displayStructure (aStruct->CStructure(), theStructure->DisplayPriority());
 
   Update (aStruct->GetZLayer());
@@ -833,7 +836,7 @@ void Graphic3d_CView::Erase (const Handle(Graphic3d_Structure)& theStructure)
     myStructsToCompute.Remove (anIndex);
   }
 
-  myStructsDisplayed.Remove (theStructure);
+  myStructsDisplayed.RemoveKey (theStructure);
   Update (theStructure->GetZLayer());
 }
 
index d10a127240a9d30e268e0c0695bb4187449f7b29..a21abac48562f5d004387b0ec23a01f7ad1c94f9 100644 (file)
@@ -54,6 +54,28 @@ class Graphic3d_StructureManager;
 
 DEFINE_STANDARD_HANDLE (Graphic3d_CView, Graphic3d_DataStructureManager)
 
+/*struct Graphic3d_ViewStructure
+{
+  Handle(Graphic3d_Structure) Presentation;
+  Handle(Graphic3d_Structure) ViewPresentation;
+public:
+  //! Returns hash code for presentation.
+  static Standard_Integer HashCode (const Graphic3d_ViewStructure& thePrs,
+                                    const Standard_Integer theUpperBound)
+  {
+    return ::HashCode (thePrs.Presentation, theUpperBound);
+  }
+
+  //! Returns true if two objects are equal.
+  static Standard_Boolean IsEqual (const Graphic3d_ViewStructure& thePrs1,
+                                   const Graphic3d_ViewStructure& thePrs2)
+  {
+    return thePrs1.Presentation == thePrs2.Presentation;
+  }
+};*/
+
+typedef NCollection_IndexedDataMap<Handle(Graphic3d_Structure), Handle(Graphic3d_Structure)> Graphic3d_ViewStructureMap;
+
 //! Base class of a graphical view that carries out rendering process for a concrete
 //! implementation of graphical driver. Provides virtual interfaces for redrawing its
 //! contents, management of displayed structures and render settings. The source code 
@@ -580,7 +602,8 @@ protected:
   Handle(Graphic3d_Camera)  myCamera;
   Graphic3d_SequenceOfStructure myStructsToCompute;
   Graphic3d_SequenceOfStructure myStructsComputed;
-  Graphic3d_MapOfStructure myStructsDisplayed;
+  //Graphic3d_MapOfStructure myStructsDisplayed;
+  Graphic3d_ViewStructureMap myStructsDisplayed;
   Handle(Graphic3d_NMapOfTransient) myHiddenObjects;
   Standard_Boolean myIsInComputedMode;
   Standard_Boolean myIsActive;
index c5e768b3dffaee0da58525df37ea40b3187224ea..d248449657230e33cf3cf6102f64957cdd0b96e5 100644 (file)
@@ -219,10 +219,10 @@ void V3d_View::Remove()
 }
 
 //=============================================================================
-//function : Update
+//function : Redraw
 //purpose  :
 //=============================================================================
-void V3d_View::Update() const
+void V3d_View::Redraw (bool theToCompute) const
 {
   if (!myView->IsDefined()
    || !myView->IsActive())
@@ -231,26 +231,14 @@ void V3d_View::Update() const
   }
 
   myIsInvalidatedImmediate = Standard_False;
-  myView->Update();
-  myView->Compute();
-  AutoZFit();
-  myView->Redraw();
-}
+  Handle(Graphic3d_StructureManager) aStructureMgr = MyViewer->StructureManager();
 
-//=============================================================================
-//function : Redraw
-//purpose  :
-//=============================================================================
-void V3d_View::Redraw() const
-{
-  if (!myView->IsDefined()
-   || !myView->IsActive())
+  if (theToCompute)
   {
-    return;
+    //myView->Update();
+    myView->Compute();
   }
 
-  myIsInvalidatedImmediate = Standard_False;
-  Handle(Graphic3d_StructureManager) aStructureMgr  = MyViewer->StructureManager();
   for (Standard_Integer aRetryIter = 0; aRetryIter < 2; ++aRetryIter)
   {
     if (aStructureMgr->IsDeviceLost())
index 222fb18ef0892296daacb3db53ac1bb157664c3e..14be5fc09eef1474cc9c5c63d913b9a5ad5f6788 100644 (file)
@@ -108,13 +108,14 @@ public:
   Standard_EXPORT void Remove();
 
   //! Deprecated, Redraw() should be used instead.
-  Standard_EXPORT void Update() const;
+  void Update() const
+  {
+    Redraw (true);
+  }
 
-  //! Redisplays the view even if there has not
-  //! been any modification.
-  //! Must be called if the view is shown.
-  //! (Ex: DeIconification ) .
-  Standard_EXPORT virtual void Redraw() const;
+  //! Redisplays the view even if there has not been any modification.
+  //! Must be called if the view is shown Ex: DeIconification).
+  Standard_EXPORT virtual void Redraw (bool theToCompute = false) const;
 
   //! Updates layer of immediate presentations.
   Standard_EXPORT virtual void RedrawImmediate() const;