PageRenderTime 39ms CodeModel.GetById 14ms app.highlight 18ms RepoModel.GetById 2ms app.codeStats 0ms

/src/nuke/OCIOLookTransform/OCIOLookTransform.h

http://github.com/imageworks/OpenColorIO
C++ Header | 140 lines | 53 code | 32 blank | 55 comment | 0 complexity | 71266633f63bdf0cddfeaba96ef5ebf6 MD5 | raw file
  1#ifndef INCLUDED_OCIO_NUKE_COLORSPACECONVERSION_H_
  2#define INCLUDED_OCIO_NUKE_COLORSPACECONVERSION_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 OCIOLookTransform : public DD::Image::PixelIop {
 20
 21    protected:
 22
 23        bool m_hasColorSpaces; //!< Were colorspaces found for both input and output? If not, always error.
 24        
 25        std::string m_look;
 26        std::string m_lookhelp;
 27        
 28        int m_dirIndex;
 29        int m_inputColorSpaceIndex;
 30        int m_outputColorSpaceIndex;
 31        
 32        std::vector<std::string> m_colorSpaceNames; //!< list of input and output colorspace names (memory for const char* s below)
 33        std::vector<const char*> m_inputColorSpaceCstrNames; //!< list for the pulldown list knob (used raw)
 34        std::vector<const char*> m_outputColorSpaceCstrNames;
 35        
 36        bool m_ignoreErrors;
 37        
 38        OCIO::ConstContextRcPtr getLocalContext();
 39        
 40        OCIO::ConstProcessorRcPtr m_processor;
 41        
 42        /*! Controlled by hidden "version" knob, incremented to redraw image */
 43        int m_reload_version;
 44    public:
 45
 46        OCIOLookTransform(Node *node);
 47
 48        virtual ~OCIOLookTransform();
 49
 50        // These are public so the nuke wrapper can introspect into it
 51        // TODO: use 'friend' instead
 52        std::string m_contextKey1;
 53        std::string m_contextValue1;
 54        std::string m_contextKey2;
 55        std::string m_contextValue2;
 56        std::string m_contextKey3;
 57        std::string m_contextValue3;
 58        std::string m_contextKey4;
 59        std::string m_contextValue4;
 60        
 61        static const DD::Image::Op::Description description;
 62
 63        /*! Return the command name that will be stored in Nuke scripts. */
 64        virtual const char *Class() const;
 65
 66        /*!
 67         * Return a name for this class that will be shown to the user. The
 68         * default implementation returns Class(). You can return a different
 69         * (ie more user-friendly) name instead here, and there is no need for
 70         * this to be unique.
 71         * 
 72         * Nuke currently will remove any trailing digits and underscores from
 73         * this and add a new number to make a unique name for the new node.
 74         * 
 75         * \return "OCIOLookTransform"
 76         */
 77        virtual const char *displayName() const;
 78
 79        /*!
 80         * Return help information for this node. This information is in the
 81         * pop-up window that the user gets when they hit the [?] button in
 82         * the lower-left corner of the control panel.
 83         */
 84        virtual const char *node_help() const;
 85
 86        /*!
 87         * Define the knobs that will be presented in the control panel.
 88         */
 89        virtual void knobs(DD::Image::Knob_Callback f);
 90
 91        /*!
 92         * Specify the channels required from input n to produce the channels
 93         * in mask by modifying mask in-place. (At least one channel in the
 94         * input is assumed.)
 95         *
 96         * Since colorspace conversions can have channel cross-talk, any rgb
 97         * output channel requires all its rgb bretheren. (Non-rgb
 98         * are passed through.)
 99         */
100        virtual void in_channels(int n, DD::Image::ChannelSet& mask) const;
101
102        /*!
103         * Calculate the output pixel data.
104         * \param rowY vertical line number
105         * \param rowX inclusive left bound
106         * \param rowXBound exclusive right bound
107         * \param outputChannels a subset of out_channels(), the required channels to be produced
108         */
109        virtual void pixel_engine(
110            const DD::Image::Row& in,
111            int rowY, int rowX, int rowXBound,
112            DD::Image::ChannelMask outputChannels,
113            DD::Image::Row& out);
114
115    protected:
116
117        /*!
118         * Check that colorspaces are available, and that the transform
119         * is not a noop. (As OCIO whether a given transform is a noop, since it
120         * can do more analysis than just name matching.)
121         */
122        virtual void _validate(bool for_real);
123        
124        /*!
125         * Ensure Node hash is reflects all parameters
126         */
127        virtual void append(DD::Image::Hash& nodehash);
128
129        /*!
130         * Hide and show UI elements based on other parameters.
131         Also handles reload button
132         */
133        virtual int knob_changed(DD::Image::Knob* k);
134
135};
136
137
138static DD::Image::Op* build(Node *node);
139
140#endif // INCLUDED_OCIO_NUKE_COLORSPACECONVERSION_H_