Salome HOME
Update copyrights
[modules/shaper.git] / src / SketcherPrs / SketcherPrs_LengthDimension.h
1 // Copyright (C) 2014-2019  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef SketcherPrs_LinearDimension_H
21 #define SketcherPrs_LinearDimension_H
22
23 #include <GeomAPI_Ax3.h>
24 #include <ModelAPI_Feature.h>
25 #include <AIS_LengthDimension.hxx>
26 #include <Standard_DefineHandle.hxx>
27
28 #include <gp_Pnt.hxx>
29 #include <gp_Pln.hxx>
30 #include <string>
31
32 #include <SketcherPrs_DimensionStyleListener.h>
33
34 DEFINE_STANDARD_HANDLE(SketcherPrs_LengthDimension, AIS_LengthDimension)
35
36 /**
37 * \ingroup GUI
38 * A class for representation of linear dimension constraint.
39 * It supports SketchPlugin_ConstraintLength and SketchPlugin_ConstraintDistance features.
40 */
41 class SketcherPrs_LengthDimension : public AIS_LengthDimension
42 {
43 public:
44   /// Constructor
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);
49
50   /// Destructor
51   Standard_EXPORT ~SketcherPrs_LengthDimension();
52
53   DEFINE_STANDARD_RTTIEXT(SketcherPrs_LengthDimension, AIS_LengthDimension)
54
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);
62 protected:
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);
68
69   /// Redefinition of virtual function
70   Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
71     const Standard_Integer aMode);
72
73 private:
74   static bool readyToDisplay(ModelAPI_Feature* theConstraint,
75                              const std::shared_ptr<GeomAPI_Ax3>& thePlane,
76                              gp_Pnt& thePnt1, gp_Pnt& thePnt2);
77
78   /// Constraint feature
79   ModelAPI_Feature* myConstraint;
80
81   /// Plane of the current sketcher
82   std::shared_ptr<GeomAPI_Ax3> mySketcherPlane;
83
84   //Handle(Prs3d_DimensionAspect) myAspect;
85
86   /// Listener to update dimension visualization style
87   SketcherPrs_DimensionStyleListener* myStyleListener;
88
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
95
96   /// the structure filled by constraint
97   SketcherPrs_DimensionStyleListener::DimensionValue myValue;
98 };
99
100 #endif