diff options
Diffstat (limited to 'src/slic3r/GUI/BackgroundSlicingProcess.hpp')
-rw-r--r-- | src/slic3r/GUI/BackgroundSlicingProcess.hpp | 73 |
1 files changed, 56 insertions, 17 deletions
diff --git a/src/slic3r/GUI/BackgroundSlicingProcess.hpp b/src/slic3r/GUI/BackgroundSlicingProcess.hpp index d091ecb31..b3f8a0a6b 100644 --- a/src/slic3r/GUI/BackgroundSlicingProcess.hpp +++ b/src/slic3r/GUI/BackgroundSlicingProcess.hpp @@ -5,18 +5,20 @@ #include <condition_variable> #include <mutex> -#include <boost/filesystem.hpp> - #include <wx/event.h> -#include "libslic3r/Print.hpp" +#include "libslic3r/PrintBase.hpp" +#include "libslic3r/GCode/ThumbnailData.hpp" +#include "libslic3r/Format/SL1.hpp" #include "slic3r/Utils/PrintHost.hpp" -#include "slic3r/Utils/Thread.hpp" +#include "libslic3r/GCode/GCodeProcessor.hpp" + + +namespace boost { namespace filesystem { class path; } } namespace Slic3r { class DynamicPrintConfig; -class GCodePreviewData; class Model; class SLAPrint; @@ -30,6 +32,39 @@ public: PrintBase::SlicingStatus status; }; +class SlicingProcessCompletedEvent : public wxEvent +{ +public: + enum StatusType { + Finished, + Cancelled, + Error + }; + + SlicingProcessCompletedEvent(wxEventType eventType, int winid, StatusType status, std::exception_ptr exception) : + wxEvent(winid, eventType), m_status(status), m_exception(exception) {} + virtual wxEvent* Clone() const { return new SlicingProcessCompletedEvent(*this); } + + StatusType status() const { return m_status; } + bool finished() const { return m_status == Finished; } + bool success() const { return m_status == Finished; } + bool cancelled() const { return m_status == Cancelled; } + bool error() const { return m_status == Error; } + // Unhandled error produced by stdlib or a Win32 structured exception, or unhandled Slic3r's own critical exception. + bool critical_error() const; + // Critical errors does invalidate plater except CopyFileError. + bool invalidate_plater() const; + // Only valid if error() + void rethrow_exception() const { assert(this->error()); assert(m_exception); std::rethrow_exception(m_exception); } + // Produce a human readable message to be displayed by a notification or a message box. + // 2nd parameter defines whether the output should be displayed with a monospace font. + std::pair<std::string, bool> format_error_message() const; + +private: + StatusType m_status; + std::exception_ptr m_exception; +}; + wxDEFINE_EVENT(EVT_SLICING_UPDATE, SlicingStatusEvent); // Print step IDs for keeping track of the print state. @@ -47,11 +82,9 @@ public: ~BackgroundSlicingProcess(); void set_fff_print(Print *print) { m_fff_print = print; } - void set_sla_print(SLAPrint *print) { m_sla_print = print; } - void set_gcode_preview_data(GCodePreviewData *gpd) { m_gcode_preview_data = gpd; } -#if ENABLE_THUMBNAIL_GENERATOR - void set_thumbnail_cb(ThumbnailsGeneratorCallback cb) { m_thumbnail_cb = cb; } -#endif // ENABLE_THUMBNAIL_GENERATOR + void set_sla_print(SLAPrint *print) { m_sla_print = print; m_sla_print->set_printer(&m_sla_archive); } + void set_thumbnail_cb(ThumbnailsGeneratorCallback cb) { m_thumbnail_cb = cb; } + void set_gcode_result(GCodeProcessor::Result* result) { m_gcode_result = result; } // The following wxCommandEvent will be sent to the UI thread / Plater window, when the slicing is finished // and the background processing will transition into G-code export. @@ -60,6 +93,10 @@ public: // The following wxCommandEvent will be sent to the UI thread / Plater window, when the G-code export is finished. // The wxCommandEvent is sent to the UI thread asynchronously without waiting for the event to be processed. void set_finished_event(int event_id) { m_event_finished_id = event_id; } + // The following wxCommandEvent will be sent to the UI thread / Plater window, when the G-code is being exported to + // specified path or uploaded. + // The wxCommandEvent is sent to the UI thread asynchronously without waiting for the event to be processed. + void set_export_began_event(int event_id) { m_event_export_began_id = event_id; } // Activate either m_fff_print or m_sla_print. // Return true if changed. @@ -86,7 +123,7 @@ public: // Apply config over the print. Returns false, if the new config values caused any of the already // processed steps to be invalidated, therefore the task will need to be restarted. - Print::ApplyStatus apply(const Model &model, const DynamicPrintConfig &config); + PrintBase::ApplyStatus apply(const Model &model, const DynamicPrintConfig &config); // After calling the apply() function, set_task() may be called to limit the task to be processed by process(). // This is useful for calculating SLA supports for a single object only. void set_task(const PrintBase::TaskParams ¶ms); @@ -154,12 +191,11 @@ private: Print *m_fff_print = nullptr; SLAPrint *m_sla_print = nullptr; // Data structure, to which the G-code export writes its annotations. - GCodePreviewData *m_gcode_preview_data = nullptr; -#if ENABLE_THUMBNAIL_GENERATOR - // Callback function, used to write thumbnails into gcode. - ThumbnailsGeneratorCallback m_thumbnail_cb = nullptr; -#endif // ENABLE_THUMBNAIL_GENERATOR - // Temporary G-code, there is one defined for the BackgroundSlicingProcess, differentiated from the other processes by a process ID. + GCodeProcessor::Result *m_gcode_result = nullptr; + // Callback function, used to write thumbnails into gcode. + ThumbnailsGeneratorCallback m_thumbnail_cb = nullptr; + SL1Archive m_sla_archive; + // Temporary G-code, there is one defined for the BackgroundSlicingProcess, differentiated from the other processes by a process ID. std::string m_temp_output_path; // Output path provided by the user. The output path may be set even if the slicing is running, // but once set, it cannot be re-set. @@ -191,6 +227,9 @@ private: int m_event_slicing_completed_id = 0; // wxWidgets command ID to be sent to the plater to inform that the task finished. int m_event_finished_id = 0; + // wxWidgets command ID to be sent to the plater to inform that the G-code is being exported. + int m_event_export_began_id = 0; + }; }; // namespace Slic3r |