From: rraphael Date: Wed, 20 Jan 2021 11:12:21 +0000 (+0100) Subject: add icons. Rectangle: link start/center and end points to picked points X-Git-Tag: V9_7_0a1~13^2~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0eeaed469a5b7b41148756c3c27c5da6490d1945;p=modules%2Fshaper.git add icons. Rectangle: link start/center and end points to picked points --- diff --git a/src/CollectionPlugin/doc/images/group_shape.png b/src/CollectionPlugin/doc/images/group_shape.png new file mode 100644 index 000000000..73b474f8b Binary files /dev/null and b/src/CollectionPlugin/doc/images/group_shape.png differ diff --git a/src/CollectionPlugin/doc/images/group_shape_property_panel.png b/src/CollectionPlugin/doc/images/group_shape_property_panel.png new file mode 100644 index 000000000..1355fc080 Binary files /dev/null and b/src/CollectionPlugin/doc/images/group_shape_property_panel.png differ diff --git a/src/CollectionPlugin/icons/group_shape.png b/src/CollectionPlugin/icons/group_shape.png new file mode 100644 index 000000000..73b474f8b Binary files /dev/null and b/src/CollectionPlugin/icons/group_shape.png differ diff --git a/src/CollectionPlugin/icons/svg/group_shape.svg b/src/CollectionPlugin/icons/svg/group_shape.svg new file mode 100644 index 000000000..640ad13fa --- /dev/null +++ b/src/CollectionPlugin/icons/svg/group_shape.svg @@ -0,0 +1,230 @@ + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/SketchPlugin/SketchPlugin_MacroRectangle.cpp b/src/SketchPlugin/SketchPlugin_MacroRectangle.cpp index cd3a06c26..ff1c97321 100644 --- a/src/SketchPlugin/SketchPlugin_MacroRectangle.cpp +++ b/src/SketchPlugin/SketchPlugin_MacroRectangle.cpp @@ -21,6 +21,7 @@ #include "SketchPlugin_Rectangle.h" #include "SketchPlugin_Sketch.h" #include "SketchPlugin_Tools.h" +#include "SketchPlugin_Line.h" #include #include @@ -53,12 +54,20 @@ void SketchPlugin_MacroRectangle::initAttributes() { data()->addAttribute(AUXILIARY_ID(), ModelAPI_AttributeBoolean::typeId()); data()->addAttribute(START1_ID(), GeomDataAPI_Point2D::typeId()); + data()->addAttribute(START1_REF_ID(), ModelAPI_AttributeRefAttr::typeId()); data()->addAttribute(END1_ID(), GeomDataAPI_Point2D::typeId()); + data()->addAttribute(END1_REF_ID(), ModelAPI_AttributeRefAttr::typeId()); data()->addAttribute(END2_ID(), GeomDataAPI_Point2D::typeId()); + data()->addAttribute(END2_REF_ID(), ModelAPI_AttributeRefAttr::typeId()); data()->addAttribute(CENTER_ID(), GeomDataAPI_Point2D::typeId()); + data()->addAttribute(CENTER_REF_ID(), ModelAPI_AttributeRefAttr::typeId()); data()->addAttribute(RECTANGLE_TYPE_ID(), ModelAPI_AttributeString::typeId()); data()->addAttribute(EDIT_RECTANGLE_TYPE_ID(), ModelAPI_AttributeString::typeId()); ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), EDIT_RECTANGLE_TYPE_ID()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), CENTER_REF_ID()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), END2_REF_ID()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), END1_REF_ID()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), START1_REF_ID()); string(EDIT_RECTANGLE_TYPE_ID())->setValue(""); } @@ -131,7 +140,7 @@ void SketchPlugin_MacroRectangle::execute() if(myHasCenterPoint){ std::dynamic_pointer_cast( myRectangleFeature->attribute(SketchPlugin_Rectangle::CENTER_ID()))->setValue(myCenterPoint->x(), - myCenterPoint->y()); + myCenterPoint->y()); } std::dynamic_pointer_cast( @@ -145,9 +154,32 @@ void SketchPlugin_MacroRectangle::execute() ->setValue(boolean(AUXILIARY_ID())->value()); myRectangleFeature->execute(); + /// create coincidences with rectangle start/center and end points + AttributeRefListPtr aLinesList = myRectangleFeature->reflist(SketchPlugin_Rectangle::LINES_LIST_ID()); + FeaturePtr aRectangleStartLineFeature = std::dynamic_pointer_cast(aLinesList->object(0)); + FeaturePtr aRectangleEndLineFeature = std::dynamic_pointer_cast(aLinesList->object(2)); + std::shared_ptr aRectanglePointEndAttr = + std::dynamic_pointer_cast(aRectangleEndLineFeature->attribute(SketchPlugin_Line::END_ID())); + std::shared_ptr aRectanglePointStartAttr = + std::dynamic_pointer_cast(aRectangleStartLineFeature->attribute(SketchPlugin_Line::END_ID())); + + if(myHasCenterPoint){ + FeaturePtr aCenterPointFeature = std::dynamic_pointer_cast(myRectangleFeature->refattr(CENTER_REF_ID())->object()); + SketchPlugin_Tools::createCoincidenceOrTangency( + this, CENTER_REF_ID(), AttributePtr(), aCenterPointFeature, false); + SketchPlugin_Tools::createCoincidenceOrTangency( + this, END2_REF_ID(), aRectanglePointEndAttr, ObjectPtr(), false); + } + else{ + SketchPlugin_Tools::createCoincidenceOrTangency( + this, START1_REF_ID(), aRectanglePointStartAttr, ObjectPtr(), false); + SketchPlugin_Tools::createCoincidenceOrTangency( + this, END1_REF_ID(), aRectanglePointEndAttr, ObjectPtr(), false); + } + /// Send events to update the sub-features by the solver. if (isUpdateFlushed) - Events_Loop::loop()->setFlushed(anUpdateEvent, true); + Events_Loop::loop()->setFlushed(anUpdateEvent, true); } void SketchPlugin_MacroRectangle::attributeChanged(const std::string& theID) @@ -157,9 +189,19 @@ void SketchPlugin_MacroRectangle::attributeChanged(const std::string& theID) SketchPlugin_Tools::resetAttribute(this, END1_ID()); SketchPlugin_Tools::resetAttribute(this, CENTER_ID()); SketchPlugin_Tools::resetAttribute(this, END2_ID()); + SketchPlugin_Tools::resetAttribute(this, START1_REF_ID()); + SketchPlugin_Tools::resetAttribute(this, END1_REF_ID()); + SketchPlugin_Tools::resetAttribute(this, CENTER_REF_ID()); + SketchPlugin_Tools::resetAttribute(this, END2_REF_ID()); + myStartPoint.reset(); + myEndPoint.reset(); + myCenterPoint.reset(); + myHasCenterPoint = false; } else if (theID == START1_ID() || theID == END1_ID() || - theID == END2_ID() || theID == CENTER_ID()) + theID == START1_REF_ID() || theID == END1_REF_ID() || + theID == END2_ID() || theID == CENTER_ID() || + theID == END2_REF_ID() || theID == CENTER_REF_ID()) { // update points startPoint(); @@ -229,4 +271,3 @@ AISObjectPtr SketchPlugin_MacroRectangle::getAISObject(AISObjectPtr thePrevious) return anAIS; } - diff --git a/src/SketchPlugin/SketchPlugin_MacroRectangle.h b/src/SketchPlugin/SketchPlugin_MacroRectangle.h index 46208f862..fc78a1cde 100644 --- a/src/SketchPlugin/SketchPlugin_MacroRectangle.h +++ b/src/SketchPlugin/SketchPlugin_MacroRectangle.h @@ -72,12 +72,25 @@ public: return ID; } + inline static const std::string& START1_REF_ID() + { + static const std::string ID("rectangle_start_point1_ref"); + return ID; + } + /// 2D point - end point of the Rectangle inline static const std::string& END1_ID() { static const std::string ID("rectangle_end_point1"); return ID; } + + inline static const std::string& END1_REF_ID() + { + static const std::string ID("rectangle_end_point1_ref"); + return ID; + } + /// 2D point - start point of the second Rectangle type inline static const std::string& END2_ID() { @@ -85,12 +98,24 @@ public: return ID; } + inline static const std::string& END2_REF_ID() + { + static const std::string ID("rectangle_end_point2_ref"); + return ID; + } + /// 2D point - center point of the second Rectangle type inline static const std::string& CENTER_ID() { static const std::string ID("rectangle_center_point"); return ID; } + /// Reference for center point selection. + inline static const std::string& CENTER_REF_ID() + { + static const std::string ID("rectangle_center_point_ref"); + return ID; + } /// Returns the kind of a feature SKETCHPLUGIN_EXPORT virtual const std::string& getKind() diff --git a/src/SketchPlugin/icons/rectangle_center_end.png b/src/SketchPlugin/icons/rectangle_center_end.png new file mode 100644 index 000000000..44728111a Binary files /dev/null and b/src/SketchPlugin/icons/rectangle_center_end.png differ diff --git a/src/SketchPlugin/icons/rectangle_start_end.png b/src/SketchPlugin/icons/rectangle_start_end.png new file mode 100644 index 000000000..095af86e6 Binary files /dev/null and b/src/SketchPlugin/icons/rectangle_start_end.png differ diff --git a/src/SketchPlugin/icons/svg/rectangle_center_end.svg b/src/SketchPlugin/icons/svg/rectangle_center_end.svg new file mode 100644 index 000000000..143fbe2a7 --- /dev/null +++ b/src/SketchPlugin/icons/svg/rectangle_center_end.svg @@ -0,0 +1,116 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + diff --git a/src/SketchPlugin/icons/svg/rectangle_start_end.svg b/src/SketchPlugin/icons/svg/rectangle_start_end.svg new file mode 100644 index 000000000..784d3aa45 --- /dev/null +++ b/src/SketchPlugin/icons/svg/rectangle_start_end.svg @@ -0,0 +1,102 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index 813607e51..628801e68 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -87,34 +87,38 @@ helpfile="rectangleFeature.html"> - - + - +