#include <GeomAlgoAPI_CompoundBuilder.h>
#include <GeomAlgoAPI_FaceBuilder.h>
-#include <GeomAPI_AISObject.h>
#include <GeomAPI_Dir.h>
#include <GeomAPI_PlanarEdges.h>
-#include <GeomAlgoAPI_FaceBuilder.h>
-
#include <GeomDataAPI_Point2D.h>
#include <GeomAlgoAPI_PointBuilder.h>
#include <ModelAPI_AttributeRefList.h>
+#include <ModelAPI_AttributeString.h>
#include <ModelAPI_Data.h>
#include <ModelAPI_Document.h>
#include <ModelAPI_Feature.h>
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()
data()->attribute(SketchPlugin_Sketch::NORM_ID()));
std::list<ObjectPtr> aFeatures = aRefList->list();
- if (aFeatures.empty())
+ if (aFeatures.empty()) // actually, this must be avoided by the validators
return;
std::list<ObjectPtr>::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
}
}
- 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<GeomAPI_PlanarEdges> aBigWire(new GeomAPI_PlanarEdges);
{
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
// 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;
}
return std::shared_ptr<GeomAPI_Ax3>(new GeomAPI_Ax3(anOrigin->pnt(), aDirX->dir(), aNorm->dir()));
}
+
+void SketchPlugin_Sketch::exchangeIDs(
+ std::shared_ptr<ModelAPI_Feature> theFeature1, std::shared_ptr<ModelAPI_Feature> theFeature2)
+{
+ reflist(SketchPlugin_Sketch::FEATURES_ID())->exchange(theFeature1, theFeature2);
+}