Salome HOME
Meet the coding style (line length <= 100)
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_Trim.h
index 532731b394bc95cbbb0d23c4f047560574d6a7b0..610ae1e1c7800e3405496f93ffcc4a2a085fd0ba 100644 (file)
@@ -7,9 +7,11 @@
 #ifndef SketchPlugin_Trim_H_
 #define SketchPlugin_Trim_H_
 
+#include <ModelAPI_IReentrant.h>
+
 #include "SketchPlugin.h"
-#include <SketchPlugin_Sketch.h>
 #include "SketchPlugin_ConstraintBase.h"
+#include <SketchPlugin_Sketch.h>
 
 class GeomDataAPI_Point2D;
 class ModelAPI_Feature;
@@ -22,7 +24,8 @@ typedef std::pair<std::string, std::shared_ptr<GeomDataAPI_Point2D> > IdToPointP
  *  \ingroup Plugins
  *  \brief Feature for creation of a new constraint trimming object. Entities for split:
  */
-class SketchPlugin_Trim : public SketchPlugin_Feature, public GeomAPI_IPresentable
+class SketchPlugin_Trim : public SketchPlugin_Feature, public GeomAPI_IPresentable,
+                          public ModelAPI_IReentrant
 {
  public:
   /// Split constraint kind
@@ -89,11 +92,8 @@ class SketchPlugin_Trim : public SketchPlugin_Feature, public GeomAPI_IPresentab
   /// Moves the feature : Empty
   SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY) {};
 
-  bool setCoincidenceToAttribute(const AttributePtr& theAttribute,
-            const std::set<std::shared_ptr<GeomDataAPI_Point2D> >& theFurtherCoincidences);
-
-  bool replaceCoincidenceAttribute(const AttributePtr& theCoincidenceAttribute,
-            const std::set<std::pair<AttributePtr, AttributePtr>>& theModifiedAttributes);
+  /// Apply information of the message to current object. It fills selected point and object
+  virtual std::string processEvent(const std::shared_ptr<Events_Message>& theMessage);
 
   typedef std::map<std::shared_ptr<GeomAPI_Pnt>,
                    std::pair<std::list<std::shared_ptr<GeomDataAPI_Point2D> >,
@@ -105,6 +105,12 @@ class SketchPlugin_Trim : public SketchPlugin_Feature, public GeomAPI_IPresentab
     std::map<std::shared_ptr<ModelAPI_Object>, PointToRefsMap>& theObjectToPoints);
 
 private:
+  bool setCoincidenceToAttribute(const AttributePtr& theAttribute,
+            const std::set<std::shared_ptr<GeomDataAPI_Point2D> >& theFurtherCoincidences);
+
+  bool replaceCoincidenceAttribute(const AttributePtr& theCoincidenceAttribute,
+            const std::set<std::pair<AttributePtr, AttributePtr>>& theModifiedAttributes);
+
   GeomShapePtr getSubShape(const std::string& theObjectAttributeId,
                            const std::string& thePointAttributeId);
 
@@ -120,7 +126,9 @@ private:
   /// Obtains those constraints of the feature that should be modified. output maps contain
   /// point of coincidence and attribute id to be modified after split
   /// \param theFeaturesToDelete [out] constrains that will be deleted after split
-  void getConstraints(std::set<std::shared_ptr<ModelAPI_Feature>>& theFeaturesToDelete);
+  /// \param theFeaturesToUpdate [out] constrains that will be updated after split
+  void getConstraints(std::set<std::shared_ptr<ModelAPI_Feature>>& theFeaturesToDelete,
+                      std::set<FeaturePtr>& theFeaturesToUpdate);
 
   /// Obtains references to feature point attributes and to feature,
   /// e.g. for feature line: 1st container is
@@ -155,12 +163,17 @@ private:
   void removeReferencesToAttribute(const AttributePtr& theAttribute,
                   std::map<AttributePtr, std::list<AttributePtr> >& theBaseRefAttributes);
 
+   /// Updates line length if it exist in the list
+  /// \param theFeaturesToUpdate a constraints container
+  void updateFeaturesAfterTrim(const std::set<FeaturePtr>& theFeaturesToUpdate);
+
   /// Make the base object is splitted by the point attributes
   /// \param theBaseRefAttributes container of references to the attributes of base feature
   /// \param thePoints a list of points where coincidences will be build
   /// \param theModifiedAttributes a container of attribute on base
   /// feature to attribute on new feature
-  void trimLine(const std::shared_ptr<GeomAPI_Pnt2d>& theStartShapePoint,
+  /// \return new line if it was created
+  FeaturePtr trimLine(const std::shared_ptr<GeomAPI_Pnt2d>& theStartShapePoint,
                 const std::shared_ptr<GeomAPI_Pnt2d>& theLastShapePoint,
                 std::map<AttributePtr, std::list<AttributePtr> >& theBaseRefAttributes,
                 std::set<std::shared_ptr<GeomDataAPI_Point2D> >& thePoints,
@@ -168,7 +181,8 @@ private:
 
   /// Make the base object is splitted by the point attributes
   /// \param thePoints a list of points where coincidences will be build
-  void trimArc(const std::shared_ptr<GeomAPI_Pnt2d>& theStartShapePoint,
+  /// \return new line if it was created
+  FeaturePtr trimArc(const std::shared_ptr<GeomAPI_Pnt2d>& theStartShapePoint,
                const std::shared_ptr<GeomAPI_Pnt2d>& theLastShapePoint,
                std::map<AttributePtr, std::list<AttributePtr> >& theBaseRefAttributes,
                std::set<std::shared_ptr<GeomDataAPI_Point2D> >& thePoints,