forked from 1b-agent/opencadstudio-upstream
feat: node graph overlay; move to opencadcodec/opencadkernel/opencadgraph
The codec and kernel repositories and crates are renamed opencadcodec and opencadkernel. Inside OCS they are depended on under short keys, so code reads `codec::`, `kernel::` and the new `graph::` (opencadgraph, the node graph engine). File-format and protocol spellings stay as they were: the ACIS product id `acadrust`, the ACADRUST_* switches and the plugin version keys `acadrust_version` / `acadrust_source`. A button left of MCP on the command line opens a translucent node graph over the viewport, with a palette of object, input, math, logic, list, text and geometry nodes added by click or drag. An object node owns drawing entities and its rows are the Properties panel's own rows for them: the single-object page is extracted from refresh_properties as entity_property_sections, values use the control protocol's property_json, and writes go through set_property_value with a property target override, so the panel, MCP and the graph share one read/write path. A list reaching an object row makes one entity per element. Each graph action is one undo step; the canvas pans and zooms. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
56c04408d6
commit
f537aff75c
430 files changed
+9925
-8540
No files matched your search
+82
-82
@@ -14,8 +14,8 @@ use crate::scene::{
|
||||
self, hover_id, CubeRegion, Scene, VIEWCUBE_DRAW_PX, VIEWCUBE_PAD, VIEWCUBE_PX,
|
||||
};
|
||||
use crate::ui::PropertiesPanel;
|
||||
use acadrust::types::Color as AcadColor;
|
||||
use acadrust::{EntityType as AcadEntityType, Handle};
|
||||
use codec::types::Color as AcadColor;
|
||||
use codec::{EntityType as AcadEntityType, Handle};
|
||||
use iced::time::Instant;
|
||||
use iced::{mouse, Point, Task};
|
||||
|
||||
@@ -64,8 +64,8 @@ fn scale_name_for_factor(scales: &[(String, f64)], factor: f64) -> Option<String
|
||||
|
||||
fn plot_render_mode_override(
|
||||
d: &crate::ui::window::plot::PlotDialogState,
|
||||
) -> Option<acadrust::entities::ViewportRenderMode> {
|
||||
use acadrust::entities::ViewportRenderMode as Mode;
|
||||
) -> Option<codec::entities::ViewportRenderMode> {
|
||||
use codec::entities::ViewportRenderMode as Mode;
|
||||
match d.shade.as_str() {
|
||||
"2D Wireframe" => Some(Mode::Wireframe2D),
|
||||
"3D Wireframe" => Some(Mode::Wireframe3D),
|
||||
@@ -123,7 +123,7 @@ fn plot_dialog_sheet_mm(d: &crate::ui::window::plot::PlotDialogState) -> (f64, f
|
||||
/// Whether the dialog still names the sheet the stored settings carry.
|
||||
fn paper_unchanged(
|
||||
d: &crate::ui::window::plot::PlotDialogState,
|
||||
stored: &acadrust::objects::PlotSettings,
|
||||
stored: &codec::objects::PlotSettings,
|
||||
) -> bool {
|
||||
!stored.paper_size.is_empty()
|
||||
&& crate::io::paper_catalog::from_drawing(
|
||||
@@ -143,7 +143,7 @@ fn paper_unchanged(
|
||||
/// selection writes the canonical name.
|
||||
fn paper_name_for_settings(
|
||||
d: &crate::ui::window::plot::PlotDialogState,
|
||||
stored: &acadrust::objects::PlotSettings,
|
||||
stored: &codec::objects::PlotSettings,
|
||||
) -> String {
|
||||
if paper_unchanged(d, stored) {
|
||||
stored.paper_size.clone()
|
||||
@@ -161,8 +161,8 @@ fn paper_name_for_settings(
|
||||
fn plot_dialog_rotation(
|
||||
d: &crate::ui::window::plot::PlotDialogState,
|
||||
natural: crate::io::paper_catalog::Orientation,
|
||||
) -> acadrust::objects::PlotRotation {
|
||||
use acadrust::objects::PlotRotation;
|
||||
) -> codec::objects::PlotRotation {
|
||||
use codec::objects::PlotRotation;
|
||||
match (plot_dialog_orientation(d) != natural, d.upside_down) {
|
||||
(false, false) => PlotRotation::None,
|
||||
(true, false) => PlotRotation::Degrees90,
|
||||
@@ -172,9 +172,9 @@ fn plot_dialog_rotation(
|
||||
}
|
||||
|
||||
/// Millimetres in the paper unit a page setup counts in.
|
||||
fn plot_paper_unit_mm(units: acadrust::objects::PlotPaperUnits) -> f64 {
|
||||
fn plot_paper_unit_mm(units: codec::objects::PlotPaperUnits) -> f64 {
|
||||
match units {
|
||||
acadrust::objects::PlotPaperUnits::Inches => 25.4,
|
||||
codec::objects::PlotPaperUnits::Inches => 25.4,
|
||||
_ => 1.0,
|
||||
}
|
||||
}
|
||||
@@ -183,16 +183,16 @@ fn plot_paper_unit_mm(units: acadrust::objects::PlotPaperUnits) -> f64 {
|
||||
/// is the `paper : drawing` ratio times 25.4 on millimetre page setups and
|
||||
/// the plain ratio on inch ones — observed in its files, whatever the
|
||||
/// published description says. Both directions of that convention live here.
|
||||
fn stored_scale_factor(ratio: f64, units: acadrust::objects::PlotPaperUnits) -> f64 {
|
||||
fn stored_scale_factor(ratio: f64, units: codec::objects::PlotPaperUnits) -> f64 {
|
||||
match units {
|
||||
acadrust::objects::PlotPaperUnits::Millimeters => ratio * 25.4,
|
||||
codec::objects::PlotPaperUnits::Millimeters => ratio * 25.4,
|
||||
_ => ratio,
|
||||
}
|
||||
}
|
||||
|
||||
fn ratio_from_stored_scale_factor(factor: f64, units: acadrust::objects::PlotPaperUnits) -> f64 {
|
||||
fn ratio_from_stored_scale_factor(factor: f64, units: codec::objects::PlotPaperUnits) -> f64 {
|
||||
match units {
|
||||
acadrust::objects::PlotPaperUnits::Millimeters => factor / 25.4,
|
||||
codec::objects::PlotPaperUnits::Millimeters => factor / 25.4,
|
||||
_ => factor,
|
||||
}
|
||||
}
|
||||
@@ -200,8 +200,8 @@ fn ratio_from_stored_scale_factor(factor: f64, units: acadrust::objects::PlotPap
|
||||
/// The file format's standard scale for a `paper : drawing` ratio, when it
|
||||
/// has one. Only the metric ratios exist as standard codes here; an
|
||||
/// architectural scale is stored as a custom ratio with the same value.
|
||||
fn standard_scale_for_ratio(paper: f64, drawing: f64) -> Option<acadrust::objects::ScaledType> {
|
||||
use acadrust::objects::ScaledType as S;
|
||||
fn standard_scale_for_ratio(paper: f64, drawing: f64) -> Option<codec::objects::ScaledType> {
|
||||
use codec::objects::ScaledType as S;
|
||||
const STANDARD: &[(f64, f64, S)] = &[
|
||||
(1.0, 1.0, S::OneToOne),
|
||||
(1.0, 2.0, S::OneToTwo),
|
||||
@@ -267,7 +267,7 @@ fn plot_dialog_device(d: &crate::ui::window::plot::PlotDialogState) -> crate::io
|
||||
/// device, or one of our own legacy labels, is written in the source application's spelling.
|
||||
fn device_name_for_settings(
|
||||
d: &crate::ui::window::plot::PlotDialogState,
|
||||
stored: &acadrust::objects::PlotSettings,
|
||||
stored: &codec::objects::PlotSettings,
|
||||
) -> String {
|
||||
use crate::io::plot_device::PlotDevice;
|
||||
let device = plot_dialog_device(d);
|
||||
@@ -285,8 +285,8 @@ fn device_name_for_settings(
|
||||
/// the equivalent of the source application's `PAPERUPDATE`.
|
||||
fn margins_for_settings(
|
||||
d: &crate::ui::window::plot::PlotDialogState,
|
||||
stored: &acadrust::objects::PlotSettings,
|
||||
) -> acadrust::objects::PaperMargin {
|
||||
stored: &codec::objects::PlotSettings,
|
||||
) -> codec::objects::PaperMargin {
|
||||
use crate::io::plot_device::PlotDevice;
|
||||
let device = plot_dialog_device(d);
|
||||
let (stored_device, _) = PlotDevice::from_stored_name(&stored.printer_name);
|
||||
@@ -294,7 +294,7 @@ fn margins_for_settings(
|
||||
return stored.margins;
|
||||
}
|
||||
let margins = device.margins_mm(&plot_dialog_paper(d), &d.custom_papers);
|
||||
acadrust::objects::PaperMargin::new(margins.left, margins.bottom, margins.right, margins.top)
|
||||
codec::objects::PaperMargin::new(margins.left, margins.bottom, margins.right, margins.top)
|
||||
}
|
||||
|
||||
fn plot_content_extents(content: &PlotContent) -> Option<(f64, f64, f64, f64)> {
|
||||
@@ -372,13 +372,13 @@ fn plot_owner_aci(scene: &crate::scene::Scene, wire: &mut crate::scene::WireMode
|
||||
};
|
||||
let common = entity.common();
|
||||
wire.aci = match &common.color {
|
||||
acadrust::types::Color::Index(index) => *index,
|
||||
acadrust::types::Color::ByLayer => scene
|
||||
codec::types::Color::Index(index) => *index,
|
||||
codec::types::Color::ByLayer => scene
|
||||
.document
|
||||
.layers
|
||||
.get(&common.layer)
|
||||
.map(|layer| match &layer.color {
|
||||
acadrust::types::Color::Index(index) => *index,
|
||||
codec::types::Color::Index(index) => *index,
|
||||
_ => 0,
|
||||
})
|
||||
.unwrap_or(7),
|
||||
@@ -389,7 +389,7 @@ fn plot_owner_aci(scene: &crate::scene::Scene, wire: &mut crate::scene::WireMode
|
||||
fn plot_scene_content(
|
||||
scene: &crate::scene::Scene,
|
||||
paper_space_last: bool,
|
||||
render_mode_override: Option<acadrust::entities::ViewportRenderMode>,
|
||||
render_mode_override: Option<codec::entities::ViewportRenderMode>,
|
||||
) -> PlotContent {
|
||||
let (mut paper_wires, mut model_wires) = scene.plot_wire_groups(render_mode_override);
|
||||
let plot_viewport_borders = scene
|
||||
@@ -403,7 +403,7 @@ fn plot_scene_content(
|
||||
.is_some_and(|entity| {
|
||||
matches!(
|
||||
entity,
|
||||
acadrust::EntityType::Viewport(viewport)
|
||||
codec::EntityType::Viewport(viewport)
|
||||
if !crate::scene::Scene::is_sheet_viewport(
|
||||
&scene.document,
|
||||
viewport,
|
||||
@@ -495,9 +495,9 @@ fn plot_scene_content(
|
||||
impl OpenCADStudio {
|
||||
/// Persist exact ACIS bodies and kernel-derived edge caches before saving.
|
||||
fn sync_solid_models_for_save(&mut self, i: usize) {
|
||||
use acadrust::EntityType;
|
||||
use codec::EntityType;
|
||||
let scene = &mut self.tabs[i].scene;
|
||||
let targets: Vec<(acadrust::Handle, bool, bool)> = scene
|
||||
let targets: Vec<(codec::Handle, bool, bool)> = scene
|
||||
.document
|
||||
.entities()
|
||||
.filter_map(|entity| {
|
||||
@@ -536,13 +536,13 @@ impl OpenCADStudio {
|
||||
.get(index * 2 + 1)
|
||||
.copied()
|
||||
.unwrap_or([0.0; 3]);
|
||||
acadrust::entities::Wire::from_points(vec![
|
||||
acadrust::types::Vector3::new(
|
||||
codec::entities::Wire::from_points(vec![
|
||||
codec::types::Vector3::new(
|
||||
points[0][0] as f64 + first_low[0] as f64,
|
||||
points[0][1] as f64 + first_low[1] as f64,
|
||||
points[0][2] as f64 + first_low[2] as f64,
|
||||
),
|
||||
acadrust::types::Vector3::new(
|
||||
codec::types::Vector3::new(
|
||||
points[1][0] as f64 + second_low[0] as f64,
|
||||
points[1][1] as f64 + second_low[1] as f64,
|
||||
points[1][2] as f64 + second_low[2] as f64,
|
||||
@@ -565,7 +565,7 @@ impl OpenCADStudio {
|
||||
/// Write a header variable on the active drawing and mark it modified.
|
||||
pub(in crate::app) fn set_drawing_var(
|
||||
&mut self,
|
||||
write: impl FnOnce(&mut acadrust::document::HeaderVariables),
|
||||
write: impl FnOnce(&mut codec::document::HeaderVariables),
|
||||
) {
|
||||
let i = self.active_tab;
|
||||
if let Some(tab) = self.tabs.get_mut(i) {
|
||||
@@ -1459,7 +1459,7 @@ impl OpenCADStudio {
|
||||
&mut self,
|
||||
i: usize,
|
||||
path: std::path::PathBuf,
|
||||
version: acadrust::DxfVersion,
|
||||
version: codec::DxfVersion,
|
||||
set_current_path: bool,
|
||||
) -> Result<(), crate::io::SaveFailure> {
|
||||
let previous_autosave = self.autosave_target(i);
|
||||
@@ -1591,7 +1591,7 @@ impl OpenCADStudio {
|
||||
&mut self,
|
||||
name: String,
|
||||
path: std::path::PathBuf,
|
||||
doc: acadrust::CadDocument,
|
||||
doc: codec::CadDocument,
|
||||
mut caches: crate::scene::DerivedCaches,
|
||||
) -> Task<Message> {
|
||||
// If the user clicked Cancel while the parser was running, the
|
||||
@@ -1612,7 +1612,7 @@ impl OpenCADStudio {
|
||||
}) || doc
|
||||
.notifications
|
||||
.iter()
|
||||
.any(|item| item.notification_type == acadrust::notification::NotificationType::Error);
|
||||
.any(|item| item.notification_type == codec::notification::NotificationType::Error);
|
||||
let reference_recovered = caches
|
||||
.xrefs
|
||||
.iter()
|
||||
@@ -2142,7 +2142,7 @@ impl OpenCADStudio {
|
||||
tab_id: u64,
|
||||
filename: String,
|
||||
ext: String,
|
||||
version: acadrust::DxfVersion,
|
||||
version: codec::DxfVersion,
|
||||
bounds: Option<iced::Rectangle>,
|
||||
screenshot: Option<iced::window::Screenshot>,
|
||||
) -> Task<Message> {
|
||||
@@ -2155,7 +2155,7 @@ impl OpenCADStudio {
|
||||
crate::io::thumbnail::from_screenshot(
|
||||
screenshot,
|
||||
bounds,
|
||||
version >= acadrust::DxfVersion::AC1027,
|
||||
version >= codec::DxfVersion::AC1027,
|
||||
)
|
||||
})
|
||||
});
|
||||
@@ -2215,7 +2215,7 @@ impl OpenCADStudio {
|
||||
&mut self,
|
||||
i: usize,
|
||||
path: std::path::PathBuf,
|
||||
version: acadrust::DxfVersion,
|
||||
version: codec::DxfVersion,
|
||||
purpose: crate::app::SavePurpose,
|
||||
continuation: crate::app::SaveContinuation,
|
||||
set_current_path: bool,
|
||||
@@ -2357,7 +2357,7 @@ impl OpenCADStudio {
|
||||
let revision = self.tabs[i].edit_revision;
|
||||
let camera_generation = self.tabs[i].scene.camera_generation;
|
||||
let thumbnail = (purpose != crate::app::SavePurpose::Autosave && i == self.active_tab)
|
||||
.then_some(version >= acadrust::DxfVersion::AC1027);
|
||||
.then_some(version >= codec::DxfVersion::AC1027);
|
||||
let capture_bounds = thumbnail.and_then(|_| {
|
||||
crate::ui::wrap_bar::dropdown_bounds(crate::app::view::VIEWPORT_CAPTURE_BOUNDS_ID)
|
||||
});
|
||||
@@ -3216,7 +3216,7 @@ impl OpenCADStudio {
|
||||
/// paper-unit conversion, the way the commercial application writes
|
||||
/// "1:1" on an inch page setup over a millimetre paper space as
|
||||
/// `1 in = 25.4 units`.
|
||||
fn dialog_plot_scale_ratio(&self) -> ((f64, f64), Option<acadrust::objects::ScaledType>) {
|
||||
fn dialog_plot_scale_ratio(&self) -> ((f64, f64), Option<codec::objects::ScaledType>) {
|
||||
let d = &self.plot_dialog;
|
||||
let scene = &self.tabs[self.active_tab].scene;
|
||||
let factor = plot_dialog_scale_factor(d);
|
||||
@@ -3347,8 +3347,8 @@ impl OpenCADStudio {
|
||||
/// Everything the dialog has no control for (viewport-border and
|
||||
/// paper-update flags, the plot view handle, the paper unit that fixes
|
||||
/// the layout's coordinate system) is carried over from here untouched.
|
||||
fn dialog_base_settings(&self) -> acadrust::objects::PlotSettings {
|
||||
use acadrust::objects::{PlotPaperUnits, PlotSettings};
|
||||
fn dialog_base_settings(&self) -> codec::objects::PlotSettings {
|
||||
use codec::objects::{PlotPaperUnits, PlotSettings};
|
||||
let scene = &self.tabs[self.active_tab].scene;
|
||||
self.plot_setup_template
|
||||
.clone()
|
||||
@@ -3367,10 +3367,10 @@ impl OpenCADStudio {
|
||||
/// settings both come from here so the two can never drift apart.
|
||||
fn plot_settings_from_dialog(
|
||||
&self,
|
||||
mut ps: acadrust::objects::PlotSettings,
|
||||
) -> acadrust::objects::PlotSettings {
|
||||
mut ps: codec::objects::PlotSettings,
|
||||
) -> codec::objects::PlotSettings {
|
||||
use crate::io::paper_catalog::Orientation;
|
||||
use acadrust::objects::{
|
||||
use codec::objects::{
|
||||
PlotPaperUnits, PlotType, ScaledType, ShadePlotMode, ShadePlotResolutionLevel,
|
||||
};
|
||||
let d = &self.plot_dialog;
|
||||
@@ -3505,7 +3505,7 @@ impl OpenCADStudio {
|
||||
let (x0, y0) = (-left * units_per_mm, -bottom * units_per_mm);
|
||||
let (lw, lh) = (w * units_per_mm, h * units_per_mm);
|
||||
for obj in self.tabs[i].scene.document.objects.values_mut() {
|
||||
if let acadrust::objects::ObjectType::Layout(layout) = obj {
|
||||
if let codec::objects::ObjectType::Layout(layout) = obj {
|
||||
if layout.name == layout_name {
|
||||
layout.min_limits = (x0, y0);
|
||||
layout.max_limits = (x0 + lw, y0 + lh);
|
||||
@@ -4084,7 +4084,7 @@ impl OpenCADStudio {
|
||||
/// active page setup, no dialog. Model space only. (#325)
|
||||
pub(crate) fn on_quick_print_handles(
|
||||
&mut self,
|
||||
handles: Vec<acadrust::Handle>,
|
||||
handles: Vec<codec::Handle>,
|
||||
) -> Task<Message> {
|
||||
let i = self.active_tab;
|
||||
if self.tabs[i].scene.current_layout != "Model" {
|
||||
@@ -4092,7 +4092,7 @@ impl OpenCADStudio {
|
||||
.push_error(crate::t!("Quick print works in model space.").as_ref());
|
||||
return Task::none();
|
||||
}
|
||||
let set: std::collections::HashSet<acadrust::Handle> = handles.into_iter().collect();
|
||||
let set: std::collections::HashSet<codec::Handle> = handles.into_iter().collect();
|
||||
// Union the AABBs of the picked entities' wires (world XY), matched by
|
||||
// each wire's handle.
|
||||
let (x0, y0, x1, y1, any) = {
|
||||
@@ -5019,14 +5019,14 @@ impl OpenCADStudio {
|
||||
/// Build a `PlotSettings` from the current dialog fields (for saving a named
|
||||
/// page setup).
|
||||
/// The dialog's values as a named page setup.
|
||||
fn dialog_to_plotsettings(&self) -> acadrust::objects::PlotSettings {
|
||||
fn dialog_to_plotsettings(&self) -> codec::objects::PlotSettings {
|
||||
self.plot_settings_from_dialog(self.dialog_base_settings())
|
||||
}
|
||||
|
||||
/// Load a `PlotSettings` into the dialog editor fields.
|
||||
pub(in crate::app) fn load_plotsettings_into_dialog(&mut self, ps: &acadrust::objects::PlotSettings) {
|
||||
pub(in crate::app) fn load_plotsettings_into_dialog(&mut self, ps: &codec::objects::PlotSettings) {
|
||||
use crate::io::paper_catalog::PaperUnits;
|
||||
use acadrust::objects::{PlotType, ShadePlotMode, ShadePlotResolutionLevel};
|
||||
use codec::objects::{PlotType, ShadePlotMode, ShadePlotResolutionLevel};
|
||||
self.plot_setup_template = Some(ps.clone());
|
||||
if matches!(ps.plot_type, PlotType::Window) && !ps.plot_window.is_empty() {
|
||||
self.plot_window = Some((
|
||||
@@ -5109,7 +5109,7 @@ impl OpenCADStudio {
|
||||
}
|
||||
d.center = ps.flags.plot_centered;
|
||||
d.paper_units = match ps.paper_units {
|
||||
acadrust::objects::PlotPaperUnits::Inches => PaperUnits::Inches,
|
||||
codec::objects::PlotPaperUnits::Inches => PaperUnits::Inches,
|
||||
_ => PaperUnits::Millimeters,
|
||||
};
|
||||
d.offset_x = trim_decimals(&format!("{:.4}", d.paper_units.from_mm(ps.origin_x)));
|
||||
@@ -5671,7 +5671,7 @@ mod plot_paper_tests {
|
||||
ps.paper_width = 297.0;
|
||||
ps.paper_height = 210.0;
|
||||
// Such drivers spell the orientation in the dimensions, not the rotation.
|
||||
ps.rotation = acadrust::objects::PlotRotation::None;
|
||||
ps.rotation = codec::objects::PlotRotation::None;
|
||||
assert!(app.tabs[i].scene.set_layout_plot_settings("Layout1", &ps));
|
||||
app
|
||||
}
|
||||
@@ -5681,21 +5681,21 @@ mod plot_paper_tests {
|
||||
(ps.paper_size, ps.paper_width, ps.paper_height)
|
||||
}
|
||||
|
||||
fn layout_settings(app: &OpenCADStudio) -> acadrust::objects::PlotSettings {
|
||||
fn layout_settings(app: &OpenCADStudio) -> codec::objects::PlotSettings {
|
||||
app.tabs[app.active_tab]
|
||||
.scene
|
||||
.plot_settings_for("Layout1")
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
fn layout_rotation(app: &OpenCADStudio) -> acadrust::objects::PlotRotation {
|
||||
fn layout_rotation(app: &OpenCADStudio) -> codec::objects::PlotRotation {
|
||||
layout_settings(app).rotation
|
||||
}
|
||||
|
||||
/// Store the drawing's plot settings for `Layout1` after `edit` touched them.
|
||||
fn edit_layout_settings(
|
||||
app: &mut OpenCADStudio,
|
||||
edit: impl FnOnce(&mut acadrust::objects::PlotSettings),
|
||||
edit: impl FnOnce(&mut codec::objects::PlotSettings),
|
||||
) {
|
||||
let i = app.active_tab;
|
||||
let mut ps = app.tabs[i].scene.plot_settings_for("Layout1").unwrap();
|
||||
@@ -5705,7 +5705,7 @@ mod plot_paper_tests {
|
||||
|
||||
#[test]
|
||||
fn a_new_drawing_starts_with_a_compatible_default_layout() {
|
||||
use acadrust::objects::{PlotRotation, PlotType, ScaledType};
|
||||
use codec::objects::{PlotRotation, PlotType, ScaledType};
|
||||
let mut app = OpenCADStudio::new_for_test();
|
||||
app.automation_op(r#"{"op":"new"}"#);
|
||||
let _ = app.update(Message::LayoutSwitch("Layout1".into()));
|
||||
@@ -5729,7 +5729,7 @@ mod plot_paper_tests {
|
||||
|
||||
#[test]
|
||||
fn orientation_is_stored_as_a_rotation_of_the_medium() {
|
||||
use acadrust::objects::PlotRotation as R;
|
||||
use codec::objects::PlotRotation as R;
|
||||
use crate::ui::window::plot::PlotFlag;
|
||||
// A newly picked sheet is the catalogue's portrait medium…
|
||||
let portrait_medium = [
|
||||
@@ -5777,7 +5777,7 @@ mod plot_paper_tests {
|
||||
|
||||
#[test]
|
||||
fn standard_scales_are_written_by_code_and_others_as_ratios() {
|
||||
use acadrust::objects::ScaledType;
|
||||
use codec::objects::ScaledType;
|
||||
let mut app = app_with_printer_named_sheet();
|
||||
let _ = app.on_plot_dialog_open();
|
||||
let _ = app.on_plot_dlg(PlotDlgMsg::Area("Extents".into()));
|
||||
@@ -5825,7 +5825,7 @@ mod plot_paper_tests {
|
||||
|
||||
#[test]
|
||||
fn a_metre_drawing_stores_the_millimetres_it_really_plots_per_unit() {
|
||||
use acadrust::objects::ScaledType;
|
||||
use codec::objects::ScaledType;
|
||||
let mut app = app_with_printer_named_sheet();
|
||||
// Insertion units: metres. "1:100" then plots 10 mm per drawing unit.
|
||||
app.tabs[app.active_tab].scene.document.header.insertion_units = 6;
|
||||
@@ -5845,7 +5845,7 @@ mod plot_paper_tests {
|
||||
|
||||
#[test]
|
||||
fn an_inch_layout_keeps_its_unit_and_converts_the_scale() {
|
||||
use acadrust::objects::{PlotPaperUnits, ScaledType};
|
||||
use codec::objects::{PlotPaperUnits, ScaledType};
|
||||
let mut app = app_with_printer_named_sheet();
|
||||
edit_layout_settings(&mut app, |ps| ps.paper_units = PlotPaperUnits::Inches);
|
||||
let _ = app.on_plot_dialog_open();
|
||||
@@ -5908,8 +5908,8 @@ mod plot_paper_tests {
|
||||
assert_eq!(layout.flags, named.flags);
|
||||
assert_eq!(layout.shade_plot_mode, named.shade_plot_mode);
|
||||
assert_eq!(layout.shade_plot_resolution, named.shade_plot_resolution);
|
||||
assert_eq!(named.rotation, acadrust::objects::PlotRotation::Degrees270);
|
||||
assert_eq!(named.scale_type, acadrust::objects::ScaledType::OneToFifty);
|
||||
assert_eq!(named.rotation, codec::objects::PlotRotation::Degrees270);
|
||||
assert_eq!(named.scale_type, codec::objects::ScaledType::OneToFifty);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -5952,7 +5952,7 @@ mod plot_paper_tests {
|
||||
}
|
||||
|
||||
/// The page-setup fields the file format stores, minus handles.
|
||||
fn stored_fields(ps: &acadrust::objects::PlotSettings) -> String {
|
||||
fn stored_fields(ps: &codec::objects::PlotSettings) -> String {
|
||||
format!(
|
||||
"{} | {} | {:?} | {:.6} {:.6} | {:.6} {:.6} {:.6} {:.6} | {:.6} {:.6} | {} {} \
|
||||
| {:.6} / {:.6} | {:.9} | {:?} | {:?} | {:?} {:?} {}",
|
||||
@@ -5986,7 +5986,7 @@ mod plot_paper_tests {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
#[test]
|
||||
fn fixture_page_setups_round_trip_through_the_dialog_unchanged() {
|
||||
use acadrust::objects::{PlotRotation, ScaledType};
|
||||
use codec::objects::{PlotRotation, ScaledType};
|
||||
let mut app = app_with_fixture();
|
||||
let a3_medium = (297.0106506347656, 419.9889831542968);
|
||||
let arch_d_medium = (914.4000244140626, 609.5999755859375);
|
||||
@@ -6031,7 +6031,7 @@ mod plot_paper_tests {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
#[test]
|
||||
fn fixture_pdf_layout_takes_a_new_sheet_in_canonical_form() {
|
||||
use acadrust::objects::{PaperMargin, PlotRotation};
|
||||
use codec::objects::{PaperMargin, PlotRotation};
|
||||
let mut app = app_with_fixture();
|
||||
let _ = app.update(Message::LayoutSwitch("A4 1-100".into()));
|
||||
let _ = app.on_plot_dialog_open();
|
||||
@@ -6068,7 +6068,7 @@ mod plot_paper_tests {
|
||||
|
||||
#[test]
|
||||
fn switching_the_page_setup_unit_respells_offsets_and_keeps_the_output() {
|
||||
use acadrust::objects::{PlotPaperUnits, ScaledType};
|
||||
use codec::objects::{PlotPaperUnits, ScaledType};
|
||||
use crate::ui::window::plot::PlotFlag;
|
||||
let mut app = app_with_printer_named_sheet();
|
||||
let _ = app.on_plot_dialog_open();
|
||||
@@ -6107,7 +6107,7 @@ mod plot_paper_tests {
|
||||
|
||||
#[test]
|
||||
fn custom_scale_fields_follow_and_drive_the_picker() {
|
||||
use acadrust::objects::ScaledType;
|
||||
use codec::objects::ScaledType;
|
||||
use crate::ui::window::plot::PlotFlag;
|
||||
let mut app = app_with_printer_named_sheet();
|
||||
let _ = app.on_plot_dialog_open();
|
||||
@@ -6235,7 +6235,7 @@ mod plot_paper_tests {
|
||||
assert_eq!(name, "A4", "the driver's own spelling must survive the dialog");
|
||||
// …and so must the driver's landscape medium: unrotated, as stored.
|
||||
assert_eq!((w, h), (297.0, 210.0));
|
||||
assert_eq!(layout_rotation(&app), acadrust::objects::PlotRotation::None);
|
||||
assert_eq!(layout_rotation(&app), codec::objects::PlotRotation::None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -6248,7 +6248,7 @@ mod plot_paper_tests {
|
||||
let (name, w, h) = layout_paper(&app);
|
||||
assert_eq!(name, "ISO_A3_(297.00_x_420.00_MM)");
|
||||
assert_eq!((w, h), (297.0, 420.0));
|
||||
assert_eq!(layout_rotation(&app), acadrust::objects::PlotRotation::Degrees90);
|
||||
assert_eq!(layout_rotation(&app), codec::objects::PlotRotation::Degrees90);
|
||||
// The next dialog remembers the sheet the user chose.
|
||||
assert_eq!(app.plot_paper.canonical, "ISO_A3_(297.00_x_420.00_MM)");
|
||||
}
|
||||
@@ -6262,7 +6262,7 @@ mod plot_paper_tests {
|
||||
let ps = app.tabs[app.active_tab].scene.plot_settings_for("Layout1").unwrap();
|
||||
assert_eq!(ps.printer_name, "DWG To PDF.pc3");
|
||||
// A changed device takes the PDF driver's printable area for the sheet.
|
||||
assert_eq!(ps.margins, acadrust::objects::PaperMargin::new(5.0, 17.0, 6.0, 18.0));
|
||||
assert_eq!(ps.margins, codec::objects::PaperMargin::new(5.0, 17.0, 6.0, 18.0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -6286,7 +6286,7 @@ mod plot_paper_tests {
|
||||
let mut ps = app.tabs[i].scene.plot_settings_for("Layout1").unwrap();
|
||||
ps.printer_name = "DWF6 ePlot.pc3".into();
|
||||
ps.paper_size = "ISO_A4_(210.00_x_297.00_MM)".into();
|
||||
ps.margins = acadrust::objects::PaperMargin::new(5.793749, 17.793753, 5.793744, 17.793747);
|
||||
ps.margins = codec::objects::PaperMargin::new(5.793749, 17.793753, 5.793744, 17.793747);
|
||||
assert!(app.tabs[i].scene.set_layout_plot_settings("Layout1", &ps));
|
||||
let _ = app.on_plot_dialog_open();
|
||||
assert!(app.plot_dialog.to_file, "an unknown plotter plots to PDF here");
|
||||
@@ -6303,18 +6303,18 @@ mod plot_paper_tests {
|
||||
let mut ps = app.tabs[i].scene.plot_settings_for("Layout1").unwrap();
|
||||
ps.printer_name = "DWG To PDF.pc3".into();
|
||||
ps.paper_size = "ISO_A4_(210.00_x_297.00_MM)".into();
|
||||
ps.margins = acadrust::objects::PaperMargin::new(5.0, 17.0, 6.0, 18.0);
|
||||
ps.margins = codec::objects::PaperMargin::new(5.0, 17.0, 6.0, 18.0);
|
||||
assert!(app.tabs[i].scene.set_layout_plot_settings("Layout1", &ps));
|
||||
let _ = app.on_plot_dialog_open();
|
||||
let _ = app.on_plot_dlg(PlotDlgMsg::Paper("ISO_full_bleed_A4_(210.00_x_297.00_MM)".into()));
|
||||
let _ = app.on_plot_dlg(PlotDlgMsg::SetCurrent);
|
||||
let ps = app.tabs[i].scene.plot_settings_for("Layout1").unwrap();
|
||||
assert_eq!(ps.paper_size, "ISO_full_bleed_A4_(210.00_x_297.00_MM)");
|
||||
assert_eq!(ps.margins, acadrust::objects::PaperMargin::new(0.0, 1.0, 0.0, 1.0));
|
||||
assert_eq!(ps.margins, codec::objects::PaperMargin::new(0.0, 1.0, 0.0, 1.0));
|
||||
let _ = app.on_plot_dlg(PlotDlgMsg::Paper("ISO_A3_(297.00_x_420.00_MM)".into()));
|
||||
let _ = app.on_plot_dlg(PlotDlgMsg::SetCurrent);
|
||||
let ps = app.tabs[i].scene.plot_settings_for("Layout1").unwrap();
|
||||
assert_eq!(ps.margins, acadrust::objects::PaperMargin::new(5.0, 17.0, 6.0, 18.0));
|
||||
assert_eq!(ps.margins, codec::objects::PaperMargin::new(5.0, 17.0, 6.0, 18.0));
|
||||
assert_eq!((ps.paper_width, ps.paper_height), (297.0, 420.0));
|
||||
}
|
||||
|
||||
@@ -6364,8 +6364,8 @@ mod plot_paper_tests {
|
||||
let ps = app.tabs[app.active_tab].scene.plot_settings_for("Layout1").unwrap();
|
||||
assert_eq!(ps.paper_size, "Roll_24_(609.60_x_1500.00_MM)");
|
||||
assert_eq!((ps.paper_width, ps.paper_height), (609.6, 1500.0));
|
||||
assert_eq!(ps.rotation, acadrust::objects::PlotRotation::Degrees90);
|
||||
assert_eq!(ps.margins, acadrust::objects::PaperMargin::new(3.0, 17.0, 6.0, 4.0));
|
||||
assert_eq!(ps.rotation, codec::objects::PlotRotation::Degrees90);
|
||||
assert_eq!(ps.margins, codec::objects::PaperMargin::new(3.0, 17.0, 6.0, 4.0));
|
||||
// Re-adding the same size replaces the definition instead of duplicating it.
|
||||
let _ = app.on_plot_dlg(custom(C::Open));
|
||||
assert_eq!(app.plot_dialog.custom_editor.as_ref().map(|d| d.name.as_str()), Some("Roll 24"));
|
||||
@@ -6485,7 +6485,7 @@ cupsPrintQuality/Print Quality: *Normal High\n";
|
||||
assert_eq!(name, "Roll_24_(609.60_x_1500.00_MM)");
|
||||
// The drawing's own landscape medium stays as it was stored.
|
||||
assert_eq!((w, h), (1500.0, 609.6));
|
||||
assert_eq!(layout_rotation(&app), acadrust::objects::PlotRotation::None);
|
||||
assert_eq!(layout_rotation(&app), codec::objects::PlotRotation::None);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6502,7 +6502,7 @@ mod plot_device_persistence_tests {
|
||||
let mut app = OpenCADStudio::new_for_test();
|
||||
// A real drawing's layout carries plot settings with no device; the
|
||||
// auto-applied setup used to reset the choice to the default.
|
||||
let mut ps = acadrust::objects::PlotSettings::default();
|
||||
let mut ps = codec::objects::PlotSettings::default();
|
||||
ps.printer_name = String::new();
|
||||
let layout = app.tabs[app.active_tab].scene.current_layout.clone();
|
||||
assert!(
|
||||
@@ -6528,7 +6528,7 @@ mod plot_device_persistence_tests {
|
||||
fn layout_device_overrides_the_saved_preference() {
|
||||
let mut app = OpenCADStudio::new_for_test();
|
||||
app.plot_dialog.printer = Some("Brother DCP-L2520D series".into());
|
||||
let mut ps = acadrust::objects::PlotSettings::default();
|
||||
let mut ps = codec::objects::PlotSettings::default();
|
||||
ps.printer_name = "Godex G500".into();
|
||||
app.load_plotsettings_into_dialog(&ps);
|
||||
assert_eq!(app.plot_dialog.printer.as_deref(), Some("Godex G500"));
|
||||
@@ -6553,8 +6553,8 @@ mod plot_device_persistence_tests {
|
||||
#[test]
|
||||
fn layout_window_is_mirrored_into_the_dialog() {
|
||||
let mut app = OpenCADStudio::new_for_test();
|
||||
let mut ps = acadrust::objects::PlotSettings::default();
|
||||
ps.plot_type = acadrust::objects::PlotType::Window;
|
||||
let mut ps = codec::objects::PlotSettings::default();
|
||||
ps.plot_type = codec::objects::PlotType::Window;
|
||||
ps.set_plot_window(1.0, 2.0, 3.0, 4.0);
|
||||
app.load_plotsettings_into_dialog(&ps);
|
||||
assert_eq!(app.plot_window, Some((1.0, 2.0, 3.0, 4.0)));
|
||||
@@ -6566,7 +6566,7 @@ mod plot_device_persistence_tests {
|
||||
fn pdf_device_switches_to_file_output() {
|
||||
let mut app = OpenCADStudio::new_for_test();
|
||||
app.plot_dialog.printer = Some("Brother DCP-L2520D series".into());
|
||||
let mut ps = acadrust::objects::PlotSettings::default();
|
||||
let mut ps = codec::objects::PlotSettings::default();
|
||||
ps.printer_name = "Microsoft Print to PDF".into();
|
||||
app.load_plotsettings_into_dialog(&ps);
|
||||
assert!(app.plot_dialog.to_file);
|
||||
|
||||
Reference in new issue
Block a user