| |
| |
| #ifndef TCOLORSTYLES_H |
| #define TCOLORSTYLES_H |
| |
| |
| #include "tfilepath.h" |
| #include "traster.h" |
| |
| |
| #include <QString> |
| |
| #undef DVAPI |
| #undef DVVAR |
| |
| #ifdef TVRENDER_EXPORTS |
| #define DVAPI DV_EXPORT_API |
| #define DVVAR DV_EXPORT_VAR |
| #else |
| #define DVAPI DV_IMPORT_API |
| #define DVVAR DV_IMPORT_VAR |
| #endif |
| |
| |
| |
| |
| |
| class TStroke; |
| class TRegion; |
| class TStrokeProp; |
| class TRegionProp; |
| class TVectorRenderData; |
| class TFlash; |
| class TInputStreamInterface; |
| class TOutputStreamInterface; |
| class TRasterStyleFx; |
| class QStringList; |
| |
| |
| |
| |
| |
| |
| |
| class DVAPI TRasterStyleFx |
| { |
| public: |
| struct Params { |
| TRasterP m_r; |
| TPoint m_p; |
| TRasterP m_rOrig; |
| int m_colorIndex; |
| int m_frame; |
| |
| public: |
| Params(const TRasterP &r, const TPoint &p, |
| const TRasterP &rOrig, int index, int frame) |
| : m_r(r), m_p(p), m_rOrig(rOrig), m_colorIndex(index), m_frame(frame) |
| { |
| assert(m_r); |
| } |
| }; |
| |
| public: |
| virtual ~TRasterStyleFx() {} |
| |
| virtual bool isInkStyle() const = 0; |
| virtual bool isPaintStyle() const = 0; |
| |
| virtual bool inkFxNeedRGBMRaster() const |
| { |
| return false; |
| } |
| |
| virtual bool compute(const Params ¶ms) const = 0; |
| |
| virtual void getEnlargement(int &borderIn, int &borderOut) const |
| { |
| borderIn = borderOut = 0; |
| } |
| }; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| class DVAPI TColorStyle : public TSmartObject |
| { |
| public: |
| |
| class Declaration |
| { |
| public: |
| Declaration(TColorStyle *style) |
| { |
| declare(style); |
| } |
| }; |
| |
| enum ParamType { |
| BOOL, |
| INT, |
| ENUM, |
| DOUBLE, |
| FILEPATH |
| }; |
| |
| struct double_tag { |
| }; |
| struct bool_tag { |
| }; |
| struct int_tag { |
| }; |
| struct TFilePath_tag { |
| }; |
| |
| private: |
| std::wstring m_name; |
| std::wstring m_globalName; |
| std::wstring m_originalName; |
| |
| int m_versionNumber; |
| |
| unsigned int m_flags; |
| bool m_enabled; |
| |
| bool m_isEditedFromOriginal; |
| |
| |
| protected: |
| TRaster32P m_icon; |
| bool m_validIcon; |
| |
| public: |
| static int m_currentFrame; |
| |
| public: |
| TColorStyle(); |
| TColorStyle(const TColorStyle &other); |
| virtual ~TColorStyle(); |
| |
| virtual TColorStyle *clone() const = 0; |
| virtual TColorStyle ©(const TColorStyle &other) |
| { |
| assignBlend(other, other, 0.0); |
| return *this; |
| } |
| |
| bool operator==(const TColorStyle &cs) const; |
| bool operator!=(const TColorStyle &cs) { return !operator==(cs); } |
| |
| |
| |
| virtual TStrokeProp *makeStrokeProp(const TStroke *stroke) = 0; |
| |
| |
| virtual TRegionProp *makeRegionProp(const TRegion *region) = 0; |
| |
| |
| virtual bool isRasterStyle() const { return false; } |
| virtual TRasterStyleFx *getRasterStyleFx() { return 0; } |
| |
| |
| virtual bool isRegionStyle() const = 0; |
| virtual bool isStrokeStyle() const = 0; |
| |
| |
| |
| void setName(wstring name) { m_name = name; } |
| wstring getName() const { return m_name; } |
| |
| |
| |
| |
| void setGlobalName(wstring name) { m_globalName = name; } |
| wstring getGlobalName() const { return m_globalName; } |
| |
| void setOriginalName(wstring name) { m_originalName = name; } |
| wstring getOriginalName() const { return m_originalName; } |
| |
| void setIsEditedFlag(bool edited) { m_isEditedFromOriginal = edited; } |
| |
| bool getIsEditedFlag() const { return m_isEditedFromOriginal; } |
| |
| void assignNames(const TColorStyle *src); |
| |
| |
| unsigned int getFlags() const { return m_flags; } |
| void setFlags(unsigned int flags) { m_flags = flags; } |
| |
| |
| |
| |
| |
| |
| virtual bool hasMainColor() const { return false; } |
| virtual TPixel32 getMainColor() const { return TPixel32::Black; } |
| virtual void setMainColor(const TPixel32 &color) {} |
| |
| |
| |
| |
| |
| |
| virtual int getColorParamCount() const |
| { |
| return hasMainColor() ? 1 : 0; |
| } |
| |
| |
| |
| |
| virtual TPixel32 getColorParamValue(int index) const |
| { |
| return getMainColor(); |
| } |
| virtual void setColorParamValue(int index, const TPixel32 &color) |
| { |
| setMainColor(color); |
| } |
| |
| virtual TPixel32 getAverageColor() const |
| { |
| return getMainColor(); |
| } |
| |
| |
| |
| |
| |
| |
| |
| virtual int getParamCount() const { return 0; } |
| |
| |
| virtual ParamType getParamType(int paramIdx) const |
| { |
| assert(0 <= paramIdx && paramIdx < getParamCount()); |
| return DOUBLE; |
| } |
| |
| virtual void setParamValue(int index, bool value) |
| { |
| assert(false); |
| } |
| virtual bool getParamValue(bool_tag, int index) const |
| { |
| assert(false); |
| return bool(); |
| } |
| |
| virtual void setParamValue(int index, int value) |
| { |
| assert(false); |
| } |
| virtual int getParamValue(int_tag, int index) const |
| { |
| assert(false); |
| return int(); |
| } |
| virtual void getParamRange(int index, int &min, int &max) const |
| { |
| assert(false); |
| } |
| |
| virtual void getParamRange(int pIndex, QStringList &stringItems) const |
| { |
| assert(false); |
| } |
| |
| virtual void setParamValue(int index, double value) |
| { |
| assert(false); |
| } |
| virtual double getParamValue(double_tag, int index) const |
| { |
| assert(false); |
| return double(); |
| } |
| virtual void getParamRange(int index, double &min, double &max) const |
| { |
| assert(false); |
| } |
| |
| virtual void setParamValue(int index, const TFilePath &fp) |
| { |
| assert(false); |
| } |
| virtual TFilePath getParamValue(TFilePath_tag, int index) const |
| { |
| assert(false); |
| return TFilePath(); |
| } |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| void assignBlend(const TColorStyle &a, const TColorStyle &b, double t); |
| |
| |
| |
| |
| |
| |
| |
| virtual QString getDescription() const = 0; |
| virtual QString getParamNames(int index) const; |
| |
| |
| |
| virtual void drawStroke(TFlash &flash, const TStroke *stroke) const; |
| |
| |
| |
| virtual int getTagId() const = 0; |
| virtual void getObsoleteTagIds(vector<int> &) const {}; |
| |
| void save(TOutputStreamInterface &) const; |
| static TColorStyle *load(TInputStreamInterface &); |
| |
| static TColorStyle *create(int tagId); |
| |
| static void declare(TColorStyle *style); |
| static void getAllTags(vector<int> &tags); |
| |
| |
| |
| |
| |
| |
| void invalidateIcon() { m_validIcon = false; } |
| virtual const TRaster32P &getIcon(const TDimension &d); |
| |
| bool isEnabled() const { return m_enabled; } |
| void enable(bool on) { m_enabled = on; } |
| |
| int getVersionNumber() const { return m_versionNumber; } |
| |
| protected: |
| virtual void makeIcon(const TDimension &d); |
| |
| virtual void loadData(TInputStreamInterface &) = 0; |
| virtual void saveData(TOutputStreamInterface &) const = 0; |
| |
| virtual void loadData(int, TInputStreamInterface &) {} |
| |
| void updateVersionNumber(); |
| |
| protected: |
| TColorStyle &operator=(const TColorStyle &other); |
| }; |
| |
| |
| |
| #ifdef WIN32 |
| template class DVAPI TSmartPointerT<TColorStyle>; |
| #endif |
| typedef TSmartPointerT<TColorStyle> TColorStyleP; |
| |
| #endif |
| |