Plan document export snapshot routing
This commit is contained in:
@@ -191,6 +191,14 @@ struct PlanExportMenuArgs {
|
||||
bool has_canvas = true;
|
||||
};
|
||||
|
||||
struct PlanExportSnapshotRouteArgs {
|
||||
std::string kind = "equirectangular";
|
||||
std::uint32_t captured_face_payloads = 6;
|
||||
std::uint32_t pending_face_payloads = 6;
|
||||
bool target_supported = true;
|
||||
bool platform_supported = true;
|
||||
};
|
||||
|
||||
struct PlanFileMenuArgs {
|
||||
std::string command = "new";
|
||||
};
|
||||
@@ -1937,6 +1945,45 @@ const char* document_export_menu_action_name(pp::app::DocumentExportMenuAction a
|
||||
return "unavailable-no-canvas";
|
||||
}
|
||||
|
||||
const char* document_export_execution_kind_name(pp::app::DocumentExportExecutionKind kind) noexcept
|
||||
{
|
||||
switch (kind) {
|
||||
case pp::app::DocumentExportExecutionKind::equirectangular_file:
|
||||
return "equirectangular-file";
|
||||
case pp::app::DocumentExportExecutionKind::layers_collection:
|
||||
return "layers-collection";
|
||||
case pp::app::DocumentExportExecutionKind::layers_stem:
|
||||
return "layers-stem";
|
||||
case pp::app::DocumentExportExecutionKind::animation_frames_collection:
|
||||
return "animation-frames-collection";
|
||||
case pp::app::DocumentExportExecutionKind::animation_frames_stem:
|
||||
return "animation-frames-stem";
|
||||
case pp::app::DocumentExportExecutionKind::depth:
|
||||
return "depth";
|
||||
case pp::app::DocumentExportExecutionKind::cube_faces:
|
||||
return "cube-faces";
|
||||
case pp::app::DocumentExportExecutionKind::animation_mp4:
|
||||
return "animation-mp4";
|
||||
case pp::app::DocumentExportExecutionKind::timelapse:
|
||||
return "timelapse";
|
||||
}
|
||||
|
||||
return "equirectangular-file";
|
||||
}
|
||||
|
||||
const char* document_export_snapshot_route_action_name(
|
||||
pp::app::DocumentExportSnapshotRouteAction action) noexcept
|
||||
{
|
||||
switch (action) {
|
||||
case pp::app::DocumentExportSnapshotRouteAction::use_document_snapshot_writer:
|
||||
return "use-document-snapshot-writer";
|
||||
case pp::app::DocumentExportSnapshotRouteAction::use_legacy_export:
|
||||
return "use-legacy-export";
|
||||
}
|
||||
|
||||
return "use-legacy-export";
|
||||
}
|
||||
|
||||
pp::foundation::Result<pp::app::DocumentExportMenuKind> parse_document_export_menu_kind(
|
||||
std::string_view kind)
|
||||
{
|
||||
@@ -1977,6 +2024,50 @@ pp::foundation::Result<pp::app::DocumentExportMenuKind> parse_document_export_me
|
||||
pp::foundation::Status::invalid_argument("unknown export menu kind"));
|
||||
}
|
||||
|
||||
pp::foundation::Result<pp::app::DocumentExportExecutionKind> parse_document_export_execution_kind(
|
||||
std::string_view kind)
|
||||
{
|
||||
if (kind == "equirectangular" || kind == "equirect" || kind == "image" || kind == "equirectangular-file") {
|
||||
return pp::foundation::Result<pp::app::DocumentExportExecutionKind>::success(
|
||||
pp::app::DocumentExportExecutionKind::equirectangular_file);
|
||||
}
|
||||
if (kind == "layers" || kind == "layers-collection") {
|
||||
return pp::foundation::Result<pp::app::DocumentExportExecutionKind>::success(
|
||||
pp::app::DocumentExportExecutionKind::layers_collection);
|
||||
}
|
||||
if (kind == "layers-stem") {
|
||||
return pp::foundation::Result<pp::app::DocumentExportExecutionKind>::success(
|
||||
pp::app::DocumentExportExecutionKind::layers_stem);
|
||||
}
|
||||
if (kind == "animation-frames" || kind == "frames" || kind == "animation-frames-collection") {
|
||||
return pp::foundation::Result<pp::app::DocumentExportExecutionKind>::success(
|
||||
pp::app::DocumentExportExecutionKind::animation_frames_collection);
|
||||
}
|
||||
if (kind == "animation-frames-stem" || kind == "frames-stem") {
|
||||
return pp::foundation::Result<pp::app::DocumentExportExecutionKind>::success(
|
||||
pp::app::DocumentExportExecutionKind::animation_frames_stem);
|
||||
}
|
||||
if (kind == "depth") {
|
||||
return pp::foundation::Result<pp::app::DocumentExportExecutionKind>::success(
|
||||
pp::app::DocumentExportExecutionKind::depth);
|
||||
}
|
||||
if (kind == "cube-faces" || kind == "cube") {
|
||||
return pp::foundation::Result<pp::app::DocumentExportExecutionKind>::success(
|
||||
pp::app::DocumentExportExecutionKind::cube_faces);
|
||||
}
|
||||
if (kind == "animation-mp4" || kind == "mp4") {
|
||||
return pp::foundation::Result<pp::app::DocumentExportExecutionKind>::success(
|
||||
pp::app::DocumentExportExecutionKind::animation_mp4);
|
||||
}
|
||||
if (kind == "timelapse") {
|
||||
return pp::foundation::Result<pp::app::DocumentExportExecutionKind>::success(
|
||||
pp::app::DocumentExportExecutionKind::timelapse);
|
||||
}
|
||||
|
||||
return pp::foundation::Result<pp::app::DocumentExportExecutionKind>::failure(
|
||||
pp::foundation::Status::invalid_argument("unknown export execution kind"));
|
||||
}
|
||||
|
||||
const char* document_export_success_kind_name(pp::app::DocumentExportSuccessKind kind) noexcept
|
||||
{
|
||||
switch (kind) {
|
||||
@@ -2384,6 +2475,7 @@ void print_help()
|
||||
<< " plan-document-session-prompt --kind close-unsaved|save-before-workflow|new-document-overwrite|file-overwrite|save-error [--name NAME]\n"
|
||||
<< " plan-export-start [--requires-license] [--demo] [--no-canvas]\n"
|
||||
<< " plan-export-menu --kind jpeg|png|layers|cube-faces|depth|animation-frames|animation-mp4|timelapse [--demo] [--no-canvas]\n"
|
||||
<< " plan-export-snapshot-route --kind equirectangular|layers-collection|layers-stem|animation-frames-collection|animation-frames-stem|cube-faces|depth [--captured-face-payloads N] [--pending-face-payloads N] [--unsupported-target] [--unsupported-platform]\n"
|
||||
<< " plan-export-target --kind file|collection|stem|cube-faces|name --doc-name NAME [--work-dir DIR] [--directory DIR] [--extension EXT] [--suffix SUFFIX]\n"
|
||||
<< " plan-export-message --kind equirectangular|layers|animation-frames|depth|cube-faces|animation-mp4|timelapse --destination photos|pictures|files|work|path|success|suppressed [--detail TEXT]\n"
|
||||
<< " plan-export-report --kind license-disabled|equirectangular|layers|animation-frames|depth|cube-faces|animation-mp4|timelapse [--message TEXT]\n"
|
||||
@@ -3743,6 +3835,90 @@ int plan_export_menu(int argc, char** argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
pp::foundation::Status parse_plan_export_snapshot_route_args(
|
||||
int argc,
|
||||
char** argv,
|
||||
PlanExportSnapshotRouteArgs& args)
|
||||
{
|
||||
for (int i = 2; i < argc; ++i) {
|
||||
const std::string_view key(argv[i]);
|
||||
if (key == "--kind") {
|
||||
if (i + 1 >= argc) {
|
||||
return pp::foundation::Status::invalid_argument("missing value for option");
|
||||
}
|
||||
args.kind = argv[++i];
|
||||
} else if (key == "--captured-face-payloads") {
|
||||
if (i + 1 >= argc) {
|
||||
return pp::foundation::Status::invalid_argument("missing value for option");
|
||||
}
|
||||
const auto value = pp::foundation::parse_u32(argv[++i]);
|
||||
if (!value) {
|
||||
return value.status();
|
||||
}
|
||||
args.captured_face_payloads = value.value();
|
||||
} else if (key == "--pending-face-payloads") {
|
||||
if (i + 1 >= argc) {
|
||||
return pp::foundation::Status::invalid_argument("missing value for option");
|
||||
}
|
||||
const auto value = pp::foundation::parse_u32(argv[++i]);
|
||||
if (!value) {
|
||||
return value.status();
|
||||
}
|
||||
args.pending_face_payloads = value.value();
|
||||
} else if (key == "--unsupported-target") {
|
||||
args.target_supported = false;
|
||||
} else if (key == "--unsupported-platform") {
|
||||
args.platform_supported = false;
|
||||
} else {
|
||||
return pp::foundation::Status::invalid_argument("unknown option");
|
||||
}
|
||||
}
|
||||
|
||||
return pp::foundation::Status::success();
|
||||
}
|
||||
|
||||
int plan_export_snapshot_route(int argc, char** argv)
|
||||
{
|
||||
PlanExportSnapshotRouteArgs args;
|
||||
const auto status = parse_plan_export_snapshot_route_args(argc, argv, args);
|
||||
if (!status.ok()) {
|
||||
print_error("plan-export-snapshot-route", status.message);
|
||||
return 2;
|
||||
}
|
||||
|
||||
const auto kind = parse_document_export_execution_kind(args.kind);
|
||||
if (!kind) {
|
||||
print_error("plan-export-snapshot-route", kind.status().message);
|
||||
return 2;
|
||||
}
|
||||
|
||||
pp::app::DocumentCanvasSaveSnapshotReport report;
|
||||
report.captured_face_payloads = args.captured_face_payloads;
|
||||
report.pending_face_payloads = args.pending_face_payloads;
|
||||
report.payload_complete = args.captured_face_payloads >= args.pending_face_payloads;
|
||||
report.can_export_ppi = report.payload_complete;
|
||||
|
||||
const auto plan = pp::app::plan_document_export_snapshot_route(
|
||||
kind.value(),
|
||||
report,
|
||||
args.target_supported,
|
||||
args.platform_supported);
|
||||
|
||||
std::cout << "{\"ok\":true,\"command\":\"plan-export-snapshot-route\""
|
||||
<< ",\"state\":{\"kind\":\"" << json_escape(args.kind)
|
||||
<< "\",\"capturedFacePayloads\":" << args.captured_face_payloads
|
||||
<< ",\"pendingFacePayloads\":" << args.pending_face_payloads
|
||||
<< ",\"payloadComplete\":" << json_bool(report.payload_complete)
|
||||
<< ",\"targetSupported\":" << json_bool(args.target_supported)
|
||||
<< ",\"platformSupported\":" << json_bool(args.platform_supported)
|
||||
<< "},\"plan\":{\"kind\":\"" << document_export_execution_kind_name(plan.kind)
|
||||
<< "\",\"action\":\"" << document_export_snapshot_route_action_name(plan.action)
|
||||
<< "\",\"usesDocumentSnapshotWriter\":" << json_bool(plan.uses_document_snapshot_writer)
|
||||
<< ",\"fallbackReason\":\"" << json_escape(std::string(plan.fallback_reason))
|
||||
<< "\"}}\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
pp::foundation::Status parse_plan_export_message_args(
|
||||
int argc,
|
||||
char** argv,
|
||||
@@ -11957,6 +12133,10 @@ int main(int argc, char** argv)
|
||||
return plan_export_menu(argc, argv);
|
||||
}
|
||||
|
||||
if (command == "plan-export-snapshot-route") {
|
||||
return plan_export_snapshot_route(argc, argv);
|
||||
}
|
||||
|
||||
if (command == "plan-export-target") {
|
||||
return plan_export_target(argc, argv);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user