/*****************************************************************************
 * $LastChangedDate: 2010-03-26 15:04:03 -0400 (Fri, 26 Mar 2010) $
 * @file
 * @author  Jim E. Brooks  http://www.palomino3d.org
 * @brief   Common subroutines to enable rendering a Graph/Subgraph.
 *//*
 * LEGAL:   COPYRIGHT (C) 2007 JIM E. BROOKS
 *          THIS SOURCE CODE IS RELEASED UNDER THE TERMS
 *          OF THE GNU GENERAL PUBLIC LICENSE VERSION 2 (GPL 2).
 *****************************************************************************/

#define GRAPH_GRAPH_ENABLEMENT_CC 1
#include "base/module.hh"
using namespace base;
#include "graph/module.hh"
#include "graph/osg.hh"
#include "graph/graph_enablement.hh"

namespace graph {

////////////////////////////////////////////////////////////////////////////////
/////////////////////////////  GraphEnablement  ////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

/*****************************************************************************
 * Enable/disable rendering a Graph.
 *****************************************************************************/
void
GraphEnablement::Enable( SwitchNode& switchNode, const bool enable )
{
    // Change the OSG Switch node.
    if ( enable )
        switchNode.setAllChildrenOn();
    else
        switchNode.setAllChildrenOff();
}

bool
GraphEnablement::IfEnabled( SwitchNode& switchNode )
{
    if ( switchNode.getNumChildren() == 0
      or not switchNode.getValue(0) )  // assume if child is disable, so are all
        return false;
    else
        return true;
}

} // namespace graph
