feat: Point coordinate regulators #118
2 changed files with 12 additions and 5 deletions
|
@ -127,7 +127,7 @@ pub trait Element: Serial + ProblemPoser + DisplayItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Debug for dyn Element {
|
impl Debug for dyn Element {
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), fmt::Error> {
|
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||||
self.id().fmt(f)
|
self.id().fmt(f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -514,7 +514,15 @@ impl ProblemPoser for HalfCurvatureRegulator {
|
||||||
pub enum Axis { X = 0, Y = 1, Z = 2 }
|
pub enum Axis { X = 0, Y = 1, Z = 2 }
|
||||||
|
|
||||||
impl Axis {
|
impl Axis {
|
||||||
pub const NAME: [&str; Axis::CARDINALITY] = ["X", "Y", "Z"];
|
fn name(&self) -> &'static str {
|
||||||
|
match self { Axis::X => "X", Axis::Y => "Y", Axis::Z => "Z" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for Axis {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
f.write_str(self.name())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct PointCoordinateRegulator {
|
pub struct PointCoordinateRegulator {
|
||||||
|
|
|
@ -6,7 +6,6 @@ use web_sys::{KeyboardEvent, MouseEvent, wasm_bindgen::JsCast};
|
||||||
use crate::{
|
use crate::{
|
||||||
AppState,
|
AppState,
|
||||||
assembly::{
|
assembly::{
|
||||||
Axis,
|
|
||||||
Element,
|
Element,
|
||||||
HalfCurvatureRegulator,
|
HalfCurvatureRegulator,
|
||||||
InversiveDistanceRegulator,
|
InversiveDistanceRegulator,
|
||||||
|
@ -123,7 +122,7 @@ impl OutlineItem for HalfCurvatureRegulator {
|
||||||
|
|
||||||
impl OutlineItem for PointCoordinateRegulator {
|
impl OutlineItem for PointCoordinateRegulator {
|
||||||
fn outline_item(self: Rc<Self>, _element: &Rc<dyn Element>) -> View {
|
fn outline_item(self: Rc<Self>, _element: &Rc<dyn Element>) -> View {
|
||||||
let name = format!("{} coordinate", Axis::NAME[self.axis as usize]);
|
let name = format!("{} coordinate", self.axis);
|
||||||
view! {
|
view! {
|
||||||
li(class = "regulator") {
|
li(class = "regulator") {
|
||||||
div(class = "regulator-label") // for spacing
|
div(class = "regulator-label") // for spacing
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue