/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

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