forked from 1b-agent/opencadstudio-upstream
fix: improve classic leader behavior and annotation linkage
This commit is contained in:
1 parent
0038e386f7
commit
2d1ee0d936
7 files changed
+418
-73
No files matched your search
+55
-1
@@ -159,7 +159,59 @@ fn grips(leader: &Leader) -> Vec<GripDef> {
|
||||
|
||||
fn apply_grip(leader: &mut Leader, grip_id: usize, apply: GripApply) {
|
||||
let n = leader.vertices.len();
|
||||
|
||||
if grip_id < n {
|
||||
if n >= 3 && leader.creation_type == LeaderCreationType::WithText {
|
||||
// Grip del codo: mueve el codo libremente, pero arrastra también
|
||||
// el extremo del renglón manteniendo la distancia relativa.
|
||||
if grip_id == n - 2 {
|
||||
let old_elbow = leader.vertices[n - 2];
|
||||
let old_end = leader.vertices[n - 1];
|
||||
|
||||
let delta = match apply {
|
||||
GripApply::Absolute(p) => acadrust::types::Vector3::new(
|
||||
p.x as f64 - old_elbow.x,
|
||||
p.y as f64 - old_elbow.y,
|
||||
p.z as f64 - old_elbow.z,
|
||||
),
|
||||
GripApply::Translate(d) => acadrust::types::Vector3::new(
|
||||
d.x as f64,
|
||||
d.y as f64,
|
||||
d.z as f64,
|
||||
),
|
||||
};
|
||||
|
||||
leader.vertices[n - 2].x = old_elbow.x + delta.x;
|
||||
leader.vertices[n - 2].y = old_elbow.y + delta.y;
|
||||
leader.vertices[n - 2].z = old_elbow.z + delta.z;
|
||||
|
||||
leader.vertices[n - 1].x = old_end.x + delta.x;
|
||||
leader.vertices[n - 1].y = old_end.y + delta.y;
|
||||
leader.vertices[n - 1].z = old_end.z + delta.z;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Grip del extremo horizontal: sólo debe estirar en X;
|
||||
// Y/Z quedan pegados al codo para que siga horizontal.
|
||||
if grip_id == n - 1 {
|
||||
let elbow = leader.vertices[n - 2];
|
||||
|
||||
match apply {
|
||||
GripApply::Absolute(p) => {
|
||||
leader.vertices[n - 1].x = p.x as f64;
|
||||
}
|
||||
GripApply::Translate(d) => {
|
||||
leader.vertices[n - 1].x += d.x as f64;
|
||||
}
|
||||
}
|
||||
|
||||
leader.vertices[n - 1].y = elbow.y;
|
||||
leader.vertices[n - 1].z = elbow.z;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(v) = leader.vertices.get_mut(grip_id) {
|
||||
match apply {
|
||||
GripApply::Absolute(p) => {
|
||||
@@ -176,7 +228,9 @@ fn apply_grip(leader: &mut Leader, grip_id: usize, apply: GripApply) {
|
||||
}
|
||||
} else if let GripApply::Translate(d) = apply {
|
||||
leader.translate(acadrust::types::Vector3::new(
|
||||
d.x as f64, d.y as f64, d.z as f64,
|
||||
d.x as f64,
|
||||
d.y as f64,
|
||||
d.z as f64,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user