Blender V2.61 - r43446
|
00001 /* 00002 * ***** BEGIN GPL LICENSE BLOCK ***** 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software Foundation, 00016 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 * 00018 * Contributor(s): Blender Foundation (2008). 00019 * 00020 * ***** END GPL LICENSE BLOCK ***** 00021 */ 00022 00028 #include <stdlib.h> 00029 #include <string.h> 00030 00031 #include "RNA_define.h" 00032 00033 #include "rna_internal.h" 00034 00035 #include "BKE_utildefines.h" 00036 00037 #ifdef RNA_RUNTIME 00038 00039 #include "BKE_main.h" 00040 #include "BKE_mesh.h" 00041 #include "BKE_global.h" 00042 00043 /* all the list begin functions are added manually here, Main is not in SDNA */ 00044 00045 static int rna_Main_is_saved_get(PointerRNA *UNUSED(ptr)) 00046 { 00047 return G.relbase_valid; 00048 } 00049 00050 static int rna_Main_is_dirty_get(PointerRNA *ptr) 00051 { 00052 /* XXX, not totally nice to do it this way, should store in main ? */ 00053 Main *bmain= (Main*)ptr->data; 00054 wmWindowManager *wm; 00055 for(wm= bmain->wm.first; wm; wm= wm->id.next) { 00056 return !wm->file_saved; 00057 } 00058 00059 return TRUE; 00060 } 00061 00062 static void rna_Main_filepath_get(PointerRNA *ptr, char *value) 00063 { 00064 Main *bmain= (Main*)ptr->data; 00065 BLI_strncpy(value, bmain->name, sizeof(bmain->name)); 00066 } 00067 00068 static int rna_Main_filepath_length(PointerRNA *ptr) 00069 { 00070 Main *bmain= (Main*)ptr->data; 00071 return strlen(bmain->name); 00072 } 00073 00074 #if 0 00075 static void rna_Main_filepath_set(PointerRNA *ptr, const char *value) 00076 { 00077 Main *bmain= (Main*)ptr->data; 00078 BLI_strncpy(bmain->name, value, sizeof(bmain->name)); 00079 } 00080 #endif 00081 00082 static void rna_Main_scene_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) 00083 { 00084 Main *bmain= (Main*)ptr->data; 00085 rna_iterator_listbase_begin(iter, &bmain->scene, NULL); 00086 } 00087 00088 static void rna_Main_object_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) 00089 { 00090 Main *bmain= (Main*)ptr->data; 00091 rna_iterator_listbase_begin(iter, &bmain->object, NULL); 00092 } 00093 00094 static void rna_Main_lamp_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) 00095 { 00096 Main *bmain= (Main*)ptr->data; 00097 rna_iterator_listbase_begin(iter, &bmain->lamp, NULL); 00098 } 00099 00100 static void rna_Main_library_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) 00101 { 00102 Main *bmain= (Main*)ptr->data; 00103 rna_iterator_listbase_begin(iter, &bmain->library, NULL); 00104 } 00105 00106 static void rna_Main_mesh_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) 00107 { 00108 Main *bmain= (Main*)ptr->data; 00109 rna_iterator_listbase_begin(iter, &bmain->mesh, NULL); 00110 } 00111 00112 static void rna_Main_curve_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) 00113 { 00114 Main *bmain= (Main*)ptr->data; 00115 rna_iterator_listbase_begin(iter, &bmain->curve, NULL); 00116 } 00117 00118 static void rna_Main_mball_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) 00119 { 00120 Main *bmain= (Main*)ptr->data; 00121 rna_iterator_listbase_begin(iter, &bmain->mball, NULL); 00122 } 00123 00124 static void rna_Main_mat_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) 00125 { 00126 Main *bmain= (Main*)ptr->data; 00127 rna_iterator_listbase_begin(iter, &bmain->mat, NULL); 00128 } 00129 00130 static void rna_Main_tex_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) 00131 { 00132 Main *bmain= (Main*)ptr->data; 00133 rna_iterator_listbase_begin(iter, &bmain->tex, NULL); 00134 } 00135 00136 static void rna_Main_image_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) 00137 { 00138 Main *bmain= (Main*)ptr->data; 00139 rna_iterator_listbase_begin(iter, &bmain->image, NULL); 00140 } 00141 00142 static void rna_Main_latt_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) 00143 { 00144 Main *bmain= (Main*)ptr->data; 00145 rna_iterator_listbase_begin(iter, &bmain->latt, NULL); 00146 } 00147 00148 static void rna_Main_camera_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) 00149 { 00150 Main *bmain= (Main*)ptr->data; 00151 rna_iterator_listbase_begin(iter, &bmain->camera, NULL); 00152 } 00153 00154 static void rna_Main_key_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) 00155 { 00156 Main *bmain= (Main*)ptr->data; 00157 rna_iterator_listbase_begin(iter, &bmain->key, NULL); 00158 } 00159 00160 static void rna_Main_world_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) 00161 { 00162 Main *bmain= (Main*)ptr->data; 00163 rna_iterator_listbase_begin(iter, &bmain->world, NULL); 00164 } 00165 00166 static void rna_Main_screen_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) 00167 { 00168 Main *bmain= (Main*)ptr->data; 00169 rna_iterator_listbase_begin(iter, &bmain->screen, NULL); 00170 } 00171 00172 static void rna_Main_script_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) 00173 { 00174 Main *bmain= (Main*)ptr->data; 00175 rna_iterator_listbase_begin(iter, &bmain->script, NULL); 00176 } 00177 00178 static void rna_Main_font_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) 00179 { 00180 Main *bmain= (Main*)ptr->data; 00181 rna_iterator_listbase_begin(iter, &bmain->vfont, NULL); 00182 } 00183 00184 static void rna_Main_text_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) 00185 { 00186 Main *bmain= (Main*)ptr->data; 00187 rna_iterator_listbase_begin(iter, &bmain->text, NULL); 00188 } 00189 00190 static void rna_Main_speaker_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) 00191 { 00192 Main *bmain= (Main*)ptr->data; 00193 rna_iterator_listbase_begin(iter, &bmain->speaker, NULL); 00194 } 00195 00196 static void rna_Main_sound_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) 00197 { 00198 Main *bmain= (Main*)ptr->data; 00199 rna_iterator_listbase_begin(iter, &bmain->sound, NULL); 00200 } 00201 00202 static void rna_Main_group_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) 00203 { 00204 Main *bmain= (Main*)ptr->data; 00205 rna_iterator_listbase_begin(iter, &bmain->group, NULL); 00206 } 00207 00208 static void rna_Main_armature_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) 00209 { 00210 Main *bmain= (Main*)ptr->data; 00211 rna_iterator_listbase_begin(iter, &bmain->armature, NULL); 00212 } 00213 00214 static void rna_Main_action_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) 00215 { 00216 Main *bmain= (Main*)ptr->data; 00217 rna_iterator_listbase_begin(iter, &bmain->action, NULL); 00218 } 00219 00220 static void rna_Main_nodetree_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) 00221 { 00222 Main *bmain= (Main*)ptr->data; 00223 rna_iterator_listbase_begin(iter, &bmain->nodetree, NULL); 00224 } 00225 00226 static void rna_Main_brush_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) 00227 { 00228 Main *bmain= (Main*)ptr->data; 00229 rna_iterator_listbase_begin(iter, &bmain->brush, NULL); 00230 } 00231 00232 static void rna_Main_particle_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) 00233 { 00234 Main *bmain= (Main*)ptr->data; 00235 rna_iterator_listbase_begin(iter, &bmain->particle, NULL); 00236 } 00237 00238 static void rna_Main_gpencil_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) 00239 { 00240 Main *bmain= (Main*)ptr->data; 00241 rna_iterator_listbase_begin(iter, &bmain->gpencil, NULL); 00242 } 00243 00244 static void rna_Main_wm_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) 00245 { 00246 Main *bmain= (Main*)ptr->data; 00247 rna_iterator_listbase_begin(iter, &bmain->wm, NULL); 00248 } 00249 00250 static void rna_Main_movieclips_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) 00251 { 00252 Main *bmain= (Main*)ptr->data; 00253 rna_iterator_listbase_begin(iter, &bmain->movieclip, NULL); 00254 } 00255 00256 #ifdef UNIT_TEST 00257 00258 static PointerRNA rna_Test_test_get(PointerRNA *ptr) 00259 { 00260 PointerRNA ret= *ptr; 00261 ret.type= &RNA_Test; 00262 00263 return ret; 00264 } 00265 00266 #endif 00267 00268 #else 00269 00270 /* local convenience types */ 00271 typedef void (CollectionDefFunc)(struct BlenderRNA *brna, struct PropertyRNA *cprop); 00272 00273 typedef struct MainCollectionDef { 00274 const char *identifier; 00275 const char *type; 00276 const char *iter_begin; 00277 const char *name; 00278 const char *description; 00279 CollectionDefFunc *func; 00280 } MainCollectionDef; 00281 00282 void RNA_def_main(BlenderRNA *brna) 00283 { 00284 StructRNA *srna; 00285 PropertyRNA *prop; 00286 CollectionDefFunc *func; 00287 00288 /* plural must match idtypes in readblenentry.c */ 00289 MainCollectionDef lists[]= { 00290 {"cameras", "Camera", "rna_Main_camera_begin", "Cameras", "Camera datablocks", RNA_def_main_cameras}, 00291 {"scenes", "Scene", "rna_Main_scene_begin", "Scenes", "Scene datablocks", RNA_def_main_scenes}, 00292 {"objects", "Object", "rna_Main_object_begin", "Objects", "Object datablocks", RNA_def_main_objects}, 00293 {"materials", "Material", "rna_Main_mat_begin", "Materials", "Material datablocks", RNA_def_main_materials}, 00294 {"node_groups", "NodeTree", "rna_Main_nodetree_begin", "Node Groups", "Node group datablocks", RNA_def_main_node_groups}, 00295 {"meshes", "Mesh", "rna_Main_mesh_begin", "Meshes", "Mesh datablocks", RNA_def_main_meshes}, 00296 {"lamps", "Lamp", "rna_Main_lamp_begin", "Lamps", "Lamp datablocks", RNA_def_main_lamps}, 00297 {"libraries", "Library", "rna_Main_library_begin", "Libraries", "Library datablocks", RNA_def_main_libraries}, 00298 {"screens", "Screen", "rna_Main_screen_begin", "Screens", "Screen datablocks", RNA_def_main_screens}, 00299 {"window_managers", "WindowManager", "rna_Main_wm_begin", "Window Managers", "Window manager datablocks", RNA_def_main_window_managers}, 00300 {"images", "Image", "rna_Main_image_begin", "Images", "Image datablocks", RNA_def_main_images}, 00301 {"lattices", "Lattice", "rna_Main_latt_begin", "Lattices", "Lattice datablocks", RNA_def_main_lattices}, 00302 {"curves", "Curve", "rna_Main_curve_begin", "Curves", "Curve datablocks", RNA_def_main_curves} , 00303 {"metaballs", "MetaBall", "rna_Main_mball_begin", "Metaballs", "Metaball datablocks", RNA_def_main_metaballs}, 00304 {"fonts", "VectorFont", "rna_Main_font_begin", "Vector Fonts", "Vector font datablocks", RNA_def_main_fonts}, 00305 {"textures", "Texture", "rna_Main_tex_begin", "Textures", "Texture datablocks", RNA_def_main_textures}, 00306 {"brushes", "Brush", "rna_Main_brush_begin", "Brushes", "Brush datablocks", RNA_def_main_brushes}, 00307 {"worlds", "World", "rna_Main_world_begin", "Worlds", "World datablocks", RNA_def_main_worlds}, 00308 {"groups", "Group", "rna_Main_group_begin", "Groups", "Group datablocks", RNA_def_main_groups}, 00309 {"shape_keys", "Key", "rna_Main_key_begin", "Shape Keys", "Shape Key datablocks", NULL}, 00310 {"scripts", "ID", "rna_Main_script_begin", "Scripts", "Script datablocks (DEPRECATED)", NULL}, 00311 {"texts", "Text", "rna_Main_text_begin", "Texts", "Text datablocks", RNA_def_main_texts}, 00312 {"speakers", "Speaker", "rna_Main_speaker_begin", "Speakers", "Speaker datablocks", RNA_def_main_speakers}, 00313 {"sounds", "Sound", "rna_Main_sound_begin", "Sounds", "Sound datablocks", RNA_def_main_sounds}, 00314 {"armatures", "Armature", "rna_Main_armature_begin", "Armatures", "Armature datablocks", RNA_def_main_armatures}, 00315 {"actions", "Action", "rna_Main_action_begin", "Actions", "Action datablocks", RNA_def_main_actions}, 00316 {"particles", "ParticleSettings", "rna_Main_particle_begin", "Particles", "Particle datablocks", RNA_def_main_particles}, 00317 {"grease_pencil", "GreasePencil", "rna_Main_gpencil_begin", "Grease Pencil", "Grease Pencil datablocks", RNA_def_main_gpencil}, 00318 {"movieclips", "MovieClip", "rna_Main_movieclips_begin", "Movie Clips", "Movie Clip datablocks", RNA_def_main_movieclips}, 00319 {NULL, NULL, NULL, NULL, NULL, NULL}}; 00320 00321 int i; 00322 00323 srna= RNA_def_struct(brna, "BlendData", NULL); 00324 RNA_def_struct_ui_text(srna, "Blendfile Data", "Main data structure representing a .blend file and all its datablocks"); 00325 RNA_def_struct_ui_icon(srna, ICON_BLENDER); 00326 00327 prop= RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH); 00328 RNA_def_property_string_maxlength(prop, FILE_MAX); 00329 RNA_def_property_string_funcs(prop, "rna_Main_filepath_get", "rna_Main_filepath_length", "rna_Main_filepath_set"); 00330 RNA_def_property_clear_flag(prop, PROP_EDITABLE); 00331 RNA_def_property_ui_text(prop, "Filename", "Path to the .blend file"); 00332 00333 prop= RNA_def_property(srna, "is_dirty", PROP_BOOLEAN, PROP_NONE); 00334 RNA_def_property_clear_flag(prop, PROP_EDITABLE); 00335 RNA_def_property_boolean_funcs(prop, "rna_Main_is_dirty_get", NULL); 00336 RNA_def_property_ui_text(prop, "File Has Unsaved Changes", "Have recent edits been saved to disk"); 00337 00338 prop= RNA_def_property(srna, "is_saved", PROP_BOOLEAN, PROP_NONE); 00339 RNA_def_property_clear_flag(prop, PROP_EDITABLE); 00340 RNA_def_property_boolean_funcs(prop, "rna_Main_is_saved_get", NULL); 00341 RNA_def_property_ui_text(prop, "File is Saved", "Has the current session been saved to disk as a .blend file"); 00342 00343 for(i=0; lists[i].name; i++) 00344 { 00345 prop= RNA_def_property(srna, lists[i].identifier, PROP_COLLECTION, PROP_NONE); 00346 RNA_def_property_struct_type(prop, lists[i].type); 00347 RNA_def_property_collection_funcs(prop, lists[i].iter_begin, "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", NULL, NULL, NULL, NULL); 00348 RNA_def_property_ui_text(prop, lists[i].name, lists[i].description); 00349 00350 /* collection functions */ 00351 func= lists[i].func; 00352 if(func) 00353 func(brna, prop); 00354 } 00355 00356 RNA_api_main(srna); 00357 00358 #ifdef UNIT_TEST 00359 00360 RNA_define_verify_sdna(0); 00361 00362 prop= RNA_def_property(srna, "test", PROP_POINTER, PROP_NONE); 00363 RNA_def_property_struct_type(prop, "Test"); 00364 RNA_def_property_pointer_funcs(prop, "rna_Test_test_get", NULL, NULL, NULL); 00365 00366 RNA_define_verify_sdna(1); 00367 00368 #endif 00369 } 00370 00371 #endif 00372