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. :-)
27 * @param fileName File name of a DXF file defining the pattern
29 Pattern::Pattern(const QString & file): EntityContainer(NULL),
30 filename(file), loaded(false)
32 DEBUG->print("Pattern::Pattern() ");
40 * Loads the given pattern file into this pattern.
41 * Entities other than lines are ignored.
43 * @param filename File name of the pattern file (without path and
44 * extension or full path.
46 bool Pattern::loadPattern()
51 DEBUG->print("Pattern::loadPattern");
54 // Search for the appropriate pattern if we have only the name of the pattern:
55 if (!filename.toLower().contains(".dxf"))
57 QStringList patterns = SYSTEM->getPatternList();
60 for(QStringList::Iterator it=patterns.begin(); it!=patterns.end(); it++)
62 if (QFileInfo(*it).baseName().toLower() == filename.toLower())
65 DEBUG->print("Pattern found: %s", path.toAscii().data());
70 // We have the full path of the pattern:
76 // No pattern paths found:
79 DEBUG->print("No pattern \"%s\"available.", filename.toAscii().data());
83 Drawing * drawing = new Drawing();
85 // TODO: Find out why the new dxf filter doesn't work for patterns:
86 FILEIO->fileImport(*drawing, path, RS2::FormatDXF1);
88 for(Entity * e=drawing->firstEntity(); e!=NULL; e=drawing->nextEntity())
90 if (e->rtti() == RS2::EntityLine || e->rtti() == RS2::EntityArc)
92 Entity * clone = e->clone();
93 clone->reparent(this);
94 Layer * layer = e->getLayer();
97 clone->setLayer(layer->getName());
105 DEBUG->print("Pattern::loadPattern: OK");
110 /** @return the fileName of this pattern. */
111 QString Pattern::getFileName() const