diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 8afeecb1e..869449a97 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -928,8 +928,6 @@ void GCode::_do_export(Print &print, FILE *file) this->apply_print_config(print.config()); this->set_extruders(print.extruders()); - // #ys_FIXME_COLOR // Initialize colorprint. - // m_colorprint_heights = cast(print.config().colorprint_heights.values); // Initialize custom gcode Model* model = print.get_object(0)->model_object()->get_model(); m_custom_g_code_heights = model->custom_gcode_per_height; @@ -1153,8 +1151,6 @@ void GCode::_do_export(Print &print, FILE *file) } print.throw_if_canceled(); - - // #ys_FIXME_COLOR /* To avoid change filament for non-used extruder for Multi-material, * check model->custom_gcode_per_height using tool_ordering values * */ @@ -1862,19 +1858,15 @@ void GCode::process_layer( // In case there are more toolchange requests that weren't done yet and should happen simultaneously, erase them all. // (Layers can be close to each other, model could have been resliced with bigger layer height, ...). bool colorprint_change = false; - // #ys_FIXME_COLOR - // while (!m_colorprint_heights.empty() && m_colorprint_heights.front()-EPSILON < layer.print_z) { - // m_colorprint_heights.erase(m_colorprint_heights.begin()); - // colorprint_change = true; - // } + std::string custom_code = ""; std::string pause_print_msg = ""; int m600_before_extruder = -1; while (!m_custom_g_code_heights.empty() && m_custom_g_code_heights.front().height-EPSILON < layer.print_z) { custom_code = m_custom_g_code_heights.front().gcode; + if (custom_code == ColorChangeCode && m_custom_g_code_heights.front().extruder > 0) m600_before_extruder = m_custom_g_code_heights.front().extruder - 1; - if (custom_code == PausePrintCode) pause_print_msg = m_custom_g_code_heights.front().color; @@ -1883,16 +1875,6 @@ void GCode::process_layer( } // we should add or not colorprint_change in respect to nozzle_diameter count instead of really used extruders count - // #ys_FIXME_COLOR - // if (colorprint_change && print./*extruders()*/config().nozzle_diameter.size()==1) - // { - // // add tag for analyzer - // gcode += "; " + GCodeAnalyzer::Color_Change_Tag + "\n"; - // // add tag for time estimator - // gcode += "; " + GCodeTimeEstimator::Color_Change_Tag + "\n"; - // - // gcode += "M600\n"; - // } // don't save "tool_change"(ExtruderChangeCode) code to GCode if (colorprint_change && custom_code != ExtruderChangeCode) { @@ -1936,28 +1918,6 @@ void GCode::process_layer( } gcode += custom_code + "\n"; } - - /* - if (single_material_print || custom_code != ExtruderChangeCode) - { - // add tag for analyzer - gcode += "; " + GCodeAnalyzer::Color_Change_Tag + "\n"; - // add tag for time estimator - gcode += "; " + GCodeTimeEstimator::Color_Change_Tag + "\n"; - if (single_material_print && custom_code == ExtruderChangeCode) - custom_code = ColorChangeCode; - - if (!single_material_print && custom_code == ColorChangeCode && - m600_before_extruder >= 0 && first_extruder_id != m600_before_extruder - // && !MMU1 - ) { - gcode += "M601\n"; // pause print - gcode += "M117 Change filament for Extruder " + std::to_string(m600_before_extruder) + "\n"; - } - else - gcode += custom_code + "\n"; - } - */ } diff --git a/src/libslic3r/GCode.hpp b/src/libslic3r/GCode.hpp index 97f31dc6a..261a24d01 100644 --- a/src/libslic3r/GCode.hpp +++ b/src/libslic3r/GCode.hpp @@ -362,10 +362,11 @@ protected: bool m_second_layer_things_done; // Index of a last object copy extruded. std::pair m_last_obj_copy; - // Layer heights for colorprint - updated before the export and erased during the process - // so no toolchange occurs twice. - std::vector m_colorprint_heights; - // extensions for colorprint - now it's not a just color_print, there can be some custom gcode + /* Extensions for colorprint - now it's not a just color_print_heights, + * there can be some custom gcode. + * Updated before the export and erased during the process, + * so no toolchange occurs twice. + * */ std::vector m_custom_g_code_heights; // Time estimators diff --git a/src/libslic3r/GCode/PreviewData.cpp b/src/libslic3r/GCode/PreviewData.cpp index ba0584e57..e7475089a 100644 --- a/src/libslic3r/GCode/PreviewData.cpp +++ b/src/libslic3r/GCode/PreviewData.cpp @@ -379,8 +379,6 @@ std::string GCodePreviewData::get_legend_title() const return ""; } -// #ys_FIXME_COLOR -// GCodePreviewData::LegendItemsList GCodePreviewData::get_legend_items(const std::vector& tool_colors, const std::vector>& cp_values) const GCodePreviewData::LegendItemsList GCodePreviewData::get_legend_items(const std::vector& tool_colors, const std::vector& cp_items) const { @@ -455,43 +453,6 @@ GCodePreviewData::LegendItemsList GCodePreviewData::get_legend_items(const std:: break; } - // #ys_FIXME_COLOR - /*case Extrusion::ColorPrint: - { - const int color_cnt = (int)tool_colors.size()/4; - const auto color_print_cnt = (int)cp_values.size(); - if (color_print_cnt > 0) { - GCodePreviewData::Color color; - ::memcpy((void*)color.rgba, (const void*)(tool_colors.data() + (color_cnt-1) * 4), 4 * sizeof(float)); - items.emplace_back(Slic3r::I18N::translate(L("Pause print or custom G-code")), color); - } - - for (int i = color_print_cnt; i >= 0 ; --i) - { - GCodePreviewData::Color color; - ::memcpy((void*)color.rgba, (const void*)(tool_colors.data() + (i % color_cnt) * 4), 4 * sizeof(float)); - - if (color_print_cnt == 0) { - items.emplace_back(Slic3r::I18N::translate(L("Default print color")), color); - break; - } - - std::string id_str = std::to_string(i + 1) + ": "; - - if (i == 0) { - items.emplace_back(id_str + (boost::format(Slic3r::I18N::translate(L("up to %.2f mm"))) % cp_values[0].first).str(), color); - break; - } - if (i == color_print_cnt) { - items.emplace_back(id_str + (boost::format(Slic3r::I18N::translate(L("above %.2f mm"))) % cp_values[i - 1].second).str(), color); - continue; - } - -// items.emplace_back((boost::format(Slic3r::I18N::translate(L("%.2f - %.2f mm"))) % cp_values[i-1] % cp_values[i]).str(), color); - items.emplace_back(id_str + (boost::format(Slic3r::I18N::translate(L("%.2f - %.2f mm"))) % cp_values[i - 1].second% cp_values[i].first).str(), color); - } - break; - }*/ case Extrusion::ColorPrint: { const int color_cnt = (int)tool_colors.size()/4; diff --git a/src/libslic3r/GCode/PreviewData.hpp b/src/libslic3r/GCode/PreviewData.hpp index 78de04d0a..725c0258d 100644 --- a/src/libslic3r/GCode/PreviewData.hpp +++ b/src/libslic3r/GCode/PreviewData.hpp @@ -237,8 +237,6 @@ public: void set_extrusion_paths_colors(const std::vector& colors); std::string get_legend_title() const; - // #ys_FIXME_COLOR - // LegendItemsList get_legend_items(const std::vector& tool_colors, const std::vector>& cp_values) const; LegendItemsList get_legend_items(const std::vector& tool_colors, const std::vector& cp_items) const; // Return an estimate of the memory consumed by the time estimator. diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index ece858c9c..909907e81 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -836,59 +836,6 @@ GLCanvas3D::LegendTexture::LegendTexture() { } -void GLCanvas3D::LegendTexture::fill_color_print_legend_values(const GCodePreviewData& preview_data, const GLCanvas3D& canvas, - std::vector>& cp_legend_values) -{ - if (preview_data.extrusion.view_type == GCodePreviewData::Extrusion::ColorPrint /*&& - wxGetApp().extruders_edited_cnt() == 1*/) // show color change legend only for single-material presets - { - /* - // #ys_FIXME_COLOR - auto& config = wxGetApp().preset_bundle->project_config; - const std::vector& color_print_values = config.option("colorprint_heights")->values; - - if (!color_print_values.empty()) { - std::vector print_zs = canvas.get_current_print_zs(true); - for (auto cp_value : color_print_values) - { - auto lower_b = std::lower_bound(print_zs.begin(), print_zs.end(), cp_value - DoubleSlider::epsilon()); - - if (lower_b == print_zs.end()) - continue; - - double current_z = *lower_b; - double previous_z = lower_b == print_zs.begin() ? 0.0 : *(--lower_b); - - // to avoid duplicate values, check adding values - if (cp_legend_values.empty() || - !(cp_legend_values.back().first == previous_z && cp_legend_values.back().second == current_z) ) - cp_legend_values.push_back(std::pair(previous_z, current_z)); - } - } - */ - std::vector custom_gcode_per_height = wxGetApp().plater()->model().custom_gcode_per_height; - - if (!custom_gcode_per_height.empty()) { - std::vector print_zs = canvas.get_current_print_zs(true); - for (auto custom_code : custom_gcode_per_height) - { - auto lower_b = std::lower_bound(print_zs.begin(), print_zs.end(), custom_code.height - DoubleSlider::epsilon()); - - if (lower_b == print_zs.end()) - continue; - - double current_z = *lower_b; - double previous_z = lower_b == print_zs.begin() ? 0.0 : *(--lower_b); - - // to avoid duplicate values, check adding values - if (cp_legend_values.empty() || - !(cp_legend_values.back().first == previous_z && cp_legend_values.back().second == current_z) ) - cp_legend_values.push_back(std::pair(previous_z, current_z)); - } - } - } -} - void GLCanvas3D::LegendTexture::fill_color_print_legend_items( const GLCanvas3D& canvas, const std::vector& colors_in, std::vector& colors, @@ -997,12 +944,6 @@ bool GLCanvas3D::LegendTexture::generate(const GCodePreviewData& preview_data, c // collects items to render auto title = _(preview_data.get_legend_title()); - // #ys_FIXME_COLOR - // std::vector> cp_legend_values; - // fill_color_print_legend_values(preview_data, canvas, cp_legend_values); - - // const GCodePreviewData::LegendItemsList& items = preview_data.get_legend_items(tool_colors, cp_legend_values); - std::vector cp_legend_items; std::vector cp_colors; @@ -2380,8 +2321,6 @@ void GLCanvas3D::load_sla_preview() } } -// #ys_FIXME_COLOR -// void GLCanvas3D::load_preview(const std::vector& str_tool_colors, const std::vector& color_print_values) void GLCanvas3D::load_preview(const std::vector& str_tool_colors, const std::vector& color_print_values) { const Print *print = this->fff_print(); @@ -5159,8 +5098,6 @@ void GLCanvas3D::_load_print_toolpaths() volume->indexed_vertex_array.finalize_geometry(m_initialized); } -// #ys_FIXME_COLOR -// void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, const std::vector& str_tool_colors, const std::vector& color_print_values) void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, const std::vector& str_tool_colors, const std::vector& color_print_values) { std::vector tool_colors = _parse_colors(str_tool_colors); @@ -5173,8 +5110,6 @@ void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, c bool has_infill; bool has_support; const std::vector* tool_colors; - // #ys_FIXME_COLOR - // const std::vector* color_print_values; bool is_single_material_print; int extruders_cnt; const std::vector* color_print_values; @@ -5192,8 +5127,6 @@ void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, c // For coloring by a color_print(M600), return a parsed color. bool color_by_color_print() const { return color_print_values!=nullptr; } const size_t color_print_color_idx_by_layer_idx(const size_t layer_idx) const { - // #ys_FIXME_COLOR - // auto it = std::lower_bound(color_print_values->begin(), color_print_values->end(), layers[layer_idx]->print_z + EPSILON); const Model::CustomGCode value(layers[layer_idx]->print_z + EPSILON, "", 0, ""); auto it = std::lower_bound(color_print_values->begin(), color_print_values->end(), value); return (it - color_print_values->begin()) % number_tools(); @@ -5350,33 +5283,13 @@ void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, c std::vector color_print_layer_to_glvolume; auto volume = [&ctxt, &vols, &color_print_layer_to_glvolume, &range](size_t layer_idx, int extruder, int feature) -> GLVolume& { return *vols[ctxt.color_by_color_print()? - //color_print_layer_to_glvolume[layer_idx - range.begin()] : ctxt.color_print_color_idx_by_layer_idx_and_extruder(layer_idx, extruder) : ctxt.color_by_tool() ? std::min(ctxt.number_tools() - 1, std::max(extruder - 1, 0)) : feature ]; }; - /*if (ctxt.color_by_color_print()) { - // Create a map from the layer index to a GLVolume, which is initialized with the correct layer span color. - std::vector color_print_tool_to_glvolume(ctxt.number_tools(), -1); - color_print_layer_to_glvolume.reserve(range.end() - range.begin()); - vols.reserve(ctxt.number_tools()); - for (size_t idx_layer = range.begin(); idx_layer < range.end(); ++ idx_layer) { - int idx_tool = (int)ctxt.color_print_color_idx_by_layer_idx(idx_layer); - if (color_print_tool_to_glvolume[idx_tool] == -1) { - color_print_tool_to_glvolume[idx_tool] = (int)vols.size(); - vols.emplace_back(new_volume(ctxt.color_tool(idx_tool))); - } - color_print_layer_to_glvolume.emplace_back(color_print_tool_to_glvolume[idx_tool]); - } - vols.emplace_back(new_volume(ctxt.color_pause_or_custom_code())); - } - for (size_t i = 0; i < ctxt.number_tools(); ++i) - vols.emplace_back(new_volume(ctxt.color_tool(i))); - vols.emplace_back(new_volume(ctxt.color_pause_or_custom_code())); - } - else */if (ctxt.color_by_color_print() || ctxt.color_by_tool()) { + if (ctxt.color_by_color_print() || ctxt.color_by_tool()) { for (size_t i = 0; i < ctxt.number_tools(); ++i) vols.emplace_back(new_volume(ctxt.color_tool(i))); } diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index f89dd006b..729b707d2 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -352,9 +352,6 @@ private: public: LegendTexture(); - void fill_color_print_legend_values(const GCodePreviewData& preview_data, const GLCanvas3D& canvas, - std::vector>& cp_legend_values); - void fill_color_print_legend_items(const GLCanvas3D& canvas, const std::vector& colors_in, std::vector& colors, @@ -555,8 +552,6 @@ public: void load_gcode_preview(const GCodePreviewData& preview_data, const std::vector& str_tool_colors); void load_sla_preview(); - // #ys_FIXME_COLOR - // void load_preview(const std::vector& str_tool_colors, const std::vector& color_print_values); void load_preview(const std::vector& str_tool_colors, const std::vector& color_print_values); void bind_event_handlers(); void unbind_event_handlers(); @@ -722,9 +717,6 @@ private: // one for perimeters, one for infill and one for supports. void _load_print_object_toolpaths(const PrintObject& print_object, const std::vector& str_tool_colors, const std::vector& color_print_values); - // #ys_FIXME_COLOR - // void _load_print_object_toolpaths(const PrintObject& print_object, const std::vector& str_tool_colors, - // const std::vector& color_print_values); // Create 3D thick extrusion lines for wipe tower extrusions void _load_wipe_tower_toolpaths(const std::vector& str_tool_colors); diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index 8f4b8a19b..cb926f1f1 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -582,16 +582,6 @@ void Preview::update_view_type(bool slice_completed) { const DynamicPrintConfig& config = wxGetApp().preset_bundle->project_config; - /* - // #ys_FIXME_COLOR - const wxString& choice = !config.option("colorprint_heights")->values.empty() && - wxGetApp().extruders_edited_cnt()==1 ? - _(L("Color Print")) : - config.option("wiping_volumes_matrix")->values.size() > 1 ? - _(L("Tool")) : - _(L("Feature type")); - */ - const wxString& choice = !wxGetApp().plater()->model().custom_gcode_per_height.empty() /*&& (wxGetApp().extruders_edited_cnt()==1 || !slice_completed) */? _(L("Color Print")) : @@ -728,9 +718,6 @@ void Preview::update_double_slider(const std::vector& layers_z, bool kee bool snap_to_min = force_sliders_full_range || m_slider->is_lower_at_min(); bool snap_to_max = force_sliders_full_range || m_slider->is_higher_at_max(); - // #ys_FIXME_COLOR - // std::vector &ticks_from_config = (wxGetApp().preset_bundle->project_config.option("colorprint_heights"))->values; - // check_slider_values(ticks_from_config, layers_z); std::vector tmp_ticks_from_model; if (m_selected_extruder != 0) tmp_ticks_from_model = wxGetApp().plater()->model().custom_gcode_per_height; @@ -761,41 +748,15 @@ void Preview::update_double_slider(const std::vector& layers_z, bool kee m_slider->SetTicksValues(ticks_from_model); bool color_print_enable = (wxGetApp().plater()->printer_technology() == ptFFF); - // #ys_FIXME_COLOR - // if (color_print_enable) { - // const DynamicPrintConfig& cfg = wxGetApp().preset_bundle->printers.get_edited_preset().config; - // if (cfg.opt("nozzle_diameter")->values.size() > 1) - // color_print_enable = false; - // } - // m_slider->EnableTickManipulation(color_print_enable); m_slider->EnableTickManipulation(color_print_enable); if (color_print_enable && wxGetApp().extruders_edited_cnt() > 1) { - //bool is_detected_full_print = //wxGetApp().plater()->fff_print().extruders().size() == 1; m_slider->SetExtruderID(m_extruder_selector->GetSelection()); } else m_slider->SetExtruderID(-1); } -// #ys_FIXME_COLOR -void Preview::check_slider_values(std::vector& ticks_from_config, - const std::vector &layers_z) -{ - // All ticks that would end up outside the slider range should be erased. - // TODO: this should be placed into more appropriate part of code, - // this function is e.g. not called when the last object is deleted - unsigned int old_size = ticks_from_config.size(); - ticks_from_config.erase(std::remove_if(ticks_from_config.begin(), ticks_from_config.end(), - [layers_z](double val) - { - auto it = std::lower_bound(layers_z.begin(), layers_z.end(), val - DoubleSlider::epsilon()); - return it == layers_z.end(); - }), - ticks_from_config.end()); - if (ticks_from_config.size() != old_size) - m_schedule_background_process(); -} void Preview::reset_double_slider() { @@ -878,51 +839,19 @@ void Preview::load_print_as_fff(bool keep_z_range) bool gcode_preview_data_valid = print->is_step_done(psGCodeExport) && ! m_gcode_preview_data->empty(); // Collect colors per extruder. std::vector colors; - // #ys_FIXME_COLOR - // std::vector color_print_values = {}; std::vector color_print_values = {}; // set color print values, if it si selected "ColorPrint" view type if (m_gcode_preview_data->extrusion.view_type == GCodePreviewData::Extrusion::ColorPrint) { - color_print_values = wxGetApp().plater()->model().custom_gcode_per_height; - /* colors = wxGetApp().plater()->get_extruder_colors_from_plater_config(); - - for (const Model::CustomGCode& code : color_print_values) - if (code.gcode == ColorChangeCode) - colors.push_back(code.color);*/ - colors = wxGetApp().plater()->get_colors_for_color_print(); + colors = wxGetApp().plater()->get_colors_for_color_print(); colors.push_back("#808080"); // gray color for pause print or custom G-code - if (gcode_preview_data_valid) - color_print_values.clear(); - /* - if (! gcode_preview_data_valid) { - // #ys_FIXME_COLOR - // const auto& config = wxGetApp().preset_bundle->project_config; - // color_print_values = config.option("colorprint_heights")->values; + if (!gcode_preview_data_valid) color_print_values = wxGetApp().plater()->model().custom_gcode_per_height; - } - */ } else if (gcode_preview_data_valid || (m_gcode_preview_data->extrusion.view_type == GCodePreviewData::Extrusion::Tool) ) { - const ConfigOptionStrings* extruders_opt = dynamic_cast(m_config->option("extruder_colour")); - const ConfigOptionStrings* filamemts_opt = dynamic_cast(m_config->option("filament_colour")); - unsigned int colors_count = std::max((unsigned int)extruders_opt->values.size(), (unsigned int)filamemts_opt->values.size()); - - unsigned char rgb[3]; - for (unsigned int i = 0; i < colors_count; ++i) - { - std::string color = m_config->opt_string("extruder_colour", i); - if (!PresetBundle::parse_color(color, rgb)) - { - color = m_config->opt_string("filament_colour", i); - if (!PresetBundle::parse_color(color, rgb)) - color = "#FFFFFF"; - } - - colors.emplace_back(color); - } + colors = wxGetApp().plater()->get_extruder_colors_from_plater_config(); color_print_values.clear(); } @@ -934,10 +863,6 @@ void Preview::load_print_as_fff(bool keep_z_range) m_canvas->load_gcode_preview(*m_gcode_preview_data, colors); m_loaded = true; } else { - // disable color change information for multi-material presets - // if (wxGetApp().extruders_edited_cnt() > 1) // #ys_FIXME_COLOR - // color_print_values.clear(); - // Load the initial preview based on slices, not the final G-code. m_canvas->load_preview(colors, color_print_values); } diff --git a/src/slic3r/GUI/GUI_Preview.hpp b/src/slic3r/GUI/GUI_Preview.hpp index 7a11e334c..900368baa 100644 --- a/src/slic3r/GUI/GUI_Preview.hpp +++ b/src/slic3r/GUI/GUI_Preview.hpp @@ -162,8 +162,6 @@ private: void check_slider_values(std::vector &ticks_from_model, const std::vector &layers_z); void update_double_slider(const std::vector& layers_z, bool keep_z_range = false); - void check_slider_values(std::vector &ticks_from_config, - const std::vector &layers_z); // #ys_FIXME_COLOR void reset_double_slider(); // update DoubleSlider after keyDown in canvas void update_double_slider_from_canvas(wxKeyEvent& event); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 09a496ca4..bf858215e 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -2725,9 +2725,6 @@ void Plater::priv::reset() // The hiding of the slicing results, if shown, is not taken care by the background process, so we do it here this->sidebar->show_sliced_info_sizer(false); - // #ys_FIXME_COLOR - // auto& config = wxGetApp().preset_bundle->project_config; - // config.option("colorprint_heights")->values.clear(); model.custom_gcode_per_height.clear(); }