Salome HOME
7749848e4dd1704fe948d62aed4260a8e5d33c21
[modules/shaper.git] / src / SketcherPrs / SketcherPrs_Angle.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        SketcherPrs_Angle.h
4 // Created:     20 August 2015
5 // Author:      Vitaly SMETANNIKOV
6
7
8 #ifndef SketcherPrs_Angle_H
9 #define SketcherPrs_Angle_H
10
11 #include <GeomAPI_Ax3.h>
12 #include <ModelAPI_Feature.h>
13
14 #include <AIS_AngleDimension.hxx>
15 #include <Standard_DefineHandle.hxx>
16
17 #include <SketcherPrs_DimensionStyleListener.h>
18
19 DEFINE_STANDARD_HANDLE(SketcherPrs_Angle, AIS_AngleDimension)
20
21 /**
22 * \ingroup GUI
23 * A class for representation of angle constraint
24 */
25 class SketcherPrs_Angle : public AIS_AngleDimension
26 {
27 public:
28   /// Constructor
29   /// \param theConstraint a constraint feature
30   /// \param thePlane a coordinate plane of current sketch
31   Standard_EXPORT SketcherPrs_Angle(ModelAPI_Feature* theConstraint, 
32                         const std::shared_ptr<GeomAPI_Ax3>& thePlane);
33
34   /// Destructor
35   Standard_EXPORT ~SketcherPrs_Angle();
36
37   DEFINE_STANDARD_RTTI(SketcherPrs_Angle)
38
39   /// Returns true if the constraint feature arguments are correcly filled to build AIS presentation
40   /// \param theConstraint a constraint feature
41   /// \param thePlane a coordinate plane of current sketch
42   /// \return boolean result value
43   static bool IsReadyToDisplay(ModelAPI_Feature* theConstraint,
44                                const std::shared_ptr<GeomAPI_Ax3>& thePlane);
45 protected:
46   /// Redefinition of virtual function
47   Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
48     const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode = 0);
49
50   /// Redefinition of virtual function
51   Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
52     const Standard_Integer aMode);
53
54   /// Checks is the angle plane has inverted direction of normal to the plane of current sketcher
55   /// Returns true if crossed product is negative.
56   /// \return bolean value
57   bool isAnglePlaneReversedToSketchPlane();
58
59   /// Calculates a distance between center of the angle presentation and the value of flyout point
60   /// attribute. It should be used after setting measured geometry for the angle presentation as
61   /// it uses calculated center/first/second point coordinates
62   /// \return real value
63   double calculateDistanceToFlyoutPoint();
64
65   static bool readyToDisplay(ModelAPI_Feature* theConstraint,
66                              const std::shared_ptr<GeomAPI_Ax3>& thePlane,
67                              gp_Pnt& theFirstPoint, gp_Pnt& theSecondPoint,
68                              gp_Pnt& theCenterPoint);
69
70 private:
71   /// Constraint feature
72   ModelAPI_Feature* myConstraint;
73
74   /// Plane of the current sketcher
75   std::shared_ptr<GeomAPI_Ax3> mySketcherPlane;
76
77   Handle(Prs3d_DimensionAspect) myAspect;
78
79   /// Listener to update dimension visualization style
80   SketcherPrs_DimensionStyleListener* myStyleListener;
81
82   /// container of values obtained from the constraint, which are necessary to fill the presentation
83   gp_Pnt myFirstPoint; ///< the dimension first point for measured geometry
84   gp_Pnt mySecondPoint; ///< the dimension second point for measured geometry
85   gp_Pnt myCenterPoint; ///< the dimension center point for measured geometry
86   gp_Pnt myFlyOutPoint;  ///< the dimension fly out point for measured geometry
87
88   SketcherPrs_DimensionStyleListener::DimensionValue myValue; /// the structure filled by constraint
89 };
90
91
92 #endif