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);
}
//=======================================================================
&& !theStruct->CStructure()->IsForHighlight
&& !theStruct->CStructure()->IsInfinite)
{
- const Standard_Integer aLayerId = theStruct->DisplayPriority();
+ const Graphic3d_ZLayerId aLayerId = theStruct->GetZLayer();
InvalidateBVHData (aLayerId);
}
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
};
const Standard_Integer theViewportWidth,
const Standard_Integer theViewportHeight) const
{
+ (void )theViewportWidth;
if (!Flags)
{
return;
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)
+ const Standard_Real aFocus = theCamera->IsOrthographic()
+ ? theCamera->Distance()
+ : (theCamera->ZFocusType() == Graphic3d_Camera::FocusType_Relative
+ ? Standard_Real(theCamera->ZFocus() * theCamera->Distance())
+ : Standard_Real(theCamera->ZFocus()));
+
+ // 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)
{
- aBottom += static_cast<T> (theViewportHeight / 2) - aGap;
- aTop += static_cast<T> (theViewportHeight / 2) - aGap;
+ aCenter.SetX (-aViewDim.X() * 0.5 + Point.z() * aScale);
+ if (Point.x() > 0.0)
+ {
+ aCenter.SetX (-aCenter.X());
+ }
}
- if (Flags == Graphic3d_TMF_2d_IsTopDown)
+ if (Point.y() != 0.0)
{
- const T aTemp = aTop;
- aTop = aBottom;
- aBottom = aTemp;
+ aCenter.SetY (-aViewDim.Y() * 0.5 + Point.z() * aScale);
+ if (Point.y() > 0.0)
+ {
+ aCenter.SetY (-aCenter.Y());
+ }
}
- Graphic3d_TransformUtils::Ortho2D<T> (theProjection, aLeft, aRight, aBottom, aTop);
-
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()),
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();
{
continue;
}
- else if ((aStructure->TransformPersistence.Flags & Graphic3d_TMF_TriedronPers) == 0)
+ else if ((aStructure->TransformPersistence.Flags & (Graphic3d_TMF_TriedronPers | Graphic3d_TMF_2d)) == 0)
{
continue;
}
myBVHPrimitives.Clear();
myBVHPrimitivesTrsfPers.Clear();
+ myAlwaysRenderedMap.Clear();
myIsBVHPrimitivesNeedsReset = Standard_False;
for (Standard_Integer aPriorityIdx = 0, aNbPriorities = myArray.Length(); aPriorityIdx < aNbPriorities; ++aPriorityIdx)
{
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);
}
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;
Bnd_Box aBoundingBox;
- if (anObject->TransformPersistence().Flags && !(anObject->TransformPersistence().Flags & Graphic3d_TMF_2d))
+ if (anObject->TransformPersistence().Flags != 0)
{
anObject->BoundingBox (aBoundingBox);
if (!aBoundingBox.IsVoid())
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;
}
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")
{
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]"
"\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.",
+++ /dev/null
-puts "============"
-puts "OCC25783_1"
-puts "Draw 2d objects in top-down mode."
-puts "============"
-puts ""
-
-vfont add [locate_data_file DejaVuSans.ttf] SansFont
-
-vinit View1
-vclear
-vaxo
-
-# display polyline in overlay
-text2brep tcc "Center" -font SansFont -height 30
-vdisplay tcc -2dTopDown -osd
-polyline lcc -50 -50 0 -50 50 0 50 50 0 50 0 0 0 -50 0 -50 -50 0
-vdisplay lcc -2dTopDown -overlay
-
-# display polyline in overlay in the top left corner of the view
-text2brep ttl "Top-Left" -font SansFont -height 30
-vdisplay ttl -2dTopDown -trsfPersPos -1 -1 5 -osd
-polyline ltl 0 0 0 0 100 0 100 100 0 100 50 0 50 0 0 0 0 0
-vdisplay ltl -2dTopDown -trsfPersPos -1 -1 3 -overlay
-
-# display polyline in overlay in the bottom left corner of the view
-text2brep tbl "Bottom-Left" -font SansFont -height 30 -pos -27 0 0
-vdisplay tbl -2dTopDown -trsfPersPos -1 1 30 -osd
-polyline lbl 0 -100 0 0 0 0 100 0 0 100 -50 0 50 -100 0 0 -100 0
-vdisplay lbl -2dTopDown -trsfPersPos -1 1 3 -overlay
-
-# display polyline in overlay in the bottom right corner of the view
-text2brep tbr Bottom-Right -font SansFont -height 30 -pos -145 0 0
-vdisplay tbr -2dTopDown -trsfPersPos 1 1 30 -osd
-polyline lbr -100 -100 0 -100 0 0 0 0 0 0 -50 0 -50 -100 0 -100 -100 0
-vdisplay lbr -2dTopDown -trsfPersPos 1 1 3 -overlay
-
-# display polyline in overlay in the top right corner of the view
-text2brep ttr "Top-Right" -font SansFont -height 30 -pos -130 0 0
-vdisplay ttr -2dTopDown -trsfPersPos 1 -1 5 -osd
-polyline ltr -100 0 0 -100 100 0 0 100 0 0 50 0 -50 0 0 -100 0 0
-vdisplay ltr -2dTopDown -trsfPersPos 1 -1 3 -overlay
-
-vdump ${imagedir}/${casename}.png
--- /dev/null
+puts "========"
+puts "Allow 3D objects with Graphic3d_TMF_2d flag"
+puts "========"
+
+pload MODELING VISUALIZATION
+
+# four rectangles
+box b4 -175 -125 -5 350 250 1
+box b3 -150 -100 -4 300 200 1
+box b2 -125 -75 -3 250 150 1
+box b1 -100 -50 -2 200 100 1
+
+# text label
+text2brep t "texT | Text\ntexT | Text" -height 50
+set aTB [bounding t]
+set aTX [expr [lindex $aTB 3] * -0.5]
+set aTY [expr [lindex $aTB 4] * -0.5]
+ttranslate t $aTX $aTY 1
+
+# sphere
+psphere s 50
+
+# clock marks
+set aPnts {}
+for {set i 1} {$i <= 1} {incr i} { vertex p1_$i [expr 75+5*$i] 86 1; lappend aPnts p1_$i }
+compound {*}$aPnts p1
+
+set aPnts {}
+for {set i 1} {$i <= 2} {incr i} { vertex p2_$i [expr 130+5*$i] 86 1; lappend aPnts p2_$i }
+compound {*}$aPnts p2
+
+set aPnts {}
+for {set i 1} {$i <= 3} {incr i} { vertex p3_$i [expr 130+5*$i] 0 1; lappend aPnts p3_$i }
+compound {*}$aPnts p3
+
+set aPnts {}
+for {set i 1} {$i <= 4} {incr i} { vertex p4_$i [expr 120+5*$i] -85 1; lappend aPnts p4_$i }
+compound {*}$aPnts p4
+
+set aPnts {}
+for {set i 1} {$i <= 5} {incr i} { vertex p5_$i [expr 55+5*$i] -85 1; lappend aPnts p5_$i }
+compound {*}$aPnts p5
+
+set aPnts {}
+for {set i 1} {$i <= 6} {incr i} { vertex p6_$i [expr -18+5*$i] -85 1; lappend aPnts p6_$i }
+compound {*}$aPnts p6
+
+set aPnts {}
+for {set i 1} {$i <= 7} {incr i} { vertex p7_$i [expr -85+5*$i] -85 1; lappend aPnts p7_$i }
+compound {*}$aPnts p7
+
+set aPnts {}
+for {set i 1} {$i <= 8} {incr i} { vertex p8_$i [expr -160+5*$i] -85 1; lappend aPnts p8_$i }
+compound {*}$aPnts p8
+
+set aPnts {}
+for {set i 1} {$i <= 9} {incr i} { vertex p9_$i [expr -160+5*$i] 0 1; lappend aPnts p9_$i }
+compound {*}$aPnts p9
+
+set aPnts {}
+for {set i 1} {$i <=10} {incr i} { vertex p10_$i [expr -165+5*$i] 86 1; lappend aPnts p10_$i }
+compound {*}$aPnts p10
+
+set aPnts {}
+for {set i 1} {$i <=11} {incr i} { vertex p11_$i [expr -100+5*$i] 86 1; lappend aPnts p11_$i }
+compound {*}$aPnts p11
+
+set aPnts {}
+for {set i 1} {$i <=12} {incr i} { vertex p12_$i [expr -30+5*$i] 86 1; lappend aPnts p12_$i }
+compound {*}$aPnts p12
+
+# entire list of 2d presentations
+set aList {b1 b2 b3 b4 s t p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12}
+
+vclear
+vinit View1
+vdisplay -dispMode 1 -highMode 1 -2d -trsfPersPos 0 0 {*}$aList
+vsetmaterial b1 b2 b3 b4 t PLASTIC
+vsetcolor b1 RED
+vsetcolor b2 GREEN
+vsetcolor b3 BLUE1
+vsetcolor b4 MAGENTA1
+vsetcolor t GOLD
+vsetlocation s 0 0 -1
+
+box bb 1000 1000 1000
+vdisplay -dispMode 0 bb
+vfit
+vdump $imagedir/${casename}_center.png
+
+vdisplay -dispMode 1 -highMode 1 -2d -trsfPersPos -1 1 {*}$aList
+vdump $imagedir/${casename}_tl.png
+
+vdisplay -dispMode 1 -highMode 1 -2d -trsfPersPos 1 1 {*}$aList
+vdump $imagedir/${casename}_tr.png
+
+vdisplay -dispMode 1 -highMode 1 -2d -trsfPersPos 1 -1 {*}$aList
+vdump $imagedir/${casename}_br.png
+
+vdisplay -dispMode 1 -highMode 1 -2d -trsfPersPos -1 -1 {*}$aList
+vdump $imagedir/${casename}_bl.png
+
+vmoveto 110 385
+vselect 110 385
+set aColor [vreadpixel 110 385 rgb name]
+if { $aColor != "WHITE" } { puts "Error: wrong object is highlighted" }