mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-11-02 20:51:23 -07:00 
			
		
		
		
	ENABLE_THUMBNAIL_GENERATOR set as default
This commit is contained in:
		
							parent
							
								
									fac28ea27a
								
							
						
					
					
						commit
						3d6c9e54e9
					
				
					 16 changed files with 7 additions and 224 deletions
				
			
		| 
						 | 
				
			
			@ -3,9 +3,7 @@
 | 
			
		|||
#include "../Utils.hpp"
 | 
			
		||||
#include "../GCode.hpp"
 | 
			
		||||
#include "../Geometry.hpp"
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
#include "../GCode/ThumbnailData.hpp"
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
 | 
			
		||||
#include "../I18N.hpp"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -47,9 +45,7 @@ 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 CONTENT_TYPES_FILE = "[Content_Types].xml";
 | 
			
		||||
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 MODEL_CONFIG_FILE = "Metadata/Slic3r_PE_model.config";
 | 
			
		||||
const std::string LAYER_HEIGHTS_PROFILE_FILE = "Metadata/Slic3r_PE_layer_heights_profile.txt";
 | 
			
		||||
| 
						 | 
				
			
			@ -1969,22 +1965,12 @@ namespace Slic3r {
 | 
			
		|||
        bool m_fullpath_sources{ true };
 | 
			
		||||
 | 
			
		||||
    public:
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
        bool save_model_to_file(const std::string& filename, Model& model, const DynamicPrintConfig* config, bool fullpath_sources, const ThumbnailData* thumbnail_data = nullptr);
 | 
			
		||||
#else
 | 
			
		||||
        bool save_model_to_file(const std::string& filename, Model& model, const DynamicPrintConfig* config, bool fullpath_sources);
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
 | 
			
		||||
    private:
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
        bool _save_model_to_file(const std::string& filename, Model& model, const DynamicPrintConfig* config, const ThumbnailData* thumbnail_data);
 | 
			
		||||
#else
 | 
			
		||||
        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);
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
        bool _add_thumbnail_file_to_archive(mz_zip_archive& archive, const ThumbnailData& thumbnail_data);
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
        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_object_to_model_stream(std::stringstream& stream, unsigned int& object_id, ModelObject& object, BuildItemsList& build_items, VolumeToOffsetsMap& volumes_offsets);
 | 
			
		||||
