Cut Gizmo -> added movements using arrow keys:

Up arrow = increase Z by 1mm

Down arrow = decrease Z by 1mm
This commit is contained in:
Enrico Turri 2020-02-03 15:00:49 +01:00
parent c09091c407
commit 8453c88482
3 changed files with 22 additions and 2 deletions

View File

@ -9,6 +9,8 @@
#include <wx/stattext.h>
#include <wx/sizer.h>
#include <algorithm>
#include "slic3r/GUI/GUI_App.hpp"
@ -189,7 +191,7 @@ void GLGizmoCut::update_max_z(const Selection& selection) const
void GLGizmoCut::set_cut_z(double cut_z) const
{
// Clamp the plane to the object's bounding box
m_cut_z = std::max(0.0, std::min(m_max_z, cut_z));
m_cut_z = std::clamp(cut_z, 0.0, m_max_z);
}
void GLGizmoCut::perform_cut(const Selection& selection)

View File

@ -25,6 +25,9 @@ class GLGizmoCut : public GLGizmoBase
public:
GLGizmoCut(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
double get_cut_z() const { return m_cut_z; }
void set_cut_z(double cut_z) const;
protected:
virtual bool on_init();
virtual void on_load(cereal::BinaryInputArchive& ar) { ar(m_cut_z, m_keep_upper, m_keep_lower, m_rotate_lower); }
@ -40,7 +43,6 @@ protected:
private:
void update_max_z(const Selection& selection) const;
void set_cut_z(double cut_z) const;
void perform_cut(const Selection& selection);
double calc_projection(const Linef3& mouse_ray) const;
};

View File

@ -815,6 +815,22 @@ bool GLGizmosManager::on_key(wxKeyEvent& evt)
default: { break; }
}
}
else if (m_current == Cut)
{
auto do_move = [this, &processed](double delta_z) {
GLGizmoCut* cut = dynamic_cast<GLGizmoCut*>(get_current());
cut->set_cut_z(delta_z + cut->get_cut_z());
m_parent.set_as_dirty();
processed = true;
};
switch (keyCode)
{
case WXK_NUMPAD_UP: case WXK_UP: { do_move(1.0); break; }
case WXK_NUMPAD_DOWN: case WXK_DOWN: { do_move(-1.0); break; }
default: { break; }
}
}
// if (processed)
// m_parent.set_cursor(GLCanvas3D::Standard);