Merge branch 'master' into tm_sla_printer_mirror

This commit is contained in:
tamasmeszaros 2019-06-05 15:10:02 +02:00
commit 97cbb5344e
109 changed files with 25034 additions and 8806 deletions

View file

@ -67,6 +67,12 @@ void AppConfig::set_defaults()
if (get("remember_output_path").empty())
set("remember_output_path", "1");
if (get("use_custom_toolbar_size").empty())
set("use_custom_toolbar_size", "0");
if (get("custom_toolbar_size").empty())
set("custom_toolbar_size", "100");
// Remove legacy window positions/sizes
erase("", "main_frame_maximized");
erase("", "main_frame_pos");

View file

@ -52,7 +52,7 @@ struct LifetimeGuard
};
BonjourDialog::BonjourDialog(wxWindow *parent, Slic3r::PrinterTechnology tech)
: wxDialog(parent, wxID_ANY, _(L("Network lookup")), wxDefaultPosition, wxDefaultSize, wxRESIZE_BORDER)
: wxDialog(parent, wxID_ANY, _(L("Network lookup")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
, list(new wxListView(this, wxID_ANY))
, replies(new ReplySet)
, label(new wxStaticText(this, wxID_ANY, ""))

View file

@ -434,7 +434,6 @@ void CheckBox::msw_rescale()
field->SetMinSize(wxSize(-1, int(1.5f*field->GetFont().GetPixelSize().y +0.5f)));
}
int undef_spin_val = -9999; //! Probably, It's not necessary
void SpinCtrl::BUILD() {
auto size = wxSize(wxDefaultSize);
@ -472,12 +471,14 @@ void SpinCtrl::BUILD() {
temp->SetFont(Slic3r::GUI::wxGetApp().normal_font());
temp->SetBackgroundStyle(wxBG_STYLE_PAINT);
#ifndef __WXOSX__
// #ys_FIXME_KILL_FOCUS
// wxEVT_KILL_FOCUS doesn't handled on OSX now (wxWidgets 3.1.1)
// So, we will update values on KILL_FOCUS & SPINCTRL events under MSW and GTK
// and on TEXT event under OSX
// XXX: On OS X the wxSpinCtrl widget is made up of two subwidgets, unfortunatelly
// the kill focus event is not propagated to the encompassing widget,
// so we need to bind it on the inner text widget instead. (Ugh.)
#ifdef __WXOSX__
temp->GetText()->Bind(wxEVT_KILL_FOCUS, ([this](wxEvent& e)
#else
temp->Bind(wxEVT_KILL_FOCUS, ([this](wxEvent& e)
#endif
{
e.Skip();
if (bEnterPressed) {
@ -486,7 +487,7 @@ void SpinCtrl::BUILD() {
}
propagate_value();
}), temp->GetId());
}));
temp->Bind(wxEVT_SPINCTRL, ([this](wxCommandEvent e) { propagate_value(); }), temp->GetId());
@ -496,7 +497,6 @@ void SpinCtrl::BUILD() {
propagate_value();
bEnterPressed = true;
}), temp->GetId());
#endif
temp->Bind(wxEVT_TEXT, ([this](wxCommandEvent e)
{
@ -504,24 +504,17 @@ void SpinCtrl::BUILD() {
// # when it was changed from the text control, so the on_change callback
// # gets the old one, and on_kill_focus resets the control to the old value.
// # As a workaround, we get the new value from $event->GetString and store
// # here temporarily so that we can return it from $self->get_value
std::string value = e.GetString().utf8_str().data();
if (is_matched(value, "^\\-?\\d+$")) {
try {
tmp_value = std::stoi(value);
}
catch (const std::exception & /* e */) {
tmp_value = -9999;
}
}
else tmp_value = -9999;
#ifdef __WXOSX__
propagate_value();
// # here temporarily so that we can return it from get_value()
long value;
const bool parsed = e.GetString().ToLong(&value);
tmp_value = parsed && value >= INT_MIN && value <= INT_MAX ? (int)value : UNDEF_VALUE;
#ifdef __WXOSX__
// Forcibly set the input value for SpinControl, since the value
// inserted from the clipboard is not updated under OSX
if (tmp_value > -9999) {
wxSpinCtrl* spin = dynamic_cast<wxSpinCtrl*>(window);
// inserted from the keyboard or clipboard is not updated under OSX
if (tmp_value != UNDEF_VALUE) {
wxSpinCtrl* spin = static_cast<wxSpinCtrl*>(window);
spin->SetValue(tmp_value);
// But in SetValue() is executed m_text_ctrl->SelectAll(), so
@ -539,10 +532,11 @@ void SpinCtrl::BUILD() {
void SpinCtrl::propagate_value()
{
if (tmp_value == -9999)
if (tmp_value == UNDEF_VALUE) {
on_kill_focus();
else if (boost::any_cast<int>(m_value) != tmp_value)
} else {
on_change_field();
}
}
void SpinCtrl::msw_rescale()
@ -583,12 +577,15 @@ void Choice::BUILD() {
// recast as a wxWindow to fit the calling convention
window = dynamic_cast<wxWindow*>(temp);
if (m_opt.enum_labels.empty() && m_opt.enum_values.empty()) {
}
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;
temp->Append(str);
if (! m_opt.enum_labels.empty() || ! m_opt.enum_values.empty()) {
if (m_opt.enum_labels.empty()) {
// Append non-localized enum_values
for (auto el : m_opt.enum_values)
temp->Append(el);
} else {
// Append localized enum_labels
for (auto el : m_opt.enum_labels)
temp->Append(_(el));
}
set_selection();
}
@ -856,7 +853,7 @@ boost::any& Choice::get_value()
else if (m_opt.gui_type == "f_enum_open") {
const int ret_enum = field->GetSelection();
if (ret_enum < 0 || m_opt.enum_values.empty() || m_opt.type == coStrings ||
ret_str != m_opt.enum_values[ret_enum] && ret_str != m_opt.enum_labels[ret_enum] )
(ret_str != m_opt.enum_values[ret_enum] && ret_str != _(m_opt.enum_labels[ret_enum])))
// modifies ret_string!
get_value_by_opt_type(ret_str);
else
@ -892,15 +889,16 @@ void Choice::msw_rescale()
// Set rescaled size
field->SetSize(size);
size_t idx, counter = idx = 0;
if (m_opt.enum_labels.empty() && m_opt.enum_values.empty()) {}
else{
for (auto el : m_opt.enum_labels.empty() ? m_opt.enum_values : m_opt.enum_labels) {
const wxString& str = _(el);
field->Append(str);
if (el.compare(selection) == 0)
size_t idx = 0;
if (! m_opt.enum_labels.empty() || ! m_opt.enum_values.empty()) {
size_t counter = 0;
bool labels = ! m_opt.enum_labels.empty();
for (const std::string &el : labels ? m_opt.enum_labels : m_opt.enum_values) {
wxString text = labels ? _(el) : wxString::FromUTF8(el.c_str());
field->Append(text);
if (text == selection)
idx = counter;
++counter;
++ counter;
}
}

View file

@ -7,6 +7,7 @@
#endif
#include <memory>
#include <cstdint>
#include <functional>
#include <boost/any.hpp>
@ -331,9 +332,11 @@ public:
class SpinCtrl : public Field {
using Field::Field;
private:
static const int UNDEF_VALUE = INT_MIN;
public:
SpinCtrl(const ConfigOptionDef& opt, const t_config_option_key& id) : Field(opt, id), tmp_value(-9999) {}
SpinCtrl(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : Field(parent, opt, id), tmp_value(-9999) {}
SpinCtrl(const ConfigOptionDef& opt, const t_config_option_key& id) : Field(opt, id), tmp_value(UNDEF_VALUE) {}
SpinCtrl(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : Field(parent, opt, id), tmp_value(UNDEF_VALUE) {}
~SpinCtrl() {}
int tmp_value;
@ -355,9 +358,10 @@ public:
dynamic_cast<wxSpinCtrl*>(window)->SetValue(tmp_value);
m_disable_change_event = false;
}
boost::any& get_value() override {
// return boost::any(tmp_value);
return m_value = tmp_value;
int value = static_cast<wxSpinCtrl*>(window)->GetValue();
return m_value = value;
}
void msw_rescale() override;

View file

@ -1252,6 +1252,8 @@ GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, Bed3D& bed, Camera& camera, GLToolbar
m_timer.SetOwner(m_canvas);
#if ENABLE_RETINA_GL
m_retina_helper.reset(new RetinaHelper(canvas));
// set default view_toolbar icons size equal to GLGizmosManager::Default_Icons_Size
m_view_toolbar.set_icons_size(GLGizmosManager::Default_Icons_Size);
#endif
}
@ -2020,7 +2022,7 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
if (it->new_geometry())
instances[istep].emplace_back(std::pair<size_t, size_t>(instance_idx, print_instance_idx));
else
// Recycling an old GLVolume. Update the Object/Instance indices into the current Model.
// Recycling an old GLVolume. Update the Object/Instance indices into the current Model.
m_volumes.volumes[it->volume_idx]->composite_id = GLVolume::CompositeID(object_idx, m_volumes.volumes[it->volume_idx]->volume_idx(), instance_idx);
}
}
@ -2292,6 +2294,9 @@ void GLCanvas3D::on_size(wxSizeEvent& evt)
void GLCanvas3D::on_idle(wxIdleEvent& evt)
{
if (!m_initialized)
return;
m_dirty |= m_toolbar.update_items_state();
m_dirty |= m_view_toolbar.update_items_state();
@ -3415,9 +3420,6 @@ bool GLCanvas3D::_init_toolbar()
return true;
}
#if ENABLE_SVG_ICONS
m_toolbar.set_icons_size(40);
#endif // ENABLE_SVG_ICONS
// m_toolbar.set_layout_type(GLToolbar::Layout::Vertical);
m_toolbar.set_layout_type(GLToolbar::Layout::Horizontal);
m_toolbar.set_layout_orientation(GLToolbar::Layout::Top);
@ -4022,8 +4024,7 @@ void GLCanvas3D::_render_selection() const
#if ENABLE_RENDER_SELECTION_CENTER
void GLCanvas3D::_render_selection_center() const
{
if (!m_gizmos.is_running())
m_selection.render_center();
m_selection.render_center(m_gizmos.is_dragging());
}
#endif // ENABLE_RENDER_SELECTION_CENTER
@ -4095,10 +4096,14 @@ void GLCanvas3D::_render_current_gizmo() const
void GLCanvas3D::_render_gizmos_overlay() const
{
#if ENABLE_RETINA_GL
m_gizmos.set_overlay_scale(m_retina_helper->get_scale_factor());
// m_gizmos.set_overlay_scale(m_retina_helper->get_scale_factor());
const float scale = m_retina_helper->get_scale_factor()*wxGetApp().toolbar_icon_scale();
m_gizmos.set_overlay_scale(scale); //! #ys_FIXME_experiment
#else
// m_gizmos.set_overlay_scale(m_canvas->GetContentScaleFactor());
m_gizmos.set_overlay_scale(wxGetApp().em_unit()*0.1f);//! #ys_FIXME_experiment
// m_gizmos.set_overlay_scale(wxGetApp().em_unit()*0.1f);
const float size = int(GLGizmosManager::Default_Icons_Size*wxGetApp().toolbar_icon_scale());
m_gizmos.set_overlay_icon_size(size); //! #ys_FIXME_experiment
#endif /* __WXMSW__ */
m_gizmos.render_overlay(*this, m_selection);
@ -4108,10 +4113,14 @@ void GLCanvas3D::_render_toolbar() const
{
#if ENABLE_SVG_ICONS
#if ENABLE_RETINA_GL
m_toolbar.set_scale(m_retina_helper->get_scale_factor());
// m_toolbar.set_scale(m_retina_helper->get_scale_factor());
const float scale = m_retina_helper->get_scale_factor() * wxGetApp().toolbar_icon_scale(true);
m_toolbar.set_scale(scale); //! #ys_FIXME_experiment
#else
// m_toolbar.set_scale(m_canvas->GetContentScaleFactor());
m_toolbar.set_scale(wxGetApp().em_unit()*0.1f);//! #ys_FIXME_experiment
// m_toolbar.set_scale(wxGetApp().em_unit()*0.1f);
const float size = int(GLToolbar::Default_Icons_Size * wxGetApp().toolbar_icon_scale(true));
m_toolbar.set_icons_size(size); //! #ys_FIXME_experiment
#endif // ENABLE_RETINA_GL
Size cnv_size = get_canvas_size();
@ -4172,10 +4181,14 @@ void GLCanvas3D::_render_view_toolbar() const
{
#if ENABLE_SVG_ICONS
#if ENABLE_RETINA_GL
m_view_toolbar.set_scale(m_retina_helper->get_scale_factor());
// m_view_toolbar.set_scale(m_retina_helper->get_scale_factor());
const float scale = m_retina_helper->get_scale_factor() * wxGetApp().toolbar_icon_scale();
m_view_toolbar.set_scale(scale); //! #ys_FIXME_experiment
#else
// m_view_toolbar.set_scale(m_canvas->GetContentScaleFactor());
m_view_toolbar.set_scale(wxGetApp().em_unit()*0.1f); //! #ys_FIXME_experiment
// m_view_toolbar.set_scale(wxGetApp().em_unit()*0.1f);
const float size = int(GLGizmosManager::Default_Icons_Size * wxGetApp().toolbar_icon_scale());
m_view_toolbar.set_icons_size(size); //! #ys_FIXME_experiment
#endif // ENABLE_RETINA_GL
Size cnv_size = get_canvas_size();
@ -5485,6 +5498,7 @@ void GLCanvas3D::_load_sla_shells()
v.set_instance_offset(unscale(instance.shift(0), instance.shift(1), 0));
v.set_instance_rotation(Vec3d(0.0, 0.0, (double)instance.rotation));
v.set_instance_mirror(X, object.is_left_handed() ? -1. : 1.);
v.set_convex_hull(new TriangleMesh(std::move(mesh.convex_hull_3d())), true);
};
// adds objects' volumes
@ -5499,7 +5513,7 @@ void GLCanvas3D::_load_sla_shells()
if (obj->is_step_done(slaposSupportTree) && obj->has_mesh(slaposSupportTree))
add_volume(*obj, -int(slaposSupportTree), instance, obj->support_mesh(), GLVolume::SLA_SUPPORT_COLOR, true);
if (obj->is_step_done(slaposBasePool) && obj->has_mesh(slaposBasePool))
add_volume(*obj, -int(slaposBasePool), instance, obj->pad_mesh(), GLVolume::SLA_PAD_COLOR, true);
add_volume(*obj, -int(slaposBasePool), instance, obj->pad_mesh(), GLVolume::SLA_PAD_COLOR, false);
}
double shift_z = obj->get_current_elevation();
for (unsigned int i = initial_volumes_count; i < m_volumes.volumes.size(); ++ i) {
@ -5622,7 +5636,7 @@ void GLCanvas3D::_update_sla_shells_outside_state()
for (GLVolume* volume : m_volumes.volumes)
{
volume->is_outside = ((print_volume.radius() > 0.0) && volume->is_sla_support()) ? !print_volume.contains(volume->transformed_convex_hull_bounding_box()) : false;
volume->is_outside = ((print_volume.radius() > 0.0) && volume->shader_outside_printer_detection_enabled) ? !print_volume.contains(volume->transformed_convex_hull_bounding_box()) : false;
}
}

View file

@ -123,7 +123,7 @@ BackgroundTexture::Metadata::Metadata()
}
#if ENABLE_SVG_ICONS
const float GLToolbar::Default_Icons_Size = 64.0f;
const float GLToolbar::Default_Icons_Size = 40.0f;
#endif // ENABLE_SVG_ICONS
GLToolbar::Layout::Layout()

View file

@ -390,6 +390,27 @@ void GUI_App::set_label_clr_sys(const wxColour& clr) {
app_config->save();
}
float GUI_App::toolbar_icon_scale(const bool is_limited/* = false*/) const
{
#ifdef __APPLE__
const float icon_sc = 1.0f; // for Retina display will be used its own scale
#else
const float icon_sc = m_em_unit*0.1f;
#endif // __APPLE__
const std::string& use_val = app_config->get("use_custom_toolbar_size");
const std::string& val = app_config->get("custom_toolbar_size");
if (val.empty() || use_val.empty() || use_val == "0")
return icon_sc;
int int_val = atoi(val.c_str());
if (is_limited && int_val < 50)
int_val = 50;
return 0.01f * int_val * icon_sc;
}
void GUI_App::recreate_GUI()
{
// Weird things happen as the Paint messages are floating around the windows being destructed.
@ -707,7 +728,7 @@ void GUI_App::update_mode()
void GUI_App::add_config_menu(wxMenuBar *menu)
{
auto local_menu = new wxMenu();
wxWindowID config_id_base = wxWindow::NewControlId((int)ConfigMenuCnt);
wxWindowID config_id_base = wxWindow::NewControlId(int(ConfigMenuCnt));
const auto config_wizard_name = _(ConfigWizard::name(true).wx_str());
const auto config_wizard_tooltip = wxString::Format(_(L("Run %s")), config_wizard_name);
@ -729,9 +750,9 @@ void GUI_App::add_config_menu(wxMenuBar *menu)
mode_menu->AppendRadioItem(config_id_base + ConfigMenuModeSimple, _(L("Simple")), _(L("Simple View Mode")));
mode_menu->AppendRadioItem(config_id_base + ConfigMenuModeAdvanced, _(L("Advanced")), _(L("Advanced View Mode")));
mode_menu->AppendRadioItem(config_id_base + ConfigMenuModeExpert, _(L("Expert")), _(L("Expert View Mode")));
Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Check(get_mode() == comSimple); }, config_id_base + ConfigMenuModeSimple);
Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Check(get_mode() == comAdvanced); }, config_id_base + ConfigMenuModeAdvanced);
Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Check(get_mode() == comExpert); }, config_id_base + ConfigMenuModeExpert);
Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { if(get_mode() == comSimple) evt.Check(true); }, config_id_base + ConfigMenuModeSimple);
Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { if(get_mode() == comAdvanced) evt.Check(true); }, config_id_base + ConfigMenuModeAdvanced);
Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { if(get_mode() == comExpert) evt.Check(true); }, config_id_base + ConfigMenuModeExpert);
local_menu->AppendSubMenu(mode_menu, _(L("Mode")), wxString::Format(_(L("%s View Mode")), SLIC3R_APP_NAME));
local_menu->AppendSeparator();
@ -810,10 +831,14 @@ void GUI_App::add_config_menu(wxMenuBar *menu)
break;
}
});
mode_menu->Bind(wxEVT_MENU, [this, config_id_base](wxEvent& event) {
int id_mode = event.GetId() - config_id_base;
save_mode(id_mode - ConfigMenuModeSimple);
});
using std::placeholders::_1;
auto modfn = [this](int mode, wxCommandEvent&) { if(get_mode() != mode) save_mode(mode); };
mode_menu->Bind(wxEVT_MENU, std::bind(modfn, comSimple, _1), config_id_base + ConfigMenuModeSimple);
mode_menu->Bind(wxEVT_MENU, std::bind(modfn, comAdvanced, _1), config_id_base + ConfigMenuModeAdvanced);
mode_menu->Bind(wxEVT_MENU, std::bind(modfn, comExpert, _1), config_id_base + ConfigMenuModeExpert);
menu->Append(local_menu, _(L("&Configuration")));
}
@ -914,6 +939,7 @@ wxNotebook* GUI_App::tab_panel() const
return mainframe->m_tabpanel;
}
// extruders count from selected printer preset
int GUI_App::extruders_cnt() const
{
const Preset& preset = preset_bundle->printers.get_selected_preset();
@ -921,6 +947,14 @@ int GUI_App::extruders_cnt() const
preset.config.option<ConfigOptionFloats>("nozzle_diameter")->values.size();
}
// extruders count from edited printer preset
int GUI_App::extruders_edited_cnt() const
{
const Preset& preset = preset_bundle->printers.get_edited_preset();
return preset.printer_technology() == ptSLA ? 1 :
preset.config.option<ConfigOptionFloats>("nozzle_diameter")->values.size();
}
void GUI_App::open_web_page_localized(const std::string &http_address)
{
wxLaunchDefaultBrowser(http_address + "&lng=" + this->current_language_code());

View file

@ -115,6 +115,7 @@ public:
const wxFont& normal_font() { return m_normal_font; }
size_t em_unit() const { return m_em_unit; }
void set_em_unit(const size_t em_unit) { m_em_unit = em_unit; }
float toolbar_icon_scale(const bool is_limited = false) const;
void recreate_GUI();
void system_info();
@ -165,6 +166,7 @@ public:
wxNotebook* tab_panel() const ;
int extruders_cnt() const;
int extruders_edited_cnt() const;
std::vector<Tab *> tabs_list;

View file

@ -1,3 +1,4 @@
#include "libslic3r/libslic3r.h"
#include "GUI_ObjectList.hpp"
#include "GUI_ObjectManipulation.hpp"
#include "GUI_App.hpp"
@ -297,13 +298,18 @@ void ObjectList::set_tooltip_for_item(const wxPoint& pt)
wxDataViewItem item;
wxDataViewColumn* col;
HitTest(pt, item, col);
if (!item) return;
/* GetMainWindow() return window, associated with wxDataViewCtrl.
* And for this window we should to set tooltips.
* Just this->SetToolTip(tooltip) => has no effect.
*/
if (!item)
{
GetMainWindow()->SetToolTip(""); // hide tooltip
return;
}
if (col->GetTitle() == " " && GetSelectedItemsCount()<2)
GetMainWindow()->SetToolTip(_(L("Right button click the icon to change the object settings")));
else if (col->GetTitle() == _("Name"))
@ -349,8 +355,8 @@ DynamicPrintConfig& ObjectList::get_item_config(const wxDataViewItem& item) cons
const int vol_idx = type & itVolume ? m_objects_model->GetVolumeIdByItem(item) : -1;
assert(obj_idx >= 0 || ((type & itVolume) && vol_idx >=0));
return type & itObject|itInstance ? (*m_objects)[obj_idx]->config :
(*m_objects)[obj_idx]->volumes[vol_idx]->config;
return type & itVolume ?(*m_objects)[obj_idx]->volumes[vol_idx]->config :
(*m_objects)[obj_idx]->config;
}
wxDataViewColumn* ObjectList::create_objects_list_extruder_column(int extruders_count)
@ -1278,6 +1284,12 @@ void ObjectList::append_menu_item_delete(wxMenu* menu)
[this](wxCommandEvent&) { remove(); }, "", menu);
}
void ObjectList::append_menu_item_scale_selection_to_fit_print_volume(wxMenu* menu)
{
append_menu_item(menu, wxID_ANY, _(L("Scale to print volume")), _(L("Scale the selected object to fit the print volume")),
[this](wxCommandEvent&) { wxGetApp().plater()->scale_selection_to_fit_print_volume(); }, "", menu);
}
void ObjectList::create_object_popupmenu(wxMenu *menu)
{
#ifdef __WXOSX__
@ -1286,6 +1298,7 @@ void ObjectList::create_object_popupmenu(wxMenu *menu)
append_menu_item_export_stl(menu);
append_menu_item_fix_through_netfabb(menu);
append_menu_item_scale_selection_to_fit_print_volume(menu);
// Split object to parts
m_menu_item_split = append_menu_item_split(menu);
@ -1452,9 +1465,6 @@ void ObjectList::load_part( ModelObject* model_object,
delta = model_object->origin_translation - object->origin_translation;
}
for (auto volume : object->volumes) {
#if !ENABLE_VOLUMES_CENTERING_FIXES
volume->center_geometry();
#endif // !ENABLE_VOLUMES_CENTERING_FIXES
volume->translate(delta);
auto new_volume = model_object->add_volume(*volume);
new_volume->set_type(type);
@ -1577,14 +1587,6 @@ void ObjectList::load_generic_subobject(const std::string& type_name, const Mode
ModelVolume *new_volume = model_object.add_volume(std::move(mesh));
new_volume->set_type(type);
#if !ENABLE_GENERIC_SUBPARTS_PLACEMENT
new_volume->set_offset(Vec3d(0.0, 0.0, model_object.origin_translation(2) - mesh.stl.stats.min(2)));
#endif // !ENABLE_GENERIC_SUBPARTS_PLACEMENT
#if !ENABLE_VOLUMES_CENTERING_FIXES
new_volume->center_geometry();
#endif // !ENABLE_VOLUMES_CENTERING_FIXES
#if ENABLE_GENERIC_SUBPARTS_PLACEMENT
if (instance_idx != -1)
{
// First (any) GLVolume of the selected instance. They all share the same instance matrix.
@ -1600,7 +1602,6 @@ void ObjectList::load_generic_subobject(const std::string& type_name, const Mode
Vec3d(instance_bb.max(0), instance_bb.min(1), instance_bb.min(2)) + 0.5 * mesh_bb.size() - v->get_instance_offset();
new_volume->set_offset(v->get_instance_transformation().get_matrix(true).inverse() * offset);
}
#endif // ENABLE_GENERIC_SUBPARTS_PLACEMENT
new_volume->name = into_u8(name);
// set a default extruder value, since user can't add it manually
@ -2047,7 +2048,10 @@ void ObjectList::delete_from_model_and_list(const std::vector<ItemForDelete>& it
void ObjectList::delete_all_objects_from_list()
{
m_prevent_list_events = true;
this->UnselectAll();
m_objects_model->DeleteAll();
m_prevent_list_events = false;
part_selection_changed();
}
@ -2820,8 +2824,10 @@ void ObjectList::OnEditingDone(wxDataViewEvent &event)
const auto renderer = dynamic_cast<BitmapTextRenderer*>(GetColumn(0)->GetRenderer());
if (renderer->WasCanceled())
show_error(this, _(L("The supplied name is not valid;")) + "\n" +
_(L("the following characters are not allowed:")) + " <>:/\\|?*\"");
wxTheApp->CallAfter([this]{
show_error(this, _(L("The supplied name is not valid;")) + "\n" +
_(L("the following characters are not allowed:")) + " <>:/\\|?*\"");
});
}
void ObjectList::show_multi_selection_menu()

View file

@ -207,6 +207,7 @@ public:
void append_menu_item_export_stl(wxMenu* menu) const ;
void append_menu_item_change_extruder(wxMenu* menu) const;
void append_menu_item_delete(wxMenu* menu);
void append_menu_item_scale_selection_to_fit_print_volume(wxMenu* menu);
void create_object_popupmenu(wxMenu *menu);
void create_sla_object_popupmenu(wxMenu*menu);
void create_part_popupmenu(wxMenu*menu);

View file

@ -44,6 +44,20 @@ GLGizmoSlaSupports::~GLGizmoSlaSupports()
bool GLGizmoSlaSupports::on_init()
{
m_shortcut_key = WXK_CONTROL_L;
m_desc["head_diameter"] = _(L("Head diameter")) + ": ";
m_desc["lock_supports"] = _(L("Lock supports under new islands"));
m_desc["remove_selected"] = _(L("Remove selected points"));
m_desc["remove_all"] = _(L("Remove all points"));
m_desc["apply_changes"] = _(L("Apply changes"));
m_desc["discard_changes"] = _(L("Discard changes"));
m_desc["minimal_distance"] = _(L("Minimal points distance")) + ": ";
m_desc["points_density"] = _(L("Support points density")) + ": ";
m_desc["auto_generate"] = _(L("Auto-generate points"));
m_desc["manual_editing"] = _(L("Manual editing"));
m_desc["clipping_of_view"] = _(L("Clipping of view"))+ ": ";
m_desc["reset_direction"] = _(L("Reset direction"));
return true;
}
@ -303,6 +317,9 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
glsafe(::glTranslated(support_point.pos(0), support_point.pos(1), support_point.pos(2)));
glsafe(::glMultMatrixd(instance_scaling_matrix_inverse.data()));
if (vol->is_left_handed())
glFrontFace(GL_CW);
// Matrices set, we can render the point mark now.
// If in editing mode, we'll also render a cone pointing to the sphere.
if (m_editing_mode) {
@ -324,6 +341,9 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
glsafe(::glPopMatrix());
}
::gluSphere(m_quadric, m_editing_mode_cache[i].support_point.head_front_radius * RenderPointScale, 24, 12);
if (vol->is_left_handed())
glFrontFace(GL_CCW);
glsafe(::glPopMatrix());
}
@ -825,7 +845,18 @@ RENDER_AGAIN:
m_imgui->set_next_window_bg_alpha(0.5f);
m_imgui->begin(on_get_name(), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse);
//ImGui::PushItemWidth(m_imgui->scaled(5.55f));
// First calculate width of all the texts that are could possibly be shown. We will decide set the dialog width based on that:
const float settings_sliders_left = std::max(m_imgui->calc_text_size(m_desc.at("minimal_distance")).x, m_imgui->calc_text_size(m_desc.at("points_density")).x) + m_imgui->scaled(1.f);
const float clipping_slider_left = std::max(m_imgui->calc_text_size(m_desc.at("clipping_of_view")).x, m_imgui->calc_text_size(m_desc.at("reset_direction")).x) + m_imgui->scaled(1.5f);
const float diameter_slider_left = m_imgui->calc_text_size(m_desc.at("head_diameter")).x + m_imgui->scaled(1.f);
const float minimal_slider_width = m_imgui->scaled(4.f);
const float buttons_width_approx = m_imgui->calc_text_size(m_desc.at("apply_changes")).x + m_imgui->calc_text_size(m_desc.at("discard_changes")).x + m_imgui->scaled(1.5f);
const float lock_supports_width_approx = m_imgui->calc_text_size(m_desc.at("lock_supports")).x + m_imgui->scaled(2.f);
float window_width = minimal_slider_width + std::max(std::max(settings_sliders_left, clipping_slider_left), diameter_slider_left);
window_width = std::max(std::max(window_width, buttons_width_approx), lock_supports_width_approx);
bool force_refresh = false;
bool remove_selected = false;
@ -836,12 +867,9 @@ RENDER_AGAIN:
float diameter_upper_cap = static_cast<ConfigOptionFloat*>(wxGetApp().preset_bundle->sla_prints.get_edited_preset().config.option("support_pillar_diameter"))->value;
if (m_new_point_head_diameter > diameter_upper_cap)
m_new_point_head_diameter = diameter_upper_cap;
wxString text = _(L("Head diameter")) + ": ";
m_imgui->text(text);
float slider_left = m_imgui->calc_text_size(text).x + m_imgui->scaled(1.f);
ImGui::SameLine(/*m_imgui->scaled(6.66f)*/slider_left);
ImGui::PushItemWidth(/*m_imgui->scaled(8.33f)*/m_imgui->scaled(15.f) - slider_left);
m_imgui->text(m_desc.at("head_diameter"));
ImGui::SameLine(diameter_slider_left);
ImGui::PushItemWidth(window_width - diameter_slider_left);
if (ImGui::SliderFloat("", &m_new_point_head_diameter, 0.1f, diameter_upper_cap, "%.1f")) {
// value was changed
@ -853,37 +881,34 @@ RENDER_AGAIN:
}
bool changed = m_lock_unique_islands;
m_imgui->checkbox(_(L("Lock supports under new islands")), m_lock_unique_islands);
m_imgui->checkbox(m_desc.at("lock_supports"), m_lock_unique_islands);
force_refresh |= changed != m_lock_unique_islands;
m_imgui->disabled_begin(m_selection_empty);
remove_selected = m_imgui->button(_(L("Remove selected points")));
remove_selected = m_imgui->button(m_desc.at("remove_selected"));
m_imgui->disabled_end();
m_imgui->disabled_begin(m_editing_mode_cache.empty());
remove_all = m_imgui->button(_(L("Remove all points")));
remove_all = m_imgui->button(m_desc.at("remove_all"));
m_imgui->disabled_end();
m_imgui->text(" "); // vertical gap
if (m_imgui->button(_(L("Apply changes")))) {
if (m_imgui->button(m_desc.at("apply_changes"))) {
editing_mode_apply_changes();
force_refresh = true;
}
ImGui::SameLine();
bool discard_changes = m_imgui->button(_(L("Discard changes")));
bool discard_changes = m_imgui->button(m_desc.at("discard_changes"));
if (discard_changes) {
editing_mode_discard_changes();
force_refresh = true;
}
}
else { // not in editing mode:
wxString text1 = _(L("Minimal points distance")) + ": ";
wxString text2 = _(L("Support points density")) + ": ";
float sliders_left = std::max(m_imgui->calc_text_size(text1).x, m_imgui->calc_text_size(text2).x) + m_imgui->scaled(1.f);
m_imgui->text(text1);
ImGui::SameLine(/*m_imgui->scaled(9.44f)*/sliders_left);
ImGui::PushItemWidth(/*m_imgui->scaled(5.55f)*/m_imgui->scaled(15.f)-sliders_left);
m_imgui->text(m_desc.at("minimal_distance"));
ImGui::SameLine(settings_sliders_left);
ImGui::PushItemWidth(window_width - settings_sliders_left);
std::vector<const ConfigOption*> opts = get_config_options({"support_points_density_relative", "support_points_minimal_distance"});
float density = static_cast<const ConfigOptionInt*>(opts[0])->value;
@ -893,8 +918,8 @@ RENDER_AGAIN:
if (value_changed)
m_model_object->config.opt<ConfigOptionFloat>("support_points_minimal_distance", true)->value = minimal_point_distance;
m_imgui->text(text2);
ImGui::SameLine(/*m_imgui->scaled(9.44f)*/sliders_left);
m_imgui->text(m_desc.at("points_density"));
ImGui::SameLine(settings_sliders_left);
if (ImGui::SliderFloat(" ", &density, 0.f, 200.f, "%.f %%")) {
value_changed = true;
@ -908,17 +933,17 @@ RENDER_AGAIN:
});
}
bool generate = m_imgui->button(_(L("Auto-generate points")));
bool generate = m_imgui->button(m_desc.at("auto_generate"));
if (generate)
auto_generate();
m_imgui->text("");
if (m_imgui->button(_(L("Manual editing"))))
if (m_imgui->button(m_desc.at("manual_editing")))
switch_to_editing_mode();
m_imgui->disabled_begin(m_editing_mode_cache.empty());
remove_all = m_imgui->button(_(L("Remove all points")));
remove_all = m_imgui->button(m_desc.at("remove_all"));
m_imgui->disabled_end();
// m_imgui->text("");
@ -931,21 +956,18 @@ RENDER_AGAIN:
// Following is rendered in both editing and non-editing mode:
m_imgui->text("");
wxString text1 = _(L("Clipping of view"))+ ": ";
wxString text2 = _(L("Reset direction"));
float slider_left = std::max(m_imgui->calc_text_size(text1).x, m_imgui->calc_text_size(text2).x) + m_imgui->scaled(1.5f);
if (m_clipping_plane_distance == 0.f)
m_imgui->text(text1);
m_imgui->text(m_desc.at("clipping_of_view"));
else {
if (m_imgui->button(text2)) {
if (m_imgui->button(m_desc.at("reset_direction"))) {
wxGetApp().CallAfter([this](){
reset_clipping_plane_normal();
});
}
}
ImGui::SameLine(/*m_imgui->scaled(6.66f)*/slider_left);
ImGui::PushItemWidth(/*m_imgui->scaled(8.33f)*/m_imgui->scaled(15.f) - slider_left);
ImGui::SameLine(clipping_slider_left);
ImGui::PushItemWidth(window_width - clipping_slider_left);
ImGui::SliderFloat(" ", &m_clipping_plane_distance, 0.f, 1.f, "%.2f");

View file

@ -95,6 +95,10 @@ private:
mutable Vec3d m_old_clipping_plane_normal;
mutable Vec3d m_clipping_plane_normal = Vec3d::Zero();
// This map holds all translated description texts, so they can be easily referenced during layout calculations
// etc. When language changes, GUI is recreated and this class constructed again, so the change takes effect.
std::map<std::string, wxString> m_desc;
GLSelectionRectangle m_selection_rectangle;
bool m_wait_for_up_event = false;

View file

@ -654,7 +654,8 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt, GLCanvas3D& canvas)
if (evt.AltDown())
transformation_type.set_independent();
selection.scale(get_scale(), transformation_type);
selection.translate(get_scale_offset(), true);
if (evt.ControlDown())
selection.translate(get_scale_offset(), true);
wxGetApp().obj_manipul()->set_dirty();
break;
}
@ -846,6 +847,19 @@ bool GLGizmosManager::on_char(wxKeyEvent& evt, GLCanvas3D& canvas)
break;
}
case 'F':
case 'f':
{
if (m_current == Scale)
{
if (!is_dragging())
wxGetApp().plater()->scale_selection_to_fit_print_volume();
processed = true;
}
break;
}
}
}

View file

@ -28,6 +28,7 @@ namespace GUI {
ImGuiWrapper::ImGuiWrapper()
: m_glyph_ranges(nullptr)
, m_font_cjk(false)
, m_font_size(18.0)
, m_font_texture(0)
, m_style_scaling(1.0)
@ -68,16 +69,52 @@ void ImGuiWrapper::set_language(const std::string &language)
0x0100, 0x017F, // Latin Extended-A
0,
};
static const ImWchar ranges_turkish[] = {
0x0020, 0x01FF, // Basic Latin + Latin Supplement
0x0100, 0x017F, // Latin Extended-A
0x0180, 0x01FF, // Turkish
0,
};
static const ImWchar ranges_vietnamese[] =
{
0x0020, 0x00FF, // Basic Latin
0x0102, 0x0103,
0x0110, 0x0111,
0x0128, 0x0129,
0x0168, 0x0169,
0x01A0, 0x01A1,
0x01AF, 0x01B0,
0x1EA0, 0x1EF9,
0,
};
m_font_cjk = false;
if (lang == "cs" || lang == "pl") {
ranges = ranges_latin2;
} else if (lang == "ru" || lang == "uk") {
ranges = ImGui::GetIO().Fonts->GetGlyphRangesCyrillic();
ranges = ImGui::GetIO().Fonts->GetGlyphRangesCyrillic(); // Default + about 400 Cyrillic characters
} else if (lang == "tr") {
ranges = ranges_turkish;
} else if (lang == "vi") {
ranges = ranges_vietnamese;
} else if (lang == "jp") {
ranges = ImGui::GetIO().Fonts->GetGlyphRangesJapanese();
} else if (lang == "kr") {
ranges = ImGui::GetIO().Fonts->GetGlyphRangesKorean();
ranges = ImGui::GetIO().Fonts->GetGlyphRangesJapanese(); // Default + Hiragana, Katakana, Half-Width, Selection of 1946 Ideographs
m_font_cjk = true;
} else if (lang == "ko") {
ranges = ImGui::GetIO().Fonts->GetGlyphRangesKorean(); // Default + Korean characters
m_font_cjk = true;
} else if (lang == "zh") {
ranges = ImGui::GetIO().Fonts->GetGlyphRangesChineseSimplifiedCommon();
ranges = (language == "zh_TW") ?
// Traditional Chinese
// Default + Half-Width + Japanese Hiragana/Katakana + full set of about 21000 CJK Unified Ideographs
ImGui::GetIO().Fonts->GetGlyphRangesChineseFull() :
// Simplified Chinese
// Default + Half-Width + Japanese Hiragana/Katakana + set of 2500 CJK Unified Ideographs for common simplified Chinese
ImGui::GetIO().Fonts->GetGlyphRangesChineseSimplifiedCommon();
m_font_cjk = true;
} else if (lang == "th") {
ranges = ImGui::GetIO().Fonts->GetGlyphRangesThai(); // Default + Thai characters
} else {
ranges = ImGui::GetIO().Fonts->GetGlyphRangesDefault(); // Basic Latin, Extended Latin
}
if (ranges != m_glyph_ranges) {
@ -188,10 +225,10 @@ ImVec2 ImGuiWrapper::calc_text_size(const wxString &text)
auto text_utf8 = into_u8(text);
ImVec2 size = ImGui::CalcTextSize(text_utf8.c_str());
#ifndef __APPLE__
/*#ifdef __linux__
size.x *= m_style_scaling;
size.y *= m_style_scaling;
#endif
#endif*/
return size;
}
@ -352,7 +389,9 @@ void ImGuiWrapper::init_font()
ImGuiIO& io = ImGui::GetIO();
io.Fonts->Clear();
ImFont* font = io.Fonts->AddFontFromFileTTF((Slic3r::resources_dir() + "/fonts/NotoSans-Regular.ttf").c_str(), m_font_size, nullptr, m_glyph_ranges);
//FIXME replace with io.Fonts->AddFontFromMemoryTTF(buf_decompressed_data, (int)buf_decompressed_size, m_font_size, nullptr, m_glyph_ranges);
//https://github.com/ocornut/imgui/issues/220
ImFont* font = io.Fonts->AddFontFromFileTTF((Slic3r::resources_dir() + "/fonts/" + (m_font_cjk ? "NotoSansCJK-Regular.ttc" : "NotoSans-Regular.ttf")).c_str(), m_font_size, nullptr, m_glyph_ranges);
if (font == nullptr) {
font = io.Fonts->AddFontDefault();
if (font == nullptr) {

View file

@ -19,6 +19,8 @@ namespace GUI {
class ImGuiWrapper
{
const ImWchar *m_glyph_ranges;
// Chinese, Japanese, Korean
bool m_font_cjk;
float m_font_size;
unsigned m_font_texture;
float m_style_scaling;

View file

@ -144,6 +144,7 @@ void KBShortcutsDialog::fill_shortcuts()
plater_shortcuts.push_back(Shortcut("F", L("Gizmo Place face on bed")));
plater_shortcuts.push_back(Shortcut("L", L("Gizmo SLA support points")));
plater_shortcuts.push_back(Shortcut("Shift+", L("Press to activate selection rectangle\nor to snap by 5% in Gizmo scale\nor to snap by 1mm in Gizmo move")));
plater_shortcuts.push_back(Shortcut("F", L("Press to scale selection to fit print volume\nin Gizmo scale")));
plater_shortcuts.push_back(Shortcut(alt, L("Press to activate deselection rectangle\nor to scale or rotate selected objects\naround their own center")));
plater_shortcuts.push_back(Shortcut(ctrl, L("Press to activate one direction scaling in Gizmo scale")));
plater_shortcuts.push_back(Shortcut("B", L("Zoom to Bed")));

View file

@ -143,7 +143,9 @@ void MainFrame::update_title()
wxString title = wxEmptyString;
if (m_plater != nullptr)
{
wxString project = from_path(into_path(m_plater->get_project_filename()).stem());
// m_plater->get_project_filename() produces file name including path, but excluding extension.
// Don't try to remove the extension, it would remove part of the file name after the last dot!
wxString project = from_path(into_path(m_plater->get_project_filename()).filename());
if (!project.empty())
title += (project + " - ");
}
@ -380,7 +382,11 @@ void MainFrame::init_menubar()
append_menu_item(fileMenu, wxID_ANY, _(L("&Save Project")) + "\tCtrl+S", _(L("Save current project file")),
[this](wxCommandEvent&) { if (m_plater) m_plater->export_3mf(into_path(m_plater->get_project_filename(".3mf"))); }, menu_icon("save"), nullptr,
[this](){return m_plater != nullptr && can_save(); }, this);
#ifdef __APPLE__
append_menu_item(fileMenu, wxID_ANY, _(L("Save Project &as")) + dots + "\tCtrl+Shift+S", _(L("Save current project file as")),
#else
append_menu_item(fileMenu, wxID_ANY, _(L("Save Project &as")) + dots + "\tCtrl+Alt+S", _(L("Save current project file as")),
#endif // __APPLE__
[this](wxCommandEvent&) { if (m_plater) m_plater->export_3mf(); }, menu_icon("save"), nullptr,
[this](){return m_plater != nullptr && can_save(); }, this);
@ -481,11 +487,9 @@ void MainFrame::init_menubar()
append_menu_item(editMenu, wxID_ANY, _(L("&Select all")) + sep + GUI::shortkey_ctrl_prefix() + sep_space + "A",
_(L("Selects all objects")), [this](wxCommandEvent&) { if (m_plater != nullptr) m_plater->select_all(); },
"", nullptr, [this](){return can_select(); }, this);
#if !DISABLE_DESELECT_ALL_MENU_ITEM
append_menu_item(editMenu, wxID_ANY, _(L("D&eselect all")) + sep + GUI::shortkey_ctrl_prefix() + sep + "Esc",
append_menu_item(editMenu, wxID_ANY, _(L("D&eselect all")) + sep + "Esc",
_(L("Deselects all objects")), [this](wxCommandEvent&) { if (m_plater != nullptr) m_plater->deselect_all(); },
"", nullptr, [this](){return can_deselect(); }, this);
#endif // !DISABLE_DESELECT_ALL_MENU_ITEM
editMenu->AppendSeparator();
append_menu_item(editMenu, wxID_ANY, _(L("&Delete selected")) + sep + hotkey_delete,
_(L("Deletes the current selection")),[this](wxCommandEvent&) { m_plater->remove_selected(); },

View file

@ -259,29 +259,45 @@ wxBitmapComboBox(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(15 *
if (preset_type == Slic3r::Preset::TYPE_FILAMENT)
{
Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &event) {
if (extruder_idx < 0 || event.GetLogicalPosition(wxClientDC(this)).x > 24) {
int shifl_Left = 0;
float scale = m_em_unit*0.1f;
#if defined(wxBITMAPCOMBOBOX_OWNERDRAWN_BASED)
shifl_Left = int(scale * 4 + 0.5f); // IMAGE_SPACING_RIGHT = 4 for wxBitmapComboBox -> Space left of image
#endif
int icon_right_pos = int(scale * (24+4) + 0.5);
int mouse_pos = event.GetLogicalPosition(wxClientDC(this)).x;
// if (extruder_idx < 0 || event.GetLogicalPosition(wxClientDC(this)).x > 24) {
if ( extruder_idx < 0 || mouse_pos < shifl_Left || mouse_pos > icon_right_pos ) {
// Let the combo box process the mouse click.
event.Skip();
return;
}
// Swallow the mouse click and open the color picker.
// get current color
DynamicPrintConfig* cfg = wxGetApp().get_tab(Preset::TYPE_PRINTER)->get_config();
auto colors = static_cast<ConfigOptionStrings*>(cfg->option("extruder_colour")->clone());
wxColour clr(colors->values[extruder_idx]);
if (!clr.IsOk())
clr = wxTransparentColour;
auto data = new wxColourData();
data->SetChooseFull(1);
auto dialog = new wxColourDialog(/* wxGetApp().mainframe */this, data);
dialog->CenterOnParent();
if (dialog->ShowModal() == wxID_OK) {
DynamicPrintConfig cfg = *wxGetApp().get_tab(Preset::TYPE_PRINTER)->get_config();
data->SetColour(clr);
//FIXME this is too expensive to call full_config to get just the extruder color!
auto colors = static_cast<ConfigOptionStrings*>(wxGetApp().preset_bundle->full_config().option("extruder_colour")->clone());
auto dialog = new wxColourDialog(this, data);
dialog->CenterOnParent();
if (dialog->ShowModal() == wxID_OK)
{
colors->values[extruder_idx] = dialog->GetColourData().GetColour().GetAsString(wxC2S_HTML_SYNTAX);
cfg.set_key_value("extruder_colour", colors);
DynamicPrintConfig cfg_new = *cfg;
cfg_new.set_key_value("extruder_colour", colors);
wxGetApp().get_tab(Preset::TYPE_PRINTER)->load_config(cfg);
wxGetApp().get_tab(Preset::TYPE_PRINTER)->load_config(cfg_new);
wxGetApp().preset_bundle->update_platter_filament_ui(extruder_idx, this);
wxGetApp().plater()->on_config_change(cfg);
wxGetApp().plater()->on_config_change(cfg_new);
}
dialog->Destroy();
});
@ -305,7 +321,7 @@ wxBitmapComboBox(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(15 *
/* In a case of a multi-material printing, for editing another Filament Preset
* it's needed to select this preset for the "Filament settings" Tab
*/
if (preset_type == Preset::TYPE_FILAMENT && wxGetApp().extruders_cnt() > 1)
if (preset_type == Preset::TYPE_FILAMENT && wxGetApp().extruders_edited_cnt() > 1)
{
const std::string& selected_preset = GetString(GetSelection()).ToUTF8().data();
@ -832,7 +848,7 @@ void Sidebar::update_presets(Preset::Type preset_type)
if (filament_cnt == 1) {
// Single filament printer, synchronize the filament presets.
const std::string &name = preset_bundle.filaments.get_selected_preset().name;
const std::string &name = preset_bundle.filaments.get_selected_preset_name();
preset_bundle.set_filament_preset(0, name);
}
@ -1251,9 +1267,7 @@ struct Plater::priv
static const std::regex pattern_3mf;
static const std::regex pattern_zip_amf;
static const std::regex pattern_any_amf;
#if ENABLE_VOLUMES_CENTERING_FIXES
static const std::regex pattern_prusa;
#endif // ENABLE_VOLUMES_CENTERING_FIXES
priv(Plater *q, MainFrame *main_frame);
@ -1288,7 +1302,8 @@ struct Plater::priv
void sla_optimize_rotation();
void split_object();
void split_volume();
bool background_processing_enabled() const { return this->get_config("background_processing") == "1"; }
void scale_selection_to_fit_print_volume();
bool background_processing_enabled() const { return this->get_config("background_processing") == "1"; }
void update_print_volume_state();
void schedule_background_process();
// Update background processing thread from the current config and Model.
@ -1387,9 +1402,7 @@ const std::regex Plater::priv::pattern_bundle(".*[.](amf|amf[.]xml|zip[.]amf|3mf
const std::regex Plater::priv::pattern_3mf(".*3mf", std::regex::icase);
const std::regex Plater::priv::pattern_zip_amf(".*[.]zip[.]amf", std::regex::icase);
const std::regex Plater::priv::pattern_any_amf(".*[.](amf|amf[.]xml|zip[.]amf)", std::regex::icase);
#if ENABLE_VOLUMES_CENTERING_FIXES
const std::regex Plater::priv::pattern_prusa(".*prusa", std::regex::icase);
#endif // ENABLE_VOLUMES_CENTERING_FIXES
Plater::priv::priv(Plater *q, MainFrame *main_frame)
: q(q)
@ -1644,11 +1657,10 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
const bool type_3mf = std::regex_match(path.string(), pattern_3mf);
const bool type_zip_amf = !type_3mf && std::regex_match(path.string(), pattern_zip_amf);
const bool type_any_amf = !type_3mf && std::regex_match(path.string(), pattern_any_amf);
#if ENABLE_VOLUMES_CENTERING_FIXES
const bool type_prusa = std::regex_match(path.string(), pattern_prusa);
#endif // ENABLE_VOLUMES_CENTERING_FIXES
Slic3r::Model model;
bool is_project_file = type_prusa;
try {
if (type_3mf || type_zip_amf) {
DynamicPrintConfig config;
@ -1672,6 +1684,7 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
Preset::normalize(config);
wxGetApp().preset_bundle->load_config_model(filename.string(), std::move(config));
wxGetApp().load_current_presets();
is_project_file = true;
}
wxGetApp().app_config->update_config_dir(path.parent_path().string());
}
@ -1691,9 +1704,7 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
{
// The model should now be initialized
#if ENABLE_VOLUMES_CENTERING_FIXES
if (!type_3mf && !type_any_amf && !type_prusa) {
#endif // ENABLE_VOLUMES_CENTERING_FIXES
if (! is_project_file) {
if (model.looks_like_multipart_object()) {
wxMessageDialog dlg(q, _(L(
"This file contains several objects positioned at multiple heights. "
@ -1704,7 +1715,6 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
model.convert_multipart_object(nozzle_dmrs->values.size());
}
}
#if ENABLE_VOLUMES_CENTERING_FIXES
}
else if ((wxGetApp().get_mode() == comSimple) && (type_3mf || type_any_amf))
{
@ -1761,22 +1771,11 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
return obj_idxs;
}
}
#endif // ENABLE_VOLUMES_CENTERING_FIXES
#if !ENABLE_VOLUMES_CENTERING_FIXES
if (type_3mf || type_any_amf) {
#endif // !ENABLE_VOLUMES_CENTERING_FIXES
for (ModelObject* model_object : model.objects) {
#if ENABLE_VOLUMES_CENTERING_FIXES
model_object->center_around_origin(false);
#else
model_object->center_around_origin();
#endif // ENABLE_VOLUMES_CENTERING_FIXES
model_object->ensure_on_bed();
}
#if !ENABLE_VOLUMES_CENTERING_FIXES
}
#endif // !ENABLE_VOLUMES_CENTERING_FIXES
// check multi-part object adding for the SLA-printing
if (printer_technology == ptSLA)
@ -2366,6 +2365,11 @@ void Plater::priv::split_volume()
wxGetApp().obj_list()->split();
}
void Plater::priv::scale_selection_to_fit_print_volume()
{
this->view3D->get_canvas3d()->get_selection().scale_to_fit_print_volume(*config);
}
void Plater::priv::schedule_background_process()
{
delayed_error_message.clear();
@ -3028,6 +3032,8 @@ bool Plater::priv::init_common_menu(wxMenu* menu, const bool is_part/* = false*/
sidebar->obj_list()->append_menu_item_fix_through_netfabb(menu);
sidebar->obj_list()->append_menu_item_scale_selection_to_fit_print_volume(menu);
wxMenu* mirror_menu = new wxMenu();
if (mirror_menu == nullptr)
return false;
@ -3467,6 +3473,11 @@ bool Plater::is_selection_empty() const
return p->get_selection().is_empty() || p->get_selection().is_wipe_tower();
}
void Plater::scale_selection_to_fit_print_volume()
{
p->scale_selection_to_fit_print_volume();
}
void Plater::cut(size_t obj_idx, size_t instance_idx, coordf_t z, bool keep_upper, bool keep_lower, bool rotate_lower)
{
wxCHECK_RET(obj_idx < p->model.objects.size(), "obj_idx out of bounds");

View file

@ -162,6 +162,7 @@ public:
void decrease_instances(size_t num = 1);
void set_number_of_copies(/*size_t num*/);
bool is_selection_empty() const;
void scale_selection_to_fit_print_volume();
void cut(size_t obj_idx, size_t instance_idx, coordf_t z, bool keep_upper = true, bool keep_lower = true, bool rotate_lower = false);

View file

@ -10,6 +10,9 @@ PreferencesDialog::PreferencesDialog(wxWindow* parent) :
DPIDialog(parent, wxID_ANY, _(L("Preferences")), wxDefaultPosition,
wxDefaultSize, wxDEFAULT_DIALOG_STYLE)
{
#ifdef __WXOSX__
isOSX = true;
#endif
build();
}
@ -18,8 +21,13 @@ void PreferencesDialog::build()
auto app_config = get_app_config();
m_optgroup = std::make_shared<ConfigOptionsGroup>(this, _(L("General")));
m_optgroup->label_width = 40;
m_optgroup->m_on_change = [this](t_config_option_key opt_key, boost::any value){
m_optgroup->m_on_change = [this](t_config_option_key opt_key, boost::any value) {
m_values[opt_key] = boost::any_cast<bool>(value) ? "1" : "0";
if (opt_key == "use_custom_toolbar_size") {
m_icon_size_sizer->ShowItems(boost::any_cast<bool>(value));
this->layout();
}
};
// TODO
@ -109,6 +117,16 @@ void PreferencesDialog::build()
m_optgroup->append_single_option_line(option);
#endif
def.label = L("Use custom size for toolbar icons");
def.type = coBool;
def.tooltip = L("If enabled, you can change size of toolbar icons manually.");
def.set_default_value(new ConfigOptionBool{ app_config->get("use_custom_toolbar_size") == "1" });
option = Option (def,"use_custom_toolbar_size");
m_optgroup->append_single_option_line(option);
create_icon_size_slider();
m_icon_size_sizer->ShowItems(app_config->get("use_custom_toolbar_size") == "1");
auto sizer = new wxBoxSizer(wxVERTICAL);
sizer->Add(m_optgroup->sizer, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10);
@ -145,17 +163,79 @@ void PreferencesDialog::on_dpi_changed(const wxRect &suggested_rect)
{
m_optgroup->msw_rescale();
msw_buttons_rescale(this, em_unit(), { wxID_OK, wxID_CANCEL });
layout();
}
void PreferencesDialog::layout()
{
const int em = em_unit();
msw_buttons_rescale(this, em, { wxID_OK, wxID_CANCEL });
const wxSize& size = wxSize(47 * em, 28 * em);
SetMinSize(size);
SetMinSize(wxSize(47 * em, 28 * em));
Fit();
Refresh();
}
void PreferencesDialog::create_icon_size_slider()
{
const auto app_config = get_app_config();
const int em = em_unit();
m_icon_size_sizer = new wxBoxSizer(wxHORIZONTAL);
wxWindow* parent = m_optgroup->ctrl_parent();
if (isOSX)
// For correct rendering of the slider and value label under OSX
// we should use system default background
parent->SetBackgroundStyle(wxBG_STYLE_ERASE);
auto label = new wxStaticText(parent, wxID_ANY, _(L("Icon size in a respect to the default size")) + " (%) :");
m_icon_size_sizer->Add(label, 0, wxALIGN_CENTER_VERTICAL| wxRIGHT | (isOSX ? 0 : wxLEFT), em);
const int def_val = atoi(app_config->get("custom_toolbar_size").c_str());
long style = wxSL_HORIZONTAL;
if (!isOSX)
style |= wxSL_LABELS | wxSL_AUTOTICKS;
auto slider = new wxSlider(parent, wxID_ANY, def_val, 30, 100,
wxDefaultPosition, wxDefaultSize, style);
slider->SetTickFreq(10);
slider->SetPageSize(10);
slider->SetToolTip(_(L("Select toolbar icon size in respect to the default one.")));
m_icon_size_sizer->Add(slider, 1, wxEXPAND);
wxStaticText* val_label{ nullptr };
if (isOSX) {
val_label = new wxStaticText(parent, wxID_ANY, wxString::Format("%d", def_val));
m_icon_size_sizer->Add(val_label, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, em);
}
slider->Bind(wxEVT_SLIDER, ([this, slider, val_label](wxCommandEvent e) {
auto val = slider->GetValue();
m_values["custom_toolbar_size"] = (boost::format("%d") % val).str();
if (val_label)
val_label->SetLabelText(wxString::Format("%d", val));
}), slider->GetId());
for (wxWindow* win : std::vector<wxWindow*>{ slider, label, val_label }) {
if (!win) continue;
win->SetFont(wxGetApp().normal_font());
if (isOSX) continue; // under OSX we use wxBG_STYLE_ERASE
win->SetBackgroundStyle(wxBG_STYLE_PAINT);
}
m_optgroup->sizer->Add(m_icon_size_sizer, 0, wxEXPAND | wxALL, em);
}
} // GUI
} // Slic3r

View file

@ -16,6 +16,8 @@ class PreferencesDialog : public DPIDialog
{
std::map<std::string, std::string> m_values;
std::shared_ptr<ConfigOptionsGroup> m_optgroup;
wxSizer* m_icon_size_sizer;
bool isOSX {false};
public:
PreferencesDialog(wxWindow* parent);
~PreferencesDialog() {}
@ -25,6 +27,8 @@ public:
protected:
void on_dpi_changed(const wxRect &suggested_rect) override;
void layout();
void create_icon_size_slider();
};
} // GUI

View file

@ -526,9 +526,9 @@ DynamicPrintConfig PresetBundle::full_fff_config() const
opt->value = boost::algorithm::clamp<int>(opt->value, 0, int(num_extruders));
}
out.option<ConfigOptionString >("print_settings_id", true)->value = this->prints.get_selected_preset().name;
out.option<ConfigOptionString >("print_settings_id", true)->value = this->prints.get_selected_preset_name();
out.option<ConfigOptionStrings>("filament_settings_id", true)->values = this->filament_presets;
out.option<ConfigOptionString >("printer_settings_id", true)->value = this->printers.get_selected_preset().name;
out.option<ConfigOptionString >("printer_settings_id", true)->value = this->printers.get_selected_preset_name();
// Serialize the collected "compatible_printers_condition" and "inherits" fields.
// There will be 1 + num_exturders fields for "inherits" and 2 + num_extruders for "compatible_printers_condition" stored.
@ -577,9 +577,9 @@ DynamicPrintConfig PresetBundle::full_sla_config() const
out.erase("compatible_printers_condition");
out.erase("inherits");
out.option<ConfigOptionString >("sla_print_settings_id", true)->value = this->sla_prints.get_selected_preset().name;
out.option<ConfigOptionString >("sla_material_settings_id", true)->value = this->sla_materials.get_selected_preset().name;
out.option<ConfigOptionString >("printer_settings_id", true)->value = this->printers.get_selected_preset().name;
out.option<ConfigOptionString >("sla_print_settings_id", true)->value = this->sla_prints.get_selected_preset_name();
out.option<ConfigOptionString >("sla_material_settings_id", true)->value = this->sla_materials.get_selected_preset_name();
out.option<ConfigOptionString >("printer_settings_id", true)->value = this->printers.get_selected_preset_name();
// Serialize the collected "compatible_printers_condition" and "inherits" fields.
// There will be 1 + num_exturders fields for "inherits" and 2 + num_extruders for "compatible_printers_condition" stored.
@ -854,11 +854,11 @@ void PresetBundle::load_config_file_config_bundle(const std::string &path, const
collection_dst.load_preset(path, preset_name_dst, std::move(preset_src->config), activate).is_external = true;
return preset_name_dst;
};
load_one(this->prints, tmp_bundle.prints, tmp_bundle.prints .get_selected_preset().name, true);
load_one(this->sla_prints, tmp_bundle.sla_prints, tmp_bundle.sla_prints .get_selected_preset().name, true);
load_one(this->filaments, tmp_bundle.filaments, tmp_bundle.filaments .get_selected_preset().name, true);
load_one(this->sla_materials, tmp_bundle.sla_materials, tmp_bundle.sla_materials.get_selected_preset().name, true);
load_one(this->printers, tmp_bundle.printers, tmp_bundle.printers .get_selected_preset().name, true);
load_one(this->prints, tmp_bundle.prints, tmp_bundle.prints .get_selected_preset_name(), true);
load_one(this->sla_prints, tmp_bundle.sla_prints, tmp_bundle.sla_prints .get_selected_preset_name(), true);
load_one(this->filaments, tmp_bundle.filaments, tmp_bundle.filaments .get_selected_preset_name(), true);
load_one(this->sla_materials, tmp_bundle.sla_materials, tmp_bundle.sla_materials.get_selected_preset_name(), true);
load_one(this->printers, tmp_bundle.printers, tmp_bundle.printers .get_selected_preset_name(), true);
this->update_multi_material_filament_presets();
for (size_t i = 1; i < std::min(tmp_bundle.filament_presets.size(), this->filament_presets.size()); ++ i)
this->filament_presets[i] = load_one(this->filaments, tmp_bundle.filaments, tmp_bundle.filament_presets[i], false);
@ -1372,10 +1372,10 @@ void PresetBundle::export_configbundle(const std::string &path, bool export_syst
// Export the names of the active presets.
c << std::endl << "[presets]" << std::endl;
c << "print = " << this->prints.get_selected_preset().name << std::endl;
c << "sla_print = " << this->sla_prints.get_selected_preset().name << std::endl;
c << "sla_material = " << this->sla_materials.get_selected_preset().name << std::endl;
c << "printer = " << this->printers.get_selected_preset().name << std::endl;
c << "print = " << this->prints.get_selected_preset_name() << std::endl;
c << "sla_print = " << this->sla_prints.get_selected_preset_name() << std::endl;
c << "sla_material = " << this->sla_materials.get_selected_preset_name() << std::endl;
c << "printer = " << this->printers.get_selected_preset_name() << std::endl;
for (size_t i = 0; i < this->filament_presets.size(); ++ i) {
char suffix[64];
if (i > 0)

View file

@ -67,7 +67,7 @@ std::string PresetHints::maximum_volumetric_flow_description(const PresetBundle
int idx_extruder = 0;
int num_extruders = (int)preset_bundle.filament_presets.size();
for (; idx_extruder < num_extruders; ++ idx_extruder)
if (preset_bundle.filament_presets[idx_extruder] == preset_bundle.filaments.get_selected_preset().name)
if (preset_bundle.filament_presets[idx_extruder] == preset_bundle.filaments.get_selected_preset_name())
break;
if (idx_extruder == num_extruders)
// The current filament preset is not active for any extruder.

View file

@ -662,14 +662,28 @@ void Selection::scale(const Vec3d& scale, TransformationType transformation_type
{
GLVolume &volume = *(*m_volumes)[i];
if (is_single_full_instance()) {
assert(transformation_type.absolute());
if (transformation_type.world() && (std::abs(scale.x() - scale.y()) > EPSILON || std::abs(scale.x() - scale.z()) > EPSILON)) {
// Non-uniform scaling. Transform the scaling factors into the local coordinate system.
// This is only possible, if the instance rotation is mulitples of ninety degrees.
assert(Geometry::is_rotation_ninety_degrees(volume.get_instance_rotation()));
volume.set_instance_scaling_factor((volume.get_instance_transformation().get_matrix(true, false, true, true).matrix().block<3, 3>(0, 0).transpose() * scale).cwiseAbs());
} else
volume.set_instance_scaling_factor(scale);
if (transformation_type.relative())
{
Transform3d m = Geometry::assemble_transform(Vec3d::Zero(), Vec3d::Zero(), scale);
Eigen::Matrix<double, 3, 3, Eigen::DontAlign> new_matrix = (m * m_cache.volumes_data[i].get_instance_scale_matrix()).matrix().block(0, 0, 3, 3);
// extracts scaling factors from the composed transformation
Vec3d new_scale(new_matrix.col(0).norm(), new_matrix.col(1).norm(), new_matrix.col(2).norm());
if (transformation_type.joint())
volume.set_instance_offset(m_cache.dragging_center + m * (m_cache.volumes_data[i].get_instance_position() - m_cache.dragging_center));
volume.set_instance_scaling_factor(new_scale);
}
else
{
if (transformation_type.world() && (std::abs(scale.x() - scale.y()) > EPSILON || std::abs(scale.x() - scale.z()) > EPSILON)) {
// Non-uniform scaling. Transform the scaling factors into the local coordinate system.
// This is only possible, if the instance rotation is mulitples of ninety degrees.
assert(Geometry::is_rotation_ninety_degrees(volume.get_instance_rotation()));
volume.set_instance_scaling_factor((volume.get_instance_transformation().get_matrix(true, false, true, true).matrix().block<3, 3>(0, 0).transpose() * scale).cwiseAbs());
}
else
volume.set_instance_scaling_factor(scale);
}
}
else if (is_single_volume() || is_single_modifier())
volume.set_volume_scaling_factor(scale);
@ -713,6 +727,49 @@ void Selection::scale(const Vec3d& scale, TransformationType transformation_type
this->set_bounding_boxes_dirty();
}
void Selection::scale_to_fit_print_volume(const DynamicPrintConfig& config)
{
if (is_empty() || (m_mode == Volume))
return;
// adds 1/100th of a mm on all sides to avoid false out of print volume detections due to floating-point roundings
Vec3d box_size = get_bounding_box().size() + 0.01 * Vec3d::Ones();
const ConfigOptionPoints* opt = dynamic_cast<const ConfigOptionPoints*>(config.option("bed_shape"));
if (opt != nullptr)
{
BoundingBox bed_box_2D = get_extents(Polygon::new_scale(opt->values));
BoundingBoxf3 print_volume(Vec3d(unscale<double>(bed_box_2D.min(0)), unscale<double>(bed_box_2D.min(1)), 0.0), Vec3d(unscale<double>(bed_box_2D.max(0)), unscale<double>(bed_box_2D.max(1)), config.opt_float("max_print_height")));
Vec3d print_volume_size = print_volume.size();
double sx = (box_size(0) != 0.0) ? print_volume_size(0) / box_size(0) : 0.0;
double sy = (box_size(1) != 0.0) ? print_volume_size(1) / box_size(1) : 0.0;
double sz = (box_size(2) != 0.0) ? print_volume_size(2) / box_size(2) : 0.0;
if ((sx != 0.0) && (sy != 0.0) && (sz != 0.0))
{
double s = std::min(sx, std::min(sy, sz));
if (s != 1.0)
{
TransformationType type;
type.set_world();
type.set_relative();
type.set_joint();
// apply scale
start_dragging();
scale(s * Vec3d::Ones(), type);
wxGetApp().plater()->canvas3D()->do_scale();
// center selection on print bed
start_dragging();
translate(print_volume.center() - get_bounding_box().center());
wxGetApp().plater()->canvas3D()->do_move();
wxGetApp().obj_manipul()->set_dirty();
}
}
}
}
void Selection::mirror(Axis axis)
{
if (!m_valid)
@ -955,14 +1012,14 @@ void Selection::render(float scale_factor) const
}
#if ENABLE_RENDER_SELECTION_CENTER
void Selection::render_center() const
void Selection::render_center(bool gizmo_is_dragging) const
{
if (!m_valid || is_empty() || (m_quadric == nullptr))
return;
const Vec3d& center = get_bounding_box().center();
Vec3d center = gizmo_is_dragging ? m_cache.dragging_center : get_bounding_box().center();
glsafe(::glDisable(GL_DEPTH_TEST)));
glsafe(::glDisable(GL_DEPTH_TEST));
glsafe(::glEnable(GL_LIGHTING));
@ -1863,7 +1920,12 @@ void Selection::paste_objects_from_clipboard()
{
ModelObject* dst_object = m_model->add_object(*src_object);
double offset = wxGetApp().plater()->canvas3D()->get_size_proportional_to_max_bed_size(0.05);
dst_object->translate(offset, offset, 0.0);
Vec3d displacement(offset, offset, 0.0);
for (ModelInstance* inst : dst_object->instances)
{
inst->set_offset(inst->get_offset() + displacement);
}
object_idxs.push_back(m_model->objects.size() - 1);
}

View file

@ -5,6 +5,11 @@
#include "libslic3r/Geometry.hpp"
#include "3DScene.hpp"
#if ENABLE_RENDER_SELECTION_CENTER
class GLUquadric;
typedef class GLUquadric GLUquadricObj;
#endif // ENABLE_RENDER_SELECTION_CENTER
namespace Slic3r {
namespace GUI {
@ -282,6 +287,7 @@ public:
void rotate(const Vec3d& rotation, TransformationType transformation_type);
void flattening_rotate(const Vec3d& normal);
void scale(const Vec3d& scale, TransformationType transformation_type);
void scale_to_fit_print_volume(const DynamicPrintConfig& config);
void mirror(Axis axis);
void translate(unsigned int object_idx, const Vec3d& displacement);
@ -291,7 +297,7 @@ public:
void render(float scale_factor = 1.0) const;
#if ENABLE_RENDER_SELECTION_CENTER
void render_center() const;
void render_center(bool gizmo_is_dragging) const;
#endif // ENABLE_RENDER_SELECTION_CENTER
void render_sidebar_hints(const std::string& sidebar_field) const;

View file

@ -1235,16 +1235,41 @@ void TabPrint::update()
return; // ys_FIXME
// #ys_FIXME_to_delete
//! Temporary workaround for the correct updates of the SpinCtrl (like "perimeters"):
//! Temporary workaround for the correct updates of the TextCtrl (like "layer_height"):
// KillFocus() for the wxSpinCtrl use CallAfter function. So,
// to except the duplicate call of the update() after dialog->ShowModal(),
// let check if this process is already started.
// if (is_msg_dlg_already_exist) // ! It looks like a fixed problem after start to using of a m_dirty_options
// return; // ! TODO Let delete this part of code after a common aplication testing
if (is_msg_dlg_already_exist)
return;
m_update_cnt++;
// Freeze();
// layer_height shouldn't be equal to zero
if (m_config->opt_float("layer_height") < EPSILON)
{
const wxString msg_text = _(L("Zero layer height is not valid.\n\nThe layer height will be reset to 0.01."));
auto dialog = new wxMessageDialog(parent(), msg_text, _(L("Layer height")), wxICON_WARNING | wxOK);
DynamicPrintConfig new_conf = *m_config;
is_msg_dlg_already_exist = true;
dialog->ShowModal();
new_conf.set_key_value("layer_height", new ConfigOptionFloat(0.01));
load_config(new_conf);
is_msg_dlg_already_exist = false;
}
if (fabs(m_config->option<ConfigOptionFloatOrPercent>("first_layer_height")->value - 0) < EPSILON)
{
const wxString msg_text = _(L("Zero first layer height is not valid.\n\nThe first layer height will be reset to 0.01."));
auto dialog = new wxMessageDialog(parent(), msg_text, _(L("First layer height")), wxICON_WARNING | wxOK);
DynamicPrintConfig new_conf = *m_config;
is_msg_dlg_already_exist = true;
dialog->ShowModal();
new_conf.set_key_value("first_layer_height", new ConfigOptionFloatOrPercent(0.01, false));
load_config(new_conf);
is_msg_dlg_already_exist = false;
}
double fill_density = m_config->option<ConfigOptionPercent>("fill_density")->value;
if (m_config->opt_bool("spiral_vase") &&
@ -1258,7 +1283,6 @@ void TabPrint::update()
"- no ensure_vertical_shell_thickness\n"
"\nShall I adjust those settings in order to enable Spiral Vase?"));
auto dialog = new wxMessageDialog(parent(), msg_text, _(L("Spiral Vase")), wxICON_WARNING | wxYES | wxNO);
// is_msg_dlg_already_exist = true;
DynamicPrintConfig new_conf = *m_config;
if (dialog->ShowModal() == wxID_YES) {
new_conf.set_key_value("perimeters", new ConfigOptionInt(1));
@ -1274,7 +1298,6 @@ void TabPrint::update()
}
load_config(new_conf);
on_value_change("fill_density", fill_density);
// is_msg_dlg_already_exist = false;
}
if (m_config->opt_bool("wipe_tower") && m_config->opt_bool("support_material") &&
@ -2215,6 +2238,18 @@ void TabPrinter::build_unregular_pages()
* */
Freeze();
#ifdef __WXMSW__
/* Workaround for correct layout of controls inside the created page:
* In some _strange_ way we should we should imitate page resizing.
*/
auto layout_page = [this](PageShp page)
{
const wxSize& sz = page->GetSize();
page->SetSize(sz.x + 1, sz.y + 1);
page->SetSize(sz);
};
#endif //__WXMSW__
// Add/delete Kinematics page according to is_marlin_flavor
size_t existed_page = 0;
for (int i = n_before_extruders; i < m_pages.size(); ++i) // first make sure it's not there already
@ -2228,6 +2263,9 @@ void TabPrinter::build_unregular_pages()
if (existed_page < n_before_extruders && is_marlin_flavor) {
auto page = build_kinematics_page();
#ifdef __WXMSW__
layout_page(page);
#endif
m_pages.insert(m_pages.begin() + n_before_extruders, page);
}
@ -2299,6 +2337,10 @@ void TabPrinter::build_unregular_pages()
optgroup = page->new_optgroup(_(L("Preview")));
optgroup->append_single_option_line("extruder_colour", extruder_idx);
#ifdef __WXMSW__
layout_page(page);
#endif
}
// # remove extra pages

View file

@ -25,7 +25,7 @@ namespace Slic3r {
namespace GUI {
static const char* URL_CHANGELOG = "http://files.prusa3d.com/file/?type=slicerstable&lng=%1%";
static const char* URL_CHANGELOG = "http://files.prusa3d.com/?latest=slicer-stable&lng=%1%";
static const char* URL_DOWNLOAD = "https://www.prusa3d.com/downloads&lng=%1%";
static const char* URL_DEV = "https://github.com/prusa3d/PrusaSlicer/releases/tag/version_%1%";
@ -39,8 +39,7 @@ MsgUpdateSlic3r::MsgUpdateSlic3r(const Semver &ver_current, const Semver &ver_on
ver_current(ver_current),
ver_online(ver_online)
{
const auto version = Semver::parse(SLIC3R_VERSION);
const bool dev_version = version->prerelease() != nullptr || boost::algorithm::ends_with(SLIC3R_BUILD_ID, "UNKNOWN");
const bool dev_version = ver_online.prerelease() != nullptr;
auto *versions = new wxFlexGridSizer(2, 0, VERT_SPACING);
versions->Add(new wxStaticText(this, wxID_ANY, _(L("Current version:"))));
@ -119,7 +118,7 @@ MsgUpdateConfig::MsgUpdateConfig(const std::vector<Update> &updates) :
versions->Add(flex);
if (! update.changelog_url.empty()) {
if (! update.changelog_url.empty() && update.version.prerelease() == nullptr) {
auto *line = new wxBoxSizer(wxHORIZONTAL);
auto changelog_url = (boost::format(update.changelog_url) % lang_code).str();
line->AddSpacer(3*VERT_SPACING);

View file

@ -2557,6 +2557,11 @@ ModeSizer::ModeSizer(wxWindow *parent, int hgap/* = 10*/) :
{_(L("Expert")), "mode_expert_sq.png"}
};
auto modebtnfn = [](wxCommandEvent &event, int mode_id) {
Slic3r::GUI::wxGetApp().save_mode(mode_id);
event.Skip();
};
m_mode_btns.reserve(3);
for (const auto& button : buttons) {
#ifdef __WXOSX__
@ -2567,37 +2572,22 @@ ModeSizer::ModeSizer(wxWindow *parent, int hgap/* = 10*/) :
#else
m_mode_btns.push_back(new ModeButton(parent, wxID_ANY, button.second, button.first));;
#endif // __WXOSX__
m_mode_btns.back()->Bind(wxEVT_BUTTON, std::bind(modebtnfn, std::placeholders::_1, m_mode_btns.size() - 1));
Add(m_mode_btns.back());
}
for (auto btn : m_mode_btns)
{
btn->Bind(wxEVT_BUTTON, [btn, this](wxCommandEvent &event) {
event.Skip();
int mode_id = 0;
for (auto cur_btn : m_mode_btns) {
if (cur_btn == btn)
break;
else
mode_id++;
}
Slic3r::GUI::wxGetApp().save_mode(mode_id);
});
Add(btn);
}
}
void ModeSizer::SetMode(const int mode)
{
for (int m = 0; m < m_mode_btns.size(); m++)
m_mode_btns[m]->SetState(m == mode);
for (size_t m = 0; m < m_mode_btns.size(); m++)
m_mode_btns[m]->SetState(int(m) == mode);
}
void ModeSizer::msw_rescale()
{
for (int m = 0; m < m_mode_btns.size(); m++)
for (size_t m = 0; m < m_mode_btns.size(); m++)
m_mode_btns[m]->msw_rescale();
}