]> Shamusworld >> Repos - architektonas/blob - src/base/color.cpp
Removed unnecessary RS_ prefix from classes and whatnot.
[architektonas] / src / base / color.cpp
1 // 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 "color.h"
18
19 #include "enums.h"
20
21 Color::Color(): QColor(), Flags()
22 {
23 }
24
25 Color::Color(int r, int g, int b): QColor(r, g, b), Flags()
26 {
27 }
28
29 Color::Color(const QColor & c): QColor(c), Flags()
30 {
31 }
32
33 Color::Color(const Color & c): QColor(c), Flags()
34 {
35         setFlags(c.getFlags());
36 }
37
38 Color::Color(unsigned int f): QColor(), Flags(f)
39 {
40 }
41
42 /** @return A copy of this color without flags. */
43 Color Color::stripFlags() const
44 {
45         return Color(red(), green(), blue());
46 }
47
48 /** @return true if the color is defined by layer. */
49 bool Color::isByLayer() const
50 {
51         return getFlag(RS2::FlagByLayer);
52 }
53
54 /** @return true if the color is defined by block. */
55 bool Color::isByBlock() const
56 {
57         return getFlag(RS2::FlagByBlock);
58 }
59
60 Color & Color::operator=(const Color & c)
61 {
62         setRgb(c.red(), c.green(), c.blue());
63         setFlags(c.getFlags());
64
65         return *this;
66 }
67
68 bool Color::operator==(const Color & c) const
69 {
70         return (red() == c.red() && green() == c.green() && blue() == c.blue()
71                 && getFlags() == c.getFlags());
72 }
73
74 #if 0
75 bool Color::operator==(const QColor & c) const
76 {
77         return (red() == c.red() && green() == c.green() && blue() == c.blue());
78 }
79 #endif
80
81 /*friend*/ std::ostream & operator<<(std::ostream & os, const Color & c)
82 {
83         os << " color: " << c.name().toLatin1().data()
84                 << " flags: " << (c.getFlag(RS2::FlagByLayer) ? "RS2::FlagByLayer " : "")
85                 << (c.getFlag(RS2::FlagByBlock) ? "RS2::FlagByBlock " : "");
86         return os;
87 }