[Bf-blender-cvs] [d808a42fb6e] greasepencil-object: GPencil: Reorganize SVG exporter UI

Antonio Vazquez noreply at git.blender.org
Tue Aug 4 12:59:44 CEST 2020


Commit: d808a42fb6ee68c6b2dfaf2003cc84d80092e745
Author: Antonio Vazquez
Date:   Tue Aug 4 09:15:25 2020 +0200
Branches: greasepencil-object
https://developer.blender.org/rBd808a42fb6ee68c6b2dfaf2003cc84d80092e745

GPencil: Reorganize SVG exporter UI

This is in preparation for more options.

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

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_base.cc
M	source/blender/io/gpencil/intern/gpencil_io_capi.cc
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 4d061761c64..bb81f43caee 100644
--- a/source/blender/editors/io/io_gpencil.c
+++ b/source/blender/editors/io/io_gpencil.c
@@ -146,23 +146,21 @@ static int wm_gpencil_export_exec(bContext *C, wmOperator *op)
   char filename[FILE_MAX];
   RNA_string_get(op->ptr, "filepath", filename);
 
-  const bool only_active_frame = RNA_boolean_get(op->ptr, "only_active_frame");
+  const bool use_storyboard = RNA_boolean_get(op->ptr, "use_storyboard");
   const bool use_fill = RNA_boolean_get(op->ptr, "use_fill");
   const bool use_norm_thickness = RNA_boolean_get(op->ptr, "use_normalized_thickness");
   const short select = RNA_enum_get(op->ptr, "selected_object_type");
 
   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_storyboard = RNA_boolean_get(op->ptr, "use_storyboard");
 
   /* Set flags. */
   int flag = 0;
-  SET_FLAG_FROM_TEST(flag, only_active_frame, GP_EXPORT_ACTIVE_FRAME);
+  SET_FLAG_FROM_TEST(flag, use_storyboard, GP_EXPORT_STORYBOARD_MODE);
   SET_FLAG_FROM_TEST(flag, use_fill, GP_EXPORT_FILL);
   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_storyboard, GP_EXPORT_STORYBOARD_MODE);
 
   struct GpencilExportParams params = {
       .C = C,
@@ -217,16 +215,17 @@ static void ui_gpencil_export_settings(uiLayout *layout, PointerRNA *imfptr)
   row = uiLayoutRow(box, false);
   uiItemR(row, imfptr, "selected_object_type", 0, NULL, ICON_NONE);
 
+  box = uiLayoutBox(layout);
+
   row = uiLayoutRow(box, false);
-  uiItemR(row, imfptr, "only_active_frame", 0, NULL, ICON_NONE);
+  uiItemR(box, imfptr, "use_storyboard", 0, NULL, ICON_NONE);
 
   col = uiLayoutColumn(box, false);
+  uiLayoutSetActive(col, RNA_boolean_get(imfptr, "use_storyboard"));
 
   sub = uiLayoutColumn(col, true);
-  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);
-  uiItemR(sub, imfptr, "use_storyboard", 0, NULL, ICON_NONE);
 
   box = uiLayoutBox(layout);
   row = uiLayoutRow(box, false);
