DoubleSlider:colored_band: Fixed get a correct color for extruder, when it's changed from Settings Tab

This commit is contained in:
YuSanka 2020-02-14 09:51:51 +01:00
parent 1399696b04
commit 3ffc565722
4 changed files with 22 additions and 8 deletions

View File

@ -77,6 +77,7 @@ Control::Control( wxWindow *parent,
m_selection = ssUndef;
m_ticks.set_pause_print_msg(_utf8(L("Place bearings in slots and resume printing")));
m_ticks.set_extruder_colors(&m_extruder_colors);
// slider events
this->Bind(wxEVT_PAINT, &Control::OnPaint, this);
@ -351,6 +352,11 @@ void Control::SetModeAndOnlyExtruder(const bool is_one_extruder_printed_model, c
UseDefaultColors(m_mode == t_mode::SingleExtruder);
}
void Control::SetExtruderColors( const std::vector<std::string>& extruder_colors)
{
m_extruder_colors = extruder_colors;
}
void Control::get_lower_and_higher_position(int& lower_pos, int& higher_pos)
{
const double step = get_scroll_step();
@ -677,7 +683,7 @@ std::string Control::get_color_for_tool_change_tick(std::set<TickCode>::const_it
return it_n->color;
}
return it->color;
return m_extruder_colors[current_extruder-1]; // return a color for a specific extruder from the colors list
}
std::string Control::get_color_for_color_change_tick(std::set<TickCode>::const_iterator it) const
@ -690,7 +696,7 @@ std::string Control::get_color_for_color_change_tick(std::set<TickCode>::const_i
if (it_n->gcode == ToolChangeCode) {
is_tool_change = true;
if (it_n->extruder == it->extruder)
return it->color;
return m_extruder_colors[it->extruder-1]; // return a color for a specific extruder from the colors list
break;
}
}
@ -736,7 +742,7 @@ void Control::draw_colored_band(wxDC& dc)
}
const int default_color_idx = m_mode==t_mode::MultiAsSingle ? std::max<int>(m_only_extruder - 1, 0) : 0;
draw_band(dc, wxColour(GUI::wxGetApp().plater()->get_extruder_colors_from_plater_config()[default_color_idx]), main_band);
draw_band(dc, wxColour(m_extruder_colors[default_color_idx]), main_band);
std::set<TickCode>::const_iterator tick_it = m_ticks.ticks.begin();
@ -1819,15 +1825,13 @@ void Control::edit_extruder_sequence()
int extruder = 0;
const int extr_cnt = m_extruders_sequence.extruders.size();
std::vector<std::string> colors = GUI::wxGetApp().plater()->get_extruder_colors_from_plater_config();
while (tick <= m_max_value)
{
const int cur_extruder = m_extruders_sequence.extruders[extruder];
bool meaningless_tick = tick == 0.0 && cur_extruder == extruder;
if (!meaningless_tick)
m_ticks.ticks.emplace(TickCode{tick, ToolChangeCode, cur_extruder + 1, colors[cur_extruder]});
m_ticks.ticks.emplace(TickCode{tick, ToolChangeCode, cur_extruder + 1, m_extruder_colors[cur_extruder]});
extruder++;
if (extruder == extr_cnt)
@ -1942,8 +1946,7 @@ std::string TickCodeInfo::get_color_for_tick(TickCode tick, const std::string& c
return colors[m_default_color_idx % colors.size()];
}
std::vector<std::string> colors = GUI::wxGetApp().plater()->get_extruder_colors_from_plater_config();
std::string color = colors[extruder - 1];
std::string color = (*m_colors)[extruder - 1];
if (code == ColorChangeCode)
{

View File

@ -95,6 +95,8 @@ class TickCodeInfo
bool m_use_default_colors= false;
int m_default_color_idx = 0;
std::vector<std::string>* m_colors {nullptr};
std::string get_color_for_tick(TickCode tick, const std::string& code, const int extruder);
public:
@ -122,6 +124,8 @@ public:
bool suppressed_plus () { return m_suppress_plus; }
bool suppressed_minus() { return m_suppress_minus; }
void set_default_colors(bool default_colors_on) { m_use_default_colors = default_colors_on; }
void set_extruder_colors(std::vector<std::string>* extruder_colors) { m_colors = extruder_colors; }
};
@ -209,6 +213,7 @@ public:
void SetManipulationMode(t_mode mode) { m_mode = mode; }
t_mode GetManipulationMode() const { return m_mode; }
void SetModeAndOnlyExtruder(const bool is_one_extruder_printed_model, const int only_extruder);
void SetExtruderColors(const std::vector<std::string>& extruder_colors);
bool is_horizontal() const { return m_style == wxSL_HORIZONTAL; }
bool is_one_layer() const { return m_is_one_layer; }
@ -357,6 +362,8 @@ private:
std::vector<double> m_values;
TickCodeInfo m_ticks;
std::vector<std::string> m_extruder_colors;
// control's view variables
wxCoord SLIDER_MARGIN; // margin around slider

View File

@ -705,6 +705,8 @@ void Preview::update_double_slider(const std::vector<double>& layers_z, bool kee
bool sla_print_technology = wxGetApp().plater()->printer_technology() == ptSLA;
bool sequential_print = wxGetApp().preset_bundle->prints.get_edited_preset().config.opt_bool("complete_objects");
m_slider->SetDrawMode(sla_print_technology, sequential_print);
m_slider->SetExtruderColors(wxGetApp().plater()->get_extruder_colors_from_plater_config());
}
void Preview::update_double_slider_mode()

View File

@ -131,8 +131,10 @@ void OptionsGroup::append_line(const Line& line, wxStaticText** full_Label/* = n
// Set sidetext width for a better alignment of options in line
if (option_set.size() > 1) {
sidetext_width = Field::def_width_thinner();
/* Temporary commented till UI-review will be completed
if (m_show_modified_btns) // means that options groups are in tabs
sublabel_width = Field::def_width();
*/
}
// add mode value for current line to m_options_mode