Plan export start decisions in app core
This commit is contained in:
@@ -28,6 +28,30 @@ void webgl_pick_file_save(const std::string& path,
|
||||
void webgl_sync();
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
[[nodiscard]] bool can_start_document_export(App& app, bool requires_license)
|
||||
{
|
||||
const auto decision = pp::app::plan_document_export_start(
|
||||
requires_license,
|
||||
!requires_license || app.check_license(),
|
||||
app.canvas != nullptr);
|
||||
|
||||
switch (decision) {
|
||||
case pp::app::DocumentExportStartDecision::start_now:
|
||||
return true;
|
||||
case pp::app::DocumentExportStartDecision::show_license_disabled:
|
||||
app.message_box("License", "This function is disabled in demo mode.");
|
||||
return false;
|
||||
case pp::app::DocumentExportStartDecision::unavailable_no_canvas:
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::shared_ptr<NodeProgressBar> App::show_progress(const std::string& title, int total /*= 0*/)
|
||||
{
|
||||
auto pb = std::make_shared<NodeProgressBar>();
|
||||
@@ -414,138 +438,114 @@ void App::dialog_save()
|
||||
|
||||
void App::dialog_export(std::string ext)
|
||||
{
|
||||
if (!check_license())
|
||||
{
|
||||
message_box("License", "This function is disabled in demo mode.");
|
||||
if (!can_start_document_export(*this, true))
|
||||
return;
|
||||
|
||||
// TODO: use picker
|
||||
const auto target = pp::app::make_document_export_file_target(work_path, doc_name, ext);
|
||||
if (!target) {
|
||||
message_box("Export Equirectangular", target.status().message);
|
||||
return;
|
||||
}
|
||||
|
||||
if (canvas)
|
||||
{
|
||||
// TODO: use picker
|
||||
const auto target = pp::app::make_document_export_file_target(work_path, doc_name, ext);
|
||||
if (!target) {
|
||||
message_box("Export Equirectangular", target.status().message);
|
||||
return;
|
||||
}
|
||||
|
||||
canvas->m_canvas->export_equirectangular(target.value().path, [this, target = target.value()]{
|
||||
canvas->m_canvas->export_equirectangular(target.value().path, [this, target = target.value()]{
|
||||
#if defined(__IOS__)
|
||||
message_box("Export Equirectangular", "Image exported to Photos");
|
||||
message_box("Export Equirectangular", "Image exported to Photos");
|
||||
#elif defined(__OSX__)
|
||||
message_box("Export Equirectangular", "Image exported to Pictures/PanoPainter folder");
|
||||
message_box("Export Equirectangular", "Image exported to Pictures/PanoPainter folder");
|
||||
#elif defined(_WIN32)
|
||||
message_box("Export Equirectangular", "Image exported to " + work_path);
|
||||
message_box("Export Equirectangular", "Image exported to " + work_path);
|
||||
#elif defined(__QUEST__)
|
||||
//auto result = ovr_Media_ShareToFacebook("Sharing from PanoPainter on Oculus Quest", path.c_str(), ovrMediaContentType_Photo);
|
||||
//auto result = ovr_Media_ShareToFacebook("Sharing from PanoPainter on Oculus Quest", path.c_str(), ovrMediaContentType_Photo);
|
||||
#elif __WEB__
|
||||
ui_task([=]{
|
||||
webgl_pick_file_save(target.path, target.suggested_name, [](bool success){ });
|
||||
});
|
||||
#endif
|
||||
ui_task([=]{
|
||||
webgl_pick_file_save(target.path, target.suggested_name, [](bool success){ });
|
||||
});
|
||||
}
|
||||
#endif
|
||||
});
|
||||
}
|
||||
|
||||
void App::dialog_export_layers()
|
||||
{
|
||||
if (!check_license())
|
||||
{
|
||||
message_box("License", "This function is disabled in demo mode.");
|
||||
if (!can_start_document_export(*this, true))
|
||||
return;
|
||||
|
||||
#if defined(__IOS__)
|
||||
const auto target = pp::app::make_document_export_collection_target(work_path, doc_name, "_layers");
|
||||
if (!target) {
|
||||
message_box("Export Layers", target.status().message);
|
||||
return;
|
||||
}
|
||||
|
||||
if (canvas)
|
||||
if (Asset::create_dir(target.value().directory))
|
||||
{
|
||||
#if defined(__IOS__)
|
||||
const auto target = pp::app::make_document_export_collection_target(work_path, doc_name, "_layers");
|
||||
canvas->m_canvas->export_layers(target.value().stem_path, [this] {
|
||||
message_box("Export Layers", "Image layers exported to Files/PanoPainter");
|
||||
});
|
||||
}
|
||||
#else
|
||||
pick_dir([this](std::string path) {
|
||||
const auto target = pp::app::make_document_export_stem_target(path, doc_name);
|
||||
if (!target) {
|
||||
message_box("Export Layers", target.status().message);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Asset::create_dir(target.value().directory))
|
||||
{
|
||||
canvas->m_canvas->export_layers(target.value().stem_path, [this] {
|
||||
message_box("Export Layers", "Image layers exported to Files/PanoPainter");
|
||||
});
|
||||
}
|
||||
#else
|
||||
pick_dir([this](std::string path) {
|
||||
const auto target = pp::app::make_document_export_stem_target(path, doc_name);
|
||||
if (!target) {
|
||||
message_box("Export Layers", target.status().message);
|
||||
return;
|
||||
}
|
||||
|
||||
canvas->m_canvas->export_layers(target.value().stem_path, [this, target = target.value()] {
|
||||
message_box("Export Layers", "Layers exported to: " + target.stem_path);
|
||||
});
|
||||
canvas->m_canvas->export_layers(target.value().stem_path, [this, target = target.value()] {
|
||||
message_box("Export Layers", "Layers exported to: " + target.stem_path);
|
||||
});
|
||||
});
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void App::dialog_export_anim_frames()
|
||||
{
|
||||
if (!check_license())
|
||||
{
|
||||
message_box("License", "This function is disabled in demo mode.");
|
||||
if (!can_start_document_export(*this, true))
|
||||
return;
|
||||
|
||||
#if defined(__IOS__)
|
||||
const auto target = pp::app::make_document_export_collection_target(work_path, doc_name, "_frames");
|
||||
if (!target) {
|
||||
message_box("Export Layers", target.status().message);
|
||||
return;
|
||||
}
|
||||
|
||||
if (canvas)
|
||||
if (Asset::create_dir(target.value().directory))
|
||||
{
|
||||
#if defined(__IOS__)
|
||||
const auto target = pp::app::make_document_export_collection_target(work_path, doc_name, "_frames");
|
||||
canvas->m_canvas->export_anim_frames(target.value().stem_path, [this] {
|
||||
message_box("Export Layers", "Image layers exported to Files/PanoPainter");
|
||||
});
|
||||
}
|
||||
#else
|
||||
pick_dir([this](std::string path) {
|
||||
const auto target = pp::app::make_document_export_stem_target(path, doc_name);
|
||||
if (!target) {
|
||||
message_box("Export Layers", target.status().message);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Asset::create_dir(target.value().directory))
|
||||
{
|
||||
canvas->m_canvas->export_anim_frames(target.value().stem_path, [this] {
|
||||
message_box("Export Layers", "Image layers exported to Files/PanoPainter");
|
||||
});
|
||||
}
|
||||
#else
|
||||
pick_dir([this](std::string path) {
|
||||
const auto target = pp::app::make_document_export_stem_target(path, doc_name);
|
||||
if (!target) {
|
||||
message_box("Export Layers", target.status().message);
|
||||
return;
|
||||
}
|
||||
|
||||
canvas->m_canvas->export_anim_frames(target.value().stem_path, [this, target = target.value()] {
|
||||
message_box("Export Layers", "Layers exported to: " + target.stem_path);
|
||||
});
|
||||
canvas->m_canvas->export_anim_frames(target.value().stem_path, [this, target = target.value()] {
|
||||
message_box("Export Layers", "Layers exported to: " + target.stem_path);
|
||||
});
|
||||
});
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void App::dialog_export_depth()
|
||||
{
|
||||
if (!check_license())
|
||||
{
|
||||
message_box("License", "This function is disabled in demo mode.");
|
||||
if (!can_start_document_export(*this, true))
|
||||
return;
|
||||
}
|
||||
|
||||
if (canvas)
|
||||
{
|
||||
// TODO: use picker
|
||||
canvas->m_canvas->export_depth(doc_name, [this] {
|
||||
// TODO: use picker
|
||||
canvas->m_canvas->export_depth(doc_name, [this] {
|
||||
#if defined(__IOS__)
|
||||
message_box("Export 3D View + Depth", "Image and depth exported to Files/PanoPainter");
|
||||
message_box("Export 3D View + Depth", "Image and depth exported to Files/PanoPainter");
|
||||
#elif defined(__OSX__)
|
||||
message_box("Export 3D View + Depth", "Image and depth exported to Pictures/PanoPainter folder");
|
||||
message_box("Export 3D View + Depth", "Image and depth exported to Pictures/PanoPainter folder");
|
||||
#elif defined(_WIN32)
|
||||
message_box("Export 3D View + Depth", "Image and depth exported to " + work_path);
|
||||
message_box("Export 3D View + Depth", "Image and depth exported to " + work_path);
|
||||
#endif
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void App::dialog_resize()
|
||||
@@ -571,18 +571,18 @@ void App::dialog_resize()
|
||||
|
||||
void App::dialog_export_cube_faces()
|
||||
{
|
||||
if (canvas)
|
||||
{
|
||||
canvas->m_canvas->export_cube_faces(doc_name, [this] {
|
||||
if (!can_start_document_export(*this, false))
|
||||
return;
|
||||
|
||||
canvas->m_canvas->export_cube_faces(doc_name, [this] {
|
||||
#if defined(__IOS__)
|
||||
message_box("Export Cube Faces", "Image and depth exported to Files/PanoPainter");
|
||||
message_box("Export Cube Faces", "Image and depth exported to Files/PanoPainter");
|
||||
#elif defined(__OSX__)
|
||||
message_box("Export Cube Faces", "Image and depth exported to Pictures/PanoPainter folder");
|
||||
message_box("Export Cube Faces", "Image and depth exported to Pictures/PanoPainter folder");
|
||||
#elif defined(_WIN32)
|
||||
message_box("Export Cube Faces", "Image and depth exported to " + work_path);
|
||||
message_box("Export Cube Faces", "Image and depth exported to " + work_path);
|
||||
#endif
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void App::dialog_layer_rename()
|
||||
|
||||
Reference in New Issue
Block a user