From bb88f3ff6e5305ad8cb5e49705e3e3824fb1d499 Mon Sep 17 00:00:00 2001 From: kgv Date: Fri, 25 Aug 2017 09:14:39 +0300 Subject: [PATCH] 0029049: Visualization - restore removed class DsgPrs_DatumPrs --- src/DsgPrs/DsgPrs_DatumPrs.cxx | 75 +++++++++++++++++++++++ src/DsgPrs/DsgPrs_DatumPrs.hxx | 42 +++++++++++++ src/DsgPrs/DsgPrs_XYZAxisPresentation.cxx | 17 +++-- src/DsgPrs/FILES | 2 + src/Prs3d/Prs3d_DatumAspect.hxx | 4 +- 5 files changed, 133 insertions(+), 7 deletions(-) create mode 100644 src/DsgPrs/DsgPrs_DatumPrs.cxx create mode 100644 src/DsgPrs/DsgPrs_DatumPrs.hxx diff --git a/src/DsgPrs/DsgPrs_DatumPrs.cxx b/src/DsgPrs/DsgPrs_DatumPrs.cxx new file mode 100644 index 0000000000..ee90be8687 --- /dev/null +++ b/src/DsgPrs/DsgPrs_DatumPrs.cxx @@ -0,0 +1,75 @@ +// Copyright (c) 2013-2014 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// ======================================================================= +// function : Add +// purpose : +// ======================================================================= +void DsgPrs_DatumPrs::Add (const Handle(Prs3d_Presentation)& thePresentation, + const gp_Ax2& theDatum, + const Handle(Prs3d_Drawer)& theDrawer) +{ + Handle(Prs3d_DatumAspect) aDatumAspect = theDrawer->DatumAspect(); + Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePresentation); + + gp_Ax2 anAxis (theDatum); + gp_Pnt anOrigin = anAxis.Location(); + gp_Dir aXDir = anAxis.XDirection(); + gp_Dir aYDir = anAxis.YDirection(); + gp_Dir aZDir = anAxis.Direction(); + + Standard_Real anAxisLength; + const Standard_Boolean toDrawLabels = theDrawer->DatumAspect()->ToDrawLabels(); + + Prs3d_DatumAxes anAxes = aDatumAspect->DatumAxes(); + Handle(Prs3d_ArrowAspect) anArrowAspect = aDatumAspect->ArrowAspect(); + Handle(Prs3d_TextAspect) aTextAspect = theDrawer->TextAspect(); + + if ((anAxes & Prs3d_DA_XAxis) != 0) + { + anAxisLength = aDatumAspect->Attribute (Prs3d_DA_XAxisLength); + const gp_Pnt aPoint1 (anOrigin.XYZ() + aXDir.XYZ()*anAxisLength); + DsgPrs_XYZAxisPresentation::Add (thePresentation, aDatumAspect->LineAspect(Prs3d_DP_XAxis), anArrowAspect, + aTextAspect, aXDir, anAxisLength, toDrawLabels ? "X" : "", anOrigin, aPoint1); + } + + if ((anAxes & Prs3d_DA_YAxis) != 0) + { + anAxisLength = aDatumAspect->Attribute (Prs3d_DA_YAxisLength); + const gp_Pnt aPoint2 (anOrigin.XYZ() + aYDir.XYZ()*anAxisLength); + DsgPrs_XYZAxisPresentation::Add (thePresentation, aDatumAspect->LineAspect(Prs3d_DP_YAxis), anArrowAspect, + aTextAspect, aYDir, anAxisLength, toDrawLabels ? "Y" : "", anOrigin, aPoint2); + } + + if ((anAxes & Prs3d_DA_ZAxis) != 0) + { + anAxisLength = aDatumAspect->Attribute (Prs3d_DA_ZAxisLength); + const gp_Pnt aPoint3 (anOrigin.XYZ() + aZDir.XYZ()*anAxisLength); + DsgPrs_XYZAxisPresentation::Add (thePresentation, aDatumAspect->LineAspect(Prs3d_DP_ZAxis), anArrowAspect, + aTextAspect, aZDir, anAxisLength, toDrawLabels ? "Z" : "", anOrigin, aPoint3); + } +} diff --git a/src/DsgPrs/DsgPrs_DatumPrs.hxx b/src/DsgPrs/DsgPrs_DatumPrs.hxx new file mode 100644 index 0000000000..41bbe5469d --- /dev/null +++ b/src/DsgPrs/DsgPrs_DatumPrs.hxx @@ -0,0 +1,42 @@ +// Copyright (c) 2013-2014 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef _DsgPrs_DatumPrs_H__ +#define _DsgPrs_DatumPrs_H__ + +#include +#include +#include +#include + +//! A framework for displaying an XYZ trihedron. +class DsgPrs_DatumPrs : public Prs3d_Root +{ +public: + + DEFINE_STANDARD_ALLOC + + //! Draw XYZ axes at specified location with attributes defined by the attribute manager theDrawer: + //! - Prs3d_DatumAspect defines arrow, line and lenght trihedron axis parameters, + //! - Prs3d_TextAspect defines displayed text. + //! The thihedron origin and axis directions are defined by theDatum coordinate system. + //! DsgPrs_XYZAxisPresentation framework is used to create graphical primitives for each axis. + //! Axes are marked with "X", "Y", "Z" text. + //! @param thePresentation [out] the modified presentation + //! @param theDatum [in] the source of trihedron position + //! @param theDrawer [in] the provider of display attributes + Standard_EXPORT static void Add (const Handle(Prs3d_Presentation)& thePresentation, const gp_Ax2& theDatum, + const Handle(Prs3d_Drawer)& theDrawer); + +}; +#endif diff --git a/src/DsgPrs/DsgPrs_XYZAxisPresentation.cxx b/src/DsgPrs/DsgPrs_XYZAxisPresentation.cxx index e1696578bb..d11770d5f2 100644 --- a/src/DsgPrs/DsgPrs_XYZAxisPresentation.cxx +++ b/src/DsgPrs/DsgPrs_XYZAxisPresentation.cxx @@ -50,8 +50,11 @@ void DsgPrs_XYZAxisPresentation::Add( Prs3d_Arrow::Draw (Prs3d_Root::CurrentGroup (aPresentation), aPlast,aDir, M_PI/180.*10., aVal/10.); - Graphic3d_Vertex a2(aPlast.X(),aPlast.Y(),aPlast.Z()); - Prs3d_Root::CurrentGroup(aPresentation)->Text(aText,a2,1./81.); + if (*aText != '\0') + { + Graphic3d_Vertex a2(aPlast.X(),aPlast.Y(),aPlast.Z()); + Prs3d_Root::CurrentGroup(aPresentation)->Text(aText,a2,1./81.); + } } @@ -74,9 +77,13 @@ void DsgPrs_XYZAxisPresentation::Add(const Handle(Prs3d_Presentation)& aPresenta G->AddPrimitiveArray(aPrims); G->SetPrimitivesAspect( anArrowAspect->Aspect() ); - Prs3d_Arrow::Draw (Prs3d_Root::CurrentGroup (aPresentation), aPlast, aDir, M_PI/180.*10., aVal/10.); + Prs3d_Arrow::Draw (Prs3d_Root::CurrentGroup (aPresentation), aPlast, aDir, anArrowAspect->Angle(), aVal/10.); G->SetPrimitivesAspect(aTextAspect->Aspect()); - Graphic3d_Vertex a2(aPlast.X(),aPlast.Y(),aPlast.Z()); - Prs3d_Root::CurrentGroup(aPresentation)->Text(aText,a2,1./81.); + + if (*aText != '\0') + { + Graphic3d_Vertex a2(aPlast.X(),aPlast.Y(),aPlast.Z()); + Prs3d_Root::CurrentGroup(aPresentation)->Text(aText,a2,1./81.); + } } diff --git a/src/DsgPrs/FILES b/src/DsgPrs/FILES index 9e25703aa3..b71d8cee4e 100644 --- a/src/DsgPrs/FILES +++ b/src/DsgPrs/FILES @@ -7,6 +7,8 @@ DsgPrs_Chamf2dPresentation.cxx DsgPrs_Chamf2dPresentation.hxx DsgPrs_ConcentricPresentation.cxx DsgPrs_ConcentricPresentation.hxx +DsgPrs_DatumPrs.cxx +DsgPrs_DatumPrs.hxx DsgPrs_DiameterPresentation.cxx DsgPrs_DiameterPresentation.hxx DsgPrs_EllipseRadiusPresentation.cxx diff --git a/src/Prs3d/Prs3d_DatumAspect.hxx b/src/Prs3d/Prs3d_DatumAspect.hxx index 97762554c2..76706c1278 100644 --- a/src/Prs3d/Prs3d_DatumAspect.hxx +++ b/src/Prs3d/Prs3d_DatumAspect.hxx @@ -88,10 +88,10 @@ public: Standard_EXPORT Standard_Boolean DrawDatumPart (Prs3d_DatumParts thePart) const; //! Sets the axes used in the datum aspect - void SetDrawDatumAxes (Prs3d_DatumAxes theType) { myAxes = theType; } + void SetDrawDatumAxes (Prs3d_DatumAxes theType) { myAxes = theType; } //! Returns axes used in the datum aspect - Prs3d_DatumAxes DatumAxes() const { return myAxes; } + Prs3d_DatumAxes DatumAxes() const { return myAxes; } //! Sets the attribute of the datum type void SetAttribute (Prs3d_DatumAttribute theType, const Standard_Real& theValue)