OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::SLAImportJob Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/Jobs/SLAImportJob.hpp>

Inheritance diagram for Slic3r::GUI::SLAImportJob:
Collaboration diagram for Slic3r::GUI::SLAImportJob:

Classes

class  priv

Public Types

enum  JobPrepareState { PREPARE_STATE_DEFAULT = 0 , PREPARE_STATE_MENU = 1 }

Public Member Functions

void prepare ()
void process (Ctl &ctl) override
void finalize (bool canceled, std::exception_ptr &) override
 SLAImportJob (const SLAImportJobView *)
 ~SLAImportJob ()
void reset ()

Private Types

using Sel = SLAImportJobView::Sel

Private Attributes

std::unique_ptr< priv > p

Detailed Description

Member Typedef Documentation

◆ Sel

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

◆ SLAImportJob()

Slic3r::GUI::SLAImportJob::SLAImportJob ( const SLAImportJobView * view)
47 : p{std::make_unique<priv>(wxGetApp().plater(), view)}
48{
49 prepare();
50}
std::unique_ptr< priv > p
Definition SLAImportJob.hpp:29
void prepare()
Definition SLAImportJob.cpp:97
static Plater * plater()
Definition GUI_Factories.cpp:400

References Slic3r::make_unique(), p, Slic3r::GUI::plater(), and prepare().

Here is the call graph for this function:

◆ ~SLAImportJob()

Slic3r::GUI::SLAImportJob::~SLAImportJob ( )
default

Member Function Documentation

◆ finalize()

void Slic3r::GUI::SLAImportJob::finalize ( bool canceled,
std::exception_ptr & eptr )
overridevirtual

Reimplemented from Slic3r::GUI::Job.

110{
111 // Ignore the arrange result if aborted.
112 if (canceled || eptr)
113 return;
114
115 if (!p->err.empty()) {
116 show_error(p->plater, p->err);
117 p->err = "";
118 return;
119 }
120
121 std::string name = wxFileName(p->path).GetName().ToUTF8().data();
122
123 if (p->profile.empty()) {
124 p->plater->get_notification_manager()->push_notification(
127 _u8L("The imported SLA archive did not contain any presets. "
128 "The current SLA presets were used as fallback."));
129 }
130
131 if (p->sel != Sel::modelOnly) {
132 if (p->profile.empty())
133 p->profile = p->plater->sla_print().full_print_config();
134
135 const ModelObjectPtrs& objects = p->plater->model().objects;
136 for (auto object : objects)
137 if (object->volumes.size() > 1)
138 {
140 _(L("You cannot load an SLA project with a multi-part object on the bed")) + "\n\n" +
141 _(L("Please check your object list before preset changing.")),
142 _(L("Attention!")) );
143 return;
144 }
145
146 DynamicPrintConfig config = {};
147 config.apply(SLAFullPrintConfig::defaults());
148 config += std::move(p->profile);
149
150 wxGetApp().preset_bundle->load_config_model(name, std::move(config));
151 wxGetApp().load_current_presets();
152 }
153
154 if (!p->mesh.empty()) {
155 bool is_centered = false;
156 p->plater->sidebar().obj_list()->load_mesh_object(TriangleMesh{std::move(p->mesh)},
157 name, is_centered);
158 }
159
160 if (! p->config_substitutions.empty())
161 show_substitutions_info(p->config_substitutions, p->path.ToUTF8().data());
162
163 reset();
164}
#define _(s)
Definition 3mf.cpp:306
#define L(s)
Definition ExtrusionEntity.cpp:25
@ WarningNotificationLevel
Definition NotificationManager.hpp:224
void reset()
Definition SLAImportJob.cpp:88
void show_error(wxWindow *parent, const wxString &message, bool has_code_excerpts)
Definition GUI.cpp:296
void show_substitutions_info(const PresetsConfigSubstitutions &presets_config_substitutions)
Definition GUI.cpp:429
void show_info(wxWindow *parent, const wxString &message, const wxString &title)
Definition GUI.cpp:316
@ CustomNotification
Definition NotificationManager.hpp:66
std::vector< ModelObject * > ModelObjectPtrs
Definition CutUtils.hpp:13
#define _u8L(s)
Definition I18N.hpp:11

References _, _u8L, Slic3r::ConfigBase::apply(), Slic3r::GUI::CustomNotification, L, p, reset(), Slic3r::GUI::show_error(), Slic3r::GUI::show_info(), Slic3r::GUI::show_substitutions_info(), and Slic3r::GUI::NotificationManager::WarningNotificationLevel.

Here is the call graph for this function:

◆ prepare()

void Slic3r::GUI::SLAImportJob::prepare ( )
98{
99 reset();
100
101 auto path = p->import_dlg->get_path();
102 auto nm = wxFileName(path);
103 p->path = !nm.Exists(wxFILE_EXISTS_REGULAR) ? "" : nm.GetFullPath();
104 p->sel = p->import_dlg->get_selection();
105 p->win = p->import_dlg->get_marchsq_windowsize();
106 p->config_substitutions.clear();
107}

References p, and reset().

Referenced by SLAImportJob().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ process()

void Slic3r::GUI::SLAImportJob::process ( Ctl & ctl)
overridevirtual

Implements Slic3r::GUI::Job.

55{
56 auto statustxt = _u8L("Importing SLA archive");
57 ctl.update_status(0, statustxt);
58
59 auto progr = [&ctl, &statustxt](int s) {
60 if (s < 100)
61 ctl.update_status(int(s), statustxt);
62 return !ctl.was_canceled();
63 };
64
65 if (p->path.empty()) return;
66
67 std::string path = p->path.ToUTF8().data();
68 try {
69 switch (p->sel) {
70 case Sel::modelAndProfile:
71 case Sel::modelOnly:
72 p->config_substitutions = import_sla_archive(path, p->win, p->mesh, p->profile, progr);
73 break;
74 case Sel::profileOnly:
75 p->config_substitutions = import_sla_archive(path, p->profile);
76 break;
77 }
78 } catch (MissingProfileError &) {
79 p->err = _u8L("The SLA archive doesn\'t contain any presets. Please activate some SLA printer presets first before importing that SLA archive.");
80 } catch (std::exception &ex) {
81 p->err = ex.what();
82 }
83
84 ctl.update_status(100, ctl.was_canceled() ? _u8L("Importing canceled.") :
85 _u8L("Importing done."));
86}
ConfigSubstitutions import_sla_archive(const std::string &zipfname, DynamicPrintConfig &out)
Definition SL1.cpp:316

References _u8L, Slic3r::import_sla_archive(), p, Slic3r::GUI::Job::Ctl::update_status(), and Slic3r::GUI::Job::Ctl::was_canceled().

Here is the call graph for this function:

◆ reset()

void Slic3r::GUI::SLAImportJob::reset ( )
89{
90 p->sel = Sel::modelAndProfile;
91 p->mesh = {};
92 p->profile = p->plater->sla_print().full_print_config();
93 p->win = {2, 2};
94 p->path.Clear();
95}

References p.

Referenced by finalize(), and prepare().

Here is the caller graph for this function:

Member Data Documentation

◆ p

std::unique_ptr<priv> Slic3r::GUI::SLAImportJob::p
private

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