[Bf-blender-cvs] [91a8426bc80] greasepencil-object: GPencil: Add different list of select type

Antonio Vazquez noreply at git.blender.org
Mon Aug 3 23:48:47 CEST 2020


Commit: 91a8426bc804b34ba3e178e2a8ce6be0b685069a
Author: Antonio Vazquez
Date:   Mon Aug 3 23:48:38 2020 +0200
Branches: greasepencil-object
https://developer.blender.org/rB91a8426bc804b34ba3e178e2a8ce6be0b685069a

GPencil: Add different list of select type

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

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 8825cb56634..4d061761c64 100644
--- a/source/blender/editors/io/io_gpencil.c
+++ b/source/blender/editors/io/io_gpencil.c
@@ -149,7 +149,8 @@ static int wm_gpencil_export_exec(bContext *C, wmOperator *op)
   const bool only_active_frame = RNA_boolean_get(op->ptr, "only_active_frame");
   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 bool use_selected_objects = RNA_boolean_get(op->ptr, "use_selected_objects");
+  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");
@@ -159,7 +160,6 @@ static int wm_gpencil_export_exec(bContext *C, wmOperator *op)
   SET_FLAG_FROM_TEST(flag, only_active_frame, GP_EXPORT_ACTIVE_FRAME);
   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_selected_objects, GP_EXPORT_SELECTED_OBJECTS);
   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);
@@ -174,6 +174,7 @@ static int wm_gpencil_export_exec(bContext *C, wmOperator *op)
       .frame_start = RNA_int_get(op->ptr, "start"),
       .frame_end = RNA_int_get(op->ptr, "end"),
       .flag = flag,
+      .select = select,
       .stroke_sample = RNA_float_get(op->ptr, "stroke_sample"),
   };
   /* Take some defaults from the scene, if not specified explicitly. */
@@ -214,7 +215,7 @@ static void ui_gpencil_export_settings(uiLayout *layout, PointerRNA *imfptr)
   uiItemL(row, IFACE_("Scene Options"), ICON_SCENE_DATA);
 
   row = uiLayoutRow(box, false);
-  uiItemR(row, imfptr, "use_selected_objects", 0, NULL, ICON_NONE);
+  uiItemR(row, imfptr, "selected_object_type", 0, NULL, ICON_NONE);
 
   row = uiLayoutRow(box, false);
   uiItemR(row, imfptr, "only_active_frame", 0, NULL, ICON_NONE);
@@ -298,6 +299,13 @@ static bool wm_gpencil_export_poll(bContext *C)
 
 void WM_OT_gpencil_export(wmOperatorType *ot)
 {
+  static const EnumPropertyItem select_items[] = {
+      {GP_EXPORT_ACTIVE, "ACTIVE", 0, "Active", "Include only active object"},
+      {GP_EXPORT_SELECTED, "SELECTED", 0, "Selected", "Include selected objects"},
+      {GP_EXPORT_VISIBLE, "VISIBLE", 0, "Visible", "Include visible objects"},
+      {0, NULL, 0, NULL, NULL},
+  };
+
   ot->name = "Export Grease Pencil";
   ot->description = "Export current grease pencil";
   ot->idname = "WM_OT_gpencil_export";
@@ -345,11 +353,13 @@ void WM_OT_gpencil_export(wmOperatorType *ot)
                   false,
                   "Normalize",
                   "Export strokes with constant thickness along the stroke");
