forked from 1b-agent/opencadstudio-upstream
style: rustfmt the tree so the CI lint check passes
This commit is contained in:
1 parent
1317a7b4fd
commit
6025d8be44
128 files changed
+4097
-1676
No files matched your search
@@ -1088,7 +1088,8 @@ impl OpenCADStudio {
|
||||
None => local,
|
||||
});
|
||||
let shown = crate::entities::common::format_direction(angle);
|
||||
self.command_line.push_output(crate::tf!("Angle Override: {shown}").as_ref());
|
||||
self.command_line
|
||||
.push_output(crate::tf!("Angle Override: {shown}").as_ref());
|
||||
true
|
||||
}
|
||||
|
||||
|
||||
+38
-45
@@ -1053,7 +1053,8 @@ impl OpenCADStudio {
|
||||
self.cliprompt_lines = crate::app::settings::clamp_clipromptlines(s.cliprompt_lines);
|
||||
self.command_line
|
||||
.set_cliprompt_lines(self.cliprompt_lines.clamp(0, 50) as u8);
|
||||
self.command_line.set_opacity_percent(s.command_line_opacity);
|
||||
self.command_line
|
||||
.set_opacity_percent(s.command_line_opacity);
|
||||
self.commandline_fade_ms =
|
||||
crate::app::settings::clamp_commandline_fade_ms(s.commandline_fade_ms);
|
||||
self.command_line
|
||||
@@ -1460,7 +1461,8 @@ impl OpenCADStudio {
|
||||
self.show_graphic_attributes = cfg.show_graphic_attributes;
|
||||
self.graphic_attributes.fill_on_current_layer = cfg.graphic_fills_on_current_layer;
|
||||
if self.show_graphic_attributes {
|
||||
self.dock.dock_below_properties(crate::ui::dock::PanelId::GraphicAttributes);
|
||||
self.dock
|
||||
.dock_below_properties(crate::ui::dock::PanelId::GraphicAttributes);
|
||||
}
|
||||
self.ribbon
|
||||
.set_graphic_attributes(self.show_graphic_attributes);
|
||||
@@ -2246,7 +2248,9 @@ impl OpenCADStudio {
|
||||
let enter_viewport_task = self.tabs[i]
|
||||
.scene
|
||||
.saved_entered_viewport()
|
||||
.map_or_else(Task::none, |handle| Task::done(Message::EnterViewport(handle)));
|
||||
.map_or_else(Task::none, |handle| {
|
||||
Task::done(Message::EnterViewport(handle))
|
||||
});
|
||||
|
||||
// The tab may have been reused for the newly opened file. Any Plot
|
||||
// dialog cache belongs to the previous/startup drawing and must not
|
||||
@@ -2463,12 +2467,10 @@ impl OpenCADStudio {
|
||||
handles,
|
||||
base,
|
||||
..
|
||||
} => {
|
||||
crate::modules::insert::wblock::extract_entities_to_doc_with_base(
|
||||
&document, &handles, base, unit,
|
||||
)
|
||||
.map_err(|e| e.to_string())?
|
||||
}
|
||||
} => crate::modules::insert::wblock::extract_entities_to_doc_with_base(
|
||||
&document, &handles, base, unit,
|
||||
)
|
||||
.map_err(|e| e.to_string())?,
|
||||
};
|
||||
crate::io::save(&out_doc, &worker_path).map_err(|e| e.to_string())
|
||||
},
|
||||
@@ -2496,7 +2498,10 @@ impl OpenCADStudio {
|
||||
let document = if worker_name == "*" {
|
||||
crate::modules::insert::wblock::extract_entities_to_doc(&document, &handles)
|
||||
} else {
|
||||
crate::modules::insert::wblock::extract_block_to_doc(&document, &worker_name)
|
||||
crate::modules::insert::wblock::extract_block_to_doc(
|
||||
&document,
|
||||
&worker_name,
|
||||
)
|
||||
}
|
||||
.map_err(|e| e.to_string())?;
|
||||
crate::io::save(&document, &worker_path).map_err(|e| e.to_string())
|
||||
@@ -2526,11 +2531,7 @@ impl OpenCADStudio {
|
||||
// Same reporting the background path used for a failed
|
||||
// extraction — straight through the existing message.
|
||||
Err(error) => {
|
||||
return Task::done(Message::WblockWriteFinished(
|
||||
block_name,
|
||||
path,
|
||||
Err(error),
|
||||
))
|
||||
return Task::done(Message::WblockWriteFinished(block_name, path, Err(error)))
|
||||
}
|
||||
};
|
||||
let ext = path
|
||||
@@ -3088,10 +3089,8 @@ impl OpenCADStudio {
|
||||
if let Err(error) = result {
|
||||
crate::io::fs_access::drop_handle(tab_id);
|
||||
self.command_line.push_error(
|
||||
crate::tf!(
|
||||
"In-place save failed ({error}); a copy was downloaded instead"
|
||||
)
|
||||
.as_ref(),
|
||||
crate::tf!("In-place save failed ({error}); a copy was downloaded instead")
|
||||
.as_ref(),
|
||||
);
|
||||
}
|
||||
self.finalize_web_save(
|
||||
@@ -4105,8 +4104,7 @@ impl OpenCADStudio {
|
||||
// updates the picked file, no dialog at all. The real
|
||||
// name (the user may have renamed it in the picker)
|
||||
// drives the save bookkeeping.
|
||||
let picked_name =
|
||||
crate::io::fs_access::handle_name(tab_id).unwrap_or(filename);
|
||||
let picked_name = crate::io::fs_access::handle_name(tab_id).unwrap_or(filename);
|
||||
Task::batch([
|
||||
close,
|
||||
self.web_save_capture(tab_id, picked_name, ext.to_string(), version),
|
||||
@@ -4124,12 +4122,8 @@ impl OpenCADStudio {
|
||||
close,
|
||||
Task::perform(
|
||||
async move {
|
||||
crate::io::fs_access::pick_save_handle(
|
||||
tab_id,
|
||||
&pick_suggested,
|
||||
ext,
|
||||
)
|
||||
.await
|
||||
crate::io::fs_access::pick_save_handle(tab_id, &pick_suggested, ext)
|
||||
.await
|
||||
},
|
||||
move |picked| Message::WebSaveHandlePicked {
|
||||
tab_id,
|
||||
@@ -4143,12 +4137,10 @@ impl OpenCADStudio {
|
||||
}
|
||||
// Firefox/Safari (no showSaveFilePicker): untouched legacy
|
||||
// download flow.
|
||||
crate::io::fs_access::SaveRoute::Download => {
|
||||
Task::batch([
|
||||
close,
|
||||
self.web_save_capture(tab_id, filename, ext.to_string(), version),
|
||||
])
|
||||
}
|
||||
crate::io::fs_access::SaveRoute::Download => Task::batch([
|
||||
close,
|
||||
self.web_save_capture(tab_id, filename, ext.to_string(), version),
|
||||
]),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4171,7 +4163,8 @@ impl OpenCADStudio {
|
||||
// record the intended ext, which the completion half re-checks
|
||||
// against the retained handle before writing.
|
||||
crate::io::fs_access::begin_web_save(tab_id, &ext);
|
||||
let bounds = crate::ui::wrap_bar::dropdown_bounds(crate::app::view::VIEWPORT_CAPTURE_BOUNDS_ID);
|
||||
let bounds =
|
||||
crate::ui::wrap_bar::dropdown_bounds(crate::app::view::VIEWPORT_CAPTURE_BOUNDS_ID);
|
||||
let Some(bounds) = bounds else {
|
||||
return Task::done(Message::WebSaveScreenshot {
|
||||
tab_id,
|
||||
@@ -4212,9 +4205,7 @@ impl OpenCADStudio {
|
||||
picked: Result<Option<String>, String>,
|
||||
) -> Task<Message> {
|
||||
match picked {
|
||||
Ok(Some(picked_name)) => {
|
||||
self.web_save_capture(tab_id, picked_name, ext, version)
|
||||
}
|
||||
Ok(Some(picked_name)) => self.web_save_capture(tab_id, picked_name, ext, version),
|
||||
Ok(None) => {
|
||||
// The picker was the save dialog: dismissing it means no
|
||||
// save — the download fallback must NOT fire (that would
|
||||
@@ -4547,9 +4538,8 @@ impl OpenCADStudio {
|
||||
let entries = std::mem::take(&mut self.web_autosave_pending);
|
||||
self.web_autosave_restore_all_remaining = entries.len();
|
||||
self.close_active_modal();
|
||||
self.command_line.push_info(
|
||||
crate::tf!("Restoring {} drawing(s)…", entries.len()).as_ref(),
|
||||
);
|
||||
self.command_line
|
||||
.push_info(crate::tf!("Restoring {} drawing(s)…", entries.len()).as_ref());
|
||||
let reads = crate::io::web_autosave::restore_all_plan(&entries)
|
||||
.into_iter()
|
||||
.map(|(open_name, key)| {
|
||||
@@ -4708,7 +4698,7 @@ impl OpenCADStudio {
|
||||
self.sync_ribbon_layers();
|
||||
self.sync_ribbon_styles();
|
||||
self.sync_ribbon_from_selection();
|
||||
|
||||
|
||||
Task::none()
|
||||
}
|
||||
|
||||
@@ -5734,9 +5724,9 @@ impl OpenCADStudio {
|
||||
background_task(
|
||||
crate::t!("Print to printer"),
|
||||
move || {
|
||||
iced::futures::executor::block_on(crate::io::print_to_printer::print_wires_with(
|
||||
page, options,
|
||||
))
|
||||
iced::futures::executor::block_on(
|
||||
crate::io::print_to_printer::print_wires_with(page, options),
|
||||
)
|
||||
},
|
||||
Message::PrintResult,
|
||||
)
|
||||
@@ -8232,7 +8222,10 @@ mod plot_paper_tests {
|
||||
// and PDF drivers, so an SVG plot stores the PDF driver spelling.
|
||||
let _ = app.on_plot_dlg(PlotDlgMsg::Printer(crate::ui::window::plot::OUT_SVG.into()));
|
||||
let _ = app.on_plot_dlg(PlotDlgMsg::SetCurrent);
|
||||
let ps = app.tabs[app.active_tab].scene.plot_settings_for("Layout1").unwrap();
|
||||
let ps = app.tabs[app.active_tab]
|
||||
.scene
|
||||
.plot_settings_for("Layout1")
|
||||
.unwrap();
|
||||
assert_eq!(ps.printer_name, "DWG To PDF.pc3");
|
||||
}
|
||||
|
||||
|
||||
@@ -118,12 +118,8 @@ fn is_open_fill_boundary(entity: &EntityType) -> bool {
|
||||
EntityType::Polyline(polyline) => {
|
||||
!polyline.flags.is_closed() && polyline.vertices.len() >= 3
|
||||
}
|
||||
EntityType::Polyline2D(polyline) => {
|
||||
!polyline.is_closed() && polyline.vertices.len() >= 3
|
||||
}
|
||||
EntityType::Polyline3D(polyline) => {
|
||||
!polyline.flags.closed && polyline.vertices.len() >= 3
|
||||
}
|
||||
EntityType::Polyline2D(polyline) => !polyline.is_closed() && polyline.vertices.len() >= 3,
|
||||
EntityType::Polyline3D(polyline) => !polyline.flags.closed && polyline.vertices.len() >= 3,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
@@ -296,11 +292,15 @@ impl OpenCADStudio {
|
||||
}
|
||||
M::HatchPattern(name) => self.apply_graphic_hatch_pattern(name),
|
||||
M::HatchPatternConfirm => {
|
||||
let name = self.graphic_attributes.hatch_editor.as_ref().and_then(|editor| {
|
||||
crate::ui::properties::filtered_hatch_patterns(&editor.search)
|
||||
.get(editor.focus)
|
||||
.map(|entry| entry.name.clone())
|
||||
});
|
||||
let name = self
|
||||
.graphic_attributes
|
||||
.hatch_editor
|
||||
.as_ref()
|
||||
.and_then(|editor| {
|
||||
crate::ui::properties::filtered_hatch_patterns(&editor.search)
|
||||
.get(editor.focus)
|
||||
.map(|entry| entry.name.clone())
|
||||
});
|
||||
match name {
|
||||
Some(name) => self.apply_graphic_hatch_pattern(name),
|
||||
None => Task::none(),
|
||||
@@ -322,7 +322,8 @@ impl OpenCADStudio {
|
||||
"" | "Y" | "YES" => self.on_graphic_fill_close_response(true),
|
||||
"N" | "NO" => self.on_graphic_fill_close_response(false),
|
||||
_ => {
|
||||
self.command_line.push_error(crate::t!("Enter Yes or No.").as_ref());
|
||||
self.command_line
|
||||
.push_error(crate::t!("Enter Yes or No.").as_ref());
|
||||
Task::none()
|
||||
}
|
||||
}
|
||||
@@ -352,7 +353,12 @@ impl OpenCADStudio {
|
||||
}
|
||||
|
||||
/// Edit the unlocked `part` of the selection as one undo step.
|
||||
fn edit_graphic_part(&mut self, part: Part, label: &str, mut edit: impl FnMut(&mut EntityType)) {
|
||||
fn edit_graphic_part(
|
||||
&mut self,
|
||||
part: Part,
|
||||
label: &str,
|
||||
mut edit: impl FnMut(&mut EntityType),
|
||||
) {
|
||||
let i = self.active_tab;
|
||||
let handles = self.unlocked_graphic_handles(i, part);
|
||||
self.apply_property_op(i, label, &handles, |app, handle| {
|
||||
@@ -363,15 +369,18 @@ impl OpenCADStudio {
|
||||
}
|
||||
|
||||
fn has_selection(&self) -> bool {
|
||||
!self.tabs[self.active_tab].scene.selected_handles_in_order().is_empty()
|
||||
!self.tabs[self.active_tab]
|
||||
.scene
|
||||
.selected_handles_in_order()
|
||||
.is_empty()
|
||||
}
|
||||
|
||||
fn current_graphic_attributes(&self, i: usize) -> ConcreteGraphicAttributes {
|
||||
let document = &self.tabs[i].scene.document;
|
||||
let handles = self.graphic_handles(i, Part::Both);
|
||||
let draw_depth = self.tabs[i].scene.draw_depth_map();
|
||||
if let Some(entity) =
|
||||
palette::top_handle(&handles, &draw_depth).and_then(|handle| document.get_entity(handle))
|
||||
if let Some(entity) = palette::top_handle(&handles, &draw_depth)
|
||||
.and_then(|handle| document.get_entity(handle))
|
||||
{
|
||||
let common = entity.common();
|
||||
return concrete_graphic_attributes(
|
||||
@@ -431,12 +440,27 @@ impl OpenCADStudio {
|
||||
|
||||
pub(super) fn on_graphic_attributes_set_all(&mut self, by_layer: bool) -> Task<Message> {
|
||||
let (color, linetype, lineweight, transparency) = if by_layer {
|
||||
(AcadColor::ByLayer, "ByLayer", LineWeight::ByLayer, Transparency::BY_LAYER)
|
||||
(
|
||||
AcadColor::ByLayer,
|
||||
"ByLayer",
|
||||
LineWeight::ByLayer,
|
||||
Transparency::BY_LAYER,
|
||||
)
|
||||
} else {
|
||||
(AcadColor::ByBlock, "ByBlock", LineWeight::ByBlock, Transparency::BY_BLOCK)
|
||||
(
|
||||
AcadColor::ByBlock,
|
||||
"ByBlock",
|
||||
LineWeight::ByBlock,
|
||||
Transparency::BY_BLOCK,
|
||||
)
|
||||
};
|
||||
if !self.has_selection() {
|
||||
self.set_current_graphic_attributes(color, linetype.to_owned(), lineweight, transparency);
|
||||
self.set_current_graphic_attributes(
|
||||
color,
|
||||
linetype.to_owned(),
|
||||
lineweight,
|
||||
transparency,
|
||||
);
|
||||
return Task::none();
|
||||
}
|
||||
self.edit_graphic_part(Part::Both, &crate::t!("Graphic Attributes"), |entity| {
|
||||
@@ -480,18 +504,27 @@ impl OpenCADStudio {
|
||||
})
|
||||
.collect();
|
||||
let handles: Vec<_> = values.keys().copied().collect();
|
||||
self.apply_property_op(i, crate::t!("Graphic Attributes"), &handles, |app, handle| {
|
||||
let (Some(values), Some(entity)) = (
|
||||
values.get(&handle),
|
||||
app.tabs[i].scene.document.get_entity_mut(handle),
|
||||
) else {
|
||||
return;
|
||||
};
|
||||
crate::scene::view::dispatch::apply_color(entity, values.color);
|
||||
crate::scene::view::dispatch::apply_common_prop(entity, "linetype", &values.linetype);
|
||||
crate::scene::view::dispatch::apply_line_weight(entity, values.lineweight);
|
||||
entity.common_mut().transparency = values.transparency;
|
||||
});
|
||||
self.apply_property_op(
|
||||
i,
|
||||
crate::t!("Graphic Attributes"),
|
||||
&handles,
|
||||
|app, handle| {
|
||||
let (Some(values), Some(entity)) = (
|
||||
values.get(&handle),
|
||||
app.tabs[i].scene.document.get_entity_mut(handle),
|
||||
) else {
|
||||
return;
|
||||
};
|
||||
crate::scene::view::dispatch::apply_color(entity, values.color);
|
||||
crate::scene::view::dispatch::apply_common_prop(
|
||||
entity,
|
||||
"linetype",
|
||||
&values.linetype,
|
||||
);
|
||||
crate::scene::view::dispatch::apply_line_weight(entity, values.lineweight);
|
||||
entity.common_mut().transparency = values.transparency;
|
||||
},
|
||||
);
|
||||
Task::none()
|
||||
}
|
||||
|
||||
@@ -499,8 +532,10 @@ impl OpenCADStudio {
|
||||
let i = self.active_tab;
|
||||
let name = raw_name.trim();
|
||||
if !crate::scene::valid_block_name(name) {
|
||||
self.command_line
|
||||
.push_error(crate::t!("Graphic Attributes: enter a valid layer name without <>/\\\":;?*|,=`.").as_ref());
|
||||
self.command_line.push_error(
|
||||
crate::t!("Graphic Attributes: enter a valid layer name without <>/\\\":;?*|,=`.")
|
||||
.as_ref(),
|
||||
);
|
||||
return Task::none();
|
||||
}
|
||||
if self.tabs[i]
|
||||
@@ -530,8 +565,9 @@ impl OpenCADStudio {
|
||||
layer.line_weight = values.lineweight;
|
||||
layer.transparency = values.transparency;
|
||||
if self.tabs[i].scene.document.layers.add(layer).is_err() {
|
||||
self.command_line
|
||||
.push_error(crate::t!("Graphic Attributes: the layer could not be created.").as_ref());
|
||||
self.command_line.push_error(
|
||||
crate::t!("Graphic Attributes: the layer could not be created.").as_ref(),
|
||||
);
|
||||
return Task::none();
|
||||
}
|
||||
self.tabs[i].dirty = true;
|
||||
@@ -781,11 +817,17 @@ impl OpenCADStudio {
|
||||
let document = &self.tabs[i].scene.document;
|
||||
let (associated, new_hatches, updated_hatches, skipped) = if value == GraphicAttribute::None
|
||||
{
|
||||
(palette::fill_handles(document, selected), Vec::new(), Vec::new(), 0)
|
||||
(
|
||||
palette::fill_handles(document, selected),
|
||||
Vec::new(),
|
||||
Vec::new(),
|
||||
0,
|
||||
)
|
||||
} else {
|
||||
let Some((name, pattern)) = fill_pattern(value) else {
|
||||
self.command_line
|
||||
.push_error(crate::t!("Graphic Attributes: no hatch pattern is available.").as_ref());
|
||||
self.command_line.push_error(
|
||||
crate::t!("Graphic Attributes: no hatch pattern is available.").as_ref(),
|
||||
);
|
||||
return false;
|
||||
};
|
||||
let working = if self.tabs[i].editing_model_space() {
|
||||
@@ -883,13 +925,15 @@ impl OpenCADStudio {
|
||||
.chain(updated_hatches.iter().map(|entity| &entity.common().handle))
|
||||
.any(|handle| self.tabs[i].scene.is_layer_locked(*handle))
|
||||
{
|
||||
self.command_line
|
||||
.push_error(crate::t!("Graphic Attributes: an associated fill is on a locked layer.").as_ref());
|
||||
self.command_line.push_error(
|
||||
crate::t!("Graphic Attributes: an associated fill is on a locked layer.").as_ref(),
|
||||
);
|
||||
return false;
|
||||
}
|
||||
if skipped == 1 {
|
||||
self.command_line
|
||||
.push_info(crate::t!("Graphic Attributes: 1 unsupported object was not changed.").as_ref());
|
||||
self.command_line.push_info(
|
||||
crate::t!("Graphic Attributes: 1 unsupported object was not changed.").as_ref(),
|
||||
);
|
||||
} else if skipped > 1 {
|
||||
self.command_line.push_info(
|
||||
crate::tf!("Graphic Attributes: {skipped} unsupported objects were not changed.")
|
||||
@@ -959,7 +1003,11 @@ impl OpenCADStudio {
|
||||
};
|
||||
if !self.has_selection() {
|
||||
let i = self.active_tab;
|
||||
self.tabs[i].scene.document.header.current_entity_linetype_scale = scale;
|
||||
self.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
.header
|
||||
.current_entity_linetype_scale = scale;
|
||||
self.tabs[i].dirty = true;
|
||||
self.refresh_properties();
|
||||
return Task::none();
|
||||
@@ -1013,7 +1061,9 @@ mod tests {
|
||||
}
|
||||
polyline.close();
|
||||
let i = app.active_tab;
|
||||
app.tabs[i].scene.add_entity(EntityType::LwPolyline(polyline))
|
||||
app.tabs[i]
|
||||
.scene
|
||||
.add_entity(EntityType::LwPolyline(polyline))
|
||||
}
|
||||
|
||||
fn select(app: &mut OpenCADStudio, handles: &[Handle]) {
|
||||
@@ -1062,13 +1112,18 @@ mod tests {
|
||||
#[test]
|
||||
fn coincident_boundaries_each_get_their_own_associative_fill() {
|
||||
let mut app = fresh();
|
||||
let boundaries = [add_closed_square(&mut app, 0.0), add_closed_square(&mut app, 0.0)];
|
||||
let boundaries = [
|
||||
add_closed_square(&mut app, 0.0),
|
||||
add_closed_square(&mut app, 0.0),
|
||||
];
|
||||
select(&mut app, &boundaries);
|
||||
|
||||
let _ = app.on_graphic_attribute(GraphicAttribute::Solid);
|
||||
let fills = hatches(&app);
|
||||
assert_eq!(fills.len(), 2);
|
||||
assert!(fills.iter().all(|hatch| hatch.is_solid && hatch.is_associative));
|
||||
assert!(fills
|
||||
.iter()
|
||||
.all(|hatch| hatch.is_solid && hatch.is_associative));
|
||||
assert!(fills.iter().all(|hatch| hatch
|
||||
.paths
|
||||
.iter()
|
||||
@@ -1087,7 +1142,10 @@ mod tests {
|
||||
fn unsupported_objects_are_skipped_while_the_rest_is_filled() {
|
||||
let mut app = fresh();
|
||||
let i = app.active_tab;
|
||||
let boundaries = [add_closed_square(&mut app, 0.0), add_closed_square(&mut app, 20.0)];
|
||||
let boundaries = [
|
||||
add_closed_square(&mut app, 0.0),
|
||||
add_closed_square(&mut app, 20.0),
|
||||
];
|
||||
select(&mut app, &boundaries);
|
||||
let _ = app.on_graphic_attribute(GraphicAttribute::Gradient);
|
||||
|
||||
@@ -1104,7 +1162,10 @@ mod tests {
|
||||
fn editing_a_shared_gradient_is_one_undo_step() {
|
||||
let mut app = fresh();
|
||||
let i = app.active_tab;
|
||||
let boundaries = [add_closed_square(&mut app, 0.0), add_closed_square(&mut app, 20.0)];
|
||||
let boundaries = [
|
||||
add_closed_square(&mut app, 0.0),
|
||||
add_closed_square(&mut app, 20.0),
|
||||
];
|
||||
select(&mut app, &boundaries);
|
||||
let _ = app.on_graphic_attribute(GraphicAttribute::Gradient);
|
||||
|
||||
@@ -1152,7 +1213,11 @@ mod tests {
|
||||
assert_eq!(palette::line_handles(document, &[hatch]), vec![boundary]);
|
||||
assert_eq!(fill_kind(&app, hatch), GraphicAttribute::Gradient);
|
||||
|
||||
for kind in [GraphicAttribute::Solid, GraphicAttribute::Hatch, GraphicAttribute::Gradient] {
|
||||
for kind in [
|
||||
GraphicAttribute::Solid,
|
||||
GraphicAttribute::Hatch,
|
||||
GraphicAttribute::Gradient,
|
||||
] {
|
||||
let _ = app.on_graphic_attribute(kind);
|
||||
assert_eq!(fill_kind(&app, hatch), kind);
|
||||
}
|
||||
@@ -1240,9 +1305,11 @@ mod tests {
|
||||
|
||||
let _ = app.update(ga(GraphicAttributesMsg::Fill(GraphicAttribute::Solid)));
|
||||
assert!(app.graphic_attributes.pending_fill_close.is_some());
|
||||
assert!(!app.tabs[i].scene.document.entities().any(|entity| {
|
||||
matches!(entity, EntityType::Hatch(_))
|
||||
}));
|
||||
assert!(!app.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
.entities()
|
||||
.any(|entity| { matches!(entity, EntityType::Hatch(_)) }));
|
||||
|
||||
let _ = app.update(Message::CommandOptionPick("Y".to_string()));
|
||||
assert!(app.graphic_attributes.pending_fill_close.is_none());
|
||||
@@ -1268,10 +1335,7 @@ mod tests {
|
||||
let _ = app.on_line_transparency(codec::types::Transparency::from_percent(0.3));
|
||||
|
||||
let header = &app.tabs[i].scene.document.header;
|
||||
assert_eq!(
|
||||
header.current_entity_color,
|
||||
codec::types::Color::Index(2)
|
||||
);
|
||||
assert_eq!(header.current_entity_color, codec::types::Color::Index(2));
|
||||
assert_eq!(header.current_linetype_name, "Continuous");
|
||||
assert_eq!(header.current_line_weight, 35);
|
||||
assert!((header.current_entity_linetype_scale - 2.5).abs() < f64::EPSILON);
|
||||
@@ -1606,14 +1670,18 @@ mod tests {
|
||||
assert_eq!(app.dock.location(PanelId::GraphicAttributes), None);
|
||||
|
||||
let _ = app.update(Message::ToggleGraphicAttributes);
|
||||
let properties = app.dock.location(PanelId::Properties).expect("properties docked");
|
||||
let properties = app
|
||||
.dock
|
||||
.location(PanelId::Properties)
|
||||
.expect("properties docked");
|
||||
assert_eq!(
|
||||
app.dock.location(PanelId::GraphicAttributes),
|
||||
Some(properties)
|
||||
);
|
||||
|
||||
// A place the user chose is kept when the palette is shown again.
|
||||
app.dock.dock(PanelId::GraphicAttributes, DockSide::Right, 0);
|
||||
app.dock
|
||||
.dock(PanelId::GraphicAttributes, DockSide::Right, 0);
|
||||
let _ = app.update(Message::ToggleGraphicAttributes);
|
||||
let _ = app.update(Message::ToggleGraphicAttributes);
|
||||
assert_eq!(
|
||||
@@ -1659,7 +1727,9 @@ mod tests {
|
||||
assert_eq!(common(&app, line).linetype_scale, 1.0);
|
||||
|
||||
// Typing alone does not apply; Enter does, with a decimal comma too.
|
||||
let _ = app.update(ga(GraphicAttributesMsg::LineLinetypeScaleInput("0,35".into())));
|
||||
let _ = app.update(ga(GraphicAttributesMsg::LineLinetypeScaleInput(
|
||||
"0,35".into(),
|
||||
)));
|
||||
assert_eq!(common(&app, line).linetype_scale, 1.0);
|
||||
let _ = app.update(ga(GraphicAttributesMsg::LineLinetypeScaleSubmit));
|
||||
assert_eq!(common(&app, line).linetype_scale, 0.35);
|
||||
@@ -1667,7 +1737,9 @@ mod tests {
|
||||
|
||||
// Invalid or non-positive input is dropped.
|
||||
for typed in ["abc", "0", "-2"] {
|
||||
let _ = app.update(ga(GraphicAttributesMsg::LineLinetypeScaleInput(typed.into())));
|
||||
let _ = app.update(ga(GraphicAttributesMsg::LineLinetypeScaleInput(
|
||||
typed.into(),
|
||||
)));
|
||||
let _ = app.update(ga(GraphicAttributesMsg::LineLinetypeScaleSubmit));
|
||||
assert_eq!(common(&app, line).linetype_scale, 0.35);
|
||||
}
|
||||
|
||||
+24
-17
@@ -50,7 +50,9 @@ fn is_modal_blocked_key_msg(msg: &Message) -> bool {
|
||||
|
||||
fn perf_message_label(msg: &Message) -> &'static str {
|
||||
match msg {
|
||||
Message::ViewportLeftPressAt(_) | Message::ViewportLeftPress | Message::PanePress(_) => "pointer-down",
|
||||
Message::ViewportLeftPressAt(_) | Message::ViewportLeftPress | Message::PanePress(_) => {
|
||||
"pointer-down"
|
||||
}
|
||||
Message::ViewportLeftRelease | Message::PaneRelease(_) => "pointer-up",
|
||||
Message::ViewportMove(_) | Message::PaneMove(_, _) => "pointer-move",
|
||||
Message::CommandFinalize => "command-finalize",
|
||||
@@ -960,11 +962,13 @@ impl OpenCADStudio {
|
||||
if pending.is_empty() {
|
||||
return autosave;
|
||||
}
|
||||
Task::batch(std::iter::once(autosave).chain(pending.into_iter().map(|script| {
|
||||
Task::perform(crate::scene::text::web_font::fetch(script), move |res| {
|
||||
Message::WebFontLoaded(script, res)
|
||||
})
|
||||
})))
|
||||
Task::batch(
|
||||
std::iter::once(autosave).chain(pending.into_iter().map(|script| {
|
||||
Task::perform(crate::scene::text::web_font::fetch(script), move |res| {
|
||||
Message::WebFontLoaded(script, res)
|
||||
})
|
||||
})),
|
||||
)
|
||||
}
|
||||
|
||||
// Web: a per-script font arrived. The same bytes feed drawing text,
|
||||
@@ -1894,8 +1898,9 @@ impl OpenCADStudio {
|
||||
|
||||
// -WBLOCK with FILEDIA 1: the file came from the dialog, the
|
||||
// command line asks for the rest.
|
||||
Message::WblockSaveResult(block_name, Some(path)) if block_name == "-" => self
|
||||
.dispatch_command(&format!("_-WBLOCKFILE {}", path.display())),
|
||||
Message::WblockSaveResult(block_name, Some(path)) if block_name == "-" => {
|
||||
self.dispatch_command(&format!("_-WBLOCKFILE {}", path.display()))
|
||||
}
|
||||
Message::WblockSaveResult(block_name, Some(path)) => {
|
||||
self.on_wblock_save_result_some(block_name, path)
|
||||
}
|
||||
@@ -8592,11 +8597,16 @@ impl OpenCADStudio {
|
||||
async {
|
||||
let handle = rfd::AsyncFileDialog::new()
|
||||
.add_filter(crate::t!("Command aliases (*.pgp)").as_ref(), &["pgp"])
|
||||
.pick_file().await?;
|
||||
.pick_file()
|
||||
.await?;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
{ Some(std::fs::read(handle.path()).map_err(|e| e.to_string())) }
|
||||
{
|
||||
Some(std::fs::read(handle.path()).map_err(|e| e.to_string()))
|
||||
}
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
{ Some(Ok(handle.read().await)) }
|
||||
{
|
||||
Some(Ok(handle.read().await))
|
||||
}
|
||||
},
|
||||
Message::AliasEditorImported,
|
||||
),
|
||||
@@ -10553,16 +10563,14 @@ impl OpenCADStudio {
|
||||
.err()
|
||||
.map(|e| e.to_string())
|
||||
};
|
||||
if let Some(tab_idx) =
|
||||
self.tabs.iter().position(|t| t.id == state.document_id)
|
||||
if let Some(tab_idx) = self.tabs.iter().position(|t| t.id == state.document_id)
|
||||
{
|
||||
if let Some(matched) = state
|
||||
.existing_names
|
||||
.iter()
|
||||
.find(|n| n.eq_ignore_ascii_case(trimmed))
|
||||
{
|
||||
state.preview =
|
||||
self.tabs[tab_idx].scene.block_preview_wires(matched);
|
||||
state.preview = self.tabs[tab_idx].scene.block_preview_wires(matched);
|
||||
state.description = self.tabs[tab_idx]
|
||||
.scene
|
||||
.document
|
||||
@@ -10582,8 +10590,7 @@ impl OpenCADStudio {
|
||||
if let Some(state) = self.block_edit_picker.as_mut() {
|
||||
state.name = name.clone();
|
||||
state.error = None;
|
||||
if let Some(tab_idx) =
|
||||
self.tabs.iter().position(|t| t.id == state.document_id)
|
||||
if let Some(tab_idx) = self.tabs.iter().position(|t| t.id == state.document_id)
|
||||
{
|
||||
state.preview = self.tabs[tab_idx].scene.block_preview_wires(&name);
|
||||
state.description = self.tabs[tab_idx]
|
||||
|
||||
+31
-15
@@ -1091,9 +1091,9 @@ impl OpenCADStudio {
|
||||
// viewport, the picker drives that viewport entity's own
|
||||
// render mode; the model-layout tab style is untouched.
|
||||
if self.tabs[i].scene.set_active_viewport_render_mode(mode) {
|
||||
self.tabs[i]
|
||||
.scene
|
||||
.set_active_visual_style_named(crate::modules::view::visual_style::style_name_for(mode));
|
||||
self.tabs[i].scene.set_active_visual_style_named(
|
||||
crate::modules::view::visual_style::style_name_for(mode),
|
||||
);
|
||||
self.tabs[i].scene.bump_geometry_no_blocks();
|
||||
self.tabs[i].dirty = true;
|
||||
self.command_line
|
||||
@@ -1102,9 +1102,9 @@ impl OpenCADStudio {
|
||||
}
|
||||
self.apply_render_mode(i, mode, label);
|
||||
// The viewport record carries the style the mode is saved as.
|
||||
self.tabs[i]
|
||||
.scene
|
||||
.set_active_visual_style_named(crate::modules::view::visual_style::style_name_for(mode));
|
||||
self.tabs[i].scene.set_active_visual_style_named(
|
||||
crate::modules::view::visual_style::style_name_for(mode),
|
||||
);
|
||||
self.command_line
|
||||
.push_output(crate::tf!("Visual style: {label}").as_ref());
|
||||
// The point cloud move gizmo follows the visual style.
|
||||
@@ -2676,9 +2676,9 @@ impl OpenCADStudio {
|
||||
// Otherwise the endpoint glyph can appear at the
|
||||
// corner while the preview/accepted point follows the
|
||||
// tracking line instead.
|
||||
!self.tabs[i].snap_result.is_some_and(|s| {
|
||||
s.snap_type != crate::snap::SnapType::Grid
|
||||
})
|
||||
!self.tabs[i]
|
||||
.snap_result
|
||||
.is_some_and(|s| s.snap_type != crate::snap::SnapType::Grid)
|
||||
}) {
|
||||
h.aligned
|
||||
} else {
|
||||
@@ -3617,8 +3617,14 @@ impl OpenCADStudio {
|
||||
let aperture = crate::ui::overlay::pick_box_aperture_px(self.pick_box);
|
||||
let world = self.cursor_model_point(i, edit_cam, p, bounds);
|
||||
let scene = &self.tabs[i].scene;
|
||||
let candidates = scene
|
||||
.interaction_hover_candidates_near(wires, world, view_rot, eye, bounds, aperture * 2.0);
|
||||
let candidates = scene.interaction_hover_candidates_near(
|
||||
wires,
|
||||
world,
|
||||
view_rot,
|
||||
eye,
|
||||
bounds,
|
||||
aperture * 2.0,
|
||||
);
|
||||
scene::pick::hit_test::click_hit(
|
||||
p,
|
||||
&candidates,
|
||||
@@ -6022,8 +6028,12 @@ properties={:.1}ms picked={}",
|
||||
// Zoom about the fingers once the drawing area's place in
|
||||
// the window is known; until then about the first finger.
|
||||
if let Some(offset) = self.touch_offset {
|
||||
self.tabs[i].scene.selection.borrow_mut().input.last_move_pos =
|
||||
Some(centre - offset);
|
||||
self.tabs[i]
|
||||
.scene
|
||||
.selection
|
||||
.borrow_mut()
|
||||
.input
|
||||
.last_move_pos = Some(centre - offset);
|
||||
}
|
||||
tasks.push(self.zoom_view_at_cursor(pinch_zoom_steps(factor - 1.0)));
|
||||
}
|
||||
@@ -6280,7 +6290,12 @@ properties={:.1}ms picked={}",
|
||||
self.snap_view_region_as(region, glam::Mat4::IDENTITY, false)
|
||||
}
|
||||
|
||||
fn snap_view_region_as(&mut self, region: CubeRegion, r_ucs: glam::Mat4, cube: bool) -> Task<Message> {
|
||||
fn snap_view_region_as(
|
||||
&mut self,
|
||||
region: CubeRegion,
|
||||
r_ucs: glam::Mat4,
|
||||
cube: bool,
|
||||
) -> Task<Message> {
|
||||
let i = self.active_tab;
|
||||
self.clear_navigation_hover(i);
|
||||
self.tabs[i].scene.remember_current_view();
|
||||
@@ -6846,7 +6861,8 @@ properties={:.1}ms picked={}",
|
||||
// LAYOUTCREATEVIEWPORT is off.
|
||||
if crate::scene::layout_create_viewport() {
|
||||
let name = new_name.clone();
|
||||
self.command_line.push_output(crate::tf!("Layout '{name}' created.").as_ref());
|
||||
self.command_line
|
||||
.push_output(crate::tf!("Layout '{name}' created.").as_ref());
|
||||
} else {
|
||||
self.command_line.push_output(
|
||||
crate::tf!("Layout \"{new_name}\" created — use MVIEW to add a viewport")
|
||||
|
||||
@@ -72,10 +72,19 @@ impl OpenCADStudio {
|
||||
return None;
|
||||
}
|
||||
let typed = token.trim().trim_start_matches('_').to_uppercase();
|
||||
let offered = self.tabs[i].active_cmd.as_ref()?.options().iter().any(|option| {
|
||||
option.keyword.eq_ignore_ascii_case(&typed)
|
||||
|| option.label.to_uppercase().replace(' ', "").starts_with(&typed)
|
||||
});
|
||||
let offered = self.tabs[i]
|
||||
.active_cmd
|
||||
.as_ref()?
|
||||
.options()
|
||||
.iter()
|
||||
.any(|option| {
|
||||
option.keyword.eq_ignore_ascii_case(&typed)
|
||||
|| option
|
||||
.label
|
||||
.to_uppercase()
|
||||
.replace(' ', "")
|
||||
.starts_with(&typed)
|
||||
});
|
||||
(!offered).then_some(kind)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user