TuttleOFX
1
|
00001 #include "PushPixelPluginFactory.hpp" 00002 #include "PushPixelPlugin.hpp" 00003 #include "PushPixelDefinitions.hpp" 00004 00005 #include <tuttle/plugin/ImageGilProcessor.hpp> 00006 00007 #include <limits> 00008 00009 namespace tuttle { 00010 namespace plugin { 00011 namespace pushPixel { 00012 00013 static const bool kSupportTiles = true; 00014 00015 /** 00016 * @brief Function called to describe the plugin main features. 00017 * @param[in, out] desc Effect descriptor 00018 */ 00019 void PushPixelPluginFactory::describe( OFX::ImageEffectDescriptor& desc ) 00020 { 00021 desc.setLabels( 00022 "TuttlePushPixel", 00023 "PushPixel", 00024 "Distort an image based on mask gradient." ); 00025 desc.setPluginGrouping( "tuttle/image/process/geometry" ); 00026 00027 desc.setDescription( 00028 "Distort an image based on mask gradient." ); 00029 00030 // add the supported contexts, only filter at the moment 00031 desc.addSupportedContext( OFX::eContextFilter ); 00032 desc.addSupportedContext( OFX::eContextGeneral ); 00033 00034 // add supported pixel depths 00035 desc.addSupportedBitDepth( OFX::eBitDepthUByte ); 00036 desc.addSupportedBitDepth( OFX::eBitDepthUShort ); 00037 desc.addSupportedBitDepth( OFX::eBitDepthFloat ); 00038 00039 // plugin flags 00040 desc.setSupportsTiles( kSupportTiles ); 00041 } 00042 00043 /** 00044 * @brief Function called to describe the plugin controls and features. 00045 * @param[in, out] desc Effect descriptor 00046 * @param[in] context Application context 00047 */ 00048 void PushPixelPluginFactory::describeInContext( OFX::ImageEffectDescriptor& desc, 00049 OFX::EContext context ) 00050 { 00051 // Create the mandated output clip 00052 OFX::ClipDescriptor* dstClip = desc.defineClip( kOfxImageEffectOutputClipName ); 00053 dstClip->addSupportedComponent( OFX::ePixelComponentRGBA ); 00054 dstClip->addSupportedComponent( OFX::ePixelComponentAlpha ); 00055 dstClip->setSupportsTiles( kSupportTiles ); 00056 00057 OFX::ClipDescriptor* srcClip = desc.defineClip( kOfxImageEffectSimpleSourceClipName ); 00058 srcClip->addSupportedComponent( OFX::ePixelComponentRGBA ); 00059 srcClip->addSupportedComponent( OFX::ePixelComponentAlpha ); 00060 // no tiles on src clip, because it depends on the mask content so we can't 00061 // define the maximal bounding box needed... 00062 srcClip->setSupportsTiles( false ); 00063 00064 OFX::ClipDescriptor* maskClip = desc.defineClip( kClipMask ); 00065 maskClip->addSupportedComponent( OFX::ePixelComponentRGBA ); 00066 maskClip->addSupportedComponent( OFX::ePixelComponentAlpha ); 00067 maskClip->setIsMask( true ); 00068 maskClip->setOptional( true ); 00069 maskClip->setSupportsTiles( true ); 00070 00071 OFX::ChoiceParamDescriptor* output = desc.defineChoiceParam( kParamOutput ); 00072 output->setLabel( "Output" ); 00073 output->appendOption( kParamOutputMotionVectors ); 00074 output->appendOption( kParamOutputPushPixel ); 00075 output->setDefault( 1 ); 00076 00077 OFX::DoubleParamDescriptor* size = desc.defineDoubleParam( kParamSize ); 00078 size->setLabel( "Size" ); 00079 size->setHint( "Size of the gradient window." ); 00080 size->setRange( 0.0, std::numeric_limits<double>::max() ); 00081 size->setDisplayRange( 1.0, 10.0 ); 00082 size->setDefault( 2.0 ); 00083 00084 OFX::BooleanParamDescriptor* normalizedKernel = desc.defineBooleanParam( kParamNormalizedKernel ); 00085 normalizedKernel->setLabel( "Normalized kernel" ); 00086 normalizedKernel->setHint( "Use a normalized kernel to compute the gradient." ); 00087 normalizedKernel->setDefault( true ); 00088 //#ifndef TUTTLE_PRODUCTION 00089 normalizedKernel->setIsSecret( true ); 00090 //#endif 00091 00092 OFX::DoubleParamDescriptor* intensity = desc.defineDoubleParam( kParamIntensity ); 00093 intensity->setLabel( "Intensity" ); 00094 intensity->setHint( "Scale motion vectors." ); 00095 intensity->setDisplayRange( 0.0, 2.0 ); 00096 intensity->setDefault( 0.75 ); 00097 00098 OFX::DoubleParamDescriptor* angle = desc.defineDoubleParam( kParamAngle ); 00099 angle->setLabel( "Angle" ); 00100 angle->setHint( "Rotation on the gradient." ); 00101 angle->setDisplayRange(-180, 180); 00102 angle->setDoubleType( OFX::eDoubleTypeAngle ); 00103 angle->setDefault( 0.0 ); 00104 00105 OFX::ChoiceParamDescriptor* interpolation = desc.defineChoiceParam( kParamInterpolation ); 00106 interpolation->setLabel( "Interpolation" ); 00107 interpolation->setHint( "Interpolation method." ); 00108 interpolation->appendOption( kParamInterpolationNearest ); 00109 interpolation->appendOption( kParamInterpolationBilinear ); 00110 interpolation->setDefault( 1 ); 00111 00112 OFX::ChoiceParamDescriptor* border = desc.defineChoiceParam( kParamBorder ); 00113 border->setLabel( "Gradient border" ); 00114 border->setHint( "Border method for gradient computation." ); 00115 border->appendOption( kParamBorderMirror ); 00116 border->appendOption( kParamBorderConstant ); 00117 border->appendOption( kParamBorderBlack ); 00118 border->appendOption( kParamBorderPadded ); 00119 } 00120 00121 /** 00122 * @brief Function called to create a plugin effect instance 00123 * @param[in] handle Effect handle 00124 * @param[in] context Application context 00125 * @return plugin instance 00126 */ 00127 OFX::ImageEffect* PushPixelPluginFactory::createInstance( OfxImageEffectHandle handle, 00128 OFX::EContext context ) 00129 { 00130 return new PushPixelPlugin( handle ); 00131 } 00132 00133 } 00134 } 00135 }