TuttleOFX
1
|
00001 #include "FloodFillPluginFactory.hpp" 00002 #include "FloodFillPlugin.hpp" 00003 #include "FloodFillDefinitions.hpp" 00004 00005 #include <ofxImageEffect.h> 00006 00007 #include <limits> 00008 00009 namespace tuttle { 00010 namespace plugin { 00011 namespace floodFill { 00012 00013 static const bool kSupportTiles = false; 00014 00015 00016 /** 00017 * @brief Function called to describe the plugin main features. 00018 * @param[in, out] desc Effect descriptor 00019 */ 00020 void FloodFillPluginFactory::describe( OFX::ImageEffectDescriptor& desc ) 00021 { 00022 desc.setLabels( "TuttleFloodFill", "FloodFill", 00023 "FloodFill" ); 00024 desc.setPluginGrouping( "tuttle/image/process/filter" ); 00025 00026 // add the supported contexts, only filter at the moment 00027 desc.addSupportedContext( OFX::eContextFilter ); 00028 desc.addSupportedContext( OFX::eContextGeneral ); 00029 00030 // add supported pixel depths 00031 desc.addSupportedBitDepth( OFX::eBitDepthUByte ); 00032 desc.addSupportedBitDepth( OFX::eBitDepthUShort ); 00033 desc.addSupportedBitDepth( OFX::eBitDepthFloat ); 00034 00035 // plugin flags 00036 desc.setSupportsTiles( kSupportTiles ); 00037 desc.setRenderThreadSafety( OFX::eRenderFullySafe ); 00038 } 00039 00040 /** 00041 * @brief Function called to describe the plugin controls and features. 00042 * @param[in, out] desc Effect descriptor 00043 * @param[in] context Application context 00044 */ 00045 void FloodFillPluginFactory::describeInContext( OFX::ImageEffectDescriptor& desc, 00046 OFX::EContext context ) 00047 { 00048 OFX::ClipDescriptor* srcClip = desc.defineClip( kOfxImageEffectSimpleSourceClipName ); 00049 srcClip->addSupportedComponent( OFX::ePixelComponentRGBA ); 00050 srcClip->addSupportedComponent( OFX::ePixelComponentRGB ); 00051 srcClip->addSupportedComponent( OFX::ePixelComponentAlpha ); 00052 srcClip->setSupportsTiles( kSupportTiles ); 00053 00054 // Create the mandated output clip 00055 OFX::ClipDescriptor* dstClip = desc.defineClip( kOfxImageEffectOutputClipName ); 00056 dstClip->addSupportedComponent( OFX::ePixelComponentRGBA ); 00057 dstClip->addSupportedComponent( OFX::ePixelComponentRGB ); 00058 dstClip->addSupportedComponent( OFX::ePixelComponentAlpha ); 00059 dstClip->setSupportsTiles( kSupportTiles ); 00060 00061 OFX::DoubleParamDescriptor* upperThres = desc.defineDoubleParam( kParamUpperThres ); 00062 upperThres->setLabel( "Upper thresold" ); 00063 upperThres->setDefault( 0.1 ); 00064 upperThres->setRange( 0.0, std::numeric_limits<double>::max() ); 00065 upperThres->setDisplayRange( 0.0, 1.0 ); 00066 00067 OFX::DoubleParamDescriptor* lowerThres = desc.defineDoubleParam( kParamLowerThres ); 00068 lowerThres->setLabel( "Lower thresold" ); 00069 lowerThres->setDefault( 0.025 ); 00070 lowerThres->setRange( 0.0, std::numeric_limits<double>::max() ); 00071 lowerThres->setDisplayRange( 0.0, 1.0 ); 00072 00073 OFX::BooleanParamDescriptor* minmax = desc.defineBooleanParam( kParamMinMaxRelative ); 00074 minmax->setLabel( "Relative to min/max" ); 00075 minmax->setHint( "Use theshold values relative to min/max" ); 00076 minmax->setDefault( true ); 00077 00078 OFX::ChoiceParamDescriptor* method = desc.defineChoiceParam( kParamMethod ); 00079 method->setLabel( "Method" ); 00080 method->appendOption( kParamMethod4Connections ); 00081 method->appendOption( kParamMethod8Connections ); 00082 #ifndef TUTTLE_PRODUCTION 00083 method->appendOption( kParamMethodBruteForce ); 00084 #endif 00085 method->setDefault( 1 ); 00086 } 00087 00088 /** 00089 * @brief Function called to create a plugin effect instance 00090 * @param[in] handle Effect handle 00091 * @param[in] context Application context 00092 * @return plugin instance 00093 */ 00094 OFX::ImageEffect* FloodFillPluginFactory::createInstance( OfxImageEffectHandle handle, 00095 OFX::EContext context ) 00096 { 00097 return new FloodFillPlugin( handle ); 00098 } 00099 00100 } 00101 } 00102 } 00103