Merge branch 'master' into lm_sla_supports_auto2

This commit is contained in:
Lukas Matena 2019-02-19 10:15:16 +01:00
commit 023b788777
44 changed files with 3347 additions and 2635 deletions

View file

@ -141,8 +141,8 @@ bool GeometryBuffer::set_from_triangles(const Polygons& triangles, float z, bool
float inv_size_y = -1.0f / size_y;
for (unsigned int i = 0; i < m_tex_coords.size(); i += 2)
{
m_tex_coords[i] *= inv_size_x;
m_tex_coords[i + 1] *= inv_size_y;
m_tex_coords[i] = (m_tex_coords[i] - min_x) * inv_size_x;
m_tex_coords[i + 1] = (m_tex_coords[i + 1] - min_y) * inv_size_y;
}
}
}
@ -595,11 +595,25 @@ void GLCanvas3D::Bed::_render_prusa(const std::string &key, float theta) const
#endif // ENABLE_PRINT_BED_MODELS
{
std::string tex_path = resources_dir() + "/icons/bed/" + key;
// use higher resolution images if graphic card allows
GLint max_tex_size;
::glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_tex_size);
// temporary set to lowest resolution
max_tex_size = 2048;
if (max_tex_size >= 8192)
tex_path += "_8192";
else if (max_tex_size >= 4096)
tex_path += "_4096";
#if ENABLE_PRINT_BED_MODELS
std::string model_path = resources_dir() + "/models/" + key;
#endif // ENABLE_PRINT_BED_MODELS
#if ENABLE_ANISOTROPIC_FILTER_ON_BED_TEXTURES
// use anisotropic filter if graphic card allows
GLfloat max_anisotropy = 0.0f;
if (glewIsSupported("GL_EXT_texture_filter_anisotropic"))
::glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &max_anisotropy);
@ -646,11 +660,17 @@ void GLCanvas3D::Bed::_render_prusa(const std::string &key, float theta) const
{
filename = model_path + "_bed.stl";
if ((m_model.get_filename() != filename) && m_model.init_from_file(filename, useVBOs)) {
Vec3d offset = m_bounding_box.center() - Vec3d(0.0, 0.0, 0.1 + 0.5 * m_model.get_bounding_box().size()(2));
Vec3d offset = m_bounding_box.center() - Vec3d(0.0, 0.0, 0.5 * m_model.get_bounding_box().size()(2));
if (key == "mk2")
offset.y() += 15. / 2.;
// hardcoded value to match the stl model
offset += Vec3d(0.0, 7.5, -0.03);
else if (key == "mk3")
offset += Vec3d(0., (19. - 8.) / 2., 2.);
// hardcoded value to match the stl model
offset += Vec3d(0.0, 5.5, 2.43);
else if (key == "sl1")
// hardcoded value to match the stl model
offset += Vec3d(0.0, 0.0, -0.03);
m_model.center_around(offset);
}
@ -5343,14 +5363,21 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
// Set focus in order to remove it from sidebar fields
if (m_canvas != nullptr) {
// Only set focus, if the top level window of this canvas is active.
auto p = dynamic_cast<wxWindow*>(evt.GetEventObject());
auto p = dynamic_cast<wxWindow*>(evt.GetEventObject());
while (p->GetParent())
p = p->GetParent();
auto *top_level_wnd = dynamic_cast<wxTopLevelWindow*>(p);
if (top_level_wnd && top_level_wnd->IsActive())
{
m_canvas->SetFocus();
}
// forces a frame render to ensure that m_hover_volume_id is updated even when the user right clicks while
// the context menu is shown, ensuring it to disappear if the mouse is outside any volume and to
// change the volume hover state if any is under the mouse
m_mouse.position = pos.cast<double>();
render();
}
}
m_mouse.set_start_position_2D_as_invalid();
//#endif
}
@ -5479,7 +5506,6 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
}
// propagate event through callback
if (m_hover_volume_id != -1)
{
if (evt.LeftDown() && m_moving_enabled && (m_mouse.drag.move_volume_idx == -1))
@ -5498,9 +5524,9 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
}
else if (evt.RightDown())
{
m_mouse.position = pos.cast<double>();
// forces a frame render to ensure that m_hover_volume_id is updated even when the user right clicks while
// the context menu is already shown, ensuring it to disappear if the mouse is outside any volume
m_mouse.position = Vec2d((double)pos(0), (double)pos(1));
// the context menu is already shown
render();
if (m_hover_volume_id != -1)
{
@ -5514,14 +5540,14 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
post_event(SimpleEvent(EVT_GLCANVAS_OBJECT_SELECT));
_update_gizmos_data();
wxGetApp().obj_manipul()->update_settings_value(m_selection);
// forces a frame render to update the view before the context menu is shown
render();
// // forces a frame render to update the view before the context menu is shown
// render();
Vec2d logical_pos = pos.cast<double>();
#if ENABLE_RETINA_GL
const float factor = m_retina_helper->get_scale_factor();
logical_pos = logical_pos.cwiseQuotient(Vec2d(factor, factor));
#endif
#endif // ENABLE_RETINA_GL
post_event(Vec2dEvent(EVT_GLCANVAS_RIGHT_CLICK, logical_pos));
}
}
@ -5817,7 +5843,7 @@ void GLCanvas3D::set_tooltip(const std::string& tooltip) const
else
t->SetTip(tooltip);
}
else
else if (!tooltip.empty()) // Avoid "empty" tooltips => unset of the empty tooltip leads to application crash under OSX
m_canvas->SetToolTip(tooltip);
}
}
@ -6150,7 +6176,6 @@ bool GLCanvas3D::_init_toolbar()
item.name = "add";
item.tooltip = GUI::L_str("Add...") + " [" + GUI::shortkey_ctrl_prefix() + "I]";
item.sprite_id = 0;
item.is_toggable = false;
item.action_event = EVT_GLTOOLBAR_ADD;
if (!m_toolbar.add_item(item))
return false;
@ -6158,7 +6183,6 @@ bool GLCanvas3D::_init_toolbar()
item.name = "delete";
item.tooltip = GUI::L_str("Delete") + " [Del]";
item.sprite_id = 1;
item.is_toggable = false;
item.action_event = EVT_GLTOOLBAR_DELETE;
if (!m_toolbar.add_item(item))
return false;
@ -6166,7 +6190,6 @@ bool GLCanvas3D::_init_toolbar()
item.name = "deleteall";
item.tooltip = GUI::L_str("Delete all") + " [" + GUI::shortkey_ctrl_prefix() + "Del]";
item.sprite_id = 2;
item.is_toggable = false;
item.action_event = EVT_GLTOOLBAR_DELETE_ALL;
if (!m_toolbar.add_item(item))
return false;
@ -6174,7 +6197,6 @@ bool GLCanvas3D::_init_toolbar()
item.name = "arrange";
item.tooltip = GUI::L_str("Arrange [A]");
item.sprite_id = 3;
item.is_toggable = false;
item.action_event = EVT_GLTOOLBAR_ARRANGE;
if (!m_toolbar.add_item(item))
return false;
@ -6185,7 +6207,6 @@ bool GLCanvas3D::_init_toolbar()
item.name = "more";
item.tooltip = GUI::L_str("Add instance [+]");
item.sprite_id = 4;
item.is_toggable = false;
item.action_event = EVT_GLTOOLBAR_MORE;
if (!m_toolbar.add_item(item))
return false;
@ -6193,7 +6214,6 @@ bool GLCanvas3D::_init_toolbar()
item.name = "fewer";
item.tooltip = GUI::L_str("Remove instance [-]");
item.sprite_id = 5;
item.is_toggable = false;
item.action_event = EVT_GLTOOLBAR_FEWER;
if (!m_toolbar.add_item(item))
return false;
@ -6204,7 +6224,6 @@ bool GLCanvas3D::_init_toolbar()
item.name = "splitobjects";
item.tooltip = GUI::L_str("Split to objects");
item.sprite_id = 6;
item.is_toggable = false;
item.action_event = EVT_GLTOOLBAR_SPLIT_OBJECTS;
if (!m_toolbar.add_item(item))
return false;
@ -6212,7 +6231,6 @@ bool GLCanvas3D::_init_toolbar()
item.name = "splitvolumes";
item.tooltip = GUI::L_str("Split to parts");
item.sprite_id = 8;
item.is_toggable = false;
item.action_event = EVT_GLTOOLBAR_SPLIT_VOLUMES;
if (!m_toolbar.add_item(item))
return false;