3 // Part of the Architektonas Project
4 // Originally part of QCad Community Edition by Andrew Mustun
5 // Extensively rewritten and refactored by James L. Hammons
6 // Portions copyright (C) 2001-2003 RibbonSoft
7 // Copyright (C) 2010 Underground Software
8 // See the README and GPLv2 files for licensing and warranty information
10 // JLH = James L. Hammons <jlhamm@acm.org>
13 // --- ---------- -----------------------------------------------------------
14 // JLH 05/05/2010 Moved implementation from header to this file. :-)
21 RS_Color::RS_Color(): QColor(), RS_Flags()
25 RS_Color::RS_Color(int r, int g, int b): QColor(r, g, b), RS_Flags()
29 RS_Color::RS_Color(const QColor & c): QColor(c), RS_Flags()
33 RS_Color::RS_Color(const RS_Color & c): QColor(c), RS_Flags()
35 setFlags(c.getFlags());
38 RS_Color::RS_Color(unsigned int f): QColor(), RS_Flags(f)
42 /** @return A copy of this color without flags. */
43 RS_Color RS_Color::stripFlags() const
45 return RS_Color(red(), green(), blue());
48 /** @return true if the color is defined by layer. */
49 bool RS_Color::isByLayer() const
51 return getFlag(RS2::FlagByLayer);
54 /** @return true if the color is defined by block. */
55 bool RS_Color::isByBlock() const
57 return getFlag(RS2::FlagByBlock);
60 RS_Color & RS_Color::operator=(const RS_Color & c)
62 setRgb(c.red(), c.green(), c.blue());
63 setFlags(c.getFlags());
68 bool RS_Color::operator==(const RS_Color & c) const
70 return (red() == c.red() && green() == c.green() && blue() == c.blue()
71 && getFlags() == c.getFlags());
75 bool RS_Color::operator==(const QColor & c) const
77 return (red() == c.red() && green() == c.green() && blue() == c.blue());
81 /*friend*/ std::ostream & operator<<(std::ostream & os, const RS_Color & c)
83 os << " color: " << c.name().toLatin1().data()
84 << " flags: " << (c.getFlag(RS2::FlagByLayer) ? "RS2::FlagByLayer " : "")
85 << (c.getFlag(RS2::FlagByBlock) ? "RS2::FlagByBlock " : "");