DD::Image::NukeWrapper Class Reference

Inherits DD::Image::Iop.

List of all members.

Public Member Functions

const MetaData::Bundle_fetchMetaData (const char *key)
Iopwrapped_iop () const
 Return Iop passed to constructor.
void _invalidate ()
void _validate (bool)
void _open ()
void _close ()
void knobs (Knob_Callback)
int knob_changed (Knob *k)
virtual bool can_clone () const
virtual HandlesMode doAnyHandles (ViewerContext *viewer)
virtual void inputsAttached ()
virtual int knob_change_finished (Knob *k, bool changedByUser)
virtual bool onAction (const ViewerContext *c, const DD::Image::Flags f, void *d)
void build_handles (ViewerContext *)
void draw_handle (ViewerContext *)
int optional_input () const
int minimum_inputs () const
int maximum_inputs () const
bool test_input (int, Op *) const
void set_input (int, Op *, int, int)
void inputs (int n)
void setOutputContext (const OutputContext &c)
void append (Hash &)
Opdefault_input (int) const
int split_input (int n) const
float uses_input (int) const
const OutputContextinputContext (int n, int offset, OutputContext &) const
const char * node_shape () const
unsigned node_color () const
const char * node_help () const
const char * input_label (int, char *) const
const char * Class () const
const char * displayName () const
void _request (int x, int y, int r, int t, ChannelMask, int count)
void engine (int y, int x, int r, ChannelMask, Row &)
bool pass_transform () const
void in_channels (int, ChannelSet &) const
bool firstEngineRendersWholeRequest () const
void build_splits ()
virtual std::vector
< DD::Image::OutputContext
getPrevVersionsWanted () const
 NukeWrapper (PixelIop *op)
 NukeWrapper (Iop *op)
NukeWrappernoMix ()
NukeWrappernoChannels ()
NukeWrappernoMask ()
NukeWrappernoUnpremult ()
NukeWrapperchannels (ChannelSetInit i)
NukeWrapperchannelsRGBoptionalAlpha ()
 ~NukeWrapper ()
ChannelMask channels () const
virtual const char * gpuEngine_decl () const
virtual const char * gpuEngine_body () const
virtual void gpuEngine_GL_begin (GPUContext *context)
virtual void gpuEngine_GL_end (GPUContext *context)

Static Public Member Functions

static Opunwrap (Op *op)

Protected Member Functions

void knobsAtTheEnd ()


Detailed Description

Provides user-friendly masking and channel-selection controls to any operator. This makes the implementation of the operators much simpler and allows the basic operators to be much faster when used outside Nuke.

The wrapper uses the in_channels() and out_channels() calls of the subclass to figure out what channels it needs from it, intesects this with the user-settable channel selector, and only asks the subclass to calculate those. All other channels will be copied unchanged from input0(). The user can also select a "mask" channel, this is used to mix the original and final results. It can also do a constant dissolve between the input and result, controlled by the enable knob on the control panel.

Much work is done to avoid calling the inner operator for any data that is not going to be used. Zero channels are detected and skipped, and the mask is checked first and only the region inside it is requested.


Constructor & Destructor Documentation

NukeWrapper::NukeWrapper ( PixelIop op  ) 

If the NukeWrapper knows the wrapped Iop is a PixelIop subclass, it will call PixelIop::pixel_engine() directly, as this saves a lot of memory and cache space because it avoids getting the input pixels twice. This also enables the unpremultiply controls.

The op's engine() will not be called, so you should not override the PixelIop::engine(). If the subclass does, be sure to cast back to an Iop so that the Iop constructor is called.

References MAX(), DD::Image::Op::minimum_inputs(), and DD::Image::Op::parent().

NukeWrapper::NukeWrapper ( Iop op  ) 

The constructor takes a pointer to the Iop to "wrap". By default the full capabilities of the NukeWrapper are enabled, you can use the noMix(), noChannels(), noMask(), and noPremult() methods to turn off controls immediately after the constructor.

References DD::Image::Mask_All, MAX(), DD::Image::Op::minimum_inputs(), and DD::Image::Op::parent().

NukeWrapper::~NukeWrapper (  ) 

This deletes the iop!


Member Function Documentation

static Op* DD::Image::NukeWrapper::unwrap ( Op op  )  [inline, static]

Helper function, which unwraps an Op from a NukeWrapper if it is within one and returns the inner op, or just returns the op.

