mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-16 10:08:36 +03:00
0028035: Visualization - V3d_Trihedron::compute() endlessly creates new graphic groups
V3d_Trihedron::compute() now reuses existing groups in the structure and resets the flag myToCompute.
This commit is contained in:
parent
e841c38c71
commit
1475265b58
src
@ -493,7 +493,8 @@ void OpenGl_View::InvalidateZLayerBoundingBox (const Graphic3d_ZLayerId theLayer
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (Standard_Integer aLayerId = Graphic3d_ZLayerId_Default; aLayerId < ZLayerMax(); ++aLayerId)
|
const Standard_Integer aLayerMax = ZLayerMax();
|
||||||
|
for (Standard_Integer aLayerId = Graphic3d_ZLayerId_Default; aLayerId < aLayerMax; ++aLayerId)
|
||||||
{
|
{
|
||||||
if (myZLayers.LayerIDs().IsBound (aLayerId))
|
if (myZLayers.LayerIDs().IsBound (aLayerId))
|
||||||
{
|
{
|
||||||
|
@ -40,6 +40,23 @@ namespace
|
|||||||
static const Standard_ShortReal THE_CYLINDER_LENGTH = 0.75f;
|
static const Standard_ShortReal THE_CYLINDER_LENGTH = 0.75f;
|
||||||
static const Standard_Integer THE_CIRCLE_SERMENTS_NB = 24;
|
static const Standard_Integer THE_CIRCLE_SERMENTS_NB = 24;
|
||||||
static const Standard_Real THE_CIRCLE_SEGMENT_ANGLE = 2.0 * M_PI / THE_CIRCLE_SERMENTS_NB;
|
static const Standard_Real THE_CIRCLE_SEGMENT_ANGLE = 2.0 * M_PI / THE_CIRCLE_SERMENTS_NB;
|
||||||
|
|
||||||
|
//! Create new or return existing group in the structure at specified position.
|
||||||
|
//! @param theStruct [in] structure holding graphic groups
|
||||||
|
//! @param theGroupIndex [in/out] group position, will be incremented as output
|
||||||
|
static Handle(Graphic3d_Group) addGroup (const Handle(Graphic3d_Structure)& theStruct,
|
||||||
|
Standard_Integer& theGroupIter)
|
||||||
|
{
|
||||||
|
const Graphic3d_SequenceOfGroup& aGroups = theStruct->Groups();
|
||||||
|
const Standard_Integer aGroupIndex = theGroupIter++;
|
||||||
|
if (!aGroups.IsEmpty()
|
||||||
|
&& aGroupIndex <= aGroups.Upper())
|
||||||
|
{
|
||||||
|
return aGroups.Value (aGroupIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
return theStruct->NewGroup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Dummy implementation of Graphic3d_Structure overriding ::Compute() method for handling Device Lost.
|
//! Dummy implementation of Graphic3d_Structure overriding ::Compute() method for handling Device Lost.
|
||||||
@ -203,6 +220,7 @@ void V3d_Trihedron::Display (const V3d_View& theView)
|
|||||||
myStructure->CStructure()->ViewAffinity = new Graphic3d_ViewAffinity();
|
myStructure->CStructure()->ViewAffinity = new Graphic3d_ViewAffinity();
|
||||||
myStructure->CStructure()->ViewAffinity->SetVisible (Standard_False);
|
myStructure->CStructure()->ViewAffinity->SetVisible (Standard_False);
|
||||||
myStructure->CStructure()->ViewAffinity->SetVisible (theView.View()->Identification(), true);
|
myStructure->CStructure()->ViewAffinity->SetVisible (theView.View()->Identification(), true);
|
||||||
|
myToCompute = Standard_True;
|
||||||
}
|
}
|
||||||
if (myToCompute)
|
if (myToCompute)
|
||||||
{
|
{
|
||||||
@ -251,6 +269,7 @@ void V3d_Trihedron::SetPosition (const Aspect_TypeOfTriedronPosition thePosition
|
|||||||
// ============================================================================
|
// ============================================================================
|
||||||
void V3d_Trihedron::compute()
|
void V3d_Trihedron::compute()
|
||||||
{
|
{
|
||||||
|
myToCompute = Standard_False;
|
||||||
myStructure->GraphicClear (Standard_False);
|
myStructure->GraphicClear (Standard_False);
|
||||||
|
|
||||||
// Create trihedron.
|
// Create trihedron.
|
||||||
@ -261,8 +280,9 @@ void V3d_Trihedron::compute()
|
|||||||
const Standard_Real aConeLength = aScale * (1.0 - THE_CYLINDER_LENGTH);
|
const Standard_Real aConeLength = aScale * (1.0 - THE_CYLINDER_LENGTH);
|
||||||
const Standard_Real aSphereRadius = aCylinderRadius * 2.0;
|
const Standard_Real aSphereRadius = aCylinderRadius * 2.0;
|
||||||
const Standard_Real aRayon = aScale / 30.0;
|
const Standard_Real aRayon = aScale / 30.0;
|
||||||
|
Standard_Integer aGroupIter = myStructure->Groups().Lower();
|
||||||
{
|
{
|
||||||
Handle(Graphic3d_Group) aSphereGroup = myStructure->NewGroup();
|
Handle(Graphic3d_Group) aSphereGroup = addGroup (myStructure, aGroupIter);
|
||||||
|
|
||||||
// Display origin.
|
// Display origin.
|
||||||
if (myIsWireframe)
|
if (myIsWireframe)
|
||||||
@ -292,7 +312,7 @@ void V3d_Trihedron::compute()
|
|||||||
const gp_Ax1 anAxes[3] = { gp::OX(), gp::OY(), gp::OZ() };
|
const gp_Ax1 anAxes[3] = { gp::OX(), gp::OY(), gp::OZ() };
|
||||||
for (Standard_Integer anIter = 0; anIter < 3; ++anIter)
|
for (Standard_Integer anIter = 0; anIter < 3; ++anIter)
|
||||||
{
|
{
|
||||||
Handle(Graphic3d_Group) anAxisGroup = myStructure->NewGroup();
|
Handle(Graphic3d_Group) anAxisGroup = addGroup (myStructure, aGroupIter);
|
||||||
if (myIsWireframe)
|
if (myIsWireframe)
|
||||||
{
|
{
|
||||||
// create a tube
|
// create a tube
|
||||||
@ -317,7 +337,7 @@ void V3d_Trihedron::compute()
|
|||||||
|
|
||||||
// Display labels.
|
// Display labels.
|
||||||
{
|
{
|
||||||
Handle(Graphic3d_Group) aLabelGroup = myStructure->NewGroup();
|
Handle(Graphic3d_Group) aLabelGroup = addGroup (myStructure, aGroupIter);
|
||||||
const TCollection_ExtendedString aLabels[3] = { "X", "Y", "Z" };
|
const TCollection_ExtendedString aLabels[3] = { "X", "Y", "Z" };
|
||||||
const gp_Pnt aPoints[3] = { gp_Pnt (aScale + 2.0 * aRayon, 0.0, -aRayon),
|
const gp_Pnt aPoints[3] = { gp_Pnt (aScale + 2.0 * aRayon, 0.0, -aRayon),
|
||||||
gp_Pnt ( aRayon, aScale + 3.0 * aRayon, 2.0 * aRayon),
|
gp_Pnt ( aRayon, aScale + 3.0 * aRayon, 2.0 * aRayon),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user