Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/xs
diff options
context:
space:
mode:
authortamasmeszaros <meszaros.q@gmail.com>2018-09-18 20:13:56 +0300
committertamasmeszaros <meszaros.q@gmail.com>2018-09-18 20:13:56 +0300
commit4d6fb52047e80017be3fc28cb49da7860d5a731a (patch)
tree6511d74c6b88e7302363cc99933e5a23e56d9ef3 /xs
parent5fa99fd903312aab34ce8db748af602237855517 (diff)
Removed explicit dependency of wxWidgets from PrintExport.hpp
Diffstat (limited to 'xs')
-rw-r--r--xs/src/libslic3r/Print.cpp32
-rw-r--r--xs/src/libslic3r/PrintExport.hpp91
2 files changed, 87 insertions, 36 deletions
diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp
index f8f6537ca..cdc12d2d1 100644
--- a/xs/src/libslic3r/Print.cpp
+++ b/xs/src/libslic3r/Print.cpp
@@ -1341,22 +1341,22 @@ std::string Print::output_filepath(const std::string &path) const
void Print::export_png(const std::string &dirpath)
{
- size_t idx = 0;
- for (PrintObject *obj : m_objects) {
- obj->slice();
- this->set_status(int(floor(idx * 100. / m_objects.size() + 0.5)), "Slicing...");
- ++ idx;
- }
- this->set_status(90, "Exporting zipped archive...");
- print_to<FilePrinterFormat::PNG>(*this,
- dirpath,
- float(m_config.bed_size_x.value),
- float(m_config.bed_size_y.value),
- int(m_config.pixel_width.value),
- int(m_config.pixel_height.value),
- float(m_config.exp_time.value),
- float(m_config.exp_time_first.value));
- this->set_status(100, "Done.");
+// size_t idx = 0;
+// for (PrintObject *obj : m_objects) {
+// obj->slice();
+// this->set_status(int(floor(idx * 100. / m_objects.size() + 0.5)), "Slicing...");
+// ++ idx;
+// }
+// this->set_status(90, "Exporting zipped archive...");
+// print_to<FilePrinterFormat::PNG>(*this,
+// dirpath,
+// float(m_config.bed_size_x.value),
+// float(m_config.bed_size_y.value),
+// int(m_config.pixel_width.value),
+// int(m_config.pixel_height.value),
+// float(m_config.exp_time.value),
+// float(m_config.exp_time_first.value));
+// this->set_status(100, "Done.");
}
// Returns extruder this eec should be printed with, according to PrintRegion config
diff --git a/xs/src/libslic3r/PrintExport.hpp b/xs/src/libslic3r/PrintExport.hpp
index 7c3871251..8286b7165 100644
--- a/xs/src/libslic3r/PrintExport.hpp
+++ b/xs/src/libslic3r/PrintExport.hpp
@@ -7,9 +7,9 @@
#include <fstream>
#include <sstream>
-#include <wx/stdstream.h>
-#include <wx/wfstream.h>
-#include <wx/zipstrm.h>
+//#include <wx/stdstream.h>
+//#include <wx/wfstream.h>
+//#include <wx/zipstrm.h>
#include <boost/log/trivial.hpp>
@@ -32,7 +32,7 @@ enum class FilePrinterFormat {
* different implementations of this class template for each supported format.
*
*/
-template<FilePrinterFormat format>
+template<FilePrinterFormat format, class LayerFormat = void>
class FilePrinter {
public:
@@ -73,10 +73,35 @@ public:
void saveLayer(unsigned lyr, const std::string& path);
};
+template<class T = void> struct VeryFalse { static const bool value = false; };
+
+// This has to be explicitly implemented in the gui layer or a default zlib
+// based implementation is needed.
+template<class Backend> class Zipper {
+public:
+
+ Zipper(const std::string& /*zipfile_path*/) {
+ static_assert(Backend>::value,
+ "No zipper implementation provided!");
+ }
+
+ void next_entry(const std::string& /*fname*/) {}
+
+ bool is_ok() { return false; }
+
+ std::string get_name() { return ""; }
+
+ template<class T> Zipper& operator<<(const T& /*arg*/) {
+ return *this;
+ }
+
+ void close() {}
+};
+
// Implementation for PNG raster output
// Be aware that if a large number of layers are allocated, it can very well
// exhaust the available memory especially on 32 bit platform.
-template<> class FilePrinter<FilePrinterFormat::PNG> {
+template<class LyrFormat> class FilePrinter<FilePrinterFormat::PNG, LyrFormat> {
struct Layer {
Raster first;
@@ -148,7 +173,7 @@ public:
pxdim_(m.pxdim_) {}
inline void layers(unsigned cnt) { if(cnt > 0) layers_rst_.resize(cnt); }
- inline unsigned layers() const { return layers_rst_.size(); }
+ inline unsigned layers() const { return unsigned(layers_rst_.size()); }
void printConfig(const Print& printconf) { print_ = &printconf; }
@@ -184,37 +209,63 @@ public:
inline void save(const std::string& path) {
- wxFileName filepath(path);
-
- wxFFileOutputStream zipfile(path);
+ Zipper<LyrFormat> zipper(path);
- std::string project = filepath.GetName().ToStdString();
+ std::string project = zipper.get_name();
- if(!zipfile.IsOk()) {
+ if(!zipper.is_ok()) {
BOOST_LOG_TRIVIAL(error) << "Can't create zip file for layers! "
<< path;
return;
}
- wxZipOutputStream zipstream(zipfile);
- wxStdOutputStream pngstream(zipstream);
-
- zipstream.PutNextEntry("config.ini");
- pngstream << createIniContent(project);
+ zipper.next_entry(project);
+ zipper << createIniContent(project);
for(unsigned i = 0; i < layers_rst_.size(); i++) {
if(layers_rst_[i].second.rdbuf()->in_avail() > 0) {
char lyrnum[6];
std::sprintf(lyrnum, "%.5d", i);
auto zfilename = project + lyrnum + ".png";
- zipstream.PutNextEntry(zfilename);
- pngstream << layers_rst_[i].second.rdbuf();
+ zipper.next_entry(zfilename);
+ zipper << layers_rst_[i].second.rdbuf();
layers_rst_[i].second.str("");
}
}
- zipstream.Close();
- zipfile.Close();
+ zipper.close();
+
+// wxFileName filepath(path);
+
+// wxFFileOutputStream zipfile(path);
+
+// std::string project = filepath.GetName().ToStdString();
+
+// if(!zipfile.IsOk()) {
+// BOOST_LOG_TRIVIAL(error) << "Can't create zip file for layers! "
+// << path;
+// return;
+// }
+
+// wxZipOutputStream zipstream(zipfile);
+// wxStdOutputStream pngstream(zipstream);
+
+// zipstream.PutNextEntry("config.ini");
+// pngstream << createIniContent(project);
+
+// for(unsigned i = 0; i < layers_rst_.size(); i++) {
+// if(layers_rst_[i].second.rdbuf()->in_avail() > 0) {
+// char lyrnum[6];
+// std::sprintf(lyrnum, "%.5d", i);
+// auto zfilename = project + lyrnum + ".png";
+// zipstream.PutNextEntry(zfilename);
+// pngstream << layers_rst_[i].second.rdbuf();
+// layers_rst_[i].second.str("");
+// }
+// }
+
+// zipstream.Close();
+// zipfile.Close();
}
void saveLayer(unsigned lyr, const std::string& path) {