X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchPlugin%2FSketchPlugin_Trim.h;h=5791ff690c450125bc1588654bb7bd0cade6ada8;hb=86cf314c1ec34383f29d0948c894579de3372b1e;hp=9f3702f84be8e4314f8a5e99c17fbf837fe45265;hpb=9775db177bfd744b9a8e85e5fbab0f2327e11183;p=modules%2Fshaper.git diff --git a/src/SketchPlugin/SketchPlugin_Trim.h b/src/SketchPlugin/SketchPlugin_Trim.h index 9f3702f84..5791ff690 100644 --- a/src/SketchPlugin/SketchPlugin_Trim.h +++ b/src/SketchPlugin/SketchPlugin_Trim.h @@ -7,13 +7,16 @@ #ifndef SketchPlugin_Trim_H_ #define SketchPlugin_Trim_H_ +#include + #include "SketchPlugin.h" -#include #include "SketchPlugin_ConstraintBase.h" +#include class GeomDataAPI_Point2D; class ModelAPI_Feature; class ModelAPI_Result; +class ModelAPI_Object; typedef std::pair > IdToPointPair; @@ -21,7 +24,8 @@ typedef std::pair > 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 @@ -38,17 +42,31 @@ class SketchPlugin_Trim : public SketchPlugin_Feature, public GeomAPI_IPresentab } /// The value parameter for the constraint - inline static const std::string& BASE_OBJECT() + inline static const std::string& SELECTED_OBJECT() { - static const std::string MY_CONSTRAINT_BASE_OBJECT("BaseObject"); - return MY_CONSTRAINT_BASE_OBJECT; + static const std::string MY_SELECTED_OBJECT("SelectedObject"); + return MY_SELECTED_OBJECT; } /// Start 2D point of the split segment - inline static const std::string& ENTITY_POINT() + inline static const std::string& SELECTED_POINT() + { + static const std::string MY_SELECTED_POINT("SelectedPoint"); + return MY_SELECTED_POINT; + } + + /// The value parameter for the preview object + inline static const std::string& PREVIEW_OBJECT() { - static const std::string MY_ENTITY_POINT("ConstraintEntityPoint"); - return MY_ENTITY_POINT; + static const std::string MY_PREVIEW_OBJECT("PreviewObject"); + return MY_PREVIEW_OBJECT; + } + + /// Start 2D point of the split segment + inline static const std::string& PREVIEW_POINT() + { + static const std::string MY_PREVIEW_POINT("PreviewPoint"); + return MY_PREVIEW_POINT; } /// \brief Creates a new part document if needed @@ -65,10 +83,6 @@ class SketchPlugin_Trim : public SketchPlugin_Feature, public GeomAPI_IPresentab /// This is necessary to perform execute only by apply the feature SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const { return false; } - /// Called on change of any argument-attribute of this object - /// \param theID identifier of changed attribute - SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID); - /// \brief Use plugin manager for features creation SketchPlugin_Trim(); @@ -78,7 +92,28 @@ class SketchPlugin_Trim : public SketchPlugin_Feature, public GeomAPI_IPresentab /// Moves the feature : Empty SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY) {}; + /// Apply information of the message to current object. It fills selected point and object + virtual std::string processEvent(const std::shared_ptr& theMessage); + + typedef std::map, + std::pair >, + std::list > > > PointToRefsMap; + + static void fillObjectShapes(const std::shared_ptr& theObject, + const std::shared_ptr& theSketch, + std::map, std::set >& theCashedShapes, + std::map, PointToRefsMap>& theObjectToPoints); + private: + bool setCoincidenceToAttribute(const AttributePtr& theAttribute, + const std::set >& theFurtherCoincidences); + + bool replaceCoincidenceAttribute(const AttributePtr& theCoincidenceAttribute, + const std::set>& theModifiedAttributes); + + GeomShapePtr getSubShape(const std::string& theObjectAttributeId, + const std::string& thePointAttributeId); + /// Returns geom point attribute of the feature bounds. It processes line or arc. /// For circle feature, the result attributes are null /// \param theFeature a source feature @@ -108,8 +143,8 @@ private: /// by the coincident attribute /// \param theObject an investigated object /// \param theCoincidencesToBaseFeature a container of list of referenced attributes - void getCoincidencesToObject(const ObjectPtr& theObject, - std::map& theCoincidencesToBaseFeature); + //void getCoincidencesToObject(const std::shared_ptr& theObject, + // std::map& theCoincidencesToBaseFeature); /// Move constraints from attribute of base feature to attribute after modification /// \param theBaseRefAttributes container of references to the attributes of base feature @@ -120,32 +155,34 @@ private: const std::set >& theModifiedAttributes, std::set>& theFeaturesToDelete); + /// Remove references constraints from attribute of base feature refer to the given attribute + /// \param theAttribute an attribute + /// \param theModifiedAttributes modifiable container of attributes + void removeReferencesToAttribute(const AttributePtr& theAttribute, + std::map >& theBaseRefAttributes); + /// Make the base object is splitted by the point attributes - /// \param theSplitFeature a result split feature - /// \param theBeforeFeature a feature between start point and the 1st point of split feature - /// \param theAfterFeature a feature between last point of split feature and the end point + /// \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& theStartShapePoint, + /// \return new line if it was created + FeaturePtr trimLine(const std::shared_ptr& theStartShapePoint, const std::shared_ptr& theLastShapePoint, + std::map >& theBaseRefAttributes, std::set >& thePoints, std::set>& theModifiedAttributes); /// Make the base object is splitted by the point attributes - /// \param theSplitFeature a result split feature - /// \param theBeforeFeature a feature between start point and the 1st point of split feature - /// \param theAfterFeature a feature between last point of split feature and the end point /// \param thePoints a list of points where coincidences will be build - void trimArc(const std::shared_ptr& theStartShapePoint, + /// \return new line if it was created + FeaturePtr trimArc(const std::shared_ptr& theStartShapePoint, const std::shared_ptr& theLastShapePoint, + std::map >& theBaseRefAttributes, std::set >& thePoints, std::set>& theModifiedAttributes); /// Make the base object is splitted by the point attributes - /// \param theSplitFeature a result split feature - /// \param theBeforeFeature a feature between start point and the 1st point of split feature - /// \param theAfterFeature a feature between last point of split feature and the end point /// \param thePoints a list of points where coincidences will be build FeaturePtr trimCircle(const std::shared_ptr& theStartShapePoint, const std::shared_ptr& theLastShapePoint, @@ -237,23 +274,16 @@ private: const std::shared_ptr& theFeature); private: - bool useGraphicIntersection() const; - - void fillObjectShapes(const ObjectPtr& theObject); - - void findShapePoints(std::shared_ptr& aStartPoint, + void findShapePoints(const std::string& theObjectAttributeId, + const std::string& thePointAttributeId, + std::shared_ptr& aStartPoint, std::shared_ptr& aLastPoint); std::shared_ptr convertPoint(const std::shared_ptr& thePoint); private: - std::map > myCashedShapes; - - typedef std::map, - std::pair >, - std::list > > > PointToRefsMap; - - std::map myObjectToPoints; + std::map, std::set > myCashedShapes; + std::map, PointToRefsMap> myObjectToPoints; }; #endif