mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 08:47:52 -06:00
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:
parent
2b9319eea1
commit
09c539a242
7 changed files with 27 additions and 6 deletions
|
@ -297,7 +297,10 @@ public:
|
||||||
|
|
||||||
// methods for handling state
|
// methods for handling state
|
||||||
bool is_step_done(PrintStep step) const { return Inherited::is_step_done(step); }
|
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;
|
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_infinite_skirt() const;
|
||||||
bool has_skirt() const;
|
bool has_skirt() const;
|
||||||
|
|
|
@ -285,6 +285,8 @@ public:
|
||||||
void cancel_internal() { m_cancel_status = CANCELED_INTERNAL; }
|
void cancel_internal() { m_cancel_status = CANCELED_INTERNAL; }
|
||||||
// Cancel the running computation. Stop execution of all the background threads.
|
// Cancel the running computation. Stop execution of all the background threads.
|
||||||
void restart() { m_cancel_status = NOT_CANCELED; }
|
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; }
|
const PlaceholderParser& placeholder_parser() const { return m_placeholder_parser; }
|
||||||
PlaceholderParser& placeholder_parser() { return m_placeholder_parser; }
|
PlaceholderParser& placeholder_parser() { return m_placeholder_parser; }
|
||||||
|
|
|
@ -936,6 +936,18 @@ bool SLAPrint::invalidate_state_by_config_options(const std::vector<t_config_opt
|
||||||
return invalidated;
|
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):
|
SLAPrintObject::SLAPrintObject(SLAPrint *print, ModelObject *model_object):
|
||||||
Inherited(print, model_object),
|
Inherited(print, model_object),
|
||||||
m_stepmask(slaposCount, true),
|
m_stepmask(slaposCount, true),
|
||||||
|
|
|
@ -185,6 +185,9 @@ public:
|
||||||
bool empty() const override { return m_objects.empty(); }
|
bool empty() const override { return m_objects.empty(); }
|
||||||
ApplyStatus apply(const Model &model, const DynamicPrintConfig &config) override;
|
ApplyStatus apply(const Model &model, const DynamicPrintConfig &config) override;
|
||||||
void process() 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) {
|
template<class Fmt> void export_raster(const std::string& fname) {
|
||||||
if(m_printer) m_printer->save<Fmt>(fname);
|
if(m_printer) m_printer->save<Fmt>(fname);
|
||||||
|
|
|
@ -110,6 +110,11 @@ public:
|
||||||
State state() const { return m_state; }
|
State state() const { return m_state; }
|
||||||
bool idle() const { return m_state == STATE_IDLE; }
|
bool idle() const { return m_state == STATE_IDLE; }
|
||||||
bool running() const { return m_state == STATE_STARTED || m_state == STATE_RUNNING || m_state == STATE_FINISHED || m_state == STATE_CANCELED; }
|
bool running() const { return m_state == STATE_STARTED || m_state == STATE_RUNNING || m_state == STATE_FINISHED || m_state == STATE_CANCELED; }
|
||||||
|
// Returns true if the last step of the active print was finished with success.
|
||||||
|
// The "finished" flag is reset by the apply() method, if it changes the state of the print.
|
||||||
|
// This "finished" flag does not account for the final export of the output file (.gcode or zipped PNGs),
|
||||||
|
// and it does not account for the OctoPrint scheduling.
|
||||||
|
bool finished() const { return m_print->finished(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void thread_proc();
|
void thread_proc();
|
||||||
|
|
|
@ -2212,6 +2212,7 @@ void Plater::priv::set_current_panel(wxPanel* panel)
|
||||||
}
|
}
|
||||||
else if (current_panel == preview)
|
else if (current_panel == preview)
|
||||||
{
|
{
|
||||||
|
this->q->reslice();
|
||||||
preview->reload_print();
|
preview->reload_print();
|
||||||
preview->set_canvas_as_dirty();
|
preview->set_canvas_as_dirty();
|
||||||
}
|
}
|
||||||
|
@ -3064,7 +3065,7 @@ void Plater::reslice()
|
||||||
#else
|
#else
|
||||||
this->p->canvas3D->reload_scene(false);
|
this->p->canvas3D->reload_scene(false);
|
||||||
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
|
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
|
||||||
if ((state & priv::UPDATE_BACKGROUND_PROCESS_INVALID) == 0 && !this->p->background_process.running()) {
|
if ((state & priv::UPDATE_BACKGROUND_PROCESS_INVALID) == 0 && !this->p->background_process.running() && !this->p->background_process.finished()) {
|
||||||
// The print is valid and it can be started.
|
// The print is valid and it can be started.
|
||||||
if (this->p->background_process.start())
|
if (this->p->background_process.start())
|
||||||
this->p->statusbar()->set_cancel_callback([this]() {
|
this->p->statusbar()->set_cancel_callback([this]() {
|
||||||
|
|
|
@ -49,8 +49,6 @@ _constant()
|
||||||
Ref<StaticPrintConfig> config()
|
Ref<StaticPrintConfig> config()
|
||||||
%code%{ RETVAL = &THIS->config(); %};
|
%code%{ RETVAL = &THIS->config(); %};
|
||||||
Points copies();
|
Points copies();
|
||||||
t_layer_height_ranges layer_height_ranges()
|
|
||||||
%code%{ RETVAL = THIS->layer_height_ranges; %};
|
|
||||||
std::vector<double> layer_height_profile()
|
std::vector<double> layer_height_profile()
|
||||||
%code%{ RETVAL = THIS->layer_height_profile; %};
|
%code%{ RETVAL = THIS->layer_height_profile; %};
|
||||||
Clone<BoundingBox> bounding_box();
|
Clone<BoundingBox> bounding_box();
|
||||||
|
@ -58,9 +56,6 @@ _constant()
|
||||||
Points _shifted_copies()
|
Points _shifted_copies()
|
||||||
%code%{ RETVAL = THIS->copies(); %};
|
%code%{ RETVAL = THIS->copies(); %};
|
||||||
|
|
||||||
void set_layer_height_ranges(t_layer_height_ranges layer_height_ranges)
|
|
||||||
%code%{ THIS->layer_height_ranges = layer_height_ranges; %};
|
|
||||||
|
|
||||||
size_t layer_count();
|
size_t layer_count();
|
||||||
Ref<Layer> get_layer(int idx);
|
Ref<Layer> get_layer(int idx);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue