TuttleOFX  1
TuttleOFX/libraries/tuttle/src/tuttle/plugin/context/ReaderPlugin.hpp
Go to the documentation of this file.
00001 #ifndef _TUTTLE_PLUGIN_CONTEXT_READERPLUGIN_HPP_
00002 #define _TUTTLE_PLUGIN_CONTEXT_READERPLUGIN_HPP_
00003 
00004 #include <boost/gil/channel_algorithm.hpp> // force to use the boostHack version first
00005 
00006 #include "ReaderDefinition.hpp"
00007 
00008 #include <tuttle/plugin/ImageEffectGilPlugin.hpp>
00009 #include <Sequence.hpp>
00010 #include <tuttle/plugin/exceptions.hpp>
00011 
00012 
00013 namespace tuttle {
00014 namespace plugin {
00015 
00016 class ReaderPlugin : public OFX::ImageEffect
00017 {
00018 public:
00019         ReaderPlugin( OfxImageEffectHandle handle );
00020         virtual ~ReaderPlugin() = 0;
00021 
00022 public:
00023         virtual void changedParam( const OFX::InstanceChangedArgs& args, const std::string& paramName );
00024         virtual bool getRegionOfDefinition( const OFX::RegionOfDefinitionArguments& args, OfxRectD& rod ) = 0;
00025         virtual void getClipPreferences( OFX::ClipPreferencesSetter& clipPreferences );
00026         virtual bool getTimeDomain( OfxRangeD& range );
00027 
00028         virtual void render( const OFX::RenderArguments& args );
00029 
00030 public:
00031         std::string getAbsoluteFilenameAt( const OfxTime time ) const
00032         {
00033                 //TUTTLE_LOG_VAR( TUTTLE_INFO, time );
00034                 if( _isSequence )
00035                 {
00036                         //TUTTLE_LOG_VAR( TUTTLE_INFO, _filePattern.getAbsoluteFilenameAt( time ) );
00037                         return _filePattern.getAbsoluteFilenameAt( static_cast<std::ssize_t>(time) );
00038                 }
00039                 else
00040                 {
00041                         //TUTTLE_LOG_VAR( TUTTLE_INFO, _paramFilepath->getValue() );
00042                         return _paramFilepath->getValue();
00043                 }
00044         }
00045 
00046         std::string getAbsoluteFirstFilename() const
00047         {
00048                 if( _isSequence )
00049                         return _filePattern.getAbsoluteFirstFilename();
00050                 else
00051                         return _paramFilepath->getValue();
00052         }
00053 
00054         OfxTime getFirstTime() const
00055         {
00056                 if( _isSequence )
00057                         return _filePattern.getFirstTime();
00058                 else
00059                         return kOfxFlagInfiniteMin;
00060         }
00061 
00062         OfxTime getLastTime() const
00063         {
00064                 if( _isSequence )
00065                         return _filePattern.getLastTime();
00066                 else
00067                         return kOfxFlagInfiniteMax;
00068         }
00069 
00070         EParamReaderBitDepth getExplicitBitDepthConversion() const
00071         {
00072                 return static_cast<EParamReaderBitDepth>( _paramBitDepth->getValue() );
00073         }
00074 
00075         
00076         EParamReaderChannel getExplicitChannelConversion() const
00077         {
00078                 return static_cast<EParamReaderChannel>( _paramChannel->getValue() );
00079         }
00080         
00081         OFX::EBitDepth getOfxExplicitConversion() const
00082         {
00083                 switch( getExplicitBitDepthConversion() )
00084                 {
00085                         case eParamReaderBitDepthByte:
00086                                 return OFX::eBitDepthUByte;
00087                         case eParamReaderBitDepthShort:
00088                                 return OFX::eBitDepthUShort;
00089                         case eParamReaderBitDepthFloat:
00090                                 return OFX::eBitDepthFloat;
00091                         case eParamReaderBitDepthAuto:
00092                                 BOOST_THROW_EXCEPTION( exception::Value() );
00093                 }
00094                 return OFX::eBitDepthNone;
00095         }
00096 
00097 protected:
00098         virtual inline bool varyOnTime() const { return _isSequence; }
00099 
00100 public:
00101         OFX::Clip*           _clipDst;        ///< Destination image clip
00102         /// @name user parameters
00103         /// @{
00104         OFX::StringParam*    _paramFilepath;  ///< File path
00105         OFX::ChoiceParam*    _paramBitDepth;  ///< Explicit bit depth conversion
00106         OFX::ChoiceParam*    _paramChannel;   ///< Explicit component conversion
00107         /// @}
00108 
00109 private:
00110         bool _isSequence;
00111         sequenceParser::Sequence _filePattern;            ///< Filename pattern manager
00112 };
00113 
00114 }
00115 }
00116 
00117 #endif
00118