TuttleOFX  1
TextPlugin.hpp
Go to the documentation of this file.
00001 #ifndef _TUTTLE_PLUGIN_TEXT_PLUGIN_HPP_
00002 #define _TUTTLE_PLUGIN_TEXT_PLUGIN_HPP_
00003 
00004 #include <tuttle/plugin/context/GeneratorPlugin.hpp>
00005 #include <tuttle/plugin/ImageEffectGilPlugin.hpp>
00006 
00007 #include "TextDefinitions.hpp"
00008 
00009 namespace tuttle {
00010 namespace plugin {
00011 namespace text {
00012 
00013 struct TextProcessParams
00014 {
00015         std::string    _text;
00016         bool           _isExpression;
00017 
00018         std::string    _fontPath;
00019         int            _font;
00020 
00021         int            _fontX;
00022         int            _fontY;
00023         OfxRGBAColourD _fontColor;
00024         OfxRGBAColourD _backgroundColor;
00025         boost::gil::point2<double> _position;
00026         double         _letterSpacing;
00027         EParamVAlign   _vAlign;
00028         EParamHAlign   _hAlign;
00029         bool           _verticalFlip;
00030         bool           _italic;
00031         bool           _bold;
00032 };
00033 
00034 /**
00035  * @brief Text plugin
00036  */
00037 class TextPlugin : public GeneratorPlugin
00038 {
00039 public:
00040         TextPlugin( OfxImageEffectHandle handle );
00041 
00042 public:
00043         TextProcessParams getProcessParams( const OfxPointD& renderScale = OFX::kNoRenderScale ) const;
00044         void getClipPreferences( OFX::ClipPreferencesSetter& clipPreferences );
00045         
00046         void render( const OFX::RenderArguments& args );
00047 
00048 private:
00049         template< class View >
00050         void render( const OFX::RenderArguments& args );
00051         template< class View, template <typename> class Functor >
00052         void render( const OFX::RenderArguments& args );
00053 
00054         template< class View, template <typename> class Functor >
00055         void render_if( const OFX::RenderArguments& args, boost::mpl::false_ );
00056         template< class View, template <typename> class Functor >
00057         void render_if( const OFX::RenderArguments& args, boost::mpl::true_ );
00058 
00059 public:
00060         OFX::StringParam*   _paramText; ///< the text to rasterize in the image
00061         OFX::BooleanParam*  _paramIsExpression;
00062 
00063         OFX::StringParam*   _paramFontPath;
00064 #ifndef __WINDOWS__
00065         OFX::ChoiceParam*   _paramFont;
00066 #endif
00067         OFX::IntParam*      _paramSize;
00068         OFX::DoubleParam*   _paramRatio;
00069         OFX::RGBAParam*     _paramColor;
00070         OFX::RGBAParam*     _paramBackgroundColor;
00071         OFX::Double2DParam* _paramPosition;
00072         OFX::DoubleParam*   _paramLetterSpacing;
00073         OFX::ChoiceParam*   _paramVAlign;
00074         OFX::ChoiceParam*   _paramHAlign;
00075         OFX::BooleanParam*  _paramVerticalFlip;
00076         OFX::BooleanParam*  _paramItalic;
00077         OFX::BooleanParam*  _paramBold;
00078 
00079         OFX::ChoiceParam*   _paramMerge;
00080 };
00081 
00082 }
00083 }
00084 }
00085 
00086 #endif