| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
|
|
| #ifndef RS_PEN_H |
| #define RS_PEN_H |
|
|
| #include "rs.h" |
| #include "rs_color.h" |
| #include "rs_flags.h" |
|
|
|
|
| |
| |
| |
| |
| |
| |
| class RS_Pen : public RS_Flags { |
| public: |
| |
| |
| |
| RS_Pen(); |
|
|
| |
| |
| |
| RS_Pen(const RS_Color& color, |
| RS2::LineWidth width, |
| RS2::LineType type){ |
| setColor(color); |
| setWidth(width); |
| setLineType(type); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| RS_Pen(unsigned int f) : RS_Flags(f) { |
| } |
| |
| |
| |
| |
| |
|
|
| RS2::LineType getLineType() const { |
| return lineType; |
| } |
| void setLineType(RS2::LineType t) { |
| lineType = t; |
| } |
| RS2::LineWidth getWidth() const { |
| return width; |
| } |
| void setWidth(RS2::LineWidth w) { |
| width = w; |
| } |
| double getScreenWidth() const { |
| return screenWidth; |
| } |
| void setScreenWidth(double w) { |
| screenWidth = w; |
| } |
|
|
| RS_Color getColor() const { |
| return color; |
| } |
|
|
| void setColor(const RS_Color& c) { |
| color = c; |
| } |
|
|
| inline void setColorFromPen(const RS_Pen& pen){ |
| color = pen.color; |
| } |
|
|
| inline void setWidthFromPen(const RS_Pen& pen){ |
| width = pen.width; |
| } |
|
|
| inline void setLineTypeFromPen(const RS_Pen& pen){ |
| lineType = pen.lineType; |
| } |
|
|
| inline bool isColorByLayer() const { |
| return color.getFlag(RS2::FlagByLayer); |
| } |
|
|
| inline bool isColorByBlock() const { |
| return color.getFlag(RS2::FlagByBlock); |
| } |
|
|
| inline bool isWidthByLayer() const { |
| return width == RS2::WidthByLayer; |
| } |
|
|
| inline bool isWidthByBlock() const { |
| return width == RS2::WidthByBlock; |
| } |
|
|
| inline bool isLineTypeByLayer() const { |
| return lineType == RS2::LineByLayer; |
| } |
|
|
| inline bool isLineTypeByBlock() const { |
| return lineType == RS2::LineByBlock; |
| } |
|
|
| bool hasByLayerAttributes() const { |
| return color.getFlag(RS2::FlagByLayer) || width == RS2::WidthByLayer || lineType == RS2::LineByLayer; |
| } |
|
|
| bool isValid() const { |
| return !getFlag(RS2::FlagInvalid); |
| } |
|
|
| float getAlpha() const { |
| return alpha; |
| } |
| void setAlpha(float a) { |
| alpha = a; |
| } |
|
|
| |
| |
| |
| |
| |
|
|
| |
| |
|
|
| bool operator == (const RS_Pen& p) const { |
| return (lineType==p.lineType && width==p.width && color==p.color); |
| } |
|
|
| bool isSameAs(const RS_Pen &p, const double &patternOffset) const{ |
| return (lineType==p.lineType && width==p.width && color==p.color && alpha == p.alpha && m_dashOffset == patternOffset && !getFlag(RS2::FlagInvalid)); |
| } |
|
|
| void updateBy(const RS_Pen & p){ |
| color = p.color; |
| lineType = p.lineType; |
| width = p.width; |
| alpha = p.alpha; |
| m_dashOffset = p.m_dashOffset; |
| setFlags(p.getFlags()); |
| delFlag(RS2::FlagInvalid); |
| } |
|
|
| bool operator != (const RS_Pen& p) const { |
| return !(*this==p); |
| } |
|
|
| |
| void setDashOffset(double offset){ |
| m_dashOffset = offset; |
| } |
|
|
| double dashOffset() const |
| { |
| return m_dashOffset; |
| } |
|
|
| friend std::ostream& operator << (std::ostream& os, const RS_Pen& p); |
|
|
|
|
| private: |
| RS2::LineType lineType = RS2::SolidLine; |
| RS2::LineWidth width = RS2::Width00; |
| double screenWidth = 0.; |
| RS_Color color{}; |
| float alpha = 1.; |
| double m_dashOffset = 0.; |
| }; |
|
|
| #endif |
|
|