@@ -374,7 +373,7 @@ void WM_OT_gpencil_export(wmOperatorType *ot)
       ot->srna, "use_storyboard", false, "Storyboard Mode", "Export several frame sin same page");
   RNA_def_float(ot->srna,
                 "stroke_sample",
-                0.03f,
+                0.0f,
                 0.0f,
                 100.0f,
                 "Sampling",
diff --git a/source/blender/io/gpencil/gpencil_io_exporter.h b/source/blender/io/gpencil/gpencil_io_exporter.h
index 28f3f055eaa..f4a278d1830 100644
--- a/source/blender/io/gpencil/gpencil_io_exporter.h
+++ b/source/blender/io/gpencil/gpencil_io_exporter.h
@@ -71,8 +71,8 @@ struct GpencilExportParams {
 };
 
 typedef enum eGpencilExportParams_Flag {
-  /* Export only active frame. */
-  GP_EXPORT_ACTIVE_FRAME = (1 << 0),
+  /* Use Storyboard format. */
+  GP_EXPORT_STORYBOARD_MODE = (1 << 0),
   /* Export Filled strokes. */
   GP_EXPORT_FILL = (1 << 1),
   /* Export normalized thickness. */
@@ -81,8 +81,6 @@ typedef enum eGpencilExportParams_Flag {
   GP_EXPORT_CLIP_CAMERA = (1 << 3),
   /* Gray Scale. */
   GP_EXPORT_GRAY_SCALE = (1 << 4),
-  /* Use Storyboard format. */
-  GP_EXPORT_STORYBOARD_MODE = (1 << 5),
 } eGpencilExportParams_Flag;
 
 bool gpencil_io_export(struct GpencilExportParams *iparams);
diff --git a/source/blender/io/gpencil/intern/gpencil_io_base.cc b/source/blender/io/gpencil/intern/gpencil_io_base.cc
index 7e46f5dc17f..52719963cd0 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_base.cc
+++ b/source/blender/io/gpencil/intern/gpencil_io_base.cc
@@ -84,7 +84,7 @@ GpencilExporter::GpencilExporter(const struct GpencilExportParams *iparams)
   depsgraph = CTX_data_depsgraph_pointer(params_.C);
   rv3d = (RegionView3D *)params_.region->regiondata;
   gpd = (bGPdata *)params_.obact->data;
-  const bool only_active_frame = ((params_.flag & GP_EXPORT_ACTIVE_FRAME) != 0);
+  const bool is_storyboard = ((params_.flag & GP_EXPORT_STORYBOARD_MODE) != 0);
 
   Scene *scene = CTX_data_scene(params_.C);
 
@@ -116,7 +116,7 @@ GpencilExporter::GpencilExporter(const struct GpencilExportParams *iparams)
   }
   else {
     is_camera = false;
-    if (only_active_frame && (ob_list_.size() == 1)) {
+    if (!is_storyboard && (ob_list_.size() == 1)) {
       /* Calc selected object boundbox. Need set initial value to some variables. */
       camera_ratio_ = 1.0f;
       offset_[0] = 0.0f;
diff --git a/source/blender/io/gpencil/intern/gpencil_io_capi.cc b/source/blender/io/gpencil/intern/gpencil_io_capi.cc
index b0574baf6d5..72cc865d13e 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_capi.cc
+++ b/source/blender/io/gpencil/intern/gpencil_io_capi.cc
@@ -82,41 +82,6 @@ static bool gpencil_io_export_frame(GpencilExporterSVG *writter,
   return result;
 }
 
-static bool gpencil_create_page(
-    Depsgraph *depsgraph, Main *bmain, Scene *scene, GpencilExportParams *iparams, int frame)
-{
-  GpencilExporterSVG writter = GpencilExporterSVG(iparams);
-  float no_offset[2] = {0.0f, 0.0f};
-  float ratio[2] = {1.0f, 1.0f};
-  writter.set_frame_ratio(ratio);
-
-  CFRA = frame;
-  BKE_scene_graph_update_for_newframe(depsgraph, bmain);
-  sprintf(iparams->file_subfix, "%04d", frame);
-  iparams->framenum = frame;
-
-  return gpencil_io_export_frame(&writter, iparams, no_offset, true, true, true);
-}
-
-/* Export full animation. */
-static bool gpencil_export_animation(
-    Depsgraph *depsgraph, Main *bmain, Scene *scene, GpencilExportParams *iparams, Object *ob)
-{
-  Object *ob_eval_ = (Object *)DEG_get_evaluated_id(depsgraph, &ob->id);
-  bGPdata *gpd_eval = (bGPdata *)ob_eval_->data;
-
-  bool done = false;
-  for (int i = iparams->frame_start; i < iparams->frame_end + 1; i++) {
-    if (is_keyframe_empty(gpd_eval, i)) {
-      continue;
-    }
-
-    done |= gpencil_create_page(depsgraph, bmain, scene, iparams, i);
-  }
-
-  return done;
-}
-
 /* Export full animation in Storyboard mode. */
 static bool gpencil_export_storyboard(
     Depsgraph *depsgraph, Main *bmain, Scene *scene, GpencilExportParams *iparams, Object *ob)
@@ -208,16 +173,15 @@ bool gpencil_io_export(GpencilExportParams *iparams)
   Scene *scene = CTX_data_scene(iparams->C);
   Object *ob = CTX_data_active_object(iparams->C);
 
-  const bool only_active_frame = ((iparams->flag & GP_EXPORT_ACTIVE_FRAME) != 0);
+  const bool is_storyboard = ((iparams->flag & GP_EXPORT_STORYBOARD_MODE) != 0);
 
-  int oldframe = (int)DEG_get_ctime(depsgraph);
   bool done = false;
 
   /* Prepare document. */
   // TODO: Fix paper using parameter
   copy_v2_v2(iparams->paper_size, paper_size[0]);
 
-  if (only_active_frame) {
+  if (!is_storyboard) {
     GpencilExporterSVG writter = GpencilExporterSVG(iparams);
     float no_offset[2] = {0.0f, 0.0f};
     float ratio[2] = {1.0f, 1.0f};
@@ -226,16 +190,9 @@ bool gpencil_io_export(GpencilExportParams *iparams)
     done |= gpencil_io_export_frame(&writter, iparams, no_offset, true, true, true);
   }
   else {
-    if ((iparams->flag & GP_EXPORT_STORYBOARD_MODE) != 0) {
-      done |= gpencil_export_storyboard(depsgraph, bmain, scene, iparams, ob);
-    }
-    else {
-      done |= gpencil_export_animation(depsgraph, bmain, scene, iparams, ob);
-    }
-  }
-
-  /* Return frame state and DB to original state. */
-  if (!only_active_frame) {
+    int oldframe = (int)DEG_get_ctime(depsgraph);
+    done |= gpencil_export_storyboard(depsgraph, bmain, scene, iparams, ob);
+    /* Return frame state and DB to original state. */
     CFRA = oldframe;
     BKE_scene_graph_update_for_newframe(depsgraph, bmain);
   }
diff --git a/source/blender/io/gpencil/intern/gpencil_io_svg.cc b/source/blender/io/gpencil/intern/gpencil_io_svg.cc
index 4725ac8e57c..87dd0e016fe 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_svg.cc
+++ b/source/blender/io/gpencil/intern/gpencil_io_svg.cc
@@ -145,7 +145,7 @@ void GpencilExporterSVG::export_layers(void)
                                                                 GP_EXPORT_STORYBOARD_MODE)) != 0;
 
   /* If is doing a set of frames, the list of objects can change for each frame. */
-  if (is_camera_mode() && ((params_.flag & GP_EXPORT_ACTIVE_FRAME) == 0)) {
+  if (is_camera_mode() && ((params_.flag & GP_EXPORT_STORYBOARD_MODE) != 0)) {
     create_object_list();
   }



More information about the Bf-blender-cvs mailing list