~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to source/blender/blenkernel/intern/idcode.c

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2012-07-23 08:54:18 UTC
  • mfrom: (14.2.16 sid)
  • mto: (14.2.19 sid)
  • mto: This revision was merged to the branch mainline in revision 42.
  • Revision ID: package-import@ubuntu.com-20120723085418-9foz30v6afaf5ffs
Tags: 2.63a-2
* debian/: Cycles support added (Closes: #658075)
  For now, this top feature has been enabled only
  on [any-amd64 any-i386] architectures because
  of OpenImageIO failing on all others
* debian/: scripts installation path changed
  from /usr/lib to /usr/share:
  + debian/patches/: patchset re-worked for path changing
  + debian/control: "Breaks" field added on yafaray-exporter

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
 
19
 * All rights reserved.
 
20
 *
 
21
 * The Original Code is: all of this file.
 
22
 *
 
23
 * Contributor(s): none yet.
 
24
 *
 
25
 * ***** END GPL LICENSE BLOCK *****
 
26
 * return info about ID types
 
27
 */
 
28
 
 
29
/** \file blender/blenkernel/intern/idcode.c
 
30
 *  \ingroup bke
 
31
 */
 
32
 
 
33
 
 
34
#include <stdlib.h>
 
35
#include <string.h>
 
36
 
 
37
#include "DNA_ID.h"
 
38
 
 
39
#include "BKE_idcode.h"
 
40
 
 
41
typedef struct {
 
42
        unsigned short code;
 
43
        const char *name, *plural;
 
44
        
 
45
        int flags;
 
46
#define IDTYPE_FLAGS_ISLINKABLE (1<<0)
 
47
} IDType;
 
48
 
 
49
/* plural need to match rna_main.c's MainCollectionDef */
 
50
static IDType idtypes[]= {
 
51
        { ID_AC,                "Action",       "actions",              IDTYPE_FLAGS_ISLINKABLE}, 
 
52
        { ID_AR,                "Armature", "armatures",        IDTYPE_FLAGS_ISLINKABLE}, 
 
53
        { ID_BR,                "Brush",        "brushes",              IDTYPE_FLAGS_ISLINKABLE}, 
 
54
        { ID_CA,                "Camera",       "cameras",              IDTYPE_FLAGS_ISLINKABLE}, 
 
55
        { ID_CU,                "Curve",        "curves",               IDTYPE_FLAGS_ISLINKABLE}, 
 
56
        { ID_GD,                "GPencil",      "grease_pencil",IDTYPE_FLAGS_ISLINKABLE},  /* rename gpencil */
 
57
        { ID_GR,                "Group",        "groups",               IDTYPE_FLAGS_ISLINKABLE}, 
 
58
        { ID_ID,                "ID",           "ids",                  0}, /* plural is fake */
 
59
        { ID_IM,                "Image",        "images",               IDTYPE_FLAGS_ISLINKABLE}, 
 
60
        { ID_IP,                "Ipo",          "ipos",                 IDTYPE_FLAGS_ISLINKABLE},  /* deprecated */
 
61
        { ID_KE,                "Key",          "shape_keys",   0}, 
 
62
        { ID_LA,                "Lamp",         "lamps",                IDTYPE_FLAGS_ISLINKABLE}, 
 
63
        { ID_LI,                "Library",      "libraries",    0}, 
 
64
        { ID_LT,                "Lattice",      "lattices",             IDTYPE_FLAGS_ISLINKABLE}, 
 
65
        { ID_MA,                "Material", "materials",        IDTYPE_FLAGS_ISLINKABLE}, 
 
66
        { ID_MB,                "Metaball", "metaballs",        IDTYPE_FLAGS_ISLINKABLE}, 
 
67
        { ID_ME,                "Mesh",         "meshes",               IDTYPE_FLAGS_ISLINKABLE}, 
 
68
        { ID_NT,                "NodeTree",     "node_groups",  IDTYPE_FLAGS_ISLINKABLE}, 
 
69
        { ID_OB,                "Object",       "objects",              IDTYPE_FLAGS_ISLINKABLE}, 
 
70
        { ID_PA,                "ParticleSettings",     "particles", 0},
 
71
        { ID_SCE,               "Scene",        "scenes",               IDTYPE_FLAGS_ISLINKABLE}, 
 
72
        { ID_SCR,               "Screen",       "screens",              0}, 
 
73
        { ID_SEQ,               "Sequence",     "sequences",    0}, /* not actually ID data */
 
74
        { ID_SPK,               "Speaker",      "speakers",             IDTYPE_FLAGS_ISLINKABLE},
 
75
        { ID_SO,                "Sound",        "sounds",               IDTYPE_FLAGS_ISLINKABLE},
 
76
        { ID_TE,                "Texture",      "textures",             IDTYPE_FLAGS_ISLINKABLE}, 
 
77
        { ID_TXT,               "Text",         "texts",                IDTYPE_FLAGS_ISLINKABLE}, 
 
78
        { ID_VF,                "VFont",        "fonts",                IDTYPE_FLAGS_ISLINKABLE}, 
 
79
        { ID_WO,                "World",        "worlds",               IDTYPE_FLAGS_ISLINKABLE}, 
 
80
        { ID_WM,                "WindowManager", "window_managers",     0}, 
 
81
        { ID_MC,                "MovieClip", "movieclips",      IDTYPE_FLAGS_ISLINKABLE},
 
82
};
 
83
static int nidtypes= sizeof(idtypes)/sizeof(idtypes[0]);
 
84
 
 
85
static IDType *idtype_from_name(const char *str) 
 
86
{
 
87
        int i= nidtypes;
 
88
        
 
89
        while (i--)
 
90
                if (strcmp(str, idtypes[i].name)==0)
 
91
                        return &idtypes[i];
 
92
 
 
93
        return NULL;
 
94
}
 
95
static IDType *idtype_from_code(int code) 
 
96
{
 
97
        int i= nidtypes;
 
98
        
 
99
        while (i--)
 
100
                if (code==idtypes[i].code)
 
101
                        return &idtypes[i];
 
102
        
 
103
        return NULL;
 
104
}
 
105
 
 
106
int BKE_idcode_is_valid(int code) 
 
107
{
 
108
        return idtype_from_code(code)?1:0;
 
109
}
 
110
 
 
111
int BKE_idcode_is_linkable(int code)
 
112
{
 
113
        IDType *idt= idtype_from_code(code);
 
114
        return idt?(idt->flags&IDTYPE_FLAGS_ISLINKABLE):0;
 
115
}
 
116
 
 
117
const char *BKE_idcode_to_name(int code) 
 
118
{
 
119
        IDType *idt= idtype_from_code(code);
 
120
        
 
121
        return idt?idt->name:NULL;
 
122
}
 
123
 
 
124
int BKE_idcode_from_name(const char *name) 
 
125
{
 
126
        IDType *idt= idtype_from_name(name);
 
127
        
 
128
        return idt?idt->code:0;
 
129
}
 
130
 
 
131
const char *BKE_idcode_to_name_plural(int code) 
 
132
{
 
133
        IDType *idt= idtype_from_code(code);
 
134
        
 
135
        return idt?idt->plural:NULL;
 
136
}
 
137
 
 
138
int BKE_idcode_iter_step(int *index)
 
139
{
 
140
        return (*index < nidtypes) ? idtypes[(*index)++].code : 0;
 
141
}