Clean and add world grid for mapping (WIP, fix glitch on pillow distortion)

This commit is contained in:
Ruben van de Ven 2025-07-02 12:32:33 +02:00
parent e8fec78250
commit e291ab480a
2 changed files with 53 additions and 54 deletions

View file

@ -177,16 +177,6 @@ fn zmq_receive(model: &mut GuiModel) {
}
// #[derive(Serialize, Deserialize)]
// #[serde(remote = "DacId")]
// pub enum DacIdSerializable {
// EtherDream { mac_address: [u8; 6] },
// Helios { id: u32 },
// }
// DEPRECATED
type DacConfigMap = HashMap<DacId, DacConfig>;
@ -641,12 +631,7 @@ fn update(_app: &App, model: &mut GuiModel, update: Update) {
let source = &mut stream_config.config.source;
// for source_option in STREAM_SOURCES {
// if ui.radio_value(source, source_option.clone(), format!("{:?}", &source_option)).changed() {
// println!("Clicked!")
// };
// }
egui::ComboBox::from_label("Source")
.selected_text(format!("{source:?}"))
.show_ui(ui, |ui| {
@ -659,43 +644,9 @@ fn update(_app: &App, model: &mut GuiModel, update: Update) {
};
}
// ui.selectable_value(source, StreamSource::CurrentLines, "Zmq Stream");
// ui.selectable_value(source, StreamSource::Rectangle, "Rectangle");
// ui.selectable_value(source, StreamSource::Grid, "Grid");
});
// ui.radio_value(source, StreamSource::Rectangle, "Rectangle");
// ui.radio_value(source, StreamSource::Grid, "Grid");
// if ui.add(DropDownBox::from_iter(
// vec!(StreamSource::CurrentLines, StreamSource::Rectangle, StreamSource::Grid(5)),
// "test_dropbox",
// &mut stream_config.config.source,
// |ui, text| ui.selectable_label(false, text)
// )).changed() {
// println!("Changed source! {:?}", stream_config.config.source);
// let source = stream_config.config.source;
// stream_config.stream.send(move |laser_model: &mut LaserModel| {
// laser_model.config.source = source;
// }).unwrap();
// }
// if ui.add(
// egui::ComboBox::from_label("Source")
// .selected_text(format!("{source:?}"))
// // .show_ui(ui, |ui| {
// // ui.selectable_value(source, StreamSource::CurrentLines, "Zmq Stream");
// // ui.selectable_value(source, StreamSource::Rectangle, "Rectangle");
// // ui.selectable_value(source, StreamSource::Grid(5), "Grid");
// // })
// ).changed()
// {
// let source = stream_config.config.source;
// stream_config.stream.send(move |laser_model: &mut LaserModel| {
// laser_model.config.source = source;
// }).unwrap();
// }
if ui
.add(egui::Slider::new(&mut stream_config.config.filters.dim.intensity, 0.0..=1.).text("Dimming"))
.changed()

View file

@ -97,12 +97,20 @@ pub enum StreamSource {
CurrentLines,
Rectangle,
Grid, // lines
Circle, // segments
Spiral,
WorldGrid, // grid in world space
// Circle, // segments
// Spiral,
}
// usefull to create pull downs with an iterator
pub const STREAM_SOURCES: [StreamSource; 5] = [StreamSource::CurrentLines, StreamSource::Rectangle, StreamSource::Grid, StreamSource::Circle, StreamSource::Spiral];
pub const STREAM_SOURCES: [StreamSource; 4] = [
StreamSource::CurrentLines,
StreamSource::Rectangle,
StreamSource::Grid,
StreamSource::WorldGrid,
// StreamSource::Circle,
// StreamSource::Spiral
];
const LASER_H: Mat3 = python_cv_h_into_mat3(TMP_PYTHON_LASER_H);
@ -193,7 +201,47 @@ impl StreamSource{
LaserPoints { points, space: CoordinateSpace::Laser }
},
_ => LaserPoints::default(),
Self::WorldGrid => {
// a grid in world space. Usefull for calibrating
let mut points = Vec::new();
for i in (-20..=50).step_by(5) {
let color = if i % 10 == 0 { [1.,0.,0.]} else {[1.,1.,1.]};
points.push(laser::Point{
position:[i as f32, 0.],
color: [0., 0., 0.],
weight: 0,
});
for j in (-20..=50).step_by(2) {
points.push(laser::Point{
position:[i as f32, j as f32],
color,
weight: 0,
});
}
points.push(points[points.len()-1].blanked());
}
for i in (-20..=50).step_by(5) {
let color = if i % 10 == 0 { [0.,0.,1.]} else {[1.,1.,1.]};
points.push(laser::Point{
position:[0., i as f32],
color: [0., 0., 0.],
weight: 0,
});
for j in (-20..=50).step_by(2) {
points.push(laser::Point{
position:[j as f32, i as f32],
color,
weight: 0,
});
}
points.push(points[points.len()-1].blanked());
}
LaserPoints { points, space: CoordinateSpace::World }
},
_ => LaserPoints::default(), // empty set
}
}
}