Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef _RASTERSTYLES_H_
Toshihiro Shimizu 890ddd
#define _RASTERSTYLES_H_
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tcolorstyles.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "traster.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include <qcoreapplication></qcoreapplication>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class TStroke;
Toshihiro Shimizu 890ddd
class TRegion;
Toshihiro Shimizu 890ddd
class TStrokeProp;
Toshihiro Shimizu 890ddd
class TRegionProp;
Toshihiro Shimizu 890ddd
class TInputStreamInterface;
Toshihiro Shimizu 890ddd
class TOutputStreamInterface;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class TAirbrushRasterStyle : public TColorStyle, public TRasterStyleFx {
Toshihiro Shimizu 890ddd
protected:
Shinya Kitaoka 120a6e
  TPixel32 m_color;
Shinya Kitaoka 120a6e
  double m_blur;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  TAirbrushRasterStyle(const TPixel32 &color, double blur)
Shinya Kitaoka 120a6e
      : m_color(color), m_blur(blur) {}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TColorStyle *clone() const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  // n.b. per un plain color: isRasterStyle() == true, ma getRasterStyleFx() = 0
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TStrokeProp *makeStrokeProp(const TStroke *stroke) { return 0; }
Shinya Kitaoka 120a6e
  TRegionProp *makeRegionProp(const TRegion *region) { return 0; }
Shinya Kitaoka 120a6e
  TRasterStyleFx *getRasterStyleFx() { return this; }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  bool isRegionStyle() const { return false; }
Shinya Kitaoka 120a6e
  bool isStrokeStyle() const { return false; }
Shinya Kitaoka 120a6e
  bool isRasterStyle() const { return true; }
Shinya Kitaoka 120a6e
  void getEnlargement(int &borderIn, int &borderOut) const {
Shinya Kitaoka 120a6e
    borderIn  = tceil(2 * m_blur);
Shinya Kitaoka 120a6e
    borderOut = tceil(m_blur);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  bool hasMainColor() const { return true; }
Shinya Kitaoka 120a6e
  TPixel32 getMainColor() const { return m_color; }
Shinya Kitaoka 120a6e
  void setMainColor(const TPixel32 &color) { m_color = color; }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  int getColorParamCount() const { return 1; }
Shinya Kitaoka 120a6e
  TPixel32 getColorParamValue(int index) const { return m_color; }
Shinya Kitaoka 120a6e
  void setColorParamValue(int index, const TPixel32 &color) { m_color = color; }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  virtual QString getDescription() const {
Shinya Kitaoka 120a6e
    return QCoreApplication::translate("TAirbrushRasterStyle", "Airbrush");
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  int getParamCount() const { return 1; }
Shinya Kitaoka 120a6e
  TColorStyle::ParamType getParamType(int index) const {
Shinya Kitaoka 120a6e
    assert(index == 0);
Shinya Kitaoka 120a6e
    return TColorStyle::DOUBLE;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  QString getParamNames(int index) const {
Shinya Kitaoka 120a6e
    assert(index == 0);
Shinya Kitaoka 120a6e
    return QCoreApplication::translate("TAirbrushRasterStyle", "Blur value");
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  void getParamRange(int index, double &min, double &max) const {
Shinya Kitaoka 120a6e
    assert(index == 0);
Shinya Kitaoka 120a6e
    min = 0;
Shinya Kitaoka 120a6e
    max = 30;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  double getParamValue(TColorStyle::double_tag, int index) const {
Shinya Kitaoka 120a6e
    assert(index == 0);
Shinya Kitaoka 120a6e
    return m_blur;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  void setParamValue(int index, double value) {
Shinya Kitaoka 120a6e
    assert(index == 0);
Shinya Kitaoka 120a6e
    m_blur = value;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void invalidateIcon();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  // const TRaster32P &getIcon(const TDimension &d) {assert(false);return
Shinya Kitaoka 120a6e
  // (TRaster32P)0;}
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TPixel32 getAverageColor() const { return m_color; }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  int getTagId() const { return 1150; }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  bool isInkStyle() const { return true; }
Shinya Kitaoka 120a6e
  bool isPaintStyle() const { return false; }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  bool compute(const Params ¶ms) const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected:
Shinya Kitaoka 120a6e
  virtual void makeIcon(const TDimension &d);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void arrangeIcon(const TDimension &d, const TRasterP &normalIc);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void loadData(TInputStreamInterface &);
Shinya Kitaoka 120a6e
  void saveData(TOutputStreamInterface &) const;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // per la compatibilita' con il passato
Shinya Kitaoka 120a6e
  void loadData(int oldId, TInputStreamInterface &){};
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class TBlendRasterStyle : public TAirbrushRasterStyle {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  TBlendRasterStyle(const TPixel32 &color, double blur)
Shinya Kitaoka 120a6e
      : TAirbrushRasterStyle(color, blur) {}
Shinya Kitaoka 120a6e
  TColorStyle *clone() const;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  int getTagId() const { return 1160; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  virtual QString getDescription() const {
Shinya Kitaoka 120a6e
    return QCoreApplication::translate("TBlendRasterStyle", "Blend");
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void makeIcon(const TDimension &d);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool compute(const TRasterStyleFx::Params ¶ms) const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  double computeFactor(const TRasterStyleFx::Params ¶ms) const;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class TNoColorRasterStyle : public TColorStyle, TRasterStyleFx {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  TNoColorRasterStyle() {}
Shinya Kitaoka 120a6e
  TColorStyle *clone() const { return new TNoColorRasterStyle(*this); }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // n.b. per un plain color: isRasterStyle() == true, ma getRasterStyleFx() = 0
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TStrokeProp *makeStrokeProp(const TStroke *stroke) { return 0; }
Shinya Kitaoka 120a6e
  TRegionProp *makeRegionProp(const TRegion *region) { return 0; }
Shinya Kitaoka 120a6e
  TRasterStyleFx *getRasterStyleFx() { return this; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool isRegionStyle() const { return false; }
Shinya Kitaoka 120a6e
  bool isStrokeStyle() const { return false; }
Shinya Kitaoka 120a6e
  bool isRasterStyle() const { return true; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  virtual QString getDescription() const {
Shinya Kitaoka 120a6e
    return QCoreApplication::translate("TNoColorRasterStyle", "Markup");
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool hasMainColor() { return false; }
Shinya Kitaoka 120a6e
  // TPixel32 getMainColor() const {return m_color;}
Shinya Kitaoka 120a6e
  // void setMainColor(const TPixel32 &color) {m_color = color;}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  int getColorParamCount() const { return 0; }
Shinya Kitaoka 120a6e
  TPixel32 getColorParamValue(int index) const {
Shinya Kitaoka 120a6e
    assert(false);
Shinya Kitaoka 120a6e
    return TPixel32();
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  void setColorParamValue(int index, const TPixel32 &color) { assert(false); }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  int getTagId() const { return 1151; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool isInkStyle() const { return true; }
Shinya Kitaoka 120a6e
  bool isPaintStyle() const { return true; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool compute(const Params ¶ms) const { return false; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected:
Shinya Kitaoka 120a6e
  void makeIcon(const TDimension &d);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void loadData(TInputStreamInterface &){};
Shinya Kitaoka 120a6e
  void saveData(TOutputStreamInterface &) const {};
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // per la compatibilita' con il passato
Shinya Kitaoka 120a6e
  void loadData(int oldId, TInputStreamInterface &){};
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif