TuttleOFX  1
Move2DPlugin.cpp
Go to the documentation of this file.
00001 #include "Move2DPlugin.hpp"
00002 #include "Move2DProcess.hpp"
00003 #include "Move2DDefinitions.hpp"
00004 
00005 #include <boost/gil/gil_all.hpp>
00006 #include <boost/gil/utilities.hpp>
00007 
00008 namespace tuttle {
00009 namespace plugin {
00010 namespace move2D {
00011 
00012 
00013 Move2DPlugin::Move2DPlugin( OfxImageEffectHandle handle )
00014 : ImageEffectGilPlugin( handle )
00015 {
00016 //    _clipSrcMatte = fetchClip( kClipMatte );
00017         _paramTranslation = fetchDouble2DParam( kParamTranslation );
00018 }
00019 
00020 Move2DProcessParams<Move2DPlugin::Scalar> Move2DPlugin::getProcessParams( const OfxPointD& renderScale ) const
00021 {
00022         Move2DProcessParams<Scalar> params;
00023 
00024         OfxPointD translation = _paramTranslation->getValue();
00025         params._translation.x = translation.x;
00026         params._translation.y = translation.y;
00027         
00028         return params;
00029 }
00030 
00031 void Move2DPlugin::changedParam( const OFX::InstanceChangedArgs &args, const std::string &paramName )
00032 {
00033 }
00034 
00035 bool Move2DPlugin::getRegionOfDefinition( const OFX::RegionOfDefinitionArguments& args, OfxRectD& rod )
00036 {
00037         const Move2DProcessParams<Scalar> params = getProcessParams();
00038         OfxRectD srcRod = _clipSrc->getCanonicalRod( args.time );
00039 
00040 //      switch( params._border )
00041 //      {
00042 //              case eParamBorderPadded:
00043                         rod.x1 = srcRod.x1 + params._translation.x;
00044                         rod.y1 = srcRod.y1 + params._translation.y;
00045                         rod.x2 = srcRod.x2 + params._translation.x;
00046                         rod.y2 = srcRod.y2 + params._translation.y;
00047                         return true;
00048 //              default:
00049 //                      break;
00050 //      }
00051 //      return false;
00052 }
00053 
00054 void Move2DPlugin::getRegionsOfInterest( const OFX::RegionsOfInterestArguments& args, OFX::RegionOfInterestSetter& rois )
00055 {
00056         const Move2DProcessParams<Scalar> params = getProcessParams();
00057         OfxRectD srcRoi;
00058 
00059 //      switch( params._border )
00060 //      {
00061 //              case eParamBorderPadded:
00062                         srcRoi.x1 = args.regionOfInterest.x1 - params._translation.x;
00063                         srcRoi.y1 = args.regionOfInterest.y1 - params._translation.y;
00064                         srcRoi.x2 = args.regionOfInterest.x2 - params._translation.x;
00065                         srcRoi.y2 = args.regionOfInterest.y2 - params._translation.y;
00066 //              default:
00067 //                      break;
00068 //      }
00069 
00070         rois.setRegionOfInterest( *this->_clipSrc, srcRoi );
00071 }
00072 
00073 bool Move2DPlugin::isIdentity( const OFX::RenderArguments& args, OFX::Clip*& identityClip, double& identityTime )
00074 {
00075         const Move2DProcessParams<Scalar> params = getProcessParams();
00076         
00077         static const boost::gil::point2<Scalar> zero(0, 0);
00078         if( params._translation == zero )
00079         {
00080                 identityClip = this->_clipSrc;
00081                 identityTime = args.time;
00082                 return true;
00083         }
00084         return false;
00085 }
00086 
00087 /**
00088  * @brief The overridden render function
00089  * @param[in]   args     Rendering parameters
00090  */
00091 void Move2DPlugin::render( const OFX::RenderArguments &args )
00092 {
00093         doGilRender<Move2DProcess>( *this, args );
00094 }
00095 
00096 
00097 }
00098 }
00099 }