| #pragma once |
| |
| #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 {}; |
| |
| struct PickedPosition { |
| TPoint pos = TPoint(); |
| int frame = 0; |
| PickedPosition(TPoint _pos = TPoint(), int _frame = 0) |
| : pos(_pos), frame(_frame) {} |
| inline bool operator==(const PickedPosition &p) const { |
| return (this->pos == p.pos) && (this->frame == p.frame); |
| } |
| inline bool operator!=(const PickedPosition &p) const { |
| return (this->pos != p.pos) || (this->frame != p.frame); |
| } |
| }; |
| |
| 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; |
| |
| |
| PickedPosition |
| m_pickedPosition; |
| |
| |
| 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(std::wstring name) { |
| m_name = name; |
| } |
| std::wstring getName() const { |
| return m_name; |
| } |
| |
| |
| |
| |
| void setGlobalName(std::wstring name) { |
| m_globalName = name; |
| } |
| std::wstring getGlobalName() const { |
| return m_globalName; |
| } |
| |
| void setOriginalName(std::wstring name) { |
| m_originalName = name; |
| } |
| std::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; |
| } |
| |
| void setPickedPosition(const TPoint &pos, const int index = 0) { |
| m_pickedPosition.pos = pos; |
| m_pickedPosition.frame = index; |
| } |
| void setPickedPosition(const PickedPosition &pos) { m_pickedPosition = pos; } |
| PickedPosition getPickedPosition() const { return m_pickedPosition; } |
| |
| |
| |
| |
| |
| |
| 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 bool hasParamDefault(int index) const { |
| return false; |
| } |
| |
| virtual void setParamDefault(int index) { |
| assert(false); |
| } |
| |
| virtual bool isParamDefault(int index) const { |
| return false; |
| } |
| |
| 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(std::vector<int> &) const {}; |
| |
| void save(TOutputStreamInterface &) const; |
| |
| |
| |
| static TColorStyle *load(TInputStreamInterface &); |
| |
| |
| |
| |
| static TColorStyle *create( |
| int tagId); |
| |
| static void declare( |
| TColorStyle *style); |
| static void getAllTags(std::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 |