1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-13 14:27:08 +03:00

0024394: Visualization - implement more general way for rendering of immediate objects

Move OpenGl_Structure::myZLayer to base class Graphic3d_CStructure.
Graphic3d_ZLayerId - introduce new pre-defined ZLayers.
Do not clear Depth buffer twice for default ZLayer.

AIS_InteractiveContext::Display() - add new argument AIS_DisplayStatus to specify displaying status.

Drop unused Graphic3d_CPick and related methods.
Drop OpenGl_Structure::myNamedStatus - use flags from parent class Graphic3d_CStructure directly.
OpenGl_LayerList ::ChangeLayer(), ::ChangePriority - fix structure remove from unexpected layer.
Merge class OpenGl_PriorityList into OpenGl_Layer.

PrsMgr_PresentationManager::mySelectionColor - store selection color as field of Presentation Manager.
PrsMgr_Presentation class - do not declare private methods as virtual.
PrsMgr_Presentation::Highlight() - extend method syntax and drop methods ::Color() and ::BoundBox().

PrsMgr_PresentableObject - store ZLayer in presentable object
to display object presentations in required layer directly
(without displaying it in wrong layer first).

test/mesh/end - force re-displaying the shape to compute mesh anew

Test-case for issue
This commit is contained in:
kgv
2015-01-22 17:29:37 +03:00
committed by bugmaster
parent 92e24f9d36
commit a195430212
72 changed files with 1590 additions and 1958 deletions

View File

@@ -16,8 +16,9 @@
#include <Standard_TypeDef.hxx>
#include <NCollection_Map.hxx>
#include <Graphic3d_ZLayerId.hxx>
#include <Graphic3d_ZLayerSettings.hxx>
typedef NCollection_DataMap<Standard_Integer, Graphic3d_ZLayerSettings> Visual3d_MapOfZLayerSettings;
typedef NCollection_DataMap<Graphic3d_ZLayerId, Graphic3d_ZLayerSettings> Visual3d_MapOfZLayerSettings;
#endif // _Visual3d_MapOfZLayerSettings_HeaderFile

View File

@@ -85,6 +85,7 @@ uses
MapOfStructure from Graphic3d,
Camera_Handle from Graphic3d,
ZLayerId from Graphic3d,
ZLayerSettings from Graphic3d,
ContextView from Visual3d,
@@ -107,6 +108,7 @@ uses
AsciiString from TCollection,
ExtendedString from TCollection,
CGraduatedTrihedron from Graphic3d,
TypeOfStructure from Graphic3d,
PixMap from Image,
Box from Bnd
@@ -752,14 +754,12 @@ is
-- Category: Private methods
----------------------------
AcceptDisplay ( me;
AStructure : Structure from Graphic3d )
returns TypeOfAnswer from Visual3d
is static private;
---Level: Internal
---Purpose: Is it possible to display the structure
-- <AStructure> in the view <me> ?
---Category: Private methods
acceptDisplay ( me;
theStructType : TypeOfStructure from Graphic3d )
returns TypeOfAnswer from Visual3d
is static private;
---Level: Internal
---Purpose: Is it possible to display the structure in the view?
ReCompute ( me : mutable;
AStructure : Structure from Graphic3d );
@@ -787,13 +787,13 @@ is
SetZLayerSettings ( me : mutable;
theLayerId : Integer from Standard;
theLayerId : ZLayerId from Graphic3d;
theSettings : ZLayerSettings from Graphic3d )
is static private;
---Purpose: Sets the settings for a single Z layer of specified view.
AddZLayer ( me : mutable;
theLayerId : Integer from Standard )
theLayerId : ZLayerId from Graphic3d )
is static private;
---Purpose: Add a new top-level Z layer to the view with ID
-- <theLayerId>. The z layer mechanism allows to display
@@ -803,13 +803,13 @@ is
-- display of graphics in all views.
RemoveZLayer ( me : mutable;
theLayerId : Integer from Standard )
theLayerId : ZLayerId from Graphic3d )
is static private;
---Purpose: Remove z layer from the view by its ID.
ChangeZLayer ( me : mutable;
theStructure : Structure from Graphic3d;
theLayerId : Integer from Standard )
theLayerId : ZLayerId from Graphic3d )
is static private;
---Purpose: Change Z layer of already displayed structure in the view.

View File

