Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Box UI improvements #2011

Merged
merged 25 commits into from
Apr 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c173641
Gaffer : Add BoxIO node
johnhaddon Mar 8, 2017
fedf572
Gaffer : Add BoxIn node
johnhaddon Mar 8, 2017
ae8adb9
Gaffer : Add BoxOut node
johnhaddon Mar 8, 2017
7f25832
Box binding : Move serialiser to anonymous namespace
johnhaddon Mar 8, 2017
f96d2ff
GafferBindings : Add BoxIO/BoxIn/BoxOut bindings
johnhaddon Mar 8, 2017
cafa6ed
GafferTest : Add tests for BoxIO nodes
johnhaddon Mar 8, 2017
c9dbbab
StandardNodeGadget : Remove unused implementation detail
johnhaddon Mar 15, 2017
61c3ff5
StandardNodeGadget : Add support for icon metadata
johnhaddon Mar 15, 2017
202e3dc
StandardNodeGadget : Fix comment
johnhaddon Mar 15, 2017
d192872
StandardNodeGadget : Support "nodeGadget:shape" metadata
johnhaddon Mar 15, 2017
a0d6f10
Graphics : Add icons for BoxIO nodes
johnhaddon Mar 15, 2017
3b3b4b0
GafferUI : Add UI files for BoxIO nodes
johnhaddon Mar 8, 2017
43269ad
GafferUI : Add custom node gadget for BoxIO
johnhaddon Mar 8, 2017
d23f898
BoxUI : Add a PlugAdder on each edge
johnhaddon Mar 8, 2017
f079e5a
StandardGraphLayout : Support auto-connect of BoxOut nodes
johnhaddon Mar 8, 2017
fddc229
GUI config : Add colour for BoxIO nodes
johnhaddon Mar 15, 2017
be1e4d1
Node menu : Add BoxIn/BoxOut nodes
johnhaddon Mar 8, 2017
40295c8
BoxIO : Delete automatically when promoted plugs are deleted
johnhaddon Mar 31, 2017
3d1893f
Box : Ignore BoxIO nodes in `create()`
johnhaddon Mar 31, 2017
86b293d
BoxIO : Add static utility methods
johnhaddon Apr 13, 2017
1874e01
BoxUI : Use BoxIO for promotion
johnhaddon Apr 13, 2017
e6ce645
BoxUI : Only allow deletion of top level plugs
johnhaddon Apr 13, 2017
269918e
BoxInTest : Add test for deletion of promoted ArrayPlug
johnhaddon Apr 13, 2017
9c9a020
BoxUI : Use top level parent in Nodule context menu
johnhaddon Apr 13, 2017
6e0fb6b
BoxIO : Apply StandardNodule metadata when promoting an ArrayPlug
johnhaddon Apr 18, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 0 additions & 7 deletions include/Gaffer/Box.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,6 @@

#include "Gaffer/SubGraph.h"

namespace GafferBindings
{

class BoxSerialiser;

} // namespace GafferBindings

