mirror of
https://github.com/storytold/cadcraft.git
synced 2026-10-27 12:27:04 -06:00
A PlotStyleTable model in doc with our own built-in tables (default.ctb keeps object properties, monochrome.ctb prints black, grayscale.ctb prints the grey of each colour's luminance). The render builder resolves each object's style by its index colour (true colours by the nearest index) and applies colour, screening, linetype and lineweight. PLOT/EXPORTPDF use the page setup's table (or the plotStyleTable option); layouts with Display plot styles (PAGESETUP displayPlotStyles, DXF plot flag 2) show it on screen and in PNG/SVG exports. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
21 lines
1.1 KiB
Rust
21 lines
1.1 KiB
Rust
//! PAGESETUP: the plot style table and "Display plot styles" of a layout (issue #410).
|
|
|
|
use cadcraft_engine::Session;
|
|
use serde_json::json;
|
|
|
|
#[test]
|
|
fn pagesetup_sets_table_and_display_flag() {
|
|
let mut s = Session::new();
|
|
let r = s.execute("pagesetup", &json!({"layout": "Layout1", "plotStyleTable": "monochrome.ctb", "displayPlotStyles": true})).unwrap();
|
|
assert_eq!(r["page"]["plotStyleTable"], "monochrome.ctb");
|
|
assert_eq!(r["page"]["showPlotStyles"], true);
|
|
let page = &s.doc().unwrap().layout("Layout1").unwrap().page;
|
|
assert!(page.show_plot_styles && page.plot_style_table == "monochrome.ctb");
|
|
// The report lists the built-in tables.
|
|
let report = s.execute("pagesetup", &json!({})).unwrap();
|
|
let tables: Vec<&str> = report["plotStyleTables"].as_array().unwrap().iter().filter_map(|v| v.as_str()).collect();
|
|
assert!(tables.contains(&"monochrome.ctb") && tables.contains(&"grayscale.ctb"), "{tables:?}");
|
|
s.execute("pagesetup", &json!({"layout": "Layout1", "displayPlotStyles": false})).unwrap();
|
|
assert!(!s.doc().unwrap().layout("Layout1").unwrap().page.show_plot_styles);
|
|
}
|