Salome HOME
Fix for the issue #2415 : generation of wide naming structure for the Compound feature
[modules/shaper.git] / src / SketcherPrs / SketcherPrs_LengthDimension.h
1 // Copyright (C) 2014-2017  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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef SketcherPrs_LinearDimension_H
22 #define SketcherPrs_LinearDimension_H
23
24 #include <GeomAPI_Ax3.h>
25 #include <ModelAPI_Feature.h>
26 #include <AIS_LengthDimension.hxx>
27 #include <Standard_DefineHandle.hxx>
28
29 #include <gp_Pnt.hxx>
30 #include <gp_Pln.hxx>
31 #include <string>
32
33 #include <SketcherPrs_DimensionStyleListener.h>
34
35 DEFINE_STANDARD_HANDLE(SketcherPrs_LengthDimension, AIS_LengthDimension)
36
37 /**
38 * \ingroup GUI
39 * A class for representation of linear dimension constraint.
40 * It supports SketchPlugin_ConstraintLength and SketchPlugin_ConstraintDistance features.
41 */
42 class SketcherPrs_LengthDimension : public AIS_LengthDimension
43 {
44 public:
45   /// Constructor
46   /// \param theConstraint a constraint feature
47   /// \param thePlane a coordinate plane of current sketch
48   Standard_EXPORT SketcherPrs_LengthDimension(ModelAPI_Feature* theConstraint,
49                         const std::shared_ptr<GeomAPI_Ax3>& thePlane);
50
51   /// Destructor
52   Standard_EXPORT ~SketcherPrs_LengthDimension();
53
54   DEFINE_STANDARD_RTTIEXT(SketcherPrs_LengthDimension, AIS_LengthDimension)
55
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);
63 protected:
64   /// Redefinition of virtual function
65   Standard_EXPORT virtual void Compute(
66     const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
67     const Handle(Prs3d_Presentation)& thePresentation,
68     const Standard_Integer theMode = 0);
69
70   /// Redefinition of virtual function
71   Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
72     const Standard_Integer aMode);
73
74 private:
75   static bool readyToDisplay(ModelAPI_Feature* theConstraint,
76                              const std::shared_ptr<GeomAPI_Ax3>& thePlane,
77                              gp_Pnt& thePnt1, gp_Pnt& thePnt2);
78
79   /// Constraint feature
80   ModelAPI_Feature* myConstraint;
81
82   /// Plane of the current sketcher
83   std::shared_ptr<GeomAPI_Ax3> mySketcherPlane;
84
85   //Handle(Prs3d_DimensionAspect) myAspect;
86
87   /// Listener to update dimension visualization style
88   SketcherPrs_DimensionStyleListener* myStyleListener;
89
90   /// container of values obtained from the constraint, which are necessary
91   /// to fill the presentation
92   gp_Pnt myFirstPoint; ///< the dimension first point for measured geometry
93   gp_Pnt mySecondPoint; ///< the dimension first point for measured geometry
94   gp_Pln myPlane; ///< the plane(plane of the sketch) for measured geometry
95   double myDistance; ///< the flyout distance
96
97   /// the structure filled by constraint
98   SketcherPrs_DimensionStyleListener::DimensionValue myValue;
99 };
100
101 #endif