From 074d5d7f11239ab958e0472150bed25e9617a256 Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Wed, 17 Jun 2015 13:57:02 +0200 Subject: [PATCH] Sketcher: Bug fix External geometry not appearing upon insertion ================================================================ A last moment change to regulate redrawing introduced this issue (reducing the redrawing to the cases where the solver geometry and the sketchObject geometry are equal). This change also solved other issues. The case of adding external geometry is special because the DoF is the same after insertion, yet there is an insertion (as opposed to the toggle case, where there is a change but no insertion). SketchObject has been adapted to require a solver update before moving (which also caused a non-yet-reported crash, a separate bug), and CommandCreateGeo has been adapted to trigger a solve with auto update mode disabled. This solve is a very low cost one as the geometry is already in place. --- src/Mod/Sketcher/App/SketchObject.cpp | 4 +++- src/Mod/Sketcher/Gui/CommandCreateGeo.cpp | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index 37e9e8713..5fc915737 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -1887,6 +1887,7 @@ int SketchObject::addExternal(App::DocumentObject *Obj, const char* SubName) return -1; } + solverNeedsUpdate=true; Constraints.acceptGeometry(getCompleteGeometry()); rebuildVertexIndex(); return ExternalGeometry.getValues().size()-1; @@ -1938,7 +1939,8 @@ int SketchObject::delExternal(int ExtGeoId) ExternalGeometry.setValues(originalObjects,originalSubElements); return -1; } - + + solverNeedsUpdate=true; Constraints.setValues(newConstraints); Constraints.acceptGeometry(getCompleteGeometry()); rebuildVertexIndex(); diff --git a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp index 699783f7f..6fc132b0b 100644 --- a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp +++ b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp @@ -4545,6 +4545,14 @@ public: if(autoRecompute) Gui::Command::updateActive(); + else { + // adding external geometry does not require a solve() per se (the DoF is the same), + // however a solve is required to update the amount of solver geometry, because we only + // redraw a changed Sketch if the solver geometry amount is the same as the SkethObject + // geometry amount (as this avoids other issues). + // This solver is a very low cost one anyway (there is actually nothing to solve). + static_cast(sketchgui->getObject())->solve(); + } Gui::Selection().clearSelection(); /* this is ok not to call to purgeHandler