CMS 3D CMS Logo

IgSoTwig Class Reference

#include <Iguana/GLModels/interface/IgSoTwig.h>

Inheritance diagram for IgSoTwig:

IgSimpleTwig IgCompoundTwig IgTwig IgRepresentable

List of all members.

Public Member Functions

virtual void destroy (void)
 IgSoTwig (const std::string &name, bool selectable=false, bool traverse=true, bool visibility=true, bool cascade=true)
 IgSoTwig (IgTwig *parent, const std::string &name, bool selectable=false, bool traverse=true, bool visibility=true, bool cascade=true)
virtual SoGroup * magic (SoGroup *node)
virtual SoGroup * magic (void) const
virtual SoGroup * node (SoGroup *node)
virtual SoGroup * node (void) const
 ~IgSoTwig (void)

Static Public Member Functions

static IgSoTwigbuildFrom (SoNode *from)

Protected Member Functions

virtual void cleared (IgTwig *parent)

Static Protected Member Functions

static IgSoTwigbuildFromOther (SoNode *from)
static IgSoTwigbuildFromReps (SoNode *from)
static IgSoTwigbuildFromVis (SoNode *from, bool top)

Private Attributes

SoGroup * m_magic
SoGroup * m_node
bool m_selectable


Detailed Description

Definition at line 20 of file IgSoTwig.h.


Constructor & Destructor Documentation

IgSoTwig::IgSoTwig ( IgTwig parent,
const std::string &  name,
bool  selectable = false,
bool  traverse = true,
bool  visibility = true,
bool  cascade = true 
)

Definition at line 21 of file IgSoTwig.cc.

References Ig3DBaseModel::encode(), m_magic, m_node, and m_selectable.

Referenced by buildFromOther(), buildFromReps(), and buildFromVis().

00026     : IgSimpleTwig (parent, name, traverse, visibility, cascade),
00027       m_magic (0),
00028       m_node (0),
00029       m_selectable (selectable)
00030 {
00031     m_magic = new SoGroup;
00032     m_magic->ref ();
00033     m_node = m_selectable ? new SoSelection : new SoSeparator;
00034     m_node->setName (Ig3DModel::encode (name));
00035     m_node->ref ();
00036 }

IgSoTwig::IgSoTwig ( const std::string &  name,
bool  selectable = false,
bool  traverse = true,
bool  visibility = true,
bool  cascade = true 
) [explicit]

Definition at line 38 of file IgSoTwig.cc.

References Ig3DBaseModel::encode(), m_magic, m_node, and m_selectable.

00043     : IgSimpleTwig (0, name, traverse, visibility, cascade),
00044       m_magic (0),
00045       m_node (0),
00046       m_selectable (selectable)
00047 {
00048     m_magic = new SoGroup;
00049     m_magic->ref ();
00050     m_node = m_selectable ? new SoSelection : new SoSeparator;
00051     m_node->setName (Ig3DModel::encode (name));
00052     m_node->ref ();
00053 }

IgSoTwig::~IgSoTwig ( void   ) 

Definition at line 55 of file IgSoTwig.cc.

References ASSERT, m_magic, and m_node.

00056 {
00057     ASSERT (m_magic);
00058     ASSERT (m_node);
00059     m_magic->unref ();
00060     m_node->unref ();
00061 }


Member Function Documentation

IgSoTwig * IgSoTwig::buildFrom ( SoNode *  from  )  [static]

Definition at line 124 of file IgSoTwig.cc.

References buildFromOther(), buildFromReps(), and buildFromVis().

Referenced by IgIVView::IgIVView().

00125 {
00126     if (node->isOfType (SoSelection::getClassTypeId ())
00127         && node->getName () == "IGUANA_SCENE_GRAPH_V2")
00128         return buildFromReps (node);
00129     else if (node->isOfType (SoSeparator::getClassTypeId ())
00130              && node->getName () == "Top")
00131         return buildFromVis (node, true);
00132     else if (node->isOfType (SoSelection::getClassTypeId ())
00133              && ((SoSelection *) node)->getNumChildren ()
00134              && ((SoSelection *) node)->getChild (0)->isOfType
00135              (SoSeparator::getClassTypeId ())
00136              && node->getName () == ""
00137              && ((SoSelection *) node)->getChild (0)->getName () != "")
00138         return buildFromVis (node, true);
00139     else
00140         return buildFromOther (node);
00141 }

IgSoTwig * IgSoTwig::buildFromOther ( SoNode *  from  )  [static, protected]

Definition at line 278 of file IgSoTwig.cc.

References IgCompoundTwig::add(), ASSERT, IgSoTwig(), node(), and IgTwig::root().

Referenced by buildFrom().

