Merge branch 'master' of https://github.com/prusa3d/Slic3r into et_canvas_gui_refactoring

This commit is contained in:
Enrico Turri 2019-03-28 09:30:23 +01:00
commit af3a32b8a0
325 changed files with 510 additions and 116396 deletions

View file

@ -92,64 +92,13 @@ void BackgroundSlicingProcess::process_fff()
}
}
// Pseudo type for specializing LayerWriter trait class
struct SLAZipFmt {};
// The implementation of creating zipped archives with wxWidgets
template<> class LayerWriter<SLAZipFmt> {
wxFileName fpath;
wxFFileOutputStream zipfile;
wxZipOutputStream zipstream;
wxStdOutputStream pngstream;
public:
inline LayerWriter(const std::string& zipfile_path):
fpath(zipfile_path),
zipfile(zipfile_path),
zipstream(zipfile),
pngstream(zipstream)
{
if(!is_ok())
throw std::runtime_error("Cannot create zip file.");
}
~LayerWriter() {
// In case of an error (disk space full) zipstream destructor would
// crash.
pngstream.clear();
zipstream.CloseEntry();
}
inline void next_entry(const std::string& fname) {
zipstream.PutNextEntry(fname);
}
inline std::string get_name() const {
return fpath.GetName().ToUTF8().data();
}
template<class T> inline LayerWriter& operator<<(const T& arg) {
pngstream << arg; return *this;
}
bool is_ok() const {
return pngstream.good() && zipstream.IsOk() && zipfile.IsOk();
}
inline void close() {
zipstream.Close();
zipfile.Close();
}
};
void BackgroundSlicingProcess::process_sla()
{
assert(m_print == m_sla_print);
m_print->process();
if (this->set_step_started(bspsGCodeFinalize)) {
if (! m_export_path.empty()) {
m_sla_print->export_raster<SLAZipFmt>(m_export_path);
m_sla_print->export_raster(m_export_path);
m_print->set_status(100, "Masked SLA file exported to " + m_export_path);
} else if (! m_upload_job.empty()) {
prepare_upload();
@ -449,8 +398,8 @@ void BackgroundSlicingProcess::prepare_upload()
}
run_post_process_scripts(source_path.string(), m_fff_print->config());
m_upload_job.upload_data.upload_path = m_fff_print->print_statistics().finalize_output_path(m_upload_job.upload_data.upload_path.string());
} else {
m_sla_print->export_raster<SLAZipFmt>(source_path.string());
} else {
m_sla_print->export_raster(source_path.string());
// TODO: Also finalize upload path like with FFF when there are statistics for SLA print
}

View file

@ -1297,7 +1297,7 @@ bool GLCanvas3D::init(bool useVBOs, bool use_legacy_opengl)
if (useVBOs && !m_shader.init("gouraud.vs", "gouraud.fs"))
return false;
if (useVBOs && !m_layers_editing.init("variable_layer_height.vs", "variable_layer_height.fs"))
if (m_toolbar.is_enabled() && useVBOs && !m_layers_editing.init("variable_layer_height.vs", "variable_layer_height.fs"))
return false;
m_use_VBOs = useVBOs;
@ -1318,7 +1318,7 @@ bool GLCanvas3D::init(bool useVBOs, bool use_legacy_opengl)
if (!_init_toolbar())
return false;
if (!m_selection.init(m_use_VBOs))
if (m_selection.is_enabled() && !m_selection.init(m_use_VBOs))
return false;
post_event(SimpleEvent(EVT_GLCANVAS_INIT));
@ -1502,6 +1502,11 @@ void GLCanvas3D::enable_gizmos(bool enable)
m_gizmos.set_enabled(enable);
}
void GLCanvas3D::enable_selection(bool enable)
{
m_selection.set_enabled(enable);
}
void GLCanvas3D::enable_toolbar(bool enable)
{
m_toolbar.set_enabled(enable);

View file

@ -498,6 +498,7 @@ public:
void enable_picking(bool enable);
void enable_moving(bool enable);
void enable_gizmos(bool enable);
void enable_selection(bool enable);
void enable_toolbar(bool enable);
void enable_dynamic_background(bool enable);
void allow_multisample(bool allow);

View file

@ -62,6 +62,7 @@ bool View3D::init(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_
m_canvas->set_process(process);
m_canvas->set_config(config);
m_canvas->enable_gizmos(true);
m_canvas->enable_selection(true);
m_canvas->enable_toolbar(true);
wxBoxSizer* main_sizer = new wxBoxSizer(wxVERTICAL);

View file

@ -1416,8 +1416,6 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
preview->get_wxglcanvas()->Bind(EVT_GLCANVAS_UPDATE_BED_SHAPE, [this](SimpleEvent&) { set_bed_shape(config->option<ConfigOptionPoints>("bed_shape")->values); });
preview->get_wxglcanvas()->Bind(EVT_GLCANVAS_TAB, [this](SimpleEvent&) { select_next_view_3D(); });
view3D_canvas->Bind(EVT_GLCANVAS_INIT, [this](SimpleEvent&) { init_view_toolbar(); });
q->Bind(EVT_SLICING_COMPLETED, &priv::on_slicing_completed, this);
q->Bind(EVT_PROCESS_COMPLETED, &priv::on_process_completed, this);
q->Bind(EVT_GLVIEWTOOLBAR_3D, [q](SimpleEvent&) { q->select_view_3D("3D"); });

View file

@ -50,6 +50,7 @@ Selection::VolumeCache::VolumeCache(const Geometry::Transformation& volume_trans
Selection::Selection()
: m_volumes(nullptr)
, m_model(nullptr)
, m_enabled(false)
, m_mode(Instance)
, m_type(Empty)
, m_valid(false)

View file

@ -154,6 +154,7 @@ private:
// Model, not owned.
Model* m_model;
bool m_enabled;
bool m_valid;
EMode m_mode;
EType m_type;
@ -180,6 +181,9 @@ public:
void set_volumes(GLVolumePtrs* volumes);
bool init(bool useVBOs);
bool is_enabled() const { return m_enabled; }
void set_enabled(bool enable) { m_enabled = enable; }
Model* get_model() const { return m_model; }
void set_model(Model* model);