TuttleOFX  1
HistogramPlugin.hpp
Go to the documentation of this file.
00001 #ifndef _TUTTLE_PLUGIN_HISTOGRAM_PLUGIN_HPP_
00002 #define _TUTTLE_PLUGIN_HISTOGRAM_PLUGIN_HPP_
00003 
00004 #include "OverlayData.hpp"
00005 
00006 namespace tuttle {
00007 namespace plugin {
00008 namespace histogram {
00009 
00010 /*
00011  * params needed by the process to compute final image (curves & time)
00012  */
00013 template<typename Scalar>
00014 struct HistogramProcessParams
00015 {
00016     OFX::ParametricParam* _paramColorRGB;               //curve RGB
00017     OFX::ParametricParam* _paramColorHSL;               //curve HSL
00018     OfxTime _time;                                                              //current time
00019         OFX::ChoiceParam* _paramOutputSetting;          //ouput display (BW/alpha)
00020         OFX::BooleanParam* _boolReverseMask;            //is mask revert
00021         boost::array<OFX::BooleanParam*, 3> _boolRGB;   //check boxes RGB selection
00022         boost::array<OFX::BooleanParam*, 3> _boolHSL;   //check boxes HSL selection
00023         boost::array<OFX::DoubleParam*, 3> _multiplierRGB;      //multiplier RGB channels
00024         boost::array<OFX::DoubleParam*, 3> _multiplierHSL;      //multiplier HSL channels
00025         OFX::BooleanParam* _boolClampCurveValues;                       //clamp curve values (Advanced group)
00026 };
00027 
00028 /**
00029  * @brief Histogram plugin
00030  */
00031 class HistogramPlugin : public ImageEffectGilPlugin
00032 {
00033 public: 
00034         /*Class arguments*/
00035     typedef float Scalar;
00036         bool _isCleaned;                                                                //ask overlay to Reset scene
00037         bool _isNbStepChanged;                                                  //do we have to recompute selection histograms (nbStep has changed)
00038         bool _isHistogramRefresh;                                               //do we have to recompute selection histograms (other reason)
00039         
00040         /*Plugin parameters*/   
00041         OFX::BooleanParam* _paramGlobalDisplaySelection;//global display 
00042         OFX::ParametricParam* _paramColorHSLSelection;  //curve HSL
00043     OFX::ParametricParam* _paramColorRGBSelection;      //curve RGB
00044         
00045         OFX::BooleanParam* _paramOverlayRSelection;             //R
00046         OFX::DoubleParam* _paramMutliplierR;                    //multiplier R
00047         
00048         OFX::BooleanParam* _paramOverlayGSelection;             //G
00049         OFX::DoubleParam* _paramMutliplierG;                    //multiplier G
00050         
00051         OFX::BooleanParam* _paramOverlayBSelection;             //B
00052         OFX::DoubleParam* _paramMutliplierB;                    //multiplier B
00053         
00054         OFX::PushButtonParam* _resetRGB;                                //Reset RGB button
00055         
00056         OFX::BooleanParam* _paramOverlayHSelection;             //H
00057         OFX::DoubleParam* _paramMutliplierH;                    //multiplier H
00058         
00059         OFX::BooleanParam* _paramOverlaySSelection;             //S
00060         OFX::DoubleParam* _paramMutliplierS;                    //multiplier S
00061         
00062         OFX::BooleanParam* _paramOverlayLSelection;             //L
00063         OFX::DoubleParam* _paramMutliplierL;                    //multiplier L
00064         
00065         OFX::PushButtonParam* _resetHSL;                                //Reset HSL button
00066         
00067     OFX::ChoiceParam* _paramDisplayTypeSelection;       //display option list global/adapted to channel (Histogram overlay group)
00068         OFX::PushButtonParam* _paramResetAll;                   //clear all button (Histogram overlay group)
00069         
00070         OFX::BooleanParam* _paramDisplaySelection;              //display selection on clip source (Selection group)
00071         OFX::IntParam* _paramSelectionFromCurve;                //precision of selection to curve (Selection group)
00072         OFX::ChoiceParam* _paramSelectionMode;                  //selection mode unique/additive/subtractive (Selection group)
00073         
00074         OFX::IntParam* _paramNbStepSelection;                           //step selection (Advanced group)
00075         OFX::DoubleParam* _paramSelectionMultiplierSelection;//selection multiplier (Advanced group)
00076         OFX::PushButtonParam* _paramRefreshOverlaySelection; //refresh overlay button (Advanced group)
00077         OFX::BooleanParam* _paramClampCurveValues;                      //clamp curve values (Advanced group)
00078         
00079         OFX::ChoiceParam* _paramOutputSettingSelection; //output display list (BW/Alpha)
00080         OFX::BooleanParam* _paramReverseMaskSelection;  //revert mask check box
00081         
00082         OFX::PushButtonParam* _paramButtonAppendToSelectionHSL; //append to selection HSL - Push button
00083         OFX::PushButtonParam* _paramButtonAppendToSelectionRGB; //append to selection RGB - Push button
00084         
00085         bool _isRendering;                                                      //is plugin rendering ? (if rendering don't modify data)
00086         
00087         /*Overlay data parameters*/
00088         boost::scoped_ptr<OverlayData> _overlayData;    //scoped pointer points the overlay data (or NULL)
00089         std::size_t _overlayDataCount;                                  //count (class calling scoped pointer)
00090         
00091         
00092         /*Creators*/
00093     HistogramPlugin( OfxImageEffectHandle handle );
00094         HistogramProcessParams<Scalar> getProcessParams( const OfxTime time, const OfxPointD& renderScale = OFX::kNoRenderScale ) const;
00095         
00096         /*Input function*/
00097     void changedParam( const OFX::InstanceChangedArgs &args, const std::string &paramName );
00098     void changedClip( const OFX::InstanceChangedArgs& args, const std::string& clipName );
00099         
00100         /*Output function*/
00101         bool isIdentity( const OFX::RenderArguments& args, OFX::Clip*& identityClip, double& identityTime );
00102     void render( const OFX::RenderArguments &args );
00103         
00104         /*Overlay data functions*/
00105         void addRefOverlayData();                                       //add reference to overlay data
00106         void releaseOverlayData();                                      //release reference to overlay data
00107         bool hasOverlayData() const;                            //is there overlay data ?
00108         OverlayData& getOverlayData();                          //getter/setter
00109         const OverlayData& getOverlayData() const;      //const getter
00110 };
00111 
00112 }
00113 }
00114 }
00115 
00116 #endif