Salome HOME
Correction of Boolean crash
[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 <SketcherPrs_Tools.h>
17
18 class SketcherPrs_DimensionStyleListener;
19
20 DEFINE_STANDARD_HANDLE(SketcherPrs_LengthDimension, AIS_LengthDimension)
21
22 /**
23 * \ingroup GUI
24 * A class for representation of linear dimension constraint.
25 * It supports SketchPlugin_ConstraintLength and SketchPlugin_ConstraintDistance features.
26 */
27 class SketcherPrs_LengthDimension : public AIS_LengthDimension
28 {
29 public:
30   /// Constructor
31   /// \param theConstraint a constraint feature
32   /// \param thePlane a coordinate plane of current sketch
33   Standard_EXPORT SketcherPrs_LengthDimension(ModelAPI_Feature* theConstraint, 
34                         const std::shared_ptr<GeomAPI_Ax3>& thePlane);
35
36   /// Destructor
37   Standard_EXPORT ~SketcherPrs_LengthDimension();
38
39   DEFINE_STANDARD_RTTI(SketcherPrs_LengthDimension)
40
41   /// Returns true if the constraint feature arguments are correcly filled to build AIS presentation
42   /// \param theConstraint a constraint feature
43   /// \param thePlane a coordinate plane of current sketch
44   /// \return boolean result value
45   static bool IsReadyToDisplay(ModelAPI_Feature* theConstraint,
46                                const std::shared_ptr<GeomAPI_Ax3>& thePlane);
47 protected:
48   /// Redefinition of virtual function
49   Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
50     const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode = 0);
51
52   /// Redefinition of virtual function
53   Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
54     const Standard_Integer aMode);
55
56 private:
57   static bool getPoints(ModelAPI_Feature* theConstraint,
58                  const std::shared_ptr<GeomAPI_Ax3>& thePlane,
59                  gp_Pnt& thePnt1, gp_Pnt& thePnt2);
60
61   /// Constraint feature
62   ModelAPI_Feature* myConstraint;
63
64   /// Plane of the current sketcher
65   std::shared_ptr<GeomAPI_Ax3> myPlane;
66
67   Handle(Prs3d_DimensionAspect) myAspect;
68
69   /// Listener to update dimension visualization style
70   SketcherPrs_DimensionStyleListener* myStyleListener;
71 };
72
73 #endif