void NukeWrapper::_invalidate (  )  [virtual]

void NukeWrapper::_validate ( bool  for_real  )  [virtual]

void NukeWrapper::_open (  )  [virtual]

void NukeWrapper::_close (  )  [virtual]

Calls close() on the wrapped Iop.

Reimplemented from DD::Image::Iop.

References DD::Image::Op::close().

void NukeWrapper::knobs ( Knob_Callback  f  )  [virtual]

The knobs this creates are controlled by the flags argument sent to the constructor. The iop's knobs() function is called in the middle of this, after the channels and before the mask knobs are made.

Reimplemented from DD::Image::Op.

References DD::Image::Bool_knob(), DD::Image::Knob::DO_NOT_WRITE, DD::Image::Knob::EARLY_STORE, DD::Image::Float_knob(), DD::Image::Input_Channel_knob(), DD::Image::INVISIBLE, DD::Image::Knob::INVISIBLE, DD::Image::Op::knobs(), DD::Image::Newline(), DD::Image::Knob::NO_ALPHA_PULLDOWN, DD::Image::Obsolete_knob(), DD::Image::SetFlags(), and DD::Image::Tooltip().

int NukeWrapper::knob_changed ( Knob k  )  [virtual]

Shows only the relevant maskChannel control depending on whether the mask input is connected and being used. This avoids questions about what happens when you set both of them (the answer is that the maskChannelInput is used and the mask input is ignored).

This also calls knob_changed() on the wrapped Iop.

Reimplemented from DD::Image::Op.

References DD::Image::Knob::hide(), DD::Image::Knob::inputChange, DD::Image::Knob::is(), DD::Image::Op::knob(), DD::Image::Op::knob_changed(), DD::Image::Op::node_input(), DD::Image::Knob::show(), and DD::Image::Knob::showPanel.

void NukeWrapper::build_handles ( ViewerContext c  )  [virtual]

Passed through to the iop.

Reimplemented from DD::Image::Iop.

References DD::Image::Iop::build_handles().

void NukeWrapper::draw_handle ( ViewerContext c  )  [virtual]

Passed through to the iop.

Reimplemented from DD::Image::Op.

References DD::Image::Op::draw_handle().

int NukeWrapper::optional_input (  )  const [virtual]

Returns the Iop's result. If the Iop actually has any optional inputs, the NukeWrapper's optional mask input is inserted after them.

Reimplemented from DD::Image::Op.

References DD::Image::Op::optional_input().

int NukeWrapper::minimum_inputs (  )  const [virtual]

Returns the result from the iop plus 1 for the mask

Reimplemented from DD::Image::Op.

int NukeWrapper::maximum_inputs (  )  const [virtual]

Returns the result from the iop plus 1 for the mask

Reimplemented from DD::Image::Op.

References MAX(), and DD::Image::Op::maximum_inputs().

bool NukeWrapper::test_input ( int  n,
Op op 
) const [virtual]

Returns the result from the wrapped iop for any input other than 0. For input 0 only Iop's are allowed, make sure you don't wrap an operator that expects something else!

Reimplemented from DD::Image::Iop.

References DD::Image::Iop::test_input().

void NukeWrapper::set_input ( int  n,
Op op,
int  base,
int  offset 
) [virtual]

Change the corresponding input of the wrapped op.

Reimplemented from DD::Image::Op.

References DD::Image::Op::set_input().

void NukeWrapper::setOutputContext ( const OutputContext c  )  [virtual]

Passed through to the wrapped iop.

Reimplemented from DD::Image::Op.

References DD::Image::Op::setOutputContext().

Op * NukeWrapper::default_input ( int  n  )  const [virtual]

Returns the result from the wrapped iop for any input other than 0. For input 0 it uses the default Iop input (a black image)

Reimplemented from DD::Image::Iop.

References DD::Image::Iop::default_input().

int NukeWrapper::split_input ( int  n  )  const [virtual]

Returns the result from the iop. The Iop must not return < 1 for n == 0! And it currently screws up if anything other than 1 is returned...

Reimplemented from DD::Image::Op.

References DD::Image::Op::split_input().

float NukeWrapper::uses_input ( int  n  )  const [virtual]

Returns the result from the iop, except if the Mix slider is turned off it returns 1 for input 0 and 0 for all others.

Reimplemented from DD::Image::Op.

References lerp(), DD::Image::Op::uses_input(), and DD::Image::IopInfoOwner::x().

