]> Shamusworld >> Repos - architektonas/blob - src/base/rs_color.cpp
6fd40963017afc3b804a7fda56e74052185bdb36
[architektonas] / src / base / rs_color.cpp
1 // rs_color.cpp
2 //
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
9 //
10 // JLH = James L. Hammons <jlhamm@acm.org>
11 //
12 // Who  When        What
13 // ---  ----------  -----------------------------------------------------------
14 // JLH  05/05/2010  Moved implementation from header to this file. :-)
15 //
16
17 #include "rs_color.h"
18
19 RS_Color::RS_Color(): QColor(), RS_Flags()
20 {
21 }
22
23 RS_Color::RS_Color(int r, int g, int b): QColor(r, g, b), RS_Flags()
24 {
25 }
26
27 RS_Color::RS_Color(const QColor & c): QColor(c), RS_Flags()
28 {
29 }
30
31 RS_Color::RS_Color(const RS_Color & c): QColor(c), RS_Flags()
32 {
33         setFlags(c.getFlags());
34 }
35
36 RS_Color::RS_Color(unsigned int f): QColor(), RS_Flags(f)
37 {
38 }
39
40 /** @return A copy of this color without flags. */
41 RS_Color RS_Color::stripFlags() const
42 {
43         return RS_Color(red(), green(), blue());
44 }
45
46 /** @return true if the color is defined by layer. */
47 bool RS_Color::isByLayer() const
48 {
49         return getFlag(RS2::FlagByLayer);
50 }
51
52 /** @return true if the color is defined by block. */
53 bool RS_Color::isByBlock() const
54 {
55         return getFlag(RS2::FlagByBlock);
56 }
57
58 RS_Color & RS_Color::operator=(const RS_Color & c)
59 {
60         setRgb(c.red(), c.green(), c.blue());
61         setFlags(c.getFlags());
62
63         return *this;
64 }
65
66 bool RS_Color::operator==(const RS_Color & c) const
67 {
68         return (red() == c.red() && green() == c.green() && blue() == c.blue()
69                 && getFlags() == c.getFlags());
70 }
71
72 #if 0
73 bool RS_Color::operator==(const QColor & c) const
74 {
75         return (red() == c.red() && green() == c.green() && blue() == c.blue());
76 }
77 #endif
78
79 /*friend*/ std::ostream & operator<<(std::ostream & os, const RS_Color & c)
80 {
81         os << " color: " << c.name().toLatin1().data()
82                 << " flags: " << (c.getFlag(RS2::FlagByLayer) ? "RS2::FlagByLayer " : "")
83                 << (c.getFlag(RS2::FlagByBlock) ? "RS2::FlagByBlock " : "");
84         return os;
85 }