[Bf-blender-cvs] [7d08c58f726] greasepencil-object: GPencil: Add markers support to SVG export
Antonio Vazquez
noreply at git.blender.org
Tue Aug 4 16:42:04 CEST 2020
Commit: 7d08c58f726a703c4e773182858d8484f6093814
Author: Antonio Vazquez
Date: Tue Aug 4 13:52:48 2020 +0200
Branches: greasepencil-object
https://developer.blender.org/rB7d08c58f726a703c4e773182858d8484f6093814
GPencil: Add markers support to SVG export
Instead to export all frames, only export frames with markers.
===================================================================
M source/blender/editors/io/io_gpencil.c
M source/blender/io/gpencil/gpencil_io_exporter.h
M source/blender/io/gpencil/intern/gpencil_io_capi.cc
===================================================================
diff --git a/source/blender/editors/io/io_gpencil.c b/source/blender/editors/io/io_gpencil.c
index 06fa78f7fb6..2865cc4726f 100644
--- a/source/blender/editors/io/io_gpencil.c
+++ b/source/blender/editors/io/io_gpencil.c
@@ -153,6 +153,7 @@ static int wm_gpencil_export_exec(bContext *C, wmOperator *op)
const bool use_clip_camera = RNA_boolean_get(op->ptr, "use_clip_camera");
const bool use_gray_scale = RNA_boolean_get(op->ptr, "use_gray_scale");
+ const bool use_markers = RNA_boolean_get(op->ptr, "use_markers");
/* Set flags. */
int flag = 0;
@@ -161,6 +162,7 @@ static int wm_gpencil_export_exec(bContext *C, wmOperator *op)
SET_FLAG_FROM_TEST(flag, use_norm_thickness, GP_EXPORT_NORM_THICKNESS);
SET_FLAG_FROM_TEST(flag, use_clip_camera, GP_EXPORT_CLIP_CAMERA);
SET_FLAG_FROM_TEST(flag, use_gray_scale, GP_EXPORT_GRAY_SCALE);
+ SET_FLAG_FROM_TEST(flag, use_markers, GP_EXPORT_MARKERS);
float paper_size[2];
if (RNA_enum_get(op->ptr, "page_type") == GP_EXPORT_PAPER_LANDSCAPE) {
@@ -259,6 +261,9 @@ static void ui_gpencil_export_settings(uiLayout *layout, PointerRNA *imfptr)
row = uiLayoutRow(col, false);
uiItemR(row, imfptr, "text_type", 0, NULL, ICON_NONE);
+ row = uiLayoutRow(col, false);
+ uiItemR(row, imfptr, "use_markers", 0, NULL, ICON_NONE);
+
box = uiLayoutBox(layout);
row = uiLayoutRow(box, false);
uiItemL(row, IFACE_("Export Options"), ICON_SCENE_DATA);
@@ -440,6 +445,7 @@ void WM_OT_gpencil_export(wmOperatorType *ot)
RNA_def_int(ot->srna, "size_col", 3, 1, 6, "Colums", "Number of columns per page", 1, 6);
RNA_def_int(ot->srna, "size_row", 2, 1, 6, "Rows", "Number of rows per page", 1, 6);
+ RNA_def_boolean(ot->srna, "use_markers", false, "Markers", "Use markers to select frames");
/* This dummy prop is used to check whether we need to init the start and
* end frame values to that of the scene's, otherwise they are reset at
diff --git a/source/blender/io/gpencil/gpencil_io_exporter.h b/source/blender/io/gpencil/gpencil_io_exporter.h
index cbadafd2974..26ce7a5055e 100644
--- a/source/blender/io/gpencil/gpencil_io_exporter.h
+++ b/source/blender/io/gpencil/gpencil_io_exporter.h
@@ -75,6 +75,8 @@ typedef enum eGpencilExportParams_Flag {
GP_EXPORT_CLIP_CAMERA = (1 << 3),
/* Gray Scale. */
GP_EXPORT_GRAY_SCALE = (1 << 4),
+ /* Export markers frames. */
+ GP_EXPORT_MARKERS = (1 << 5),
} eGpencilExportParams_Flag;
typedef enum eGpencilExport_Modes {
diff --git a/source/blender/io/gpencil/intern/gpencil_io_capi.cc b/source/blender/io/gpencil/intern/gpencil_io_capi.cc
index d83c3481185..c0e77c7abde 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_capi.cc
+++ b/source/blender/io/gpencil/intern/gpencil_io_capi.cc
@@ -34,6 +34,8 @@
#include "BKE_main.h"
#include "BKE_scene.h"
+#include "ED_markers.h"
+
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
@@ -42,18 +44,31 @@
using blender::io::gpencil::GpencilExporterSVG;
-static bool is_keyframe_empty(bGPdata *gpd, int framenum)
+static bool is_keyframe_empty(bContext *C, bGPdata *gpd, int framenum, bool use_markers)
{
- LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
- if (gpl->flag & GP_LAYER_HIDE) {
- continue;
+ if (!use_markers) {
+ /* Check if exist a frame. */
+ LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
+ if (gpl->flag & GP_LAYER_HIDE) {
+ continue;
+ }
+ LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
+ if (gpf->framenum == framenum) {
+ return false;
+ }
+ }
}
- LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
- if (gpf->framenum == framenum) {
+ }
+ else {
+ ListBase *markers = ED_context_get_markers(C);
+ /* Check if exist a marker. */
+ LISTBASE_FOREACH (TimeMarker *, marker, markers) {
+ if (marker->frame == framenum) {
return false;
}
}
}
+
return true;
}
@@ -113,8 +128,11 @@ static bool gpencil_export_storyboard(
bool header = true;
bool pending_save = false;
int shot = 0;
+
+ const bool use_markers = ((iparams->flag & GP_EXPORT_MARKERS) != 0);
+
for (int i = iparams->frame_start; i < iparams->frame_end + 1; i++) {
- if (is_keyframe_empty(gpd_eval, i)) {
+ if (is_keyframe_empty(iparams->C, gpd_eval, i, use_markers)) {
continue;
}
shot++;
More information about the Bf-blender-cvs
mailing list