diff --git a/src/libslic3r/CustomGCode.cpp b/src/libslic3r/CustomGCode.cpp index 7c505c978..824bcdd93 100644 --- a/src/libslic3r/CustomGCode.cpp +++ b/src/libslic3r/CustomGCode.cpp @@ -62,7 +62,8 @@ std::vector<std::pair<double, unsigned int>> custom_tool_changes(const Info& cus for (const Item& custom_gcode : custom_gcode_per_print_z.gcodes) if (custom_gcode.gcode == ToolChangeCode) { // If extruder count in PrinterSettings was changed, use default (0) extruder for extruders, more than num_extruders - custom_tool_changes.emplace_back(custom_gcode.print_z, static_cast<unsigned int>(custom_gcode.extruder > num_extruders ? 1 : custom_gcode.extruder)); + assert(custom_gcode.extruder >= 0); + custom_tool_changes.emplace_back(custom_gcode.print_z, static_cast<unsigned int>(size_t(custom_gcode.extruder) > num_extruders ? 1 : custom_gcode.extruder)); } return custom_tool_changes; } diff --git a/src/libslic3r/EdgeGrid.cpp b/src/libslic3r/EdgeGrid.cpp index 065a69ba3..240951053 100644 --- a/src/libslic3r/EdgeGrid.cpp +++ b/src/libslic3r/EdgeGrid.cpp @@ -1147,7 +1147,7 @@ EdgeGrid::Grid::ClosestPointResult EdgeGrid::Grid::closest_point(const Point &pt } } } - if (result.contour_idx != -1 && d_min <= double(search_radius)) { + if (result.contour_idx != size_t(-1) && d_min <= double(search_radius)) { result.distance = d_min * sign_min; result.t /= l2_seg_min; assert(result.t >= 0. && result.t < 1.); diff --git a/src/libslic3r/Fill/FillBase.cpp b/src/libslic3r/Fill/FillBase.cpp index 39679e3d6..3b200769c 100644 --- a/src/libslic3r/Fill/FillBase.cpp +++ b/src/libslic3r/Fill/FillBase.cpp @@ -611,7 +611,7 @@ static inline SegmentPoint clip_start_segment_and_point(const Points &polyline, SegmentPoint out; if (polyline.size() >= 2) { Vec2d pt_prev = polyline.front().cast<double>(); - for (int i = 1; i < polyline.size(); ++ i) { + for (size_t i = 1; i < polyline.size(); ++ i) { Vec2d pt = polyline[i].cast<double>(); Vec2d v = pt - pt_prev; double l2 = v.squaredNorm(); @@ -674,7 +674,7 @@ static inline double segment_point_distance_squared(const Vec2d &p1a, const Vec2 if (l2 < EPSILON) // p1a == p1b return (p2 - p1a).squaredNorm(); - return segment_point_distance_squared(p1a, p1b, v, v.squaredNorm(), p2); + return segment_point_distance_squared(p1a, p1b, v, v.squaredNorm(), p2); } // Distance to the closest point of line. @@ -692,7 +692,7 @@ static inline double min_distance_of_segments(const Vec2d &p1a, const Vec2d &p1b // p2a == p2b: Return distance of p2a from the (p1a, p1b) segment. return segment_point_distance_squared(p1a, p1b, v1, l1_2, p2a); - return std::min( + return std::min( std::min(segment_point_distance_squared(p1a, p1b, v1, l1_2, p2a), segment_point_distance_squared(p1a, p1b, v1, l1_2, p2b)), std::min(segment_point_distance_squared(p2a, p2b, v2, l2_2, p1a), segment_point_distance_squared(p2a, p2b, v2, l2_2, p1b))); } diff --git a/src/libslic3r/Fill/FillGyroid.cpp b/src/libslic3r/Fill/FillGyroid.cpp index 913b0b0c0..964b87cef 100644 --- a/src/libslic3r/Fill/FillGyroid.cpp +++ b/src/libslic3r/Fill/FillGyroid.cpp @@ -156,7 +156,7 @@ void FillGyroid::_fill_surface_single( Polylines &polylines_out) { float infill_angle = this->angle + (CorrectionAngle * 2*M_PI) / 360.; - if(abs(infill_angle) >= EPSILON) + if(std::abs(infill_angle) >= EPSILON) expolygon.rotate(-infill_angle); BoundingBox bb = expolygon.contour.bounding_box(); @@ -197,8 +197,9 @@ void FillGyroid::_fill_surface_single( append(polylines_out, std::move(polylines)); else this->connect_infill(std::move(polylines), expolygon, polylines_out, this->spacing, params); + // new paths must be rotated back - if (abs(infill_angle) >= EPSILON) { + if (std::abs(infill_angle) >= EPSILON) { for (auto it = polylines_out.begin() + polylines_out_first_idx; it != polylines_out.end(); ++ it) it->rotate(infill_angle); } diff --git a/src/libslic3r/Format/3mf.cpp b/src/libslic3r/Format/3mf.cpp index efeb23700..462dcf27b 100644 --- a/src/libslic3r/Format/3mf.cpp +++ b/src/libslic3r/Format/3mf.cpp @@ -1722,7 +1722,7 @@ namespace Slic3r { } // Added because of github #3435, currently not used by PrusaSlicer - int instances_count_id = get_attribute_value_int(attributes, num_attributes, INSTANCESCOUNT_ATTR); + // int instances_count_id = get_attribute_value_int(attributes, num_attributes, INSTANCESCOUNT_ATTR); m_objects_metadata.insert(IdToMetadataMap::value_type(object_id, ObjectMetadata())); m_curr_config.object_id = object_id; diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 899b35cc3..49a49a85e 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -1749,7 +1749,6 @@ std::vector<GCode::InstanceToPrint> GCode::sort_print_object_instances( std::sort(sorted.begin(), sorted.end()); if (! sorted.empty()) { - const Print &print = *sorted.front().first->print(); out.reserve(sorted.size()); for (const PrintInstance *instance : *ordering) { const PrintObject &print_object = *instance->print_object; @@ -1795,13 +1794,14 @@ namespace ProcessLayer // we should add or not colorprint_change in respect to nozzle_diameter count instead of really used extruders count if (color_change || tool_change) { + assert(m600_extruder_before_layer >= 0); // Color Change or Tool Change as Color Change. // add tag for analyzer gcode += "; " + GCodeAnalyzer::Color_Change_Tag + ",T" + std::to_string(m600_extruder_before_layer) + "\n"; // add tag for time estimator gcode += "; " + GCodeTimeEstimator::Color_Change_Tag + "\n"; - if (!single_extruder_printer && m600_extruder_before_layer >= 0 && first_extruder_id != m600_extruder_before_layer + if (!single_extruder_printer && m600_extruder_before_layer >= 0 && first_extruder_id != (unsigned)m600_extruder_before_layer // && !MMU1 ) { //! FIXME_in_fw show message during print pause diff --git a/src/libslic3r/GCode/Analyzer.cpp b/src/libslic3r/GCode/Analyzer.cpp index ec5de71b1..4098e66ef 100644 --- a/src/libslic3r/GCode/Analyzer.cpp +++ b/src/libslic3r/GCode/Analyzer.cpp @@ -644,7 +644,7 @@ bool GCodeAnalyzer::_process_tags(const GCodeReader::GCodeLine& line) if (pos != comment.npos) { pos = comment.find_last_of(",T"); - int extruder = pos == comment.npos ? 0 : std::atoi(comment.substr(pos + 1, comment.npos).c_str()); + unsigned extruder = pos == comment.npos ? 0 : std::stoi(comment.substr(pos + 1, comment.npos)); _process_color_change_tag(extruder); return true; } @@ -702,7 +702,7 @@ void GCodeAnalyzer::_process_height_tag(const std::string& comment, size_t pos) _set_height((float)::strtod(comment.substr(pos + Height_Tag.length()).c_str(), nullptr)); } -void GCodeAnalyzer::_process_color_change_tag(int extruder) +void GCodeAnalyzer::_process_color_change_tag(unsigned extruder) { m_extruder_color[extruder] = m_extruders_count + m_state.cp_color_counter; // color_change position in list of color for preview m_state.cp_color_counter++; diff --git a/src/libslic3r/GCode/Analyzer.hpp b/src/libslic3r/GCode/Analyzer.hpp index 781c3f265..cd5654a74 100644 --- a/src/libslic3r/GCode/Analyzer.hpp +++ b/src/libslic3r/GCode/Analyzer.hpp @@ -220,7 +220,7 @@ private: void _process_height_tag(const std::string& comment, size_t pos); // Processes color change tag - void _process_color_change_tag(int extruder); + void _process_color_change_tag(unsigned extruder); // Processes pause print and custom gcode tag void _process_pause_print_or_custom_code_tag(); diff --git a/src/libslic3r/GCode/ToolOrdering.hpp b/src/libslic3r/GCode/ToolOrdering.hpp index de0460f1b..1281d1493 100644 --- a/src/libslic3r/GCode/ToolOrdering.hpp +++ b/src/libslic3r/GCode/ToolOrdering.hpp @@ -72,7 +72,7 @@ private: std::map<const ExtrusionEntity*, ExtruderPerCopy> entity_map; // to keep track of who prints what bool something_overridable = false; bool something_overridden = false; - const LayerTools* m_layer_tools; // so we know which LayerTools object this belongs to + const LayerTools* m_layer_tools = nullptr; // so we know which LayerTools object this belongs to }; diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index b4a2a1b3e..5cdcbd2f8 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -1936,7 +1936,7 @@ void Print::_make_brim() // Find all pieces that the initial loop was split into. size_t j = i + 1; for (; j < loops_trimmed_order.size() && loops_trimmed_order[i].second == loops_trimmed_order[j].second; ++ j) ; - const ClipperLib_Z::Path &first_path = *loops_trimmed_order[i].first; + const ClipperLib_Z::Path &first_path = *loops_trimmed_order[i].first; if (i + 1 == j && first_path.size() > 3 && first_path.front().X == first_path.back().X && first_path.front().Y == first_path.back().Y) { auto *loop = new ExtrusionLoop(); m_brim.entities.emplace_back(loop); diff --git a/src/libslic3r/SLA/EigenMesh3D.hpp b/src/libslic3r/SLA/EigenMesh3D.hpp index e8b869bb4..bcf94ec16 100644 --- a/src/libslic3r/SLA/EigenMesh3D.hpp +++ b/src/libslic3r/SLA/EigenMesh3D.hpp @@ -101,6 +101,9 @@ public: // Iterates over hits and holes and returns the true hit, possibly // on the inside of a hole. + // This function is currently not used anywhere, it was written when the + // holes were subtracted on slices, that is, before we started using CGAL + // to actually cut the holes into the mesh. hit_result filter_hits(const std::vector<EigenMesh3D::hit_result>& obj_hits) const; class si_result { diff --git a/src/slic3r/Config/Snapshot.cpp b/src/slic3r/Config/Snapshot.cpp index fa756f49d..2264afa7d 100644 --- a/src/slic3r/Config/Snapshot.cpp +++ b/src/slic3r/Config/Snapshot.cpp @@ -5,11 +5,12 @@ #include <time.h> #include <boost/algorithm/string/predicate.hpp> -#include <boost/algorithm/string/trim.hpp> #include <boost/nowide/cstdio.hpp> #include <boost/nowide/fstream.hpp> #include <boost/property_tree/ini_parser.hpp> -#include <boost/property_tree/ptree.hpp> +#include <boost/property_tree/ptree_fwd.hpp> +#include <boost/filesystem/operations.hpp> + #include "libslic3r/libslic3r.h" #include "libslic3r/Time.hpp" diff --git a/src/slic3r/Config/Snapshot.hpp b/src/slic3r/Config/Snapshot.hpp index 9a7391691..c6bd5c6e8 100644 --- a/src/slic3r/Config/Snapshot.hpp +++ b/src/slic3r/Config/Snapshot.hpp @@ -6,7 +6,7 @@ #include <string> #include <vector> -#include <boost/filesystem.hpp> +#include <boost/filesystem/path.hpp> #include "libslic3r/Semver.hpp" #include "Version.hpp" @@ -18,7 +18,6 @@ class AppConfig; namespace GUI { namespace Config { -class Index; // A snapshot contains: // Slic3r.ini diff --git a/src/slic3r/Config/Version.cpp b/src/slic3r/Config/Version.cpp index 2d036e9f3..d00e4a2ab 100644 --- a/src/slic3r/Config/Version.cpp +++ b/src/slic3r/Config/Version.cpp @@ -2,8 +2,7 @@ #include <cctype> -#include <boost/algorithm/string/predicate.hpp> -#include <boost/algorithm/string/trim.hpp> +#include <boost/filesystem/operations.hpp> #include <boost/nowide/fstream.hpp> #include "libslic3r/libslic3r.h" diff --git a/src/slic3r/Config/Version.hpp b/src/slic3r/Config/Version.hpp index 881b856ff..8249573de 100644 --- a/src/slic3r/Config/Version.hpp +++ b/src/slic3r/Config/Version.hpp @@ -4,7 +4,7 @@ #include <string> #include <vector> -#include <boost/filesystem.hpp> +#include <boost/filesystem/path.hpp> #include "libslic3r/FileParserError.hpp" #include "libslic3r/Semver.hpp" @@ -54,7 +54,7 @@ struct Version class Index { public: - typedef std::vector<Version>::const_iterator const_iterator; + typedef std::vector<Version>::const_iterator const_iterator; // Read a config index file in the simple format described in the Index class comment. // Throws Slic3r::file_parser_error and the standard std file access exceptions. size_t load(const boost::filesystem::path &path); diff --git a/src/slic3r/GUI/2DBed.cpp b/src/slic3r/GUI/2DBed.cpp index d2075f673..debd104ef 100644 --- a/src/slic3r/GUI/2DBed.cpp +++ b/src/slic3r/GUI/2DBed.cpp @@ -166,4 +166,4 @@ void Bed_2D::set_pos(const Vec2d& pos) } } // GUI -} // Slic3r \ No newline at end of file +} // Slic3r diff --git a/src/slic3r/GUI/3DBed.cpp b/src/slic3r/GUI/3DBed.cpp index 23acd18ef..742941b84 100644 --- a/src/slic3r/GUI/3DBed.cpp +++ b/src/slic3r/GUI/3DBed.cpp @@ -8,7 +8,6 @@ #include "GUI_App.hpp" #include "PresetBundle.hpp" -#include "Gizmos/GLGizmoBase.hpp" #include "GLCanvas3D.hpp" #include <GL/glew.h> @@ -630,4 +629,4 @@ void Bed3D::reset() } } // GUI -} // Slic3r \ No newline at end of file +} // Slic3r diff --git a/src/slic3r/GUI/3DScene.cpp b/src/slic3r/GUI/3DScene.cpp index 9f36ab537..de56546ac 100644 --- a/src/slic3r/GUI/3DScene.cpp +++ b/src/slic3r/GUI/3DScene.cpp @@ -17,23 +17,17 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <utility> #include <assert.h> #include <boost/log/trivial.hpp> #include <boost/filesystem/operations.hpp> -#include <boost/algorithm/string.hpp> +#include <boost/algorithm/string/predicate.hpp> #include <boost/nowide/cstdio.hpp> -#include <tbb/parallel_for.h> -#include <tbb/spin_mutex.h> - #include <Eigen/Dense> -#include "GUI.hpp" - #ifdef HAS_GLSAFE void glAssertRecentCallImpl(const char *file_name, unsigned int line, const char *function_name) { diff --git a/src/slic3r/GUI/3DScene.hpp b/src/slic3r/GUI/3DScene.hpp index aed907004..1fc8308f7 100644 --- a/src/slic3r/GUI/3DScene.hpp +++ b/src/slic3r/GUI/3DScene.hpp @@ -10,7 +10,6 @@ #include "slic3r/GUI/GLCanvas3DManager.hpp" #include <functional> -#include <memory> #ifndef NDEBUG #define HAS_GLSAFE @@ -34,13 +33,8 @@ struct Camera; class GLToolbar; } // namespace GUI -class Print; -class PrintObject; -class SLAPrint; class SLAPrintObject; enum SLAPrintObjectStep : unsigned int; -class Model; -class ModelObject; class DynamicPrintConfig; class ExtrusionPath; class ExtrusionMultiPath; diff --git a/src/slic3r/GUI/AboutDialog.cpp b/src/slic3r/GUI/AboutDialog.cpp index 30892d9c9..3273db514 100644 --- a/src/slic3r/GUI/AboutDialog.cpp +++ b/src/slic3r/GUI/AboutDialog.cpp @@ -2,8 +2,9 @@ #include "I18N.hpp" #include "libslic3r/Utils.hpp" +#include "GUI.hpp" #include "GUI_App.hpp" -#include "wxExtensions.hpp" + namespace Slic3r { namespace GUI { diff --git a/src/slic3r/GUI/AboutDialog.hpp b/src/slic3r/GUI/AboutDialog.hpp index 5fec21495..f1e26fde4 100644 --- a/src/slic3r/GUI/AboutDialog.hpp +++ b/src/slic3r/GUI/AboutDialog.hpp @@ -1,8 +1,6 @@ #ifndef slic3r_GUI_AboutDialog_hpp_ #define slic3r_GUI_AboutDialog_hpp_ -#include "GUI.hpp" - #include <wx/wx.h> #include <wx/intl.h> #include <wx/html/htmlwin.h> diff --git a/src/slic3r/GUI/AppConfig.cpp b/src/slic3r/GUI/AppConfig.cpp index 35799e046..90bf337cf 100644 --- a/src/slic3r/GUI/AppConfig.cpp +++ b/src/slic3r/GUI/AppConfig.cpp @@ -2,22 +2,18 @@ #include "libslic3r/Utils.hpp" #include "AppConfig.hpp" -#include <stdio.h> -#include <stdlib.h> -#include <string.h> #include <utility> -#include <assert.h> #include <vector> #include <stdexcept> -#include <boost/filesystem.hpp> +#include <boost/filesystem/path.hpp> +#include <boost/filesystem/operations.hpp> #include <boost/nowide/cenv.hpp> #include <boost/nowide/fstream.hpp> #include <boost/property_tree/ini_parser.hpp> -#include <boost/property_tree/ptree.hpp> -#include <boost/property_tree/exceptions.hpp> +#include <boost/property_tree/ptree_fwd.hpp> #include <boost/algorithm/string/predicate.hpp> -#include <boost/format.hpp> +#include <boost/format/format_fwd.hpp> #include <wx/string.h> #include "I18N.hpp" @@ -76,7 +72,7 @@ void AppConfig::set_defaults() if (get("remember_output_path").empty()) set("remember_output_path", "1"); - if (get("remember_output_path_removable").empty()) + if (get("remember_output_path_removable").empty()) set("remember_output_path_removable", "1"); if (get("use_custom_toolbar_size").empty()) diff --git a/src/slic3r/GUI/BackgroundSlicingProcess.cpp b/src/slic3r/GUI/BackgroundSlicingProcess.cpp index f22d54e2b..0cd710b83 100644 --- a/src/slic3r/GUI/BackgroundSlicingProcess.cpp +++ b/src/slic3r/GUI/BackgroundSlicingProcess.cpp @@ -25,17 +25,16 @@ #include <cassert> #include <stdexcept> #include <cctype> -#include <algorithm> -#include <boost/format.hpp> -#include <boost/filesystem/path.hpp> -#include <boost/filesystem.hpp> +#include <boost/format/format_fwd.hpp> +#include <boost/filesystem/operations.hpp> #include <boost/log/trivial.hpp> #include <boost/nowide/cstdio.hpp> #include "I18N.hpp" -#include "GUI.hpp" #include "RemovableDriveManager.hpp" +#include "slic3r/Utils/Thread.hpp" + namespace Slic3r { BackgroundSlicingProcess::BackgroundSlicingProcess() diff --git a/src/slic3r/GUI/BackgroundSlicingProcess.hpp b/src/slic3r/GUI/BackgroundSlicingProcess.hpp index c8ece38f0..6373bad7e 100644 --- a/src/slic3r/GUI/BackgroundSlicingProcess.hpp +++ b/src/slic3r/GUI/BackgroundSlicingProcess.hpp @@ -5,13 +5,13 @@ #include <condition_variable> #include <mutex> -#include <boost/filesystem.hpp> +#include <boost/filesystem/path.hpp> #include <wx/event.h> #include "libslic3r/Print.hpp" #include "slic3r/Utils/PrintHost.hpp" -#include "slic3r/Utils/Thread.hpp" + namespace Slic3r { diff --git a/src/slic3r/GUI/ConfigWizard.cpp b/src/slic3r/GUI/ConfigWizard.cpp index 0e034b33b..1f35d941d 100644 --- a/src/slic3r/GUI/ConfigWizard.cpp +++ b/src/slic3r/GUI/ConfigWizard.cpp @@ -1726,7 +1726,7 @@ bool ConfigWizard::priv::on_bnt_finish() page_sla_materials->reload_presets(); // theres no need to check that filament is selected if we have only custom printer - if (custom_printer_selected && !any_fff_selected && !any_sla_selected) return true; + if (custom_printer_selected && !any_fff_selected && !any_sla_selected) return true; // check, that there is selected at least one filament/material return check_materials_in_config(T_ANY); } diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index 3fc43b726..b6f8be499 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -511,7 +511,7 @@ void TextCtrl::disable() { dynamic_cast<wxTextCtrl*>(window)->Disable(); dynamic #ifdef __WXGTK__ void TextCtrl::change_field_value(wxEvent& event) { - if (bChangedValueEvent = (event.GetEventType()==wxEVT_KEY_UP)) + if ((bChangedValueEvent = (event.GetEventType()==wxEVT_KEY_UP))) on_change_field(); event.Skip(); }; diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index a6eee73e8..d3b83057e 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -22,6 +22,8 @@ #include "slic3r/GUI/PresetBundle.hpp" #include "slic3r/GUI/Tab.hpp" #include "slic3r/GUI/GUI_Preview.hpp" +#include "slic3r/GUI/3DBed.hpp" +#include "slic3r/GUI/Camera.hpp" #include "GUI_App.hpp" #include "GUI_ObjectList.hpp" @@ -1296,7 +1298,7 @@ void GLCanvas3D::Labels::render(const std::vector<const ModelInstance*>& sorted_ // updates print order strings if (sorted_instances.size() > 1) { - for (int i = 0; i < sorted_instances.size(); ++i) { + for (size_t i = 0; i < sorted_instances.size(); ++i) { size_t id = sorted_instances[i]->id().id; std::vector<Owner>::iterator it = std::find_if(owners.begin(), owners.end(), [id](const Owner& owner) { return owner.model_instance_id == id; @@ -3978,6 +3980,13 @@ Linef3 GLCanvas3D::mouse_ray(const Point& mouse_pos) return Linef3(_mouse_to_3d(mouse_pos, &z0), _mouse_to_3d(mouse_pos, &z1)); } + +void GLCanvas3D::refresh_camera_scene_box() +{ + m_camera.set_scene_box(scene_bounding_box()); +} + + double GLCanvas3D::get_size_proportional_to_max_bed_size(double factor) const { return factor * m_bed.get_bounding_box(false).max_size(); diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index 9ae127880..2e84782aa 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -6,19 +6,18 @@ #include "3DScene.hpp" #include "GLToolbar.hpp" +#include "GLShader.hpp" #include "Event.hpp" -#include "3DBed.hpp" -#include "Camera.hpp" #include "Selection.hpp" #include "Gizmos/GLGizmosManager.hpp" #include "GUI_ObjectLayers.hpp" +#include "GLSelectionRectangle.hpp" #include "MeshUtils.hpp" #include <float.h> #include <wx/timer.h> -class wxWindow; class wxSizeEvent; class wxIdleEvent; class wxKeyEvent; @@ -32,8 +31,8 @@ class wxGLCanvas; namespace Slic3r { -class GLShader; -class ExPolygon; +class Bed3D; +struct Camera; class BackgroundSlicingProcess; class GCodePreviewData; #if ENABLE_THUMBNAIL_GENERATOR @@ -44,8 +43,6 @@ enum LayerHeightEditActionType : unsigned int; namespace GUI { -class GLGizmoBase; - #if ENABLE_RETINA_GL class RetinaHelper; #endif @@ -646,7 +643,7 @@ public: Linef3 mouse_ray(const Point& mouse_pos); void set_mouse_as_dragging() { m_mouse.dragging = true; } - void refresh_camera_scene_box() { m_camera.set_scene_box(scene_bounding_box()); } + void refresh_camera_scene_box(); bool is_mouse_dragging() const { return m_mouse.dragging; } double get_size_proportional_to_max_bed_size(double factor) const; diff --git a/src/slic3r/GUI/GLToolbar.cpp b/src/slic3r/GUI/GLToolbar.cpp index 61dba1c19..079e69b21 100644 --- a/src/slic3r/GUI/GLToolbar.cpp +++ b/src/slic3r/GUI/GLToolbar.cpp @@ -4,8 +4,7 @@ #include "GLToolbar.hpp" #include "../../slic3r/GUI/GLCanvas3D.hpp" - -#include <GL/glew.h> +#include "../../slic3r/GUI/Camera.hpp" #include <wx/event.h> #include <wx/bitmap.h> diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp index 961fc2077..afcf62ae1 100644 --- a/src/slic3r/GUI/GUI_ObjectList.cpp +++ b/src/slic3r/GUI/GUI_ObjectList.cpp @@ -479,7 +479,6 @@ void ObjectList::update_extruder_values_for_items(const size_t max_extruder) void ObjectList::update_objects_list_extruder_column(size_t extruders_count) { - if (!this) return; // #ys_FIXME if (printer_technology() == ptSLA) extruders_count = 1; @@ -1544,7 +1543,7 @@ wxMenuItem* ObjectList::append_menu_item_settings(wxMenu* menu_) // If there are selected more then one instance but not all of them // don't add settings menu items const Selection& selection = scene_selection(); - if (selection.is_multiple_full_instance() && !selection.is_single_full_object() || + if ((selection.is_multiple_full_instance() && !selection.is_single_full_object()) || selection.is_multiple_volume() || selection.is_mixed() ) // more than one volume(part) is selected on the scene return nullptr; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp b/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp index f33a7bd8b..0a3a6f898 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp @@ -1,5 +1,6 @@ #include "GLGizmoHollow.hpp" #include "slic3r/GUI/GLCanvas3D.hpp" +#include "slic3r/GUI/Camera.hpp" #include "slic3r/GUI/Gizmos/GLGizmos.hpp" #include <GL/glew.h> @@ -99,16 +100,11 @@ void GLGizmoHollow::on_render() const return; } - // !!! is it necessary? - //const_cast<GLGizmoHollow*>(this)->m_c->update_from_backend(m_parent, m_c->m_model_object); - glsafe(::glEnable(GL_BLEND)); glsafe(::glEnable(GL_DEPTH_TEST)); m_z_shift = selection.get_volume(*selection.get_volume_idxs().begin())->get_sla_shift_z(); - render_hollowed_mesh(); - if (m_quadric != nullptr && selection.is_from_single_instance()) render_points(selection, false); @@ -120,28 +116,6 @@ void GLGizmoHollow::on_render() const -void GLGizmoHollow::render_hollowed_mesh() const -{ - /*if (m_c->m_volume_with_cavity) { - m_c->m_volume_with_cavity->set_sla_shift_z(m_z_shift); - m_parent.get_shader().start_using(); - - GLint current_program_id; - glsafe(::glGetIntegerv(GL_CURRENT_PROGRAM, ¤t_program_id)); - GLint color_id = (current_program_id > 0) ? ::glGetUniformLocation(current_program_id, "uniform_color") : -1; - GLint print_box_detection_id = (current_program_id > 0) ? ::glGetUniformLocation(current_program_id, "print_box.volume_detection") : -1; - GLint print_box_worldmatrix_id = (current_program_id > 0) ? ::glGetUniformLocation(current_program_id, "print_box.volume_world_matrix") : -1; - glcheck(); - m_c->m_volume_with_cavity->set_render_color(); - const Geometry::Transformation& volume_trafo = m_c->m_model_object->volumes.front()->get_transformation(); - m_c->m_volume_with_cavity->set_volume_transformation(volume_trafo); - m_c->m_volume_with_cavity->set_instance_transformation(m_c->m_model_object->instances[size_t(m_c->m_active_instance)]->get_transformation()); - m_c->m_volume_with_cavity->render(color_id, print_box_detection_id, print_box_worldmatrix_id); - m_parent.get_shader().stop_using(); - }*/ -} - - void GLGizmoHollow::render_clipping_plane(const Selection& selection) const { if (m_c->m_clipping_plane_distance == 0.f) @@ -169,11 +143,6 @@ void GLGizmoHollow::render_clipping_plane(const Selection& selection) const m_c->m_object_clipper->set_plane(*m_c->m_clipping_plane); m_c->m_object_clipper->set_transformation(trafo); - - // Next, ask the backend if supports are already calculated. If so, we are gonna cut them too. - //if (m_c->m_print_object_idx < 0) - // m_c->update_from_backend(m_parent, m_c->m_model_object); - if (m_c->m_print_object_idx >= 0) { const SLAPrintObject* print_object = m_parent.sla_print()->objects()[m_c->m_print_object_idx]; @@ -229,7 +198,6 @@ void GLGizmoHollow::on_render_for_picking() const glsafe(::glEnable(GL_DEPTH_TEST)); render_points(selection, true); - render_hollowed_mesh(); } void GLGizmoHollow::render_points(const Selection& selection, bool picking) const @@ -343,10 +311,6 @@ bool GLGizmoHollow::unproject_on_mesh(const Vec2d& mouse_pos, std::pair<Vec3f, V if (! m_c->m_mesh_raycaster) return false; - // if the gizmo doesn't have the V, F structures for igl, calculate them first: - // !!! is it really necessary? - //m_c->update_from_backend(m_parent, m_c->m_model_object); - const Camera& camera = m_parent.get_camera(); const Selection& selection = m_parent.get_selection(); const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin()); @@ -561,87 +525,15 @@ void GLGizmoHollow::on_update(const UpdateData& data) } } -std::pair<const TriangleMesh *, sla::HollowingConfig> GLGizmoHollow::get_hollowing_parameters() const -{ - // FIXME this function is probably obsolete, caller could - // get the data from model config himself - auto opts = get_config_options({"hollowing_min_thickness", "hollowing_quality", "hollowing_closing_distance"}); - double offset = static_cast<const ConfigOptionFloat*>(opts[0].first)->value; - double quality = static_cast<const ConfigOptionFloat*>(opts[1].first)->value; - double closing_d = static_cast<const ConfigOptionFloat*>(opts[2].first)->value; - return std::make_pair(m_c->m_mesh, sla::HollowingConfig{offset, quality, closing_d}); -} - -void GLGizmoHollow::update_mesh_raycaster(std::unique_ptr<MeshRaycaster> &&rc) -{ - m_c->m_mesh_raycaster = std::move(rc); - m_c->m_object_clipper.reset(); - //m_c->m_volume_with_cavity.reset(); -} void GLGizmoHollow::hollow_mesh(bool postpone_error_messages) { - // Trigger a UI job to hollow the mesh. - // wxGetApp().plater()->hollow(); - wxGetApp().CallAfter([this, postpone_error_messages]() { wxGetApp().plater()->reslice_SLA_hollowing(*m_c->m_model_object, postpone_error_messages); }); } -void GLGizmoHollow::update_hollowed_mesh(std::unique_ptr<TriangleMesh> &&mesh) -{ - // Called from Plater when the UI job finishes - /*m_c->m_cavity_mesh = std::move(mesh); - - if(m_c->m_cavity_mesh) { - // First subtract the holes: - if (! m_c->m_model_object->sla_drain_holes.empty()) { - TriangleMesh holes_mesh; - for (const sla::DrainHole& hole : m_c->m_model_object->sla_drain_holes) { - TriangleMesh hole_mesh = make_cylinder(hole.radius, hole.height, 2*M_PI/32); - - Vec3d scaling = m_c->m_model_object->instances[m_c->m_active_instance]->get_scaling_factor(); - Vec3d normal_transformed = Vec3d(hole.normal(0)/scaling(0), hole.normal(1)/scaling(1), hole.normal(2)/scaling(2)); - normal_transformed.normalize(); - - // Rotate the cylinder appropriately - Eigen::Quaterniond q; - Transform3d m = Transform3d::Identity(); - m.matrix().block(0, 0, 3, 3) = q.setFromTwoVectors(Vec3d::UnitZ(), normal_transformed).toRotationMatrix(); - hole_mesh.transform(m); - - // If the instance is scaled, undo the scaling of the hole - hole_mesh.scale(Vec3d(1/scaling(0), 1/scaling(1), 1/scaling(2))); - - // Translate the hole into position and merge with the others - hole_mesh.translate(hole.pos); - holes_mesh.merge(hole_mesh); - holes_mesh.repair(); - } - MeshBoolean::minus(*m_c->m_cavity_mesh.get(), holes_mesh); - } - - // create a new GLVolume that only has the cavity inside - m_c->m_volume_with_cavity.reset(new GLVolume(GLVolume::MODEL_COLOR[2])); - m_c->m_volume_with_cavity->indexed_vertex_array.load_mesh(*m_c->m_cavity_mesh.get()); - m_c->m_volume_with_cavity->finalize_geometry(true); - m_c->m_volume_with_cavity->force_transparent = false; - - m_parent.toggle_model_objects_visibility(false, m_c->m_model_object, m_c->m_active_instance); - m_parent.toggle_sla_auxiliaries_visibility(true, m_c->m_model_object, m_c->m_active_instance); - - // Reset raycaster so it works with the new mesh: - m_c->m_mesh_raycaster.reset(new MeshRaycaster(*m_c->mesh())); - } - - if (m_c->m_clipping_plane_distance == 0.f) { - m_c->m_clipping_plane_distance = 0.5f; - update_clipping_plane(); - }*/ -} - std::vector<std::pair<const ConfigOption*, const ConfigOptionDef*>> GLGizmoHollow::get_config_options(const std::vector<std::string>& keys) const { std::vector<std::pair<const ConfigOption*, const ConfigOptionDef*>> out; @@ -829,7 +721,6 @@ RENDER_AGAIN: bool remove_selected = false; bool remove_all = false; - // m_imgui->text(" "); // vertical gap ImGui::Separator(); float diameter_upper_cap = 15.; @@ -1013,10 +904,6 @@ void GLGizmoHollow::on_set_state() m_parent.toggle_model_objects_visibility(true, m_c->m_model_object, m_c->m_active_instance); m_parent.toggle_sla_auxiliaries_visibility(m_show_supports, m_c->m_model_object, m_c->m_active_instance); } - - // Set default head diameter from config. - //const DynamicPrintConfig& cfg = wxGetApp().preset_bundle->sla_prints.get_edited_preset().config; - //m_new_hole_radius = static_cast<const ConfigOptionFloat*>(cfg.option("support_head_front_diameter"))->value; } if (m_state == Off && m_old_state != Off) { // the gizmo was just turned Off //Plater::TakeSnapshot snapshot(wxGetApp().plater(), _(L("SLA gizmo turned off"))); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoHollow.hpp b/src/slic3r/GUI/Gizmos/GLGizmoHollow.hpp index bc4549a0e..3aafcbf55 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoHollow.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoHollow.hpp @@ -36,11 +36,6 @@ public: void delete_selected_points(); ClippingPlane get_sla_clipping_plane() const; - - std::pair<const TriangleMesh *, sla::HollowingConfig> get_hollowing_parameters() const; - void update_mesh_raycaster(std::unique_ptr<MeshRaycaster> &&rc); - void update_hollowed_mesh(std::unique_ptr<TriangleMesh> &&mesh); - bool is_selection_rectangle_dragging() const { return m_selection_rectangle.is_dragging(); } void update_clipping_plane(bool keep_normal = false) const; void set_common_data_ptr(CommonGizmosData* ptr) { m_c = ptr; } @@ -53,7 +48,6 @@ private: void render_points(const Selection& selection, bool picking = false) const; void render_clipping_plane(const Selection& selection) const; - void render_hollowed_mesh() const; void hollow_mesh(bool postpone_error_messages = false); bool unsaved_changes() const; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp index 0e98f7364..ab0b9b5d6 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp @@ -1,6 +1,7 @@ // Include GLGizmoBase.hpp before I18N.hpp as it includes some libigl code, which overrides our localization "L" macro. #include "GLGizmoSlaSupports.hpp" #include "slic3r/GUI/GLCanvas3D.hpp" +#include "slic3r/GUI/Camera.hpp" #include "slic3r/GUI/Gizmos/GLGizmos.hpp" #include <GL/glew.h> @@ -106,8 +107,6 @@ void GLGizmoSlaSupports::on_render() const m_z_shift = selection.get_volume(*selection.get_volume_idxs().begin())->get_sla_shift_z(); - render_hollowed_mesh(); - if (m_quadric != nullptr && selection.is_from_single_instance()) render_points(selection, false); @@ -119,29 +118,6 @@ void GLGizmoSlaSupports::on_render() const -void GLGizmoSlaSupports::render_hollowed_mesh() const -{ - /*if (m_c->m_volume_with_cavity) { - m_c->m_volume_with_cavity->set_sla_shift_z(m_z_shift); - m_parent.get_shader().start_using(); - - GLint current_program_id; - glsafe(::glGetIntegerv(GL_CURRENT_PROGRAM, ¤t_program_id)); - GLint color_id = (current_program_id > 0) ? ::glGetUniformLocation(current_program_id, "uniform_color") : -1; - GLint print_box_detection_id = (current_program_id > 0) ? ::glGetUniformLocation(current_program_id, "print_box.volume_detection") : -1; - GLint print_box_worldmatrix_id = (current_program_id > 0) ? ::glGetUniformLocation(current_program_id, "print_box.volume_world_matrix") : -1; - glcheck(); - m_c->m_volume_with_cavity->set_render_color(); - const Geometry::Transformation& volume_trafo = m_c->m_model_object->volumes.front()->get_transformation(); - m_c->m_volume_with_cavity->set_volume_transformation(volume_trafo); - m_c->m_volume_with_cavity->set_instance_transformation(m_c->m_model_object->instances[size_t(m_c->m_active_instance)]->get_transformation()); - m_c->m_volume_with_cavity->render(color_id, print_box_detection_id, print_box_worldmatrix_id); - m_parent.get_shader().stop_using(); - }*/ -} - - - void GLGizmoSlaSupports::render_clipping_plane(const Selection& selection) const { if (m_c->m_clipping_plane_distance == 0.f || m_c->m_mesh->empty()) @@ -238,7 +214,6 @@ void GLGizmoSlaSupports::on_render_for_picking() const glsafe(::glEnable(GL_DEPTH_TEST)); render_points(selection, true); - render_hollowed_mesh(); } void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking) const @@ -627,8 +602,6 @@ void GLGizmoSlaSupports::delete_selected_points(bool force) } select_point(NoPoints); - - //m_parent.post_event(SimpleEvent(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS)); } void GLGizmoSlaSupports::on_update(const UpdateData& data) @@ -643,8 +616,6 @@ void GLGizmoSlaSupports::on_update(const UpdateData& data) m_editing_cache[m_hover_id].support_point.pos = pos_and_normal.first; m_editing_cache[m_hover_id].support_point.is_new_island = false; m_editing_cache[m_hover_id].normal = pos_and_normal.second; - // Do not update immediately, wait until the mouse is released. - // m_parent.post_event(SimpleEvent(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS)); } } } diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp index deddabe5f..bd48ecd65 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp @@ -93,7 +93,6 @@ private: //void render_selection_rectangle() const; void render_points(const Selection& selection, bool picking = false) const; void render_clipping_plane(const Selection& selection) const; - void render_hollowed_mesh() const; bool unsaved_changes() const; bool m_lock_unique_islands = false; diff --git a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp index 35292f31c..d465196f3 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp @@ -8,8 +8,9 @@ #include "slic3r/Utils/UndoRedo.hpp" #include "libslic3r/SLAPrint.hpp" #include "slic3r/GUI/MeshUtils.hpp" +#include "slic3r/GUI/Gizmos/GLGizmos.hpp" +#include "slic3r/GUI/Camera.hpp" -#include <GL/glew.h> #include <wx/glcanvas.h> namespace Slic3r { diff --git a/src/slic3r/GUI/Gizmos/GLGizmosManager.hpp b/src/slic3r/GUI/Gizmos/GLGizmosManager.hpp index a479b645b..2eac470f9 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmosManager.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmosManager.hpp @@ -3,8 +3,8 @@ #include "slic3r/GUI/GLTexture.hpp" #include "slic3r/GUI/GLToolbar.hpp" -#include "slic3r/GUI/Gizmos/GLGizmos.hpp" #include "libslic3r/ObjectID.hpp" +#include "slic3r/GUI/Gizmos/GLGizmoBase.hpp" #include <map> @@ -18,6 +18,8 @@ namespace GUI { class GLCanvas3D; class ClippingPlane; +enum class SLAGizmoEventType : unsigned char; +class CommonGizmosData; class Rect { diff --git a/src/slic3r/GUI/ObjectDataViewModel.cpp b/src/slic3r/GUI/ObjectDataViewModel.cpp index 649b3c32e..0905f4915 100644 --- a/src/slic3r/GUI/ObjectDataViewModel.cpp +++ b/src/slic3r/GUI/ObjectDataViewModel.cpp @@ -5,6 +5,8 @@ #include "GUI_ObjectList.hpp" #include "I18N.hpp" +#include "libslic3r/Model.hpp" + #include <wx/bmpcbox.h> #include <wx/dc.h> diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index a57225954..7432f6633 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -80,7 +80,6 @@ #include "../Utils/PrintHost.hpp" #include "../Utils/FixModelByWin10.hpp" #include "../Utils/UndoRedo.hpp" -#include "../Utils/Thread.hpp" #include "RemovableDriveManager.hpp" #include <wx/glcanvas.h> // Needs to be last because reasons :-/ @@ -1554,8 +1553,7 @@ struct Plater::priv enum class Jobs : size_t { Arrange, - Rotoptimize, - Hollow + Rotoptimize }; class ArrangeJob : public PlaterJob @@ -1699,22 +1697,6 @@ struct Plater::priv void process() override; }; - class HollowJob : public PlaterJob - { - public: - using PlaterJob::PlaterJob; - void prepare() override; - void process() override; - void finalize() override; - private: - GLGizmoHollow * get_gizmo(); - const GLGizmoHollow * get_gizmo() const; - - std::unique_ptr<TriangleMesh> m_output_mesh; - std::unique_ptr<MeshRaycaster> m_output_raycaster; - const TriangleMesh* m_object_mesh = nullptr; - sla::HollowingConfig m_cfg; - }; // Jobs defined inside the group class will be managed so that only one can // run at a time. Also, the background process will be stopped if a job is @@ -1727,7 +1709,6 @@ struct Plater::priv ArrangeJob arrange_job{m_plater}; RotoptimizeJob rotoptimize_job{m_plater}; - HollowJob hollow_job{m_plater}; // To create a new job, just define a new subclass of Job, implement // the process and the optional prepare() and finalize() methods @@ -1735,8 +1716,7 @@ struct Plater::priv // if it cannot run concurrently with other jobs in this group std::vector<std::reference_wrapper<Job>> m_jobs{arrange_job, - rotoptimize_job, - hollow_job}; + rotoptimize_job}; public: ExclusiveJobGroup(priv *_plater) : m_plater(_plater) {} @@ -1839,7 +1819,6 @@ struct Plater::priv void reset(); void mirror(Axis axis); void arrange(); - void hollow(); void sla_optimize_rotation(); void split_object(); void split_volume(); @@ -2755,11 +2734,6 @@ void Plater::priv::arrange() m_ui_jobs.start(Jobs::Arrange); } -void Plater::priv::hollow() -{ - this->take_snapshot(_(L("Hollow"))); - m_ui_jobs.start(Jobs::Hollow); -} // This method will find an optimal orientation for the currently selected item // Very similar in nature to the arrange method above... @@ -2892,67 +2866,6 @@ void Plater::priv::RotoptimizeJob::process() : _(L("Orientation found."))); } -void Plater::priv::HollowJob::prepare() -{ - const GLGizmosManager& gizmo_manager = plater().q->canvas3D()->get_gizmos_manager(); - const GLGizmoHollow* gizmo_hollow = dynamic_cast<const GLGizmoHollow*>(gizmo_manager.get_current()); - assert(gizmo_hollow); - auto hlw_data = gizmo_hollow->get_hollowing_parameters(); - m_object_mesh = hlw_data.first; - m_cfg = hlw_data.second; - m_output_mesh.reset(); -} - -void Plater::priv::HollowJob::process() -{ - sla::JobController ctl; - ctl.stopcondition = [this]{ return was_canceled(); }; - ctl.statuscb = [this](unsigned st, const std::string &s) { - if (st < 100) update_status(int(st), s); - }; - - std::unique_ptr<TriangleMesh> omesh = - sla::generate_interior(*m_object_mesh, m_cfg, ctl); - - if (omesh && !omesh->empty()) { - m_output_mesh.reset(new TriangleMesh{*m_object_mesh}); - m_output_mesh->merge(*omesh); - m_output_mesh->require_shared_vertices(); - - update_status(90, _(L("Indexing hollowed object"))); - - m_output_raycaster.reset(new MeshRaycaster(*m_output_mesh)); - - update_status(100, was_canceled() ? _(L("Hollowing cancelled.")) : - _(L("Hollowing done."))); - } else { - update_status(100, _(L("Hollowing failed."))); - } -} - -void Plater::priv::HollowJob::finalize() -{ - if (auto gizmo = get_gizmo()) { - gizmo->update_mesh_raycaster(std::move(m_output_raycaster)); - gizmo->update_hollowed_mesh(std::move(m_output_mesh)); - } -} - -GLGizmoHollow *Plater::priv::HollowJob::get_gizmo() -{ - const GLGizmosManager& gizmo_manager = plater().q->canvas3D()->get_gizmos_manager(); - auto ret = dynamic_cast<GLGizmoHollow*>(gizmo_manager.get_current()); - assert(ret); - return ret; -} - -const GLGizmoHollow *Plater::priv::HollowJob::get_gizmo() const -{ - const GLGizmosManager& gizmo_manager = plater().q->canvas3D()->get_gizmos_manager(); - auto ret = dynamic_cast<const GLGizmoHollow*>(gizmo_manager.get_current()); - assert(ret); - return ret; -} void Plater::priv::split_object() { @@ -3698,7 +3611,7 @@ void Plater::priv::on_process_completed(wxCommandEvent &evt) else if (wxGetApp().get_mode() == comSimple) show_action_buttons(false); - if(!canceled && RemovableDriveManager::get_instance().get_is_writing()) + if(!canceled && RemovableDriveManager::get_instance().get_is_writing()) { RemovableDriveManager::get_instance().set_is_writing(false); show_action_buttons(false); @@ -5072,10 +4985,6 @@ void Plater::export_toolpaths_to_obj() const p->preview->get_canvas3d()->export_toolpaths_to_obj(into_u8(path).c_str()); } -void Plater::hollow() -{ - p->hollow(); -} void Plater::reslice() { diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index 249e0a043..f3b0181a0 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -10,14 +10,11 @@ #include "Preset.hpp" -#include "3DScene.hpp" -#include "GLTexture.hpp" +#include "libslic3r/BoundingBox.hpp" #include "wxExtensions.hpp" class wxButton; class ScalableButton; -class wxBoxSizer; -class wxGLCanvas; class wxScrolledWindow; class wxString; @@ -30,9 +27,9 @@ class SLAPrint; enum SLAPrintObjectStep : unsigned int; namespace UndoRedo { - class Stack; - struct Snapshot; -}; + class Stack; + struct Snapshot; +} namespace GUI { @@ -44,6 +41,7 @@ class ObjectLayers; class ObjectList; class GLCanvas3D; class Mouse3DController; +struct Camera; using t_optgroups = std::vector <std::shared_ptr<ConfigOptionsGroup>>; @@ -200,7 +198,6 @@ public: void reload_all_from_disk(); bool has_toolpaths_to_export() const; void export_toolpaths_to_obj() const; - void hollow(); void reslice(); void reslice_SLA_supports(const ModelObject &object, bool postpone_error_messages = false); void reslice_SLA_hollowing(const ModelObject &object, bool postpone_error_messages = false); diff --git a/src/slic3r/GUI/Preset.cpp b/src/slic3r/GUI/Preset.cpp index c0af7bcea..e73133fdf 100644 --- a/src/slic3r/GUI/Preset.cpp +++ b/src/slic3r/GUI/Preset.cpp @@ -1012,7 +1012,7 @@ const std::string& PresetCollection::get_preset_name_by_alias(const std::string& it != m_map_alias_to_profile_name.end() && it->first == alias; ++ it) if (auto it_preset = this->find_preset_internal(it->second); it_preset != m_presets.end() && it_preset->name == it->second && - it_preset->is_visible && (it_preset->is_compatible || (it_preset - m_presets.begin()) == m_idx_selected)) + it_preset->is_visible && (it_preset->is_compatible || size_t(it_preset - m_presets.begin()) == m_idx_selected)) return it_preset->name; return alias; } @@ -1065,6 +1065,7 @@ size_t PresetCollection::update_compatible_internal(const PresetWithVendorProfil bool selected = idx_preset == m_idx_selected; Preset &preset_selected = m_presets[idx_preset]; Preset &preset_edited = selected ? m_edited_preset : preset_selected; + const PresetWithVendorProfile this_preset_with_vendor_profile = this->get_preset_with_vendor_profile(preset_edited); bool was_compatible = preset_edited.is_compatible; preset_edited.is_compatible = is_compatible_with_printer(this_preset_with_vendor_profile, active_printer, &config); @@ -1072,7 +1073,7 @@ size_t PresetCollection::update_compatible_internal(const PresetWithVendorProfil preset_edited.is_compatible &= is_compatible_with_print(this_preset_with_vendor_profile, *active_print, active_printer); if (! preset_edited.is_compatible && selected && (unselect_if_incompatible == PresetSelectCompatibleType::Always || (unselect_if_incompatible == PresetSelectCompatibleType::OnlyIfWasCompatible && was_compatible))) - m_idx_selected = -1; + m_idx_selected = size_t(-1); if (selected) preset_selected.is_compatible = preset_edited.is_compatible; } @@ -1369,7 +1370,7 @@ void add_correct_opts_to_diff(const std::string &opt_key, t_config_option_keys& const T* opt_init = static_cast<const T*>(other.option(opt_key)); const T* opt_cur = static_cast<const T*>(this_c.option(opt_key)); int opt_init_max_id = opt_init->values.size() - 1; - for (int i = 0; i < opt_cur->values.size(); i++) + for (int i = 0; i < int(opt_cur->values.size()); i++) { int init_id = i <= opt_init_max_id ? i : 0; if (opt_cur->values[i] != opt_init->values[init_id]) diff --git a/src/slic3r/GUI/Preset.hpp b/src/slic3r/GUI/Preset.hpp index 46008eadb..224adaeaa 100644 --- a/src/slic3r/GUI/Preset.hpp +++ b/src/slic3r/GUI/Preset.hpp @@ -342,9 +342,9 @@ public: // Return the selected preset, without the user modifications applied. Preset& get_selected_preset() { return m_presets[m_idx_selected]; } const Preset& get_selected_preset() const { return m_presets[m_idx_selected]; } - int get_selected_idx() const { return m_idx_selected; } + size_t get_selected_idx() const { return m_idx_selected; } // Returns the name of the selected preset, or an empty string if no preset is selected. - std::string get_selected_preset_name() const { return (m_idx_selected == -1) ? std::string() : this->get_selected_preset().name; } + std::string get_selected_preset_name() const { return (m_idx_selected == size_t(-1)) ? std::string() : this->get_selected_preset().name; } // For the current edited preset, return the parent preset if there is one. // If there is no parent preset, nullptr is returned. // The parent preset may be a system preset or a user preset, which will be @@ -365,7 +365,7 @@ public: // used to update preset_choice from Tab const std::deque<Preset>& get_presets() const { return m_presets; } - int get_idx_selected() { return m_idx_selected; } + size_t get_idx_selected() { return m_idx_selected; } static const std::string& get_suffix_modified(); // Return a preset possibly with modifications. @@ -373,7 +373,7 @@ public: const Preset& default_preset(size_t idx = 0) const { assert(idx < m_num_default_presets); return m_presets[idx]; } virtual const Preset& default_preset_for(const DynamicPrintConfig & /* config */) const { return this->default_preset(); } // Return a preset by an index. If the preset is active, a temporary copy is returned. - Preset& preset(size_t idx) { return (int(idx) == m_idx_selected) ? m_edited_preset : m_presets[idx]; } + Preset& preset(size_t idx) { return (idx == m_idx_selected) ? m_edited_preset : m_presets[idx]; } const Preset& preset(size_t idx) const { return const_cast<PresetCollection*>(this)->preset(idx); } void discard_current_changes() { m_presets[m_idx_selected].reset_dirty(); m_edited_preset = m_presets[m_idx_selected]; } @@ -541,7 +541,7 @@ private: // Initially this preset contains a copy of the selected preset. Later on, this copy may be modified by the user. Preset m_edited_preset; // Selected preset. - int m_idx_selected; + size_t m_idx_selected; // Is the "- default -" preset suppressed? bool m_default_suppressed = true; size_t m_num_default_presets = 0; diff --git a/src/slic3r/GUI/PresetBundle.cpp b/src/slic3r/GUI/PresetBundle.cpp index 5c9dc2ec9..e36c85d68 100644 --- a/src/slic3r/GUI/PresetBundle.cpp +++ b/src/slic3r/GUI/PresetBundle.cpp @@ -29,8 +29,10 @@ #include "libslic3r/libslic3r.h" #include "libslic3r/Utils.hpp" +#include "libslic3r/Model.hpp" #include "GUI_App.hpp" + // Store the print/filament/printer presets into a "presets" subdirectory of the Slic3rPE config dir. // This breaks compatibility with the upstream Slic3r if the --datadir is used to switch between the two versions. // #define SLIC3R_PROFILE_USE_PRESETS_SUBDIR @@ -964,8 +966,6 @@ static void flatten_configbundle_hierarchy(boost::property_tree::ptree &tree, co { namespace pt = boost::property_tree; - typedef std::pair<pt::ptree::key_type, pt::ptree> ptree_child_type; - // 1) For the group given by group_name, initialize the presets. struct Prst { Prst(const std::string &name, pt::ptree *node) : name(name), node(node) {} @@ -1316,7 +1316,7 @@ size_t PresetBundle::load_configbundle(const std::string &path, unsigned int fla // Derive the profile logical name aka alias from the preset name if the alias was not stated explicitely. if (alias_name.empty()) { - int end_pos = preset_name.find_first_of("@"); + size_t end_pos = preset_name.find_first_of("@"); if (end_pos != std::string::npos) { alias_name = preset_name.substr(0, end_pos); if (renamed_from.empty()) @@ -1717,7 +1717,7 @@ void PresetBundle::update_plater_filament_ui(unsigned int idx_extruder, GUI::Pre if (selected_preset_item == INT_MAX) selected_preset_item = ui->GetCount() - 1; - ui->SetSelection(selected_preset_item); + ui->SetSelection(selected_preset_item); ui->SetToolTip(tooltip.IsEmpty() ? ui->GetString(selected_preset_item) : tooltip); ui->check_selection(); ui->Thaw(); diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 1033ffac4..615dd377e 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -4,6 +4,7 @@ #include "PresetBundle.hpp" #include "PresetHints.hpp" #include "libslic3r/Utils.hpp" +#include "libslic3r/Model.hpp" #include "slic3r/Utils/Http.hpp" #include "slic3r/Utils/PrintHost.hpp" diff --git a/src/slic3r/Utils/FlashAir.cpp b/src/slic3r/Utils/FlashAir.cpp index c033bd843..c99a404ca 100644 --- a/src/slic3r/Utils/FlashAir.cpp +++ b/src/slic3r/Utils/FlashAir.cpp @@ -182,8 +182,6 @@ std::string FlashAir::timestamp_str() const auto t = std::time(nullptr); auto tm = *std::localtime(&t); - const char *name = get_name(); - unsigned long fattime = ((tm.tm_year - 80) << 25) | ((tm.tm_mon + 1) << 21) | (tm.tm_mday << 16) | diff --git a/src/slic3r/Utils/PresetUpdater.cpp b/src/slic3r/Utils/PresetUpdater.cpp index a28937e15..4da5f0f52 100644 --- a/src/slic3r/Utils/PresetUpdater.cpp +++ b/src/slic3r/Utils/PresetUpdater.cpp @@ -526,8 +526,8 @@ Updates PresetUpdater::priv::get_config_updates(const Semver &old_slic3r_version existing_idx.load(bundle_path_idx); // Find a recommended config bundle version for the slic3r version last executed. This makes sure that a config bundle update will not be missed // when upgrading an application. On the other side, the user will be bugged every time he will switch between slic3r versions. - const auto existing_recommended = existing_idx.recommended(old_slic3r_version); - /*if (existing_recommended != existing_idx.end() && recommended->config_version == existing_recommended->config_version) { + /*const auto existing_recommended = existing_idx.recommended(old_slic3r_version); + if (existing_recommended != existing_idx.end() && recommended->config_version == existing_recommended->config_version) { // The user has already seen (and presumably rejected) this update BOOST_LOG_TRIVIAL(info) << boost::format("Downloaded index for `%1%` is the same as installed one, not offering an update.") % idx.vendor(); continue; diff --git a/tests/fff_print/test_data.cpp b/tests/fff_print/test_data.cpp index b3c16f4b0..7d7cd5480 100644 --- a/tests/fff_print/test_data.cpp +++ b/tests/fff_print/test_data.cpp @@ -161,7 +161,7 @@ void init_print(std::vector<TriangleMesh> &&meshes, Slic3r::Print &print, Slic3r if (verbose_gcode()) config.set_key_value("gcode_comments", new ConfigOptionBool(true)); - for (const TriangleMesh &t : meshes) { + for (const TriangleMesh &t : meshes) { ModelObject *object = model.add_object(); object->name += "object.stl"; object->add_volume(std::move(t)); diff --git a/tests/fff_print/test_trianglemesh.cpp b/tests/fff_print/test_trianglemesh.cpp index 9598a3c5a..6b467a511 100644 --- a/tests/fff_print/test_trianglemesh.cpp +++ b/tests/fff_print/test_trianglemesh.cpp @@ -277,7 +277,6 @@ SCENARIO( "make_xxx functions produce meshes.") { GIVEN("make_sphere() function") { WHEN("make_sphere() is called with arguments 10, PI / 3") { TriangleMesh sph = make_sphere(10, PI / 243.0); - double angle = (2.0*PI / floor(2.0*PI / (PI / 243.0))); THEN("Resulting mesh has one point at 0,0,-10 and one at 0,0,10") { const std::vector<stl_vertex> &verts = sph.its.vertices; REQUIRE(std::count_if(verts.begin(), verts.end(), [](const Vec3f& t) { return is_approx(t, Vec3f(0.f, 0.f, 10.f)); } ) == 1);