CMS 3D CMS Logo

Ig2DRep.cc

Go to the documentation of this file.
00001 //<<<<<< INCLUDES                                                       >>>>>>
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 //<<<<<< PRIVATE DEFINES                                                >>>>>>
00011 //<<<<<< PRIVATE CONSTANTS                                              >>>>>>
00012 //<<<<<< PRIVATE TYPES                                                  >>>>>>
00013 //<<<<<< PRIVATE VARIABLE DEFINITIONS                                   >>>>>>
00014 //<<<<<< PUBLIC VARIABLE DEFINITIONS                                    >>>>>>
00015 //<<<<<< CLASS STRUCTURE INITIALIZATION                                 >>>>>>
00016 //<<<<<< PRIVATE FUNCTION DEFINITIONS                                   >>>>>>
00017 //<<<<<< PUBLIC FUNCTION DEFINITIONS                                    >>>>>>
00018 //<<<<<< MEMBER FUNCTION DEFINITIONS                                    >>>>>>
00019 
00020 Ig2DRep::Ig2DRep (Ig2DModel *model,
00021                   Ig2DRep *parent,
00022                   Ig2DRep *prev,
00023                   SoGroup *node)
00024     : Ig3DBaseRep (model, parent, prev, node)
00025 {
00026     // Translate by a fixed amount: the rep will have a scaling
00027     // operation in front which takes care of everything.
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 }

Generated on Tue Jun 9 17:38:42 2009 for CMSSW by  doxygen 1.5.4