1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #ifndef SKETCHPLUGIN_TOOLS_H_
22 #define SKETCHPLUGIN_TOOLS_H_
24 #include <GeomAPI_Pnt2d.h>
26 #include <ModelAPI_Feature.h>
27 #include <ModelAPI_Attribute.h>
28 #include <ModelAPI_AttributeRefAttr.h>
29 #include <GeomDataAPI_Point2D.h>
31 class SketchPlugin_Feature;
33 namespace SketchPlugin_Tools {
35 /// Clears text expressions for all attributes of the feature
36 void clearExpressions(FeaturePtr theFeature);
38 /// \return coincidence point
39 /// \param[in] theStartCoin coincidence feature
40 std::shared_ptr<GeomAPI_Pnt2d> getCoincidencePoint(const FeaturePtr theStartCoin);
42 /// Find all Coincident constraints referred to the feature or its attribute
43 std::set<FeaturePtr> findCoincidentConstraints(const FeaturePtr& theFeature);
45 /// Finds lines coincident at point
46 /// \param[in] theStartCoin coincidence feature
47 /// \param[in] theAttr attribute name
48 /// \param[out] theList list of lines
49 /// \param[in] theIsAttrOnly if true includes only coincidences with attributes.
50 void findCoincidences(const FeaturePtr theStartCoin,
51 const std::string& theAttr,
52 std::set<FeaturePtr>& theList,
53 const bool theIsAttrOnly = false);
55 /// Find all features the point is coincident to.
56 std::set<FeaturePtr> findFeaturesCoincidentToPoint(const AttributePoint2DPtr& thePoint);
58 /// Find all points the given point is coincident to.
59 std::set<AttributePoint2DPtr> findPointsCoincidentToPoint(const AttributePoint2DPtr& thePoint);
61 void resetAttribute(SketchPlugin_Feature* theFeature, const std::string& theId);
63 /// Creates coincidence or tangent constraint.
64 /// \param[in] theFeature to get selected attribute or object
65 /// \param[in] theId ID of attribute where selection is.
66 /// \param[in] theObject object for constraint
67 /// \param[in] theIsCanBeTangent if true constraint can be tangent or coincidence, depending on
68 /// the selection in the attribute with passed ID.
69 void createConstraint(SketchPlugin_Feature* theFeature,
70 const std::string& theId,
71 const AttributePtr theAttr,
72 const ObjectPtr theObject,
73 const bool theIsCanBeTangent);
75 /// Creates passing point or tangent curve basing on the given attributes are initialized.
76 /// \param[in] theRefAttr prefered attribute to be converted
77 /// \param[in] theDefaultAttr default attribute if theRefAttr is not initialized
78 /// \param[out] theTangentCurve tangent curve if theRefAttr refers to an edge
79 /// \param[out] thePassingPoint passing point if theRefAttr does not refer to an edge
80 void convertRefAttrToPointOrTangentCurve(const AttributeRefAttrPtr& theRefAttr,
81 const AttributePtr& theDefaultAttr,
82 std::shared_ptr<GeomAPI_Shape>& theTangentCurve,
83 std::shared_ptr<GeomAPI_Pnt2d>& thePassingPoint);
84 }; // namespace SketchPlugin_Tools
86 #endif // SKETCHPLUGIN_TOOLS_H_