Corrected a bug where the data window of an image is displayed incorrectly in the ImageViewer.
Simplified some arithmetic.
Merge pull request #744 from goddardl/ImageViewerUiFix

Image Viewer UI Fix
Added graph layout algorithm and Edit/Arrange menu item.

The algorithm is invoked via a new pure virtual GraphLayout::layoutNodes() method, which is implemented in the StandardGraphLayout class. The StandardGraphLayout uses a new internal LayoutEngine class which converts the GraphGadget contents into boost::graph form, and then uses a hybrid combination of force directed layout and hard constraints to produce something resembling a sensible layout, before transferring it back to the GraphGadget.

The hybrid approach was necessary because existing layered graph drawing algorithms don't apply too well to our graphs where connections flow both left->right /and/ top->bottom. Pleasingly, it also can be seen as a generalisation of the existing system we had for positioning nodes one at a time in positionNode() or as a group in positionNodes(), where the former soft constraints are treated as springs and iteration over the hard constraints is used to allow more complex constraint relationships to be resolved, along with collisions. This means that positionNode() and positionNodes() are now implemented using the same LayoutEngine as layoutNodes().

Hopefully fixes #638 sufficiently to be given a go in the wild before we make new issues for further refinement.
Fixed TextGadget vertical bound.

It is now always big enough to fully enclose any character in height, rather than changing height when taller characters are added or removed. This fixes StandardNodeGadget heights which were dependent on the node name.
Updated GraphGadget for new layout code.

Removed inappropriate call to positionNode() in GraphGadget. There's a significant overhead to this now, and it's also unnecessary, because the creator of the node is responsible for calling one of the layout functions at the appropriate time. Removed \todo which suggested that GraphGadget should automatically figure out the right thing to do get new nodes laid out properly - I now think that this requires external knowledge unavailable to the GraphGadget (e.g. is this an import operation, or a paste, or a new node, or a whole load of scripted operations).
Added failing NodeGraph test case.

The problem is that GraphGadget makes a position plug immediately upon a new node being added, in addNodeGadget(). But when a node with an existing position plug is being pasted, it will add a second position plug immediately after, resulting it being named and becoming a useless duplicate. Perhaps ideally we shouldn't add the plug at all in addNodeGadget(), but we currently rely on it existing in offsetNodes(), so it's not totally clear what the best approach is.
Merge pull request #745 from johnhaddon/constrainedLayoutRebased

Automatic graph layout
Moved OSLImage::shadingEngine() to OSLShader::shadingEngine().

It makes more sense there as the shade node is the one responsible for representing shaders, and it was weird that OSLObject had to use OSLImage functionality.
Added arbitrary channel and layer support to OSLImage.
Fixed dirty propagation through OSLShader closure outputs.
Moved OSLObject and OSLImage shader input to the left of the node.
Added V3fVectorData support to OSLRenderer user data queries.
Added arbitrary primitive variables output to OSLObject.
Improved OSL processor shader input acceptance.

- Only accepts OSLShader nodes if they hold a surface shader, as other shader types can't be used directly.
- Also accepts Box and ShaderSwitch connections so that shaders can be connected indirectly.
Disabled caching of OSLImage channelData plug.

Effectively it is cached already in the __shading plug, and we don't want to count the memory twice.
Fixed disappearing 0 values in OSLObject and OSLImage.

The problem was that we were using the weight of a debug closure to specify the value for channels and primitive variables. OSL optimises away any closures with a zero weight, so we were ending up with no closure, and therefore were unable to correctly manipulate the image/object. Storing the value as an internal attribute on the debug closure and always using a weight of 1 works around this issue.
Replaced OSL Sum with OutObject and OutImage shaders.

Although these have identical functionality to the Sum shader (they just sum a bunch of closures), it's good to have shaders with names that make it clearer what their purpose is. Later on we may also be able to use metadata to limit the input closures to only come from the appropriate Out* shaders.
Revised shader naming convention to use UpperCamelCase.

Since the C++ analogue of directories full of shaders in is namespaces full of classes, this is more consistent with the rest of Gaffer. It's also convenient to be able to not have to worry about shader names clashing with function names.
Fixed unwanted copy/paste Plug.setValue() calls.

When the input to a plug wasn't part of the selection being copied, we were computing the input value and storing it as a setValue() call in the serialisation. This was bogus, because any computed value can be dependent on any part of a Context, and the Context in which we perform the serialisation may not be suitable for computing the value. Now copy/paste with excluded connections causes the plug to revert to its default value, which is more like the disconnection behaviour.

There is an argument that we should actually be outputting a setValue() call, but for the value that would exist if the connection was removed, but for now we've decided that this approach is sufficient to fix #740.

As for a fuller fix, there are still some open questions about how disconnection should affect the plug anyway. Perhaps for plugs with inputs which aren't from a ComputeNode (just a direct connection from a promoted plug for instance), there is an argument that they should retain the connected value rather than revert to their previous value. When we resolve these questions we could also revisit this issue.