Salome HOME
bfb4433542811aa46b0d3a5135a883228e25d10e
[modules/shaper.git] / src / SketcherPrs / SketcherPrs_LengthDimension.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        SketcherPrs_LengthDimension.h
4 // Created:     27 March 2015
5 // Author:      Vitaly SMETANNIKOV
6
7
8 #ifndef SketcherPrs_LinearDimension_H
9 #define SketcherPrs_LinearDimension_H
10
11 #include <GeomAPI_Ax3.h>
12 #include <ModelAPI_Feature.h>
13 #include <AIS_LengthDimension.hxx>
14 #include <Standard_DefineHandle.hxx>
15
16 #include <gp_Pnt.hxx>
17 #include <gp_Pln.hxx>
18 #include <string>
19
20 class SketcherPrs_DimensionStyleListener;
21
22 DEFINE_STANDARD_HANDLE(SketcherPrs_LengthDimension, AIS_LengthDimension)
23
24 /**
25 * \ingroup GUI
26 * A class for representation of linear dimension constraint.
27 * It supports SketchPlugin_ConstraintLength and SketchPlugin_ConstraintDistance features.
28 */
29 class SketcherPrs_LengthDimension : public AIS_LengthDimension
30 {
31 public:
32   /// Constructor
33   /// \param theConstraint a constraint feature
34   /// \param thePlane a coordinate plane of current sketch
35   Standard_EXPORT SketcherPrs_LengthDimension(ModelAPI_Feature* theConstraint, 
36                         const std::shared_ptr<GeomAPI_Ax3>& thePlane);
37
38   /// Destructor
39   Standard_EXPORT ~SketcherPrs_LengthDimension();
40
41   DEFINE_STANDARD_RTTI(SketcherPrs_LengthDimension)
42
43   /// Returns true if the constraint feature arguments are correcly filled to build AIS presentation
44   /// \param theConstraint a constraint feature
45   /// \param thePlane a coordinate plane of current sketch
46   /// \return boolean result value
47   static bool IsReadyToDisplay(ModelAPI_Feature* theConstraint,
48                                const std::shared_ptr<GeomAPI_Ax3>& thePlane);
49 protected:
50   /// Redefinition of virtual function
51   Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
52     const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode = 0);
53
54   /// Redefinition of virtual function
55   Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
56     const Standard_Integer aMode);
57
58 private:
59   static bool getPoints(ModelAPI_Feature* theConstraint,
60                  const std::shared_ptr<GeomAPI_Ax3>& thePlane,
61                  gp_Pnt& thePnt1, gp_Pnt& thePnt2);
62
63   /// Update variable aspect parameters (depending on viewer scale)
64   void updateArrows();
65
66   /// Constraint feature
67   ModelAPI_Feature* myConstraint;
68
69   /// Plane of the current sketcher
70   std::shared_ptr<GeomAPI_Ax3> mySketcherPlane;
71
72   //Handle(Prs3d_DimensionAspect) myAspect;
73
74   /// Listener to update dimension visualization style
75   SketcherPrs_DimensionStyleListener* myStyleListener;
76
77   double myDistance; ///< the flyout distance
78   gp_Pnt myFirstPoint; ///< the dimension first point for measured geometry
79   gp_Pnt mySecondPoint; ///< the dimension first point for measured geometry
80   gp_Pln myPlane; ///< the plane(plane of the sketch) for measured geometry
81   bool myHasParameters; ///< true if the atrribute value has used parameters
82   std::string myValue; ///< dimension value
83 };
84
85 #endif