namespace Gaffer
{

Expand Down
169 changes: 169 additions & 0 deletions include/Gaffer/BoxIO.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
//////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2017, 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 GAFFER_BOXIO_H
#define GAFFER_BOXIO_H

#include "Gaffer/Node.h"
#include "Gaffer/Plug.h"

namespace Gaffer
{

IE_CORE_FORWARDDECLARE( StringPlug )
IE_CORE_FORWARDDECLARE( Box )

/// Utility node for representing plug promotion
/// graphically in the NodeGraph. Note that this has
/// no special priviledges or meaning in the Box API;
/// it is merely a convenience for the user.
///
/// In terms of structure, BoxIO is much like
/// a Dot, with an internal pass-through connection
/// between a single input plug and a single output plug.
/// It differs in that one of these plugs is
/// always private and managed such that it is
/// automatically promoted to any parent Box. Which plug
/// is promoted is determined by the BoxIO's direction,
/// which specifies whether it provides an input or
/// output for the box.
///
/// The BoxIO constructor is protected. Construct
/// the derived BoxIn and BoxOut classes rather than
/// attempt to construct BoxIO itself.
class BoxIO : public Node
{

public :

virtual ~BoxIO();

IE_CORE_DECLARERUNTIMETYPEDEXTENSION( Gaffer::BoxIO, BoxIOTypeId, Node );

StringPlug *namePlug();
const StringPlug *namePlug() const;

/// Sets this node up using `plug`
/// as a prototype. Call this after
/// construction to determine what
/// sort of plug this node will promote.
void setup( const Plug *plug );

/// The internal plug which
/// can be used within the box.
/// Will be NULL unless `setup()`
/// has been called.
template<typename T>
T *plug();
template<typename T>
const T *plug() const;

/// The external plug which has
/// been promoted to the outside
/// of the box. Will be NULL unless
/// `setup()` has been called.
template<typename T>
T *promotedPlug();
template<typename T>
const T *promotedPlug() const;

Plug::Direction direction() const;

/// Static utility methods
/// ======================
///
/// Equivalent to `PlugAlgo::promote()`, but
/// inserting an intermediate BoxIO node where
/// relevant (based on querying nodule layout
/// metadata).
/// \undoable
static Plug *promote( Plug *plug );
/// Inserts intermediate BoxIO nodes for any
/// promoted plugs that require them (based
/// on querying nodule layout metadata). This
/// can be used to upgrade boxes that were
/// either authored in the pre-BoxIO era, or
/// were created by automated scripts that
/// are not BoxIO savvy.
/// \undoable
static void insert( Box *box );
/// Returns true if `insert( box )` would
/// do anything.
/// \undoable
static bool canInsert( const Box *box );

protected :

BoxIO( Plug::Direction direction, const std::string &name=defaultName<BoxIO>() );

Gaffer::Plug *inPlugInternal();
const Gaffer::Plug *inPlugInternal() const;

Gaffer::Plug *outPlugInternal();
const Gaffer::Plug *outPlugInternal() const;

virtual void parentChanging( Gaffer::GraphComponent *newParent );

private :

IECore::InternedString inPlugName() const;
IECore::InternedString outPlugName() const;

Plug::Direction m_direction;

boost::signals::scoped_connection m_promotedPlugNameChangedConnection;
boost::signals::scoped_connection m_promotedPlugParentChangedConnection;

void plugSet( Plug *plug );
void parentChanged( GraphComponent *oldParent );
void plugInputChanged( Plug *plug );
void promotedPlugNameChanged( GraphComponent *graphComponent );
void promotedPlugParentChanged( GraphComponent *graphComponent );

static size_t g_firstPlugIndex;

};

IE_CORE_DECLAREPTR( BoxIO )

typedef FilteredChildIterator<TypePredicate<BoxIO> > BoxIOIterator;
typedef FilteredRecursiveChildIterator<TypePredicate<BoxIO> > RecursiveBoxIOIterator;

} // namespace Gaffer

#include "Gaffer/BoxIO.inl"

#endif // GAFFER_BOXIO_H
95 changes: 95 additions & 0 deletions include/Gaffer/BoxIO.inl
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
//////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2017, 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 GAFFER_BOXIO_INL
#define GAFFER_BOXIO_INL

#include "Gaffer/Node.h"
#include "Gaffer/Plug.h"

namespace Gaffer
{

template<typename T>
T *BoxIO::plug()
{
return IECore::runTimeCast<T>(
m_direction == Plug::In ? outPlugInternal() : inPlugInternal()
);
}

template<typename T>
const T *BoxIO::plug() const
{
return IECore::runTimeCast<const T>(
m_direction == Plug::In ? outPlugInternal() : inPlugInternal()
);
}

template<typename T>
T *BoxIO::promotedPlug()
{
if( m_direction == Plug::In )
{
if( Plug *p = inPlugInternal() )
{
return p->getInput<T>();
}
}
else
{
if( Plug *p = outPlugInternal() )
{
const Plug::OutputContainer &outputs = p->outputs();
if( !outputs.empty() )
{
return outputs.front();
}
}
}
return NULL;
}

template<typename T>
const T *BoxIO::promotedPlug() const
{
// Prefer cast over maintaining identical copies of function
return const_cast<BoxIO *>( this )->promotedPlug<T>();
}

} // namespace Gaffer

#endif // GAFFER_BOXIO_INL
64 changes: 64 additions & 0 deletions include/Gaffer/BoxIn.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2017, 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 GAFFER_BOXIN_H
#define GAFFER_BOXIN_H

#include "Gaffer/BoxIO.h"

namespace Gaffer
{

class BoxIn : public BoxIO
{

public :

BoxIn( const std::string &name=defaultName<BoxIn>() );
virtual ~BoxIn();

IE_CORE_DECLARERUNTIMETYPEDEXTENSION( Gaffer::BoxIn, BoxInTypeId, BoxIO );

};

IE_CORE_DECLAREPTR( BoxIn )

typedef FilteredChildIterator<TypePredicate<BoxIn> > BoxInIterator;
typedef FilteredRecursiveChildIterator<TypePredicate<BoxIn> > RecursiveBoxInIterator;

} // namespace Gaffer

#endif // GAFFER_BOXIN_H