bool Model_AttributeSelection::update()
{
ResultPtr aContext = context();
+ if (!aContext) return false;
if (aContext->groupName() == ModelAPI_ResultBody::group()) {
// body: just a named shape, use selection mechanism from OCCT
TNaming_Selector aSelector(myRef.myRef->Label());
#include "SketchPlugin_Sketch.h"
#include <ModelAPI_Data.h>
#include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_AttributeSelection.h>
+#include <ModelAPI_Validator.h>
#include <GeomAPI_Circ2d.h>
#include <GeomAPI_Pnt2d.h>
void SketchPlugin_Arc::initAttributes()
{
- data()->addAttribute(SketchPlugin_Arc::CENTER_ID(), GeomDataAPI_Point2D::type());
- data()->addAttribute(SketchPlugin_Arc::START_ID(), GeomDataAPI_Point2D::type());
- data()->addAttribute(SketchPlugin_Arc::END_ID(), GeomDataAPI_Point2D::type());
+ data()->addAttribute(CENTER_ID(), GeomDataAPI_Point2D::type());
+ data()->addAttribute(START_ID(), GeomDataAPI_Point2D::type());
+ data()->addAttribute(END_ID(), GeomDataAPI_Point2D::type());
+ data()->addAttribute(EXTERNAL_ID(), ModelAPI_AttributeSelection::type());
+ ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), EXTERNAL_ID());
}
void SketchPlugin_Arc::execute()
return aDelta;
}
+
+bool SketchPlugin_Arc::isFixed() {
+ return data()->selection(EXTERNAL_ID())->context();
+}
return MY_KIND;
}
+ /// Returns true is sketch element is under the rigid constraint
+ SKETCHPLUGIN_EXPORT virtual bool isFixed();
+
/// Creates an arc-shape
SKETCHPLUGIN_EXPORT virtual void execute();
#include "SketchPlugin_Sketch.h"
#include <ModelAPI_Data.h>
#include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_AttributeSelection.h>
+#include <ModelAPI_Validator.h>
#include <GeomAPI_Pnt2d.h>
#include <GeomDataAPI_Point2D.h>
{
data()->addAttribute(SketchPlugin_Circle::CENTER_ID(), GeomDataAPI_Point2D::type());
data()->addAttribute(SketchPlugin_Circle::RADIUS_ID(), ModelAPI_AttributeDouble::type());
+ data()->addAttribute(EXTERNAL_ID(), ModelAPI_AttributeSelection::type());
+ ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), EXTERNAL_ID());
}
void SketchPlugin_Circle::execute()
return aPoint->pnt()->distance(thePoint);
}
+
+bool SketchPlugin_Circle::isFixed() {
+ return data()->selection(EXTERNAL_ID())->context();
+}
return MY_KIND;
}
+ /// Returns true is sketch element is under the rigid constraint
+ SKETCHPLUGIN_EXPORT virtual bool isFixed();
+
/// Creates a new part document if needed
SKETCHPLUGIN_EXPORT virtual void execute();
static AISObjectPtr simpleAISObject(boost::shared_ptr<ModelAPI_Result> theRes,
AISObjectPtr thePrevious);
+ /// Reference to the external edge or vertex as a AttributeSelection
+ inline static const std::string& EXTERNAL_ID()
+ {
+ static const std::string MY_EXTERNAL_ID("External");
+ return MY_EXTERNAL_ID;
+ }
+
/// Returns true if this feature must be displayed in the history (top level of Part tree)
SKETCHPLUGIN_EXPORT virtual bool isInHistory()
{
/// Construction result is allways recomuted on the fly
SKETCHPLUGIN_EXPORT virtual bool isPersistentResult() {return false;}
+ /// Returns true is sketch element is under the rigid constraint
+ SKETCHPLUGIN_EXPORT virtual bool isFixed() {return false;}
+
/// Returns the sketch of this feature
inline SketchPlugin_Sketch* sketch() {return mySketch;}
protected:
#include "SketchPlugin_Sketch.h"
#include <ModelAPI_Data.h>
#include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_AttributeSelection.h>
+#include <ModelAPI_Validator.h>
#include <GeomAPI_Pnt.h>
#include <GeomAPI_Lin2d.h>
{
data()->addAttribute(SketchPlugin_Line::START_ID(), GeomDataAPI_Point2D::type());
data()->addAttribute(SketchPlugin_Line::END_ID(), GeomDataAPI_Point2D::type());
+ data()->addAttribute(EXTERNAL_ID(), ModelAPI_AttributeSelection::type());
+ ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), EXTERNAL_ID());
}
void SketchPlugin_Line::execute()
return aDelta;
}
+
+bool SketchPlugin_Line::isFixed() {
+ return data()->selection(EXTERNAL_ID())->context();
+}
return MY_KIND;
}
+ /// Returns true is sketch element is under the rigid constraint
+ SKETCHPLUGIN_EXPORT virtual bool isFixed();
+
/// Creates a new part document if needed
SKETCHPLUGIN_EXPORT virtual void execute();
#include <ModelAPI_Data.h>
#include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_AttributeSelection.h>
+#include <ModelAPI_Validator.h>
#include <GeomAPI_Pnt2d.h>
void SketchPlugin_Point::initAttributes()
{
data()->addAttribute(SketchPlugin_Point::COORD_ID(), GeomDataAPI_Point2D::type());
+ data()->addAttribute(EXTERNAL_ID(), ModelAPI_AttributeSelection::type());
+ ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), EXTERNAL_ID());
}
void SketchPlugin_Point::execute()
return aPoint->pnt()->distance(thePoint);
}
+
+bool SketchPlugin_Point::isFixed() {
+ return data()->selection(EXTERNAL_ID())->context();
+}
return MY_KIND;
}
+ /// Returns true is sketch element is under the rigid constraint
+ SKETCHPLUGIN_EXPORT virtual bool isFixed();
+
/// Creates a new part document if needed
SKETCHPLUGIN_EXPORT virtual void execute();