#include <SketchPlugin_BSplinePeriodic.h>
#include <SketchPlugin_Tools.h>
+#include <SketcherPrs_Factory.h>
+
#include <Events_InfoMessage.h>
#include <ModelAPI_AttributeBoolean.h>
return true;
}
+
+
+AISObjectPtr SketchPlugin_Offset::getAISObject(AISObjectPtr thePrevious)
+{
+ if (!sketch())
+ return thePrevious;
+
+ AISObjectPtr anAIS = SketcherPrs_Factory::offsetObject(this, sketch(),
+ thePrevious);
+ return anAIS;
+}
#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 isPreviewNeeded() const { return false; }
SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const { return true; }
/// \return \c false in case the action not performed.
SKETCHPLUGIN_EXPORT virtual bool customAction(const std::string& theActionId);
+ /// Returns the AIS preview
+ SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
+
/// Use plugin manager for features creation.
SketchPlugin_Offset();
SketcherPrs_Mirror.h
SketcherPrs_Transformation.h
SketcherPrs_Angle.h
+ SketcherPrs_Offset.h
)
SET(PROJECT_SOURCES
SketcherPrs_Mirror.cpp
SketcherPrs_Transformation.cpp
SketcherPrs_Angle.cpp
+ SketcherPrs_Offset.cpp
)
SET(PROJECT_LIBRARIES
icons/mirror.png
icons/rotate.png
icons/translate.png
+ icons/offset.png
)
ADD_DEFINITIONS(-DSKETCHERPRS_EXPORTS ${OpenCASCADE_DEFINITIONS} -D_CRT_SECURE_NO_WARNINGS)
#include "SketcherPrs_Mirror.h"
#include "SketcherPrs_Transformation.h"
#include "SketcherPrs_Angle.h"
+#include "SketcherPrs_Offset.h"
// Macros for constraint presentation definition
#define CONSTRAINT_PRS_IMPL(NAME, CLASS) \
CONSTRAINT_PRS_IMPL(lengthDimensionConstraint, SketcherPrs_LengthDimension);
CONSTRAINT_PRS_IMPL(angleConstraint, SketcherPrs_Angle);
CONSTRAINT_PRS_IMPL(radiusConstraint, SketcherPrs_Radius);
+CONSTRAINT_PRS_IMPL(offsetObject, SketcherPrs_Offset);
// Non-standard constraints definition
AISObjectPtr SketcherPrs_Factory::horisontalConstraint(ModelAPI_Feature* theConstraint,
/// \param thePlane the current sketch plane
/// \param thePrevious the previous presentation
GET_CONSTRAINT_PRS(radiusConstraint)
+
+ /// Creates radius dimension presentation
+ /// \param theConstraint the constraint
+ /// \param thePlane the current sketch plane
+ /// \param thePrevious the previous presentation
+ GET_CONSTRAINT_PRS(offsetObject)
};
#endif
--- /dev/null
+// Copyright (C) 2014-2019 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 "SketcherPrs_Offset.h"
+#include "SketcherPrs_Tools.h"
+#include "SketcherPrs_PositionMgr.h"
+
+#include <SketchPlugin_Offset.h>
+
+#include <ModelAPI_AttributeRefList.h>
+#include <ModelAPI_AttributeDouble.h>
+
+#include <Graphic3d_AspectLine3d.hxx>
+#include <Prs3d_Root.hxx>
+
+
+IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Offset, SketcherPrs_SymbolPrs);
+
+static Handle(Image_AlienPixMap) MyPixMap;
+
+SketcherPrs_Offset::SketcherPrs_Offset(ModelAPI_Feature* theConstraint,
+ SketchPlugin_Sketch* theSketcher)
+ : SketcherPrs_SymbolPrs(theConstraint, theSketcher)
+{
+}
+
+bool SketcherPrs_Offset::IsReadyToDisplay(ModelAPI_Feature* theConstraint,
+ const std::shared_ptr<GeomAPI_Ax3>&/* thePlane*/)
+{
+ bool aReadyToDisplay = false;
+
+ AttributeDoublePtr aValueAttr = theConstraint->real(SketchPlugin_Offset::VALUE_ID());
+ if (aValueAttr->isInitialized()) {
+ AttributeRefListPtr aSelectedEdges = theConstraint->reflist(SketchPlugin_Offset::EDGES_ID());
+ aReadyToDisplay = (aSelectedEdges->list().size() > 0);
+ }
+ return aReadyToDisplay;
+}
+
+bool SketcherPrs_Offset::updateIfReadyToDisplay(double theStep, bool withColor) const
+{
+ if (!IsReadyToDisplay(myConstraint, plane()))
+ return false;
+ if (!plane())
+ return false;
+
+ // Set points of the presentation
+ SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
+
+ AttributeRefListPtr aSelectedEdges = myConstraint->reflist(SketchPlugin_Offset::EDGES_ID());
+ int aNb = aSelectedEdges->size();
+
+ //std::list<std::shared_ptr<ModelAPI_Result> > aResList = myConstraint->results();
+ //int aRNb = aResList.size();
+
+ myPntArray = new Graphic3d_ArrayOfPoints(aNb, withColor);
+ int i;
+ ObjectPtr aObj;
+ gp_Pnt aP1;
+ // get position for each source object
+ for (i = 0; i < aNb; i++) {
+ aObj = aSelectedEdges->object(i);
+ if (SketcherPrs_Tools::getShape(aObj).get() == NULL)
+ continue;
+ aP1 = aMgr->getPosition(aObj, this, theStep);
+ myPntArray->SetVertice(i + 1, aP1);
+ }
+ return true;
+}
+
+void SketcherPrs_Offset::drawLines(const Handle(Prs3d_Presentation)& thePrs,
+ Quantity_Color theColor) const
+{
+ AttributeRefListPtr aSelectedEdges = myConstraint->reflist(SketchPlugin_Offset::EDGES_ID());
+ if (aSelectedEdges.get() == NULL)
+ return;
+
+ int aNb = aSelectedEdges->size();
+ if (aNb == 0)
+ return;
+
+ // Draw source objects
+ drawListOfShapes(aSelectedEdges, thePrs, theColor);
+}
--- /dev/null
+// Copyright (C) 2014-2019 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 SketcherPrs_Offset_H
+#define SketcherPrs_Offset_H
+
+#include "SketcherPrs_SymbolPrs.h"
+
+
+DEFINE_STANDARD_HANDLE(SketcherPrs_Offset, SketcherPrs_SymbolPrs)
+
+/**
+* \ingroup GUI
+* A redefinition of standard AIS Interactive Object in order to provide
+* presentation of Equal constraint
+*/
+class SketcherPrs_Offset : public SketcherPrs_SymbolPrs
+{
+public:
+ /// Constructor
+ /// \param theConstraint a constraint feature
+ /// \param theSketcher a sketcher object
+ Standard_EXPORT SketcherPrs_Offset(ModelAPI_Feature* theConstraint,
+ SketchPlugin_Sketch* theSketcher);
+ DEFINE_STANDARD_RTTIEXT(SketcherPrs_Offset, SketcherPrs_SymbolPrs)
+
+ /// Returns true if the constraint feature arguments are correcly filled to build AIS presentation
+ /// \param theConstraint a constraint feature
+ /// \param thePlane a coordinate plane of current sketch
+ /// \return boolean result value
+ static bool IsReadyToDisplay(ModelAPI_Feature* theConstraint,
+ const std::shared_ptr<GeomAPI_Ax3>& thePlane);
+protected:
+
+ virtual const char* iconName() const { return "offset.png"; }
+
+ virtual void drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const;
+
+ /// Update myPntArray according to presentation positions
+ /// \return true in case of success
+ virtual bool updateIfReadyToDisplay(double theStep, bool withColor) const;
+};
+
+#endif
\ No newline at end of file