Salome HOME
#1404 Random crash with Shaper: AIS presentations: avoid IsReadyToDisplay calling...
[modules/shaper.git] / src / SketcherPrs / SketcherPrs_Radius.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        SketcherPrs_Radius.h
4 // Created:     26 March 2015
5 // Author:      Vitaly SMETANNIKOV
6
7
8 #ifndef SketcherPrs_Radius_H
9 #define SketcherPrs_Radius_H
10
11 #include <GeomAPI_Ax3.h>
12 #include <ModelAPI_Feature.h>
13
14 #include <AIS_RadiusDimension.hxx>
15 #include <Standard_DefineHandle.hxx>
16
17 class SketcherPrs_DimensionStyleListener;
18
19 DEFINE_STANDARD_HANDLE(SketcherPrs_Radius, AIS_RadiusDimension)
20
21 /**
22 * \ingroup GUI
23 * A class for representation of radius constraint
24 */
25 class SketcherPrs_Radius : public AIS_RadiusDimension
26 {
27 public:
28   /// Constructor
29   /// \param theConstraint a constraint feature
30   /// \param thePlane a coordinate plane of current sketch
31   Standard_EXPORT SketcherPrs_Radius(ModelAPI_Feature* theConstraint, 
32                         const std::shared_ptr<GeomAPI_Ax3>& thePlane);
33
34   /// Destructor
35   Standard_EXPORT ~SketcherPrs_Radius();
36
37   DEFINE_STANDARD_RTTI(SketcherPrs_Radius)
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 private:
46   /// Fills the constraint parameters by constraint and plane
47   /// \param theConstraint a constraint feature
48   /// \param thePlane a coordinate plane of current sketch
49   /// \param theCircle a circle build on the constraint values
50   /// \param thePoint an anchor point to show text value
51   /// \param theRadius a circle custom radius value to be visualized
52   /// \return boolean result value
53   static bool readyToDisplay(ModelAPI_Feature* theConstraint,
54                              const std::shared_ptr<GeomAPI_Ax3>& thePlane,
55                              gp_Circ& theCircle, gp_Pnt& theAnchorPoint,
56                              double& theRadius);
57 protected:
58   /// Redefinition of virtual function
59   Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
60     const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode = 0);
61
62   /// Redefinition of virtual function
63   Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
64     const Standard_Integer aMode);
65
66 private:
67   /// Constraint feature
68   ModelAPI_Feature* myConstraint;
69
70   /// Plane of the current sketcher
71   std::shared_ptr<GeomAPI_Ax3> mySketcherPlane;
72
73   /// Listener to update dimension visualization style
74   SketcherPrs_DimensionStyleListener* myStyleListener;
75
76   /// container of values obtained from the constraint, which are necessary to fill the presentation
77   double myRadius; ///< the radius custom value
78   gp_Circ myCircle; ///< the radius circle
79   gp_Pnt myAnchorPoint; ///< an ancor for the radius value visualization
80
81   bool myHasParameters; ///< true if the atrribute value has used parameters
82   std::string myValue; ///< dimension value
83 };
84
85 #endif