Merge branch 'master' of https://github.com/prusa3d/PrusaSlicer into et_bug_fixes

This commit is contained in:
enricoturri1966 2020-03-25 09:34:17 +01:00
commit fac28ea27a
48 changed files with 98 additions and 351 deletions

View file

@ -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) for (const Item& custom_gcode : custom_gcode_per_print_z.gcodes)
if (custom_gcode.gcode == ToolChangeCode) { if (custom_gcode.gcode == ToolChangeCode) {
// If extruder count in PrinterSettings was changed, use default (0) extruder for extruders, more than num_extruders // 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; return custom_tool_changes;
} }

View file

@ -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.distance = d_min * sign_min;
result.t /= l2_seg_min; result.t /= l2_seg_min;
assert(result.t >= 0. && result.t < 1.); assert(result.t >= 0. && result.t < 1.);

View file

@ -611,7 +611,7 @@ static inline SegmentPoint clip_start_segment_and_point(const Points &polyline,
SegmentPoint out; SegmentPoint out;
if (polyline.size() >= 2) { if (polyline.size() >= 2) {
Vec2d pt_prev = polyline.front().cast<double>(); 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 pt = polyline[i].cast<double>();
Vec2d v = pt - pt_prev; Vec2d v = pt - pt_prev;
double l2 = v.squaredNorm(); double l2 = v.squaredNorm();
@ -674,7 +674,7 @@ static inline double segment_point_distance_squared(const Vec2d &p1a, const Vec2
if (l2 < EPSILON) if (l2 < EPSILON)
// p1a == p1b // p1a == p1b
return (p2 - p1a).squaredNorm(); 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. // 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. // p2a == p2b: Return distance of p2a from the (p1a, p1b) segment.
return segment_point_distance_squared(p1a, p1b, v1, l1_2, p2a); 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(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))); std::min(segment_point_distance_squared(p2a, p2b, v2, l2_2, p1a), segment_point_distance_squared(p2a, p2b, v2, l2_2, p1b)));
} }

View file

@ -156,7 +156,7 @@ void FillGyroid::_fill_surface_single(
Polylines &polylines_out) Polylines &polylines_out)
{ {
float infill_angle = this->angle + (CorrectionAngle * 2*M_PI) / 360.; 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); expolygon.rotate(-infill_angle);
BoundingBox bb = expolygon.contour.bounding_box(); BoundingBox bb = expolygon.contour.bounding_box();
@ -197,8 +197,9 @@ void FillGyroid::_fill_surface_single(
append(polylines_out, std::move(polylines)); append(polylines_out, std::move(polylines));
else else
this->connect_infill(std::move(polylines), expolygon, polylines_out, this->spacing, params); this->connect_infill(std::move(polylines), expolygon, polylines_out, this->spacing, params);
// new paths must be rotated back // 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) for (auto it = polylines_out.begin() + polylines_out_first_idx; it != polylines_out.end(); ++ it)
it->rotate(infill_angle); it->rotate(infill_angle);
} }

View file

@ -1722,7 +1722,7 @@ namespace Slic3r {
} }
// Added because of github #3435, currently not used by PrusaSlicer // 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_objects_metadata.insert(IdToMetadataMap::value_type(object_id, ObjectMetadata()));
m_curr_config.object_id = object_id; m_curr_config.object_id = object_id;

View file

