mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-27 10:41:15 -06:00
Merge remote-tracking branch 'origin/vb_3dscene_partial_update' into tm_sla_supports_backend
This commit is contained in:
commit
013e068d71
6 changed files with 100 additions and 50 deletions
|
|
@ -126,8 +126,16 @@ private:
|
|||
static bool is_end_of_line(char c) { return c == '\r' || c == '\n' || c == 0; }
|
||||
static bool is_end_of_gcode_line(char c) { return c == ';' || is_end_of_line(c); }
|
||||
static bool is_end_of_word(char c) { return is_whitespace(c) || is_end_of_gcode_line(c); }
|
||||
static const char* skip_whitespaces(const char *c) { for (; is_whitespace(*c); ++ c); return c; }
|
||||
static const char* skip_word(const char *c) { for (; ! is_end_of_word(*c); ++ c); return c; }
|
||||
static const char* skip_whitespaces(const char *c) {
|
||||
for (; is_whitespace(*c); ++ c)
|
||||
; // silence -Wempty-body
|
||||
return c;
|
||||
}
|
||||
static const char* skip_word(const char *c) {
|
||||
for (; ! is_end_of_word(*c); ++ c)
|
||||
; // silence -Wempty-body
|
||||
return c;
|
||||
}
|
||||
|
||||
GCodeConfig m_config;
|
||||
char m_extrusion_axis;
|
||||
|
|
|
|||
|
|
@ -15,9 +15,4 @@ std::function<void()> PrintObjectBase::cancel_callback(PrintBase *print)
|
|||
return print->cancel_callback();
|
||||
}
|
||||
|
||||
void PrintObjectBase::throw_if_canceled(PrintBase *print)
|
||||
{
|
||||
print->throw_if_canceled();
|
||||
}
|
||||
|
||||
} // namespace Slic3r
|
||||
|
|
|
|||
|
|
@ -31,12 +31,14 @@ public:
|
|||
DONE,
|
||||
};
|
||||
|
||||
typedef size_t TimeStamp;
|
||||
|
||||
// A new unique timestamp is being assigned to the step every time the step changes its state.
|
||||
struct StateWithTimeStamp
|
||||
{
|
||||
StateWithTimeStamp() : state(INVALID), timestamp(0) {}
|
||||
State state;
|
||||
size_t timestamp;
|
||||
State state;
|
||||
TimeStamp timestamp;
|
||||
};
|
||||
|
||||
protected:
|
||||
|
|
@ -90,13 +92,14 @@ public:
|
|||
// Set the step as done. Block on mutex while the Print / PrintObject / PrintRegion objects are being
|
||||
// modified by the UI thread.
|
||||
template<typename ThrowIfCanceled>
|
||||
void set_done(StepType step, tbb::mutex &mtx, ThrowIfCanceled throw_if_canceled) {
|
||||
TimeStamp set_done(StepType step, tbb::mutex &mtx, ThrowIfCanceled throw_if_canceled) {
|
||||
tbb::mutex::scoped_lock lock(mtx);
|
||||
// If canceled, throw before changing the step state.
|
||||
throw_if_canceled();
|
||||
assert(m_state[step].state != DONE);
|
||||
m_state[step].state = DONE;
|
||||
m_state[step].timestamp = ++ g_last_timestamp;
|
||||
return m_state[step].timestamp;
|
||||
}
|
||||
|
||||
// Make the step invalid.
|
||||
|
|
@ -187,9 +190,6 @@ protected:
|
|||
// Declared here to allow access from PrintBase through friendship.
|
||||
static tbb::mutex& state_mutex(PrintBase *print);
|
||||
static std::function<void()> cancel_callback(PrintBase *print);
|
||||
// If the background processing stop was requested, throw CanceledException.
|
||||
// To be called by the worker thread and its sub-threads (mostly launched on the TBB thread pool) regularly.
|
||||
static void throw_if_canceled(PrintBase *print);
|
||||
|
||||
ModelObject *m_model_object;
|
||||
};
|
||||
|
|
@ -236,16 +236,27 @@ public:
|
|||
|
||||
virtual void process() = 0;
|
||||
|
||||
typedef std::function<void(int, const std::string&)> status_callback_type;
|
||||
struct Status {
|
||||
Status(int percent, const std::string &text, unsigned int flags = 0) : percent(percent), text(text), flags(flags) {}
|
||||
int percent;
|
||||
std::string text;
|
||||
// Bitmap of flags.
|
||||
enum FlagBits {
|
||||
RELOAD_SCENE = 1,
|
||||
};
|
||||
// Bitmap of FlagBits
|
||||
unsigned int flags;
|
||||
};
|
||||
typedef std::function<void(const Status&)> status_callback_type;
|
||||
// Default status console print out in the form of percent => message.
|
||||
void set_status_default() { m_status_callback = nullptr; }
|
||||
// No status output or callback whatsoever, useful mostly for automatic tests.
|
||||
void set_status_silent() { m_status_callback = [](int, const std::string&){}; }
|
||||
void set_status_silent() { m_status_callback = [](const Status&){}; }
|
||||
// Register a custom status callback.
|
||||
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.
|
||||
void set_status(int percent, const std::string &message) {
|
||||
if (m_status_callback) m_status_callback(percent, message);
|
||||
void set_status(int percent, const std::string &message, unsigned int flags = 0) {
|
||||
if (m_status_callback) m_status_callback(Status(percent, message, flags));
|
||||
else printf("%d => %s\n", percent, message.c_str());
|
||||
}
|
||||
|
||||
|
|
@ -309,7 +320,7 @@ public:
|
|||
|
||||
protected:
|
||||
bool set_started(PrintStepEnum step) { return m_state.set_started(step, this->state_mutex(), [this](){ this->throw_if_canceled(); }); }
|
||||
void set_done(PrintStepEnum step) { m_state.set_done(step, this->state_mutex(), [this](){ this->throw_if_canceled(); }); }
|
||||
PrintStateBase::TimeStamp set_done(PrintStepEnum step) { return m_state.set_done(step, this->state_mutex(), [this](){ this->throw_if_canceled(); }); }
|
||||
bool invalidate_step(PrintStepEnum step)
|
||||
{ return m_state.invalidate(step, this->cancel_callback()); }
|
||||
template<typename StepTypeIterator>
|
||||
|
|
@ -339,9 +350,9 @@ protected:
|
|||
PrintObjectBaseWithState(PrintType *print, ModelObject *model_object) : PrintObjectBase(model_object), m_print(print) {}
|
||||
|
||||
bool set_started(PrintObjectStepEnum step)
|
||||
{ return m_state.set_started(step, PrintObjectBase::state_mutex(m_print), [this](){ PrintObjectBase::throw_if_canceled(this->m_print); }); }
|
||||
void set_done(PrintObjectStepEnum step)
|
||||
{ m_state.set_done(step, PrintObjectBase::state_mutex(m_print), [this](){ PrintObjectBase::throw_if_canceled(this->m_print); }); }
|
||||
{ return m_state.set_started(step, PrintObjectBase::state_mutex(m_print), [this](){ this->throw_if_canceled(); }); }
|
||||
PrintStateBase::TimeStamp set_done(PrintObjectStepEnum step)
|
||||
{ return m_state.set_done(step, PrintObjectBase::state_mutex(m_print), [this](){ this->throw_if_canceled(); }); }
|
||||
|
||||
bool invalidate_step(PrintObjectStepEnum step)
|
||||
{ return m_state.invalidate(step, PrintObjectBase::cancel_callback(m_print)); }
|
||||
|
|
@ -354,6 +365,10 @@ protected:
|
|||
{ return m_state.invalidate_all(PrintObjectBase::cancel_callback(m_print)); }
|
||||
|
||||
protected:
|
||||
// If the background processing stop was requested, throw CanceledException.
|
||||
// To be called by the worker thread and its sub-threads (mostly launched on the TBB thread pool) regularly.
|
||||
void throw_if_canceled() { if (m_print->canceled()) throw CanceledException(); }
|
||||
|
||||
friend PrintType;
|
||||
PrintType *m_print;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue