: SketchPlugin_SketchEntity()
{}
+void SketchPlugin_Line::initAttributes()
+{
+ SketchPlugin_SketchEntity::initAttributes();
+ /// new attributes should be added to end of the feature in order to provide
+ /// correct attribute values in previous saved studies
+ data()->addAttribute(LENGTH_ID(), ModelAPI_AttributeDouble::typeId());
+}
+
void SketchPlugin_Line::initDerivedClassAttributes()
{
data()->addAttribute(START_ID(), GeomDataAPI_Point2D::typeId());
data()->addAttribute(END_ID(), GeomDataAPI_Point2D::typeId());
data()->addAttribute(EXTERNAL_ID(), ModelAPI_AttributeSelection::typeId());
-#ifndef LINE_LENGHT_BLOCKED
- data()->addAttribute(LENGTH_ID(), ModelAPI_AttributeDouble::typeId());
-#endif
ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), EXTERNAL_ID());
}
// to be removed after debug
if ((theID == EXTERNAL_ID() || isFixed()) && !isCopy()) {
std::shared_ptr<GeomAPI_Shape> aSelection = data()->selection(EXTERNAL_ID())->value();
- // update arguments due to the selection value
+ if (!aSelection) {
+ // empty shape in selection shows that the shape is equal to context
+ ResultPtr anExtRes = selection(EXTERNAL_ID())->context();
+ if (anExtRes)
+ aSelection = anExtRes->shape();
+ }
+ // update arguments due to the selection value
if (aSelection && !aSelection->isNull() && aSelection->isEdge()) {
std::shared_ptr<GeomAPI_Edge> anEdge( new GeomAPI_Edge(aSelection));
std::shared_ptr<GeomDataAPI_Point2D> aStartAttr =
void SketchPlugin_Line::updateLenghtValue()
{
-#ifndef LINE_LENGHT_BLOCKED
std::shared_ptr<GeomDataAPI_Point2D> aStartAttr = std::dynamic_pointer_cast<
GeomDataAPI_Point2D>(data()->attribute(START_ID()));
std::shared_ptr<GeomDataAPI_Point2D> anEndAttr = std::dynamic_pointer_cast<
double aDistance = aStartAttr->pnt()->distance(anEndAttr->pnt());
data()->real(LENGTH_ID())->setValue(aDistance);
}
-#endif
}