Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYuSanka <yusanka@gmail.com>2020-06-25 13:58:59 +0300
committerYuSanka <yusanka@gmail.com>2020-06-25 13:58:59 +0300
commit1a2926050fee0b5ab118054aaa4ccb65614d2063 (patch)
tree9588f098a4e489e13be900586d6a29753056b6d7 /src
parent8ac839f427ef2c0d1470de51e8d9515689296e83 (diff)
PhysicalPrinter. PhysicalPrinterDialog improvements
Diffstat (limited to 'src')
-rw-r--r--src/libslic3r/Preset.cpp3
-rw-r--r--src/libslic3r/PrintConfig.cpp11
-rw-r--r--src/libslic3r/PrintConfig.hpp13
-rw-r--r--src/slic3r/GUI/Field.cpp2
-rw-r--r--src/slic3r/GUI/Field.hpp2
-rw-r--r--src/slic3r/GUI/GUI.cpp2
-rw-r--r--src/slic3r/GUI/OptionsGroup.cpp19
-rw-r--r--src/slic3r/GUI/OptionsGroup.hpp7
-rw-r--r--src/slic3r/GUI/PresetComboBoxes.cpp44
-rw-r--r--src/slic3r/GUI/PresetComboBoxes.hpp2
10 files changed, 84 insertions, 21 deletions
diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp
index e17130f69..abc508b48 100644
--- a/src/libslic3r/Preset.cpp
+++ b/src/libslic3r/Preset.cpp
@@ -1354,7 +1354,8 @@ const std::vector<std::string>& PhysicalPrinter::printer_options()
"host_type",
"print_host",
"printhost_apikey",
- "printhost_cafile",
+ "printhost_cafile",
+ "authorization_type",
"login",
"password"
};
diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp
index 93ef170fb..01b17ec0d 100644
--- a/src/libslic3r/PrintConfig.cpp
+++ b/src/libslic3r/PrintConfig.cpp
@@ -150,6 +150,17 @@ void PrintConfigDef::init_common_params()
def->tooltip = L("Related printer preset name");
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionString(""));
+
+ def = this->add("authorization_type", coEnum);
+ def->label = L("Authorization Type");
+// def->tooltip = L("");
+ def->enum_keys_map = &ConfigOptionEnum<AuthorizationType>::get_enum_values();
+ def->enum_values.push_back("key");
+ def->enum_values.push_back("user");
+ def->enum_labels.push_back("KeyPassword");
+ def->enum_labels.push_back("UserPassword");
+ def->mode = comAdvanced;
+ def->set_default_value(new ConfigOptionEnum<AuthorizationType>(atKeyPassword));
}
void PrintConfigDef::init_fff_params()
diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp
index f28ef2a22..9b5c47512 100644
--- a/src/libslic3r/PrintConfig.hpp
+++ b/src/libslic3r/PrintConfig.hpp
@@ -33,6 +33,10 @@ enum PrintHostType {
htOctoPrint, htDuet, htFlashAir, htAstroBox
};
+enum AuthorizationType {
+ atKeyPassword, atUserPassword
+};
+
enum InfillPattern : int {
ipRectilinear, ipMonotonous, ipGrid, ipTriangles, ipStars, ipCubic, ipLine, ipConcentric, ipHoneycomb, ip3DHoneycomb,
ipGyroid, ipHilbertCurve, ipArchimedeanChords, ipOctagramSpiral, ipCount,
@@ -109,6 +113,15 @@ template<> inline const t_config_enum_values& ConfigOptionEnum<PrintHostType>::g
return keys_map;
}
+template<> inline const t_config_enum_values& ConfigOptionEnum<AuthorizationType>::get_enum_values() {
+ static t_config_enum_values keys_map;
+ if (keys_map.empty()) {
+ keys_map["key"] = atKeyPassword;
+ keys_map["user"] = atUserPassword;
+ }
+ return keys_map;
+}
+
template<> inline const t_config_enum_values& ConfigOptionEnum<InfillPattern>::get_enum_values() {
static t_config_enum_values keys_map;
if (keys_map.empty()) {
diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp
index 8ab82e20d..9cb3d726d 100644
--- a/src/slic3r/GUI/Field.cpp
+++ b/src/slic3r/GUI/Field.cpp
@@ -1080,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();
diff --git a/src/slic3r/GUI/Field.hpp b/src/slic3r/GUI/Field.hpp
index 484b2059f..1a4997756 100644
--- a/src/slic3r/GUI/Field.hpp
+++ b/src/slic3r/GUI/Field.hpp
@@ -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);
diff --git a/src/slic3r/GUI/GUI.cpp b/src/slic3r/GUI/GUI.cpp
index b9516b12f..88c457668 100644
--- a/src/slic3r/GUI/GUI.cpp
+++ b/src/slic3r/GUI/GUI.cpp
@@ -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:{
diff --git a/src/slic3r/GUI/OptionsGroup.cpp b/src/slic3r/GUI/OptionsGroup.cpp
index 819c214a8..1bebb8827 100644
--- a/src/slic3r/GUI/OptionsGroup.cpp
+++ b/src/slic3r/GUI/OptionsGroup.cpp
@@ -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);
diff --git a/src/slic3r/GUI/OptionsGroup.hpp b/src/slic3r/GUI/OptionsGroup.hpp
index 2e6f9aa0f..edd4a15bc 100644
--- a/src/slic3r/GUI/OptionsGroup.hpp
+++ b/src/slic3r/GUI/OptionsGroup.hpp
@@ -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);
}
diff --git a/src/slic3r/GUI/PresetComboBoxes.cpp b/src/slic3r/GUI/PresetComboBoxes.cpp
index e9da7dc9d..b39582ee0 100644
--- a/src/slic3r/GUI/PresetComboBoxes.cpp
+++ b/src/slic3r/GUI/PresetComboBoxes.cpp
@@ -837,7 +837,7 @@ void TabPresetComboBox::update_dirty()
PhysicalPrinterDialog::PhysicalPrinterDialog(wxString printer_name)
- : DPIDialog(NULL, wxID_ANY, _L("PhysicalPrinter"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
+ : 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));
@@ -856,7 +856,7 @@ PhysicalPrinterDialog::PhysicalPrinterDialog(wxString printer_name)
// update values
m_optgroup->reload_config();
- update_octoprint_visible();
+ update();
});
m_printer_presets->update();
@@ -898,6 +898,11 @@ PhysicalPrinterDialog::PhysicalPrinterDialog(wxString printer_name)
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) {
@@ -952,6 +957,9 @@ void PhysicalPrinterDialog::build_printhost_settings(ConfigOptionsGroup* m_optgr
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);
@@ -999,7 +1007,8 @@ void PhysicalPrinterDialog::build_printhost_settings(ConfigOptionsGroup* m_optgr
(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\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);
@@ -1015,20 +1024,33 @@ void PhysicalPrinterDialog::build_printhost_settings(ConfigOptionsGroup* m_optgr
m_optgroup->append_single_option_line(option);
}
- update_octoprint_visible();
+ update();
}
-void PhysicalPrinterDialog::update_octoprint_visible()
+void PhysicalPrinterDialog::update()
{
const PrinterTechnology tech = Preset::printer_technology(m_printer.config);
// Only offer the host type selection for FFF, for SLA it's always the SL1 printer (at the moment)
- Field* host_type = m_optgroup->get_field("host_type");
- if (tech == ptFFF)
- host_type->enable();
+ 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 {
- host_type->set_value(int(PrintHostType::htOctoPrint), false);
- host_type->disable();
+ 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();
}
void PhysicalPrinterDialog::on_dpi_changed(const wxRect& suggested_rect)
@@ -1044,7 +1066,7 @@ void PhysicalPrinterDialog::on_dpi_changed(const wxRect& suggested_rect)
msw_buttons_rescale(this, em, { wxID_OK, wxID_CANCEL });
- const wxSize& size = wxSize(40 * em, 30 * em);
+ const wxSize& size = wxSize(45 * em, 35 * em);
SetMinSize(size);
Fit();
diff --git a/src/slic3r/GUI/PresetComboBoxes.hpp b/src/slic3r/GUI/PresetComboBoxes.hpp
index 9261e92ef..196c4368e 100644
--- a/src/slic3r/GUI/PresetComboBoxes.hpp
+++ b/src/slic3r/GUI/PresetComboBoxes.hpp
@@ -177,7 +177,7 @@ class PhysicalPrinterDialog : public DPIDialog
ScalableButton* m_printhost_cafile_browse_btn {nullptr};
void build_printhost_settings(ConfigOptionsGroup* optgroup);
- void update_octoprint_visible();
+ void update();
void OnOK(wxEvent& event);
public: