ENABLE_THUMBNAIL_GENERATOR -> WIP: Refactoring and preparation for adding thumbnails to exported gcode and 3mf files
This commit is contained in:
parent
959ef9a9ec
commit
4d1153c866
15 changed files with 346 additions and 46 deletions
|
@ -3,6 +3,11 @@
|
||||||
#include "../Utils.hpp"
|
#include "../Utils.hpp"
|
||||||
#include "../GCode.hpp"
|
#include "../GCode.hpp"
|
||||||
#include "../Geometry.hpp"
|
#include "../Geometry.hpp"
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
#include "../GCode/ThumbnailData.hpp"
|
||||||
|
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
|
||||||
#include "../I18N.hpp"
|
#include "../I18N.hpp"
|
||||||
|
|
||||||
|
@ -40,6 +45,11 @@ const std::string MODEL_EXTENSION = ".model";
|
||||||
const std::string MODEL_FILE = "3D/3dmodel.model"; // << this is the only format of the string which works with CURA
|
const std::string MODEL_FILE = "3D/3dmodel.model"; // << this is the only format of the string which works with CURA
|
||||||
const std::string CONTENT_TYPES_FILE = "[Content_Types].xml";
|
const std::string CONTENT_TYPES_FILE = "[Content_Types].xml";
|
||||||
const std::string RELATIONSHIPS_FILE = "_rels/.rels";
|
const std::string RELATIONSHIPS_FILE = "_rels/.rels";
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
const std::string THUMBNAIL_FILE = "Metadata/thumbnail.png";
|
||||||
|
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
const std::string PRINT_CONFIG_FILE = "Metadata/Slic3r_PE.config";
|
const std::string PRINT_CONFIG_FILE = "Metadata/Slic3r_PE.config";
|
||||||
const std::string MODEL_CONFIG_FILE = "Metadata/Slic3r_PE_model.config";
|
const std::string MODEL_CONFIG_FILE = "Metadata/Slic3r_PE_model.config";
|
||||||
const std::string LAYER_HEIGHTS_PROFILE_FILE = "Metadata/Slic3r_PE_layer_heights_profile.txt";
|
const std::string LAYER_HEIGHTS_PROFILE_FILE = "Metadata/Slic3r_PE_layer_heights_profile.txt";
|
||||||
|
@ -1806,11 +1816,32 @@ namespace Slic3r {
|
||||||
typedef std::map<int, ObjectData> IdToObjectDataMap;
|
typedef std::map<int, ObjectData> IdToObjectDataMap;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
bool save_model_to_file(const std::string& filename, Model& model, const DynamicPrintConfig* config, const ThumbnailData* thumbnail = nullptr);
|
||||||
|
#else
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
bool save_model_to_file(const std::string& filename, Model& model, const DynamicPrintConfig* config);
|
bool save_model_to_file(const std::string& filename, Model& model, const DynamicPrintConfig* config);
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
bool _save_model_to_file(const std::string& filename, Model& model, const DynamicPrintConfig* config, const ThumbnailData* thumbnail);
|
||||||
|
#else
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
bool _save_model_to_file(const std::string& filename, Model& model, const DynamicPrintConfig* config);
|
bool _save_model_to_file(const std::string& filename, Model& model, const DynamicPrintConfig* config);
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
bool _add_content_types_file_to_archive(mz_zip_archive& archive);
|
bool _add_content_types_file_to_archive(mz_zip_archive& archive);
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
bool _add_thumbnail_file_to_archive(mz_zip_archive& archive, const ThumbnailData& thumbnail);
|
||||||
|
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
bool _add_relationships_file_to_archive(mz_zip_archive& archive);
|
bool _add_relationships_file_to_archive(mz_zip_archive& archive);
|
||||||
bool _add_model_file_to_archive(mz_zip_archive& archive, const Model& model, IdToObjectDataMap &objects_data);
|
bool _add_model_file_to_archive(mz_zip_archive& archive, const Model& model, IdToObjectDataMap &objects_data);
|
||||||
bool _add_object_to_model_stream(std::stringstream& stream, unsigned int& object_id, ModelObject& object, BuildItemsList& build_items, VolumeToOffsetsMap& volumes_offsets);
|
bool _add_object_to_model_stream(std::stringstream& stream, unsigned int& object_id, ModelObject& object, BuildItemsList& build_items, VolumeToOffsetsMap& volumes_offsets);
|
||||||
|
@ -1823,13 +1854,33 @@ namespace Slic3r {
|
||||||
bool _add_model_config_file_to_archive(mz_zip_archive& archive, const Model& model, const IdToObjectDataMap &objects_data);
|
bool _add_model_config_file_to_archive(mz_zip_archive& archive, const Model& model, const IdToObjectDataMap &objects_data);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
bool _3MF_Exporter::save_model_to_file(const std::string& filename, Model& model, const DynamicPrintConfig* config, const ThumbnailData* thumbnail)
|
||||||
|
{
|
||||||
|
clear_errors();
|
||||||
|
return _save_model_to_file(filename, model, config, thumbnail);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
bool _3MF_Exporter::save_model_to_file(const std::string& filename, Model& model, const DynamicPrintConfig* config)
|
bool _3MF_Exporter::save_model_to_file(const std::string& filename, Model& model, const DynamicPrintConfig* config)
|
||||||
{
|
{
|
||||||
clear_errors();
|
clear_errors();
|
||||||
return _save_model_to_file(filename, model, config);
|
return _save_model_to_file(filename, model, config);
|
||||||
}
|
}
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
bool _3MF_Exporter::_save_model_to_file(const std::string& filename, Model& model, const DynamicPrintConfig* config, const ThumbnailData* thumbnail)
|
||||||
|
#else
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
bool _3MF_Exporter::_save_model_to_file(const std::string& filename, Model& model, const DynamicPrintConfig* config)
|
bool _3MF_Exporter::_save_model_to_file(const std::string& filename, Model& model, const DynamicPrintConfig* config)
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
{
|
{
|
||||||
mz_zip_archive archive;
|
mz_zip_archive archive;
|
||||||
mz_zip_zero_struct(&archive);
|
mz_zip_zero_struct(&archive);
|
||||||
|
@ -1848,6 +1899,21 @@ namespace Slic3r {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
if ((thumbnail != nullptr) && thumbnail->is_valid())
|
||||||
|
{
|
||||||
|
// Adds the file Metadata/thumbnail.png.
|
||||||
|
if (!_add_thumbnail_file_to_archive(archive, *thumbnail))
|
||||||
|
{
|
||||||
|
close_zip_writer(&archive);
|
||||||
|
boost::filesystem::remove(filename);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
|
||||||
// Adds relationships file ("_rels/.rels").
|
// Adds relationships file ("_rels/.rels").
|
||||||
// The content of this file is the same for each PrusaSlicer 3mf.
|
// The content of this file is the same for each PrusaSlicer 3mf.
|
||||||
// The relationshis file contains a reference to the geometry file "3D/3dmodel.model", the name was chosen to be compatible with CURA.
|
// The relationshis file contains a reference to the geometry file "3D/3dmodel.model", the name was chosen to be compatible with CURA.
|
||||||
|
@ -1941,6 +2007,11 @@ namespace Slic3r {
|
||||||
stream << "<Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\">\n";
|
stream << "<Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\">\n";
|
||||||
stream << " <Default Extension=\"rels\" ContentType=\"application/vnd.openxmlformats-package.relationships+xml\" />\n";
|
stream << " <Default Extension=\"rels\" ContentType=\"application/vnd.openxmlformats-package.relationships+xml\" />\n";
|
||||||
stream << " <Default Extension=\"model\" ContentType=\"application/vnd.ms-package.3dmanufacturing-3dmodel+xml\" />\n";
|
stream << " <Default Extension=\"model\" ContentType=\"application/vnd.ms-package.3dmanufacturing-3dmodel+xml\" />\n";
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
stream << " <Default Extension=\"png\" ContentType=\"image/png\" />\n";
|
||||||
|
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
stream << "</Types>";
|
stream << "</Types>";
|
||||||
|
|
||||||
std::string out = stream.str();
|
std::string out = stream.str();
|
||||||
|
@ -1954,12 +2025,28 @@ namespace Slic3r {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
bool _3MF_Exporter::_add_thumbnail_file_to_archive(mz_zip_archive& archive, const ThumbnailData& thumbnail)
|
||||||
|
{
|
||||||
|
// TODO -> add Metadata/thumbnail.png file containing thumbnail_data
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
|
||||||
bool _3MF_Exporter::_add_relationships_file_to_archive(mz_zip_archive& archive)
|
bool _3MF_Exporter::_add_relationships_file_to_archive(mz_zip_archive& archive)
|
||||||
{
|
{
|
||||||
std::stringstream stream;
|
std::stringstream stream;
|
||||||
stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
|
stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
|
||||||
stream << "<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">\n";
|
stream << "<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">\n";
|
||||||
stream << " <Relationship Target=\"/" << MODEL_FILE << "\" Id=\"rel-1\" Type=\"http://schemas.microsoft.com/3dmanufacturing/2013/01/3dmodel\" />\n";
|
stream << " <Relationship Target=\"/" << MODEL_FILE << "\" Id=\"rel-1\" Type=\"http://schemas.microsoft.com/3dmanufacturing/2013/01/3dmodel\" />\n";
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
stream << " <Relationship Target=\"/" << THUMBNAIL_FILE << "\" Id=\"rel-2\" Type=\"http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail\" />\n";
|
||||||
|
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
stream << "</Relationships>";
|
stream << "</Relationships>";
|
||||||
|
|
||||||
std::string out = stream.str();
|
std::string out = stream.str();
|
||||||
|
@ -2453,13 +2540,29 @@ namespace Slic3r {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
bool store_3mf(const char* path, Model* model, const DynamicPrintConfig* config, const ThumbnailData* thumbnail)
|
||||||
|
#else
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
bool store_3mf(const char* path, Model* model, const DynamicPrintConfig* config)
|
bool store_3mf(const char* path, Model* model, const DynamicPrintConfig* config)
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
{
|
{
|
||||||
if ((path == nullptr) || (model == nullptr))
|
if ((path == nullptr) || (model == nullptr))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
_3MF_Exporter exporter;
|
_3MF_Exporter exporter;
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
bool res = exporter.save_model_to_file(path, *model, config, thumbnail);
|
||||||
|
#else
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
bool res = exporter.save_model_to_file(path, *model, config);
|
bool res = exporter.save_model_to_file(path, *model, config);
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
|
||||||
if (!res)
|
if (!res)
|
||||||
exporter.log_errors();
|
exporter.log_errors();
|
||||||
|
|
|
@ -22,13 +22,26 @@ namespace Slic3r {
|
||||||
|
|
||||||
class Model;
|
class Model;
|
||||||
class DynamicPrintConfig;
|
class DynamicPrintConfig;
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
struct ThumbnailData;
|
||||||
|
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
|
||||||
// Load the content of a 3mf file into the given model and preset bundle.
|
// Load the content of a 3mf file into the given model and preset bundle.
|
||||||
extern bool load_3mf(const char* path, DynamicPrintConfig* config, Model* model, bool check_version);
|
extern bool load_3mf(const char* path, DynamicPrintConfig* config, Model* model, bool check_version);
|
||||||
|
|
||||||
// Save the given model and the config data contained in the given Print into a 3mf file.
|
// Save the given model and the config data contained in the given Print into a 3mf file.
|
||||||
// The model could be modified during the export process if meshes are not repaired or have no shared vertices
|
// The model could be modified during the export process if meshes are not repaired or have no shared vertices
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
extern bool store_3mf(const char* path, Model* model, const DynamicPrintConfig* config, const ThumbnailData* thumbnail = nullptr);
|
||||||
|
#else
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
extern bool store_3mf(const char* path, Model* model, const DynamicPrintConfig* config);
|
extern bool store_3mf(const char* path, Model* model, const DynamicPrintConfig* config);
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
|
||||||
}; // namespace Slic3r
|
}; // namespace Slic3r
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,11 @@
|
||||||
#include "Geometry.hpp"
|
#include "Geometry.hpp"
|
||||||
#include "GCode/PrintExtents.hpp"
|
#include "GCode/PrintExtents.hpp"
|
||||||
#include "GCode/WipeTower.hpp"
|
#include "GCode/WipeTower.hpp"
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
#include "GCode/ThumbnailData.hpp"
|
||||||
|
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
#include "ShortestPath.hpp"
|
#include "ShortestPath.hpp"
|
||||||
#include "Utils.hpp"
|
#include "Utils.hpp"
|
||||||
|
|
||||||
|
@ -652,7 +657,15 @@ std::vector<std::pair<coordf_t, std::vector<GCode::LayerToPrint>>> GCode::collec
|
||||||
return layers_to_print;
|
return layers_to_print;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
void GCode::do_export(Print* print, const char* path, GCodePreviewData* preview_data, const ThumbnailData* thumbnail_data)
|
||||||
|
#else
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
void GCode::do_export(Print *print, const char *path, GCodePreviewData *preview_data)
|
void GCode::do_export(Print *print, const char *path, GCodePreviewData *preview_data)
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
{
|
{
|
||||||
PROFILE_CLEAR();
|
PROFILE_CLEAR();
|
||||||
|
|
||||||
|
@ -678,7 +691,15 @@ void GCode::do_export(Print *print, const char *path, GCodePreviewData *preview_
|
||||||
|
|
||||||
try {
|
try {
|
||||||
m_placeholder_parser_failed_templates.clear();
|
m_placeholder_parser_failed_templates.clear();
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
this->_do_export(*print, file, thumbnail_data);
|
||||||
|
#else
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
this->_do_export(*print, file);
|
this->_do_export(*print, file);
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
fflush(file);
|
fflush(file);
|
||||||
if (ferror(file)) {
|
if (ferror(file)) {
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
@ -742,7 +763,15 @@ void GCode::do_export(Print *print, const char *path, GCodePreviewData *preview_
|
||||||
PROFILE_OUTPUT(debug_out_path("gcode-export-profile.txt").c_str());
|
PROFILE_OUTPUT(debug_out_path("gcode-export-profile.txt").c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
void GCode::_do_export(Print& print, FILE* file, const ThumbnailData* thumbnail_data)
|
||||||
|
#else
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
void GCode::_do_export(Print &print, FILE *file)
|
void GCode::_do_export(Print &print, FILE *file)
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
{
|
{
|
||||||
PROFILE_FUNC();
|
PROFILE_FUNC();
|
||||||
|
|
||||||
|
@ -934,6 +963,21 @@ void GCode::_do_export(Print &print, FILE *file)
|
||||||
|
|
||||||
// Write information on the generator.
|
// Write information on the generator.
|
||||||
_write_format(file, "; %s\n\n", Slic3r::header_slic3r_generated().c_str());
|
_write_format(file, "; %s\n\n", Slic3r::header_slic3r_generated().c_str());
|
||||||
|
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
// Write thumbnail
|
||||||
|
if ((thumbnail_data != nullptr) && thumbnail_data->is_valid())
|
||||||
|
{
|
||||||
|
_write(file, "\n;\n; thumbnail begin\n");
|
||||||
|
|
||||||
|
// TODO -> export content of thumbnail_data.pixels
|
||||||
|
|
||||||
|
_write(file, "; thumbnail end\n;\n\n");
|
||||||
|
}
|
||||||
|
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
|
||||||
// Write notes (content of the Print Settings tab -> Notes)
|
// Write notes (content of the Print Settings tab -> Notes)
|
||||||
{
|
{
|
||||||
std::list<std::string> lines;
|
std::list<std::string> lines;
|
||||||
|
@ -949,11 +993,6 @@ void GCode::_do_export(Print &print, FILE *file)
|
||||||
}
|
}
|
||||||
print.throw_if_canceled();
|
print.throw_if_canceled();
|
||||||
|
|
||||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
|
||||||
#if ENABLE_THUMBNAIL_GENERATOR
|
|
||||||
#endif // ENABLE_THUMBNAIL_GENERATOR
|
|
||||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
|
||||||
|
|
||||||
// Write some terse information on the slicing parameters.
|
// Write some terse information on the slicing parameters.
|
||||||
const PrintObject *first_object = print.objects().front();
|
const PrintObject *first_object = print.objects().front();
|
||||||
const double layer_height = first_object->config().layer_height.value;
|
const double layer_height = first_object->config().layer_height.value;
|
||||||
|
|
|
@ -30,6 +30,11 @@ namespace Slic3r {
|
||||||
// Forward declarations.
|
// Forward declarations.
|
||||||
class GCode;
|
class GCode;
|
||||||
class GCodePreviewData;
|
class GCodePreviewData;
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
struct ThumbnailData;
|
||||||
|
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
|
||||||
class AvoidCrossingPerimeters {
|
class AvoidCrossingPerimeters {
|
||||||
public:
|
public:
|
||||||
|
@ -162,7 +167,15 @@ public:
|
||||||
|
|
||||||
// throws std::runtime_exception on error,
|
// throws std::runtime_exception on error,
|
||||||
// throws CanceledException through print->throw_if_canceled().
|
// throws CanceledException through print->throw_if_canceled().
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
void do_export(Print* print, const char* path, GCodePreviewData* preview_data = nullptr, const ThumbnailData* thumbnail_data = nullptr);
|
||||||
|
#else
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
void do_export(Print *print, const char *path, GCodePreviewData *preview_data = nullptr);
|
void do_export(Print *print, const char *path, GCodePreviewData *preview_data = nullptr);
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
|
||||||
// Exported for the helper classes (OozePrevention, Wipe) and for the Perl binding for unit tests.
|
// Exported for the helper classes (OozePrevention, Wipe) and for the Perl binding for unit tests.
|
||||||
const Vec2d& origin() const { return m_origin; }
|
const Vec2d& origin() const { return m_origin; }
|
||||||
|
@ -190,7 +203,15 @@ public:
|
||||||
static void append_full_config(const Print& print, std::string& str);
|
static void append_full_config(const Print& print, std::string& str);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
void _do_export(Print& print, FILE* file, const ThumbnailData* thumbnail_data);
|
||||||
|
#else
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
void _do_export(Print &print, FILE *file);
|
void _do_export(Print &print, FILE *file);
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#endif //ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
|
||||||
// Object and support extrusions of the same PrintObject at the same print_z.
|
// Object and support extrusions of the same PrintObject at the same print_z.
|
||||||
struct LayerToPrint
|
struct LayerToPrint
|
||||||
|
|
|
@ -7,17 +7,17 @@ namespace Slic3r {
|
||||||
|
|
||||||
void ThumbnailData::set(unsigned int w, unsigned int h)
|
void ThumbnailData::set(unsigned int w, unsigned int h)
|
||||||
{
|
{
|
||||||
if (!pixels.empty())
|
|
||||||
reset();
|
|
||||||
|
|
||||||
if ((w == 0) || (h == 0))
|
if ((w == 0) || (h == 0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if ((width != w) || (height != h))
|
||||||
|
{
|
||||||
width = w;
|
width = w;
|
||||||
height = h;
|
height = h;
|
||||||
// defaults to white texture
|
// defaults to white texture
|
||||||
pixels = std::vector<unsigned char>(width * height * 4, 255);
|
pixels = std::vector<unsigned char>(width * height * 4, 255);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ThumbnailData::reset()
|
void ThumbnailData::reset()
|
||||||
{
|
{
|
||||||
|
@ -26,6 +26,11 @@ void ThumbnailData::reset()
|
||||||
pixels.clear();
|
pixels.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ThumbnailData::is_valid() const
|
||||||
|
{
|
||||||
|
return (width != 0) && (height != 0) && ((unsigned int)pixels.size() == 4 * width * height);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Slic3r
|
} // namespace Slic3r
|
||||||
|
|
||||||
#endif // ENABLE_THUMBNAIL_GENERATOR
|
#endif // ENABLE_THUMBNAIL_GENERATOR
|
|
@ -16,6 +16,8 @@ struct ThumbnailData
|
||||||
ThumbnailData() { reset(); }
|
ThumbnailData() { reset(); }
|
||||||
void set(unsigned int w, unsigned int h);
|
void set(unsigned int w, unsigned int h);
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
|
bool is_valid() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Slic3r
|
} // namespace Slic3r
|
||||||
|
|
|
@ -1536,7 +1536,15 @@ void Print::process()
|
||||||
// The export_gcode may die for various reasons (fails to process output_filename_format,
|
// The export_gcode may die for various reasons (fails to process output_filename_format,
|
||||||
// write error into the G-code, cannot execute post-processing scripts).
|
// write error into the G-code, cannot execute post-processing scripts).
|
||||||
// It is up to the caller to show an error message.
|
// It is up to the caller to show an error message.
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
std::string Print::export_gcode(const std::string& path_template, GCodePreviewData* preview_data, const ThumbnailData* thumbnail_data)
|
||||||
|
#else
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
std::string Print::export_gcode(const std::string &path_template, GCodePreviewData *preview_data)
|
std::string Print::export_gcode(const std::string &path_template, GCodePreviewData *preview_data)
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
{
|
{
|
||||||
// output everything to a G-code file
|
// output everything to a G-code file
|
||||||
// The following call may die if the output_filename_format template substitution fails.
|
// The following call may die if the output_filename_format template substitution fails.
|
||||||
|
@ -1553,7 +1561,15 @@ std::string Print::export_gcode(const std::string &path_template, GCodePreviewDa
|
||||||
|
|
||||||
// The following line may die for multiple reasons.
|
// The following line may die for multiple reasons.
|
||||||
GCode gcode;
|
GCode gcode;
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
gcode.do_export(this, path.c_str(), preview_data, thumbnail_data);
|
||||||
|
#else
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
gcode.do_export(this, path.c_str(), preview_data);
|
gcode.do_export(this, path.c_str(), preview_data);
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
return path.c_str();
|
return path.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,11 @@ class PrintObject;
|
||||||
class ModelObject;
|
class ModelObject;
|
||||||
class GCode;
|
class GCode;
|
||||||
class GCodePreviewData;
|
class GCodePreviewData;
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
struct ThumbnailData;
|
||||||
|
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
|
||||||
// Print step IDs for keeping track of the print state.
|
// Print step IDs for keeping track of the print state.
|
||||||
enum PrintStep {
|
enum PrintStep {
|
||||||
|
@ -305,7 +310,15 @@ public:
|
||||||
void process() override;
|
void process() override;
|
||||||
// Exports G-code into a file name based on the path_template, returns the file path of the generated G-code file.
|
// Exports G-code into a file name based on the path_template, returns the file path of the generated G-code file.
|
||||||
// If preview_data is not null, the preview_data is filled in for the G-code visualization (not used by the command line Slic3r).
|
// If preview_data is not null, the preview_data is filled in for the G-code visualization (not used by the command line Slic3r).
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
std::string export_gcode(const std::string& path_template, GCodePreviewData* preview_data, const ThumbnailData* thumbnail_data = nullptr);
|
||||||
|
#else
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
std::string export_gcode(const std::string &path_template, GCodePreviewData *preview_data);
|
std::string export_gcode(const std::string &path_template, GCodePreviewData *preview_data);
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
|
||||||
// methods for handling state
|
// methods for handling state
|
||||||
bool is_step_done(PrintStep step) const { return Inherited::is_step_done(step); }
|
bool is_step_done(PrintStep step) const { return Inherited::is_step_done(step); }
|
||||||
|
|
|
@ -82,7 +82,15 @@ void BackgroundSlicingProcess::process_fff()
|
||||||
assert(m_print == m_fff_print);
|
assert(m_print == m_fff_print);
|
||||||
m_print->process();
|
m_print->process();
|
||||||
wxQueueEvent(GUI::wxGetApp().mainframe->m_plater, new wxCommandEvent(m_event_slicing_completed_id));
|
wxQueueEvent(GUI::wxGetApp().mainframe->m_plater, new wxCommandEvent(m_event_slicing_completed_id));
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
m_fff_print->export_gcode(m_temp_output_path, m_gcode_preview_data, m_thumbnail_data);
|
||||||
|
#else
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
m_fff_print->export_gcode(m_temp_output_path, m_gcode_preview_data);
|
m_fff_print->export_gcode(m_temp_output_path, m_gcode_preview_data);
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
if (this->set_step_started(bspsGCodeFinalize)) {
|
if (this->set_step_started(bspsGCodeFinalize)) {
|
||||||
if (! m_export_path.empty()) {
|
if (! m_export_path.empty()) {
|
||||||
//FIXME localize the messages
|
//FIXME localize the messages
|
||||||
|
|
|
@ -17,6 +17,11 @@ namespace Slic3r {
|
||||||
|
|
||||||
class DynamicPrintConfig;
|
class DynamicPrintConfig;
|
||||||
class GCodePreviewData;
|
class GCodePreviewData;
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
struct ThumbnailData;
|
||||||
|
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
class Model;
|
class Model;
|
||||||
class SLAPrint;
|
class SLAPrint;
|
||||||
|
|
||||||
|
@ -49,6 +54,12 @@ public:
|
||||||
void set_fff_print(Print *print) { m_fff_print = print; }
|
void set_fff_print(Print *print) { m_fff_print = print; }
|
||||||
void set_sla_print(SLAPrint *print) { m_sla_print = print; }
|
void set_sla_print(SLAPrint *print) { m_sla_print = print; }
|
||||||
void set_gcode_preview_data(GCodePreviewData *gpd) { m_gcode_preview_data = gpd; }
|
void set_gcode_preview_data(GCodePreviewData *gpd) { m_gcode_preview_data = gpd; }
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
void set_thumbnail_data(const ThumbnailData* data) { m_thumbnail_data = data; }
|
||||||
|
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
|
||||||
// The following wxCommandEvent will be sent to the UI thread / Platter window, when the slicing is finished
|
// The following wxCommandEvent will be sent to the UI thread / Platter window, when the slicing is finished
|
||||||
// and the background processing will transition into G-code export.
|
// and the background processing will transition into G-code export.
|
||||||
// The wxCommandEvent is sent to the UI thread asynchronously without waiting for the event to be processed.
|
// The wxCommandEvent is sent to the UI thread asynchronously without waiting for the event to be processed.
|
||||||
|
@ -151,6 +162,12 @@ private:
|
||||||
SLAPrint *m_sla_print = nullptr;
|
SLAPrint *m_sla_print = nullptr;
|
||||||
// Data structure, to which the G-code export writes its annotations.
|
// Data structure, to which the G-code export writes its annotations.
|
||||||
GCodePreviewData *m_gcode_preview_data = nullptr;
|
GCodePreviewData *m_gcode_preview_data = nullptr;
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
// Data structure, used to write thumbnail into gcode.
|
||||||
|
const ThumbnailData *m_thumbnail_data = nullptr;
|
||||||
|
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
// Temporary G-code, there is one defined for the BackgroundSlicingProcess, differentiated from the other processes by a process ID.
|
// 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;
|
std::string m_temp_output_path;
|
||||||
// Output path provided by the user. The output path may be set even if the slicing is running,
|
// Output path provided by the user. The output path may be set even if the slicing is running,
|
||||||
|
|
|
@ -2108,6 +2108,12 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
|
||||||
manip->set_dirty();
|
manip->set_dirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
//#if ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
// wxGetApp().plater()->generate_thumbnail(256, 256, true);
|
||||||
|
//#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
|
||||||
// and force this canvas to be redrawn.
|
// and force this canvas to be redrawn.
|
||||||
m_dirty = true;
|
m_dirty = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1926,6 +1926,12 @@ struct Plater::priv
|
||||||
bool can_mirror() const;
|
bool can_mirror() const;
|
||||||
bool can_reload_from_disk() const;
|
bool can_reload_from_disk() const;
|
||||||
|
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
void generate_thumbnail(unsigned int w, unsigned int h, bool printable_only);
|
||||||
|
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
|
||||||
void msw_rescale_object_menu();
|
void msw_rescale_object_menu();
|
||||||
|
|
||||||
// returns the path to project file with the given extension (none if extension == wxEmptyString)
|
// returns the path to project file with the given extension (none if extension == wxEmptyString)
|
||||||
|
@ -1993,6 +1999,11 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
|
||||||
background_process.set_fff_print(&fff_print);
|
background_process.set_fff_print(&fff_print);
|
||||||
background_process.set_sla_print(&sla_print);
|
background_process.set_sla_print(&sla_print);
|
||||||
background_process.set_gcode_preview_data(&gcode_preview_data);
|
background_process.set_gcode_preview_data(&gcode_preview_data);
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
background_process.set_thumbnail_data(&thumbnail_generator.get_data());
|
||||||
|
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
background_process.set_slicing_completed_event(EVT_SLICING_COMPLETED);
|
background_process.set_slicing_completed_event(EVT_SLICING_COMPLETED);
|
||||||
background_process.set_finished_event(EVT_PROCESS_COMPLETED);
|
background_process.set_finished_event(EVT_PROCESS_COMPLETED);
|
||||||
// Default printer technology for default config.
|
// Default printer technology for default config.
|
||||||
|
@ -3037,6 +3048,16 @@ bool Plater::priv::restart_background_process(unsigned int state)
|
||||||
( ((state & UPDATE_BACKGROUND_PROCESS_FORCE_RESTART) != 0 && ! this->background_process.finished()) ||
|
( ((state & UPDATE_BACKGROUND_PROCESS_FORCE_RESTART) != 0 && ! this->background_process.finished()) ||
|
||||||
(state & UPDATE_BACKGROUND_PROCESS_FORCE_EXPORT) != 0 ||
|
(state & UPDATE_BACKGROUND_PROCESS_FORCE_EXPORT) != 0 ||
|
||||||
(state & UPDATE_BACKGROUND_PROCESS_RESTART) != 0 ) ) {
|
(state & UPDATE_BACKGROUND_PROCESS_RESTART) != 0 ) ) {
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
if ((state & UPDATE_BACKGROUND_PROCESS_FORCE_EXPORT) == 0)
|
||||||
|
{
|
||||||
|
// force update of thumbnail data, so that they can be inserted into the exported gcode
|
||||||
|
thumbnail_generator.generate(view3D->get_canvas3d()->get_volumes().volumes, 256, 256, true);
|
||||||
|
thumbnail_generator.save_to_png_file("C:/prusa/test/test.png");
|
||||||
|
}
|
||||||
|
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
// The print is valid and it can be started.
|
// The print is valid and it can be started.
|
||||||
if (this->background_process.start()) {
|
if (this->background_process.start()) {
|
||||||
this->statusbar()->set_cancel_callback([this]() {
|
this->statusbar()->set_cancel_callback([this]() {
|
||||||
|
@ -3070,11 +3091,6 @@ void Plater::priv::export_gcode(fs::path output_path, PrintHostJob upload_job)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (! output_path.empty()) {
|
if (! output_path.empty()) {
|
||||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
|
||||||
#if ENABLE_THUMBNAIL_GENERATOR
|
|
||||||
thumbnail_generator.render_to_png_file(*view3D->get_canvas3d(), "C:/prusa/test/test.png", 256, 256, false);
|
|
||||||
#endif // ENABLE_THUMBNAIL_GENERATOR
|
|
||||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
|
||||||
background_process.schedule_export(output_path.string());
|
background_process.schedule_export(output_path.string());
|
||||||
} else {
|
} else {
|
||||||
background_process.schedule_upload(std::move(upload_job));
|
background_process.schedule_upload(std::move(upload_job));
|
||||||
|
@ -3604,6 +3620,15 @@ bool Plater::priv::init_object_menu()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
void Plater::priv::generate_thumbnail(unsigned int w, unsigned int h, bool printable_only)
|
||||||
|
{
|
||||||
|
thumbnail_generator.generate(view3D->get_canvas3d()->get_volumes().volumes, w, h, printable_only);
|
||||||
|
}
|
||||||
|
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
|
||||||
void Plater::priv::msw_rescale_object_menu()
|
void Plater::priv::msw_rescale_object_menu()
|
||||||
{
|
{
|
||||||
for (MenuWithSeparators* menu : { &object_menu, &sla_object_menu, &part_menu, &default_menu })
|
for (MenuWithSeparators* menu : { &object_menu, &sla_object_menu, &part_menu, &default_menu })
|
||||||
|
@ -4642,7 +4667,16 @@ void Plater::export_3mf(const boost::filesystem::path& output_path)
|
||||||
DynamicPrintConfig cfg = wxGetApp().preset_bundle->full_config_secure();
|
DynamicPrintConfig cfg = wxGetApp().preset_bundle->full_config_secure();
|
||||||
const std::string path_u8 = into_u8(path);
|
const std::string path_u8 = into_u8(path);
|
||||||
wxBusyCursor wait;
|
wxBusyCursor wait;
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
p->generate_thumbnail(128, 128, false);
|
||||||
|
if (Slic3r::store_3mf(path_u8.c_str(), &p->model, export_config ? &cfg : nullptr, &p->thumbnail_generator.get_data())) {
|
||||||
|
#else
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
if (Slic3r::store_3mf(path_u8.c_str(), &p->model, export_config ? &cfg : nullptr)) {
|
if (Slic3r::store_3mf(path_u8.c_str(), &p->model, export_config ? &cfg : nullptr)) {
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
// Success
|
// Success
|
||||||
p->statusbar()->set_status_text(wxString::Format(_(L("3MF file exported to %s")), path));
|
p->statusbar()->set_status_text(wxString::Format(_(L("3MF file exported to %s")), path));
|
||||||
p->set_project_filename(path);
|
p->set_project_filename(path);
|
||||||
|
@ -5139,6 +5173,15 @@ void Plater::paste_from_clipboard()
|
||||||
p->view3D->get_canvas3d()->get_selection().paste_from_clipboard();
|
p->view3D->get_canvas3d()->get_selection().paste_from_clipboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
void Plater::generate_thumbnail(unsigned int w, unsigned int h, bool printable_only)
|
||||||
|
{
|
||||||
|
p->generate_thumbnail(w, h, printable_only);
|
||||||
|
}
|
||||||
|
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
|
||||||
void Plater::msw_rescale()
|
void Plater::msw_rescale()
|
||||||
{
|
{
|
||||||
p->preview->msw_rescale();
|
p->preview->msw_rescale();
|
||||||
|
|
|
@ -240,6 +240,12 @@ public:
|
||||||
void copy_selection_to_clipboard();
|
void copy_selection_to_clipboard();
|
||||||
void paste_from_clipboard();
|
void paste_from_clipboard();
|
||||||
|
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
#if ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
void generate_thumbnail(unsigned int w, unsigned int h, bool printable_only);
|
||||||
|
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
|
||||||
bool can_delete() const;
|
bool can_delete() const;
|
||||||
bool can_delete_all() const;
|
bool can_delete_all() const;
|
||||||
bool can_increase_instances() const;
|
bool can_increase_instances() const;
|
||||||
|
|
|
@ -3,9 +3,12 @@
|
||||||
|
|
||||||
#if ENABLE_THUMBNAIL_GENERATOR
|
#if ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
|
||||||
#include "GLCanvas3D.hpp"
|
#include "Camera.hpp"
|
||||||
#include "3DScene.hpp"
|
#include "3DScene.hpp"
|
||||||
|
#include "GUI.hpp"
|
||||||
|
|
||||||
|
#include <boost/filesystem.hpp>
|
||||||
|
#include <boost/algorithm/string/predicate.hpp>
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
@ -16,10 +19,18 @@ void ThumbnailGenerator::reset()
|
||||||
m_data.reset();
|
m_data.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ThumbnailGenerator::render_to_png_file(const GLCanvas3D& canvas, const std::string& filename, unsigned int w, unsigned int h, bool printable_only)
|
void ThumbnailGenerator::generate(const GLVolumePtrs& volumes, unsigned int w, unsigned int h, bool printable_only)
|
||||||
{
|
{
|
||||||
|
std::cout << "Generated thumbnail " << w << "x" << h << std::endl;
|
||||||
|
|
||||||
m_data.set(w, h);
|
m_data.set(w, h);
|
||||||
render(canvas, printable_only);
|
render_and_store(volumes, printable_only);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ThumbnailGenerator::save_to_png_file(const std::string& filename)
|
||||||
|
{
|
||||||
|
if (!m_data.is_valid())
|
||||||
|
return false;
|
||||||
|
|
||||||
wxImage image(m_data.width, m_data.height);
|
wxImage image(m_data.width, m_data.height);
|
||||||
image.InitAlpha();
|
image.InitAlpha();
|
||||||
|
@ -30,24 +41,26 @@ bool ThumbnailGenerator::render_to_png_file(const GLCanvas3D& canvas, const std:
|
||||||
for (unsigned int c = 0; c < m_data.width; ++c)
|
for (unsigned int c = 0; c < m_data.width; ++c)
|
||||||
{
|
{
|
||||||
unsigned char* px = m_data.pixels.data() + 4 * (rr + c);
|
unsigned char* px = m_data.pixels.data() + 4 * (rr + c);
|
||||||
// unsigned char* px = m_data.pixels.data() + 4 * (r * m_data.width + c);
|
|
||||||
image.SetRGB((int)c, (int)r, px[0], px[1], px[2]);
|
image.SetRGB((int)c, (int)r, px[0], px[1], px[2]);
|
||||||
image.SetAlpha((int)c, (int)r, px[3]);
|
image.SetAlpha((int)c, (int)r, px[3]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
image.SaveFile(filename, wxBITMAP_TYPE_PNG);
|
std::string path = filename;
|
||||||
|
if (!boost::iends_with(path, ".png"))
|
||||||
|
path = boost::filesystem::path(path).replace_extension(".png").string();
|
||||||
|
|
||||||
return true;
|
return image.SaveFile(from_u8(path), wxBITMAP_TYPE_PNG);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThumbnailGenerator::render(const GLCanvas3D& canvas, bool printable_only)
|
void ThumbnailGenerator::render_and_store(const GLVolumePtrs& volumes, bool printable_only)
|
||||||
{
|
{
|
||||||
const GLVolumeCollection& volumes = canvas.get_volumes();
|
static const float orange[] = { 0.99f, 0.49f, 0.26f };
|
||||||
|
static const float gray[] = { 0.64f, 0.64f, 0.64f };
|
||||||
|
|
||||||
std::vector<const GLVolume*> visible_volumes;
|
GLVolumeConstPtrs visible_volumes;
|
||||||
|
|
||||||
for (const GLVolume* vol : volumes.volumes)
|
for (const GLVolume* vol : volumes)
|
||||||
{
|
{
|
||||||
if (!printable_only || vol->printable)
|
if (!printable_only || vol->printable)
|
||||||
visible_volumes.push_back(vol);
|
visible_volumes.push_back(vol);
|
||||||
|
@ -69,19 +82,10 @@ void ThumbnailGenerator::render(const GLCanvas3D& canvas, bool printable_only)
|
||||||
camera.apply_projection(box);
|
camera.apply_projection(box);
|
||||||
|
|
||||||
glsafe(::glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
|
glsafe(::glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
|
||||||
render_objects(visible_volumes);
|
|
||||||
glsafe(::glReadPixels(0, 0, m_data.width, m_data.height, GL_RGBA, GL_UNSIGNED_BYTE, (void*)m_data.pixels.data()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ThumbnailGenerator::render_objects(const std::vector<const GLVolume*>& volumes) const
|
|
||||||
{
|
|
||||||
static const float orange[] = { 0.99f, 0.49f, 0.26f };
|
|
||||||
static const float gray[] = { 0.64f, 0.64f, 0.64f };
|
|
||||||
|
|
||||||
glsafe(::glEnable(GL_LIGHTING));
|
glsafe(::glEnable(GL_LIGHTING));
|
||||||
glsafe(::glEnable(GL_DEPTH_TEST));
|
glsafe(::glEnable(GL_DEPTH_TEST));
|
||||||
|
|
||||||
for (const GLVolume* vol : volumes)
|
for (const GLVolume* vol : visible_volumes)
|
||||||
{
|
{
|
||||||
glsafe(::glColor3fv(vol->printable ? orange : gray));
|
glsafe(::glColor3fv(vol->printable ? orange : gray));
|
||||||
vol->render();
|
vol->render();
|
||||||
|
@ -89,6 +93,7 @@ void ThumbnailGenerator::render_objects(const std::vector<const GLVolume*>& volu
|
||||||
|
|
||||||
glsafe(::glDisable(GL_DEPTH_TEST));
|
glsafe(::glDisable(GL_DEPTH_TEST));
|
||||||
glsafe(::glDisable(GL_LIGHTING));
|
glsafe(::glDisable(GL_LIGHTING));
|
||||||
|
glsafe(::glReadPixels(0, 0, m_data.width, m_data.height, GL_RGBA, GL_UNSIGNED_BYTE, (void*)m_data.pixels.data()));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace GUI
|
} // namespace GUI
|
||||||
|
|
|
@ -5,15 +5,15 @@
|
||||||
|
|
||||||
#include "../libslic3r/GCode/ThumbnailData.hpp"
|
#include "../libslic3r/GCode/ThumbnailData.hpp"
|
||||||
|
|
||||||
#include <array>
|
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
class GLVolume;
|
class GLVolume;
|
||||||
|
typedef std::vector<GLVolume*> GLVolumePtrs;
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
class GLCanvas3D;
|
|
||||||
|
|
||||||
class ThumbnailGenerator
|
class ThumbnailGenerator
|
||||||
{
|
{
|
||||||
|
typedef std::vector<const GLVolume*> GLVolumeConstPtrs;
|
||||||
|
|
||||||
ThumbnailData m_data;
|
ThumbnailData m_data;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -21,11 +21,14 @@ namespace GUI {
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
bool render_to_png_file(const GLCanvas3D& canvas, const std::string& filename, unsigned int w, unsigned int h, bool printable_only);
|
void generate(const GLVolumePtrs& volumes, unsigned int w, unsigned int h, bool printable_only);
|
||||||
|
|
||||||
|
const ThumbnailData& get_data() const { return m_data; }
|
||||||
|
|
||||||
|
bool save_to_png_file(const std::string& filename);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void render(const GLCanvas3D& canvas, bool printable_only);
|
void render_and_store(const GLVolumePtrs& volumes, bool printable_only);
|
||||||
void render_objects(const std::vector<const GLVolume*>& volumes) const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace GUI
|
} // namespace GUI
|
||||||
|
|
Loading…
Reference in a new issue