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