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 // (C) 2010 Underground Software
8 // JLH = James L. Hammons <jlhamm@acm.org>
11 // --- ---------- -----------------------------------------------------------
12 // JLH 05/21/2010 Added this text. :-)
21 * @param parent The graphic this block belongs to.
22 * @param name The name of the block used as an identifier.
23 * @param basePoint Base point (offset) of the block.
25 RS_Block::RS_Block(RS_EntityContainer * parent, const RS_BlockData & d):
26 RS_Document(parent), data(d)
28 pen = RS_Pen(RS_Color(128, 128, 128), RS2::Width01, RS2::SolidLine);
35 RS_Entity * RS_Block::clone()
37 RS_Block * blk = new RS_Block(*this);
38 #warning "!!! Need to port setAutoDelete() behaviour from Qt3 to Qt4 !!!"
39 // blk->entities.setAutoDelete(entities.autoDelete());
45 RS_LayerList * RS_Block::getLayerList()
47 Drawing * g = getGraphic();
50 return g->getLayerList();
55 RS_BlockList * RS_Block::getBlockList()
57 Drawing * g = getGraphic();
60 return g->getBlockList();
67 Drawing * g = getGraphic();
75 bool RS_Block::saveAs(const QString & filename, RS2::FormatType type)
77 Drawing * g = getGraphic();
80 return g->saveAs(filename, type);
86 * Sets the parent documents modified status to 'm'.
88 void RS_Block::setModified(bool m)
90 Drawing * p = getGraphic();
98 /** @return RS2::EntityBlock */
99 /*virtual*/ RS2::EntityType RS_Block::rtti() const
101 return RS2::EntityBlock;
105 * @return Name of this block (the name is an Id for this block).
107 QString RS_Block::getName() const
113 * @return base point of this block.
115 Vector RS_Block::getBasePoint() const
117 return data.basePoint;
121 * Reimplementation from RS_Document. Does nothing.
123 /*virtual*/ void RS_Block::newDoc()
129 * Reimplementation from RS_Document. Does nothing.
131 /*virtual*/ bool RS_Block::open(const QString &, RS2::FormatType)
137 /*friend*/ std::ostream & operator<<(std::ostream & os, const RS_Block & b)
139 os << " name: " << b.getName().toLatin1().data() << std::endl;
140 os << " entities: " << (RS_EntityContainer &)b << std::endl;
145 * sets a new name for the block. Only called by blocklist to
146 * assure that block names stay unique.
148 void RS_Block::setName(const QString & n)
154 * @retval true if this block is frozen (invisible)
155 * @retval false if this block isn't frozen (visible)
157 bool RS_Block::isFrozen() const
163 * Toggles the visibility of this block.
164 * Freezes the block if it's not frozen, thaws the block otherwise
166 void RS_Block::toggle()
168 data.frozen = !data.frozen;
172 * (De-)freezes this block.
174 * @param freeze true: freeze, false: defreeze
176 void RS_Block::freeze(bool freeze)
178 data.frozen = freeze;