1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
20 #ifndef SketcherPrs_LinearDimension_H
21 #define SketcherPrs_LinearDimension_H
23 #include <GeomAPI_Ax3.h>
24 #include <ModelAPI_Feature.h>
25 #include <AIS_LengthDimension.hxx>
26 #include <Standard_DefineHandle.hxx>
32 #include <SketcherPrs_DimensionStyleListener.h>
34 DEFINE_STANDARD_HANDLE(SketcherPrs_LengthDimension, AIS_LengthDimension)
38 * A class for representation of linear dimension constraint.
39 * It supports SketchPlugin_ConstraintLength and SketchPlugin_ConstraintDistance features.
41 class SketcherPrs_LengthDimension : public AIS_LengthDimension
45 /// \param theConstraint a constraint feature
46 /// \param thePlane a coordinate plane of current sketch
47 Standard_EXPORT SketcherPrs_LengthDimension(ModelAPI_Feature* theConstraint,
48 const std::shared_ptr<GeomAPI_Ax3>& thePlane);
51 Standard_EXPORT ~SketcherPrs_LengthDimension();
53 DEFINE_STANDARD_RTTIEXT(SketcherPrs_LengthDimension, AIS_LengthDimension)
55 /// Returns true if the constraint feature arguments are correcly filled
56 /// to build AIS presentation
57 /// \param theConstraint a constraint feature
58 /// \param thePlane a coordinate plane of current sketch
59 /// \return boolean result value
60 static bool IsReadyToDisplay(ModelAPI_Feature* theConstraint,
61 const std::shared_ptr<GeomAPI_Ax3>& thePlane);
63 /// Redefinition of virtual function
64 Standard_EXPORT virtual void Compute(
65 const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
66 const Handle(Prs3d_Presentation)& thePresentation,
67 const Standard_Integer theMode = 0);
69 /// Redefinition of virtual function
70 Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
71 const Standard_Integer aMode);
74 static bool readyToDisplay(ModelAPI_Feature* theConstraint,
75 const std::shared_ptr<GeomAPI_Ax3>& thePlane,
76 gp_Pnt& thePnt1, gp_Pnt& thePnt2);
78 /// Constraint feature
79 ModelAPI_Feature* myConstraint;
81 /// Plane of the current sketcher
82 std::shared_ptr<GeomAPI_Ax3> mySketcherPlane;
84 //Handle(Prs3d_DimensionAspect) myAspect;
86 /// Listener to update dimension visualization style
87 SketcherPrs_DimensionStyleListener* myStyleListener;
89 /// container of values obtained from the constraint, which are necessary
90 /// to fill the presentation
91 gp_Pnt myFirstPoint; ///< the dimension first point for measured geometry
92 gp_Pnt mySecondPoint; ///< the dimension first point for measured geometry
93 gp_Pln myPlane; ///< the plane(plane of the sketch) for measured geometry
94 double myDistance; ///< the flyout distance
96 /// the structure filled by constraint
97 SketcherPrs_DimensionStyleListener::DimensionValue myValue;