|
@@ -9,14 +9,12 @@ use std::{
|
|
|
use binrw::{BinRead, BinWrite, BinWriterExt};
|
|
|
use clap::{error::ErrorKind, Args, Error, Parser, Subcommand};
|
|
|
use clap_verbosity_flag::{InfoLevel, Verbosity};
|
|
|
-use config::{hatch, object};
|
|
|
use dialoguer::Confirm;
|
|
|
use diff::Diff;
|
|
|
use env_logger::Target;
|
|
|
-use ezcad::{file::EzCadHeader, layer::Layer, objects::Object, pen::Pen, types::PulseWidth};
|
|
|
+use ezcad::{file::EzCadHeader, layer::Layer, objects::Object, pen::Pen};
|
|
|
use itertools::Itertools;
|
|
|
use log::{info, trace, warn};
|
|
|
-use num_enum::TryFromPrimitive;
|
|
|
use num_format::{Locale, ToFormattedString};
|
|
|
use regex::Regex;
|
|
|
|
|
@@ -257,25 +255,11 @@ fn main() {
|
|
|
|
|
|
// Calculate estimated power density if object is hatched
|
|
|
let hatch_power: Option<String> = match object {
|
|
|
- Object::Hatch(hatch) => {
|
|
|
- let line_spacing: f64 = *hatch
|
|
|
- .hatch_settings
|
|
|
- .iter()
|
|
|
- .find(|h| h.enabled.into())
|
|
|
- .expect("Hatch object does not have enabled settings")
|
|
|
- .line_spacing;
|
|
|
- let power: f64 = *pen.power;
|
|
|
- let speed: f64 = *pen.speed;
|
|
|
- let frequency: f64 = f64::from(*pen.frequency);
|
|
|
- let pulse: f64 = PulseWidth::try_from_primitive(*pen.pulse_width)
|
|
|
- .expect("Invalid pen pulse width")
|
|
|
- .power_ratio();
|
|
|
-
|
|
|
- let hatch_power: u64 =
|
|
|
- ((1.0 / line_spacing) * power * (1.0 / speed) * frequency * pulse)
|
|
|
- as u64;
|
|
|
- Some(hatch_power.to_formatted_string(&Locale::en))
|
|
|
- }
|
|
|
+ Object::Hatch(hatch) => Some(
|
|
|
+ hatch
|
|
|
+ .calc_power_density(pens)
|
|
|
+ .to_formatted_string(&Locale::en),
|
|
|
+ ),
|
|
|
_ => None,
|
|
|
};
|
|
|
|