Seamly2D
Code documentation
pen.h
Go to the documentation of this file.
1 /******************************************************************************
2  * @file pen.h
3  ** @author DS Caskey
4  ** @date Jan 14, 2023
5  **
6  ** @brief
7  ** @copyright
8  ** This source code is part of the Seamly2D project, a pattern making
9  ** program, whose allow create and modeling patterns of clothing.
10  ** Copyright (C) 2017-2023 Seamly2D project
11  ** <https://github.com/fashionfreedom/seamly2d> All Rights Reserved.
12  **
13  ** Seamly2D is free software: you can redistribute it and/or modify
14  ** it under the terms of the GNU General Public License as published by
15  ** the Free Software Foundation, either version 3 of the License, or
16  ** (at your option) any later version.
17  **
18  ** Seamly2D is distributed in the hope that it will be useful,
19  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
20  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  ** GNU General Public License for more details.
22  **
23  ** You should have received a copy of the GNU General Public License
24  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
25  **
26  *************************************************************************/
27 
28 
29 #ifndef PEN_H
30 #define PEN_H
31 
32 /**
33  * A pen stores attributes for painting such as line weight,
34  * linetype, color, ...
35  */
36 class Pen
37 {
38 public:
39 /**
40 * Creates a default pen (black, solid, weight 0).
41 */
42 
43 Pen ()
44 {
45  setColor(QString("black"));
46  setLineWeight(0.00);
47  setLineType(QString("solidLine"));
48 }
49 
50 /**
51 * Creates a pen with the given attributes.
52 */
53 Pen (const QString& color, const qreal &weight, const QString &type)
54 {
55  setColor(color);
56  setLineWeight(weight);
57  setLineType(type);
58 }
59 
60 virtual ~Pen () {}
61 
62 QString getLineType() const
63 {
64  return m_lineType;
65 }
66 
67 void setLineType(const QString &type)
68 {
69  m_lineType = type;
70 }
71 
72 qreal getLineWeight() const
73 {
74  return m_lineWeight;
75 }
76 
77 void setLineWeight(const qreal &weight)
78 {
79  m_lineWeight = weight;
80 }
81 
82 QString getColor() const
83 {
84  return m_color;
85 }
86 
87 void setColor(const QString &color)
88 {
89  m_color = color;
90 }
91 
92 bool operator == (const Pen &pen) const
93 {
94  return (m_lineType==pen.m_lineType && m_lineWeight==pen.m_lineWeight && m_color==pen.m_color);
95 }
96 
97 bool operator != (const Pen &pen) const
98 {
99  return !(*this==pen);
100 }
101 
102 friend std::ostream &operator << (std::ostream &stream, const Pen &pen);
103 
104 protected:
105  QString m_color;
107  QString m_lineType;
108 };
109 
110 #endif
Definition: pen.h:37
QString color
Definition: pen_toolbar.h:51
Pen(const QString &color, const qreal &weight, const QString &type)
Definition: pen.h:53
Pen()
Definition: pen.h:43
qreal m_lineWeight
Definition: pen.h:106
bool operator==(const Pen &pen) const
Definition: pen.h:92
QString m_color
Definition: pen.h:105
void setColor(const QString &color)
Definition: pen.h:87
void setLineType(const QString &type)
Definition: pen.h:67
QString m_lineType
Definition: pen.h:107
friend std::ostream & operator<<(std::ostream &stream, const Pen &pen)
Definition: pen.cpp:31
virtual ~Pen()
Definition: pen.h:60
QString getLineType() const
Definition: pen.h:62
QString getColor() const
Definition: pen.h:82
bool operator!=(const Pen &pen) const
Definition: pen.h:97
void setLineWeight(const qreal &weight)
Definition: pen.h:77
qreal getLineWeight() const
Definition: pen.h:72