Logo Search packages:      
Sourcecode: ktechlab version File versions  Download package

bool RigidBody::findOverallParent (  )  [protected]

Attempt to find the overall parent.

Returns:
false iff unsucessful (including if there are no MechanicsItems present)

Definition at line 77 of file mechanicssimulation.cpp.

References Item::parentItem().

Referenced by addMechanicsItem().

{
      p_overallParent = 0l;
      if ( m_mechanicsItemList.isEmpty() )
            return false;
      
      m_mechanicsItemList.remove(0l);
      
      const MechanicsItemList::iterator end = m_mechanicsItemList.end();
      for ( MechanicsItemList::iterator it = m_mechanicsItemList.begin(); it != end; ++it )
      {
            MechanicsItem *parentItem = *it;
            MechanicsItem *parentCandidate = dynamic_cast<MechanicsItem*>((*it)->parentItem());
            
            while (parentCandidate)
            {
                  parentItem = parentCandidate;
                  parentCandidate = dynamic_cast<MechanicsItem*>(parentItem->parentItem());
            }
            
            if ( !p_overallParent )
                  // Must be the first item to test
                  p_overallParent = parentItem;
            
            if ( p_overallParent != parentItem )
            {
                  p_overallParent = 0l;
                  return false;
            }
      }
      return true;
}


Generated by  Doxygen 1.6.0   Back to index