Heightmap probing ... done?
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
#include "glm/gtx/quaternion.hpp"
|
||||
#include "nanogui/nanogui.h"
|
||||
#include "glm/gtc/matrix_inverse.hpp"
|
||||
#include "heightmap.h"
|
||||
#include <glm/ext/quaternion_float.hpp>
|
||||
#include <glm/ext/quaternion_trigonometric.hpp>
|
||||
#include <glm/vec3.hpp> // glm::vec3
|
||||
@@ -84,6 +85,7 @@ public:
|
||||
|
||||
Button *btn_keyboard_jog;
|
||||
std::stringstream dro_ss;
|
||||
grbl::heightmap heightmap_grid;
|
||||
|
||||
|
||||
SenderApp() : Screen(Vector2i(1024, 768), "GRBL Sender") {
|
||||
@@ -128,6 +130,7 @@ public:
|
||||
|
||||
m_render_pass = new RenderPass({this});
|
||||
m_render_pass->set_clear_color(0, Color(0.13f, 0.13f, 0.13f, 1.f));
|
||||
m_render_pass->set_clear_depth(0.0);
|
||||
m_render_pass->set_depth_test(RenderPass::DepthTest::Always, true);
|
||||
m_render_pass->set_cull_mode(RenderPass::CullMode::Disabled);
|
||||
}
|
||||
@@ -456,6 +459,7 @@ public:
|
||||
TextBox *txt_heightmap_from_x, *txt_heightmap_from_y;
|
||||
TextBox *txt_heightmap_to_x, *txt_heightmap_to_y;
|
||||
TextBox *txt_grid_res;
|
||||
TextBox *txt_clearance_height, *txt_start_probing_at, *txt_max_negative_z, *txt_final_z_height;
|
||||
|
||||
void add_heightmap_markup() {
|
||||
heightmap_layer->add<Label>("Grid definition", "sans-bold", 20);
|
||||
@@ -524,6 +528,37 @@ public:
|
||||
return true;
|
||||
});
|
||||
grid_res_holder->add<Label>("mm", "sans-bold", 20);
|
||||
|
||||
// business params
|
||||
auto heightmap_business_holder = heightmap_params_holder->add<Widget>();
|
||||
heightmap_business_holder->set_layout(new GridLayout(nanogui::Orientation::Horizontal, 3, Alignment::Fill, 4, 4));
|
||||
|
||||
heightmap_business_holder->add<Label>("Clearance height Z", "sans-bold", 20);
|
||||
txt_clearance_height = heightmap_business_holder->add<TextBox>("1.5");
|
||||
txt_clearance_height->set_editable(true);
|
||||
heightmap_business_holder->add<Label>("", "sans-bold");
|
||||
|
||||
heightmap_business_holder->add<Label>("Start probing at Z", "sans-bold", 20);
|
||||
txt_start_probing_at = heightmap_business_holder->add<TextBox>("0.5");
|
||||
txt_start_probing_at->set_editable(true);
|
||||
heightmap_business_holder->add<Label>("", "sans-bold");
|
||||
|
||||
heightmap_business_holder->add<Label>("Max negative Z", "sans-bold", 20);
|
||||
txt_max_negative_z = heightmap_business_holder->add<TextBox>("-1.0");
|
||||
txt_max_negative_z->set_editable(true);
|
||||
heightmap_business_holder->add<Label>("(when to fail probing)", "sans-bold");
|
||||
|
||||
heightmap_business_holder->add<Label>("Final Z safety height", "sans-bold", 20);
|
||||
txt_final_z_height = heightmap_business_holder->add<TextBox>("15");
|
||||
txt_final_z_height->set_editable(true);
|
||||
heightmap_business_holder->add<Label>("", "sans-bold");
|
||||
|
||||
heightmap_business_holder->add<Label>("", "sans-bold");
|
||||
auto btn_start_probing = heightmap_business_holder->add<Button>("Start Probing");
|
||||
btn_start_probing->set_callback([&]() {
|
||||
cnc.probe_heightmap(heightmap_grid);
|
||||
});
|
||||
heightmap_business_holder->add<Label>("", "sans-bold");
|
||||
}
|
||||
|
||||
void fill_heightmap_from_model() {
|
||||
@@ -540,8 +575,17 @@ public:
|
||||
auto from_y = std::stof(txt_heightmap_from_y->value());
|
||||
auto to_x = std::stof(txt_heightmap_to_x->value());
|
||||
auto to_y = std::stof(txt_heightmap_to_y->value());
|
||||
auto res = std::stoi(txt_grid_res->value());
|
||||
renderer.update_grid(from_x, from_y, to_x, to_y, res);
|
||||
auto res = std::stof(txt_grid_res->value());
|
||||
|
||||
if (from_x != heightmap_grid.from_x ||
|
||||
from_y != heightmap_grid.from_y ||
|
||||
to_x != heightmap_grid.to_x ||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void add_pins_markup() {
|
||||
@@ -773,6 +817,11 @@ public:
|
||||
new MessageDialog(this, MessageDialog::Type::Warning, "Probe result", ss.str());
|
||||
}
|
||||
|
||||
void on_heightmap_probe_acquired(grbl::heightmap *grid) override {
|
||||
std::cout << "Updating grid" << std::endl;
|
||||
renderer.update_grid(*grid);
|
||||
}
|
||||
|
||||
void on_check_completed(bool success, size_t failed_index, size_t error) override {
|
||||
btn_check_program->set_background_color(success ? colGreen : color_red);
|
||||
if (success) {
|
||||
|
||||
Reference in New Issue
Block a user