Skip to content

Commit

Permalink
initial implementation of external spur gears
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom committed Feb 13, 2024
1 parent ad4bea0 commit 7e52fba
Show file tree
Hide file tree
Showing 9 changed files with 940 additions and 7 deletions.
33 changes: 30 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

77 changes: 77 additions & 0 deletions detailer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,25 @@ impl<'a> Widget<'a> {
meta,
)
}
Some(Feature::SpurGear(
meta,
_p,
drawing::GearInfo {
module,
teeth,
pressure_angle,
offset: _,
},
)) => Widget::show_selection_entry_spur_gear(
ui,
&mut commands,
&mut changed,
&k,
module,
teeth,
pressure_angle,
meta,
),
None => {}
}

Expand Down Expand Up @@ -882,6 +901,64 @@ impl<'a> Widget<'a> {
});
}

fn show_selection_entry_spur_gear(
ui: &mut egui::Ui,
commands: &mut Vec<ToolResponse>,
changed: &mut bool,
k: &FeatureKey,
module: &mut f32,
teeth: &mut usize,
_pressure_angle: &mut f32,
meta: &mut FeatureMeta,
) {
ui.horizontal(|ui| {
let r = ui.available_size();
let text_height = egui::TextStyle::Body.resolve(ui.style()).size;

use slotmap::Key;
ui.add(
egui::Label::new(format!("Spur gear {:?}", k.data()))
.wrap(false)
.truncate(true),
);
if r.x - ui.available_width() < FEATURE_NAME_WIDTH {
ui.add_space(FEATURE_NAME_WIDTH - (r.x - ui.available_width()));
}

*changed |= ui
.add(egui::Checkbox::without_text(&mut meta.construction))
.changed();
ui.add(egui::Image::new(CONSTRUCTION_IMG).rounding(5.0));

if ui.available_width() > r.x / 2. - ui.spacing().item_spacing.x {
ui.add_space(ui.available_width() - r.x / 2. - ui.spacing().item_spacing.x);
}

*changed |= ui
.add_sized(
[50., text_height * 1.4],
egui::DragValue::new(module)
.clamp_range(0.1..=25.0)
.prefix("m")
.speed(1.0),
)
.changed();
*changed |= ui
.add_sized(
[50., text_height * 1.4],
egui::DragValue::new(teeth)
.clamp_range(5..=150)
.suffix("t")
.speed(1.0),
)
.changed();
ui.with_layout(egui::Layout::right_to_left(egui::Align::TOP), |ui| {
if ui.button("⊗").clicked() {
commands.push(ToolResponse::Delete(*k));
}
});
});
}
fn show_groups_tab<F>(&mut self, ui: &mut egui::Ui, export_save: F)
where
F: FnOnce(&'static str, &'static str, Vec<u8>),
Expand Down
5 changes: 4 additions & 1 deletion drawing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ kurbo.workspace = true
truck-modeling.workspace = true
truck-polymesh.workspace = true
truck-meshalgo.workspace = true
truck-topology.workspace = true
truck-topology.workspace = true

[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
tiny-skia = "0.11"
Loading

0 comments on commit 7e52fba

Please sign in to comment.