00279 {
00280     ASSERT (from);
00281     IgSoTwig *root = new IgSoTwig ("Root", false, true, true, true);
00282     IgSoTwig *content = new IgSoTwig ("Objects", false, true, true, true);
00283     root->add (content);
00284     content->node ()->addChild (from);
00285 
00286     return root;
00287 }

IgSoTwig * IgSoTwig::buildFromReps ( SoNode *  from  )  [static, protected]

Definition at line 225 of file IgSoTwig.cc.

References IgCompoundTwig::add(), ASSERT, Ig3DBaseModel::decode(), i, IgSoTwig(), and max.

Referenced by buildFrom().

00226 {
00227     ASSERT (from);
00228     ASSERT (from->isOfType (SoGroup::getClassTypeId ()));
00229     SoGroup *sep = static_cast<SoGroup *> (from);
00230     IgSoTwig *twig;
00231     
00232     if (sep->isOfType (SoSelection::getClassTypeId ()))
00233     {
00234         // Create phantom top twig to contain nodes that should go to
00235         // the scene graph's top magic node.  The real twigs are the
00236         // children of the top twig.
00237         ASSERT (sep->getName () == "IGUANA_SCENE_GRAPH_V2");
00238         ASSERT (sep->getNumChildren () == 1);
00239         from = sep->getChild (0);
00240         ASSERT (from->isOfType (SoSeparator::getClassTypeId ()));
00241         ASSERT (from->getName () == "IGUANA_3D_REP");
00242         sep = static_cast<SoGroup *> (from);
00243         ASSERT (sep->getNumChildren () >= 2);
00244         ASSERT (sep->getChild (0)->isOfType (SoGroup::getClassTypeId ()));
00245         ASSERT (sep->getChild (1)->isOfType (SoGroup::getClassTypeId ()));
00246         ASSERT (((SoGroup *) sep->getChild (1))->getNumChildren () == 0);
00247         twig = new IgSoTwig ("Root", false, true, true, true);
00248         twig->magic (static_cast<SoGroup *> (sep->getChild (0)));
00249     }
00250     else
00251     {
00252         ASSERT (sep->isOfType (SoSeparator::getClassTypeId ()));
00253         ASSERT (sep->getName () == "IGUANA_3D_REP");
00254         ASSERT (sep->getNumChildren () >= 2);
00255         ASSERT (sep->getChild (0)->isOfType (SoGroup::getClassTypeId ()));
00256         ASSERT (sep->getChild (1)->isOfType (SoGroup::getClassTypeId ()));
00257         twig = new IgSoTwig (Ig3DModel::decode (sep->getChild (1)->getName ()),
00258                              false, true, true, true);
00259         twig->magic (static_cast<SoGroup *> (sep->getChild (0)));
00260         twig->node (static_cast<SoGroup *> (sep->getChild (1)));
00261     }
00262 
00263     for (int i = 2, max = sep->getNumChildren (); i < max; ++i)
00264     {
00265         SoNode *child = sep->getChild (i);
00266         ASSERT (child);
00267         ASSERT (child->isOfType (SoSeparator::getClassTypeId ()));
00268         SoGroup *rep = static_cast<SoGroup *> (child);
00269         ASSERT (rep->getName () == "IGUANA_3D_REP");
00270         ASSERT (rep->getNumChildren () >= 2);
00271         twig->add (buildFromReps (rep));
00272     }
00273     
00274     return twig;
00275 }

IgSoTwig * IgSoTwig::buildFromVis ( SoNode *  from,
bool  top 
) [static, protected]

Definition at line 144 of file IgSoTwig.cc.

References IgCompoundTwig::add(), ASSERT, Ig3DBaseModel::decode(), i, IgSoTwig(), magic(), max, and node().

Referenced by buildFrom().