@@ -28,7 +28,6 @@
#include <Graphic3d_Vertex.hxx>
#include <Visual3d_DepthCueingDefinitionError.hxx>
#include <Visual3d_Light.hxx>
#include <Visual3d_HSequenceOfView.hxx>
#include <Visual3d_ZClippingDefinitionError.hxx>
#include <OSD.hxx>
#include <TColStd_HArray2OfReal.hxx>
@@ -712,10 +711,10 @@ void Visual3d_View::SetContext (const Visual3d_ContextView& theViewCtx)
// It is not necessary to warn ViewManager as this structure should not disappear from
// the list of structures displayed in it.
NCollection_Sequence<Handle(Graphic3d_Structure)> aStructs;
for (Graphic3d_MapIteratorOfMapOfStructure aStructIter (myStructsDisplayed); aStructIter.More(); aStructIter.Next())
for (Graphic3d_MapOfStructure::Iterator aStructIter (myStructsDisplayed); aStructIter.More(); aStructIter.Next())
{
const Handle(Graphic3d_Structure)& aStruct = aStructIter.Key();
const Visual3d_TypeOfAnswer anAnswer = AcceptDisplay (aStruct);
const Visual3d_TypeOfAnswer anAnswer = acceptDisplay (aStruct->Visual());
if (anAnswer == Visual3d_TOA_NO
|| anAnswer == Visual3d_TOA_COMPUTE)
{
@@ -743,7 +742,7 @@ void Visual3d_View::SetContext (const Visual3d_ContextView& theViewCtx)
continue;
}
const Visual3d_TypeOfAnswer anAnswer = AcceptDisplay (aStruct);
const Visual3d_TypeOfAnswer anAnswer = acceptDisplay (aStruct->Visual());
if (anAnswer == Visual3d_TOA_YES
|| anAnswer == Visual3d_TOA_COMPUTE)
{
@@ -780,7 +779,7 @@ void Visual3d_View::DisplayedStructures (Graphic3d_MapOfStructure& theStructures
return;
}
for (Graphic3d_MapIteratorOfMapOfStructure aStructIter (myStructsDisplayed); aStructIter.More(); aStructIter.Next())
for (Graphic3d_MapOfStructure::Iterator aStructIter (myStructsDisplayed); aStructIter.More(); aStructIter.Next())
{
theStructures.Add (aStructIter.Key());
}
@@ -825,7 +824,7 @@ void Visual3d_View::Activate()
}
// If the structure can be displayed in the new context of the view, it is displayed.
const Visual3d_TypeOfAnswer anAnswer = AcceptDisplay (aStruct);
const Visual3d_TypeOfAnswer anAnswer = acceptDisplay (aStruct->Visual());
if (anAnswer == Visual3d_TOA_YES
|| anAnswer == Visual3d_TOA_COMPUTE)
{
@@ -898,7 +897,7 @@ void Visual3d_View::Deactivate()
continue;
}
const Visual3d_TypeOfAnswer anAnswer = AcceptDisplay (aStruct);
const Visual3d_TypeOfAnswer anAnswer = acceptDisplay (aStruct->Visual());
if (anAnswer == Visual3d_TOA_YES
|| anAnswer == Visual3d_TOA_COMPUTE)
{
@@ -1131,13 +1130,13 @@ void Visual3d_View::ZFitAll (const Standard_Real theScaleFactor)
}
// ========================================================================
// function : AcceptDisplay
// function : acceptDisplay
// purpose :
// ========================================================================
Visual3d_TypeOfAnswer Visual3d_View::AcceptDisplay (const Handle(Graphic3d_Structure)& theStruct) const
Visual3d_TypeOfAnswer Visual3d_View::acceptDisplay (const Graphic3d_TypeOfStructure theStructType) const
{
const Visual3d_TypeOfVisualization ViewType = MyContext.Visualization();
switch (theStruct->Visual())
const Visual3d_TypeOfVisualization aViewType = MyContext.Visualization();
switch (theStructType)
{
case Graphic3d_TOS_ALL:
{
@@ -1145,19 +1144,19 @@ Visual3d_TypeOfAnswer Visual3d_View::AcceptDisplay (const Handle(Graphic3d_Struc
}
case Graphic3d_TOS_SHADING:
{
return ViewType == Visual3d_TOV_SHADING
return aViewType == Visual3d_TOV_SHADING
? Visual3d_TOA_YES
: Visual3d_TOA_NO;
}
case Graphic3d_TOS_WIREFRAME:
{
return ViewType == Visual3d_TOV_WIREFRAME
return aViewType == Visual3d_TOV_WIREFRAME
? Visual3d_TOA_YES
: Visual3d_TOA_NO;
}
case Graphic3d_TOS_COMPUTED:
{
return (ViewType == Visual3d_TOV_SHADING || ViewType == Visual3d_TOV_WIREFRAME)
return (aViewType == Visual3d_TOV_SHADING || aViewType == Visual3d_TOV_WIREFRAME)
? Visual3d_TOA_COMPUTE
: Visual3d_TOA_NO;
}
@@ -1260,18 +1259,18 @@ Standard_Boolean Visual3d_View::DisplayImmediate (const Handle(Graphic3d_Structu
if (theIsSingleView)
{
Handle(Visual3d_HSequenceOfView) aViews = myViewManager->DefinedView();
for (int i=1;i<=aViews->Length();i++)
const Visual3d_SequenceOfView& aViews = myViewManager->DefinedViews();
for (Standard_Integer aViewIter = 1; aViewIter <= aViews.Length(); ++aViewIter)
{
if (aViews->Value(i).Access() != this)
const Handle(Visual3d_View)& aView = aViews.Value (aViewIter);
if (aView.Access() != this)
{
aViews->Value(i)->EraseImmediate (theStructure);
aView->EraseImmediate (theStructure);
}
}
}
myGraphicDriver->DisplayImmediateStructure (MyCView, *theStructure->CStructure());
myGraphicDriver->DisplayImmediateStructure (MyCView, theStructure);
return Standard_True;
}
@@ -1301,9 +1300,9 @@ Standard_Boolean Visual3d_View::ClearImmediate()
return Standard_False;
}
for (Graphic3d_MapIteratorOfMapOfStructure anIter (myImmediateStructures); anIter.More(); anIter.Next())
for (Graphic3d_MapOfStructure::Iterator aStructIter (myImmediateStructures); aStructIter.More(); aStructIter.Next())
{
myGraphicDriver->EraseImmediateStructure (MyCView, *anIter.Key()->CStructure());
myGraphicDriver->EraseImmediateStructure (MyCView, *aStructIter.Key()->CStructure());
}
myImmediateStructures.Clear();
return Standard_True;
@@ -1345,7 +1344,7 @@ void Visual3d_View::Display (const Handle(Graphic3d_Structure)& theStruct,
anIndex = 0;
}
Visual3d_TypeOfAnswer anAnswer = AcceptDisplay (theStruct);
Visual3d_TypeOfAnswer anAnswer = acceptDisplay (theStruct->Visual());
if (anAnswer == Visual3d_TOA_NO)
{
return;
@@ -1358,14 +1357,13 @@ void Visual3d_View::Display (const Handle(Graphic3d_Structure)& theStruct,
if (anAnswer == Visual3d_TOA_YES)
{
if (IsDisplayed (theStruct))
if (!myStructsDisplayed.Add (theStruct))
{
return;
}
theStruct->CalculateBoundBox();
myGraphicDriver->DisplayStructure (MyCView, *theStruct->CStructure(), theStruct->DisplayPriority());
myStructsDisplayed.Add (theStruct);
myGraphicDriver->DisplayStructure (MyCView, theStruct, theStruct->DisplayPriority());
Update (theUpdateMode);
return;
}
@@ -1380,14 +1378,14 @@ void Visual3d_View::Display (const Handle(Graphic3d_Structure)& theStruct,
const Handle(Graphic3d_Structure)& anOldStruct = myStructsComputed.Value (anIndex);
if (anOldStruct->HLRValidation())
{
// Case COMPUTED valid
// to be displayed
if (!IsDisplayed (theStruct))
// Case COMPUTED valid, to be displayed
if (!myStructsDisplayed.Add (theStruct))
{
myStructsDisplayed.Add (theStruct);
myGraphicDriver->DisplayStructure (MyCView, *anOldStruct->CStructure(), theStruct->DisplayPriority());
Update (theUpdateMode);
return;
}
myGraphicDriver->DisplayStructure (MyCView, anOldStruct, theStruct->DisplayPriority());
Update (theUpdateMode);
return;
}
else
@@ -1401,25 +1399,25 @@ void Visual3d_View::Display (const Handle(Graphic3d_Structure)& theStruct,
const Standard_Integer aNewIndex = HaveTheSameOwner (theStruct);
if (aNewIndex != 0)
{
// Case of COMPUTED invalid, WITH a valid of replacement
// to be displayed
if (!IsDisplayed (theStruct))
// Case of COMPUTED invalid, WITH a valid of replacement; to be displayed
if (!myStructsDisplayed.Add (theStruct))
{
const Handle(Graphic3d_Structure)& aNewStruct = myStructsComputed.Value (aNewIndex);
myStructsComputed.SetValue (anIndex, aNewStruct);
myStructsDisplayed.Add (theStruct);
myGraphicDriver->DisplayStructure (MyCView, *aNewStruct->CStructure(), theStruct->DisplayPriority());
Update (theUpdateMode);
return;
}
const Handle(Graphic3d_Structure)& aNewStruct = myStructsComputed.Value (aNewIndex);
myStructsComputed.SetValue (anIndex, aNewStruct);
myGraphicDriver->DisplayStructure (MyCView, aNewStruct, theStruct->DisplayPriority());
Update (theUpdateMode);
return;
}
else
{
// Case COMPUTED invalid, WITHOUT a valid of replacement
// COMPUTED is removed if displayed
if (IsDisplayed (theStruct))
if (myStructsDisplayed.Contains (theStruct))
{
myGraphicDriver->EraseStructure (MyCView, *anOldStruct->CStructure());
myGraphicDriver->EraseStructure (MyCView, anOldStruct);
}
}
}
@@ -1484,26 +1482,25 @@ void Visual3d_View::Display (const Handle(Graphic3d_Structure)& theStruct,
else
{
aStruct->SetVisual (toComputeWireframe ? Graphic3d_TOS_WIREFRAME : Graphic3d_TOS_SHADING);
anAnswer = AcceptDisplay (aStruct);
anAnswer = acceptDisplay (aStruct->Visual());
}
if (theStruct->IsHighlighted())
{
aStruct->SetHighlightColor (theStruct->HighlightColor());
aStruct->GraphicHighlight (Aspect_TOHM_COLOR);
aStruct->Highlight (Aspect_TOHM_COLOR, theStruct->HighlightColor(), Standard_False);
}
// It is displayed only if the calculated structure
// has a proper type corresponding to the one of the view.
if (anAnswer != Visual3d_TOA_NO)
if (anAnswer == Visual3d_TOA_NO)
{
if (!IsDisplayed (theStruct))
{
myStructsDisplayed.Add (theStruct);
}
myGraphicDriver->DisplayStructure (MyCView, *aStruct->CStructure(), theStruct->DisplayPriority());
Update (theUpdateMode);
return;
}
myStructsDisplayed.Add (theStruct);
myGraphicDriver->DisplayStructure (MyCView, aStruct, theStruct->DisplayPriority());
Update (theUpdateMode);
}
// ========================================================================
@@ -1525,13 +1522,14 @@ void Visual3d_View::Erase (const Handle(Graphic3d_Structure)& theStruct)
void Visual3d_View::Erase (const Handle(Graphic3d_Structure)& theStruct,
const Aspect_TypeOfUpdate theUpdateMode)
{
if (IsDeleted()
|| !IsDisplayed (theStruct))
if ( IsDeleted()
|| EraseImmediate (theStruct)
|| !IsDisplayed (theStruct))
{
return;
}
Visual3d_TypeOfAnswer anAnswer = AcceptDisplay (theStruct);
Visual3d_TypeOfAnswer anAnswer = acceptDisplay (theStruct->Visual());
if (!ComputedMode())
{
anAnswer = Visual3d_TOA_YES;
@@ -1539,7 +1537,7 @@ void Visual3d_View::Erase (const Handle(Graphic3d_Structure)& theStruct,
if (anAnswer != Visual3d_TOA_COMPUTE)
{
myGraphicDriver->EraseStructure (MyCView, *theStruct->CStructure());
myGraphicDriver->EraseStructure (MyCView, theStruct);
}
else if (anAnswer == Visual3d_TOA_COMPUTE
&& myIsInComputedMode)
@@ -1548,7 +1546,7 @@ void Visual3d_View::Erase (const Handle(Graphic3d_Structure)& theStruct,
if (anIndex != 0)
{
const Handle(Graphic3d_Structure)& aCompStruct = myStructsComputed.ChangeValue (anIndex);
myGraphicDriver->EraseStructure (MyCView, *aCompStruct->CStructure());
myGraphicDriver->EraseStructure (MyCView, aCompStruct);
}
}
myStructsDisplayed.Remove (theStruct);
@@ -1566,8 +1564,7 @@ void Visual3d_View::Highlight (const Handle(Graphic3d_Structure)& theStruct,
if (anIndex != 0)
{
const Handle(Graphic3d_Structure)& aCompStruct = myStructsComputed.ChangeValue (anIndex);
aCompStruct->SetHighlightColor (theStruct->HighlightColor());
aCompStruct->GraphicHighlight (theMethod);
aCompStruct->Highlight (theMethod, theStruct->HighlightColor(), Standard_False);
}
}
@@ -1603,7 +1600,7 @@ void Visual3d_View::SetTransform (const Handle(Graphic3d_Structure)& theStruct,
&& !theStruct->CStructure()->IsForHighlight
&& !theStruct->CStructure()->IsInfinite)
{
const Standard_Integer aLayerId = theStruct->GetZLayer();
const Graphic3d_ZLayerId aLayerId = theStruct->GetZLayer();
myGraphicDriver->InvalidateBVHData (MyCView, aLayerId);
}
}
@@ -1657,7 +1654,14 @@ Standard_Boolean Visual3d_View::IsDisplayed (const Handle(Graphic3d_Structure)&
// ========================================================================
Standard_Boolean Visual3d_View::ContainsFacet() const
{
return ContainsFacet (myStructsDisplayed);
for (Graphic3d_MapOfStructure::Iterator aStructIter (myStructsDisplayed); aStructIter.More(); aStructIter.Next())
{
if (aStructIter.Key()->ContainsFacet())
{
return Standard_True;
}
}
return Standard_False;
}
// ========================================================================
@@ -1676,14 +1680,51 @@ Standard_Boolean Visual3d_View::ContainsFacet (const Graphic3d_MapOfStructure& t
return Standard_False;
}
//! Auxiliary method for MinMaxValues() method
inline void addStructureBndBox (const Handle(Graphic3d_Structure)& theStruct,
const Standard_Boolean theToIgnoreInfiniteFlag,
Bnd_Box& theBndBox)
{
if (!theStruct->IsVisible())
{
return;
}
else if (theStruct->IsInfinite()
&& !theToIgnoreInfiniteFlag)
{
// XMin, YMin .... ZMax are initialized by means of infinite line data
const Bnd_Box aBox = theStruct->MinMaxValues (Standard_False);
if (!aBox.IsWhole()
&& !aBox.IsVoid())
{
theBndBox.Add (aBox);
}
return;
}
// Only non-empty and non-infinite structures
// are taken into account for calculation of MinMax
if (theStruct->IsEmpty()
|| theStruct->TransformPersistenceMode() != Graphic3d_TMF_None)
{
return;
}
// "FitAll" operation ignores object with transform persistence parameter
const Bnd_Box aBox = theStruct->MinMaxValues (theToIgnoreInfiniteFlag);
theBndBox.Add (aBox);
}
// ========================================================================
// function : MinMaxValues
// purpose :
// ========================================================================
Bnd_Box Visual3d_View::MinMaxValues (const Standard_Boolean theToIgnoreInfiniteFlag) const
{
return MinMaxValues (myStructsDisplayed,
theToIgnoreInfiniteFlag);
Bnd_Box aResult = MinMaxValues (myStructsDisplayed, theToIgnoreInfiniteFlag);
Bnd_Box anImmediate = MinMaxValues (myImmediateStructures, theToIgnoreInfiniteFlag);
aResult.Add (anImmediate);
return aResult;
}
// ========================================================================
@@ -1691,45 +1732,18 @@ Bnd_Box Visual3d_View::MinMaxValues (const Standard_Boolean theToIgnoreInfiniteF
// purpose :
// ========================================================================
Bnd_Box Visual3d_View::MinMaxValues (const Graphic3d_MapOfStructure& theSet,
const Standard_Boolean theToIgnoreInfiniteFlag) const
const Standard_Boolean theToIgnoreInfiniteFlag) const
{
Bnd_Box aResult;
if (theSet.IsEmpty ())
for (Graphic3d_MapIteratorOfMapOfStructure aStructIter (theSet); aStructIter.More(); aStructIter.Next())
{
// Return an empty box.
return aResult;
}
Graphic3d_MapIteratorOfMapOfStructure anIterator (theSet);
for (anIterator.Initialize (theSet); anIterator.More(); anIterator.Next())
{
const Handle(Graphic3d_Structure)& aStructure = anIterator.Key();
if (!aStructure->IsVisible())
const Handle(Graphic3d_Structure)& aStructure = aStructIter.Key();
if (!aStructIter.Value()->IsVisible())
{
continue;
if (aStructure->IsInfinite() && !theToIgnoreInfiniteFlag)
{
//XMin, YMin .... ZMax are initialized by means of infinite line data
Bnd_Box aBox = aStructure->MinMaxValues (Standard_False);
if (!aBox.IsWhole() && !aBox.IsVoid())
{
aResult.Add (aBox);
}
}
// Only non-empty and non-infinite structures
// are taken into account for calculation of MinMax
if ((!aStructure->IsInfinite() || theToIgnoreInfiniteFlag) && !aStructure->IsEmpty())
{
Bnd_Box aBox = aStructure->MinMaxValues (theToIgnoreInfiniteFlag);
/* ABD 29/10/04 Transform Persistence of Presentation( pan, zoom, rotate ) */
//"FitAll" operation ignores object with transform persitence parameter
if(aStructure->TransformPersistenceMode() == Graphic3d_TMF_None )
{
aResult.Add (aBox);
}
}
addStructureBndBox (aStructure, theToIgnoreInfiniteFlag, aResult);
}
return aResult;
}
@@ -1862,9 +1876,9 @@ void Visual3d_View::Compute()
// Remove structures that were calculated for the previous orientation.
// Recalculation of new structures.
NCollection_Sequence<Handle(Graphic3d_Structure)> aStructsSeq;
for (Graphic3d_MapIteratorOfMapOfStructure aStructIter (myStructsDisplayed); aStructIter.More(); aStructIter.Next())
for (Graphic3d_MapOfStructure::Iterator aStructIter (myStructsDisplayed); aStructIter.More(); aStructIter.Next())
{
const Visual3d_TypeOfAnswer anAnswer = AcceptDisplay (aStructIter.Key());
const Visual3d_TypeOfAnswer anAnswer = acceptDisplay (aStructIter.Key()->Visual());
if (anAnswer == Visual3d_TOA_COMPUTE)
{
aStructsSeq.Append (aStructIter.Key()); // if the structure was calculated, it is recalculated
@@ -1902,7 +1916,7 @@ void Visual3d_View::ReCompute (const Handle(Graphic3d_Structure)& theStruct)
return;
}
const Visual3d_TypeOfAnswer anAnswer = AcceptDisplay (theStruct);
const Visual3d_TypeOfAnswer anAnswer = acceptDisplay (theStruct->Visual());
if (anAnswer != Visual3d_TOA_COMPUTE)
{
return;
@@ -1950,13 +1964,12 @@ void Visual3d_View::ReCompute (const Handle(Graphic3d_Structure)& theStruct)
if (theStruct->IsHighlighted())
{
aCompStruct->SetHighlightColor (theStruct->HighlightColor());
aCompStruct->GraphicHighlight (Aspect_TOHM_COLOR);
aCompStruct->Highlight (Aspect_TOHM_COLOR, theStruct->HighlightColor(), Standard_False);
}
// The previous calculation is removed and the new one is dislayed
myGraphicDriver->EraseStructure (MyCView, *aCompStructOld->CStructure());
myGraphicDriver->DisplayStructure (MyCView, *aCompStruct->CStructure(), theStruct->DisplayPriority());
// The previous calculation is removed and the new one is displayed
myGraphicDriver->EraseStructure (MyCView, aCompStructOld);
myGraphicDriver->DisplayStructure (MyCView, aCompStruct, theStruct->DisplayPriority());
// why not just replace existing items?
//myStructsToCompute.ChangeValue (anIndex) = theStruct;
@@ -2324,10 +2337,10 @@ void Visual3d_View::SetComputedMode (const Standard_Boolean theMode)
myIsInComputedMode = theMode;
if (!myIsInComputedMode)
{
for (Graphic3d_MapIteratorOfMapOfStructure aStructIter (myStructsDisplayed); aStructIter.More(); aStructIter.Next())
for (Graphic3d_MapOfStructure::Iterator aStructIter (myStructsDisplayed); aStructIter.More(); aStructIter.Next())
{
const Handle(Graphic3d_Structure)& aStruct = aStructIter.Key();
const Visual3d_TypeOfAnswer anAnswer = AcceptDisplay (aStruct);
const Visual3d_TypeOfAnswer anAnswer = acceptDisplay (aStruct->Visual());
if (anAnswer != Visual3d_TOA_COMPUTE)
{
continue;
@@ -2337,17 +2350,17 @@ void Visual3d_View::SetComputedMode (const Standard_Boolean theMode)
if (anIndex != 0)
{
const Handle(Graphic3d_Structure)& aStructComp = myStructsComputed.Value (anIndex);
myGraphicDriver->EraseStructure (MyCView, *aStructComp->CStructure());
myGraphicDriver->DisplayStructure (MyCView, *aStruct->CStructure(), aStruct->DisplayPriority());
myGraphicDriver->EraseStructure (MyCView, aStructComp);
myGraphicDriver->DisplayStructure (MyCView, aStruct, aStruct->DisplayPriority());
}
}
return;
}
for (Graphic3d_MapIteratorOfMapOfStructure aDispStructIter (myStructsDisplayed); aDispStructIter.More(); aDispStructIter.Next())
for (Graphic3d_MapOfStructure::Iterator aDispStructIter (myStructsDisplayed); aDispStructIter.More(); aDispStructIter.Next())
{
Handle(Graphic3d_Structure) aStruct = aDispStructIter.Key();
const Visual3d_TypeOfAnswer anAnswer = AcceptDisplay (aStruct);
Handle(Graphic3d_Structure) aStruct = aDispStructIter.Key();
const Visual3d_TypeOfAnswer anAnswer = acceptDisplay (aStruct->Visual());
if (anAnswer != Visual3d_TOA_COMPUTE)
{
continue;
@@ -2356,8 +2369,8 @@ void Visual3d_View::SetComputedMode (const Standard_Boolean theMode)
const Standard_Integer anIndex = IsComputed (aStruct);
if (anIndex != 0)
{
myGraphicDriver->EraseStructure (MyCView, *aStruct->CStructure());
myGraphicDriver->DisplayStructure (MyCView, *(myStructsComputed.Value (anIndex)->CStructure()), aStruct->DisplayPriority());
myGraphicDriver->EraseStructure (MyCView, aStruct);
myGraphicDriver->DisplayStructure (MyCView, myStructsComputed.Value (anIndex), aStruct->DisplayPriority());
Display (aStruct, Aspect_TOU_WAIT);
if (aStruct->IsHighlighted())
@@ -2365,8 +2378,7 @@ void Visual3d_View::SetComputedMode (const Standard_Boolean theMode)
const Handle(Graphic3d_Structure)& aCompStruct = myStructsComputed.Value (anIndex);
if (!aCompStruct->IsHighlighted())
{
aCompStruct->SetHighlightColor (aStruct->HighlightColor());
aCompStruct->GraphicHighlight (Aspect_TOHM_COLOR);
aCompStruct->Highlight (Aspect_TOHM_COLOR, aStruct->HighlightColor(), Standard_False);
}
}
}
@@ -2387,8 +2399,7 @@ void Visual3d_View::SetComputedMode (const Standard_Boolean theMode)
if (aStruct->IsHighlighted())
{
aCompStruct->SetHighlightColor (aStruct->HighlightColor());
aCompStruct->GraphicHighlight (Aspect_TOHM_COLOR);
aCompStruct->Highlight (Aspect_TOHM_COLOR, aStruct->HighlightColor(), Standard_False);
}
Standard_Boolean hasResult = Standard_False;
@@ -2410,8 +2421,8 @@ void Visual3d_View::SetComputedMode (const Standard_Boolean theMode)
myStructsComputed .Append (aCompStruct);
}
myGraphicDriver->EraseStructure (MyCView, *aStruct->CStructure());
myGraphicDriver->DisplayStructure (MyCView, *aCompStruct->CStructure(), aStruct->DisplayPriority());
myGraphicDriver->EraseStructure (MyCView, aStruct);
myGraphicDriver->DisplayStructure (MyCView, aCompStruct, aStruct->DisplayPriority());
}
}
Update (myViewManager->UpdateMode());
@@ -2599,7 +2610,7 @@ Standard_Boolean Visual3d_View::Export (const Standard_CString theFileName
// function : SetZLayerSettings
// purpose :
// =======================================================================
void Visual3d_View::SetZLayerSettings (const Standard_Integer theLayerId,
void Visual3d_View::SetZLayerSettings (const Graphic3d_ZLayerId theLayerId,
const Graphic3d_ZLayerSettings& theSettings)
{
myGraphicDriver->SetZLayerSettings (MyCView, theLayerId, theSettings);
@@ -2609,7 +2620,7 @@ void Visual3d_View::SetZLayerSettings (const Standard_Integer theLayerId,
// function : AddZLayer
// purpose :
// =======================================================================
void Visual3d_View::AddZLayer (const Standard_Integer theLayerId)
void Visual3d_View::AddZLayer (const Graphic3d_ZLayerId theLayerId)
{
myGraphicDriver->AddZLayer (MyCView, theLayerId);
}
@@ -2618,7 +2629,7 @@ void Visual3d_View::AddZLayer (const Standard_Integer theLayerId)
// function : RemoveZLayer
// purpose :
// =======================================================================
void Visual3d_View::RemoveZLayer (const Standard_Integer theLayerId)
void Visual3d_View::RemoveZLayer (const Graphic3d_ZLayerId theLayerId)
{
myGraphicDriver->RemoveZLayer (MyCView, theLayerId);
}
@@ -2628,7 +2639,7 @@ void Visual3d_View::RemoveZLayer (const Standard_Integer theLayerId)
// purpose :
// =======================================================================
void Visual3d_View::ChangeZLayer (const Handle(Graphic3d_Structure)& theStructure,
const Standard_Integer theLayerId)
const Graphic3d_ZLayerId theLayerId)
{
myGraphicDriver->ChangeZLayer (*(theStructure->CStructure()), MyCView, theLayerId);
}

View File

@@ -22,7 +22,6 @@ class ViewManager from Visual3d inherits StructureManager from Graphic3d
---Purpose: This class allows the definition of a manager to
-- which the views are associated.
-- It allows them to be globally manipulated.
-- It activates the pick.
uses
@@ -41,10 +40,10 @@ uses
CView from Graphic3d,
Vector from Graphic3d,
ZLayerId from Graphic3d,
ZLayerSettings from Graphic3d,
MapOfZLayerSettings from Visual3d,
ContextPick from Visual3d,
Layer from Visual3d,
SequenceOfView from Visual3d,
HSequenceOfView from Visual3d,
@@ -129,9 +128,10 @@ is
---Purpose: Returns the group of views activated in the visualiser <me>.
---Category: Inquire methods
DefinedView ( me )
returns HSequenceOfView from Visual3d
is static;
DefinedViews (me)
returns SequenceOfView from Visual3d
is static;
---C++: return const &
---Level: Internal
---Purpose: Returns the group of views defined in the visualiser <me>.
---Category: Inquire methods
@@ -163,29 +163,6 @@ is
---Purpose: Release a unique ID of the view reserved for the view on its creation.
is static;
-------------------------------------------------
-- Summary of Pick Input --
-- --
-- Picking returns information about an --
-- object pointed to on the display. --
-- --
-- To be picked, a structure must be : --
-- --
-- Visible --
-- Within the pick aperture --
-- Pickable as determined by the method --
-- Graphic3d_Structure::SetPick --
-- --
-- To insert a Pick Identification use the --
-- method Graphic3d_Group::SetPickId --
-- --
-- The pick search order tends to select the --
-- "top" object : --
-- High to low structure display priority --
-- Most recently displayed to least --
-- recently displayed. --
-------------------------------------------------
------------------------------
-- Category: Redefined methods
------------------------------
@@ -232,30 +209,25 @@ is
ChangeZLayer ( me : mutable;
theStructure : Structure from Graphic3d;
theLayerId : Integer from Standard )
theLayerId : ZLayerId from Graphic3d )
is redefined static;
---Purpose: Change Z layer for structure. The layer mechanism allows
-- to display structures in higher layers in overlay of structures in
-- lower layers.
GetZLayer ( me;
theStructure : Structure from Graphic3d )
returns Integer from Standard is redefined static;
---Purpose: Get Z layer ID assigned for the structure.
SetZLayerSettings ( me : mutable;
theLayerId : Integer from Standard;
theLayerId : ZLayerId from Graphic3d;
theSettings : ZLayerSettings from Graphic3d )
is redefined static;
---Purpose: Sets the settings for a single Z layer for all managed views.
ZLayerSettings ( me : mutable;
theLayerId : Integer from Standard )
theLayerId : ZLayerId from Graphic3d )
returns ZLayerSettings from Graphic3d is redefined static;
---Purpose: Returns the settings of a single Z layer.
AddZLayer ( me : mutable;
theLayerId : in out Integer from Standard )
theLayerId : out ZLayerId from Graphic3d )
returns Boolean from Standard is redefined static;
---Purpose: Add a new top-level Z layer and get its ID as
-- <theLayerId> value. The method returns Standard_False if the layer
@@ -263,7 +235,7 @@ is
-- structures in higher layers in overlay of structures in lower layers.
RemoveZLayer ( me : mutable;
theLayerId : Integer from Standard )
theLayerId : ZLayerId from Graphic3d )
returns Boolean from Standard is redefined static;
---Purpose: Remove Z layer with ID <theLayerId>. Method returns
-- Standard_False if the layer can not be removed or doesn't exists.
@@ -284,12 +256,6 @@ is
-- controlled view. This method used on the view initialization to
-- make the layer lists consistent.
getZLayerGenId ( myclass )
---Purpose: Returns global instance of z layer ids generator.
---C++: return &
returns GenId from Aspect is protected;
Clear ( me : mutable;
AStructure : Structure from Graphic3d;
WithDestruction : Boolean from Standard )
@@ -457,8 +423,9 @@ fields
MyZBufferAuto : Boolean from Standard;
-- Z layer indexes
myLayerIds : MapOfInteger from TColStd;
myLayerSeq : SequenceOfInteger from TColStd;
myZLayerGenId : GenId from Aspect;
myLayerIds : MapOfInteger from TColStd;
myLayerSeq : SequenceOfInteger from TColStd;
myMapOfZLayerSettings : MapOfZLayerSettings from Visual3d;

View File

@@ -82,15 +82,43 @@ Visual3d_ViewManager::Visual3d_ViewManager (const Handle(Graphic3d_GraphicDriver
Graphic3d_StructureManager (theDriver),
MyDefinedView (),
MyViewGenId (View_IDMIN+((View_IDMIN+View_IDMAX)/(Visual3d_ViewManager::Limit ()))*(Visual3d_ViewManager::CurrentId ()-1),View_IDMIN+((View_IDMIN+View_IDMAX)/(Visual3d_ViewManager::Limit ()))*Visual3d_ViewManager::CurrentId ()-1),
MyZBufferAuto (Standard_False)
MyZBufferAuto (Standard_False),
myZLayerGenId (1, IntegerLast())
{
// default layer is always presented in display layer sequence
// it can not be removed
myLayerIds.Add (0);
myLayerSeq.Append (0);
MyGraphicDriver = theDriver;
myMapOfZLayerSettings.Bind (0, Graphic3d_ZLayerSettings());
// default layers are always presented in display layer sequence it can not be removed
Graphic3d_ZLayerSettings aDefSettings;
aDefSettings.Flags = Graphic3d_ZLayerDepthTest
| Graphic3d_ZLayerDepthWrite;
aDefSettings.IsImmediate = false;
myLayerIds.Add (Graphic3d_ZLayerId_Default);
myLayerSeq.Append (Graphic3d_ZLayerId_Default);
myMapOfZLayerSettings.Bind (Graphic3d_ZLayerId_Default, aDefSettings);
Graphic3d_ZLayerSettings aTopSettings;
aTopSettings.Flags = Graphic3d_ZLayerDepthTest
| Graphic3d_ZLayerDepthWrite;
aTopSettings.IsImmediate = true;
myLayerIds.Add (Graphic3d_ZLayerId_Top);
myLayerSeq.Append (Graphic3d_ZLayerId_Top);
myMapOfZLayerSettings.Bind (Graphic3d_ZLayerId_Top, aTopSettings);
Graphic3d_ZLayerSettings aTopmostSettings;
aTopmostSettings.Flags = Graphic3d_ZLayerDepthTest
| Graphic3d_ZLayerDepthWrite
| Graphic3d_ZLayerDepthClear;
aTopmostSettings.IsImmediate = true;
myLayerIds.Add (Graphic3d_ZLayerId_Topmost);
myLayerSeq.Append (Graphic3d_ZLayerId_Topmost);
myMapOfZLayerSettings.Bind (Graphic3d_ZLayerId_Topmost, aTopmostSettings);
Graphic3d_ZLayerSettings anOsdSettings;
anOsdSettings.Flags = 0;
anOsdSettings.IsImmediate = true;
myLayerIds.Add (Graphic3d_ZLayerId_TopOSD);
myLayerSeq.Append (Graphic3d_ZLayerId_TopOSD);
myMapOfZLayerSettings.Bind (Graphic3d_ZLayerId_TopOSD, anOsdSettings);
}
//-Destructors
@@ -124,7 +152,6 @@ void Visual3d_ViewManager::Remove () {
// clear all structures whilst views are alive for correct GPU memory management
MyDisplayedStructure.Clear();
MyHighlightedStructure.Clear();
MyPickStructure.Clear();
// clear list of managed views
MyDefinedView.Clear();
@@ -255,7 +282,6 @@ void Visual3d_ViewManager::Erase (const Handle(Graphic3d_Structure)& AStructure)
}
MyHighlightedStructure.Remove (AStructure);
MyPickStructure.Remove (AStructure);
}
void Visual3d_ViewManager::Erase () {
@@ -423,16 +449,9 @@ Standard_Boolean Visual3d_ViewManager::ContainsComputedStructure () const
}
#endif
Handle(Visual3d_HSequenceOfView) Visual3d_ViewManager::DefinedView () const
const Visual3d_SequenceOfView& Visual3d_ViewManager::DefinedViews() const
{
Handle (Visual3d_HSequenceOfView) SG = new Visual3d_HSequenceOfView();
for(int i=1; i<=MyDefinedView.Length(); i++)
{
SG->Append(MyDefinedView.Value(i));
}
return (SG);
return MyDefinedView;
}
Standard_Boolean Visual3d_ViewManager::ViewExists (const Handle(Aspect_Window)& AWindow, Graphic3d_CView& TheCView) const
@@ -629,39 +648,26 @@ const Handle(Visual3d_Layer)& Visual3d_ViewManager::OverLayer () const {
//=======================================================================
void Visual3d_ViewManager::ChangeZLayer (const Handle(Graphic3d_Structure)& theStructure,
const Standard_Integer theLayerId)
const Graphic3d_ZLayerId theLayerId)
{
if (!myLayerIds.Contains (theLayerId))
return;
// change display layer for structure in all views
if (MyDisplayedStructure.Contains (theStructure))
if (!myLayerIds.Contains (theLayerId)
|| !MyDisplayedStructure.Contains (theStructure))
{
for(int i=1; i<=MyDefinedView.Length(); i++)
{
(MyDefinedView.Value(i))->ChangeZLayer(theStructure, theLayerId);
}
return;
}
// tell graphic driver to update the structure's display layer
MyGraphicDriver->ChangeZLayer (*(theStructure->CStructure()), theLayerId);
}
//=======================================================================
//function : GetZLayer
//purpose :
//=======================================================================
Standard_Integer Visual3d_ViewManager::GetZLayer (const Handle(Graphic3d_Structure)& theStructure) const
{
return MyGraphicDriver->GetZLayer (*theStructure->CStructure ());
// change display layer for structure in all views
for (int aViewIter = 1; aViewIter <= MyDefinedView.Length(); ++aViewIter)
{
MyDefinedView.Value (aViewIter)->ChangeZLayer (theStructure, theLayerId);
}
}
//=======================================================================
//function : SetZLayerSettings
//purpose :
//=======================================================================
void Visual3d_ViewManager::SetZLayerSettings (const Standard_Integer theLayerId,
void Visual3d_ViewManager::SetZLayerSettings (const Graphic3d_ZLayerId theLayerId,
const Graphic3d_ZLayerSettings& theSettings)
{
// tell all managed views to set zlayer settings
@@ -685,7 +691,7 @@ void Visual3d_ViewManager::SetZLayerSettings (const Standard_Integer theLayerId,
//function : ZLayerSettings
//purpose :
//=======================================================================
Graphic3d_ZLayerSettings Visual3d_ViewManager::ZLayerSettings (const Standard_Integer theLayerId)
Graphic3d_ZLayerSettings Visual3d_ViewManager::ZLayerSettings (const Graphic3d_ZLayerId theLayerId)
{
if (!myLayerIds.Contains (theLayerId))
{
@@ -700,13 +706,13 @@ Graphic3d_ZLayerSettings Visual3d_ViewManager::ZLayerSettings (const Standard_In
//purpose :
//=======================================================================
Standard_Boolean Visual3d_ViewManager::AddZLayer (Standard_Integer& theLayerId)
Standard_Boolean Visual3d_ViewManager::AddZLayer (Graphic3d_ZLayerId& theLayerId)
{
try
{
OCC_CATCH_SIGNALS
theLayerId = getZLayerGenId ().Next ();
myLayerIds.Add (theLayerId);
theLayerId = myZLayerGenId.Next();
myLayerIds.Add (theLayerId);
myLayerSeq.Append (theLayerId);
}
catch (Aspect_IdentDefinitionError)
@@ -732,10 +738,14 @@ Standard_Boolean Visual3d_ViewManager::AddZLayer (Standard_Integer& theLayerId)
//purpose :
//=======================================================================
Standard_Boolean Visual3d_ViewManager::RemoveZLayer (const Standard_Integer theLayerId)
Standard_Boolean Visual3d_ViewManager::RemoveZLayer (const Graphic3d_ZLayerId theLayerId)
{
if (!myLayerIds.Contains (theLayerId) || theLayerId == 0)
if (!myLayerIds.Contains (theLayerId)
|| theLayerId < myZLayerGenId.Lower()
|| theLayerId > myZLayerGenId.Upper())
{
return Standard_False;
}
// tell all managed views to remove display layers
for(int i=1; i<=MyDefinedView.Length(); i++)
@@ -757,8 +767,8 @@ Standard_Boolean Visual3d_ViewManager::RemoveZLayer (const Standard_Integer theL
myMapOfZLayerSettings.UnBind (theLayerId);
myLayerIds.Remove (theLayerId);
getZLayerGenId ().Free (theLayerId);
myLayerIds.Remove (theLayerId);
myZLayerGenId.Free (theLayerId);
return Standard_True;
}
@@ -773,17 +783,6 @@ void Visual3d_ViewManager::GetAllZLayers (TColStd_SequenceOfInteger& theLayerSeq
theLayerSeq.Assign (myLayerSeq);
}
//=======================================================================
//function : getZLayerGenId
//purpose :
//=======================================================================
Aspect_GenId& Visual3d_ViewManager::getZLayerGenId ()
{
static Aspect_GenId aGenId (1, IntegerLast());
return aGenId;
}
//=======================================================================
//function : InstallZLayers
//purpose :
@@ -808,10 +807,19 @@ void Visual3d_ViewManager::InstallZLayers(const Handle(Visual3d_View)& theView)
// order: the new layers are always appended to the end of the list
// inside of view, while layer remove operation doesn't affect the order.
// Starting from second layer : no need to change the default z layer.
for (Standard_Integer aSeqIdx = 2; aSeqIdx <= myLayerSeq.Length (); aSeqIdx++)
for (Standard_Integer aSeqIdx = 1; aSeqIdx <= myLayerSeq.Length(); ++aSeqIdx)
{
Standard_Integer aLayerID = myLayerSeq.Value (aSeqIdx);
theView->RemoveZLayer (aLayerID);
theView->AddZLayer (aLayerID);
const Graphic3d_ZLayerId aLayerID = myLayerSeq.Value (aSeqIdx);
const Graphic3d_ZLayerSettings& aSettings = myMapOfZLayerSettings.Find (aLayerID);
if (aLayerID < myZLayerGenId.Lower()
|| aLayerID > myZLayerGenId.Upper())
{
theView->SetZLayerSettings (aLayerID, aSettings);
continue;
}
theView->RemoveZLayer (aLayerID);
theView->AddZLayer (aLayerID);
theView->SetZLayerSettings (aLayerID, aSettings);
}
}