Debian Codegraph @

lib/database/src/so/engines/SoEngineInit.c++

raw
1 /*
2 *
3 * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
27 * Mountain View, CA 94043, or:
28 *
29 * http://www.sgi.com
30 *
31 * For further information regarding this notice, see:
32 *
33 * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
34 *
35 */
36
37 /*
38 * Copyright (C) 1990,91,92 Silicon Graphics, Inc.
39 *
40 _______________________________________________________________________
41 ______________ S I L I C O N G R A P H I C S I N C . ____________
42 |
43 | $Revision: 1.1.1.1 $
44 |
45 | Class:
46 | initClass code for all engine classes
47 |
48 | Author(s) : Ronen Barzel, Gavin Bell
49 |
50 ______________ S I L I C O N G R A P H I C S I N C . ____________
51 _______________________________________________________________________
52 */
53
54 #include <Inventor/engines/SoEngines.h>
55 #include <SoUnknownEngine.h>
56 #include "SoFieldConverters.h"
57
58 ////////////////////////////////////////////////////////////////////////
59 //
60 // Description:
61 // This initializes ALL Inventor engine classes.
62 //
63 // Use: internal
64
65 void
66 SoEngine::initClasses()
67 //
68 ////////////////////////////////////////////////////////////////////////
69 {
70 //
71 // base class
72 //
73 SoEngine::initClass();
74
75 //
76 // collections of engines init'd by their own base class method
77 //
78 SoInterpolate::initClasses();
79
80 // Field converters
81 SoFieldConverter::initClass(); // Must come first
82 SoBuiltinFieldConverter::initClass();
83 SoConvToTrigger::initClass();
84
85 //
86 // composers/decomposers
87 //
88 SoComposeMatrix::initClass();
89 SoComposeRotation::initClass();
90 SoComposeRotationFromTo::initClass();
91 SoComposeVec2f::initClass();
92 SoComposeVec3f::initClass();
93 SoComposeVec4f::initClass();
94 SoDecomposeMatrix::initClass();
95 SoDecomposeRotation::initClass();
96 SoDecomposeVec2f::initClass();
97 SoDecomposeVec3f::initClass();
98 SoDecomposeVec4f::initClass();
99
100 // miscellaneous engines
101 SoBoolOperation::initClass();
102 SoCalculator::initClass();
103 SoComputeBoundingBox::initClass();
104 SoConcatenate::initClass();
105 SoCounter::initClass();
106 SoElapsedTime::initClass();
107 SoGate::initClass();
108 SoOnOff::initClass();
109 SoOneShot::initClass();
110 SoSelectOne::initClass();
111 SoTimeCounter::initClass();
112 SoTransformVec3f::initClass();
113 SoTriggerAny::initClass();
114 SoUnknownEngine::initClass();
115 }
116
117 ////////////////////////////////////////////////////////////////////////
118 //
119 // Description:
120 // This initializes the SoBoolOperation class.
121 //
122 // Use: internal
123
124 void
125 SoBoolOperation::initClass()
126 //
127 ////////////////////////////////////////////////////////////////////////
128 {
129 SO__ENGINE_INIT_CLASS(SoBoolOperation, "BoolOperation", SoEngine);
130 }
131
132 ////////////////////////////////////////////////////////////////////////
133 //
134 // Description:
135 // This initializes the SoCalculator class.
136 //
137 // Use: internal
138
139 void
140 SoCalculator::initClass()
141 //
142 ////////////////////////////////////////////////////////////////////////
143 {
144 SO__ENGINE_INIT_CLASS(SoCalculator, "Calculator", SoEngine);
145 }
146
147 //////////////////
148 //
149 // Utility macro defines basic source for composition/decomposition
150 // engines
151 //
152 #define SO_COMPOSE__INIT(Name,String) \
153 void Name::initClass() { \
154 SO__ENGINE_INIT_CLASS(Name,String,SoEngine); \
155 }
156 SO_COMPOSE__INIT(SoComposeVec2f,"ComposeVec2f");
157 SO_COMPOSE__INIT(SoComposeVec3f,"ComposeVec3f");
158 SO_COMPOSE__INIT(SoComposeVec4f,"ComposeVec4f");
159 SO_COMPOSE__INIT(SoDecomposeVec2f,"DecomposeVec2f");
160 SO_COMPOSE__INIT(SoDecomposeVec3f,"DecomposeVec3f");
161 SO_COMPOSE__INIT(SoDecomposeVec4f,"DecomposeVec4f");
162 SO_COMPOSE__INIT(SoComposeRotation,"ComposeRotation");
163 SO_COMPOSE__INIT(SoComposeRotationFromTo,"ComposeRotationFromTo");
164 SO_COMPOSE__INIT(SoDecomposeRotation,"DecomposeRotation");
165 SO_COMPOSE__INIT(SoComposeMatrix,"ComposeMatrix");
166 SO_COMPOSE__INIT(SoDecomposeMatrix,"DecomposeMatrix");
167 #undef SO_COMPOSE__INIT
168
169 ////////////////////////////////////////////////////////////////////////
170 //
171 // Description:
172 // This initializes the SoComputeBoundingBox class.
173 //
174 // Use: internal
175
176 void
177 SoComputeBoundingBox::initClass()
178 //
179 ////////////////////////////////////////////////////////////////////////
180 {
181 SO__ENGINE_INIT_CLASS(SoComputeBoundingBox,
182 "ComputeBoundingBox", SoEngine);
183 }
184
185 ////////////////////////////////////////////////////////////////////////
186 //
187 // Description:
188 // This initializes the SoConcatenate class.
189 //
190 // Use: internal
191
192 void
193 SoConcatenate::initClass()
194 //
195 ////////////////////////////////////////////////////////////////////////
196 {
197 SO__ENGINE_INIT_CLASS(SoConcatenate, "Concatenate",
198 SoEngine);
199 }
200
201 ////////////////////////////////////////////////////////////////////////
202 //
203 // Description:
204 // This initializes the SoCounter class.
205 //
206 // Use: internal
207
208 void
209 SoCounter::initClass()
210 //
211 ////////////////////////////////////////////////////////////////////////
212 {
213 SO__ENGINE_INIT_CLASS(SoCounter, "Counter", SoEngine);
214 }
215
216 ////////////////////////////////////////////////////////////////////////
217 //
218 // Description:
219 // This initializes the SoElapsedTime class.
220 //
221 // Use: internal
222
223 void
224 SoElapsedTime::initClass()
225 //
226 ////////////////////////////////////////////////////////////////////////
227 {
228 SO__ENGINE_INIT_CLASS(SoElapsedTime, "ElapsedTime", SoEngine);
229 }
230
231 ////////////////////////////////////////////////////////////////////////
232 //
233 // Description:
234 // This initializes the base SoEngine class. Called by
235 // SoDB::init().
236 //
237 // Use: internal
238
239 void
240 SoEngine::initClass()
241 //
242 ////////////////////////////////////////////////////////////////////////
243 {
244 // Allocate a new engine type id
245 // No real parent id
246 classTypeId = SoType::createType(SoFieldContainer::getClassTypeId(),
247 SbName("Engine"), 0, 0);
248 }
249
250 ////////////////////////////////////////////////////////////////////////
251 //
252 // Description:
253 // This initializes the SoFieldConverter class.
254 //
255 // Use: internal
256
257 void
258 SoFieldConverter::initClass()
259 //
260 ////////////////////////////////////////////////////////////////////////
261 {
262 SO__ENGINE_INIT_ABSTRACT_CLASS(SoFieldConverter, "FieldConverter",
263 SoEngine);
264 }
265
266 void
267 SoConvToTrigger::initClass()
268 {
269 SO__ENGINE_INIT_CLASS(SoConvToTrigger,"SoConvToTrigger",SoFieldConverter);
270 classTypeId.makeInternal();
271 SoType trigType = SoSFTrigger::getClassTypeId();
272 SoType conv = SoConvToTrigger::getClassTypeId();
273
274 // Any field type can be connected to a trigger, so just register
275 // the converter on all field classes
276 SoTypeList fieldTypes;
277 int numFieldTypes;
278 numFieldTypes = SoType::getAllDerivedFrom(SoField::getClassTypeId(),
279 fieldTypes);
280 for (int i = 0; i < numFieldTypes; i++)
281 if (fieldTypes[i] != trigType)
282 SoDB::addConverter(fieldTypes[i], trigType, conv);
283 }
284
285 ////////////////////////////////////////////////////////////////////////
286 //
287 // Description:
288 // This initializes the SoGate class.
289 //
290 // Use: internal
291
292 void
293 SoGate::initClass()
294 //
295 ////////////////////////////////////////////////////////////////////////
296 {
297 SO__ENGINE_INIT_CLASS(SoGate, "Gate", SoEngine);
298 }
299
300 ////////////////////////////////////////////////////////////////////////
301 //
302 //
303 // Description:
304 // This initializes the SoInterpolate class.
305 //
306 // Use: internal
307
308 void
309 SoInterpolate::initClass()
310 //
311 ////////////////////////////////////////////////////////////////////////
312 {
313 SO__ENGINE_INIT_ABSTRACT_CLASS(SoInterpolate, "Interpolate",
314 SoEngine);
315 }
316
317 ////////////////////////////////////////////////////////////////////////
318 //
319 //
320 // Description:
321 // This initializes the builtin SoInterpolate classes.
322 //
323 // Use: internal
324
325 void
326 SoInterpolate::initClasses()
327 //
328 ////////////////////////////////////////////////////////////////////////
329 {
330 // ... first the base class
331 SoInterpolate::initClass();
332 // ... then the derived classes
333 SoInterpolateFloat::initClass();
334 SoInterpolateRotation::initClass();
335 SoInterpolateVec2f::initClass();
336 SoInterpolateVec3f::initClass();
337 SoInterpolateVec4f::initClass();
338 }
339
340 SO_INTERPOLATE_INITCLASS(SoInterpolateFloat, "InterpolateFloat");
341 SO_INTERPOLATE_INITCLASS(SoInterpolateRotation, "InterpolateRotation");
342 SO_INTERPOLATE_INITCLASS(SoInterpolateVec2f, "InterpolateVec2f");
343 SO_INTERPOLATE_INITCLASS(SoInterpolateVec3f, "InterpolateVec3f");
344 SO_INTERPOLATE_INITCLASS(SoInterpolateVec4f, "InterpolateVec4f");
345
346 ////////////////////////////////////////////////////////////////////////
347 //
348 // Description:
349 // This initializes the SoOnOff class.
350 //
351 // Use: internal
352
353 void
354 SoOnOff::initClass()
355 //
356 ////////////////////////////////////////////////////////////////////////
357 {
358 SO__ENGINE_INIT_CLASS(SoOnOff, "OnOff", SoEngine);
359 }
360
361 ////////////////////////////////////////////////////////////////////////
362 //
363 // Description:
364 // This initializes the SoOneShot class.
365 //
366 // Use: internal
367
368 void
369 SoOneShot::initClass()
370 //
371 ////////////////////////////////////////////////////////////////////////
372 {
373 SO__ENGINE_INIT_CLASS(SoOneShot, "OneShot", SoEngine);
374 }
375
376 ////////////////////////////////////////////////////////////////////////
377 //
378 // Description:
379 // This initializes the SoSelectOne class.
380 //
381 // Use: internal
382 //
383 void
384 SoSelectOne::initClass()
385 //
386 ////////////////////////////////////////////////////////////////////////
387 {
388 SO__ENGINE_INIT_CLASS(SoSelectOne, "SelectOne", SoEngine);
389 }
390
391 ////////////////////////////////////////////////////////////////////////
392 //
393 // Description:
394 // This initializes the SoTimeCounter class.
395 //
396 // Use: internal
397
398 void
399 SoTimeCounter::initClass()
400 //
401 ////////////////////////////////////////////////////////////////////////
402 {
403 SO__ENGINE_INIT_CLASS(SoTimeCounter, "TimeCounter", SoEngine);
404 }
405
406 ////////////////////////////////////////////////////////////////////////
407 //
408 // Description:
409 // This initializes the SoTransformVec3f class.
410 //
411 // Use: internal
412
413 void
414 SoTransformVec3f::initClass()
415 //
416 ////////////////////////////////////////////////////////////////////////
417 {
418 SO__ENGINE_INIT_CLASS(SoTransformVec3f, "TransformVec3f", SoEngine);
419 }
420
421 ////////////////////////////////////////////////////////////////////////
422 //
423 // Description:
424 // This initializes the SoTriggerAny class.
425 //
426 // Use: internal
427
428 void
429 SoTriggerAny::initClass()
430 //
431 ////////////////////////////////////////////////////////////////////////
432 {
433 SO__ENGINE_INIT_CLASS(SoTriggerAny, "TriggerAny", SoEngine);
434 }
435
436 ////////////////////////////////////////////////////////////////////////
437 //
438 // Description:
439 // This initializes the SoUnknownEngine class.
440 //
441 // Use: internal
442
443 void
444 SoUnknownEngine::initClass()
445 //
446 ////////////////////////////////////////////////////////////////////////
447 {
448 SO__ENGINE_INIT_CLASS(SoUnknownEngine, "UnknownEngine", SoEngine);
449 }
450
451
452 ////////////////////////////////////////////////////////////////////////
453 //
454 // Description:
455 // This initializes the built-in field converter class.
456 //
457 // Use: internal
458
459 void
460 SoBuiltinFieldConverter::initClass()
461 //
462 ////////////////////////////////////////////////////////////////////////
463 {
464 SO__ENGINE_INIT_CLASS(SoBuiltinFieldConverter,
465 "BuiltinFieldConverter", SoFieldConverter);
466 classTypeId.makeInternal();
467
468 // Macro for registering the single/multi to multi/single field
469 // conversions:
470 #define REG1(type) \
471 SoDB::addConverter(SO__CONCAT(SoSF,type)::getClassTypeId(), \
472 SO__CONCAT(SoMF,type)::getClassTypeId(), \
473 getClassTypeId()); \
474 SoDB::addConverter(SO__CONCAT(SoMF,type)::getClassTypeId(), \
475 SO__CONCAT(SoSF,type)::getClassTypeId(), \
476 getClassTypeId())
477
478 // Cases for all the field types:
479 REG1(BitMask);
480 REG1(Bool);
481 REG1(Color);
482 REG1(Enum);
483 REG1(Float);
484 REG1(Int32);
485 REG1(Matrix);
486 REG1(Name);
487 REG1(Node);
488 REG1(Path);
489 REG1(Plane);
490 REG1(Rotation);
491 REG1(Short);
492 REG1(String);
493 REG1(Time);
494 REG1(UInt32);
495 REG1(UShort);
496 REG1(Vec2f);
497 REG1(Vec3f);
498 REG1(Vec4f);
499 #undef REG1
500
501 // Macro for registering all of the to/from single/multi-valued
502 // string conversions (eight for each type):
503 #define REGSTRING(type) \
504 SoDB::addConverter(SO__CONCAT(SoSF,type)::getClassTypeId(), \
505 SoSFString::getClassTypeId(), \
506 getClassTypeId()); \
507 SoDB::addConverter(SO__CONCAT(SoMF,type)::getClassTypeId(), \
508 SoSFString::getClassTypeId(), \
509 getClassTypeId()); \
510 SoDB::addConverter(SO__CONCAT(SoSF,type)::getClassTypeId(), \
511 SoMFString::getClassTypeId(), \
512 getClassTypeId()); \
513 SoDB::addConverter(SO__CONCAT(SoMF,type)::getClassTypeId(), \
514 SoMFString::getClassTypeId(), \
515 getClassTypeId()); \
516 SoDB::addConverter(SoSFString::getClassTypeId(), \
517 SO__CONCAT(SoSF,type)::getClassTypeId(), \
518 getClassTypeId()); \
519 SoDB::addConverter(SoSFString::getClassTypeId(), \
520 SO__CONCAT(SoMF,type)::getClassTypeId(), \
521 getClassTypeId()); \
522 SoDB::addConverter(SoMFString::getClassTypeId(), \
523 SO__CONCAT(SoSF,type)::getClassTypeId(), \
524 getClassTypeId()); \
525 SoDB::addConverter(SoMFString::getClassTypeId(), \
526 SO__CONCAT(SoMF,type)::getClassTypeId(), \
527 getClassTypeId())
528
529 // All types except string:
530 REGSTRING(BitMask);
531 REGSTRING(Bool);
532 REGSTRING(Color);
533 REGSTRING(Enum);
534 REGSTRING(Float);
535 REGSTRING(Int32);
536 REGSTRING(Matrix);
537 REGSTRING(Name);
538 REGSTRING(Node);
539 REGSTRING(Path);
540 REGSTRING(Plane);
541 REGSTRING(Rotation);
542 REGSTRING(Short);
543 REGSTRING(Time);
544 REGSTRING(UInt32);
545 REGSTRING(UShort);
546 REGSTRING(Vec2f);
547 REGSTRING(Vec3f);
548 REGSTRING(Vec4f);
549 #undef REGSTRING
550
551 // Macro for other conversions (float to int32_t, etc):
552
553 #define REGHALF(type1,type2) \
554 SoDB::addConverter(SO__CONCAT(SoSF,type1)::getClassTypeId(), \
555 SO__CONCAT(SoSF,type2)::getClassTypeId(), \
556 getClassTypeId()); \
557 SoDB::addConverter(SO__CONCAT(SoMF,type1)::getClassTypeId(), \
558 SO__CONCAT(SoSF,type2)::getClassTypeId(), \
559 getClassTypeId()); \
560 SoDB::addConverter(SO__CONCAT(SoSF,type1)::getClassTypeId(), \
561 SO__CONCAT(SoMF,type2)::getClassTypeId(), \
562 getClassTypeId()); \
563 SoDB::addConverter(SO__CONCAT(SoMF,type1)::getClassTypeId(), \
564 SO__CONCAT(SoMF,type2)::getClassTypeId(), \
565 getClassTypeId())
566
567 #define REGCONV(type1,type2) \
568 REGHALF(type1,type2); \
569 REGHALF(type2,type1)
570
571 REGCONV(Bool,Float);
572 REGCONV(Bool,Int32);
573 REGCONV(Bool,Short);
574 REGCONV(Bool,UInt32);
575 REGCONV(Bool,UShort);
576
577 REGCONV(Color, Vec3f);
578
579 REGCONV(Float,Int32);
580 REGCONV(Float,Short);
581 REGCONV(Float,UInt32);
582 REGCONV(Float,UShort);
583
584 REGCONV(Int32,Short);
585 REGCONV(Int32,UInt32);
586 REGCONV(Int32,UShort);
587
588 REGCONV(Short,UInt32);
589 REGCONV(Short,UShort);
590
591 REGCONV(UInt32,UShort);
592
593 REGCONV(Float, Time);
594
595 REGCONV(Matrix, Rotation);
596 }