###########################################################################
# cgkit - Python Computer Graphics Kit
# Copyright (C) 2004 Matthias Baas (baas@ira.uka.de)
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
# cgkit homepage: http://cgkit.sourceforge.net
###########################################################################
# $Id: group.py,v 1.3 2005/04/19 08:45:56 mbaas Exp $

## \file group.py
## Contains the Group class.

from Interfaces import *
import protocols
from slots import *
from worldobject import WorldObject
import cmds

# Group
class Group(WorldObject):
    """Group class.

    This class is almost identical to the WorldObject class, except
    that its constructor accepts additional arguments.
    """

    protocols.advise(instancesProvide=[ISceneItem, IRigidBody])

    def __init__(self,
                 name="group",
                 dynamics=True,
                 static=False,
                 childs=[],
                 **params):
        """Constructor.

        \param name (\c str) Object name
        \param childs (\c list) A list of WorldObjects or object names.
        """
        WorldObject.__init__(self, name=name, **params)

        self.dynamics_slot = BoolSlot(dynamics)
        self.static_slot = BoolSlot(static)
        self.addSlot("dynamics", self.dynamics_slot)
        self.addSlot("static", self.static_slot)
        
        for c in childs:
            c = cmds.worldObject(c)
            if c.parent!=None:
                c.parent.removeChild(c)
            self.addChild(c)

    exec slotPropertyCode("dynamics")
    exec slotPropertyCode("static")
