From c8f0fa331d068e46dc6f7d843243bc189bec2b8f Mon Sep 17 00:00:00 2001 From: goddardl Date: Mon, 29 Apr 2013 19:10:55 -0700 Subject: [PATCH 1/4] Created a Transform2dPlug and it's test cases. --- include/Gaffer/Transform2dPlug.h | 79 +++++++++ include/Gaffer/TypeIds.h | 1 + .../GafferBindings/Transform2dPlugBinding.h | 47 +++++ python/GafferTest/Transform2dPlugTest.py | 115 ++++++++++++ python/GafferTest/__init__.py | 1 + src/Gaffer/Transform2dPlug.cpp | 165 ++++++++++++++++++ src/GafferBindings/Transform2dPlugBinding.cpp | 66 +++++++ src/GafferModule/GafferModule.cpp | 2 + 8 files changed, 476 insertions(+) create mode 100644 include/Gaffer/Transform2dPlug.h create mode 100644 include/GafferBindings/Transform2dPlugBinding.h create mode 100644 python/GafferTest/Transform2dPlugTest.py create mode 100644 src/Gaffer/Transform2dPlug.cpp create mode 100644 src/GafferBindings/Transform2dPlugBinding.cpp diff --git a/include/Gaffer/Transform2dPlug.h b/include/Gaffer/Transform2dPlug.h new file mode 100644 index 00000000000..8de6e1fb725 --- /dev/null +++ b/include/Gaffer/Transform2dPlug.h @@ -0,0 +1,79 @@ +////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2013, 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 Image Engine Design 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 GAFFER_TRANSFORM2DPLUG_H +#define GAFFER_TRANSFORM2DPLUG_H + +#include "Gaffer/CompoundNumericPlug.h" + +namespace Gaffer +{ + +class Transform2dPlug : public CompoundPlug +{ + + public : + + Transform2dPlug( const std::string &name = staticTypeName(), Direction direction=In, unsigned flags = Default ); + virtual ~Transform2dPlug(); + + IE_CORE_DECLARERUNTIMETYPEDEXTENSION( Transform2dPlug, Transform2dPlugTypeId, CompoundPlug ); + + virtual bool acceptsChild( const GraphComponent *potentialChild ) const; + virtual PlugPtr createCounterpart( const std::string &name, Direction direction ) const; + + V2fPlug *pivotPlug(); + const V2fPlug *pivotPlug() const; + V2fPlug *translatePlug(); + const V2fPlug *translatePlug() const; + FloatPlug *rotatePlug(); + const FloatPlug *rotatePlug() const; + V2fPlug *scalePlug(); + const V2fPlug *scalePlug() const; + + Imath::M33f matrix() const; + +}; + +IE_CORE_DECLAREPTR( Transform2dPlug ); + +typedef FilteredChildIterator > Transform2dPlugIterator; +typedef FilteredChildIterator > InputTransform2dPlugIterator; +typedef FilteredChildIterator > OutputTransform2dPlugIterator; + +} // namespace Gaffer + +#endif // GAFFER_TRANSFORM2DPLUG_H diff --git a/include/Gaffer/TypeIds.h b/include/Gaffer/TypeIds.h index 52adcd9377f..7241751ff14 100644 --- a/include/Gaffer/TypeIds.h +++ b/include/Gaffer/TypeIds.h @@ -102,6 +102,7 @@ enum TypeId ExecutableNodeTypeId = 110055, ExecutableOpHolderTypeId = 110056, DespatcherTypeId = 110057, + Transform2dPlugTypeId = 110058, LastTypeId = 110200, }; diff --git a/include/GafferBindings/Transform2dPlugBinding.h b/include/GafferBindings/Transform2dPlugBinding.h new file mode 100644 index 00000000000..b01aafe7f0e --- /dev/null +++ b/include/GafferBindings/Transform2dPlugBinding.h @@ -0,0 +1,47 @@ +////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2013, 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 Image Engine Design 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 GAFFERBINDINGS_TRANSFORM2DPLUGBINDING_H +#define GAFFERBINDINGS_TRANSFORM2DPLUGBINDING_H + +namespace GafferBindings +{ + +void bindTransform2dPlug(); + +} // namespace GafferBindings + +#endif // GAFFERBINDINGS_TRANSFORM2DPLUGBINDING_H diff --git a/python/GafferTest/Transform2dPlugTest.py b/python/GafferTest/Transform2dPlugTest.py new file mode 100644 index 00000000000..bf8f652950f --- /dev/null +++ b/python/GafferTest/Transform2dPlugTest.py @@ -0,0 +1,115 @@ +########################################################################## +# +# Copyright (c) 2013, 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 Image Engine Design 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. +# +########################################################################## + +import unittest + +import IECore +import Gaffer +import math + +class Transform2dPlugTest( unittest.TestCase ) : + + def testMatrix( self ) : + + p = Gaffer.Transform2dPlug() + + p["pivot"].setValue( IECore.V2f( 1, 1 ) ) + p["translate"].setValue( IECore.V2f( 1, 2 ) ) + p["rotate"].setValue( 45 ) + p["scale"].setValue( IECore.V2f( 2, 3 ) ) + + pivot = IECore.M33f.createTranslated( p["pivot"].getValue() ) + translate = IECore.M33f.createTranslated( p["translate"].getValue() ) + rotate = IECore.M33f.createRotated( IECore.degreesToRadians( p["rotate"].getValue() ) ) + scale = IECore.M33f.createScaled( p["scale"].getValue() ) + invPivot = IECore.M33f.createTranslated( p["pivot"].getValue() * IECore.V2f(-1.) ) + + transforms = { + "p" : pivot, + "t" : translate, + "r" : rotate, + "s" : scale, + "pi" : invPivot, + } + + transform = IECore.M33f() + for m in ( "pi", "s", "r", "t", "p" ) : + transform = transform * transforms[m] + + self.assertEqual( p.matrix(), transform ) + + def testTransformOrderExplicit( self ) : + + plug = Gaffer.Transform2dPlug() + + t = IECore.V2f( 100, 0 ) + r = 90 + s = IECore.V2f( 2, 2 ) + p = IECore.V2f( 10, 10 ) + plug["translate"].setValue( t ) + plug["rotate"].setValue( r ) + plug["scale"].setValue( s ) + plug["pivot"].setValue( p ) + + # Test if this is equal to a simple hardcoded matrix, down to floating point error + # This verifies that translation is not being affected by rotation and scale, + # which is what users will expect + self.assertTrue( plug.matrix().equalWithAbsError( + IECore.M33f( + 0, 2, 0, + -2, 0, 0, + 130, -10, 1), + 1e-6 + ) ) + + def testCreateCounterpart( self ) : + + t = Gaffer.Transform2dPlug() + t2 = t.createCounterpart( "a", Gaffer.Plug.Direction.Out ) + + self.assertEqual( t2.getName(), "a" ) + self.assertEqual( t2.direction(), Gaffer.Plug.Direction.Out ) + self.assertTrue( isinstance( t2, Gaffer.Transform2dPlug ) ) + + def testRunTimeTyped( self ) : + + p = Gaffer.Transform2dPlug() + self.failIf( p.typeId() == Gaffer.CompoundPlug.staticTypeId() ) + self.failUnless( p.isInstanceOf( Gaffer.CompoundPlug.staticTypeId() ) ) + +if __name__ == "__main__": + unittest.main() + diff --git a/python/GafferTest/__init__.py b/python/GafferTest/__init__.py index 5e706374fd3..9a1fb550dc9 100644 --- a/python/GafferTest/__init__.py +++ b/python/GafferTest/__init__.py @@ -100,6 +100,7 @@ def wrapper( self ) : from BlockedConnectionTest import BlockedConnectionTest from TimeWarpDependencyNodeTest import TimeWarpDependencyNodeTest from TransformPlugTest import TransformPlugTest +from Transform2dPlugTest import Transform2dPlugTest from SequencePathTest import SequencePathTest from OpMatcherTest import OpMatcherTest from WeakMethodTest import WeakMethodTest diff --git a/src/Gaffer/Transform2dPlug.cpp b/src/Gaffer/Transform2dPlug.cpp new file mode 100644 index 00000000000..ee929b887d6 --- /dev/null +++ b/src/Gaffer/Transform2dPlug.cpp @@ -0,0 +1,165 @@ +////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2013, 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 Image Engine Design 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 "IECore/AngleConversion.h" + +#include "Gaffer/Transform2dPlug.h" + +using namespace Imath; +using namespace Gaffer; + +IE_CORE_DEFINERUNTIMETYPED( Transform2dPlug ); + +Transform2dPlug::Transform2dPlug( const std::string &name, Direction direction, unsigned flags ) + : CompoundPlug( name, direction, flags ) +{ + addChild( + new V2fPlug( + "translate", + direction, + V2f( 0 ), + V2f( limits::min() ), + V2f( limits::max() ), + flags + ) + ); + + addChild( + new FloatPlug( + "rotate", + direction, + 0., + limits::min(), + limits::max(), + flags + ) + ); + + addChild( + new V2fPlug( + "scale", + direction, + V2f( 1 ), + V2f( limits::min() ), + V2f( limits::max() ), + flags + ) + ); + + addChild( + new V2fPlug( + "pivot", + direction, + V2f( 0 ), + V2f( limits::min() ), + V2f( limits::max() ), + flags + ) + ); + +} + +Transform2dPlug::~Transform2dPlug() +{ +} + +bool Transform2dPlug::acceptsChild( const GraphComponent *potentialChild ) const +{ + return children().size() != 4; +} + +PlugPtr Transform2dPlug::createCounterpart( const std::string &name, Direction direction ) const +{ + return new Transform2dPlug( name, direction, getFlags() ); +} + +V2fPlug *Transform2dPlug::pivotPlug() +{ + return getChild( "pivot" ); +} + +const V2fPlug *Transform2dPlug::pivotPlug() const +{ + return getChild( "pivot" ); +} + +V2fPlug *Transform2dPlug::translatePlug() +{ + return getChild( "translate" ); +} + +const V2fPlug *Transform2dPlug::translatePlug() const +{ + return getChild( "translate" ); +} + +FloatPlug *Transform2dPlug::rotatePlug() +{ + return getChild( "rotate" ); +} + +const FloatPlug *Transform2dPlug::rotatePlug() const +{ + return getChild( "rotate" ); +} + +V2fPlug *Transform2dPlug::scalePlug() +{ + return getChild( "scale" ); +} + +const V2fPlug *Transform2dPlug::scalePlug() const +{ + return getChild( "scale" ); +} + +Imath::M33f Transform2dPlug::matrix() const +{ + M33f p; + p.translate( pivotPlug()->getValue() ); + M33f t; + t.translate( translatePlug()->getValue() ); + M33f r; + r.rotate( IECore::degreesToRadians( rotatePlug()->getValue() ) ); + M33f s; + s.scale( scalePlug()->getValue() ); + M33f pi; + pi.translate( pivotPlug()->getValue()*Imath::V2f(-1.f) ); + M33f result = pi * s * r * t * p; + + return result; +} + diff --git a/src/GafferBindings/Transform2dPlugBinding.cpp b/src/GafferBindings/Transform2dPlugBinding.cpp new file mode 100644 index 00000000000..cd5b30985e3 --- /dev/null +++ b/src/GafferBindings/Transform2dPlugBinding.cpp @@ -0,0 +1,66 @@ +////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2013, 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 Image Engine Design 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 "IECorePython/RunTimeTypedBinding.h" + +#include "Gaffer/Transform2dPlug.h" + +#include "GafferBindings/PlugBinding.h" +#include "GafferBindings/Transform2dPlugBinding.h" + +using namespace boost::python; +using namespace GafferBindings; +using namespace Gaffer; + +void GafferBindings::bindTransform2dPlug() +{ + IECorePython::RunTimeTypedClass() + .def( + init< const std::string &, Gaffer::Plug::Direction, unsigned > + ( + ( + arg( "name" ) = Gaffer::Transform2dPlug::staticTypeName(), + arg( "direction" ) = Gaffer::Plug::In, + arg( "flags" ) = Gaffer::Plug::Default + ) + ) + ) + .GAFFERBINDINGS_DEFPLUGWRAPPERFNS( Transform2dPlug ) + .def( "matrix", &Transform2dPlug::matrix ) + ; +} diff --git a/src/GafferModule/GafferModule.cpp b/src/GafferModule/GafferModule.cpp index 95e2c70dff8..4414364e533 100644 --- a/src/GafferModule/GafferModule.cpp +++ b/src/GafferModule/GafferModule.cpp @@ -66,6 +66,7 @@ #include "GafferBindings/BoxPlugBinding.h" #include "GafferBindings/ExpressionBinding.h" #include "GafferBindings/TransformPlugBinding.h" +#include "GafferBindings/Transform2dPlugBinding.h" #include "GafferBindings/CompoundDataPlugBinding.h" #include "GafferBindings/RandomBinding.h" #include "GafferBindings/DependencyNodeBinding.h" @@ -110,6 +111,7 @@ BOOST_PYTHON_MODULE( _Gaffer ) bindBoxPlug(); bindExpression(); bindTransformPlug(); + bindTransform2dPlug(); bindCompoundDataPlug(); bindRandom(); bindBox(); From 3bb8aa214c1704e12d974473172d7bdfea464b55 Mon Sep 17 00:00:00 2001 From: goddardl Date: Fri, 3 May 2013 11:02:48 -0700 Subject: [PATCH 2/4] Changed getChild() calls to use an index from the first plug rather than by name. --- include/Gaffer/Transform2dPlug.h | 3 +++ src/Gaffer/Transform2dPlug.cpp | 20 ++++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/include/Gaffer/Transform2dPlug.h b/include/Gaffer/Transform2dPlug.h index 8de6e1fb725..bb7b041c9f7 100644 --- a/include/Gaffer/Transform2dPlug.h +++ b/include/Gaffer/Transform2dPlug.h @@ -66,6 +66,9 @@ class Transform2dPlug : public CompoundPlug Imath::M33f matrix() const; + private : + + static size_t g_firstPlugIndex; }; IE_CORE_DECLAREPTR( Transform2dPlug ); diff --git a/src/Gaffer/Transform2dPlug.cpp b/src/Gaffer/Transform2dPlug.cpp index ee929b887d6..21ecd61bf61 100644 --- a/src/Gaffer/Transform2dPlug.cpp +++ b/src/Gaffer/Transform2dPlug.cpp @@ -43,9 +43,13 @@ using namespace Gaffer; IE_CORE_DEFINERUNTIMETYPED( Transform2dPlug ); +size_t Transform2dPlug::g_firstPlugIndex = 0; + Transform2dPlug::Transform2dPlug( const std::string &name, Direction direction, unsigned flags ) : CompoundPlug( name, direction, flags ) { + storeIndexOfNextChild( g_firstPlugIndex ); + addChild( new V2fPlug( "translate", @@ -108,42 +112,42 @@ PlugPtr Transform2dPlug::createCounterpart( const std::string &name, Direction d V2fPlug *Transform2dPlug::pivotPlug() { - return getChild( "pivot" ); + return getChild( g_firstPlugIndex+3 ); } const V2fPlug *Transform2dPlug::pivotPlug() const { - return getChild( "pivot" ); + return getChild( g_firstPlugIndex+3 ); } V2fPlug *Transform2dPlug::translatePlug() { - return getChild( "translate" ); + return getChild( g_firstPlugIndex ); } const V2fPlug *Transform2dPlug::translatePlug() const { - return getChild( "translate" ); + return getChild( g_firstPlugIndex ); } FloatPlug *Transform2dPlug::rotatePlug() { - return getChild( "rotate" ); + return getChild( g_firstPlugIndex+1 ); } const FloatPlug *Transform2dPlug::rotatePlug() const { - return getChild( "rotate" ); + return getChild( g_firstPlugIndex+1 ); } V2fPlug *Transform2dPlug::scalePlug() { - return getChild( "scale" ); + return getChild( g_firstPlugIndex+2 ); } const V2fPlug *Transform2dPlug::scalePlug() const { - return getChild( "scale" ); + return getChild( g_firstPlugIndex+2 ); } Imath::M33f Transform2dPlug::matrix() const From c7059666e6698ca7002dab3c6befc6c525ce55a8 Mon Sep 17 00:00:00 2001 From: goddardl Date: Fri, 3 May 2013 11:07:50 -0700 Subject: [PATCH 3/4] Rebased and added Recursive Child Iterator. --- include/Gaffer/Transform2dPlug.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/Gaffer/Transform2dPlug.h b/include/Gaffer/Transform2dPlug.h index bb7b041c9f7..999d825b5b2 100644 --- a/include/Gaffer/Transform2dPlug.h +++ b/include/Gaffer/Transform2dPlug.h @@ -77,6 +77,10 @@ typedef FilteredChildIterator > Tr typedef FilteredChildIterator > InputTransform2dPlugIterator; typedef FilteredChildIterator > OutputTransform2dPlugIterator; +typedef FilteredRecursiveChildIterator > RecursiveTransform2dPlugPlugIterator; +typedef FilteredRecursiveChildIterator > RecursiveInputTransform2dPlugPlugIterator; +typedef FilteredRecursiveChildIterator > RecursiveOutputTransform2dPlugPlugIterator; + } // namespace Gaffer #endif // GAFFER_TRANSFORM2DPLUG_H From 7297d139cf224d5a59d298efa9d99c5c0b3a33a2 Mon Sep 17 00:00:00 2001 From: goddardl Date: Fri, 3 May 2013 11:18:56 -0700 Subject: [PATCH 4/4] Renamed Transform2dPlug to Transform2DPlug --- .../{Transform2dPlug.h => Transform2DPlug.h} | 22 ++++++------ include/Gaffer/TypeIds.h | 2 +- ...PlugBinding.h => Transform2DPlugBinding.h} | 2 +- ...rm2dPlugTest.py => Transform2DPlugTest.py} | 12 +++---- ...ransform2dPlug.cpp => Transform2DPlug.cpp} | 34 +++++++++---------- ...Binding.cpp => Transform2DPlugBinding.cpp} | 14 ++++---- src/GafferModule/GafferModule.cpp | 4 +-- 7 files changed, 45 insertions(+), 45 deletions(-) rename include/Gaffer/{Transform2dPlug.h => Transform2DPlug.h} (83%) rename include/GafferBindings/{Transform2dPlugBinding.h => Transform2DPlugBinding.h} (98%) rename python/GafferTest/{Transform2dPlugTest.py => Transform2DPlugTest.py} (94%) rename src/Gaffer/{Transform2dPlug.cpp => Transform2DPlug.cpp} (81%) rename src/GafferBindings/{Transform2dPlugBinding.cpp => Transform2DPlugBinding.cpp} (86%) diff --git a/include/Gaffer/Transform2dPlug.h b/include/Gaffer/Transform2DPlug.h similarity index 83% rename from include/Gaffer/Transform2dPlug.h rename to include/Gaffer/Transform2DPlug.h index 999d825b5b2..e9c1098bcb7 100644 --- a/include/Gaffer/Transform2dPlug.h +++ b/include/Gaffer/Transform2DPlug.h @@ -42,15 +42,15 @@ namespace Gaffer { -class Transform2dPlug : public CompoundPlug +class Transform2DPlug : public CompoundPlug { public : - Transform2dPlug( const std::string &name = staticTypeName(), Direction direction=In, unsigned flags = Default ); - virtual ~Transform2dPlug(); + Transform2DPlug( const std::string &name = staticTypeName(), Direction direction=In, unsigned flags = Default ); + virtual ~Transform2DPlug(); - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( Transform2dPlug, Transform2dPlugTypeId, CompoundPlug ); + IE_CORE_DECLARERUNTIMETYPEDEXTENSION( Transform2DPlug, Transform2DPlugTypeId, CompoundPlug ); virtual bool acceptsChild( const GraphComponent *potentialChild ) const; virtual PlugPtr createCounterpart( const std::string &name, Direction direction ) const; @@ -71,15 +71,15 @@ class Transform2dPlug : public CompoundPlug static size_t g_firstPlugIndex; }; -IE_CORE_DECLAREPTR( Transform2dPlug ); +IE_CORE_DECLAREPTR( Transform2DPlug ); -typedef FilteredChildIterator > Transform2dPlugIterator; -typedef FilteredChildIterator > InputTransform2dPlugIterator; -typedef FilteredChildIterator > OutputTransform2dPlugIterator; +typedef FilteredChildIterator > Transform2DPlugIterator; +typedef FilteredChildIterator > InputTransform2DPlugIterator; +typedef FilteredChildIterator > OutputTransform2DPlugIterator; -typedef FilteredRecursiveChildIterator > RecursiveTransform2dPlugPlugIterator; -typedef FilteredRecursiveChildIterator > RecursiveInputTransform2dPlugPlugIterator; -typedef FilteredRecursiveChildIterator > RecursiveOutputTransform2dPlugPlugIterator; +typedef FilteredRecursiveChildIterator > RecursiveTransform2DPlugPlugIterator; +typedef FilteredRecursiveChildIterator > RecursiveInputTransform2DPlugPlugIterator; +typedef FilteredRecursiveChildIterator > RecursiveOutputTransform2DPlugPlugIterator; } // namespace Gaffer diff --git a/include/Gaffer/TypeIds.h b/include/Gaffer/TypeIds.h index 7241751ff14..a80e8b7f608 100644 --- a/include/Gaffer/TypeIds.h +++ b/include/Gaffer/TypeIds.h @@ -102,7 +102,7 @@ enum TypeId ExecutableNodeTypeId = 110055, ExecutableOpHolderTypeId = 110056, DespatcherTypeId = 110057, - Transform2dPlugTypeId = 110058, + Transform2DPlugTypeId = 110058, LastTypeId = 110200, }; diff --git a/include/GafferBindings/Transform2dPlugBinding.h b/include/GafferBindings/Transform2DPlugBinding.h similarity index 98% rename from include/GafferBindings/Transform2dPlugBinding.h rename to include/GafferBindings/Transform2DPlugBinding.h index b01aafe7f0e..13deefa92f7 100644 --- a/include/GafferBindings/Transform2dPlugBinding.h +++ b/include/GafferBindings/Transform2DPlugBinding.h @@ -40,7 +40,7 @@ namespace GafferBindings { -void bindTransform2dPlug(); +void bindTransform2DPlug(); } // namespace GafferBindings diff --git a/python/GafferTest/Transform2dPlugTest.py b/python/GafferTest/Transform2DPlugTest.py similarity index 94% rename from python/GafferTest/Transform2dPlugTest.py rename to python/GafferTest/Transform2DPlugTest.py index bf8f652950f..62e5cb898d4 100644 --- a/python/GafferTest/Transform2dPlugTest.py +++ b/python/GafferTest/Transform2DPlugTest.py @@ -40,11 +40,11 @@ import Gaffer import math -class Transform2dPlugTest( unittest.TestCase ) : +class Transform2DPlugTest( unittest.TestCase ) : def testMatrix( self ) : - p = Gaffer.Transform2dPlug() + p = Gaffer.Transform2DPlug() p["pivot"].setValue( IECore.V2f( 1, 1 ) ) p["translate"].setValue( IECore.V2f( 1, 2 ) ) @@ -73,7 +73,7 @@ def testMatrix( self ) : def testTransformOrderExplicit( self ) : - plug = Gaffer.Transform2dPlug() + plug = Gaffer.Transform2DPlug() t = IECore.V2f( 100, 0 ) r = 90 @@ -97,16 +97,16 @@ def testTransformOrderExplicit( self ) : def testCreateCounterpart( self ) : - t = Gaffer.Transform2dPlug() + t = Gaffer.Transform2DPlug() t2 = t.createCounterpart( "a", Gaffer.Plug.Direction.Out ) self.assertEqual( t2.getName(), "a" ) self.assertEqual( t2.direction(), Gaffer.Plug.Direction.Out ) - self.assertTrue( isinstance( t2, Gaffer.Transform2dPlug ) ) + self.assertTrue( isinstance( t2, Gaffer.Transform2DPlug ) ) def testRunTimeTyped( self ) : - p = Gaffer.Transform2dPlug() + p = Gaffer.Transform2DPlug() self.failIf( p.typeId() == Gaffer.CompoundPlug.staticTypeId() ) self.failUnless( p.isInstanceOf( Gaffer.CompoundPlug.staticTypeId() ) ) diff --git a/src/Gaffer/Transform2dPlug.cpp b/src/Gaffer/Transform2DPlug.cpp similarity index 81% rename from src/Gaffer/Transform2dPlug.cpp rename to src/Gaffer/Transform2DPlug.cpp index 21ecd61bf61..3bbb8ddfe05 100644 --- a/src/Gaffer/Transform2dPlug.cpp +++ b/src/Gaffer/Transform2DPlug.cpp @@ -36,16 +36,16 @@ #include "IECore/AngleConversion.h" -#include "Gaffer/Transform2dPlug.h" +#include "Gaffer/Transform2DPlug.h" using namespace Imath; using namespace Gaffer; -IE_CORE_DEFINERUNTIMETYPED( Transform2dPlug ); +IE_CORE_DEFINERUNTIMETYPED( Transform2DPlug ); -size_t Transform2dPlug::g_firstPlugIndex = 0; +size_t Transform2DPlug::g_firstPlugIndex = 0; -Transform2dPlug::Transform2dPlug( const std::string &name, Direction direction, unsigned flags ) +Transform2DPlug::Transform2DPlug( const std::string &name, Direction direction, unsigned flags ) : CompoundPlug( name, direction, flags ) { storeIndexOfNextChild( g_firstPlugIndex ); @@ -96,61 +96,61 @@ Transform2dPlug::Transform2dPlug( const std::string &name, Direction direction, } -Transform2dPlug::~Transform2dPlug() +Transform2DPlug::~Transform2DPlug() { } -bool Transform2dPlug::acceptsChild( const GraphComponent *potentialChild ) const +bool Transform2DPlug::acceptsChild( const GraphComponent *potentialChild ) const { return children().size() != 4; } -PlugPtr Transform2dPlug::createCounterpart( const std::string &name, Direction direction ) const +PlugPtr Transform2DPlug::createCounterpart( const std::string &name, Direction direction ) const { - return new Transform2dPlug( name, direction, getFlags() ); + return new Transform2DPlug( name, direction, getFlags() ); } -V2fPlug *Transform2dPlug::pivotPlug() +V2fPlug *Transform2DPlug::pivotPlug() { return getChild( g_firstPlugIndex+3 ); } -const V2fPlug *Transform2dPlug::pivotPlug() const +const V2fPlug *Transform2DPlug::pivotPlug() const { return getChild( g_firstPlugIndex+3 ); } -V2fPlug *Transform2dPlug::translatePlug() +V2fPlug *Transform2DPlug::translatePlug() { return getChild( g_firstPlugIndex ); } -const V2fPlug *Transform2dPlug::translatePlug() const +const V2fPlug *Transform2DPlug::translatePlug() const { return getChild( g_firstPlugIndex ); } -FloatPlug *Transform2dPlug::rotatePlug() +FloatPlug *Transform2DPlug::rotatePlug() { return getChild( g_firstPlugIndex+1 ); } -const FloatPlug *Transform2dPlug::rotatePlug() const +const FloatPlug *Transform2DPlug::rotatePlug() const { return getChild( g_firstPlugIndex+1 ); } -V2fPlug *Transform2dPlug::scalePlug() +V2fPlug *Transform2DPlug::scalePlug() { return getChild( g_firstPlugIndex+2 ); } -const V2fPlug *Transform2dPlug::scalePlug() const +const V2fPlug *Transform2DPlug::scalePlug() const { return getChild( g_firstPlugIndex+2 ); } -Imath::M33f Transform2dPlug::matrix() const +Imath::M33f Transform2DPlug::matrix() const { M33f p; p.translate( pivotPlug()->getValue() ); diff --git a/src/GafferBindings/Transform2dPlugBinding.cpp b/src/GafferBindings/Transform2DPlugBinding.cpp similarity index 86% rename from src/GafferBindings/Transform2dPlugBinding.cpp rename to src/GafferBindings/Transform2DPlugBinding.cpp index cd5b30985e3..9ba8e09d3f5 100644 --- a/src/GafferBindings/Transform2dPlugBinding.cpp +++ b/src/GafferBindings/Transform2DPlugBinding.cpp @@ -38,29 +38,29 @@ #include "IECorePython/RunTimeTypedBinding.h" -#include "Gaffer/Transform2dPlug.h" +#include "Gaffer/Transform2DPlug.h" #include "GafferBindings/PlugBinding.h" -#include "GafferBindings/Transform2dPlugBinding.h" +#include "GafferBindings/Transform2DPlugBinding.h" using namespace boost::python; using namespace GafferBindings; using namespace Gaffer; -void GafferBindings::bindTransform2dPlug() +void GafferBindings::bindTransform2DPlug() { - IECorePython::RunTimeTypedClass() + IECorePython::RunTimeTypedClass() .def( init< const std::string &, Gaffer::Plug::Direction, unsigned > ( ( - arg( "name" ) = Gaffer::Transform2dPlug::staticTypeName(), + arg( "name" ) = Gaffer::Transform2DPlug::staticTypeName(), arg( "direction" ) = Gaffer::Plug::In, arg( "flags" ) = Gaffer::Plug::Default ) ) ) - .GAFFERBINDINGS_DEFPLUGWRAPPERFNS( Transform2dPlug ) - .def( "matrix", &Transform2dPlug::matrix ) + .GAFFERBINDINGS_DEFPLUGWRAPPERFNS( Transform2DPlug ) + .def( "matrix", &Transform2DPlug::matrix ) ; } diff --git a/src/GafferModule/GafferModule.cpp b/src/GafferModule/GafferModule.cpp index 4414364e533..e716ef14147 100644 --- a/src/GafferModule/GafferModule.cpp +++ b/src/GafferModule/GafferModule.cpp @@ -66,7 +66,7 @@ #include "GafferBindings/BoxPlugBinding.h" #include "GafferBindings/ExpressionBinding.h" #include "GafferBindings/TransformPlugBinding.h" -#include "GafferBindings/Transform2dPlugBinding.h" +#include "GafferBindings/Transform2DPlugBinding.h" #include "GafferBindings/CompoundDataPlugBinding.h" #include "GafferBindings/RandomBinding.h" #include "GafferBindings/DependencyNodeBinding.h" @@ -111,7 +111,7 @@ BOOST_PYTHON_MODULE( _Gaffer ) bindBoxPlug(); bindExpression(); bindTransformPlug(); - bindTransform2dPlug(); + bindTransform2DPlug(); bindCompoundDataPlug(); bindRandom(); bindBox();