Salome HOME
Merge branch 'master' into cgt/devCEA
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_Tools.h
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef SKETCHPLUGIN_TOOLS_H_
22 #define SKETCHPLUGIN_TOOLS_H_
23
24 #include <GeomAPI_Pnt2d.h>
25
26 #include <ModelAPI_Feature.h>
27 #include <ModelAPI_Attribute.h>
28 #include <ModelAPI_AttributeRefAttr.h>
29 #include <GeomDataAPI_Point2D.h>
30
31 class SketchPlugin_Feature;
32
33 namespace SketchPlugin_Tools {
34
35 /// Clears text expressions for all attributes of the feature
36 void clearExpressions(FeaturePtr theFeature);
37
38 /// \return coincidence point
39 /// \param[in] theStartCoin coincidence feature
40 std::shared_ptr<GeomAPI_Pnt2d> getCoincidencePoint(const FeaturePtr theStartCoin);
41
42 /// Find all Coincident constraints referred to the feature or its attribute
43 std::set<FeaturePtr> findCoincidentConstraints(const FeaturePtr& theFeature);
44
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);
54
55 /// Find all features the point is coincident to.
56 std::set<FeaturePtr> findFeaturesCoincidentToPoint(const AttributePoint2DPtr& thePoint);
57
58 /// Find all points the given point is coincident to.
59 std::set<AttributePoint2DPtr> findPointsCoincidentToPoint(const AttributePoint2DPtr& thePoint);
60
61 void resetAttribute(SketchPlugin_Feature* theFeature, const std::string& theId);
62
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);
74
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
85
86 #endif // SKETCHPLUGIN_TOOLS_H_