1 /****************************************************************************
2 ** $Id: rs_layer.cpp 1938 2004-12-09 23:09:53Z 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 **********************************************************************/
36 RS_Layer::RS_Layer(const QString & name)
40 data.pen.setLineType(RS2::SolidLine);
41 data.pen.setWidth(RS2::Width00);
42 data.pen.setColor(Qt::black);
47 RS_Layer * RS_Layer::clone()
49 return new RS_Layer(*this);
52 /** sets a new name for this layer. */
53 void RS_Layer::setName(const QString & name)
58 /** @return the name of this layer. */
59 QString RS_Layer::getName() const
64 /** sets the default pen for this layer. */
65 void RS_Layer::setPen(const RS_Pen & pen)
70 /** @return default pen for this layer. */
71 RS_Pen RS_Layer::getPen() const
77 * @retval true if this layer is frozen (invisible)
78 * @retval false if this layer isn't frozen (visible)
80 bool RS_Layer::isFrozen() const
83 //getFlag(RS2::FlagFrozen);
87 * @retval true the layer has been converted already
88 * @retval false the layer still needs to be converted
90 bool RS_Layer::isConverted() const
92 return data.converted;
96 * Sets the converted flag
98 void RS_Layer::setConverted(bool c)
104 * Toggles the visibility of this layer.
105 * Freezes the layer if it's not frozen, thaws the layer otherwise
107 void RS_Layer::toggle()
109 //toggleFlag(RS2::FlagFrozen);
110 data.frozen = !data.frozen;
114 * (De-)freezes this layer.
116 * @param freeze true: freeze, false: defreeze
118 void RS_Layer::freeze(bool freeze)
120 data.frozen = freeze;
122 setFlag(RS2::FlagFrozen);
124 delFlag(RS2::FlagFrozen);
129 * Toggles the lock of this layer.
131 void RS_Layer::toggleLock()
133 //toggleFlag(RS2::FlagFrozen);
134 data.locked = !data.locked;
138 * Locks/Unlocks this layer.
140 * @param l true: lock, false: unlock
142 void RS_Layer::lock(bool l)
148 * return the LOCK state of the Layer
150 bool RS_Layer::isLocked()
156 * Copies all attributes (pen) and the name of the layer.
159 RS_Layer & RS_Layer::operator=(const RS_Layer & l)
161 setName(l.getName());
163 setFrozen(l.isFrozen());
169 * Dumps the layers data to stdout.
171 std::ostream & operator<<(std::ostream & os, const RS_Layer & l)
173 os << " name: " << l.getName().toLatin1().data()
174 << " pen: " << l.getPen()
175 << " frozen: " << (int)l.isFrozen()
176 << " address: " << (int)(&l)