From 2c51e432e340a921a8204d2bbd7c7cb153f1e34a Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Wed, 3 Apr 2019 09:05:52 +0200 Subject: [PATCH 01/14] Fixed negative values for size shown in the sidebar matrix fields when mirroring is applied --- src/slic3r/GUI/GUI_ObjectManipulation.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/slic3r/GUI/GUI_ObjectManipulation.cpp b/src/slic3r/GUI/GUI_ObjectManipulation.cpp index 6c8fdcab73c..61e98d5425a 100644 --- a/src/slic3r/GUI/GUI_ObjectManipulation.cpp +++ b/src/slic3r/GUI/GUI_ObjectManipulation.cpp @@ -179,7 +179,7 @@ void ObjectManipulation::update_settings_value(const Selection& selection) changed_box = true; } if (changed_box || !m_cache.instance.matches_instance(instance_idx) || !m_cache.scale.isApprox(100.0 * m_new_scale)) - m_new_size = volume->get_instance_transformation().get_matrix(true, true) * m_cache.instance.box_size; + m_new_size = (volume->get_instance_transformation().get_matrix(true, true) * m_cache.instance.box_size).cwiseAbs(); } else // this should never happen @@ -209,7 +209,7 @@ void ObjectManipulation::update_settings_value(const Selection& selection) m_new_position = volume->get_volume_offset(); m_new_rotation = volume->get_volume_rotation(); m_new_scale = volume->get_volume_scaling_factor(); - m_new_size = volume->get_volume_transformation().get_matrix(true, true) * volume->bounding_box.size(); + m_new_size = (volume->get_volume_transformation().get_matrix(true, true) * volume->bounding_box.size()).cwiseAbs(); m_new_enabled = true; } else if (wxGetApp().obj_list()->multiple_selection()) From 0119160a1bf929a29b9cea7394397d50c35949f4 Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Wed, 3 Apr 2019 10:17:57 +0200 Subject: [PATCH 02/14] Get rid of unnecessary copies and moves in ClipperUtils This is up to a code review session. --- src/libslic3r/ClipperUtils.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/libslic3r/ClipperUtils.cpp b/src/libslic3r/ClipperUtils.cpp index f00e908ce56..86b4ee4475b 100644 --- a/src/libslic3r/ClipperUtils.cpp +++ b/src/libslic3r/ClipperUtils.cpp @@ -120,7 +120,7 @@ Slic3r::Polygon ClipperPath_to_Slic3rPolygon(const ClipperLib::Path &input) { Polygon retval; for (ClipperLib::Path::const_iterator pit = input.begin(); pit != input.end(); ++pit) - retval.points.push_back(Point( (*pit).X, (*pit).Y )); + retval.points.emplace_back(pit->X, pit->Y); return retval; } @@ -128,7 +128,7 @@ Slic3r::Polyline ClipperPath_to_Slic3rPolyline(const ClipperLib::Path &input) { Polyline retval; for (ClipperLib::Path::const_iterator pit = input.begin(); pit != input.end(); ++pit) - retval.points.push_back(Point( (*pit).X, (*pit).Y )); + retval.points.emplace_back(pit->X, pit->Y); return retval; } @@ -137,7 +137,7 @@ Slic3r::Polygons ClipperPaths_to_Slic3rPolygons(const ClipperLib::Paths &input) Slic3r::Polygons retval; retval.reserve(input.size()); for (ClipperLib::Paths::const_iterator it = input.begin(); it != input.end(); ++it) - retval.push_back(ClipperPath_to_Slic3rPolygon(*it)); + retval.emplace_back(ClipperPath_to_Slic3rPolygon(*it)); return retval; } @@ -146,7 +146,7 @@ Slic3r::Polylines ClipperPaths_to_Slic3rPolylines(const ClipperLib::Paths &input Slic3r::Polylines retval; retval.reserve(input.size()); for (ClipperLib::Paths::const_iterator it = input.begin(); it != input.end(); ++it) - retval.push_back(ClipperPath_to_Slic3rPolyline(*it)); + retval.emplace_back(ClipperPath_to_Slic3rPolyline(*it)); return retval; } @@ -171,7 +171,7 @@ Slic3rMultiPoint_to_ClipperPath(const MultiPoint &input) { ClipperLib::Path retval; for (Points::const_iterator pit = input.points.begin(); pit != input.points.end(); ++pit) - retval.push_back(ClipperLib::IntPoint( (*pit)(0), (*pit)(1) )); + retval.emplace_back((*pit)(0), (*pit)(1)); return retval; } @@ -181,7 +181,7 @@ Slic3rMultiPoint_to_ClipperPath_reversed(const Slic3r::MultiPoint &input) ClipperLib::Path output; output.reserve(input.points.size()); for (Slic3r::Points::const_reverse_iterator pit = input.points.rbegin(); pit != input.points.rend(); ++pit) - output.push_back(ClipperLib::IntPoint( (*pit)(0), (*pit)(1) )); + output.emplace_back((*pit)(0), (*pit)(1)); return output; } @@ -189,7 +189,7 @@ ClipperLib::Paths Slic3rMultiPoints_to_ClipperPaths(const Polygons &input) { ClipperLib::Paths retval; for (Polygons::const_iterator it = input.begin(); it != input.end(); ++it) - retval.push_back(Slic3rMultiPoint_to_ClipperPath(*it)); + retval.emplace_back(Slic3rMultiPoint_to_ClipperPath(*it)); return retval; } @@ -197,7 +197,7 @@ ClipperLib::Paths Slic3rMultiPoints_to_ClipperPaths(const Polylines &input) { ClipperLib::Paths retval; for (Polylines::const_iterator it = input.begin(); it != input.end(); ++it) - retval.push_back(Slic3rMultiPoint_to_ClipperPath(*it)); + retval.emplace_back(Slic3rMultiPoint_to_ClipperPath(*it)); return retval; } @@ -226,7 +226,7 @@ ClipperLib::Paths _offset(ClipperLib::Paths &&input, ClipperLib::EndType endType ClipperLib::Paths _offset(ClipperLib::Path &&input, ClipperLib::EndType endType, const float delta, ClipperLib::JoinType joinType, double miterLimit) { ClipperLib::Paths paths; - paths.push_back(std::move(input)); + paths.emplace_back(std::move(input)); return _offset(std::move(paths), endType, delta, joinType, miterLimit); } @@ -585,7 +585,7 @@ Polylines _clipper_pl(ClipperLib::ClipType clipType, const Polygons &subject, co Polylines polylines; polylines.reserve(subject.size()); for (Polygons::const_iterator polygon = subject.begin(); polygon != subject.end(); ++polygon) - polylines.push_back(*polygon); // implicit call to split_at_first_point() + polylines.emplace_back(polygon->operator Polyline()); // implicit call to split_at_first_point() // perform clipping Polylines retval = _clipper_pl(clipType, polylines, clip, safety_offset_); @@ -643,7 +643,7 @@ _clipper_ln(ClipperLib::ClipType clipType, const Lines &subject, const Polygons // convert Polylines to Lines Lines retval; for (Polylines::const_iterator polyline = polylines.begin(); polyline != polylines.end(); ++polyline) - retval.push_back(*polyline); + retval.emplace_back(std::move(*polyline)); return retval; } @@ -673,7 +673,7 @@ void traverse_pt(ClipperLib::PolyNodes &nodes, Polygons* retval) ordering_points.reserve(nodes.size()); for (ClipperLib::PolyNodes::const_iterator it = nodes.begin(); it != nodes.end(); ++it) { Point p((*it)->Contour.front().X, (*it)->Contour.front().Y); - ordering_points.push_back(p); + ordering_points.emplace_back(p); } // perform the ordering @@ -684,7 +684,7 @@ void traverse_pt(ClipperLib::PolyNodes &nodes, Polygons* retval) for (ClipperLib::PolyNodes::iterator it = ordered_nodes.begin(); it != ordered_nodes.end(); ++it) { // traverse the next depth traverse_pt((*it)->Childs, retval); - retval->push_back(ClipperPath_to_Slic3rPolygon((*it)->Contour)); + retval->emplace_back(ClipperPath_to_Slic3rPolygon((*it)->Contour)); if ((*it)->IsHole()) retval->back().reverse(); // ccw } } @@ -791,8 +791,8 @@ Polygons top_level_islands(const Slic3r::Polygons &polygons) Polygons out; out.reserve(polytree.ChildCount()); for (int i = 0; i < polytree.ChildCount(); ++i) - out.push_back(ClipperPath_to_Slic3rPolygon(polytree.Childs[i]->Contour)); + out.emplace_back(ClipperPath_to_Slic3rPolygon(polytree.Childs[i]->Contour)); return out; } -} \ No newline at end of file +} From b48aee34151320d3813c2e930c9dd56955356080 Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Wed, 3 Apr 2019 10:29:27 +0200 Subject: [PATCH 03/14] Remove unnecessary reversals of print polygons. --- src/libslic3r/SLAPrint.cpp | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/libslic3r/SLAPrint.cpp b/src/libslic3r/SLAPrint.cpp index 7dc920517bb..809b32d901a 100644 --- a/src/libslic3r/SLAPrint.cpp +++ b/src/libslic3r/SLAPrint.cpp @@ -1041,31 +1041,37 @@ void SLAPrint::process() { ClipperPolygon poly; + // We need to reverse if flpXY OR is_lefthanded is true but + // not if both are true which is a logical inequality (XOR) + bool needreverse = flpXY != is_lefthanded; + // should be a move poly.Contour.reserve(polygon.contour.size() + 1); - for(auto& p : polygon.contour.points) - poly.Contour.emplace_back(p.x(), p.y()); - - auto pfirst = poly.Contour.front(); - poly.Contour.emplace_back(pfirst); + auto& cntr = polygon.contour.points; + if(needreverse) + for(auto it = cntr.rbegin(); it != cntr.rend(); ++it) + poly.Contour.emplace_back(it->x(), it->y()); + else + for(auto& p : cntr) + poly.Contour.emplace_back(p.x(), p.y()); for(auto& h : polygon.holes) { poly.Holes.emplace_back(); auto& hole = poly.Holes.back(); hole.reserve(h.points.size() + 1); - for(auto& p : h.points) hole.emplace_back(p.x(), p.y()); - auto pfirst = hole.front(); hole.emplace_back(pfirst); + if(needreverse) + for(auto& p : h.points) + hole.emplace_back(p.x(), p.y()); + else + for(auto it = h.points.rbegin(); it != h.points.rend(); ++it) + hole.emplace_back(it->x(), it->y()); } if(is_lefthanded) { for(auto& p : poly.Contour) p.X = -p.X; - std::reverse(poly.Contour.begin(), poly.Contour.end()); - for(auto& h : poly.Holes) { - for(auto& p : h) p.X = -p.X; - std::reverse(h.begin(), h.end()); - } + for(auto& h : poly.Holes) for(auto& p : h) p.X = -p.X; } sl::rotate(poly, double(instances[i].rotation)); @@ -1074,12 +1080,7 @@ void SLAPrint::process() if (flpXY) { for(auto& p : poly.Contour) std::swap(p.X, p.Y); - std::reverse(poly.Contour.begin(), poly.Contour.end()); - - for(auto& h : poly.Holes) { - for(auto& p : h) std::swap(p.X, p.Y); - std::reverse(h.begin(), h.end()); - } + for(auto& h : poly.Holes) for(auto& p : h) std::swap(p.X, p.Y); } polygons.emplace_back(std::move(poly)); From 5b1a8d6a14990b59e8862fe1cc1a6eeeb21664d4 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Wed, 3 Apr 2019 10:36:54 +0200 Subject: [PATCH 04/14] Deliberately setting the SLA dialog a bit too large It is not possible to precisely calculate actual window size before the rendering, so I added a safety margin. It would be nicer to let the window autoscale and only use the inflated dimension for possible moving the window upward to prevent collision with the bottom panel, but... ImGui autoscaling does not work properly for some reason (the window size autoscales only after a mouse move), so this is a workaround. --- src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp index 75f13cdcf0f..5be7f9100a1 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp @@ -565,12 +565,12 @@ void GLGizmoSlaSupports::on_render_input_window(float x, float y, float bottom_l RENDER_AGAIN: m_imgui->set_next_window_pos(x, y, ImGuiCond_Always); - const ImVec2 window_size(m_imgui->scaled(15.f, 16.5f)); + const ImVec2 window_size(m_imgui->scaled(17.f, 18.f)); ImGui::SetNextWindowPos(ImVec2(x, y - std::max(0.f, y+window_size.y-bottom_limit) )); ImGui::SetNextWindowSize(ImVec2(window_size)); m_imgui->set_next_window_bg_alpha(0.5f); - m_imgui->begin(on_get_name(), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse); + m_imgui->begin(on_get_name(), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse); ImGui::PushItemWidth(100.0f); From 380f5fbfa570addd99adcaaff815d352988fbf25 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Wed, 3 Apr 2019 11:12:03 +0200 Subject: [PATCH 05/14] Fixed FFF slicing of meshes with left hand oriented transformations applied. Slight optimization of FFF slicing - optimized copy of an object with just a single volume. --- src/libslic3r/PrintObject.cpp | 17 +++++++++-------- src/libslic3r/TriangleMesh.cpp | 7 ++++++- src/libslic3r/TriangleMesh.hpp | 2 +- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index 6c04c7781aa..42c6fbf7549 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -1790,15 +1790,16 @@ std::vector PrintObject::_slice_volumes(const std::vector &z, if (! volumes.empty()) { // Compose mesh. //FIXME better to perform slicing over each volume separately and then to use a Boolean operation to merge them. - TriangleMesh mesh; - for (const ModelVolume *v : volumes) - { - TriangleMesh vol_mesh(v->mesh); - vol_mesh.transform(v->get_matrix()); + TriangleMesh mesh(volumes.front()->mesh); + mesh.transform(volumes.front()->get_matrix(), true); + for (size_t idx_volume = 1; idx_volume < volumes.size(); ++ idx_volume) { + const ModelVolume &model_volume = *volumes[idx_volume]; + TriangleMesh vol_mesh(model_volume.mesh); + vol_mesh.transform(model_volume.get_matrix(), true); mesh.merge(vol_mesh); } if (mesh.stl.stats.number_of_facets > 0) { - mesh.transform(m_trafo); + mesh.transform(m_trafo, true); // apply XY shift mesh.translate(- unscale(m_copies_shift(0)), - unscale(m_copies_shift(1)), 0); // perform actual slicing @@ -1819,9 +1820,9 @@ std::vector PrintObject::_slice_volume(const std::vector &z, // Compose mesh. //FIXME better to perform slicing over each volume separately and then to use a Boolean operation to merge them. TriangleMesh mesh(volume.mesh); - mesh.transform(volume.get_matrix()); + mesh.transform(volume.get_matrix(), true); if (mesh.stl.stats.number_of_facets > 0) { - mesh.transform(m_trafo); + mesh.transform(m_trafo, true); // apply XY shift mesh.translate(- unscale(m_copies_shift(0)), - unscale(m_copies_shift(1)), 0); // perform actual slicing diff --git a/src/libslic3r/TriangleMesh.cpp b/src/libslic3r/TriangleMesh.cpp index c145380c963..0d9a79978d4 100644 --- a/src/libslic3r/TriangleMesh.cpp +++ b/src/libslic3r/TriangleMesh.cpp @@ -314,10 +314,15 @@ void TriangleMesh::mirror(const Axis &axis) stl_invalidate_shared_vertices(&this->stl); } -void TriangleMesh::transform(const Transform3d& t) +void TriangleMesh::transform(const Transform3d& t, bool fix_left_handed) { stl_transform(&stl, t); stl_invalidate_shared_vertices(&stl); + if (fix_left_handed && t.matrix().block(0, 0, 3, 3).determinant() < 0.) { + // Left handed transformation is being applied. It is a good idea to flip the faces and their normals. + this->repair(); + stl_reverse_all_facets(&stl); + } } void TriangleMesh::align_to_origin() diff --git a/src/libslic3r/TriangleMesh.hpp b/src/libslic3r/TriangleMesh.hpp index a65a4be75bc..527846f9d9f 100644 --- a/src/libslic3r/TriangleMesh.hpp +++ b/src/libslic3r/TriangleMesh.hpp @@ -49,7 +49,7 @@ public: void mirror_x() { this->mirror(X); } void mirror_y() { this->mirror(Y); } void mirror_z() { this->mirror(Z); } - void transform(const Transform3d& t); + void transform(const Transform3d& t, bool fix_left_handed = false); void align_to_origin(); void rotate(double angle, Point* center); TriangleMeshPtrs split() const; From 4080c33570d26ab99ef582b9ab6cadb6fa685916 Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Wed, 3 Apr 2019 11:17:15 +0200 Subject: [PATCH 06/14] Call Line conversion operator explicitly. --- src/libslic3r/ClipperUtils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libslic3r/ClipperUtils.cpp b/src/libslic3r/ClipperUtils.cpp index 86b4ee4475b..4c6e542f4de 100644 --- a/src/libslic3r/ClipperUtils.cpp +++ b/src/libslic3r/ClipperUtils.cpp @@ -643,7 +643,7 @@ _clipper_ln(ClipperLib::ClipType clipType, const Lines &subject, const Polygons // convert Polylines to Lines Lines retval; for (Polylines::const_iterator polyline = polylines.begin(); polyline != polylines.end(); ++polyline) - retval.emplace_back(std::move(*polyline)); + retval.emplace_back(polyline->operator Line()); return retval; } From 3ebc21ebcd6872dd91e64bf53ebb75d1c472d3b3 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Wed, 3 Apr 2019 12:07:58 +0200 Subject: [PATCH 07/14] Fixed cutting of objects in left oriented coordinate space. Removed some spurious debugging printf. --- src/libslic3r/Model.cpp | 5 +++-- src/slic3r/GUI/GUI_ObjectList.cpp | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libslic3r/Model.cpp b/src/libslic3r/Model.cpp index b5b9a008d01..ba898d9d527 100644 --- a/src/libslic3r/Model.cpp +++ b/src/libslic3r/Model.cpp @@ -1187,8 +1187,9 @@ ModelObjectPtrs ModelObject::cut(size_t instance, coordf_t z, bool keep_upper, b else { TriangleMesh upper_mesh, lower_mesh; - // Transform the mesh by the combined transformation matrix - volume->mesh.transform(instance_matrix * volume_matrix); + // Transform the mesh by the combined transformation matrix. + // Flip the triangles in case the composite transformation is left handed. + volume->mesh.transform(instance_matrix * volume_matrix, true); // Perform cut TriangleMeshSlicer tms(&volume->mesh); diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp index 224bb802eb5..c0dcc659d96 100644 --- a/src/slic3r/GUI/GUI_ObjectList.cpp +++ b/src/slic3r/GUI/GUI_ObjectList.cpp @@ -507,7 +507,6 @@ void ObjectList::key_event(wxKeyEvent& event) || event.GetKeyCode() == WXK_BACK #endif //__WXOSX__ ) { - printf("WXK_BACK\n"); remove(); } else if (wxGetKeyState(wxKeyCode('A')) && wxGetKeyState(WXK_SHIFT)) From b65df6e5602474fbd33974d8a114554703ac021c Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Wed, 3 Apr 2019 12:45:06 +0200 Subject: [PATCH 08/14] Added call to schedule_background_process() when deleting modifier attribute --- src/slic3r/GUI/GUI_ObjectSettings.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/GUI_ObjectSettings.cpp b/src/slic3r/GUI/GUI_ObjectSettings.cpp index 4c0879ad3cf..cd995bc0942 100644 --- a/src/slic3r/GUI/GUI_ObjectSettings.cpp +++ b/src/slic3r/GUI/GUI_ObjectSettings.cpp @@ -85,7 +85,8 @@ void ObjectSettings::update_settings_list() #endif // __WXMSW__ btn->Bind(wxEVT_BUTTON, [opt_key, config, this](wxEvent &event) { config->erase(opt_key); - wxTheApp->CallAfter([this]() { + wxGetApp().obj_list()->part_settings_changed(); + wxTheApp->CallAfter([this]() { wxWindowUpdateLocker noUpdates(m_parent); update_settings_list(); m_parent->Layout(); From e44e8af02a8a8a921d91bb3de5d3353f5a8dd690 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Wed, 3 Apr 2019 14:44:15 +0200 Subject: [PATCH 09/14] SLA gizmo now allows to deselect a point --- src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp | 21 ++++++++++++++++++-- src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp | 1 + 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp index 5be7f9100a1..2264c541e8f 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp @@ -330,8 +330,12 @@ bool GLGizmoSlaSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mous m_canvas_width = m_parent.get_canvas_size().get_width(); m_canvas_height = m_parent.get_canvas_size().get_height(); } - else - select_point(m_hover_id); + else { + if (m_editing_mode_cache[m_hover_id].selected) + unselect_point(m_hover_id); + else + select_point(m_hover_id); + } return true; } @@ -791,6 +795,19 @@ void GLGizmoSlaSupports::select_point(int i) } +void GLGizmoSlaSupports::unselect_point(int i) +{ + m_editing_mode_cache[i].selected = false; + m_selection_empty = true; + for (const CacheEntry& ce : m_editing_mode_cache) { + if (ce.selected) { + m_selection_empty = false; + break; + } + } +} + + void GLGizmoSlaSupports::editing_mode_discard_changes() { diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp index 7e8113774bb..bb3cf06ce42 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp @@ -93,6 +93,7 @@ private: NoPoints, }; void select_point(int i); + void unselect_point(int i); void editing_mode_apply_changes(); void editing_mode_discard_changes(); void editing_mode_reload_cache(); From d226efefe26a75ddec6bda1181a2b594432fc1bf Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Wed, 3 Apr 2019 15:28:09 +0200 Subject: [PATCH 10/14] Keep instance mode selection when at least one instance is already selected --- src/slic3r/GUI/Selection.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/slic3r/GUI/Selection.cpp b/src/slic3r/GUI/Selection.cpp index 7103ca12dc6..ca245029c14 100644 --- a/src/slic3r/GUI/Selection.cpp +++ b/src/slic3r/GUI/Selection.cpp @@ -108,21 +108,26 @@ void Selection::add(unsigned int volume_idx, bool as_single_selection) if (is_wipe_tower() && volume->is_wipe_tower) return; + bool keep_instance_mode = (m_mode == Instance) && !as_single_selection && (is_single_full_instance() || is_multiple_full_instance()); + // resets the current list if needed bool needs_reset = as_single_selection; needs_reset |= volume->is_wipe_tower; needs_reset |= is_wipe_tower() && !volume->is_wipe_tower; - needs_reset |= !is_modifier() && volume->is_modifier; + needs_reset |= !keep_instance_mode && !is_modifier() && volume->is_modifier; needs_reset |= is_modifier() && !volume->is_modifier; if (needs_reset) clear(); if (!contains_volume(volume_idx)) - m_mode = volume->is_modifier ? Volume : Instance; + { + if (!keep_instance_mode) + m_mode = volume->is_modifier ? Volume : Instance; + } else - // keep current mode - return; + // keep current mode + return; switch (m_mode) { From 53e40cc0491118a235bc9ea71f0fac02f0551669 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Wed, 3 Apr 2019 16:31:40 +0200 Subject: [PATCH 11/14] imgui: Yet another font size fix --- src/slic3r/GUI/ImGuiWrapper.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/slic3r/GUI/ImGuiWrapper.cpp b/src/slic3r/GUI/ImGuiWrapper.cpp index 1b4d4edf9e2..8a6a71b1b92 100644 --- a/src/slic3r/GUI/ImGuiWrapper.cpp +++ b/src/slic3r/GUI/ImGuiWrapper.cpp @@ -340,13 +340,11 @@ bool ImGuiWrapper::want_any_input() const void ImGuiWrapper::init_font() { - const float font_size = m_font_size * m_style_scaling; - destroy_font(); ImGuiIO& io = ImGui::GetIO(); io.Fonts->Clear(); - ImFont* font = io.Fonts->AddFontFromFileTTF((Slic3r::resources_dir() + "/fonts/NotoSans-Regular.ttf").c_str(), font_size, nullptr, m_glyph_ranges); + ImFont* font = io.Fonts->AddFontFromFileTTF((Slic3r::resources_dir() + "/fonts/NotoSans-Regular.ttf").c_str(), m_font_size, nullptr, m_glyph_ranges); if (font == nullptr) { font = io.Fonts->AddFontDefault(); if (font == nullptr) { From 1c762dcd78f2b3c0bd7f2f62eedc4f29ef154b73 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Wed, 3 Apr 2019 16:39:28 +0200 Subject: [PATCH 12/14] imgui: Fix scaling --- src/slic3r/GUI/ImGuiWrapper.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/slic3r/GUI/ImGuiWrapper.hpp b/src/slic3r/GUI/ImGuiWrapper.hpp index c1bf491e140..b593054c4ab 100644 --- a/src/slic3r/GUI/ImGuiWrapper.hpp +++ b/src/slic3r/GUI/ImGuiWrapper.hpp @@ -45,8 +45,8 @@ public: void new_frame(); void render(); - float scaled(float x) const { return x * m_font_size * m_style_scaling; } - ImVec2 scaled(float x, float y) const { return ImVec2(x * m_font_size * m_style_scaling, y * m_font_size * m_style_scaling); } + float scaled(float x) const { return x * m_font_size; } + ImVec2 scaled(float x, float y) const { return ImVec2(x * m_font_size, y * m_font_size); } ImVec2 calc_text_size(const wxString &text); void set_next_window_pos(float x, float y, int flag); From af4c7a1d4542200a29a265cf679f87202f21a91d Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Thu, 4 Apr 2019 09:01:47 +0200 Subject: [PATCH 13/14] Keeps non selected instances as disabled for any combination of current instance's volumes selection --- src/slic3r/GUI/Selection.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/slic3r/GUI/Selection.cpp b/src/slic3r/GUI/Selection.cpp index ca245029c14..db25e6332fe 100644 --- a/src/slic3r/GUI/Selection.cpp +++ b/src/slic3r/GUI/Selection.cpp @@ -1147,16 +1147,12 @@ void Selection::_update_type() } if (modifiers_count == 0) - { m_type = MultipleVolume; - requires_disable = true; - } else if (modifiers_count == (unsigned int)m_list.size()) - { m_type = MultipleModifier; - requires_disable = true; - } } + + requires_disable = true; } else if ((selected_instances_count > 1) && (selected_instances_count * volumes_count == (unsigned int)m_list.size())) { From dcfc8bb47a7fe5393c913a607f1a6025055539a7 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Thu, 4 Apr 2019 09:02:53 +0200 Subject: [PATCH 14/14] First batch of SVG icons. Support for loading SVG icons into a BitmapCache. --- resources/icons/cog.svg | 17 ++++++++++++++ resources/icons/cooling.svg | 25 ++++++++++++++++++++ resources/icons/funnel.svg | 15 ++++++++++++ resources/icons/infill.svg | 33 +++++++++++++++++++++++++++ resources/icons/note.svg | 25 ++++++++++++++++++++ resources/icons/output+page_white.svg | 21 +++++++++++++++++ resources/icons/printer.svg | 14 ++++++++++++ resources/icons/skirt+brim.svg | 19 +++++++++++++++ resources/icons/spool.svg | 21 +++++++++++++++++ resources/icons/support.svg | 25 ++++++++++++++++++++ resources/icons/time.svg | 16 +++++++++++++ resources/icons/wrench.svg | 24 +++++++++++++++++++ 12 files changed, 255 insertions(+) create mode 100644 resources/icons/cog.svg create mode 100644 resources/icons/cooling.svg create mode 100644 resources/icons/funnel.svg create mode 100644 resources/icons/infill.svg create mode 100644 resources/icons/note.svg create mode 100644 resources/icons/output+page_white.svg create mode 100644 resources/icons/printer.svg create mode 100644 resources/icons/skirt+brim.svg create mode 100644 resources/icons/spool.svg create mode 100644 resources/icons/support.svg create mode 100644 resources/icons/time.svg create mode 100644 resources/icons/wrench.svg diff --git a/resources/icons/cog.svg b/resources/icons/cog.svg new file mode 100644 index 00000000000..07adb66101e --- /dev/null +++ b/resources/icons/cog.svg @@ -0,0 +1,17 @@ + + + + + + + + diff --git a/resources/icons/cooling.svg b/resources/icons/cooling.svg new file mode 100644 index 00000000000..b5d80e434a2 --- /dev/null +++ b/resources/icons/cooling.svg @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + diff --git a/resources/icons/funnel.svg b/resources/icons/funnel.svg new file mode 100644 index 00000000000..8877722e333 --- /dev/null +++ b/resources/icons/funnel.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + diff --git a/resources/icons/infill.svg b/resources/icons/infill.svg new file mode 100644 index 00000000000..fcb1f99c9ed --- /dev/null +++ b/resources/icons/infill.svg @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/icons/note.svg b/resources/icons/note.svg new file mode 100644 index 00000000000..c1421420109 --- /dev/null +++ b/resources/icons/note.svg @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/icons/output+page_white.svg b/resources/icons/output+page_white.svg new file mode 100644 index 00000000000..ec1518f2525 --- /dev/null +++ b/resources/icons/output+page_white.svg @@ -0,0 +1,21 @@ + + + + + + + + + + + + + diff --git a/resources/icons/printer.svg b/resources/icons/printer.svg new file mode 100644 index 00000000000..91e103ec704 --- /dev/null +++ b/resources/icons/printer.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + diff --git a/resources/icons/skirt+brim.svg b/resources/icons/skirt+brim.svg new file mode 100644 index 00000000000..9242761b61a --- /dev/null +++ b/resources/icons/skirt+brim.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + diff --git a/resources/icons/spool.svg b/resources/icons/spool.svg new file mode 100644 index 00000000000..84036593818 --- /dev/null +++ b/resources/icons/spool.svg @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/resources/icons/support.svg b/resources/icons/support.svg new file mode 100644 index 00000000000..65c7592c835 --- /dev/null +++ b/resources/icons/support.svg @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/icons/time.svg b/resources/icons/time.svg new file mode 100644 index 00000000000..5d8f23cfc38 --- /dev/null +++ b/resources/icons/time.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + diff --git a/resources/icons/wrench.svg b/resources/icons/wrench.svg new file mode 100644 index 00000000000..7966da8d8f6 --- /dev/null +++ b/resources/icons/wrench.svg @@ -0,0 +1,24 @@ + + + + + + + + + + + +