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