ConstructCraft

cc_views API

← API reference · Generated from the source by cargo run -p api_doc; edit the doc comments, not this page.

View generation for ConstructCraft. Each cc_core::View is a query over the model. generate produces a resolution-independent Drawing2D for graphical views; schedule computes tables.

Modules

Module Items Summary
cc_views 4 View generation for ConstructCraft.
cc_views::annotate 12 Annotations drawn over views: room, door and window tags, grids and dimensions.
cc_views::bar_tags 3 Bar tags in plans, elevations and sections (see cc_core::bar_tag): the text 2x 25 N1 Ø12.5 c/12 C=500 derived from the tagged set, with an optional leader, and the set’s bars drawn as thin lines in that view (no view draws reinforcement otherwise, so a tag always points at its bars; bars seen end-on are dots).
cc_views::bending 14 Bending schedules: a reinforcement schedule with one row per bar mark (mark, diameter, grade, a sketch of the shape with its dimensions, the length of one bar, the count, the total length and the weight; rows of bars longer than the stock length noted) and a summary per diameter and grade under it (total length and weight, with the waste added when the schedule gives one).
cc_views::cad 3 Imported CAD drawings (underlays) in the view they belong to: pictures, then thin lines in their own pen (grey, black or the layer colors, faded when the element asks), fills and texts, all below the model’s linework and picked only when nothing of the model is under the pointer.
cc_views::callout 3 Crop regions and callout marks (see cc_core::callout).
cc_views::component_view 6 Views of a component definition for the modeling environment: the pieces seen from above, the front, the right or in a 3D axonometric, with the reference planes seen edge-on as dash-dot lines named at one end, the reference lines of that view and the dimensions between planes (labeled ones show their parameter).
cc_views::cut 5 Fills of cut regions (plans and sections) from the material’s cut pattern.
cc_views::detail 3 Detail lines in the view they belong to: each curve as short segments in its style’s own pen (width, color, dash pattern; built-in or one of the project’s line styles), on top of the model’s linework.
cc_views::detail_component 5 Detail components in the view they belong to (see cc_core::detail_component), in id order over the model and the view’s regions, under its detail lines and annotations: each one’s pieces and those of the components it nests, through its placement (position, rotation, mirror, scale).
cc_views::diagram 1 The single-line diagram of a distribution board with its load schedule: the supply and main breaker, the busbar and one branch per circuit with its breaker, conductor and load, then a table of the circuits (from cc_geom::sizing).
cc_views::drawing 9  
cc_views::drawing_index 1 Lookups over a drawing’s primitives: the primitives of each element and a grid of the pickable ones, so picking under the pointer does not walk every primitive of a large drawing (an imported DXF holds 100 000).
cc_views::dxf 9 DXF export of drawings, for exchanging 2D views with other CAD programs.
cc_views::export 5 Vector export of drawings in paper millimeters (composed sheets) to SVG and PDF.
cc_views::fonts 4 Fallback fonts for the scripts Inter lacks (Chinese, Japanese, Korean, Lao), found among the fonts operating systems usually ship and read once.
cc_views::format 50 Number formatting for drawings, schedules and the interface.
cc_views::graphics 5 View graphics applied to drawings: hidden categories, filters and elements leave the drawing, as do elements the view’s phase and phase filter leave out, and the resolved overrides change the pens of lines and the colors and patterns of fills (see cc_core::graphics and cc_core::phase).
cc_views::hatch 9 Hatch patterns: the line work of a material Pattern clipped to a polygon.
cc_views::joins 1 Joined geometry in cut views (plans and sections): the outline of the element that is cut stops where the cutting element begins, the cutting element is painted over it, and when both are cut in the same material the line between them goes, so they read as one piece.
cc_views::legend 1  
cc_views::level_marks 2 Level marks: the finished level above a shelf line and the raw level under it, beside a symbol on the point measured.
cc_views::mep 5 Building services in plans: pipes and conduits as bands in their system’s color with diameter, slope and circuit tags, cable trays as outlines as wide as they are, valves on pipes, and electrical devices as the usual plan symbols (sizes in paper millimeters).
cc_views::notes 11 Text notes and their leaders.
cc_views::plan 8  
cc_views::projected 12 Orthographic projected views: elevations, sections and axonometrics, with painter’s-algorithm hidden surface removal.
cc_views::raster 4 Imported pictures: reading their size and decoding their pixels.
cc_views::region 5 Filled and masking regions in the view they belong to (see cc_core::region), in id order, over the model’s linework and under the view’s annotations: a filled region as its type’s fill (a solid color, or a clear background under pattern lines), a masking region opaque white; then the boundary in its line style, when it has one.
cc_views::schedule 10 Schedules: one row per element of a category, one column per field of the schedule definition, with filtering, sorting and totals.
cc_views::shadow 17 The shadows a view’s sun casts in projected views and plans, as exact polygons (see crate::projected::render).
cc_views::sheet 6 Sheet composition: the title block and the placed viewports, as one drawing in paper millimeters (origin at the bottom-left corner).
cc_views::sheet_fields 5 {fields} in title block texts: sheet, project and date values, and the title block’s per-sheet parameters.
cc_views::sun_path 34 The sun path diagram of a view with a sun (cc_core::View::sun with show_path): a compass ring turned to true north on the ground, the sky dome’s path of the sun over the day shown (and, over several days, over the first and last), its whole hours, sunrise, sunset and the date, and the sun where it stands.
cc_views::topography 1 Terrain in floor plans: contour lines (majors heavier) and the boundary below the cut plane; where the cut plane crosses the surface, the earth above it hatched in the type’s material and outlined as cut.

cc_views

crates/cc_views/src/lib.rs

Re-exports

Items: generate · generate_labeled · generate_temporary · hosts_cad

fn generate

pub fn generate(project: &Project, geom: &ModelGeometry, view: &View) -> Option<Drawing2D>

Drawing for any graphical view (None for schedules and sheets), with the headings of diagrams left as their translation keys.

fn generate_labeled

pub fn generate_labeled(project: &Project, geom: &ModelGeometry, view: &View, label: &dyn Fn(&str) -> String) -> Option<Drawing2D>

Drawing for any graphical view, with the view’s graphics applied; label translates the headings drawn by the view itself (diagrams).

fn generate_temporary

pub fn generate_temporary(project: &Project, geom: &ModelGeometry, view: &View, label: &dyn Fn(&str) -> String, temporary: Option<&cc_core::TemporaryVisibility>) -> Option<Drawing2D>

Drawing for any graphical view with its graphics and, when given, the elements temporarily hidden or isolated in it.

fn hosts_cad

pub fn hosts_cad(kind: &ViewKind) -> bool

Whether a view can hold imported CAD drawings: plans, ceiling plans, elevations, sections, legends and drafting views (2D views with a drawing plane).

cc_views::annotate

crates/cc_views/src/annotate.rs

Annotations drawn over views: room, door and window tags, grids and dimensions. Sizes are given in paper millimeters and converted with the view scale, so annotations read the same at any scale.

Items: HIGHLIGHT_ONLY · TagOffsets · plan_annotations · section_label · structure_tags · projected_grids · dimension_type · dimensions · draw_dimension · draw_marks · DimensionLayout · dimension_layout

const HIGHLIGHT_ONLY

pub const HIGHLIGHT_ONLY: [u8; 4]

Fill color that is invisible but highlights when the element is selected.

type alias TagOffsets

pub type TagOffsets = std::collections::BTreeMap<cc_core::ElementId, DVec2>

Tags a view moved by hand: offsets in plan by the element they tag.

fn plan_annotations

pub fn plan_annotations(d: &mut Drawing2D, project: &Project, geom: &ModelGeometry, level: LevelId, ceiling: bool, structural: bool, view: &cc_core::View)

Tags of rooms and openings, and grids, for a floor or ceiling plan of level.

fn section_label

pub fn section_label(project: &Project, data: &TypeData) -> Option<String>

A steel or cold-formed profile’s name (IPE 200), else the section’s size in centimeters (inches in imperial units): 15×40, Ø30.

fn structure_tags

pub fn structure_tags(d: &mut Drawing2D, project: &Project, geom: &ModelGeometry, level: LevelId, scale: u32, offsets: &TagOffsets)

Tags of the beams, columns, pad footings and pile caps of level: their mark and section (V1 15×40). Beam tags run along the beam, beside it; column and footing tags sit above and to the right.

fn projected_grids

pub fn projected_grids(d: &mut Drawing2D, project: &Project, frame: &crate::projected::Frame, scale: u32)

