Salome HOME
Merge branch 'master' into cgt/devCEA
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_Tools.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:        SketchPlugin_Tools.h
4 // Created:     07 July 2015
5 // Author:      Sergey POKHODENKO
6
7 #ifndef SKETCHPLUGIN_TOOLS_H_
8 #define SKETCHPLUGIN_TOOLS_H_
9
10 #include <GeomAPI_Pnt2d.h>
11
12 #include <ModelAPI_Feature.h>
13 #include <ModelAPI_Attribute.h>
14 #include <ModelAPI_AttributeRefAttr.h>
15 #include <GeomDataAPI_Point2D.h>
16
17 class SketchPlugin_Feature;
18
19 namespace SketchPlugin_Tools {
20
21 /// Clears text expressions for all attributes of the feature
22 void clearExpressions(FeaturePtr theFeature);
23
24 /// \return coincidence point
25 /// \param[in] theStartCoin coincidence feature
26 std::shared_ptr<GeomAPI_Pnt2d> getCoincidencePoint(const FeaturePtr theStartCoin);
27
28 /// Find all Coincident constraints referred to the feature or its attribute
29 std::set<FeaturePtr> findCoincidentConstraints(const FeaturePtr& theFeature);
30
31 /// Finds lines coincident at point
32 /// \param[in] theStartCoin coincidence feature
33 /// \param[in] theAttr attribute name
34 /// \param[out] theList list of lines
35 void findCoincidences(const FeaturePtr theStartCoin,
36                       const std::string& theAttr,
37                       std::set<FeaturePtr>& theList);
38
39 /// Find all features the point is coincident to.
40 std::set<FeaturePtr> findFeaturesCoincidentToPoint(const AttributePoint2DPtr& thePoint);
41
42 void resetAttribute(SketchPlugin_Feature* theFeature, const std::string& theId);
43
44 /// Creates coincidence or tangent constraint.
45 /// \param[in] theFeature to get selected attribute or object
46 /// \param[in] theId ID of attribute where selection is.
47 /// \param[in] theObject object for constraint
48 /// \param[in] theIsCanBeTangent if true constraint can be tangent or coincidence, depending on
49 ///                              the selection in the attribute with passed ID.
50 void createConstraint(SketchPlugin_Feature* theFeature,
51                       const std::string& theId,
52                       const AttributePtr theAttr,
53                       const ObjectPtr theObject,
54                       const bool theIsCanBeTangent);
55
56 /// Creates passing point or tangent curve basing on the given attributes are initialized.
57 /// \param[in]  theRefAttr       prefered attribute to be converted
58 /// \param[in]  theDefaultAttr   default attribute if theRefAttr is not initialized
59 /// \param[out] theTangentCurve  tangent curve if theRefAttr refers to an edge
60 /// \param[out] thePassingPoint  passing point if theRefAttr does not refer to an edge
61 void convertRefAttrToPointOrTangentCurve(const AttributeRefAttrPtr&      theRefAttr,
62                                          const AttributePtr&             theDefaultAttr,
63                                          std::shared_ptr<GeomAPI_Shape>& theTangentCurve,
64                                          std::shared_ptr<GeomAPI_Pnt2d>& thePassingPoint);
65 }; // namespace SketchPlugin_Tools
66
67 #endif // SKETCHPLUGIN_TOOLS_H_