Set current filament color to the ColorPicker
This commit is contained in:
parent
8e12189b37
commit
6de5b34312
@ -274,22 +274,30 @@ wxBitmapComboBox(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(15 *
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Swallow the mouse click and open the color picker.
|
// 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 = wxTransparentColour;
|
||||||
|
|
||||||
auto data = new wxColourData();
|
auto data = new wxColourData();
|
||||||
data->SetChooseFull(1);
|
data->SetChooseFull(1);
|
||||||
auto dialog = new wxColourDialog(/* wxGetApp().mainframe */this, data);
|
data->SetColour(clr);
|
||||||
dialog->CenterOnParent();
|
|
||||||
if (dialog->ShowModal() == wxID_OK) {
|
|
||||||
DynamicPrintConfig cfg = *wxGetApp().get_tab(Preset::TYPE_PRINTER)->get_config();
|
|
||||||
|
|
||||||
//FIXME this is too expensive to call full_config to get just the extruder color!
|
auto dialog = new wxColourDialog(this, data);
|
||||||
auto colors = static_cast<ConfigOptionStrings*>(wxGetApp().preset_bundle->full_config().option("extruder_colour")->clone());
|
dialog->CenterOnParent();
|
||||||
|
if (dialog->ShowModal() == wxID_OK)
|
||||||
|
{
|
||||||
colors->values[extruder_idx] = dialog->GetColourData().GetColour().GetAsString(wxC2S_HTML_SYNTAX);
|
colors->values[extruder_idx] = dialog->GetColourData().GetColour().GetAsString(wxC2S_HTML_SYNTAX);
|
||||||
|
|
||||||
cfg.set_key_value("extruder_colour", colors);
|
DynamicPrintConfig cfg_new = *cfg;
|
||||||
|
cfg_new.set_key_value("extruder_colour", colors);
|
||||||
|
|
||||||
wxGetApp().get_tab(Preset::TYPE_PRINTER)->load_config(cfg);
|
wxGetApp().get_tab(Preset::TYPE_PRINTER)->load_config(cfg_new);
|
||||||
wxGetApp().preset_bundle->update_platter_filament_ui(extruder_idx, this);
|
wxGetApp().preset_bundle->update_platter_filament_ui(extruder_idx, this);
|
||||||
wxGetApp().plater()->on_config_change(cfg);
|
wxGetApp().plater()->on_config_change(cfg_new);
|
||||||
}
|
}
|
||||||
dialog->Destroy();
|
dialog->Destroy();
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user