2016-05-17 03:04:11 +12:00
|
|
|
#pragma once
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
#ifndef _RASTERSTYLES_H_
|
|
|
|
#define _RASTERSTYLES_H_
|
|
|
|
|
|
|
|
#include "tcolorstyles.h"
|
|
|
|
|
|
|
|
#include "traster.h"
|
|
|
|
|
|
|
|
#include <QCoreApplication>
|
|
|
|
|
|
|
|
class TStroke;
|
|
|
|
class TRegion;
|
|
|
|
class TStrokeProp;
|
|
|
|
class TRegionProp;
|
|
|
|
class TInputStreamInterface;
|
|
|
|
class TOutputStreamInterface;
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
class TAirbrushRasterStyle : public TColorStyle, public TRasterStyleFx {
|
2016-03-19 06:57:51 +13:00
|
|
|
protected:
|
2016-06-15 18:43:10 +12:00
|
|
|
TPixel32 m_color;
|
|
|
|
double m_blur;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
TAirbrushRasterStyle(const TPixel32 &color, double blur)
|
|
|
|
: m_color(color), m_blur(blur) {}
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-19 20:06:29 +12:00
|
|
|
TColorStyle *clone() const override;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
// n.b. per un plain color: isRasterStyle() == true, ma getRasterStyleFx() = 0
|
|
|
|
|
2016-06-19 20:06:29 +12:00
|
|
|
TStrokeProp *makeStrokeProp(const TStroke *stroke) override { return 0; }
|
|
|
|
TRegionProp *makeRegionProp(const TRegion *region) override { return 0; }
|
|
|
|
TRasterStyleFx *getRasterStyleFx() override { return this; }
|
2016-06-15 18:43:10 +12:00
|
|
|
|
2016-06-19 20:06:29 +12:00
|
|
|
bool isRegionStyle() const override { return false; }
|
|
|
|
bool isStrokeStyle() const override { return false; }
|
|
|
|
bool isRasterStyle() const override { return true; }
|
|
|
|
void getEnlargement(int &borderIn, int &borderOut) const override {
|
2016-06-15 18:43:10 +12:00
|
|
|
borderIn = tceil(2 * m_blur);
|
|
|
|
borderOut = tceil(m_blur);
|
|
|
|
}
|
|
|
|
|
2016-06-19 20:06:29 +12:00
|
|
|
bool hasMainColor() const override { return true; }
|
|
|
|
TPixel32 getMainColor() const override { return m_color; }
|
|
|
|
void setMainColor(const TPixel32 &color) override { m_color = color; }
|
2016-06-15 18:43:10 +12:00
|
|
|
|
2016-06-19 20:06:29 +12:00
|
|
|
int getColorParamCount() const override { return 1; }
|
|
|
|
TPixel32 getColorParamValue(int index) const override { return m_color; }
|
2016-06-20 14:23:05 +12:00
|
|
|
void setColorParamValue(int index, const TPixel32 &color) override {
|
|
|
|
m_color = color;
|
|
|
|
}
|
2016-06-15 18:43:10 +12:00
|
|
|
|
2016-06-19 20:06:29 +12:00
|
|
|
QString getDescription() const override {
|
2016-06-15 18:43:10 +12:00
|
|
|
return QCoreApplication::translate("TAirbrushRasterStyle", "Airbrush");
|
|
|
|
}
|
|
|
|
|
2016-06-19 20:06:29 +12:00
|
|
|
int getParamCount() const override { return 1; }
|
|
|
|
TColorStyle::ParamType getParamType(int index) const override {
|
2016-06-15 18:43:10 +12:00
|
|
|
assert(index == 0);
|
|
|
|
return TColorStyle::DOUBLE;
|
|
|
|
}
|
|
|
|
|
2016-06-19 20:06:29 +12:00
|
|
|
QString getParamNames(int index) const override {
|
2016-06-15 18:43:10 +12:00
|
|
|
assert(index == 0);
|
|
|
|
return QCoreApplication::translate("TAirbrushRasterStyle", "Blur value");
|
|
|
|
}
|
2016-06-19 20:06:29 +12:00
|
|
|
void getParamRange(int index, double &min, double &max) const override {
|
2016-06-15 18:43:10 +12:00
|
|
|
assert(index == 0);
|
|
|
|
min = 0;
|
|
|
|
max = 30;
|
|
|
|
}
|
2016-06-19 20:06:29 +12:00
|
|
|
double getParamValue(TColorStyle::double_tag, int index) const override {
|
2016-06-15 18:43:10 +12:00
|
|
|
assert(index == 0);
|
|
|
|
return m_blur;
|
|
|
|
}
|
2016-06-19 20:06:29 +12:00
|
|
|
void setParamValue(int index, double value) override {
|
2016-06-15 18:43:10 +12:00
|
|
|
assert(index == 0);
|
|
|
|
m_blur = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
void invalidateIcon();
|
|
|
|
|
|
|
|
// const TRaster32P &getIcon(const TDimension &d) {assert(false);return
|
|
|
|
// (TRaster32P)0;}
|
|
|
|
|
2016-06-19 20:06:29 +12:00
|
|
|
TPixel32 getAverageColor() const override { return m_color; }
|
2016-06-15 18:43:10 +12:00
|
|
|
|
2016-06-19 20:06:29 +12:00
|
|
|
int getTagId() const override { return 1150; }
|
2016-06-15 18:43:10 +12:00
|
|
|
|
2016-06-19 20:06:29 +12:00
|
|
|
bool isInkStyle() const override { return true; }
|
|
|
|
bool isPaintStyle() const override { return false; }
|
2016-06-15 18:43:10 +12:00
|
|
|
|
2016-06-19 20:06:29 +12:00
|
|
|
bool compute(const Params ¶ms) const override;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
protected:
|
2016-06-19 20:06:29 +12:00
|
|
|
void makeIcon(const TDimension &d) override;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void arrangeIcon(const TDimension &d, const TRasterP &normalIc);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-19 20:06:29 +12:00
|
|
|
void loadData(TInputStreamInterface &) override;
|
|
|
|
void saveData(TOutputStreamInterface &) const override;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
// per la compatibilita' con il passato
|
2016-06-20 14:23:05 +12:00
|
|
|
void loadData(int oldId, TInputStreamInterface &) override{};
|
2016-03-19 06:57:51 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
|
2016-06-29 18:17:12 +12:00
|
|
|
class TBlendRasterStyle final : public TAirbrushRasterStyle {
|
2016-03-19 06:57:51 +13:00
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
TBlendRasterStyle(const TPixel32 &color, double blur)
|
|
|
|
: TAirbrushRasterStyle(color, blur) {}
|
2016-06-19 20:06:29 +12:00
|
|
|
TColorStyle *clone() const override;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-19 20:06:29 +12:00
|
|
|
int getTagId() const override { return 1160; }
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-19 20:06:29 +12:00
|
|
|
QString getDescription() const override {
|
2016-06-15 18:43:10 +12:00
|
|
|
return QCoreApplication::translate("TBlendRasterStyle", "Blend");
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-19 20:06:29 +12:00
|
|
|
void makeIcon(const TDimension &d) override;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-19 20:06:29 +12:00
|
|
|
bool compute(const TRasterStyleFx::Params ¶ms) const override;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
private:
|
2016-06-15 18:43:10 +12:00
|
|
|
double computeFactor(const TRasterStyleFx::Params ¶ms) const;
|
2016-03-19 06:57:51 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
|
2016-06-29 18:17:12 +12:00
|
|
|
class TNoColorRasterStyle final : public TColorStyle, TRasterStyleFx {
|
2016-03-19 06:57:51 +13:00
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
TNoColorRasterStyle() {}
|
2016-06-19 20:06:29 +12:00
|
|
|
TColorStyle *clone() const override { return new TNoColorRasterStyle(*this); }
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
// n.b. per un plain color: isRasterStyle() == true, ma getRasterStyleFx() = 0
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-19 20:06:29 +12:00
|
|
|
TStrokeProp *makeStrokeProp(const TStroke *stroke) override { return 0; }
|
|
|
|
TRegionProp *makeRegionProp(const TRegion *region) override { return 0; }
|
|
|
|
TRasterStyleFx *getRasterStyleFx() override { return this; }
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-19 20:06:29 +12:00
|
|
|
bool isRegionStyle() const override { return false; }
|
|
|
|
bool isStrokeStyle() const override { return false; }
|
|
|
|
bool isRasterStyle() const override { return true; }
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-19 20:06:29 +12:00
|
|
|
QString getDescription() const override {
|
2016-06-15 18:43:10 +12:00
|
|
|
return QCoreApplication::translate("TNoColorRasterStyle", "Markup");
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
bool hasMainColor() { return false; }
|
|
|
|
// TPixel32 getMainColor() const {return m_color;}
|
|
|
|
// void setMainColor(const TPixel32 &color) {m_color = color;}
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-19 20:06:29 +12:00
|
|
|
int getColorParamCount() const override { return 0; }
|
|
|
|
TPixel32 getColorParamValue(int index) const override {
|
2016-06-15 18:43:10 +12:00
|
|
|
assert(false);
|
|
|
|
return TPixel32();
|
|
|
|
}
|
2016-06-20 14:23:05 +12:00
|
|
|
void setColorParamValue(int index, const TPixel32 &color) override {
|
|
|
|
assert(false);
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-19 20:06:29 +12:00
|
|
|
int getTagId() const override { return 1151; }
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-19 20:06:29 +12:00
|
|
|
bool isInkStyle() const override { return true; }
|
|
|
|
bool isPaintStyle() const override { return true; }
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-19 20:06:29 +12:00
|
|
|
bool compute(const Params ¶ms) const override { return false; }
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
protected:
|
2016-06-19 20:06:29 +12:00
|
|
|
void makeIcon(const TDimension &d) override;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-20 14:23:05 +12:00
|
|
|
void loadData(TInputStreamInterface &) override{};
|
|
|
|
void saveData(TOutputStreamInterface &) const override{};
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
// per la compatibilita' con il passato
|
2016-06-20 14:23:05 +12:00
|
|
|
void loadData(int oldId, TInputStreamInterface &) override{};
|
2016-03-19 06:57:51 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|