forked from 1b-agent/opencadstudio-upstream
Merge pull request #1251
This commit is contained in:
commit
2d20bdd51c
8 files changed
+864
-42
No files matched your search
+24
-20
@@ -203,16 +203,11 @@ pub(super) fn on_tab_close(&mut self, idx: usize) -> Task<Message> {
|
||||
.buffer
|
||||
.get_or_insert_with(String::new)
|
||||
.push_str(&s);
|
||||
if self.tabs[i].active_grip.as_ref().is_some_and(|grip| {
|
||||
matches!(
|
||||
grip.mode,
|
||||
GripEditMode::Lengthen
|
||||
| GripEditMode::Radius
|
||||
| GripEditMode::ArcLength
|
||||
| GripEditMode::RectangleWidth
|
||||
| GripEditMode::RectangleHeight
|
||||
)
|
||||
}) {
|
||||
if self.tabs[i]
|
||||
.active_grip
|
||||
.as_ref()
|
||||
.is_some_and(|grip| grip.mode.uses_scalar_dynamic_input())
|
||||
{
|
||||
self.command_line.input.push_str(&s);
|
||||
}
|
||||
} else {
|
||||
@@ -258,16 +253,11 @@ pub(super) fn on_tab_close(&mut self, idx: usize) -> Task<Message> {
|
||||
if buf.is_empty() {
|
||||
self.tabs[i].dyn_fields[a].buffer = None;
|
||||
}
|
||||
if self.tabs[i].active_grip.as_ref().is_some_and(|grip| {
|
||||
matches!(
|
||||
grip.mode,
|
||||
GripEditMode::Lengthen
|
||||
| GripEditMode::Radius
|
||||
| GripEditMode::ArcLength
|
||||
| GripEditMode::RectangleWidth
|
||||
| GripEditMode::RectangleHeight
|
||||
)
|
||||
}) {
|
||||
if self.tabs[i]
|
||||
.active_grip
|
||||
.as_ref()
|
||||
.is_some_and(|grip| grip.mode.uses_scalar_dynamic_input())
|
||||
{
|
||||
self.command_line.input.pop();
|
||||
}
|
||||
return self.focus_cmd_input();
|
||||
@@ -326,6 +316,9 @@ pub(super) fn on_tab_close(&mut self, idx: usize) -> Task<Message> {
|
||||
crate::scene::model::object::GripMenuAction::RectangleHeight => {
|
||||
Some(GripEditMode::RectangleHeight)
|
||||
}
|
||||
crate::scene::model::object::GripMenuAction::MoveParallel => {
|
||||
Some(GripEditMode::MoveParallel)
|
||||
}
|
||||
_ => None,
|
||||
};
|
||||
expected_mode.is_some_and(|mode| {
|
||||
@@ -384,6 +377,9 @@ pub(super) fn on_tab_close(&mut self, idx: usize) -> Task<Message> {
|
||||
) | (
|
||||
GripEditMode::RectangleHeight,
|
||||
crate::scene::model::object::GripMenuAction::RectangleHeight,
|
||||
) | (
|
||||
GripEditMode::MoveParallel,
|
||||
crate::scene::model::object::GripMenuAction::MoveParallel,
|
||||
)
|
||||
)
|
||||
&& grip.handle == pending.handle
|
||||
@@ -1522,6 +1518,7 @@ pub(super) fn on_tab_close(&mut self, idx: usize) -> Task<Message> {
|
||||
| GripMenuAction::ArcLength
|
||||
| GripMenuAction::RectangleWidth
|
||||
| GripMenuAction::RectangleHeight
|
||||
| GripMenuAction::MoveParallel
|
||||
) {
|
||||
if let Some((_, grip)) = self.tabs[i]
|
||||
.selected_grip_handles
|
||||
@@ -1561,6 +1558,11 @@ pub(super) fn on_tab_close(&mut self, idx: usize) -> Task<Message> {
|
||||
popup.grip_id,
|
||||
grip.world,
|
||||
),
|
||||
GripMenuAction::MoveParallel => GripEdit::move_parallel(
|
||||
popup.handle,
|
||||
popup.grip_id,
|
||||
grip.world,
|
||||
),
|
||||
_ => GripEdit::lengthen(
|
||||
popup.handle,
|
||||
popup.grip_id,
|
||||
@@ -1586,6 +1588,8 @@ pub(super) fn on_tab_close(&mut self, idx: usize) -> Task<Message> {
|
||||
self.command_line.push_info("Specify point or enter width:");
|
||||
} else if matches!(item.action, GripMenuAction::RectangleHeight) {
|
||||
self.command_line.push_info("Specify point or enter height:");
|
||||
} else if matches!(item.action, GripMenuAction::MoveParallel) {
|
||||
self.command_line.push_info("Specify point or enter parallel offset:");
|
||||
} else {
|
||||
self.command_line.push_info(
|
||||
crate::t!("Specify point or enter distance:").as_ref(),
|
||||
|
||||
@@ -97,6 +97,9 @@ impl OpenCADStudio {
|
||||
crate::scene::pick::grip::GripEditMode::RectangleHeight => {
|
||||
(grip.origin_world, Some(crate::command::DynRole::Height))
|
||||
}
|
||||
crate::scene::pick::grip::GripEditMode::MoveParallel => {
|
||||
(grip.origin_world, Some(crate::command::DynRole::Distance))
|
||||
}
|
||||
crate::scene::pick::grip::GripEditMode::RectangleResize => {
|
||||
(grip.origin_world, None)
|
||||
}
|
||||
|
||||
+4
-10
@@ -1614,16 +1614,10 @@ impl OpenCADStudio {
|
||||
self.command_line.input = live_input.clone();
|
||||
let i = self.active_tab;
|
||||
if self.dyn_input
|
||||
&& self.tabs[i].active_grip.as_ref().is_some_and(|grip| {
|
||||
matches!(
|
||||
grip.mode,
|
||||
crate::scene::pick::grip::GripEditMode::Lengthen
|
||||
| crate::scene::pick::grip::GripEditMode::Radius
|
||||
| crate::scene::pick::grip::GripEditMode::ArcLength
|
||||
| crate::scene::pick::grip::GripEditMode::RectangleWidth
|
||||
| crate::scene::pick::grip::GripEditMode::RectangleHeight
|
||||
)
|
||||
})
|
||||
&& self.tabs[i]
|
||||
.active_grip
|
||||
.as_ref()
|
||||
.is_some_and(|grip| grip.mode.uses_scalar_dynamic_input())
|
||||
&& !self.tabs[i].dyn_fields.is_empty()
|
||||
{
|
||||
let a = self.tabs[i]
|
||||
|
||||
@@ -1619,6 +1619,9 @@ impl OpenCADStudio {
|
||||
GripEditMode::RectangleHeight => {
|
||||
Some(crate::scene::model::object::GripMenuAction::RectangleHeight)
|
||||
}
|
||||
GripEditMode::MoveParallel => {
|
||||
Some(crate::scene::model::object::GripMenuAction::MoveParallel)
|
||||
}
|
||||
GripEditMode::RectangleResize => None,
|
||||
GripEditMode::Stretch => None,
|
||||
};
|
||||
@@ -1682,16 +1685,36 @@ impl OpenCADStudio {
|
||||
snapped,
|
||||
);
|
||||
if let Some(value) = value {
|
||||
let origin_value =
|
||||
crate::scene::view::dispatch::grip_menu_point_value(
|
||||
&original,
|
||||
grip.grip_id,
|
||||
action,
|
||||
grip.origin_world,
|
||||
);
|
||||
let mut candidate = original.clone();
|
||||
crate::entities::traits::EntityTypeOps::apply_grip_menu_value(
|
||||
&mut candidate,
|
||||
grip.grip_id,
|
||||
action,
|
||||
value,
|
||||
);
|
||||
let returns_to_origin = origin_value.is_some_and(|origin_value| {
|
||||
(value - origin_value).abs()
|
||||
<= 1.0e-9 * value.abs().max(origin_value.abs()).max(1.0)
|
||||
});
|
||||
if let Some(current) =
|
||||
self.tabs[i].scene.document.get_entity_mut(grip.handle)
|
||||
{
|
||||
*current = original;
|
||||
crate::entities::traits::EntityTypeOps::apply_grip_menu_value(
|
||||
current,
|
||||
grip.grip_id,
|
||||
action,
|
||||
value,
|
||||
);
|
||||
// Some radius/parallel positions have no geometric
|
||||
// solution. Their entity edit is deliberately a
|
||||
// no-op; retain the last valid preview instead of
|
||||
// flashing back to the drag-start geometry. The
|
||||
// exact origin remains reachable when the cursor
|
||||
// moves back there.
|
||||
if candidate != original || returns_to_origin {
|
||||
*current = candidate;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3360,6 +3383,7 @@ impl OpenCADStudio {
|
||||
grip.mode,
|
||||
GripEditMode::Lengthen | GripEditMode::Radius | GripEditMode::ArcLength
|
||||
| GripEditMode::RectangleWidth | GripEditMode::RectangleHeight
|
||||
| GripEditMode::MoveParallel
|
||||
) {
|
||||
self.grip_pending = None;
|
||||
self.command_line.input.clear();
|
||||
|
||||
@@ -1025,6 +1025,9 @@ bg={bg_ms:.1}ms n={view_count}"
|
||||
crate::scene::pick::grip::GripEditMode::RectangleHeight => {
|
||||
crate::scene::model::object::GripMenuAction::RectangleHeight
|
||||
}
|
||||
crate::scene::pick::grip::GripEditMode::MoveParallel => {
|
||||
crate::scene::model::object::GripMenuAction::MoveParallel
|
||||
}
|
||||
_ => return None,
|
||||
};
|
||||
let original = self
|
||||
@@ -1894,6 +1897,7 @@ bg={bg_ms:.1}ms n={view_count}"
|
||||
| crate::scene::pick::grip::GripEditMode::ArcLength
|
||||
| crate::scene::pick::grip::GripEditMode::RectangleWidth
|
||||
| crate::scene::pick::grip::GripEditMode::RectangleHeight
|
||||
| crate::scene::pick::grip::GripEditMode::MoveParallel
|
||||
)
|
||||
});
|
||||
let dyn_capturing =
|
||||
|
||||
Reference in new issue
Block a user