Implementation of the "ColorPrint" on the 3DScene

This commit is contained in:
YuSanka 2018-11-26 16:07:09 +01:00
parent b153c8cb20
commit f8bc7cb959
9 changed files with 96 additions and 25 deletions

View file

@ -3119,7 +3119,10 @@ bool GLCanvas3D::LegendTexture::generate(const GCodePreviewData& preview_data, c
// collects items to render
auto title = _(preview_data.get_legend_title());
const GCodePreviewData::LegendItemsList& items = preview_data.get_legend_items(tool_colors);
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);
unsigned int items_count = (unsigned int)items.size();
if (items_count == 0)
@ -6473,6 +6476,8 @@ void GLCanvas3D::_load_gcode_extrusion_paths(const GCodePreviewData& preview_dat
return path.feedrate * (float)path.mm3_per_mm;
case GCodePreviewData::Extrusion::Tool:
return (float)path.extruder_id;
case GCodePreviewData::Extrusion::ColorPrint:
return (float)path.cp_color_id;
default:
return 0.0f;
}
@ -6500,6 +6505,15 @@ void GLCanvas3D::_load_gcode_extrusion_paths(const GCodePreviewData& preview_dat
::memcpy((void*)color.rgba, (const void*)(tool_colors.data() + (unsigned int)value * 4), 4 * sizeof(float));
return color;
}
case GCodePreviewData::Extrusion::ColorPrint:
{
int val = int(value);
while (val >= GCodePreviewData::Range::Colors_Count)
val -= GCodePreviewData::Range::Colors_Count;
GCodePreviewData::Color color = GCodePreviewData::Range::Default_Colors[val];
return color;
}
default:
return GCodePreviewData::Color::Dummy;
}

View file

@ -89,6 +89,7 @@ bool Preview::init(wxNotebook* notebook, DynamicPrintConfig* config, BackgroundS
m_choice_view_type->Append(_(L("Speed")));
m_choice_view_type->Append(_(L("Volumetric flow rate")));
m_choice_view_type->Append(_(L("Tool")));
m_choice_view_type->Append(_(L("Color Print")));
m_choice_view_type->SetSelection(0);
m_label_show_features = new wxStaticText(this, wxID_ANY, _(L("Show")));
@ -466,12 +467,14 @@ void Preview::set_double_slider_thumbs(const bool force_sliders_full_range,
}
for (int i = layers_z.size() - 1; i >= 0; i--)
if (z_low >= layers_z[i]) {
// if (z_low >= layers_z[i]) {
if (fabs(z_low - layers_z[i]) <= 1e-6) {
m_slider->SetLowerValue(i);
break;
}
for (int i = layers_z.size() - 1; i >= 0; i--)
if (z_high >= layers_z[i]) {
// if (z_high >= layers_z[i]) {
if (fabs(z_high-layers_z[i]) <= 1e-6) {
m_slider->SetHigherValue(i);
break;
}

View file

@ -1474,7 +1474,7 @@ void PrusaDoubleSlider::SetTicksValues(const std::vector<double>& heights)
++i;
if (i == m_values.size())
return;
m_ticks.insert(i);
m_ticks.insert(i-1);
}
}
@ -1895,18 +1895,16 @@ void PrusaDoubleSlider::action_tick(const TicksAction action)
const int tick = m_selection == ssLower ? m_lower_value : m_higher_value;
if (action == taOnIcon && !m_ticks.insert(tick).second)
m_ticks.erase(tick);
if (action == taOnIcon) {
if (!m_ticks.insert(tick).second)
m_ticks.erase(tick);
}
else {
const auto it = m_ticks.find(tick);
if (it == m_ticks.end() && action == taAdd)
m_ticks.insert(tick);
else if (it != m_ticks.end() && action == taDel)
m_ticks.erase(tick);
else {
wxPostEvent(this->GetParent(), wxCommandEvent(wxCUSTOMEVT_TICKSCHANGED));
return;
}
}
wxPostEvent(this->GetParent(), wxCommandEvent(wxCUSTOMEVT_TICKSCHANGED));