diff options
author | YuSanka <yusanka@gmail.com> | 2020-01-23 14:49:39 +0300 |
---|---|---|
committer | YuSanka <yusanka@gmail.com> | 2020-01-23 18:11:21 +0300 |
commit | 1ed313ab7983bed9a1911da153ce2e3e0b473d6f (patch) | |
tree | bcf43c3f70851920e97ae473986630a4ccc44d54 /src/slic3r/GUI | |
parent | 3d9ac0ada19107c20c75ea6fa21336276cd2b935 (diff) |
Synchronized mode of color_print data to/from 3mf/amf
+ Code refactoring " CustomGCode extracted to separate namespace and file
Diffstat (limited to 'src/slic3r/GUI')
-rw-r--r-- | src/slic3r/GUI/GLCanvas3D.cpp | 20 | ||||
-rw-r--r-- | src/slic3r/GUI/GLCanvas3D.hpp | 4 | ||||
-rw-r--r-- | src/slic3r/GUI/GUI_Preview.cpp | 8 | ||||
-rw-r--r-- | src/slic3r/GUI/GUI_Preview.hpp | 2 | ||||
-rw-r--r-- | src/slic3r/GUI/Plater.cpp | 2 | ||||
-rw-r--r-- | src/slic3r/GUI/PresetBundle.cpp | 2 | ||||
-rw-r--r-- | src/slic3r/GUI/wxExtensions.cpp | 8 | ||||
-rw-r--r-- | src/slic3r/GUI/wxExtensions.hpp | 6 |
8 files changed, 26 insertions, 26 deletions
diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 9a5cea511..09d6eda2e 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -892,7 +892,7 @@ void GLCanvas3D::LegendTexture::fill_color_print_legend_items( const GLCanvas3D std::vector<float>& colors, std::vector<std::string>& cp_legend_items) { - std::vector<Model::CustomGCode> custom_gcode_per_print_z = wxGetApp().plater()->model().custom_gcode_per_print_z.gcodes; + std::vector<CustomGCode::Item> custom_gcode_per_print_z = wxGetApp().plater()->model().custom_gcode_per_print_z.gcodes; const int extruders_cnt = wxGetApp().extruders_edited_cnt(); if (extruders_cnt == 1) @@ -2410,7 +2410,7 @@ void GLCanvas3D::load_sla_preview() } } -void GLCanvas3D::load_preview(const std::vector<std::string>& str_tool_colors, const std::vector<Model::CustomGCode>& color_print_values) +void GLCanvas3D::load_preview(const std::vector<std::string>& str_tool_colors, const std::vector<CustomGCode::Item>& color_print_values) { const Print *print = this->fff_print(); if (print == nullptr) @@ -5245,7 +5245,7 @@ void GLCanvas3D::_load_print_toolpaths() volume->indexed_vertex_array.finalize_geometry(m_initialized); } -void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, const std::vector<std::string>& str_tool_colors, const std::vector<Model::CustomGCode>& color_print_values) +void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, const std::vector<std::string>& str_tool_colors, const std::vector<CustomGCode::Item>& color_print_values) { std::vector<float> tool_colors = _parse_colors(str_tool_colors); @@ -5259,7 +5259,7 @@ void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, c const std::vector<float>* tool_colors; bool is_single_material_print; int extruders_cnt; - const std::vector<Model::CustomGCode>* color_print_values; + const std::vector<CustomGCode::Item>* color_print_values; static const float* color_perimeters() { static float color[4] = { 1.0f, 1.0f, 0.0f, 1.f }; return color; } // yellow static const float* color_infill() { static float color[4] = { 1.0f, 0.5f, 0.5f, 1.f }; return color; } // redish @@ -5274,7 +5274,7 @@ 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 { - const Model::CustomGCode value{layers[layer_idx]->print_z + EPSILON, "", 0, ""}; + const CustomGCode::Item 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(); } @@ -5284,7 +5284,7 @@ void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, c const coordf_t print_z = layers[layer_idx]->print_z; auto it = std::find_if(color_print_values->begin(), color_print_values->end(), - [print_z](const Model::CustomGCode& code) + [print_z](const CustomGCode::Item& code) { return fabs(code.print_z - print_z) < EPSILON; }); if (it != color_print_values->end()) { @@ -5305,7 +5305,7 @@ void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, c } } - const Model::CustomGCode value{print_z + EPSILON, "", 0, ""}; + const CustomGCode::Item value{print_z + EPSILON, "", 0, ""}; it = std::lower_bound(color_print_values->begin(), color_print_values->end(), value); while (it != color_print_values->begin()) { @@ -5325,7 +5325,7 @@ void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, c } private: - int get_m600_color_idx(std::vector<Model::CustomGCode>::const_iterator it) const + int get_m600_color_idx(std::vector<CustomGCode::Item>::const_iterator it) const { int shift = 0; while (it != color_print_values->begin()) { @@ -5336,7 +5336,7 @@ void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, c return extruders_cnt + shift; } - int get_color_idx_for_tool_change(std::vector<Model::CustomGCode>::const_iterator it, const int extruder) const + int get_color_idx_for_tool_change(std::vector<CustomGCode::Item>::const_iterator it, const int extruder) const { const int current_extruder = it->extruder == 0 ? extruder : it->extruder; if (number_tools() == extruders_cnt + 1) // there is no one "M600" @@ -5352,7 +5352,7 @@ void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, c return std::min<int>(extruders_cnt - 1, std::max<int>(current_extruder - 1, 0)); } - int get_color_idx_for_color_change(std::vector<Model::CustomGCode>::const_iterator it, const int extruder) const + int get_color_idx_for_color_change(std::vector<CustomGCode::Item>::const_iterator it, const int extruder) const { if (extruders_cnt == 1) return get_m600_color_idx(it); diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index d4386f7f3..9ea7568e4 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -557,7 +557,7 @@ public: void load_gcode_preview(const GCodePreviewData& preview_data, const std::vector<std::string>& str_tool_colors); void load_sla_preview(); - void load_preview(const std::vector<std::string>& str_tool_colors, const std::vector<Model::CustomGCode>& color_print_values); + void load_preview(const std::vector<std::string>& str_tool_colors, const std::vector<CustomGCode::Item>& color_print_values); void bind_event_handlers(); void unbind_event_handlers(); @@ -720,7 +720,7 @@ private: // Adds a new Slic3r::GUI::3DScene::Volume to $self->volumes, // one for perimeters, one for infill and one for supports. void _load_print_object_toolpaths(const PrintObject& print_object, const std::vector<std::string>& str_tool_colors, - const std::vector<Model::CustomGCode>& color_print_values); + const std::vector<CustomGCode::Item>& color_print_values); // Create 3D thick extrusion lines for wipe tower extrusions void _load_wipe_tower_toolpaths(const std::vector<std::string>& str_tool_colors); diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index f7010a503..c60547abc 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -633,7 +633,7 @@ static int find_close_layer_idx(const std::vector<double>& zs, double &z, double return -1; } -void Preview::check_slider_values(std::vector<Model::CustomGCode>& ticks_from_model, +void Preview::check_slider_values(std::vector<CustomGCode::Item>& ticks_from_model, const std::vector<double>& layers_z) { // All ticks that would end up outside the slider range should be erased. @@ -641,7 +641,7 @@ void Preview::check_slider_values(std::vector<Model::CustomGCode>& ticks_from_mo // this function is e.g. not called when the last object is deleted unsigned int old_size = ticks_from_model.size(); ticks_from_model.erase(std::remove_if(ticks_from_model.begin(), ticks_from_model.end(), - [layers_z](Model::CustomGCode val) + [layers_z](CustomGCode::Item val) { auto it = std::lower_bound(layers_z.begin(), layers_z.end(), val.print_z - DoubleSlider::epsilon()); return it == layers_z.end(); @@ -669,7 +669,7 @@ void Preview::update_double_slider(const std::vector<double>& layers_z, bool kee // Detect and set manipulation mode for double slider update_double_slider_mode(); - Model::CustomGCodeInfo &ticks_info_from_model = wxGetApp().plater()->model().custom_gcode_per_print_z; + CustomGCode::Info &ticks_info_from_model = wxGetApp().plater()->model().custom_gcode_per_print_z; check_slider_values(ticks_info_from_model.gcodes, layers_z); m_slider->SetSliderValues(layers_z); @@ -830,7 +830,7 @@ 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<std::string> colors; - std::vector<Model::CustomGCode> color_print_values = {}; + std::vector<CustomGCode::Item> 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) { diff --git a/src/slic3r/GUI/GUI_Preview.hpp b/src/slic3r/GUI/GUI_Preview.hpp index ae93e2ff0..ef311e307 100644 --- a/src/slic3r/GUI/GUI_Preview.hpp +++ b/src/slic3r/GUI/GUI_Preview.hpp @@ -155,7 +155,7 @@ private: // Create/Update/Reset double slider on 3dPreview void create_double_slider(); - void check_slider_values(std::vector<Model::CustomGCode> &ticks_from_model, + void check_slider_values(std::vector<CustomGCode::Item> &ticks_from_model, const std::vector<double> &layers_z); void reset_double_slider(); void update_double_slider(const std::vector<double>& layers_z, bool keep_z_range = false); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index a86dd5ceb..8baa0657e 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -5423,7 +5423,7 @@ std::vector<std::string> Plater::get_colors_for_color_print() const std::vector<std::string> colors = get_extruder_colors_from_plater_config(); colors.reserve(colors.size() + p->model.custom_gcode_per_print_z.gcodes.size()); - for (const Model::CustomGCode& code : p->model.custom_gcode_per_print_z.gcodes) + for (const CustomGCode::Item& code : p->model.custom_gcode_per_print_z.gcodes) if (code.gcode == ColorChangeCode) colors.emplace_back(code.color); diff --git a/src/slic3r/GUI/PresetBundle.cpp b/src/slic3r/GUI/PresetBundle.cpp index 7e823f925..6c80a9eab 100644 --- a/src/slic3r/GUI/PresetBundle.cpp +++ b/src/slic3r/GUI/PresetBundle.cpp @@ -884,7 +884,7 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool // 4) Load the project config values (the per extruder wipe matrix etc). this->project_config.apply_only(config, s_project_options); - update_custom_gcode_per_print_z_from_config(GUI::wxGetApp().plater()->model().custom_gcode_per_print_z.gcodes, &this->project_config); + update_custom_gcode_per_print_z_from_config(GUI::wxGetApp().plater()->model().custom_gcode_per_print_z, &this->project_config); break; } diff --git a/src/slic3r/GUI/wxExtensions.cpp b/src/slic3r/GUI/wxExtensions.cpp index d4b207dc1..626d6f392 100644 --- a/src/slic3r/GUI/wxExtensions.cpp +++ b/src/slic3r/GUI/wxExtensions.cpp @@ -2531,10 +2531,10 @@ double DoubleSlider::get_double_value(const SelectedSlider& selection) return m_values[selection == ssLower ? m_lower_value : m_higher_value]; } -using t_custom_code = Slic3r::Model::CustomGCode; -Slic3r::Model::CustomGCodeInfo DoubleSlider::GetTicksValues() const +using t_custom_code = Slic3r::CustomGCode::Item; +Slic3r::CustomGCode::Info DoubleSlider::GetTicksValues() const { - Slic3r::Model::CustomGCodeInfo custom_gcode_per_print_z; + Slic3r::CustomGCode::Info custom_gcode_per_print_z; std::vector<t_custom_code>& values = custom_gcode_per_print_z.gcodes; const int val_size = m_values.size(); @@ -2550,7 +2550,7 @@ Slic3r::Model::CustomGCodeInfo DoubleSlider::GetTicksValues() const return custom_gcode_per_print_z; } -void DoubleSlider::SetTicksValues(const Slic3r::Model::CustomGCodeInfo& custom_gcode_per_print_z) +void DoubleSlider::SetTicksValues(const Slic3r::CustomGCode::Info& custom_gcode_per_print_z) { if (m_values.empty()) { diff --git a/src/slic3r/GUI/wxExtensions.hpp b/src/slic3r/GUI/wxExtensions.hpp index 7511e8a19..322358ffe 100644 --- a/src/slic3r/GUI/wxExtensions.hpp +++ b/src/slic3r/GUI/wxExtensions.hpp @@ -782,7 +782,7 @@ public: const wxString& name = wxEmptyString); ~DoubleSlider() {} - using t_mode = Slic3r::Model::CustomGCodeInfo::MODE; + using t_mode = Slic3r::CustomGCode::Mode; /* For exporting GCode in GCodeWriter is used XYZF_NUM(val) = PRECISION(val, 3) for XYZ values. * So, let use same value as a permissible error for layer height. @@ -810,8 +810,8 @@ public: void SetKoefForLabels(const double koef) { m_label_koef = koef; } void SetSliderValues(const std::vector<double>& values) { m_values = values; } void ChangeOneLayerLock(); - Slic3r::Model::CustomGCodeInfo GetTicksValues() const; - void SetTicksValues(const Slic3r::Model::CustomGCodeInfo &custom_gcode_per_print_z); + Slic3r::CustomGCode::Info GetTicksValues() const; + void SetTicksValues(const Slic3r::CustomGCode::Info &custom_gcode_per_print_z); void EnableTickManipulation(bool enable = true) { m_is_enabled_tick_manipulation = enable; } void DisableTickManipulation() { EnableTickManipulation(false); } |