Merge branch 'tm_sla_wildcards_SPE-1625'
This commit is contained in:
commit
169024fefa
@ -11,20 +11,17 @@
|
|||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
static std::mutex arch_mtx;
|
|
||||||
|
|
||||||
class Registry {
|
class Registry {
|
||||||
static std::unique_ptr<Registry> registry;
|
static std::unique_ptr<Registry> registry;
|
||||||
|
|
||||||
std::set<ArchiveEntry> entries;
|
std::set<ArchiveEntry> entries;
|
||||||
public:
|
|
||||||
|
|
||||||
Registry ()
|
Registry ()
|
||||||
{
|
{
|
||||||
entries = {
|
entries = {
|
||||||
{
|
{
|
||||||
"SL1", // id
|
"SL1", // id
|
||||||
L("SL1 archive format"), // description
|
L("SL1 archive"), // description
|
||||||
"sl1", // main extension
|
"sl1", // main extension
|
||||||
{"sl1s", "zip"}, // extension aliases
|
{"sl1s", "zip"}, // extension aliases
|
||||||
|
|
||||||
@ -38,22 +35,14 @@ public:
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"SL1SVG",
|
"SL1SVG",
|
||||||
L("SL1SVG archive files"),
|
L("SL1 SVG archive"),
|
||||||
"sl1_svg",
|
"sl1_svg",
|
||||||
{},
|
{"zip"},
|
||||||
[] (const auto &cfg) { return std::make_unique<SL1_SVGArchive>(cfg); },
|
[] (const auto &cfg) { return std::make_unique<SL1_SVGArchive>(cfg); },
|
||||||
[] (const std::string &fname, SLAImportQuality quality, const ProgrFn &progr) {
|
[] (const std::string &fname, SLAImportQuality quality, const ProgrFn &progr) {
|
||||||
return std::make_unique<SL1_SVGReader>(fname, quality, progr);
|
return std::make_unique<SL1_SVGReader>(fname, quality, progr);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"SL2",
|
|
||||||
"",
|
|
||||||
"sl1_svg",
|
|
||||||
{},
|
|
||||||
[] (const auto &cfg) { return std::make_unique<SL1_SVGArchive>(cfg); },
|
|
||||||
nullptr
|
|
||||||
},
|
|
||||||
anycubic_sla_format("pwmo", "Photon Mono"),
|
anycubic_sla_format("pwmo", "Photon Mono"),
|
||||||
anycubic_sla_format("pwmx", "Photon Mono X"),
|
anycubic_sla_format("pwmx", "Photon Mono X"),
|
||||||
anycubic_sla_format("pwms", "Photon Mono SE"),
|
anycubic_sla_format("pwms", "Photon Mono SE"),
|
||||||
@ -85,28 +74,26 @@ public:
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static Registry& get_instance()
|
public:
|
||||||
|
|
||||||
|
static const Registry& get_instance()
|
||||||
{
|
{
|
||||||
if (!registry)
|
if (!registry)
|
||||||
registry = std::make_unique<Registry>();
|
registry.reset(new Registry());
|
||||||
|
|
||||||
return *registry;
|
return *registry;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::set<ArchiveEntry>& get()
|
static const std::set<ArchiveEntry>& get()
|
||||||
{
|
{
|
||||||
return get_instance().entries;
|
return get_instance().entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<ArchiveEntry>& get_entries() { return entries; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<Registry> Registry::registry = nullptr;
|
std::unique_ptr<Registry> Registry::registry = nullptr;
|
||||||
|
|
||||||
std::set<ArchiveEntry> registered_sla_archives()
|
const std::set<ArchiveEntry>& registered_sla_archives()
|
||||||
{
|
{
|
||||||
std::lock_guard lk{arch_mtx};
|
|
||||||
|
|
||||||
return Registry::get();
|
return Registry::get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,8 +110,6 @@ std::vector<std::string> get_extensions(const ArchiveEntry &entry)
|
|||||||
|
|
||||||
ArchiveWriterFactory get_writer_factory(const char *formatid)
|
ArchiveWriterFactory get_writer_factory(const char *formatid)
|
||||||
{
|
{
|
||||||
std::lock_guard lk{arch_mtx};
|
|
||||||
|
|
||||||
ArchiveWriterFactory ret;
|
ArchiveWriterFactory ret;
|
||||||
auto entry = Registry::get().find(ArchiveEntry{formatid});
|
auto entry = Registry::get().find(ArchiveEntry{formatid});
|
||||||
if (entry != Registry::get().end())
|
if (entry != Registry::get().end())
|
||||||
@ -135,7 +120,6 @@ ArchiveWriterFactory get_writer_factory(const char *formatid)
|
|||||||
|
|
||||||
ArchiveReaderFactory get_reader_factory(const char *formatid)
|
ArchiveReaderFactory get_reader_factory(const char *formatid)
|
||||||
{
|
{
|
||||||
std::lock_guard lk{arch_mtx};
|
|
||||||
|
|
||||||
ArchiveReaderFactory ret;
|
ArchiveReaderFactory ret;
|
||||||
auto entry = Registry::get().find(ArchiveEntry{formatid});
|
auto entry = Registry::get().find(ArchiveEntry{formatid});
|
||||||
@ -145,4 +129,28 @@ ArchiveReaderFactory get_reader_factory(const char *formatid)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *get_default_extension(const char *formatid)
|
||||||
|
{
|
||||||
|
static constexpr const char *Empty = "";
|
||||||
|
|
||||||
|
const char * ret = Empty;
|
||||||
|
|
||||||
|
auto entry = Registry::get().find(ArchiveEntry{formatid});
|
||||||
|
if (entry != Registry::get().end())
|
||||||
|
ret = entry->ext;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ArchiveEntry * get_archive_entry(const char *formatid)
|
||||||
|
{
|
||||||
|
const ArchiveEntry *ret = nullptr;
|
||||||
|
|
||||||
|
auto entry = Registry::get().find(ArchiveEntry{formatid});
|
||||||
|
if (entry != Registry::get().end())
|
||||||
|
ret = &(*entry);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Slic3r::sla
|
} // namespace Slic3r::sla
|
||||||
|
@ -48,9 +48,9 @@ struct ArchiveEntry {
|
|||||||
: id{formatid}
|
: id{formatid}
|
||||||
, desc{description}
|
, desc{description}
|
||||||
, ext{extension}
|
, ext{extension}
|
||||||
, ext_aliases{extaliases}
|
|
||||||
, wrfactoryfn{wrfn}
|
, wrfactoryfn{wrfn}
|
||||||
, rdfactoryfn{rdfn}
|
, rdfactoryfn{rdfn}
|
||||||
|
, ext_aliases{extaliases}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool operator <(const ArchiveEntry &other) const
|
bool operator <(const ArchiveEntry &other) const
|
||||||
@ -61,8 +61,10 @@ struct ArchiveEntry {
|
|||||||
|
|
||||||
std::vector<std::string> get_extensions(const ArchiveEntry &entry);
|
std::vector<std::string> get_extensions(const ArchiveEntry &entry);
|
||||||
|
|
||||||
std::set<ArchiveEntry> registered_sla_archives();
|
const std::set<ArchiveEntry>& registered_sla_archives();
|
||||||
|
|
||||||
|
const ArchiveEntry * get_archive_entry(const char *formatid);
|
||||||
|
const char * get_default_extension(const char *formatid);
|
||||||
ArchiveWriterFactory get_writer_factory(const char *formatid);
|
ArchiveWriterFactory get_writer_factory(const char *formatid);
|
||||||
ArchiveReaderFactory get_reader_factory(const char *formatid);
|
ArchiveReaderFactory get_reader_factory(const char *formatid);
|
||||||
|
|
||||||
|
@ -1541,6 +1541,7 @@ std::string Print::output_filename(const std::string &filename_base) const
|
|||||||
// These values will be just propagated into the output file name.
|
// These values will be just propagated into the output file name.
|
||||||
DynamicConfig config = this->finished() ? this->print_statistics().config() : this->print_statistics().placeholders();
|
DynamicConfig config = this->finished() ? this->print_statistics().config() : this->print_statistics().placeholders();
|
||||||
config.set_key_value("num_extruders", new ConfigOptionInt((int)m_config.nozzle_diameter.size()));
|
config.set_key_value("num_extruders", new ConfigOptionInt((int)m_config.nozzle_diameter.size()));
|
||||||
|
config.set_key_value("default_output_extension", new ConfigOptionString(".gcode"));
|
||||||
return this->PrintBase::output_filename(m_config.output_filename_format.value, ".gcode", filename_base, &config);
|
return this->PrintBase::output_filename(m_config.output_filename_format.value, ".gcode", filename_base, &config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1983,7 +1983,7 @@ void PrintConfigDef::init_fff_params()
|
|||||||
def->tooltip = L("You can use all configuration options as variables inside this template. "
|
def->tooltip = L("You can use all configuration options as variables inside this template. "
|
||||||
"For example: [layer_height], [fill_density] etc. You can also use [timestamp], "
|
"For example: [layer_height], [fill_density] etc. You can also use [timestamp], "
|
||||||
"[year], [month], [day], [hour], [minute], [second], [version], [input_filename], "
|
"[year], [month], [day], [hour], [minute], [second], [version], [input_filename], "
|
||||||
"[input_filename_base].");
|
"[input_filename_base], [default_output_extension].");
|
||||||
def->full_width = true;
|
def->full_width = true;
|
||||||
def->mode = comExpert;
|
def->mode = comExpert;
|
||||||
def->set_default_value(new ConfigOptionString("[input_filename_base].gcode"));
|
def->set_default_value(new ConfigOptionString("[input_filename_base].gcode"));
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
#include "CSGMesh/PerformCSGMeshBooleans.hpp"
|
#include "CSGMesh/PerformCSGMeshBooleans.hpp"
|
||||||
#include "format.hpp"
|
#include "format.hpp"
|
||||||
|
|
||||||
|
#include "Format/SLAArchiveFormatRegistry.hpp"
|
||||||
|
|
||||||
#include "Geometry.hpp"
|
#include "Geometry.hpp"
|
||||||
#include "Thread.hpp"
|
#include "Thread.hpp"
|
||||||
|
|
||||||
@ -522,6 +524,7 @@ SLAPrint::ApplyStatus SLAPrint::apply(const Model &model, DynamicPrintConfig con
|
|||||||
#endif /* _DEBUG */
|
#endif /* _DEBUG */
|
||||||
|
|
||||||
m_full_print_config = std::move(config);
|
m_full_print_config = std::move(config);
|
||||||
|
|
||||||
return static_cast<ApplyStatus>(apply_status);
|
return static_cast<ApplyStatus>(apply_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -531,7 +534,16 @@ SLAPrint::ApplyStatus SLAPrint::apply(const Model &model, DynamicPrintConfig con
|
|||||||
std::string SLAPrint::output_filename(const std::string &filename_base) const
|
std::string SLAPrint::output_filename(const std::string &filename_base) const
|
||||||
{
|
{
|
||||||
DynamicConfig config = this->finished() ? this->print_statistics().config() : this->print_statistics().placeholders();
|
DynamicConfig config = this->finished() ? this->print_statistics().config() : this->print_statistics().placeholders();
|
||||||
return this->PrintBase::output_filename(m_print_config.output_filename_format.value, ".sl1", filename_base, &config);
|
std::string default_ext = get_default_extension(m_printer_config.sla_archive_format.value.c_str());
|
||||||
|
if (default_ext.empty())
|
||||||
|
default_ext = "sl1";
|
||||||
|
|
||||||
|
default_ext.insert(default_ext.begin(), '.');
|
||||||
|
|
||||||
|
config.set_key_value("default_output_extension",
|
||||||
|
new ConfigOptionString(default_ext));
|
||||||
|
|
||||||
|
return this->PrintBase::output_filename(m_print_config.output_filename_format.value, default_ext, filename_base, &config);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SLAPrint::validate(std::vector<std::string>*) const
|
std::string SLAPrint::validate(std::vector<std::string>*) const
|
||||||
|
@ -54,6 +54,7 @@
|
|||||||
#include "libslic3r/Model.hpp"
|
#include "libslic3r/Model.hpp"
|
||||||
#include "libslic3r/PresetBundle.hpp"
|
#include "libslic3r/PresetBundle.hpp"
|
||||||
#include "libslic3r/Color.hpp"
|
#include "libslic3r/Color.hpp"
|
||||||
|
#include "libslic3r/Format/SLAArchiveFormatRegistry.hpp"
|
||||||
|
|
||||||
#include "GUI.hpp"
|
#include "GUI.hpp"
|
||||||
#include "GUI_Utils.hpp"
|
#include "GUI_Utils.hpp"
|
||||||
@ -490,15 +491,13 @@ static const FileWildcards file_wildcards_by_type[FT_SIZE] = {
|
|||||||
|
|
||||||
/* FT_TEX */ { "Texture"sv, { ".png"sv, ".svg"sv } },
|
/* FT_TEX */ { "Texture"sv, { ".png"sv, ".svg"sv } },
|
||||||
|
|
||||||
/* FT_SL1 */ { "Masked SLA files"sv, { ".sl1"sv, ".sl1s"sv, ".pwmx"sv } },
|
/* FT_SL1 (deprecated, overriden by sla_wildcards) */ { "Masked SLA files"sv, { ".sl1"sv, ".sl1s"sv, ".pwmx"sv } },
|
||||||
|
|
||||||
/* FT_ZIP */ { "Zip files"sv, { ".zip"sv } },
|
/* FT_ZIP */ { "Zip files"sv, { ".zip"sv } },
|
||||||
};
|
};
|
||||||
|
|
||||||
#if ENABLE_ALTERNATIVE_FILE_WILDCARDS_GENERATOR
|
static wxString file_wildcards(const FileWildcards& data)
|
||||||
wxString file_wildcards(FileType file_type)
|
|
||||||
{
|
{
|
||||||
const FileWildcards& data = file_wildcards_by_type[file_type];
|
|
||||||
std::string title;
|
std::string title;
|
||||||
std::string mask;
|
std::string mask;
|
||||||
|
|
||||||
@ -532,6 +531,14 @@ wxString file_wildcards(FileType file_type)
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_ALTERNATIVE_FILE_WILDCARDS_GENERATOR
|
||||||
|
wxString file_wildcards(FileType file_type)
|
||||||
|
{
|
||||||
|
const FileWildcards& data = file_wildcards_by_type[file_type];
|
||||||
|
|
||||||
|
return file_wildcards(data);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
// This function produces a Win32 file dialog file template mask to be consumed by wxWidgets on all platforms.
|
// This function produces a Win32 file dialog file template mask to be consumed by wxWidgets on all platforms.
|
||||||
// The function accepts a custom extension parameter. If the parameter is provided, the custom extension
|
// The function accepts a custom extension parameter. If the parameter is provided, the custom extension
|
||||||
@ -590,6 +597,34 @@ wxString file_wildcards(FileType file_type, const std::string &custom_extension)
|
|||||||
}
|
}
|
||||||
#endif // ENABLE_ALTERNATIVE_FILE_WILDCARDS_GENERATOR
|
#endif // ENABLE_ALTERNATIVE_FILE_WILDCARDS_GENERATOR
|
||||||
|
|
||||||
|
wxString sla_wildcards(const char *formatid)
|
||||||
|
{
|
||||||
|
const ArchiveEntry *entry = get_archive_entry(formatid);
|
||||||
|
wxString ret;
|
||||||
|
|
||||||
|
if (entry) {
|
||||||
|
FileWildcards wc;
|
||||||
|
std::string tr_title = I18N::translate_utf8(entry->desc);
|
||||||
|
tr_title = GUI::format(_u8L("%s files"), tr_title);
|
||||||
|
wc.title = tr_title;
|
||||||
|
|
||||||
|
std::vector<std::string> exts = get_extensions(*entry);
|
||||||
|
|
||||||
|
wc.file_extensions.reserve(exts.size());
|
||||||
|
for (std::string &ext : exts) {
|
||||||
|
ext.insert(ext.begin(), '.');
|
||||||
|
wc.file_extensions.emplace_back(ext);
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = file_wildcards(wc);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret.empty())
|
||||||
|
ret = file_wildcards(FT_SL1);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static std::string libslic3r_translate_callback(const char *s) { return wxGetTranslation(wxString(s, wxConvUTF8)).utf8_str().data(); }
|
static std::string libslic3r_translate_callback(const char *s) { return wxGetTranslation(wxString(s, wxConvUTF8)).utf8_str().data(); }
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
@ -84,6 +84,8 @@ extern wxString file_wildcards(FileType file_type);
|
|||||||
extern wxString file_wildcards(FileType file_type, const std::string &custom_extension = std::string{});
|
extern wxString file_wildcards(FileType file_type, const std::string &custom_extension = std::string{});
|
||||||
#endif // ENABLE_ALTERNATIVE_FILE_WILDCARDS_GENERATOR
|
#endif // ENABLE_ALTERNATIVE_FILE_WILDCARDS_GENERATOR
|
||||||
|
|
||||||
|
wxString sla_wildcards(const char *formatid);
|
||||||
|
|
||||||
enum ConfigMenuIDs {
|
enum ConfigMenuIDs {
|
||||||
ConfigMenuWizard,
|
ConfigMenuWizard,
|
||||||
ConfigMenuSnapshots,
|
ConfigMenuSnapshots,
|
||||||
|
@ -6377,9 +6377,11 @@ void Plater::export_gcode(bool prefer_removable)
|
|||||||
start_dir,
|
start_dir,
|
||||||
from_path(default_output_file.filename()),
|
from_path(default_output_file.filename()),
|
||||||
#if ENABLE_ALTERNATIVE_FILE_WILDCARDS_GENERATOR
|
#if ENABLE_ALTERNATIVE_FILE_WILDCARDS_GENERATOR
|
||||||
GUI::file_wildcards((printer_technology() == ptFFF) ? FT_GCODE : FT_SL1),
|
printer_technology() == ptFFF ? GUI::file_wildcards(FT_GCODE) :
|
||||||
|
GUI::sla_wildcards(p->sla_print.printer_config().sla_archive_format.value.c_str()),
|
||||||
#else
|
#else
|
||||||
GUI::file_wildcards((printer_technology() == ptFFF) ? FT_GCODE : FT_SL1, ext),
|
printer_technology() == ptFFF ? GUI::file_wildcards(FT_GCODE, ext) :
|
||||||
|
GUI::sla_wildcards(p->sla_print.printer_config().sla_archive_format.value.c_str()),
|
||||||
#endif // ENABLE_ALTERNATIVE_FILE_WILDCARDS_GENERATOR
|
#endif // ENABLE_ALTERNATIVE_FILE_WILDCARDS_GENERATOR
|
||||||
wxFD_SAVE | wxFD_OVERWRITE_PROMPT
|
wxFD_SAVE | wxFD_OVERWRITE_PROMPT
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user