tahoma2d/toonz/sources/colorfx/regionstyles.h

917 lines
32 KiB
C
Raw Normal View History

2016-05-17 03:04:11 +12:00
#pragma once
2016-03-19 06:57:51 +13:00
#ifndef TDERIVEDREGIONSTYLES_H
#define TDERIVEDREGIONSTYLES_H
// TnzCore includes
#include "tvectorimage.h"
#include "tregionoutline.h"
#include "tsimplecolorstyles.h"
#undef DVAPI
#undef DVVAR
#ifdef COLORFX_EXPORTS
#define DVAPI DV_EXPORT_API
#define DVVAR DV_EXPORT_VAR
#else
#define DVAPI DV_IMPORT_API
#define DVVAR DV_IMPORT_VAR
#endif
//======================================================
// Forward declarations
class TRandom;
//======================================================
//============================================================
class MovingModifier final : public TOutlineStyle::RegionOutlineModifier {
2016-06-15 18:43:10 +12:00
TPointD m_move;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
MovingModifier(const TPointD &point) : m_move(point) {}
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
TOutlineStyle::RegionOutlineModifier *clone() const override;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
TPointD getMovePoint() const { return m_move; }
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
void modify(TRegionOutline &outline) const override;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
void loadData(TInputStreamInterface &is) { is >> m_move.x >> m_move.y; }
void saveData(TOutputStreamInterface &os) const {
os << m_move.x << m_move.y;
}
2016-03-19 06:57:51 +13:00
};
//============================================================
class MovingSolidColor final : public TSolidColorStyle {
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
MovingSolidColor(const TPixel32 &color, const TPointD &move);
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
2016-06-19 20:06:29 +12:00
bool isRegionStyle() const override { return true; }
bool isStrokeStyle() const override { return false; }
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getParamCount() const override;
TColorStyle::ParamType getParamType(int index) const override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
QString getParamNames(int index) const override;
void getParamRange(int index, double &min, double &max) const override;
double getParamValue(TColorStyle::double_tag, int index) const override;
void setParamValue(int index, double value) override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getTagId() const override { return 1125; };
QString getDescription() const override {
2016-06-15 18:43:10 +12:00
return QCoreApplication::translate("MovingSolidColor", "Offset");
}
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void drawRegion(const TColorFunction *cf, const bool antiAliasing,
2016-06-19 20:06:29 +12:00
TRegionOutline &boundary) const override;
void drawRegion(TFlash &flash, const TRegion *r) const override;
2016-03-19 06:57:51 +13:00
protected:
2016-06-19 20:06:29 +12:00
void loadData(TInputStreamInterface &is) override;
void saveData(TOutputStreamInterface &os) const override;
2016-03-19 06:57:51 +13:00
};
//============================================================
class DVAPI ShadowStyle final : public TSolidColorStyle {
2016-06-15 18:43:10 +12:00
TPointD m_shadowDirection;
TPixel32 m_shadowColor;
double m_density;
double m_len;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
ShadowStyle(const TPixel32 &bgColor, const TPixel32 &shadowColor,
const TPointD &shadowDirection = TPointD(-1, -1),
double len = 30.0, double density = 0.4);
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
2016-06-19 20:06:29 +12:00
void makeIcon(const TDimension &d) override;
bool isRegionStyle() const override { return true; }
bool isStrokeStyle() const override { return false; }
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
// TPixel32 getMainColor() const {return m_shadowColor; }
// void setMainColor(const TPixel32 &color){ m_shadowColor=color; }
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getColorParamCount() const override { return 2; }
TPixel32 getColorParamValue(int index) const override;
void setColorParamValue(int index, const TPixel32 &color) override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getParamCount() const override;
TColorStyle::ParamType getParamType(int index) const override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
QString getParamNames(int index) const override;
void getParamRange(int index, double &min, double &max) const override;
double getParamValue(TColorStyle::double_tag, int index) const override;
void setParamValue(int index, double value) override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getTagId() const override { return 1127; };
QString getDescription() const override {
2016-06-15 18:43:10 +12:00
return QCoreApplication::translate("ShadowStyle", "Hatched Shading");
}
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void drawRegion(const TColorFunction *cf, const bool antiAliasing,
2016-06-19 20:06:29 +12:00
TRegionOutline &boundary) const override;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
// it is too slow and if the region is too complex, some flash readers
// (IExplorer) crash.
// So it's better drawing it as a normal solid color
// void drawRegion( TFlash& flash, const TRegion* r) const;
2016-03-19 06:57:51 +13:00
protected:
2016-06-19 20:06:29 +12:00
void loadData(TInputStreamInterface &is) override;
void saveData(TOutputStreamInterface &os) const override;
2016-03-19 06:57:51 +13:00
private:
2016-06-15 18:43:10 +12:00
void drawPolyline(const TColorFunction *cf, std::vector<T3DPointD> &polyline,
TPointD shadowDirection) const;
2016-03-19 06:57:51 +13:00
};
//============================================================
class DVAPI ShadowStyle2 final : public TSolidColorStyle {
2016-06-15 18:43:10 +12:00
TPointD m_shadowDirection;
TPixel32 m_shadowColor;
double m_shadowLength;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
ShadowStyle2(const TPixel32 &bgColor, const TPixel32 &shadowColor,
const TPointD &shadowDirection = TPointD(-1, -1),
double shadowLength = 70.0);
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
2016-06-19 20:06:29 +12:00
bool isRegionStyle() const override { return true; }
bool isStrokeStyle() const override { return false; }
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
// TPixel32 getMainColor() const {return m_shadowColor; }
// void setMainColor(const TPixel32 &color){ m_shadowColor=color; }
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getColorParamCount() const override { return 2; }
TPixel32 getColorParamValue(int index) const override;
void setColorParamValue(int index, const TPixel32 &color) override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getParamCount() const override;
TColorStyle::ParamType getParamType(int index) const override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
QString getParamNames(int index) const override;
void getParamRange(int index, double &min, double &max) const override;
double getParamValue(TColorStyle::double_tag, int index) const override;
void setParamValue(int index, double value) override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getTagId() const override { return 1135; };
QString getDescription() const override {
2016-06-15 18:43:10 +12:00
return QCoreApplication::translate("ShadowStyle2", "Plain Shadow");
}
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void drawRegion(const TColorFunction *cf, const bool antiAliasing,
2016-06-19 20:06:29 +12:00
TRegionOutline &boundary) const override;
void drawRegion(TFlash &flash, const TRegion *r) const override;
2016-03-19 06:57:51 +13:00
protected:
2016-06-19 20:06:29 +12:00
void loadData(TInputStreamInterface &is) override;
void saveData(TOutputStreamInterface &os) const override;
2016-03-19 06:57:51 +13:00
private:
2016-06-15 18:43:10 +12:00
void drawPolyline(const TColorFunction *cf,
const std::vector<T3DPointD> &polyline,
TPointD shadowDirection) const;
int drawPolyline(TFlash &flash, std::vector<T3DPointD> &polyline,
TPointD shadowDirection, const bool isDraw = true) const;
2016-03-19 06:57:51 +13:00
};
//============================================================
class RubberModifier final : public TOutlineStyle::RegionOutlineModifier {
2016-06-15 18:43:10 +12:00
double m_deform;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
RubberModifier(double deform) : m_deform(deform) {}
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void loadData(TInputStreamInterface &is) { is >> m_deform; }
void saveData(TOutputStreamInterface &os) const { os << m_deform; }
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
double getDeform() { return m_deform; }
void setDeform(const double deform) { m_deform = deform; }
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
void modify(TRegionOutline &outline) const override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
TOutlineStyle::RegionOutlineModifier *clone() const override;
2016-03-19 06:57:51 +13:00
};
//============================================================
class DVAPI TRubberFillStyle final : public TSolidColorStyle {
2016-06-15 18:43:10 +12:00
typedef std::vector<TQuadratic> QuadraticVector;
typedef std::vector<TQuadratic *> QuadraticPVector;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
TRubberFillStyle(const TPixel32 &color, double deform);
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
2016-06-19 20:06:29 +12:00
bool isRegionStyle() const override { return true; }
bool isStrokeStyle() const override { return false; }
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getParamCount() const override;
TColorStyle::ParamType getParamType(int index) const override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
QString getParamNames(int index) const override;
void getParamRange(int index, double &min, double &max) const override;
double getParamValue(TColorStyle::double_tag, int index) const override;
void setParamValue(int index, double value) override;
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
int getTagId() const override { return 1128; };
QString getDescription() const override {
2016-06-15 18:43:10 +12:00
return QCoreApplication::translate("TRubberFillStyle", "Blob");
}
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void drawRegion(const TColorFunction *cf, const bool antiAliasing,
2016-06-19 20:06:29 +12:00
TRegionOutline &boundary) const override;
void drawRegion(TFlash &flash, const TRegion *r) const override;
2016-03-19 06:57:51 +13:00
protected:
2016-06-19 20:06:29 +12:00
void loadData(TInputStreamInterface &is) override;
void saveData(TOutputStreamInterface &os) const override;
2016-03-19 06:57:51 +13:00
private:
2016-06-15 18:43:10 +12:00
void transformPolylines();
2016-03-19 06:57:51 +13:00
};
//============================================================
class DVAPI TPointShadowFillStyle final : public TSolidColorStyle {
2016-06-15 18:43:10 +12:00
TPointD m_shadowDirection;
TPixel32 m_shadowColor;
double m_shadowSize;
double m_density;
double m_pointSize;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
TPointShadowFillStyle(const TPixel32 &bgColor, const TPixel32 &shadowColor,
const TPointD &shadowDirection = TPointD(-1, -1),
double density = 0.1, double shadowSize = 30.0,
double pointSize = 5.0);
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
2016-06-19 20:06:29 +12:00
bool isRegionStyle() const override { return true; }
bool isStrokeStyle() const override { return false; }
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
/*
TPixel32 getMainColor() const {return m_shadowColor; }
void setMainColor(const TPixel32 &color){ m_shadowColor=color; }
*/
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getColorParamCount() const override { return 2; }
TPixel32 getColorParamValue(int index) const override;
void setColorParamValue(int index, const TPixel32 &color) override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getParamCount() const override;
TColorStyle::ParamType getParamType(int index) const override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
QString getParamNames(int index) const override;
void getParamRange(int index, double &min, double &max) const override;
double getParamValue(TColorStyle::double_tag, int index) const override;
void setParamValue(int index, double value) override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getTagId() const override { return 1129; };
QString getDescription() const override {
2016-06-15 18:43:10 +12:00
return QCoreApplication::translate("TPointShadowFillStyle",
"Sponge Shading");
}
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void drawRegion(const TColorFunction *cf, const bool antiAliasing,
2016-06-19 20:06:29 +12:00
TRegionOutline &boundary) const override;
void drawRegion(TFlash &flash, const TRegion *r) const override;
2016-03-19 06:57:51 +13:00
protected:
2016-06-19 20:06:29 +12:00
void loadData(TInputStreamInterface &is) override;
void saveData(TOutputStreamInterface &os) const override;
2016-03-19 06:57:51 +13:00
private:
2016-06-15 18:43:10 +12:00
double triangleArea(const TPointD &a, const TPointD &b,
const TPointD &c) const;
void shadowOnEdge_parallel(const TPointD &p0, const TPointD &p1,
const TPointD &p2, TRandom &rnd) const;
int shadowOnEdge_parallel(TFlash &flash, const TPointD &p0, const TPointD &p1,
const TPointD &p2, TRandom &rnd,
const double radius, const bool isDraw) const;
void deleteSameVerts(TRegionOutline::Boundary::iterator &rit,
std::vector<T3DPointD> &pv) const;
2016-03-19 06:57:51 +13:00
};
//============================================================
class DVAPI TDottedFillStyle final : public TSolidColorStyle {
2016-06-15 18:43:10 +12:00
TPixel32 m_pointColor;
double m_dotSize;
double m_dotDist;
bool m_isShifted;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
TDottedFillStyle(const TPixel32 &bgColor, const TPixel32 &pointColor,
const double dotSize, const double dotDist,
const bool isShifted);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
TDottedFillStyle(const TPixel32 &color);
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
2016-06-15 18:43:10 +12:00
/*
TPixel32 getMainColor() const {return m_pointColor; }
void setMainColor(const TPixel32 &color){ m_pointColor=color; }
*/
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getColorParamCount() const override { return 2; }
TPixel32 getColorParamValue(int index) const override;
void setColorParamValue(int index, const TPixel32 &color) override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
bool isRegionStyle() const override { return true; }
bool isStrokeStyle() const override { return false; }
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getParamCount() const override;
TColorStyle::ParamType getParamType(int index) const override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
QString getParamNames(int index) const override;
void getParamRange(int index, double &min, double &max) const override;
double getParamValue(TColorStyle::double_tag, int index) const override;
void setParamValue(int index, double value) override;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void drawRegion(const TColorFunction *cf, const bool antiAliasing,
2016-06-19 20:06:29 +12:00
TRegionOutline &boundary) const override;
void drawRegion(TFlash &flash, const TRegion *r) const override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getTagId() const override { return 1130; };
QString getDescription() const override {
2016-06-15 18:43:10 +12:00
return QCoreApplication::translate("TDottedFillStyle", "Polka Dots");
}
2016-03-19 06:57:51 +13:00
protected:
2016-06-19 20:06:29 +12:00
void loadData(TInputStreamInterface &is) override;
void saveData(TOutputStreamInterface &os) const override;
2016-03-19 06:57:51 +13:00
private:
2016-06-15 18:43:10 +12:00
int nbClip(const double LDotDist, const bool LIsShifted,
const TRectD &bbox) const;
2016-03-19 06:57:51 +13:00
};
//============================================================
class DVAPI TCheckedFillStyle final : public TSolidColorStyle {
2016-06-15 18:43:10 +12:00
TPixel32 m_pointColor;
double m_HDist, m_HAngle;
double m_VDist, m_VAngle, m_Thickness;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
TCheckedFillStyle(const TPixel32 &bgColor, const TPixel32 &pointColor,
const double HDist, const double HAngle, const double VDist,
const double VAngle, const double Thickness);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
TCheckedFillStyle(const TPixel32 &color);
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
2016-06-15 18:43:10 +12:00
/*
TPixel32 getMainColor() const {return m_pointColor; }
void setMainColor(const TPixel32 &color){ m_pointColor=color; }
*/
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getColorParamCount() const override { return 2; }
TPixel32 getColorParamValue(int index) const override;
void setColorParamValue(int index, const TPixel32 &color) override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
bool isRegionStyle() const override { return true; }
bool isStrokeStyle() const override { return false; }
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getParamCount() const override;
TColorStyle::ParamType getParamType(int index) const override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
QString getParamNames(int index) const override;
void getParamRange(int index, double &min, double &max) const override;
double getParamValue(TColorStyle::double_tag, int index) const override;
void setParamValue(int index, double value) override;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void drawRegion(const TColorFunction *cf, const bool antiAliasing,
2016-06-19 20:06:29 +12:00
TRegionOutline &boundary) const override;
void drawRegion(TFlash &flash, const TRegion *r) const override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getTagId() const override { return 1131; };
QString getDescription() const override {
2016-06-15 18:43:10 +12:00
return QCoreApplication::translate("TCheckedFillStyle", "Square");
}
2016-03-19 06:57:51 +13:00
private:
2016-06-15 18:43:10 +12:00
void getHThickline(const TPointD &lc, const double lx, TPointD &p0,
TPointD &p1, TPointD &p2, TPointD &p3) const;
void getVThickline(const TPointD &lc, const double ly, TPointD &p0,
TPointD &p1, TPointD &p2, TPointD &p3) const;
int nbClip(const TRectD &bbox) const;
2016-03-19 06:57:51 +13:00
protected:
2016-06-19 20:06:29 +12:00
void loadData(TInputStreamInterface &is) override;
void saveData(TOutputStreamInterface &os) const override;
2016-03-19 06:57:51 +13:00
};
//============================================================
class ArtisticModifier final : public TOutlineStyle::RegionOutlineModifier {
2016-06-15 18:43:10 +12:00
TPointD m_move;
double m_period;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
ArtisticModifier(const TPointD &point, double period)
: m_move(point), m_period(period) {}
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
TOutlineStyle::RegionOutlineModifier *clone() const override;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void loadData(TInputStreamInterface &is) {
is >> m_move.x >> m_move.y >> m_period;
}
void saveData(TOutputStreamInterface &os) const {
os << m_move.x << m_move.y << m_period;
}
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
TPointD getMovePoint() const { return m_move; }
double getPeriod() const { return m_period; }
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
void modify(TRegionOutline &outline) const override;
2016-03-19 06:57:51 +13:00
};
//============================================================
class ArtisticSolidColor final : public TSolidColorStyle {
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
ArtisticSolidColor(const TPixel32 &color, const TPointD &move, double period);
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
2016-06-19 20:06:29 +12:00
bool isRegionStyle() const override { return true; }
bool isStrokeStyle() const override { return false; }
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getParamCount() const override;
TColorStyle::ParamType getParamType(int index) const override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
QString getParamNames(int index) const override;
void getParamRange(int index, double &min, double &max) const override;
double getParamValue(TColorStyle::double_tag, int index) const override;
void setParamValue(int index, double value) override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getTagId() const override { return 1132; };
QString getDescription() const override {
2016-06-15 18:43:10 +12:00
return QCoreApplication::translate("ArtisticSolidColor", "Irregular");
}
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void drawRegion(const TColorFunction *cf, const bool antiAliasing,
2016-06-19 20:06:29 +12:00
TRegionOutline &boundary) const override;
void drawRegion(TFlash &flash, const TRegion *r) const override;
2016-03-19 06:57:51 +13:00
protected:
2016-06-19 20:06:29 +12:00
void loadData(TInputStreamInterface &is) override;
void saveData(TOutputStreamInterface &os) const override;
2016-03-19 06:57:51 +13:00
};
//============================================================
class DVAPI TChalkFillStyle final : public TSolidColorStyle {
2016-06-15 18:43:10 +12:00
TPixel32 m_color0;
double m_density, m_size;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
TChalkFillStyle(const TPixel32 &color0, const TPixel32 &color1,
const double density, const double size);
TChalkFillStyle(const TPixel32 &color0, const TPixel32 &color1);
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
2016-06-15 18:43:10 +12:00
/*
TPixel32 getMainColor() const {return m_color0; }
void setMainColor(const TPixel32 &color){ m_color0=color; }
*/
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getColorParamCount() const override { return 2; }
TPixel32 getColorParamValue(int index) const override;
void setColorParamValue(int index, const TPixel32 &color) override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
bool isRegionStyle() const override { return true; }
bool isStrokeStyle() const override { return false; }
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getParamCount() const override;
TColorStyle::ParamType getParamType(int index) const override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
QString getParamNames(int index) const override;
void getParamRange(int index, double &min, double &max) const override;
double getParamValue(TColorStyle::double_tag, int index) const override;
void setParamValue(int index, double value) override;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void drawRegion(const TColorFunction *cf, const bool antiAliasing,
2016-06-19 20:06:29 +12:00
TRegionOutline &boundary) const override;
void drawRegion(TFlash &flash, const TRegion *r) const override;
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("TChalkFillStyle", "Chalk");
}
2016-06-19 20:06:29 +12:00
void loadData(int oldId, TInputStreamInterface &) override;
2016-06-20 14:23:05 +12:00
void getObsoleteTagIds(std::vector<int> &ids) const override {
ids.push_back(1133);
}
2016-06-19 20:06:29 +12:00
int getTagId() const override { return 1143; };
2016-03-19 06:57:51 +13:00
protected:
2016-06-19 20:06:29 +12:00
void loadData(TInputStreamInterface &is) override;
void saveData(TOutputStreamInterface &os) const override;
2016-03-19 06:57:51 +13:00
};
//============================================================
class DVAPI TChessFillStyle final : public TSolidColorStyle {
2016-06-15 18:43:10 +12:00
TPixel32 m_pointColor;
double m_HDist, m_VDist, m_Angle;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
TChessFillStyle(const TPixel32 &bgColor, const TPixel32 &pointColor,
const double HDist, const double VDist, const double Angle);
TChessFillStyle(const TPixel32 &color);
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
2016-06-15 18:43:10 +12:00
/*
TPixel32 getMainColor() const {return m_pointColor; }
void setMainColor(const TPixel32 &color){ m_pointColor=color; }
*/
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getColorParamCount() const override { return 2; }
TPixel32 getColorParamValue(int index) const override;
void setColorParamValue(int index, const TPixel32 &color) override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
bool isRegionStyle() const override { return true; }
bool isStrokeStyle() const override { return false; }
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getParamCount() const override;
TColorStyle::ParamType getParamType(int index) const override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
QString getParamNames(int index) const override;
void getParamRange(int index, double &min, double &max) const override;
double getParamValue(TColorStyle::double_tag, int index) const override;
void setParamValue(int index, double value) override;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void drawRegion(const TColorFunction *cf, const bool antiAliasing,
2016-06-19 20:06:29 +12:00
TRegionOutline &boundary) const override;
void drawRegion(TFlash &flash, const TRegion *r) const override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getTagId() const override { return 1136; };
QString getDescription() const override {
2016-06-15 18:43:10 +12:00
return QCoreApplication::translate("TChessFillStyle", "Chessboard");
}
2016-03-19 06:57:51 +13:00
protected:
2016-06-19 20:06:29 +12:00
void loadData(TInputStreamInterface &is) override;
void saveData(TOutputStreamInterface &os) const override;
2016-03-19 06:57:51 +13:00
private:
2016-06-15 18:43:10 +12:00
void makeGrid(TRectD &bbox, TRotation &rotM, std::vector<TPointD> &grid,
int &nbClip) const;
2016-03-19 06:57:51 +13:00
};
//============================================================
class DVAPI TStripeFillStyle final : public TSolidColorStyle {
2016-06-15 18:43:10 +12:00
TPixel32 m_pointColor;
double m_Dist, m_Angle, m_Thickness;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
TStripeFillStyle(const TPixel32 &bgColor, const TPixel32 &pointColor,
const double Dist, const double Angle,
const double Thickness);
TStripeFillStyle(const TPixel32 &color);
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
2016-06-15 18:43:10 +12:00
/*
TPixel32 getMainColor() const {return m_pointColor; }
void setMainColor(const TPixel32 &color){ m_pointColor=color; }
*/
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getColorParamCount() const override { return 2; }
TPixel32 getColorParamValue(int index) const override;
void setColorParamValue(int index, const TPixel32 &color) override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
bool isRegionStyle() const override { return true; }
bool isStrokeStyle() const override { return false; }
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getParamCount() const override;
TColorStyle::ParamType getParamType(int index) const override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
QString getParamNames(int index) const override;
void getParamRange(int index, double &min, double &max) const override;
double getParamValue(TColorStyle::double_tag, int index) const override;
void setParamValue(int index, double value) override;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void drawRegion(const TColorFunction *cf, const bool antiAliasing,
2016-06-19 20:06:29 +12:00
TRegionOutline &boundary) const override;
void drawRegion(TFlash &flash, const TRegion *r) const override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getTagId() const override { return 1137; };
QString getDescription() const override {
2016-06-15 18:43:10 +12:00
return QCoreApplication::translate("TStripeFillStyle", "Banded");
}
2016-03-19 06:57:51 +13:00
protected:
2016-06-19 20:06:29 +12:00
void loadData(TInputStreamInterface &is) override;
void saveData(TOutputStreamInterface &os) const override;
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
private:
2016-06-15 18:43:10 +12:00
void getThickline(const TPointD &lc, const double ly, TPointD &p0,
TPointD &p1, TPointD &p2, TPointD &p3) const;
int nbClip(const TRectD &bbox) const;
2016-03-19 06:57:51 +13:00
};
//============================================================
class DVAPI TLinGradFillStyle final : public TSolidColorStyle {
2016-06-15 18:43:10 +12:00
TPixel32 m_pointColor;
double m_Angle;
double m_XPos, m_YPos, m_Size;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
TLinGradFillStyle(const TPixel32 &bgColor, const TPixel32 &pointColor,
const double Angle, const double XPos, const double YPos,
const double Size);
TLinGradFillStyle(const TPixel32 &color);
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
2016-06-15 18:43:10 +12:00
/*
TPixel32 getMainColor() const {return m_pointColor; }
void setMainColor(const TPixel32 &color){ m_pointColor=color; }
*/
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getColorParamCount() const override { return 2; }
TPixel32 getColorParamValue(int index) const override;
void setColorParamValue(int index, const TPixel32 &color) override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
bool isRegionStyle() const override { return true; }
bool isStrokeStyle() const override { return false; }
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getParamCount() const override;
TColorStyle::ParamType getParamType(int index) const override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
QString getParamNames(int index) const override;
void getParamRange(int index, double &min, double &max) const override;
double getParamValue(TColorStyle::double_tag, int index) const override;
void setParamValue(int index, double value) override;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void drawRegion(const TColorFunction *cf, const bool antiAliasing,
2016-06-19 20:06:29 +12:00
TRegionOutline &boundary) const override;
void drawRegion(TFlash &flash, const TRegion *r) const override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getTagId() const override { return 1138; };
QString getDescription() const override {
2016-06-15 18:43:10 +12:00
return QCoreApplication::translate("TLinGradFillStyle", "Linear Gradient");
}
2016-03-19 06:57:51 +13:00
protected:
2016-06-19 20:06:29 +12:00
void loadData(TInputStreamInterface &is) override;
void saveData(TOutputStreamInterface &os) const override;
2016-03-19 06:57:51 +13:00
private:
2016-06-15 18:43:10 +12:00
void getRects(const TRectD &bbox, std::vector<TPointD> &r0,
std::vector<TPointD> &r1, std::vector<TPointD> &r2) const;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void getRect(const TRectD &bbox, std::vector<TPointD> &r) const;
2016-03-19 06:57:51 +13:00
};
//============================================================
class DVAPI TRadGradFillStyle final : public TSolidColorStyle {
2016-06-15 18:43:10 +12:00
TPixel32 m_pointColor;
double m_Radius;
double m_XPos, m_YPos;
double m_Smooth;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
TRadGradFillStyle(const TPixel32 &bgColor, const TPixel32 &pointColor,
const double XPos, const double YPos, const double Radius,
const double Smooth);
TRadGradFillStyle(const TPixel32 &color);
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
2016-06-15 18:43:10 +12:00
// TPixel32 getMainColor() const {return m_pointColor; }
// void setMainColor(const TPixel32 &color){ m_pointColor=color; }
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getColorParamCount() const override { return 2; }
TPixel32 getColorParamValue(int index) const override;
void setColorParamValue(int index, const TPixel32 &color) override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
bool isRegionStyle() const override { return true; }
bool isStrokeStyle() const override { return false; }
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getParamCount() const override;
TColorStyle::ParamType getParamType(int index) const override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
QString getParamNames(int index) const override;
void getParamRange(int index, double &min, double &max) const override;
double getParamValue(TColorStyle::double_tag, int index) const override;
void setParamValue(int index, double value) override;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void drawRegion(const TColorFunction *cf, const bool antiAliasing,
2016-06-19 20:06:29 +12:00
TRegionOutline &boundary) const override;
void drawRegion(TFlash &flash, const TRegion *r) const override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getTagId() const override { return 1139; };
QString getDescription() const override {
2016-06-15 18:43:10 +12:00
return QCoreApplication::translate("TRadGradFillStyle", "Radial Gradient");
}
2016-03-19 06:57:51 +13:00
protected:
2016-06-19 20:06:29 +12:00
void loadData(TInputStreamInterface &is) override;
void saveData(TOutputStreamInterface &os) const override;
2016-03-19 06:57:51 +13:00
};
//============================================================
class DVAPI TCircleStripeFillStyle final : public TSolidColorStyle {
2016-06-15 18:43:10 +12:00
TPixel32 m_pointColor;
double m_XPos, m_YPos;
double m_Dist, m_Thickness;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
TCircleStripeFillStyle(const TPixel32 &bgColor, const TPixel32 &pointColor,
const double XPos, const double YPos,
const double Dist, const double Thickness);
TCircleStripeFillStyle(const TPixel32 &color);
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
2016-06-15 18:43:10 +12:00
/*
TPixel32 getMainColor() const {return m_pointColor; }
void setMainColor(const TPixel32 &color){ m_pointColor=color; }
*/
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getColorParamCount() const override { return 2; }
TPixel32 getColorParamValue(int index) const override;
void setColorParamValue(int index, const TPixel32 &color) override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
bool isRegionStyle() const override { return true; }
bool isStrokeStyle() const override { return false; }
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getParamCount() const override;
TColorStyle::ParamType getParamType(int index) const override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
QString getParamNames(int index) const override;
void getParamRange(int index, double &min, double &max) const override;
double getParamValue(TColorStyle::double_tag, int index) const override;
void setParamValue(int index, double value) override;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void drawRegion(const TColorFunction *cf, const bool antiAliasing,
2016-06-19 20:06:29 +12:00
TRegionOutline &boundary) const override;
void drawRegion(TFlash &flash, const TRegion *r) const override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getTagId() const override { return 1140; };
QString getDescription() const override {
2016-06-15 18:43:10 +12:00
return QCoreApplication::translate("TCircleStripeFillStyle", "Concentric");
}
2016-03-19 06:57:51 +13:00
protected:
2016-06-19 20:06:29 +12:00
void loadData(TInputStreamInterface &is) override;
void saveData(TOutputStreamInterface &os) const override;
2016-03-19 06:57:51 +13:00
private:
2016-06-15 18:43:10 +12:00
void getCircleStripeQuads(const TPointD &center, const double r1,
const double r2, std::vector<TPointD> &pv) const;
void drawCircleStripe(const TPointD &center, const double r1, const double r2,
const TPixel32 &col) const;
2016-03-19 06:57:51 +13:00
};
//============================================================
class DVAPI TMosaicFillStyle final : public TSolidColorStyle {
2016-06-15 18:43:10 +12:00
TPixel32 m_pointColor[4];
double m_size;
double m_deform;
double m_minThickness;
double m_maxThickness;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
TMosaicFillStyle(const TPixel32 &bgColor, const TPixel32 pointColor[4],
const double size, const double deform,
const double minThickness, const double maxThickness);
TMosaicFillStyle(const TPixel32 bgColor);
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
2016-06-15 18:43:10 +12:00
/*
TPixel32 getMainColor() const {return m_pointColor[0]; }
void setMainColor(const TPixel32 &color){ m_pointColor[0]=color; }
*/
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getColorParamCount() const override { return 5; }
TPixel32 getColorParamValue(int index) const override;
void setColorParamValue(int index, const TPixel32 &color) override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
bool isRegionStyle() const override { return true; }
bool isStrokeStyle() const override { return false; }
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getParamCount() const override;
TColorStyle::ParamType getParamType(int index) const override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
QString getParamNames(int index) const override;
void getParamRange(int index, double &min, double &max) const override;
double getParamValue(TColorStyle::double_tag, int index) const override;
void setParamValue(int index, double value) override;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void drawRegion(const TColorFunction *cf, const bool antiAliasing,
2016-06-19 20:06:29 +12:00
TRegionOutline &boundary) const override;
void drawRegion(TFlash &flash, const TRegion *r) const override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getTagId() const override { return 1141; };
QString getDescription() const override {
2016-06-15 18:43:10 +12:00
return QCoreApplication::translate("TMosaicFillStyle", "Stained Glass");
}
2016-03-19 06:57:51 +13:00
protected:
2016-06-19 20:06:29 +12:00
void loadData(TInputStreamInterface &is) override;
void saveData(TOutputStreamInterface &os) const override;
2016-03-19 06:57:51 +13:00
private:
2016-06-15 18:43:10 +12:00
void preaprePos(const TRectD &box, std::vector<TPointD> &v, int &lX, int &lY,
TRandom &rand) const;
bool getQuad(const int ix, const int iy, const int lX, const int lY,
std::vector<TPointD> &v, TPointD *pquad, TRandom &rand) const;
2016-03-19 06:57:51 +13:00
};
//============================================================
class DVAPI TPatchFillStyle final : public TSolidColorStyle {
2016-06-15 18:43:10 +12:00
TPixel32 m_pointColor[6];
double m_size;
double m_deform;
double m_thickness;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
TPatchFillStyle(const TPixel32 &bgColor, const TPixel32 pointColor[6],
const double size, const double deform,
const double thickness);
TPatchFillStyle(const TPixel32 &bgColor);
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
2016-06-19 20:06:29 +12:00
int getColorParamCount() const override { return 7; }
TPixel32 getColorParamValue(int index) const override;
void setColorParamValue(int index, const TPixel32 &color) override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
bool isRegionStyle() const override { return true; }
bool isStrokeStyle() const override { return false; }
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getParamCount() const override;
TColorStyle::ParamType getParamType(int index) const override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
QString getParamNames(int index) const override;
void getParamRange(int index, double &min, double &max) const override;
double getParamValue(TColorStyle::double_tag, int index) const override;
void setParamValue(int index, double value) override;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void drawRegion(const TColorFunction *cf, const bool antiAliasing,
2016-06-19 20:06:29 +12:00
TRegionOutline &boundary) const override;
void drawRegion(TFlash &flash, const TRegion *r) const override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getTagId() const override { return 1142; };
QString getDescription() const override {
2016-06-15 18:43:10 +12:00
return QCoreApplication::translate("TPatchFillStyle", "Beehive");
}
2016-03-19 06:57:51 +13:00
private:
2016-06-15 18:43:10 +12:00
void preaprePos(const TRectD &box, std::vector<TPointD> &v, int &lX, int &lY,
TRandom &rand) const;
bool getQuadLine(const TPointD &a, const TPointD &b, const double thickn,
TPointD *quad) const;
void drawGLQuad(const TPointD *quad) const;
int nbClip(const int lX, const int lY, const std::vector<TPointD> &v) const;
void drawFlashQuad(TFlash &flash, const TPointD *quad) const;
void drawFlashTriangle(TFlash &flash, const TPointD &p1, const TPointD &p2,
const TPointD &p3) const;
2016-03-19 06:57:51 +13:00
protected:
2016-06-19 20:06:29 +12:00
void loadData(TInputStreamInterface &is) override;
void saveData(TOutputStreamInterface &os) const override;
2016-03-19 06:57:51 +13:00
};
2016-06-15 18:43:10 +12:00
#endif // TDERIVEDREGIONSTYLES_H