00145 {
00146     ASSERT (from && from->isOfType (SoGroup::getClassTypeId ()));
00147     SoGroup     *sep = static_cast<SoGroup *> (from);
00148     int         max = sep->getNumChildren ();
00149     int         i = 0;
00150     IgSoTwig    *twig;
00151     
00152     if (top
00153         && from->isOfType (SoSeparator::getClassTypeId ())
00154         && from->getName () == "Top")
00155     {
00156         twig = new IgSoTwig ("Root", false, true, true, true);
00157         
00158         // Pick magic stuff
00159         for ( ; i < max; ++i)
00160         {
00161             SoNode *child = sep->getChild (i);
00162             ASSERT (child);
00163             
00164             if ((child->isOfType (SoGroup::getClassTypeId ())
00165                  && (child->getName () == "Default_Light_Group"
00166                      || child->getName () == "Default_Clip_Group"
00167                      || child->getName () == "Default_Animator_Group"))
00168                 || child->isOfType (SoClipPlane::getClassTypeId ()))
00169             {
00170                 twig->magic ()->addChild (child);
00171             }
00172             else
00173             {
00174                 ASSERT (i == max-1);
00175                 ASSERT (child->isOfType (SoSelection::getClassTypeId ()));
00176                 ASSERT (child->getName () == "Scene");
00177                 sep = static_cast<SoGroup *> (child);
00178                 break;
00179             }
00180         }
00181     }
00182     else if (top)
00183         twig = new IgSoTwig ("Root", false, true, true, true);
00184     else
00185     {
00186         twig = new IgSoTwig (Ig3DModel::decode (from->getName ()),
00187                              false, true, true, true);
00188         twig->node (sep);
00189     }
00190     
00191     // Insert nodes that look like twigs as sub-twigs into the parent;
00192     // then remove their SoNodes from the scene graph relationships in
00193     // order to make the twig their sole parent.  This will allow us
00194     // to use the twig's nodes directly as its 3D representation.
00195     std::vector<bool>   erase (sep->getNumChildren (), false);
00196     bool                sawcontent = false;
00197 
00198     for (int i = 0, max = sep->getNumChildren (); i < max; ++i)
00199     {
00200         SoNode *child = sep->getChild (i);
00201         ASSERT (child);
00202         
00203         if (child->isOfType (SoSeparator::getClassTypeId ())
00204             && child->getName () != ""
00205             && !sawcontent)
00206         {
00207             twig->add (buildFromVis (child, false));
00208             erase [i] = true;
00209         }
00210         else
00211         {
00212             twig->node ()->addChild (child);
00213             sawcontent = true;
00214         }
00215     }
00216  
00217     for (int i = sep->getNumChildren (); --i >= 0; )
00218         if (erase [i])
00219             sep->removeChild (i);
00220 
00221     return twig;
00222 }

void IgSoTwig::cleared ( IgTwig parent  )  [protected, virtual]

Reimplemented from IgTwig.

Definition at line 64 of file IgSoTwig.cc.

References IgTwig::cleared(), Ig3DBaseModel::encode(), m_selectable, magic(), IgSimpleTwig::name(), and node().

00065 {
00066     // This works its way bottom up; our children have already been cleared.
00067     // So just blow away everything and recreate the tree.
00068     IgTwig::cleared (parent);
00069 
00070     node (m_selectable ? new SoSelection : new SoSeparator)
00071         ->setName (Ig3DModel::encode (name ()));
00072     magic (new SoGroup);
00073 }

void IgSoTwig::destroy ( void   )  [virtual]

Reimplemented from IgCompoundTwig.

Definition at line 76 of file IgSoTwig.cc.

References IgTwig::destroy(), magic(), and node().

00077 {
00078     magic ()->removeAllChildren ();
00079     node ()->removeAllChildren ();
00080     IgTwig::destroy ();
00081 }

SoGroup * IgSoTwig::magic ( SoGroup *  node  )  [virtual]

Definition at line 112 of file IgSoTwig.cc.

References ASSERT, and m_magic.

00113 {
00114     ASSERT (m_magic);
00115     ASSERT (magic);
00116     
00117     magic->ref ();
00118     m_magic->unref ();
00119     return m_magic = magic;
00120 }

SoGroup * IgSoTwig::magic ( void   )  const [virtual]

Definition at line 105 of file IgSoTwig.cc.

References ASSERT, and m_magic.

Referenced by buildFromVis(), cleared(), and destroy().

00106 {
00107     ASSERT (m_magic);
00108     return m_magic;
00109 }

SoGroup * IgSoTwig::node ( SoGroup *  node  )  [virtual]

Definition at line 91 of file IgSoTwig.cc.

References ASSERT, and m_node.

00092 {
00093     ASSERT (m_node);
00094     ASSERT (node);
00095 
00096     if (node->getName () == "")
00097         node->setName (m_node->getName ());
00098 
00099     node->ref ();
00100     m_node->unref ();
00101     return m_node = node;
00102 }

SoGroup * IgSoTwig::node ( void   )  const [virtual]

Definition at line 84 of file IgSoTwig.cc.

References ASSERT, and m_node.

Referenced by buildFromOther(), buildFromVis(), cleared(), and destroy().

00085 {
00086     ASSERT (m_node);
00087     return m_node;
00088 }


Member Data Documentation

SoGroup* IgSoTwig::m_magic [private]

Definition at line 67 of file IgSoTwig.h.

Referenced by IgSoTwig(), magic(), and ~IgSoTwig().

SoGroup* IgSoTwig::m_node [private]

Definition at line 68 of file IgSoTwig.h.

Referenced by IgSoTwig(), node(), and ~IgSoTwig().

bool IgSoTwig::m_selectable [private]

Definition at line 69 of file IgSoTwig.h.

Referenced by cleared(), and IgSoTwig().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:25:44 2009 for CMSSW by  doxygen 1.5.4