Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/io/io_gpencil_export.c
| /* SPDX-License-Identifier: GPL-2.0-or-later | /* SPDX-License-Identifier: GPL-2.0-or-later | ||||
| * Copyright 2020 Blender Foundation. All rights reserved. */ | * Copyright 2020 Blender Foundation. All rights reserved. */ | ||||
| /** \file | /** \file | ||||
| * \ingroup editor/io | * \ingroup editor/io | ||||
| */ | */ | ||||
| #ifdef WITH_IO_GPENCIL | |||||
| #include "BLI_path_util.h" | # include "BLI_path_util.h" | ||||
| #include "BLI_string.h" | # include "BLI_string.h" | ||||
| #include "DNA_gpencil_types.h" | # include "DNA_gpencil_types.h" | ||||
| #include "DNA_space_types.h" | # include "DNA_space_types.h" | ||||
| #include "BKE_gpencil.h" | # include "BKE_gpencil.h" | ||||
| #include "BKE_main.h" | # include "BKE_main.h" | ||||
| #include "BKE_report.h" | # include "BKE_report.h" | ||||
| #include "BKE_screen.h" | # include "BKE_screen.h" | ||||
| #include "BLT_translation.h" | # include "BLT_translation.h" | ||||
| #include "RNA_access.h" | # include "RNA_access.h" | ||||
| #include "RNA_define.h" | # include "RNA_define.h" | ||||
| #include "UI_interface.h" | # include "UI_interface.h" | ||||
| #include "UI_resources.h" | # include "UI_resources.h" | ||||
| #include "WM_api.h" | # include "WM_api.h" | ||||
| #include "WM_types.h" | # include "WM_types.h" | ||||
| #include "DEG_depsgraph.h" | # include "DEG_depsgraph.h" | ||||
| #include "DEG_depsgraph_query.h" | # include "DEG_depsgraph_query.h" | ||||
| #include "io_gpencil.h" | # include "io_gpencil.h" | ||||
| #include "gpencil_io.h" | # include "gpencil_io.h" | ||||
| #if defined(WITH_PUGIXML) || defined(WITH_HARU) | # if defined(WITH_PUGIXML) || defined(WITH_HARU) | ||||
| /* Definition of enum elements to export. */ | /* Definition of enum elements to export. */ | ||||
| /* Common props for exporting. */ | /* Common props for exporting. */ | ||||
| static void gpencil_export_common_props_definition(wmOperatorType *ot) | static void gpencil_export_common_props_definition(wmOperatorType *ot) | ||||
| { | { | ||||
| static const EnumPropertyItem select_items[] = { | static const EnumPropertyItem select_items[] = { | ||||
| {GP_EXPORT_ACTIVE, "ACTIVE", 0, "Active", "Include only the active object"}, | {GP_EXPORT_ACTIVE, "ACTIVE", 0, "Active", "Include only the active object"}, | ||||
| {GP_EXPORT_SELECTED, "SELECTED", 0, "Selected", "Include selected objects"}, | {GP_EXPORT_SELECTED, "SELECTED", 0, "Selected", "Include selected objects"}, | ||||
| {GP_EXPORT_VISIBLE, "VISIBLE", 0, "Visible", "Include all visible objects"}, | {GP_EXPORT_VISIBLE, "VISIBLE", 0, "Visible", "Include all visible objects"}, | ||||
| Show All 36 Lines | if (!RNA_struct_property_is_set(op->ptr, "filepath")) { | ||||
| else { | else { | ||||
| BLI_strncpy(filepath, BKE_main_blendfile_path(bmain), sizeof(filepath)); | BLI_strncpy(filepath, BKE_main_blendfile_path(bmain), sizeof(filepath)); | ||||
| } | } | ||||
| BLI_path_extension_replace(filepath, sizeof(filepath), extension); | BLI_path_extension_replace(filepath, sizeof(filepath), extension); | ||||
| RNA_string_set(op->ptr, "filepath", filepath); | RNA_string_set(op->ptr, "filepath", filepath); | ||||
| } | } | ||||
| } | } | ||||
| #endif | # endif | ||||
| /* <-------- SVG single frame export. --------> */ | /* <-------- SVG single frame export. --------> */ | ||||
| #ifdef WITH_PUGIXML | # ifdef WITH_PUGIXML | ||||
| static bool wm_gpencil_export_svg_common_check(bContext *UNUSED(C), wmOperator *op) | static bool wm_gpencil_export_svg_common_check(bContext *UNUSED(C), wmOperator *op) | ||||
| { | { | ||||
| char filepath[FILE_MAX]; | char filepath[FILE_MAX]; | ||||
| RNA_string_get(op->ptr, "filepath", filepath); | RNA_string_get(op->ptr, "filepath", filepath); | ||||
| if (!BLI_path_extension_check(filepath, ".svg")) { | if (!BLI_path_extension_check(filepath, ".svg")) { | ||||
| BLI_path_extension_ensure(filepath, FILE_MAX, ".svg"); | BLI_path_extension_ensure(filepath, FILE_MAX, ".svg"); | ||||
| RNA_string_set(op->ptr, "filepath", filepath); | RNA_string_set(op->ptr, "filepath", filepath); | ||||
| ▲ Show 20 Lines • Show All 134 Lines • ▼ Show 20 Lines | void WM_OT_gpencil_export_svg(wmOperatorType *ot) | ||||
| gpencil_export_common_props_definition(ot); | gpencil_export_common_props_definition(ot); | ||||
| RNA_def_boolean(ot->srna, | RNA_def_boolean(ot->srna, | ||||
| "use_clip_camera", | "use_clip_camera", | ||||
| false, | false, | ||||
| "Clip Camera", | "Clip Camera", | ||||
| "Clip drawings to camera size when export in camera view"); | "Clip drawings to camera size when export in camera view"); | ||||
| } | } | ||||
| #endif | # endif | ||||
| /* <-------- PDF single frame export. --------> */ | /* <-------- PDF single frame export. --------> */ | ||||
| #ifdef WITH_HARU | # ifdef WITH_HARU | ||||
| static bool wm_gpencil_export_pdf_common_check(bContext *UNUSED(C), wmOperator *op) | static bool wm_gpencil_export_pdf_common_check(bContext *UNUSED(C), wmOperator *op) | ||||
| { | { | ||||
| char filepath[FILE_MAX]; | char filepath[FILE_MAX]; | ||||
| RNA_string_get(op->ptr, "filepath", filepath); | RNA_string_get(op->ptr, "filepath", filepath); | ||||
| if (!BLI_path_extension_check(filepath, ".pdf")) { | if (!BLI_path_extension_check(filepath, ".pdf")) { | ||||
| BLI_path_extension_ensure(filepath, FILE_MAX, ".pdf"); | BLI_path_extension_ensure(filepath, FILE_MAX, ".pdf"); | ||||
| ▲ Show 20 Lines • Show All 145 Lines • ▼ Show 20 Lines | void WM_OT_gpencil_export_pdf(wmOperatorType *ot) | ||||
| gpencil_export_common_props_definition(ot); | gpencil_export_common_props_definition(ot); | ||||
| ot->prop = RNA_def_enum(ot->srna, | ot->prop = RNA_def_enum(ot->srna, | ||||
| "frame_mode", | "frame_mode", | ||||
| gpencil_export_frame_items, | gpencil_export_frame_items, | ||||
| GP_EXPORT_ACTIVE, | GP_EXPORT_ACTIVE, | ||||
| "Frames", | "Frames", | ||||
| "Which frames to include in the export"); | "Which frames to include in the export"); | ||||
| } | } | ||||
| #endif | # endif /* `defined(WITH_PUGIXML) || defined(WITH_HARU)` */ | ||||
| #endif /* WITH_IO_GPENCIL */ | |||||