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
diff options
context:
space:
mode:
authorVojtech Kral <vojtech@kral.hk>2018-04-16 18:26:02 +0300
committerVojtech Kral <vojtech@kral.hk>2018-04-16 18:32:58 +0300
commit214ad2925bc03893d9511bd8b540e2083a2c1c96 (patch)
treed43a6a02ab80dd0f466f42b0b7762f3dac9848f2 /xs/src/slic3r/GUI/GUI.cpp
parent7710b541da5a5b6c519fa67a91286d1c37a12791 (diff)
parent2726267748b7ff23665794db121db2484fbc3060 (diff)
Merge branch 'master' into updating
Diffstat (limited to 'xs/src/slic3r/GUI/GUI.cpp')
-rw-r--r--xs/src/slic3r/GUI/GUI.cpp99
1 files changed, 86 insertions, 13 deletions
diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp
index ebc62af1b..96d137165 100644
--- a/xs/src/slic3r/GUI/GUI.cpp
+++ b/xs/src/slic3r/GUI/GUI.cpp
@@ -1,6 +1,8 @@
#include "GUI.hpp"
+#include "WipeTowerDialog.hpp"
#include <assert.h>
+#include <cmath>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/filesystem.hpp>
@@ -38,6 +40,7 @@
#include <wx/combo.h>
#include <wx/window.h>
#include <wx/msgdlg.h>
+#include <wx/settings.h>
#include "wxExtensions.hpp"
@@ -182,6 +185,8 @@ wxNotebook *g_wxTabPanel = nullptr;
AppConfig *g_AppConfig = nullptr;
PresetBundle *g_PresetBundle= nullptr;
PresetUpdater *g_PresetUpdater = nullptr;
+wxColour g_color_label_modified;
+wxColour g_color_label_sys;
std::vector<Tab *> g_tabs_list;
@@ -189,10 +194,24 @@ wxLocale* g_wxLocale;
std::shared_ptr<ConfigOptionsGroup> m_optgroup;
double m_brim_width = 0.0;
+wxButton* g_wiping_dialog_button = nullptr;
+
+static void init_label_colours()
+{
+ auto luma = get_colour_approx_luma(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
+ if (luma >= 128) {
+ g_color_label_modified = wxColour(253, 88, 0);
+ g_color_label_sys = wxColour(26, 132, 57);
+ } else {
+ g_color_label_modified = wxColour(253, 111, 40);
+ g_color_label_sys = wxColour(115, 220, 103);
+ }
+}
void set_wxapp(wxApp *app)
{
g_wxApp = app;
+ init_label_colours();
}
void set_main_frame(wxFrame *main_frame)
@@ -531,7 +550,7 @@ TabIface* get_preset_tab_iface(char *name)
}
// opt_index = 0, by the reason of zero-index in ConfigOptionVector by default (in case only one element)
-void change_opt_value(DynamicPrintConfig& config, t_config_option_key opt_key, boost::any value, int opt_index /*= 0*/)
+void change_opt_value(DynamicPrintConfig& config, const t_config_option_key& opt_key, const boost::any& value, int opt_index /*= 0*/)
{
try{
switch (config.def()->get(opt_key)->type){
@@ -567,11 +586,18 @@ void change_opt_value(DynamicPrintConfig& config, t_config_option_key opt_key, b
config.set_key_value(opt_key, new ConfigOptionString(boost::any_cast<std::string>(value)));
break;
case coStrings:{
- if (opt_key.compare("compatible_printers") == 0 ||
- config.def()->get(opt_key)->gui_flags.compare("serialized") == 0){
- config.option<ConfigOptionStrings>(opt_key)->values.resize(0);
- std::vector<std::string> values = boost::any_cast<std::vector<std::string>>(value);
- if (values.size() == 1 && values[0] == "")
+ if (opt_key.compare("compatible_printers") == 0) {
+ config.option<ConfigOptionStrings>(opt_key)->values =
+ boost::any_cast<std::vector<std::string>>(value);
+ }
+ else if (config.def()->get(opt_key)->gui_flags.compare("serialized") == 0){
+ std::string str = boost::any_cast<std::string>(value);
+ if (str.back() == ';') str.pop_back();
+ // Split a string to multiple strings by a semi - colon.This is the old way of storing multi - string values.
+ // Currently used for the post_process config value only.
+ std::vector<std::string> values;
+ boost::split(values, str, boost::is_any_of(";"));
+ if (values.size() == 1 && values[0] == "")
break;
config.option<ConfigOptionStrings>(opt_key)->values = values;
}
@@ -638,17 +664,17 @@ void add_created_tab(Tab* panel)
g_wxTabPanel->AddPage(panel, panel->title());
}
-void show_error(wxWindow* parent, wxString message){
+void show_error(wxWindow* parent, const wxString& message){
auto msg_wingow = new wxMessageDialog(parent, message, _(L("Error")), wxOK | wxICON_ERROR);
msg_wingow->ShowModal();
}
-void show_info(wxWindow* parent, wxString message, wxString title){
+void show_info(wxWindow* parent, const wxString& message, const wxString& title){
auto msg_wingow = new wxMessageDialog(parent, message, title.empty() ? _(L("Notice")) : title, wxOK | wxICON_INFORMATION);
msg_wingow->ShowModal();
}
-void warning_catcher(wxWindow* parent, wxString message){
+void warning_catcher(wxWindow* parent, const wxString& message){
if (message == _(L("GLUquadricObjPtr | Attempt to free unreferenced scalar")) )
return;
auto msg = new wxMessageDialog(parent, message, _(L("Warning")), wxOK | wxICON_WARNING);
@@ -659,12 +685,25 @@ wxApp* get_app(){
return g_wxApp;
}
-wxColour* get_modified_label_clr(){
- return new wxColour(253, 88, 0);
+const wxColour& get_modified_label_clr() {
+ return g_color_label_modified;
}
-wxColour* get_sys_label_clr(){
- return new wxColour(26, 132, 57);
+const wxColour& get_sys_label_clr() {
+ return g_color_label_sys;
+}
+
+unsigned get_colour_approx_luma(const wxColour &colour)
+{
+ double r = colour.Red();
+ double g = colour.Green();
+ double b = colour.Blue();
+
+ return std::round(std::sqrt(
+ r * r * .241 +
+ g * g * .691 +
+ b * b * .068
+ ));
}
void create_combochecklist(wxComboCtrl* comboCtrl, std::string text, std::string items, bool initial_value)
@@ -829,6 +868,33 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl
option = Option(def, "brim");
m_optgroup->append_single_option_line(option);
+
+ Line line = { _(L("")), "" };
+ line.widget = [config](wxWindow* parent){
+ g_wiping_dialog_button = new wxButton(parent, wxID_ANY, _(L("Purging volumes")) + "\u2026", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
+ auto sizer = new wxBoxSizer(wxHORIZONTAL);
+ sizer->Add(g_wiping_dialog_button);
+ g_wiping_dialog_button->Bind(wxEVT_BUTTON, ([parent](wxCommandEvent& e)
+ {
+ auto &config = g_PresetBundle->project_config;
+ std::vector<double> init_matrix = (config.option<ConfigOptionFloats>("wiping_volumes_matrix"))->values;
+ std::vector<double> init_extruders = (config.option<ConfigOptionFloats>("wiping_volumes_extruders"))->values;
+
+ WipingDialog dlg(parent,std::vector<float>(init_matrix.begin(),init_matrix.end()),std::vector<float>(init_extruders.begin(),init_extruders.end()));
+
+ if (dlg.ShowModal() == wxID_OK) {
+ std::vector<float> matrix = dlg.get_matrix();
+ std::vector<float> extruders = dlg.get_extruders();
+ (config.option<ConfigOptionFloats>("wiping_volumes_matrix"))->values = std::vector<double>(matrix.begin(),matrix.end());
+ (config.option<ConfigOptionFloats>("wiping_volumes_extruders"))->values = std::vector<double>(extruders.begin(),extruders.end());
+ }
+ }));
+ return sizer;
+ };
+ m_optgroup->append_line(line);
+
+
+
sizer->Add(m_optgroup->sizer, 0, wxEXPAND | wxBOTTOM | wxBottom, 1);
}
@@ -837,6 +903,12 @@ ConfigOptionsGroup* get_optgroup()
return m_optgroup.get();
}
+
+wxButton* get_wiping_dialog_button()
+{
+ return g_wiping_dialog_button;
+}
+
wxWindow* export_option_creator(wxWindow* parent)
{
wxPanel* panel = new wxPanel(parent, -1);
@@ -880,6 +952,7 @@ int get_export_option(wxFileDialog* dlg)
}
return 0;
+
}
void about()