PageRenderTime 30ms CodeModel.GetById 16ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 0ms

/src/nuke/OCIOFileTransform/OCIOFileTransform.h

http://github.com/imageworks/OpenColorIO
C Header | 128 lines | 41 code | 30 blank | 57 comment | 0 complexity | 76eebfe52973542cc020f889f2b1a57b MD5 | raw file
Possible License(s): BSD-3-Clause
  1#ifndef INCLUDED_OCIO_NUKE_FILETRANSFORM_H_
  2#define INCLUDED_OCIO_NUKE_FILETRANSFORM_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 perform colorspace conversions
 18 */
 19class OCIOFileTransform : public DD::Image::PixelIop {
 20
 21    protected:
 22        const char* m_file;
 23        std::string m_cccid;
 24
 25        /*! Transform direction dropdown index */
 26        int m_dirindex;
 27
 28        /*! Interpolation dropdown index */
 29        int m_interpindex;
 30
 31        /*! Processor used to apply the FileTransform */
 32        OCIO::ConstProcessorRcPtr m_processor;
 33
 34        /*! Holds computed help string */
 35        mutable std::string m_nodehelp;
 36
 37        /*! Controlled by hidden "version" knob, incremented to redraw image */
 38        int m_reload_version;
 39
 40    public:
 41        static const char* dirs[];
 42        static const char* interp[];
 43
 44        OCIOFileTransform(Node *node);
 45
 46        virtual ~OCIOFileTransform();
 47
 48        static const DD::Image::Op::Description description;
 49
 50        /*! Return the command name that will be stored in Nuke scripts. */
 51        virtual const char *Class() const;
 52
 53        /*!
 54         * Return a name for this class that will be shown to the user. The
 55         * default implementation returns Class(). You can return a different
 56         * (ie more user-friendly) name instead here, and there is no need for
 57         * this to be unique.
 58         * 
 59         * Nuke currently will remove any trailing digits and underscores from
 60         * this and add a new number to make a unique name for the new node.
 61         * 
 62         * \return "OCIOFileTransform"
 63         */
 64        virtual const char *displayName() const;
 65
 66        /*!
 67         * Return help information for this node. This information is in the
 68         * pop-up window that the user gets when they hit the [?] button in
 69         * the lower-left corner of the control panel.
 70         */
 71        virtual const char *node_help() const;
 72
 73        /*!
 74         * Define the knobs that will be presented in the control panel.
 75         */
 76        virtual void knobs(DD::Image::Knob_Callback f);
 77
 78        /*!
 79         * Specify the channels required from input n to produce the channels
 80         * in mask by modifying mask in-place. (At least one channel in the
 81         * input is assumed.)
 82         *
 83         * Since OCIOFileTransform conversions can have channel cross-talk, any rgb
 84         * output channel requires all its rgb bretheren. (Non-rgb
 85         * are passed through.)
 86         */
 87        virtual void in_channels(int n, DD::Image::ChannelSet& mask) const;
 88
 89        /*!
 90         * Calculate the output pixel data.
 91         * \param rowY vertical line number
 92         * \param rowX inclusive left bound
 93         * \param rowXBound exclusive right bound
 94         * \param outputChannels a subset of out_channels(), the required channels to be produced
 95         */
 96        virtual void pixel_engine(
 97            const DD::Image::Row& in,
 98            int rowY, int rowX, int rowXBound,
 99            DD::Image::ChannelMask outputChannels,
100            DD::Image::Row& out);
101
102
103    protected:
104
105        /*!
106         * Check that colorspaces are available, and that the transform
107         * is not a noop. (As OCIO whether a given transform is a noop, since it
108         * can do more analysis than just name matching.)
109         */
110        virtual void _validate(bool for_real);
111
112        /*!
113         * Ensure Node hash is reflects all parameters
114         */
115        virtual void append(DD::Image::Hash& nodehash);
116
117        /*!
118         * Hide and show UI elements based on other parameters.
119         Also handles reload button
120         */
121        virtual int knob_changed(DD::Image::Knob* k);
122
123};
124
125
126static DD::Image::Op* build(Node *node);
127
128#endif // INCLUDED_OCIO_NUKE_FILETRANSFORM_H_