X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchPlugin%2FSketchPlugin_Sketch.cpp;h=a63344e58fda66b21299919bd574339b87b9fcad;hb=c7a5ff20294ae8270bfb9120b8887f0c9959d658;hp=c8f7a22e6694d2239060ed00411651e21cdc3844;hpb=543eb9a49b8620510c5d9a5c56a60d80e6802a95;p=modules%2Fshaper.git diff --git a/src/SketchPlugin/SketchPlugin_Sketch.cpp b/src/SketchPlugin/SketchPlugin_Sketch.cpp index c8f7a22e6..a63344e58 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.cpp +++ b/src/SketchPlugin/SketchPlugin_Sketch.cpp @@ -9,16 +9,14 @@ #include #include -#include #include #include -#include - #include #include #include +#include #include #include #include @@ -56,6 +54,9 @@ void SketchPlugin_Sketch::initAttributes() data()->addAttribute(SketchPlugin_SketchEntity::EXTERNAL_ID(), ModelAPI_AttributeSelection::typeId()); ModelAPI_Session::get()->validators()->registerNotObligatory( getKind(), SketchPlugin_SketchEntity::EXTERNAL_ID()); + data()->addAttribute(SketchPlugin_Sketch::SOLVER_ERROR(), ModelAPI_AttributeString::typeId()); + ModelAPI_Session::get()->validators()->registerNotObligatory( + getKind(), SketchPlugin_Sketch::SOLVER_ERROR()); } void SketchPlugin_Sketch::execute() @@ -73,7 +74,7 @@ void SketchPlugin_Sketch::execute() data()->attribute(SketchPlugin_Sketch::NORM_ID())); std::list aFeatures = aRefList->list(); - if (aFeatures.empty()) + if (aFeatures.empty()) // actually, this must be avoided by the validators return; std::list::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end(); @@ -109,8 +110,12 @@ void SketchPlugin_Sketch::execute() } } - if (aFeaturesPreview.empty()) + if (aFeaturesPreview.empty()) { + // no good features for generation of preview => erase result if exists + if (firstResult().get() && !firstResult()->isDisabled()) + removeResults(0, false); return; + } // Collect all edges as one big wire std::shared_ptr aBigWire(new GeomAPI_PlanarEdges); @@ -140,9 +145,15 @@ void SketchPlugin_Sketch::removeFeature(std::shared_ptr theFea { if (!data()->isValid()) // sketch is already removed (case on undo of sketch), sync is not needed return; - // to keep the persistent sub-elements indexing, do not remove elements from list, - // but substitute by nulls - reflist(SketchPlugin_Sketch::FEATURES_ID())->substitute(theFeature, ObjectPtr()); + AttributeRefListPtr aList = reflist(SketchPlugin_Sketch::FEATURES_ID()); + // if the object is last, remove it from the list (needed to skip empty transaction on edit of sketch feature) + if (aList->object(aList->size(true) - 1, true) == theFeature) { + aList->remove(theFeature); + } else { + // to keep the persistent sub-elements indexing, do not remove elements from list, + // but substitute by nulls + aList->substitute(theFeature, ObjectPtr()); + } } int SketchPlugin_Sketch::numberOfSubs(bool forTree) const @@ -296,7 +307,7 @@ FeaturePtr SketchPlugin_Sketch::addUniqueNamedCopiedFeature(FeaturePtr theFeatur // as a name for the feature, the generated unique name is set aNewFeature->data()->setName(aUniqueFeatureName); // text expressions could block setValue of some attributes - clearExpressions(aNewFeature); + SketchPlugin_Tools::clearExpressions(aNewFeature); return aNewFeature; } @@ -314,3 +325,9 @@ std::shared_ptr SketchPlugin_Sketch::plane(SketchPlugin_Sketch* the return std::shared_ptr(new GeomAPI_Ax3(anOrigin->pnt(), aDirX->dir(), aNorm->dir())); } + +void SketchPlugin_Sketch::exchangeIDs( + std::shared_ptr theFeature1, std::shared_ptr theFeature2) +{ + reflist(SketchPlugin_Sketch::FEATURES_ID())->exchange(theFeature1, theFeature2); +}