Skip to content

Commit

Permalink
Added visualisation of clipping colours in the Viewer.
Browse files Browse the repository at this point in the history
Fixes #572.
  • Loading branch information
johnhaddon committed Nov 27, 2013
1 parent 40a1fe5 commit cfd3b94
Show file tree
Hide file tree
Showing 4 changed files with 217 additions and 47 deletions.
3 changes: 3 additions & 0 deletions include/GafferImageUI/ImageView.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ class ImageView : public GafferUI::View

IE_CORE_DECLARERUNTIMETYPEDEXTENSION( GafferImageUI::ImageView, ImageViewTypeId, GafferUI::View );

Gaffer::BoolPlug *clippingPlug();
const Gaffer::BoolPlug *clippingPlug() const;

Gaffer::FloatPlug *exposurePlug();
const Gaffer::FloatPlug *exposurePlug() const;

Expand Down
29 changes: 21 additions & 8 deletions python/GafferImageUI/ImageViewToolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,21 @@
# Toggles between default value and the last non-default value
class _TogglePlugValueWidget( GafferUI.PlugValueWidget ) :

def __init__( self, plug, image, defaultToggleValue = None, **kw ) :
def __init__( self, plug, imagePrefix, defaultToggleValue = None, **kw ) :

row = GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Horizontal )

GafferUI.PlugValueWidget.__init__( self, row, plug, **kw )

self.__imagePrefix = imagePrefix
with row :

button = GafferUI.Button( "", image, hasFrame=False )
self.__clickedConnection = button.clickedSignal().connect( Gaffer.WeakMethod( self.__clicked ) )
self.__button = GafferUI.Button( "", self.__imagePrefix + "Off.png", hasFrame=False )
self.__clickedConnection = self.__button.clickedSignal().connect( Gaffer.WeakMethod( self.__clicked ) )

plugValueWidget = GafferUI.PlugValueWidget.create( plug, useTypeOnly=True )
plugValueWidget.numericWidget().setFixedCharacterWidth( 5 )
if not isinstance( plug, Gaffer.BoolPlug ) :
plugValueWidget = GafferUI.PlugValueWidget.create( plug, useTypeOnly=True )
plugValueWidget.numericWidget().setFixedCharacterWidth( 5 )

self.__toggleValue = defaultToggleValue
self._updateFromPlug()
Expand All @@ -79,6 +81,9 @@ def _updateFromPlug( self ) :

if value != self.getPlug().defaultValue() :
self.__toggleValue = value
self.__button.setImage( self.__imagePrefix + "On.png" )
else :
self.__button.setImage( self.__imagePrefix + "Off.png" )

self.setEnabled( self.getPlug().settable() )

Expand All @@ -92,21 +97,29 @@ def __clicked( self, button ) :
else :
self.getPlug().setToDefault()

## Exposure and gamma
## Clipping, exposure and gamma

GafferUI.PlugValueWidget.registerCreator(
GafferImageUI.ImageView.staticTypeId(),
"clipping",
_TogglePlugValueWidget,
imagePrefix ="clipping",
defaultToggleValue = True,
)

GafferUI.PlugValueWidget.registerCreator(
GafferImageUI.ImageView.staticTypeId(),
"exposure",
_TogglePlugValueWidget,
image ="exposure.png",
imagePrefix ="exposure",
defaultToggleValue = 1,
)

GafferUI.PlugValueWidget.registerCreator(
GafferImageUI.ImageView.staticTypeId(),
"gamma",
_TogglePlugValueWidget,
image ="gamma.png",
imagePrefix ="gamma",
defaultToggleValue = 2,
)

Expand Down
204 changes: 167 additions & 37 deletions resources/graphics.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 26 additions & 2 deletions src/GafferImageUI/ImageView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
#include "GafferImage/Grade.h"
#include "GafferImage/ImagePlug.h"
#include "GafferImage/ImageStats.h"
#include "GafferImage/Clamp.h"

#include "GafferImageUI/ImageView.h"

Expand Down Expand Up @@ -933,15 +934,28 @@ ImageView::ImageView( const std::string &name )
NodePtr preprocessor = new Node;
ImagePlugPtr preprocessorInput = new ImagePlug( "in" );
preprocessor->addChild( preprocessorInput );

ImageStatsPtr statsNode = new ImageStats( "__imageStats" );
addChild( statsNode ); /// \todo Store this in the preprocessor when we've disallowed the changing of it by subclasses
statsNode->inPlug()->setInput( preprocessorInput );
statsNode->channelsPlug()->setInput( preprocessorInput->channelNamesPlug() );

ClampPtr clampNode = new Clamp();
preprocessor->setChild( "__clipping", clampNode );
clampNode->inPlug()->setInput( preprocessorInput );
clampNode->minClampToEnabledPlug()->setValue( true );
clampNode->maxClampToEnabledPlug()->setValue( true );
clampNode->minClampToPlug()->setValue( Color4f( 1.0f, 1.0f, 1.0f, 0.0f ) );
clampNode->maxClampToPlug()->setValue( Color4f( 0.0f, 0.0f, 0.0f, 1.0f ) );

BoolPlugPtr clippingPlug = new BoolPlug( "clipping" );
clippingPlug->setFlags( Plug::AcceptsInputs, false );
addChild( clippingPlug );
clampNode->enabledPlug()->setInput( clippingPlug );

GradePtr gradeNode = new Grade;
preprocessor->setChild( "__grade", gradeNode );
gradeNode->inPlug()->setInput( preprocessorInput );
gradeNode->inPlug()->setInput( clampNode->outPlug() );

FloatPlugPtr exposurePlug = new FloatPlug( "exposure" );
exposurePlug->setFlags( Plug::AcceptsInputs, false );
Expand Down Expand Up @@ -1009,6 +1023,16 @@ ImageView::~ImageView()
{
}

Gaffer::BoolPlug *ImageView::clippingPlug()
{
return getChild<BoolPlug>( "clipping" );
}

const Gaffer::BoolPlug *ImageView::clippingPlug() const
{
return getChild<BoolPlug>( "clipping" );
}

Gaffer::FloatPlug *ImageView::exposurePlug()
{
return getChild<FloatPlug>( "exposure" );
Expand Down

0 comments on commit cfd3b94

Please sign in to comment.