From: mzernova Date: Sun, 21 Jun 2020 22:40:02 +0000 (+0300) Subject: Add the ability to make the arrow in the dimension zoomable or not zoomable X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=2f47659bdd93deedf03f11b7f0758f6545a855f3;p=occt-copy.git Add the ability to make the arrow in the dimension zoomable or not zoomable bugs/vis/bug27919: test case added (cherry picked from commit 957fe01c241a87fb1a6e5f49c12ea187922d6874) (cherry picked from commit 7640d07d284ebbafc48177d2ad4e76cd9ffd8095) (cherry picked from commit 35f302fa341f3ca62d428882a760775c795f5c7c) (cherry picked from commit ba0adbfc419a3a564a638bdbf8db500bba799c17) (cherry picked from commit 43967a7bef6270292e0ef861ff3ed6049ba3f565) --- diff --git a/src/OpenGl/OpenGl_Structure.cxx b/src/OpenGl/OpenGl_Structure.cxx index 72df9594ad..d8c3c718e2 100644 --- a/src/OpenGl/OpenGl_Structure.cxx +++ b/src/OpenGl/OpenGl_Structure.cxx @@ -403,7 +403,7 @@ void OpenGl_Structure::renderGeometry (const Handle(OpenGl_Workspace)& theWorksp OpenGl_Mat4& aModelWorld = aCtx->ModelWorldState.ChangeCurrent(); aStartPnt = aTrsfPersistence->AnchorPoint(); Graphic3d_Vec4 anAnchorPoint = aModelWorld * Graphic3d_Vec4 (aStartPnt.X(), aStartPnt.Y(), aStartPnt.Z(), 1.0); - aModelWorld.InitIdentity(); + aModelWorld.SetColumn (3, Graphic3d_Vec4 (Graphic3d_Vec3 (0.0), 1.0)); aTrsfPersistence->SetAnchorPoint (gp_Pnt (anAnchorPoint.x(), anAnchorPoint.y(), anAnchorPoint.z())); } applyPersistence (aCtx, aTrsfPersistence, Standard_True); diff --git a/src/Prs3d/Prs3d_ArrowAspect.cxx b/src/Prs3d/Prs3d_ArrowAspect.cxx index 130d868900..aac00a74ef 100644 --- a/src/Prs3d/Prs3d_ArrowAspect.cxx +++ b/src/Prs3d/Prs3d_ArrowAspect.cxx @@ -26,7 +26,8 @@ IMPLEMENT_STANDARD_RTTIEXT(Prs3d_ArrowAspect, Prs3d_BasicAspect) Prs3d_ArrowAspect::Prs3d_ArrowAspect() : myArrowAspect (new Graphic3d_AspectLine3d (Quantity_Color(Quantity_NOC_WHITE), Aspect_TOL_SOLID, 1.0)), myAngle (M_PI / 180.0 * 10.0), - myLength(1.0) + myLength (1.0), + myIsZoomable (Standard_True) { // } diff --git a/src/Prs3d/Prs3d_ArrowAspect.hxx b/src/Prs3d/Prs3d_ArrowAspect.hxx index f63e59a417..0c9276f061 100644 --- a/src/Prs3d/Prs3d_ArrowAspect.hxx +++ b/src/Prs3d/Prs3d_ArrowAspect.hxx @@ -51,6 +51,12 @@ public: //! Returns the current value of the length used when drawing an arrow. Standard_Real Length() const { return myLength; } + //! Turns usage of arrow zoomable on/off + void SetZoomable (bool theIsZoomable) { myIsZoomable = theIsZoomable; } + + //! Returns TRUE when the Arrow Zoomable is on. + bool Zoomable() const { return myIsZoomable; } + void SetColor (const Quantity_Color& theColor) { myArrowAspect->SetColor (theColor); } const Handle(Graphic3d_AspectLine3d)& Aspect() const { return myArrowAspect; } @@ -65,6 +71,7 @@ protected: Handle(Graphic3d_AspectLine3d) myArrowAspect; Standard_Real myAngle; Standard_Real myLength; + Standard_Boolean myIsZoomable; }; diff --git a/src/PrsDim/PrsDim_AngleDimension.cxx b/src/PrsDim/PrsDim_AngleDimension.cxx index 41702f5268..4829f39acd 100644 --- a/src/PrsDim/PrsDim_AngleDimension.cxx +++ b/src/PrsDim/PrsDim_AngleDimension.cxx @@ -692,8 +692,14 @@ void PrsDim_AngleDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& aFirstArrowBegin = aFirstAttach; aSecondArrowBegin = aSecondAttach; - aFirstArrowEnd = aFirstAttach.Translated (-aFirstArrowVec); - aSecondArrowEnd = aSecondAttach.Translated (-aSecondArrowVec); + aFirstArrowEnd = aFirstAttach; + aSecondArrowEnd = aSecondAttach; + + if (aDimensionAspect->ArrowAspect()->Zoomable()) + { + aFirstArrowEnd.Translate (-aFirstArrowVec); + aSecondArrowEnd.Translate (-aSecondArrowVec); + } // Group1: stenciling text and the angle dimension arc Prs3d_Root::NewGroup (thePresentation); diff --git a/src/PrsDim/PrsDim_Dimension.cxx b/src/PrsDim/PrsDim_Dimension.cxx index 9589d7d062..2cbf6020f2 100644 --- a/src/PrsDim/PrsDim_Dimension.cxx +++ b/src/PrsDim/PrsDim_Dimension.cxx @@ -358,6 +358,7 @@ void PrsDim_Dimension::DrawArrow (const Handle(Prs3d_Presentation)& thePresentat Standard_Real aLength = myDrawer->DimensionAspect()->ArrowAspect()->Length(); Standard_Real anAngle = myDrawer->DimensionAspect()->ArrowAspect()->Angle(); + Standard_Boolean isZoomable = myDrawer->DimensionAspect()->ArrowAspect()->Zoomable(); if (myDrawer->DimensionAspect()->IsArrows3d()) { @@ -370,16 +371,17 @@ void PrsDim_Dimension::DrawArrow (const Handle(Prs3d_Presentation)& thePresentat } else { + gp_Pnt aLocation = isZoomable ? theLocation : gp::Origin(); gp_Pnt aLeftPoint (gp::Origin()); gp_Pnt aRightPoint (gp::Origin()); const gp_Dir& aPlane = GetPlane().Axis().Direction(); - PointsForArrow (theLocation, theDirection, aPlane, aLength, anAngle, aLeftPoint, aRightPoint); + PointsForArrow (aLocation, theDirection, aPlane, aLength, anAngle, aLeftPoint, aRightPoint); Handle(Graphic3d_ArrayOfTriangles) anArrow = new Graphic3d_ArrayOfTriangles(3); anArrow->AddVertex (aLeftPoint); - anArrow->AddVertex (theLocation); + anArrow->AddVertex (aLocation); anArrow->AddVertex (aRightPoint); // Set aspect for arrow triangles @@ -395,6 +397,10 @@ void PrsDim_Dimension::DrawArrow (const Handle(Prs3d_Presentation)& thePresentat aGroup->SetPrimitivesAspect (aShadingStyle); aGroup->AddPrimitiveArray (anArrow); + if (!isZoomable) + { + aGroup->SetTransformPersistence (new Graphic3d_TransformPers (Graphic3d_TMF_ZoomPers, theLocation)); + } } SelectionGeometry::Arrow& aSensitiveArrow = mySelectionGeom.NewArrow(); @@ -702,10 +708,16 @@ void PrsDim_Dimension::DrawLinearDimension (const Handle(Prs3d_Presentation)& th aFirstArrowBegin = aLineBegPoint; aSecondArrowBegin = aLineEndPoint; - aFirstArrowEnd = aLineBegPoint.Translated (-gp_Vec (aFirstArrowDir).Scaled (anArrowLength)); - aSecondArrowEnd = aLineEndPoint.Translated (-gp_Vec (aSecondArrowDir).Scaled (anArrowLength)); + aFirstArrowEnd = aLineBegPoint; + aSecondArrowEnd = aLineEndPoint; + + if (aDimensionAspect->ArrowAspect()->Zoomable()) + { + aFirstArrowEnd.Translate (-gp_Vec (aFirstArrowDir).Scaled (anArrowLength)); + aSecondArrowEnd.Translate (-gp_Vec (aSecondArrowDir).Scaled (anArrowLength)); + } - gp_Pnt aCenterLineBegin = isArrowsExternal + gp_Pnt aCenterLineBegin = isArrowsExternal ? aLineBegPoint : aFirstArrowEnd; gp_Pnt aCenterLineEnd = isArrowsExternal || theIsOneSide diff --git a/src/ViewerTest/ViewerTest_RelationCommands.cxx b/src/ViewerTest/ViewerTest_RelationCommands.cxx index 44b8c8cbf4..10d3128759 100644 --- a/src/ViewerTest/ViewerTest_RelationCommands.cxx +++ b/src/ViewerTest/ViewerTest_RelationCommands.cxx @@ -377,6 +377,16 @@ static int ParseDimensionParams (Standard_Integer theArgNum, if (aLocalParam == "internal") { theAspect->SetArrowOrientation (Prs3d_DAO_Internal); } if (aLocalParam == "fit") { theAspect->SetArrowOrientation (Prs3d_DAO_Fit); } } + else if (aParam.IsEqual ("-zoomablearrow")) + { + TCollection_AsciiString aValue (theArgVec[++anIt]); + if (!aValue.IsIntegerValue()) + { + Message::SendFail() << "Error: zoomable arrow value should be 0 or 1."; + return 1; + } + theAspect->ArrowAspect()->SetZoomable (Draw::Atoi (aValue.ToCString()) != 0); + } else if (aParam.IsEqual ("-arrowlength") || aParam.IsEqual ("-arlen")) { TCollection_AsciiString aValue (theArgVec[++anIt]); @@ -1916,6 +1926,7 @@ void ViewerTest::RelationCommands(Draw_Interpretor& theCommands) "[-font FontName]\n" "[-label left|right|hcenter|hfit top|bottom|vcenter|vfit]\n" "[-arrow external|internal|fit]\n" + "[-zoomablearrow 0|1]\n" "[{-arrowlength|-arlen} RealArrowLength]\n" "[{-arrowangle|-arangle} ArrowAngle(degrees)]\n" "[-plane xoy|yoz|zox]\n" @@ -1951,6 +1962,7 @@ void ViewerTest::RelationCommands(Draw_Interpretor& theCommands) "[-font FontName]\n" "[-label left|right|hcenter|hfit top|bottom|vcenter|vfit]\n" "[-arrow external|internal|fit]\n" + "[-zoomablearrow 0|1]\n" "[{-arrowlength|-arlen} RealArrowLength]\n" "[{-arrowangle|-arangle} ArrowAngle(degrees)]\n" "[-plane xoy|yoz|zox]\n" diff --git a/tests/bugs/vis/bug27919 b/tests/bugs/vis/bug27919 new file mode 100644 index 0000000000..038837c841 --- /dev/null +++ b/tests/bugs/vis/bug27919 @@ -0,0 +1,25 @@ +puts "=============" +puts "0027919: Visualization - support multiple transformation persistence groups within single presentation" +puts "=============" + +vinit +vtrihedron t1 + +vpoint p11 -25 50 0 +vpoint p12 25 50 0 +vdimension dim -length -plane xoy -shapes p11 p12 +vdimparam dim -flyout 1 -arrowlength 30 -arrow internal -label hcenter -zoomablearrow 0 + +vpoint p21 -100 0 0 +vpoint p22 0 0 0 +vpoint p23 100 0 0 +vdimension angle -angle -shapes p21 p22 p23 -arrowlength 30 -zoomablearrow 0 + +vtop +vfit +vzoom 1.5 + +if {[vreadpixel 182 119 rgb name] != "BLACK"} { puts "ERROR: the arrow of the dimension should not be zoomable" } +if {[vreadpixel 149 195 rgb name] != "BLACK"} { puts "ERROR: the arrow of the angle dimension should not be zoomable" } + +vdump $imagedir/${casename}.png