Struct four_bar::plot::FigureBase

source ยท
pub struct FigureBase<'a, 'b, M: Clone, C: Clone> {
    pub fb: Option<Cow<'b, M>>,
    pub angle: Option<f64>,
    pub lines: Vec<Rc<RefCell<LineData<'a, C>>>>,
    pub opt: Opt<'a>,
}
Available on crate feature plot only.
Expand description

Option type base.

Fieldsยง

ยงfb: Option<Cow<'b, M>>

Linkage

ยงangle: Option<f64>

Input angle

ยงlines: Vec<Rc<RefCell<LineData<'a, C>>>>

Line data

ยงopt: Opt<'a>

Drawing options

Implementationsยง

sourceยง

impl FigureBase<'_, '_, FourBarBase<UnNorm, NormFourBar>, [f64; 2]>

source

pub fn plot<B, R>( &self, root: R ) -> Result<(), DrawingAreaErrorKind<<B as DrawingBackend>::ErrorType>>where B: DrawingBackend, DrawingArea<B, Shift>: From<R>,

Plot 2D curves and linkages.

use four_bar::{plot::*, plot2d, FourBar};
let fb = FourBar::example();
let mut buf = String::new();
plot2d::Figure::from(&fb)
    .axis(false)
    .add_line("First Curve", fb.curve(180), Style::Line, BLACK)
    .plot(SVGBackend::with_string(&mut buf, (1600, 1600)))
    .unwrap();
sourceยง

impl FigureBase<'_, '_, FourBarBase<UnNorm, SNormFourBar>, [f64; 3]>

source

pub fn plot<B, R>( &self, root: R ) -> Result<(), DrawingAreaErrorKind<<B as DrawingBackend>::ErrorType>>where B: DrawingBackend, DrawingArea<B, Shift>: From<R>,

Plot 3D spherical linkage.

Please see Opt for more options.

use four_bar::{plot3d::*, SFourBar};
let fb = SFourBar::example();
let mut buf = String::new();
Figure::from(&fb)
    .axis(false)
    .add_line("First Curve", fb.curve(180), Style::Line, BLACK)
    .plot(SVGBackend::with_string(&mut buf, (1600, 1600)))
    .unwrap();
sourceยง

impl<'a, 'b, M: Clone, C: Clone> FigureBase<'a, 'b, M, C>

source

pub fn new(fb: Option<M>) -> Self

Create a new instance with linkage.

source

pub fn new_ref(fb: Option<&'b M>) -> Self

From an optional linkage setting.

source

pub fn with_fb(self, fb: M) -> Self

Attach linkage.

source

pub fn with_fb_ref(self, fb: &'b M) -> Self

Attach linkage with its reference.

source

pub fn remove_fb(self) -> Self

Remove linkage.

source

pub fn angle(self, angle: f64) -> Self

Set the input angle of the linkage.

If the angle value is not in the range of fb::FourBarBase::angle_bound(), the actual angle will be the midpoint.

source

pub fn font_family(self, family: impl Into<Cow<'a, str>>) -> Self

Set the font family.

source

pub fn stroke(self, stroke: u32) -> Self

Set the line stroke of the linkage.

source

pub fn font(self, font: f64) -> Self

Set font size.

source

pub fn grid(self, grid: bool) -> Self

Use grid in the plot.

source

pub fn axis(self, axis: bool) -> Self

Show the axis.

source

pub fn legend(self, legend: LegendPos) -> Self

Set legend position.

source

pub fn with_opt(self, opt: Opt<'a>) -> Self

Set the inner options.

source

pub fn add_line<S, L>( self, label: S, line: L, style: Style, color: RGBColor ) -> Selfwhere S: Into<Cow<'a, str>>, L: Into<Cow<'a, [C]>>,

Add a line.

source

pub fn add_line_data(self, data: LineData<'a, C>) -> Self

Add a line from a LineData instance.

source

pub fn push_line<S, L>( &mut self, label: S, line: L, style: Style, color: RGBColor )where S: Into<Cow<'a, str>>, L: Into<Cow<'a, [C]>>,

Add a line in-placed.

source

pub fn push_line_data(&mut self, data: LineData<'a, C>)

Add a line from a LineData instance in-placed.

source

pub fn push_line_default<S, L>(&mut self, label: S, line: L)where S: Into<Cow<'a, str>>, L: Into<Cow<'a, [C]>>,

Add a line with default settings in-placed.

source

pub fn lines(&self) -> impl Iterator<Item = Ref<'_, LineData<'a, C>>>

Iterate over lines.

source

pub fn lines_mut(&mut self) -> &mut Vec<Rc<RefCell<LineData<'a, C>>>>

Get a mutable reference to the lines.

Trait Implementationsยง

sourceยง

impl<'a, 'b, M: Clone + Clone, C: Clone + Clone> Clone for FigureBase<'a, 'b, M, C>

sourceยง

fn clone(&self) -> FigureBase<'a, 'b, M, C>

Returns a copy 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<M: Clone, C: Clone> Default for FigureBase<'_, '_, M, C>

sourceยง

fn default() -> Self

Returns the โ€œdefault valueโ€ for a type. Read more
sourceยง

impl<'a, M: Clone, C: Clone> Deref for FigureBase<'a, '_, M, C>

ยง

type Target = Opt<'a>

The resulting type after dereferencing.
sourceยง

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

Dereferences the value.
sourceยง

impl<'a, M: Clone, C: Clone> DerefMut for FigureBase<'a, '_, M, C>

sourceยง

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

Mutably dereferences the value.
sourceยง

impl<'de, 'a, 'b, M, C> Deserialize<'de> for FigureBase<'a, 'b, M, C>where FigureBase<'a, 'b, M, C>: Default, M: Deserialize<'de> + Clone, C: Deserialize<'de> + Clone,

sourceยง

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
sourceยง

impl<'a, 'b, M, C> Serialize for FigureBase<'a, 'b, M, C>where M: Serialize + Clone, C: Serialize + Clone,

sourceยง

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementationsยง

ยง

impl<'a, 'b, M, C> !RefUnwindSafe for FigureBase<'a, 'b, M, C>

ยง

impl<'a, 'b, M, C> !Send for FigureBase<'a, 'b, M, C>

ยง

impl<'a, 'b, M, C> !Sync for FigureBase<'a, 'b, M, C>

ยง

impl<'a, 'b, M, C> Unpin for FigureBase<'a, 'b, M, C>where M: Unpin,

ยง

impl<'a, 'b, M, C> !UnwindSafe for FigureBase<'a, 'b, M, C>

Blanket Implementationsยง

sourceยง

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

sourceยง

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
sourceยง

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

sourceยง

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
sourceยง

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

sourceยง

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

Mutably borrows from an owned value. 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 Twhere 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.

ยง

impl<T> Pointable for T

ยง

const ALIGN: usize = _

The alignment of pointer.
ยง

type Init = T

The type for initializers.
ยง

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

Initializes a with the given initializer. Read more
ยง

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

Dereferences the given pointer. Read more
ยง

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

Mutably dereferences the given pointer. Read more
ยง

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
sourceยง

impl<T> Same for T

ยง

type Output = T

Should always be Self
ยง

impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,

ยง

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
ยง

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
ยง

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
ยง

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
sourceยง

impl<T> ToOwned for Twhere T: Clone,

ยง

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, U> TryFrom<U> for Twhere U: Into<T>,

ยง

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 Twhere U: TryFrom<T>,

ยง

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.
ยง

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

ยง

fn vzip(self) -> V

sourceยง

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,