mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0027796: Visualization - allow 3D objects with Graphic3d_TMF_2d flag
Graphic3d_TransformPers::Apply() now does not reset projection matrix for objects with Graphic3d_TMF_2d flag. Useless flag Graphic3d_TMF_2d_IsTopDown has been removed. SelectMgr_SelectableObjectTrsfPersSet now does not skip Graphic3d_TMF_2d presentations. OpenGl_Layer::BoundingBox() now takes into account Graphic3d_TMF_2d presentations for proper Z-fit. AIS_ColorScale now uses "lazy" mode for rendering labels (considering 2D persistence to be already defined within entire structure). OpenGl_Layer::updateBVH() now updates myAlwaysRenderedMap to handle dynamic transformation persistence flag change without redisplaying the object.
This commit is contained in:
@@ -762,7 +762,7 @@ void AIS_ColorScale::drawText (const Handle(Prs3d_Presentation)& thePresentation
|
||||
anAspect->Aspect()->SetTextZoomable (Standard_True);
|
||||
anAspect->Aspect()->SetTextAngle (0.0);
|
||||
anAspect->Aspect()->SetTextFontAspect (Font_FA_Regular);
|
||||
Prs3d_Text::Draw (Prs3d_Root::CurrentGroup (thePresentation), anAspect, theText,gp_Pnt (theX,theY,0.0));
|
||||
Prs3d_Text::Draw (Prs3d_Root::CurrentGroup (thePresentation), anAspect, theText, gp_Ax2 (gp_Pnt (theX, theY, 0.0), gp::DZ()), Standard_False);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@@ -290,7 +290,7 @@ void Graphic3d_CView::ReCompute (const Handle(Graphic3d_Structure)& theStruct)
|
||||
&& !theStruct->CStructure()->IsForHighlight
|
||||
&& !theStruct->CStructure()->IsInfinite)
|
||||
{
|
||||
const Standard_Integer aLayerId = theStruct->DisplayPriority();
|
||||
const Graphic3d_ZLayerId aLayerId = theStruct->GetZLayer();
|
||||
InvalidateBVHData (aLayerId);
|
||||
}
|
||||
|
||||
|
@@ -25,7 +25,6 @@ enum {
|
||||
Graphic3d_TMF_RotatePers = 0x0008,
|
||||
Graphic3d_TMF_TriedronPers = 0x0020,
|
||||
Graphic3d_TMF_2d = 0x0040,
|
||||
Graphic3d_TMF_2d_IsTopDown = 0x0041,
|
||||
Graphic3d_TMF_FullPers = Graphic3d_TMF_PanPers | Graphic3d_TMF_ZoomPers | Graphic3d_TMF_RotatePers
|
||||
};
|
||||
|
||||
|
@@ -109,6 +109,7 @@ void Graphic3d_TransformPers::Apply (const Handle(Graphic3d_Camera)& theCamera,
|
||||
const Standard_Integer theViewportWidth,
|
||||
const Standard_Integer theViewportHeight) const
|
||||
{
|
||||
(void )theViewportWidth;
|
||||
if (!Flags)
|
||||
{
|
||||
return;
|
||||
@@ -160,46 +161,41 @@ void Graphic3d_TransformPers::Apply (const Handle(Graphic3d_Camera)& theCamera,
|
||||
Graphic3d_TransformUtils::Scale (theWorldView, T(aScale), T(aScale), T(aScale));
|
||||
return;
|
||||
}
|
||||
|
||||
if (Flags & Graphic3d_TMF_2d)
|
||||
else if (Flags == Graphic3d_TMF_2d)
|
||||
{
|
||||
T aLeft = -static_cast<T> (theViewportWidth / 2);
|
||||
T aRight = static_cast<T> (theViewportWidth / 2);
|
||||
T aBottom = -static_cast<T> (theViewportHeight / 2);
|
||||
T aTop = static_cast<T> (theViewportHeight / 2);
|
||||
T aGap = static_cast<T> (Point.z());
|
||||
if (Point.x() > 0)
|
||||
{
|
||||
aLeft -= static_cast<T> (theViewportWidth / 2) - aGap;
|
||||
aRight -= static_cast<T> (theViewportWidth / 2) - aGap;
|
||||
}
|
||||
else if (Point.x() < 0)
|
||||
{
|
||||
aLeft += static_cast<T> (theViewportWidth / 2) - aGap;
|
||||
aRight += static_cast<T> (theViewportWidth / 2) - aGap;
|
||||
}
|
||||
if (Point.y() > 0)
|
||||
{
|
||||
aBottom -= static_cast<T> (theViewportHeight / 2) - aGap;
|
||||
aTop -= static_cast<T> (theViewportHeight / 2) - aGap;
|
||||
}
|
||||
else if (Point.y() < 0)
|
||||
{
|
||||
aBottom += static_cast<T> (theViewportHeight / 2) - aGap;
|
||||
aTop += static_cast<T> (theViewportHeight / 2) - aGap;
|
||||
}
|
||||
if (Flags == Graphic3d_TMF_2d_IsTopDown)
|
||||
{
|
||||
const T aTemp = aTop;
|
||||
aTop = aBottom;
|
||||
aBottom = aTemp;
|
||||
}
|
||||
const Standard_Real aFocus = theCamera->IsOrthographic()
|
||||
? theCamera->Distance()
|
||||
: (theCamera->ZFocusType() == Graphic3d_Camera::FocusType_Relative
|
||||
? Standard_Real(theCamera->ZFocus() * theCamera->Distance())
|
||||
: Standard_Real(theCamera->ZFocus()));
|
||||
|
||||
Graphic3d_TransformUtils::Ortho2D<T> (theProjection, aLeft, aRight, aBottom, aTop);
|
||||
// scale factor to pixels
|
||||
const gp_XYZ aViewDim = theCamera->ViewDimensions (aFocus);
|
||||
const Standard_Real aScale = Abs(aViewDim.Y()) / Standard_Real(theViewportHeight);
|
||||
gp_XYZ aCenter (0.0, 0.0, -aFocus);
|
||||
if (Point.x() != 0.0)
|
||||
{
|
||||
aCenter.SetX (-aViewDim.X() * 0.5 + Point.z() * aScale);
|
||||
if (Point.x() > 0.0)
|
||||
{
|
||||
aCenter.SetX (-aCenter.X());
|
||||
}
|
||||
}
|
||||
if (Point.y() != 0.0)
|
||||
{
|
||||
aCenter.SetY (-aViewDim.Y() * 0.5 + Point.z() * aScale);
|
||||
if (Point.y() > 0.0)
|
||||
{
|
||||
aCenter.SetY (-aCenter.Y());
|
||||
}
|
||||
}
|
||||
|
||||
theWorldView.InitIdentity();
|
||||
Graphic3d_TransformUtils::Translate (theWorldView, T(aCenter.X()), T(aCenter.Y()), T(aCenter.Z()));
|
||||
Graphic3d_TransformUtils::Scale (theWorldView, T(aScale), T(aScale), T(aScale));
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
||||
{
|
||||
// Compute reference point for transformation in untransformed projection space.
|
||||
NCollection_Vec4<T> aRefPoint (static_cast<T> (Point.x()),
|
||||
|
@@ -174,6 +174,8 @@ Graphic3d_BndBox4f OpenGl_Layer::BoundingBox (const Standard_Integer th
|
||||
const Standard_Integer theWindowHeight,
|
||||
const Standard_Boolean theToIncludeAuxiliary) const
|
||||
{
|
||||
updateBVH();
|
||||
|
||||
const Standard_Integer aBoxId = !theToIncludeAuxiliary ? 0 : 1;
|
||||
const Graphic3d_Mat4& aProjectionMat = theCamera->ProjectionMatrixF();
|
||||
const Graphic3d_Mat4& aWorldViewMat = theCamera->OrientationMatrixF();
|
||||
@@ -267,7 +269,7 @@ Graphic3d_BndBox4f OpenGl_Layer::BoundingBox (const Standard_Integer th
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if ((aStructure->TransformPersistence.Flags & Graphic3d_TMF_TriedronPers) == 0)
|
||||
else if ((aStructure->TransformPersistence.Flags & (Graphic3d_TMF_TriedronPers | Graphic3d_TMF_2d)) == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -459,6 +461,7 @@ void OpenGl_Layer::updateBVH() const
|
||||
|
||||
myBVHPrimitives.Clear();
|
||||
myBVHPrimitivesTrsfPers.Clear();
|
||||
myAlwaysRenderedMap.Clear();
|
||||
myIsBVHPrimitivesNeedsReset = Standard_False;
|
||||
for (Standard_Integer aPriorityIdx = 0, aNbPriorities = myArray.Length(); aPriorityIdx < aNbPriorities; ++aPriorityIdx)
|
||||
{
|
||||
@@ -467,10 +470,10 @@ void OpenGl_Layer::updateBVH() const
|
||||
const OpenGl_Structure* aStruct = aStructIter.Value();
|
||||
if (aStruct->IsAlwaysRendered())
|
||||
{
|
||||
continue;
|
||||
aStruct->MarkAsNotCulled();
|
||||
myAlwaysRenderedMap.Add (aStruct);
|
||||
}
|
||||
|
||||
if (aStruct->TransformPersistence.Flags == Graphic3d_TMF_None)
|
||||
else if (aStruct->TransformPersistence.Flags == Graphic3d_TMF_None)
|
||||
{
|
||||
myBVHPrimitives.Add (aStruct);
|
||||
}
|
||||
|
@@ -159,7 +159,7 @@ private:
|
||||
mutable OpenGl_BVHClipPrimitiveTrsfPersSet myBVHPrimitivesTrsfPers;
|
||||
|
||||
//! Indexed map of always rendered structures.
|
||||
NCollection_IndexedMap<const OpenGl_Structure*> myAlwaysRenderedMap;
|
||||
mutable NCollection_IndexedMap<const OpenGl_Structure*> myAlwaysRenderedMap;
|
||||
|
||||
//! Is needed for implementation of stochastic order of BVH traverse.
|
||||
mutable Standard_Boolean myBVHIsLeftChildQueuedFirst;
|
||||
|
@@ -137,7 +137,7 @@ const NCollection_Handle<BVH_Tree<Standard_Real, 3> >&
|
||||
|
||||
Bnd_Box aBoundingBox;
|
||||
|
||||
if (anObject->TransformPersistence().Flags && !(anObject->TransformPersistence().Flags & Graphic3d_TMF_2d))
|
||||
if (anObject->TransformPersistence().Flags != 0)
|
||||
{
|
||||
anObject->BoundingBox (aBoundingBox);
|
||||
if (!aBoundingBox.IsVoid())
|
||||
|
@@ -206,7 +206,7 @@ void StdSelect_ViewerSelector3d::DisplaySensitive (const Handle(V3d_View)& theVi
|
||||
|
||||
Handle(Graphic3d_Structure) aStruct = new Graphic3d_Structure (theView->Viewer()->StructureManager());
|
||||
|
||||
if (!anObj->TransformPersistence().Flags || (anObj->TransformPersistence().Flags & Graphic3d_TMF_2d))
|
||||
if (anObj->TransformPersistence().Flags == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@@ -3527,11 +3527,6 @@ static int VDisplay2 (Draw_Interpretor& theDI,
|
||||
toSetTrsfPers = Standard_True;
|
||||
aTrsfPersFlags = Graphic3d_TMF_2d;
|
||||
}
|
||||
else if (aNameCase == "-2dtopdown")
|
||||
{
|
||||
toSetTrsfPers = Standard_True;
|
||||
aTrsfPersFlags = Graphic3d_TMF_2d | Graphic3d_TMF_2d_IsTopDown;
|
||||
}
|
||||
else if (aNameCase == "-trsfpers"
|
||||
|| aNameCase == "-pers")
|
||||
{
|
||||
@@ -5567,7 +5562,7 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
|
||||
|
||||
theCommands.Add("vdisplay",
|
||||
"vdisplay [-noupdate|-update] [-local] [-mutable] [-neutral]"
|
||||
"\n\t\t: [-trsfPers {pan|zoom|rotate|trihedron|full|none}=none] [-trsfPersPos X Y [Z]] [-3d|-2d|-2dTopDown]"
|
||||
"\n\t\t: [-trsfPers {pan|zoom|rotate|trihedron|full|none}=none] [-trsfPersPos X Y [Z]] [-3d|-2d]"
|
||||
"\n\t\t: [-dispMode mode] [-highMode mode]"
|
||||
"\n\t\t: [-layer index] [-top|-topmost|-overlay|-underlay]"
|
||||
"\n\t\t: [-redisplay]"
|
||||
@@ -5587,7 +5582,7 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
|
||||
"\n\t\t: -selectable|-noselect controls selection of objects."
|
||||
"\n\t\t: -trsfPers sets a transform persistence flags. Flag 'full' is pan, zoom and rotate."
|
||||
"\n\t\t: -trsfPersPos sets an anchor point for transform persistence."
|
||||
"\n\t\t: -2d|-2dTopDown displays object in screen coordinates."
|
||||
"\n\t\t: -2d displays object in screen coordinates (DY looks up)."
|
||||
"\n\t\t: -dispmode sets display mode for objects."
|
||||
"\n\t\t: -highmode sets hilight mode for objects."
|
||||
"\n\t\t: -redisplay recomputes presentation of objects.",
|
||||
|
Reference in New Issue
Block a user