mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-14 23:05:53 +08:00
Improved progress message
This commit is contained in:
parent
53be240a75
commit
6741b9ba25
@ -471,8 +471,8 @@ int CLI::run(int argc, char **argv)
|
|||||||
sla_print.set_status_callback(
|
sla_print.set_status_callback(
|
||||||
[](const PrintBase::SlicingStatus& s)
|
[](const PrintBase::SlicingStatus& s)
|
||||||
{
|
{
|
||||||
if(s.percent >= 0) // FIXME: is this sufficient?
|
if(s.percent >= 0 && s.args.empty()) // FIXME: is this sufficient?
|
||||||
printf("%3d%s %s\n", s.percent, "% =>", s.text.c_str());
|
printf("%3d%s %s\n", s.percent, "% =>", s.main_text.c_str());
|
||||||
});
|
});
|
||||||
|
|
||||||
PrintBase *print = (printer_technology == ptFFF) ? static_cast<PrintBase*>(&fff_print) : static_cast<PrintBase*>(&sla_print);
|
PrintBase *print = (printer_technology == ptFFF) ? static_cast<PrintBase*>(&fff_print) : static_cast<PrintBase*>(&sla_print);
|
||||||
|
@ -1087,6 +1087,8 @@ void GCode::_do_export(Print& print, FILE* file, ThumbnailsGeneratorCallback thu
|
|||||||
{
|
{
|
||||||
PROFILE_FUNC();
|
PROFILE_FUNC();
|
||||||
|
|
||||||
|
m_last_status_update = std::chrono::system_clock::now();
|
||||||
|
|
||||||
// modifies m_silent_time_estimator_enabled
|
// modifies m_silent_time_estimator_enabled
|
||||||
DoExport::init_gcode_processor(print.config(), m_processor, m_silent_time_estimator_enabled);
|
DoExport::init_gcode_processor(print.config(), m_processor, m_silent_time_estimator_enabled);
|
||||||
|
|
||||||
@ -2712,6 +2714,13 @@ void GCode::process_layer(
|
|||||||
_write(file, gcode);
|
_write(file, gcode);
|
||||||
BOOST_LOG_TRIVIAL(trace) << "Exported layer " << layer.id() << " print_z " << print_z <<
|
BOOST_LOG_TRIVIAL(trace) << "Exported layer " << layer.id() << " print_z " << print_z <<
|
||||||
log_memory_info();
|
log_memory_info();
|
||||||
|
|
||||||
|
|
||||||
|
std::chrono::time_point<std::chrono::system_clock> end_export_layer = std::chrono::system_clock::now();
|
||||||
|
if ((static_cast<std::chrono::duration<double>>(end_export_layer - m_last_status_update)).count() > 0.2) {
|
||||||
|
m_last_status_update = std::chrono::system_clock::now();
|
||||||
|
print.set_status(int((layer.id() * 100) / layer_count()), std::string(L("Generating G-code layer %s / %s")), std::vector<std::string>{ std::to_string(layer.id()), std::to_string(layer_count()) }, PrintBase::SlicingStatus::DEFAULT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GCode::apply_print_config(const PrintConfig &print_config)
|
void GCode::apply_print_config(const PrintConfig &print_config)
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
#ifdef HAS_PRESSURE_EQUALIZER
|
#ifdef HAS_PRESSURE_EQUALIZER
|
||||||
#include "GCode/PressureEqualizer.hpp"
|
#include "GCode/PressureEqualizer.hpp"
|
||||||
@ -409,6 +410,9 @@ private:
|
|||||||
|
|
||||||
bool m_silent_time_estimator_enabled;
|
bool m_silent_time_estimator_enabled;
|
||||||
|
|
||||||
|
//for gui status update
|
||||||
|
std::chrono::time_point<std::chrono::system_clock> m_last_status_update;
|
||||||
|
|
||||||
// Processor
|
// Processor
|
||||||
GCodeProcessor m_processor;
|
GCodeProcessor m_processor;
|
||||||
|
|
||||||
|
@ -389,13 +389,16 @@ public:
|
|||||||
virtual void finalize() {}
|
virtual void finalize() {}
|
||||||
|
|
||||||
struct SlicingStatus {
|
struct SlicingStatus {
|
||||||
SlicingStatus(int percent, const std::string &text, unsigned int flags = 0) : percent(percent), text(text), flags(flags) {}
|
SlicingStatus(int percent, const std::string& text, unsigned int flags = 0) : percent(percent), main_text(text), flags(flags) {}
|
||||||
|
SlicingStatus(int percent, const std::string& text, const std::vector<std::string>& args, unsigned int flags = 0)
|
||||||
|
: percent(percent), main_text(text), args(args), flags(flags) {}
|
||||||
SlicingStatus(const PrintBase &print, int warning_step) :
|
SlicingStatus(const PrintBase &print, int warning_step) :
|
||||||
flags(UPDATE_PRINT_STEP_WARNINGS), warning_object_id(print.id()), warning_step(warning_step) {}
|
flags(UPDATE_PRINT_STEP_WARNINGS), warning_object_id(print.id()), warning_step(warning_step) {}
|
||||||
SlicingStatus(const PrintObjectBase &print_object, int warning_step) :
|
SlicingStatus(const PrintObjectBase &print_object, int warning_step) :
|
||||||
flags(UPDATE_PRINT_OBJECT_STEP_WARNINGS), warning_object_id(print_object.id()), warning_step(warning_step) {}
|
flags(UPDATE_PRINT_OBJECT_STEP_WARNINGS), warning_object_id(print_object.id()), warning_step(warning_step) {}
|
||||||
int percent { -1 };
|
int percent { -1 };
|
||||||
std::string text;
|
std::string main_text;
|
||||||
|
std::vector<std::string> args;
|
||||||
// Bitmap of flags.
|
// Bitmap of flags.
|
||||||
enum FlagBits {
|
enum FlagBits {
|
||||||
DEFAULT = 0,
|
DEFAULT = 0,
|
||||||
@ -422,8 +425,12 @@ public:
|
|||||||
// Register a custom status callback.
|
// Register a custom status callback.
|
||||||
void set_status_callback(status_callback_type cb) { m_status_callback = cb; }
|
void set_status_callback(status_callback_type cb) { m_status_callback = cb; }
|
||||||
// Calls a registered callback to update the status, or print out the default message.
|
// Calls a registered callback to update the status, or print out the default message.
|
||||||
void set_status(int percent, const std::string &message, unsigned int flags = SlicingStatus::DEFAULT) {
|
void set_status(int percent, const std::string& message, unsigned int flags = SlicingStatus::DEFAULT) const {
|
||||||
if (m_status_callback) m_status_callback(SlicingStatus(percent, message, flags));
|
if (m_status_callback) m_status_callback(SlicingStatus(percent, message, flags));
|
||||||
|
else printf("%d => %s\n", percent, message.c_str());
|
||||||
|
}
|
||||||
|
void set_status(int percent, const std::string& message, const std::vector<std::string>& args, unsigned int flags = SlicingStatus::DEFAULT) const {
|
||||||
|
if (m_status_callback) m_status_callback(SlicingStatus(percent, message, args, flags));
|
||||||
else printf("%d => %s\n", percent, message.c_str());
|
else printf("%d => %s\n", percent, message.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,6 +303,11 @@ namespace Slic3r {
|
|||||||
m_typed_slices = false;
|
m_typed_slices = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// atomic counter for gui progress
|
||||||
|
std::atomic<int> atomic_count{ 0 };
|
||||||
|
int nb_layers_update = std::max(1, (int)m_layers.size() / 20);
|
||||||
|
std::chrono::time_point<std::chrono::system_clock> last_update = std::chrono::system_clock::now();
|
||||||
|
|
||||||
// compare each layer to the one below, and mark those slices needing
|
// compare each layer to the one below, and mark those slices needing
|
||||||
// one additional inner perimeter, like the top of domed objects-
|
// one additional inner perimeter, like the top of domed objects-
|
||||||
|
|
||||||
@ -376,10 +381,22 @@ namespace Slic3r {
|
|||||||
BOOST_LOG_TRIVIAL(debug) << "Generating perimeters in parallel - start";
|
BOOST_LOG_TRIVIAL(debug) << "Generating perimeters in parallel - start";
|
||||||
tbb::parallel_for(
|
tbb::parallel_for(
|
||||||
tbb::blocked_range<size_t>(0, m_layers.size()),
|
tbb::blocked_range<size_t>(0, m_layers.size()),
|
||||||
[this](const tbb::blocked_range<size_t>& range) {
|
[this, &atomic_count, &last_update, nb_layers_update](const tbb::blocked_range<size_t>& range) {
|
||||||
for (size_t layer_idx = range.begin(); layer_idx < range.end(); ++layer_idx) {
|
for (size_t layer_idx = range.begin(); layer_idx < range.end(); ++layer_idx) {
|
||||||
|
std::chrono::time_point<std::chrono::system_clock> start_make_perimeter = std::chrono::system_clock::now();
|
||||||
m_print->throw_if_canceled();
|
m_print->throw_if_canceled();
|
||||||
m_layers[layer_idx]->make_perimeters();
|
m_layers[layer_idx]->make_perimeters();
|
||||||
|
|
||||||
|
// updating progress
|
||||||
|
int nb_layers_done = (++atomic_count);
|
||||||
|
std::chrono::time_point<std::chrono::system_clock> end_make_perimeter = std::chrono::system_clock::now();
|
||||||
|
if (nb_layers_done % nb_layers_update == 0 || (static_cast<std::chrono::duration<double>>(end_make_perimeter - start_make_perimeter)).count() > 5) {
|
||||||
|
if ((static_cast<std::chrono::duration<double>>(end_make_perimeter - last_update)).count() > 0.2) {
|
||||||
|
// note: i don't care if a thread erase last_update in-between here
|
||||||
|
last_update = std::chrono::system_clock::now();
|
||||||
|
m_print->set_status( int((nb_layers_done * 100) / m_layers.size()), L("Generating perimeters: layer %s / %s"), { std::to_string(nb_layers_done), std::to_string(m_layers.size()) });
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -548,13 +565,30 @@ namespace Slic3r {
|
|||||||
if (this->set_started(posInfill)) {
|
if (this->set_started(posInfill)) {
|
||||||
auto [adaptive_fill_octree, support_fill_octree] = this->prepare_adaptive_infill_data();
|
auto [adaptive_fill_octree, support_fill_octree] = this->prepare_adaptive_infill_data();
|
||||||
|
|
||||||
|
// atomic counter for gui progress
|
||||||
|
std::atomic<int> atomic_count{ 0 };
|
||||||
|
int nb_layers_update = std::max(1, (int)m_layers.size() / 20);
|
||||||
|
std::chrono::time_point<std::chrono::system_clock> last_update = std::chrono::system_clock::now();
|
||||||
|
|
||||||
BOOST_LOG_TRIVIAL(debug) << "Filling layers in parallel - start";
|
BOOST_LOG_TRIVIAL(debug) << "Filling layers in parallel - start";
|
||||||
tbb::parallel_for(
|
tbb::parallel_for(
|
||||||
tbb::blocked_range<size_t>(0, m_layers.size()),
|
tbb::blocked_range<size_t>(0, m_layers.size()),
|
||||||
[this, &adaptive_fill_octree = adaptive_fill_octree, &support_fill_octree = support_fill_octree](const tbb::blocked_range<size_t>& range) {
|
[this, &adaptive_fill_octree = adaptive_fill_octree, &support_fill_octree = support_fill_octree, &atomic_count , &last_update, nb_layers_update](const tbb::blocked_range<size_t>& range) {
|
||||||
for (size_t layer_idx = range.begin(); layer_idx < range.end(); ++layer_idx) {
|
for (size_t layer_idx = range.begin(); layer_idx < range.end(); ++layer_idx) {
|
||||||
|
std::chrono::time_point<std::chrono::system_clock> start_make_fill = std::chrono::system_clock::now();
|
||||||
m_print->throw_if_canceled();
|
m_print->throw_if_canceled();
|
||||||
m_layers[layer_idx]->make_fills(adaptive_fill_octree.get(), support_fill_octree.get());
|
m_layers[layer_idx]->make_fills(adaptive_fill_octree.get(), support_fill_octree.get());
|
||||||
|
|
||||||
|
// updating progress
|
||||||
|
int nb_layers_done = (++atomic_count);
|
||||||
|
std::chrono::time_point<std::chrono::system_clock> end_make_fill = std::chrono::system_clock::now();
|
||||||
|
if (nb_layers_done % nb_layers_update == 0 || (static_cast<std::chrono::duration<double>>(end_make_fill - start_make_fill)).count() > 5) {
|
||||||
|
if ((static_cast<std::chrono::duration<double>>(end_make_fill - last_update)).count() > 0.2) {
|
||||||
|
// note: i don't care if a thread erase last_update in-between here
|
||||||
|
last_update = std::chrono::system_clock::now();
|
||||||
|
m_print->set_status( int((nb_layers_done * 100) / m_layers.size()), L("Infilling layer %s / %s"), { std::to_string(nb_layers_done), std::to_string(m_layers.size()) });
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -3675,7 +3675,24 @@ void Plater::priv::on_slicing_update(SlicingStatusEvent &evt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
this->statusbar()->set_progress(evt.status.percent);
|
this->statusbar()->set_progress(evt.status.percent);
|
||||||
this->statusbar()->set_status_text(_(evt.status.text) + wxString::FromUTF8("…"));
|
if (evt.status.args.empty()) {
|
||||||
|
this->statusbar()->set_status_text(_(evt.status.main_text) + wxString::FromUTF8("…"));
|
||||||
|
} else {
|
||||||
|
std::vector<wxString> arg_lst;
|
||||||
|
for (std::string str : evt.status.args)
|
||||||
|
arg_lst.push_back(_(str));
|
||||||
|
//FIXME use var-args list
|
||||||
|
if (arg_lst.size() == 1)
|
||||||
|
this->statusbar()->set_status_text(wxString::Format(_(evt.status.main_text), arg_lst[0]));
|
||||||
|
else if (arg_lst.size() == 2)
|
||||||
|
this->statusbar()->set_status_text(wxString::Format(_(evt.status.main_text), arg_lst[0], arg_lst[1]));
|
||||||
|
else if (arg_lst.size() == 3)
|
||||||
|
this->statusbar()->set_status_text(wxString::Format(_(evt.status.main_text), arg_lst[0], arg_lst[1], arg_lst[2]));
|
||||||
|
else if (arg_lst.size() == 4)
|
||||||
|
this->statusbar()->set_status_text(wxString::Format(_(evt.status.main_text), arg_lst[0], arg_lst[1], arg_lst[2], arg_lst[3]));
|
||||||
|
else
|
||||||
|
this->statusbar()->set_status_text(wxString::Format(_(evt.status.main_text), arg_lst[0], arg_lst[1], arg_lst[2], arg_lst[3], arg_lst[4]));
|
||||||
|
}
|
||||||
//notification_manager->set_progress_bar_percentage("Slicing progress", (float)evt.status.percent / 100.0f);
|
//notification_manager->set_progress_bar_percentage("Slicing progress", (float)evt.status.percent / 100.0f);
|
||||||
}
|
}
|
||||||
if (evt.status.flags & (PrintBase::SlicingStatus::RELOAD_SCENE | PrintBase::SlicingStatus::RELOAD_SLA_SUPPORT_POINTS)) {
|
if (evt.status.flags & (PrintBase::SlicingStatus::RELOAD_SCENE | PrintBase::SlicingStatus::RELOAD_SLA_SUPPORT_POINTS)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user