mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-14 20:26:00 +08:00
Add the default/custom switch into project settings
This commit is contained in:
parent
e1b2bd4155
commit
c0aba8e2ca
@ -38,7 +38,8 @@ namespace Slic3r {
|
|||||||
|
|
||||||
static std::vector<std::string> s_project_options {
|
static std::vector<std::string> s_project_options {
|
||||||
"colorprint_heights",
|
"colorprint_heights",
|
||||||
"wiping_volumes_matrix"
|
"wiping_volumes_matrix",
|
||||||
|
"wiping_volumes_use_custom_matrix"
|
||||||
};
|
};
|
||||||
|
|
||||||
const char *PresetBundle::PRUSA_BUNDLE = "PrusaResearch";
|
const char *PresetBundle::PRUSA_BUNDLE = "PrusaResearch";
|
||||||
|
@ -246,6 +246,7 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n
|
|||||||
|| opt_key == "wipe_tower_no_sparse_layers"
|
|| opt_key == "wipe_tower_no_sparse_layers"
|
||||||
|| opt_key == "wipe_tower_extruder"
|
|| opt_key == "wipe_tower_extruder"
|
||||||
|| opt_key == "wiping_volumes_matrix"
|
|| opt_key == "wiping_volumes_matrix"
|
||||||
|
|| opt_key == "wiping_volumes_use_custom_matrix"
|
||||||
|| opt_key == "parking_pos_retraction"
|
|| opt_key == "parking_pos_retraction"
|
||||||
|| opt_key == "cooling_tube_retraction"
|
|| opt_key == "cooling_tube_retraction"
|
||||||
|| opt_key == "cooling_tube_length"
|
|| opt_key == "cooling_tube_length"
|
||||||
|
@ -3310,6 +3310,11 @@ void PrintConfigDef::init_fff_params()
|
|||||||
140., 140., 140., 0., 140.,
|
140., 140., 140., 0., 140.,
|
||||||
140., 140., 140., 140., 0. });
|
140., 140., 140., 140., 0. });
|
||||||
|
|
||||||
|
def = this->add("wiping_volumes_use_custom_matrix", coBool);
|
||||||
|
def->label = L("");
|
||||||
|
def->tooltip = L("");
|
||||||
|
def->set_default_value(new ConfigOptionBool{ false });
|
||||||
|
|
||||||
def = this->add("wipe_tower_x", coFloat);
|
def = this->add("wipe_tower_x", coFloat);
|
||||||
def->label = L("Position X");
|
def->label = L("Position X");
|
||||||
def->tooltip = L("X coordinate of the left front corner of a wipe tower");
|
def->tooltip = L("X coordinate of the left front corner of a wipe tower");
|
||||||
@ -4526,6 +4531,26 @@ void PrintConfigDef::handle_legacy_composite(DynamicPrintConfig &config)
|
|||||||
config.set_key_value("thumbnails", new ConfigOptionString(thumbnails_str));
|
config.set_key_value("thumbnails", new ConfigOptionString(thumbnails_str));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config.has("wiping_volumes_matrix") && !config.has("wiping_volumes_use_custom_matrix")) {
|
||||||
|
// This is apparently some pre-2.7.3 config, where the wiping_volumes_matrix was always used.
|
||||||
|
// The 2.7.3 introduced an option to use defaults derived from config. In case the matrix
|
||||||
|
// contains only default values, switch it to default behaviour. The default values
|
||||||
|
// were zeros on the diagonal and 140 otherwise.
|
||||||
|
std::vector<double> matrix = config.opt<ConfigOptionFloats>("wiping_volumes_matrix")->values;
|
||||||
|
int num_of_extruders = int(std::sqrt(matrix.size()) + 0.5);
|
||||||
|
int i = -1;
|
||||||
|
bool custom = false;
|
||||||
|
for (int j = 0; j < int(matrix.size()); ++j) {
|
||||||
|
if (j % num_of_extruders == 0)
|
||||||
|
++i;
|
||||||
|
if (i != j % num_of_extruders && !is_approx(matrix[j], 140.)) {
|
||||||
|
custom = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
config.set_key_value("wiping_volumes_use_custom_matrix", new ConfigOptionBool(custom));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const PrintConfigDef print_config_def;
|
const PrintConfigDef print_config_def;
|
||||||
|
@ -883,6 +883,7 @@ PRINT_CONFIG_CLASS_DERIVED_DEFINE(
|
|||||||
((ConfigOptionFloat, wipe_tower_bridging))
|
((ConfigOptionFloat, wipe_tower_bridging))
|
||||||
((ConfigOptionInt, wipe_tower_extruder))
|
((ConfigOptionInt, wipe_tower_extruder))
|
||||||
((ConfigOptionFloats, wiping_volumes_matrix))
|
((ConfigOptionFloats, wiping_volumes_matrix))
|
||||||
|
((ConfigOptionBool, wiping_volumes_use_custom_matrix))
|
||||||
((ConfigOptionFloat, z_offset))
|
((ConfigOptionFloat, z_offset))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -520,6 +520,7 @@ FreqChangedParams::FreqChangedParams(wxWindow* parent) :
|
|||||||
{
|
{
|
||||||
PresetBundle* preset_bundle = wxGetApp().preset_bundle;
|
PresetBundle* preset_bundle = wxGetApp().preset_bundle;
|
||||||
DynamicPrintConfig& project_config = preset_bundle->project_config;
|
DynamicPrintConfig& project_config = preset_bundle->project_config;
|
||||||
|
const bool use_custom_matrix = (project_config.option<ConfigOptionBool>("wiping_volumes_use_custom_matrix"))->value;
|
||||||
const std::vector<double> &init_matrix = (project_config.option<ConfigOptionFloats>("wiping_volumes_matrix"))->values;
|
const std::vector<double> &init_matrix = (project_config.option<ConfigOptionFloats>("wiping_volumes_matrix"))->values;
|
||||||
const std::vector<std::string> extruder_colours = wxGetApp().plater()->get_extruder_colors_from_plater_config();
|
const std::vector<std::string> extruder_colours = wxGetApp().plater()->get_extruder_colors_from_plater_config();
|
||||||
|
|
||||||
@ -527,11 +528,12 @@ FreqChangedParams::FreqChangedParams(wxWindow* parent) :
|
|||||||
const double default_purge = static_cast<const ConfigOptionFloat*>(preset_bundle->printers.get_edited_preset().config.option("multimaterial_purging"))->value;
|
const double default_purge = static_cast<const ConfigOptionFloat*>(preset_bundle->printers.get_edited_preset().config.option("multimaterial_purging"))->value;
|
||||||
std::vector<double> filament_purging_multipliers = preset_bundle->get_config_options_for_current_filaments<ConfigOptionPercents>("filament_purge_multiplier");
|
std::vector<double> filament_purging_multipliers = preset_bundle->get_config_options_for_current_filaments<ConfigOptionPercents>("filament_purge_multiplier");
|
||||||
|
|
||||||
WipingDialog dlg(parent, cast<float>(init_matrix), extruder_colours, default_purge, filament_purging_multipliers);
|
WipingDialog dlg(parent, cast<float>(init_matrix), extruder_colours, default_purge, filament_purging_multipliers, use_custom_matrix);
|
||||||
|
|
||||||
if (dlg.ShowModal() == wxID_OK) {
|
if (dlg.ShowModal() == wxID_OK) {
|
||||||
std::vector<float> matrix = dlg.get_matrix();
|
std::vector<float> matrix = dlg.get_matrix();
|
||||||
(project_config.option<ConfigOptionFloats>("wiping_volumes_matrix"))->values = std::vector<double>(matrix.begin(), matrix.end());
|
(project_config.option<ConfigOptionFloats>("wiping_volumes_matrix"))->values = std::vector<double>(matrix.begin(), matrix.end());
|
||||||
|
(project_config.option<ConfigOptionBool>("wiping_volumes_use_custom_matrix"))->value = dlg.get_use_custom_matrix();
|
||||||
// Update Project dirty state, update application title bar.
|
// Update Project dirty state, update application title bar.
|
||||||
wxGetApp().plater()->update_project_dirty_from_presets();
|
wxGetApp().plater()->update_project_dirty_from_presets();
|
||||||
wxPostEvent(parent, SimpleEvent(EVT_SCHEDULE_BACKGROUND_PROCESS, parent));
|
wxPostEvent(parent, SimpleEvent(EVT_SCHEDULE_BACKGROUND_PROCESS, parent));
|
||||||
|
@ -190,7 +190,7 @@ std::string RammingPanel::get_parameters()
|
|||||||
|
|
||||||
// Parent dialog for purging volume adjustments - it fathers WipingPanel widget (that contains all controls) and a button.
|
// Parent dialog for purging volume adjustments - it fathers WipingPanel widget (that contains all controls) and a button.
|
||||||
WipingDialog::WipingDialog(wxWindow* parent, const std::vector<float>& matrix, const std::vector<std::string>& extruder_colours,
|
WipingDialog::WipingDialog(wxWindow* parent, const std::vector<float>& matrix, const std::vector<std::string>& extruder_colours,
|
||||||
double printer_purging_volume, const std::vector<double>& filament_purging_multipliers)
|
double printer_purging_volume, const std::vector<double>& filament_purging_multipliers, bool use_custom_matrix)
|
||||||
: wxDialog(parent, wxID_ANY, _(L("Wipe tower - Purging volume adjustment")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE/* | wxRESIZE_BORDER*/)
|
: wxDialog(parent, wxID_ANY, _(L("Wipe tower - Purging volume adjustment")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE/* | wxRESIZE_BORDER*/)
|
||||||
{
|
{
|
||||||
SetFont(wxGetApp().normal_font());
|
SetFont(wxGetApp().normal_font());
|
||||||
@ -252,9 +252,8 @@ WipingDialog::WipingDialog(wxWindow* parent, const std::vector<float>& matrix, c
|
|||||||
enable_or_disable_panel();
|
enable_or_disable_panel();
|
||||||
});
|
});
|
||||||
|
|
||||||
const bool start_default = should_start_as_default();
|
m_radio_button1->SetValue(! use_custom_matrix);
|
||||||
m_radio_button1->SetValue(start_default);
|
m_radio_button2->SetValue(use_custom_matrix);
|
||||||
m_radio_button2->SetValue(! start_default);
|
|
||||||
enable_or_disable_panel();
|
enable_or_disable_panel();
|
||||||
|
|
||||||
this->Show();
|
this->Show();
|
||||||
@ -394,13 +393,6 @@ std::vector<float> WipingPanel::read_matrix_values() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool WipingDialog::should_start_as_default() const
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void WipingDialog::enable_or_disable_panel()
|
void WipingDialog::enable_or_disable_panel()
|
||||||
{
|
{
|
||||||
bool enable = m_radio_button2->GetValue();
|
bool enable = m_radio_button2->GetValue();
|
||||||
|
@ -76,12 +76,12 @@ private:
|
|||||||
class WipingDialog : public wxDialog {
|
class WipingDialog : public wxDialog {
|
||||||
public:
|
public:
|
||||||
WipingDialog(wxWindow* parent, const std::vector<float>& matrix, const std::vector<std::string>& extruder_colours,
|
WipingDialog(wxWindow* parent, const std::vector<float>& matrix, const std::vector<std::string>& extruder_colours,
|
||||||
double printer_purging_volume, const std::vector<double>& filament_purging_multipliers);
|
double printer_purging_volume, const std::vector<double>& filament_purging_multipliers, bool use_custom_matrix);
|
||||||
std::vector<float> get_matrix() const { return m_output_matrix; }
|
std::vector<float> get_matrix() const { return m_output_matrix; }
|
||||||
|
bool get_use_custom_matrix() const { return m_radio_button2->GetValue(); }
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool should_start_as_default() const;
|
|
||||||
void enable_or_disable_panel();
|
void enable_or_disable_panel();
|
||||||
|
|
||||||
WipingPanel* m_panel_wiping = nullptr;
|
WipingPanel* m_panel_wiping = nullptr;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user