ColorPrint improvement
+ Select "Color Print" preview type if it's not after add/delete new color change + Added level heights to the color legend instead of "Color N"
This commit is contained in:
parent
4c8f3f6ea7
commit
f203f6fbd9
@ -382,7 +382,7 @@ std::string GCodePreviewData::get_legend_title() const
|
||||
return "";
|
||||
}
|
||||
|
||||
GCodePreviewData::LegendItemsList GCodePreviewData::get_legend_items(const std::vector<float>& tool_colors, const int color_print_cnt /*= 0*/) const
|
||||
GCodePreviewData::LegendItemsList GCodePreviewData::get_legend_items(const std::vector<float>& tool_colors, const std::vector<double>& cp_values) const
|
||||
{
|
||||
struct Helper
|
||||
{
|
||||
@ -452,13 +452,28 @@ GCodePreviewData::LegendItemsList GCodePreviewData::get_legend_items(const std::
|
||||
}
|
||||
case Extrusion::ColorPrint:
|
||||
{
|
||||
const auto color_print_cnt = cp_values.size();
|
||||
for (int i = color_print_cnt; i >= 0 ; --i)
|
||||
{
|
||||
int val = i;
|
||||
while (val >= GCodePreviewData::Range::Colors_Count)
|
||||
val -= GCodePreviewData::Range::Colors_Count;
|
||||
GCodePreviewData::Color color = Range::Default_Colors[val];
|
||||
items.emplace_back((boost::format(Slic3r::I18N::translate(L("Color %d"))) % (i + 1)).str(), color);
|
||||
|
||||
if (color_print_cnt == 0) {
|
||||
items.emplace_back(Slic3r::I18N::translate(L("Default print color")), color);
|
||||
break;
|
||||
}
|
||||
if (i == 0) {
|
||||
items.emplace_back((boost::format(Slic3r::I18N::translate(L("up to %.2f mm"))) % cp_values[0]).str(), color);
|
||||
break;
|
||||
}
|
||||
if (i == color_print_cnt) {
|
||||
items.emplace_back((boost::format(Slic3r::I18N::translate(L("above %.2f mm"))) % cp_values[i-1]).str(), color);
|
||||
continue;
|
||||
}
|
||||
|
||||
items.emplace_back((boost::format(Slic3r::I18N::translate(L("%.2f - %.2f mm"))) % cp_values[i-1] % cp_values[i]).str(), color);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ public:
|
||||
void set_extrusion_paths_colors(const std::vector<std::string>& colors);
|
||||
|
||||
std::string get_legend_title() const;
|
||||
LegendItemsList get_legend_items(const std::vector<float>& tool_colors, const int color_print_cnt = 1) const;
|
||||
LegendItemsList get_legend_items(const std::vector<float>& tool_colors, const std::vector<double>& cp_values) const;
|
||||
};
|
||||
|
||||
GCodePreviewData::Color operator + (const GCodePreviewData::Color& c1, const GCodePreviewData::Color& c2);
|
||||
|
@ -3121,8 +3121,8 @@ bool GLCanvas3D::LegendTexture::generate(const GCodePreviewData& preview_data, c
|
||||
auto title = _(preview_data.get_legend_title());
|
||||
|
||||
const auto& config = wxGetApp().preset_bundle->full_config();
|
||||
const int color_print_cnt = config.option<ConfigOptionFloats>("colorprint_heights")->values.size();
|
||||
const GCodePreviewData::LegendItemsList& items = preview_data.get_legend_items(tool_colors, color_print_cnt);
|
||||
const std::vector<double>& color_print_values = config.option<ConfigOptionFloats>("colorprint_heights")->values;
|
||||
const GCodePreviewData::LegendItemsList& items = preview_data.get_legend_items(tool_colors, color_print_values);
|
||||
|
||||
unsigned int items_count = (unsigned int)items.size();
|
||||
if (items_count == 0)
|
||||
|
@ -397,6 +397,13 @@ void Preview::create_double_slider()
|
||||
auto& config = wxGetApp().preset_bundle->project_config;
|
||||
((config.option<ConfigOptionFloats>("colorprint_heights"))->values) = (m_slider->GetTicksValues());
|
||||
m_schedule_background_process();
|
||||
int type = m_choice_view_type->FindString(_(L("Color Print")));
|
||||
if (m_choice_view_type->GetSelection() != type) {
|
||||
m_choice_view_type->SetSelection(type);
|
||||
if ((0 <= type) && (type < (int)GCodePreviewData::Extrusion::Num_View_Types))
|
||||
m_gcode_preview_data->extrusion.view_type = (GCodePreviewData::Extrusion::EViewType)type;
|
||||
m_preferred_color_mode = "feature";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1444,10 +1444,14 @@ void PrusaDoubleSlider::get_size(int *w, int *h)
|
||||
is_horizontal() ? *w -= m_lock_icon_dim : *h -= m_lock_icon_dim;
|
||||
}
|
||||
|
||||
double PrusaDoubleSlider::get_double_value(const SelectedSlider& selection) const
|
||||
double PrusaDoubleSlider::get_double_value(const SelectedSlider& selection)
|
||||
{
|
||||
if (m_values.empty())
|
||||
return 0.0;
|
||||
if (m_values.size() <= m_higher_value) {
|
||||
correct_higher_value();
|
||||
return m_values.back().second;
|
||||
}
|
||||
return m_values[selection == ssLower ? m_lower_value : m_higher_value].second;
|
||||
}
|
||||
|
||||
|
@ -668,8 +668,8 @@ public:
|
||||
return m_higher_value;
|
||||
}
|
||||
int GetActiveValue() const;
|
||||
double GetLowerValueD() const { return get_double_value(ssLower); }
|
||||
double GetHigherValueD() const { return get_double_value(ssHigher); }
|
||||
double GetLowerValueD() { return get_double_value(ssLower); }
|
||||
double GetHigherValueD() { return get_double_value(ssHigher); }
|
||||
wxSize DoGetBestSize() const override;
|
||||
void SetLowerValue(const int lower_val);
|
||||
void SetHigherValue(const int higher_val);
|
||||
@ -729,7 +729,7 @@ protected:
|
||||
wxCoord get_position_from_value(const int value);
|
||||
wxSize get_size();
|
||||
void get_size(int *w, int *h);
|
||||
double get_double_value(const SelectedSlider& selection) const;
|
||||
double get_double_value(const SelectedSlider& selection);
|
||||
|
||||
private:
|
||||
int m_min_value;
|
||||
|
Loading…
Reference in New Issue
Block a user