From: kgv Date: Wed, 8 Dec 2021 10:58:22 +0000 (+0300) Subject: 0031653: Visualization, V3d_View - get rid of Computed Mode X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=15cb25b8f3d8fa0de73a484f1fa071df276651aa;p=occt.git 0031653: Visualization, V3d_View - get rid of Computed Mode --- diff --git a/src/Graphic3d/Graphic3d_CView.cxx b/src/Graphic3d/Graphic3d_CView.cxx index a97efe8692..91544a662b 100644 --- a/src/Graphic3d/Graphic3d_CView.cxx +++ b/src/Graphic3d/Graphic3d_CView.cxx @@ -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 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()); } diff --git a/src/Graphic3d/Graphic3d_CView.hxx b/src/Graphic3d/Graphic3d_CView.hxx index d10a127240..a21abac485 100644 --- a/src/Graphic3d/Graphic3d_CView.hxx +++ b/src/Graphic3d/Graphic3d_CView.hxx @@ -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 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; diff --git a/src/V3d/V3d_View.cxx b/src/V3d/V3d_View.cxx index c5e768b3df..d248449657 100644 --- a/src/V3d/V3d_View.cxx +++ b/src/V3d/V3d_View.cxx @@ -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()) diff --git a/src/V3d/V3d_View.hxx b/src/V3d/V3d_View.hxx index 222fb18ef0..14be5fc09e 100644 --- a/src/V3d/V3d_View.hxx +++ b/src/V3d/V3d_View.hxx @@ -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;