mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-26 02:01:12 -06:00
Merge branch 'master' of https://github.com/prusa3d/PrusaSlicer into et_gcode_viewer
This commit is contained in:
commit
dea641183c
62 changed files with 3519 additions and 1865 deletions
|
|
@ -12,8 +12,6 @@ set(SLIC3R_GUI_SOURCES
|
|||
GUI/SysInfoDialog.hpp
|
||||
GUI/KBShortcutsDialog.cpp
|
||||
GUI/KBShortcutsDialog.hpp
|
||||
GUI/AppConfig.cpp
|
||||
GUI/AppConfig.hpp
|
||||
GUI/BackgroundSlicingProcess.cpp
|
||||
GUI/BackgroundSlicingProcess.hpp
|
||||
GUI/BitmapCache.cpp
|
||||
|
|
@ -67,10 +65,6 @@ set(SLIC3R_GUI_SOURCES
|
|||
GUI/GCodeViewer.cpp
|
||||
GUI/Preferences.cpp
|
||||
GUI/Preferences.hpp
|
||||
GUI/Preset.cpp
|
||||
GUI/Preset.hpp
|
||||
GUI/PresetBundle.cpp
|
||||
GUI/PresetBundle.hpp
|
||||
GUI/PresetHints.cpp
|
||||
GUI/PresetHints.hpp
|
||||
GUI/GUI.cpp
|
||||
|
|
@ -87,6 +81,10 @@ set(SLIC3R_GUI_SOURCES
|
|||
GUI/MainFrame.hpp
|
||||
GUI/Plater.cpp
|
||||
GUI/Plater.hpp
|
||||
GUI/PresetComboBoxes.hpp
|
||||
GUI/PresetComboBoxes.cpp
|
||||
GUI/PhysicalPrinterDialog.hpp
|
||||
GUI/PhysicalPrinterDialog.cpp
|
||||
GUI/GUI_ObjectList.cpp
|
||||
GUI/GUI_ObjectList.hpp
|
||||
GUI/GUI_ObjectManipulation.cpp
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
#include "Snapshot.hpp"
|
||||
#include "../GUI/AppConfig.hpp"
|
||||
#include "../GUI/PresetBundle.hpp"
|
||||
|
||||
#include <time.h>
|
||||
|
||||
|
|
@ -11,7 +9,7 @@
|
|||
#include <boost/property_tree/ptree_fwd.hpp>
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
|
||||
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
#include "libslic3r/libslic3r.h"
|
||||
#include "libslic3r/Time.hpp"
|
||||
#include "libslic3r/Config.hpp"
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
#endif // ENABLE_GCODE_VIEWER
|
||||
|
||||
#include "GUI_App.hpp"
|
||||
#include "PresetBundle.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
#include "GLCanvas3D.hpp"
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
#include "3DScene.hpp"
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@
|
|||
#include "GUI_App.hpp"
|
||||
#if ENABLE_ENVIRONMENT_MAP
|
||||
#include "Plater.hpp"
|
||||
#include "AppConfig.hpp"
|
||||
#endif // ENABLE_ENVIRONMENT_MAP
|
||||
|
||||
#include "libslic3r/ExtrusionEntity.hpp"
|
||||
|
|
@ -29,6 +28,7 @@
|
|||
#include "slic3r/GUI/BitmapCache.hpp"
|
||||
#include "libslic3r/Format/STL.hpp"
|
||||
#include "libslic3r/Utils.hpp"
|
||||
#include "libslic3r/AppConfig.hpp"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
|
|
|||
|
|
@ -1,397 +0,0 @@
|
|||
#include "libslic3r/libslic3r.h"
|
||||
#include "libslic3r/Utils.hpp"
|
||||
#include "AppConfig.hpp"
|
||||
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <stdexcept>
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <boost/nowide/cenv.hpp>
|
||||
#include <boost/nowide/fstream.hpp>
|
||||
#include <boost/property_tree/ini_parser.hpp>
|
||||
#include <boost/property_tree/ptree_fwd.hpp>
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <boost/format/format_fwd.hpp>
|
||||
|
||||
#include <wx/string.h>
|
||||
#include "I18N.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
static const std::string VENDOR_PREFIX = "vendor:";
|
||||
static const std::string MODEL_PREFIX = "model:";
|
||||
static const std::string VERSION_CHECK_URL = "https://files.prusa3d.com/wp-content/uploads/repository/PrusaSlicer-settings-master/live/PrusaSlicer.version";
|
||||
|
||||
const std::string AppConfig::SECTION_FILAMENTS = "filaments";
|
||||
const std::string AppConfig::SECTION_MATERIALS = "sla_materials";
|
||||
|
||||
void AppConfig::reset()
|
||||
{
|
||||
m_storage.clear();
|
||||
set_defaults();
|
||||
};
|
||||
|
||||
// Override missing or keys with their defaults.
|
||||
void AppConfig::set_defaults()
|
||||
{
|
||||
// Reset the empty fields to defaults.
|
||||
if (get("autocenter").empty())
|
||||
set("autocenter", "0");
|
||||
// Disable background processing by default as it is not stable.
|
||||
if (get("background_processing").empty())
|
||||
set("background_processing", "0");
|
||||
// If set, the "Controller" tab for the control of the printer over serial line and the serial port settings are hidden.
|
||||
// By default, Prusa has the controller hidden.
|
||||
if (get("no_controller").empty())
|
||||
set("no_controller", "1");
|
||||
// If set, the "- default -" selections of print/filament/printer are suppressed, if there is a valid preset available.
|
||||
if (get("no_defaults").empty())
|
||||
set("no_defaults", "1");
|
||||
if (get("show_incompatible_presets").empty())
|
||||
set("show_incompatible_presets", "0");
|
||||
|
||||
if (get("version_check").empty())
|
||||
set("version_check", "1");
|
||||
if (get("preset_update").empty())
|
||||
set("preset_update", "1");
|
||||
|
||||
if (get("export_sources_full_pathnames").empty())
|
||||
set("export_sources_full_pathnames", "0");
|
||||
|
||||
// remove old 'use_legacy_opengl' parameter from this config, if present
|
||||
if (!get("use_legacy_opengl").empty())
|
||||
erase("", "use_legacy_opengl");
|
||||
|
||||
#ifdef __APPLE__
|
||||
if (get("use_retina_opengl").empty())
|
||||
set("use_retina_opengl", "1");
|
||||
#endif
|
||||
|
||||
if (get("single_instance").empty())
|
||||
set("single_instance", "0");
|
||||
|
||||
if (get("remember_output_path").empty())
|
||||
set("remember_output_path", "1");
|
||||
|
||||
if (get("remember_output_path_removable").empty())
|
||||
set("remember_output_path_removable", "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");
|
||||
|
||||
if (get("auto_toolbar_size").empty())
|
||||
set("auto_toolbar_size", "100");
|
||||
|
||||
if (get("use_perspective_camera").empty())
|
||||
set("use_perspective_camera", "1");
|
||||
|
||||
if (get("use_free_camera").empty())
|
||||
set("use_free_camera", "0");
|
||||
|
||||
#if ENABLE_ENVIRONMENT_MAP
|
||||
if (get("use_environment_map").empty())
|
||||
set("use_environment_map", "0");
|
||||
#endif // ENABLE_ENVIRONMENT_MAP
|
||||
|
||||
if (get("use_inches").empty())
|
||||
set("use_inches", "0");
|
||||
|
||||
// Remove legacy window positions/sizes
|
||||
erase("", "main_frame_maximized");
|
||||
erase("", "main_frame_pos");
|
||||
erase("", "main_frame_size");
|
||||
erase("", "object_settings_maximized");
|
||||
erase("", "object_settings_pos");
|
||||
erase("", "object_settings_size");
|
||||
}
|
||||
|
||||
void AppConfig::load()
|
||||
{
|
||||
// 1) Read the complete config file into a boost::property_tree.
|
||||
namespace pt = boost::property_tree;
|
||||
pt::ptree tree;
|
||||
boost::nowide::ifstream ifs(AppConfig::config_path());
|
||||
try {
|
||||
pt::read_ini(ifs, tree);
|
||||
} catch (pt::ptree_error& ex) {
|
||||
// Error while parsing config file. We'll customize the error message and rethrow to be displayed.
|
||||
throw std::runtime_error(
|
||||
_utf8(L("Error parsing PrusaSlicer config file, it is probably corrupted. "
|
||||
"Try to manually delete the file to recover from the error. Your user profiles will not be affected.")) +
|
||||
"\n\n" + AppConfig::config_path() + "\n\n" + ex.what());
|
||||
}
|
||||
|
||||
// 2) Parse the property_tree, extract the sections and key / value pairs.
|
||||
for (const auto §ion : tree) {
|
||||
if (section.second.empty()) {
|
||||
// This may be a top level (no section) entry, or an empty section.
|
||||
std::string data = section.second.data();
|
||||
if (! data.empty())
|
||||
// If there is a non-empty data, then it must be a top-level (without a section) config entry.
|
||||
m_storage[""][section.first] = data;
|
||||
} else if (boost::starts_with(section.first, VENDOR_PREFIX)) {
|
||||
// This is a vendor section listing enabled model / variants
|
||||
const auto vendor_name = section.first.substr(VENDOR_PREFIX.size());
|
||||
auto &vendor = m_vendors[vendor_name];
|
||||
for (const auto &kvp : section.second) {
|
||||
if (! boost::starts_with(kvp.first, MODEL_PREFIX)) { continue; }
|
||||
const auto model_name = kvp.first.substr(MODEL_PREFIX.size());
|
||||
std::vector<std::string> variants;
|
||||
if (! unescape_strings_cstyle(kvp.second.data(), variants)) { continue; }
|
||||
for (const auto &variant : variants) {
|
||||
vendor[model_name].insert(variant);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// This must be a section name. Read the entries of a section.
|
||||
std::map<std::string, std::string> &storage = m_storage[section.first];
|
||||
for (auto &kvp : section.second)
|
||||
storage[kvp.first] = kvp.second.data();
|
||||
}
|
||||
}
|
||||
|
||||
// Figure out if datadir has legacy presets
|
||||
auto ini_ver = Semver::parse(get("version"));
|
||||
m_legacy_datadir = false;
|
||||
if (ini_ver) {
|
||||
m_orig_version = *ini_ver;
|
||||
// Make 1.40.0 alphas compare well
|
||||
ini_ver->set_metadata(boost::none);
|
||||
ini_ver->set_prerelease(boost::none);
|
||||
m_legacy_datadir = ini_ver < Semver(1, 40, 0);
|
||||
}
|
||||
|
||||
// Override missing or keys with their defaults.
|
||||
this->set_defaults();
|
||||
m_dirty = false;
|
||||
}
|
||||
|
||||
void AppConfig::save()
|
||||
{
|
||||
// The config is first written to a file with a PID suffix and then moved
|
||||
// to avoid race conditions with multiple instances of Slic3r
|
||||
const auto path = config_path();
|
||||
std::string path_pid = (boost::format("%1%.%2%") % path % get_current_pid()).str();
|
||||
|
||||
boost::nowide::ofstream c;
|
||||
c.open(path_pid, std::ios::out | std::ios::trunc);
|
||||
c << "# " << Slic3r::header_slic3r_generated() << std::endl;
|
||||
// Make sure the "no" category is written first.
|
||||
for (const std::pair<std::string, std::string> &kvp : m_storage[""])
|
||||
c << kvp.first << " = " << kvp.second << std::endl;
|
||||
// Write the other categories.
|
||||
for (const auto category : m_storage) {
|
||||
if (category.first.empty())
|
||||
continue;
|
||||
c << std::endl << "[" << category.first << "]" << std::endl;
|
||||
for (const std::pair<std::string, std::string> &kvp : category.second)
|
||||
c << kvp.first << " = " << kvp.second << std::endl;
|
||||
}
|
||||
// Write vendor sections
|
||||
for (const auto &vendor : m_vendors) {
|
||||
size_t size_sum = 0;
|
||||
for (const auto &model : vendor.second) { size_sum += model.second.size(); }
|
||||
if (size_sum == 0) { continue; }
|
||||
|
||||
c << std::endl << "[" << VENDOR_PREFIX << vendor.first << "]" << std::endl;
|
||||
|
||||
for (const auto &model : vendor.second) {
|
||||
if (model.second.size() == 0) { continue; }
|
||||
const std::vector<std::string> variants(model.second.begin(), model.second.end());
|
||||
const auto escaped = escape_strings_cstyle(variants);
|
||||
c << MODEL_PREFIX << model.first << " = " << escaped << std::endl;
|
||||
}
|
||||
}
|
||||
c.close();
|
||||
|
||||
rename_file(path_pid, path);
|
||||
m_dirty = false;
|
||||
}
|
||||
|
||||
bool AppConfig::get_variant(const std::string &vendor, const std::string &model, const std::string &variant) const
|
||||
{
|
||||
const auto it_v = m_vendors.find(vendor);
|
||||
if (it_v == m_vendors.end()) { return false; }
|
||||
const auto it_m = it_v->second.find(model);
|
||||
return it_m == it_v->second.end() ? false : it_m->second.find(variant) != it_m->second.end();
|
||||
}
|
||||
|
||||
void AppConfig::set_variant(const std::string &vendor, const std::string &model, const std::string &variant, bool enable)
|
||||
{
|
||||
if (enable) {
|
||||
if (get_variant(vendor, model, variant)) { return; }
|
||||
m_vendors[vendor][model].insert(variant);
|
||||
} else {
|
||||
auto it_v = m_vendors.find(vendor);
|
||||
if (it_v == m_vendors.end()) { return; }
|
||||
auto it_m = it_v->second.find(model);
|
||||
if (it_m == it_v->second.end()) { return; }
|
||||
auto it_var = it_m->second.find(variant);
|
||||
if (it_var == it_m->second.end()) { return; }
|
||||
it_m->second.erase(it_var);
|
||||
}
|
||||
// If we got here, there was an update
|
||||
m_dirty = true;
|
||||
}
|
||||
|
||||
void AppConfig::set_vendors(const AppConfig &from)
|
||||
{
|
||||
m_vendors = from.m_vendors;
|
||||
m_dirty = true;
|
||||
}
|
||||
|
||||
std::string AppConfig::get_last_dir() const
|
||||
{
|
||||
const auto it = m_storage.find("recent");
|
||||
if (it != m_storage.end()) {
|
||||
{
|
||||
const auto it2 = it->second.find("skein_directory");
|
||||
if (it2 != it->second.end() && ! it2->second.empty())
|
||||
return it2->second;
|
||||
}
|
||||
{
|
||||
const auto it2 = it->second.find("config_directory");
|
||||
if (it2 != it->second.end() && ! it2->second.empty())
|
||||
return it2->second;
|
||||
}
|
||||
}
|
||||
return std::string();
|
||||
}
|
||||
|
||||
std::vector<std::string> AppConfig::get_recent_projects() const
|
||||
{
|
||||
std::vector<std::string> ret;
|
||||
const auto it = m_storage.find("recent_projects");
|
||||
if (it != m_storage.end())
|
||||
{
|
||||
for (const std::map<std::string, std::string>::value_type& item : it->second)
|
||||
{
|
||||
ret.push_back(item.second);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void AppConfig::set_recent_projects(const std::vector<std::string>& recent_projects)
|
||||
{
|
||||
auto it = m_storage.find("recent_projects");
|
||||
if (it == m_storage.end())
|
||||
it = m_storage.insert(std::map<std::string, std::map<std::string, std::string>>::value_type("recent_projects", std::map<std::string, std::string>())).first;
|
||||
|
||||
it->second.clear();
|
||||
for (unsigned int i = 0; i < (unsigned int)recent_projects.size(); ++i)
|
||||
{
|
||||
it->second[std::to_string(i + 1)] = recent_projects[i];
|
||||
}
|
||||
}
|
||||
|
||||
void AppConfig::set_mouse_device(const std::string& name, double translation_speed, double translation_deadzone, float rotation_speed, float rotation_deadzone, double zoom_speed, bool swap_yz)
|
||||
{
|
||||
std::string key = std::string("mouse_device:") + name;
|
||||
auto it = m_storage.find(key);
|
||||
if (it == m_storage.end())
|
||||
it = m_storage.insert(std::map<std::string, std::map<std::string, std::string>>::value_type(key, std::map<std::string, std::string>())).first;
|
||||
|
||||
it->second.clear();
|
||||
it->second["translation_speed"] = std::to_string(translation_speed);
|
||||
it->second["translation_deadzone"] = std::to_string(translation_deadzone);
|
||||
it->second["rotation_speed"] = std::to_string(rotation_speed);
|
||||
it->second["rotation_deadzone"] = std::to_string(rotation_deadzone);
|
||||
it->second["zoom_speed"] = std::to_string(zoom_speed);
|
||||
it->second["swap_yz"] = swap_yz ? "1" : "0";
|
||||
}
|
||||
|
||||
std::vector<std::string> AppConfig::get_mouse_device_names() const
|
||||
{
|
||||
static constexpr const char *prefix = "mouse_device:";
|
||||
static const size_t prefix_len = strlen(prefix);
|
||||
std::vector<std::string> out;
|
||||
for (const std::pair<std::string, std::map<std::string, std::string>>& key_value_pair : m_storage)
|
||||
if (boost::starts_with(key_value_pair.first, prefix) && key_value_pair.first.size() > prefix_len)
|
||||
out.emplace_back(key_value_pair.first.substr(prefix_len));
|
||||
return out;
|
||||
}
|
||||
|
||||
void AppConfig::update_config_dir(const std::string &dir)
|
||||
{
|
||||
this->set("recent", "config_directory", dir);
|
||||
}
|
||||
|
||||
void AppConfig::update_skein_dir(const std::string &dir)
|
||||
{
|
||||
this->set("recent", "skein_directory", dir);
|
||||
}
|
||||
/*
|
||||
std::string AppConfig::get_last_output_dir(const std::string &alt) const
|
||||
{
|
||||
|
||||
const auto it = m_storage.find("");
|
||||
if (it != m_storage.end()) {
|
||||
const auto it2 = it->second.find("last_output_path");
|
||||
const auto it3 = it->second.find("remember_output_path");
|
||||
if (it2 != it->second.end() && it3 != it->second.end() && ! it2->second.empty() && it3->second == "1")
|
||||
return it2->second;
|
||||
}
|
||||
return alt;
|
||||
}
|
||||
|
||||
void AppConfig::update_last_output_dir(const std::string &dir)
|
||||
{
|
||||
this->set("", "last_output_path", dir);
|
||||
}
|
||||
*/
|
||||
std::string AppConfig::get_last_output_dir(const std::string& alt, const bool removable) const
|
||||
{
|
||||
std::string s1 = (removable ? "last_output_path_removable" : "last_output_path");
|
||||
std::string s2 = (removable ? "remember_output_path_removable" : "remember_output_path");
|
||||
const auto it = m_storage.find("");
|
||||
if (it != m_storage.end()) {
|
||||
const auto it2 = it->second.find(s1);
|
||||
const auto it3 = it->second.find(s2);
|
||||
if (it2 != it->second.end() && it3 != it->second.end() && !it2->second.empty() && it3->second == "1")
|
||||
return it2->second;
|
||||
}
|
||||
return alt;
|
||||
}
|
||||
|
||||
void AppConfig::update_last_output_dir(const std::string& dir, const bool removable)
|
||||
{
|
||||
this->set("", (removable ? "last_output_path_removable" : "last_output_path"), dir);
|
||||
}
|
||||
|
||||
|
||||
void AppConfig::reset_selections()
|
||||
{
|
||||
auto it = m_storage.find("presets");
|
||||
if (it != m_storage.end()) {
|
||||
it->second.erase("print");
|
||||
it->second.erase("filament");
|
||||
it->second.erase("sla_print");
|
||||
it->second.erase("sla_material");
|
||||
it->second.erase("printer");
|
||||
m_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
std::string AppConfig::config_path()
|
||||
{
|
||||
return (boost::filesystem::path(Slic3r::data_dir()) / (SLIC3R_APP_KEY ".ini")).make_preferred().string();
|
||||
}
|
||||
|
||||
std::string AppConfig::version_check_url() const
|
||||
{
|
||||
auto from_settings = get("version_check_url");
|
||||
return from_settings.empty() ? VERSION_CHECK_URL : from_settings;
|
||||
}
|
||||
|
||||
bool AppConfig::exists()
|
||||
{
|
||||
return boost::filesystem::exists(AppConfig::config_path());
|
||||
}
|
||||
|
||||
}; // namespace Slic3r
|
||||
|
|
@ -1,191 +0,0 @@
|
|||
#ifndef slic3r_AppConfig_hpp_
|
||||
#define slic3r_AppConfig_hpp_
|
||||
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include <boost/algorithm/string/trim_all.hpp>
|
||||
|
||||
#include "libslic3r/Config.hpp"
|
||||
#include "libslic3r/Semver.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
class AppConfig
|
||||
{
|
||||
public:
|
||||
AppConfig() :
|
||||
m_dirty(false),
|
||||
m_orig_version(Semver::invalid()),
|
||||
m_legacy_datadir(false)
|
||||
{
|
||||
this->reset();
|
||||
}
|
||||
|
||||
// Clear and reset to defaults.
|
||||
void reset();
|
||||
// Override missing or keys with their defaults.
|
||||
void set_defaults();
|
||||
|
||||
// Load the slic3r.ini from a user profile directory (or a datadir, if configured).
|
||||
void load();
|
||||
// Store the slic3r.ini into a user profile directory (or a datadir, if configured).
|
||||
void save();
|
||||
|
||||
// Does this config need to be saved?
|
||||
bool dirty() const { return m_dirty; }
|
||||
|
||||
// Const accessor, it will return false if a section or a key does not exist.
|
||||
bool get(const std::string §ion, const std::string &key, std::string &value) const
|
||||
{
|
||||
value.clear();
|
||||
auto it = m_storage.find(section);
|
||||
if (it == m_storage.end())
|
||||
return false;
|
||||
auto it2 = it->second.find(key);
|
||||
if (it2 == it->second.end())
|
||||
return false;
|
||||
value = it2->second;
|
||||
return true;
|
||||
}
|
||||
std::string get(const std::string §ion, const std::string &key) const
|
||||
{ std::string value; this->get(section, key, value); return value; }
|
||||
std::string get(const std::string &key) const
|
||||
{ std::string value; this->get("", key, value); return value; }
|
||||
void set(const std::string §ion, const std::string &key, const std::string &value)
|
||||
{
|
||||
#ifndef _NDEBUG
|
||||
std::string key_trimmed = key;
|
||||
boost::trim_all(key_trimmed);
|
||||
assert(key_trimmed == key);
|
||||
assert(! key_trimmed.empty());
|
||||
#endif // _NDEBUG
|
||||
std::string &old = m_storage[section][key];
|
||||
if (old != value) {
|
||||
old = value;
|
||||
m_dirty = true;
|
||||
}
|
||||
}
|
||||
void set(const std::string &key, const std::string &value)
|
||||
{ this->set("", key, value); }
|
||||
bool has(const std::string §ion, const std::string &key) const
|
||||
{
|
||||
auto it = m_storage.find(section);
|
||||
if (it == m_storage.end())
|
||||
return false;
|
||||
auto it2 = it->second.find(key);
|
||||
return it2 != it->second.end() && ! it2->second.empty();
|
||||
}
|
||||
bool has(const std::string &key) const
|
||||
{ return this->has("", key); }
|
||||
|
||||
void erase(const std::string §ion, const std::string &key)
|
||||
{
|
||||
auto it = m_storage.find(section);
|
||||
if (it != m_storage.end()) {
|
||||
it->second.erase(key);
|
||||
}
|
||||
}
|
||||
|
||||
bool has_section(const std::string §ion) const
|
||||
{ return m_storage.find(section) != m_storage.end(); }
|
||||
const std::map<std::string, std::string>& get_section(const std::string §ion) const
|
||||
{ return m_storage.find(section)->second; }
|
||||
void set_section(const std::string §ion, const std::map<std::string, std::string>& data)
|
||||
{ m_storage[section] = data; }
|
||||
void clear_section(const std::string §ion)
|
||||
{ m_storage[section].clear(); }
|
||||
|
||||
typedef std::map<std::string, std::map<std::string, std::set<std::string>>> VendorMap;
|
||||
bool get_variant(const std::string &vendor, const std::string &model, const std::string &variant) const;
|
||||
void set_variant(const std::string &vendor, const std::string &model, const std::string &variant, bool enable);
|
||||
void set_vendors(const AppConfig &from);
|
||||
void set_vendors(const VendorMap &vendors) { m_vendors = vendors; m_dirty = true; }
|
||||
void set_vendors(VendorMap &&vendors) { m_vendors = std::move(vendors); m_dirty = true; }
|
||||
const VendorMap& vendors() const { return m_vendors; }
|
||||
|
||||
// return recent/skein_directory or recent/config_directory or empty string.
|
||||
std::string get_last_dir() const;
|
||||
void update_config_dir(const std::string &dir);
|
||||
void update_skein_dir(const std::string &dir);
|
||||
|
||||
//std::string get_last_output_dir(const std::string &alt) const;
|
||||
//void update_last_output_dir(const std::string &dir);
|
||||
std::string get_last_output_dir(const std::string& alt, const bool removable = false) const;
|
||||
void update_last_output_dir(const std::string &dir, const bool removable = false);
|
||||
|
||||
// reset the current print / filament / printer selections, so that
|
||||
// the PresetBundle::load_selections(const AppConfig &config) call will select
|
||||
// the first non-default preset when called.
|
||||
void reset_selections();
|
||||
|
||||
// Get the default config path from Slic3r::data_dir().
|
||||
static std::string config_path();
|
||||
|
||||
// Returns true if the user's data directory comes from before Slic3r 1.40.0 (no updating)
|
||||
bool legacy_datadir() const { return m_legacy_datadir; }
|
||||
void set_legacy_datadir(bool value) { m_legacy_datadir = value; }
|
||||
|
||||
// Get the Slic3r version check url.
|
||||
// This returns a hardcoded string unless it is overriden by "version_check_url" in the ini file.
|
||||
std::string version_check_url() const;
|
||||
|
||||
// Returns the original Slic3r version found in the ini file before it was overwritten
|
||||
// by the current version
|
||||
Semver orig_version() const { return m_orig_version; }
|
||||
|
||||
// Does the config file exist?
|
||||
static bool exists();
|
||||
|
||||
std::vector<std::string> get_recent_projects() const;
|
||||
void set_recent_projects(const std::vector<std::string>& recent_projects);
|
||||
|
||||
void set_mouse_device(const std::string& name, double translation_speed, double translation_deadzone, float rotation_speed, float rotation_deadzone, double zoom_speed, bool swap_yz);
|
||||
std::vector<std::string> get_mouse_device_names() const;
|
||||
bool get_mouse_device_translation_speed(const std::string& name, double& speed) const
|
||||
{ return get_3dmouse_device_numeric_value(name, "translation_speed", speed); }
|
||||
bool get_mouse_device_translation_deadzone(const std::string& name, double& deadzone) const
|
||||
{ return get_3dmouse_device_numeric_value(name, "translation_deadzone", deadzone); }
|
||||
bool get_mouse_device_rotation_speed(const std::string& name, float& speed) const
|
||||
{ return get_3dmouse_device_numeric_value(name, "rotation_speed", speed); }
|
||||
bool get_mouse_device_rotation_deadzone(const std::string& name, float& deadzone) const
|
||||
{ return get_3dmouse_device_numeric_value(name, "rotation_deadzone", deadzone); }
|
||||
bool get_mouse_device_zoom_speed(const std::string& name, double& speed) const
|
||||
{ return get_3dmouse_device_numeric_value(name, "zoom_speed", speed); }
|
||||
bool get_mouse_device_swap_yz(const std::string& name, bool& swap) const
|
||||
{ return get_3dmouse_device_numeric_value(name, "swap_yz", swap); }
|
||||
|
||||
static const std::string SECTION_FILAMENTS;
|
||||
static const std::string SECTION_MATERIALS;
|
||||
|
||||
private:
|
||||
template<typename T>
|
||||
bool get_3dmouse_device_numeric_value(const std::string &device_name, const char *parameter_name, T &out) const
|
||||
{
|
||||
std::string key = std::string("mouse_device:") + device_name;
|
||||
auto it = m_storage.find(key);
|
||||
if (it == m_storage.end())
|
||||
return false;
|
||||
auto it_val = it->second.find(parameter_name);
|
||||
if (it_val == it->second.end())
|
||||
return false;
|
||||
out = T(::atof(it_val->second.c_str()));
|
||||
return true;
|
||||
}
|
||||
|
||||
// Map of section, name -> value
|
||||
std::map<std::string, std::map<std::string, std::string>> m_storage;
|
||||
// Map of enabled vendors / models / variants
|
||||
VendorMap m_vendors;
|
||||
// Has any value been modified since the config.ini has been last saved or loaded?
|
||||
bool m_dirty;
|
||||
// Original version found in the ini file before it was overwritten
|
||||
Semver m_orig_version;
|
||||
// Whether the existing version is before system profiles & configuration updating
|
||||
bool m_legacy_datadir;
|
||||
};
|
||||
|
||||
}; // namespace Slic3r
|
||||
|
||||
#endif /* slic3r_AppConfig_hpp_ */
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
#include "libslic3r/libslic3r.h"
|
||||
#include "libslic3r/AppConfig.hpp"
|
||||
|
||||
#include "Camera.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "AppConfig.hpp"
|
||||
#if ENABLE_CAMERA_STATISTICS
|
||||
#include "Mouse3DController.hpp"
|
||||
#include "Plater.hpp"
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#include "ConfigManipulation.hpp"
|
||||
#include "I18N.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "PresetBundle.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
|
||||
#include <wx/msgdlg.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -20,9 +20,8 @@
|
|||
#include <wx/radiobut.h>
|
||||
|
||||
#include "libslic3r/PrintConfig.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
#include "slic3r/Utils/PresetUpdater.hpp"
|
||||
#include "AppConfig.hpp"
|
||||
#include "PresetBundle.hpp"
|
||||
#include "BedShapeDialog.hpp"
|
||||
#include "GUI.hpp"
|
||||
#include "wxExtensions.hpp"
|
||||
|
|
|
|||
|
|
@ -295,6 +295,7 @@ void Field::msw_rescale(bool rescale_sidetext)
|
|||
{
|
||||
m_Undo_to_sys_btn->msw_rescale();
|
||||
m_Undo_btn->msw_rescale();
|
||||
m_blinking_bmp->msw_rescale();
|
||||
|
||||
// update em_unit value
|
||||
m_em_unit = em_unit(m_parent);
|
||||
|
|
@ -1079,6 +1080,8 @@ boost::any& Choice::get_value()
|
|||
m_value = static_cast<SLADisplayOrientation>(ret_enum);
|
||||
else if (m_opt_id.compare("support_pillar_connection_mode") == 0)
|
||||
m_value = static_cast<SLAPillarConnectionMode>(ret_enum);
|
||||
else if (m_opt_id == "authorization_type")
|
||||
m_value = static_cast<AuthorizationType>(ret_enum);
|
||||
}
|
||||
else if (m_opt.gui_type == "f_enum_open") {
|
||||
const int ret_enum = field->GetSelection();
|
||||
|
|
|
|||
|
|
@ -151,6 +151,8 @@ public:
|
|||
virtual wxSizer* getSizer() { return nullptr; }
|
||||
virtual wxWindow* getWindow() { return nullptr; }
|
||||
|
||||
wxStaticText* getLabel() { return m_Label; }
|
||||
|
||||
bool is_matched(const std::string& string, const std::string& pattern);
|
||||
void get_value_by_opt_type(wxString& str, const bool check_value = true);
|
||||
|
||||
|
|
|
|||
|
|
@ -15,11 +15,11 @@
|
|||
#include "libslic3r/Utils.hpp"
|
||||
#include "libslic3r/Technologies.hpp"
|
||||
#include "libslic3r/Tesselate.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
#include "slic3r/GUI/3DScene.hpp"
|
||||
#include "slic3r/GUI/BackgroundSlicingProcess.hpp"
|
||||
#include "slic3r/GUI/GLShader.hpp"
|
||||
#include "slic3r/GUI/GUI.hpp"
|
||||
#include "slic3r/GUI/PresetBundle.hpp"
|
||||
#include "slic3r/GUI/Tab.hpp"
|
||||
#include "slic3r/GUI/GUI_Preview.hpp"
|
||||
#include "slic3r/GUI/OpenGLManager.hpp"
|
||||
|
|
|
|||
|
|
@ -194,6 +194,8 @@ void change_opt_value(DynamicPrintConfig& config, const t_config_option_key& opt
|
|||
config.set_key_value(opt_key, new ConfigOptionEnum<SLADisplayOrientation>(boost::any_cast<SLADisplayOrientation>(value)));
|
||||
else if(opt_key.compare("support_pillar_connection_mode") == 0)
|
||||
config.set_key_value(opt_key, new ConfigOptionEnum<SLAPillarConnectionMode>(boost::any_cast<SLAPillarConnectionMode>(value)));
|
||||
else if(opt_key == "authorization_type")
|
||||
config.set_key_value(opt_key, new ConfigOptionEnum<AuthorizationType>(boost::any_cast<AuthorizationType>(value)));
|
||||
}
|
||||
break;
|
||||
case coPoints:{
|
||||
|
|
|
|||
|
|
@ -28,14 +28,16 @@
|
|||
#include <wx/log.h>
|
||||
#include <wx/intl.h>
|
||||
|
||||
#include <wx/dialog.h>
|
||||
#include <wx/textctrl.h>
|
||||
|
||||
#include "libslic3r/Utils.hpp"
|
||||
#include "libslic3r/Model.hpp"
|
||||
#include "libslic3r/I18N.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
|
||||
#include "GUI.hpp"
|
||||
#include "GUI_Utils.hpp"
|
||||
#include "AppConfig.hpp"
|
||||
#include "PresetBundle.hpp"
|
||||
#include "3DScene.hpp"
|
||||
#include "MainFrame.hpp"
|
||||
#include "Plater.hpp"
|
||||
|
|
@ -323,7 +325,13 @@ void GUI_App::init_app_config()
|
|||
// load settings
|
||||
app_conf_exists = app_config->exists();
|
||||
if (app_conf_exists) {
|
||||
app_config->load();
|
||||
std::string error = app_config->load();
|
||||
if (!error.empty())
|
||||
// Error while parsing config file. We'll customize the error message and rethrow to be displayed.
|
||||
throw std::runtime_error(
|
||||
_u8L("Error parsing PrusaSlicer config file, it is probably corrupted. "
|
||||
"Try to manually delete the file to recover from the error. Your user profiles will not be affected.") +
|
||||
"\n\n" + AppConfig::config_path() + "\n\n" + error);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -635,6 +643,27 @@ void GUI_App::set_auto_toolbar_icon_scale(float scale) const
|
|||
app_config->set("auto_toolbar_size", val);
|
||||
}
|
||||
|
||||
// check user printer_presets for the containing information about "Print Host upload"
|
||||
void GUI_App::check_printer_presets()
|
||||
{
|
||||
std::vector<std::string> preset_names = PhysicalPrinter::presets_with_print_host_information(preset_bundle->printers);
|
||||
if (preset_names.empty())
|
||||
return;
|
||||
|
||||
wxString msg_text = _L("You have next presets with saved options for \"Print Host upload\"") + ":";
|
||||
for (const std::string& preset_name : preset_names)
|
||||
msg_text += "\n \"" + from_u8(preset_name) + "\",";
|
||||
msg_text.RemoveLast();
|
||||
msg_text += "\n\n" + _L("But from this version of PrusaSlicer we don't show/use this information in Printer Settings.\n"
|
||||
"Now, this information will be exposed in physical printers settings.") + "\n\n" +
|
||||
_L("By default new Printer devices will be named as \"Printer N\" during its creation.\n"
|
||||
"Note: This name can be changed later from the physical printers settings");
|
||||
|
||||
wxMessageDialog(nullptr, msg_text, _L("Information"), wxOK | wxICON_INFORMATION).ShowModal();
|
||||
|
||||
preset_bundle->physical_printers.load_printers_from_presets(preset_bundle->printers);
|
||||
}
|
||||
|
||||
void GUI_App::recreate_GUI(const wxString& msg_name)
|
||||
{
|
||||
mainframe->shutdown();
|
||||
|
|
@ -957,7 +986,7 @@ bool GUI_App::load_language(wxString language, bool initial)
|
|||
m_imgui->set_language(into_u8(language_info->CanonicalName));
|
||||
//FIXME This is a temporary workaround, the correct solution is to switch to "C" locale during file import / export only.
|
||||
wxSetlocale(LC_NUMERIC, "C");
|
||||
Preset::update_suffix_modified();
|
||||
Preset::update_suffix_modified((" (" + _L("modified") + ")").ToUTF8().data());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -1178,6 +1207,10 @@ bool GUI_App::checked_tab(Tab* tab)
|
|||
// Update UI / Tabs to reflect changes in the currently loaded presets
|
||||
void GUI_App::load_current_presets()
|
||||
{
|
||||
// check printer_presets for the containing information about "Print Host upload"
|
||||
// and create physical printer from it, if any exists
|
||||
check_printer_presets();
|
||||
|
||||
PrinterTechnology printer_technology = preset_bundle->printers.get_edited_preset().printer_technology();
|
||||
this->plater()->set_printer_technology(printer_technology);
|
||||
for (Tab *tab : tabs_list)
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@
|
|||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include "Preset.hpp"
|
||||
#include "ImGuiWrapper.hpp"
|
||||
#include "ConfigWizard.hpp"
|
||||
#include "OpenGLManager.hpp"
|
||||
#include "libslic3r/Preset.hpp"
|
||||
|
||||
#include <wx/app.h>
|
||||
#include <wx/colour.h>
|
||||
|
|
@ -150,6 +150,7 @@ public:
|
|||
wxSize get_min_size() const;
|
||||
float toolbar_icon_scale(const bool is_limited = false) const;
|
||||
void set_auto_toolbar_icon_scale(float scale) const;
|
||||
void check_printer_presets();
|
||||
|
||||
void recreate_GUI(const wxString& message);
|
||||
void system_info();
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "OptionsGroup.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "PresetBundle.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
#include "libslic3r/Model.hpp"
|
||||
#include "GLCanvas3D.hpp"
|
||||
#include "Plater.hpp"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#include "libslic3r/libslic3r.h"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
#include "GUI_ObjectList.hpp"
|
||||
#include "GUI_ObjectManipulation.hpp"
|
||||
#include "GUI_ObjectLayers.hpp"
|
||||
|
|
@ -7,7 +8,6 @@
|
|||
#include "Plater.hpp"
|
||||
|
||||
#include "OptionsGroup.hpp"
|
||||
#include "PresetBundle.hpp"
|
||||
#include "Tab.hpp"
|
||||
#include "wxExtensions.hpp"
|
||||
#include "libslic3r/Model.hpp"
|
||||
|
|
@ -88,9 +88,6 @@ ObjectList::ObjectList(wxWindow* parent) :
|
|||
{
|
||||
// Fill CATEGORY_ICON
|
||||
{
|
||||
// Note: `this` isn't passed to create_scaled_bitmap() here because of bugs in the widget,
|
||||
// see note in PresetBundle::load_compatible_bitmaps()
|
||||
|
||||
// ptFFF
|
||||
CATEGORY_ICON[L("Layers and Perimeters")] = create_scaled_bitmap("layers");
|
||||
CATEGORY_ICON[L("Infill")] = create_scaled_bitmap("infill");
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
#include "OptionsGroup.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "wxExtensions.hpp"
|
||||
#include "PresetBundle.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
#include "libslic3r/Model.hpp"
|
||||
#include "libslic3r/Geometry.hpp"
|
||||
#include "Selection.hpp"
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
#include "OptionsGroup.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "wxExtensions.hpp"
|
||||
#include "PresetBundle.hpp"
|
||||
#include "Plater.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
#include "libslic3r/Model.hpp"
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
#include "BackgroundSlicingProcess.hpp"
|
||||
#include "OpenGLManager.hpp"
|
||||
#include "GLCanvas3D.hpp"
|
||||
#include "PresetBundle.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
#include "DoubleSlider.hpp"
|
||||
#include "Plater.hpp"
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
#include <GL/glew.h>
|
||||
|
||||
#include "slic3r/GUI/GUI_App.hpp"
|
||||
#include "slic3r/GUI/PresetBundle.hpp"
|
||||
#include "slic3r/GUI/Camera.hpp"
|
||||
#include "slic3r/GUI/Plater.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
#include "libslic3r/Model.hpp"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
#include "slic3r/GUI/GUI_ObjectSettings.hpp"
|
||||
#include "slic3r/GUI/GUI_ObjectList.hpp"
|
||||
#include "slic3r/GUI/Plater.hpp"
|
||||
#include "slic3r/GUI/PresetBundle.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
|
||||
#include "libslic3r/Model.hpp"
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
#include "slic3r/GUI/GUI_ObjectSettings.hpp"
|
||||
#include "slic3r/GUI/GUI_ObjectList.hpp"
|
||||
#include "slic3r/GUI/Plater.hpp"
|
||||
#include "slic3r/GUI/PresetBundle.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
#include "libslic3r/SLAPrint.hpp"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#include "slic3r/GUI/Camera.hpp"
|
||||
#include "slic3r/GUI/Plater.hpp"
|
||||
|
||||
#include "slic3r/GUI/PresetBundle.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
|
||||
#include <GL/glew.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
#include "slic3r/GUI/Camera.hpp"
|
||||
#include "slic3r/GUI/GUI_App.hpp"
|
||||
#include "slic3r/GUI/GUI_ObjectManipulation.hpp"
|
||||
#include "slic3r/GUI/PresetBundle.hpp"
|
||||
#include "slic3r/GUI/Plater.hpp"
|
||||
#include "slic3r/Utils/UndoRedo.hpp"
|
||||
|
||||
|
|
@ -19,6 +18,7 @@
|
|||
#include "slic3r/GUI/Gizmos/GLGizmoHollow.hpp"
|
||||
|
||||
#include "libslic3r/Model.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
|
||||
#include <wx/glcanvas.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
#ifndef L
|
||||
// !!! If you needed to translate some wxString,
|
||||
// !!! please use _(L(string))
|
||||
// !!! please use _L(string)
|
||||
// !!! _() - is a standard wxWidgets macro to translate
|
||||
// !!! L() is used only for marking localizable string
|
||||
// !!! It will be used in "xgettext" to create a Locating Message Catalog.
|
||||
|
|
|
|||
|
|
@ -2,13 +2,12 @@
|
|||
|
||||
#include "slic3r/GUI/GUI.hpp"
|
||||
#include "slic3r/GUI/GUI_App.hpp"
|
||||
#include "slic3r/GUI/AppConfig.hpp"
|
||||
#include "slic3r/GUI/Plater.hpp"
|
||||
#include "slic3r/GUI/PresetBundle.hpp"
|
||||
#include "slic3r/GUI/GUI_ObjectList.hpp"
|
||||
#include "slic3r/Utils/SLAImport.hpp"
|
||||
|
||||
#include "libslic3r/Model.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
|
||||
#include <wx/dialog.h>
|
||||
#include <wx/stattext.h>
|
||||
|
|
|
|||
|
|
@ -15,12 +15,11 @@
|
|||
#include "libslic3r/Print.hpp"
|
||||
#include "libslic3r/Polygon.hpp"
|
||||
#include "libslic3r/SLAPrint.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
|
||||
#include "Tab.hpp"
|
||||
#include "PresetBundle.hpp"
|
||||
#include "ProgressStatusBar.hpp"
|
||||
#include "3DScene.hpp"
|
||||
#include "AppConfig.hpp"
|
||||
#include "PrintHostDialogs.hpp"
|
||||
#include "wxExtensions.hpp"
|
||||
#include "GUI_ObjectList.hpp"
|
||||
|
|
@ -104,11 +103,6 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S
|
|||
SLIC3R_VERSION +
|
||||
_(L(" - Remember to check for updates at https://github.com/prusa3d/PrusaSlicer/releases")));
|
||||
|
||||
/* Load default preset bitmaps before a tabpanel initialization,
|
||||
* but after filling of an em_unit value
|
||||
*/
|
||||
wxGetApp().preset_bundle->load_default_preset_bitmaps();
|
||||
|
||||
// initialize tabpanel and menubar
|
||||
init_tabpanel();
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
|
|
@ -717,11 +711,6 @@ void MainFrame::on_dpi_changed(const wxRect& suggested_rect)
|
|||
#endif // ENABLE_WX_3_1_3_DPI_CHANGED_EVENT
|
||||
this->SetFont(this->normal_font());
|
||||
|
||||
/* Load default preset bitmaps before a tabpanel initialization,
|
||||
* but after filling of an em_unit value
|
||||
*/
|
||||
wxGetApp().preset_bundle->load_default_preset_bitmaps();
|
||||
|
||||
// update Plater
|
||||
wxGetApp().plater()->msw_rescale();
|
||||
|
||||
|
|
@ -766,8 +755,6 @@ void MainFrame::on_sys_color_changed()
|
|||
// update label colors in respect to the system mode
|
||||
wxGetApp().init_label_colours();
|
||||
|
||||
wxGetApp().preset_bundle->load_default_preset_bitmaps();
|
||||
|
||||
// update Plater
|
||||
wxGetApp().plater()->sys_color_changed();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
#include "libslic3r/libslic3r.h"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
#include "Mouse3DController.hpp"
|
||||
|
||||
#include "Camera.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "PresetBundle.hpp"
|
||||
#include "AppConfig.hpp"
|
||||
#include "GLCanvas3D.hpp"
|
||||
#include "Plater.hpp"
|
||||
#include "NotificationManager.hpp"
|
||||
|
|
|
|||
|
|
@ -729,31 +729,34 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config
|
|||
opt_key == "fill_pattern" ) {
|
||||
ret = static_cast<int>(config.option<ConfigOptionEnum<InfillPattern>>(opt_key)->value);
|
||||
}
|
||||
else if (opt_key.compare("ironing_type") == 0 ) {
|
||||
else if (opt_key == "ironing_type") {
|
||||
ret = static_cast<int>(config.option<ConfigOptionEnum<IroningType>>(opt_key)->value);
|
||||
}
|
||||
else if (opt_key.compare("gcode_flavor") == 0 ) {
|
||||
else if (opt_key == "gcode_flavor") {
|
||||
ret = static_cast<int>(config.option<ConfigOptionEnum<GCodeFlavor>>(opt_key)->value);
|
||||
}
|
||||
else if (opt_key.compare("support_material_pattern") == 0) {
|
||||
else if (opt_key == "support_material_pattern") {
|
||||
ret = static_cast<int>(config.option<ConfigOptionEnum<SupportMaterialPattern>>(opt_key)->value);
|
||||
}
|
||||
else if (opt_key.compare("seam_position") == 0) {
|
||||
else if (opt_key == "seam_position") {
|
||||
ret = static_cast<int>(config.option<ConfigOptionEnum<SeamPosition>>(opt_key)->value);
|
||||
}
|
||||
else if (opt_key.compare("host_type") == 0) {
|
||||
else if (opt_key == "host_type") {
|
||||
ret = static_cast<int>(config.option<ConfigOptionEnum<PrintHostType>>(opt_key)->value);
|
||||
}
|
||||
else if (opt_key.compare("display_orientation") == 0) {
|
||||
else if (opt_key == "display_orientation") {
|
||||
ret = static_cast<int>(config.option<ConfigOptionEnum<SLADisplayOrientation>>(opt_key)->value);
|
||||
}
|
||||
else if (opt_key.compare("support_pillar_connection_mode") == 0) {
|
||||
else if (opt_key == "support_pillar_connection_mode") {
|
||||
ret = static_cast<int>(config.option<ConfigOptionEnum<SLAPillarConnectionMode>>(opt_key)->value);
|
||||
}
|
||||
else if (opt_key == "authorization_type") {
|
||||
ret = static_cast<int>(config.option<ConfigOptionEnum<AuthorizationType>>(opt_key)->value);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case coPoints:
|
||||
if (opt_key.compare("bed_shape") == 0)
|
||||
if (opt_key == "bed_shape")
|
||||
ret = config.option<ConfigOptionPoints>(opt_key)->values;
|
||||
else
|
||||
ret = config.option<ConfigOptionPoints>(opt_key)->get_at(idx);
|
||||
|
|
|
|||
|
|
@ -149,6 +149,13 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
void show_field(const t_config_option_key& opt_key, bool show = true) {
|
||||
Field* field = get_field(opt_key);
|
||||
field->getWindow()->Show(show);
|
||||
field->getLabel()->Show(show);
|
||||
}
|
||||
void hide_field(const t_config_option_key& opt_key) { show_field(opt_key, false); }
|
||||
|
||||
void set_name(const wxString& new_name) {
|
||||
stb->SetLabel(new_name);
|
||||
}
|
||||
|
|
|
|||
564
src/slic3r/GUI/PhysicalPrinterDialog.cpp
Normal file
564
src/slic3r/GUI/PhysicalPrinterDialog.cpp
Normal file
|
|
@ -0,0 +1,564 @@
|
|||
#include "PhysicalPrinterDialog.hpp"
|
||||
#include "PresetComboBoxes.hpp"
|
||||
|
||||
#include <cstddef>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/stattext.h>
|
||||
#include <wx/textctrl.h>
|
||||
#include <wx/button.h>
|
||||
#include <wx/statbox.h>
|
||||
#include <wx/wupdlock.h>
|
||||
|
||||
#include "libslic3r/libslic3r.h"
|
||||
#include "libslic3r/PrintConfig.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
|
||||
#include "GUI.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "MainFrame.hpp"
|
||||
#include "format.hpp"
|
||||
#include "Tab.hpp"
|
||||
#include "wxExtensions.hpp"
|
||||
#include "PrintHostDialogs.hpp"
|
||||
#include "../Utils/ASCIIFolding.hpp"
|
||||
#include "../Utils/PrintHost.hpp"
|
||||
#include "../Utils/FixModelByWin10.hpp"
|
||||
#include "../Utils/UndoRedo.hpp"
|
||||
#include "RemovableDriveManager.hpp"
|
||||
#include "BitmapCache.hpp"
|
||||
#include "BonjourDialog.hpp"
|
||||
|
||||
using Slic3r::GUI::format_wxstr;
|
||||
|
||||
//static const std::pair<unsigned int, unsigned int> THUMBNAIL_SIZE_3MF = { 256, 256 };
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
#define BORDER_W 10
|
||||
|
||||
//------------------------------------------
|
||||
// PresetForPrinter
|
||||
//------------------------------------------
|
||||
|
||||
PresetForPrinter::PresetForPrinter(PhysicalPrinterDialog* parent, const std::string& preset_name) :
|
||||
m_parent(parent)
|
||||
{
|
||||
m_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
m_delete_preset_btn = new ScalableButton(parent, wxID_ANY, "cross", "", wxDefaultSize, wxDefaultPosition, /*wxBU_LEFT | */wxBU_EXACTFIT);
|
||||
m_delete_preset_btn->SetFont(wxGetApp().normal_font());
|
||||
m_delete_preset_btn->SetToolTip(_L("Delete this preset from this printer device"));
|
||||
m_delete_preset_btn->Bind(wxEVT_BUTTON, &PresetForPrinter::DeletePreset, this);
|
||||
|
||||
m_presets_list = new PresetComboBox(parent, Preset::TYPE_PRINTER);
|
||||
m_presets_list->set_printer_technology(parent->get_printer_technology());
|
||||
|
||||
m_presets_list->set_selection_changed_function([this](int selection) {
|
||||
std::string selected_string = Preset::remove_suffix_modified(m_presets_list->GetString(selection).ToUTF8().data());
|
||||
Preset* preset = wxGetApp().preset_bundle->printers.find_preset(selected_string);
|
||||
assert(preset);
|
||||
Preset& edited_preset = wxGetApp().preset_bundle->printers.get_edited_preset();
|
||||
if (preset->name == edited_preset.name)
|
||||
preset = &edited_preset;
|
||||
|
||||
// if created physical printer doesn't have any settings, use the settings from the selected preset
|
||||
if (m_parent->get_printer()->has_empty_config()) {
|
||||
// update Print Host upload from the selected preset
|
||||
m_parent->get_printer()->update_from_preset(*preset);
|
||||
// update values in parent (PhysicalPrinterDialog)
|
||||
m_parent->update();
|
||||
}
|
||||
|
||||
// update PrinterTechnology if it was changed
|
||||
if (m_presets_list->set_printer_technology(preset->printer_technology()))
|
||||
m_parent->set_printer_technology(preset->printer_technology());
|
||||
|
||||
update_full_printer_name();
|
||||
});
|
||||
m_presets_list->update(preset_name);
|
||||
|
||||
m_info_line = new wxStaticText(parent, wxID_ANY, _L("This printer will be shown in the presets list as") + ":");
|
||||
|
||||
m_full_printer_name = new wxStaticText(parent, wxID_ANY, "");
|
||||
m_full_printer_name->SetFont(wxGetApp().bold_font());
|
||||
|
||||
wxBoxSizer* preset_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
preset_sizer->Add(m_presets_list , 1, wxEXPAND);
|
||||
preset_sizer->Add(m_delete_preset_btn , 0, wxEXPAND | wxLEFT, BORDER_W);
|
||||
|
||||
wxBoxSizer* name_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
name_sizer->Add(m_info_line, 0, wxEXPAND);
|
||||
name_sizer->Add(m_full_printer_name, 0, wxEXPAND | wxLEFT, BORDER_W);
|
||||
|
||||
m_sizer->Add(preset_sizer , 0, wxEXPAND);
|
||||
m_sizer->Add(name_sizer, 0, wxEXPAND);
|
||||
}
|
||||
|
||||
PresetForPrinter::~PresetForPrinter()
|
||||
{
|
||||
m_presets_list->Destroy();
|
||||
m_delete_preset_btn->Destroy();
|
||||
m_info_line->Destroy();
|
||||
m_full_printer_name->Destroy();
|
||||
}
|
||||
|
||||
void PresetForPrinter::DeletePreset(wxEvent& event)
|
||||
{
|
||||
m_parent->DeletePreset(this);
|
||||
}
|
||||
|
||||
void PresetForPrinter::update_full_printer_name()
|
||||
{
|
||||
wxString printer_name = m_parent->get_printer_name();
|
||||
wxString preset_name = m_presets_list->GetString(m_presets_list->GetSelection());
|
||||
|
||||
m_full_printer_name->SetLabelText(printer_name + " * " + preset_name);
|
||||
}
|
||||
|
||||
std::string PresetForPrinter::get_preset_name()
|
||||
{
|
||||
return into_u8(m_presets_list->GetString(m_presets_list->GetSelection()));
|
||||
}
|
||||
|
||||
void PresetForPrinter::SuppressDelete()
|
||||
{
|
||||
m_delete_preset_btn->Enable(false);
|
||||
|
||||
// this case means that now we have only one related preset for the printer
|
||||
// So, allow any selection
|
||||
m_presets_list->set_printer_technology(ptAny);
|
||||
m_presets_list->update();
|
||||
}
|
||||
|
||||
void PresetForPrinter::AllowDelete()
|
||||
{
|
||||
if (!m_delete_preset_btn->IsEnabled())
|
||||
m_delete_preset_btn->Enable();
|
||||
|
||||
m_presets_list->set_printer_technology(m_parent->get_printer_technology());
|
||||
m_presets_list->update();
|
||||
}
|
||||
|
||||
void PresetForPrinter::msw_rescale()
|
||||
{
|
||||
m_presets_list->msw_rescale();
|
||||
m_delete_preset_btn->msw_rescale();
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------
|
||||
// PhysicalPrinterDialog
|
||||
//------------------------------------------
|
||||
|
||||
PhysicalPrinterDialog::PhysicalPrinterDialog(wxString printer_name)
|
||||
: DPIDialog(NULL, wxID_ANY, _L("Physical Printer"), wxDefaultPosition, wxSize(45 * wxGetApp().em_unit(), -1), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
||||
{
|
||||
SetFont(wxGetApp().normal_font());
|
||||
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
|
||||
m_default_name = _L("Type here the name of your printer device");
|
||||
bool new_printer = true;
|
||||
|
||||
if (printer_name.IsEmpty())
|
||||
printer_name = m_default_name;
|
||||
else {
|
||||
std::string full_name = into_u8(printer_name);
|
||||
printer_name = from_u8(PhysicalPrinter::get_short_name(full_name));
|
||||
new_printer = false;
|
||||
}
|
||||
|
||||
wxStaticText* label_top = new wxStaticText(this, wxID_ANY, _L("Descriptive name for the printer device") + ":");
|
||||
|
||||
m_add_preset_btn = new ScalableButton(this, wxID_ANY, "add_copies", "", wxDefaultSize, wxDefaultPosition, /*wxBU_LEFT | */wxBU_EXACTFIT);
|
||||
m_add_preset_btn->SetFont(wxGetApp().normal_font());
|
||||
m_add_preset_btn->SetToolTip(_L("Add preset for this printer device"));
|
||||
m_add_preset_btn->Bind(wxEVT_BUTTON, &PhysicalPrinterDialog::AddPreset, this);
|
||||
|
||||
m_printer_name = new wxTextCtrl(this, wxID_ANY, printer_name, wxDefaultPosition, wxDefaultSize);
|
||||
m_printer_name->Bind(wxEVT_TEXT, [this](wxEvent&) { this->update_full_printer_names(); });
|
||||
|
||||
PhysicalPrinterCollection& printers = wxGetApp().preset_bundle->physical_printers;
|
||||
PhysicalPrinter* printer = printers.find_printer(into_u8(printer_name));
|
||||
if (!printer) {
|
||||
const Preset& preset = wxGetApp().preset_bundle->printers.get_edited_preset();
|
||||
printer = new PhysicalPrinter(into_u8(printer_name), preset);
|
||||
// if printer_name is empty it means that new printer is created, so enable all items in the preset list
|
||||
m_presets.emplace_back(new PresetForPrinter(this, preset.name));
|
||||
}
|
||||
else
|
||||
{
|
||||
const std::set<std::string>& preset_names = printer->get_preset_names();
|
||||
for (const std::string& preset_name : preset_names)
|
||||
m_presets.emplace_back(new PresetForPrinter(this, preset_name));
|
||||
}
|
||||
assert(printer);
|
||||
m_printer = *printer;
|
||||
|
||||
if (m_presets.size() == 1)
|
||||
m_presets.front()->SuppressDelete();
|
||||
|
||||
update_full_printer_names();
|
||||
|
||||
m_config = &m_printer.config;
|
||||
|
||||
m_optgroup = new ConfigOptionsGroup(this, _L("Print Host upload"), m_config);
|
||||
build_printhost_settings(m_optgroup);
|
||||
|
||||
wxStdDialogButtonSizer* btns = this->CreateStdDialogButtonSizer(wxOK | wxCANCEL);
|
||||
wxButton* btnOK = static_cast<wxButton*>(this->FindWindowById(wxID_OK, this));
|
||||
btnOK->Bind(wxEVT_BUTTON, &PhysicalPrinterDialog::OnOK, this);
|
||||
|
||||
wxBoxSizer* nameSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
nameSizer->Add(m_printer_name, 1, wxEXPAND);
|
||||
nameSizer->Add(m_add_preset_btn, 0, wxEXPAND | wxLEFT, BORDER_W);
|
||||
|
||||
m_presets_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
for (PresetForPrinter* preset : m_presets)
|
||||
m_presets_sizer->Add(preset->sizer(), 1, wxEXPAND | wxTOP, BORDER_W);
|
||||
|
||||
wxBoxSizer* topSizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
topSizer->Add(label_top , 0, wxEXPAND | wxLEFT | wxTOP | wxRIGHT, BORDER_W);
|
||||
topSizer->Add(nameSizer , 0, wxEXPAND | wxLEFT | wxRIGHT, BORDER_W);
|
||||
topSizer->Add(m_presets_sizer , 0, wxEXPAND | wxLEFT | wxRIGHT, BORDER_W);
|
||||
topSizer->Add(m_optgroup->sizer , 1, wxEXPAND | wxLEFT | wxTOP | wxRIGHT, BORDER_W);
|
||||
topSizer->Add(btns , 0, wxEXPAND | wxALL, BORDER_W);
|
||||
|
||||
SetSizer(topSizer);
|
||||
topSizer->SetSizeHints(this);
|
||||
|
||||
if (new_printer) {
|
||||
m_printer_name->SetFocus();
|
||||
m_printer_name->SelectAll();
|
||||
}
|
||||
}
|
||||
|
||||
PhysicalPrinterDialog::~PhysicalPrinterDialog()
|
||||
{
|
||||
for (PresetForPrinter* preset : m_presets) {
|
||||
delete preset;
|
||||
preset = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void PhysicalPrinterDialog::build_printhost_settings(ConfigOptionsGroup* m_optgroup)
|
||||
{
|
||||
m_optgroup->m_on_change = [this](t_config_option_key opt_key, boost::any value) {
|
||||
if (opt_key == "authorization_type")
|
||||
this->update();
|
||||
};
|
||||
|
||||
m_optgroup->append_single_option_line("host_type");
|
||||
|
||||
auto create_sizer_with_btn = [this](wxWindow* parent, ScalableButton** btn, const std::string& icon_name, const wxString& label) {
|
||||
*btn = new ScalableButton(parent, wxID_ANY, icon_name, label, wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT);
|
||||
(*btn)->SetFont(wxGetApp().normal_font());
|
||||
|
||||
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
sizer->Add(*btn);
|
||||
return sizer;
|
||||
};
|
||||
|
||||
auto printhost_browse = [=](wxWindow* parent)
|
||||
{
|
||||
auto sizer = create_sizer_with_btn(parent, &m_printhost_browse_btn, "browse", _L("Browse") + " " + dots);
|
||||
m_printhost_browse_btn->Bind(wxEVT_BUTTON, [=](wxCommandEvent& e) {
|
||||
BonjourDialog dialog(this, Preset::printer_technology(m_printer.config));
|
||||
if (dialog.show_and_lookup()) {
|
||||
m_optgroup->set_value("print_host", std::move(dialog.get_selected()), true);
|
||||
m_optgroup->get_field("print_host")->field_changed();
|
||||
}
|
||||
});
|
||||
|
||||
return sizer;
|
||||
};
|
||||
|
||||
auto print_host_test = [=](wxWindow* parent) {
|
||||
auto sizer = create_sizer_with_btn(parent, &m_printhost_test_btn, "test", _L("Test"));
|
||||
|
||||
m_printhost_test_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent& e) {
|
||||
std::unique_ptr<PrintHost> host(PrintHost::get_print_host(m_config));
|
||||
if (!host) {
|
||||
const wxString text = _L("Could not get a valid Printer Host reference");
|
||||
show_error(this, text);
|
||||
return;
|
||||
}
|
||||
wxString msg;
|
||||
if (host->test(msg)) {
|
||||
show_info(this, host->get_test_ok_msg(), _L("Success!"));
|
||||
}
|
||||
else {
|
||||
show_error(this, host->get_test_failed_msg(msg));
|
||||
}
|
||||
});
|
||||
|
||||
return sizer;
|
||||
};
|
||||
|
||||
// Set a wider width for a better alignment
|
||||
Option option = m_optgroup->get_option("print_host");
|
||||
option.opt.width = Field::def_width_wider();
|
||||
Line host_line = m_optgroup->create_single_option_line(option);
|
||||
host_line.append_widget(printhost_browse);
|
||||
host_line.append_widget(print_host_test);
|
||||
m_optgroup->append_line(host_line);
|
||||
|
||||
m_optgroup->append_single_option_line("authorization_type");
|
||||
|
||||
option = m_optgroup->get_option("printhost_apikey");
|
||||
option.opt.width = Field::def_width_wider();
|
||||
m_optgroup->append_single_option_line(option);
|
||||
|
||||
const auto ca_file_hint = _u8L("HTTPS CA file is optional. It is only needed if you use HTTPS with a self-signed certificate.");
|
||||
|
||||
if (Http::ca_file_supported()) {
|
||||
option = m_optgroup->get_option("printhost_cafile");
|
||||
option.opt.width = Field::def_width_wider();
|
||||
Line cafile_line = m_optgroup->create_single_option_line(option);
|
||||
|
||||
auto printhost_cafile_browse = [=](wxWindow* parent) {
|
||||
auto sizer = create_sizer_with_btn(parent, &m_printhost_cafile_browse_btn, "browse", _L("Browse") + " " + dots);
|
||||
m_printhost_cafile_browse_btn->Bind(wxEVT_BUTTON, [this, m_optgroup](wxCommandEvent e) {
|
||||
static const auto filemasks = _L("Certificate files (*.crt, *.pem)|*.crt;*.pem|All files|*.*");
|
||||
wxFileDialog openFileDialog(this, _L("Open CA certificate file"), "", "", filemasks, wxFD_OPEN | wxFD_FILE_MUST_EXIST);
|
||||
if (openFileDialog.ShowModal() != wxID_CANCEL) {
|
||||
m_optgroup->set_value("printhost_cafile", std::move(openFileDialog.GetPath()), true);
|
||||
m_optgroup->get_field("printhost_cafile")->field_changed();
|
||||
}
|
||||
});
|
||||
|
||||
return sizer;
|
||||
};
|
||||
|
||||
cafile_line.append_widget(printhost_cafile_browse);
|
||||
m_optgroup->append_line(cafile_line);
|
||||
|
||||
Line cafile_hint{ "", "" };
|
||||
cafile_hint.full_width = 1;
|
||||
cafile_hint.widget = [this, ca_file_hint](wxWindow* parent) {
|
||||
auto txt = new wxStaticText(parent, wxID_ANY, ca_file_hint);
|
||||
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
sizer->Add(txt);
|
||||
return sizer;
|
||||
};
|
||||
m_optgroup->append_line(cafile_hint);
|
||||
}
|
||||
else {
|
||||
Line line{ "", "" };
|
||||
line.full_width = 1;
|
||||
|
||||
line.widget = [ca_file_hint](wxWindow* parent) {
|
||||
std::string info = _u8L("HTTPS CA File") + ":\n\t" +
|
||||
(boost::format(_u8L("On this system, %s uses HTTPS certificates from the system Certificate Store or Keychain.")) % SLIC3R_APP_NAME).str() +
|
||||
"\n\t" + _u8L("To use a custom CA file, please import your CA file into Certificate Store / Keychain.");
|
||||
|
||||
//auto txt = new wxStaticText(parent, wxID_ANY, from_u8((boost::format("%1%\n\n\t%2%") % info % ca_file_hint).str()));
|
||||
auto txt = new wxStaticText(parent, wxID_ANY, from_u8((boost::format("%1%\n\t%2%") % info % ca_file_hint).str()));
|
||||
txt->SetFont(wxGetApp().normal_font());
|
||||
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
sizer->Add(txt, 1, wxEXPAND);
|
||||
return sizer;
|
||||
};
|
||||
|
||||
m_optgroup->append_line(line);
|
||||
}
|
||||
|
||||
for (const std::string& opt_key : std::vector<std::string>{ "login", "password" }) {
|
||||
option = m_optgroup->get_option(opt_key);
|
||||
option.opt.width = Field::def_width_wider();
|
||||
m_optgroup->append_single_option_line(option);
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
void PhysicalPrinterDialog::update()
|
||||
{
|
||||
m_optgroup->reload_config();
|
||||
|
||||
const PrinterTechnology tech = Preset::printer_technology(*m_config);
|
||||
// Only offer the host type selection for FFF, for SLA it's always the SL1 printer (at the moment)
|
||||
if (tech == ptFFF) {
|
||||
m_optgroup->show_field("host_type");
|
||||
m_optgroup->hide_field("authorization_type");
|
||||
for (const std::string& opt_key : std::vector<std::string>{ "login", "password" })
|
||||
m_optgroup->hide_field(opt_key);
|
||||
}
|
||||
else {
|
||||
m_optgroup->set_value("host_type", int(PrintHostType::htOctoPrint), false);
|
||||
m_optgroup->hide_field("host_type");
|
||||
|
||||
m_optgroup->show_field("authorization_type");
|
||||
|
||||
AuthorizationType auth_type = m_config->option<ConfigOptionEnum<AuthorizationType>>("authorization_type")->value;
|
||||
m_optgroup->show_field("printhost_apikey", auth_type == AuthorizationType::atKeyPassword);
|
||||
|
||||
for (const std::string& opt_key : std::vector<std::string>{ "login", "password" })
|
||||
m_optgroup->show_field(opt_key, auth_type == AuthorizationType::atUserPassword);
|
||||
}
|
||||
|
||||
this->Layout();
|
||||
}
|
||||
|
||||
|
||||
wxString PhysicalPrinterDialog::get_printer_name()
|
||||
{
|
||||
return m_printer_name->GetValue();
|
||||
}
|
||||
|
||||
void PhysicalPrinterDialog::update_full_printer_names()
|
||||
{
|
||||
for (PresetForPrinter* preset : m_presets)
|
||||
preset->update_full_printer_name();
|
||||
|
||||
this->Layout();
|
||||
}
|
||||
|
||||
void PhysicalPrinterDialog::set_printer_technology(PrinterTechnology pt)
|
||||
{
|
||||
m_config->set_key_value("printer_technology", new ConfigOptionEnum<PrinterTechnology>(pt));
|
||||
update();
|
||||
}
|
||||
|
||||
PrinterTechnology PhysicalPrinterDialog::get_printer_technology()
|
||||
{
|
||||
return m_printer.printer_technology();
|
||||
}
|
||||
|
||||
void PhysicalPrinterDialog::on_dpi_changed(const wxRect& suggested_rect)
|
||||
{
|
||||
const int& em = em_unit();
|
||||
|
||||
m_printhost_browse_btn->msw_rescale();
|
||||
m_printhost_test_btn->msw_rescale();
|
||||
if (m_printhost_cafile_browse_btn)
|
||||
m_printhost_cafile_browse_btn->msw_rescale();
|
||||
|
||||
m_optgroup->msw_rescale();
|
||||
|
||||
msw_buttons_rescale(this, em, { wxID_OK, wxID_CANCEL });
|
||||
|
||||
for (PresetForPrinter* preset : m_presets)
|
||||
preset->msw_rescale();
|
||||
|
||||
const wxSize& size = wxSize(45 * em, 35 * em);
|
||||
SetMinSize(size);
|
||||
|
||||
Fit();
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void PhysicalPrinterDialog::OnOK(wxEvent& event)
|
||||
{
|
||||
wxString printer_name = m_printer_name->GetValue();
|
||||
if (printer_name.IsEmpty()) {
|
||||
warning_catcher(this, _L("The supplied name is empty. It can't be saved."));
|
||||
return;
|
||||
}
|
||||
if (printer_name == m_default_name) {
|
||||
warning_catcher(this, _L("You should to change a name of your printer device. It can't be saved."));
|
||||
return;
|
||||
}
|
||||
|
||||
PhysicalPrinterCollection& printers = wxGetApp().preset_bundle->physical_printers;
|
||||
const PhysicalPrinter* existing = printers.find_printer(into_u8(printer_name));
|
||||
if (existing && into_u8(printer_name) != printers.get_selected_printer_name())
|
||||
{
|
||||
wxString msg_text = from_u8((boost::format(_u8L("Printer with name \"%1%\" already exists.")) % printer_name).str());
|
||||
msg_text += "\n" + _L("Replace?");
|
||||
wxMessageDialog dialog(nullptr, msg_text, _L("Warning"), wxICON_WARNING | wxYES | wxNO);
|
||||
|
||||
if (dialog.ShowModal() == wxID_NO)
|
||||
return;
|
||||
}
|
||||
|
||||
std::set<std::string> repeat_presets;
|
||||
m_printer.reset_presets();
|
||||
for (PresetForPrinter* preset : m_presets) {
|
||||
if (!m_printer.add_preset(preset->get_preset_name()))
|
||||
repeat_presets.emplace(preset->get_preset_name());
|
||||
}
|
||||
|
||||
if (!repeat_presets.empty())
|
||||
{
|
||||
wxString repeatable_presets = "\n";
|
||||
for (const std::string& preset_name : repeat_presets)
|
||||
repeatable_presets += " " + from_u8(preset_name) + "\n";
|
||||
repeatable_presets += "\n";
|
||||
|
||||
wxString msg_text = from_u8((boost::format(_u8L("Next printer preset(s) is(are) duplicated:%1%"
|
||||
"Should I add it(they) just once for the printer \"%2%\" and close the Editing Dialog?")) % repeatable_presets % printer_name).str());
|
||||
wxMessageDialog dialog(nullptr, msg_text, _L("Warning"), wxICON_WARNING | wxYES | wxNO);
|
||||
if (dialog.ShowModal() == wxID_NO)
|
||||
return;
|
||||
}
|
||||
|
||||
std::string renamed_from;
|
||||
// temporary save previous printer name if it was edited
|
||||
if (m_printer.name != into_u8(m_default_name) &&
|
||||
m_printer.name != into_u8(printer_name))
|
||||
renamed_from = m_printer.name;
|
||||
|
||||
//update printer name, if it was changed
|
||||
m_printer.set_name(into_u8(printer_name));
|
||||
|
||||
// save new physical printer
|
||||
printers.save_printer(m_printer, renamed_from);
|
||||
|
||||
if (m_printer.preset_names.find(printers.get_selected_printer_preset_name()) == m_printer.preset_names.end()) {
|
||||
// select first preset for this printer
|
||||
printers.select_printer(m_printer);
|
||||
// refresh preset list on Printer Settings Tab
|
||||
wxGetApp().get_tab(Preset::TYPE_PRINTER)->select_preset(printers.get_selected_printer_preset_name());
|
||||
}
|
||||
else
|
||||
wxGetApp().get_tab(Preset::TYPE_PRINTER)->update_preset_choice();
|
||||
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
void PhysicalPrinterDialog::AddPreset(wxEvent& event)
|
||||
{
|
||||
m_presets.emplace_back(new PresetForPrinter(this));
|
||||
// enable DELETE button for the first preset, if was disabled
|
||||
m_presets.front()->AllowDelete();
|
||||
|
||||
m_presets_sizer->Add(m_presets.back()->sizer(), 1, wxEXPAND | wxTOP, BORDER_W);
|
||||
update_full_printer_names();
|
||||
|
||||
this->Fit();
|
||||
}
|
||||
|
||||
void PhysicalPrinterDialog::DeletePreset(PresetForPrinter* preset_for_printer)
|
||||
{
|
||||
if (m_presets.size() == 1) {
|
||||
wxString msg_text = _L("It's not possible to delete last related preset for the printer.");
|
||||
wxMessageDialog dialog(nullptr, msg_text, _L("Infornation"), wxICON_INFORMATION | wxOK);
|
||||
dialog.ShowModal();
|
||||
return;
|
||||
}
|
||||
|
||||
assert(preset_for_printer);
|
||||
auto it = std::find(m_presets.begin(), m_presets.end(), preset_for_printer);
|
||||
if (it == m_presets.end())
|
||||
return;
|
||||
|
||||
const int remove_id = it - m_presets.begin();
|
||||
m_presets_sizer->Remove(remove_id);
|
||||
delete preset_for_printer;
|
||||
m_presets.erase(it);
|
||||
|
||||
if (m_presets.size() == 1)
|
||||
m_presets.front()->SuppressDelete();
|
||||
|
||||
this->Layout();
|
||||
this->Fit();
|
||||
}
|
||||
|
||||
|
||||
}} // namespace Slic3r::GUI
|
||||
105
src/slic3r/GUI/PhysicalPrinterDialog.hpp
Normal file
105
src/slic3r/GUI/PhysicalPrinterDialog.hpp
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
#ifndef slic3r_PhysicalPrinterDialog_hpp_
|
||||
#define slic3r_PhysicalPrinterDialog_hpp_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <wx/gdicmn.h>
|
||||
|
||||
#include "libslic3r/Preset.hpp"
|
||||
#include "GUI_Utils.hpp"
|
||||
|
||||
class wxString;
|
||||
class wxTextCtrl;
|
||||
class wxStaticText;
|
||||
class ScalableButton;
|
||||
class wxBoxSizer;
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
namespace GUI {
|
||||
|
||||
class PresetComboBox;
|
||||
|
||||
//------------------------------------------
|
||||
// PresetForPrinter
|
||||
//------------------------------------------
|
||||
//static std::string g_info_string = " (modified)";
|
||||
class PhysicalPrinterDialog;
|
||||
class PresetForPrinter
|
||||
{
|
||||
PhysicalPrinterDialog* m_parent { nullptr };
|
||||
|
||||
PresetComboBox* m_presets_list { nullptr };
|
||||
ScalableButton* m_delete_preset_btn { nullptr };
|
||||
wxStaticText* m_info_line { nullptr };
|
||||
wxStaticText* m_full_printer_name { nullptr };
|
||||
|
||||
wxBoxSizer* m_sizer { nullptr };
|
||||
|
||||
void DeletePreset(wxEvent& event);
|
||||
|
||||
public:
|
||||
PresetForPrinter(PhysicalPrinterDialog* parent, const std::string& preset_name = "");
|
||||
~PresetForPrinter();
|
||||
|
||||
wxBoxSizer* sizer() { return m_sizer; }
|
||||
void update_full_printer_name();
|
||||
std::string get_preset_name();
|
||||
void SuppressDelete();
|
||||
void AllowDelete();
|
||||
|
||||
void msw_rescale();
|
||||
void on_sys_color_changed() {};
|
||||
};
|
||||
|
||||
|
||||
//------------------------------------------
|
||||
// PhysicalPrinterDialog
|
||||
//------------------------------------------
|
||||
|
||||
class ConfigOptionsGroup;
|
||||
class PhysicalPrinterDialog : public DPIDialog
|
||||
{
|
||||
PhysicalPrinter m_printer;
|
||||
wxString m_default_name;
|
||||
DynamicPrintConfig* m_config { nullptr };
|
||||
|
||||
wxTextCtrl* m_printer_name { nullptr };
|
||||
std::vector<PresetForPrinter*> m_presets;
|
||||
|
||||
ConfigOptionsGroup* m_optgroup { nullptr };
|
||||
|
||||
ScalableButton* m_add_preset_btn {nullptr};
|
||||
ScalableButton* m_printhost_browse_btn {nullptr};
|
||||
ScalableButton* m_printhost_test_btn {nullptr};
|
||||
ScalableButton* m_printhost_cafile_browse_btn {nullptr};
|
||||
|
||||
wxBoxSizer* m_presets_sizer {nullptr};
|
||||
|
||||
void build_printhost_settings(ConfigOptionsGroup* optgroup);
|
||||
void OnOK(wxEvent& event);
|
||||
void AddPreset(wxEvent& event);
|
||||
|
||||
public:
|
||||
PhysicalPrinterDialog(wxString printer_name);
|
||||
~PhysicalPrinterDialog();
|
||||
|
||||
void update();
|
||||
wxString get_printer_name();
|
||||
void update_full_printer_names();
|
||||
PhysicalPrinter* get_printer() {return &m_printer; }
|
||||
void set_printer_technology(PrinterTechnology pt);
|
||||
PrinterTechnology get_printer_technology();
|
||||
|
||||
void DeletePreset(PresetForPrinter* preset_for_printer);
|
||||
|
||||
protected:
|
||||
void on_dpi_changed(const wxRect& suggested_rect) override;
|
||||
void on_sys_color_changed() override {};
|
||||
};
|
||||
|
||||
|
||||
} // namespace GUI
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif
|
||||
|
|
@ -24,7 +24,6 @@
|
|||
#include <wx/dnd.h>
|
||||
#include <wx/progdlg.h>
|
||||
#include <wx/wupdlock.h>
|
||||
#include <wx/colordlg.h>
|
||||
#include <wx/numdlg.h>
|
||||
#include <wx/debug.h>
|
||||
#include <wx/busyinfo.h>
|
||||
|
|
@ -48,6 +47,7 @@
|
|||
#include "libslic3r/PrintConfig.hpp"
|
||||
#include "libslic3r/SLAPrint.hpp"
|
||||
#include "libslic3r/Utils.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
|
||||
#include "GUI.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
|
|
@ -70,7 +70,6 @@
|
|||
#include "Jobs/ArrangeJob.hpp"
|
||||
#include "Jobs/RotoptimizeJob.hpp"
|
||||
#include "Jobs/SLAImportJob.hpp"
|
||||
#include "PresetBundle.hpp"
|
||||
#include "BackgroundSlicingProcess.hpp"
|
||||
#include "ProgressStatusBar.hpp"
|
||||
#include "PrintHostDialogs.hpp"
|
||||
|
|
@ -83,6 +82,7 @@
|
|||
#include "RemovableDriveManager.hpp"
|
||||
#include "InstanceCheck.hpp"
|
||||
#include "NotificationManager.hpp"
|
||||
#include "PresetComboBoxes.hpp"
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include "Gizmos/GLGizmosManager.hpp"
|
||||
|
|
@ -260,153 +260,6 @@ void SlicedInfo::SetTextAndShow(SlicedInfoIdx idx, const wxString& text, const w
|
|||
info_vec[idx].second->Show(show);
|
||||
}
|
||||
|
||||
PresetComboBox::PresetComboBox(wxWindow *parent, Preset::Type preset_type) :
|
||||
PresetBitmapComboBox(parent, wxSize(15 * wxGetApp().em_unit(), -1)),
|
||||
preset_type(preset_type),
|
||||
last_selected(wxNOT_FOUND),
|
||||
m_em_unit(wxGetApp().em_unit())
|
||||
{
|
||||
SetFont(wxGetApp().normal_font());
|
||||
#ifdef _WIN32
|
||||
// Workaround for ignoring CBN_EDITCHANGE events, which are processed after the content of the combo box changes, so that
|
||||
// the index of the item inside CBN_EDITCHANGE may no more be valid.
|
||||
EnableTextChangedEvents(false);
|
||||
#endif /* _WIN32 */
|
||||
Bind(wxEVT_COMBOBOX, [this](wxCommandEvent &evt) {
|
||||
auto selected_item = evt.GetSelection();
|
||||
|
||||
auto marker = reinterpret_cast<Marker>(this->GetClientData(selected_item));
|
||||
if (marker >= LABEL_ITEM_MARKER && marker < LABEL_ITEM_MAX) {
|
||||
this->SetSelection(this->last_selected);
|
||||
evt.StopPropagation();
|
||||
if (marker >= LABEL_ITEM_WIZARD_PRINTERS) {
|
||||
ConfigWizard::StartPage sp = ConfigWizard::SP_WELCOME;
|
||||
switch (marker) {
|
||||
case LABEL_ITEM_WIZARD_PRINTERS: sp = ConfigWizard::SP_PRINTERS; break;
|
||||
case LABEL_ITEM_WIZARD_FILAMENTS: sp = ConfigWizard::SP_FILAMENTS; break;
|
||||
case LABEL_ITEM_WIZARD_MATERIALS: sp = ConfigWizard::SP_MATERIALS; break;
|
||||
}
|
||||
wxTheApp->CallAfter([sp]() { wxGetApp().run_wizard(ConfigWizard::RR_USER, sp); });
|
||||
}
|
||||
} else if ( this->last_selected != selected_item ||
|
||||
wxGetApp().get_tab(this->preset_type)->get_presets()->current_is_dirty() ) {
|
||||
this->last_selected = selected_item;
|
||||
evt.SetInt(this->preset_type);
|
||||
evt.Skip();
|
||||
} else {
|
||||
evt.StopPropagation();
|
||||
}
|
||||
});
|
||||
|
||||
if (preset_type == Slic3r::Preset::TYPE_FILAMENT)
|
||||
{
|
||||
Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &event) {
|
||||
PresetBundle* preset_bundle = wxGetApp().preset_bundle;
|
||||
const Preset* selected_preset = preset_bundle->filaments.find_preset(preset_bundle->filament_presets[extruder_idx]);
|
||||
// Wide icons are shown if the currently selected preset is not compatible with the current printer,
|
||||
// and red flag is drown in front of the selected preset.
|
||||
bool wide_icons = selected_preset != nullptr && !selected_preset->is_compatible;
|
||||
float scale = m_em_unit*0.1f;
|
||||
|
||||
int shifl_Left = wide_icons ? int(scale * 16 + 0.5) : 0;
|
||||
#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 = shifl_Left + int(scale * (24+4) + 0.5);
|
||||
int mouse_pos = event.GetLogicalPosition(wxClientDC(this)).x;
|
||||
if (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 = wxColour(0,0,0); // Don't set alfa to transparence
|
||||
|
||||
auto data = new wxColourData();
|
||||
data->SetChooseFull(1);
|
||||
data->SetColour(clr);
|
||||
|
||||
wxColourDialog dialog(this, data);
|
||||
dialog.CenterOnParent();
|
||||
if (dialog.ShowModal() == wxID_OK)
|
||||
{
|
||||
colors->values[extruder_idx] = dialog.GetColourData().GetColour().GetAsString(wxC2S_HTML_SYNTAX).ToStdString();
|
||||
|
||||
DynamicPrintConfig cfg_new = *cfg;
|
||||
cfg_new.set_key_value("extruder_colour", colors);
|
||||
|
||||
wxGetApp().get_tab(Preset::TYPE_PRINTER)->load_config(cfg_new);
|
||||
preset_bundle->update_plater_filament_ui(extruder_idx, this);
|
||||
wxGetApp().plater()->on_config_change(cfg_new);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
edit_btn = new ScalableButton(parent, wxID_ANY, "cog");
|
||||
edit_btn->SetToolTip(_L("Click to edit preset"));
|
||||
|
||||
edit_btn->Bind(wxEVT_BUTTON, ([preset_type, this](wxCommandEvent)
|
||||
{
|
||||
Tab* tab = wxGetApp().get_tab(preset_type);
|
||||
if (!tab)
|
||||
return;
|
||||
|
||||
int page_id = wxGetApp().tab_panel()->FindPage(tab);
|
||||
if (page_id == wxNOT_FOUND)
|
||||
return;
|
||||
|
||||
wxGetApp().tab_panel()->SetSelection(page_id);
|
||||
|
||||
// Switch to Settings NotePad
|
||||
wxGetApp().mainframe->select_tab();
|
||||
|
||||
/* 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_edited_cnt() > 1)
|
||||
{
|
||||
const std::string& selected_preset = GetString(GetSelection()).ToUTF8().data();
|
||||
|
||||
// Call select_preset() only if there is new preset and not just modified
|
||||
if ( !boost::algorithm::ends_with(selected_preset, Preset::suffix_modified()) )
|
||||
{
|
||||
const std::string& preset_name = wxGetApp().preset_bundle->filaments.get_preset_name_by_alias(selected_preset);
|
||||
tab->select_preset(/*selected_preset*/preset_name);
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
PresetComboBox::~PresetComboBox()
|
||||
{
|
||||
if (edit_btn)
|
||||
edit_btn->Destroy();
|
||||
}
|
||||
|
||||
|
||||
void PresetComboBox::set_label_marker(int item, LabelItemType label_item_type)
|
||||
{
|
||||
this->SetClientData(item, (void*)label_item_type);
|
||||
}
|
||||
|
||||
void PresetComboBox::check_selection(int selection)
|
||||
{
|
||||
this->last_selected = selection;
|
||||
}
|
||||
|
||||
void PresetComboBox::msw_rescale()
|
||||
{
|
||||
m_em_unit = wxGetApp().em_unit();
|
||||
edit_btn->msw_rescale();
|
||||
}
|
||||
|
||||
// Frequently changed parameters
|
||||
|
||||
class FreqChangedParams : public OG_Settings
|
||||
|
|
@ -704,12 +557,12 @@ struct Sidebar::priv
|
|||
|
||||
ModeSizer *mode_sizer;
|
||||
wxFlexGridSizer *sizer_presets;
|
||||
PresetComboBox *combo_print;
|
||||
std::vector<PresetComboBox*> combos_filament;
|
||||
PlaterPresetComboBox *combo_print;
|
||||
std::vector<PlaterPresetComboBox*> combos_filament;
|
||||
wxBoxSizer *sizer_filaments;
|
||||
PresetComboBox *combo_sla_print;
|
||||
PresetComboBox *combo_sla_material;
|
||||
PresetComboBox *combo_printer;
|
||||
PlaterPresetComboBox *combo_sla_print;
|
||||
PlaterPresetComboBox *combo_sla_material;
|
||||
PlaterPresetComboBox *combo_printer;
|
||||
|
||||
wxBoxSizer *sizer_params;
|
||||
FreqChangedParams *frequently_changed_parameters{ nullptr };
|
||||
|
|
@ -808,10 +661,10 @@ Sidebar::Sidebar(Plater *parent)
|
|||
|
||||
p->sizer_filaments = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
auto init_combo = [this](PresetComboBox **combo, wxString label, Preset::Type preset_type, bool filament) {
|
||||
auto init_combo = [this](PlaterPresetComboBox **combo, wxString label, Preset::Type preset_type, bool filament) {
|
||||
auto *text = new wxStaticText(p->presets_panel, wxID_ANY, label + " :");
|
||||
text->SetFont(wxGetApp().small_font());
|
||||
*combo = new PresetComboBox(p->presets_panel, preset_type);
|
||||
*combo = new PlaterPresetComboBox(p->presets_panel, preset_type);
|
||||
|
||||
auto combo_and_btn_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
combo_and_btn_sizer->Add(*combo, 1, wxEXPAND);
|
||||
|
|
@ -948,8 +801,8 @@ Sidebar::Sidebar(Plater *parent)
|
|||
|
||||
Sidebar::~Sidebar() {}
|
||||
|
||||
void Sidebar::init_filament_combo(PresetComboBox **combo, const int extr_idx) {
|
||||
*combo = new PresetComboBox(p->presets_panel, Slic3r::Preset::TYPE_FILAMENT);
|
||||
void Sidebar::init_filament_combo(PlaterPresetComboBox **combo, const int extr_idx) {
|
||||
*combo = new PlaterPresetComboBox(p->presets_panel, Slic3r::Preset::TYPE_FILAMENT);
|
||||
// # copy icons from first choice
|
||||
// $choice->SetItemBitmap($_, $choices->[0]->GetItemBitmap($_)) for 0..$#presets;
|
||||
|
||||
|
|
@ -984,18 +837,18 @@ void Sidebar::update_all_preset_comboboxes()
|
|||
|
||||
// Update the print choosers to only contain the compatible presets, update the dirty flags.
|
||||
if (print_tech == ptFFF)
|
||||
preset_bundle.prints.update_plater_ui(p->combo_print);
|
||||
p->combo_print->update();
|
||||
else {
|
||||
preset_bundle.sla_prints.update_plater_ui(p->combo_sla_print);
|
||||
preset_bundle.sla_materials.update_plater_ui(p->combo_sla_material);
|
||||
p->combo_sla_print->update();
|
||||
p->combo_sla_material->update();
|
||||
}
|
||||
// Update the printer choosers, update the dirty flags.
|
||||
preset_bundle.printers.update_plater_ui(p->combo_printer);
|
||||
p->combo_printer->update();
|
||||
// Update the filament choosers to only contain the compatible presets, update the color preview,
|
||||
// update the dirty flags.
|
||||
if (print_tech == ptFFF) {
|
||||
for (size_t i = 0; i < p->combos_filament.size(); ++i)
|
||||
preset_bundle.update_plater_filament_ui(i, p->combos_filament[i]);
|
||||
for (PlaterPresetComboBox* cb : p->combos_filament)
|
||||
cb->update();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1017,23 +870,22 @@ void Sidebar::update_presets(Preset::Type preset_type)
|
|||
preset_bundle.set_filament_preset(0, name);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < filament_cnt; i++) {
|
||||
preset_bundle.update_plater_filament_ui(i, p->combos_filament[i]);
|
||||
}
|
||||
for (size_t i = 0; i < filament_cnt; i++)
|
||||
p->combos_filament[i]->update();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case Preset::TYPE_PRINT:
|
||||
preset_bundle.prints.update_plater_ui(p->combo_print);
|
||||
p->combo_print->update();
|
||||
break;
|
||||
|
||||
case Preset::TYPE_SLA_PRINT:
|
||||
preset_bundle.sla_prints.update_plater_ui(p->combo_sla_print);
|
||||
p->combo_sla_print->update();
|
||||
break;
|
||||
|
||||
case Preset::TYPE_SLA_MATERIAL:
|
||||
preset_bundle.sla_materials.update_plater_ui(p->combo_sla_material);
|
||||
p->combo_sla_material->update();
|
||||
break;
|
||||
|
||||
case Preset::TYPE_PRINTER:
|
||||
|
|
@ -1069,18 +921,14 @@ void Sidebar::msw_rescale()
|
|||
|
||||
p->mode_sizer->msw_rescale();
|
||||
|
||||
// Rescale preset comboboxes in respect to the current em_unit ...
|
||||
for (PresetComboBox* combo : std::vector<PresetComboBox*> { p->combo_print,
|
||||
for (PlaterPresetComboBox* combo : std::vector<PlaterPresetComboBox*> { p->combo_print,
|
||||
p->combo_sla_print,
|
||||
p->combo_sla_material,
|
||||
p->combo_printer } )
|
||||
combo->msw_rescale();
|
||||
for (PresetComboBox* combo : p->combos_filament)
|
||||
for (PlaterPresetComboBox* combo : p->combos_filament)
|
||||
combo->msw_rescale();
|
||||
|
||||
// ... then refill them and set min size to correct layout of the sidebar
|
||||
update_all_preset_comboboxes();
|
||||
|
||||
p->frequently_changed_parameters->msw_rescale();
|
||||
p->object_list->msw_rescale();
|
||||
p->object_manipulation->msw_rescale();
|
||||
|
|
@ -1101,22 +949,16 @@ void Sidebar::msw_rescale()
|
|||
|
||||
void Sidebar::sys_color_changed()
|
||||
{
|
||||
// Update preset comboboxes in respect to the system color ...
|
||||
// combo->msw_rescale() updates icon on button, so use it
|
||||
for (PresetComboBox* combo : std::vector<PresetComboBox*>{ p->combo_print,
|
||||
for (PlaterPresetComboBox* combo : std::vector<PlaterPresetComboBox*>{ p->combo_print,
|
||||
p->combo_sla_print,
|
||||
p->combo_sla_material,
|
||||
p->combo_printer })
|
||||
combo->msw_rescale();
|
||||
for (PresetComboBox* combo : p->combos_filament)
|
||||
for (PlaterPresetComboBox* combo : p->combos_filament)
|
||||
combo->msw_rescale();
|
||||
|
||||
// ... then refill them and set min size to correct layout of the sidebar
|
||||
update_all_preset_comboboxes();
|
||||
|
||||
p->object_list->sys_color_changed();
|
||||
p->object_manipulation->sys_color_changed();
|
||||
// p->object_settings->msw_rescale();
|
||||
p->object_layers->sys_color_changed();
|
||||
|
||||
// btn...->msw_rescale() updates icon on button, so use it
|
||||
|
|
@ -1479,7 +1321,7 @@ void Sidebar::update_ui_from_settings()
|
|||
update_sliced_info_sizer();
|
||||
}
|
||||
|
||||
std::vector<PresetComboBox*>& Sidebar::combos_filament()
|
||||
std::vector<PlaterPresetComboBox*>& Sidebar::combos_filament()
|
||||
{
|
||||
return p->combos_filament;
|
||||
}
|
||||
|
|
@ -2339,6 +2181,8 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
|
|||
if (!config.empty()) {
|
||||
Preset::normalize(config);
|
||||
wxGetApp().preset_bundle->load_config_model(filename.string(), std::move(config));
|
||||
if (printer_technology == ptFFF)
|
||||
CustomGCode::update_custom_gcode_per_print_z_from_config(model.custom_gcode_per_print_z, &wxGetApp().preset_bundle->project_config);
|
||||
wxGetApp().load_current_presets();
|
||||
is_project_file = true;
|
||||
}
|
||||
|
|
@ -3428,7 +3272,7 @@ void Plater::priv::set_current_panel(wxPanel* panel)
|
|||
void Plater::priv::on_select_preset(wxCommandEvent &evt)
|
||||
{
|
||||
auto preset_type = static_cast<Preset::Type>(evt.GetInt());
|
||||
auto *combo = static_cast<PresetComboBox*>(evt.GetEventObject());
|
||||
auto *combo = static_cast<PlaterPresetComboBox*>(evt.GetEventObject());
|
||||
|
||||
// see https://github.com/prusa3d/PrusaSlicer/issues/3889
|
||||
// Under OSX: in case of use of a same names written in different case (like "ENDER" and "Ender"),
|
||||
|
|
@ -3447,19 +3291,27 @@ void Plater::priv::on_select_preset(wxCommandEvent &evt)
|
|||
//! instead of
|
||||
//! combo->GetStringSelection().ToUTF8().data());
|
||||
|
||||
const std::string preset_name = wxGetApp().preset_bundle->get_preset_name_by_alias(preset_type,
|
||||
std::string preset_name = wxGetApp().preset_bundle->get_preset_name_by_alias(preset_type,
|
||||
Preset::remove_suffix_modified(combo->GetString(selection).ToUTF8().data()));
|
||||
|
||||
if (preset_type == Preset::TYPE_FILAMENT) {
|
||||
wxGetApp().preset_bundle->set_filament_preset(idx, preset_name);
|
||||
}
|
||||
|
||||
bool select_preset = !combo->selection_is_changed_according_to_physical_printers();
|
||||
// TODO: ?
|
||||
if (preset_type == Preset::TYPE_FILAMENT && sidebar->is_multifilament()) {
|
||||
// Only update the plater UI for the 2nd and other filaments.
|
||||
wxGetApp().preset_bundle->update_plater_filament_ui(idx, combo);
|
||||
combo->update();
|
||||
}
|
||||
else {
|
||||
else if (select_preset) {
|
||||
if (preset_type == Preset::TYPE_PRINTER) {
|
||||
PhysicalPrinterCollection& physical_printers = wxGetApp().preset_bundle->physical_printers;
|
||||
if(combo->is_selected_physical_printer())
|
||||
preset_name = physical_printers.get_selected_printer_preset_name();
|
||||
else
|
||||
physical_printers.unselect_printer();
|
||||
}
|
||||
wxWindowUpdateLocker noUpdates(sidebar->presets_panel());
|
||||
wxGetApp().get_tab(preset_type)->select_preset(preset_name);
|
||||
}
|
||||
|
|
@ -4321,7 +4173,12 @@ void Plater::priv::show_action_buttons(const bool ready_to_slice) const
|
|||
this->ready_to_slice = ready_to_slice;
|
||||
|
||||
wxWindowUpdateLocker noUpdater(sidebar);
|
||||
const auto prin_host_opt = config->option<ConfigOptionString>("print_host");
|
||||
|
||||
DynamicPrintConfig* selected_printer_config = wxGetApp().preset_bundle->physical_printers.get_selected_printer_config();
|
||||
if (!selected_printer_config)
|
||||
selected_printer_config = config;
|
||||
|
||||
const auto prin_host_opt = selected_printer_config->option<ConfigOptionString>("print_host");
|
||||
const bool send_gcode_shown = prin_host_opt != nullptr && !prin_host_opt->value.empty();
|
||||
|
||||
// when a background processing is ON, export_btn and/or send_btn are showing
|
||||
|
|
@ -5301,7 +5158,9 @@ void Plater::send_gcode()
|
|||
{
|
||||
if (p->model.objects.empty()) { return; }
|
||||
|
||||
PrintHostJob upload_job(p->config);
|
||||
// if physical_printer is selected, send gcode for this printer
|
||||
DynamicPrintConfig* physical_printer_config = wxGetApp().preset_bundle->physical_printers.get_selected_printer_config();
|
||||
PrintHostJob upload_job(physical_printer_config ? physical_printer_config : p->config);
|
||||
if (upload_job.empty()) { return; }
|
||||
|
||||
// Obtain default output path
|
||||
|
|
@ -5412,12 +5271,12 @@ void Plater::on_extruders_change(size_t num_extruders)
|
|||
size_t i = choices.size();
|
||||
while ( i < num_extruders )
|
||||
{
|
||||
PresetComboBox* choice/*{ nullptr }*/;
|
||||
PlaterPresetComboBox* choice/*{ nullptr }*/;
|
||||
sidebar().init_filament_combo(&choice, i);
|
||||
choices.push_back(choice);
|
||||
|
||||
// initialize selection
|
||||
wxGetApp().preset_bundle->update_plater_filament_ui(i, choice);
|
||||
choice->update();
|
||||
++i;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,14 +6,12 @@
|
|||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
#include <wx/panel.h>
|
||||
#include <wx/bmpcbox.h>
|
||||
|
||||
#include "Preset.hpp"
|
||||
#include "Selection.hpp"
|
||||
|
||||
#include "libslic3r/Preset.hpp"
|
||||
#include "libslic3r/BoundingBox.hpp"
|
||||
#include "Jobs/Job.hpp"
|
||||
#include "wxExtensions.hpp"
|
||||
#include "Search.hpp"
|
||||
|
||||
class wxButton;
|
||||
|
|
@ -51,46 +49,13 @@ class NotificationManager;
|
|||
struct Camera;
|
||||
class Bed3D;
|
||||
class GLToolbar;
|
||||
class PlaterPresetComboBox;
|
||||
|
||||
using t_optgroups = std::vector <std::shared_ptr<ConfigOptionsGroup>>;
|
||||
|
||||
class Plater;
|
||||
enum class ActionButtonType : int;
|
||||
|
||||
class PresetComboBox : public PresetBitmapComboBox
|
||||
{
|
||||
public:
|
||||
PresetComboBox(wxWindow *parent, Preset::Type preset_type);
|
||||
~PresetComboBox();
|
||||
|
||||
ScalableButton* edit_btn { nullptr };
|
||||
|
||||
enum LabelItemType {
|
||||
LABEL_ITEM_MARKER = 0xffffff01,
|
||||
LABEL_ITEM_WIZARD_PRINTERS,
|
||||
LABEL_ITEM_WIZARD_FILAMENTS,
|
||||
LABEL_ITEM_WIZARD_MATERIALS,
|
||||
|
||||
LABEL_ITEM_MAX,
|
||||
};
|
||||
|
||||
void set_label_marker(int item, LabelItemType label_item_type = LABEL_ITEM_MARKER);
|
||||
void set_extruder_idx(const int extr_idx) { extruder_idx = extr_idx; }
|
||||
int get_extruder_idx() const { return extruder_idx; }
|
||||
int em_unit() const { return m_em_unit; }
|
||||
void check_selection(int selection);
|
||||
|
||||
void msw_rescale();
|
||||
|
||||
private:
|
||||
typedef std::size_t Marker;
|
||||
|
||||
Preset::Type preset_type;
|
||||
int last_selected;
|
||||
int extruder_idx = -1;
|
||||
int m_em_unit;
|
||||
};
|
||||
|
||||
class Sidebar : public wxPanel
|
||||
{
|
||||
ConfigOptionMode m_mode;
|
||||
|
|
@ -102,7 +67,7 @@ public:
|
|||
Sidebar &operator=(const Sidebar &) = delete;
|
||||
~Sidebar();
|
||||
|
||||
void init_filament_combo(PresetComboBox **combo, const int extr_idx);
|
||||
void init_filament_combo(PlaterPresetComboBox **combo, const int extr_idx);
|
||||
void remove_unused_filament_combos(const size_t current_extruder_count);
|
||||
void update_all_preset_comboboxes();
|
||||
void update_presets(Slic3r::Preset::Type preset_type);
|
||||
|
|
@ -141,7 +106,7 @@ public:
|
|||
void update_searcher();
|
||||
void update_ui_from_settings();
|
||||
|
||||
std::vector<PresetComboBox*>& combos_filament();
|
||||
std::vector<PlaterPresetComboBox*>& combos_filament();
|
||||
Search::OptionsSearcher& get_searcher();
|
||||
std::string& get_search_line();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
#include "Preferences.hpp"
|
||||
#include "AppConfig.hpp"
|
||||
#include "OptionsGroup.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "I18N.hpp"
|
||||
#include "libslic3r/AppConfig.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,590 +0,0 @@
|
|||
#ifndef slic3r_Preset_hpp_
|
||||
#define slic3r_Preset_hpp_
|
||||
|
||||
#include <deque>
|
||||
#include <set>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/property_tree/ptree_fwd.hpp>
|
||||
|
||||
#include "libslic3r/libslic3r.h"
|
||||
#include "libslic3r/PrintConfig.hpp"
|
||||
#include "libslic3r/Semver.hpp"
|
||||
|
||||
class wxBitmap;
|
||||
class wxBitmapComboBox;
|
||||
class wxChoice;
|
||||
class wxItemContainer;
|
||||
class wxString;
|
||||
class wxWindow;
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
class AppConfig;
|
||||
class PresetBundle;
|
||||
|
||||
namespace GUI {
|
||||
class BitmapCache;
|
||||
class PresetComboBox;
|
||||
}
|
||||
|
||||
enum ConfigFileType
|
||||
{
|
||||
CONFIG_FILE_TYPE_UNKNOWN,
|
||||
CONFIG_FILE_TYPE_APP_CONFIG,
|
||||
CONFIG_FILE_TYPE_CONFIG,
|
||||
CONFIG_FILE_TYPE_CONFIG_BUNDLE,
|
||||
};
|
||||
|
||||
extern ConfigFileType guess_config_file_type(const boost::property_tree::ptree &tree);
|
||||
|
||||
class VendorProfile
|
||||
{
|
||||
public:
|
||||
std::string name;
|
||||
std::string id;
|
||||
Semver config_version;
|
||||
std::string config_update_url;
|
||||
std::string changelog_url;
|
||||
|
||||
struct PrinterVariant {
|
||||
PrinterVariant() {}
|
||||
PrinterVariant(const std::string &name) : name(name) {}
|
||||
std::string name;
|
||||
};
|
||||
|
||||
struct PrinterModel {
|
||||
PrinterModel() {}
|
||||
std::string id;
|
||||
std::string name;
|
||||
PrinterTechnology technology;
|
||||
std::string family;
|
||||
std::vector<PrinterVariant> variants;
|
||||
std::vector<std::string> default_materials;
|
||||
// Vendor & Printer Model specific print bed model & texture.
|
||||
std::string bed_model;
|
||||
std::string bed_texture;
|
||||
|
||||
PrinterVariant* variant(const std::string &name) {
|
||||
for (auto &v : this->variants)
|
||||
if (v.name == name)
|
||||
return &v;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const PrinterVariant* variant(const std::string &name) const { return const_cast<PrinterModel*>(this)->variant(name); }
|
||||
};
|
||||
std::vector<PrinterModel> models;
|
||||
|
||||
std::set<std::string> default_filaments;
|
||||
std::set<std::string> default_sla_materials;
|
||||
|
||||
VendorProfile() {}
|
||||
VendorProfile(std::string id) : id(std::move(id)) {}
|
||||
|
||||
bool valid() const { return ! name.empty() && ! id.empty() && config_version.valid(); }
|
||||
|
||||
// Load VendorProfile from an ini file.
|
||||
// If `load_all` is false, only the header with basic info (name, version, URLs) is loaded.
|
||||
static VendorProfile from_ini(const boost::filesystem::path &path, bool load_all=true);
|
||||
static VendorProfile from_ini(const boost::property_tree::ptree &tree, const boost::filesystem::path &path, bool load_all=true);
|
||||
|
||||
size_t num_variants() const { size_t n = 0; for (auto &model : models) n += model.variants.size(); return n; }
|
||||
std::vector<std::string> families() const;
|
||||
|
||||
bool operator< (const VendorProfile &rhs) const { return this->id < rhs.id; }
|
||||
bool operator==(const VendorProfile &rhs) const { return this->id == rhs.id; }
|
||||
};
|
||||
|
||||
class Preset;
|
||||
|
||||
// Helper to hold a profile with its vendor definition, where the vendor definition may have been extracted from a parent system preset.
|
||||
// The parent preset is only accessible through PresetCollection, therefore to allow definition of the various is_compatible_with methods
|
||||
// outside of the PresetCollection, this composite is returned by PresetCollection::get_preset_with_vendor_profile() when needed.
|
||||
struct PresetWithVendorProfile {
|
||||
PresetWithVendorProfile(const Preset &preset, const VendorProfile *vendor) : preset(preset), vendor(vendor) {}
|
||||
const Preset &preset;
|
||||
const VendorProfile *vendor;
|
||||
};
|
||||
|
||||
// Note: it is imporant that map is used here rather than unordered_map,
|
||||
// because we need iterators to not be invalidated,
|
||||
// because Preset and the ConfigWizard hold pointers to VendorProfiles.
|
||||
// XXX: maybe set is enough (cf. changes in Wizard)
|
||||
typedef std::map<std::string, VendorProfile> VendorMap;
|
||||
|
||||
class Preset
|
||||
{
|
||||
public:
|
||||
enum Type
|
||||
{
|
||||
TYPE_INVALID,
|
||||
TYPE_PRINT,
|
||||
TYPE_SLA_PRINT,
|
||||
TYPE_FILAMENT,
|
||||
TYPE_SLA_MATERIAL,
|
||||
TYPE_PRINTER,
|
||||
TYPE_COUNT,
|
||||
};
|
||||
|
||||
Preset(Type type, const std::string &name, bool is_default = false) : type(type), is_default(is_default), name(name) {}
|
||||
|
||||
Type type = TYPE_INVALID;
|
||||
|
||||
// The preset represents a "default" set of properties,
|
||||
// pulled from the default values of the PrintConfig (see PrintConfigDef for their definitions).
|
||||
bool is_default;
|
||||
// External preset points to a configuration, which has been loaded but not imported
|
||||
// into the Slic3r default configuration location.
|
||||
bool is_external = false;
|
||||
// System preset is read-only.
|
||||
bool is_system = false;
|
||||
// Preset is visible, if it is associated with a printer model / variant that is enabled in the AppConfig
|
||||
// or if it has no printer model / variant association.
|
||||
// Also the "default" preset is only visible, if it is the only preset in the list.
|
||||
bool is_visible = true;
|
||||
// Has this preset been modified?
|
||||
bool is_dirty = false;
|
||||
// Is this preset compatible with the currently active printer?
|
||||
bool is_compatible = true;
|
||||
|
||||
bool is_user() const { return ! this->is_default && ! this->is_system; }
|
||||
|
||||
// Name of the preset, usually derived form the file name.
|
||||
std::string name;
|
||||
// File name of the preset. This could be a Print / Filament / Printer preset,
|
||||
// or a Configuration file bundling the Print + Filament + Printer presets (in that case is_external and possibly is_system will be true),
|
||||
// or it could be a G-code (again, is_external will be true).
|
||||
std::string file;
|
||||
// If this is a system profile, then there should be a vendor data available to display at the UI.
|
||||
const VendorProfile *vendor = nullptr;
|
||||
|
||||
// Has this profile been loaded?
|
||||
bool loaded = false;
|
||||
|
||||
// Configuration data, loaded from a file, or set from the defaults.
|
||||
DynamicPrintConfig config;
|
||||
|
||||
// Alias of the preset
|
||||
std::string alias;
|
||||
// List of profile names, from which this profile was renamed at some point of time.
|
||||
// This list is then used to match profiles by their names when loaded from .gcode, .3mf, .amf,
|
||||
// and to match the "inherits" field of user profiles with updated system profiles.
|
||||
std::vector<std::string> renamed_from;
|
||||
|
||||
void save();
|
||||
|
||||
// Return a label of this preset, consisting of a name and a "(modified)" suffix, if this preset is dirty.
|
||||
std::string label() const;
|
||||
|
||||
// Set the is_dirty flag if the provided config is different from the active one.
|
||||
void set_dirty(const DynamicPrintConfig &config) { this->is_dirty = ! this->config.diff(config).empty(); }
|
||||
void set_dirty(bool dirty = true) { this->is_dirty = dirty; }
|
||||
void reset_dirty() { this->is_dirty = false; }
|
||||
|
||||
// Returns the name of the preset, from which this preset inherits.
|
||||
static std::string& inherits(DynamicPrintConfig &cfg) { return cfg.option<ConfigOptionString>("inherits", true)->value; }
|
||||
std::string& inherits() { return Preset::inherits(this->config); }
|
||||
const std::string& inherits() const { return Preset::inherits(const_cast<Preset*>(this)->config); }
|
||||
|
||||
// Returns the "compatible_prints_condition".
|
||||
static std::string& compatible_prints_condition(DynamicPrintConfig &cfg) { return cfg.option<ConfigOptionString>("compatible_prints_condition", true)->value; }
|
||||
std::string& compatible_prints_condition() {
|
||||
assert(this->type == TYPE_FILAMENT || this->type == TYPE_SLA_MATERIAL);
|
||||
return Preset::compatible_prints_condition(this->config);
|
||||
}
|
||||
const std::string& compatible_prints_condition() const { return const_cast<Preset*>(this)->compatible_prints_condition(); }
|
||||
|
||||
// Returns the "compatible_printers_condition".
|
||||
static std::string& compatible_printers_condition(DynamicPrintConfig &cfg) { return cfg.option<ConfigOptionString>("compatible_printers_condition", true)->value; }
|
||||
std::string& compatible_printers_condition() {
|
||||
assert(this->type == TYPE_PRINT || this->type == TYPE_SLA_PRINT || this->type == TYPE_FILAMENT || this->type == TYPE_SLA_MATERIAL);
|
||||
return Preset::compatible_printers_condition(this->config);
|
||||
}
|
||||
const std::string& compatible_printers_condition() const { return const_cast<Preset*>(this)->compatible_printers_condition(); }
|
||||
|
||||
// Return a printer technology, return ptFFF if the printer technology is not set.
|
||||
static PrinterTechnology printer_technology(const DynamicPrintConfig &cfg) {
|
||||
auto *opt = cfg.option<ConfigOptionEnum<PrinterTechnology>>("printer_technology");
|
||||
// The following assert may trigger when importing some legacy profile,
|
||||
// but it is safer to keep it here to capture the cases where the "printer_technology" key is queried, where it should not.
|
||||
// assert(opt != nullptr);
|
||||
return (opt == nullptr) ? ptFFF : opt->value;
|
||||
}
|
||||
PrinterTechnology printer_technology() const { return Preset::printer_technology(this->config); }
|
||||
// This call returns a reference, it may add a new entry into the DynamicPrintConfig.
|
||||
PrinterTechnology& printer_technology_ref() { return this->config.option<ConfigOptionEnum<PrinterTechnology>>("printer_technology", true)->value; }
|
||||
|
||||
// Set is_visible according to application config
|
||||
void set_visible_from_appconfig(const AppConfig &app_config);
|
||||
|
||||
// Resize the extruder specific fields, initialize them with the content of the 1st extruder.
|
||||
void set_num_extruders(unsigned int n) { this->config.set_num_extruders(n); }
|
||||
|
||||
// Sort lexicographically by a preset name. The preset name shall be unique across a single PresetCollection.
|
||||
bool operator<(const Preset &other) const { return this->name < other.name; }
|
||||
|
||||
static const std::vector<std::string>& print_options();
|
||||
static const std::vector<std::string>& filament_options();
|
||||
// Printer options contain the nozzle options.
|
||||
static const std::vector<std::string>& printer_options();
|
||||
// Nozzle options of the printer options.
|
||||
static const std::vector<std::string>& nozzle_options();
|
||||
|
||||
static const std::vector<std::string>& sla_printer_options();
|
||||
static const std::vector<std::string>& sla_material_options();
|
||||
static const std::vector<std::string>& sla_print_options();
|
||||
|
||||
static void update_suffix_modified();
|
||||
static const std::string& suffix_modified();
|
||||
static std::string remove_suffix_modified(const std::string& name);
|
||||
static void normalize(DynamicPrintConfig &config);
|
||||
// Report configuration fields, which are misplaced into a wrong group, remove them from the config.
|
||||
static std::string remove_invalid_keys(DynamicPrintConfig &config, const DynamicPrintConfig &default_config);
|
||||
|
||||
protected:
|
||||
friend class PresetCollection;
|
||||
friend class PresetBundle;
|
||||
};
|
||||
|
||||
bool is_compatible_with_print (const PresetWithVendorProfile &preset, const PresetWithVendorProfile &active_print, const PresetWithVendorProfile &active_printer);
|
||||
bool is_compatible_with_printer(const PresetWithVendorProfile &preset, const PresetWithVendorProfile &active_printer, const DynamicPrintConfig *extra_config);
|
||||
bool is_compatible_with_printer(const PresetWithVendorProfile &preset, const PresetWithVendorProfile &active_printer);
|
||||
|
||||
enum class PresetSelectCompatibleType {
|
||||
// Never select a compatible preset if the newly selected profile is not compatible.
|
||||
Never,
|
||||
// Only select a compatible preset if the active profile used to be compatible, but it is no more.
|
||||
OnlyIfWasCompatible,
|
||||
// Always select a compatible preset if the active profile is no more compatible.
|
||||
Always
|
||||
};
|
||||
|
||||
// Collections of presets of the same type (one of the Print, Filament or Printer type).
|
||||
class PresetCollection
|
||||
{
|
||||
public:
|
||||
// Initialize the PresetCollection with the "- default -" preset.
|
||||
PresetCollection(Preset::Type type, const std::vector<std::string> &keys, const Slic3r::StaticPrintConfig &defaults, const std::string &default_name = "- default -");
|
||||
~PresetCollection();
|
||||
|
||||
typedef std::deque<Preset>::iterator Iterator;
|
||||
typedef std::deque<Preset>::const_iterator ConstIterator;
|
||||
Iterator begin() { return m_presets.begin() + m_num_default_presets; }
|
||||
ConstIterator begin() const { return m_presets.cbegin() + m_num_default_presets; }
|
||||
ConstIterator cbegin() const { return m_presets.cbegin() + m_num_default_presets; }
|
||||
Iterator end() { return m_presets.end(); }
|
||||
ConstIterator end() const { return m_presets.cend(); }
|
||||
ConstIterator cend() const { return m_presets.cend(); }
|
||||
|
||||
void reset(bool delete_files);
|
||||
|
||||
Preset::Type type() const { return m_type; }
|
||||
// Name, to be used on the screen and in error messages. Not localized.
|
||||
std::string name() const;
|
||||
// Name, to be used as a section name in config bundle, and as a folder name for presets.
|
||||
std::string section_name() const;
|
||||
const std::deque<Preset>& operator()() const { return m_presets; }
|
||||
|
||||
// Add default preset at the start of the collection, increment the m_default_preset counter.
|
||||
void add_default_preset(const std::vector<std::string> &keys, const Slic3r::StaticPrintConfig &defaults, const std::string &preset_name);
|
||||
|
||||
// Load ini files of the particular type from the provided directory path.
|
||||
void load_presets(const std::string &dir_path, const std::string &subdir);
|
||||
|
||||
// Load a preset from an already parsed config file, insert it into the sorted sequence of presets
|
||||
// and select it, losing previous modifications.
|
||||
Preset& load_preset(const std::string &path, const std::string &name, const DynamicPrintConfig &config, bool select = true);
|
||||
Preset& load_preset(const std::string &path, const std::string &name, DynamicPrintConfig &&config, bool select = true);
|
||||
|
||||
Preset& load_external_preset(
|
||||
// Path to the profile source file (a G-code, an AMF or 3MF file, a config file)
|
||||
const std::string &path,
|
||||
// Name of the profile, derived from the source file name.
|
||||
const std::string &name,
|
||||
// Original name of the profile, extracted from the loaded config. Empty, if the name has not been stored.
|
||||
const std::string &original_name,
|
||||
// Config to initialize the preset from.
|
||||
const DynamicPrintConfig &config,
|
||||
// Select the preset after loading?
|
||||
bool select = true);
|
||||
|
||||
// Save the preset under a new name. If the name is different from the old one,
|
||||
// a new preset is stored into the list of presets.
|
||||
// All presets are marked as not modified and the new preset is activated.
|
||||
void save_current_preset(const std::string &new_name, bool detach = false);
|
||||
|
||||
// Delete the current preset, activate the first visible preset.
|
||||
// returns true if the preset was deleted successfully.
|
||||
bool delete_current_preset();
|
||||
// Delete the current preset, activate the first visible preset.
|
||||
// returns true if the preset was deleted successfully.
|
||||
bool delete_preset(const std::string& name);
|
||||
|
||||
// Load default bitmap to be placed at the wxBitmapComboBox of a MainFrame.
|
||||
void load_bitmap_default(const std::string &file_name);
|
||||
|
||||
// Load "add new printer" bitmap to be placed at the wxBitmapComboBox of a MainFrame.
|
||||
void load_bitmap_add(const std::string &file_name);
|
||||
|
||||
// Compatible & incompatible marks, to be placed at the wxBitmapComboBox items.
|
||||
void set_bitmap_compatible (const wxBitmap *bmp) { m_bitmap_compatible = bmp; }
|
||||
void set_bitmap_incompatible(const wxBitmap *bmp) { m_bitmap_incompatible = bmp; }
|
||||
void set_bitmap_lock (const wxBitmap *bmp) { m_bitmap_lock = bmp; }
|
||||
void set_bitmap_lock_open (const wxBitmap *bmp) { m_bitmap_lock_open = bmp; }
|
||||
|
||||
// Enable / disable the "- default -" preset.
|
||||
void set_default_suppressed(bool default_suppressed);
|
||||
bool is_default_suppressed() const { return m_default_suppressed; }
|
||||
|
||||
// Select a preset. If an invalid index is provided, the first visible preset is selected.
|
||||
Preset& select_preset(size_t idx);
|
||||
// Return the selected preset, without the user modifications applied.
|
||||
Preset& get_selected_preset() { return m_presets[m_idx_selected]; }
|
||||
const Preset& get_selected_preset() const { return m_presets[m_idx_selected]; }
|
||||
size_t get_selected_idx() const { return m_idx_selected; }
|
||||
// Returns the name of the selected preset, or an empty string if no preset is selected.
|
||||
std::string get_selected_preset_name() const { return (m_idx_selected == size_t(-1)) ? std::string() : this->get_selected_preset().name; }
|
||||
// For the current edited preset, return the parent preset if there is one.
|
||||
// If there is no parent preset, nullptr is returned.
|
||||
// The parent preset may be a system preset or a user preset, which will be
|
||||
// reflected by the UI.
|
||||
const Preset* get_selected_preset_parent() const;
|
||||
// Get parent preset for a child preset, based on the "inherits" field of a child,
|
||||
// where the "inherits" profile name is searched for in both m_presets and m_map_system_profile_renamed.
|
||||
const Preset* get_preset_parent(const Preset& child) const;
|
||||
// Return the selected preset including the user modifications.
|
||||
Preset& get_edited_preset() { return m_edited_preset; }
|
||||
const Preset& get_edited_preset() const { return m_edited_preset; }
|
||||
|
||||
// Return vendor of the first parent profile, for which the vendor is defined, or null if such profile does not exist.
|
||||
PresetWithVendorProfile get_preset_with_vendor_profile(const Preset &preset) const;
|
||||
PresetWithVendorProfile get_edited_preset_with_vendor_profile() const { return this->get_preset_with_vendor_profile(this->get_edited_preset()); }
|
||||
|
||||
const std::string& get_preset_name_by_alias(const std::string& alias) const;
|
||||
const std::string* get_preset_name_renamed(const std::string &old_name) const;
|
||||
|
||||
// used to update preset_choice from Tab
|
||||
const std::deque<Preset>& get_presets() const { return m_presets; }
|
||||
size_t get_idx_selected() { return m_idx_selected; }
|
||||
static const std::string& get_suffix_modified();
|
||||
|
||||
// Return a preset possibly with modifications.
|
||||
Preset& default_preset(size_t idx = 0) { assert(idx < m_num_default_presets); return m_presets[idx]; }
|
||||
const Preset& default_preset(size_t idx = 0) const { assert(idx < m_num_default_presets); return m_presets[idx]; }
|
||||
virtual const Preset& default_preset_for(const DynamicPrintConfig & /* config */) const { return this->default_preset(); }
|
||||
// Return a preset by an index. If the preset is active, a temporary copy is returned.
|
||||
Preset& preset(size_t idx) { return (idx == m_idx_selected) ? m_edited_preset : m_presets[idx]; }
|
||||
const Preset& preset(size_t idx) const { return const_cast<PresetCollection*>(this)->preset(idx); }
|
||||
void discard_current_changes() { m_presets[m_idx_selected].reset_dirty(); m_edited_preset = m_presets[m_idx_selected]; }
|
||||
|
||||
// Return a preset by its name. If the preset is active, a temporary copy is returned.
|
||||
// If a preset is not found by its name, null is returned.
|
||||
Preset* find_preset(const std::string &name, bool first_visible_if_not_found = false);
|
||||
const Preset* find_preset(const std::string &name, bool first_visible_if_not_found = false) const
|
||||
{ return const_cast<PresetCollection*>(this)->find_preset(name, first_visible_if_not_found); }
|
||||
|
||||
size_t first_visible_idx() const;
|
||||
// Return index of the first compatible preset. Certainly at least the '- default -' preset shall be compatible.
|
||||
// If one of the prefered_alternates is compatible, select it.
|
||||
template<typename PreferedCondition>
|
||||
size_t first_compatible_idx(PreferedCondition prefered_condition) const
|
||||
{
|
||||
size_t i = m_default_suppressed ? m_num_default_presets : 0;
|
||||
size_t n = this->m_presets.size();
|
||||
size_t i_compatible = n;
|
||||
for (; i < n; ++ i)
|
||||
// Since we use the filament selection from Wizard, it's needed to control the preset visibility too
|
||||
if (m_presets[i].is_compatible && m_presets[i].is_visible) {
|
||||
if (prefered_condition(m_presets[i].name))
|
||||
return i;
|
||||
if (i_compatible == n)
|
||||
// Store the first compatible profile into i_compatible.
|
||||
i_compatible = i;
|
||||
}
|
||||
return (i_compatible == n) ? 0 : i_compatible;
|
||||
}
|
||||
// Return index of the first compatible preset. Certainly at least the '- default -' preset shall be compatible.
|
||||
size_t first_compatible_idx() const { return this->first_compatible_idx([](const std::string&){return true;}); }
|
||||
|
||||
// Return index of the first visible preset. Certainly at least the '- default -' preset shall be visible.
|
||||
// Return the first visible preset. Certainly at least the '- default -' preset shall be visible.
|
||||
Preset& first_visible() { return this->preset(this->first_visible_idx()); }
|
||||
const Preset& first_visible() const { return this->preset(this->first_visible_idx()); }
|
||||
Preset& first_compatible() { return this->preset(this->first_compatible_idx()); }
|
||||
template<typename PreferedCondition>
|
||||
Preset& first_compatible(PreferedCondition prefered_condition) { return this->preset(this->first_compatible_idx(prefered_condition)); }
|
||||
const Preset& first_compatible() const { return this->preset(this->first_compatible_idx()); }
|
||||
|
||||
// Return number of presets including the "- default -" preset.
|
||||
size_t size() const { return m_presets.size(); }
|
||||
bool has_defaults_only() const { return m_presets.size() <= m_num_default_presets; }
|
||||
|
||||
// For Print / Filament presets, disable those, which are not compatible with the printer.
|
||||
template<typename PreferedCondition>
|
||||
void update_compatible(const PresetWithVendorProfile &active_printer, const PresetWithVendorProfile *active_print, PresetSelectCompatibleType select_other_if_incompatible, PreferedCondition prefered_condition)
|
||||
{
|
||||
if (this->update_compatible_internal(active_printer, active_print, select_other_if_incompatible) == (size_t)-1)
|
||||
// Find some other compatible preset, or the "-- default --" preset.
|
||||
this->select_preset(this->first_compatible_idx(prefered_condition));
|
||||
}
|
||||
void update_compatible(const PresetWithVendorProfile &active_printer, const PresetWithVendorProfile *active_print, PresetSelectCompatibleType select_other_if_incompatible)
|
||||
{ this->update_compatible(active_printer, active_print, select_other_if_incompatible, [](const std::string&){return true;}); }
|
||||
|
||||
size_t num_visible() const { return std::count_if(m_presets.begin(), m_presets.end(), [](const Preset &preset){return preset.is_visible;}); }
|
||||
|
||||
// Compare the content of get_selected_preset() with get_edited_preset() configs, return true if they differ.
|
||||
bool current_is_dirty() const { return ! this->current_dirty_options().empty(); }
|
||||
// Compare the content of get_selected_preset() with get_edited_preset() configs, return the list of keys where they differ.
|
||||
std::vector<std::string> current_dirty_options(const bool deep_compare = false) const
|
||||
{ return dirty_options(&this->get_edited_preset(), &this->get_selected_preset(), deep_compare); }
|
||||
// Compare the content of get_selected_preset() with get_edited_preset() configs, return the list of keys where they differ.
|
||||
std::vector<std::string> current_different_from_parent_options(const bool deep_compare = false) const
|
||||
{ return dirty_options(&this->get_edited_preset(), this->get_selected_preset_parent(), deep_compare); }
|
||||
|
||||
// Return a sorted list of system preset names.
|
||||
std::vector<std::string> system_preset_names() const;
|
||||
|
||||
// Update the choice UI from the list of presets.
|
||||
// If show_incompatible, all presets are shown, otherwise only the compatible presets are shown.
|
||||
// If an incompatible preset is selected, it is shown as well.
|
||||
size_t update_tab_ui(wxBitmapComboBox *ui, bool show_incompatible, const int em = 10);
|
||||
// Update the choice UI from the list of presets.
|
||||
// Only the compatible presets are shown.
|
||||
// If an incompatible preset is selected, it is shown as well.
|
||||
void update_plater_ui(GUI::PresetComboBox *ui);
|
||||
|
||||
// Update a dirty floag of the current preset, update the labels of the UI component accordingly.
|
||||
// Return true if the dirty flag changed.
|
||||
bool update_dirty_ui(wxBitmapComboBox *ui);
|
||||
|
||||
// Select a profile by its name. Return true if the selection changed.
|
||||
// Without force, the selection is only updated if the index changes.
|
||||
// With force, the changes are reverted if the new index is the same as the old index.
|
||||
bool select_preset_by_name(const std::string &name, bool force);
|
||||
|
||||
// Generate a file path from a profile name. Add the ".ini" suffix if it is missing.
|
||||
std::string path_from_name(const std::string &new_name) const;
|
||||
|
||||
void clear_bitmap_cache();
|
||||
|
||||
#ifdef __linux__
|
||||
static const char* separator_head() { return "------- "; }
|
||||
static const char* separator_tail() { return " -------"; }
|
||||
#else /* __linux__ */
|
||||
static const char* separator_head() { return "————— "; }
|
||||
static const char* separator_tail() { return " —————"; }
|
||||
#endif /* __linux__ */
|
||||
static wxString separator(const std::string &label);
|
||||
|
||||
protected:
|
||||
// Select a preset, if it exists. If it does not exist, select an invalid (-1) index.
|
||||
// This is a temporary state, which shall be fixed immediately by the following step.
|
||||
bool select_preset_by_name_strict(const std::string &name);
|
||||
|
||||
// Merge one vendor's presets with the other vendor's presets, report duplicates.
|
||||
std::vector<std::string> merge_presets(PresetCollection &&other, const VendorMap &new_vendors);
|
||||
|
||||
// Update m_map_alias_to_profile_name from loaded system profiles.
|
||||
void update_map_alias_to_profile_name();
|
||||
|
||||
// Update m_map_system_profile_renamed from loaded system profiles.
|
||||
void update_map_system_profile_renamed();
|
||||
|
||||
private:
|
||||
PresetCollection();
|
||||
PresetCollection(const PresetCollection &other);
|
||||
PresetCollection& operator=(const PresetCollection &other);
|
||||
|
||||
// Find a preset position in the sorted list of presets.
|
||||
// The "-- default -- " preset is always the first, so it needs
|
||||
// to be handled differently.
|
||||
// If a preset does not exist, an iterator is returned indicating where to insert a preset with the same name.
|
||||
std::deque<Preset>::iterator find_preset_internal(const std::string &name)
|
||||
{
|
||||
Preset key(m_type, name);
|
||||
auto it = std::lower_bound(m_presets.begin() + m_num_default_presets, m_presets.end(), key);
|
||||
if (it == m_presets.end() || it->name != name) {
|
||||
// Preset has not been not found in the sorted list of non-default presets. Try the defaults.
|
||||
for (size_t i = 0; i < m_num_default_presets; ++ i)
|
||||
if (m_presets[i].name == name) {
|
||||
it = m_presets.begin() + i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return it;
|
||||
}
|
||||
std::deque<Preset>::const_iterator find_preset_internal(const std::string &name) const
|
||||
{ return const_cast<PresetCollection*>(this)->find_preset_internal(name); }
|
||||
std::deque<Preset>::iterator find_preset_renamed(const std::string &name) {
|
||||
auto it_renamed = m_map_system_profile_renamed.find(name);
|
||||
auto it = (it_renamed == m_map_system_profile_renamed.end()) ? m_presets.end() : this->find_preset_internal(it_renamed->second);
|
||||
assert((it_renamed == m_map_system_profile_renamed.end()) || (it != m_presets.end() && it->name == it_renamed->second));
|
||||
return it;
|
||||
}
|
||||
std::deque<Preset>::const_iterator find_preset_renamed(const std::string &name) const
|
||||
{ return const_cast<PresetCollection*>(this)->find_preset_renamed(name); }
|
||||
|
||||
size_t update_compatible_internal(const PresetWithVendorProfile &active_printer, const PresetWithVendorProfile *active_print, PresetSelectCompatibleType unselect_if_incompatible);
|
||||
|
||||
static std::vector<std::string> dirty_options(const Preset *edited, const Preset *reference, const bool is_printer_type = false);
|
||||
|
||||
// Type of this PresetCollection: TYPE_PRINT, TYPE_FILAMENT or TYPE_PRINTER.
|
||||
Preset::Type m_type;
|
||||
// List of presets, starting with the "- default -" preset.
|
||||
// Use deque to force the container to allocate an object per each entry,
|
||||
// so that the addresses of the presets don't change during resizing of the container.
|
||||
std::deque<Preset> m_presets;
|
||||
// System profiles may have aliases. Map to the full profile name.
|
||||
std::vector<std::pair<std::string, std::string>> m_map_alias_to_profile_name;
|
||||
// Map from old system profile name to a current system profile name.
|
||||
std::map<std::string, std::string> m_map_system_profile_renamed;
|
||||
// Initially this preset contains a copy of the selected preset. Later on, this copy may be modified by the user.
|
||||
Preset m_edited_preset;
|
||||
// Selected preset.
|
||||
size_t m_idx_selected;
|
||||
// Is the "- default -" preset suppressed?
|
||||
bool m_default_suppressed = true;
|
||||
size_t m_num_default_presets = 0;
|
||||
// Compatible & incompatible marks, to be placed at the wxBitmapComboBox items of a Plater.
|
||||
// These bitmaps are not owned by PresetCollection, but by a PresetBundle.
|
||||
const wxBitmap *m_bitmap_compatible = nullptr;
|
||||
const wxBitmap *m_bitmap_incompatible = nullptr;
|
||||
const wxBitmap *m_bitmap_lock = nullptr;
|
||||
const wxBitmap *m_bitmap_lock_open = nullptr;
|
||||
// Marks placed at the wxBitmapComboBox of a MainFrame.
|
||||
// These bitmaps are owned by PresetCollection.
|
||||
wxBitmap *m_bitmap_main_frame;
|
||||
// "Add printer profile" icon, owned by PresetCollection.
|
||||
wxBitmap *m_bitmap_add;
|
||||
// Path to the directory to store the config files into.
|
||||
std::string m_dir_path;
|
||||
|
||||
// Caching color bitmaps for the filament combo box.
|
||||
GUI::BitmapCache *m_bitmap_cache = nullptr;
|
||||
|
||||
// to access select_preset_by_name_strict()
|
||||
friend class PresetBundle;
|
||||
};
|
||||
|
||||
// Printer supports the FFF and SLA technologies, with different set of configuration values,
|
||||
// therefore this PresetCollection needs to handle two defaults.
|
||||
class PrinterPresetCollection : public PresetCollection
|
||||
{
|
||||
public:
|
||||
PrinterPresetCollection(Preset::Type type, const std::vector<std::string> &keys, const Slic3r::StaticPrintConfig &defaults, const std::string &default_name = "- default -") :
|
||||
PresetCollection(type, keys, defaults, default_name) {}
|
||||
const Preset& default_preset_for(const DynamicPrintConfig &config) const override;
|
||||
|
||||
const Preset* find_by_model_id(const std::string &model_id) const;
|
||||
};
|
||||
|
||||
namespace PresetUtils {
|
||||
// PrinterModel of a system profile, from which this preset is derived, or null if it is not derived from a system profile.
|
||||
const VendorProfile::PrinterModel* system_printer_model(const Preset &preset);
|
||||
} // namespace PresetUtils
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif /* slic3r_Preset_hpp_ */
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,185 +0,0 @@
|
|||
#ifndef slic3r_PresetBundle_hpp_
|
||||
#define slic3r_PresetBundle_hpp_
|
||||
|
||||
#include "AppConfig.hpp"
|
||||
#include "Preset.hpp"
|
||||
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <unordered_map>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
class wxWindow;
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
namespace GUI {
|
||||
class BitmapCache;
|
||||
};
|
||||
|
||||
// Bundle of Print + Filament + Printer presets.
|
||||
class PresetBundle
|
||||
{
|
||||
public:
|
||||
PresetBundle();
|
||||
~PresetBundle();
|
||||
|
||||
// Remove all the presets but the "-- default --".
|
||||
// Optionally remove all the files referenced by the presets from the user profile directory.
|
||||
void reset(bool delete_files);
|
||||
|
||||
void setup_directories();
|
||||
|
||||
// Load ini files of all types (print, filament, printer) from Slic3r::data_dir() / presets.
|
||||
// Load selections (current print, current filaments, current printer) from config.ini
|
||||
// This is done just once on application start up.
|
||||
void load_presets(AppConfig &config, const std::string &preferred_model_id = "");
|
||||
|
||||
// Export selections (current print, current filaments, current printer) into config.ini
|
||||
void export_selections(AppConfig &config);
|
||||
|
||||
PresetCollection prints;
|
||||
PresetCollection sla_prints;
|
||||
PresetCollection filaments;
|
||||
PresetCollection sla_materials;
|
||||
PresetCollection& materials(PrinterTechnology pt) { return pt == ptFFF ? this->filaments : this->sla_materials; }
|
||||
const PresetCollection& materials(PrinterTechnology pt) const { return pt == ptFFF ? this->filaments : this->sla_materials; }
|
||||
PrinterPresetCollection printers;
|
||||
// Filament preset names for a multi-extruder or multi-material print.
|
||||
// extruders.size() should be the same as printers.get_edited_preset().config.nozzle_diameter.size()
|
||||
std::vector<std::string> filament_presets;
|
||||
|
||||
// The project configuration values are kept separated from the print/filament/printer preset,
|
||||
// they are being serialized / deserialized from / to the .amf, .3mf, .config, .gcode,
|
||||
// and they are being used by slicing core.
|
||||
DynamicPrintConfig project_config;
|
||||
|
||||
// There will be an entry for each system profile loaded,
|
||||
// and the system profiles will point to the VendorProfile instances owned by PresetBundle::vendors.
|
||||
VendorMap vendors;
|
||||
|
||||
struct ObsoletePresets {
|
||||
std::vector<std::string> prints;
|
||||
std::vector<std::string> sla_prints;
|
||||
std::vector<std::string> filaments;
|
||||
std::vector<std::string> sla_materials;
|
||||
std::vector<std::string> printers;
|
||||
};
|
||||
ObsoletePresets obsolete_presets;
|
||||
|
||||
bool has_defauls_only() const
|
||||
{ return prints.has_defaults_only() && filaments.has_defaults_only() && printers.has_defaults_only(); }
|
||||
|
||||
DynamicPrintConfig full_config() const;
|
||||
// full_config() with the "printhost_apikey" and "printhost_cafile" removed.
|
||||
DynamicPrintConfig full_config_secure() const;
|
||||
|
||||
// Load user configuration and store it into the user profiles.
|
||||
// This method is called by the configuration wizard.
|
||||
void load_config(const std::string &name, DynamicPrintConfig config)
|
||||
{ this->load_config_file_config(name, false, std::move(config)); }
|
||||
|
||||
// Load configuration that comes from a model file containing configuration, such as 3MF et al.
|
||||
// This method is called by the Plater.
|
||||
void load_config_model(const std::string &name, DynamicPrintConfig config)
|
||||
{ this->load_config_file_config(name, true, std::move(config)); }
|
||||
|
||||
// Load an external config file containing the print, filament and printer presets.
|
||||
// Instead of a config file, a G-code may be loaded containing the full set of parameters.
|
||||
// In the future the configuration will likely be read from an AMF file as well.
|
||||
// If the file is loaded successfully, its print / filament / printer profiles will be activated.
|
||||
void load_config_file(const std::string &path);
|
||||
|
||||
// Load a config bundle file, into presets and store the loaded presets into separate files
|
||||
// of the local configuration directory.
|
||||
// Load settings into the provided settings instance.
|
||||
// Activate the presets stored in the config bundle.
|
||||
// Returns the number of presets loaded successfully.
|
||||
enum {
|
||||
// Save the profiles, which have been loaded.
|
||||
LOAD_CFGBNDLE_SAVE = 1,
|
||||
// Delete all old config profiles before loading.
|
||||
LOAD_CFGBNDLE_RESET_USER_PROFILE = 2,
|
||||
// Load a system config bundle.
|
||||
LOAD_CFGBNDLE_SYSTEM = 4,
|
||||
LOAD_CFGBUNDLE_VENDOR_ONLY = 8,
|
||||
};
|
||||
// Load the config bundle, store it to the user profile directory by default.
|
||||
size_t load_configbundle(const std::string &path, unsigned int flags = LOAD_CFGBNDLE_SAVE);
|
||||
|
||||
// Export a config bundle file containing all the presets and the names of the active presets.
|
||||
void export_configbundle(const std::string &path, bool export_system_settings = false);
|
||||
|
||||
// Update a filament selection combo box on the plater for an idx_extruder.
|
||||
void update_plater_filament_ui(unsigned int idx_extruder, GUI::PresetComboBox *ui);
|
||||
|
||||
// Enable / disable the "- default -" preset.
|
||||
void set_default_suppressed(bool default_suppressed);
|
||||
|
||||
// Set the filament preset name. As the name could come from the UI selection box,
|
||||
// an optional "(modified)" suffix will be removed from the filament name.
|
||||
void set_filament_preset(size_t idx, const std::string &name);
|
||||
|
||||
// Read out the number of extruders from an active printer preset,
|
||||
// update size and content of filament_presets.
|
||||
void update_multi_material_filament_presets();
|
||||
|
||||
// Update the is_compatible flag of all print and filament presets depending on whether they are marked
|
||||
// as compatible with the currently selected printer (and print in case of filament presets).
|
||||
// Also updates the is_visible flag of each preset.
|
||||
// If select_other_if_incompatible is true, then the print or filament preset is switched to some compatible
|
||||
// preset if the current print or filament preset is not compatible.
|
||||
void update_compatible(PresetSelectCompatibleType select_other_print_if_incompatible, PresetSelectCompatibleType select_other_filament_if_incompatible);
|
||||
void update_compatible(PresetSelectCompatibleType select_other_if_incompatible) { this->update_compatible(select_other_if_incompatible, select_other_if_incompatible); }
|
||||
|
||||
void load_default_preset_bitmaps();
|
||||
|
||||
// Set the is_visible flag for printer vendors, printer models and printer variants
|
||||
// based on the user configuration.
|
||||
// If the "vendor" section is missing, enable all models and variants of the particular vendor.
|
||||
void load_installed_printers(const AppConfig &config);
|
||||
|
||||
const std::string& get_preset_name_by_alias(const Preset::Type& preset_type, const std::string& alias) const;
|
||||
|
||||
static const char *PRUSA_BUNDLE;
|
||||
private:
|
||||
std::string load_system_presets();
|
||||
// Merge one vendor's presets with the other vendor's presets, report duplicates.
|
||||
std::vector<std::string> merge_presets(PresetBundle &&other);
|
||||
// Update renamed_from and alias maps of system profiles.
|
||||
void update_system_maps();
|
||||
|
||||
// Set the is_visible flag for filaments and sla materials,
|
||||
// apply defaults based on enabled printers when no filaments/materials are installed.
|
||||
void load_installed_filaments(AppConfig &config);
|
||||
void load_installed_sla_materials(AppConfig &config);
|
||||
|
||||
// Load selections (current print, current filaments, current printer) from config.ini
|
||||
// This is done just once on application start up.
|
||||
void load_selections(AppConfig &config, const std::string &preferred_model_id = "");
|
||||
|
||||
// Load print, filament & printer presets from a config. If it is an external config, then the name is extracted from the external path.
|
||||
// and the external config is just referenced, not stored into user profile directory.
|
||||
// If it is not an external config, then the config will be stored into the user profile directory.
|
||||
void load_config_file_config(const std::string &name_or_path, bool is_external, DynamicPrintConfig &&config);
|
||||
void load_config_file_config_bundle(const std::string &path, const boost::property_tree::ptree &tree);
|
||||
void load_compatible_bitmaps();
|
||||
|
||||
DynamicPrintConfig full_fff_config() const;
|
||||
DynamicPrintConfig full_sla_config() const;
|
||||
|
||||
// Indicator, that the preset is compatible with the selected printer.
|
||||
wxBitmap *m_bitmapCompatible;
|
||||
// Indicator, that the preset is NOT compatible with the selected printer.
|
||||
wxBitmap *m_bitmapIncompatible;
|
||||
// Indicator, that the preset is system and not modified.
|
||||
wxBitmap *m_bitmapLock;
|
||||
// Indicator, that the preset is system and user modified.
|
||||
wxBitmap *m_bitmapLockOpen;
|
||||
// Caching color bitmaps for the filament combo box.
|
||||
GUI::BitmapCache *m_bitmapCache;
|
||||
};
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif /* slic3r_PresetBundle_hpp_ */
|
||||
1331
src/slic3r/GUI/PresetComboBoxes.cpp
Normal file
1331
src/slic3r/GUI/PresetComboBoxes.cpp
Normal file
File diff suppressed because it is too large
Load diff
276
src/slic3r/GUI/PresetComboBoxes.hpp
Normal file
276
src/slic3r/GUI/PresetComboBoxes.hpp
Normal file
|
|
@ -0,0 +1,276 @@
|
|||
#ifndef slic3r_PresetComboBoxes_hpp_
|
||||
#define slic3r_PresetComboBoxes_hpp_
|
||||
|
||||
#include <wx/bmpcbox.h>
|
||||
#include <wx/gdicmn.h>
|
||||
|
||||
#include "libslic3r/Preset.hpp"
|
||||
#include "wxExtensions.hpp"
|
||||
#include "GUI_Utils.hpp"
|
||||
|
||||
class wxString;
|
||||
class wxTextCtrl;
|
||||
class wxStaticText;
|
||||
class ScalableButton;
|
||||
class wxBoxSizer;
|
||||
class wxComboBox;
|
||||
class wxStaticBitmap;
|
||||
class wxRadioBox;
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
namespace GUI {
|
||||
|
||||
class BitmapCache;
|
||||
|
||||
// ---------------------------------
|
||||
// *** PresetComboBox ***
|
||||
// ---------------------------------
|
||||
|
||||
// BitmapComboBox used to presets list on Sidebar and Tabs
|
||||
class PresetComboBox : public wxBitmapComboBox
|
||||
{
|
||||
public:
|
||||
PresetComboBox(wxWindow* parent, Preset::Type preset_type, const wxSize& size = wxDefaultSize);
|
||||
~PresetComboBox();
|
||||
|
||||
enum LabelItemType {
|
||||
LABEL_ITEM_PHYSICAL_PRINTER = 0xffffff01,
|
||||
LABEL_ITEM_DISABLED,
|
||||
LABEL_ITEM_MARKER,
|
||||
LABEL_ITEM_PHYSICAL_PRINTERS,
|
||||
LABEL_ITEM_WIZARD_PRINTERS,
|
||||
LABEL_ITEM_WIZARD_FILAMENTS,
|
||||
LABEL_ITEM_WIZARD_MATERIALS,
|
||||
|
||||
LABEL_ITEM_MAX,
|
||||
};
|
||||
|
||||
void set_label_marker(int item, LabelItemType label_item_type = LABEL_ITEM_MARKER);
|
||||
bool set_printer_technology(PrinterTechnology pt);
|
||||
|
||||
void set_selection_changed_function(std::function<void(int)> sel_changed) { on_selection_changed = sel_changed; }
|
||||
|
||||
bool is_selected_physical_printer();
|
||||
|
||||
// Return true, if physical printer was selected
|
||||
// and next internal selection was accomplished
|
||||
bool selection_is_changed_according_to_physical_printers();
|
||||
|
||||
void update(std::string select_preset);
|
||||
|
||||
virtual void update();
|
||||
virtual void msw_rescale();
|
||||
|
||||
protected:
|
||||
typedef std::size_t Marker;
|
||||
std::function<void(int)> on_selection_changed { nullptr };
|
||||
|
||||
Preset::Type m_type;
|
||||
std::string m_main_bitmap_name;
|
||||
|
||||
PresetBundle* m_preset_bundle {nullptr};
|
||||
PresetCollection* m_collection {nullptr};
|
||||
|
||||
// Caching bitmaps for the all bitmaps, used in preset comboboxes
|
||||
static BitmapCache& bitmap_cache();
|
||||
|
||||
// Indicator, that the preset is compatible with the selected printer.
|
||||
ScalableBitmap m_bitmapCompatible;
|
||||
// Indicator, that the preset is NOT compatible with the selected printer.
|
||||
ScalableBitmap m_bitmapIncompatible;
|
||||
|
||||
int m_last_selected;
|
||||
int m_em_unit;
|
||||
|
||||
// parameters for an icon's drawing
|
||||
int icon_height;
|
||||
int norm_icon_width;
|
||||
int thin_icon_width;
|
||||
int wide_icon_width;
|
||||
int space_icon_width;
|
||||
int thin_space_icon_width;
|
||||
int wide_space_icon_width;
|
||||
|
||||
PrinterTechnology printer_technology {ptAny};
|
||||
|
||||
void invalidate_selection();
|
||||
void validate_selection(bool predicate = false);
|
||||
void update_selection();
|
||||
|
||||
#ifdef __linux__
|
||||
static const char* separator_head() { return "------- "; }
|
||||
static const char* separator_tail() { return " -------"; }
|
||||
#else // __linux__
|
||||
static const char* separator_head() { return "————— "; }
|
||||
static const char* separator_tail() { return " —————"; }
|
||||
#endif // __linux__
|
||||
static wxString separator(const std::string& label);
|
||||
|
||||
wxBitmap* get_bmp( std::string bitmap_key, bool wide_icons, const std::string& main_icon_name,
|
||||
bool is_compatible = true, bool is_system = false, bool is_single_bar = false,
|
||||
std::string filament_rgb = "", std::string extruder_rgb = "");
|
||||
|
||||
wxBitmap* get_bmp( std::string bitmap_key, const std::string& main_icon_name, const std::string& next_icon_name,
|
||||
bool is_enabled = true, bool is_compatible = true, bool is_system = false);
|
||||
|
||||
#ifdef __APPLE__
|
||||
/* For PresetComboBox we use bitmaps that are created from images that are already scaled appropriately for Retina
|
||||
* (Contrary to the intuition, the `scale` argument for Bitmap's constructor doesn't mean
|
||||
* "please scale this to such and such" but rather
|
||||
* "the wxImage is already sized for backing scale such and such". )
|
||||
* Unfortunately, the constructor changes the size of wxBitmap too.
|
||||
* Thus We need to use unscaled size value for bitmaps that we use
|
||||
* to avoid scaled size of control items.
|
||||
* For this purpose control drawing methods and
|
||||
* control size calculation methods (virtual) are overridden.
|
||||
**/
|
||||
virtual bool OnAddBitmap(const wxBitmap& bitmap) override;
|
||||
virtual void OnDrawItem(wxDC& dc, const wxRect& rect, int item, int flags) const override;
|
||||
#endif
|
||||
|
||||
private:
|
||||
void fill_width_height();
|
||||
};
|
||||
|
||||
|
||||
// ---------------------------------
|
||||
// *** PlaterPresetComboBox ***
|
||||
// ---------------------------------
|
||||
|
||||
class PlaterPresetComboBox : public PresetComboBox
|
||||
{
|
||||
public:
|
||||
PlaterPresetComboBox(wxWindow *parent, Preset::Type preset_type);
|
||||
~PlaterPresetComboBox();
|
||||
|
||||
ScalableButton* edit_btn { nullptr };
|
||||
|
||||
void set_extruder_idx(const int extr_idx) { m_extruder_idx = extr_idx; }
|
||||
int get_extruder_idx() const { return m_extruder_idx; }
|
||||
|
||||
bool switch_to_tab();
|
||||
void show_add_menu();
|
||||
void show_edit_menu();
|
||||
|
||||
void update() override;
|
||||
void msw_rescale() override;
|
||||
|
||||
private:
|
||||
int m_extruder_idx = -1;
|
||||
};
|
||||
|
||||
|
||||
// ---------------------------------
|
||||
// *** TabPresetComboBox ***
|
||||
// ---------------------------------
|
||||
|
||||
class TabPresetComboBox : public PresetComboBox
|
||||
{
|
||||
bool show_incompatible {false};
|
||||
bool m_enable_all {false};
|
||||
|
||||
public:
|
||||
TabPresetComboBox(wxWindow *parent, Preset::Type preset_type);
|
||||
~TabPresetComboBox() {}
|
||||
void set_show_incompatible_presets(bool show_incompatible_presets) {
|
||||
show_incompatible = show_incompatible_presets;
|
||||
}
|
||||
|
||||
void update() override;
|
||||
void update_dirty();
|
||||
void msw_rescale() override;
|
||||
|
||||
void set_enable_all(bool enable=true) { m_enable_all = enable; }
|
||||
|
||||
PresetCollection* presets() const { return m_collection; }
|
||||
Preset::Type type() const { return m_type; }
|
||||
};
|
||||
|
||||
|
||||
//------------------------------------------------
|
||||
// SavePresetDialog
|
||||
//------------------------------------------------
|
||||
|
||||
class SavePresetDialog : public DPIDialog
|
||||
{
|
||||
enum ActionType
|
||||
{
|
||||
ChangePreset,
|
||||
AddPreset,
|
||||
Switch,
|
||||
UndefAction
|
||||
};
|
||||
|
||||
struct Item
|
||||
{
|
||||
enum ValidationType
|
||||
{
|
||||
Valid,
|
||||
NoValid,
|
||||
Warning
|
||||
};
|
||||
|
||||
Item(Preset::Type type, const std::string& suffix, wxBoxSizer* sizer, SavePresetDialog* parent);
|
||||
|
||||
void update_valid_bmp();
|
||||
void accept();
|
||||
|
||||
bool is_valid() const { return m_valid_type != NoValid; }
|
||||
Preset::Type type() const { return m_type; }
|
||||
std::string preset_name() const { return m_preset_name; }
|
||||
|
||||
private:
|
||||
Preset::Type m_type;
|
||||
ValidationType m_valid_type;
|
||||
std::string m_preset_name;
|
||||
|
||||
SavePresetDialog* m_parent {nullptr};
|
||||
wxStaticBitmap* m_valid_bmp {nullptr};
|
||||
wxComboBox* m_combo {nullptr};
|
||||
wxStaticText* m_valid_label {nullptr};
|
||||
|
||||
PresetCollection* m_presets {nullptr};
|
||||
|
||||
void update();
|
||||
};
|
||||
|
||||
std::vector<Item> m_items;
|
||||
|
||||
wxBoxSizer* m_presets_sizer {nullptr};
|
||||
wxStaticText* m_label {nullptr};
|
||||
wxRadioBox* m_action_radio_box {nullptr};
|
||||
wxBoxSizer* m_radio_sizer {nullptr};
|
||||
ActionType m_action {UndefAction};
|
||||
|
||||
std::string m_ph_printer_name;
|
||||
std::string m_old_preset_name;
|
||||
|
||||
public:
|
||||
|
||||
SavePresetDialog(Preset::Type type, const std::string& suffix);
|
||||
~SavePresetDialog() {}
|
||||
|
||||
void AddItem(Preset::Type type, const std::string& suffix);
|
||||
|
||||
std::string get_name();
|
||||
std::string get_name(Preset::Type type);
|
||||
|
||||
bool enable_ok_btn() const;
|
||||
void add_info_for_edit_ph_printer(wxBoxSizer *sizer);
|
||||
void update_info_for_edit_ph_printer(const std::string &preset_name);
|
||||
void layout();
|
||||
|
||||
protected:
|
||||
void on_dpi_changed(const wxRect& suggested_rect) override;
|
||||
void on_sys_color_changed() override {}
|
||||
|
||||
private:
|
||||
void update_physical_printers(const std::string& preset_name);
|
||||
void accept();
|
||||
};
|
||||
|
||||
} // namespace GUI
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif
|
||||
|
|
@ -4,7 +4,6 @@
|
|||
#include "libslic3r/Slicing.hpp"
|
||||
#include "libslic3r/libslic3r.h"
|
||||
|
||||
#include "PresetBundle.hpp"
|
||||
#include "PresetHints.hpp"
|
||||
|
||||
#include <wx/intl.h>
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#include "PresetBundle.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
|
|
|
|||
|
|
@ -15,11 +15,11 @@
|
|||
|
||||
#include "GUI.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "AppConfig.hpp"
|
||||
#include "MsgDialog.hpp"
|
||||
#include "I18N.hpp"
|
||||
#include "../Utils/PrintHost.hpp"
|
||||
#include "wxExtensions.hpp"
|
||||
#include "libslic3r/AppConfig.hpp"
|
||||
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@
|
|||
#include "wx/dataview.h"
|
||||
|
||||
#include "libslic3r/PrintConfig.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "Plater.hpp"
|
||||
#include "Tab.hpp"
|
||||
#include "PresetBundle.hpp"
|
||||
|
||||
#define FTS_FUZZY_MATCH_IMPLEMENTATION
|
||||
#include "fts_fuzzy_match.h"
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@
|
|||
#include <wx/dialog.h>
|
||||
|
||||
#include "GUI_Utils.hpp"
|
||||
#include "Preset.hpp"
|
||||
#include "wxExtensions.hpp"
|
||||
#include "libslic3r/Preset.hpp"
|
||||
|
||||
|
||||
namespace Slic3r {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
// #include "libslic3r/GCodeSender.hpp"
|
||||
#include "slic3r/Utils/Serial.hpp"
|
||||
#include "Tab.hpp"
|
||||
#include "PresetBundle.hpp"
|
||||
#include "PresetHints.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
#include "libslic3r/Utils.hpp"
|
||||
#include "libslic3r/Model.hpp"
|
||||
|
||||
|
|
@ -27,14 +27,15 @@
|
|||
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include "wxExtensions.hpp"
|
||||
#include "PresetComboBoxes.hpp"
|
||||
#include <wx/wupdlock.h>
|
||||
|
||||
#include "GUI_App.hpp"
|
||||
#include "GUI_ObjectList.hpp"
|
||||
#include "ConfigWizard.hpp"
|
||||
#include "Plater.hpp"
|
||||
#include "MainFrame.hpp"
|
||||
#include "format.hpp"
|
||||
#include "PhysicalPrinterDialog.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
|
@ -160,10 +161,17 @@ void Tab::create_preset_tab()
|
|||
#endif //__WXOSX__
|
||||
|
||||
// preset chooser
|
||||
m_presets_choice = new PresetBitmapComboBox(panel, wxSize(35 * m_em_unit, -1));
|
||||
m_presets_choice = new TabPresetComboBox(panel, m_type);
|
||||
m_presets_choice->set_selection_changed_function([this](int selection) {
|
||||
if (!m_presets_choice->selection_is_changed_according_to_physical_printers())
|
||||
{
|
||||
if (m_type == Preset::TYPE_PRINTER && !m_presets_choice->is_selected_physical_printer())
|
||||
m_preset_bundle->physical_printers.unselect_printer();
|
||||
|
||||
// search combox
|
||||
// m_search = new Search::SearchCtrl(panel);
|
||||
// select preset
|
||||
select_preset(m_presets_choice->GetString(selection).ToUTF8().data());
|
||||
}
|
||||
});
|
||||
|
||||
auto color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
|
||||
|
||||
|
|
@ -173,6 +181,8 @@ void Tab::create_preset_tab()
|
|||
|
||||
add_scaled_button(panel, &m_btn_save_preset, "save");
|
||||
add_scaled_button(panel, &m_btn_delete_preset, "cross");
|
||||
if (m_type == Preset::Type::TYPE_PRINTER)
|
||||
add_scaled_button(panel, &m_btn_edit_ph_printer, "cog");
|
||||
|
||||
m_show_incompatible_presets = false;
|
||||
add_scaled_bitmap(this, m_bmp_show_incompatible_presets, "flag_red");
|
||||
|
|
@ -184,6 +194,8 @@ void Tab::create_preset_tab()
|
|||
m_btn_save_preset->SetToolTip(from_u8((boost::format(_utf8(L("Save current %s"))) % m_title).str()));
|
||||
m_btn_delete_preset->SetToolTip(_(L("Delete this preset")));
|
||||
m_btn_delete_preset->Disable();
|
||||
if (m_btn_edit_ph_printer)
|
||||
m_btn_edit_ph_printer->Disable();
|
||||
|
||||
add_scaled_button(panel, &m_question_btn, "question");
|
||||
m_question_btn->SetToolTip(_(L("Hover the cursor over buttons to find more information \n"
|
||||
|
|
@ -238,6 +250,10 @@ void Tab::create_preset_tab()
|
|||
m_hsizer->Add(m_btn_save_preset, 0, wxALIGN_CENTER_VERTICAL);
|
||||
m_hsizer->AddSpacer(int(4 * scale_factor));
|
||||
m_hsizer->Add(m_btn_delete_preset, 0, wxALIGN_CENTER_VERTICAL);
|
||||
if (m_btn_edit_ph_printer) {
|
||||
m_hsizer->AddSpacer(int(4 * scale_factor));
|
||||
m_hsizer->Add(m_btn_edit_ph_printer, 0, wxALIGN_CENTER_VERTICAL);
|
||||
}
|
||||
m_hsizer->AddSpacer(int(/*16*/8 * scale_factor));
|
||||
m_hsizer->Add(m_btn_hide_incompatible_presets, 0, wxALIGN_CENTER_VERTICAL);
|
||||
m_hsizer->AddSpacer(int(8 * scale_factor));
|
||||
|
|
@ -278,41 +294,19 @@ void Tab::create_preset_tab()
|
|||
m_treectrl->Bind(wxEVT_TREE_SEL_CHANGED, &Tab::OnTreeSelChange, this);
|
||||
m_treectrl->Bind(wxEVT_KEY_DOWN, &Tab::OnKeyDown, this);
|
||||
|
||||
m_presets_choice->Bind(wxEVT_COMBOBOX, ([this](wxCommandEvent e) {
|
||||
//! Because of The MSW and GTK version of wxBitmapComboBox derived from wxComboBox,
|
||||
//! but the OSX version derived from wxOwnerDrawnCombo, instead of:
|
||||
//! select_preset(m_presets_choice->GetStringSelection().ToUTF8().data());
|
||||
//! we doing next:
|
||||
// int selected_item = m_presets_choice->GetSelection();
|
||||
|
||||
// see https://github.com/prusa3d/PrusaSlicer/issues/3889
|
||||
// Under OSX: in case of use of a same names written in different case (like "ENDER" and "Ender")
|
||||
// m_presets_choice->GetSelection() will return first item, because search in PopupListCtrl is case-insensitive.
|
||||
// So, use GetSelection() from event parameter
|
||||
int selected_item = e.GetSelection();
|
||||
if (m_selected_preset_item == size_t(selected_item) && !m_presets->current_is_dirty())
|
||||
return;
|
||||
if (selected_item >= 0) {
|
||||
std::string selected_string = m_presets_choice->GetString(selected_item).ToUTF8().data();
|
||||
if (selected_string.find(PresetCollection::separator_head()) == 0
|
||||
/*selected_string == "------- System presets -------" ||
|
||||
selected_string == "------- User presets -------"*/) {
|
||||
m_presets_choice->SetSelection(m_selected_preset_item);
|
||||
if (wxString::FromUTF8(selected_string.c_str()) == PresetCollection::separator(L("Add a new printer")))
|
||||
wxTheApp->CallAfter([]() { wxGetApp().run_wizard(ConfigWizard::RR_USER); });
|
||||
return;
|
||||
}
|
||||
m_selected_preset_item = selected_item;
|
||||
select_preset(selected_string);
|
||||
}
|
||||
}));
|
||||
|
||||
m_btn_save_preset->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e) { save_preset(); }));
|
||||
m_btn_delete_preset->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e) { delete_preset(); }));
|
||||
m_btn_hide_incompatible_presets->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e) {
|
||||
toggle_show_hide_incompatible();
|
||||
}));
|
||||
|
||||
if (m_btn_edit_ph_printer)
|
||||
m_btn_edit_ph_printer->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e) {
|
||||
PhysicalPrinterDialog dlg(m_presets_choice->GetString(m_presets_choice->GetSelection()));
|
||||
if (dlg.ShowModal() == wxID_OK)
|
||||
update_tab_ui();
|
||||
}));
|
||||
|
||||
// Fill cache for mode bitmaps
|
||||
m_mode_bitmap_cache.reserve(3);
|
||||
m_mode_bitmap_cache.push_back(ScalableBitmap(this, "mode_simple" , mode_icon_px_size()));
|
||||
|
|
@ -778,14 +772,14 @@ void Tab::on_roll_back_value(const bool to_sys /*= true*/)
|
|||
// comparing the selected preset config with $self->{config}.
|
||||
void Tab::update_dirty()
|
||||
{
|
||||
m_presets->update_dirty_ui(m_presets_choice);
|
||||
m_presets_choice->update_dirty();
|
||||
on_presets_changed();
|
||||
update_changed_ui();
|
||||
}
|
||||
|
||||
void Tab::update_tab_ui()
|
||||
{
|
||||
m_selected_preset_item = m_presets->update_tab_ui(m_presets_choice, m_show_incompatible_presets, m_em_unit);
|
||||
m_presets_choice->update();
|
||||
}
|
||||
|
||||
// Load a provied DynamicConfig into the tab, modifying the active preset.
|
||||
|
|
@ -847,20 +841,20 @@ void Tab::update_visibility()
|
|||
|
||||
void Tab::msw_rescale()
|
||||
{
|
||||
m_em_unit = wxGetApp().em_unit();
|
||||
m_em_unit = em_unit(m_parent);
|
||||
|
||||
m_mode_sizer->msw_rescale();
|
||||
m_presets_choice->msw_rescale();
|
||||
|
||||
m_presets_choice->SetSize(35 * m_em_unit, -1);
|
||||
m_treectrl->SetMinSize(wxSize(20 * m_em_unit, -1));
|
||||
|
||||
update_tab_ui();
|
||||
|
||||
// rescale buttons and cached bitmaps
|
||||
for (const auto btn : m_scaled_buttons)
|
||||
btn->msw_rescale();
|
||||
for (const auto bmp : m_scaled_bitmaps)
|
||||
bmp->msw_rescale();
|
||||
for (const auto ikon : m_blinking_ikons)
|
||||
ikon.second->msw_rescale();
|
||||
for (ScalableBitmap& bmp : m_mode_bitmap_cache)
|
||||
bmp.msw_rescale();
|
||||
|
||||
|
|
@ -963,7 +957,7 @@ void Tab::load_key_value(const std::string& opt_key, const boost::any& value, bo
|
|||
// Don't select another profile if this profile happens to become incompatible.
|
||||
m_preset_bundle->update_compatible(PresetSelectCompatibleType::Never);
|
||||
}
|
||||
m_presets->update_dirty_ui(m_presets_choice);
|
||||
m_presets_choice->update_dirty();
|
||||
on_presets_changed();
|
||||
update();
|
||||
}
|
||||
|
|
@ -2148,11 +2142,10 @@ void TabPrinter::build_fff()
|
|||
line.append_widget(serial_test);
|
||||
optgroup->append_line(line);
|
||||
}
|
||||
#endif
|
||||
|
||||
optgroup = page->new_optgroup(L("Print Host upload"));
|
||||
build_printhost(optgroup.get());
|
||||
|
||||
#endif
|
||||
optgroup = page->new_optgroup(L("Firmware"));
|
||||
optgroup->append_single_option_line("gcode_flavor");
|
||||
optgroup->append_single_option_line("silent_mode");
|
||||
|
|
@ -2310,8 +2303,10 @@ void TabPrinter::build_sla()
|
|||
optgroup->append_single_option_line("min_initial_exposure_time");
|
||||
optgroup->append_single_option_line("max_initial_exposure_time");
|
||||
|
||||
/*
|
||||
optgroup = page->new_optgroup(L("Print Host upload"));
|
||||
build_printhost(optgroup.get());
|
||||
*/
|
||||
|
||||
const int notes_field_height = 25; // 250
|
||||
|
||||
|
|
@ -2699,11 +2694,13 @@ void TabPrinter::update_fff()
|
|||
m_serial_test_btn->Disable();
|
||||
}
|
||||
|
||||
/*
|
||||
{
|
||||
std::unique_ptr<PrintHost> host(PrintHost::get_print_host(m_config));
|
||||
m_print_host_test_btn->Enable(!m_config->opt_string("print_host").empty() && host->can_test());
|
||||
m_printhost_browse_btn->Enable(host->has_auto_discovery());
|
||||
}
|
||||
*/
|
||||
|
||||
bool have_multiple_extruders = m_extruders_count > 1;
|
||||
get_field("toolchange_gcode")->toggle(have_multiple_extruders);
|
||||
|
|
@ -2805,7 +2802,7 @@ void Tab::load_current_preset()
|
|||
{
|
||||
const Preset& preset = m_presets->get_edited_preset();
|
||||
|
||||
(preset.is_default || preset.is_system) ? m_btn_delete_preset->Disable() : m_btn_delete_preset->Enable(true);
|
||||
update_btns_enabling();
|
||||
|
||||
update();
|
||||
if (m_type == Slic3r::Preset::TYPE_PRINTER) {
|
||||
|
|
@ -2942,10 +2939,31 @@ void Tab::update_page_tree_visibility()
|
|||
|
||||
}
|
||||
|
||||
void Tab::update_btns_enabling()
|
||||
{
|
||||
// we can't delete last preset from the physical printer
|
||||
if (m_type == Preset::TYPE_PRINTER && m_preset_bundle->physical_printers.has_selection())
|
||||
m_btn_delete_preset->Enable(m_preset_bundle->physical_printers.get_selected_printer().preset_names.size() > 1);
|
||||
else {
|
||||
const Preset& preset = m_presets->get_edited_preset();
|
||||
m_btn_delete_preset->Enable(!preset.is_default && !preset.is_system);
|
||||
}
|
||||
|
||||
// we can edit physical printer only if it's selected in the list
|
||||
if (m_btn_edit_ph_printer)
|
||||
m_btn_edit_ph_printer->Enable(m_preset_bundle->physical_printers.has_selection());
|
||||
}
|
||||
|
||||
void Tab::update_preset_choice()
|
||||
{
|
||||
m_presets_choice->update();
|
||||
update_btns_enabling();
|
||||
}
|
||||
|
||||
// Called by the UI combo box when the user switches profiles, and also to delete the current profile.
|
||||
// Select a preset by a name.If !defined(name), then the default preset is selected.
|
||||
// If the current profile is modified, user is asked to save the changes.
|
||||
void Tab::select_preset(std::string preset_name, bool delete_current)
|
||||
void Tab::select_preset(std::string preset_name, bool delete_current /*=false*/, const std::string& last_selected_ph_printer_name/* =""*/)
|
||||
{
|
||||
if (preset_name.empty()) {
|
||||
if (delete_current) {
|
||||
|
|
@ -3053,7 +3071,16 @@ void Tab::select_preset(std::string preset_name, bool delete_current)
|
|||
}
|
||||
|
||||
if (canceled) {
|
||||
if (m_type == Preset::TYPE_PRINTER) {
|
||||
if (!last_selected_ph_printer_name.empty() &&
|
||||
m_presets->get_edited_preset().name == PhysicalPrinter::get_preset_name(last_selected_ph_printer_name)) {
|
||||
// If preset selection was canceled and previously was selected physical printer, we should select it back
|
||||
m_preset_bundle->physical_printers.select_printer(last_selected_ph_printer_name);
|
||||
}
|
||||
}
|
||||
|
||||
update_tab_ui();
|
||||
|
||||
// Trigger the on_presets_changed event so that we also restore the previous value in the plater selector,
|
||||
// if this action was initiated from the plater.
|
||||
on_presets_changed();
|
||||
|
|
@ -3095,6 +3122,7 @@ void Tab::select_preset(std::string preset_name, bool delete_current)
|
|||
else if (printer_technology == ptSLA && m_dependent_tabs.front() != Preset::Type::TYPE_SLA_PRINT)
|
||||
m_dependent_tabs = { Preset::Type::TYPE_SLA_PRINT, Preset::Type::TYPE_SLA_MATERIAL };
|
||||
}
|
||||
|
||||
load_current_preset();
|
||||
}
|
||||
}
|
||||
|
|
@ -3234,56 +3262,10 @@ void Tab::save_preset(std::string name /*= ""*/, bool detach)
|
|||
std::string suffix = detach ? _utf8(L("Detached")) : _CTX_utf8(L_CONTEXT("Copy", "PresetName"), "PresetName");
|
||||
|
||||
if (name.empty()) {
|
||||
const Preset &preset = m_presets->get_selected_preset();
|
||||
auto default_name = preset.is_default ? "Untitled" :
|
||||
// preset.is_system ? (boost::format(_CTX_utf8(L_CONTEXT("%1% - Copy", "PresetName"), "PresetName")) % preset.name).str() :
|
||||
preset.is_system ? (boost::format(("%1% - %2%")) % preset.name % suffix).str() :
|
||||
preset.name;
|
||||
|
||||
bool have_extention = boost::iends_with(default_name, ".ini");
|
||||
if (have_extention) {
|
||||
size_t len = default_name.length()-4;
|
||||
default_name.resize(len);
|
||||
}
|
||||
//[map $_->name, grep !$_->default && !$_->external, @{$self->{presets}}],
|
||||
std::vector<std::string> values;
|
||||
for (size_t i = 0; i < m_presets->size(); ++i) {
|
||||
const Preset &preset = m_presets->preset(i);
|
||||
if (preset.is_default || preset.is_system || preset.is_external)
|
||||
continue;
|
||||
values.push_back(preset.name);
|
||||
}
|
||||
|
||||
SavePresetWindow dlg(parent());
|
||||
dlg.build(title(), default_name, values);
|
||||
SavePresetDialog dlg(m_type, suffix);
|
||||
if (dlg.ShowModal() != wxID_OK)
|
||||
return;
|
||||
name = dlg.get_name();
|
||||
if (name == "") {
|
||||
show_error(this, _(L("The supplied name is empty. It can't be saved.")));
|
||||
return;
|
||||
}
|
||||
const Preset *existing = m_presets->find_preset(name, false);
|
||||
if (existing && (existing->is_default || existing->is_system)) {
|
||||
show_error(this, _(L("Cannot overwrite a system profile.")));
|
||||
return;
|
||||
}
|
||||
if (existing && (existing->is_external)) {
|
||||
show_error(this, _(L("Cannot overwrite an external profile.")));
|
||||
return;
|
||||
}
|
||||
if (existing && name != preset.name)
|
||||
{
|
||||
wxString msg_text = GUI::from_u8((boost::format(_utf8(L("Preset with name \"%1%\" already exists."))) % name).str());
|
||||
msg_text += "\n" + _(L("Replace?"));
|
||||
wxMessageDialog dialog(nullptr, msg_text, _(L("Warning")), wxICON_WARNING | wxYES | wxNO);
|
||||
|
||||
if (dialog.ShowModal() == wxID_NO)
|
||||
return;
|
||||
|
||||
// Remove the preset from the list.
|
||||
m_presets->delete_preset(name);
|
||||
}
|
||||
}
|
||||
|
||||
// Save the preset into Slic3r::data_dir / presets / section_name / preset_name.ini
|
||||
|
|
@ -3345,13 +3327,70 @@ void Tab::delete_preset()
|
|||
// Don't let the user delete the ' - default - ' configuration.
|
||||
std::string action = current_preset.is_external ? _utf8(L("remove")) : _utf8(L("delete"));
|
||||
// TRN remove/delete
|
||||
const wxString msg = from_u8((boost::format(_utf8(L("Are you sure you want to %1% the selected preset?"))) % action).str());
|
||||
|
||||
PhysicalPrinterCollection& physical_printers = m_preset_bundle->physical_printers;
|
||||
wxString msg;
|
||||
if (m_presets_choice->is_selected_physical_printer())
|
||||
msg = from_u8((boost::format(_u8L("Are you sure you want to delete \"%1%\" preset from the physical printer \"%2%\"?"))
|
||||
% current_preset.name % physical_printers.get_selected_printer_name()).str());
|
||||
else
|
||||
{
|
||||
if (m_type == Preset::TYPE_PRINTER && !physical_printers.empty())
|
||||
{
|
||||
// Check preset for delete in physical printers
|
||||
// Ask a customer about next action, if there is a printer with just one preset and this preset is equal to delete
|
||||
std::vector<std::string> ph_printers = physical_printers.get_printers_with_preset(current_preset.name);
|
||||
std::vector<std::string> ph_printers_only = physical_printers.get_printers_with_only_preset(current_preset.name);
|
||||
|
||||
if (!ph_printers.empty()) {
|
||||
msg += _L("Next physical printer(s) has/have selected preset") + ":";
|
||||
for (const std::string& printer : ph_printers)
|
||||
msg += "\n \"" + from_u8(printer) + "\",";
|
||||
msg.RemoveLast();
|
||||
msg += "\n" + _L("Note, that selected preset will be deleted from this/those printer(s) too.")+ "\n\n";
|
||||
}
|
||||
|
||||
if (!ph_printers_only.empty()) {
|
||||
msg += _L("Next physical printer(s) has/have one and only selected preset") + ":";
|
||||
for (const std::string& printer : ph_printers_only)
|
||||
msg += "\n \"" + from_u8(printer) + "\",";
|
||||
msg.RemoveLast();
|
||||
msg += "\n" + _L("Note, that this/those printer(s) will be deleted after deleting of the selected preset.") + "\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
msg += from_u8((boost::format(_u8L("Are you sure you want to %1% the selected preset?")) % action).str());
|
||||
}
|
||||
|
||||
action = current_preset.is_external ? _utf8(L("Remove")) : _utf8(L("Delete"));
|
||||
// TRN Remove/Delete
|
||||
wxString title = from_u8((boost::format(_utf8(L("%1% Preset"))) % action).str()); //action + _(L(" Preset"));
|
||||
if (current_preset.is_default ||
|
||||
wxID_YES != wxMessageDialog(parent(), msg, title, wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION).ShowModal())
|
||||
return;
|
||||
|
||||
// if we just delete preset from the physical printer
|
||||
if (m_presets_choice->is_selected_physical_printer()) {
|
||||
PhysicalPrinter& printer = physical_printers.get_selected_printer();
|
||||
|
||||
if (printer.preset_names.size() == 1) {
|
||||
wxMessageDialog dialog(nullptr, _L("It's a last for this physical printer. We can't delete it"), _L("Information"), wxICON_INFORMATION | wxOK);
|
||||
dialog.ShowModal();
|
||||
return;
|
||||
}
|
||||
// just delete this preset from the current physical printer
|
||||
printer.delete_preset(m_presets->get_edited_preset().name);
|
||||
// select first from the possible presets for this printer
|
||||
physical_printers.select_printer(printer);
|
||||
|
||||
this->select_preset(physical_printers.get_selected_printer_preset_name());
|
||||
return;
|
||||
}
|
||||
|
||||
// delete selected preset from printers and printer, if it's needed
|
||||
if (m_type == Preset::TYPE_PRINTER && !physical_printers.empty())
|
||||
physical_printers.delete_preset_from_printers(current_preset.name);
|
||||
|
||||
// Select will handle of the preset dependencies, of saving & closing the depending profiles, and
|
||||
// finally of deleting the preset.
|
||||
this->select_preset("", true);
|
||||
|
|
@ -3360,6 +3399,7 @@ void Tab::delete_preset()
|
|||
void Tab::toggle_show_hide_incompatible()
|
||||
{
|
||||
m_show_incompatible_presets = !m_show_incompatible_presets;
|
||||
m_presets_choice->set_show_incompatible_presets(m_show_incompatible_presets);
|
||||
update_show_hide_incompatible_button();
|
||||
update_tab_ui();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,12 +33,14 @@
|
|||
#include "Event.hpp"
|
||||
#include "wxExtensions.hpp"
|
||||
#include "ConfigManipulation.hpp"
|
||||
#include "Preset.hpp"
|
||||
#include "OptionsGroup.hpp"
|
||||
#include "libslic3r/Preset.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
class TabPresetComboBox;
|
||||
|
||||
// Single Tab page containing a{ vsizer } of{ optgroups }
|
||||
// package Slic3r::GUI::Tab::Page;
|
||||
using ConfigOptionsGroupShp = std::shared_ptr<ConfigOptionsGroup>;
|
||||
|
|
@ -113,10 +115,11 @@ protected:
|
|||
Preset::Type m_type;
|
||||
std::string m_name;
|
||||
const wxString m_title;
|
||||
PresetBitmapComboBox* m_presets_choice;
|
||||
TabPresetComboBox* m_presets_choice;
|
||||
ScalableButton* m_search_btn;
|
||||
ScalableButton* m_btn_save_preset;
|
||||
ScalableButton* m_btn_delete_preset;
|
||||
ScalableButton* m_btn_edit_ph_printer {nullptr};
|
||||
ScalableButton* m_btn_hide_incompatible_presets;
|
||||
wxBoxSizer* m_hsizer;
|
||||
wxBoxSizer* m_left_sizer;
|
||||
|
|
@ -206,8 +209,6 @@ protected:
|
|||
bool m_is_nonsys_values{ true };
|
||||
bool m_postpone_update_ui {false};
|
||||
|
||||
size_t m_selected_preset_item{ 0 };
|
||||
|
||||
void set_type();
|
||||
|
||||
int m_em_unit;
|
||||
|
|
@ -275,8 +276,10 @@ public:
|
|||
void load_current_preset();
|
||||
void rebuild_page_tree();
|
||||
void update_page_tree_visibility();
|
||||
// Select a new preset, possibly delete the current one.
|
||||
void select_preset(std::string preset_name = "", bool delete_current = false);
|
||||
void update_btns_enabling();
|
||||
void update_preset_choice();
|
||||
// Select a new preset, possibly delete the current one.
|
||||
void select_preset(std::string preset_name = "", bool delete_current = false, const std::string& last_selected_ph_printer_name = "");
|
||||
bool may_discard_current_dirty_preset(PresetCollection* presets = nullptr, const std::string& new_printer_name = "");
|
||||
bool may_switch_to_SLA_preset();
|
||||
|
||||
|
|
@ -320,7 +323,6 @@ public:
|
|||
|
||||
DynamicPrintConfig* get_config() { return m_config; }
|
||||
PresetCollection* get_presets() { return m_presets; }
|
||||
size_t get_selected_preset_item() { return m_selected_preset_item; }
|
||||
|
||||
void on_value_change(const std::string& opt_key, const boost::any& value);
|
||||
|
||||
|
|
|
|||
|
|
@ -304,94 +304,6 @@ void wxCheckListBoxComboPopup::OnListBoxSelection(wxCommandEvent& evt)
|
|||
}
|
||||
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
// *** PresetBitmapComboBox ***
|
||||
|
||||
/* For PresetBitmapComboBox we use bitmaps that are created from images that are already scaled appropriately for Retina
|
||||
* (Contrary to the intuition, the `scale` argument for Bitmap's constructor doesn't mean
|
||||
* "please scale this to such and such" but rather
|
||||
* "the wxImage is already sized for backing scale such and such". )
|
||||
* Unfortunately, the constructor changes the size of wxBitmap too.
|
||||
* Thus We need to use unscaled size value for bitmaps that we use
|
||||
* to avoid scaled size of control items.
|
||||
* For this purpose control drawing methods and
|
||||
* control size calculation methods (virtual) are overridden.
|
||||
**/
|
||||
|
||||
PresetBitmapComboBox::PresetBitmapComboBox(wxWindow* parent, const wxSize& size) :
|
||||
wxBitmapComboBox(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, size, 0, nullptr, wxCB_READONLY)
|
||||
{}
|
||||
|
||||
#ifdef __APPLE__
|
||||
bool PresetBitmapComboBox::OnAddBitmap(const wxBitmap& bitmap)
|
||||
{
|
||||
if (bitmap.IsOk())
|
||||
{
|
||||
// we should use scaled! size values of bitmap
|
||||
int width = (int)bitmap.GetScaledWidth();
|
||||
int height = (int)bitmap.GetScaledHeight();
|
||||
|
||||
if (m_usedImgSize.x < 0)
|
||||
{
|
||||
// If size not yet determined, get it from this image.
|
||||
m_usedImgSize.x = width;
|
||||
m_usedImgSize.y = height;
|
||||
|
||||
// Adjust control size to vertically fit the bitmap
|
||||
wxWindow* ctrl = GetControl();
|
||||
ctrl->InvalidateBestSize();
|
||||
wxSize newSz = ctrl->GetBestSize();
|
||||
wxSize sz = ctrl->GetSize();
|
||||
if (newSz.y > sz.y)
|
||||
ctrl->SetSize(sz.x, newSz.y);
|
||||
else
|
||||
DetermineIndent();
|
||||
}
|
||||
|
||||
wxCHECK_MSG(width == m_usedImgSize.x && height == m_usedImgSize.y,
|
||||
false,
|
||||
"you can only add images of same size");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void PresetBitmapComboBox::OnDrawItem(wxDC& dc,
|
||||
const wxRect& rect,
|
||||
int item,
|
||||
int flags) const
|
||||
{
|
||||
const wxBitmap& bmp = *(wxBitmap*)m_bitmaps[item];
|
||||
if (bmp.IsOk())
|
||||
{
|
||||
// we should use scaled! size values of bitmap
|
||||
wxCoord w = bmp.GetScaledWidth();
|
||||
wxCoord h = bmp.GetScaledHeight();
|
||||
|
||||
const int imgSpacingLeft = 4;
|
||||
|
||||
// Draw the image centered
|
||||
dc.DrawBitmap(bmp,
|
||||
rect.x + (m_usedImgSize.x - w) / 2 + imgSpacingLeft,
|
||||
rect.y + (rect.height - h) / 2,
|
||||
true);
|
||||
}
|
||||
|
||||
wxString text = GetString(item);
|
||||
if (!text.empty())
|
||||
dc.DrawText(text,
|
||||
rect.x + m_imgAreaWidth + 1,
|
||||
rect.y + (rect.height - dc.GetCharHeight()) / 2);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// *** wxDataViewTreeCtrlComboPopup ***
|
||||
|
||||
const unsigned int wxDataViewTreeCtrlComboPopup::DefaultWidth = 270;
|
||||
|
|
@ -823,11 +735,12 @@ void MenuWithSeparators::SetSecondSeparator()
|
|||
// ----------------------------------------------------------------------------
|
||||
ScalableBitmap::ScalableBitmap( wxWindow *parent,
|
||||
const std::string& icon_name/* = ""*/,
|
||||
const int px_cnt/* = 16*/):
|
||||
const int px_cnt/* = 16*/,
|
||||
const bool grayscale/* = false*/):
|
||||
m_parent(parent), m_icon_name(icon_name),
|
||||
m_px_cnt(px_cnt)
|
||||
{
|
||||
m_bmp = create_scaled_bitmap(icon_name, parent, px_cnt);
|
||||
m_bmp = create_scaled_bitmap(icon_name, parent, px_cnt, grayscale);
|
||||
}
|
||||
|
||||
wxSize ScalableBitmap::GetBmpSize() const
|
||||
|
|
@ -860,7 +773,7 @@ int ScalableBitmap::GetBmpHeight() const
|
|||
|
||||
void ScalableBitmap::msw_rescale()
|
||||
{
|
||||
m_bmp = create_scaled_bitmap(m_icon_name, m_parent, m_px_cnt);
|
||||
m_bmp = create_scaled_bitmap(m_icon_name, m_parent, m_px_cnt, m_grayscale);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -94,37 +94,6 @@ public:
|
|||
void OnListBoxSelection(wxCommandEvent& evt);
|
||||
};
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
// *** PresetBitmapComboBox ***
|
||||
|
||||
// BitmapComboBox used to presets list on Sidebar and Tabs
|
||||
class PresetBitmapComboBox: public wxBitmapComboBox
|
||||
{
|
||||
public:
|
||||
PresetBitmapComboBox(wxWindow* parent, const wxSize& size = wxDefaultSize);
|
||||
~PresetBitmapComboBox() {}
|
||||
|
||||
#ifdef __APPLE__
|
||||
protected:
|
||||
/* For PresetBitmapComboBox we use bitmaps that are created from images that are already scaled appropriately for Retina
|
||||
* (Contrary to the intuition, the `scale` argument for Bitmap's constructor doesn't mean
|
||||
* "please scale this to such and such" but rather
|
||||
* "the wxImage is already sized for backing scale such and such". )
|
||||
* Unfortunately, the constructor changes the size of wxBitmap too.
|
||||
* Thus We need to use unscaled size value for bitmaps that we use
|
||||
* to avoid scaled size of control items.
|
||||
* For this purpose control drawing methods and
|
||||
* control size calculation methods (virtual) are overridden.
|
||||
**/
|
||||
virtual bool OnAddBitmap(const wxBitmap& bitmap) override;
|
||||
virtual void OnDrawItem(wxDC& dc, const wxRect& rect, int item, int flags) const override;
|
||||
#endif
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// *** wxDataViewTreeCtrlComboBox ***
|
||||
|
||||
|
|
@ -160,7 +129,8 @@ public:
|
|||
ScalableBitmap() {};
|
||||
ScalableBitmap( wxWindow *parent,
|
||||
const std::string& icon_name = "",
|
||||
const int px_cnt = 16);
|
||||
const int px_cnt = 16,
|
||||
const bool grayscale = false);
|
||||
|
||||
~ScalableBitmap() {}
|
||||
|
||||
|
|
@ -181,6 +151,7 @@ private:
|
|||
wxBitmap m_bmp = wxBitmap();
|
||||
std::string m_icon_name = "";
|
||||
int m_px_cnt {16};
|
||||
bool m_grayscale {false};
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -30,10 +30,10 @@
|
|||
|
||||
#include "libslic3r/Model.hpp"
|
||||
#include "libslic3r/Print.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
#include "libslic3r/Format/3mf.hpp"
|
||||
#include "../GUI/GUI.hpp"
|
||||
#include "../GUI/I18N.hpp"
|
||||
#include "../GUI/PresetBundle.hpp"
|
||||
|
||||
#include <wx/msgdlg.h>
|
||||
#include <wx/progdlg.h>
|
||||
|
|
|
|||
|
|
@ -19,9 +19,9 @@
|
|||
#include "libslic3r/libslic3r.h"
|
||||
#include "libslic3r/format.hpp"
|
||||
#include "libslic3r/Utils.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
#include "slic3r/GUI/GUI.hpp"
|
||||
#include "slic3r/GUI/I18N.hpp"
|
||||
#include "slic3r/GUI/PresetBundle.hpp"
|
||||
#include "slic3r/GUI/UpdateDialogs.hpp"
|
||||
#include "slic3r/GUI/ConfigWizard.hpp"
|
||||
#include "slic3r/GUI/GUI_App.hpp"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue