20 #ifndef SketchPlugin_Trim_H_
21 #define SketchPlugin_Trim_H_
23 #include "SketchPlugin.h"
24 #include <SketchPlugin_Tools.h>
26 #include <GeomAPI_IPresentable.h>
27 #include <ModelAPI_IReentrant.h>
28 #include <SketchPlugin_Sketch.h>
35 typedef std::pair<std::string, std::shared_ptr<GeomDataAPI_Point2D> > IdToPointPair;
46 inline static const std::string&
ID()
48 static const std::string MY_TRIM_ID(
"SketchTrim");
52 SKETCHPLUGIN_EXPORT
virtual const std::string&
getKind()
61 static const std::string MY_SELECTED_OBJECT(
"SelectedObject");
62 return MY_SELECTED_OBJECT;
68 static const std::string MY_SELECTED_POINT(
"SelectedPoint");
69 return MY_SELECTED_POINT;
75 static const std::string MY_PREVIEW_OBJECT(
"PreviewObject");
76 return MY_PREVIEW_OBJECT;
82 static const std::string MY_PREVIEW_POINT(
"PreviewPoint");
83 return MY_PREVIEW_POINT;
87 SKETCHPLUGIN_EXPORT
virtual void execute();
94 SKETCHPLUGIN_EXPORT
virtual bool isMacro()
const {
return true; }
104 SKETCHPLUGIN_EXPORT
virtual AISObjectPtr
getAISObject(AISObjectPtr thePrevious);
107 virtual std::string
processEvent(
const std::shared_ptr<Events_Message>& theMessage);
110 bool setCoincidenceToAttribute(
const AttributePtr& theAttribute,
111 const std::set<std::shared_ptr<GeomDataAPI_Point2D> >& theFurtherCoincidences,
112 std::set<std::shared_ptr<ModelAPI_Feature>>& theFeaturesToDelete);
116 bool moveTangency(
const AttributePtr& theAttribute,
const FeaturePtr& theFeature);
122 void getConstraints(std::set<std::shared_ptr<ModelAPI_Feature>>& theFeaturesToDelete,
123 std::set<FeaturePtr>& theFeaturesToUpdate);
128 void removeReferencesToAttribute(
const AttributePtr& theAttribute,
129 std::map<AttributePtr, std::list<AttributePtr> >& theBaseRefAttributes);
137 FeaturePtr trimLine(
const std::shared_ptr<GeomAPI_Pnt2d>& theStartShapePoint,
138 const std::shared_ptr<GeomAPI_Pnt2d>& theLastShapePoint,
139 std::map<AttributePtr, std::list<AttributePtr> >& theBaseRefAttributes,
140 std::set<std::shared_ptr<GeomDataAPI_Point2D> >& thePoints,
141 std::set<std::pair<AttributePtr, AttributePtr>>& theModifiedAttributes);
146 FeaturePtr trimArc(
const std::shared_ptr<GeomAPI_Pnt2d>& theStartShapePoint,
147 const std::shared_ptr<GeomAPI_Pnt2d>& theLastShapePoint,
148 std::map<AttributePtr, std::list<AttributePtr> >& theBaseRefAttributes,
149 std::set<std::shared_ptr<GeomDataAPI_Point2D> >& thePoints,
150 std::set<std::pair<AttributePtr, AttributePtr>>& theModifiedAttributes);
155 FeaturePtr trimEllipticArc(
const std::shared_ptr<GeomAPI_Pnt2d>& theStartShapePoint,
156 const std::shared_ptr<GeomAPI_Pnt2d>& theLastShapePoint,
157 std::map<AttributePtr, std::list<AttributePtr> >& theBaseRefAttributes,
158 std::set<std::shared_ptr<GeomDataAPI_Point2D> >& thePoints,
159 std::set<std::pair<AttributePtr, AttributePtr>>& theModifiedAttributes);
163 FeaturePtr trimClosed(
const std::shared_ptr<GeomAPI_Pnt2d>& theStartShapePoint,
164 const std::shared_ptr<GeomAPI_Pnt2d>& theLastShapePoint,
165 std::set<std::shared_ptr<GeomDataAPI_Point2D> >& thePoints,
166 std::set<std::pair<AttributePtr, AttributePtr>>& theModifiedAttributes);
175 void arrangePointsOnLine(
const std::shared_ptr<GeomDataAPI_Point2D>& theStartPointAttr,
176 const std::shared_ptr<GeomDataAPI_Point2D>& theEndPointAttr,
177 std::shared_ptr<GeomAPI_Pnt2d>& theFirstPoint,
178 std::shared_ptr<GeomAPI_Pnt2d>& theSecondPoint)
const;
188 void arrangePointsOnArc(
const FeaturePtr& theArc,
189 const std::shared_ptr<GeomDataAPI_Point2D>& theStartPointAttr,
190 const std::shared_ptr<GeomDataAPI_Point2D>& theEndPointAttr,
191 std::shared_ptr<GeomAPI_Pnt2d>& theFirstPoint,
192 std::shared_ptr<GeomAPI_Pnt2d>& theSecondPoint)
const;
197 void fillAttribute(
const AttributePtr& theModifiedAttribute,
198 const AttributePtr& theSourceAttribute);
203 void fillPointAttribute(
const AttributePtr& theModifiedAttribute,
204 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint);
207 void findShapePoints(
const std::string& theObjectAttributeId,
208 const std::string& thePointAttributeId,
209 std::shared_ptr<GeomAPI_Pnt>& aStartPoint,
210 std::shared_ptr<GeomAPI_Pnt>& aLastPoint);
212 std::shared_ptr<GeomAPI_Pnt2d> convertPoint(
const std::shared_ptr<GeomAPI_Pnt>& thePoint);
215 std::map<std::shared_ptr<ModelAPI_Object>, std::set<GeomShapePtr> > myCashedShapes;
216 std::map<std::shared_ptr<ModelAPI_Object>,
217 GeomAlgoAPI_ShapeTools::PointToRefsMap> myObjectToPoints;
A class which defines an interface of object which is able to create its own presentation.
Definition: GeomAPI_IPresentable.h:29
Attribute that contains 2D point coordinates.
Definition: GeomDataAPI_Point2D.h:37
Feature function that represents the particular functionality of this operation.
Definition: ModelAPI_Feature.h:39
Interface of a class which can process specific messages.
Definition: ModelAPI_IReentrant.h:35
Represents any object in the data model and in the object browser.
Definition: ModelAPI_Object.h:45
The result of a feature.
Definition: ModelAPI_Result.h:35
Feature for creation of the new feature in PartSet.
Definition: SketchPlugin_Feature.h:40
Feature for creation of a new constraint trimming object.
Definition: SketchPlugin_Trim.h:43
virtual bool isMacro() const
Reimplemented from ModelAPI_Feature::isMacro()
Definition: SketchPlugin_Trim.h:94
static const std::string & SELECTED_POINT()
Start 2D point of the split segment.
Definition: SketchPlugin_Trim.h:66
virtual const std::string & getKind()
Returns the kind of a feature.
Definition: SketchPlugin_Trim.h:52
static const std::string & ID()
Split constraint kind.
Definition: SketchPlugin_Trim.h:46
virtual std::string processEvent(const std::shared_ptr< Events_Message > &theMessage)
Apply information of the message to current object. It fills selected point and object.
Definition: SketchPlugin_Trim.cpp:510
virtual void initAttributes()
Request for initialization of data model of the feature: adding all attributes.
Definition: SketchPlugin_Trim.cpp:83
static const std::string & SELECTED_OBJECT()
The value parameter for the constraint.
Definition: SketchPlugin_Trim.h:59
virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious)
Returns the AIS preview.
Definition: SketchPlugin_Trim.cpp:647
SketchPlugin_Trim()
Use plugin manager for features creation.
Definition: SketchPlugin_Trim.cpp:79
virtual void execute()
Creates a new part document if needed.
Definition: SketchPlugin_Trim.cpp:195
static const std::string & PREVIEW_POINT()
Start 2D point of the split segment.
Definition: SketchPlugin_Trim.h:80
virtual bool isPreviewNeeded() const
Reimplemented from ModelAPI_Feature::isPreviewNeeded().
Definition: SketchPlugin_Trim.h:98
static const std::string & PREVIEW_OBJECT()
The value parameter for the preview object.
Definition: SketchPlugin_Trim.h:73