TuttleOFX  1
TuttleOFX/libraries/tuttle/src/tuttle/plugin/context/WriterPlugin.hpp
Go to the documentation of this file.
00001 #ifndef _TUTTLE_PLUGIN_CONTEXT_WRITERPLUGIN_HPP_
00002 #define _TUTTLE_PLUGIN_CONTEXT_WRITERPLUGIN_HPP_
00003 
00004 #include <boost/gil/channel_algorithm.hpp> // force to use the boostHack version first
00005 
00006 #include "WriterDefinition.hpp"
00007 
00008 #include <tuttle/plugin/ImageEffectGilPlugin.hpp>
00009 
00010 #include <ofxsImageEffect.h>
00011 
00012 #include <boost/filesystem/path.hpp>
00013 #include <boost/filesystem/operations.hpp>
00014 #include <boost/numeric/conversion/cast.hpp>
00015 
00016 #include <boost/gil/gil_all.hpp>
00017 
00018 #include <Sequence.hpp>
00019 
00020 namespace tuttle {
00021 namespace plugin {
00022 
00023 
00024 class WriterPlugin : public ImageEffectGilPlugin
00025 {
00026 public:
00027         WriterPlugin( OfxImageEffectHandle handle );
00028         virtual ~WriterPlugin() = 0;
00029 
00030 public:
00031         virtual void changedParam( const OFX::InstanceChangedArgs& args, const std::string& paramName );
00032         virtual void getClipPreferences( OFX::ClipPreferencesSetter& clipPreferences );
00033         virtual bool isIdentity( const OFX::RenderArguments& args, OFX::Clip*& identityClip, double& identityTime );
00034 
00035         virtual void beginSequenceRender( const OFX::BeginSequenceRenderArguments& args );
00036         virtual void render( const OFX::RenderArguments& args );
00037 
00038 protected:
00039         inline bool varyOnTime() const { return _isSequence; }
00040 
00041 private:
00042         bool _isSequence;                            ///<
00043         sequenceParser::Sequence _filePattern;               ///< Filename pattern manager
00044 
00045         bool _oneRender;                            ///<
00046         OfxTime _oneRenderAtTime;                         ///<
00047 
00048 public:
00049         std::string getAbsoluteFilenameAt( const OfxTime time ) const
00050         {
00051                 if( _isSequence )
00052                         return _filePattern.getAbsoluteFilenameAt( boost::numeric_cast<sequenceParser::Time>(time) );
00053                 else
00054                         return _paramFilepath->getValue();
00055         }
00056 
00057         std::string getAbsoluteDirectory() const
00058         {
00059                 namespace bfs = boost::filesystem;
00060                 if( _isSequence )
00061                 {
00062                         return _filePattern.getAbsoluteDirectory().string();
00063                 }
00064                 else
00065                 {
00066                         bfs::path filepath( _paramFilepath->getValue() );
00067                         return bfs::absolute(filepath).parent_path().string();
00068                 }
00069         }
00070 
00071         std::string getAbsoluteFirstFilename() const
00072         {
00073                 if( _isSequence )
00074                         return _filePattern.getAbsoluteFirstFilename();
00075                 else
00076                         return _paramFilepath->getValue();
00077         }
00078 
00079         OfxTime getFirstTime() const
00080         {
00081                 if( _isSequence )
00082                         return _filePattern.getFirstTime();
00083                 else
00084                         return kOfxFlagInfiniteMin;
00085         }
00086 
00087         OfxTime getLastTime() const
00088         {
00089                 if( _isSequence )
00090                         return _filePattern.getLastTime();
00091                 else
00092                         return kOfxFlagInfiniteMax;
00093         }
00094 
00095 public:
00096         /// @group Attributes
00097         /// @{
00098         OFX::Clip* _clipSrc; ///< Input image clip
00099         OFX::Clip* _clipDst; ///< Ouput image clip
00100 
00101         OFX::PushButtonParam* _paramRenderButton; ///< Render push button
00102         OFX::StringParam*     _paramFilepath; ///< Target file path
00103         OFX::BooleanParam*    _paramRenderAlways;
00104         OFX::BooleanParam*    _paramCopyToOutput; ///< Copy the image buffer to the output clip
00105         OFX::ChoiceParam*     _paramBitDepth;
00106         OFX::BooleanParam*    _paramPremult;
00107         OFX::ChoiceParam*     _paramExistingFile;
00108         OFX::IntParam*        _paramForceNewRender; ///< Hack parameter, to force a new rendering
00109         /// @}
00110 };
00111 
00112 }
00113 }
00114 
00115 #endif
00116