void Crop::compute( Gaffer::ValuePlug *output, const Gaffer::Context *context ) const { if ( output == cropWindowPlug() ) { int areaSource = areaSourcePlug()->getValue(); Imath::Box2i cropWindow; switch ( areaSource ) { case Crop::DataWindow: { cropWindow = inPlug()->dataWindowPlug()->getValue(); break; } case Crop::DisplayWindow: { cropWindow = inPlug()->formatPlug()->getValue().getDisplayWindow(); break; } case Crop::Format: { cropWindow = formatPlug()->getValue().getDisplayWindow(); if( formatCenterPlug()->getValue() ) { const Imath::Box2i displayWindow = inPlug()->formatPlug()->getValue().getDisplayWindow(); Imath::V2i centerOffset( cropWindow.center() - displayWindow.center() ); cropWindow.min -= centerOffset; cropWindow.max -= centerOffset; } break; } default: { cropWindow = areaPlug()->getValue(); break; } } static_cast<Gaffer::AtomicBox2iPlug *>( output )->setValue( cropWindow ); } else if( output->parent<Plug>() == offsetPlug() ) { ImagePlug::GlobalScope c( context ); V2i offset( 0 ); if( affectDisplayWindowPlug()->getValue() ) { if( resetOriginPlug()->getValue() ) { offset -= cropWindowPlug()->getValue().min; } else if( areaSourcePlug()->getValue() == Crop::Format && formatCenterPlug()->getValue() ) { offset -= cropWindowPlug()->getValue().min - formatPlug()->getValue().getDisplayWindow().min; } } static_cast<IntPlug *>( output )->setValue( output == offsetPlug()->getChild( 0 ) ? offset[0] : offset[1] ); } else { ImageProcessor::compute( output, context ); } }