Fix (unreported) some RNA func definitions setting flags of other func parameters!
[blender.git] / source / blender / makesrna / intern / rna_depsgraph.c
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * Contributor(s): Blender Foundation (2014).
19  *
20  * ***** END GPL LICENSE BLOCK *****
21  */
22
23 /** \file blender/makesrna/intern/rna_depsgraph.c
24  *  \ingroup RNA
25  */
26
27 #include <stdlib.h>
28
29 #include "BLI_utildefines.h"
30 #include "BLI_path_util.h"
31
32 #include "RNA_define.h"
33 #include "RNA_enum_types.h"
34
35 #include "rna_internal.h"
36
37 #include "DEG_depsgraph.h"
38
39 #include "BKE_depsgraph.h"
40
41 #ifdef RNA_RUNTIME
42
43 #include "BKE_report.h"
44
45 #include "DEG_depsgraph_debug.h"
46
47 static void rna_Depsgraph_debug_graphviz(Depsgraph *graph, const char *filename)
48 {
49         FILE *f = fopen(filename, "w");
50         if (f == NULL)
51                 return;
52         
53         DEG_debug_graphviz(graph, f, "Depsgraph", false);
54         
55         fclose(f);
56 }
57
58 static void rna_Depsgraph_debug_rebuild(Depsgraph *UNUSED(graph), Main *bmain)
59 {
60         Scene *sce;
61         DAG_relations_tag_update(bmain);
62         for (sce = bmain->scene.first; sce; sce = sce->id.next) {
63                 DAG_scene_relations_rebuild(bmain, sce);
64                 DEG_graph_on_visible_update(bmain, sce);
65         }
66 }
67
68 static void rna_Depsgraph_debug_stats(Depsgraph *graph, ReportList *reports)
69 {
70         size_t outer, ops, rels;
71         
72         DEG_stats_simple(graph, &outer, &ops, &rels);
73         
74         // XXX: report doesn't seem to work
75         printf("Approx %lu Operations, %lu Relations, %lu Outer Nodes\n",
76                ops, rels, outer);
77                    
78         BKE_reportf(reports, RPT_WARNING, "Approx. %lu Operations, %lu Relations, %lu Outer Nodes",
79                     ops, rels, outer);
80 }
81
82 #else
83
84 static void rna_def_depsgraph(BlenderRNA *brna)
85 {
86         StructRNA *srna;
87         FunctionRNA *func;
88         PropertyRNA *parm;
89
90         srna = RNA_def_struct(brna, "Depsgraph", NULL);
91         RNA_def_struct_ui_text(srna, "Dependency Graph", "");
92         
93         func = RNA_def_function(srna, "debug_graphviz", "rna_Depsgraph_debug_graphviz");
94         parm = RNA_def_string_file_path(func, "filename", NULL, FILE_MAX, "File Name",
95                                         "File in which to store graphviz debug output");
96         RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
97
98         func = RNA_def_function(srna, "debug_rebuild", "rna_Depsgraph_debug_rebuild");
99         RNA_def_function_flag(func, FUNC_USE_MAIN);
100
101         func = RNA_def_function(srna, "debug_stats", "rna_Depsgraph_debug_stats");
102         RNA_def_function_ui_description(func, "Report the number of elements in the Dependency Graph");
103         RNA_def_function_flag(func, FUNC_USE_REPORTS);
104 }
105
106 void RNA_def_depsgraph(BlenderRNA *brna)
107 {
108         rna_def_depsgraph(brna);
109 }
110
111 #endif