Skip to content

Commit

Permalink
Merge pull request #1042 from johnhaddon/nextInPlug
Browse files Browse the repository at this point in the history
Added Group::nextInPlug() method.
  • Loading branch information
andrewkaufman committed Oct 14, 2014
2 parents 185adee + 990c78e commit 787ec91
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 2 deletions.
9 changes: 9 additions & 0 deletions include/GafferScene/Group.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ class Group : public SceneProcessor

IE_CORE_DECLARERUNTIMETYPEDEXTENSION( GafferScene::Group, GroupTypeId, SceneProcessor );

/// The Group adds new input plugs as needed as the existing
/// ones receive input connections. This method returns the
/// most recently added plug - the one that should be used
/// to connect a new input.
/// \todo If SceneProcessor::inPlug() was an ArrayPlug as
/// per #996, we wouldn't need this method.
ScenePlug *nextInPlug();
const ScenePlug *nextInPlug() const;

Gaffer::StringPlug *namePlug();
const Gaffer::StringPlug *namePlug() const;

Expand Down
47 changes: 47 additions & 0 deletions include/GafferSceneBindings/GroupBinding.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2014, Image Engine Design Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above
// copyright notice, this list of conditions and the following
// disclaimer.
//
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided with
// the distribution.
//
// * Neither the name of John Haddon nor the names of
// any other contributors to this software may be used to endorse or
// promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////

#ifndef GAFFERSCENEBINDINGS_GROUPBINDING_H
#define GAFFERSCENEBINDINGS_GROUPBINDING_H

namespace GafferSceneBindings
{

void bindGroup();

} // namespace GafferSceneBindings

#endif // GAFFERSCENEBINDINGS_GROUPBINDING_H
19 changes: 19 additions & 0 deletions python/GafferSceneTest/GroupTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,25 @@ def testDifferentSetsInEachInput( self ) :
} )
)

def testNextInPlug( self ) :

g = GafferScene.Group()
self.assertTrue( g.nextInPlug().isSame( g["in"] ) )

p = GafferScene.Plane()
g["in"].setInput( p["out"] )
self.assertTrue( g.nextInPlug().isSame( g["in1"] ) )

g["in"].setInput( None )
self.assertTrue( g.nextInPlug().isSame( g["in"] ) )

g["in"].setInput( p["out"] )
g["in1"].setInput( p["out"] )
self.assertTrue( g.nextInPlug().isSame( g["in2"] ) )

g["in"].setInput( None )
self.assertTrue( g.nextInPlug().isSame( g["in2"] ) )

def setUp( self ) :

self.__originalCacheMemoryLimit = Gaffer.ValuePlug.getCacheMemoryLimit()
Expand Down
10 changes: 10 additions & 0 deletions src/GafferScene/Group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@ Group::~Group()
{
}

ScenePlug *Group::nextInPlug()
{
return m_inPlugs.inputs().back().get();
}

const ScenePlug *Group::nextInPlug() const
{
return m_inPlugs.inputs().back().get();
}

Gaffer::StringPlug *Group::namePlug()
{
return getChild<StringPlug>( g_firstPlugIndex );
Expand Down
54 changes: 54 additions & 0 deletions src/GafferSceneBindings/GroupBinding.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2014, Image Engine Design Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above
// copyright notice, this list of conditions and the following
// disclaimer.
//
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided with
// the distribution.
//
// * Neither the name of John Haddon nor the names of
// any other contributors to this software may be used to endorse or
// promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////

#include "boost/python.hpp"

#include "GafferBindings/DependencyNodeBinding.h"

#include "GafferScene/Group.h"

#include "GafferSceneBindings/GroupBinding.h"

using namespace boost::python;
using namespace IECorePython;
using namespace GafferScene;

void GafferSceneBindings::bindGroup()
{
GafferBindings::DependencyNodeClass<Group>()
.def( "nextInPlug", (ScenePlug *(Group::*)())&Group::nextInPlug, return_value_policy<CastToIntrusivePtr>() )
;
}
4 changes: 2 additions & 2 deletions src/GafferSceneModule/GafferSceneModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
#include "GafferScene/PrimitiveVariableProcessor.h"
#include "GafferScene/DeletePrimitiveVariables.h"
#include "GafferScene/MeshType.h"
#include "GafferScene/Group.h"
#include "GafferScene/Plane.h"
#include "GafferScene/Seeds.h"
#include "GafferScene/Instancer.h"
Expand Down Expand Up @@ -94,6 +93,7 @@
#include "GafferSceneBindings/CoordinateSystemBinding.h"
#include "GafferSceneBindings/DeleteGlobalsBinding.h"
#include "GafferSceneBindings/ExternalProceduralBinding.h"
#include "GafferSceneBindings/GroupBinding.h"

using namespace boost::python;
using namespace GafferScene;
Expand All @@ -112,7 +112,6 @@ BOOST_PYTHON_MODULE( _GafferScene )
GafferBindings::DependencyNodeClass<SceneElementProcessor>();
GafferBindings::DependencyNodeClass<AttributeCache>();
GafferBindings::DependencyNodeClass<MeshType>();
GafferBindings::DependencyNodeClass<Group>();
GafferBindings::DependencyNodeClass<ObjectSource>();
GafferBindings::DependencyNodeClass<Cube>();
GafferBindings::DependencyNodeClass<Plane>();
Expand All @@ -132,6 +131,7 @@ BOOST_PYTHON_MODULE( _GafferScene )
bindSceneProcedural();
bindShader();
bindOptions();
bindGroup();

GafferBindings::DependencyNodeClass<AlembicSource>();
GafferBindings::DependencyNodeClass<SubTree>();
Expand Down

0 comments on commit 787ec91

Please sign in to comment.