| 
						 | 
				
			
			@ -1999,26 +1985,14 @@ namespace Slic3r {
 | 
			
		|||
        bool _add_custom_gcode_per_print_z_file_to_archive(mz_zip_archive& archive, Model& model);
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
    bool _3MF_Exporter::save_model_to_file(const std::string& filename, Model& model, const DynamicPrintConfig* config, bool fullpath_sources, const ThumbnailData* thumbnail_data)
 | 
			
		||||
    {
 | 
			
		||||
        clear_errors();
 | 
			
		||||
        m_fullpath_sources = fullpath_sources;
 | 
			
		||||
        return _save_model_to_file(filename, model, config, thumbnail_data);
 | 
			
		||||
    }
 | 
			
		||||
#else
 | 
			
		||||
    bool _3MF_Exporter::save_model_to_file(const std::string& filename, Model& model, const DynamicPrintConfig* config, bool fullpath_sources)
 | 
			
		||||
    {
 | 
			
		||||
        clear_errors();
 | 
			
		||||
        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_data)
 | 
			
		||||
#else
 | 
			
		||||
    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_zero_struct(&archive);
 | 
			
		||||
| 
						 | 
				
			
			@ -2037,7 +2011,6 @@ namespace Slic3r {
 | 
			
		|||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
        if ((thumbnail_data != nullptr) && thumbnail_data->is_valid())
 | 
			
		||||
        {
 | 
			
		||||
            // Adds the file Metadata/thumbnail.png.
 | 
			
		||||
| 
						 | 
				
			
			@ -2048,7 +2021,6 @@ namespace Slic3r {
 | 
			
		|||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
 | 
			
		||||
        // Adds relationships file ("_rels/.rels"). 
 | 
			
		||||
        // The content of this file is the same for each PrusaSlicer 3mf.
 | 
			
		||||
| 
						 | 
				
			
			@ -2160,9 +2132,7 @@ namespace Slic3r {
 | 
			
		|||
        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=\"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>";
 | 
			
		||||
 | 
			
		||||
        std::string out = stream.str();
 | 
			
		||||
| 
						 | 
				
			
			@ -2176,7 +2146,6 @@ namespace Slic3r {
 | 
			
		|||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
    bool _3MF_Exporter::_add_thumbnail_file_to_archive(mz_zip_archive& archive, const ThumbnailData& thumbnail_data)
 | 
			
		||||
    {
 | 
			
		||||
        bool res = false;
 | 
			
		||||
| 
						 | 
				
			
			@ -2194,7 +2163,6 @@ namespace Slic3r {
 | 
			
		|||
 | 
			
		||||
        return res;
 | 
			
		||||
    }
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
 | 
			
		||||
    bool _3MF_Exporter::_add_relationships_file_to_archive(mz_zip_archive& archive)
 | 
			
		||||
    {
 | 
			
		||||
| 
						 | 
				
			
			@ -2202,9 +2170,7 @@ namespace Slic3r {
 | 
			
		|||
        stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\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";
 | 
			
		||||
#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>";
 | 
			
		||||
 | 
			
		||||
        std::string out = stream.str();
 | 
			
		||||
| 
						 | 
				
			
			@ -2795,22 +2761,13 @@ bool load_3mf(const char* path, DynamicPrintConfig* config, Model* model, bool c
 | 
			
		|||
        return res;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
bool store_3mf(const char* path, Model* model, const DynamicPrintConfig* config, bool fullpath_sources, const ThumbnailData* thumbnail_data)
 | 
			
		||||
#else
 | 
			
		||||
bool store_3mf(const char* path, Model* model, const DynamicPrintConfig* config, bool fullpath_sources)
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
    {
 | 
			
		||||
        if ((path == nullptr) || (model == nullptr))
 | 
			
		||||
            return false;
 | 
			
		||||
 | 
			
		||||
        _3MF_Exporter exporter;
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
        bool res = exporter.save_model_to_file(path, *model, config, fullpath_sources, thumbnail_data);
 | 
			
		||||
#else
 | 
			
		||||
        bool res = exporter.save_model_to_file(path, *model, config, fullpath_sources);
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
 | 
			
		||||
        if (!res)
 | 
			
		||||
            exporter.log_errors();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -26,20 +26,14 @@ namespace Slic3r {
 | 
			
		|||
 | 
			
		||||
    class Model;
 | 
			
		||||
    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.
 | 
			
		||||
    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.
 | 
			
		||||
    // 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, bool fullpath_sources, const ThumbnailData* thumbnail_data = nullptr);
 | 
			
		||||
#else
 | 
			
		||||
    extern bool store_3mf(const char* path, Model* model, const DynamicPrintConfig* config, bool fullpath_sources);
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
 | 
			
		||||
}; // namespace Slic3r
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,9 +20,7 @@
 | 
			
		|||
#include <boost/foreach.hpp>
 | 
			
		||||
#include <boost/filesystem.hpp>
 | 
			
		||||
#include <boost/log/trivial.hpp>
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
#include <boost/beast/core/detail/base64.hpp>
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
 | 
			
		||||
#include <boost/nowide/iostream.hpp>
 | 
			
		||||
#include <boost/nowide/cstdio.hpp>
 | 
			
		||||
| 
						 | 
				
			
			@ -700,11 +698,7 @@ std::vector<std::pair<coordf_t, std::vector<GCode::LayerToPrint>>> GCode::collec
 | 
			
		|||
    return layers_to_print;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
void GCode::do_export(Print* print, const char* path, GCodePreviewData* preview_data, ThumbnailsGeneratorCallback thumbnail_cb)
 | 
			
		||||
#else
 | 
			
		||||
void GCode::do_export(Print *print, const char *path, GCodePreviewData *preview_data)
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
{
 | 
			
		||||
    PROFILE_CLEAR();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -730,11 +724,7 @@ void GCode::do_export(Print *print, const char *path, GCodePreviewData *preview_
 | 
			
		|||
 | 
			
		||||
    try {
 | 
			
		||||
        m_placeholder_parser_failed_templates.clear();
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
        this->_do_export(*print, file, thumbnail_cb);
 | 
			
		||||
#else
 | 
			
		||||
        this->_do_export(*print, file);
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
        fflush(file);
 | 
			
		||||
        if (ferror(file)) {
 | 
			
		||||
            fclose(file);
 | 
			
		||||
| 
						 | 
				
			
			@ -974,7 +964,6 @@ namespace DoExport {
 | 
			
		|||
	    }
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
	template<typename WriteToOutput, typename ThrowIfCanceledCallback>
 | 
			
		||||
	static void export_thumbnails_to_file(ThumbnailsGeneratorCallback &thumbnail_cb, const std::vector<Vec2d> &sizes, WriteToOutput output, ThrowIfCanceledCallback throw_if_canceled)
 | 
			
		||||
	{
 | 
			
		||||
| 
						 | 
				
			
			@ -1018,7 +1007,6 @@ namespace DoExport {
 | 
			
		|||
	        }
 | 
			
		||||
	    }
 | 
			
		||||
	}
 | 
			
		||||
	#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
 | 
			
		||||
	// Fill in print_statistics and return formatted string containing filament statistics to be inserted into G-code comment section.
 | 
			
		||||
	static std::string update_print_stats_and_format_filament_stats(
 | 
			
		||||
| 
						 | 
				
			
			@ -1124,11 +1112,7 @@ std::vector<const PrintInstance*> sort_object_instances_by_model_order(const Pri
 | 
			
		|||
    return instances;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
void GCode::_do_export(Print& print, FILE* file, ThumbnailsGeneratorCallback thumbnail_cb)
 | 
			
		||||
#else
 | 
			
		||||
void GCode::_do_export(Print& print, FILE* file)
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
{
 | 
			
		||||
    PROFILE_FUNC();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,9 +17,7 @@
 | 
			
		|||
#include "GCodeTimeEstimator.hpp"
 | 
			
		||||
#include "EdgeGrid.hpp"
 | 
			
		||||
#include "GCode/Analyzer.hpp"
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
#include "GCode/ThumbnailData.hpp"
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
 | 
			
		||||
#include <memory>
 | 
			
		||||
#include <string>
 | 
			
		||||
| 
						 | 
				
			
			@ -166,11 +164,7 @@ public:
 | 
			
		|||
 | 
			
		||||
    // throws std::runtime_exception on error,
 | 
			
		||||
    // throws CanceledException through print->throw_if_canceled().
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
    void            do_export(Print* print, const char* path, GCodePreviewData* preview_data = nullptr, ThumbnailsGeneratorCallback thumbnail_cb = nullptr);
 | 
			
		||||
#else
 | 
			
		||||
    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.
 | 
			
		||||
    const Vec2d&    origin() const { return m_origin; }
 | 
			
		||||
| 
						 | 
				
			
			@ -210,11 +204,7 @@ public:
 | 
			
		|||
    };
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
    void            _do_export(Print &print, FILE *file, ThumbnailsGeneratorCallback thumbnail_cb);
 | 
			
		||||
#else
 | 
			
		||||
    void            _do_export(Print &print, FILE *file);
 | 
			
		||||
#endif //ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
 | 
			
		||||
    static std::vector<LayerToPrint>        		                   collect_layers_to_print(const PrintObject &object);
 | 
			
		||||
    static std::vector<std::pair<coordf_t, std::vector<LayerToPrint>>> collect_layers_to_print(const Print &print);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,8 +1,6 @@
 | 
			
		|||
#include "libslic3r/libslic3r.h"
 | 
			
		||||
#include "ThumbnailData.hpp"
 | 
			
		||||
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
 | 
			
		||||
namespace Slic3r {
 | 
			
		||||
 | 
			
		||||
void ThumbnailData::set(unsigned int w, unsigned int h)
 | 
			
		||||
| 
						 | 
				
			
			@ -32,5 +30,3 @@ bool ThumbnailData::is_valid() const
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
} // namespace Slic3r
 | 
			
		||||
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
| 
						 | 
				
			
			@ -1,8 +1,6 @@
 | 
			
		|||
#ifndef slic3r_ThumbnailData_hpp_
 | 
			
		||||
#define slic3r_ThumbnailData_hpp_
 | 
			
		||||
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
 | 
			
		||||
#include <vector>
 | 
			
		||||
#include "libslic3r/Point.hpp"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -26,6 +24,4 @@ typedef std::function<void(ThumbnailsList & thumbnails, const Vec2ds & sizes, bo
 | 
			
		|||
 | 
			
		||||
} // namespace Slic3r
 | 
			
		||||
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
 | 
			
		||||
#endif // slic3r_ThumbnailData_hpp_
 | 
			
		||||
| 
						 | 
				
			
			@ -1622,11 +1622,7 @@ void Print::process()
 | 
			
		|||
// 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).
 | 
			
		||||
// 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, ThumbnailsGeneratorCallback thumbnail_cb)
 | 
			
		||||
#else
 | 
			
		||||
std::string Print::export_gcode(const std::string &path_template, GCodePreviewData *preview_data)
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
{
 | 
			
		||||
    // output everything to a G-code file
 | 
			
		||||
    // The following call may die if the output_filename_format template substitution fails.
 | 
			
		||||
| 
						 | 
				
			
			@ -1643,11 +1639,7 @@ std::string Print::export_gcode(const std::string &path_template, GCodePreviewDa
 | 
			
		|||
 | 
			
		||||
    // The following line may die for multiple reasons.
 | 
			
		||||
    GCode gcode;
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
    gcode.do_export(this, path.c_str(), preview_data, thumbnail_cb);
 | 
			
		||||
#else
 | 
			
		||||
    gcode.do_export(this, path.c_str(), preview_data);
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
    return path.c_str();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,9 +11,7 @@
 | 
			
		|||
#include "Slicing.hpp"
 | 
			
		||||
#include "GCode/ToolOrdering.hpp"
 | 
			
		||||
#include "GCode/WipeTower.hpp"
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
#include "GCode/ThumbnailData.hpp"
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
 | 
			
		||||
#include "libslic3r.h"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -364,11 +362,7 @@ public:
 | 
			
		|||
    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.
 | 
			
		||||
    // 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, ThumbnailsGeneratorCallback thumbnail_cb = nullptr);
 | 
			
		||||
#else
 | 
			
		||||
    std::string         export_gcode(const std::string &path_template, GCodePreviewData *preview_data);
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
 | 
			
		||||
    // methods for handling state
 | 
			
		||||
    bool                is_step_done(PrintStep step) const { return Inherited::is_step_done(step); }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
#ifndef _technologies_h_
 | 
			
		||||
#define _technologies_h_
 | 
			
		||||
#ifndef _prusaslicer_technologies_h_
 | 
			
		||||
#define _prusaslicer_technologies_h_
 | 
			
		||||
 | 
			
		||||
//============
 | 
			
		||||
// debug techs
 | 
			
		||||
| 
						 | 
				
			
			@ -17,29 +17,12 @@
 | 
			
		|||
#define ENABLE_CAMERA_STATISTICS 0
 | 
			
		||||
//  Render the picking pass instead of the main scene (use [T] key to toggle between regular rendering and picking pass only rendering)
 | 
			
		||||
#define ENABLE_RENDER_PICKING_PASS 0
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
//====================
 | 
			
		||||
// 1.42.0.alpha1 techs
 | 
			
		||||
//====================
 | 
			
		||||
#define ENABLE_1_42_0_ALPHA1 1
 | 
			
		||||
 | 
			
		||||
// Enable extracting thumbnails from selected gcode and save them as png files
 | 
			
		||||
#define ENABLE_THUMBNAIL_GENERATOR_DEBUG 0
 | 
			
		||||
// Disable synchronization of unselected instances
 | 
			
		||||
#define DISABLE_INSTANCES_SYNCH (0 && ENABLE_1_42_0_ALPHA1)
 | 
			
		||||
#define DISABLE_INSTANCES_SYNCH 0
 | 
			
		||||
// Use wxDataViewRender instead of wxDataViewCustomRenderer
 | 
			
		||||
#define ENABLE_NONCUSTOM_DATA_VIEW_RENDERING (0 && ENABLE_1_42_0_ALPHA1)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
//====================
 | 
			
		||||
// 2.2.0.alpha1 techs
 | 
			
		||||
//====================
 | 
			
		||||
#define ENABLE_2_2_0_ALPHA1 1
 | 
			
		||||
 | 
			
		||||
// Enable thumbnail generator
 | 
			
		||||
// When removing this technology, remove it also from stable branch, 
 | 
			
		||||
// where it has been partially copied for patch 2.1.1
 | 
			
		||||
#define ENABLE_THUMBNAIL_GENERATOR (1 && ENABLE_2_2_0_ALPHA1)
 | 
			
		||||
#define ENABLE_THUMBNAIL_GENERATOR_DEBUG (0 && ENABLE_THUMBNAIL_GENERATOR)
 | 
			
		||||
#define ENABLE_NONCUSTOM_DATA_VIEW_RENDERING 0
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
//================
 | 
			
		||||
| 
						 | 
				
			
			@ -72,4 +55,4 @@
 | 
			
		|||
#define ENABLE_GIZMO_TOOLBAR_DRAGGING_FIX (1 && ENABLE_2_2_0_FINAL)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif // _technologies_h_
 | 
			
		||||
#endif // _prusaslicer_technologies_h_
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,9 +11,7 @@
 | 
			
		|||
#include <wx/wfstream.h>
 | 
			
		||||
#include <wx/zipstrm.h>
 | 
			
		||||
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
#include <miniz.h>
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
 | 
			
		||||
// Print now includes tbb, and tbb includes Windows. This breaks compilation of wxWidgets if included before wx.
 | 
			
		||||
#include "libslic3r/Print.hpp"
 | 
			
		||||
| 
						 | 
				
			
			@ -89,11 +87,7 @@ void BackgroundSlicingProcess::process_fff()
 | 
			
		|||
	assert(m_print == m_fff_print);
 | 
			
		||||
    m_print->process();
 | 
			
		||||
	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_cb);
 | 
			
		||||
#else
 | 
			
		||||
    m_fff_print->export_gcode(m_temp_output_path, m_gcode_preview_data);
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
 | 
			
		||||
	if (this->set_step_started(bspsGCodeFinalize)) {
 | 
			
		||||
	    if (! m_export_path.empty()) {
 | 
			
		||||
| 
						 | 
				
			
			@ -135,7 +129,6 @@ void BackgroundSlicingProcess::process_fff()
 | 
			
		|||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
static void write_thumbnail(Zipper& zipper, const ThumbnailData& data)
 | 
			
		||||
{
 | 
			
		||||
    size_t png_size = 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -146,7 +139,6 @@ static void write_thumbnail(Zipper& zipper, const ThumbnailData& data)
 | 
			
		|||
        mz_free(png_data);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
 | 
			
		||||
void BackgroundSlicingProcess::process_sla()
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -159,7 +151,6 @@ void BackgroundSlicingProcess::process_sla()
 | 
			
		|||
            Zipper zipper(export_path);
 | 
			
		||||
            m_sla_print->export_raster(zipper);
 | 
			
		||||
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
            if (m_thumbnail_cb != nullptr)
 | 
			
		||||
            {
 | 
			
		||||
                ThumbnailsList thumbnails;
 | 
			
		||||
| 
						 | 
				
			
			@ -171,7 +162,6 @@ void BackgroundSlicingProcess::process_sla()
 | 
			
		|||
                        write_thumbnail(zipper, data);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
 | 
			
		||||
            zipper.finalize();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -486,7 +476,6 @@ void BackgroundSlicingProcess::prepare_upload()
 | 
			
		|||
 | 
			
		||||
        Zipper zipper{source_path.string()};
 | 
			
		||||
        m_sla_print->export_raster(zipper, m_upload_job.upload_data.upload_path.string());
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
        if (m_thumbnail_cb != nullptr)
 | 
			
		||||
        {
 | 
			
		||||
            ThumbnailsList thumbnails;
 | 
			
		||||
| 
						 | 
				
			
			@ -498,7 +487,6 @@ void BackgroundSlicingProcess::prepare_upload()
 | 
			
		|||
                    write_thumbnail(zipper, data);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
        zipper.finalize();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -49,9 +49,7 @@ public:
 | 
			
		|||
	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
 | 
			
		||||
 | 
			
		||||
	// 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.
 | 
			
		||||
| 
						 | 
				
			
			@ -155,10 +153,8 @@ private:
 | 
			
		|||
	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.
 | 
			
		||||
	std::string 				m_temp_output_path;
 | 
			
		||||
	// Output path provided by the user. The output path may be set even if the slicing is running,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,6 @@
 | 
			
		|||
#include "libslic3r/libslic3r.h"
 | 
			
		||||
 | 
			
		||||
#include "Camera.hpp"
 | 
			
		||||
#if !ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
#include "3DScene.hpp"
 | 
			
		||||
#endif // !ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
#include "GUI_App.hpp"
 | 
			
		||||
#include "AppConfig.hpp"
 | 
			
		||||
#if ENABLE_CAMERA_STATISTICS
 | 
			
		||||
| 
						 | 
				
			
			@ -25,10 +22,8 @@ namespace Slic3r {
 | 
			
		|||
namespace GUI {
 | 
			
		||||
 | 
			
		||||
const double Camera::DefaultDistance = 1000.0;
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
const double Camera::DefaultZoomToBoxMarginFactor = 1.025;
 | 
			
		||||
const double Camera::DefaultZoomToVolumesMarginFactor = 1.025;
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
double Camera::FrustrumMinZRange = 50.0;
 | 
			
		||||
double Camera::FrustrumMinNearZ = 100.0;
 | 
			
		||||
double Camera::FrustrumZMargin = 10.0;
 | 
			
		||||
| 
						 | 
				
			
			@ -219,18 +214,10 @@ void Camera::apply_projection(const BoundingBoxf3& box, double near_z, double fa
 | 
			
		|||
    glsafe(::glMatrixMode(GL_MODELVIEW));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
void Camera::zoom_to_box(const BoundingBoxf3& box, double margin_factor)
 | 
			
		||||
#else
 | 
			
		||||
void Camera::zoom_to_box(const BoundingBoxf3& box, int canvas_w, int canvas_h)
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
{
 | 
			
		||||
    // Calculate the zoom factor needed to adjust the view around the given box.
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
    double zoom = calc_zoom_to_bounding_box_factor(box, margin_factor);
 | 
			
		||||
#else
 | 
			
		||||
    double zoom = calc_zoom_to_bounding_box_factor(box, canvas_w, canvas_h);
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
    if (zoom > 0.0)
 | 
			
		||||
    {
 | 
			
		||||
        m_zoom = zoom;
 | 
			
		||||
| 
						 | 
				
			
			@ -239,7 +226,6 @@ void Camera::zoom_to_box(const BoundingBoxf3& box, int canvas_w, int canvas_h)
 | 
			
		|||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
void Camera::zoom_to_volumes(const GLVolumePtrs& volumes, double margin_factor)
 | 
			
		||||
{
 | 
			
		||||
    Vec3d center;
 | 
			
		||||
| 
						 | 
				
			
			@ -251,7 +237,6 @@ void Camera::zoom_to_volumes(const GLVolumePtrs& volumes, double margin_factor)
 | 
			
		|||
        set_target(center);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
 | 
			
		||||
#if ENABLE_CAMERA_STATISTICS
 | 
			
		||||
void Camera::debug_render() const
 | 
			
		||||
| 
						 | 
				
			
			@ -387,11 +372,7 @@ std::pair<double, double> Camera::calc_tight_frustrum_zs_around(const BoundingBo
 | 
			
		|||
    return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
double Camera::calc_zoom_to_bounding_box_factor(const BoundingBoxf3& box, double margin_factor) const
 | 
			
		||||
#else
 | 
			
		||||
double Camera::calc_zoom_to_bounding_box_factor(const BoundingBoxf3& box, int canvas_w, int canvas_h) const
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
{
 | 
			
		||||
    double max_bb_size = box.max_size();
 | 
			
		||||
    if (max_bb_size == 0.0)
 | 
			
		||||
| 
						 | 
				
			
			@ -423,11 +404,6 @@ double Camera::calc_zoom_to_bounding_box_factor(const BoundingBoxf3& box, int ca
 | 
			
		|||
    double max_x = -DBL_MAX;
 | 
			
		||||
    double max_y = -DBL_MAX;
 | 
			
		||||
 | 
			
		||||
#if !ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
    // margin factor to give some empty space around the box
 | 
			
		||||
    double margin_factor = 1.25;
 | 
			
		||||
#endif // !ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
 | 
			
		||||
    for (const Vec3d& v : vertices)
 | 
			
		||||
    {
 | 
			
		||||
        // project vertex on the plane perpendicular to camera forward axis
 | 
			
		||||
| 
						 | 
				
			
			@ -458,7 +434,6 @@ double Camera::calc_zoom_to_bounding_box_factor(const BoundingBoxf3& box, int ca
 | 
			
		|||
    return std::min((double)m_viewport[2] / dx, (double)m_viewport[3] / dy);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
double Camera::calc_zoom_to_volumes_factor(const GLVolumePtrs& volumes, Vec3d& center, double margin_factor) const
 | 
			
		||||
{
 | 
			
		||||
    if (volumes.empty())
 | 
			
		||||
| 
						 | 
				
			
			@ -519,7 +494,6 @@ double Camera::calc_zoom_to_volumes_factor(const GLVolumePtrs& volumes, Vec3d& c
 | 
			
		|||
 | 
			
		||||
    return std::min((double)m_viewport[2] / dx, (double)m_viewport[3] / dy);
 | 
			
		||||
}
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
 | 
			
		||||
void Camera::set_distance(double distance) const
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,9 +2,7 @@
 | 
			
		|||
#define slic3r_Camera_hpp_
 | 
			
		||||
 | 
			
		||||
#include "libslic3r/BoundingBox.hpp"
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
#include "3DScene.hpp"
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
#include <array>
 | 
			
		||||
 | 
			
		||||
namespace Slic3r {
 | 
			
		||||
| 
						 | 
				
			
			@ -13,10 +11,8 @@ namespace GUI {
 | 
			
		|||
struct Camera
 | 
			
		||||
{
 | 
			
		||||
    static const double DefaultDistance;
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
    static const double DefaultZoomToBoxMarginFactor;
 | 
			
		||||
    static const double DefaultZoomToVolumesMarginFactor;
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
    static double FrustrumMinZRange;
 | 
			
		||||
    static double FrustrumMinNearZ;
 | 
			
		||||
    static double FrustrumZMargin;
 | 
			
		||||
| 
						 | 
				
			
			@ -97,12 +93,8 @@ public:
 | 
			
		|||
    // If larger z span is needed, pass the desired values of near and far z (negative values are ignored)
 | 
			
		||||
    void apply_projection(const BoundingBoxf3& box, double near_z = -1.0, double far_z = -1.0) const;
 | 
			
		||||
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
    void zoom_to_box(const BoundingBoxf3& box, double margin_factor = DefaultZoomToBoxMarginFactor);
 | 
			
		||||
    void zoom_to_volumes(const GLVolumePtrs& volumes, double margin_factor = DefaultZoomToVolumesMarginFactor);
 | 
			
		||||
#else
 | 
			
		||||
    void zoom_to_box(const BoundingBoxf3& box, int canvas_w, int canvas_h);
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
 | 
			
		||||
#if ENABLE_CAMERA_STATISTICS
 | 
			
		||||
    void debug_render() const;
 | 
			
		||||
| 
						 | 
				
			
			@ -138,12 +130,8 @@ private:
 | 
			
		|||
    // returns tight values for nearZ and farZ plane around the given bounding box
 | 
			
		||||
    // the camera MUST be outside of the bounding box in eye coordinate of the given box
 | 
			
		||||
    std::pair<double, double> calc_tight_frustrum_zs_around(const BoundingBoxf3& box) const;
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
    double calc_zoom_to_bounding_box_factor(const BoundingBoxf3& box, double margin_factor = DefaultZoomToBoxMarginFactor) const;
 | 
			
		||||
    double calc_zoom_to_volumes_factor(const GLVolumePtrs& volumes, Vec3d& center, double margin_factor = DefaultZoomToVolumesMarginFactor) const;
 | 
			
		||||
#else
 | 
			
		||||
    double calc_zoom_to_bounding_box_factor(const BoundingBoxf3& box, int canvas_w, int canvas_h) const;
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
    void set_distance(double distance) const;
 | 
			
		||||
 | 
			
		||||
    void set_default_orientation();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,9 +7,7 @@
 | 
			
		|||
#include "libslic3r/ClipperUtils.hpp"
 | 
			
		||||
#include "libslic3r/PrintConfig.hpp"
 | 
			
		||||
#include "libslic3r/GCode/PreviewData.hpp"
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
#include "libslic3r/GCode/ThumbnailData.hpp"
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
#include "libslic3r/Geometry.hpp"
 | 
			
		||||
#include "libslic3r/ExtrusionEntity.hpp"
 | 
			
		||||
#include "libslic3r/Utils.hpp"
 | 
			
		||||
| 
						 | 
				
			
			@ -1457,9 +1455,7 @@ wxDEFINE_EVENT(EVT_GLCANVAS_ADAPTIVE_LAYER_HEIGHT_PROFILE, Event<float>);
 | 
			
		|||
wxDEFINE_EVENT(EVT_GLCANVAS_SMOOTH_LAYER_HEIGHT_PROFILE, HeightProfileSmoothEvent);
 | 
			
		||||
wxDEFINE_EVENT(EVT_GLCANVAS_RELOAD_FROM_DISK, SimpleEvent);
 | 
			
		||||
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
const double GLCanvas3D::DefaultCameraZoomToBoxMarginFactor = 1.25;
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
 | 
			
		||||
GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar)
 | 
			
		||||
    : m_canvas(canvas)
 | 
			
		||||
| 
						 | 
				
			
			@ -2060,7 +2056,6 @@ void GLCanvas3D::render()
 | 
			
		|||
#endif // !ENABLE_CANVAS_TOOLTIP_USING_IMGUI
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
void GLCanvas3D::render_thumbnail(ThumbnailData& thumbnail_data, unsigned int w, unsigned int h, bool printable_only, bool parts_only, bool show_bed, bool transparent_background) const
 | 
			
		||||
{
 | 
			
		||||
    switch (GLCanvas3DManager::get_framebuffers_type())
 | 
			
		||||
| 
						 | 
				
			
			@ -2070,7 +2065,6 @@ void GLCanvas3D::render_thumbnail(ThumbnailData& thumbnail_data, unsigned int w,
 | 
			
		|||
    default: { _render_thumbnail_legacy(thumbnail_data, w, h, printable_only, parts_only, show_bed, transparent_background); break; }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
 | 
			
		||||
void GLCanvas3D::select_all()
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -4221,7 +4215,6 @@ bool GLCanvas3D::_render_undo_redo_stack(const bool is_undo, float pos_x) const
 | 
			
		|||
    return action_taken;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
#define ENABLE_THUMBNAIL_GENERATOR_DEBUG_OUTPUT 0
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR_DEBUG_OUTPUT
 | 
			
		||||
static void debug_output_thumbnail(const ThumbnailData& thumbnail_data)
 | 
			
		||||
| 
						 | 
				
			
			@ -4571,7 +4564,6 @@ void GLCanvas3D::_render_thumbnail_legacy(ThumbnailData& thumbnail_data, unsigne
 | 
			
		|||
    // restore the default framebuffer size to avoid flickering on the 3D scene
 | 
			
		||||
    m_camera.apply_viewport(0, 0, cnv_size.get_width(), cnv_size.get_height());
 | 
			
		||||
}
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
 | 
			
		||||
bool GLCanvas3D::_init_toolbars()
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -4899,20 +4891,11 @@ BoundingBoxf3 GLCanvas3D::_max_bounding_box(bool include_gizmos, bool include_be
 | 
			
		|||
    return bb;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
void GLCanvas3D::_zoom_to_box(const BoundingBoxf3& box, double margin_factor)
 | 
			
		||||
{
 | 
			
		||||
    m_camera.zoom_to_box(box, margin_factor);
 | 
			
		||||
    m_dirty = true;
 | 
			
		||||
}
 | 
			
		||||
#else
 | 
			
		||||
void GLCanvas3D::_zoom_to_box(const BoundingBoxf3& box)
 | 
			
		||||
{
 | 
			
		||||
    const Size& cnv_size = get_canvas_size();
 | 
			
		||||
    m_camera.zoom_to_box(box, cnv_size.get_width(), cnv_size.get_height());
 | 
			
		||||
    m_dirty = true;
 | 
			
		||||
}
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
 | 
			
		||||
void GLCanvas3D::_update_camera_zoom(double zoom)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -5115,9 +5098,6 @@ void GLCanvas3D::_render_objects() const
 | 
			
		|||
    if (m_volumes.empty())
 | 
			
		||||
        return;
 | 
			
		||||
 | 
			
		||||
#if !ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
    glsafe(::glEnable(GL_LIGHTING));
 | 
			
		||||
#endif // !ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
    glsafe(::glEnable(GL_DEPTH_TEST));
 | 
			
		||||
 | 
			
		||||
    m_camera_clipping_plane = m_gizmos.get_sla_clipping_plane();
 | 
			
		||||
| 
						 | 
				
			
			@ -5161,9 +5141,6 @@ void GLCanvas3D::_render_objects() const
 | 
			
		|||
    m_shader.stop_using();
 | 
			
		||||
 | 
			
		||||
    m_camera_clipping_plane = ClippingPlane::ClipsNothing();
 | 
			
		||||
#if !ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
    glsafe(::glDisable(GL_LIGHTING));
 | 
			
		||||
#endif // !ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void GLCanvas3D::_render_selection() const
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -38,9 +38,7 @@ class Bed3D;
 | 
			
		|||
struct Camera;
 | 
			
		||||
class BackgroundSlicingProcess;
 | 
			
		||||
class GCodePreviewData;
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
struct ThumbnailData;
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
struct SlicingParameters;
 | 
			
		||||
enum LayerHeightEditActionType : unsigned int;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -113,9 +111,7 @@ wxDECLARE_EVENT(EVT_GLCANVAS_RELOAD_FROM_DISK, SimpleEvent);
 | 
			
		|||
 | 
			
		||||
class GLCanvas3D
 | 
			
		||||
{
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
    static const double DefaultCameraZoomToBoxMarginFactor;
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    struct GCodePreviewVolumeIndex
 | 
			
		||||
| 
						 | 
				
			
			@ -577,11 +573,9 @@ public:
 | 
			
		|||
    bool is_dragging() const { return m_gizmos.is_dragging() || m_moving; }
 | 
			
		||||
 | 
			
		||||
    void render();
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
    // printable_only == false -> render also non printable volumes as grayed
 | 
			
		||||
    // parts_only == false -> render also sla support and pad
 | 
			
		||||
    void render_thumbnail(ThumbnailData& thumbnail_data, unsigned int w, unsigned int h, bool printable_only, bool parts_only, bool show_bed, bool transparent_background) const;
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
 | 
			
		||||
    void select_all();
 | 
			
		||||
    void deselect_all();
 | 
			
		||||
| 
						 | 
				
			
			@ -702,11 +696,7 @@ private:
 | 
			
		|||
 | 
			
		||||
    BoundingBoxf3 _max_bounding_box(bool include_gizmos, bool include_bed_model) const;
 | 
			
		||||
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
    void _zoom_to_box(const BoundingBoxf3& box, double margin_factor = DefaultCameraZoomToBoxMarginFactor);
 | 
			
		||||
#else
 | 
			
		||||
    void _zoom_to_box(const BoundingBoxf3& box);
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
    void _update_camera_zoom(double zoom);
 | 
			
		||||
 | 
			
		||||
    void _refresh_if_shown_on_screen();
 | 
			
		||||
| 
						 | 
				
			
			@ -735,7 +725,6 @@ private:
 | 
			
		|||
    void _render_sla_slices() const;
 | 
			
		||||
    void _render_selection_sidebar_hints() const;
 | 
			
		||||
    bool _render_undo_redo_stack(const bool is_undo, float pos_x) const;
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
    void _render_thumbnail_internal(ThumbnailData& thumbnail_data, bool printable_only, bool parts_only, bool show_bed, bool transparent_background) const;
 | 
			
		||||
    // render thumbnail using an off-screen framebuffer
 | 
			
		||||
    void _render_thumbnail_framebuffer(ThumbnailData& thumbnail_data, unsigned int w, unsigned int h, bool printable_only, bool parts_only, bool show_bed, bool transparent_background) const;
 | 
			
		||||
| 
						 | 
				
			
			@ -743,7 +732,6 @@ private:
 | 
			
		|||
    void _render_thumbnail_framebuffer_ext(ThumbnailData& thumbnail_data, unsigned int w, unsigned int h, bool printable_only, bool parts_only, bool show_bed, bool transparent_background) const;
 | 
			
		||||
    // render thumbnail using the default framebuffer
 | 
			
		||||
    void _render_thumbnail_legacy(ThumbnailData& thumbnail_data, unsigned int w, unsigned int h, bool printable_only, bool parts_only, bool show_bed, bool transparent_background) const;
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
 | 
			
		||||
    void _update_volumes_hover_state() const;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -33,9 +33,7 @@
 | 
			
		|||
#include "libslic3r/Format/AMF.hpp"
 | 
			
		||||
#include "libslic3r/Format/3mf.hpp"
 | 
			
		||||
#include "libslic3r/GCode/PreviewData.hpp"
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
#include "libslic3r/GCode/ThumbnailData.hpp"
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
#include "libslic3r/Model.hpp"
 | 
			
		||||
#include "libslic3r/SLA/Hollowing.hpp"
 | 
			
		||||
#include "libslic3r/SLA/Rotfinder.hpp"
 | 
			
		||||
| 
						 | 
				
			
			@ -92,9 +90,7 @@ using Slic3r::_3DScene;
 | 
			
		|||
using Slic3r::Preset;
 | 
			
		||||
using Slic3r::PrintHostJob;
 | 
			
		||||
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
static const std::pair<unsigned int, unsigned int> THUMBNAIL_SIZE_3MF = { 256, 256 };
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
 | 
			
		||||
namespace Slic3r {
 | 
			
		||||
namespace GUI {
 | 
			
		||||
| 
						 | 
				
			
			@ -1955,10 +1951,8 @@ struct Plater::priv
 | 
			
		|||
    bool can_mirror() const;
 | 
			
		||||
    bool can_reload_from_disk() const;
 | 
			
		||||
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
    void generate_thumbnail(ThumbnailData& data, unsigned int w, unsigned int h, bool printable_only, bool parts_only, bool show_bed, bool transparent_background);
 | 
			
		||||
    void generate_thumbnails(ThumbnailsList& thumbnails, const Vec2ds& sizes, bool printable_only, bool parts_only, bool show_bed, bool transparent_background);
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
 | 
			
		||||
    void msw_rescale_object_menu();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -2032,7 +2026,6 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
 | 
			
		|||
    background_process.set_fff_print(&fff_print);
 | 
			
		||||
    background_process.set_sla_print(&sla_print);
 | 
			
		||||
    background_process.set_gcode_preview_data(&gcode_preview_data);
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
    background_process.set_thumbnail_cb([this](ThumbnailsList& thumbnails, const Vec2ds& sizes, bool printable_only, bool parts_only, bool show_bed, bool transparent_background)
 | 
			
		||||
        {
 | 
			
		||||
            std::packaged_task<void(ThumbnailsList&, const Vec2ds&, bool, bool, bool, bool)> task([this](ThumbnailsList& thumbnails, const Vec2ds& sizes, bool printable_only, bool parts_only, bool show_bed, bool transparent_background) {
 | 
			
		||||
| 
						 | 
				
			
			@ -2042,7 +2035,6 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
 | 
			
		|||
            wxTheApp->CallAfter([&]() { task(thumbnails, sizes, printable_only, parts_only, show_bed, transparent_background); });
 | 
			
		||||
            result.wait();
 | 
			
		||||
        });
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
    background_process.set_slicing_completed_event(EVT_SLICING_COMPLETED);
 | 
			
		||||
    background_process.set_finished_event(EVT_PROCESS_COMPLETED);
 | 
			
		||||
    // Default printer technology for default config.
 | 
			
		||||
| 
						 | 
				
			
			@ -3852,7 +3844,6 @@ bool Plater::priv::init_object_menu()
 | 
			
		|||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
void Plater::priv::generate_thumbnail(ThumbnailData& data, unsigned int w, unsigned int h, bool printable_only, bool parts_only, bool show_bed, bool transparent_background)
 | 
			
		||||
{
 | 
			
		||||
    view3D->get_canvas3d()->render_thumbnail(data, w, h, printable_only, parts_only, show_bed, transparent_background);
 | 
			
		||||
| 
						 | 
				
			
			@ -3870,7 +3861,6 @@ void Plater::priv::generate_thumbnails(ThumbnailsList& thumbnails, const Vec2ds&
 | 
			
		|||
            thumbnails.pop_back();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
 | 
			
		||||
void Plater::priv::msw_rescale_object_menu()
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -4999,13 +4989,9 @@ void Plater::export_3mf(const boost::filesystem::path& output_path)
 | 
			
		|||
    const std::string path_u8 = into_u8(path);
 | 
			
		||||
    wxBusyCursor wait;
 | 
			
		||||
    bool full_pathnames = wxGetApp().app_config->get("export_sources_full_pathnames") == "1";
 | 
			
		||||
#if ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
    ThumbnailData thumbnail_data;
 | 
			
		||||
    p->generate_thumbnail(thumbnail_data, THUMBNAIL_SIZE_3MF.first, THUMBNAIL_SIZE_3MF.second, false, true, true, true);
 | 
			
		||||
    if (Slic3r::store_3mf(path_u8.c_str(), &p->model, export_config ? &cfg : nullptr, full_pathnames, &thumbnail_data)) {
 | 
			
		||||
#else
 | 
			
		||||
    if (Slic3r::store_3mf(path_u8.c_str(), &p->model, export_config ? &cfg : nullptr, full_pathnames)) {
 | 
			
		||||
#endif // ENABLE_THUMBNAIL_GENERATOR
 | 
			
		||||
        // Success
 | 
			
		||||
        p->statusbar()->set_status_text(from_u8((boost::format(_utf8(L("3MF file exported to %s"))) % path).str()));
 | 
			
		||||
        p->set_project_filename(path);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue