Centralize legacy document image exports

This commit is contained in:
2026-06-04 13:57:32 +02:00
parent ab6223c256
commit 78003923ca
9 changed files with 530 additions and 53 deletions

View File

@@ -0,0 +1,152 @@
#include "pch.h"
#include "legacy_document_export_services.h"
#include "app.h"
namespace pp::panopainter {
namespace {
class LegacyDocumentExportServices final : public pp::app::DocumentExportServices {
public:
explicit LegacyDocumentExportServices(App& app) noexcept
: app_(app)
{
}
bool create_directory(std::string_view directory) override
{
return Asset::create_dir(std::string(directory));
}
void export_equirectangular(const pp::app::DocumentExportFileTarget& target) override
{
auto* app = &app_;
app_.canvas->m_canvas->export_equirectangular(target.path, [app, target] {
#if defined(__IOS__)
app->message_box("Export Equirectangular", "Image exported to Photos");
#elif defined(__OSX__)
app->message_box("Export Equirectangular", "Image exported to Pictures/PanoPainter folder");
#elif defined(_WIN32)
app->message_box("Export Equirectangular", "Image exported to " + app->work_path);
#elif defined(__QUEST__)
(void)target;
#elif __WEB__
app->ui_task([app, target] {
app->save_prepared_file(target.path, target.suggested_name, [](const std::string&, bool) { });
});
#else
(void)target;
#endif
});
}
void export_layers_to_stem(const pp::app::DocumentExportStemTarget& target) override
{
auto* app = &app_;
app_.canvas->m_canvas->export_layers(target.stem_path, [app, target] {
app->message_box("Export Layers", "Layers exported to: " + target.stem_path);
});
}
void export_layers_to_collection(const pp::app::DocumentExportCollectionTarget& target) override
{
auto* app = &app_;
app_.canvas->m_canvas->export_layers(target.stem_path, [app] {
app->message_box("Export Layers", "Image layers exported to Files/PanoPainter");
});
}
void export_animation_frames_to_stem(const pp::app::DocumentExportStemTarget& target) override
{
auto* app = &app_;
app_.canvas->m_canvas->export_anim_frames(target.stem_path, [app, target] {
app->message_box("Export Layers", "Layers exported to: " + target.stem_path);
});
}
void export_animation_frames_to_collection(const pp::app::DocumentExportCollectionTarget& target) override
{
auto* app = &app_;
app_.canvas->m_canvas->export_anim_frames(target.stem_path, [app] {
app->message_box("Export Layers", "Image layers exported to Files/PanoPainter");
});
}
void export_depth(std::string_view document_name) override
{
auto* app = &app_;
app_.canvas->m_canvas->export_depth(std::string(document_name), [app] {
#if defined(__IOS__)
app->message_box("Export 3D View + Depth", "Image and depth exported to Files/PanoPainter");
#elif defined(__OSX__)
app->message_box("Export 3D View + Depth", "Image and depth exported to Pictures/PanoPainter folder");
#elif defined(_WIN32)
app->message_box("Export 3D View + Depth", "Image and depth exported to " + app->work_path);
#endif
});
}
void export_cube_faces(std::string_view document_name) override
{
auto* app = &app_;
app_.canvas->m_canvas->export_cube_faces(std::string(document_name), [app] {
#if defined(__IOS__)
app->message_box("Export Cube Faces", "Image and depth exported to Files/PanoPainter");
#elif defined(__OSX__)
app->message_box("Export Cube Faces", "Image and depth exported to Pictures/PanoPainter folder");
#elif defined(_WIN32)
app->message_box("Export Cube Faces", "Image and depth exported to " + app->work_path);
#endif
});
}
private:
App& app_;
};
} // namespace
pp::foundation::Status execute_legacy_document_export_file(
App& app,
const pp::app::DocumentExportFileTarget& target)
{
LegacyDocumentExportServices services(app);
return pp::app::execute_document_export_file(target, services);
}
pp::foundation::Status execute_legacy_document_export_stem(
App& app,
pp::app::DocumentExportCollectionKind kind,
const pp::app::DocumentExportStemTarget& target)
{
LegacyDocumentExportServices services(app);
return pp::app::execute_document_export_stem(kind, target, services);
}
pp::foundation::Status execute_legacy_document_export_collection(
App& app,
pp::app::DocumentExportCollectionKind kind,
const pp::app::DocumentExportCollectionTarget& target)
{
LegacyDocumentExportServices services(app);
return pp::app::execute_document_export_collection(kind, target, services);
}
pp::foundation::Status execute_legacy_document_export_depth(
App& app,
std::string_view document_name)
{
LegacyDocumentExportServices services(app);
return pp::app::execute_document_export_depth(document_name, services);
}
pp::foundation::Status execute_legacy_document_export_cube_faces(
App& app,
std::string_view document_name)
{
LegacyDocumentExportServices services(app);
return pp::app::execute_document_export_cube_faces(document_name, services);
}
} // namespace pp::panopainter