From 7e944b1b2ccd1bf63b293f90c8a8269fe65d765c Mon Sep 17 00:00:00 2001 From: Pratik Borhade Date: Thu, 21 Sep 2023 12:42:40 +0200 Subject: [PATCH] GPv3: Add statistics information Like legacy Grease pencil, display strokes, points, frames information for new grease pencil object Pull Request: https://projects.blender.org/blender/blender/pulls/112573 --- .../blender/editors/space_info/info_stats.cc | 31 +++++++++++++++++-- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/space_info/info_stats.cc b/source/blender/editors/space_info/info_stats.cc index 1f5d75803f0..ee9b570466a 100644 --- a/source/blender/editors/space_info/info_stats.cc +++ b/source/blender/editors/space_info/info_stats.cc @@ -15,6 +15,7 @@ #include "DNA_collection_types.h" #include "DNA_curve_types.h" #include "DNA_gpencil_legacy_types.h" +#include "DNA_grease_pencil_types.h" #include "DNA_lattice_types.h" #include "DNA_mesh_types.h" #include "DNA_meta_types.h" @@ -30,6 +31,7 @@ #include "BLI_string_utf8.h" #include "BLI_timecode.h" #include "BLI_utildefines.h" +#include "BLI_span.hh" #include "BLT_translation.h" @@ -38,9 +40,11 @@ #include "BKE_blender_version.h" #include "BKE_context.h" #include "BKE_curve.h" +#include "BKE_curves.hh" #include "BKE_displist.h" #include "BKE_editmesh.h" #include "BKE_gpencil_legacy.h" +#include "BKE_grease_pencil.hh" #include "BKE_key.h" #include "BKE_layer.h" #include "BKE_main.h" @@ -190,10 +194,31 @@ static void stats_object(Object *ob, } break; } + case OB_GREASE_PENCIL: { + if (!is_selected) { + break; + } + + const GreasePencil *grease_pencil = static_cast(ob->data); + + for (const GreasePencilDrawingBase *drawing_base : grease_pencil->drawings()) { + const GreasePencilDrawing *drawing = reinterpret_cast(drawing_base); + const blender::bke::CurvesGeometry &curves = drawing->wrap().strokes(); + + stats->totgppoint += curves.points_num(); + stats->totgpstroke += curves.curves_num(); + } + + for (const blender::bke::greasepencil::Layer *layer : grease_pencil->layers()) { + stats->totgpframe += layer->frames().size(); + } + + stats->totgplayer += grease_pencil->layers().size(); + break; + } case OB_CURVES: case OB_POINTCLOUD: - case OB_VOLUME: - case OB_GREASE_PENCIL: { + case OB_VOLUME: { break; } } @@ -835,7 +860,7 @@ void ED_info_draw_stats( else if (ob && (object_mode & OB_MODE_POSE)) { stats_row(col1, labels[BONES], col2, stats_fmt.totbonesel, stats_fmt.totbone, y, height); } - else if ((ob) && (ob->type == OB_GPENCIL_LEGACY)) { + else if ((ob) && ELEM(ob->type, OB_GPENCIL_LEGACY, OB_GREASE_PENCIL)) { stats_row(col1, labels[LAYERS], col2, stats_fmt.totgplayer, nullptr, y, height); stats_row(col1, labels[FRAMES], col2, stats_fmt.totgpframe, nullptr, y, height); stats_row(col1, labels[STROKES], col2, stats_fmt.totgpstroke, nullptr, y, height);