TuttleOFX  1
MathOperatorPluginFactory.cpp
Go to the documentation of this file.
00001 #include "MathOperatorPluginFactory.hpp"
00002 #include "MathOperatorPlugin.hpp"
00003 #include "MathOperatorDefinitions.hpp"
00004 #include "ofxsImageEffect.h"
00005 
00006 #include <limits>
00007 
00008 namespace tuttle {
00009 namespace plugin {
00010 namespace mathOperator {
00011 
00012 static const bool kSupportTiles = false;
00013 
00014 
00015 /**
00016  * @brief Function called to describe the plugin main features.
00017  * @param[in, out] desc Effect descriptor
00018  */
00019 void MathOperatorPluginFactory::describe( OFX::ImageEffectDescriptor& desc )
00020 {
00021         desc.setLabels( "TuttleMathOperator", "MathOperator",
00022                             "MathOperator" );
00023         desc.setPluginGrouping( "tuttle/image/process/math" );
00024 
00025         desc.setDescription( "Plugin under early development." );
00026 
00027         // add the supported contexts, only filter at the moment
00028         desc.addSupportedContext( OFX::eContextFilter );
00029         desc.addSupportedContext( OFX::eContextGeneral );
00030 
00031         // add supported pixel depths
00032         desc.addSupportedBitDepth( OFX::eBitDepthUByte );
00033         desc.addSupportedBitDepth( OFX::eBitDepthUShort );
00034         desc.addSupportedBitDepth( OFX::eBitDepthFloat );
00035 
00036         // plugin flags
00037         desc.setSupportsTiles( kSupportTiles );
00038         desc.setRenderThreadSafety( OFX::eRenderFullySafe );
00039 }
00040 
00041 /**
00042  * @brief Function called to describe the plugin controls and features.
00043  * @param[in, out]   desc       Effect descriptor
00044  * @param[in]        context    Application context
00045  */
00046 void MathOperatorPluginFactory::describeInContext( OFX::ImageEffectDescriptor& desc,
00047                                                   OFX::EContext context )
00048 {
00049         OFX::ClipDescriptor* srcClip = desc.defineClip( kOfxImageEffectSimpleSourceClipName );
00050         srcClip -> addSupportedComponent ( OFX::ePixelComponentRGBA );
00051         srcClip -> addSupportedComponent ( OFX::ePixelComponentRGB );
00052         srcClip -> addSupportedComponent ( OFX::ePixelComponentAlpha );
00053         srcClip -> setSupportsTiles      ( kSupportTiles );
00054 
00055         // Create the mandated output clip
00056         OFX::ClipDescriptor* dstClip = desc.defineClip( kOfxImageEffectOutputClipName );
00057         dstClip -> addSupportedComponent ( OFX::ePixelComponentRGBA );
00058         dstClip -> addSupportedComponent ( OFX::ePixelComponentRGB );
00059         dstClip -> addSupportedComponent ( OFX::ePixelComponentAlpha );
00060         dstClip -> setSupportsTiles      ( kSupportTiles );
00061 
00062         OFX::ChoiceParamDescriptor* mathOperatorOp = desc.defineChoiceParam( kMathOperatorOperator );
00063         mathOperatorOp -> setLabel          ( "Operation" );
00064         mathOperatorOp -> setHint           ( "Operator selection mode." );
00065         mathOperatorOp -> appendOption      ( kMathOperatorPlus );
00066         mathOperatorOp -> appendOption      ( kMathOperatorMultiply );
00067         mathOperatorOp -> appendOption      ( kMathOperatorPow );
00068         mathOperatorOp -> appendOption      ( kMathOperatorSqrt );
00069         mathOperatorOp -> appendOption      ( kMathOperatorLog );
00070         mathOperatorOp -> appendOption      ( kMathOperatorLn );
00071 
00072         OFX::ChoiceParamDescriptor* mathOperatorType = desc.defineChoiceParam( kMathOperatorType );
00073         mathOperatorType -> setLabel        ( "Type" );
00074         mathOperatorType -> setHint         ( "Operator selection mode." );
00075         mathOperatorType -> appendOption    ( kMathOperatorRgba );
00076         mathOperatorType -> appendOption    ( kMathOperatorRgb );
00077         mathOperatorType -> appendOption    ( kMathOperatorChannels );
00078 
00079         OFX::DoubleParamDescriptor* masterValue = desc.defineDoubleParam( kMasterValue );
00080         masterValue -> setLabel          ( "Master" );
00081         masterValue -> setDisplayRange   ( -1.0, 1.0 );
00082         masterValue -> setDoubleType     ( OFX::eDoubleTypePlain );
00083         masterValue -> setDefault        ( 1.0 );
00084 
00085         OFX::DoubleParamDescriptor* redValue = desc.defineDoubleParam( kRedValue );
00086         redValue -> setLabel             ( "Red" );
00087         redValue -> setDisplayRange      ( -1.0, 1.0 );
00088         redValue -> setDoubleType        ( OFX::eDoubleTypePlain );
00089         redValue -> setDefault           ( 1.0 );
00090 
00091         OFX::DoubleParamDescriptor* greenValue = desc.defineDoubleParam( kGreenValue );
00092         greenValue -> setLabel           ( "Green" );
00093         greenValue -> setDisplayRange    ( -1.0, 1.0 );
00094         greenValue -> setDoubleType      ( OFX::eDoubleTypePlain );
00095         greenValue -> setDefault         ( 1.0 );
00096 
00097         OFX::DoubleParamDescriptor* blueValue = desc.defineDoubleParam( kBlueValue );
00098         blueValue -> setLabel            ( "Blue" );
00099         blueValue -> setDisplayRange     ( -1.0, 1.0 );
00100         blueValue -> setDoubleType       ( OFX::eDoubleTypePlain );
00101         blueValue -> setDefault          ( 1.0 );
00102 
00103         OFX::DoubleParamDescriptor* alphaValue = desc.defineDoubleParam( kAlphaValue );
00104         alphaValue -> setLabel           ( "Alpha" );
00105         alphaValue -> setDisplayRange    ( -1.0, 1.0 );
00106         alphaValue -> setDoubleType      ( OFX::eDoubleTypePlain );
00107         alphaValue -> setDefault         ( 1.0 );
00108 
00109 
00110         OFX::BooleanParamDescriptor* redChannel = desc.defineBooleanParam( kRedChannel );
00111         redChannel -> setLabel           ( "Red" );
00112         redChannel -> setDefault         ( true );
00113 
00114 
00115         OFX::BooleanParamDescriptor* greenChannel = desc.defineBooleanParam( kGreenChannel );
00116         greenChannel -> setLabel         ( "Green" );
00117         greenChannel -> setDefault       ( true );
00118 
00119 
00120         OFX::BooleanParamDescriptor* blueChannel = desc.defineBooleanParam( kBlueChannel );
00121         blueChannel -> setLabel          ( "Blue" );
00122         blueChannel -> setDefault        ( true );
00123 
00124 
00125         OFX::BooleanParamDescriptor* alphaChannel = desc.defineBooleanParam( kAlphaChannel );
00126         alphaChannel -> setLabel         ( "Alpha" );
00127         alphaChannel -> setDefault       ( true );
00128 
00129 }
00130 
00131 /**
00132  * @brief Function called to create a plugin effect instance
00133  * @param[in] handle  Effect handle
00134  * @param[in] context Application context
00135  * @return  plugin instance
00136  */
00137 OFX::ImageEffect* MathOperatorPluginFactory::createInstance( OfxImageEffectHandle handle,
00138                                                             OFX::EContext context )
00139 {
00140         return new MathOperatorPlugin( handle );
00141 }
00142 
00143 }
00144 }
00145 }
00146