1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 // File: SketchPlugin_Tools.h
4 // Created: 07 July 2015
5 // Author: Sergey POKHODENKO
7 #ifndef SKETCHPLUGIN_TOOLS_H_
8 #define SKETCHPLUGIN_TOOLS_H_
10 #include <GeomAPI_Pnt2d.h>
12 #include <ModelAPI_Feature.h>
13 #include <ModelAPI_Attribute.h>
14 #include <ModelAPI_AttributeRefAttr.h>
15 #include <GeomDataAPI_Point2D.h>
17 class SketchPlugin_Feature;
19 namespace SketchPlugin_Tools {
21 /// Clears text expressions for all attributes of the feature
22 void clearExpressions(FeaturePtr theFeature);
24 /// \return coincidence point
25 /// \param[in] theStartCoin coincidence feature
26 std::shared_ptr<GeomAPI_Pnt2d> getCoincidencePoint(const FeaturePtr theStartCoin);
28 /// Find all Coincident constraints referred to the feature or its attribute
29 std::set<FeaturePtr> findCoincidentConstraints(const FeaturePtr& theFeature);
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);
39 /// Find all features the point is coincident to.
40 std::set<FeaturePtr> findFeaturesCoincidentToPoint(const AttributePoint2DPtr& thePoint);
42 /// Find all points the given point is coincident to.
43 std::set<AttributePoint2DPtr> findPointsCoincidentToPoint(const AttributePoint2DPtr& thePoint);
45 void resetAttribute(SketchPlugin_Feature* theFeature, const std::string& theId);
47 /// Creates coincidence or tangent constraint.
48 /// \param[in] theFeature to get selected attribute or object
49 /// \param[in] theId ID of attribute where selection is.
50 /// \param[in] theObject object for constraint
51 /// \param[in] theIsCanBeTangent if true constraint can be tangent or coincidence, depending on
52 /// the selection in the attribute with passed ID.
53 void createConstraint(SketchPlugin_Feature* theFeature,
54 const std::string& theId,
55 const AttributePtr theAttr,
56 const ObjectPtr theObject,
57 const bool theIsCanBeTangent);
59 /// Creates passing point or tangent curve basing on the given attributes are initialized.
60 /// \param[in] theRefAttr prefered attribute to be converted
61 /// \param[in] theDefaultAttr default attribute if theRefAttr is not initialized
62 /// \param[out] theTangentCurve tangent curve if theRefAttr refers to an edge
63 /// \param[out] thePassingPoint passing point if theRefAttr does not refer to an edge
64 void convertRefAttrToPointOrTangentCurve(const AttributeRefAttrPtr& theRefAttr,
65 const AttributePtr& theDefaultAttr,
66 std::shared_ptr<GeomAPI_Shape>& theTangentCurve,
67 std::shared_ptr<GeomAPI_Pnt2d>& thePassingPoint);
68 }; // namespace SketchPlugin_Tools
70 #endif // SKETCHPLUGIN_TOOLS_H_