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 06/01/2010 Added this text. :-)
20 #include "mathextra.h"
25 Layer::Layer(const QString & name)
29 data.pen.setLineType(RS2::SolidLine);
30 data.pen.setWidth(RS2::Width00);
31 data.pen.setColor(Qt::black);
36 Layer * Layer::clone()
38 return new Layer(*this);
41 /** sets a new name for this layer. */
42 void Layer::setName(const QString & name)
47 /** @return the name of this layer. */
48 QString Layer::getName() const
53 /** sets the default pen for this layer. */
54 void Layer::setPen(const Pen & pen)
59 /** @return default pen for this layer. */
60 Pen Layer::getPen() const
66 * @retval true if this layer is frozen (invisible)
67 * @retval false if this layer isn't frozen (visible)
69 bool Layer::isFrozen() const
72 //getFlag(RS2::FlagFrozen);
76 * @retval true the layer has been converted already
77 * @retval false the layer still needs to be converted
79 bool Layer::isConverted() const
81 return data.converted;
85 * Sets the converted flag
87 void Layer::setConverted(bool c)
93 * Toggles the visibility of this layer.
94 * Freezes the layer if it's not frozen, thaws the layer otherwise
98 //toggleFlag(RS2::FlagFrozen);
99 data.frozen = !data.frozen;
103 * (De-)freezes this layer.
105 * @param freeze true: freeze, false: defreeze
107 void Layer::freeze(bool freeze)
109 data.frozen = freeze;
111 setFlag(RS2::FlagFrozen);
113 delFlag(RS2::FlagFrozen);
118 * Toggles the lock of this layer.
120 void Layer::toggleLock()
122 //toggleFlag(RS2::FlagFrozen);
123 data.locked = !data.locked;
127 * Locks/Unlocks this layer.
129 * @param l true: lock, false: unlock
131 void Layer::lock(bool l)
137 * return the LOCK state of the Layer
139 bool Layer::isLocked()
145 * Copies all attributes (pen) and the name of the layer.
148 Layer & Layer::operator=(const Layer & l)
150 setName(l.getName());
152 setFrozen(l.isFrozen());
158 * Dumps the layers data to stdout.
160 std::ostream & operator<<(std::ostream & os, const Layer & l)
162 os << " name: " << l.getName().toLatin1().data()
163 << " pen: " << l.getPen()
164 << " frozen: " << (int)l.isFrozen()
165 << " address: " << (int)(&l)