mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 09:17:52 -06:00
Merge branch 'master' of https://github.com/prusa3d/PrusaSlicer into et_splitted_vbuffer
This commit is contained in:
commit
5161643fc6
22 changed files with 257 additions and 184 deletions
2
deps/wxWidgets/wxWidgets.cmake
vendored
2
deps/wxWidgets/wxWidgets.cmake
vendored
|
@ -1,4 +1,4 @@
|
||||||
if (APPLE AND ${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm")
|
if (APPLE)
|
||||||
# The new OSX 11 (Big Sur) is not compatible with wxWidgets 3.1.3.
|
# The new OSX 11 (Big Sur) is not compatible with wxWidgets 3.1.3.
|
||||||
# Let's use patched wxWidgets 3.1.4, even though it is not quite tested.
|
# Let's use patched wxWidgets 3.1.4, even though it is not quite tested.
|
||||||
set(_wx_git_tag v3.1.4-patched)
|
set(_wx_git_tag v3.1.4-patched)
|
||||||
|
|
|
@ -57,6 +57,12 @@
|
||||||
|
|
||||||
using namespace Slic3r;
|
using namespace Slic3r;
|
||||||
|
|
||||||
|
static PrinterTechnology get_printer_technology(const DynamicConfig &config)
|
||||||
|
{
|
||||||
|
const ConfigOptionEnum<PrinterTechnology> *opt = config.option<ConfigOptionEnum<PrinterTechnology>>("printer_technology");
|
||||||
|
return (opt == nullptr) ? ptUnknown : opt->value;
|
||||||
|
}
|
||||||
|
|
||||||
int CLI::run(int argc, char **argv)
|
int CLI::run(int argc, char **argv)
|
||||||
{
|
{
|
||||||
// Mark the main thread for the debugger and for runtime checks.
|
// Mark the main thread for the debugger and for runtime checks.
|
||||||
|
@ -95,7 +101,7 @@ int CLI::run(int argc, char **argv)
|
||||||
m_extra_config.apply(m_config, true);
|
m_extra_config.apply(m_config, true);
|
||||||
m_extra_config.normalize_fdm();
|
m_extra_config.normalize_fdm();
|
||||||
|
|
||||||
PrinterTechnology printer_technology = Slic3r::printer_technology(m_config);
|
PrinterTechnology printer_technology = get_printer_technology(m_config);
|
||||||
|
|
||||||
bool start_gui = m_actions.empty() &&
|
bool start_gui = m_actions.empty() &&
|
||||||
// cutting transformations are setting an "export" action.
|
// cutting transformations are setting an "export" action.
|
||||||
|
@ -130,7 +136,7 @@ int CLI::run(int argc, char **argv)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
config.normalize_fdm();
|
config.normalize_fdm();
|
||||||
PrinterTechnology other_printer_technology = Slic3r::printer_technology(config);
|
PrinterTechnology other_printer_technology = get_printer_technology(config);
|
||||||
if (printer_technology == ptUnknown) {
|
if (printer_technology == ptUnknown) {
|
||||||
printer_technology = other_printer_technology;
|
printer_technology = other_printer_technology;
|
||||||
} else if (printer_technology != other_printer_technology && other_printer_technology != ptUnknown) {
|
} else if (printer_technology != other_printer_technology && other_printer_technology != ptUnknown) {
|
||||||
|
@ -167,7 +173,7 @@ int CLI::run(int argc, char **argv)
|
||||||
// When loading an AMF or 3MF, config is imported as well, including the printer technology.
|
// When loading an AMF or 3MF, config is imported as well, including the printer technology.
|
||||||
DynamicPrintConfig config;
|
DynamicPrintConfig config;
|
||||||
model = Model::read_from_file(file, &config, true);
|
model = Model::read_from_file(file, &config, true);
|
||||||
PrinterTechnology other_printer_technology = Slic3r::printer_technology(config);
|
PrinterTechnology other_printer_technology = get_printer_technology(config);
|
||||||
if (printer_technology == ptUnknown) {
|
if (printer_technology == ptUnknown) {
|
||||||
printer_technology = other_printer_technology;
|
printer_technology = other_printer_technology;
|
||||||
}
|
}
|
||||||
|
@ -197,6 +203,10 @@ int CLI::run(int argc, char **argv)
|
||||||
// Normalizing after importing the 3MFs / AMFs
|
// Normalizing after importing the 3MFs / AMFs
|
||||||
m_print_config.normalize_fdm();
|
m_print_config.normalize_fdm();
|
||||||
|
|
||||||
|
if (printer_technology == ptUnknown)
|
||||||
|
printer_technology = std::find(m_actions.begin(), m_actions.end(), "export_sla") == m_actions.end() ? ptFFF : ptSLA;
|
||||||
|
m_print_config.option<ConfigOptionEnum<PrinterTechnology>>("printer_technology", true)->value = printer_technology;
|
||||||
|
|
||||||
// Initialize full print configs for both the FFF and SLA technologies.
|
// Initialize full print configs for both the FFF and SLA technologies.
|
||||||
FullPrintConfig fff_print_config;
|
FullPrintConfig fff_print_config;
|
||||||
SLAFullPrintConfig sla_print_config;
|
SLAFullPrintConfig sla_print_config;
|
||||||
|
@ -205,9 +215,8 @@ int CLI::run(int argc, char **argv)
|
||||||
if (printer_technology == ptFFF) {
|
if (printer_technology == ptFFF) {
|
||||||
fff_print_config.apply(m_print_config, true);
|
fff_print_config.apply(m_print_config, true);
|
||||||
m_print_config.apply(fff_print_config, true);
|
m_print_config.apply(fff_print_config, true);
|
||||||
} else if (printer_technology == ptSLA) {
|
} else {
|
||||||
// The default value has to be different from the one in fff mode.
|
assert(printer_technology == ptSLA);
|
||||||
sla_print_config.printer_technology.value = ptSLA;
|
|
||||||
sla_print_config.output_filename_format.value = "[input_filename_base].sl1";
|
sla_print_config.output_filename_format.value = "[input_filename_base].sl1";
|
||||||
|
|
||||||
// The default bed shape should reflect the default display parameters
|
// The default bed shape should reflect the default display parameters
|
||||||
|
@ -220,11 +229,13 @@ int CLI::run(int argc, char **argv)
|
||||||
m_print_config.apply(sla_print_config, true);
|
m_print_config.apply(sla_print_config, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
std::string validity = m_print_config.validate();
|
std::string validity = m_print_config.validate();
|
||||||
if (!validity.empty()) {
|
if (! validity.empty()) {
|
||||||
boost::nowide::cerr << "error: " << validity << std::endl;
|
boost::nowide::cerr << "Error: The composite configation is not valid: " << validity << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Loop through transform options.
|
// Loop through transform options.
|
||||||
bool user_center_specified = false;
|
bool user_center_specified = false;
|
||||||
|
@ -481,12 +492,6 @@ int CLI::run(int argc, char **argv)
|
||||||
if (printer_technology == ptFFF) {
|
if (printer_technology == ptFFF) {
|
||||||
for (auto* mo : model.objects)
|
for (auto* mo : model.objects)
|
||||||
fff_print.auto_assign_extruders(mo);
|
fff_print.auto_assign_extruders(mo);
|
||||||
} else {
|
|
||||||
// The default for "output_filename_format" is good for FDM: "[input_filename_base].gcode"
|
|
||||||
// Replace it with a reasonable SLA default.
|
|
||||||
std::string &format = m_print_config.opt_string("output_filename_format", true);
|
|
||||||
if (format == static_cast<const ConfigOptionString*>(m_print_config.def()->get("output_filename_format")->default_value.get())->value)
|
|
||||||
format = "[input_filename_base].SL1";
|
|
||||||
}
|
}
|
||||||
print->apply(model, m_print_config);
|
print->apply(model, m_print_config);
|
||||||
std::string err = print->validate();
|
std::string err = print->validate();
|
||||||
|
@ -647,6 +652,7 @@ bool CLI::setup(int argc, char **argv)
|
||||||
set_logging_level(opt_loglevel->value);
|
set_logging_level(opt_loglevel->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//FIXME Validating at this stage most likely does not make sense, as the config is not fully initialized yet.
|
||||||
std::string validity = m_config.validate();
|
std::string validity = m_config.validate();
|
||||||
|
|
||||||
// Initialize with defaults.
|
// Initialize with defaults.
|
||||||
|
@ -656,6 +662,7 @@ bool CLI::setup(int argc, char **argv)
|
||||||
|
|
||||||
set_data_dir(m_config.opt_string("datadir"));
|
set_data_dir(m_config.opt_string("datadir"));
|
||||||
|
|
||||||
|
//FIXME Validating at this stage most likely does not make sense, as the config is not fully initialized yet.
|
||||||
if (!validity.empty()) {
|
if (!validity.empty()) {
|
||||||
boost::nowide::cerr << "error: " << validity << std::endl;
|
boost::nowide::cerr << "error: " << validity << std::endl;
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -2591,10 +2591,10 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
|
||||||
throw Slic3r::InvalidArgument("Invalid speed");
|
throw Slic3r::InvalidArgument("Invalid speed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this->on_first_layer())
|
|
||||||
speed = m_config.get_abs_value("first_layer_speed", speed);
|
|
||||||
if (m_volumetric_speed != 0. && speed == 0)
|
if (m_volumetric_speed != 0. && speed == 0)
|
||||||
speed = m_volumetric_speed / path.mm3_per_mm;
|
speed = m_volumetric_speed / path.mm3_per_mm;
|
||||||
|
if (this->on_first_layer())
|
||||||
|
speed = m_config.get_abs_value("first_layer_speed", speed);
|
||||||
if (m_config.max_volumetric_speed.value > 0) {
|
if (m_config.max_volumetric_speed.value > 0) {
|
||||||
// cap speed with max_volumetric_speed anyway (even if user is not using autospeed)
|
// cap speed with max_volumetric_speed anyway (even if user is not using autospeed)
|
||||||
speed = std::min(
|
speed = std::min(
|
||||||
|
|
|
@ -928,7 +928,11 @@ void PresetBundle::load_config_file_config_bundle(const std::string &path, const
|
||||||
if (opt_compatible->type() == coStrings)
|
if (opt_compatible->type() == coStrings)
|
||||||
static_cast<ConfigOptionStrings*>(opt_compatible)->values.clear();
|
static_cast<ConfigOptionStrings*>(opt_compatible)->values.clear();
|
||||||
}
|
}
|
||||||
collection_dst.load_preset(path, preset_name_dst, std::move(preset_src->config), activate).is_external = true;
|
(collection_dst.type() == Preset::TYPE_FILAMENT ?
|
||||||
|
collection_dst.load_preset(path, preset_name_dst, preset_src->config, activate) :
|
||||||
|
// Only move the source config for non filament profiles, as single filament profile may be referenced multiple times.
|
||||||
|
collection_dst.load_preset(path, preset_name_dst, std::move(preset_src->config), activate))
|
||||||
|
.is_external = true;
|
||||||
return preset_name_dst;
|
return preset_name_dst;
|
||||||
};
|
};
|
||||||
load_one(this->prints, tmp_bundle.prints, tmp_bundle.prints .get_selected_preset_name(), true);
|
load_one(this->prints, tmp_bundle.prints, tmp_bundle.prints .get_selected_preset_name(), true);
|
||||||
|
|
|
@ -1400,8 +1400,12 @@ std::string Print::validate() const
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto validate_extrusion_width = [min_nozzle_diameter, max_nozzle_diameter](const ConfigBase &config, const char *opt_key, double layer_height, std::string &err_msg) -> bool {
|
auto validate_extrusion_width = [min_nozzle_diameter, max_nozzle_diameter](const ConfigBase &config, const char *opt_key, double layer_height, std::string &err_msg) -> bool {
|
||||||
double extrusion_width_min = config.get_abs_value(opt_key, min_nozzle_diameter);
|
// This may change in the future, if we switch to "extrusion width wrt. nozzle diameter"
|
||||||
double extrusion_width_max = config.get_abs_value(opt_key, max_nozzle_diameter);
|
// instead of currently used logic "extrusion width wrt. layer height", see GH issues #1923 #2829.
|
||||||
|
// double extrusion_width_min = config.get_abs_value(opt_key, min_nozzle_diameter);
|
||||||
|
// double extrusion_width_max = config.get_abs_value(opt_key, max_nozzle_diameter);
|
||||||
|
double extrusion_width_min = config.get_abs_value(opt_key, layer_height);
|
||||||
|
double extrusion_width_max = config.get_abs_value(opt_key, layer_height);
|
||||||
if (extrusion_width_min == 0) {
|
if (extrusion_width_min == 0) {
|
||||||
// Default "auto-generated" extrusion width is always valid.
|
// Default "auto-generated" extrusion width is always valid.
|
||||||
} else if (extrusion_width_min <= layer_height) {
|
} else if (extrusion_width_min <= layer_height) {
|
||||||
|
|
|
@ -3299,15 +3299,20 @@ DynamicPrintConfig* DynamicPrintConfig::new_from_defaults_keys(const std::vector
|
||||||
|
|
||||||
double min_object_distance(const ConfigBase &cfg)
|
double min_object_distance(const ConfigBase &cfg)
|
||||||
{
|
{
|
||||||
|
const ConfigOptionEnum<PrinterTechnology> *opt_printer_technology = cfg.option<ConfigOptionEnum<PrinterTechnology>>("printer_technology");
|
||||||
|
auto printer_technology = opt_printer_technology ? opt_printer_technology->value : ptUnknown;
|
||||||
|
|
||||||
double ret = 0.;
|
double ret = 0.;
|
||||||
|
|
||||||
if (printer_technology(cfg) == ptSLA) ret = 6.;
|
if (printer_technology == ptSLA)
|
||||||
|
ret = 6.;
|
||||||
else {
|
else {
|
||||||
auto ecr_opt = cfg.option<ConfigOptionFloat>("extruder_clearance_radius");
|
auto ecr_opt = cfg.option<ConfigOptionFloat>("extruder_clearance_radius");
|
||||||
auto dd_opt = cfg.option<ConfigOptionFloat>("duplicate_distance");
|
auto dd_opt = cfg.option<ConfigOptionFloat>("duplicate_distance");
|
||||||
auto co_opt = cfg.option<ConfigOptionBool>("complete_objects");
|
auto co_opt = cfg.option<ConfigOptionBool>("complete_objects");
|
||||||
|
|
||||||
if (!ecr_opt || !dd_opt || !co_opt) ret = 0.;
|
if (!ecr_opt || !dd_opt || !co_opt)
|
||||||
|
ret = 0.;
|
||||||
else {
|
else {
|
||||||
// min object distance is max(duplicate_distance, clearance_radius)
|
// min object distance is max(duplicate_distance, clearance_radius)
|
||||||
ret = (co_opt->value && ecr_opt->value > dd_opt->value) ?
|
ret = (co_opt->value && ecr_opt->value > dd_opt->value) ?
|
||||||
|
@ -3318,21 +3323,6 @@ double min_object_distance(const ConfigBase &cfg)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
PrinterTechnology printer_technology(const ConfigBase &cfg)
|
|
||||||
{
|
|
||||||
const ConfigOptionEnum<PrinterTechnology> *opt = cfg.option<ConfigOptionEnum<PrinterTechnology>>("printer_technology");
|
|
||||||
|
|
||||||
if (opt) return opt->value;
|
|
||||||
|
|
||||||
const ConfigOptionBool *export_opt = cfg.option<ConfigOptionBool>("export_sla");
|
|
||||||
if (export_opt && export_opt->getBool()) return ptSLA;
|
|
||||||
|
|
||||||
export_opt = cfg.option<ConfigOptionBool>("export_gcode");
|
|
||||||
if (export_opt && export_opt->getBool()) return ptFFF;
|
|
||||||
|
|
||||||
return ptUnknown;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DynamicPrintConfig::normalize_fdm()
|
void DynamicPrintConfig::normalize_fdm()
|
||||||
{
|
{
|
||||||
if (this->has("extruder")) {
|
if (this->has("extruder")) {
|
||||||
|
|
|
@ -246,7 +246,7 @@ extern const PrintConfigDef print_config_def;
|
||||||
|
|
||||||
class StaticPrintConfig;
|
class StaticPrintConfig;
|
||||||
|
|
||||||
PrinterTechnology printer_technology(const ConfigBase &cfg);
|
// Minimum object distance for arrangement, based on printer technology.
|
||||||
double min_object_distance(const ConfigBase &cfg);
|
double min_object_distance(const ConfigBase &cfg);
|
||||||
|
|
||||||
// Slic3r dynamic configuration, used to override the configuration
|
// Slic3r dynamic configuration, used to override the configuration
|
||||||
|
|
|
@ -111,10 +111,15 @@
|
||||||
</dict>
|
</dict>
|
||||||
</array>
|
</array>
|
||||||
<key>LSMinimumSystemVersion</key>
|
<key>LSMinimumSystemVersion</key>
|
||||||
<string>10.9</string>
|
<string>10.10</string>
|
||||||
<key>NSPrincipalClass</key>
|
<key>NSPrincipalClass</key>
|
||||||
<string>NSApplication</string>
|
<string>NSApplication</string>
|
||||||
<key>NSHighResolutionCapable</key>
|
<key>NSHighResolutionCapable</key>
|
||||||
<true/>
|
<true/>
|
||||||
|
<key>LSEnvironment</key>
|
||||||
|
<dict>
|
||||||
|
<key>ASAN_OPTIONS</key>
|
||||||
|
<string>detect_container_overflow=0</string>
|
||||||
</dict>
|
</dict>
|
||||||
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|
|
@ -158,6 +158,8 @@ set(SLIC3R_GUI_SOURCES
|
||||||
GUI/PrintHostDialogs.hpp
|
GUI/PrintHostDialogs.hpp
|
||||||
GUI/Jobs/Job.hpp
|
GUI/Jobs/Job.hpp
|
||||||
GUI/Jobs/Job.cpp
|
GUI/Jobs/Job.cpp
|
||||||
|
GUI/Jobs/PlaterJob.hpp
|
||||||
|
GUI/Jobs/PlaterJob.cpp
|
||||||
GUI/Jobs/ArrangeJob.hpp
|
GUI/Jobs/ArrangeJob.hpp
|
||||||
GUI/Jobs/ArrangeJob.cpp
|
GUI/Jobs/ArrangeJob.cpp
|
||||||
GUI/Jobs/RotoptimizeJob.hpp
|
GUI/Jobs/RotoptimizeJob.hpp
|
||||||
|
|
|
@ -1377,7 +1377,7 @@ void GLCanvas3D::update_instance_printable_state_for_object(const size_t obj_idx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas3D::update_instance_printable_state_for_objects(std::vector<size_t>& object_idxs)
|
void GLCanvas3D::update_instance_printable_state_for_objects(const std::vector<size_t>& object_idxs)
|
||||||
{
|
{
|
||||||
for (size_t obj_idx : object_idxs)
|
for (size_t obj_idx : object_idxs)
|
||||||
update_instance_printable_state_for_object(obj_idx);
|
update_instance_printable_state_for_object(obj_idx);
|
||||||
|
|
|
@ -565,7 +565,7 @@ public:
|
||||||
void toggle_sla_auxiliaries_visibility(bool visible, const ModelObject* mo = nullptr, int instance_idx = -1);
|
void toggle_sla_auxiliaries_visibility(bool visible, const ModelObject* mo = nullptr, int instance_idx = -1);
|
||||||
void toggle_model_objects_visibility(bool visible, const ModelObject* mo = nullptr, int instance_idx = -1);
|
void toggle_model_objects_visibility(bool visible, const ModelObject* mo = nullptr, int instance_idx = -1);
|
||||||
void update_instance_printable_state_for_object(size_t obj_idx);
|
void update_instance_printable_state_for_object(size_t obj_idx);
|
||||||
void update_instance_printable_state_for_objects(std::vector<size_t>& object_idxs);
|
void update_instance_printable_state_for_objects(const std::vector<size_t>& object_idxs);
|
||||||
|
|
||||||
void set_config(const DynamicPrintConfig* config);
|
void set_config(const DynamicPrintConfig* config);
|
||||||
void set_process(BackgroundSlicingProcess* process);
|
void set_process(BackgroundSlicingProcess* process);
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
#include "slic3r/GUI/GLCanvas3D.hpp"
|
#include "slic3r/GUI/GLCanvas3D.hpp"
|
||||||
#include "slic3r/GUI/GUI.hpp"
|
#include "slic3r/GUI/GUI.hpp"
|
||||||
|
|
||||||
|
#include "libnest2d/common.hpp"
|
||||||
|
|
||||||
namespace Slic3r { namespace GUI {
|
namespace Slic3r { namespace GUI {
|
||||||
|
|
||||||
// Cache the wti info
|
// Cache the wti info
|
||||||
|
@ -140,6 +142,19 @@ void ArrangeJob::prepare()
|
||||||
wxGetKeyState(WXK_SHIFT) ? prepare_selected() : prepare_all();
|
wxGetKeyState(WXK_SHIFT) ? prepare_selected() : prepare_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ArrangeJob::on_exception(const std::exception_ptr &eptr)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
if (eptr)
|
||||||
|
std::rethrow_exception(eptr);
|
||||||
|
} catch (libnest2d::GeometryException &) {
|
||||||
|
show_error(m_plater, _(L("Could not arrange model objects! "
|
||||||
|
"Some geometries may be invalid.")));
|
||||||
|
} catch (std::exception &e) {
|
||||||
|
PlaterJob::on_exception(eptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ArrangeJob::process()
|
void ArrangeJob::process()
|
||||||
{
|
{
|
||||||
static const auto arrangestr = _(L("Arranging"));
|
static const auto arrangestr = _(L("Arranging"));
|
||||||
|
@ -151,13 +166,11 @@ void ArrangeJob::process()
|
||||||
params.allow_rotations = settings.enable_rotation;
|
params.allow_rotations = settings.enable_rotation;
|
||||||
params.min_obj_distance = scaled(settings.distance);
|
params.min_obj_distance = scaled(settings.distance);
|
||||||
|
|
||||||
|
|
||||||
auto count = unsigned(m_selected.size() + m_unprintable.size());
|
auto count = unsigned(m_selected.size() + m_unprintable.size());
|
||||||
Points bedpts = get_bed_shape(*m_plater->config());
|
Points bedpts = get_bed_shape(*m_plater->config());
|
||||||
|
|
||||||
params.stopcondition = [this]() { return was_canceled(); };
|
params.stopcondition = [this]() { return was_canceled(); };
|
||||||
|
|
||||||
try {
|
|
||||||
params.progressind = [this, count](unsigned st) {
|
params.progressind = [this, count](unsigned st) {
|
||||||
st += m_unprintable.size();
|
st += m_unprintable.size();
|
||||||
if (st > 0) update_status(int(count - st), arrangestr);
|
if (st > 0) update_status(int(count - st), arrangestr);
|
||||||
|
@ -170,11 +183,6 @@ void ArrangeJob::process()
|
||||||
};
|
};
|
||||||
|
|
||||||
arrangement::arrange(m_unprintable, {}, bedpts, params);
|
arrangement::arrange(m_unprintable, {}, bedpts, params);
|
||||||
} catch (std::exception & /*e*/) {
|
|
||||||
GUI::show_error(m_plater,
|
|
||||||
_(L("Could not arrange model objects! "
|
|
||||||
"Some geometries may be invalid.")));
|
|
||||||
}
|
|
||||||
|
|
||||||
// finalize just here.
|
// finalize just here.
|
||||||
update_status(int(count),
|
update_status(int(count),
|
||||||
|
|
|
@ -1,17 +1,13 @@
|
||||||
#ifndef ARRANGEJOB_HPP
|
#ifndef ARRANGEJOB_HPP
|
||||||
#define ARRANGEJOB_HPP
|
#define ARRANGEJOB_HPP
|
||||||
|
|
||||||
#include "Job.hpp"
|
#include "PlaterJob.hpp"
|
||||||
#include "libslic3r/Arrange.hpp"
|
#include "libslic3r/Arrange.hpp"
|
||||||
|
|
||||||
namespace Slic3r { namespace GUI {
|
namespace Slic3r { namespace GUI {
|
||||||
|
|
||||||
class Plater;
|
class ArrangeJob : public PlaterJob
|
||||||
|
|
||||||
class ArrangeJob : public Job
|
|
||||||
{
|
{
|
||||||
Plater *m_plater;
|
|
||||||
|
|
||||||
using ArrangePolygon = arrangement::ArrangePolygon;
|
using ArrangePolygon = arrangement::ArrangePolygon;
|
||||||
using ArrangePolygons = arrangement::ArrangePolygons;
|
using ArrangePolygons = arrangement::ArrangePolygons;
|
||||||
|
|
||||||
|
@ -31,9 +27,11 @@ protected:
|
||||||
|
|
||||||
void prepare() override;
|
void prepare() override;
|
||||||
|
|
||||||
|
void on_exception(const std::exception_ptr &) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ArrangeJob(std::shared_ptr<ProgressIndicator> pri, Plater *plater)
|
ArrangeJob(std::shared_ptr<ProgressIndicator> pri, Plater *plater)
|
||||||
: Job{std::move(pri)}, m_plater{plater}
|
: PlaterJob{std::move(pri), plater}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
int status_range() const override
|
int status_range() const override
|
||||||
|
|
|
@ -7,9 +7,8 @@ namespace Slic3r { namespace GUI {
|
||||||
|
|
||||||
class Plater;
|
class Plater;
|
||||||
|
|
||||||
class FillBedJob : public Job
|
class FillBedJob : public PlaterJob
|
||||||
{
|
{
|
||||||
Plater *m_plater;
|
|
||||||
int m_object_idx = -1;
|
int m_object_idx = -1;
|
||||||
|
|
||||||
using ArrangePolygon = arrangement::ArrangePolygon;
|
using ArrangePolygon = arrangement::ArrangePolygon;
|
||||||
|
@ -28,7 +27,7 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FillBedJob(std::shared_ptr<ProgressIndicator> pri, Plater *plater)
|
FillBedJob(std::shared_ptr<ProgressIndicator> pri, Plater *plater)
|
||||||
: Job{std::move(pri)}, m_plater{plater}
|
: PlaterJob{std::move(pri), plater}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
int status_range() const override
|
int status_range() const override
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <exception>
|
||||||
|
|
||||||
#include "Job.hpp"
|
#include "Job.hpp"
|
||||||
#include <libslic3r/Thread.hpp>
|
#include <libslic3r/Thread.hpp>
|
||||||
|
@ -6,10 +7,15 @@
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
void GUI::Job::run()
|
void GUI::Job::run(std::exception_ptr &eptr)
|
||||||
{
|
{
|
||||||
m_running.store(true);
|
m_running.store(true);
|
||||||
|
try {
|
||||||
process();
|
process();
|
||||||
|
} catch (...) {
|
||||||
|
eptr = std::current_exception();
|
||||||
|
}
|
||||||
|
|
||||||
m_running.store(false);
|
m_running.store(false);
|
||||||
|
|
||||||
// ensure to call the last status to finalize the job
|
// ensure to call the last status to finalize the job
|
||||||
|
@ -29,18 +35,25 @@ GUI::Job::Job(std::shared_ptr<ProgressIndicator> pri)
|
||||||
{
|
{
|
||||||
Bind(wxEVT_THREAD, [this](const wxThreadEvent &evt) {
|
Bind(wxEVT_THREAD, [this](const wxThreadEvent &evt) {
|
||||||
auto msg = evt.GetString();
|
auto msg = evt.GetString();
|
||||||
if (!msg.empty())
|
if (!msg.empty() && !m_worker_error)
|
||||||
m_progress->set_status_text(msg.ToUTF8().data());
|
m_progress->set_status_text(msg.ToUTF8().data());
|
||||||
|
|
||||||
if (m_finalized) return;
|
if (m_finalized) return;
|
||||||
|
|
||||||
m_progress->set_progress(evt.GetInt());
|
m_progress->set_progress(evt.GetInt());
|
||||||
if (evt.GetInt() == status_range()) {
|
if (evt.GetInt() == status_range() || m_worker_error) {
|
||||||
// set back the original range and cancel callback
|
// set back the original range and cancel callback
|
||||||
m_progress->set_range(m_range);
|
m_progress->set_range(m_range);
|
||||||
m_progress->set_cancel_callback();
|
m_progress->set_cancel_callback();
|
||||||
wxEndBusyCursor();
|
wxEndBusyCursor();
|
||||||
|
|
||||||
|
if (m_worker_error) {
|
||||||
|
m_finalized = true;
|
||||||
|
m_progress->set_status_text("");
|
||||||
|
m_progress->set_progress(m_range);
|
||||||
|
on_exception(m_worker_error);
|
||||||
|
}
|
||||||
|
else
|
||||||
finalize();
|
finalize();
|
||||||
|
|
||||||
// dont do finalization again for the same process
|
// dont do finalization again for the same process
|
||||||
|
@ -69,7 +82,8 @@ void GUI::Job::start()
|
||||||
wxBeginBusyCursor();
|
wxBeginBusyCursor();
|
||||||
|
|
||||||
try { // Execute the job
|
try { // Execute the job
|
||||||
m_thread = create_thread([this] { this->run(); });
|
m_worker_error = nullptr;
|
||||||
|
m_thread = create_thread([this] { this->run(m_worker_error); });
|
||||||
} catch (std::exception &) {
|
} catch (std::exception &) {
|
||||||
update_status(status_range(),
|
update_status(status_range(),
|
||||||
_(L("ERROR: not enough resources to "
|
_(L("ERROR: not enough resources to "
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define JOB_HPP
|
#define JOB_HPP
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
#include <exception>
|
||||||
|
|
||||||
#include "libslic3r/libslic3r.h"
|
#include "libslic3r/libslic3r.h"
|
||||||
|
|
||||||
|
@ -32,8 +33,9 @@ class Job : public wxEvtHandler
|
||||||
std::atomic<bool> m_running{false}, m_canceled{false};
|
std::atomic<bool> m_running{false}, m_canceled{false};
|
||||||
bool m_finalized = false;
|
bool m_finalized = false;
|
||||||
std::shared_ptr<ProgressIndicator> m_progress;
|
std::shared_ptr<ProgressIndicator> m_progress;
|
||||||
|
std::exception_ptr m_worker_error = nullptr;
|
||||||
|
|
||||||
void run();
|
void run(std::exception_ptr &);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// status range for a particular job
|
// status range for a particular job
|
||||||
|
@ -50,6 +52,8 @@ protected:
|
||||||
// Launched when the job is finished. It refreshes the 3Dscene by def.
|
// Launched when the job is finished. It refreshes the 3Dscene by def.
|
||||||
virtual void finalize() { m_finalized = true; }
|
virtual void finalize() { m_finalized = true; }
|
||||||
|
|
||||||
|
virtual void on_exception(const std::exception_ptr &) {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Job(std::shared_ptr<ProgressIndicator> pri);
|
Job(std::shared_ptr<ProgressIndicator> pri);
|
||||||
|
|
||||||
|
|
17
src/slic3r/GUI/Jobs/PlaterJob.cpp
Normal file
17
src/slic3r/GUI/Jobs/PlaterJob.cpp
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#include "PlaterJob.hpp"
|
||||||
|
#include "slic3r/GUI/GUI.hpp"
|
||||||
|
#include "slic3r/GUI/Plater.hpp"
|
||||||
|
|
||||||
|
namespace Slic3r { namespace GUI {
|
||||||
|
|
||||||
|
void PlaterJob::on_exception(const std::exception_ptr &eptr)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
if (eptr)
|
||||||
|
std::rethrow_exception(eptr);
|
||||||
|
} catch (std::exception &e) {
|
||||||
|
show_error(m_plater, _(L("An unexpected error occured: ")) + e.what());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}} // namespace Slic3r::GUI
|
24
src/slic3r/GUI/Jobs/PlaterJob.hpp
Normal file
24
src/slic3r/GUI/Jobs/PlaterJob.hpp
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
#ifndef PLATERJOB_HPP
|
||||||
|
#define PLATERJOB_HPP
|
||||||
|
|
||||||
|
#include "Job.hpp"
|
||||||
|
|
||||||
|
namespace Slic3r { namespace GUI {
|
||||||
|
|
||||||
|
class Plater;
|
||||||
|
|
||||||
|
class PlaterJob : public Job {
|
||||||
|
protected:
|
||||||
|
Plater *m_plater;
|
||||||
|
|
||||||
|
void on_exception(const std::exception_ptr &) override;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
PlaterJob(std::shared_ptr<ProgressIndicator> pri, Plater *plater):
|
||||||
|
Job{std::move(pri)}, m_plater{plater} {}
|
||||||
|
};
|
||||||
|
|
||||||
|
}} // namespace Slic3r::GUI
|
||||||
|
|
||||||
|
#endif // PLATERJOB_HPP
|
|
@ -1,18 +1,15 @@
|
||||||
#ifndef ROTOPTIMIZEJOB_HPP
|
#ifndef ROTOPTIMIZEJOB_HPP
|
||||||
#define ROTOPTIMIZEJOB_HPP
|
#define ROTOPTIMIZEJOB_HPP
|
||||||
|
|
||||||
#include "Job.hpp"
|
#include "PlaterJob.hpp"
|
||||||
|
|
||||||
namespace Slic3r { namespace GUI {
|
namespace Slic3r { namespace GUI {
|
||||||
|
|
||||||
class Plater;
|
class RotoptimizeJob : public PlaterJob
|
||||||
|
|
||||||
class RotoptimizeJob : public Job
|
|
||||||
{
|
{
|
||||||
Plater *m_plater;
|
|
||||||
public:
|
public:
|
||||||
RotoptimizeJob(std::shared_ptr<ProgressIndicator> pri, Plater *plater)
|
RotoptimizeJob(std::shared_ptr<ProgressIndicator> pri, Plater *plater)
|
||||||
: Job{std::move(pri)}, m_plater{plater}
|
: PlaterJob{std::move(pri), plater}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void process() override;
|
void process() override;
|
||||||
|
|
|
@ -124,7 +124,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
SLAImportJob::SLAImportJob(std::shared_ptr<ProgressIndicator> pri, Plater *plater)
|
SLAImportJob::SLAImportJob(std::shared_ptr<ProgressIndicator> pri, Plater *plater)
|
||||||
: Job{std::move(pri)}, p{std::make_unique<priv>(plater)}
|
: PlaterJob{std::move(pri), plater}, p{std::make_unique<priv>(plater)}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
SLAImportJob::~SLAImportJob() = default;
|
SLAImportJob::~SLAImportJob() = default;
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
#ifndef SLAIMPORTJOB_HPP
|
#ifndef SLAIMPORTJOB_HPP
|
||||||
#define SLAIMPORTJOB_HPP
|
#define SLAIMPORTJOB_HPP
|
||||||
|
|
||||||
#include "Job.hpp"
|
#include "PlaterJob.hpp"
|
||||||
|
|
||||||
namespace Slic3r { namespace GUI {
|
namespace Slic3r { namespace GUI {
|
||||||
|
|
||||||
class Plater;
|
class SLAImportJob : public PlaterJob {
|
||||||
|
|
||||||
class SLAImportJob : public Job {
|
|
||||||
class priv;
|
class priv;
|
||||||
|
|
||||||
std::unique_ptr<priv> p;
|
std::unique_ptr<priv> p;
|
||||||
|
|
|
@ -6111,8 +6111,10 @@ void Plater::changed_objects(const std::vector<size_t>& object_idxs)
|
||||||
// pulls the correct data, update the 3D scene.
|
// pulls the correct data, update the 3D scene.
|
||||||
this->p->update_restart_background_process(true, false);
|
this->p->update_restart_background_process(true, false);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
p->view3D->reload_scene(false);
|
p->view3D->reload_scene(false);
|
||||||
|
p->view3D->get_canvas3d()->update_instance_printable_state_for_objects(object_idxs);
|
||||||
|
}
|
||||||
|
|
||||||
// update print
|
// update print
|
||||||
this->p->schedule_background_process();
|
this->p->schedule_background_process();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue