Trigger background processing update when switching to a preview tab.

Implements "Go Direct to the preview screen after slicing #152"
This commit is contained in:
bubnikv 2018-12-11 17:49:31 +01:00
parent 2b9319eea1
commit 09c539a242
7 changed files with 27 additions and 6 deletions

View file

@ -297,7 +297,10 @@ public:
// methods for handling state
bool is_step_done(PrintStep step) const { return Inherited::is_step_done(step); }
// Returns true if an object step is done on all objects and there's at least one object.
bool is_step_done(PrintObjectStep step) const;
// Returns true if the last step was finished with success.
bool finished() const override { return this->is_step_done(psGCodeExport); }
bool has_infinite_skirt() const;
bool has_skirt() const;

View file

@ -285,6 +285,8 @@ public:
void cancel_internal() { m_cancel_status = CANCELED_INTERNAL; }
// Cancel the running computation. Stop execution of all the background threads.
void restart() { m_cancel_status = NOT_CANCELED; }
// Returns true if the last step was finished with success.
virtual bool finished() const = 0;
const PlaceholderParser& placeholder_parser() const { return m_placeholder_parser; }
PlaceholderParser& placeholder_parser() { return m_placeholder_parser; }

View file

@ -936,6 +936,18 @@ bool SLAPrint::invalidate_state_by_config_options(const std::vector<t_config_opt
return invalidated;
}
// Returns true if an object step is done on all objects and there's at least one object.
bool SLAPrint::is_step_done(SLAPrintObjectStep step) const
{
if (m_objects.empty())
return false;
tbb::mutex::scoped_lock lock(this->state_mutex());
for (const SLAPrintObject *object : m_objects)
if (! object->m_state.is_done_unguarded(step))
return false;
return true;
}
SLAPrintObject::SLAPrintObject(SLAPrint *print, ModelObject *model_object):
Inherited(print, model_object),
m_stepmask(slaposCount, true),

View file

@ -185,6 +185,9 @@ public:
bool empty() const override { return m_objects.empty(); }
ApplyStatus apply(const Model &model, const DynamicPrintConfig &config) override;
void process() override;
bool is_step_done(SLAPrintObjectStep step) const;
// Returns true if the last step was finished with success.
bool finished() const override { return this->is_step_done(slaposIndexSlices); }
template<class Fmt> void export_raster(const std::string& fname) {
if(m_printer) m_printer->save<Fmt>(fname);