00001
00002
00003 #include "Iguana/GLModels/interface/Ig2DRep.h"
00004 #include "Iguana/GLModels/interface/Ig2DModel.h"
00005 #include "Inventor/nodes/SoTranslation.h"
00006 #include "Inventor/nodes/SoScale.h"
00007 #include "Inventor/nodes/SoGroup.h"
00008 #include "classlib/utils/DebugAids.h"
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 Ig2DRep::Ig2DRep (Ig2DModel *model,
00021 Ig2DRep *parent,
00022 Ig2DRep *prev,
00023 SoGroup *node)
00024 : Ig3DBaseRep (model, parent, prev, node)
00025 {
00026
00027
00028 SoTranslation *translation = new SoTranslation;
00029 translation->translation = SbVec3f (0, 0, 1);
00030 translation->setName ("LAYER_OFFSET");
00031 magic ()->addChild (translation);
00032
00033 SoScale *scale = new SoScale;
00034 scale->setName ("SUBLAYER_SCALING");
00035 magic ()->addChild (scale);
00036
00037 if (parent)
00038 parent->repositionChildren ();
00039 }
00040
00041 void
00042 Ig2DRep::repositionChildren (void)
00043 {
00044 for (int i = 0; i < children (); i++)
00045 {
00046 SoNode *node = child (i)->findMagic ("LAYER_OFFSET");
00047 SoTranslation *translation = dynamic_cast<SoTranslation *>(node);
00048 ASSERT (translation);
00049 translation->translation = SbVec3f(0,0,i);
00050 }
00051 SoNode *node = findMagic ("SUBLAYER_SCALING");
00052 SoScale *scale = dynamic_cast<SoScale *> (node);
00053 ASSERT (scale);
00054 scale->scaleFactor = SbVec3f (1, 1, 1./(children () + 1));
00055 }