Implement the feature for the offset operation.
SketchPlugin_MacroEllipticArc.h
SketchPlugin_MultiRotation.h
SketchPlugin_MultiTranslation.h
+ SketchPlugin_Offset.h
SketchPlugin_Plugin.h
SketchPlugin_Point.h
SketchPlugin_Projection.h
SketchPlugin_MacroEllipticArc.cpp
SketchPlugin_MultiRotation.cpp
SketchPlugin_MultiTranslation.cpp
+ SketchPlugin_Offset.cpp
SketchPlugin_Plugin.cpp
SketchPlugin_Point.cpp
SketchPlugin_Projection.cpp
--- /dev/null
+// Copyright (C) 2020 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include <SketchPlugin_Offset.h>
+
+#include <Events_InfoMessage.h>
+
+#include <ModelAPI_AttributeBoolean.h>
+#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeRefList.h>
+
+
+SketchPlugin_Offset::SketchPlugin_Offset()
+ : SketchPlugin_SketchEntity()
+{
+}
+
+void SketchPlugin_Offset::initDerivedClassAttributes()
+{
+ data()->addAttribute(EDGES_ID(), ModelAPI_AttributeRefList::typeId());
+ data()->addAttribute(VALUE_ID(), ModelAPI_AttributeDouble::typeId());
+ data()->addAttribute(REVERSED_ID(), ModelAPI_AttributeBoolean::typeId());
+}
+
+void SketchPlugin_Offset::execute()
+{
+}
+
+void SketchPlugin_Offset::attributeChanged(const std::string& theID)
+{
+}
+
+bool SketchPlugin_Offset::customAction(const std::string& theActionId)
+{
+ bool isOk = false;
+ if (theActionId == ADD_WIRE_ACTION_ID()) {
+ isOk = findWires();
+ }
+ else {
+ std::string aMsg = "Error: Feature \"%1\" does not support action \"%2\".";
+ Events_InfoMessage("SketchPlugin_Offset", aMsg).arg(getKind()).arg(theActionId).send();
+ }
+ return isOk;
+}
+
+bool SketchPlugin_Offset::findWires()
+{
+ return false;
+}
--- /dev/null
+// Copyright (C) 2020 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef SketchPlugin_Offset_H_
+#define SketchPlugin_Offset_H_
+
+#include <SketchPlugin.h>
+#include <SketchPlugin_SketchEntity.h>
+
+/**\class SketchPlugin_Offset
+ * \ingroup Plugins
+ * \brief Builds offset curves in the sketch.
+ */
+class SketchPlugin_Offset : public SketchPlugin_SketchEntity
+{
+public:
+ /// Offset macro feature kind
+ inline static const std::string& ID()
+ {
+ static const std::string ID("SketchOffset");
+ return ID;
+ }
+
+ /// Returns the kind of a feature
+ SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
+ {
+ static std::string MY_KIND = SketchPlugin_Offset::ID();
+ return MY_KIND;
+ }
+
+ /// list of offset edges
+ inline static const std::string& EDGES_ID()
+ {
+ static const std::string ID("segments");
+ return ID;
+ }
+
+ /// attribute to store the offset value
+ inline static const std::string& VALUE_ID()
+ {
+ static const std::string ID("offset_value");
+ return ID;
+ }
+
+ /// attribute to store the reversed offset direction
+ inline static const std::string& REVERSED_ID()
+ {
+ static const std::string ID("reversed");
+ return ID;
+ }
+
+ /// name for add wire action
+ inline static const std::string& ADD_WIRE_ACTION_ID()
+ {
+ static const std::string ID("add_wire");
+ return ID;
+ }
+
+ /// Called on change of any argument-attribute of this object
+ SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
+
+ /// Creates a new part document if needed
+ SKETCHPLUGIN_EXPORT virtual void execute();
+
+ /// Reimplemented from ModelAPI_Feature::isMacro().
+ /// \returns true
+ SKETCHPLUGIN_EXPORT virtual bool isMacro() const { return true; }
+
+ SKETCHPLUGIN_EXPORT virtual bool isPreviesNeeded() const { return false; }
+
+ /// Find edges connected by coincident boundary constraint and composing a wire with
+ /// the already selected segments. It means that not more than 2 edges can be connected
+ /// with the coincident point.
+ /// \param[in] theActionId action key id (in following form: Action#Index)
+ /// \return \c false in case the action not performed.
+ SKETCHPLUGIN_EXPORT virtual bool customAction(const std::string& theActionId);
+
+ /// Use plugin manager for features creatio
+ SketchPlugin_Offset();
+
+protected:
+ /// \brief Initializes attributes of derived class.
+ virtual void initDerivedClassAttributes();
+
+private:
+ /// Find all wires connected with the selected edges
+ bool findWires();
+};
+
+#endif
#include <SketchPlugin_MacroCircle.h>
#include <SketchPlugin_MultiRotation.h>
#include <SketchPlugin_MultiTranslation.h>
+#include <SketchPlugin_Offset.h>
#include <SketchPlugin_Trim.h>
#include <SketchPlugin_Split.h>
#include <SketchPlugin_Validators.h>
return FeaturePtr(new SketchPlugin_SketchDrawer);
} else if (theFeatureID == SketchPlugin_SketchCopy::ID()) {
return FeaturePtr(new SketchPlugin_SketchCopy);
+ } else if (theFeatureID == SketchPlugin_Offset::ID()) {
+ return FeaturePtr(new SketchPlugin_Offset);
}
// feature of such kind is not found
return FeaturePtr();
aMsg->setState(SketchPlugin_MacroEllipticArc::ID(), aHasSketchPlane);
aMsg->setState(SketchPlugin_ConstraintDistanceHorizontal::ID(), aHasSketchPlane);
aMsg->setState(SketchPlugin_ConstraintDistanceVertical::ID(), aHasSketchPlane);
+ aMsg->setState(SketchPlugin_Offset::ID(), aHasSketchPlane);
// SketchRectangle is a python feature, so its ID is passed just as a string
aMsg->setState("SketchRectangle", aHasSketchPlane);
}
SketchConstraintCoincidence SketchConstraintCoincidenceInternal
SketchConstraintMirror SketchConstraintAngle
SketchMultiRotation SketchMultiTranslation
+ SketchOffset
SketchConstraintCollinear SketchConstraintMiddle"
when_nested="accept abort"
title="Sketch"
</integervalue>
<validator id="PartSet_MultyTranslationSelection" />
</feature>
+
+ <!-- Offset curve -->
+ <feature id="SketchOffset"
+ title="Offset"
+ tooltip="Offset a curve to a distance"
+ icon="icons/Sketch/offset.png"
+ helpfile="offsetFeature.html">
+ <sketch_multi_selector id="segments"
+ label="Edges"
+ tooltip="Select edges to offset"
+ shape_types="Edges"
+ use_external="true"
+ greed="true">
+ </sketch_multi_selector>
+ <doublevalue id="offset_value"
+ label="Offset value"
+ tooltip="Offset value"
+ default="1" min="0.000001"
+ use_reset="false">
+ <validator id="GeomValidators_Positive" parameters="1"/>
+ </doublevalue>
+ <boolvalue id="reversed"
+ label="Reversed"
+ tooltip="Reverse the offset"
+ default="false"
+ obligatory="0"/>
+ <action id="add_wire"
+ label="Select wire"
+ tooltip="Add the list of segments conposing a wire with the selected items through the coincidence by boundary points"/>
+ </feature>
</group>
<group id="Dimensional constraints">