1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-19 13:40:49 +03:00

0031653: Visualization, V3d_View - get rid of Computed Mode

This commit is contained in:
kgv
2021-12-08 13:58:22 +03:00
parent e463b2f685
commit 15cb25b8f3
4 changed files with 56 additions and 41 deletions

View 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());
}

View 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;

View File

@@ -218,30 +218,11 @@ void V3d_View::Remove()
aWin.Nullify();
}
//=============================================================================
//function : Update
//purpose :
//=============================================================================
void V3d_View::Update() const
{
if (!myView->IsDefined()
|| !myView->IsActive())
{
return;
}
myIsInvalidatedImmediate = Standard_False;
myView->Update();
myView->Compute();
AutoZFit();
myView->Redraw();
}
//=============================================================================
//function : Redraw
//purpose :
//=============================================================================
void V3d_View::Redraw() const
void V3d_View::Redraw (bool theToCompute) const
{
if (!myView->IsDefined()
|| !myView->IsActive())
@@ -250,7 +231,14 @@ void V3d_View::Redraw() const
}
myIsInvalidatedImmediate = Standard_False;
Handle(Graphic3d_StructureManager) aStructureMgr = MyViewer->StructureManager();
Handle(Graphic3d_StructureManager) aStructureMgr = MyViewer->StructureManager();
if (theToCompute)
{
//myView->Update();
myView->Compute();
}
for (Standard_Integer aRetryIter = 0; aRetryIter < 2; ++aRetryIter)
{
if (aStructureMgr->IsDeviceLost())

View 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;