OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::PlaterWorker< WorkerSubclass >::PlaterJob Class Reference
Inheritance diagram for Slic3r::GUI::PlaterWorker< WorkerSubclass >::PlaterJob:
Collaboration diagram for Slic3r::GUI::PlaterWorker< WorkerSubclass >::PlaterJob:

Public Types

enum  JobPrepareState { PREPARE_STATE_DEFAULT = 0 , PREPARE_STATE_MENU = 1 }

Public Member Functions

void process (Ctl &c) override
void finalize (bool canceled, std::exception_ptr &eptr) override
 PlaterJob (wxWindow *p, std::shared_ptr< Job > j)
 ~PlaterJob () override

Private Attributes

std::shared_ptr< Job > m_job
wxWindow * m_plater
long long m_process_duration

Detailed Description

template<class WorkerSubclass>
class Slic3r::GUI::PlaterWorker< WorkerSubclass >::PlaterJob

Member Enumeration Documentation

◆ JobPrepareState

Enumerator
PREPARE_STATE_DEFAULT 
PREPARE_STATE_MENU 
22 {
25 };
@ PREPARE_STATE_MENU
Definition Job.hpp:24
@ PREPARE_STATE_DEFAULT
Definition Job.hpp:23

Constructor & Destructor Documentation

◆ PlaterJob()

template<class WorkerSubclass>
Slic3r::GUI::PlaterWorker< WorkerSubclass >::PlaterJob::PlaterJob ( wxWindow * p,
std::shared_ptr< Job > j )
inline
114 {
115 // TODO: decide if disabling slice button during UI job is what we
116 // want.
117 // if (m_plater)
118 // m_plater->sidebar().enable_buttons(false);
119 }
wxWindow * m_plater
Definition PlaterWorker.hpp:35
std::shared_ptr< Job > m_job
Definition PlaterWorker.hpp:34
Definition PlaterWorker.hpp:29

References m_job, and m_plater.

◆ ~PlaterJob()

template<class WorkerSubclass>
Slic3r::GUI::PlaterWorker< WorkerSubclass >::PlaterJob::~PlaterJob ( )
inlineoverride
122 {
123 // TODO: decide if disabling slice button during UI job is what we want.
124
125 // Reload scene ensures that the slice button gets properly
126 // enabled or disabled after the job finishes, depending on the
127 // state of slicing. This might be an overkill but works for now.
128 // if (m_plater)
129 // m_plater->canvas3D()->reload_scene(false);
130 }

Member Function Documentation

◆ finalize()

template<class WorkerSubclass>
void Slic3r::GUI::PlaterWorker< WorkerSubclass >::PlaterJob::finalize ( bool canceled,
std::exception_ptr & eptr )
inlineoverridevirtual

Reimplemented from Slic3r::GUI::Job.

88 {
89 using namespace std::chrono;
91 m_job->finalize(canceled, eptr);
94
95 // Bound first so typeid's operand is not a call. typeid evaluates it for a
96 // polymorphic type, which clang reports as -Wpotentially-evaluated-expression.
97 const Job &job = *m_job;
99 << std::fixed // do not use scientific notations
100 << "Job '" << typeid(job).name() << "' "
101 << "spend " << m_process_duration + finalize_duration << "ms "
102 << "(process " << m_process_duration << "ms + finalize " << finalize_duration << "ms)";
103
104 if (eptr) try {
106 } catch (std::exception &e) {
107 show_error(m_plater, _L("An unexpected error occurred") + ": " + from_u8(e.what()));
108 eptr = nullptr;
109 }
110 }
#define _L(s)
Definition OBJ.cpp:34
long long m_process_duration
Definition PlaterWorker.hpp:36
void show_error(wxWindow *parent, const wxString &message, bool has_code_excerpts)
Definition GUI.cpp:296
wxString from_u8(const std::string &str)
Definition GUI.cpp:544

References _L, Slic3r::GUI::from_u8(), m_job, m_plater, m_process_duration, and Slic3r::GUI::show_error().

Here is the call graph for this function:

◆ process()

template<class WorkerSubclass>
void Slic3r::GUI::PlaterWorker< WorkerSubclass >::PlaterJob::process ( Ctl & c)
inlineoverridevirtual

Implements Slic3r::GUI::Job.

40 {
41 // Ensure that wxWidgets processing wakes up to handle outgoing
42 // messages in plater's wxIdle handler. Otherwise it might happen
43 // that the message will only be processed when an event like mouse
44 // move comes along which might be too late.
45 struct WakeUpCtl: Ctl {
46 Ctl &ctl;
47 WakeUpCtl(Ctl &c) : ctl{c} {}
48
49 void update_status(int st, const std::string &msg = "") override
50 {
51 ctl.update_status(st, msg);
53 }
54
55 bool was_canceled() const override { return ctl.was_canceled(); }
56
58 {
59 auto ftr = ctl.call_on_main_thread(std::move(fn));
61
62 return ftr;
63 }
64
65 void clear_percent() override {
66 ctl.clear_percent();
68 }
69
70 void show_error_info(const std::string &msg, int code, const std::string &description, const std::string &extra) override
71 {
72 ctl.show_error_info(msg, code, description, extra);
74 }
75
76 } wctl{c};
77
79
80 using namespace std::chrono;
82 m_job->process(wctl);
85 }
Definition Job.hpp:29

References Slic3r::GUI::Job::Ctl::call_on_main_thread(), Slic3r::GUI::Job::Ctl::clear_percent(), m_job, m_process_duration, Slic3r::GUI::Job::Ctl::show_error_info(), Slic3r::GUI::Job::Ctl::update_status(), and Slic3r::GUI::Job::Ctl::was_canceled().

Here is the call graph for this function:

Member Data Documentation

◆ m_job

template<class WorkerSubclass>
std::shared_ptr<Job> Slic3r::GUI::PlaterWorker< WorkerSubclass >::PlaterJob::m_job
private

Referenced by PlaterJob(), finalize(), and process().

◆ m_plater

template<class WorkerSubclass>
wxWindow* Slic3r::GUI::PlaterWorker< WorkerSubclass >::PlaterJob::m_plater
private

Referenced by PlaterJob(), and finalize().

◆ m_process_duration

template<class WorkerSubclass>
long long Slic3r::GUI::PlaterWorker< WorkerSubclass >::PlaterJob::m_process_duration
private

Referenced by finalize(), and process().


The documentation for this class was generated from the following file: