This commit is contained in:
enricoturri1966 2020-12-15 15:57:32 +01:00
commit 9704eb6ece
12 changed files with 62 additions and 24 deletions

View file

@ -1020,6 +1020,12 @@ bool load_amf_archive(const char* path, DynamicPrintConfig* config, Model* model
#endif // forward compatibility
close_zip_reader(&archive);
for (ModelObject *o : model->objects)
for (ModelVolume *v : o->volumes)
if (v->source.input_file.empty() && (v->type() == ModelVolumeType::MODEL_PART))
v->source.input_file = path;
return true;
}

View file

@ -1849,6 +1849,13 @@ void PhysicalPrinterCollection::select_printer(const std::string& full_name)
m_selected_preset = it->get_preset_name(full_name);
}
void PhysicalPrinterCollection::select_printer(const std::string& printer_name, const std::string& preset_name)
{
if (preset_name.empty())
return select_printer(printer_name);
return select_printer(printer_name + PhysicalPrinter::separator() + preset_name);
}
void PhysicalPrinterCollection::select_printer(const PhysicalPrinter& printer)
{
return select_printer(printer.name);

View file

@ -701,6 +701,7 @@ public:
// If full_name doesn't contain name of selected preset, then select first preset in the list for this printer
void select_printer(const std::string& full_name);
void select_printer(const PhysicalPrinter& printer);
void select_printer(const std::string& printer_name, const std::string& preset_name);
bool has_selection() const;
void unselect_printer() ;
bool is_selected(ConstIterator it, const std::string &preset_name) const;

View file

@ -876,7 +876,7 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool
// Activate the physical printer profile if possible.
PhysicalPrinter *pp = this->physical_printers.find_printer(physical_printer, true);
if (pp != nullptr && std::find(pp->preset_names.begin(), pp->preset_names.end(), this->printers.get_edited_preset().name) != pp->preset_names.end())
this->physical_printers.select_printer(*pp);
this->physical_printers.select_printer(pp->name, this->printers.get_edited_preset().name);
else
this->physical_printers.unselect_printer();
}
@ -1396,7 +1396,7 @@ size_t PresetBundle::load_configbundle(const std::string &path, unsigned int fla
if (! active_printer.empty())
printers.select_preset_by_name(active_printer, true);
if (! active_physical_printer.empty())
physical_printers.select_printer(active_physical_printer +" * " + active_printer);
physical_printers.select_printer(active_physical_printer, active_printer);
// Activate the first filament preset.
if (! active_filaments.empty() && ! active_filaments.front().empty())
filaments.select_preset_by_name(active_filaments.front(), true);

View file

@ -184,13 +184,13 @@ void PrintConfigDef::init_fff_params()
def->mode = comExpert;
def->set_default_value(new ConfigOptionBool(false));
def = this->add("avoid_crossing_perimeters_max_detour", coFloat);
def = this->add("avoid_crossing_perimeters_max_detour", coFloatOrPercent);
def->label = L("Avoid crossing perimeters - Max detour length");
def->category = L("Layers and Perimeters");
def->tooltip = L("The maximum detour length for avoid crossing perimeters. "
"If the detour is longer than this value, avoid crossing perimeters is not applied for this travel path. "
"Detour length could be specified either as an absolute value or as percentage (for example 50%) of a direct travel path.");
def->sidetext = L("mm (zero to disable)");
def->sidetext = L("mm or % (zero to disable)");
def->min = 0;
def->mode = comExpert;
def->set_default_value(new ConfigOptionFloatOrPercent(0., false));

View file

@ -86,6 +86,13 @@ static const size_t VERTEX_BUFFER_RESERVE_SIZE_SUM_MAX = 1024 * 1024 * 128 / 4;
namespace Slic3r {
namespace GUI {
#ifdef __WXGTK3__
// wxGTK3 seems to simulate OSX behavior in regard to HiDPI scaling support.
RetinaHelper::RetinaHelper(wxWindow* window) : m_window(window), m_self(nullptr) {}
RetinaHelper::~RetinaHelper() {}
float RetinaHelper::get_scale_factor() { return float(m_window->GetContentScaleFactor()); }
#endif // __WXGTK3__
Size::Size()
: m_width(0)
, m_height(0)
@ -3732,7 +3739,8 @@ void GLCanvas3D::update_ui_from_settings()
{
m_dirty = true;
#if ENABLE_RETINA_GL
#if __APPLE__
// Update OpenGL scaling on OSX after the user toggled the "use_retina_opengl" settings in Preferences dialog.
const float orig_scaling = m_retina_helper->get_scale_factor();
const bool use_retina = wxGetApp().app_config->get("use_retina_opengl") == "1";

View file

@ -31,8 +31,9 @@ class wxPaintEvent;
class wxGLCanvas;
class wxGLContext;
// Support for Retina OpenGL on Mac OS
#define ENABLE_RETINA_GL __APPLE__
// Support for Retina OpenGL on Mac OS.
// wxGTK3 seems to simulate OSX behavior in regard to HiDPI scaling support, enable it as well.
#define ENABLE_RETINA_GL (__APPLE__ || __WXGTK3__)
namespace Slic3r {

View file

@ -963,6 +963,8 @@ void ImGuiWrapper::init_font(bool compress)
// Fill rectangles from the SVG-icons
for (auto icon : font_icons) {
if (const ImFontAtlas::CustomRect* rect = io.Fonts->GetCustomRectByIndex(rect_id)) {
assert(rect->Width == icon_sz);
assert(rect->Height == icon_sz);
std::vector<unsigned char> raw_data = load_svg(icon.second, icon_sz, icon_sz);
const ImU32* pIn = (ImU32*)raw_data.data();
for (int y = 0; y < icon_sz; y++) {
@ -973,10 +975,12 @@ void ImGuiWrapper::init_font(bool compress)
}
rect_id++;
}
icon_sz = lround(32 * font_scale); // default size of large icon is 32 px
icon_sz *= 2; // default size of large icon is 32 px
for (auto icon : font_icons_large) {
if (const ImFontAtlas::CustomRect* rect = io.Fonts->GetCustomRectByIndex(rect_id)) {
assert(rect->Width == icon_sz);
assert(rect->Height == icon_sz);
std::vector<unsigned char> raw_data = load_svg(icon.second, icon_sz, icon_sz);
const ImU32* pIn = (ImU32*)raw_data.data();
for (int y = 0; y < icon_sz; y++) {

View file

@ -228,7 +228,8 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S
// OSX specific issue:
// When we move application between Retina and non-Retina displays, The legend on a canvas doesn't redraw
// So, redraw explicitly canvas, when application is moved
#if ENABLE_RETINA_GL
//FIXME maybe this is useful for __WXGTK3__ as well?
#if __APPLE__
Bind(wxEVT_MOVE, [this](wxMoveEvent& event) {
wxGetApp().plater()->get_current_canvas3D()->set_as_dirty();
wxGetApp().plater()->get_current_canvas3D()->request_extra_frame();

View file

@ -346,7 +346,6 @@ bool Mouse3DController::State::apply(const Mouse3DController::Params &params, Ca
if (params.swap_yz)
rot = Vec3d(rot.x(), -rot.z(), rot.y());
camera.rotate_local_around_target(Vec3d(rot.x(), - rot.z(), rot.y()));
break;
} else {
assert(input_queue_item.is_buttons());
switch (input_queue_item.type_or_buttons) {
@ -895,7 +894,10 @@ bool Mouse3DController::connect_device()
if (device.second.size() == 1) {
#if defined(__linux__)
hid_device* test_device = hid_open(device.first.first, device.first.second, nullptr);
if (test_device != nullptr) {
if (test_device == nullptr) {
BOOST_LOG_TRIVIAL(error) << "3DConnexion device cannot be opened: " << device.second.front().path <<
" You may need to update /etc/udev/rules.d";
} else {
hid_close(test_device);
#else
if (device.second.front().has_valid_usage()) {
@ -940,10 +942,13 @@ bool Mouse3DController::connect_device()
break;
}
#endif // __linux__
else {
BOOST_LOG_TRIVIAL(error) << "3DConnexion device cannot be opened: " << data.path <<
" You may need to update /etc/udev/rules.d";
#if ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT
else
std::cout << "-> NOT PASSED" << std::endl;
#endif // ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT
}
}
if (found)

View file

@ -2398,7 +2398,7 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
auto convert_from_imperial_units = [](Model& model, bool only_small_volumes) {
model.convert_from_imperial_units(only_small_volumes);
wxGetApp().app_config->set("use_inches", "1");
// wxGetApp().app_config->set("use_inches", "1");
wxGetApp().sidebar().update_ui_from_settings();
};

View file

@ -51,7 +51,12 @@ static std::string get_icon_name(Preset::Type type, PrinterTechnology pt) {
return pt == ptSLA && type == Preset::TYPE_PRINTER ? "sla_printer" : type_icon_names.at(type);
}
static std::string black = "#000000";
static std::string def_text_color()
{
wxColour def_colour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
auto clr_str = wxString::Format(wxT("#%02X%02X%02X"), def_colour.Red(), def_colour.Green(), def_colour.Blue());
return clr_str.ToStdString();
}
static std::string grey = "#808080";
static std::string orange = "#ed6b21";
@ -158,7 +163,7 @@ ModelNode::ModelNode(ModelNode* parent, const wxString& text, const wxString& ol
}
// "color" strings
color_string(m_old_value, black);
color_string(m_old_value, def_text_color());
color_string(m_new_value, orange);
UpdateIcons();
@ -176,13 +181,13 @@ void ModelNode::UpdateEnabling()
};
if (!m_toggle) {
change_text_color(m_text, black, grey);
change_text_color(m_old_value, black, grey);
change_text_color(m_text, def_text_color(), grey);
change_text_color(m_old_value, def_text_color(), grey);
change_text_color(m_new_value, orange,grey);
}
else {
change_text_color(m_text, grey, black);
change_text_color(m_old_value, grey, black);
change_text_color(m_text, grey, def_text_color());
change_text_color(m_old_value, grey, def_text_color());
change_text_color(m_new_value, grey, orange);
}
// update icons for the colors
@ -227,7 +232,7 @@ UnsavedChangesModel::~UnsavedChangesModel()
wxDataViewItem UnsavedChangesModel::AddPreset(Preset::Type type, wxString preset_name, PrinterTechnology pt)
{
// "color" strings
color_string(preset_name, black);
color_string(preset_name, def_text_color());
make_string_bold(preset_name);
auto preset = new ModelNode(type, m_parent_win, preset_name, get_icon_name(type, pt));
@ -274,9 +279,9 @@ wxDataViewItem UnsavedChangesModel::AddOption(Preset::Type type, wxString catego
wxString old_value, wxString new_value, const std::string category_icon_name)
{
// "color" strings
color_string(category_name, black);
color_string(group_name, black);
color_string(option_name, black);
color_string(category_name, def_text_color());
color_string(group_name, def_text_color());
color_string(option_name, def_text_color());
// "make" strings bold
make_string_bold(category_name);