Merge remote-tracking branch 'origin/master' into ys_hdpi

This commit is contained in:
YuSanka 2019-02-05 11:04:28 +01:00
commit 1b5c118fd0
11 changed files with 317 additions and 121 deletions

View file

@ -366,7 +366,11 @@ const Pointfs& GLCanvas3D::Bed::get_shape() const
bool GLCanvas3D::Bed::set_shape(const Pointfs& shape)
{
#if ENABLE_REWORKED_BED_SHAPE_CHANGE
EType new_type = _detect_type(shape);
#else
EType new_type = _detect_type();
#endif // ENABLE_REWORKED_BED_SHAPE_CHANGE
if (m_shape == shape && m_type == new_type)
// No change, no need to update the UI.
return false;
@ -516,7 +520,11 @@ void GLCanvas3D::Bed::_calc_gridlines(const ExPolygon& poly, const BoundingBox&
printf("Unable to create bed grid lines\n");
}
#if ENABLE_REWORKED_BED_SHAPE_CHANGE
GLCanvas3D::Bed::EType GLCanvas3D::Bed::_detect_type(const Pointfs& shape) const
#else
GLCanvas3D::Bed::EType GLCanvas3D::Bed::_detect_type() const
#endif // ENABLE_REWORKED_BED_SHAPE_CHANGE
{
EType type = Custom;
@ -528,7 +536,27 @@ GLCanvas3D::Bed::EType GLCanvas3D::Bed::_detect_type() const
{
if (curr->config.has("bed_shape"))
{
if (boost::contains(curr->name, "SL1"))
#if ENABLE_REWORKED_BED_SHAPE_CHANGE
if ((curr->vendor != nullptr) && (curr->vendor->name == "Prusa Research") && (shape == dynamic_cast<const ConfigOptionPoints*>(curr->config.option("bed_shape"))->values))
{
if (boost::contains(curr->name, "SL1"))
{
type = SL1;
break;
}
else if (boost::contains(curr->name, "MK3") || boost::contains(curr->name, "MK2.5"))
{
type = MK3;
break;
}
else if (boost::contains(curr->name, "MK2"))
{
type = MK2;
break;
}
}
#else
if (boost::contains(curr->name, "SL1"))
{
//FIXME add a condition on the size of the print bed?
type = SL1;
@ -549,7 +577,8 @@ GLCanvas3D::Bed::EType GLCanvas3D::Bed::_detect_type() const
}
}
}
}
#endif // ENABLE_REWORKED_BED_SHAPE_CHANGE
}
curr = bundle->printers.get_preset_parent(*curr);
}
@ -707,6 +736,7 @@ void GLCanvas3D::Bed::_render_custom() const
}
}
#if !ENABLE_REWORKED_BED_SHAPE_CHANGE
bool GLCanvas3D::Bed::_are_equal(const Pointfs& bed_1, const Pointfs& bed_2)
{
if (bed_1.size() != bed_2.size())
@ -720,6 +750,7 @@ bool GLCanvas3D::Bed::_are_equal(const Pointfs& bed_1, const Pointfs& bed_2)
return true;
}
#endif // !ENABLE_REWORKED_BED_SHAPE_CHANGE
const double GLCanvas3D::Axes::Radius = 0.5;
const double GLCanvas3D::Axes::ArrowBaseRadius = 2.5 * GLCanvas3D::Axes::Radius;
@ -1071,12 +1102,11 @@ void GLCanvas3D::LayersEditing::_render_tooltip_texture(const GLCanvas3D& canvas
#if ENABLE_RETINA_GL
const float scale = canvas.get_canvas_size().get_scale_factor();
#else
const float scale = canvas.get_wxglcanvas()->GetContentScaleFactor();
#endif
const float width = (float)m_tooltip_texture.get_width() * scale;
const float height = (float)m_tooltip_texture.get_height() * scale;
#else
const float width = (float)m_tooltip_texture.get_width();
const float height = (float)m_tooltip_texture.get_height();
#endif
float zoom = canvas.get_camera_zoom();
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
@ -1298,20 +1328,24 @@ void GLCanvas3D::LayersEditing::update_slicing_parameters()
float GLCanvas3D::LayersEditing::thickness_bar_width(const GLCanvas3D &canvas)
{
return
#if ENABLE_RETINA_GL
return canvas.get_canvas_size().get_scale_factor() * THICKNESS_BAR_WIDTH;
canvas.get_canvas_size().get_scale_factor()
#else
return THICKNESS_BAR_WIDTH;
canvas.get_wxglcanvas()->GetContentScaleFactor()
#endif
* THICKNESS_BAR_WIDTH;
}
float GLCanvas3D::LayersEditing::reset_button_height(const GLCanvas3D &canvas)
{
return
#if ENABLE_RETINA_GL
return canvas.get_canvas_size().get_scale_factor() * THICKNESS_RESET_BUTTON_HEIGHT;
canvas.get_canvas_size().get_scale_factor()
#else
return THICKNESS_RESET_BUTTON_HEIGHT;
canvas.get_wxglcanvas()->GetContentScaleFactor()
#endif
* THICKNESS_RESET_BUTTON_HEIGHT;
}
@ -4175,6 +4209,9 @@ unsigned int GLCanvas3D::get_volumes_count() const
void GLCanvas3D::reset_volumes()
{
if (!m_initialized)
return;
_set_current();
if (!m_volumes.empty())
@ -4217,18 +4254,27 @@ void GLCanvas3D::set_bed_shape(const Pointfs& shape)
{
bool new_shape = m_bed.set_shape(shape);
#if ENABLE_REWORKED_BED_SHAPE_CHANGE
if (new_shape)
{
// Set the origin and size for painting of the coordinate system axes.
m_axes.origin = Vec3d(0.0, 0.0, (double)GROUND_Z);
set_bed_axes_length(0.1 * m_bed.get_bounding_box().max_size());
m_camera.set_scene_box(scene_bounding_box(), *this);
m_requires_zoom_to_bed = true;
m_dirty = true;
}
#else
// Set the origin and size for painting of the coordinate system axes.
m_axes.origin = Vec3d(0.0, 0.0, (double)GROUND_Z);
set_bed_axes_length(0.1 * m_bed.get_bounding_box().max_size());
if (new_shape)
#if ENABLE_REWORKED_BED_SHAPE_CHANGE
m_requires_zoom_to_bed = true;
#else
zoom_to_bed();
#endif // ENABLE_REWORKED_BED_SHAPE_CHANGE
m_dirty = true;
#endif // ENABLE_REWORKED_BED_SHAPE_CHANGE
}
void GLCanvas3D::set_bed_axes_length(double length)
@ -4474,6 +4520,13 @@ void GLCanvas3D::render()
return;
#if ENABLE_REWORKED_BED_SHAPE_CHANGE
if (m_bed.get_shape().empty())
{
// this happens at startup when no data is still saved under <>\AppData\Roaming\Slic3rPE
if (m_config != nullptr)
set_bed_shape(m_config->opt<ConfigOptionPoints>("bed_shape")->values);
}
if (m_requires_zoom_to_bed)
{
zoom_to_bed();
@ -4649,7 +4702,8 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
if ((m_canvas == nullptr) || (m_config == nullptr) || (m_model == nullptr))
return;
_set_current();
if (m_initialized)
_set_current();
struct ModelVolumeState {
ModelVolumeState(const GLVolume *volume) :
@ -4779,7 +4833,9 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
if (m_reload_delayed)
return;
#if !ENABLE_REWORKED_BED_SHAPE_CHANGE
set_bed_shape(dynamic_cast<const ConfigOptionPoints*>(m_config->option("bed_shape"))->values);
#endif // !ENABLE_REWORKED_BED_SHAPE_CHANGE
if (m_regenerate_volumes)
{
@ -5107,15 +5163,16 @@ void GLCanvas3D::on_char(wxKeyEvent& evt)
//#endif /* __APPLE__ */
if ((evt.GetModifiers() & ctrlMask) != 0) {
switch (keyCode) {
#ifndef __APPLE__
// Even though Control+A is captured by the accelerator on OSX/wxWidgets in Slic3r, it works in text edit lines.
case 'a':
case 'A':
case WXK_CONTROL_A: post_event(SimpleEvent(EVT_GLCANVAS_SELECT_ALL)); break;
#endif /* __APPLE__ */
#ifdef __APPLE__
case WXK_BACK: // the low cost Apple solutions are not equipped with a Delete key, use Backspace instead.
#else /* __APPLE__ */
case WXK_DELETE:
#endif /* __APPLE__ */
case WXK_DELETE: post_event(SimpleEvent(EVT_GLTOOLBAR_DELETE_ALL)); break;
default: evt.Skip();
post_event(SimpleEvent(EVT_GLTOOLBAR_DELETE_ALL)); break;
default: evt.Skip();
}
} else if (evt.HasModifiers()) {
evt.Skip();
@ -5126,9 +5183,11 @@ void GLCanvas3D::on_char(wxKeyEvent& evt)
case WXK_ESCAPE: { m_gizmos.reset_all_states(); m_dirty = true; break; }
#ifdef __APPLE__
case WXK_BACK: // the low cost Apple solutions are not equipped with a Delete key, use Backspace instead.
#else /* __APPLE__ */
case WXK_DELETE:
#endif /* __APPLE__ */
case WXK_DELETE: post_event(SimpleEvent(EVT_GLTOOLBAR_DELETE)); break;
case '0': { select_view("iso"); break; }
post_event(SimpleEvent(EVT_GLTOOLBAR_DELETE)); break;
case '0': { select_view("iso"); break; }
case '1': { select_view("top"); break; }
case '2': { select_view("bottom"); break; }
case '3': { select_view("front"); break; }
@ -5704,8 +5763,11 @@ Point GLCanvas3D::get_local_mouse_position() const
void GLCanvas3D::reset_legend_texture()
{
_set_current();
m_legend_texture.reset();
if (m_legend_texture.get_id() != 0)
{
_set_current();
m_legend_texture.reset();
}
}
void GLCanvas3D::set_tooltip(const std::string& tooltip) const
@ -6157,7 +6219,9 @@ void GLCanvas3D::_resize(unsigned int w, unsigned int h)
wxGetApp().imgui()->set_display_size((float)w, (float)h);
#if ENABLE_RETINA_GL
wxGetApp().imgui()->set_style_scaling(m_retina_helper->get_scale_factor());
#endif // ENABLE_RETINA_GL
#else
wxGetApp().imgui()->set_style_scaling(m_canvas->GetContentScaleFactor());
#endif
#endif // ENABLE_IMGUI
// ensures that this canvas is current
@ -6616,7 +6680,10 @@ void GLCanvas3D::_render_gizmos_overlay() const
{
#if ENABLE_RETINA_GL
m_gizmos.set_overlay_scale(m_retina_helper->get_scale_factor());
#endif
#else
m_gizmos.set_overlay_scale(m_canvas->GetContentScaleFactor());
#endif /* __WXMSW__ */
m_gizmos.render_overlay(*this, m_selection);
}
@ -6624,7 +6691,10 @@ void GLCanvas3D::_render_toolbar() const
{
#if ENABLE_RETINA_GL
m_toolbar.set_icons_scale(m_retina_helper->get_scale_factor());
#endif
#else
m_toolbar.set_icons_scale(m_canvas->GetContentScaleFactor());
#endif /* __WXMSW__ */
m_toolbar.render(*this);
}
@ -6633,7 +6703,9 @@ void GLCanvas3D::_render_view_toolbar() const
if (m_view_toolbar != nullptr) {
#if ENABLE_RETINA_GL
m_view_toolbar->set_icons_scale(m_retina_helper->get_scale_factor());
#endif
#else
m_view_toolbar->set_icons_scale(m_canvas->GetContentScaleFactor());
#endif /* __WXMSW__ */
m_view_toolbar->render(*this);
}
}
@ -8381,7 +8453,9 @@ void GLCanvas3D::_resize_toolbars() const
#if ENABLE_RETINA_GL
m_toolbar.set_icons_scale(m_retina_helper->get_scale_factor());
#endif
#else
m_toolbar.set_icons_scale(m_canvas->GetContentScaleFactor());
#endif /* __WXMSW__ */
GLToolbar::Layout::EOrientation orientation = m_toolbar.get_layout_orientation();
@ -8428,7 +8502,9 @@ void GLCanvas3D::_resize_toolbars() const
{
#if ENABLE_RETINA_GL
m_view_toolbar->set_icons_scale(m_retina_helper->get_scale_factor());
#endif
#else
m_view_toolbar->set_icons_scale(m_canvas->GetContentScaleFactor());
#endif /* __WXMSW__ */
// places the toolbar on the bottom-left corner of the 3d scene
float top = (-0.5f * (float)cnv_size.get_height() + m_view_toolbar->get_height()) * inv_zoom;

View file

@ -226,6 +226,10 @@ class GLCanvas3D
public:
Bed();
#if ENABLE_REWORKED_BED_SHAPE_CHANGE
EType get_type() const { return m_type; }
#endif // ENABLE_REWORKED_BED_SHAPE_CHANGE
bool is_prusa() const;
bool is_custom() const;
@ -247,14 +251,20 @@ class GLCanvas3D
void _calc_bounding_box();
void _calc_triangles(const ExPolygon& poly);
void _calc_gridlines(const ExPolygon& poly, const BoundingBox& bed_bbox);
#if ENABLE_REWORKED_BED_SHAPE_CHANGE
EType _detect_type(const Pointfs& shape) const;
#else
EType _detect_type() const;
#endif // ENABLE_REWORKED_BED_SHAPE_CHANGE
#if ENABLE_PRINT_BED_MODELS
void _render_prusa(const std::string &key, float theta, bool useVBOs) const;
#else
void _render_prusa(const std::string &key, float theta) const;
#endif // ENABLE_PRINT_BED_MODELS
void _render_custom() const;
#if !ENABLE_REWORKED_BED_SHAPE_CHANGE
static bool _are_equal(const Pointfs& bed_1, const Pointfs& bed_2);
#endif // !ENABLE_REWORKED_BED_SHAPE_CHANGE
};
struct Axes
@ -931,6 +941,7 @@ public:
void set_context(wxGLContext* context) { m_context = context; }
wxGLCanvas* get_wxglcanvas() { return m_canvas; }
const wxGLCanvas* get_wxglcanvas() const { return m_canvas; }
void set_view_toolbar(GLToolbar* toolbar) { m_view_toolbar = toolbar; }

View file

@ -324,29 +324,33 @@ void MainFrame::init_menubar()
Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable((m_plater != nullptr) && can_slice()); }, m_menu_item_reslice_now->GetId());
}
#ifdef _MSC_VER
// \xA0 is a non-breaking space. It is entered here to spoil the automatic accelerators,
// as the simple numeric accelerators spoil all numeric data entry.
wxString sep = "\t\xA0";
wxString sep_space = "\xA0";
#else
wxString sep = " - ";
wxString sep_space = "";
#endif
// Edit menu
wxMenu* editMenu = nullptr;
if (m_plater != nullptr)
{
editMenu = new wxMenu();
// \xA0 is a non-breaking space. It is entered here to spoil the automatic accelerators,
// as the simple numeric accelerators spoil all numeric data entry.
wxMenuItem* item_select_all = append_menu_item(editMenu, wxID_ANY, _(L("&Select all")) +
#ifdef _MSC_VER
"\t\xA0" + "Ctrl+\xA0" + "A"
#else
#ifdef __APPLE__
"\tCtrl+A"
#else
" - Ctrl+A"
#endif
#endif
, _(L("Selects all objects")),
#ifdef __APPLE__
// Backspace sign
wxString hotkey_delete = "\u232b";
#else
wxString hotkey_delete = "Del";
#endif
wxMenuItem* item_select_all = append_menu_item(editMenu, wxID_ANY, _(L("&Select all")) + sep + GUI::shortkey_ctrl_prefix() + sep_space + "A", _(L("Selects all objects")),
[this](wxCommandEvent&) { m_plater->select_all(); }, "");
editMenu->AppendSeparator();
wxMenuItem* item_delete_sel = append_menu_item(editMenu, wxID_ANY, _(L("&Delete selected")) + "\tDel", _(L("Deletes the current selection")),
wxMenuItem* item_delete_sel = append_menu_item(editMenu, wxID_ANY, _(L("&Delete selected")) + sep + hotkey_delete, _(L("Deletes the current selection")),
[this](wxCommandEvent&) { m_plater->remove_selected(); }, "");
wxMenuItem* item_delete_all = append_menu_item(editMenu, wxID_ANY, _(L("Delete &all")) + "\tCtrl+Del", _(L("Deletes all objects")),
wxMenuItem* item_delete_all = append_menu_item(editMenu, wxID_ANY, _(L("Delete &all")) + sep + GUI::shortkey_ctrl_prefix() + sep_space + hotkey_delete, _(L("Deletes all objects")),
[this](wxCommandEvent&) { m_plater->reset(); }, "");
Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_select()); }, item_select_all->GetId());
@ -403,12 +407,6 @@ void MainFrame::init_menubar()
// View menu
wxMenu* viewMenu = nullptr;
wxString sep =
#ifdef _MSC_VER
"\t";
#else
" - ";
#endif
if (m_plater) {
viewMenu = new wxMenu();
// The camera control accelerators are captured by GLCanvas3D::on_char().

View file

@ -3017,13 +3017,20 @@ void Plater::on_extruders_change(int num_extruders)
void Plater::on_config_change(const DynamicPrintConfig &config)
{
bool update_scheduled = false;
#if ENABLE_REWORKED_BED_SHAPE_CHANGE
bool bed_shape_changed = false;
#endif // ENABLE_REWORKED_BED_SHAPE_CHANGE
for (auto opt_key : p->config->diff(config)) {
p->config->set_key_value(opt_key, config.option(opt_key)->clone());
if (opt_key == "printer_technology")
this->set_printer_technology(config.opt_enum<PrinterTechnology>(opt_key));
else if (opt_key == "bed_shape") {
#if ENABLE_REWORKED_BED_SHAPE_CHANGE
bed_shape_changed = true;
#else
if (p->view3D) p->view3D->set_bed_shape(p->config->option<ConfigOptionPoints>(opt_key)->values);
if (p->preview) p->preview->set_bed_shape(p->config->option<ConfigOptionPoints>(opt_key)->values);
#endif // ENABLE_REWORKED_BED_SHAPE_CHANGE
update_scheduled = true;
}
else if (boost::starts_with(opt_key, "wipe_tower") ||
@ -3049,8 +3056,12 @@ void Plater::on_config_change(const DynamicPrintConfig &config)
}
else if (opt_key == "printer_model") {
// update to force bed selection(for texturing)
#if ENABLE_REWORKED_BED_SHAPE_CHANGE
bed_shape_changed = true;
#else
if (p->view3D) p->view3D->set_bed_shape(p->config->option<ConfigOptionPoints>("bed_shape")->values);
if (p->preview) p->preview->set_bed_shape(p->config->option<ConfigOptionPoints>("bed_shape")->values);
#endif // ENABLE_REWORKED_BED_SHAPE_CHANGE
update_scheduled = true;
}
else if (opt_key == "host_type" && this->p->printer_technology == ptSLA) {
@ -3063,6 +3074,14 @@ void Plater::on_config_change(const DynamicPrintConfig &config)
p->sidebar->show_send(prin_host_opt != nullptr && !prin_host_opt->value.empty());
}
#if ENABLE_REWORKED_BED_SHAPE_CHANGE
if (bed_shape_changed)
{
if (p->view3D) p->view3D->set_bed_shape(p->config->option<ConfigOptionPoints>("bed_shape")->values);
if (p->preview) p->preview->set_bed_shape(p->config->option<ConfigOptionPoints>("bed_shape")->values);
}
#endif // ENABLE_REWORKED_BED_SHAPE_CHANGE
if (update_scheduled)
update();

View file

@ -499,8 +499,6 @@ void TabSLAMaterial::init_options_list()
void Tab::get_sys_and_mod_flags(const std::string& opt_key, bool& sys_page, bool& modified_page)
{
if (m_options_list.empty())
return;
auto opt = m_options_list.find(opt_key);
if (sys_page) sys_page = (opt->second & osSystemValue) != 0;
modified_page |= (opt->second & osInitValue) == 0;
@ -508,6 +506,8 @@ void Tab::get_sys_and_mod_flags(const std::string& opt_key, bool& sys_page, bool
void Tab::update_changed_tree_ui()
{
if (m_options_list.empty())
return;
auto cur_item = m_treectrl->GetFirstVisibleItem();
if (!cur_item || !m_treectrl->IsVisible(cur_item))
return;