const OutputContext & NukeWrapper::inputContext ( int  n,
int  offset,
OutputContext temp 
) const [virtual]

Passed through to the iop. Any changes it makes to input 0 will also effect the masked-off area or the turned-off channels, which may not be what the user expects.

Reimplemented from DD::Image::Op.

References DD::Image::Op::inputContext(), and DD::Image::Op::outputContext().

const char * NukeWrapper::node_shape (  )  const [virtual]

Passed through to the wrapped iop.

Reimplemented from DD::Image::Op.

References DD::Image::Op::node_shape().

unsigned NukeWrapper::node_color (  )  const [virtual]

Passed through to the wrapped iop.

Reimplemented from DD::Image::Op.

References DD::Image::Op::node_color().

const char * NukeWrapper::node_help (  )  const [virtual]

Passed through to the wrapped iop.

Implements DD::Image::Op.

References DD::Image::Op::node_help().

const char * NukeWrapper::input_label ( int  n,
char *  buffer 
) const [virtual]

Passed through to the wrapped iop.

Reimplemented from DD::Image::Op.

References DD::Image::Op::input_label().

const char * NukeWrapper::Class (  )  const [virtual]

Returns the result from the iop.

Implements DD::Image::Op.

References DD::Image::Op::Class().

const char * NukeWrapper::displayName (  )  const [virtual]

Returns the result from the iop.

Reimplemented from DD::Image::Op.

References DD::Image::Op::displayName().

void NukeWrapper::_request ( int  x,
int  y,
int  r,
int  t,
ChannelMask  channels,
int  count 
) [virtual]

Calls request() on the inner Iop, which will usually cause a request() to be done of the inputs to this Iop. If the mask or blending is enabled this will also call request() on input0() and this usually results in a count of 2 and the cache being enabled on the input.

If the op is a PixelIop request() of the input is called with count = 0, which should prevent the cache from being created.

Reimplemented from DD::Image::Iop.

References DD::Image::Iop::input(), DD::Image::Iop::input0(), and DD::Image::Iop::request().

void NukeWrapper::engine ( int  y,
int  x,
int  r,
ChannelMask  channels,
Row row 
) [virtual]

Calls engine() of the Iop, and (depending on the settings) this also reads raw data in from the input and mixes it together with the iop output to produce the final image.

If the operator is a PixelIop, PixelIop::pixel_engine() is called directly to avoid having to read a row twice from the input.

If a mask is enabled and the process-mask flag is off, the mask is looked at first, and only the non-zero region is requested with the x and r arguments to the iop's engine. If the mask is completely blank no line is asked for at all. Make sure your wrapped Iop can handle x and r changing.

Implements DD::Image::Iop.

References DD::Image::Row::copy(), DD::Image::Iop::get(), DD::Image::Iop::in_channels(), DD::Image::Iop::input(), DD::Image::Iop::input0(), DD::Image::Row::is_zero(), DD::Image::Row::pre_copy(), and DD::Image::Row::writable().

void NukeWrapper::in_channels ( int  n,
ChannelSet channels 
) const [virtual]

Fairly complex, this returns the correct set taking into account the in_channels() of the Iop, and the settings of premult, mask, and the mix slider.

Reimplemented from DD::Image::Iop.

References DD::Image::Iop::in_channels().

bool NukeWrapper::firstEngineRendersWholeRequest (  )  const [virtual]

Passed through to the wrapped iop.

Reimplemented from DD::Image::Op.

References DD::Image::Op::firstEngineRendersWholeRequest().

NukeWrapper * NukeWrapper::noMix (  ) 

You can call this immediately after the constructor to remove the "mix" control. You don't want this if your operator has a mixing or amplitude control of it's own.

NukeWrapper * NukeWrapper::noChannels (  ) 

You can call this immediately after the constructor to remove the channel selector controls. You don't want this if your operator does not naturally operate on all channels.

Returns this to allow you to call this in the same statement as the constructor.

NukeWrapper * NukeWrapper::noMask (  ) 

You can call this immediately after the constructor to remove the "mask" control and the extra mask input. You don't want this if your operator has it's own masking or some other way of using a channel to control it's amplitude.

NukeWrapper * NukeWrapper::noUnpremult (  ) 

You can call this immediately after the constructor to remove the "unpremult by" control. You don't want this if your operator requires premultiplied images.



©2009 The Foundry Visionmongers, Ltd. All Rights Reserved.
www.thefoundry.co.uk