diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index 9cd933160e..52b930a60d 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -540,13 +540,26 @@ void Choice::BUILD() { else{ for (auto el : m_opt.enum_labels.empty() ? m_opt.enum_values : m_opt.enum_labels) { const wxString& str = _(el);//m_opt_id == "support" ? _(el) : el; - //FIXME Vojtech: Why is the single column empty icon necessary? It is a workaround of some kind, but what for? - // Please document such workarounds by comments! - // temp->Append(str, create_scaled_bitmap("empty_icon.png")); - temp->Append(str, wxNullBitmap); + temp->Append(str); } set_selection(); } + +#ifndef __WXGTK__ + /* Workaround for a correct rendering of the control without Bitmap (under MSW and OSX): + * + * 1. We should create small Bitmap to fill Bitmaps RefData, + * ! in this case wxBitmap.IsOK() return true. + * 2. But then set width to 0 value for no using of bitmap left and right spacing + * 3. Set this empty bitmap to the at list one item and BitmapCombobox will be recreated correct + * + * Note: Set bitmap height to the Font size because of OSX rendering. + */ + wxBitmap empty_bmp(1, temp->GetFont().GetPixelSize().y + 2); + empty_bmp.SetWidth(0); + temp->SetItemBitmap(0, empty_bmp); +#endif + // temp->Bind(wxEVT_TEXT, ([this](wxCommandEvent e) { on_change_field(); }), temp->GetId()); temp->Bind(wxEVT_COMBOBOX, ([this](wxCommandEvent e) { on_change_field(); }), temp->GetId()); diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 9514eaaa83..313ae8facf 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -1183,6 +1183,7 @@ wxDEFINE_EVENT(EVT_GLCANVAS_UPDATE_GEOMETRY, Vec3dsEvent<2>); wxDEFINE_EVENT(EVT_GLCANVAS_MOUSE_DRAGGING_FINISHED, SimpleEvent); wxDEFINE_EVENT(EVT_GLCANVAS_UPDATE_BED_SHAPE, SimpleEvent); wxDEFINE_EVENT(EVT_GLCANVAS_TAB, SimpleEvent); +wxDEFINE_EVENT(EVT_GLCANVAS_RESETGIZMOS, SimpleEvent); GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar) : m_canvas(canvas) diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index 1dde132c83..0f6333f733 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -90,6 +90,7 @@ wxDECLARE_EVENT(EVT_GLCANVAS_UPDATE_GEOMETRY, Vec3dsEvent<2>); wxDECLARE_EVENT(EVT_GLCANVAS_MOUSE_DRAGGING_FINISHED, SimpleEvent); wxDECLARE_EVENT(EVT_GLCANVAS_UPDATE_BED_SHAPE, SimpleEvent); wxDECLARE_EVENT(EVT_GLCANVAS_TAB, SimpleEvent); +wxDECLARE_EVENT(EVT_GLCANVAS_RESETGIZMOS, SimpleEvent); class GLCanvas3D { @@ -558,6 +559,7 @@ public: void set_camera_zoom(float zoom); void update_gizmos_on_off_state(); + void reset_all_gizmos() { m_gizmos.reset_all_states(); } void handle_sidebar_focus_event(const std::string& opt_key, bool focus_on); diff --git a/src/slic3r/GUI/GUI_ObjectSettings.cpp b/src/slic3r/GUI/GUI_ObjectSettings.cpp index dbfdb8e6c5..4c0879ad3c 100644 --- a/src/slic3r/GUI/GUI_ObjectSettings.cpp +++ b/src/slic3r/GUI/GUI_ObjectSettings.cpp @@ -123,8 +123,8 @@ void ObjectSettings::update_settings_list() continue; auto optgroup = std::make_shared(m_og->ctrl_parent(), cat.first, config, false, extra_column); - optgroup->label_width = 15 * wxGetApp().em_unit();//150; - optgroup->sidetext_width = 7 * wxGetApp().em_unit();//70; + optgroup->label_width = 15 * wxGetApp().em_unit(); + optgroup->sidetext_width = 5.5 * wxGetApp().em_unit(); optgroup->m_on_change = [](const t_config_option_key& opt_id, const boost::any& value) { wxGetApp().obj_list()->part_settings_changed(); }; @@ -134,7 +134,7 @@ void ObjectSettings::update_settings_list() if (opt == "extruder") continue; Option option = optgroup->get_option(opt); - option.opt.width = 7 * wxGetApp().em_unit();//70; + option.opt.width = 12 * wxGetApp().em_unit(); optgroup->append_single_option_line(option); } optgroup->reload_config(); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp index ae3d3ee1e6..f22c5e4c93 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp @@ -22,7 +22,7 @@ GLGizmoSlaSupports::GLGizmoSlaSupports(GLCanvas3D& parent, const std::string& ic GLGizmoSlaSupports::GLGizmoSlaSupports(GLCanvas3D& parent, unsigned int sprite_id) : GLGizmoBase(parent, sprite_id) #endif // ENABLE_SVG_ICONS - , m_starting_center(Vec3d::Zero()), m_quadric(nullptr) + , m_quadric(nullptr) { m_quadric = ::gluNewQuadric(); if (m_quadric != nullptr) @@ -45,12 +45,11 @@ bool GLGizmoSlaSupports::on_init() void GLGizmoSlaSupports::set_sla_support_data(ModelObject* model_object, const Selection& selection) { - m_starting_center = Vec3d::Zero(); + if (selection.is_empty()) + return; + m_old_model_object = m_model_object; m_model_object = model_object; - if (selection.is_empty()) - m_old_instance_id = -1; - m_active_instance = selection.get_instance_idx(); if (model_object && selection.is_from_single_instance()) @@ -75,6 +74,14 @@ void GLGizmoSlaSupports::set_sla_support_data(ModelObject* model_object, const S void GLGizmoSlaSupports::on_render(const Selection& selection) const { + // If current m_model_object does not match selection, ask GLCanvas3D to turn us off + if (m_state == On + && (m_model_object != selection.get_model()->objects[selection.get_object_idx()] + || m_active_instance != selection.get_instance_idx())) { + m_parent.post_event(SimpleEvent(EVT_GLCANVAS_RESETGIZMOS)); + return; + } + glsafe(::glEnable(GL_BLEND)); glsafe(::glEnable(GL_DEPTH_TEST)); @@ -718,6 +725,7 @@ std::string GLGizmoSlaSupports::on_get_name() const void GLGizmoSlaSupports::on_set_state() { if (m_state == On && m_old_state != On) { // the gizmo was just turned on + if (is_mesh_update_necessary()) update_mesh(); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp index a0428cc414..95af05fd53 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp @@ -23,7 +23,6 @@ private: ModelObject* m_model_object = nullptr; ModelObject* m_old_model_object = nullptr; int m_active_instance = -1; - int m_old_instance_id = -1; std::pair unproject_on_mesh(const Vec2d& mouse_pos); const float RenderPointScale = 1.f; @@ -33,10 +32,6 @@ private: Eigen::MatrixXi m_F; // facets indices igl::AABB m_AABB; - struct SourceDataSummary { - Geometry::Transformation transformation; - }; - class CacheEntry { public: CacheEntry(const sla::SupportPoint& point, bool sel, const Vec3f& norm = Vec3f::Zero()) : @@ -47,11 +42,6 @@ private: Vec3f normal; }; - // This holds information to decide whether recalculation is necessary: - SourceDataSummary m_source_data; - - mutable Vec3d m_starting_center; - public: #if ENABLE_SVG_ICONS GLGizmoSlaSupports(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 0505d92761..7b31c80c0d 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -1191,6 +1191,7 @@ struct Plater::priv void select_view(const std::string& direction); void select_view_3D(const std::string& name); void select_next_view_3D(); + void reset_all_gizmos(); void update_ui_from_settings(); ProgressStatusBar* statusbar(); std::string get_config(const std::string &key) const; @@ -1396,6 +1397,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) view3D_canvas->Bind(EVT_GLCANVAS_UPDATE_GEOMETRY, &priv::on_update_geometry, this); view3D_canvas->Bind(EVT_GLCANVAS_MOUSE_DRAGGING_FINISHED, &priv::on_3dcanvas_mouse_dragging_finished, this); view3D_canvas->Bind(EVT_GLCANVAS_TAB, [this](SimpleEvent&) { select_next_view_3D(); }); + view3D_canvas->Bind(EVT_GLCANVAS_RESETGIZMOS, [this](SimpleEvent&) { reset_all_gizmos(); }); // 3DScene/Toolbar: view3D_canvas->Bind(EVT_GLTOOLBAR_ADD, &priv::on_action_add, this); view3D_canvas->Bind(EVT_GLTOOLBAR_DELETE, [q](SimpleEvent&) { q->remove_selected(); }); @@ -1478,6 +1480,11 @@ void Plater::priv::select_next_view_3D() set_current_panel(view3D); } +void Plater::priv::reset_all_gizmos() +{ + view3D->get_canvas3d()->reset_all_gizmos(); +} + // Called after the Preferences dialog is closed and the program settings are saved. // Update the UI based on the current preferences. void Plater::priv::update_ui_from_settings() diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp index 5ce65b6691..8ffff1a417 100644 --- a/src/slic3r/GUI/Preferences.cpp +++ b/src/slic3r/GUI/Preferences.cpp @@ -35,7 +35,7 @@ void PreferencesDialog::build() def.type = coBool; def.tooltip = L("If this is enabled, Slic3r will prompt the last output directory " "instead of the one containing the input files."); - def.default_value = new ConfigOptionBool{ app_config->has("remember_output_path") ? app_config->get("remember_output_path")[0] == '1' : true }; // 1; + def.default_value = new ConfigOptionBool{ app_config->has("remember_output_path") ? app_config->get("remember_output_path") == "1" : true }; Option option(def, "remember_output_path"); m_optgroup->append_single_option_line(option); @@ -43,7 +43,7 @@ void PreferencesDialog::build() def.type = coBool; def.tooltip = L("If this is enabled, Slic3r will auto-center objects " "around the print bed center."); - def.default_value = new ConfigOptionBool{ app_config->get("autocenter")[0] == '1' }; // 1; + def.default_value = new ConfigOptionBool{ app_config->get("autocenter") == "1" }; option = Option (def,"autocenter"); m_optgroup->append_single_option_line(option); @@ -51,7 +51,7 @@ void PreferencesDialog::build() def.type = coBool; def.tooltip = L("If this is enabled, Slic3r will pre-process objects as soon " "as they\'re loaded in order to save time when exporting G-code."); - def.default_value = new ConfigOptionBool{ app_config->get("background_processing")[0] == '1' }; // 1; + def.default_value = new ConfigOptionBool{ app_config->get("background_processing") == "1" }; option = Option (def,"background_processing"); m_optgroup->append_single_option_line(option); @@ -75,7 +75,7 @@ void PreferencesDialog::build() def.type = coBool; def.tooltip = L("Suppress \" - default - \" presets in the Print / Filament / Printer " "selections once there are any other valid presets available."); - def.default_value = new ConfigOptionBool{ app_config->get("no_defaults")[0] == '1' }; // 1; + def.default_value = new ConfigOptionBool{ app_config->get("no_defaults") == "1" }; option = Option (def,"no_defaults"); m_optgroup->append_single_option_line(option); @@ -83,7 +83,7 @@ void PreferencesDialog::build() def.type = coBool; def.tooltip = L("When checked, the print and filament presets are shown in the preset editor " "even if they are marked as incompatible with the active printer"); - def.default_value = new ConfigOptionBool{ app_config->get("show_incompatible_presets")[0] == '1' }; // 1; + def.default_value = new ConfigOptionBool{ app_config->get("show_incompatible_presets") == "1" }; option = Option (def,"show_incompatible_presets"); m_optgroup->append_single_option_line(option); @@ -93,7 +93,7 @@ void PreferencesDialog::build() def.tooltip = L("If you have rendering issues caused by a buggy OpenGL 2.0 driver, " "you may try to check this checkbox. This will disable the layer height " "editing and anti aliasing, so it is likely better to upgrade your graphics driver."); - def.default_value = new ConfigOptionBool{ app_config->get("use_legacy_opengl")[0] == '1' }; // 1; + def.default_value = new ConfigOptionBool{ app_config->get("use_legacy_opengl") == "1" }; option = Option (def,"use_legacy_opengl"); m_optgroup->append_single_option_line(option);