Model

Struct Model 

Source
pub struct Model(/* private fields */);
Expand description

A reference counted, mutable Model.

Implementations§

Source§

impl Model

Source

pub fn new(inner: RcMut<ModelInner>) -> Self

Create new model from inner.

Source

pub fn depth(&self) -> usize

Calculate depth of the model.

Source

pub fn is_operation(&self) -> bool

Check if a model contains an operation element.

Source

pub fn make_deep_copy(&self) -> Self

Make a deep copy if this model. TODO: isn’t this a Clone?

Source

pub fn addr(&self) -> usize

Return address of this model.

Source

pub fn is_same_as(&self, other: &Model) -> bool

Check if other is and self have the same address.

Source

pub fn remove_child(&self, child: &Model)

Remove child from this model.

Source

pub fn detach(&self)

Detaches a model from its parent. Children are not affected.

Source

pub fn append(&self, model: Model) -> Model

Append a single model as child.

Also tries to set the output type if it has not been determined yet.

Source

pub fn append_children(&self, models: Models) -> Self

Append multiple models as children.

Return self.

Source

pub fn boolean_op(self, op: BooleanOp, other: Model) -> Model

Short cut to generate boolean operator as binary operation with two models.

Source

pub fn replace_input_placeholders(&self, input_model: &Model) -> Self

Replace each input placeholder with copies of input_model.

Source

pub fn deduce_output_type(&self) -> OutputType

Deduce output type from children and set it and return it.

Source

pub fn into_group(&self) -> Option<Model>

Return inner group if this model only contains a group as single child.

This function is used when we evaluate operations like subtract() {} or hull() {}. When evaluating these operations, we want to iterate over the group’s children.

Source

pub fn signature(&self) -> String

A Model signature has the form [id: ]ElementType[ = origin][ -> result_type].

Source§

impl Model

Iterator methods.

Source

pub fn descendants(&self) -> Descendants

Returns an iterator of models to this model and its unnamed descendants, in tree order.

Includes the current model.

Source

pub fn source_file_descendants(&self) -> SourceFileDescendants

Returns an iterator of models that belong to the same source file as this one

Source

pub fn parents(&self) -> Parents

Parents iterator.

Source

pub fn ancestors(&self) -> Ancestors

Ancestors iterator.

Source

pub fn get_property(&self, id: &Identifier) -> Option<Value>

Get a property from this model.

Source

pub fn set_property(&mut self, id: Identifier, value: Value) -> Option<Value>

Set a property in this model.

Source

pub fn add_property(&self, id: Identifier, value: Value)

Add a new property to the model.

Source§

impl Model

Source

pub fn prerender(&self, resolution: RenderResolution) -> RenderResult<()>

Pre render the model.

Rendering the model means that all geometry is calculated and stored in the in the render cache.

Trait Implementations§

Source§

impl AttributesAccess for Model

Source§

fn get_attributes_by_id(&self, id: &Identifier) -> Vec<Attribute>

Get a value attribute by id.
Source§

fn get_single_attribute(&self, id: &Identifier) -> Option<Attribute>

Get a single attributes.
Source§

fn get_attribute_value(&self, id: &Identifier) -> Value

Get single attribute as value.
Source§

fn get_resolution(&self) -> Option<ResolutionAttribute>

Get resolution attribute.
Source§

fn get_color(&self) -> Option<Color>

Color (builtin attribute).
Source§

fn get_theme(&self) -> Option<Rc<Theme>>

Color theme (builtin attribute).
Source§

fn get_size(&self) -> Option<Size2>

Get size.
Source§

fn get_exports(&self) -> Vec<ExportCommand>

Get all export commands.
Source§

fn get_measures(&self) -> Vec<MeasureCommand>

Get all measure commands.
Source§

fn get_custom_attributes(&self, id: &Identifier) -> Vec<Tuple>

Get custom attributes.
Source§

impl CallMethod<Option<Model>> for Model

Source§

fn call_method( &self, name: &QualifiedName, args: &ArgumentValueList, context: &mut Context, ) -> EvalResult<Option<Model>>

Evaluate method call into a value (if possible) Read more
Source§

impl Clone for Model

Source§

fn clone(&self) -> Model

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Model

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl DerefMut for Model

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl Display for Model

Prints a Model.

A Model signature has the form [id: ]ElementType[ = origin][ -> result_type]. The exemplary output will look like this:

id: Object:
    Object = std::geo2d::Circle(radius = 3.0mm) -> Geometry2D:
        Primitive = __builtin::geo2d::Circle(radius = 3.0) -> Geometry2D`
Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eval<Model> for Body

Evaluate the body into a single group: {}.

Source§

fn eval(&self, context: &mut Context) -> EvalResult<Model>

Evaluate a syntax element into a type T.
Source§

impl Eval<Model> for Rc<SourceFile>

Source§

fn eval(&self, context: &mut Context) -> EvalResult<Model>

Evaluate a syntax element into a type T.
Source§

impl FetchBounds2D for Model

Source§

fn fetch_bounds_2d(&self) -> Bounds2D

Fetch bounds.
Source§

impl From<Model> for Value

Source§

fn from(model: Model) -> Self

Converts to this type from the input type.
Source§

impl FromIterator<Model> for Models

Source§

fn from_iter<T: IntoIterator<Item = Model>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl PartialEq for Model

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Render<Model> for Model

Source§

fn render(&self, context: &mut RenderContext) -> RenderResult<Model>

Render method.
Source§

impl Render<Option<Rc<Geometry2D>>> for Model

This implementation renders a Geometry2D out of a Model.

Notes:

  • The impl attaches the output geometry to the model’s render output.
  • It is assumed the model has been pre-rendered.
Source§

fn render(&self, context: &mut RenderContext) -> RenderResult<Geometry2DOutput>

Render method.
Source§

impl Render<Option<Rc<Geometry3D>>> for Model

This implementation renders a Geometry3D out of a Model.

Notes:

  • The impl attaches the output geometry to the model’s render output.
  • It is assumed the model has been pre-rendered.
Source§

fn render(&self, context: &mut RenderContext) -> RenderResult<Geometry3DOutput>

Render method.
Source§

impl SrcReferrer for Model

Source§

fn src_ref(&self) -> SrcRef

Return source code reference.
Source§

fn source_hash(&self) -> u64

Return source code hash.
Source§

impl TreeDisplay for Model

Source§

fn tree_print(&self, f: &mut Formatter<'_>, tree_state: TreeState) -> Result

Write item into f and use {:depth$} syntax in front of your single line output to get proper indention.
Source§

fn print_tree(&self, f: &mut Formatter<'_>, shorten: bool) -> Result

Display as tree starting at depth 0.
Source§

fn write_tree(&self, f: &mut impl Write) -> Result<()>

Display as tree starting at depth 0.
Source§

impl WriteToFile for Model

Source§

fn write_to_file(&self, filename: &impl AsRef<Path>) -> Result<()>

Write something to a file.
Source§

impl Deref for Model

Source§

type Target = RcMut<ModelInner>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

§

impl Freeze for Model

§

impl !RefUnwindSafe for Model

§

impl !Send for Model

§

impl !Sync for Model

§

impl Unpin for Model

§

impl !UnwindSafe for Model

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToCompactString for T
where T: Display,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

Source§

fn is_within(&self, b: &G2) -> bool