Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_info/info_stats.c
| Context not available. | |||||
| #include "ED_armature.h" | #include "ED_armature.h" | ||||
| #define MAX_INFO_LEN 512 | #define MAX_INFO_LEN 512 | ||||
| #define MAX_NUM_LEN 30 | |||||
| typedef struct SceneStats { | typedef struct SceneStats { | ||||
| int totvert, totvertsel; | int totvert, totvertsel; | ||||
| Context not available. | |||||
| char infostr[MAX_INFO_LEN]; | char infostr[MAX_INFO_LEN]; | ||||
| } SceneStats; | } SceneStats; | ||||
| typedef struct FormattedStats { | |||||
| /* Totals */ | |||||
| char totvert[MAX_NUM_LEN]; | |||||
| char totface[MAX_NUM_LEN]; | |||||
| char tottri[MAX_NUM_LEN]; | |||||
| char totedge[MAX_NUM_LEN]; | |||||
| char totbone[MAX_NUM_LEN]; | |||||
| char totobj[MAX_NUM_LEN]; | |||||
| char totlamp[MAX_NUM_LEN]; | |||||
| /* Selected Totals */ | |||||
| char totvertsel[MAX_NUM_LEN]; | |||||
| char totfacesel[MAX_NUM_LEN]; | |||||
| char totedgesel[MAX_NUM_LEN]; | |||||
| char totbonesel[MAX_NUM_LEN]; | |||||
| char totobjsel[MAX_NUM_LEN]; | |||||
| char totlampsel[MAX_NUM_LEN]; | |||||
| } FormattedStats; | |||||
| static void stats_object(Object *ob, int sel, int totob, SceneStats *stats) | static void stats_object(Object *ob, int sel, int totob, SceneStats *stats) | ||||
| { | { | ||||
| switch (ob->type) { | switch (ob->type) { | ||||
| Context not available. | |||||
| static void stats_string(Scene *scene) | static void stats_string(Scene *scene) | ||||
| { | { | ||||
| #define MAX_INFO_MEM_LEN 64 | #define MAX_INFO_MEM_LEN 64 | ||||
| SceneStats *stats = scene->stats; | SceneStats *stats = scene->stats; | ||||
| FormattedStats nice_stats = {0}; | |||||
| Object *ob = (scene->basact) ? scene->basact->object : NULL; | Object *ob = (scene->basact) ? scene->basact->object : NULL; | ||||
| uintptr_t mem_in_use, mmap_in_use; | uintptr_t mem_in_use, mmap_in_use; | ||||
| char memstr[MAX_INFO_MEM_LEN]; | char memstr[MAX_INFO_MEM_LEN]; | ||||
| Context not available. | |||||
| mem_in_use = MEM_get_memory_in_use(); | mem_in_use = MEM_get_memory_in_use(); | ||||
| mmap_in_use = MEM_get_mapped_memory_in_use(); | mmap_in_use = MEM_get_mapped_memory_in_use(); | ||||
| /* Generate formatted numbers*/ | |||||
| BLI_str_number_separator(stats->totvert, nice_stats.totvert, MAX_NUM_LEN ); | |||||
| BLI_str_number_separator(stats->totface, nice_stats.totface, MAX_NUM_LEN); | |||||
| BLI_str_number_separator(stats->tottri, nice_stats.tottri, MAX_NUM_LEN); | |||||
| BLI_str_number_separator(stats->totedge, nice_stats.totedge, MAX_NUM_LEN); | |||||
| BLI_str_number_separator(stats->totlamp, nice_stats.totlamp, MAX_NUM_LEN); | |||||
| BLI_str_number_separator(stats->totobj, nice_stats.totobj, MAX_NUM_LEN); | |||||
| BLI_str_number_separator(stats->totbone, nice_stats.totbone, MAX_NUM_LEN); | |||||
| BLI_str_number_separator(stats->totvertsel, nice_stats.totvertsel, MAX_NUM_LEN ); | |||||
| BLI_str_number_separator(stats->totfacesel, nice_stats.totfacesel, MAX_NUM_LEN); | |||||
| BLI_str_number_separator(stats->totedgesel, nice_stats.totedgesel, MAX_NUM_LEN); | |||||
| BLI_str_number_separator(stats->totlampsel, nice_stats.totlampsel, MAX_NUM_LEN); | |||||
| BLI_str_number_separator(stats->totobjsel, nice_stats.totobjsel, MAX_NUM_LEN); | |||||
| BLI_str_number_separator(stats->totbonesel, nice_stats.totbonesel, MAX_NUM_LEN); | |||||
| /* get memory statistics */ | /* get memory statistics */ | ||||
| s = memstr; | s = memstr; | ||||
| ofs += BLI_snprintf(s + ofs, MAX_INFO_MEM_LEN - ofs, IFACE_(" | Mem:%.2fM"), | ofs += BLI_snprintf(s + ofs, MAX_INFO_MEM_LEN - ofs, IFACE_(" | Mem:%.2fM"), | ||||
| Context not available. | |||||
| if (scene->obedit->type == OB_MESH) { | if (scene->obedit->type == OB_MESH) { | ||||
| ofs += BLI_snprintf(s + ofs, MAX_INFO_LEN - ofs, | ofs += BLI_snprintf(s + ofs, MAX_INFO_LEN - ofs, | ||||
| IFACE_("Verts:%d/%d | Edges:%d/%d | Faces:%d/%d | Tris:%d"), | IFACE_("Verts:%s/%s | Edges:%s/%s | Faces:%s/%s | Tris:%s"), | ||||
| stats->totvertsel, stats->totvert, stats->totedgesel, stats->totedge, | nice_stats.totvertsel, nice_stats.totvert, nice_stats.totedgesel, nice_stats.totedge, | ||||
| stats->totfacesel, stats->totface, stats->tottri); | nice_stats.totfacesel, nice_stats.totface, nice_stats.tottri); | ||||
| } | } | ||||
| else if (scene->obedit->type == OB_ARMATURE) { | else if (scene->obedit->type == OB_ARMATURE) { | ||||
| ofs += BLI_snprintf(s + ofs, MAX_INFO_LEN - ofs, IFACE_("Verts:%d/%d | Bones:%d/%d"), stats->totvertsel, | ofs += BLI_snprintf(s + ofs, MAX_INFO_LEN - ofs, IFACE_("Verts:%s/%s | Bones:%s/%s"), nice_stats.totvertsel, | ||||
| stats->totvert, stats->totbonesel, stats->totbone); | nice_stats.totvert, nice_stats.totbonesel, nice_stats.totbone); | ||||
| } | } | ||||
| else { | else { | ||||
| ofs += BLI_snprintf(s + ofs, MAX_INFO_LEN - ofs, IFACE_("Verts:%d/%d"), stats->totvertsel, stats->totvert); | ofs += BLI_snprintf(s + ofs, MAX_INFO_LEN - ofs, IFACE_("Verts:%s/%s"), nice_stats.totvertsel, | ||||
| nice_stats.totvert); | |||||
| } | } | ||||
| ofs += BLI_strncpy_rlen(s + ofs, memstr, MAX_INFO_LEN - ofs); | ofs += BLI_strncpy_rlen(s + ofs, memstr, MAX_INFO_LEN - ofs); | ||||
| } | } | ||||
| else if (ob && (ob->mode & OB_MODE_POSE)) { | else if (ob && (ob->mode & OB_MODE_POSE)) { | ||||
| ofs += BLI_snprintf(s + ofs, MAX_INFO_LEN - ofs, IFACE_("Bones:%d/%d %s"), | ofs += BLI_snprintf(s + ofs, MAX_INFO_LEN - ofs, IFACE_("Bones:%s/%s %s"), | ||||
| stats->totbonesel, stats->totbone, memstr); | nice_stats.totbonesel, nice_stats.totbone, memstr); | ||||
| } | } | ||||
| else if (stats_is_object_dynamic_topology_sculpt(ob)) { | else if (stats_is_object_dynamic_topology_sculpt(ob)) { | ||||
| ofs += BLI_snprintf(s + ofs, MAX_INFO_LEN - ofs, IFACE_("Verts:%d | Tris:%d"), stats->totvert, stats->tottri); | ofs += BLI_snprintf(s + ofs, MAX_INFO_LEN - ofs, IFACE_("Verts:%s | Tris:%s"), nice_stats.totvert, | ||||
| nice_stats.tottri); | |||||
| } | } | ||||
| else { | else { | ||||
| ofs += BLI_snprintf(s + ofs, MAX_INFO_LEN - ofs, | ofs += BLI_snprintf(s + ofs, MAX_INFO_LEN - ofs, | ||||
| IFACE_("Verts:%d | Faces:%d | Tris:%d | Objects:%d/%d | Lamps:%d/%d%s"), stats->totvert, | IFACE_("Verts: %s | Faces:%s | Tris:%s | Objects:%s/%s | Lamps:%s/%s%s"), | ||||
| stats->totface, stats->tottri, stats->totobjsel, stats->totobj, stats->totlampsel, | nice_stats.totvert, nice_stats.totface, | ||||
| stats->totlamp, memstr); | nice_stats.tottri, nice_stats.totobjsel, | ||||
| nice_stats.totobj, nice_stats.totlampsel, | |||||
| nice_stats.totlamp, memstr); | |||||
| } | } | ||||
| if (ob) | if (ob) | ||||
| Context not available. | |||||