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 05/21/2010 Added this text. :-)
23 * @param parent The graphic this block belongs to.
24 * @param name The name of the block used as an identifier.
25 * @param basePoint Base point (offset) of the block.
27 Block::Block(EntityContainer * parent, const BlockData & d):
28 Document(parent), data(d)
30 pen = Pen(Color(128, 128, 128), RS2::Width01, RS2::SolidLine);
37 Entity * Block::clone()
39 Block * blk = new Block(*this);
40 #warning "!!! Need to port setAutoDelete() behaviour from Qt3 to Qt4 !!!"
41 // blk->entities.setAutoDelete(entities.autoDelete());
47 LayerList * Block::getLayerList()
49 Drawing * g = getGraphic();
52 return g->getLayerList();
57 BlockList * Block::getBlockList()
59 Drawing * g = getGraphic();
62 return g->getBlockList();
69 Drawing * g = getGraphic();
77 bool Block::saveAs(const QString & filename, RS2::FormatType type)
79 Drawing * g = getGraphic();
82 return g->saveAs(filename, type);
88 * Sets the parent documents modified status to 'm'.
90 void Block::setModified(bool m)
92 Drawing * p = getGraphic();
100 /** @return RS2::EntityBlock */
101 /*virtual*/ RS2::EntityType Block::rtti() const
103 return RS2::EntityBlock;
107 * @return Name of this block (the name is an Id for this block).
109 QString Block::getName() const
115 * @return base point of this block.
117 Vector Block::getBasePoint() const
119 return data.basePoint;
123 * Reimplementation from Document. Does nothing.
125 /*virtual*/ void Block::newDoc()
131 * Reimplementation from Document. Does nothing.
133 /*virtual*/ bool Block::open(const QString &, RS2::FormatType)
139 /*friend*/ std::ostream & operator<<(std::ostream & os, const Block & b)
141 os << " name: " << b.getName().toLatin1().data() << std::endl;
142 os << " entities: " << (EntityContainer &)b << std::endl;
147 * sets a new name for the block. Only called by blocklist to
148 * assure that block names stay unique.
150 void Block::setName(const QString & n)
156 * @retval true if this block is frozen (invisible)
157 * @retval false if this block isn't frozen (visible)
159 bool Block::isFrozen() const
165 * Toggles the visibility of this block.
166 * Freezes the block if it's not frozen, thaws the block otherwise
170 data.frozen = !data.frozen;
174 * (De-)freezes this block.
176 * @param freeze true: freeze, false: defreeze
178 void Block::freeze(bool freeze)
180 data.frozen = freeze;