align flag descriptions on cli & web

master
Sameer Puri 4 years ago
parent 97b76ca0d0
commit 7127168dd6

@ -18,34 +18,34 @@ use svg2gcode::{
#[derive(Debug, StructOpt)]
#[structopt(name = "svg2gcode", author, about)]
struct Opt {
/// Curve interpolation tolerance
/// Curve interpolation tolerance (mm)
#[structopt(long, default_value = "0.002")]
tolerance: f64,
/// Machine feed rate in mm/min
/// Machine feed rate (mm/min)
#[structopt(long, default_value = "300")]
feedrate: f64,
/// Dots per inch (DPI) for pixels, points, picas, etc.
/// Dots per Inch (DPI)
/// Used for scaling visual units (pixels, points, picas, etc.)
#[structopt(long, default_value = "96")]
dpi: f64,
#[structopt(alias = "tool_on_sequence", long = "on")]
/// Tool on "G-Code sequence
/// G-Code for turning on the tool
tool_on_sequence: Option<String>,
#[structopt(alias = "tool_off_sequence", long = "off")]
/// Tool off "G-Code sequence
/// G-Code for turning off the tool
tool_off_sequence: Option<String>,
/// Optional "G-Code begin sequence (i.e. change to a cutter tool)
/// G-Code for initializing the machine at the beginning of the program
#[structopt(alias = "begin_sequence", long = "begin")]
begin_sequence: Option<String>,
/// Optional "G-Code end sequence, prior to program end (i.e. put away a cutter tool)
/// G-Code for stopping/idling the machine at the end of the program
#[structopt(alias = "end_sequence", long = "end")]
end_sequence: Option<String>,
/// A file path for an SVG, else reads from stdin
/// A file path to an SVG, else reads from stdin
file: Option<PathBuf>,
/// Output file path (overwrites old files), else writes to stdout
#[structopt(short, long)]
out: Option<PathBuf>,
/// Set where the bottom left corner of the SVG will be placed. Also affects begin/end and
/// on/off sequences.
/// Coordinates for the bottom left corner of the machine
#[structopt(long, default_value = "0,0")]
origin: String,
/// Whether to use circular arcs when generating g-code

@ -1,13 +1,13 @@
/// Approximate [Bézier curves](https://en.wikipedia.org/wiki/B%C3%A9zier_curve) with [Circular arcs](https://en.wikipedia.org/wiki/Circular_arc)
mod arc;
/// Converts an SVG to "G-Code in an internal representation
/// Converts an SVG to G-Code in an internal representation
mod converter;
/// Emulates the state of an arbitrary machine that can run "G-Code
/// Emulates the state of an arbitrary machine that can run G-Code
mod machine;
/// Operations that are easier to implement after "G-Code is generated, or would
/// Operations that are easier to implement after G-Code is generated, or would
/// otherwise over-complicate SVG conversion
mod postprocess;
/// Provides an interface for drawing lines in "G-Code
/// Provides an interface for drawing lines in G-Code
/// This concept is referred to as [Turtle graphics](https://en.wikipedia.org/wiki/Turtle_graphics).
mod turtle;

@ -35,7 +35,7 @@ impl std::ops::Not for Distance {
}
/// Generic machine state simulation, assuming nothing is known about the machine when initialized.
/// This is used to reduce output "G-Code verbosity and run repetitive actions.
/// This is used to reduce output G-Code verbosity and run repetitive actions.
#[derive(Debug, Default, Clone)]
pub struct Machine<'input> {
supported_functionality: SupportedFunctionality,

@ -276,27 +276,27 @@ macro_rules! form_input {
form_input! {
Tolerance {
"Tolerance",
"Curve interpolation tolerance",
"Curve interpolation tolerance (mm)",
tolerance,
}
Feedrate {
"Feedrate",
"Machine feedrate in mm/min",
"Machine feedrate (mm/min)",
feedrate,
}
Dpi {
"Dots per Inch",
"Used for non-physical units (pixels, points, picas, etc.)",
"Used for scaling visual units (pixels, points, picas, etc.)",
dpi,
}
OriginX {
"Origin X",
"X-axis coordinate for the bottom left corner of the SVG",
"X-axis coordinate for the bottom left corner of the machine",
origin => 0,
}
OriginY {
"Origin Y",
"Y-axis coordinate for the bottom left corner of the SVG",
"Y-axis coordinate for the bottom left corner of the machine",
origin => 1,
}
}
@ -390,9 +390,10 @@ pub fn settings_form() -> Html {
<FeedrateInput/>
<OriginXInput/>
<OriginYInput/>
<FormGroup success=true>
<FormGroup>
<Checkbox
label="Enable circular interpolation"
desc="Please check if your machine supports G2/G3 commands before enabling this"
checked={circular_interpolation_checked}
onchange={on_circular_interpolation_change}
/>
@ -437,89 +438,6 @@ pub fn settings_form() -> Html {
}
}
// pub enum FileMsg {
// File(File),
// Data(FileData),
// }
// pub struct SvgUploadOrLink {
// link: ComponentLink<Self>,
// reader_task: Option<ReaderTask>,
// }
// impl Component for SvgUploadOrLink {
// type Message = FileMsg;
// type Properties = ();
// fn create(props: Self::Properties, link: ComponentLink<Self>) -> Self {
// Self {
// link,
// reader_task: None,
// }
// }
// fn update(&mut self, msg: Self::Message) -> ShouldRender {
// match msg {
// FileMsg::File(file) => {
// self.reader_task = Some(
// ReaderService::read_file(file, self.link.callback(FileMsg::Data)).unwrap(),
// );
// false
// }
// FileMsg::Data(data) => {
// self.reader_task = None;
// false
// }
// }
// }
// fn change(&mut self, _props: Self::Properties) -> ShouldRender {
// todo!()
// }
// fn view(&self) -> Html {
// html! {
// <label>
// { "SVG File" }
// <input type="file" accept=".svg,image/svg+xml" multiple=false onchange={
// self.link.callback(|value| {
// if let ChangeData::Files(files) = value {
// FileMsg::File(files.get(0).unwrap())
// } else {
// unreachable!()
// }
// })
// }/>
// </label>
// }
// }
// }
// trait FileInputDispatcher: Dispatcher {
// fn file_text(
// &self,
// f: impl Fn(&mut <Self::Store as Store>::Model, Result<String, FileReadError>) + Copy + 'static,
// ) -> Callback<FileList>
// where
// Self: Clone,
// {
// let set_file = self.future_callback_with(f);
// Callback::from(move |file_list: FileList| {
// for file in (0..file_list.length()).filter_map(|i| file_list.item(i)) {
// let cb = set_file.clone();
// read_as_text(&gloo_file::File::from(file), move |result| {
// cb.emit(result);
// })
// .await;
// }
// })
// }
// }
// impl<T: Dispatcher> FileInputDispatcher for T {}
#[function_component(SvgInput)]
pub fn svg_input() -> Html {
let app = use_store::<AppStore>();

@ -116,6 +116,7 @@ where
#[derive(Properties, PartialEq, Clone)]
pub struct CheckboxProps {
pub label: &'static str,
pub desc: Option<&'static str>,
#[prop_or(false)]
pub checked: bool,
#[prop_or_default]
@ -131,6 +132,13 @@ pub fn checkbox(props: &CheckboxProps) -> Html {
<Icon form={true} name={IconName::None} />
{ props.label }
</label>
{
if let Some(desc) = props.desc {
html! { <p class="form-input-hint">{ desc }</p> }
} else {
html!()
}
}
</>
}
}

Loading…
Cancel
Save