TuttleOFX  1
WarpPlugin.hpp
Go to the documentation of this file.
00001 #ifndef _TUTTLE_PLUGIN_WARP_PLUGIN_HPP_
00002 #define _TUTTLE_PLUGIN_WARP_PLUGIN_HPP_
00003 
00004 #include "WarpDefinitions.hpp"
00005 
00006 #include <tuttle/plugin/global.hpp>
00007 
00008 #include <ofxsImageEffect.h>
00009 
00010 #include <boost/numeric/ublas/matrix.hpp>
00011 #include <boost/gil/gil_all.hpp>
00012 #include <boost/array.hpp>
00013 
00014 namespace tuttle {
00015 namespace plugin {
00016 namespace warp {
00017 
00018 using namespace boost::gil;
00019 
00020 template<typename Scalar>
00021 struct WarpProcessParams
00022 {
00023 
00024         std::vector< point2<Scalar> > _inPoints;
00025         std::vector< point2<Scalar> > _outPoints;
00026 
00027         std::vector< point2<Scalar> > _tgtPointsIn;
00028         std::vector< point2<Scalar> > _tgtPointsOut;
00029 
00030         std::vector< point2<Scalar> > _buildPoints;
00031 
00032         std::vector< point2<Scalar> > _bezierIn;
00033         std::vector< point2<Scalar> > _bezierOut;
00034 
00035         bool _activateWarp;
00036         double _rigiditeTPS;
00037         std::size_t _nbPoints;
00038         double _transition;
00039 
00040         EParamMethod _method;
00041 };
00042 
00043 /**
00044  * @brief Warp plugin
00045  */
00046 class WarpPlugin : public OFX::ImageEffect
00047 {
00048 
00049 public:
00050         typedef double Scalar;
00051         typedef boost::gil::point2<Scalar> Point2;
00052 public:
00053         WarpPlugin( OfxImageEffectHandle handle );
00054 
00055 public:
00056         WarpProcessParams<Scalar> getProcessParams( const OfxPointD& renderScale = OFX::kNoRenderScale ) const;
00057 
00058         void changedParam( const OFX::InstanceChangedArgs &args, const std::string &paramName );
00059 
00060         //      bool getRegionOfDefinition( const OFX::RegionOfDefinitionArguments& args, OfxRectD& rod );
00061         //      void getRegionsOfInterest( const OFX::RegionsOfInterestArguments& args, OFX::RegionOfInterestSetter& rois );
00062         bool isIdentity( const OFX::RenderArguments& args, OFX::Clip*& identityClip, double& identityTime );
00063 
00064         void render( const OFX::RenderArguments &args );
00065 
00066 public:
00067         OFX::Clip* _clipSrc; ///< Source image clip
00068         OFX::Clip* _clipSrcB; ///< Source image clip
00069         OFX::Clip* _clipDst; ///< Destination image clip
00070 
00071         OFX::BooleanParam* _paramOverlay;
00072         OFX::BooleanParam* _paramInverse;
00073         OFX::PushButtonParam* _paramReset;
00074         OFX::PushButtonParam* _paramNextCurve;
00075         OFX::PushButtonParam* _paramSetKey;
00076         OFX::ChoiceParam* _paramMethod;
00077 
00078         OFX::IntParam* _paramNbPoints;
00079         OFX::DoubleParam* _transition;
00080 
00081         OFX::GroupParam* _paramGroupSettings;
00082         OFX::DoubleParam* _paramRigiditeTPS;
00083         OFX::IntParam* _paramNbPointsBezier;
00084 
00085         //In
00086         OFX::GroupParam* _paramGroupIn;
00087         boost::array<OFX::Double2DParam*, kMaxNbPoints> _paramPointIn;
00088 
00089         OFX::BooleanParam* _paramOverlayIn;
00090         OFX::RGBParam* _paramOverlayInColor;
00091 
00092         //Out
00093         OFX::GroupParam* _paramGroupOut;
00094         boost::array<OFX::Double2DParam*, kMaxNbPoints> _paramPointOut;
00095 
00096         OFX::BooleanParam* _paramOverlayOut;
00097         OFX::RGBParam* _paramOverlayOutColor;
00098 
00099         //Tgt In
00100         OFX::GroupParam* _paramGroupTgtIn;
00101         boost::array<OFX::Double2DParam*, 2 * kMaxNbPoints> _paramPointTgtIn;
00102 
00103         OFX::BooleanParam* _paramOverlayTgtIn;
00104         OFX::RGBParam* _paramOverlayTgtInColor;
00105 
00106         //Tgt Out
00107         OFX::GroupParam* _paramGroupTgtOut;
00108         boost::array<OFX::Double2DParam*, 2 * kMaxNbPoints> _paramPointTgtOut;
00109 
00110         OFX::BooleanParam* _paramOverlayTgtOut;
00111         OFX::RGBParam* _paramOverlayTgtOutColor;
00112 
00113         OFX::GroupParam* _paramGroupCurveBegin;
00114         boost::array<OFX::BooleanParam*, kMaxNbPoints> _paramCurveBegin;
00115 
00116 private:
00117         OFX::InstanceChangedArgs _instanceChangedArgs;
00118 };
00119 
00120 }
00121 }
00122 }
00123 
00124 #endif