1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +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:
kgv
2016-08-20 19:37:56 +03:00
committed by bugmaster
parent 0766573201
commit 150ed3d5ef
11 changed files with 151 additions and 95 deletions

View File

@@ -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);
}

View File

@@ -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
};

View File

@@ -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()),