Skip to content

Commit

Permalink
Sketcher: Bug fix External geometry not appearing upon insertion
Browse files Browse the repository at this point in the history
================================================================

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.
  • Loading branch information
abdullahtahiriyo authored and wwmayer committed Jun 17, 2015
1 parent 8b4492e commit 074d5d7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Mod/Sketcher/App/SketchObject.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -1938,7 +1939,8 @@ int SketchObject::delExternal(int ExtGeoId)
ExternalGeometry.setValues(originalObjects,originalSubElements);
return -1;
}


solverNeedsUpdate=true;
Constraints.setValues(newConstraints);
Constraints.acceptGeometry(getCompleteGeometry());
rebuildVertexIndex();
Expand Down
8 changes: 8 additions & 0 deletions src/Mod/Sketcher/Gui/CommandCreateGeo.cpp
Expand Up @@ -4545,6 +4545,14 @@ class DrawSketchHandlerExternal: public DrawSketchHandler

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<Sketcher::SketchObject *>(sketchgui->getObject())->solve();
}

Gui::Selection().clearSelection();
/* this is ok not to call to purgeHandler
Expand Down

0 comments on commit 074d5d7

Please sign in to comment.