TuttleOFX  1
LocalMaximaPlugin.cpp
Go to the documentation of this file.
00001 #include "LocalMaximaPlugin.hpp"
00002 #include "LocalMaximaProcess.hpp"
00003 #include "LocalMaximaDefinitions.hpp"
00004 
00005 #include <boost/gil/gil_all.hpp>
00006 
00007 namespace tuttle {
00008 namespace plugin {
00009 namespace localmaxima {
00010 
00011 
00012 LocalMaximaPlugin::LocalMaximaPlugin( OfxImageEffectHandle handle )
00013 : ImageEffectGilPlugin( handle )
00014 {
00015         _paramBorder = fetchChoiceParam( kParamBorder );
00016         _paramOutputComponent = fetchChoiceParam( kParamOutputComponent );
00017 }
00018 
00019 LocalMaximaProcessParams<LocalMaximaPlugin::Scalar> LocalMaximaPlugin::getProcessParams( const OfxPointD& renderScale ) const
00020 {
00021         LocalMaximaProcessParams<Scalar> params;
00022 
00023         params._border     = static_cast<EParamBorder>( _paramBorder->getValue() );
00024 
00025         return params;
00026 }
00027 
00028 void LocalMaximaPlugin::changedParam( const OFX::InstanceChangedArgs &args, const std::string &paramName )
00029 {
00030 //    if( paramName == kParamHelpButton )
00031 //    {
00032 //        sendMessage( OFX::Message::eMessageMessage,
00033 //                     "", // No XML resources
00034 //                     kParamHelpString );
00035 //    }
00036 }
00037 
00038 void LocalMaximaPlugin::getClipPreferences( OFX::ClipPreferencesSetter& clipPreferences )
00039 {
00040         EParamOutputComponent comp = static_cast<EParamOutputComponent>(_paramOutputComponent->getValue());
00041         switch( comp )
00042         {
00043                 case eParamOutputComponentRGBA:
00044                 {
00045                         clipPreferences.setClipComponents( *_clipDst, OFX::ePixelComponentRGBA );
00046                         break;
00047                 }
00048                 case eParamOutputComponentRGB:
00049                 {
00050                         clipPreferences.setClipComponents( *_clipDst, OFX::ePixelComponentRGB );
00051                         break;
00052                 }
00053                 case eParamOutputComponentAlpha:
00054                 {
00055                         clipPreferences.setClipComponents( *_clipDst, OFX::ePixelComponentAlpha );
00056                         break;
00057                 }
00058         }
00059 }
00060 
00061 bool LocalMaximaPlugin::getRegionOfDefinition( const OFX::RegionOfDefinitionArguments& args, OfxRectD& rod )
00062 {
00063         LocalMaximaProcessParams<Scalar> params = getProcessParams();
00064         OfxRectD srcRod = _clipSrc->getCanonicalRod( args.time );
00065 
00066         switch( params._border )
00067         {
00068                 case eParamBorderPadded:
00069                         rod.x1 = srcRod.x1 + 1;
00070                         rod.y1 = srcRod.y1 + 1;
00071                         rod.x2 = srcRod.x2 - 1;
00072                         rod.y2 = srcRod.y2 - 1;
00073                         return true;
00074                 default:
00075                         break;
00076         }
00077         return false;
00078 }
00079 
00080 void LocalMaximaPlugin::getRegionsOfInterest( const OFX::RegionsOfInterestArguments& args, OFX::RegionOfInterestSetter& rois )
00081 {
00082         const OfxRectD srcRod = _clipSrc->getCanonicalRod( args.time );
00083 
00084         OfxRectD srcRoi;
00085         srcRoi.x1 = srcRod.x1 - 1;
00086         srcRoi.y1 = srcRod.y1 - 1;
00087         srcRoi.x2 = srcRod.x2 + 1;
00088         srcRoi.y2 = srcRod.y2 + 1;
00089         rois.setRegionOfInterest( *_clipSrc, srcRoi );
00090 }
00091 
00092 /**
00093  * @brief The overridden render function
00094  * @param[in]   args     Rendering parameters
00095  */
00096 void LocalMaximaPlugin::render( const OFX::RenderArguments &args )
00097 {
00098         doGilRender2<LocalMaximaProcess>( *this, args, *_clipSrc, *_clipDst );
00099         
00100 //      OFX::EBitDepth sBitDepth = _clipSrc->getPixelDepth( );
00101 //      OFX::EPixelComponent sComponent = _clipSrc->getPixelComponents( );
00102 //
00103 //      OFX::EBitDepth dBitDepth = _clipDst->getPixelDepth( );
00104 //      OFX::EPixelComponent dComponent = _clipDst->getPixelComponents( );
00105 //
00106 //      switch( sComponent )
00107 //      {
00108 //              case OFX::ePixelComponentRGBA:
00109 //              {
00110 //                      doGilRender2<LocalMaximaProcess, false, boost::gil::rgba_layout_t>( *this, args, sBitDepth, false, dComponent, dBitDepth );
00111 //                      return;
00112 //              }
00113 //              case OFX::ePixelComponentRGB:
00114 //              {
00115 ////                    doGilRender2<LocalMaximaProcess, false, boost::gil::rgb_layout_t>( *this, args, sBitDepth, false, dComponent, dBitDepth );
00116 //                      return;
00117 //              }
00118 //              case OFX::ePixelComponentAlpha:
00119 //              case OFX::ePixelComponentCustom:
00120 //              case OFX::ePixelComponentNone:
00121 //              {
00122 //                      BOOST_THROW_EXCEPTION( exception::Unsupported()
00123 //                              << exception::user() + "Pixel components (" + mapPixelComponentEnumToString(sComponent) + ") not supported by the plugin." );
00124 //              }
00125 //      }
00126 //      BOOST_THROW_EXCEPTION( exception::Unknown() );
00127 
00128         /*
00129     switch( components )
00130         {
00131                 case OFX::ePixelComponentRGBA:
00132                 {
00133                         doGilRender<LocalMaximaProcess, false, boost::gil::rgba_layout_t>( *this, args, bitDepth );
00134                         return;
00135                 }
00136                 case OFX::ePixelComponentRGB:
00137                 {
00138                         doGilRender<LocalMaximaProcess, false, boost::gil::rgb_layout_t>( *this, args, bitDepth );
00139                         return;
00140                 }
00141                 case OFX::ePixelComponentAlpha:
00142                 case OFX::ePixelComponentCustom:
00143                 case OFX::ePixelComponentNone:
00144                 {
00145                         BOOST_THROW_EXCEPTION( exception::Unsupported()
00146                                 << exception::user() + "Pixel components (" + mapPixelComponentEnumToString(components) + ") not supported by the plugin." );
00147                 }
00148         }
00149         BOOST_THROW_EXCEPTION( exception::Unknown() );
00150 */
00151 }
00152 
00153 
00154 }
00155 }
00156 }