Grids in an elevation or a section looking through frame (issue #332): each grid running square to the view’s plane, as a vertical line where it stands with its bubble on top, as tall as what the view draws. A section shows the grids that cross what it sees: between the ends of its line, and between its cut and its depth. They belong to their grid, so the view’s graphics hide them with the category or one by one.

fn dimension_type

pub fn dimension_type(project: &Project, type_id: cc_core::ElementTypeId) -> (f64, DimensionStyle)

The text size and style of a dimension type (the defaults for a missing one).

fn dimensions

pub fn dimensions(d: &mut Drawing2D, project: &Project, view: ViewId, scale: u32)

Dimensions placed in view, in its drawing coordinates.

fn draw_dimension

pub fn draw_dimension(d: &mut Drawing2D, layout: &DimensionLayout, style: &DimensionStyle, text_size: f64, scale: u32, id: Option<cc_core::ElementId>)

Draw a laid-out dimension: lines, marks, the box behind an opaque text, and the text.

fn draw_marks

pub fn draw_marks(d: &mut Drawing2D, layout: &DimensionLayout, style: &DimensionStyle, scale: u32, id: Option<cc_core::ElementId>)

The marks at the ends of a laid-out dimension line.

struct DimensionLayout

pub struct DimensionLayout

Linework and text of a dimension, in its view’s drawing coordinates.

Traits: Debug, Clone, PartialEq

Fields

fn dimension_layout

pub fn dimension_layout(dim: &Dimension, scale: u32, style: &DimensionStyle) -> Option<DimensionLayout>

Lay out a dimension at a view scale as style says; None when it measures nothing.

cc_views::bar_tags

crates/cc_views/src/bar_tags.rs

Bar tags in plans, elevations and sections (see cc_core::bar_tag): the text 2x 25 N1 Ø12.5 c/12 C=500 derived from the tagged set, with an optional leader, and the set’s bars drawn as thin lines in that view (no view draws reinforcement otherwise, so a tag always points at its bars; bars seen end-on are dots). Sizes are paper millimeters at the view scale.

Items: text · takes_tags · bar_tags

fn text

pub fn text(project: &Project, geom: &ModelGeometry, marks: &BarMarks, tag: &BarTag) -> Option<String>

The text of tag: its parts, from the tagged set’s bars (in geom) and their marks; None when the set has no bars there.

fn takes_tags

pub fn takes_tags(view: &View) -> bool

Whether view takes bar tags: plans, elevations and sections.

fn bar_tags

pub fn bar_tags(d: &mut Drawing2D, project: &Project, geom: &ModelGeometry, view: &View)

The bar tags of view, with the bars of the sets they tag.

cc_views::bending

crates/cc_views/src/bending.rs

Bending schedules: a reinforcement schedule with one row per bar mark (mark, diameter, grade, a sketch of the shape with its dimensions, the length of one bar, the count, the total length and the weight; rows of bars longer than the stock length noted) and a summary per diameter and grade under it (total length and weight, with the waste added when the schedule gives one). Every total is the exact sum of the bars it counts: a row adds its bars’ lengths and weights, the totals and the summary add the rows, so the summary per diameter equals the sum of the individual bars. The shape of a mark is written as a code (CSV, the app’s table): straight 500, L 30-470, U 30-470-30, Z …, bent …, stirrup 14x44, ring R=50 L=314, closed …, arc R=220 L=345, legs of arcs as (R=… L=…); lengths as format::bar_length writes them. Sheets draw a sketch instead (BarSketch): the bar’s legs laid flat in order, to proportion (very short straight legs drawn longer), normalized into the cell, each leg labelled with its length.

Items: SKETCH_ROW · SKETCH_WIDTH · SKETCH_TEXT · BarSketch · SketchLabel · shape_code · sketch_of · draw_sketch · diameter_text · BendingRow · DiameterTotal · Bending · bending · table

const SKETCH_ROW

pub const SKETCH_ROW: f64

Height of a row with a sketch, paper millimeters.

const SKETCH_WIDTH

pub const SKETCH_WIDTH: f64

Narrowest column of sketches, paper millimeters.

const SKETCH_TEXT

pub const SKETCH_TEXT: f64

Text height of the sketches’ dimensions, paper millimeters.

struct BarSketch

pub struct BarSketch

A bar’s shape drawn for a schedule: one polyline per leg in the sketch’s own frame (meters, schematic) and the dimensions.

Traits: Debug, Clone, PartialEq, Default

Fields

struct SketchLabel

pub struct SketchLabel

A dimension of a sketch: its text, the point of the leg it stands by and the unit direction it stands off to.

Traits: Debug, Clone, PartialEq

Fields

fn shape_code

pub fn shape_code(shape: &ShapeSummary) -> String

The code of a shape (see the module’s documentation).

fn sketch_of

pub fn sketch_of(shape: &ShapeSummary) -> BarSketch

The sketch of a shape (see BarSketch): its legs laid flat one after another, each bend turning the way the bar turns, the longest straight leg along x and the rest above it, short straight legs of open bars drawn longer, each leg labelled with its length (arcs also with their radius).

fn draw_sketch

pub fn draw_sketch(d: &mut Drawing2D, sketch: &BarSketch, (lo, hi): (DVec2, DVec2), k: f64)

Draw sketch into the cell from lo to hi (paper millimeters, y up) of a drawing at k meters per paper millimeter.

fn diameter_text

pub fn diameter_text(diameter: f64) -> String

A rebar diameter as schedules write it (Ø 12,5 mm, Ø 1/2").

struct BendingRow

pub struct BendingRow

One row of a bending schedule: the bars of one mark (in one partition when grouped), with exact sums.

Traits: Debug, Clone, PartialEq

Fields

struct DiameterTotal

pub struct DiameterTotal

The total of one diameter and grade: the rows of it added up.

Traits: Debug, Clone, PartialEq

Fields

struct Bending

pub struct Bending

A bending schedule’s numbers: the marks, the rows in order and the totals per diameter and grade (diameters ascending).

Traits: Debug, Clone, PartialEq, Default

Fields

fn bending

pub fn bending(project: &Project, geom: &ModelGeometry, options: &BendingOptions, keep: &mut dyn FnMut(&Element) -> bool) -> Bending

The rows and totals of a bending schedule of the reinforcement sets keep accepts (those a view’s phase and options show) and options lets through. Marks are resolved over the whole model, so they read the same in every schedule. Each row adds its bars in set and bar order; the totals add the rows in order.

fn table

pub fn table(project: &Project, geom: &ModelGeometry, def: &ScheduleDef, options: &BendingOptions, keep: &mut dyn FnMut(&Element) -> bool) -> Table

The bending schedule as a table (see bending): a row per mark (under a heading per partition when grouped), the totals, and the summary per diameter under it.

cc_views::cad

crates/cc_views/src/cad.rs

Imported CAD drawings (underlays) in the view they belong to: pictures, then thin lines in their own pen (grey, black or the layer colors, faded when the element asks), fills and texts, all below the model’s linework and picked only when nothing of the model is under the pointer.

Items: GREY · underlays · draw

const GREY

pub const GREY: [u8; 3]

The grey of CadColorMode::Grey.

fn underlays

pub fn underlays(d: &mut Drawing2D, project: &Project, view: ViewId, scale: u32)

Draw the imported drawings of view under what d holds.

fn draw

pub fn draw(d: &mut Drawing2D, c: &CadImport, id: ElementId, scale: u32)

One imported drawing, in view coordinates.

cc_views::callout

crates/cc_views/src/callout.rs

Crop regions and callout marks (see cc_core::callout).

Items: CalloutHandle · marks · crop

struct CalloutHandle

pub struct CalloutHandle

A callout’s mark in its parent, as drawn (meters on the parent’s plane).

Traits: Debug, Clone, Copy, PartialEq

Fields

Methods

fn marks

pub(crate) fn marks(d: &mut Drawing2D, project: &Project, view: &View)

The marks of the callouts drawn in view, each listed in d.callouts.

fn crop

pub(crate) fn crop(d: &mut Drawing2D, project: &Project, view: ViewId, rect: CropBox)

Crop the drawing of view to rect: lines and fills of the model (and of anything not owned by the view) are clipped to it, texts and pictures outside it dropped; what the view owns (detail lines, regions, notes, dimensions…) is kept whole.

cc_views::component_view

crates/cc_views/src/component_view.rs

Views of a component definition for the modeling environment: the pieces seen from above, the front, the right or in a 3D axonometric, with the reference planes seen edge-on as dash-dot lines named at one end, the reference lines of that view and the dimensions between planes (labeled ones show their parameter). Coordinates are the view’s own (u, v) in meters, as SketchPlane defines them: plan x, y; front x, z; side y, z. Lines carry no element: the environment picks planes and dimensions from the lists returned.

Items: ComponentViewKind · ViewPlane · ViewDimension · ViewConnector · ComponentView · component_view

enum ComponentViewKind

pub enum ComponentViewKind

The views of the environment.

Traits: Debug, Clone, Copy, PartialEq, Eq, Hash, Default

Variants

Methods

struct ViewPlane

pub struct ViewPlane

A reference plane seen edge-on: its name and the ends of its line.

Traits: Debug, Clone, PartialEq

Fields

struct ViewDimension

pub struct ViewDimension

A dimension between planes as drawn: where its text sits.

Traits: Debug, Clone, PartialEq

Fields

struct ViewConnector

pub struct ViewConnector

A connector as seen in a view: where it is and which way runs leave it.

Traits: Debug, Clone, PartialEq

Fields

struct ComponentView

pub struct ComponentView

A view of a component: its drawing and what can be picked in it.

Traits: Debug, Clone, Default

Fields

fn component_view

pub fn component_view(def: &ComponentDef, overrides: &BTreeMap<String, f64>, kind: ComponentViewKind, scale: u32) -> ComponentView

The component def (with instance overrides) in kind, drawn at a view scale (for text and dimension sizes).

cc_views::cut

crates/cc_views/src/cut.rs

Fills of cut regions (plans and sections) from the material’s cut pattern.

Items: POCHE · PATTERN_MM · spacing · cut_fill · cut_fill_with_holes

const POCHE

pub(crate) const POCHE: [u8; 4]

Neutral fill of cut regions whose material has no cut pattern.

const PATTERN_MM

pub(crate) const PATTERN_MM: f64

Base spacing of hatch patterns on paper, millimeters.

fn spacing

pub(crate) fn spacing(scale: u32) -> f64

Hatch spacing in drawing units for a view at 1:scale.

fn cut_fill

pub(crate) fn cut_fill(d: &mut Drawing2D, project: &Project, material: &str, poly: Vec<DVec2>, spacing: f64, id: Option<ElementId>)

Fill poly with the cut pattern of material (or the neutral poche).

fn cut_fill_with_holes

pub(crate) fn cut_fill_with_holes(d: &mut Drawing2D, project: &Project, material: &str, outer: &[DVec2], holes: &[Vec<DVec2>], spacing: f64, id: Option<ElementId>)

cut_fill of a region with holes: one keyhole ring (triangles when no ring can be made), the pattern lines clipped out of the holes.

cc_views::detail

crates/cc_views/src/detail.rs

Detail lines in the view they belong to: each curve as short segments in its style’s own pen (width, color, dash pattern; built-in or one of the project’s line styles), on top of the model’s linework. View graphics override them like any line.

Items: pen · draw · lines

fn pen

pub fn pen(style: LineStyleRef, styles: &LineStyles) -> Pen

The pen of a line style.

fn draw

pub fn draw(d: &mut Drawing2D, line: &DetailLine, styles: &LineStyles, id: Option<ElementId>)

Draw one detail line.

fn lines

pub fn lines(d: &mut Drawing2D, project: &Project, view: ViewId)

The detail lines of view.

cc_views::detail_component

crates/cc_views/src/detail_component.rs

Detail components in the view they belong to (see cc_core::detail_component), in id order over the model and the view’s regions, under its detail lines and annotations: each one’s pieces and those of the components it nests, through its placement (position, rotation, mirror, scale). Pictures first, then strokes (a closed one’s solid or pattern fill under its lines), then texts, as title blocks draw theirs; lengths are meters, pen weights paper millimeters, text heights meters turned into paper millimeters by the view’s scale.

Items: def_of · components · draw · draw_pieces · dxf_blocks

fn def_of

pub fn def_of<'a>(project: &'a Project, e: &cc_core::Element) -> Option<(&'a str, &'a ComponentDef)>

The definition and component name of an element’s type, if it is a detail component.

fn components

pub fn components(d: &mut Drawing2D, project: &Project, view: ViewId, scale: u32)

The detail components of view, at 1:scale.

fn draw

pub fn draw(d: &mut Drawing2D, project: &Project, name: &str, def: &ComponentDef, overrides: &std::collections::BTreeMap<String, f64>, place: Place, scale: u32, id: Option<ElementId>) -> bool

Draw the component name (def, with overrides) and what it nests through place; returns whether nothing was left out.

fn draw_pieces

pub fn draw_pieces(d: &mut Drawing2D, patterns: &cc_core::fill_pattern::FillPatterns, pieces: &SheetPieces, place: &Place, scale: u32, id: Option<ElementId>)

Draw one resolution’s own pieces (not what it nests) through place.

fn dxf_blocks

pub fn dxf_blocks(project: &Project, view: ViewId, drawing: &Drawing2D, scale: u32, layer: &dyn Fn(&cc_core::Element) -> String) -> crate::dxf::DxfBlocks

The detail components of view that drawing shows, as DXF blocks: one block per component (an element with its own parameter values gets its own), drawn at 1:scale with what it nests as inserts of further blocks (a nested piece that would close a cycle is left out), and an insert per element on the layer layer names.

cc_views::diagram

crates/cc_views/src/diagram.rs

The single-line diagram of a distribution board with its load schedule: the supply and main breaker, the busbar and one branch per circuit with its breaker, conductor and load, then a table of the circuits (from cc_geom::sizing). Sizes in paper millimeters; label translates the headings (keys diagram-*).

Items: panel_diagram

fn panel_diagram

pub fn panel_diagram(project: &Project, geom: &ModelGeometry, panel: ElementId, scale: u32, label: &dyn Fn(&str) -> String) -> Drawing2D

cc_views::drawing

crates/cc_views/src/drawing.rs

Items: LineStyle · Pen · ResolvedPen · halftone · Anchor · Prim · Drawing2D · SectionHandle · TagHandle

enum LineStyle

pub enum LineStyle

Graphic weight of a line, resolved to pen widths by the renderer.

Traits: Debug, Clone, Copy, PartialEq, Eq, Hash

Variants

Methods

struct Pen

pub struct Pen

Graphic overrides of one line (view graphics); None keeps the style’s pen.

Traits: Debug, Clone, Copy, PartialEq, Default

Fields

struct ResolvedPen

pub struct ResolvedPen

A line’s pen resolved: width in paper millimeters, color and dash lengths in paper millimeters (empty: continuous).

Traits: Debug, Clone, Copy, PartialEq

Fields

fn halftone

pub fn halftone(c: [u8; 3]) -> [u8; 3]

A color mixed two thirds with white (faint drawing).

enum Anchor

pub enum Anchor

Which point of a text box sits at its position.

Traits: Debug, Clone, Copy, PartialEq, Eq, Default

Variants

enum Prim

pub enum Prim

Drawing primitive, in view coordinates (meters on the view plane).

Traits: Debug, Clone, PartialEq

Variants

Methods

struct Drawing2D

pub struct Drawing2D

Ordered list of primitives, painted first to last.

Traits: Debug, Clone, Default, PartialEq

Fields

Methods

struct SectionHandle

pub struct SectionHandle

A section’s mark in a plan, as drawn (meters on the plan).

Traits: Debug, Clone, PartialEq

Fields

Methods

struct TagHandle

pub struct TagHandle

A tag of an element in a view, as drawn: picked within half of center; offset is how far the view moved it from its default spot.

Traits: Debug, Clone, Copy, PartialEq

Fields

cc_views::drawing_index

crates/cc_views/src/drawing_index.rs

Lookups over a drawing’s primitives: the primitives of each element and a grid of the pickable ones, so picking under the pointer does not walk every primitive of a large drawing (an imported DXF holds 100 000).

Items: DrawingIndex

struct DrawingIndex

pub struct DrawingIndex

Built once for a drawing whose primitives no longer change: the cached drawings of views are shared and read only. Each lookup checks that the primitives are still the ones it was built from (their count and storage); when they are not, callers fall back to searching them all.

Traits: Default, Clone, PartialEq, std::fmt::Debug

Some fields are private.

Methods

cc_views::dxf

crates/cc_views/src/dxf.rs

DXF export of drawings, for exchanging 2D views with other CAD programs. The writer is self-contained and writes ASCII DXF R12 (AC1009), the version every CAD program reads: lines as LINE with their dash patterns as line types, opaque fills as SOLID triangles, and texts as TEXT with their alignment. Each primitive goes to the layer the caller names (the element’s category); colors are the nearest AutoCAD Color Index of the pen’s color, so a plot style by color can give the pens their weights (R12 has no line weights).

Items: DxfScale · aci · layer_name · default_layer · DxfBlock · DxfInsert · DxfBlocks · to_dxf · to_dxf_with

struct DxfScale

pub struct DxfScale

How a drawing is written: coordinates are multiplied by unit; text heights and dash lengths, in paper millimeters, by paper.

Traits: Debug, Clone, Copy, PartialEq

Fields

Methods

fn aci

pub fn aci(c: [u8; 3]) -> u8

The nearest index color of c (7, black on white paper, for dark colors).

fn layer_name

pub fn layer_name(name: &str) -> String

A layer name DXF R12 accepts: letters, digits, $, - and _, at most 31 characters, upper case.

fn default_layer

pub fn default_layer(prim: &Prim) -> &'static str

The layer of a primitive with no element: annotation lines, texts, or the rest.

struct DxfBlock

pub struct DxfBlock

A block definition: primitives in its own frame (drawing units, as the drawing’s), on layer 0, and the blocks it inserts.

Traits: Debug, Clone, Default

Fields

struct DxfInsert

pub struct DxfInsert

A block placed: its origin at position (drawing units), scaled by scale along its own axes (a negative one mirrors), then turned rotation_deg counter-clockwise.

Traits: Debug, Clone, PartialEq

Fields

struct DxfBlocks

pub struct DxfBlocks

Blocks written with a drawing: their definitions, where the drawing inserts them, and the elements they stand for (left out of the drawing’s own entities).

Traits: Debug, Clone, Default

Fields

fn to_dxf

pub fn to_dxf(drawing: &Drawing2D, scale: DxfScale, layer: &dyn Fn(&Prim) -> String) -> Vec<u8>

The DXF R12 document of drawing (in code page 1252), scaled by scale, each primitive on the layer layer names (sanitized with layer_name).

fn to_dxf_with

pub fn to_dxf_with(drawing: &Drawing2D, scale: DxfScale, layer: &dyn Fn(&Prim) -> String, blocks: &DxfBlocks) -> Vec<u8>

to_dxf with blocks: their definitions in the BLOCKS section and their inserts in the entities, in place of the primitives of the elements in blocks.skip. Block names are sanitized like layer names.

cc_views::export

crates/cc_views/src/export.rs

Vector export of drawings in paper millimeters (composed sheets) to SVG and PDF. Both writers are self-contained: the PDF uses the standard Helvetica font, so no font is embedded.

Items: to_svg · to_pdf · MAX_PIXELS · view_on_paper · to_png

fn to_svg

pub fn to_svg(drawing: &Drawing2D, paper: DVec2) -> String

SVG document of drawing on a sheet of paper millimeters.

fn to_pdf

pub fn to_pdf(drawing: &Drawing2D, paper: DVec2) -> Vec<u8>

PDF document (one page) of drawing on a sheet of paper millimeters.

const MAX_PIXELS

pub const MAX_PIXELS: u64

The largest raster export, in pixels (about 20000 x 5000, or an A0 sheet at 300 dpi).

fn view_on_paper

pub fn view_on_paper(drawing: &Drawing2D, scale: u32, margin: f64) -> (Drawing2D, DVec2)

A view’s drawing (meters, drawn at 1:scale; text sizes in paper millimeters) laid out on paper: the drawing in millimeters with margin around it, and the paper size.

fn to_png

pub fn to_png(drawing: &Drawing2D, paper: DVec2, dpi: f64) -> Result<Vec<u8>, String>

PNG image of drawing on a sheet of paper millimeters at dpi dots per inch, on white; text is drawn as outlines of Inter (embedded), with the system’s fallback fonts (fonts::fallbacks: CJK, Lao) for the characters Inter lacks.

cc_views::fonts

crates/cc_views/src/fonts.rs

Fallback fonts for the scripts Inter lacks (Chinese, Japanese, Korean, Lao), found among the fonts operating systems usually ship and read once. Nothing is bundled, so a system without them shows missing glyphs as boxes, as before.

Items: FontFile · cjk · lao · fallbacks

struct FontFile

pub struct FontFile

A font file and the face to use in it (collections hold several).

Fields

Methods

fn cjk

pub fn cjk() -> &'static [FontFile]

The system’s CJK fonts in fallback order (empty when there is none).

fn lao

pub fn lao() -> &'static [FontFile]

The system’s Lao font (empty when there is none).

fn fallbacks

pub fn fallbacks() -> impl Iterator<Item = &'static FontFile>

Every fallback font, in order: CJK, then Lao.

cc_views::format

crates/cc_views/src/format.rs

Number formatting for drawings, schedules and the interface. Quantities follow the project units (cc_core::Units), set by the application with set_units; with the default number style the decimal symbol follows the interface language (set_decimal_comma). The *_with functions take the settings explicitly (used by tests and previews); the others read the current ones.

Items: set_decimal_comma · set_units · current · number_with · length_number_with · length_with · length_unit_with · inch_size_with · MetricSize · size_with · POUND · Quantity · quantity_with · area_with · volume_with · angle_with · slope_with · parse_slope_with · money_with · scale_with · paper_with · paper_weight_with · parse_paper_with · parse_number · parse_length_with · parse_size_with · number · meters · length · imperial · bar_length · trimmed · bar_diameter · scale · inch_size · size · quantity · system · parse_size · parse_slope · area · volume · angle · slope · money · parse_length · paper · paper_weight · parse_paper · elevation

fn set_decimal_comma

pub fn set_decimal_comma(comma: bool)

Use , (true) or . (false) as the decimal separator of the language.

fn set_units

pub fn set_units(units: &Units)

Display quantities with units from now on.

fn current

pub fn current() -> (Units, bool)

The current units and language decimal symbol.

fn number_with

pub fn number_with(units: &Units, comma: bool, value: f64, decimals: usize) -> String

value with decimals places, the style’s decimal symbol and grouping.

fn length_number_with

pub fn length_number_with(units: &Units, comma: bool, meters: f64) -> String

A length’s number in the length unit, without the unit symbol; feet and inches and fractional inches carry their own marks.

fn length_with

pub fn length_with(units: &Units, comma: bool, meters: f64) -> String

Length in meters, in the length unit (symbol when the settings ask for it).

fn length_unit_with

pub fn length_unit_with(units: &Units, comma: bool, meters: f64) -> String

Length always with its unit symbol (property fields, labels).

fn inch_size_with

pub fn inch_size_with(units: &Units, comma: bool, meters: f64) -> String

A small size (a section’s side, a diameter, a layer) in inches, without feet, with the inch mark: a fraction at the length precision (1 1/4", 5/16", 16"; sixteenths when lengths are not in fractional inches), or the length’s decimals when lengths are in decimal feet or inches (1.25").

enum MetricSize

pub enum MetricSize

How size_with writes a small size in metric projects: each place keeps the form it always had there.

Traits: Debug, Clone, Copy, PartialEq, Eq

Variants

fn size_with

pub fn size_with(units: &Units, comma: bool, meters: f64, metric: MetricSize) -> String

A small size (a section’s side, a diameter, a layer, a riser): as metric says in metric projects, in inches with the inch mark in imperial ones (see inch_size_with).

const POUND

pub const POUND: f64

Kilograms in a pound (exact, by definition).

enum Quantity

pub enum Quantity

A physical quantity stored in SI units: shown in them in metric projects and in US customary units in imperial ones. Engine commands and files keep the SI value; only the text changes.

Traits: Debug, Clone, Copy, PartialEq, Eq

Variants

Methods

fn quantity_with

pub fn quantity_with(units: &Units, comma: bool, q: Quantity, si: f64, decimals: usize) -> String

si (a Quantity in SI units) in the units’ system, with decimals places and its symbol: 12,50 kg, 27.56 lb.

fn area_with

pub fn area_with(units: &Units, comma: bool, square_meters: f64) -> String

fn volume_with

pub fn volume_with(units: &Units, comma: bool, cubic_meters: f64) -> String

fn angle_with

pub fn angle_with(units: &Units, comma: bool, degrees: f64) -> String

fn slope_with

pub fn slope_with(units: &Units, comma: bool, slope: f64) -> String

Slope given as rise over run: 8,3 %, 4,76°, or the rise per 12 of run (6:12, 4.5:12; trailing zeros dropped).

fn parse_slope_with

pub fn parse_slope_with(units: &Units, text: &str) -> Option<f64>

Parse a slope as rise over run: a number in the slope unit (percent, degrees, or the rise per 12 of run), or with its unit typed: 8.3 %, 5°, a ratio 6:12 or 6/12 (1 1/2:12 too). None for anything else, and for 90° or more.

fn money_with

pub fn money_with(units: &Units, comma: bool, amount: f64) -> String

fn scale_with

pub fn scale_with(units: &Units, n: u32) -> String

The scale 1:n as a project with units writes it (1/4" = 1'-0" in imperial projects, else 1:n; see cc_core::scale::label).

fn paper_with

pub fn paper_with(units: &Units, comma: bool, mm: f64) -> String

A size on paper (text heights, bubbles, gaps, sheet sides), stored in millimeters, with its unit: 2,5 mm in metric projects; in imperial ones inches as a fraction to 1/64 (3/32", 1 1/2", 17"), or with three decimals when the size is not on a 1/64 step (0.098").

fn paper_weight_with

pub fn paper_weight_with(units: &Units, comma: bool, mm: f64) -> String

A pen weight on paper, stored in millimeters: 0,25 mm in metric projects, decimal inches in imperial ones (0.010").

fn parse_paper_with

pub fn parse_paper_with(units: &Units, text: &str) -> Option<f64>

Parse a size on paper, in millimeters: a bare number is millimeters in metric projects and inches in imperial ones; mm, cm, in or " after it say which. Fractions and mixed numbers are read (3/32, 1 1/2"); None for anything else.

fn parse_number

pub fn parse_number(text: &str) -> Option<f64>

Parse a number typed with either decimal symbol and optional grouping.

fn parse_length_with

pub fn parse_length_with(units: &Units, text: &str) -> Option<f64>

Parse a length typed in the length unit (a trailing unit symbol, or feet and inch marks, override it).

fn parse_size_with

pub fn parse_size_with(units: &Units, text: &str) -> Option<f64>

Parse a small size (see size_with) typed in a project of units: in imperial projects a bare number is inches (3/4, 1 1/2, 6); otherwise, and with feet or a unit typed, as parse_length_with.

fn number

pub fn number(value: f64, decimals: usize) -> String

Plain number with the current decimal symbol and grouping.

fn meters

pub fn meters(value: f64) -> String

Length in the project’s length unit (dimensions, tags, schedules).

fn length

pub fn length(value: f64) -> String

Length with its unit symbol.

fn imperial

pub fn imperial() -> bool

Whether lengths are shown in US customary units.

fn bar_length

pub fn bar_length(meters: f64) -> String

A bar’s length (or a leg’s, a radius, a spacing) as bending schedules and bar tags write it: whole centimeters without the unit in metric projects, the project’s length format in imperial ones.

fn trimmed

pub fn trimmed(value: f64, decimals: usize) -> String

A number with up to decimals places, trailing zeros dropped (12.5, 10).

fn bar_diameter

pub fn bar_diameter(meters: f64) -> String

A bar diameter as bar tags write it: Ø12.5 (millimeters), Ø1/2" in imperial projects.

fn scale

pub fn scale(n: u32) -> String

The scale 1:n in the current units (see scale_with).

fn inch_size

pub fn inch_size(meters: f64) -> String

A small size in inches with the inch mark (see inch_size_with).

fn size

pub fn size(meters: f64, metric: MetricSize) -> String

A small size in the current units (see size_with).

fn quantity

pub fn quantity(q: Quantity, si: f64, decimals: usize) -> String

A physical quantity in the current units (see quantity_with).

fn system

pub fn system() -> cc_core::MeasurementSystem

The measurement system of the current units.

fn parse_size

pub fn parse_size(text: &str) -> Option<f64>

Parse a small size in the current units (see parse_size_with).

fn parse_slope

pub fn parse_slope(text: &str) -> Option<f64>

Parse a slope in the current units (see parse_slope_with).

fn area

pub fn area(value: f64) -> String

fn volume

pub fn volume(value: f64) -> String

fn angle

pub fn angle(degrees: f64) -> String

fn slope

pub fn slope(value: f64) -> String

fn money

pub fn money(value: f64) -> String

fn parse_length

pub fn parse_length(text: &str) -> Option<f64>

fn paper

pub fn paper(mm: f64) -> String

A size on paper in the current units (see paper_with).

fn paper_weight

pub fn paper_weight(mm: f64) -> String

A pen weight in the current units (see paper_weight_with).

fn parse_paper

pub fn parse_paper(text: &str) -> Option<f64>

Parse a size on paper in the current units (see parse_paper_with).

fn elevation

pub fn elevation(value: f64) -> String

Level elevation with an explicit sign, e.g. +3,00.

cc_views::graphics

crates/cc_views/src/graphics.rs

View graphics applied to drawings: hidden categories, filters and elements leave the drawing, as do elements the view’s phase and phase filter leave out, and the resolved overrides change the pens of lines and the colors and patterns of fills (see cc_core::graphics and cc_core::phase).

Items: filter_matches · filter_elements · PhaseView · Resolver · apply

fn filter_matches

pub fn filter_matches(project: &Project, geom: &ModelGeometry, filter: &ViewFilter, e: &Element) -> bool

Whether filter matches the element e.

fn filter_elements

pub fn filter_elements(project: &Project, geom: &ModelGeometry, filter: &ViewFilter) -> Vec<ElementId>

The elements filter matches, in id order.

struct PhaseView

pub struct PhaseView<'a>

A view’s phase (an index into the project’s phases) and phase filter.

Traits: Debug, Clone, Copy

Fields

Methods

struct Resolver

pub struct Resolver<'a>

Resolves the graphics of elements in one view (cached per element).

Some fields are private.

Methods

fn apply

pub fn apply(d: &mut Drawing2D, resolver: &mut Resolver, scale: u32)

Apply the view’s graphics to a generated drawing at 1:scale.

cc_views::hatch

crates/cc_views/src/hatch.rs

Hatch patterns: the line work of a material Pattern clipped to a polygon. Lines are anchored to the drawing origin so neighbouring regions line up; spacing is the pattern’s base spacing in drawing units (callers derive it from paper millimeters and the view scale).

Items: hatch · hatch_with_holes · MAX_CUSTOM_SEGMENTS · MIN_PAPER_SPACING · paper_unit · custom_unit · hatch_in · hatch_with_holes_in · hatch_custom

fn hatch

pub fn hatch(pattern: Pattern, poly: &[DVec2], spacing: f64) -> Vec<(DVec2, DVec2)>

Segments of pattern inside poly. Solid and None give no lines (solid patterns are filled by the caller).

fn hatch_with_holes

pub fn hatch_with_holes(pattern: Pattern, poly: &[DVec2], holes: &[Vec<DVec2>], spacing: f64) -> Vec<(DVec2, DVec2)>

Segments of pattern inside poly and outside each of holes.

const MAX_CUSTOM_SEGMENTS

pub const MAX_CUSTOM_SEGMENTS: usize

Most segments one region may produce with a custom pattern.

const MIN_PAPER_SPACING

pub const MIN_PAPER_SPACING: f64

Families whose lines would print closer than this are left out (they would print as a gray blot), paper millimeters.

fn paper_unit

pub fn paper_unit(spacing: f64) -> f64

Drawing units per paper millimeter for a hatch spacing (see crate::cut::spacing).

fn custom_unit

pub fn custom_unit(fp: &FillPattern, spacing: f64) -> f64

Drawing units per millimeter of fp’s definition, with its scale: paper millimeters for drafting patterns, real ones (drawings in meters) for model patterns.

fn hatch_in

pub fn hatch_in(patterns: &FillPatterns, pattern: Pattern, poly: &[DVec2], spacing: f64) -> Vec<(DVec2, DVec2)>

Segments of pattern (built-in, or one of patterns) inside poly; a custom pattern that is gone gives none.

fn hatch_with_holes_in

pub fn hatch_with_holes_in(patterns: &FillPatterns, pattern: Pattern, poly: &[DVec2], holes: &[Vec<DVec2>], spacing: f64) -> Vec<(DVec2, DVec2)>

hatch_in outside each of holes.

fn hatch_custom

pub fn hatch_custom(fp: &FillPattern, poly: &[DVec2], unit: f64, paper: f64) -> Vec<(DVec2, DVec2)>

The line families of fp inside poly, its lengths at unit drawing units per millimeter (scale included), paper drawing units per paper millimeter (too dense families are left out; dots are drawn as short strokes). Lines are anchored to the drawing origin, so neighbouring regions line up.

cc_views::joins

crates/cc_views/src/joins.rs

Joined geometry in cut views (plans and sections): the outline of the element that is cut stops where the cutting element begins, the cutting element is painted over it, and when both are cut in the same material the line between them goes, so they read as one piece.

Items: merge

fn merge

pub(crate) fn merge(project: &Project, d: &mut Drawing2D)

Merge the cut regions of joined elements drawn in d.

cc_views::legend

crates/cc_views/src/legend.rs

Items: legend

fn legend

pub fn legend(project: &Project, types: &[ElementTypeId], scale: u32) -> Drawing2D

Legend: one row per type with a 2D symbol and its name. Rows are spaced in paper units so the legend reads the same at any scale.

cc_views::level_marks

crates/cc_views/src/level_marks.rs

Level marks: the finished level above a shelf line and the raw level under it, beside a symbol on the point measured. Plans draw a circle with two filled quarters crossed by the shelf and a vertical line; elevations and sections a triangle pointing down to the point on a stem that the shelf crosses. Sizes are paper millimeters converted with the view scale, like the other annotations.

Items: texts · level_marks

fn texts

pub fn texts(project: &Project, view: &View, mark: &LevelMark, data: &TypeData) -> Option<Vec<String>>

The texts a mark writes: the finished level, then the raw one when it has one, each with its sign, the type’s datum added, and its suffix.

fn level_marks

pub fn level_marks(d: &mut Drawing2D, project: &Project, view: &View)

The level marks of view.

cc_views::mep

crates/cc_views/src/mep.rs

Building services in plans: pipes and conduits as bands in their system’s color with diameter, slope and circuit tags, cable trays as outlines as wide as they are, valves on pipes, and electrical devices as the usual plan symbols (sizes in paper millimeters). Symbols follow common Brazilian practice: an outlet is a triangle, hollow when low, half filled at medium height and filled when high; a ceiling light is a circle with its circuit above its power; a switch is a small filled circle; a board is a rectangle with a filled half.

Items: services · discipline_of · valve_symbol · Frame · symbol

fn services

pub(crate) fn services(d: &mut Drawing2D, project: &Project, geom: &ModelGeometry, level: LevelId, cut_height: f64, discipline: MepDiscipline, scale: u32)

Pipes or conduits of level and, in electrical plans, the device symbols.

fn discipline_of

pub fn discipline_of(class: SystemClass) -> MepDiscipline

The services plan that shows devices of a family of systems.

fn valve_symbol

pub(crate) fn valve_symbol(d: &mut Drawing2D, c: DVec2, dir: DVec2, mm: f64, kind: cc_core::ValveKind, id: Option<cc_core::ElementId>)

The plan symbol of a valve at c on a pipe running along dir: two triangles meeting at their tips (a gate valve); a ball valve adds a hollow circle, a globe valve a filled one, and a check valve fills the triangle the flow leaves through. mm is one paper millimeter.

struct Frame

pub(crate) struct Frame

Where a symbol is drawn: the device’s insertion point and rotation. Wall devices stand out towards their local -Y.

Fields

fn symbol

pub(crate) fn symbol(d: &mut Drawing2D, f: &Frame, device: DeviceKind, height: f64, power: f64, circuit: Option<&str>, id: Option<cc_core::ElementId>)

The plan symbol of an electrical device mounted height above its level.

cc_views::notes

crates/cc_views/src/notes.rs

Text notes and their leaders. Sizes are paper millimeters converted with the view scale, like the other annotations; text widths are estimated from the character count (the same estimate wraps multiline text, places leaders and makes the text clickable).

Items: wrap · TextLayout · text_layout · leader_points · leader_symbol · SymbolPens · symbol_fill · symbol_at · draw_note · note_size · notes

fn wrap

pub fn wrap(text: &str, size: f64, width: Option<f64>) -> Vec<String>

Lines of text: explicit line breaks, and words wrapped to width paper millimeters when given (a word longer than the width is split).

struct TextLayout

pub struct TextLayout

Where a note’s text goes, in its view’s drawing coordinates.

Traits: Debug, Clone, PartialEq

Fields

Methods

fn text_layout

pub fn text_layout(note: &TextNote, size: f64, scale: u32) -> TextLayout

Layout of note with text of size paper millimeters at scale.

fn leader_points

pub fn leader_points(layout: &TextLayout, leader: &Leader) -> Vec<DVec2>

The polyline of a leader: from the text to its elbow (if any) and end.

fn leader_symbol

pub fn leader_symbol(d: &mut Drawing2D, symbol: LeaderSymbol, from: DVec2, end: DVec2, size: f64, scale: u32, id: Option<ElementId>)

The symbol at end of a leader coming from from, sized for text of size paper millimeters at scale.

struct SymbolPens

pub struct SymbolPens

Pens of a symbol’s strokes and of a tick, and the color of its fills.

Traits: Debug, Clone, Copy, Default

Fields

fn symbol_fill

pub fn symbol_fill(color: Option<[u8; 3]>) -> [u8; 4]

The fill of filled symbols drawn in color (the default symbol fill for none).

fn symbol_at

pub fn symbol_at(d: &mut Drawing2D, symbol: LeaderSymbol, u: DVec2, end: DVec2, len: f64, pens: SymbolPens, id: Option<ElementId>)

symbol at end of a line arriving along u (a unit vector), len drawing units long.

fn draw_note

pub fn draw_note(d: &mut Drawing2D, note: &TextNote, size: f64, scale: u32, id: Option<ElementId>)

Draw a note: its text, a clickable area and its leaders.

fn note_size

pub fn note_size(project: &Project, type_id: cc_core::ElementTypeId) -> f64

Text size of a note’s type (paper millimeters).

fn notes

pub fn notes(d: &mut Drawing2D, project: &Project, view: ViewId, scale: u32)

The text notes placed in view.

cc_views::plan

crates/cc_views/src/plan.rs

Re-exports

Items: plan · is_structural · plan_of · section_marks · section_labels · section_pieces · style_underlay · strip_fills

fn plan

pub fn plan(project: &Project, geom: &ModelGeometry, level: LevelId, cut_height: f64, ceiling: bool, scale: u32) -> Drawing2D

Floor plan (ceiling == false) or reflected ceiling plan of level.

fn is_structural

pub fn is_structural(e: &cc_core::Element) -> bool

Whether a structural plan shows the element: slabs, the load-bearing walls and columns, beams and foundations.

fn plan_of

pub fn plan_of(project: &Project, geom: &ModelGeometry, level: LevelId, cut_height: f64, (ceiling, structural): (bool, bool), scale: u32, (detail, style): (DetailLevel, VisualStyle)) -> Drawing2D

A plan as plan draws it, at detail; a structural plan shows only the structure, with the beams above the cut drawn as seen from below. A floor plan in a visual style that fills faces draws the pieces of components (and of swept profiles and connections) as seen from above: their edges only where no face of them lies over them (see PlanCover); the wireframe sees through them.

fn section_marks

pub(crate) fn section_marks(d: &mut Drawing2D, project: &Project, scale: u32)

The marks of every section in a plan at 1:scale, each listed in d.sections to be picked, moved and flipped.

fn section_labels

pub(crate) fn section_labels(project: &Project, view: &cc_core::View) -> (String, String)

What a section head shows: the drawing’s number on its sheet and the sheet’s number, or, while the section is on no sheet, the last word of its name (its letter, as in “Section A”) over a dash.

fn section_pieces

pub fn section_pieces(start: DVec2, end: DVec2, segments: Option<[f64; 2]>, head: f64) -> Vec<(DVec2, DVec2)>

The pieces of a section line drawn between its heads: the whole line, or with segments only that much of it next to each head (the whole line when they would meet). The line starts at the base of each head’s triangle, head from its end.

fn style_underlay

pub fn style_underlay(geom: &ModelGeometry, cut_z: f64, ceiling: bool, mut look: crate::Look<'_>, patterns: &cc_core::fill_pattern::FillPatterns) -> Vec<crate::Prim>

The faces a plan sees beyond its cut plane at cut_z, filled in the view’s visual style, to lie under the plan’s linework: what is below the cut in floor plans, above it in ceiling plans (the shaded, consistent colors and textures styles). Only fills and surface patterns: the plan draws its own edges and cuts. The sun’s shadows of a floor plan read the site (crate::shadow::Catch::Site): the whole model casts them, what stands above the cut plane too, on the faces and on the ground, but for what is indoors of them (the spaces the look’s shadows carry; none when it carries none). A ceiling plan draws none.

fn strip_fills

pub fn strip_fills(d: &mut Drawing2D)

The wireframe style of a plan: no fills (but the invisible room areas that make rooms pickable) and no hatches, only lines.

cc_views::projected

crates/cc_views/src/projected.rs

Orthographic projected views: elevations, sections and axonometrics, with painter’s-algorithm hidden surface removal. Faces are painted back to front. The order comes from comparing the depth of every pair of faces that overlap on screen, at a point inside their overlap; sorting by centroid depth alone fails for large faces such as roofs.

Items: Frame · Look · CutStyle · render · clip_convex · chain_loops · view_frame · elevation · section · axonometric · analytical · rebar

struct Frame

pub struct Frame

Orthographic view frame with optional clip planes.

Traits: Debug, Clone, Copy

Fields

Methods

struct Look

pub struct Look<'a>

How a view draws the model: its detail level, its visual style, the spacing of patterns (cut and surface hatches) in drawing units, the light that shades its faces and the shadows it casts.

Traits: Debug, Clone, Copy, PartialEq

Fields

Methods

struct CutStyle

pub struct CutStyle<'a>

How section cuts are filled: the project’s materials at a hatch spacing.

Traits: Clone, Copy

Fields

fn render

pub fn render(geom: &ModelGeometry, frame: &Frame, cut: Option<CutStyle>, look: Look<'_>, patterns: &cc_core::fill_pattern::FillPatterns) -> Drawing2D

Render the solids a view shows through frame, at its detail level and in its visual style; section cuts use cut (else, and at the coarse level, the neutral poche; in the wireframe, only their outline).

fn clip_convex

pub(crate) fn clip_convex(subject: &[DVec2], clipper: &[DVec2]) -> Vec<DVec2>

Clip a polygon by a counter-clockwise convex polygon (Sutherland-Hodgman; a polygon that is not convex may come out with sides along the clip’s).

fn chain_loops

pub(crate) fn chain_loops(segs: &[(DVec2, DVec2)]) -> Vec<Vec<DVec2>>

Join segments end-to-end into closed loops.

fn view_frame

pub fn view_frame(view: &cc_core::View) -> Option<Frame>

The frame through which a projected view (elevation, section, the 2D form of a 3D view) maps the model onto its drawing, as its generator builds it; None for other views (plans draw plan coordinates as they are).

fn elevation

pub fn elevation(project: &Project, geom: &ModelGeometry, direction: Direction, look: Look<'_>) -> Drawing2D

fn section

pub fn section(project: &Project, geom: &ModelGeometry, (start, end): (DVec2, DVec2), depth: f64, scale: u32, look: Look<'_>) -> Drawing2D

fn axonometric

pub fn axonometric(project: &Project, geom: &ModelGeometry, camera: &CameraState, look: Look<'_>) -> Drawing2D

fn analytical

pub fn analytical(project: &Project, geom: &ModelGeometry, camera: &CameraState) -> Drawing2D

The analytical model seen along the camera: member lines (columns and beams) and nodes, supports marked with a triangle.

fn rebar

pub fn rebar(geom: &ModelGeometry, camera: &CameraState) -> Drawing2D

The reinforcing bars seen along the camera, tagged with their sets.

cc_views::raster

crates/cc_views/src/raster.rs

Imported pictures: reading their size and decoding their pixels.

Items: Rgba · probe · decode · fade

struct Rgba

pub struct Rgba

Decoded pixels: width, height and RGBA rows from the top.

Traits: Debug, Clone, PartialEq

Fields

fn probe

pub fn probe(data: Vec<u8>) -> Option<RasterImage>

An image file read as a RasterImage (format from its signature, size from its header); None when it is not a picture this reads, or too big.

fn decode

pub fn decode(image: &RasterImage, max_side: u32) -> Option<Rgba>

The pixels of image, reduced (by whole steps) so that neither side exceeds max_side; None when it cannot be decoded.

fn fade

pub fn fade(pixels: &mut [u8])

c mixed two thirds with white (as faded lines are).

cc_views::region

crates/cc_views/src/region.rs

Filled and masking regions in the view they belong to (see cc_core::region), in id order, over the model’s linework and under the view’s annotations: a filled region as its type’s fill (a solid color, or a clear background under pattern lines), a masking region opaque white; then the boundary in its line style, when it has one. A region with openings is one keyhole ring (cc_geom::polygon::keyhole), or triangles where no ring could be made.

Items: MASK · regions · base_color · draw_filled · draw_masking

const MASK

pub const MASK: [u8; 4]

Opaque white: masking regions.

fn regions

pub fn regions(d: &mut Drawing2D, project: &Project, view: ViewId, scale: u32)

The regions of view, at 1:scale.

fn base_color

pub fn base_color(fill: &PatternFill) -> [u8; 4]

The color under a fill’s pattern lines: a solid pattern’s color, else clear.

fn draw_filled

pub fn draw_filled(d: &mut Drawing2D, r: &Region, fill: &PatternFill, styles: &LineStyles, patterns: &cc_core::fill_pattern::FillPatterns, scale: u32, id: Option<ElementId>)

Draw a filled region with fill.

fn draw_masking

pub fn draw_masking(d: &mut Drawing2D, r: &Region, styles: &LineStyles, id: Option<ElementId>)

Draw a masking region.

cc_views::schedule

crates/cc_views/src/schedule.rs

Schedules: one row per element of a category, one column per field of the schedule definition, with filtering, sorting and totals.

Items: Cell · Table · Row · totaled_by_default · field_value · schedule · schedule_where · to_csv · MAX_DRAWN_ROWS · drawing

enum Cell

pub enum Cell

A cell: plain text, or a translation key for the application to resolve.

Traits: Debug, Clone, PartialEq

Variants

Methods

struct Table

pub struct Table

A computed schedule. Headers are translation keys.

Traits: Debug, Clone, PartialEq, Default

Fields

Methods

struct Row

pub struct Row

Traits: Debug, Clone, PartialEq

Fields

Methods

fn totaled_by_default

pub fn totaled_by_default(field: ScheduleField) -> bool

Whether a schedule adds the column of field up unless its format says otherwise.

fn field_value

pub fn field_value(project: &Project, geom: &ModelGeometry, e: &Element, field: ScheduleField) -> Option<(String, Option<f64>)>

A field’s value for view filters: its text (keys reduced to their last word, e.g. yes, exterior) and, for quantities, its number in SI units (meters, square and cubic meters; yes/no as 1/0; diameters in meters). None when the element has no value.

fn schedule

pub fn schedule(project: &Project, geom: &ModelGeometry, category: Category, def: &ScheduleDef) -> Table

fn schedule_where

pub fn schedule_where(project: &Project, geom: &ModelGeometry, category: Category, def: &ScheduleDef, keep: &mut dyn FnMut(&Element) -> bool) -> Table

A schedule of the elements keep accepts (those a schedule view’s phase and phase filter show, see crate::graphics::PhaseView).

fn to_csv

pub fn to_csv(table: &Table, header: impl Fn(&str) -> String, cell: impl Fn(&Cell) -> String) -> String

The table as CSV: ;-separated when the decimal separator is a comma, so spreadsheets in those locales open it directly. header and cell translate keys.

const MAX_DRAWN_ROWS

pub const MAX_DRAWN_ROWS: usize

Most element rows drawn; the rest are counted in a last row.

fn drawing

pub fn drawing(table: &Table, title: &str, scale: u32, label: &dyn Fn(&str) -> String) -> crate::Drawing2D

A schedule as a drawing, for sheets: a title row, the headers, one row per element and the totals, ruled like a table, then any table under it (a bending schedule’s summary) with its caption. Sizes are paper millimeters at the view’s scale (as the panel diagrams), so a sheet places it at its printed size; numbers are right-aligned, and label translates the headers and the key cells. Group headings run across their row; rows with a bar’s sketch are as tall as it needs.

cc_views::shadow

crates/cc_views/src/shadow.rs

The shadows a view’s sun casts in projected views and plans, as exact polygons (see crate::projected::render). Every opaque face of the model that is not edge-on to the sun casts; a face turned to the sun catches. The shadow on a face is the union of the casters standing in front of its plane, slid along the sun’s rays onto that plane and kept within the face (cc_geom::region::covered); the ground catches them the same way on a level plane. A closed convex solid (a box, a round column) casts as one polygon, the hull of its points. Which faces catch them is the view’s (Catch), as drawings are read:

Items: MAX_CASTERS · MAX_UNION_POINTS · MAX_POINTS · MAX_LOOKS · FACE_PROBE · TEXTURES_AMBIENT · Skip · Shadows · Catch · OPEN_AIR · Indoors · Storey · point_within · textures_light · veil · ground_veil · Scene

const MAX_CASTERS

pub const MAX_CASTERS: usize

Most faces that cast in one view.

const MAX_UNION_POINTS

pub const MAX_UNION_POINTS: usize

Most points of the casters over one face (or the ground).

const MAX_POINTS

pub const MAX_POINTS: usize

Most points of the casters over all the faces of one view.

const MAX_LOOKS

pub const MAX_LOOKS: usize

Most casters looked at over all the faces of one view.

const FACE_PROBE

pub(crate) const FACE_PROBE: f64

A face is indoors when the point this far in front of it is, meters.

const TEXTURES_AMBIENT

pub(crate) const TEXTURES_AMBIENT: f64

The light a face of the textures style keeps turned away from the sun at the default shading (a face square to it is fully lit).

struct Skip

pub struct Skip

The elements a view’s graphics keep out of its shadows.

Traits: Debug, Clone, Default, PartialEq, Eq

Fields

struct Shadows

pub struct Shadows<'a>

The shadows the sun of a view casts.

Traits: Debug, Clone, Copy, PartialEq

Fields

enum Catch

pub enum Catch<'a>

Which faces of a view catch its sun’s shadows, and what casts them.

Traits: Debug, Clone, Copy, PartialEq, Default

Variants

static OPEN_AIR

pub static OPEN_AIR: Indoors

No space indoors: everything catches the sun’s shadows.

struct Indoors

pub struct Indoors

The spaces of a model that are indoors, storey by storey, for the shadows of floor plans and sections. A storey runs from a level up to the next one (the last one without end), and its walls are those standing STOREY_PROBE above its level (halfway up a lower storey). The spaces their outlines close, the walls’ own bodies among them (RoomArrangement::spaces: rooms, whether or not a room was placed in them), are indoors when floors, roofs and ceilings above cover more than INDOORS_COVER of them; a storey keeps them united, as the outlines of what is indoors on it. So a room is indoors; a courtyard, a walled garden with the eaves over its edge and a terrace behind a parapet are not, nor is a porch or a garage that walls do not close. A point is indoors when it is in one of the spaces of the storey at its height (Indoors::holds) and a floor, roof or ceiling of another element lies above it (Scene::above, Scene::covers): the top of a roof is not, whatever the storey it falls in. A section takes a face whole, by the point FACE_PROBE in front of it, so the face of an outer wall under an eave, which looks onto the open, keeps the eave’s shadow; a floor plan takes the part of each face seen from above that is indoors, in the storey PLAN_PROBE above it. Spaces closed by something other than walls (columns, components) are not found: their faces catch shadows.

Traits: Debug, Clone, Default, PartialEq

Fields

Methods

struct Storey

pub struct Storey

A storey and its spaces indoors.

Traits: Debug, Clone, PartialEq

Fields

fn point_within

pub(crate) fn point_within(verts: &[DVec3], normal: DVec3) -> Option<DVec3>

A point of the face verts (with unit normal): the mean of its corners, or when that lies outside it (a face that is not convex), the middle of its largest triangle.

fn textures_light

pub(crate) fn textures_light(shading: &ShadingSettings, facing: f64) -> f64

The light of a face of the textures style at facing (the cosine of its angle to the light): TEXTURES_AMBIENT turned away and full square to it at the default shading; a view’s ambient light moves the first as it moves the shaded style’s grey (up to full light at 1).

fn veil

pub fn veil(style: VisualStyle, facing: f64, shading: &ShadingSettings) -> u8

The opacity (0 to 255) of the black veil that a cast shadow lays on a face of style at facing (the cosine of its angle to the sun), so that 2D views match the 3D view: in the shaded style the face shows the shadow’s grey (ShadingSettings::shadow_grey) under it, in the textures style it loses the sun’s light and darkens as much as the shaded style’s shadow does from its ambient light, in consistent colors it darkens as the 3D view’s unlit faces do. The shadow fades out where the face turns edge-on to the sun, as in the 3D view. No shadows in the other styles.

fn ground_veil

pub fn ground_veil(shading: &ShadingSettings) -> u8

The opacity (0 to 255) of the black veil of a shadow on the ground: GROUND_SHADOW at the default shading, none to black with the view’s shadow intensity.

struct Scene

pub(crate) struct Scene<'a>

What casts shadows in a view, seen from its sun.

Some fields are private.

Methods

cc_views::sheet

crates/cc_views/src/sheet.rs

Sheet composition: the title block and the placed viewports, as one drawing in paper millimeters (origin at the bottom-left corner). The title block is a component type (ComponentKind::TitleBlock) whose 2D pieces draw the border and the block; its texts’ {fields} are filled in from the sheet and the project. The application paints the result and the exporters write it, so the screen and the PDF/SVG files match.

Items: MARGIN · SheetEnv · PlacedViewport · Sheet · compose · title_block_drawing

const MARGIN

pub const MARGIN: f64

The margin of the standard title block’s border, millimeters.

struct SheetEnv

pub struct SheetEnv

What a sheet’s fields read besides the model.

Traits: Debug, Clone

Fields

struct PlacedViewport

pub struct PlacedViewport

A viewport resolved on the sheet (for selection and dragging).

Traits: Debug, Clone, PartialEq

Fields

struct Sheet

pub struct Sheet

A composed sheet.

Traits: Debug, Clone, Default

Fields

fn compose

pub fn compose(project: &Project, sheet: &View, env: &SheetEnv, mut drawing_of: impl FnMut(ViewId) -> Option<Rc<Drawing2D>>) -> Option<Sheet>

Compose sheet; drawing_of returns the drawing of a placed view.

fn title_block_drawing

pub fn title_block_drawing(pieces: &SheetPieces, expand: &dyn Fn(&str) -> String) -> Drawing2D

The drawing of a title block’s resolved pieces (paper millimeters), each text passed through expand (the editor fills fields or shows them raw).

cc_views::sheet_fields

crates/cc_views/src/sheet_fields.rs

{fields} in title block texts: sheet, project and date values, and the title block’s per-sheet parameters. Unknown keys stay as written.

Items: KEYS · FieldCtx · expand · expand_with · value

const KEYS

pub const KEYS: [&str; 12]

The fixed keys, in the order the editor’s menu lists them.

struct FieldCtx

pub struct FieldCtx<'a>

What the fields read from.

Fields

fn expand

pub fn expand(text: &str, ctx: &FieldCtx) -> String

Replaces each {key} of text with its value; {{ and }} are literal braces, and unknown keys and braces without a match stay as written (see field_parts).

fn expand_with

pub fn expand_with(text: &str, lookup: &dyn Fn(&str) -> Option<String>) -> String

expand with any lookup (the title block editor’s sample values).

fn value

pub fn value(key: &str, ctx: &FieldCtx) -> Option<String>

The value of one field, or None for an unknown key.

cc_views::sun_path

crates/cc_views/src/sun_path.rs

The sun path diagram of a view with a sun (cc_core::View::sun with show_path): a compass ring turned to true north on the ground, the sky dome’s path of the sun over the day shown (and, over several days, over the first and last), its whole hours, sunrise, sunset and the date, and the sun where it stands. diagram builds it in world coordinates, view-independent and purely geometric, so it can be drawn over any projection (2D views here, the live 3D view by the app); draw lays it over a view’s drawing as an overlay (Drawing2D::overlay): no element, not picked or snapped to, not cropped, but fitted.

Items: MIN_RADIUS · MAX_RADIUS · MAX_POINTS · SunLineKind · SunLine · SunText · SunLabelKind · SunLabel · SunDiagram · diagram · GRID_COLOR · GRID_WEIGHT · BAND_COLOR · PATH_COLOR · PATH_WEIGHT · RANGE_WEIGHT · DOT_RADIUS_MM · SUN_FILL · SUN_OUTLINE · SUN_OUTLINE_WEIGHT · MIN_SUN_RADIUS_MM · CARDINAL_SIZE · TIME_SIZE · DATE_SIZE · LABEL_GAP_MM · label_anchor · on_horizon · stacked_on · half_extent · text_width · time_text · date_text · label_text · draw

const MIN_RADIUS

pub const MIN_RADIUS: f64

Smallest and largest radius of the diagram, meters.

const MAX_RADIUS

pub const MAX_RADIUS: f64

const MAX_POINTS

pub const MAX_POINTS: usize

Most points a diagram holds (lines, dots and labels together).

enum SunLineKind

pub enum SunLineKind

What a line of the diagram is.

Traits: Debug, Clone, Copy, PartialEq, Eq

Variants

struct SunLine

pub struct SunLine

A polyline of the diagram, world coordinates.

Traits: Debug, Clone, PartialEq

Fields

enum SunText

pub enum SunText

What a label says, to be written in the reader’s language.

Traits: Debug, Clone, Copy, PartialEq

Variants

enum SunLabelKind

pub enum SunLabelKind

What a label marks.

Traits: Debug, Clone, Copy, PartialEq, Eq

Variants

struct SunLabel

pub struct SunLabel

A label of the diagram at pos, pushed away from it along out (a unit direction in world coordinates, or zero).

Traits: Debug, Clone, Copy, PartialEq

Fields

struct SunDiagram

pub struct SunDiagram

A sun path diagram in world coordinates (see the module’s documentation).

Traits: Debug, Clone, PartialEq

Fields

Methods

fn diagram

pub fn diagram(project: &Project, geom: &ModelGeometry, view: &View) -> Option<SunDiagram>

The sun path diagram of view: None unless it takes a sun, has one and shows its path. Centered on the plan center of the model’s extents in geom (the geometry the view shows; the origin for an empty model), on the ground level’s plane (else the bottom of the extents), with a radius of three quarters of the extents’ plan diagonal within MIN_RADIUS..=MAX_RADIUS. Every point is finite, and there are at most MAX_POINTS.

const GRID_COLOR

pub const GRID_COLOR: [u8; 3]

Lines of the compass: neutral grey-blue (RGB; weights are pen weights, mm).

const GRID_WEIGHT

pub const GRID_WEIGHT: f64

const BAND_COLOR

pub const BAND_COLOR: [u8; 4]

The band between the two circles of the ring (RGBA).

const PATH_COLOR

pub const PATH_COLOR: [u8; 3]

The sun’s path: amber.

const PATH_WEIGHT

pub const PATH_WEIGHT: f64

const RANGE_WEIGHT

pub const RANGE_WEIGHT: f64

const DOT_RADIUS_MM

pub const DOT_RADIUS_MM: f64

Radius of an hour’s dot on paper, mm.

const SUN_FILL

pub const SUN_FILL: [u8; 4]

The sun’s disc (RGBA) and its outline.

const SUN_OUTLINE

pub const SUN_OUTLINE: [u8; 3]

const SUN_OUTLINE_WEIGHT

pub const SUN_OUTLINE_WEIGHT: f64

const MIN_SUN_RADIUS_MM

pub const MIN_SUN_RADIUS_MM: f64

Smallest radius of the sun’s disc on paper, mm.

const CARDINAL_SIZE

pub const CARDINAL_SIZE: f64

Text heights on paper, mm.

const TIME_SIZE

pub const TIME_SIZE: f64

const DATE_SIZE

pub const DATE_SIZE: f64

const LABEL_GAP_MM

pub const LABEL_GAP_MM: f64

Gap between a label and its point on paper, mm.

fn label_anchor

pub fn label_anchor(d: &SunDiagram, l: &SunLabel) -> DVec3

The point a label is laid out from, world coordinates: a label on the horizon (see on_horizon) stands past the compass’s ticks along its out, clear of the ring; the others at their point.

fn on_horizon

pub fn on_horizon(d: &SunDiagram, l: &SunLabel) -> bool

Whether l marks a point on the horizon: a sunrise, a sunset, or a date at the sunrise (a polar day’s date stands on the path, above it).

fn stacked_on

pub fn stacked_on(d: &SunDiagram, index: usize) -> Option<usize>

The label that the label at index stacks beyond, further from the ring: a date on the sunrise’s time at the same point.

fn half_extent

pub fn half_extent(dir: DVec2, width: f64, height: f64) -> f64

Half the extent along the unit direction dir of a text box width wide and height tall (axis aligned).

fn text_width

pub fn text_width(text: &str, size: f64) -> f64

The approximate width of text written size tall (wide characters, such as CJK ones, a full size; others six tenths of it).

fn time_text

pub fn time_text(minutes: f64) -> String

A time of day as HH:MM (minutes after midnight, any day).

fn date_text

pub fn date_text(date: SunDate, label: &dyn Fn(&str) -> String) -> String

date in the reader’s language: the pattern label gives for DATE_PATTERN_KEY, else ISO YYYY-MM-DD.

fn label_text

pub fn label_text(text: SunText, label: &dyn Fn(&str) -> String) -> String

The text of a label in the reader’s language.

fn draw

pub fn draw(d: &mut Drawing2D, project: &Project, geom: &ModelGeometry, view: &View, label: &dyn Fn(&str) -> String)

Lay view’s sun path diagram over d (nothing when it has none), last and counted in Drawing2D::overlay: plans in plan coordinates, the other views through their frame (crate::projected::view_frame), with no hidden lines removed and no element.

cc_views::topography

crates/cc_views/src/topography.rs

Terrain in floor plans: contour lines (majors heavier) and the boundary below the cut plane; where the cut plane crosses the surface, the earth above it hatched in the type’s material and outlined as cut. Building pads: their outline with their elevation, ticks across their slopes (long and short in turn, the short ones from the top of the slope), the daylight line, and the existing ground’s contours dashed where the pads changed it.

Items: draw

fn draw

pub(crate) fn draw(d: &mut Drawing2D, project: &Project, geom: &ModelGeometry, level: LevelId, cut_z: f64, scale: u32)

The terrain surfaces of level in its floor plan cut at cut_z.