PageRenderTime 13ms CodeModel.GetById 6ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/src/nuke/OCIOCDLTransform/OCIOCDLTransform.h

http://github.com/imageworks/OpenColorIO
C++ Header | 137 lines | 52 code | 33 blank | 52 comment | 0 complexity | 727dcdf9db3f922366d97141bc83fde7 MD5 | raw file
  1#ifndef INCLUDED_OCIO_NUKE_CDLTRANSFORM_H_
  2#define INCLUDED_OCIO_NUKE_CDLTRANSFORM_H_
  3
  4// Include these early, for Nuke's headers under gcc 4.4.2.
  5#include <memory>
  6#include <cstdarg>
  7
  8#include <DDImage/PixelIop.h>
  9#include <DDImage/Row.h>
 10#include <DDImage/Knob.h>
 11
 12#include <OpenColorIO/OpenColorIO.h>
 13namespace OCIO = OCIO_NAMESPACE;
 14
 15
 16/*!
 17 * Iop that uses OpenColorIO to apply an ASC CDL transform
 18 */
 19class OCIOCDLTransform : public DD::Image::PixelIop {
 20
 21    protected:
 22
 23        // ASC CDL grade numbers
 24        float m_slope[3];
 25        float m_offset[3];
 26        float m_power[3];
 27        float m_saturation;
 28
 29        static const char* dirs[];
 30        int m_dirindex;
 31
 32        bool m_readFromFile;
 33        
 34        // ID used for exporting grades into .cc/.ccc files
 35        const char* m_file;
 36        std::string m_cccid;
 37        
 38        DD::Image::Knob* m_slopeKnob;
 39        DD::Image::Knob* m_offsetKnob;
 40        DD::Image::Knob* m_powerKnob;
 41        DD::Image::Knob* m_saturationKnob;
 42        DD::Image::Knob* m_fileKnob;
 43        DD::Image::Knob* m_cccidKnob;
 44        
 45        OCIO::ConstProcessorRcPtr m_processor;
 46        bool m_firstLoad;
 47
 48        /*! Controlled by hidden "version" knob, incremented to redraw image */
 49        int m_reload_version;
 50
 51    public:
 52        OCIOCDLTransform(Node *node);
 53
 54        virtual ~OCIOCDLTransform();
 55
 56        static const DD::Image::Op::Description description;
 57
 58        /*! Return the command name that will be stored in Nuke scripts. */
 59        virtual const char *Class() const;
 60
 61        /*!
 62         * Return a name for this class that will be shown to the user. The
 63         * default implementation returns Class(). You can return a different
 64         * (ie more user-friendly) name instead here, and there is no need for
 65         * this to be unique.
 66         *
 67         * Nuke currently will remove any trailing digits and underscores from
 68         * this and add a new number to make a unique name for the new node.
 69         *
 70         * \return "OCIOCDLTransform"
 71         */
 72        virtual const char *displayName() const;
 73
 74        /*!
 75         * Return help information for this node. This information is in the
 76         * pop-up window that the user gets when they hit the [?] button in
 77         * the lower-left corner of the control panel.
 78         */
 79        virtual const char *node_help() const;
 80        
 81        /*!
 82         * Define the knobs that will be presented in the control panel.
 83         */
 84        virtual void knobs(DD::Image::Knob_Callback f);
 85
 86        //! The will handle the knob changes.
 87        virtual int knob_changed(DD::Image::Knob*);
 88        
 89        void refreshKnobEnabledState();
 90        void loadCDLFromFile();
 91        
 92        
 93        /*!
 94         * Specify the channels required from input n to produce the channels
 95         * in mask by modifying mask in-place. (At least one channel in the
 96         * input is assumed.)
 97         *
 98         * Since OCIOCDLTransform conversions can have channel cross-talk, any rgb
 99         * output channel requires all its rgb bretheren. (Non-rgb
100         * are passed through.)
101         */
102        virtual void in_channels(int n, DD::Image::ChannelSet& mask) const;
103
104        /*!
105         * Calculate the output pixel data.
106         * \param rowY vertical line number
107         * \param rowX inclusive left bound
108         * \param rowXBound exclusive right bound
109         * \param outputChannels a subset of out_channels(), the required channels to be produced
110         */
111        virtual void pixel_engine(
112            const DD::Image::Row& in,
113            int rowY, int rowX, int rowXBound,
114            DD::Image::ChannelMask outputChannels,
115            DD::Image::Row& out);
116
117
118    protected:
119
120        /*!
121         * Check that colorspaces are available, and that the transform
122         * is not a noop. (As OCIO whether a given transform is a noop, since it
123         * can do more analysis than just name matching.)
124         */
125        virtual void _validate(bool for_real);
126
127        /*!
128         * Ensure Node hash is reflects all parameters
129         */
130        void append(DD::Image::Hash& nodehash);
131
132};
133
134
135static DD::Image::Op* build(Node *node);
136
137#endif // INCLUDED_OCIO_NUKE_CDLTRANSFORM_H_