TuttleOFX  1
NormalizePluginFactory.cpp
Go to the documentation of this file.
00001 #include "NormalizePluginFactory.hpp"
00002 #include "NormalizePlugin.hpp"
00003 #include "NormalizeDefinitions.hpp"
00004 
00005 #include <tuttle/plugin/exceptions.hpp>
00006 
00007 #include <ofxsMultiThread.h>
00008 
00009 namespace tuttle {
00010 namespace plugin {
00011 namespace normalize {
00012 
00013 static const bool kSupportTiles = true;
00014 
00015 
00016 /**
00017  * @brief Function called to describe the plugin main features.
00018  * @param[in, out] desc Effect descriptor
00019  */
00020 void NormalizePluginFactory::describe( OFX::ImageEffectDescriptor& desc )
00021 {
00022         desc.setLabels( "TuttleNormalize", "Normalize",
00023                             "Normalize" );
00024         desc.setPluginGrouping( "tuttle/image/process/color" );
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 NormalizePluginFactory::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::ChoiceParamDescriptor* mode = desc.defineChoiceParam( kParamMode );
00062         mode->setLabel( "Input" );
00063         mode->appendOption( kParamModeAnalyse );
00064         mode->appendOption( kParamModeCustom );
00065 
00066         OFX::ChoiceParamDescriptor* analyse = desc.defineChoiceParam( kParamAnalyseMode );
00067         analyse->setLabel( "Analyse" );
00068         analyse->appendOption( kParamAnalysePerChannel );
00069         analyse->appendOption( kParamAnalyseLuminosity );
00070         analyse->appendOption( kParamAnalyseR );
00071         analyse->appendOption( kParamAnalyseG );
00072         analyse->appendOption( kParamAnalyseB );
00073         analyse->appendOption( kParamAnalyseA );
00074 
00075         OFX::PushButtonParamDescriptor* analyseNow = desc.definePushButtonParam( kParamAnalyseNow );
00076         analyseNow->setLabel( "Analyse" );
00077 
00078         OFX::GroupParamDescriptor* srcGroup = desc.defineGroupParam( kParamSrcGroup );
00079         srcGroup->setLabel( "Source" );
00080 
00081         OFX::RGBAParamDescriptor* srcMinColor = desc.defineRGBAParam( kParamSrcCustomColorMin );
00082         srcMinColor->setLabel( "Min" );
00083         srcMinColor->setDefault( 0.0, 0.0, 0.0, 0.0 );
00084         srcMinColor->setParent( srcGroup );
00085 
00086         OFX::RGBAParamDescriptor* srcMaxColor = desc.defineRGBAParam( kParamSrcCustomColorMax );
00087         srcMaxColor->setLabel( "Max" );
00088         srcMaxColor->setDefault( 1.0, 1.0, 1.0, 1.0 );
00089         srcMaxColor->setParent( srcGroup );
00090 
00091         OFX::GroupParamDescriptor* dstGroup = desc.defineGroupParam( kParamDstGroup );
00092         dstGroup->setLabel( "Destination" );
00093 
00094         OFX::RGBAParamDescriptor* dstMinColor = desc.defineRGBAParam( kParamDstCustomColorMin );
00095         dstMinColor->setLabel( "Min" );
00096         dstMinColor->setDefault( 0.0, 0.0, 0.0, 0.0 );
00097         dstMinColor->setParent( dstGroup );
00098 
00099         OFX::RGBAParamDescriptor* dstMaxColor = desc.defineRGBAParam( kParamDstCustomColorMax );
00100         dstMaxColor->setLabel( "Max" );
00101         dstMaxColor->setDefault( 1.0, 1.0, 1.0, 1.0 );
00102         dstMaxColor->setParent( dstGroup );
00103 
00104         OFX::GroupParamDescriptor* processGroup = desc.defineGroupParam( kParamProcessGroup );
00105         processGroup->setLabel( "Process" );
00106 
00107         OFX::BooleanParamDescriptor* processR = desc.defineBooleanParam( kParamProcessR );
00108         processR->setLabel( "R" );
00109         processR->setDefault( true );
00110         processR->setParent( processGroup );
00111 
00112         OFX::BooleanParamDescriptor* processG = desc.defineBooleanParam( kParamProcessG );
00113         processG->setLabel( "G" );
00114         processG->setDefault( true );
00115         processG->setParent( processGroup );
00116 
00117         OFX::BooleanParamDescriptor* processB = desc.defineBooleanParam( kParamProcessB );
00118         processB->setLabel( "B" );
00119         processB->setDefault( true );
00120         processB->setParent( processGroup );
00121 
00122         OFX::BooleanParamDescriptor* processA = desc.defineBooleanParam( kParamProcessA );
00123         processA->setLabel( "A" );
00124         processA->setDefault( true );
00125         processA->setParent( processGroup );
00126 }
00127 
00128 /**
00129  * @brief Function called to create a plugin effect instance
00130  * @param[in] handle  Effect handle
00131  * @param[in] context Application context
00132  * @return  plugin instance
00133  */
00134 OFX::ImageEffect* NormalizePluginFactory::createInstance( OfxImageEffectHandle handle,
00135                                                             OFX::EContext context )
00136 {
00137         return new NormalizePlugin( handle );
00138 }
00139 
00140 }
00141 }
00142 }
00143