-  RNA_def_boolean(ot->srna,
-                  "use_selected_objects",
-                  true,
-                  "All Selected Objects",
-                  "Export all selected objects, unselect for export active object only");
+  ot->prop = RNA_def_enum(ot->srna,
+                          "selected_object_type",
+                          select_items,
+                          0,
+                          "Object",
+                          "Objects included in the export");
+
   RNA_def_boolean(ot->srna,
                   "use_clip_camera",
                   false,
diff --git a/source/blender/io/gpencil/gpencil_io_exporter.h b/source/blender/io/gpencil/gpencil_io_exporter.h
index b79735792db..28f3f055eaa 100644
--- a/source/blender/io/gpencil/gpencil_io_exporter.h
+++ b/source/blender/io/gpencil/gpencil_io_exporter.h
@@ -34,6 +34,12 @@ typedef enum eGpencilExport_Modes {
   GP_EXPORT_TO_SVG = 0,
 } eGpencilExport_Modes;
 
+typedef enum eGpencilExportSelect {
+  GP_EXPORT_ACTIVE = 0,
+  GP_EXPORT_SELECTED = 1,
+  GP_EXPORT_VISIBLE = 2,
+} eGpencilExportSelect;
+
 struct GpencilExportParams {
   bContext *C;
   ARegion *region;
@@ -54,6 +60,8 @@ struct GpencilExportParams {
   int framenum;
   /** Flags. */
   int flag;
+  /** Select mode */
+  short select;
   /** Stroke sampling. */
   float stroke_sample;
   /** Row and cols of storyboard. */
@@ -69,14 +77,12 @@ typedef enum eGpencilExportParams_Flag {
   GP_EXPORT_FILL = (1 << 1),
   /* Export normalized thickness. */
   GP_EXPORT_NORM_THICKNESS = (1 << 2),
-  /* Export all selected objects. */
-  GP_EXPORT_SELECTED_OBJECTS = (1 << 3),
   /* Clip camera area. */
-  GP_EXPORT_CLIP_CAMERA = (1 << 4),
+  GP_EXPORT_CLIP_CAMERA = (1 << 3),
   /* Gray Scale. */
-  GP_EXPORT_GRAY_SCALE = (1 << 5),
+  GP_EXPORT_GRAY_SCALE = (1 << 4),
   /* Use Storyboard format. */
-  GP_EXPORT_STORYBOARD_MODE = (1 << 6),
+  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 2aba9f7a9d6..22a2eebb4aa 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_base.cc
+++ b/source/blender/io/gpencil/intern/gpencil_io_base.cc
@@ -72,6 +72,7 @@ GpencilExporter::GpencilExporter(const struct GpencilExportParams *iparams)
   params_.filename = iparams->filename;
   params_.mode = iparams->mode;
   params_.flag = iparams->flag;
+  params_.select = iparams->select;
   params_.stroke_sample = iparams->stroke_sample;
   params_.framenum = iparams->framenum;
 
@@ -150,29 +151,31 @@ void GpencilExporter::create_object_list(void)
     if (object->type != OB_GPENCIL) {
       continue;
     }
-    if (((params_.flag & GP_EXPORT_SELECTED_OBJECTS) == 0) && (params_.obact != object)) {
+    if ((params_.select == GP_EXPORT_ACTIVE) && (params_.obact != object)) {
       continue;
     }
 
-    if (base->flag & BASE_SELECTED) {
-      /* Save z-depth from view to sort from back to front. */
-      if (is_camera) {
-        float camera_z = dot_v3v3(camera_z_axis, object->obmat[3]);
-        ObjectZ obz = {camera_z, object};
-        ob_list_.push_back(obz);
-      }
-      else {
-        float zdepth = 0;
-        if (rv3d) {
-          if (rv3d->is_persp) {
-            zdepth = ED_view3d_calc_zfac(rv3d, object->obmat[3], NULL);
-          }
-          else {
-            zdepth = -dot_v3v3(rv3d->viewinv[2], object->obmat[3]);
-          }
-          ObjectZ obz = {zdepth * -1.0f, object};
-          ob_list_.push_back(obz);
+    if ((params_.select == GP_EXPORT_SELECTED) && ((base->flag & BASE_SELECTED) == 0)) {
+      continue;
+    }
+
+    /* Save z-depth from view to sort from back to front. */
+    if (is_camera) {
+      float camera_z = dot_v3v3(camera_z_axis, object->obmat[3]);
+      ObjectZ obz = {camera_z, object};
+      ob_list_.push_back(obz);
+    }
+    else {
+      float zdepth = 0;
+      if (rv3d) {
+        if (rv3d->is_persp) {
+          zdepth = ED_view3d_calc_zfac(rv3d, object->obmat[3], NULL);
         }
+        else {
+          zdepth = -dot_v3v3(rv3d->viewinv[2], object->obmat[3]);
+        }
+        ObjectZ obz = {zdepth * -1.0f, object};
+        ob_list_.push_back(obz);
       }
     }
 
diff --git a/source/blender/io/gpencil/intern/gpencil_io_capi.cc b/source/blender/io/gpencil/intern/gpencil_io_capi.cc
index 77572d9156c..b0574baf6d5 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_capi.cc
+++ b/source/blender/io/gpencil/intern/gpencil_io_capi.cc
@@ -222,6 +222,7 @@ bool gpencil_io_export(GpencilExportParams *iparams)
     float no_offset[2] = {0.0f, 0.0f};
     float ratio[2] = {1.0f, 1.0f};
     writter.set_frame_ratio(ratio);
+    iparams->file_subfix[0] = '\0';
     done |= gpencil_io_export_frame(&writter, iparams, no_offset, true, true, true);
   }
   else {
diff --git a/source/blender/io/gpencil/intern/gpencil_io_svg.cc b/source/blender/io/gpencil/intern/gpencil_io_svg.cc
index 915084e74e8..fa67c6c712d 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_svg.cc
+++ b/source/blender/io/gpencil/intern/gpencil_io_svg.cc
@@ -187,7 +187,8 @@ void GpencilExporterSVG::export_layers(void)
         continue;
       }
       gpl_current_set(gpl);
-      bGPDframe *gpf = BKE_gpencil_layer_frame_get(gpl, cfra_, GP_GETFRAME_USE_PREV);
+
+      bGPDframe *gpf = gpl->actframe;
       if ((gpf == NULL) || (gpf->strokes.first == NULL)) {
         continue;
       }



More information about the Bf-blender-cvs mailing list