ElementFactories Group::_child_factories;
const std::string Group::TYPE_NAME = "group";
+ void warnTransformExpired(const char* member_name)
+ {
+ SG_LOG( SG_GENERAL,
+ SG_WARN,
+ "canvas::Group::" << member_name << ": Group has expired." );
+ }
+
//----------------------------------------------------------------------------
Group::Group( const CanvasWeakPtr& canvas,
const SGPropertyNode_ptr& node,
//----------------------------------------------------------------------------
ElementPtr Group::getElementById(const std::string& id)
{
- std::vector<GroupPtr> groups;
+ if( !_transform.valid() )
+ {
+ warnTransformExpired("getElementById");
+ return ElementPtr();
+ }
+ std::vector<GroupPtr> groups;
for(size_t i = 0; i < _transform->getNumChildren(); ++i)
{
const ElementPtr& el = getChildByIndex(i);
//----------------------------------------------------------------------------
void Group::clearEventListener()
{
+ if( _transform.valid() )
+ return warnTransformExpired("clearEventListener");
for(size_t i = 0; i < _transform->getNumChildren(); ++i)
getChildByIndex(i)->clearEventListener();
bool handled = setStyleImpl(style, style_info);
if( style_info->inheritable )
{
+ if( !_transform.valid() )
+ {
+ warnTransformExpired("setStyle");
+ return false;
+ }
+
for(size_t i = 0; i < _transform->getNumChildren(); ++i)
handled |= getChildByIndex(i)->setStyle(style, style_info);
}
osg::BoundingBox Group::getTransformedBounds(const osg::Matrix& m) const
{
osg::BoundingBox bb;
+ if( !_transform.valid() )
+ {
+ warnTransformExpired("getTransformedBounds");
+ return bb;
+ }
for(size_t i = 0; i < _transform->getNumChildren(); ++i)
{
ElementFactory child_factory = getChildFactory( child->getNameString() );
if( child_factory )
{
+ if( !_transform.valid() )
+ return warnTransformExpired("childAdded");
+
ElementPtr element = child_factory(_canvas, child, _style, this);
// Add to osg scene graph...
//----------------------------------------------------------------------------
void Group::handleZIndexChanged(ElementPtr child, int z_index)
{
- if( !child )
+ if( !child || _transform.valid() )
return;
osg::ref_ptr<osg::MatrixTransform> tf = child->getMatrixTransform();
ElementPtr Group::findChild( const SGPropertyNode* node,
const std::string& id ) const
{
+ if( !_transform.valid() )
+ {
+ warnTransformExpired("findChild");
+ return ElementPtr();
+ }
+
for(size_t i = 0; i < _transform->getNumChildren(); ++i)
{
ElementPtr el = getChildByIndex(i);