#include <SketchPlugin.h>
#include <SketchPlugin_SketchEntity.h>
+#include <GeomDataAPI_Point2D.h>
+
+#include <GeomAPI_Edge.h>
+#include <GeomAPI_IPresentable.h>
+
/**\class SketchPlugin_Offset
* \ingroup Plugins
* \brief Builds offset curves in the sketch.
*/
-class SketchPlugin_Offset : public SketchPlugin_SketchEntity
+class SketchPlugin_Offset : public SketchPlugin_SketchEntity, public GeomAPI_IPresentable
{
public:
/// Offset macro feature kind
/// Reimplemented from ModelAPI_Feature::isMacro().
/// \returns true
- SKETCHPLUGIN_EXPORT virtual bool isMacro() const { return true; }
+ //SKETCHPLUGIN_EXPORT virtual bool isMacro() const { return false; }
- SKETCHPLUGIN_EXPORT virtual bool isPreviesNeeded() const { return false; }
+ //SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const { return false; }
+ SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const { return true; }
/// 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
/// \return \c false in case the action not performed.
SKETCHPLUGIN_EXPORT virtual bool customAction(const std::string& theActionId);
- /// Use plugin manager for features creatio
+ /// Returns the AIS preview
+ SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
+
+ /// Use plugin manager for features creation.
SketchPlugin_Offset();
protected:
private:
/// Find all wires connected with the selected edges
bool findWires();
+
+ // Create sketch feature for each edge of theOffsetResult,
+ // and store it in myCreatedFeatures to remove on next execute()
+ void addToSketch (const std::shared_ptr<GeomAPI_Shape>& theOffsetResult);
+
+ // Create BSpline or BSplinePeriodic sketch feature from theEdge
+ void mkBSpline (FeaturePtr& theResult, const GeomEdgePtr& theEdge);
+
+ // Find edges that prolongate theEdgeFeature (in a chain) at theEndPoint
+ // Recursive method.
+ // \param[in] theFirstEdge Start edge of wire searching
+ // \param[in] theEdge Current edge
+ // \param[in] theEndPoint Point of the Current edge, not belonging to a previous edge
+ // \param[in/out] theEdgesSet All edges to find among. If empty, all sketch edges assumed.
+ // \param[in/out] theChain Resulting edges
+ /// \return \c true if the chain is closed
+ bool findWireOneWay (const FeaturePtr& theFirstEdge,
+ const FeaturePtr& theEdge,
+ const std::shared_ptr<GeomDataAPI_Point2D>& theEndPoint,
+ std::set<FeaturePtr>& theEdgesSet,
+ std::list<FeaturePtr>& theChain);
+
+ // tmp
+ std::set<FeaturePtr> myCreatedFeatures;
};
#endif