/*------------------------------------------------------------------------------
 src/lib/djImage/djImageOpGen.h
 
 Copyright (c) 2004-2006 Darby Johnston.
 All rights reserved.
 Use is subject to license terms.
------------------------------------------------------------------------------*/

#ifndef DJ_IMAGE_OP_GEN_H
#define DJ_IMAGE_OP_GEN_H
#include <djImageOp.h>

namespace dj {

class ImageLoad;

// Image input operation.
//
class ImageOpInput : public ImageOp {
public:

  ImageOpInput();
  ~ImageOpInput();
  
  const Str name() const { return "Input"; }
  Plugin * copy() const { return new ImageOpInput(*this); }
  
  enum ATTR { ATTR_FILE_NAME, ATTR_PROXY, ATTR_FORMAT, ATTR_TYPE, ATTR_FRAME };
  const StrList attrNameList() const;
  bool attr(const Str &, const StrList &);
  const StrList attr(const Str &) const;
  
  const PixelDataInfo info(const InfoList & = InfoList()) const;
  const Image work(const InputList & = InputList()) const;
  
  static const Image work(
    const Str &, int proxy = 0, int format = -1, int type = -1, int frame = -1
  );
  
private:

  Str _fileName;
  int _proxy, _format, _type, _frame;
  ImageLoad * _load;
  PixelDataInfo _info;
};

// Image solid operation.
//
class ImageOpSolid : public ImageOp {
public:

  ImageOpSolid();
  
  const Str name() const { return "Solid"; }
  Plugin * copy() const { return new ImageOpSolid(*this); }

  enum ATTR { ATTR_SIZE, ATTR_PIXEL, ATTR_COLOR };  
  const StrList attrNameList() const;
  bool attr(const Str &, const StrList &);
  const StrList attr(const Str &) const;
  
  const PixelDataInfo info(const InfoList & = InfoList()) const;
  const Image work(const InputList & = InputList()) const;
  
  static const Image work(const Vec2i & size, const Pixel &, const Color &);
  
private:

  Vec2i _size;
  Pixel _pixel;
  Color _color;
};

// Image noise operation.
//
class ImageOpNoise : public ImageOp {
public:

  ImageOpNoise();
  
  const Str name() const { return "Noise"; }
  Plugin * copy() const { return new ImageOpNoise(*this); }
  
  enum ATTR {
    ATTR_SIZE, ATTR_PIXEL, ATTR_COLOR, ATTR_COLOR_2, ATTR_RANDOM_SEED
  };
  const StrList attrNameList() const;
  bool attr(const Str &, const StrList &);
  const StrList attr(const Str &) const;
  
  const PixelDataInfo info(const InfoList & = InfoList()) const;
  const Image work(const InputList & = InputList()) const;
  
  static const Image work(
    const Vec2i & size, const Pixel &,
    const Color & = Color(0.0), const Color & = Color(1.0),
    int randSeed = 0
  );
  
private:

  Vec2i _size;
  Pixel _pixel;
  Color _color, _color2;
  int _randSeed;
};

// Image gradient operation.
//
class ImageOpGradient : public ImageOp {
public:

  ImageOpGradient();
  
  const Str name() const { return "Gradient"; }
  Plugin * copy() const { return new ImageOpGradient(*this); }
  
  enum ATTR {
    ATTR_SIZE, ATTR_PIXEL, ATTR_POSITION, ATTR_POSITION_2, ATTR_COLOR,
    ATTR_COLOR_2
  };
  const StrList attrNameList() const;
  bool attr(const Str &, const StrList &);
  const StrList attr(const Str &) const;
  
  const PixelDataInfo info(const InfoList & = InfoList()) const;
  const Image work(const InputList & = InputList()) const;
  
  static const Image work(
    const Vec2i & size, const Pixel &,
    const Vec2i &, const Vec2i &,
    const Color & = Color(0.0), const Color & = Color(1.0)
  );
  
private:

  Vec2i _size;
  Pixel _pixel;
  Vec2i _position, _position2;
  Color _color, _color2;
};

// Utility.
//
inline const List<ImageOp *> imageOpGenList()
{
  List<ImageOp *> out;
  out += new ImageOpInput;
  out += new ImageOpSolid;
  out += new ImageOpNoise;
  out += new ImageOpGradient;
  return out;
}

// Labels.
//
inline const StrList imageOpInputAttrStr()
  { return StrList() + Str("File Name") + Str("Proxy") + Str("Format") +
    Str("Type") + Str("Frame"); }
inline const StrList imageOpSolidAttrStr()
  { return StrList() + Str("Size") + Str("Pixel") + Str("Color"); }
inline const StrList imageOpNoiseAttrStr()
  { return StrList() + Str("Size") + Str("Pixel") + Str("Color") +
    Str("Color 2") + Str("Random Seed"); }
inline const StrList imageOpGradientAttrStr()
  { return StrList() + Str("Size") + Str("Pixel") + Str("Position") +
    Str("Position 2") + Str("Color") + Str("Color 2"); }

}

#endif
