Exposed exaggeration factor when rendering heightmap.

Added checkbox to select whether to run autoleveled program or not.
Heightmap can handle non integer from_x and to_x.
This commit is contained in:
2023-05-23 14:28:08 +03:00
parent 4e7e059e22
commit b7b9fed0dd
8 changed files with 118 additions and 143 deletions
+24 -7
View File
@@ -102,7 +102,7 @@ void SenderApp::add_work_parameters_markup() {
auto work_btn_holder = work_holder->add<nanogui::Widget>();
work_btn_holder->set_layout(
new nanogui::GridLayout(nanogui::Orientation::Horizontal, 3, nanogui::Alignment::Fill, 0, 6));
new nanogui::GridLayout(nanogui::Orientation::Horizontal, 4, nanogui::Alignment::Fill, 0, 6));
btn_load_program = work_btn_holder->add<nanogui::Button>("Load");
@@ -132,12 +132,16 @@ void SenderApp::add_work_parameters_markup() {
btn_run_program = work_btn_holder->add<nanogui::Button>("Run");
// btnRunProgram->set_enabled(false);
btn_run_program->set_callback([&] {
// auto leveled_pgm = pgm.apply_heightmap(heightmap_grid);
// leveled_pgm.save("output_corrected6.nc");
cnc.run_program(pgm, "G" + std::to_string(cbo_work_offset->selected_index() + 54));
auto leveled_pgm = pgm.apply_heightmap(heightmap_grid);
leveled_pgm.save("last-run-autoleveled.nc");
cnc.run_program(btn_run_autoleveled->pushed() ? leveled_pgm : pgm,
"G" + std::to_string(cbo_work_offset->selected_index() + 54));
});
btn_run_program->set_tooltip("Execute program");
btn_run_autoleveled = work_btn_holder->add<nanogui::Button>("", FA_TABLE);
btn_run_autoleveled->set_flags(nanogui::Button::ToggleButton);
btn_run_autoleveled->set_tooltip("Run auto-leveled program version, using the current heightmap");
}
void SenderApp::add_status_markup() {
@@ -490,7 +494,7 @@ void SenderApp::add_heightmap_markup() {
if (!path.empty()) {
heightmap_grid = load_heightmap(path);
fill_heightmap_controls_from_grid(heightmap_grid);
renderer.update_grid(heightmap_grid);
renderer.update_grid(heightmap_grid, std::stof(exaggeration_factors[cbo_exaggeration->selected_index()]));
}
});
@@ -566,6 +570,19 @@ void SenderApp::add_heightmap_markup() {
save_heightmap(heightmap_grid, path);
}
});
heightmap_layer->add<nanogui::Label>("Grid rendering", "sans-bold", 20);
auto heightmap_render_holder = heightmap_layer->add<nanogui::Widget>();
heightmap_render_holder->set_layout(
new nanogui::GridLayout(nanogui::Orientation::Horizontal, 2, nanogui::Alignment::Fill, 4, 4));
heightmap_render_holder->add<nanogui::Label>("Exaggeration factor");
cbo_exaggeration = heightmap_render_holder->add<nanogui::ComboBox>(exaggeration_factors);
cbo_exaggeration->set_callback([&](int idx) {
renderer.update_grid(heightmap_grid, std::stof(exaggeration_factors[cbo_exaggeration->selected_index()]));
});
}
void SenderApp::fill_heightmap_from_model() const {
@@ -590,7 +607,7 @@ void SenderApp::update_grid() {
to_y != heightmap_grid.to_y ||
res != heightmap_grid.resolution) {
heightmap_grid = std::move(grbl::heightmap::from_params(from_x, from_y, to_x, to_y, res));
renderer.update_grid(heightmap_grid);
renderer.update_grid(heightmap_grid, std::stof(exaggeration_factors[cbo_exaggeration->selected_index()]));
}
}
@@ -996,7 +1013,7 @@ void SenderApp::draw(NVGcontext *ctx) {
case grbl::machine_event_type::heightmap_probe_acquired: {
std::cout << "Updating grid" << std::endl;
auto ev = dynamic_cast<grbl::machine_event_heightmap_probe_acquired *>(event.get());
renderer.update_grid(*ev->grid);
renderer.update_grid(*ev->grid, std::stof(exaggeration_factors[cbo_exaggeration->selected_index()]));
break;
}
}