Merge pull request #26554 from PaddleStroke/patch-106258

Sketcher: Reverse #25478 and #26033 and fix #13852
This commit is contained in:
Chris Hennes
2026-01-05 08:50:47 -09:00
committed by GitHub
2 changed files with 14 additions and 42 deletions

View File

@@ -648,8 +648,6 @@ bool Document::trySetEdit(Gui::ViewProvider* p, int ModNum, const char* subname)
{
auto vp = DocumentP::throwIfCastFails(p);
resetIfEditing();
auto obj = DocumentP::tryGetObject(vp);
std::string _subname = subname ? subname : "";
@@ -660,11 +658,20 @@ bool Document::trySetEdit(Gui::ViewProvider* p, int ModNum, const char* subname)
obj = finder.getObject();
vp = finder.getViewProvider();
if (vp->getDocument() != this) {
resetIfEditing();
return vp->getDocument()->setEdit(vp, ModNum, _subname.c_str());
}
}
}
// Fix for #13852: When switching edit directly between sketches, resetIfEditing()
// triggers unsetEdit() on the previous sketch which restores its selection.
// This clobbers the selection of the new sketch that ParentFinder relies on.
// Moving resetIfEditing() after ParentFinder ensures we resolve the parent context correctly
// using the current selection before closing the previous edit.
resetIfEditing();
d->throwIfNotInMap(obj, getDocument());
Application::Instance->setEditDocument(this);

View File

@@ -3192,6 +3192,11 @@ void ViewProviderSketch::drawEditMarkers(const std::vector<Base::Vector2d>& Edit
}
void ViewProviderSketch::updateData(const App::Property* prop) {
if (std::string(prop->getName()) != "ShapeMaterial") {
// We don't want material to override the colors of sketches.
ViewProvider2DObject::updateData(prop);
}
if (prop == &getSketchObject()->InternalShape) {
const auto& shape = getSketchObject()->InternalShape.getValue();
setupCoinGeometry(shape,
@@ -3203,43 +3208,6 @@ void ViewProviderSketch::updateData(const App::Property* prop) {
if (prop != &getSketchObject()->Constraints) {
signalElementsChanged();
}
// clang-format on
// update placement changes while in edit mode
if (isInEditMode() && prop) {
// check if the changed property is `placement` or `attachmentoffset`
if (strcmp(prop->getName(), "Placement") == 0
|| strcmp(prop->getName(), "AttachmentOffset") == 0) {
#ifdef FC_DEBUG
Base::Console().warning("updating editing transform!\n");
#endif
// recalculate the placement matrix
Sketcher::SketchObject* sketchObj = getSketchObject();
if (sketchObj) {
// use globalPlacement for both attached and unattached sketches
Base::Placement plm = sketchObj->Placement.getValue();
#ifdef FC_DEBUG
// log what is actually being set
Base::Console().warning(
"Placement: pos=(%f,%f,%f)\n",
plm.getPosition().x,
plm.getPosition().y,
plm.getPosition().z
);
#endif
// update the document's editing transform
getDocument()->setEditingTransform(plm.toMatrix());
}
}
}
if (std::string(prop->getName()) != "ShapeMaterial") {
// We don't want material to override the colors of sketches.
ViewProvider2DObject::updateData(prop);
}
// clang-format off
}
void ViewProviderSketch::slotSolverUpdate()
@@ -3483,9 +3451,6 @@ bool ViewProviderSketch::setEdit(int ModNum)
addNodeToRoot(gridnode);
setGridEnabled(true);
// update the documents stored transform
getDocument()->setEditingTransform(plm.toMatrix());
// create the container for the additional edit data
assert(!isInEditMode());
preselection.reset();