Added visual hints in 3D scene for layers editing
This commit is contained in:
parent
1525a864c5
commit
1058721dba
4 changed files with 126 additions and 46 deletions
|
@ -3307,7 +3307,8 @@ void GLCanvas3D::handle_sidebar_focus_event(const std::string& opt_key, bool foc
|
||||||
|
|
||||||
void GLCanvas3D::handle_layers_data_focus_event(const t_layer_height_range range, const EditorType type)
|
void GLCanvas3D::handle_layers_data_focus_event(const t_layer_height_range range, const EditorType type)
|
||||||
{
|
{
|
||||||
printf("min_z = %.2f, max_z = %.2f, type=%d\n", range.first, range.second, type);
|
std::string field = "layer_" + std::to_string(type) + "_" + std::to_string(range.first) + "_" + std::to_string(range.second);
|
||||||
|
handle_sidebar_focus_event(field, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas3D::update_ui_from_settings()
|
void GLCanvas3D::update_ui_from_settings()
|
||||||
|
@ -4275,13 +4276,7 @@ void GLCanvas3D::_render_sla_slices() const
|
||||||
|
|
||||||
void GLCanvas3D::_render_selection_sidebar_hints() const
|
void GLCanvas3D::_render_selection_sidebar_hints() const
|
||||||
{
|
{
|
||||||
if (m_use_VBOs)
|
m_selection.render_sidebar_hints(m_sidebar_field, m_shader);
|
||||||
m_shader.start_using();
|
|
||||||
|
|
||||||
m_selection.render_sidebar_hints(m_sidebar_field);
|
|
||||||
|
|
||||||
if (m_use_VBOs)
|
|
||||||
m_shader.stop_using();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -257,6 +257,8 @@ LayerRangeEditor::LayerRangeEditor( ObjectLayers* parent,
|
||||||
|
|
||||||
this->Bind(wxEVT_KILL_FOCUS, [this, edit_fn](wxFocusEvent& e)
|
this->Bind(wxEVT_KILL_FOCUS, [this, edit_fn](wxFocusEvent& e)
|
||||||
{
|
{
|
||||||
|
wxGetApp().plater()->canvas3D()->handle_sidebar_focus_event("", false);
|
||||||
|
|
||||||
if (!m_enter_pressed) {
|
if (!m_enter_pressed) {
|
||||||
#ifndef __WXGTK__
|
#ifndef __WXGTK__
|
||||||
/* Update data for next editor selection.
|
/* Update data for next editor selection.
|
||||||
|
|
|
@ -1070,18 +1070,24 @@ void Selection::render_center(bool gizmo_is_dragging) const
|
||||||
}
|
}
|
||||||
#endif // ENABLE_RENDER_SELECTION_CENTER
|
#endif // ENABLE_RENDER_SELECTION_CENTER
|
||||||
|
|
||||||
void Selection::render_sidebar_hints(const std::string& sidebar_field) const
|
void Selection::render_sidebar_hints(const std::string& sidebar_field, const Shader& shader) const
|
||||||
{
|
{
|
||||||
if (sidebar_field.empty())
|
if (sidebar_field.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!boost::starts_with(sidebar_field, "layer"))
|
||||||
|
{
|
||||||
|
shader.start_using();
|
||||||
glsafe(::glClear(GL_DEPTH_BUFFER_BIT));
|
glsafe(::glClear(GL_DEPTH_BUFFER_BIT));
|
||||||
glsafe(::glEnable(GL_DEPTH_TEST));
|
|
||||||
|
|
||||||
glsafe(::glEnable(GL_LIGHTING));
|
glsafe(::glEnable(GL_LIGHTING));
|
||||||
|
}
|
||||||
|
|
||||||
|
glsafe(::glEnable(GL_DEPTH_TEST));
|
||||||
|
|
||||||
glsafe(::glPushMatrix());
|
glsafe(::glPushMatrix());
|
||||||
|
|
||||||
|
if (!boost::starts_with(sidebar_field, "layer"))
|
||||||
|
{
|
||||||
const Vec3d& center = get_bounding_box().center();
|
const Vec3d& center = get_bounding_box().center();
|
||||||
|
|
||||||
if (is_single_full_instance() && !wxGetApp().obj_manipul()->get_world_coordinates())
|
if (is_single_full_instance() && !wxGetApp().obj_manipul()->get_world_coordinates())
|
||||||
|
@ -1127,6 +1133,7 @@ void Selection::render_sidebar_hints(const std::string& sidebar_field) const
|
||||||
glsafe(::glMultMatrixd(orient_matrix.data()));
|
glsafe(::glMultMatrixd(orient_matrix.data()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (boost::starts_with(sidebar_field, "position"))
|
if (boost::starts_with(sidebar_field, "position"))
|
||||||
render_sidebar_position_hints(sidebar_field);
|
render_sidebar_position_hints(sidebar_field);
|
||||||
|
@ -1136,10 +1143,16 @@ void Selection::render_sidebar_hints(const std::string& sidebar_field) const
|
||||||
render_sidebar_scale_hints(sidebar_field);
|
render_sidebar_scale_hints(sidebar_field);
|
||||||
else if (boost::starts_with(sidebar_field, "size"))
|
else if (boost::starts_with(sidebar_field, "size"))
|
||||||
render_sidebar_size_hints(sidebar_field);
|
render_sidebar_size_hints(sidebar_field);
|
||||||
|
else if (boost::starts_with(sidebar_field, "layer"))
|
||||||
|
render_sidebar_layers_hints(sidebar_field);
|
||||||
|
|
||||||
glsafe(::glPopMatrix());
|
glsafe(::glPopMatrix());
|
||||||
|
|
||||||
|
if (!boost::starts_with(sidebar_field, "layer"))
|
||||||
|
{
|
||||||
glsafe(::glDisable(GL_LIGHTING));
|
glsafe(::glDisable(GL_LIGHTING));
|
||||||
|
shader.stop_using();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Selection::requires_local_axes() const
|
bool Selection::requires_local_axes() const
|
||||||
|
@ -1709,6 +1722,75 @@ void Selection::render_sidebar_size_hints(const std::string& sidebar_field) cons
|
||||||
render_sidebar_scale_hints(sidebar_field);
|
render_sidebar_scale_hints(sidebar_field);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Selection::render_sidebar_layers_hints(const std::string& sidebar_field) const
|
||||||
|
{
|
||||||
|
static const double Margin = 10.0;
|
||||||
|
|
||||||
|
std::string field = sidebar_field;
|
||||||
|
|
||||||
|
// extract max_z
|
||||||
|
std::string::size_type pos = field.rfind("_");
|
||||||
|
if (pos == std::string::npos)
|
||||||
|
return;
|
||||||
|
|
||||||
|
double max_z = std::stod(field.substr(pos + 1));
|
||||||
|
|
||||||
|
// extract min_z
|
||||||
|
field = field.substr(0, pos);
|
||||||
|
pos = field.rfind("_");
|
||||||
|
if (pos == std::string::npos)
|
||||||
|
return;
|
||||||
|
|
||||||
|
double min_z = std::stod(field.substr(pos + 1));
|
||||||
|
|
||||||
|
// extract type
|
||||||
|
field = field.substr(0, pos);
|
||||||
|
pos = field.rfind("_");
|
||||||
|
if (pos == std::string::npos)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int type = std::stoi(field.substr(pos + 1));
|
||||||
|
|
||||||
|
const BoundingBoxf3& box = get_bounding_box();
|
||||||
|
|
||||||
|
const float min_x = box.min(0) - Margin;
|
||||||
|
const float max_x = box.max(0) + Margin;
|
||||||
|
const float min_y = box.min(1) - Margin;
|
||||||
|
const float max_y = box.max(1) + Margin;
|
||||||
|
|
||||||
|
glsafe(::glEnable(GL_DEPTH_TEST));
|
||||||
|
glsafe(::glDisable(GL_CULL_FACE));
|
||||||
|
glsafe(::glEnable(GL_BLEND));
|
||||||
|
glsafe(::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
|
||||||
|
|
||||||
|
// Draw the min_z plane
|
||||||
|
::glBegin(GL_QUADS);
|
||||||
|
if (type == 1)
|
||||||
|
::glColor4f(1.0f, 0.38f, 0.0f, 1.0f);
|
||||||
|
else
|
||||||
|
::glColor4f(0.8f, 0.8f, 0.8f, 0.5f);
|
||||||
|
::glVertex3f(min_x, min_y, min_z);
|
||||||
|
::glVertex3f(max_x, min_y, min_z);
|
||||||
|
::glVertex3f(max_x, max_y, min_z);
|
||||||
|
::glVertex3f(min_x, max_y, min_z);
|
||||||
|
glsafe(::glEnd());
|
||||||
|
|
||||||
|
// Draw the max_z plane
|
||||||
|
::glBegin(GL_QUADS);
|
||||||
|
if (type == 2)
|
||||||
|
::glColor4f(1.0f, 0.38f, 0.0f, 1.0f);
|
||||||
|
else
|
||||||
|
::glColor4f(0.8f, 0.8f, 0.8f, 0.5f);
|
||||||
|
::glVertex3f(min_x, min_y, max_z);
|
||||||
|
::glVertex3f(max_x, min_y, max_z);
|
||||||
|
::glVertex3f(max_x, max_y, max_z);
|
||||||
|
::glVertex3f(min_x, max_y, max_z);
|
||||||
|
glsafe(::glEnd());
|
||||||
|
|
||||||
|
glsafe(::glEnable(GL_CULL_FACE));
|
||||||
|
glsafe(::glDisable(GL_BLEND));
|
||||||
|
}
|
||||||
|
|
||||||
void Selection::render_sidebar_position_hint(Axis axis) const
|
void Selection::render_sidebar_position_hint(Axis axis) const
|
||||||
{
|
{
|
||||||
m_arrow.set_color(AXES_COLOR[axis], 3);
|
m_arrow.set_color(AXES_COLOR[axis], 3);
|
||||||
|
|
|
@ -11,8 +11,8 @@ typedef class GLUquadric GLUquadricObj;
|
||||||
#endif // ENABLE_RENDER_SELECTION_CENTER
|
#endif // ENABLE_RENDER_SELECTION_CENTER
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
class Shader;
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
class TransformationType
|
class TransformationType
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -302,7 +302,7 @@ public:
|
||||||
#if ENABLE_RENDER_SELECTION_CENTER
|
#if ENABLE_RENDER_SELECTION_CENTER
|
||||||
void render_center(bool gizmo_is_dragging) const;
|
void render_center(bool gizmo_is_dragging) const;
|
||||||
#endif // ENABLE_RENDER_SELECTION_CENTER
|
#endif // ENABLE_RENDER_SELECTION_CENTER
|
||||||
void render_sidebar_hints(const std::string& sidebar_field) const;
|
void render_sidebar_hints(const std::string& sidebar_field, const Shader& shader) const;
|
||||||
|
|
||||||
bool requires_local_axes() const;
|
bool requires_local_axes() const;
|
||||||
|
|
||||||
|
@ -332,6 +332,7 @@ private:
|
||||||
void render_sidebar_rotation_hints(const std::string& sidebar_field) const;
|
void render_sidebar_rotation_hints(const std::string& sidebar_field) const;
|
||||||
void render_sidebar_scale_hints(const std::string& sidebar_field) const;
|
void render_sidebar_scale_hints(const std::string& sidebar_field) const;
|
||||||
void render_sidebar_size_hints(const std::string& sidebar_field) const;
|
void render_sidebar_size_hints(const std::string& sidebar_field) const;
|
||||||
|
void render_sidebar_layers_hints(const std::string& sidebar_field) const;
|
||||||
void render_sidebar_position_hint(Axis axis) const;
|
void render_sidebar_position_hint(Axis axis) const;
|
||||||
void render_sidebar_rotation_hint(Axis axis) const;
|
void render_sidebar_rotation_hint(Axis axis) const;
|
||||||
void render_sidebar_scale_hint(Axis axis) const;
|
void render_sidebar_scale_hint(Axis axis) const;
|
||||||
|
|
Loading…
Add table
Reference in a new issue