fix(mleader): improve grips, styles and annotative behavior

This commit is contained in:
gianlucafiore 2026-08-24 21:12:30 -03:00
commit d693bcf968
8 changed files with 1071 additions and 185 deletions

View file

@ -1195,23 +1195,66 @@ impl OpenCADStudio {
}
}
CmdResult::CommitAndEditText(entity) => {
let label = self.history_label_from_active_cmd(i, "ENTITY");
let delta_safe = self.delta_add_safe(i, &entity);
let pending = self.begin_undo(i, label, 1, delta_safe);
let handle = self.commit_entity_handle(entity);
self.tabs[i].dirty = true;
self.tabs[i].scene.clear_preview_wire();
self.tabs[i].active_cmd = None;
self.tabs[i].snap_result = None;
self.restore_pre_cmd_tangent();
self.ribbon.deactivate_tool();
if let Some(pd) = pending {
self.commit_undo_delta(i, pd);
}
if let Some(h) = handle {
return self.begin_text_edit(h);
// Una MLEADER cuyo estilo es anotativo necesita además del flag
// enable_annotation_scale un contexto real asociado a la escala
// anotativa actual.
let annotative_mleader = matches!(
&entity,
acadrust::EntityType::MultiLeader(ml)
if ml.enable_annotation_scale
);
let label =
self.history_label_from_active_cmd(i, "ENTITY");
// Crear un contexto anotativo agrega objetos/diccionarios al DWG,
// así que no puede tratarse como un simple delta de entidad.
let delta_safe =
self.delta_add_safe(i, &entity)
&& !annotative_mleader;
let pending =
self.begin_undo(i, label, 1, delta_safe);
let handle =
self.commit_entity_handle(entity);
// Registrar la representación de la escala actual.
if annotative_mleader {
if let (Some(handle), Some(scale_handle)) = (
handle,
self.tabs[i]
.scene
.current_annotation_scale_handle(),
) {
crate::scene::annotative::create_annotation_context(
&mut self.tabs[i].scene.document,
handle,
scale_handle,
);
self.tabs[i].scene.bump_entities(&[(
handle,
crate::scene::ChangeKind::Modified,
)]);
}
}
self.tabs[i].dirty = true;
self.tabs[i].scene.clear_preview_wire();
self.tabs[i].active_cmd = None;
self.tabs[i].snap_result = None;
self.restore_pre_cmd_tangent();
self.ribbon.deactivate_tool();
if let Some(pd) = pending {
self.commit_undo_delta(i, pd);
}
if let Some(h) = handle {
return self.begin_text_edit(h);
}
}
CmdResult::CommitManyAndEditText {
entities,
edit_index,