TuttleOFX  1
ColorGradationPluginFactory.cpp
Go to the documentation of this file.
00001 #include "ColorGradationPluginFactory.hpp"
00002 #include "ColorGradationPlugin.hpp"
00003 #include "ColorGradationDefinitions.hpp"
00004 
00005 #include <tuttle/plugin/ImageGilProcessor.hpp>
00006 
00007 namespace tuttle {
00008 namespace plugin {
00009 namespace colorGradation {
00010 
00011 static const bool kSupportTiles = true;
00012 
00013 /**
00014  * @brief Function called to describe the plugin main features.
00015  * @param[in, out] desc Effect descriptor
00016  */
00017 void ColorGradationPluginFactory::describe( OFX::ImageEffectDescriptor& desc )
00018 {
00019         desc.setLabels( "TuttleColorGradation", "ColorGradation",
00020                         "ColorGradation" );
00021         desc.setPluginGrouping( "tuttle/image/process/color" );
00022         desc.setDescription(
00023 "Color distribution / Color gradation"
00024 "\n"
00025 "\n"
00026 "http://en.wikipedia.org/wiki/Gamma_correction"
00027 "\n"
00028         /// @todo documentation: definition of color gradation
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         // For the moment, this node is float only to handle clamping pb. TODO fix correctly this
00038         desc.addSupportedBitDepth( OFX::eBitDepthFloat );
00039 
00040         // plugin flags
00041         desc.setSupportsTiles( kSupportTiles );
00042         desc.setRenderThreadSafety( OFX::eRenderFullySafe );
00043 }
00044 
00045 /**
00046  * @brief Function called to describe the plugin controls and features.
00047  * @param[in, out]   desc       Effect descriptor
00048  * @param[in]        context    Application context
00049  */
00050 void ColorGradationPluginFactory::describeInContext( OFX::ImageEffectDescriptor& desc,
00051                                                         OFX::EContext               context )
00052 {
00053         OFX::ClipDescriptor* srcClip = desc.defineClip( kOfxImageEffectSimpleSourceClipName );
00054 
00055         srcClip->addSupportedComponent( OFX::ePixelComponentRGBA );
00056         srcClip->addSupportedComponent( OFX::ePixelComponentRGB );
00057         srcClip->addSupportedComponent( OFX::ePixelComponentAlpha );
00058         srcClip->setSupportsTiles( kSupportTiles );
00059 
00060         // Create the mandated output clip
00061         OFX::ClipDescriptor* dstClip = desc.defineClip( kOfxImageEffectOutputClipName );
00062         dstClip->addSupportedComponent( OFX::ePixelComponentRGBA );
00063         dstClip->addSupportedComponent( OFX::ePixelComponentRGB );
00064         dstClip->addSupportedComponent( OFX::ePixelComponentAlpha );
00065         dstClip->setSupportsTiles( kSupportTiles );
00066 
00067         OFX::ChoiceParamDescriptor* in = desc.defineChoiceParam( kParamIn );
00068         in->setLabel( "In" );
00069         in->setHint( "Input color gradation." );
00070         in->appendOption( kParamGradation_linear );
00071         in->appendOption( kParamGradation_sRGB );
00072         in->appendOption( kParamGradation_Rec709 );
00073         in->appendOption( kParamGradation_cineon );
00074         in->appendOption( kParamGradation_gamma );
00075         in->appendOption( kParamGradation_panalog );
00076         in->appendOption( kParamGradation_REDLog );
00077         in->appendOption( kParamGradation_ViperLog );
00078         in->appendOption( kParamGradation_REDSpace );
00079         in->appendOption( kParamGradation_AlexaV3LogC );
00080 
00081         //      in->appendOption( kParamGradation_rec601 );
00082         in->setDefault( eParamGradation_linear );
00083 
00084         OFX::DoubleParamDescriptor* inGammaValue = desc.defineDoubleParam( kColorSpaceInGammaValue );
00085         inGammaValue->setLabel                  ( "Gamma" );
00086         inGammaValue->setDefault                ( 1.0 );
00087         inGammaValue->setRange                  ( 0.0, std::numeric_limits<double>::max() );
00088         inGammaValue->setDisplayRange           ( 0.0, 5.0 );
00089         inGammaValue->setHint                   ( "Adjust the Gamma." );
00090 
00091         OFX::DoubleParamDescriptor* inBlackPoint = desc.defineDoubleParam( kColorSpaceInBlackPoint );
00092         inBlackPoint->setLabel                  ( "Black Point" );
00093         inBlackPoint->setDefault                ( kColorSpaceInBlackPointDefaultValue);
00094         inBlackPoint->setRange                  ( 0.0, 1023.0 );
00095         inBlackPoint->setDisplayRange           ( 0.0, 1023.0 );
00096         inBlackPoint->setHint                   ( "Adjust the Black Point." );
00097 
00098         OFX::DoubleParamDescriptor* inWhitePoint = desc.defineDoubleParam( kColorSpaceInWhitePoint );
00099         inWhitePoint->setLabel                  ( "White Point" );
00100         inWhitePoint->setDefault                ( kColorSpaceInWhitePointDefaultValue );
00101         inWhitePoint->setRange                  ( 0.0, 1023.0 );
00102         inWhitePoint->setDisplayRange           ( 0.0, 1023.0 );
00103         inWhitePoint->setHint                   ( "Adjust the White Point." );
00104 
00105         OFX::DoubleParamDescriptor* inGammaSensito = desc.defineDoubleParam( kColorSpaceInGammaSensito );
00106         inGammaSensito->setLabel                ( "Gamma Sensito" );
00107         inGammaSensito->setDefault              ( kColorSpaceInGammaSensitoDefaultValue );
00108         inGammaSensito->setRange                ( 0.0, std::numeric_limits<double>::max() );
00109         inGammaSensito->setDisplayRange         ( 0.0, 5.0 );
00110         inGammaSensito->setHint                 ( "Adjust the Gamma Sensito." );
00111 
00112 
00113         OFX::ChoiceParamDescriptor* out = desc.defineChoiceParam( kParamOut );
00114         out->setLabel( "Out" );
00115         out->setHint( "Output color gradation." );
00116         out->appendOption( kParamGradation_linear );
00117         out->appendOption( kParamGradation_sRGB );
00118         out->appendOption( kParamGradation_Rec709 );
00119         out->appendOption( kParamGradation_cineon );
00120         out->appendOption( kParamGradation_gamma );
00121         out->appendOption( kParamGradation_panalog );
00122         out->appendOption( kParamGradation_REDLog );
00123         out->appendOption( kParamGradation_ViperLog );
00124         out->appendOption( kParamGradation_REDSpace );
00125         out->appendOption( kParamGradation_AlexaV3LogC );
00126 
00127         //      out->appendOption( kParamGradation_rec601 );
00128         out->setDefault( eParamGradation_linear );
00129 
00130         OFX::DoubleParamDescriptor* outGammaValue = desc.defineDoubleParam( kColorSpaceOutGammaValue );
00131         outGammaValue->setLabel                 ( "Gamma" );
00132         outGammaValue->setDefault               ( 1.0 );
00133         outGammaValue->setRange                 ( 0.0, std::numeric_limits<double>::max() );
00134         outGammaValue->setDisplayRange          ( 0.0, 5.0 );
00135         outGammaValue->setHint                  ( "Adjust the Gamma." );
00136 
00137         OFX::DoubleParamDescriptor* outBlackPoint = desc.defineDoubleParam( kColorSpaceOutBlackPoint );
00138         outBlackPoint->setLabel                 ( "Black Point" );
00139         outBlackPoint->setDefault               (  kColorSpaceInBlackPointDefaultValue );
00140         outBlackPoint->setRange                 ( 0.0, 1023.0 );
00141         outBlackPoint->setDisplayRange          ( 0.0, 1023.0 );
00142         outBlackPoint->setHint                  ( "Adjust the Black Point." );
00143 
00144         OFX::DoubleParamDescriptor* outWhitePoint = desc.defineDoubleParam( kColorSpaceOutWhitePoint );
00145         outWhitePoint->setLabel                 ( "White Point" );
00146         outWhitePoint->setDefault               (  kColorSpaceInWhitePointDefaultValue );
00147         outWhitePoint->setRange                 ( 0.0, 1023.0 );
00148         outWhitePoint->setDisplayRange          ( 0.0, 1023.0 );
00149         outWhitePoint->setHint                  ( "Adjust the White Point." );
00150 
00151         OFX::DoubleParamDescriptor* outGammaSensito = desc.defineDoubleParam( kColorSpaceOutGammaSensito );
00152         outGammaSensito->setLabel               ( "Gamma Sensito" );
00153         outGammaSensito->setDefault             (  kColorSpaceInGammaSensitoDefaultValue);
00154         outGammaSensito->setRange               ( 0.0, std::numeric_limits<double>::max() );
00155         outGammaSensito->setDisplayRange        ( 0.0, 5.0 );
00156         outGammaSensito->setHint                ( "Adjust the Gamma Sensito." );
00157 
00158 
00159         OFX::BooleanParamDescriptor* alpha = desc.defineBooleanParam( kParamProcessAlpha );
00160         alpha->setLabel( "Process alpha" );
00161         alpha->setHint( "Apply the conversion on alpha channel." );
00162         alpha->setDefault( false );
00163 
00164         OFX::PushButtonParamDescriptor* invert = desc.definePushButtonParam( kParamInvert );
00165         invert->setLabel( "Invert" );
00166 }
00167 
00168 /**
00169  * @brief Function called to create a plugin effect instance
00170  * @param[in] handle  Effect handle
00171  * @param[in] context Application context
00172  * @return  plugin instance
00173  */
00174 OFX::ImageEffect* ColorGradationPluginFactory::createInstance( OfxImageEffectHandle handle,
00175                                                                   OFX::EContext        context )
00176 {
00177         return new ColorGradationPlugin( handle );
00178 }
00179 
00180 }
00181 }
00182 }
00183