@ -431,7 +431,6 @@ std::string WipeTowerIntegration::post_process_wipe_tower_moves(const WipeTower:
Vec2f pos = tcr.start_pos; Vec2f pos = tcr.start_pos;
Vec2f transformed_pos = pos; Vec2f transformed_pos = pos;
Vec2f old_pos(-1000.1f, -1000.1f); Vec2f old_pos(-1000.1f, -1000.1f);
std::string never_skip_tag = WipeTower::never_skip_tag();
while (gcode_str) { while (gcode_str) {
std::getline(gcode_str, line); // we read the gcode line by line std::getline(gcode_str, line); // we read the gcode line by line
@ -441,11 +440,11 @@ std::string WipeTowerIntegration::post_process_wipe_tower_moves(const WipeTower:
// WT generator can override this by appending the never_skip_tag // WT generator can override this by appending the never_skip_tag
if (line.find("G1 ") == 0) { if (line.find("G1 ") == 0) {
bool never_skip = false; bool never_skip = false;
auto it = line.find(never_skip_tag); auto it = line.find(WipeTower::never_skip_tag());
if (it != std::string::npos) { if (it != std::string::npos) {
// remove the tag and remember we saw it // remove the tag and remember we saw it
never_skip = true; never_skip = true;
line.erase(it, it+never_skip_tag.size()); line.erase(it, it+WipeTower::never_skip_tag().size());
} }
std::ostringstream line_out; std::ostringstream line_out;
std::istringstream line_str(line); std::istringstream line_str(line);
@ -1752,7 +1751,6 @@ std::vector<GCode::InstanceToPrint> GCode::sort_print_object_instances(
std::sort(sorted.begin(), sorted.end()); std::sort(sorted.begin(), sorted.end());
if (! sorted.empty()) { if (! sorted.empty()) {
const Print &print = *sorted.front().first->print();
out.reserve(sorted.size()); out.reserve(sorted.size());
for (const PrintInstance *instance : *ordering) { for (const PrintInstance *instance : *ordering) {
const PrintObject &print_object = *instance->print_object; const PrintObject &print_object = *instance->print_object;
@ -1798,13 +1796,14 @@ namespace ProcessLayer
// we should add or not colorprint_change in respect to nozzle_diameter count instead of really used extruders count // we should add or not colorprint_change in respect to nozzle_diameter count instead of really used extruders count
if (color_change || tool_change) if (color_change || tool_change)
{ {
assert(m600_extruder_before_layer >= 0);
// Color Change or Tool Change as Color Change. // Color Change or Tool Change as Color Change.
// add tag for analyzer // add tag for analyzer
gcode += "; " + GCodeAnalyzer::Color_Change_Tag + ",T" + std::to_string(m600_extruder_before_layer) + "\n"; gcode += "; " + GCodeAnalyzer::Color_Change_Tag + ",T" + std::to_string(m600_extruder_before_layer) + "\n";
// add tag for time estimator // add tag for time estimator
gcode += "; " + GCodeTimeEstimator::Color_Change_Tag + "\n"; 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 // && !MMU1
) { ) {
//! FIXME_in_fw show message during print pause //! FIXME_in_fw show message during print pause

View file

@ -646,7 +646,7 @@ bool GCodeAnalyzer::_process_tags(const GCodeReader::GCodeLine& line)
if (pos != comment.npos) if (pos != comment.npos)
{ {
pos = comment.find_last_of(",T"); 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); _process_color_change_tag(extruder);
return true; return true;
} }
@ -704,7 +704,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)); _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_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++; m_state.cp_color_counter++;

View file

@ -220,7 +220,7 @@ private:
void _process_height_tag(const std::string& comment, size_t pos); void _process_height_tag(const std::string& comment, size_t pos);
// Processes color change tag // 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 // Processes pause print and custom gcode tag
void _process_pause_print_or_custom_code_tag(); void _process_pause_print_or_custom_code_tag();

View file

@ -64,7 +64,7 @@ private:
std::map<const ExtrusionEntity*, ExtruderPerCopy> entity_map; // to keep track of who prints what std::map<const ExtrusionEntity*, ExtruderPerCopy> entity_map; // to keep track of who prints what
bool something_overridable = false; bool something_overridable = false;
bool something_overridden = 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
}; };

View file

@ -21,7 +21,7 @@ enum GCodeFlavor : unsigned char;
class WipeTower class WipeTower
{ {
public: public:
static char const* never_skip_tag() { return "_GCODE_WIPE_TOWER_NEVER_SKIP_TAG"; } static const std::string never_skip_tag() { return "_GCODE_WIPE_TOWER_NEVER_SKIP_TAG"; }
struct Extrusion struct Extrusion
{ {
@ -189,8 +189,6 @@ public:
}; };
private: private:
WipeTower();
enum wipe_shape // A fill-in direction enum wipe_shape // A fill-in direction
{ {
SHAPE_NORMAL = 1, SHAPE_NORMAL = 1,

View file

@ -1935,7 +1935,7 @@ void Print::_make_brim()
// Find all pieces that the initial loop was split into. // Find all pieces that the initial loop was split into.
size_t j = i + 1; size_t j = i + 1;
for (; j < loops_trimmed_order.size() && loops_trimmed_order[i].second == loops_trimmed_order[j].second; ++ j) ; 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) { 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(); auto *loop = new ExtrusionLoop();
m_brim.entities.emplace_back(loop); m_brim.entities.emplace_back(loop);

View file

@ -101,6 +101,9 @@ public:
// Iterates over hits and holes and returns the true hit, possibly // Iterates over hits and holes and returns the true hit, possibly
// on the inside of a hole. // 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; hit_result filter_hits(const std::vector<EigenMesh3D::hit_result>& obj_hits) const;
class si_result { class si_result {

View file

@ -5,11 +5,12 @@
#include <time.h> #include <time.h>
#include <boost/algorithm/string/predicate.hpp> #include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/trim.hpp>
#include <boost/nowide/cstdio.hpp> #include <boost/nowide/cstdio.hpp>
#include <boost/nowide/fstream.hpp> #include <boost/nowide/fstream.hpp>
#include <boost/property_tree/ini_parser.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/libslic3r.h"
#include "libslic3r/Time.hpp" #include "libslic3r/Time.hpp"

View file

@ -6,7 +6,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <boost/filesystem.hpp> #include <boost/filesystem/path.hpp>
#include "libslic3r/Semver.hpp" #include "libslic3r/Semver.hpp"
#include "Version.hpp" #include "Version.hpp"
@ -18,7 +18,6 @@ class AppConfig;
namespace GUI { namespace GUI {
namespace Config { namespace Config {
class Index;
// A snapshot contains: // A snapshot contains:
// Slic3r.ini // Slic3r.ini

View file

@ -2,8 +2,7 @@
#include <cctype> #include <cctype>
#include <boost/algorithm/string/predicate.hpp> #include <boost/filesystem/operations.hpp>
#include <boost/algorithm/string/trim.hpp>
#include <boost/nowide/fstream.hpp> #include <boost/nowide/fstream.hpp>
#include "libslic3r/libslic3r.h" #include "libslic3r/libslic3r.h"

View file

@ -4,7 +4,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <boost/filesystem.hpp> #include <boost/filesystem/path.hpp>
#include "libslic3r/FileParserError.hpp" #include "libslic3r/FileParserError.hpp"
#include "libslic3r/Semver.hpp" #include "libslic3r/Semver.hpp"
@ -54,7 +54,7 @@ struct Version
class Index class Index
{ {
public: 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. // 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. // Throws Slic3r::file_parser_error and the standard std file access exceptions.
size_t load(const boost::filesystem::path &path); size_t load(const boost::filesystem::path &path);

View file

@ -166,4 +166,4 @@ void Bed_2D::set_pos(const Vec2d& pos)
} }
} // GUI } // GUI
} // Slic3r } // Slic3r

View file

@ -8,7 +8,6 @@
#include "GUI_App.hpp" #include "GUI_App.hpp"
#include "PresetBundle.hpp" #include "PresetBundle.hpp"
#include "Gizmos/GLGizmoBase.hpp"
#include "GLCanvas3D.hpp" #include "GLCanvas3D.hpp"
#include <GL/glew.h> #include <GL/glew.h>
@ -630,4 +629,4 @@ void Bed3D::reset()
} }
} // GUI } // GUI
} // Slic3r } // Slic3r

View file

@ -17,23 +17,17 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <utility>
#include <assert.h> #include <assert.h>
#include <boost/log/trivial.hpp> #include <boost/log/trivial.hpp>
#include <boost/filesystem/operations.hpp> #include <boost/filesystem/operations.hpp>
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string/predicate.hpp>
#include <boost/nowide/cstdio.hpp> #include <boost/nowide/cstdio.hpp>
#include <tbb/parallel_for.h>
#include <tbb/spin_mutex.h>
#include <Eigen/Dense> #include <Eigen/Dense>
#include "GUI.hpp"
#ifdef HAS_GLSAFE #ifdef HAS_GLSAFE
void glAssertRecentCallImpl(const char *file_name, unsigned int line, const char *function_name) void glAssertRecentCallImpl(const char *file_name, unsigned int line, const char *function_name)
{ {

View file

@ -10,7 +10,6 @@
#include "slic3r/GUI/GLCanvas3DManager.hpp" #include "slic3r/GUI/GLCanvas3DManager.hpp"
#include <functional> #include <functional>
#include <memory>
#ifndef NDEBUG #ifndef NDEBUG
#define HAS_GLSAFE #define HAS_GLSAFE
@ -34,13 +33,8 @@ struct Camera;
class GLToolbar; class GLToolbar;
} // namespace GUI } // namespace GUI
class Print;
class PrintObject;
class SLAPrint;
class SLAPrintObject; class SLAPrintObject;
enum SLAPrintObjectStep : unsigned int; enum SLAPrintObjectStep : unsigned int;
class Model;
class ModelObject;
class DynamicPrintConfig; class DynamicPrintConfig;
class ExtrusionPath; class ExtrusionPath;
class ExtrusionMultiPath; class ExtrusionMultiPath;

View file

@ -2,8 +2,9 @@
#include "I18N.hpp" #include "I18N.hpp"
#include "libslic3r/Utils.hpp" #include "libslic3r/Utils.hpp"
#include "GUI.hpp"
#include "GUI_App.hpp" #include "GUI_App.hpp"
#include "wxExtensions.hpp"
namespace Slic3r { namespace Slic3r {
namespace GUI { namespace GUI {

View file

@ -1,8 +1,6 @@
#ifndef slic3r_GUI_AboutDialog_hpp_ #ifndef slic3r_GUI_AboutDialog_hpp_
#define slic3r_GUI_AboutDialog_hpp_ #define slic3r_GUI_AboutDialog_hpp_
#include "GUI.hpp"
#include <wx/wx.h> #include <wx/wx.h>
#include <wx/intl.h> #include <wx/intl.h>
#include <wx/html/htmlwin.h> #include <wx/html/htmlwin.h>

View file

@ -2,22 +2,18 @@
#include "libslic3r/Utils.hpp" #include "libslic3r/Utils.hpp"
#include "AppConfig.hpp" #include "AppConfig.hpp"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <utility> #include <utility>
#include <assert.h>
#include <vector> #include <vector>
#include <stdexcept> #include <stdexcept>
#include <boost/filesystem.hpp> #include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/nowide/cenv.hpp> #include <boost/nowide/cenv.hpp>
#include <boost/nowide/fstream.hpp> #include <boost/nowide/fstream.hpp>
#include <boost/property_tree/ini_parser.hpp> #include <boost/property_tree/ini_parser.hpp>
#include <boost/property_tree/ptree.hpp> #include <boost/property_tree/ptree_fwd.hpp>
#include <boost/property_tree/exceptions.hpp>
#include <boost/algorithm/string/predicate.hpp> #include <boost/algorithm/string/predicate.hpp>
#include <boost/format.hpp> #include <boost/format/format_fwd.hpp>
#include <wx/string.h> #include <wx/string.h>
#include "I18N.hpp" #include "I18N.hpp"
@ -76,7 +72,7 @@ void AppConfig::set_defaults()
if (get("remember_output_path").empty()) if (get("remember_output_path").empty())
set("remember_output_path", "1"); 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"); set("remember_output_path_removable", "1");
if (get("use_custom_toolbar_size").empty()) if (get("use_custom_toolbar_size").empty())

View file

@ -26,17 +26,16 @@
#include <cassert> #include <cassert>
#include <stdexcept> #include <stdexcept>
#include <cctype> #include <cctype>
#include <algorithm>
#include <boost/format.hpp> #include <boost/format/format_fwd.hpp>
#include <boost/filesystem/path.hpp> #include <boost/filesystem/operations.hpp>
#include <boost/filesystem.hpp>
#include <boost/log/trivial.hpp> #include <boost/log/trivial.hpp>
#include <boost/nowide/cstdio.hpp> #include <boost/nowide/cstdio.hpp>
#include "I18N.hpp" #include "I18N.hpp"
#include "GUI.hpp"
#include "RemovableDriveManager.hpp" #include "RemovableDriveManager.hpp"
#include "slic3r/Utils/Thread.hpp"
namespace Slic3r { namespace Slic3r {
BackgroundSlicingProcess::BackgroundSlicingProcess() BackgroundSlicingProcess::BackgroundSlicingProcess()

View file

@ -5,13 +5,13 @@
#include <condition_variable> #include <condition_variable>
#include <mutex> #include <mutex>
#include <boost/filesystem.hpp> #include <boost/filesystem/path.hpp>
#include <wx/event.h> #include <wx/event.h>
#include "libslic3r/Print.hpp" #include "libslic3r/Print.hpp"
#include "slic3r/Utils/PrintHost.hpp" #include "slic3r/Utils/PrintHost.hpp"
#include "slic3r/Utils/Thread.hpp"
namespace Slic3r { namespace Slic3r {

View file

@ -1755,7 +1755,7 @@ bool ConfigWizard::priv::on_bnt_finish()
page_sla_materials->reload_presets(); page_sla_materials->reload_presets();
// theres no need to check that filament is selected if we have only custom printer // 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 // check, that there is selected at least one filament/material
return check_and_install_missing_materials(T_ANY); return check_and_install_missing_materials(T_ANY);
} }

View file

@ -514,7 +514,7 @@ void TextCtrl::disable() { dynamic_cast<wxTextCtrl*>(window)->Disable(); dynamic
#ifdef __WXGTK__ #ifdef __WXGTK__
void TextCtrl::change_field_value(wxEvent& event) void TextCtrl::change_field_value(wxEvent& event)
{ {
if (bChangedValueEvent = (event.GetEventType()==wxEVT_KEY_UP)) if ((bChangedValueEvent = (event.GetEventType()==wxEVT_KEY_UP)))
on_change_field(); on_change_field();
event.Skip(); event.Skip();
}; };

View file

@ -22,6 +22,8 @@
#include "slic3r/GUI/PresetBundle.hpp" #include "slic3r/GUI/PresetBundle.hpp"
#include "slic3r/GUI/Tab.hpp" #include "slic3r/GUI/Tab.hpp"
#include "slic3r/GUI/GUI_Preview.hpp" #include "slic3r/GUI/GUI_Preview.hpp"
#include "slic3r/GUI/3DBed.hpp"
#include "slic3r/GUI/Camera.hpp"
#include "GUI_App.hpp" #include "GUI_App.hpp"
#include "GUI_ObjectList.hpp" #include "GUI_ObjectList.hpp"
@ -1298,7 +1300,7 @@ void GLCanvas3D::Labels::render(const std::vector<const ModelInstance*>& sorted_
// updates print order strings // updates print order strings
if (sorted_instances.size() > 1) { 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; size_t id = sorted_instances[i]->id().id;
std::vector<Owner>::iterator it = std::find_if(owners.begin(), owners.end(), [id](const Owner& owner) { std::vector<Owner>::iterator it = std::find_if(owners.begin(), owners.end(), [id](const Owner& owner) {
return owner.model_instance_id == id; return owner.model_instance_id == id;
@ -4117,6 +4119,13 @@ Linef3 GLCanvas3D::mouse_ray(const Point& mouse_pos)
return Linef3(_mouse_to_3d(mouse_pos, &z0), _mouse_to_3d(mouse_pos, &z1)); 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 double GLCanvas3D::get_size_proportional_to_max_bed_size(double factor) const
{ {
return factor * m_bed.get_bounding_box(false).max_size(); return factor * m_bed.get_bounding_box(false).max_size();

View file

@ -9,19 +9,18 @@
#include "3DScene.hpp" #include "3DScene.hpp"
#include "GLToolbar.hpp" #include "GLToolbar.hpp"
#include "GLShader.hpp"
#include "Event.hpp" #include "Event.hpp"
#include "3DBed.hpp"
#include "Camera.hpp"
#include "Selection.hpp" #include "Selection.hpp"
#include "Gizmos/GLGizmosManager.hpp" #include "Gizmos/GLGizmosManager.hpp"
#include "GUI_ObjectLayers.hpp" #include "GUI_ObjectLayers.hpp"
#include "GLSelectionRectangle.hpp"
#include "MeshUtils.hpp" #include "MeshUtils.hpp"
#include <float.h> #include <float.h>
#include <wx/timer.h> #include <wx/timer.h>
class wxWindow;
class wxSizeEvent; class wxSizeEvent;
class wxIdleEvent; class wxIdleEvent;
class wxKeyEvent; class wxKeyEvent;
@ -35,8 +34,8 @@ class wxGLCanvas;
namespace Slic3r { namespace Slic3r {
class GLShader; class Bed3D;
class ExPolygon; struct Camera;
class BackgroundSlicingProcess; class BackgroundSlicingProcess;
class GCodePreviewData; class GCodePreviewData;
#if ENABLE_THUMBNAIL_GENERATOR #if ENABLE_THUMBNAIL_GENERATOR
@ -47,8 +46,6 @@ enum LayerHeightEditActionType : unsigned int;
namespace GUI { namespace GUI {
class GLGizmoBase;
#if ENABLE_RETINA_GL #if ENABLE_RETINA_GL
class RetinaHelper; class RetinaHelper;
#endif #endif
@ -670,7 +667,7 @@ public:
Linef3 mouse_ray(const Point& mouse_pos); Linef3 mouse_ray(const Point& mouse_pos);
void set_mouse_as_dragging() { m_mouse.dragging = true; } 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; } bool is_mouse_dragging() const { return m_mouse.dragging; }
double get_size_proportional_to_max_bed_size(double factor) const; double get_size_proportional_to_max_bed_size(double factor) const;

View file

@ -4,8 +4,7 @@
#include "GLToolbar.hpp" #include "GLToolbar.hpp"
#include "../../slic3r/GUI/GLCanvas3D.hpp" #include "../../slic3r/GUI/GLCanvas3D.hpp"
#include "../../slic3r/GUI/Camera.hpp"
#include <GL/glew.h>
#include <wx/event.h> #include <wx/event.h>
#include <wx/bitmap.h> #include <wx/bitmap.h>

View file

@ -483,7 +483,6 @@ void ObjectList::update_extruder_values_for_items(const size_t max_extruder)
void ObjectList::update_objects_list_extruder_column(size_t extruders_count) void ObjectList::update_objects_list_extruder_column(size_t extruders_count)
{ {
if (!this) return; // #ys_FIXME
if (printer_technology() == ptSLA) if (printer_technology() == ptSLA)
extruders_count = 1; extruders_count = 1;
@ -1558,7 +1557,7 @@ wxMenuItem* ObjectList::append_menu_item_settings(wxMenu* menu_)
// If there are selected more then one instance but not all of them // If there are selected more then one instance but not all of them
// don't add settings menu items // don't add settings menu items
const Selection& selection = scene_selection(); 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 selection.is_multiple_volume() || selection.is_mixed() ) // more than one volume(part) is selected on the scene
return nullptr; return nullptr;

View file

@ -1,5 +1,6 @@
#include "GLGizmoHollow.hpp" #include "GLGizmoHollow.hpp"
#include "slic3r/GUI/GLCanvas3D.hpp" #include "slic3r/GUI/GLCanvas3D.hpp"
#include "slic3r/GUI/Camera.hpp"
#include "slic3r/GUI/Gizmos/GLGizmos.hpp" #include "slic3r/GUI/Gizmos/GLGizmos.hpp"
#include <GL/glew.h> #include <GL/glew.h>
@ -99,16 +100,11 @@ void GLGizmoHollow::on_render() const
return; 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_BLEND));
glsafe(::glEnable(GL_DEPTH_TEST)); glsafe(::glEnable(GL_DEPTH_TEST));
m_z_shift = selection.get_volume(*selection.get_volume_idxs().begin())->get_sla_shift_z(); 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()) if (m_quadric != nullptr && selection.is_from_single_instance())
render_points(selection, false); 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, &current_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 void GLGizmoHollow::render_clipping_plane(const Selection& selection) const
{ {
if (m_c->m_clipping_plane_distance == 0.f) 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_plane(*m_c->m_clipping_plane);
m_c->m_object_clipper->set_transformation(trafo); 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) { if (m_c->m_print_object_idx >= 0) {
const SLAPrintObject* print_object = m_parent.sla_print()->objects()[m_c->m_print_object_idx]; 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)); glsafe(::glEnable(GL_DEPTH_TEST));
render_points(selection, true); render_points(selection, true);
render_hollowed_mesh();
} }
void GLGizmoHollow::render_points(const Selection& selection, bool picking) const 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) if (! m_c->m_mesh_raycaster)
return false; 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 Camera& camera = m_parent.get_camera();
const Selection& selection = m_parent.get_selection(); const Selection& selection = m_parent.get_selection();
const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin()); 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) 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().CallAfter([this, postpone_error_messages]() {
wxGetApp().plater()->reslice_SLA_hollowing(*m_c->m_model_object, 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*>> GLGizmoHollow::get_config_options(const std::vector<std::string>& keys) const
{ {
std::vector<std::pair<const ConfigOption*, const ConfigOptionDef*>> out; std::vector<std::pair<const ConfigOption*, const ConfigOptionDef*>> out;
@ -829,7 +721,6 @@ RENDER_AGAIN:
bool remove_selected = false; bool remove_selected = false;
bool remove_all = false; bool remove_all = false;
// m_imgui->text(" "); // vertical gap
ImGui::Separator(); ImGui::Separator();
float diameter_upper_cap = 15.; 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_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); 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 if (m_state == Off && m_old_state != Off) { // the gizmo was just turned Off
//Plater::TakeSnapshot snapshot(wxGetApp().plater(), _(L("SLA gizmo turned off"))); //Plater::TakeSnapshot snapshot(wxGetApp().plater(), _(L("SLA gizmo turned off")));

View file

@ -36,11 +36,6 @@ public:
void delete_selected_points(); void delete_selected_points();
ClippingPlane get_sla_clipping_plane() const; 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(); } bool is_selection_rectangle_dragging() const { return m_selection_rectangle.is_dragging(); }
void update_clipping_plane(bool keep_normal = false) const; void update_clipping_plane(bool keep_normal = false) const;
void set_common_data_ptr(CommonGizmosData* ptr) { m_c = ptr; } 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_points(const Selection& selection, bool picking = false) const;
void render_clipping_plane(const Selection& selection) const; void render_clipping_plane(const Selection& selection) const;
void render_hollowed_mesh() const;
void hollow_mesh(bool postpone_error_messages = false); void hollow_mesh(bool postpone_error_messages = false);
bool unsaved_changes() const; bool unsaved_changes() const;

View file

@ -1,6 +1,7 @@
// Include GLGizmoBase.hpp before I18N.hpp as it includes some libigl code, which overrides our localization "L" macro. // Include GLGizmoBase.hpp before I18N.hpp as it includes some libigl code, which overrides our localization "L" macro.
#include "GLGizmoSlaSupports.hpp" #include "GLGizmoSlaSupports.hpp"
#include "slic3r/GUI/GLCanvas3D.hpp" #include "slic3r/GUI/GLCanvas3D.hpp"
#include "slic3r/GUI/Camera.hpp"
#include "slic3r/GUI/Gizmos/GLGizmos.hpp" #include "slic3r/GUI/Gizmos/GLGizmos.hpp"
#include <GL/glew.h> #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(); 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()) if (m_quadric != nullptr && selection.is_from_single_instance())
render_points(selection, false); 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, &current_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 void GLGizmoSlaSupports::render_clipping_plane(const Selection& selection) const
{ {
if (m_c->m_clipping_plane_distance == 0.f || m_c->m_mesh->empty()) 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)); glsafe(::glEnable(GL_DEPTH_TEST));
render_points(selection, true); render_points(selection, true);
render_hollowed_mesh();
} }
void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking) const void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking) const
@ -627,8 +602,6 @@ void GLGizmoSlaSupports::delete_selected_points(bool force)
} }
select_point(NoPoints); select_point(NoPoints);
//m_parent.post_event(SimpleEvent(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS));
} }
void GLGizmoSlaSupports::on_update(const UpdateData& data) 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.pos = pos_and_normal.first;
m_editing_cache[m_hover_id].support_point.is_new_island = false; m_editing_cache[m_hover_id].support_point.is_new_island = false;
m_editing_cache[m_hover_id].normal = pos_and_normal.second; 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));
} }
} }
} }

View file

@ -93,7 +93,6 @@ private:
//void render_selection_rectangle() const; //void render_selection_rectangle() const;
void render_points(const Selection& selection, bool picking = false) const; void render_points(const Selection& selection, bool picking = false) const;
void render_clipping_plane(const Selection& selection) const; void render_clipping_plane(const Selection& selection) const;
void render_hollowed_mesh() const;
bool unsaved_changes() const; bool unsaved_changes() const;
bool m_lock_unique_islands = false; bool m_lock_unique_islands = false;

View file

@ -8,8 +8,9 @@
#include "slic3r/Utils/UndoRedo.hpp" #include "slic3r/Utils/UndoRedo.hpp"
#include "libslic3r/SLAPrint.hpp" #include "libslic3r/SLAPrint.hpp"
#include "slic3r/GUI/MeshUtils.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> #include <wx/glcanvas.h>
namespace Slic3r { namespace Slic3r {

View file

@ -3,8 +3,8 @@
#include "slic3r/GUI/GLTexture.hpp" #include "slic3r/GUI/GLTexture.hpp"
#include "slic3r/GUI/GLToolbar.hpp" #include "slic3r/GUI/GLToolbar.hpp"
#include "slic3r/GUI/Gizmos/GLGizmos.hpp"
#include "libslic3r/ObjectID.hpp" #include "libslic3r/ObjectID.hpp"
#include "slic3r/GUI/Gizmos/GLGizmoBase.hpp"
#include <map> #include <map>
@ -18,6 +18,8 @@ namespace GUI {
class GLCanvas3D; class GLCanvas3D;
class ClippingPlane; class ClippingPlane;
enum class SLAGizmoEventType : unsigned char;
class CommonGizmosData;
class Rect class Rect
{ {

View file

@ -5,6 +5,8 @@
#include "GUI_ObjectList.hpp" #include "GUI_ObjectList.hpp"
#include "I18N.hpp" #include "I18N.hpp"
#include "libslic3r/Model.hpp"
#include <wx/bmpcbox.h> #include <wx/bmpcbox.h>
#include <wx/dc.h> #include <wx/dc.h>

View file

@ -80,7 +80,6 @@
#include "../Utils/PrintHost.hpp" #include "../Utils/PrintHost.hpp"
#include "../Utils/FixModelByWin10.hpp" #include "../Utils/FixModelByWin10.hpp"
#include "../Utils/UndoRedo.hpp" #include "../Utils/UndoRedo.hpp"
#include "../Utils/Thread.hpp"
#include "RemovableDriveManager.hpp" #include "RemovableDriveManager.hpp"
#include <wx/glcanvas.h> // Needs to be last because reasons :-/ #include <wx/glcanvas.h> // Needs to be last because reasons :-/
@ -1560,8 +1559,7 @@ struct Plater::priv
enum class Jobs : size_t { enum class Jobs : size_t {
Arrange, Arrange,
Rotoptimize, Rotoptimize
Hollow
}; };
class ArrangeJob : public PlaterJob class ArrangeJob : public PlaterJob
@ -1734,22 +1732,6 @@ struct Plater::priv
void process() override; 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 // 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 // run at a time. Also, the background process will be stopped if a job is
@ -1762,7 +1744,6 @@ struct Plater::priv
ArrangeJob arrange_job{m_plater}; ArrangeJob arrange_job{m_plater};
RotoptimizeJob rotoptimize_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 // To create a new job, just define a new subclass of Job, implement
// the process and the optional prepare() and finalize() methods // the process and the optional prepare() and finalize() methods
@ -1770,8 +1751,7 @@ struct Plater::priv
// if it cannot run concurrently with other jobs in this group // if it cannot run concurrently with other jobs in this group
std::vector<std::reference_wrapper<Job>> m_jobs{arrange_job, std::vector<std::reference_wrapper<Job>> m_jobs{arrange_job,
rotoptimize_job, rotoptimize_job};
hollow_job};
public: public:
ExclusiveJobGroup(priv *_plater) : m_plater(_plater) {} ExclusiveJobGroup(priv *_plater) : m_plater(_plater) {}
@ -1874,7 +1854,6 @@ struct Plater::priv
void reset(); void reset();
void mirror(Axis axis); void mirror(Axis axis);
void arrange(); void arrange();
void hollow();
void sla_optimize_rotation(); void sla_optimize_rotation();
void split_object(); void split_object();
void split_volume(); void split_volume();
@ -2818,11 +2797,6 @@ void Plater::priv::arrange()
m_ui_jobs.start(Jobs::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 // This method will find an optimal orientation for the currently selected item
// Very similar in nature to the arrange method above... // Very similar in nature to the arrange method above...
@ -2960,67 +2934,6 @@ void Plater::priv::RotoptimizeJob::process()
: _(L("Orientation found."))); : _(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() void Plater::priv::split_object()
{ {
@ -5131,10 +5044,6 @@ void Plater::export_toolpaths_to_obj() const
p->preview->get_canvas3d()->export_toolpaths_to_obj(into_u8(path).c_str()); p->preview->get_canvas3d()->export_toolpaths_to_obj(into_u8(path).c_str());
} }
void Plater::hollow()
{
p->hollow();
}
void Plater::reslice() void Plater::reslice()
{ {

View file

@ -10,14 +10,11 @@
#include "Preset.hpp" #include "Preset.hpp"
#include "3DScene.hpp" #include "libslic3r/BoundingBox.hpp"
#include "GLTexture.hpp"
#include "wxExtensions.hpp" #include "wxExtensions.hpp"
class wxButton; class wxButton;
class ScalableButton; class ScalableButton;
class wxBoxSizer;
class wxGLCanvas;
class wxScrolledWindow; class wxScrolledWindow;
class wxString; class wxString;
@ -30,9 +27,9 @@ class SLAPrint;
enum SLAPrintObjectStep : unsigned int; enum SLAPrintObjectStep : unsigned int;
namespace UndoRedo { namespace UndoRedo {
class Stack; class Stack;
struct Snapshot; struct Snapshot;
}; }
namespace GUI { namespace GUI {
@ -44,6 +41,7 @@ class ObjectLayers;
class ObjectList; class ObjectList;
class GLCanvas3D; class GLCanvas3D;
class Mouse3DController; class Mouse3DController;
struct Camera;
using t_optgroups = std::vector <std::shared_ptr<ConfigOptionsGroup>>; using t_optgroups = std::vector <std::shared_ptr<ConfigOptionsGroup>>;
@ -200,7 +198,6 @@ public:
void reload_all_from_disk(); void reload_all_from_disk();
bool has_toolpaths_to_export() const; bool has_toolpaths_to_export() const;
void export_toolpaths_to_obj() const; void export_toolpaths_to_obj() const;
void hollow();
void reslice(); void reslice();
void reslice_SLA_supports(const ModelObject &object, bool postpone_error_messages = false); void reslice_SLA_supports(const ModelObject &object, bool postpone_error_messages = false);
void reslice_SLA_hollowing(const ModelObject &object, bool postpone_error_messages = false); void reslice_SLA_hollowing(const ModelObject &object, bool postpone_error_messages = false);

View file

@ -1027,7 +1027,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) it != m_map_alias_to_profile_name.end() && it->first == alias; ++ it)
if (auto it_preset = this->find_preset_internal(it->second); if (auto it_preset = this->find_preset_internal(it->second);
it_preset != m_presets.end() && it_preset->name == 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 it_preset->name;
return alias; return alias;
} }
@ -1089,6 +1089,7 @@ size_t PresetCollection::update_compatible_internal(const PresetWithVendorProfil
bool selected = idx_preset == m_idx_selected; bool selected = idx_preset == m_idx_selected;
Preset &preset_selected = m_presets[idx_preset]; Preset &preset_selected = m_presets[idx_preset];
Preset &preset_edited = selected ? m_edited_preset : preset_selected; Preset &preset_edited = selected ? m_edited_preset : preset_selected;
const PresetWithVendorProfile this_preset_with_vendor_profile = this->get_preset_with_vendor_profile(preset_edited); const PresetWithVendorProfile this_preset_with_vendor_profile = this->get_preset_with_vendor_profile(preset_edited);
bool was_compatible = preset_edited.is_compatible; bool was_compatible = preset_edited.is_compatible;
preset_edited.is_compatible = is_compatible_with_printer(this_preset_with_vendor_profile, active_printer, &config); preset_edited.is_compatible = is_compatible_with_printer(this_preset_with_vendor_profile, active_printer, &config);
@ -1097,7 +1098,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); preset_edited.is_compatible &= is_compatible_with_print(this_preset_with_vendor_profile, *active_print, active_printer);
if (! preset_edited.is_compatible && selected && if (! preset_edited.is_compatible && selected &&
(unselect_if_incompatible == PresetSelectCompatibleType::Always || (unselect_if_incompatible == PresetSelectCompatibleType::OnlyIfWasCompatible && was_compatible))) (unselect_if_incompatible == PresetSelectCompatibleType::Always || (unselect_if_incompatible == PresetSelectCompatibleType::OnlyIfWasCompatible && was_compatible)))
m_idx_selected = -1; m_idx_selected = size_t(-1);
if (selected) if (selected)
preset_selected.is_compatible = preset_edited.is_compatible; preset_selected.is_compatible = preset_edited.is_compatible;
} }
@ -1398,7 +1399,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_init = static_cast<const T*>(other.option(opt_key));
const T* opt_cur = static_cast<const T*>(this_c.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; 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; int init_id = i <= opt_init_max_id ? i : 0;
if (opt_cur->values[i] != opt_init->values[init_id]) if (opt_cur->values[i] != opt_init->values[init_id])

View file

@ -342,9 +342,9 @@ public:
// Return the selected preset, without the user modifications applied. // Return the selected preset, without the user modifications applied.
Preset& get_selected_preset() { return m_presets[m_idx_selected]; } Preset& get_selected_preset() { return m_presets[m_idx_selected]; }
const Preset& get_selected_preset() const { 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. // 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. // For the current edited preset, return the parent preset if there is one.
// If there is no parent preset, nullptr is returned. // If there is no parent preset, nullptr is returned.
// The parent preset may be a system preset or a user preset, which will be // The parent preset may be a system preset or a user preset, which will be
@ -366,7 +366,7 @@ public:
// used to update preset_choice from Tab // used to update preset_choice from Tab
const std::deque<Preset>& get_presets() const { return m_presets; } 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(); static const std::string& get_suffix_modified();
// Return a preset possibly with modifications. // Return a preset possibly with modifications.
@ -374,7 +374,7 @@ public:
const Preset& default_preset(size_t idx = 0) const { assert(idx < m_num_default_presets); return m_presets[idx]; } 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(); } 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. // 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); } 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]; } void discard_current_changes() { m_presets[m_idx_selected].reset_dirty(); m_edited_preset = m_presets[m_idx_selected]; }
@ -542,7 +542,7 @@ private:
// Initially this preset contains a copy of the selected preset. Later on, this copy may be modified by the user. // Initially this preset contains a copy of the selected preset. Later on, this copy may be modified by the user.
Preset m_edited_preset; Preset m_edited_preset;
// Selected preset. // Selected preset.
int m_idx_selected; size_t m_idx_selected;
// Is the "- default -" preset suppressed? // Is the "- default -" preset suppressed?
bool m_default_suppressed = true; bool m_default_suppressed = true;
size_t m_num_default_presets = 0; size_t m_num_default_presets = 0;

View file

@ -29,8 +29,10 @@
#include "libslic3r/libslic3r.h" #include "libslic3r/libslic3r.h"
#include "libslic3r/Utils.hpp" #include "libslic3r/Utils.hpp"
#include "libslic3r/Model.hpp"
#include "GUI_App.hpp" #include "GUI_App.hpp"
// Store the print/filament/printer presets into a "presets" subdirectory of the Slic3rPE config dir. // 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. // This breaks compatibility with the upstream Slic3r if the --datadir is used to switch between the two versions.
// #define SLIC3R_PROFILE_USE_PRESETS_SUBDIR // #define SLIC3R_PROFILE_USE_PRESETS_SUBDIR
@ -971,8 +973,6 @@ static void flatten_configbundle_hierarchy(boost::property_tree::ptree &tree, co
{ {
namespace pt = boost::property_tree; 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. // 1) For the group given by group_name, initialize the presets.
struct Prst { struct Prst {
Prst(const std::string &name, pt::ptree *node) : name(name), node(node) {} Prst(const std::string &name, pt::ptree *node) : name(name), node(node) {}
@ -1332,7 +1332,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. // Derive the profile logical name aka alias from the preset name if the alias was not stated explicitely.
if (alias_name.empty()) { 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) { if (end_pos != std::string::npos) {
alias_name = preset_name.substr(0, end_pos); alias_name = preset_name.substr(0, end_pos);
if (renamed_from.empty()) if (renamed_from.empty())
@ -1735,7 +1735,7 @@ void PresetBundle::update_plater_filament_ui(unsigned int idx_extruder, GUI::Pre
if (selected_preset_item == INT_MAX) if (selected_preset_item == INT_MAX)
selected_preset_item = ui->GetCount() - 1; 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->SetToolTip(tooltip.IsEmpty() ? ui->GetString(selected_preset_item) : tooltip);
ui->check_selection(); ui->check_selection();
ui->Thaw(); ui->Thaw();

View file

@ -4,6 +4,7 @@
#include "PresetBundle.hpp" #include "PresetBundle.hpp"
#include "PresetHints.hpp" #include "PresetHints.hpp"
#include "libslic3r/Utils.hpp" #include "libslic3r/Utils.hpp"
#include "libslic3r/Model.hpp"
#include "slic3r/Utils/Http.hpp" #include "slic3r/Utils/Http.hpp"
#include "slic3r/Utils/PrintHost.hpp" #include "slic3r/Utils/PrintHost.hpp"

View file

@ -182,8 +182,6 @@ std::string FlashAir::timestamp_str() const
auto t = std::time(nullptr); auto t = std::time(nullptr);
auto tm = *std::localtime(&t); auto tm = *std::localtime(&t);
const char *name = get_name();
unsigned long fattime = ((tm.tm_year - 80) << 25) | unsigned long fattime = ((tm.tm_year - 80) << 25) |
((tm.tm_mon + 1) << 21) | ((tm.tm_mon + 1) << 21) |
(tm.tm_mday << 16) | (tm.tm_mday << 16) |

View file

@ -526,8 +526,8 @@ Updates PresetUpdater::priv::get_config_updates(const Semver &old_slic3r_version
existing_idx.load(bundle_path_idx); 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 // 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. // 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); /*const auto existing_recommended = existing_idx.recommended(old_slic3r_version);
/*if (existing_recommended != existing_idx.end() && recommended->config_version == existing_recommended->config_version) { if (existing_recommended != existing_idx.end() && recommended->config_version == existing_recommended->config_version) {
// The user has already seen (and presumably rejected) this update // 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(); BOOST_LOG_TRIVIAL(info) << boost::format("Downloaded index for `%1%` is the same as installed one, not offering an update.") % idx.vendor();
continue; continue;

View file

@ -161,7 +161,7 @@ void init_print(std::vector<TriangleMesh> &&meshes, Slic3r::Print &print, Slic3r
if (verbose_gcode()) if (verbose_gcode())
config.set_key_value("gcode_comments", new ConfigOptionBool(true)); config.set_key_value("gcode_comments", new ConfigOptionBool(true));
for (const TriangleMesh &t : meshes) { for (const TriangleMesh &t : meshes) {
ModelObject *object = model.add_object(); ModelObject *object = model.add_object();
object->name += "object.stl"; object->name += "object.stl";
object->add_volume(std::move(t)); object->add_volume(std::move(t));

View file

@ -277,7 +277,6 @@ SCENARIO( "make_xxx functions produce meshes.") {
GIVEN("make_sphere() function") { GIVEN("make_sphere() function") {
WHEN("make_sphere() is called with arguments 10, PI / 3") { WHEN("make_sphere() is called with arguments 10, PI / 3") {
TriangleMesh sph = make_sphere(10, PI / 243.0); 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") { 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; 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); REQUIRE(std::count_if(verts.begin(), verts.end(), [](const Vec3f& t) { return is_approx(t, Vec3f(0.f, 0.f, 10.f)); } ) == 1);