mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 17:27:52 -06:00
First try to convert a user printer profiles to the physical printers
This commit is contained in:
parent
72ec414f1e
commit
3d990a9189
5 changed files with 42 additions and 8 deletions
|
@ -1481,7 +1481,7 @@ PhysicalPrinterCollection::PhysicalPrinterCollection( const std::vector<std::str
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load all presets found in dir_path.
|
// Load all printers found in dir_path.
|
||||||
// Throws an exception on error.
|
// Throws an exception on error.
|
||||||
void PhysicalPrinterCollection::load_printers(const std::string& dir_path, const std::string& subdir)
|
void PhysicalPrinterCollection::load_printers(const std::string& dir_path, const std::string& subdir)
|
||||||
{
|
{
|
||||||
|
@ -1498,7 +1498,7 @@ void PhysicalPrinterCollection::load_printers(const std::string& dir_path, const
|
||||||
if (this->find_printer(name, false)) {
|
if (this->find_printer(name, false)) {
|
||||||
// This happens when there's is a preset (most likely legacy one) with the same name as a system preset
|
// This happens when there's is a preset (most likely legacy one) with the same name as a system preset
|
||||||
// that's already been loaded from a bundle.
|
// that's already been loaded from a bundle.
|
||||||
BOOST_LOG_TRIVIAL(warning) << "Preset already present, not loading: " << name;
|
BOOST_LOG_TRIVIAL(warning) << "Printer already present, not loading: " << name;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -1530,6 +1530,35 @@ void PhysicalPrinterCollection::load_printers(const std::string& dir_path, const
|
||||||
throw std::runtime_error(errors_cummulative);
|
throw std::runtime_error(errors_cummulative);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if there is saved user presets, contains information about "Print Host upload",
|
||||||
|
// Create default printers with this presets
|
||||||
|
// Throws an exception on error.
|
||||||
|
void PhysicalPrinterCollection::load_printers(const PrinterPresetCollection& printer_presets, std::string def_printer_name/* = ""*/)
|
||||||
|
{
|
||||||
|
if (def_printer_name.empty())
|
||||||
|
def_printer_name = "Printer";
|
||||||
|
|
||||||
|
int cnt=0;
|
||||||
|
std::string errors_cummulative;
|
||||||
|
// Store the loaded printers into a new vector
|
||||||
|
std::deque<PhysicalPrinter> printers_loaded;
|
||||||
|
for (const Preset& preset: printer_presets) {
|
||||||
|
const DynamicPrintConfig& config = preset.config;
|
||||||
|
if (!config.opt_string("print_host").empty() ||
|
||||||
|
!config.opt_string("printhost_apikey").empty() ||
|
||||||
|
!config.opt_string("printhost_cafile").empty() ) {
|
||||||
|
PhysicalPrinter printer((boost::format("%1% %2%") % def_printer_name % ++cnt ).str(), preset);
|
||||||
|
printer.loaded = true;
|
||||||
|
printers_loaded.emplace_back(printer);
|
||||||
|
|
||||||
|
save_printer(printer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!errors_cummulative.empty())
|
||||||
|
throw std::runtime_error(errors_cummulative);
|
||||||
|
}
|
||||||
|
|
||||||
PhysicalPrinter* PhysicalPrinterCollection::find_printer( const std::string& name, bool first_visible_if_not_found)
|
PhysicalPrinter* PhysicalPrinterCollection::find_printer( const std::string& name, bool first_visible_if_not_found)
|
||||||
{
|
{
|
||||||
PhysicalPrinter key(name);
|
PhysicalPrinter key(name);
|
||||||
|
|
|
@ -626,6 +626,7 @@ public:
|
||||||
|
|
||||||
// Load ini files of the particular type from the provided directory path.
|
// Load ini files of the particular type from the provided directory path.
|
||||||
void load_printers(const std::string& dir_path, const std::string& subdir);
|
void load_printers(const std::string& dir_path, const std::string& subdir);
|
||||||
|
void load_printers(const PrinterPresetCollection &printer_presets, std::string def_printer_name = "");
|
||||||
|
|
||||||
// Save the printer under a new name. If the name is different from the old one,
|
// Save the printer under a new name. If the name is different from the old one,
|
||||||
// a new printer is stored into the list of printers.
|
// a new printer is stored into the list of printers.
|
||||||
|
|
|
@ -201,6 +201,7 @@ void PresetBundle::load_presets(AppConfig &config, const std::string &preferred_
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
this->physical_printers.load_printers(dir_user_presets, "physical_printer");
|
this->physical_printers.load_printers(dir_user_presets, "physical_printer");
|
||||||
|
this->physical_printers.load_printers(this->printers);
|
||||||
} catch (const std::runtime_error &err) {
|
} catch (const std::runtime_error &err) {
|
||||||
errors_cummulative += err.what();
|
errors_cummulative += err.what();
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,6 +131,12 @@ PresetComboBox::~PresetComboBox()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BitmapCache& PresetComboBox::bitmap_cache()
|
||||||
|
{
|
||||||
|
static BitmapCache bmps;
|
||||||
|
return bmps;
|
||||||
|
}
|
||||||
|
|
||||||
void PresetComboBox::set_label_marker(int item, LabelItemType label_item_type)
|
void PresetComboBox::set_label_marker(int item, LabelItemType label_item_type)
|
||||||
{
|
{
|
||||||
this->SetClientData(item, (void*)label_item_type);
|
this->SetClientData(item, (void*)label_item_type);
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#include "libslic3r/Preset.hpp"
|
#include "libslic3r/Preset.hpp"
|
||||||
#include "wxExtensions.hpp"
|
#include "wxExtensions.hpp"
|
||||||
#include "GUI_Utils.hpp"
|
#include "GUI_Utils.hpp"
|
||||||
#include "BitmapCache.hpp"
|
//#include "BitmapCache.hpp"
|
||||||
|
|
||||||
class wxString;
|
class wxString;
|
||||||
class wxTextCtrl;
|
class wxTextCtrl;
|
||||||
|
@ -22,7 +22,7 @@ namespace Slic3r {
|
||||||
|
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
|
class BitmapCache;
|
||||||
// ---------------------------------
|
// ---------------------------------
|
||||||
// *** PresetComboBox ***
|
// *** PresetComboBox ***
|
||||||
// ---------------------------------
|
// ---------------------------------
|
||||||
|
@ -72,10 +72,7 @@ protected:
|
||||||
PresetCollection* m_collection {nullptr};
|
PresetCollection* m_collection {nullptr};
|
||||||
|
|
||||||
// Caching bitmaps for the all bitmaps, used in preset comboboxes
|
// Caching bitmaps for the all bitmaps, used in preset comboboxes
|
||||||
static BitmapCache& bitmap_cache() {
|
static BitmapCache& bitmap_cache();
|
||||||
static BitmapCache bmps;
|
|
||||||
return bmps;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Indicator, that the preset is compatible with the selected printer.
|
// Indicator, that the preset is compatible with the selected printer.
|
||||||
ScalableBitmap m_bitmapCompatible;
|
ScalableBitmap m_bitmapCompatible;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue