[Bf-blender-cvs] [94e1b14ceac] greasepencil-object: GPencil: New option to disable fill strokes in SVG export

Antonio Vazquez noreply at git.blender.org
Mon Jul 27 18:35:45 CEST 2020


Commit: 94e1b14ceac84b109af05f3da45919b916dd1133
Author: Antonio Vazquez
Date:   Mon Jul 27 18:35:38 2020 +0200
Branches: greasepencil-object
https://developer.blender.org/rB94e1b14ceac84b109af05f3da45919b916dd1133

GPencil: New option to disable fill strokes in SVG export

===================================================================

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_svg.cc

===================================================================

diff --git a/source/blender/editors/io/io_gpencil.c b/source/blender/editors/io/io_gpencil.c
index 81f73431763..9783697575c 100644
--- a/source/blender/editors/io/io_gpencil.c
+++ b/source/blender/editors/io/io_gpencil.c
@@ -147,6 +147,11 @@ static int wm_gpencil_export_exec(bContext *C, wmOperator *op)
   RNA_string_get(op->ptr, "filepath", filename);
 
   const bool only_active_frame = RNA_boolean_get(op->ptr, "only_active_frame");
+  const bool use_fill = RNA_boolean_get(op->ptr, "use_fill");
+
+  /* Set flags. */
+  int flag = 0;
+  SET_FLAG_FROM_TEST(flag, use_fill, GP_EXPORT_FILL);
 
   struct GpencilExportParams params = {
       .C = C,
@@ -156,6 +161,7 @@ static int wm_gpencil_export_exec(bContext *C, wmOperator *op)
       .mode = GP_EXPORT_TO_SVG,
       .frame_start = RNA_int_get(op->ptr, "start"),
       .frame_end = RNA_int_get(op->ptr, "end"),
+      .flag = flag,
   };
   /* Take some defaults from the scene, if not specified explicitly. */
   Scene *scene = CTX_data_scene(C);
@@ -223,6 +229,15 @@ static void ui_gpencil_export_settings(uiLayout *layout, PointerRNA *imfptr)
   uiLayoutSetActive(sub, !RNA_boolean_get(imfptr, "only_active_frame"));
   uiItemR(sub, imfptr, "start", 0, IFACE_("Frame Start"), ICON_NONE);
   uiItemR(sub, imfptr, "end", 0, IFACE_("End"), ICON_NONE);
+
+  box = uiLayoutBox(layout);
+  row = uiLayoutRow(box, false);
+  uiItemL(row, IFACE_("Export Options"), ICON_SCENE_DATA);
+
+  col = uiLayoutColumn(box, false);
+
+  sub = uiLayoutColumn(col, true);
+  uiItemR(sub, imfptr, "use_fill", 0, NULL, ICON_NONE);
 }
 
 static void wm_gpencil_export_draw(bContext *C, wmOperator *op)
@@ -323,6 +338,7 @@ void WM_OT_gpencil_export(wmOperatorType *ot)
               INT_MAX);
 
   RNA_def_boolean(ot->srna, "only_active_frame", true, "Active Frame", "Export only active frame");
+  RNA_def_boolean(ot->srna, "use_fill", true, "Fill", "Export filled areas");
 
   /* 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 83d3c5037f8..eb779112fe4 100644
--- a/source/blender/io/gpencil/gpencil_io_exporter.h
+++ b/source/blender/io/gpencil/gpencil_io_exporter.h
@@ -46,8 +46,15 @@ struct GpencilExportParams {
   double frame_end;
   /** Frame subfix. */
   char frame[5];
+  /** Flags. */
+  int flag;
 };
 
+typedef enum eGpencilExportParams_Flag {
+  /* Export Filled strokes. */
+  GP_EXPORT_FILL = (1 << 0),
+} eGpencilExportParams_Flag;
+
 bool gpencil_io_export(const struct GpencilExportParams *params);
 
 #ifdef __cplusplus
diff --git a/source/blender/io/gpencil/intern/gpencil_io_svg.cc b/source/blender/io/gpencil/intern/gpencil_io_svg.cc
index 431e4d1f913..c87ae5dd1fa 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_svg.cc
+++ b/source/blender/io/gpencil/intern/gpencil_io_svg.cc
@@ -68,6 +68,7 @@ GpencilExporterSVG::GpencilExporterSVG(const struct GpencilExportParams *params)
   this->params.C = params->C;
   this->params.filename = params->filename;
   this->params.mode = params->mode;
+  this->params.flag = params->flag;
 
   this->gpd = (bGPdata *)params->ob->data;
 
@@ -232,7 +233,7 @@ void GpencilExporterSVG::export_layers(void)
       }
       else {
         /* Fill. */
-        if (is_fill) {
+        if ((is_fill) && (params.flag & GP_EXPORT_FILL)) {
           export_stroke(gpl_node, gps, diff_mat, true);
         }



More information about the Bf-blender-cvs mailing list