1 /****************************************************************************
2 ** $Id: rs_pen.h 1760 2003-10-13 19:52:37Z andrew $
4 ** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
6 ** This file is part of the qcadlib Library project.
8 ** This file may be distributed and/or modified under the terms of the
9 ** GNU General Public License version 2 as published by the Free Software
10 ** Foundation and appearing in the file LICENSE.GPL included in the
11 ** packaging of this file.
13 ** Licensees holding valid qcadlib Professional Edition licenses may use
14 ** this file in accordance with the qcadlib Commercial License
15 ** Agreement provided with the Software.
17 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
18 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 ** See http://www.ribbonsoft.com for further details.
22 ** Contact info@ribbonsoft.com if any conditions of this licensing are
25 **********************************************************************/
35 * A pen stores attributes for painting such as line width,
36 * linetype, color, ...
38 * @author Andrew Mustun
40 class RS_Pen: public RS_Flags
44 * Creates a default pen (black, solid, width 0).
46 RS_Pen() : RS_Flags() {
47 setColor(RS_Color(0,0,0));
48 setWidth(RS2::Width00);
49 setLineType(RS2::SolidLine);
53 * Creates a pen with the given attributes.
55 RS_Pen(const RS_Color& c,
57 RS2::LineType t) : RS_Flags() {
64 * Creates a default pen with the given flags. This is
65 * usually used to create invalid pens.
69 * RS_Pen p(RS2::FlagInvalid);
72 RS_Pen(unsigned int f) : RS_Flags(f) {
73 setColor(RS_Color(0,0,0));
74 setWidth(RS2::Width00);
75 setLineType(RS2::SolidLine);
78 //RS_Pen(const RS_Pen& pen) : RS_Flags(pen.getFlags()) {
79 // lineType = pen.lineType;
85 RS2::LineType getLineType() const {
88 void setLineType(RS2::LineType t) {
91 RS2::LineWidth getWidth() const {
94 void setWidth(RS2::LineWidth w) {
97 double getScreenWidth() const {
100 void setScreenWidth(double w) {
103 const RS_Color& getColor() const {
106 void setColor(const RS_Color& c) {
110 return !getFlag(RS2::FlagInvalid);
113 //RS_Pen& operator = (const RS_Pen& p) {
114 // lineType = p.lineType;
117 // setFlags(p.getFlags());
122 bool operator == (const RS_Pen& p) const {
123 return (lineType==p.lineType && width==p.width && color==p.color);
126 bool operator != (const RS_Pen& p) const {
130 friend std::ostream& operator << (std::ostream& os, const RS_Pen& p) {
131 //os << "style: " << p.style << std::endl;
132 os << " pen color: " << p.getColor()
133 << " pen width: " << p.getWidth()
134 << " pen screen width: " << p.getScreenWidth()
135 << " pen line type: " << p.getLineType()
136 << " flags: " << (p.getFlag(RS2::FlagInvalid) ? "INVALID" : "")
142 RS2::LineType lineType;
143 RS2::LineWidth width;