1 // Copyright (C) 2014-2019 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
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>
27 #include <SketchPlugin_Sketch.h>
33 #include <SketcherPrs_DimensionStyleListener.h>
35 DEFINE_STANDARD_HANDLE(SketcherPrs_LengthDimension, AIS_LengthDimension)
39 * A class for representation of linear dimension constraint.
40 * It supports SketchPlugin_ConstraintLength and SketchPlugin_ConstraintDistance features.
42 class SketcherPrs_LengthDimension : public AIS_LengthDimension
46 /// \param theConstraint a constraint feature
47 /// \param thePlane a coordinate plane of current sketch
48 Standard_EXPORT SketcherPrs_LengthDimension(ModelAPI_Feature* theConstraint,
49 SketchPlugin_Sketch* theSketcher);
52 Standard_EXPORT ~SketcherPrs_LengthDimension();
54 DEFINE_STANDARD_RTTIEXT(SketcherPrs_LengthDimension, AIS_LengthDimension)
56 /// Returns true if the constraint feature arguments are correcly filled
57 /// to build AIS presentation
58 /// \param theConstraint a constraint feature
59 /// \param thePlane a coordinate plane of current sketch
60 /// \return boolean result value
61 static bool IsReadyToDisplay(ModelAPI_Feature* theConstraint,
62 const std::shared_ptr<GeomAPI_Ax3>& thePlane);
64 /// Returns sketcher plane
65 Standard_EXPORT std::shared_ptr<GeomAPI_Ax3> plane() const
67 return mySketcher->coordinatePlane();
71 /// Redefinition of virtual function
72 Standard_EXPORT virtual void Compute(
73 const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
74 const Handle(Prs3d_Presentation)& thePresentation,
75 const Standard_Integer theMode = 0);
77 /// Redefinition of virtual function
78 Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
79 const Standard_Integer aMode);
82 static bool readyToDisplay(ModelAPI_Feature* theConstraint,
83 const std::shared_ptr<GeomAPI_Ax3>& thePlane,
84 gp_Pnt& thePnt1, gp_Pnt& thePnt2);
86 /// Set the direction for horizontal/vertical constraint
87 void setDirection(ModelAPI_Feature* theConstraint,
88 const std::shared_ptr<GeomAPI_Ax3>& thePlane);
90 /// Constraint feature
91 ModelAPI_Feature* myConstraint;
93 /// A current sketcher
94 SketchPlugin_Sketch* mySketcher;
96 //Handle(Prs3d_DimensionAspect) myAspect;
98 /// Listener to update dimension visualization style
99 SketcherPrs_DimensionStyleListener* myStyleListener;
101 /// container of values obtained from the constraint, which are necessary
102 /// to fill the presentation
103 gp_Pnt myFirstPoint; ///< the dimension first point for measured geometry
104 gp_Pnt mySecondPoint; ///< the dimension first point for measured geometry
105 gp_Pln myPlane; ///< the plane(plane of the sketch) for measured geometry
106 double myDistance; ///< the flyout distance
108 /// the structure filled by constraint
109 SketcherPrs_DimensionStyleListener::DimensionValue myValue;