fibomat.default_backends.bokeh_backend module#
- class fibomat.default_backends.bokeh_backend.StubRasterStyle(dimension: int)[source]#
Bases:
RasterStyle- property dimension: int#
Returns the required dimensionality a shape must have to apply this raster style Returns:
- rasterize(dim_shape: DimShape, mill: Mill, out_length_unit: Unit, out_time_unit: Unit) RasterizedPoints[source]#
Rasterize the given shape.
The number of repeats and dwell_time defined in the mill object must be applied! The points and dwell times in the returned RasterizedPoints object must be scaled according to out_length_unit and out_time_unit.
- Args:
dim_shape (DimObjLike[Shape, LengthUnit]): shpae with length unit to be rasterized. mill (Mill): mill out_length_unit (LengthUnit): length unit of returned RasterizedPoints out_time_unit (TimeUnit): time unit of returned RasterizedPoints
- Returns:
RasterizedPoints
- clone() RasterStyle#
Deep copy the raster style.
- Returns:
RasterStyle
- class fibomat.default_backends.bokeh_backend.BokehImage(file: str | Path | Image, image_pixel_scale: Quantity, center: DimVector | None = None)[source]#
Bases:
DimShape- __init__(file: str | Path | Image, image_pixel_scale: Quantity, center: DimVector | None = None)[source]#
- Args:
- pivot (VectorLike, optional): if set, the
Transformable.pivotis set to pivot. If not set, Transformable.centeris used as default.
description (str, optional): optional description
- pivot (VectorLike, optional): if set, the
- property shape#
- property width#
- property height#
- property center#
center of the (geometric) object
- Access:
get
- Returns:
Any
- property data#
- property bounding_box: DimBoundingBox#
BoundingBox: bounding box of transformable- Access:
get
- clone() T#
Create a deepcopy of the object.
- Returns:
Describable
- mirrored(mirror_plane: VectorT) SelfT#
Return a mirrored object mirrored about mirror_plane.
- Args:
mirror_plane (VectorLike): mirror plane to be used.
- Returns:
TransformableBase
- property pivot: VectorT#
Origin of the (geometric) object. If origin is set to None,
Transformable.centerwill be returned.Pivot must be set to a callable function without parameters.
transformable_obj = ... transformable_obj.pivot = lambda: return Vector(1, 2) print(transformable_obj.pivot) # will print Vector(1, 2)
- Access:
get/set
- Returns:
Vector
- rotated(theta: float, origin: VectorT | str | None = None) SelfT#
Return a rotated copy around origin with angle theta in math. positive direction (counterclockwise).
- Args:
theta (float): rotation angle in rad origin (Optional[Union[linalg.VectorLike, str]], optional):
origin of rotation. If not set, (0,0) is used as origin. If origin == ‘center’, the
Transformable.centerof the object will be used. The same applies for the case that origin == ‘origin’ with theTransformable.originproperty. Default to None.- Returns:
TransformableBase
- scaled(fac: float, origin: VectorT | str | None = None) SelfT#
Return a scale object homogeneously about origin with factor s.
- Args:
fac (float): rotation angle in rad origin (Optional[Union[linalg.VectorLike, str]], optional):
origin of rotation. If not set, (0,0) is used as origin. If origin == ‘center’, the
Transformable.centerof the object will be used. The same applies for the case that origin == ‘origin’ with theTransformable.originproperty. Default to None.- Returns:
TransformableBase
- transformed(transformations: _TransformationBuilder[VectorT]) SelfT#
- Return a transformed object. the transformation can be build by the following functions:
translate()rotate()scale()mirror()
E.g.
transformable_obj.transform(translate([1, 2]) | rotate(np.pi/3) | mirror([3,4])
- Args:
transformations (_TransformationBuilder): transformation
- Returns:
TransformableBase
- translated(trans_vec: VectorT) SelfT#
Return a translated copy of the object by trans_vec.
- Args:
trans_vec (VectorLike): translation vector
- Returns:
TransformableBase
- translated_to(pos: VectorT) SelfT#
Return a translated copy of the object so that self.pivot == pos
- Args:
pos: new position of object
- Returns:
TransformableBase
- property unit#
- class fibomat.default_backends.bokeh_backend.BokehBackendBase(**kwargs)[source]#
Bases:
BackendBase- bokeh_image(ptn: Pattern[BokehImage])[source]#
- __init__(**kwargs)#
- Args:
- **kwargs: optional parameters for the backend given by **kwargs in
fibomat.project.Project.export()
- arc(ptn: Pattern[Arc]) None#
Adds pattern with Arc as shape to the backend.
- Args:
ptn (Pattern): pattern with Arc as shape
- Returns:
None
- arc_spline(ptn: Pattern[ArcSpline]) None#
Adds pattern with ArcSpline as shape to the backend.
- Args:
ptn (Pattern): pattern with ArcSpline as shape
- Returns:
None
- circle(ptn: Pattern[Circle]) None#
Adds pattern with Ellipse as shape to the backend.
- Args:
ptn (Pattern): pattern with Ellipse as shape
- Returns:
None
- ellipse(ptn: Pattern[Ellipse]) None#
Adds pattern with Ellipse as shape to the backend.
- Args:
ptn (Pattern): pattern with Ellipse as shape
- Returns:
None
- hollow_arc_spline(ptn: Pattern[HollowArcSpline]) None#
Adds pattern with HollowArcSpline as shape to the backend.
- Args:
ptn (Pattern): pattern with HollowArcSpline as shape
- Returns:
None
- property implemented_shape_methods: Dict[Shape, Callable]#
Dict[Shape, str]: implemented shape methods of backend
- line(ptn: Pattern[Line]) None#
Adds pattern with Line as shape to the backend.
- Args:
ptn (Pattern): pattern with Line as shape
- Returns:
None
- parametric_curve(ptn: Pattern[ParametricCurve]) None#
Adds pattern with Curve as shape to the backend.
- Args:
ptn (Pattern): pattern with Curve as shape
- Returns:
None
- polygon(ptn: Pattern[Polygon]) None#
Adds pattern with Ellipse as shape to the backend.
- Args:
ptn (Pattern): pattern with Ellipse as shape
- Returns:
None
- polyline(ptn: Pattern[Polyline]) None#
Adds pattern with Ellipse as shape to the backend.
- Args:
ptn (Pattern): pattern with Ellipse as shape
- Returns:
None
- process_pattern(ptn: Pattern) None#
Add a pattern to the backend. The appropriate method is determined by the pattern’s shape class automatically.
If pattern contains a Layout, the contained shapes will be extracted automatically.
- Args:
ptn (Pattern): pattern to be added. on_unknown_shape:
- Returns:
None
- process_site(new_site: Site) None#
Adds a
fibomat.site.Siteto the backend. Note, that this method processes all patterns contained in the site. Use the following example as reference, if a backend overwrites this method.... def process_site(self, site: Site): # ... # do the backend specific stuff here (e.g. initialize a new patterning site) # call base method to add all patterns automatically super().process_site(site) ...
- Args:
new_site (Site): site to be added.
- Returns:
None
- process_unknown(ptn: Pattern) None#
Process a shape, which do not have a registered shape handler. Raises an exception by default.
- Args:
ptn (Pattern): pattern to be added.
- Returns:
None
- rasterized_pattern(ptn: Pattern[RasterizedPattern])#
Adds pattern with RasterizedPattern as shape to the backend.
- Args:
ptn (Pattern): pattern with RasterizedPattern as shape
- Returns:
None
- rasterized_points(ptn: Pattern[RasterizedPoints])#
Adds pattern with RasterizedPoints as shape to the backend.
- Args:
ptn (Pattern): pattern with RasterizedPoints as shape
- Returns:
None
- rect(ptn: Pattern[Rect]) None#
Adds pattern with Rect as shape to the backend.
- Args:
ptn (Pattern): pattern with Rect as shape
- Returns:
None
- class fibomat.default_backends.bokeh_backend.BokehBackend(*, unit: Unit | None = None, title: str | None = None, hide_sites: bool = False, rasterize_pitch: Quantity | None = None, fullscreen: bool = True, legend: bool = True, cycle_colors: bool = True, image_alpha: float = 0.75, plot_reduced_lattices: bool = False, only_sites: bool = False, **kwargs)[source]#
Bases:
BokehBackendBaseThe default backend for plotting projects, based on the bokeh library. All shapes defined in fibomat library are supported.
Note
ArcandCurveare rasterized during plotting due to lack of supported of the HoverTool for this shapes in the bokeh library. The pitch can be defined via the rasterize_pitch parameter.- name = 'bokeh'#
- __init__(*, unit: Unit | None = None, title: str | None = None, hide_sites: bool = False, rasterize_pitch: Quantity | None = None, fullscreen: bool = True, legend: bool = True, cycle_colors: bool = True, image_alpha: float = 0.75, plot_reduced_lattices: bool = False, only_sites: bool = False, **kwargs)[source]#
- Args:
unit (units.UnitType, optional): used unit for plotting, default to units.U_(‘µm’) title (str, optional): title of plot, default to ‘’ hide_sites (bool, optional): if true, sides’ outlines are not shown, default to false rasterize_pitch (units.QuantityType. optional): curve_tools.rasterize pitch for shapes.Arc, … and shapes.Curve, default to units.Q_(‘0.01 µm’) fullscreen (bool, optional): if true, plot will be take the whole page, default to True cycle_colors (bool): if True, different sites get different colors. image_alpha (float): alpha value (transparency) of images, default to 0.75
- process_site(site: Site)[source]#
Adds a
fibomat.site.Siteto the backend. Note, that this method processes all patterns contained in the site. Use the following example as reference, if a backend overwrites this method.... def process_site(self, site: Site): # ... # do the backend specific stuff here (e.g. initialize a new patterning site) # call base method to add all patterns automatically super().process_site(site) ...
- Args:
new_site (Site): site to be added.
- Returns:
None
- process_pattern(ptn: Pattern) None[source]#
Add a pattern to the backend. The appropriate method is determined by the pattern’s shape class automatically.
If pattern contains a Layout, the contained shapes will be extracted automatically.
- Args:
ptn (Pattern): pattern to be added. on_unknown_shape:
- Returns:
None
- process_unknown(ptn: Pattern) None[source]#
Process a shape, which do not have a registered shape handler. Raises an exception by default.
- Args:
ptn (Pattern): pattern to be added.
- Returns:
None
- save(filename: str | Path, use_cdn: bool = False)[source]#
Saves the exported project to file. Args:
filename (PathLike): filename
- Returns:
None
- spot(ptn: Pattern[Spot]) None[source]#
Adds pattern with Spot as shape to the backend.
- Args:
ptn (Pattern): pattern with Spot as shape
- Returns:
None
- line(ptn: Pattern[Line]) None[source]#
Adds pattern with Line as shape to the backend.
- Args:
ptn (Pattern): pattern with Line as shape
- Returns:
None
- polyline(ptn: Pattern[Polyline]) None[source]#
Adds pattern with Ellipse as shape to the backend.
- Args:
ptn (Pattern): pattern with Ellipse as shape
- Returns:
None
- arc(ptn: Pattern[Arc]) None[source]#
Adds pattern with Arc as shape to the backend.
- Args:
ptn (Pattern): pattern with Arc as shape
- Returns:
None
- arc_spline(ptn: Pattern[ArcSpline]) None[source]#
Adds pattern with ArcSpline as shape to the backend.
- Args:
ptn (Pattern): pattern with ArcSpline as shape
- Returns:
None
- polygon(ptn: Pattern[Polygon]) None[source]#
Adds pattern with Ellipse as shape to the backend.
- Args:
ptn (Pattern): pattern with Ellipse as shape
- Returns:
None
- rect(ptn: Pattern[Rect]) None[source]#
Adds pattern with Rect as shape to the backend.
- Args:
ptn (Pattern): pattern with Rect as shape
- Returns:
None
- ellipse(ptn: Pattern[Ellipse]) None[source]#
Adds pattern with Ellipse as shape to the backend.
- Args:
ptn (Pattern): pattern with Ellipse as shape
- Returns:
None
- circle(ptn: Pattern[Circle]) None[source]#
Adds pattern with Ellipse as shape to the backend.
- Args:
ptn (Pattern): pattern with Ellipse as shape
- Returns:
None
- property implemented_shape_methods: Dict[Shape, Callable]#
Dict[Shape, str]: implemented shape methods of backend
- parametric_curve(ptn: Pattern[ParametricCurve]) None#
Adds pattern with Curve as shape to the backend.
- Args:
ptn (Pattern): pattern with Curve as shape
- Returns:
None
- rasterized_pattern(ptn: Pattern[RasterizedPattern])#
Adds pattern with RasterizedPattern as shape to the backend.
- Args:
ptn (Pattern): pattern with RasterizedPattern as shape
- Returns:
None
- rasterized_points(ptn: Pattern[RasterizedPoints])[source]#
Adds pattern with RasterizedPoints as shape to the backend.
- Args:
ptn (Pattern): pattern with RasterizedPoints as shape
- Returns:
None
- hollow_arc_spline(ptn: Pattern[HollowArcSpline]) None[source]#
Adds pattern with HollowArcSpline as shape to the backend.
- Args:
ptn (Pattern): pattern with HollowArcSpline as shape
- Returns:
None
- bokeh_image(ptn: Pattern[BokehImage])[source]#