Sketcher: Allow live preview of sketch placement (#26033)

along with unit tests
This commit is contained in:
Chris
2025-12-21 10:34:30 -06:00
committed by GitHub
parent 0193b1776d
commit 4cd81136b6
4 changed files with 253 additions and 8 deletions

View File

@@ -3123,22 +3123,54 @@ 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,
pcSketchFaces,
Deviation.getValue(),
AngularDeflection.getValue());
pcSketchFaces,
Deviation.getValue(),
AngularDeflection.getValue());
}
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()