From b153c8cb202f9cf27baa6038ee71e00db6fce28f Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 26 Nov 2018 16:17:59 +0100 Subject: [PATCH 1/3] SLA slices preview - wip 2 --- src/libslic3r/SLAPrint.hpp | 2 +- src/slic3r/GUI/GLCanvas3D.cpp | 4 +-- src/slic3r/GUI/GUI_Preview.cpp | 51 ++++++++++++++++++++++++++++------ src/slic3r/GUI/GUI_Preview.hpp | 6 ++-- 4 files changed, 49 insertions(+), 14 deletions(-) diff --git a/src/libslic3r/SLAPrint.hpp b/src/libslic3r/SLAPrint.hpp index 88b207d82..c29c4d1cc 100644 --- a/src/libslic3r/SLAPrint.hpp +++ b/src/libslic3r/SLAPrint.hpp @@ -93,7 +93,7 @@ public: // to the z coordinate of the object coordinate system. struct SliceRecord { using Key = long long; - inline static float scale_back(Key h) { return float(scale_(h)); } + inline static float scale_back(Key h) { return float(h * SCALING_FACTOR); } using Idx = size_t; static const Idx NONE = Idx(-1); // this will be the max limit of size_t diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 62e996ba1..42df2f421 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -7003,7 +7003,7 @@ void GLCanvas3D::_load_shells_sla() unsigned int partial_volumes_count = (unsigned int)m_volumes.volumes.size(); // add supports - if (obj->is_step_done(slaposSupportTree)) + if (obj->is_step_done(slaposSupportTree) && obj->has_mesh(slaposSupportTree)) { const TriangleMesh& mesh = obj->support_mesh(); m_volumes.volumes.emplace_back(new GLVolume(GLVolume::SLA_SUPPORT_COLOR)); @@ -7021,7 +7021,7 @@ void GLCanvas3D::_load_shells_sla() } // add pad - if (obj->is_step_done(slaposBasePool)) + if (obj->is_step_done(slaposBasePool) && obj->has_mesh(slaposBasePool)) { const TriangleMesh& mesh = obj->pad_mesh(); m_volumes.volumes.emplace_back(new GLVolume(GLVolume::SLA_PAD_COLOR)); diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index 5b0153c20..cae7440f6 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -22,6 +22,7 @@ // this include must follow the wxWidgets ones or it won't compile on Windows -> see http://trac.wxwidgets.org/ticket/2421 #include "libslic3r/Print.hpp" +#include "libslic3r/SLAPrint.hpp" namespace Slic3r { namespace GUI { @@ -326,10 +327,10 @@ void Preview::reset_sliders() m_double_slider_sizer->Hide((size_t)0); } -void Preview::update_sliders() +void Preview::update_sliders(const std::vector& layers_z) { m_enabled = true; - update_double_slider(m_force_sliders_full_range); + update_double_slider(layers_z, m_force_sliders_full_range); m_double_slider_sizer->Show((size_t)0); Layout(); } @@ -402,10 +403,9 @@ void Preview::create_double_slider() }); } -void Preview::update_double_slider(bool force_sliders_full_range) +void Preview::update_double_slider(const std::vector& layers_z, bool force_sliders_full_range) { std::vector> values; - std::vector layers_z = m_canvas->get_current_print_zs(true); fill_slider_values(values, layers_z); const double z_low = m_slider->GetLowerValueD(); @@ -606,7 +606,7 @@ void Preview::load_print_as_fff() } if (n_layers > 0) - update_sliders(); + update_sliders(m_canvas->get_current_print_zs(true)); m_loaded = true; } @@ -617,9 +617,44 @@ void Preview::load_print_as_sla() if (m_loaded || (m_process->current_printer_technology() != ptSLA)) return; - std::cout << "Preview::load_print_as_sla()" << std::endl; - m_canvas->load_sla_preview(); - show_hide_ui_elements("none"); + unsigned int n_layers = 0; + const SLAPrint* print = m_process->sla_print(); + + std::set zs; + for (const SLAPrintObject* obj : print->objects()) + { + if (obj->is_step_done(slaposIndexSlices)) + { + const SLAPrintObject::SliceIndex& index = obj->get_slice_index(); + for (const SLAPrintObject::SliceIndex::value_type& id : index) + { + zs.insert(id.second.scale_back(id.first)); + } + } + } + + n_layers = (unsigned int)zs.size(); + if (n_layers == 0) + { + reset_sliders(); + m_canvas_widget->Refresh(); + } + + if (IsShown()) + { + std::cout << "Preview::load_print_as_sla()" << std::endl; + m_canvas->load_sla_preview(); + show_hide_ui_elements("none"); + + if (n_layers > 0) + { + std::vector layer_zs; + std::copy(zs.begin(), zs.end(), std::back_inserter(layer_zs)); + update_sliders(layer_zs); + } + + m_loaded = true; + } } } // namespace GUI diff --git a/src/slic3r/GUI/GUI_Preview.hpp b/src/slic3r/GUI/GUI_Preview.hpp index 9a175205c..902ead38d 100644 --- a/src/slic3r/GUI/GUI_Preview.hpp +++ b/src/slic3r/GUI/GUI_Preview.hpp @@ -85,7 +85,7 @@ private: void show_hide_ui_elements(const std::string& what); void reset_sliders(); - void update_sliders(); + void update_sliders(const std::vector& layers_z); void on_size(wxSizeEvent& evt); void on_choice_view_type(wxCommandEvent& evt); @@ -97,8 +97,8 @@ private: // Create/Update/Reset double slider on 3dPreview void create_double_slider(); - void update_double_slider(bool force_sliders_full_range); - void fill_slider_values(std::vector> &values, + void update_double_slider(const std::vector& layers_z, bool force_sliders_full_range); + void fill_slider_values(std::vector> &values, const std::vector &layers_z); void set_double_slider_thumbs( const bool force_sliders_full_range, const std::vector &layers_z, From f8bc7cb95972681837610d508210d620920c3611 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Mon, 26 Nov 2018 16:07:09 +0100 Subject: [PATCH 2/3] Implementation of the "ColorPrint" on the 3DScene --- src/libslic3r/ExtrusionEntity.hpp | 14 ++++++----- src/libslic3r/GCode.cpp | 2 +- src/libslic3r/GCode/Analyzer.cpp | 37 +++++++++++++++++++++++++---- src/libslic3r/GCode/Analyzer.hpp | 12 ++++++++-- src/libslic3r/GCode/PreviewData.cpp | 17 ++++++++++++- src/libslic3r/GCode/PreviewData.hpp | 4 +++- src/slic3r/GUI/GLCanvas3D.cpp | 16 ++++++++++++- src/slic3r/GUI/GUI_Preview.cpp | 7 ++++-- src/slic3r/GUI/wxExtensions.cpp | 12 ++++------ 9 files changed, 96 insertions(+), 25 deletions(-) diff --git a/src/libslic3r/ExtrusionEntity.hpp b/src/libslic3r/ExtrusionEntity.hpp index cce3020f8..a62a189ce 100644 --- a/src/libslic3r/ExtrusionEntity.hpp +++ b/src/libslic3r/ExtrusionEntity.hpp @@ -113,15 +113,17 @@ public: float feedrate; // Id of the extruder, used for visualization purposed. unsigned int extruder_id; + // Id of the color, used for visualization purposed in the color printing case. + unsigned int cp_color_id; - ExtrusionPath(ExtrusionRole role) : mm3_per_mm(-1), width(-1), height(-1), feedrate(0.0f), extruder_id(0), m_role(role) {}; - ExtrusionPath(ExtrusionRole role, double mm3_per_mm, float width, float height) : mm3_per_mm(mm3_per_mm), width(width), height(height), feedrate(0.0f), extruder_id(0), m_role(role) {}; - ExtrusionPath(const ExtrusionPath &rhs) : polyline(rhs.polyline), mm3_per_mm(rhs.mm3_per_mm), width(rhs.width), height(rhs.height), feedrate(rhs.feedrate), extruder_id(rhs.extruder_id), m_role(rhs.m_role) {} - ExtrusionPath(ExtrusionPath &&rhs) : polyline(std::move(rhs.polyline)), mm3_per_mm(rhs.mm3_per_mm), width(rhs.width), height(rhs.height), feedrate(rhs.feedrate), extruder_id(rhs.extruder_id), m_role(rhs.m_role) {} + ExtrusionPath(ExtrusionRole role) : mm3_per_mm(-1), width(-1), height(-1), feedrate(0.0f), extruder_id(0), cp_color_id(0), m_role(role) {}; + ExtrusionPath(ExtrusionRole role, double mm3_per_mm, float width, float height) : mm3_per_mm(mm3_per_mm), width(width), height(height), feedrate(0.0f), extruder_id(0), cp_color_id(0), m_role(role) {}; + ExtrusionPath(const ExtrusionPath &rhs) : polyline(rhs.polyline), mm3_per_mm(rhs.mm3_per_mm), width(rhs.width), height(rhs.height), feedrate(rhs.feedrate), extruder_id(rhs.extruder_id), cp_color_id(rhs.cp_color_id), m_role(rhs.m_role) {} + ExtrusionPath(ExtrusionPath &&rhs) : polyline(std::move(rhs.polyline)), mm3_per_mm(rhs.mm3_per_mm), width(rhs.width), height(rhs.height), feedrate(rhs.feedrate), extruder_id(rhs.extruder_id), cp_color_id(rhs.cp_color_id), m_role(rhs.m_role) {} // ExtrusionPath(ExtrusionRole role, const Flow &flow) : m_role(role), mm3_per_mm(flow.mm3_per_mm()), width(flow.width), height(flow.height), feedrate(0.0f), extruder_id(0) {}; - ExtrusionPath& operator=(const ExtrusionPath &rhs) { m_role = rhs.m_role; this->mm3_per_mm = rhs.mm3_per_mm; this->width = rhs.width; this->height = rhs.height; this->feedrate = rhs.feedrate, this->extruder_id = rhs.extruder_id, this->polyline = rhs.polyline; return *this; } - ExtrusionPath& operator=(ExtrusionPath &&rhs) { m_role = rhs.m_role; this->mm3_per_mm = rhs.mm3_per_mm; this->width = rhs.width; this->height = rhs.height; this->feedrate = rhs.feedrate, this->extruder_id = rhs.extruder_id, this->polyline = std::move(rhs.polyline); return *this; } + ExtrusionPath& operator=(const ExtrusionPath &rhs) { m_role = rhs.m_role; this->mm3_per_mm = rhs.mm3_per_mm; this->width = rhs.width; this->height = rhs.height; this->feedrate = rhs.feedrate, this->extruder_id = rhs.extruder_id, this->cp_color_id = rhs.cp_color_id, this->polyline = rhs.polyline; return *this; } + ExtrusionPath& operator=(ExtrusionPath &&rhs) { m_role = rhs.m_role; this->mm3_per_mm = rhs.mm3_per_mm; this->width = rhs.width; this->height = rhs.height; this->feedrate = rhs.feedrate, this->extruder_id = rhs.extruder_id, this->cp_color_id = rhs.cp_color_id, this->polyline = std::move(rhs.polyline); return *this; } ExtrusionPath* clone() const { return new ExtrusionPath (*this); } void reverse() { this->polyline.reverse(); } diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index b9625523d..bcfb8faec 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -1322,7 +1322,7 @@ 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; - while (!m_colorprint_heights.empty() && m_colorprint_heights.front()-EPSILON < layer.print_z) { + while (!m_colorprint_heights.empty() && m_colorprint_heights.front()/*-EPSILON*/ < layer.print_z-EPSILON) { m_colorprint_heights.erase(m_colorprint_heights.begin()); colorprint_change = true; } diff --git a/src/libslic3r/GCode/Analyzer.cpp b/src/libslic3r/GCode/Analyzer.cpp index e3cd67e7c..c56f02753 100644 --- a/src/libslic3r/GCode/Analyzer.cpp +++ b/src/libslic3r/GCode/Analyzer.cpp @@ -14,6 +14,7 @@ static const float MMMIN_TO_MMSEC = 1.0f / 60.0f; static const float INCHES_TO_MM = 25.4f; static const float DEFAULT_FEEDRATE = 0.0f; static const unsigned int DEFAULT_EXTRUDER_ID = 0; +static const unsigned int DEFAULT_COLOR_PRINT_ID = 0; static const Slic3r::Vec3d DEFAULT_START_POSITION = Slic3r::Vec3d(0.0f, 0.0f, 0.0f); static const float DEFAULT_START_EXTRUSION = 0.0f; @@ -31,6 +32,7 @@ const float GCodeAnalyzer::Default_Height = 0.0f; GCodeAnalyzer::Metadata::Metadata() : extrusion_role(erNone) , extruder_id(DEFAULT_EXTRUDER_ID) + , cp_color_id(DEFAULT_COLOR_PRINT_ID) , mm3_per_mm(GCodeAnalyzer::Default_mm3_per_mm) , width(GCodeAnalyzer::Default_Width) , height(GCodeAnalyzer::Default_Height) @@ -38,13 +40,14 @@ GCodeAnalyzer::Metadata::Metadata() { } -GCodeAnalyzer::Metadata::Metadata(ExtrusionRole extrusion_role, unsigned int extruder_id, double mm3_per_mm, float width, float height, float feedrate) +GCodeAnalyzer::Metadata::Metadata(ExtrusionRole extrusion_role, unsigned int extruder_id, double mm3_per_mm, float width, float height, float feedrate, unsigned int cp_color_id/* = 0*/) : extrusion_role(extrusion_role) , extruder_id(extruder_id) , mm3_per_mm(mm3_per_mm) , width(width) , height(height) , feedrate(feedrate) + , cp_color_id(cp_color_id) { } @@ -68,12 +71,15 @@ bool GCodeAnalyzer::Metadata::operator != (const GCodeAnalyzer::Metadata& other) if (feedrate != other.feedrate) return true; + if (cp_color_id != other.cp_color_id) + return true; + return false; } -GCodeAnalyzer::GCodeMove::GCodeMove(GCodeMove::EType type, ExtrusionRole extrusion_role, unsigned int extruder_id, double mm3_per_mm, float width, float height, float feedrate, const Vec3d& start_position, const Vec3d& end_position, float delta_extruder) +GCodeAnalyzer::GCodeMove::GCodeMove(GCodeMove::EType type, ExtrusionRole extrusion_role, unsigned int extruder_id, double mm3_per_mm, float width, float height, float feedrate, const Vec3d& start_position, const Vec3d& end_position, float delta_extruder, unsigned int cp_color_id/* = 0*/) : type(type) - , data(extrusion_role, extruder_id, mm3_per_mm, width, height, feedrate) + , data(extrusion_role, extruder_id, mm3_per_mm, width, height, feedrate, cp_color_id) , start_position(start_position) , end_position(end_position) , delta_extruder(delta_extruder) @@ -101,6 +107,7 @@ void GCodeAnalyzer::reset() _set_e_local_positioning_type(Absolute); _set_extrusion_role(erNone); _set_extruder_id(DEFAULT_EXTRUDER_ID); + _set_cp_color_id(DEFAULT_COLOR_PRINT_ID); _set_mm3_per_mm(Default_mm3_per_mm); _set_width(Default_Width); _set_height(Default_Height); @@ -220,6 +227,11 @@ void GCodeAnalyzer::_process_gcode_line(GCodeReader&, const GCodeReader::GCodeLi { switch (::atoi(&cmd[1])) { + case 600: // Set color change + { + _processM600(line); + break; + } case 82: // Set extruder to absolute mode { _processM82(line); @@ -401,6 +413,12 @@ void GCodeAnalyzer::_processM83(const GCodeReader::GCodeLine& line) _set_e_local_positioning_type(Relative); } +void GCodeAnalyzer::_processM600(const GCodeReader::GCodeLine& line) +{ + m_state.cur_cp_color_id++; + _set_cp_color_id(m_state.cur_cp_color_id); +} + void GCodeAnalyzer::_processT(const GCodeReader::GCodeLine& line) { std::string cmd = line.cmd(); @@ -532,6 +550,16 @@ unsigned int GCodeAnalyzer::_get_extruder_id() const return m_state.data.extruder_id; } +void GCodeAnalyzer::_set_cp_color_id(unsigned int id) +{ + m_state.data.cp_color_id = id; +} + +unsigned int GCodeAnalyzer::_get_cp_color_id() const +{ + return m_state.data.cp_color_id; +} + void GCodeAnalyzer::_set_mm3_per_mm(double value) { m_state.data.mm3_per_mm = value; @@ -625,7 +653,7 @@ void GCodeAnalyzer::_store_move(GCodeAnalyzer::GCodeMove::EType type) it = m_moves_map.insert(TypeToMovesMap::value_type(type, GCodeMovesList())).first; // store move - it->second.emplace_back(type, _get_extrusion_role(), _get_extruder_id(), _get_mm3_per_mm(), _get_width(), _get_height(), _get_feedrate(), _get_start_position(), _get_end_position(), _get_delta_extrusion()); + it->second.emplace_back(type, _get_extrusion_role(), _get_extruder_id(), _get_mm3_per_mm(), _get_width(), _get_height(), _get_feedrate(), _get_start_position(), _get_end_position(), _get_delta_extrusion(), _get_cp_color_id()); } bool GCodeAnalyzer::_is_valid_extrusion_role(int value) const @@ -660,6 +688,7 @@ void GCodeAnalyzer::_calc_gcode_preview_extrusion_layers(GCodePreviewData& previ path.polyline = polyline; path.feedrate = data.feedrate; path.extruder_id = data.extruder_id; + path.cp_color_id = data.cp_color_id; get_layer_at_z(preview_data.extrusion.layers, z).paths.push_back(path); } diff --git a/src/libslic3r/GCode/Analyzer.hpp b/src/libslic3r/GCode/Analyzer.hpp index 97ee6381b..f50138b56 100644 --- a/src/libslic3r/GCode/Analyzer.hpp +++ b/src/libslic3r/GCode/Analyzer.hpp @@ -53,9 +53,10 @@ public: float width; // mm float height; // mm float feedrate; // mm/s + unsigned int cp_color_id; Metadata(); - Metadata(ExtrusionRole extrusion_role, unsigned int extruder_id, double mm3_per_mm, float width, float height, float feedrate); + Metadata(ExtrusionRole extrusion_role, unsigned int extruder_id, double mm3_per_mm, float width, float height, float feedrate, unsigned int cp_color_id = 0); bool operator != (const Metadata& other) const; }; @@ -79,7 +80,7 @@ public: Vec3d end_position; float delta_extruder; - GCodeMove(EType type, ExtrusionRole extrusion_role, unsigned int extruder_id, double mm3_per_mm, float width, float height, float feedrate, const Vec3d& start_position, const Vec3d& end_position, float delta_extruder); + GCodeMove(EType type, ExtrusionRole extrusion_role, unsigned int extruder_id, double mm3_per_mm, float width, float height, float feedrate, const Vec3d& start_position, const Vec3d& end_position, float delta_extruder, unsigned int cp_color_id = 0); GCodeMove(EType type, const Metadata& data, const Vec3d& start_position, const Vec3d& end_position, float delta_extruder); }; @@ -96,6 +97,7 @@ private: Vec3d start_position = Vec3d::Zero(); float start_extrusion; float position[Num_Axis]; + unsigned int cur_cp_color_id = 0; }; private: @@ -154,6 +156,9 @@ private: // Set extruder to relative mode void _processM83(const GCodeReader::GCodeLine& line); + // Set color change + void _processM600(const GCodeReader::GCodeLine& line); + // Processes T line (Select Tool) void _processT(const GCodeReader::GCodeLine& line); @@ -188,6 +193,9 @@ private: void _set_extruder_id(unsigned int id); unsigned int _get_extruder_id() const; + void _set_cp_color_id(unsigned int id); + unsigned int _get_cp_color_id() const; + void _set_mm3_per_mm(double value); double _get_mm3_per_mm() const; diff --git a/src/libslic3r/GCode/PreviewData.cpp b/src/libslic3r/GCode/PreviewData.cpp index 564fc34dc..ef38a5db3 100644 --- a/src/libslic3r/GCode/PreviewData.cpp +++ b/src/libslic3r/GCode/PreviewData.cpp @@ -219,6 +219,7 @@ void GCodePreviewData::Travel::set_default() width = Default_Width; height = Default_Height; ::memcpy((void*)type_colors, (const void*)Default_Type_Colors, Num_Types * sizeof(Color)); + color_print_idx = 0; is_visible = false; } @@ -374,12 +375,14 @@ std::string GCodePreviewData::get_legend_title() const return L("Volumetric flow rate (mm3/s)"); case Extrusion::Tool: return L("Tool"); + case Extrusion::ColorPrint: + return L("Color Print"); } return ""; } -GCodePreviewData::LegendItemsList GCodePreviewData::get_legend_items(const std::vector& tool_colors) const +GCodePreviewData::LegendItemsList GCodePreviewData::get_legend_items(const std::vector& tool_colors, const int color_print_cnt /*= 0*/) const { struct Helper { @@ -445,6 +448,18 @@ GCodePreviewData::LegendItemsList GCodePreviewData::get_legend_items(const std:: items.emplace_back((boost::format(Slic3r::I18N::translate(L("Extruder %d"))) % (i + 1)).str(), color); } + break; + } + case Extrusion::ColorPrint: + { + 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); + } break; } } diff --git a/src/libslic3r/GCode/PreviewData.hpp b/src/libslic3r/GCode/PreviewData.hpp index 966e2e796..5b944c992 100644 --- a/src/libslic3r/GCode/PreviewData.hpp +++ b/src/libslic3r/GCode/PreviewData.hpp @@ -71,6 +71,7 @@ public: Feedrate, VolumetricRate, Tool, + ColorPrint, Num_View_Types }; @@ -140,6 +141,7 @@ public: float height; Color type_colors[Num_Types]; bool is_visible; + size_t color_print_idx; void set_default(); }; @@ -196,7 +198,7 @@ public: void set_extrusion_paths_colors(const std::vector& colors); std::string get_legend_title() const; - LegendItemsList get_legend_items(const std::vector& tool_colors) const; + LegendItemsList get_legend_items(const std::vector& tool_colors, const int color_print_cnt = 1) const; }; GCodePreviewData::Color operator + (const GCodePreviewData::Color& c1, const GCodePreviewData::Color& c2); diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 42df2f421..fd3287d81 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -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("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; } diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index cae7440f6..0e533134a 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -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; } diff --git a/src/slic3r/GUI/wxExtensions.cpp b/src/slic3r/GUI/wxExtensions.cpp index dda731945..b14c958ed 100644 --- a/src/slic3r/GUI/wxExtensions.cpp +++ b/src/slic3r/GUI/wxExtensions.cpp @@ -1474,7 +1474,7 @@ void PrusaDoubleSlider::SetTicksValues(const std::vector& 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)); From 21a1106776823a7ba528c9cf012d8827320b528f Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Mon, 26 Nov 2018 16:32:24 +0100 Subject: [PATCH 3/3] SLA support points are rendered with regard to sla_shift_z --- src/slic3r/GUI/GLGizmo.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/slic3r/GUI/GLGizmo.cpp b/src/slic3r/GUI/GLGizmo.cpp index bb06eb243..b876be8f9 100644 --- a/src/slic3r/GUI/GLGizmo.cpp +++ b/src/slic3r/GUI/GLGizmo.cpp @@ -1657,6 +1657,8 @@ void GLGizmoSlaSupports::on_render(const GLCanvas3D::Selection& selection) const ::glPushMatrix(); //::glTranslatef((GLfloat)dragged_offset(0), (GLfloat)dragged_offset(1), (GLfloat)dragged_offset(2)); + float z_shift = m_parent.get_selection().get_volume(0)->get_sla_shift_z(); + ::glTranslatef((GLfloat)0, (GLfloat)0, (GLfloat)z_shift); render_grabbers(); ::glPopMatrix();