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 RS_Pattern::RS_Pattern(const QString & fileName): RS_EntityContainer(NULL)
31 RS_DEBUG->print("RS_Pattern::RS_Pattern() ");
33 this->fileName = fileName;
40 * @param fileName File name of a PAT file which defines this
41 * pattern among others.
42 * @param name Pattern name.
45 /*RS_Pattern::RS_Pattern(const QString& fileName, const QString& name)
46 : RS_EntityContainer(NULL) {
47 this->fileName = fileName;
52 RS_Pattern::~RS_Pattern()
57 * Loads the given pattern file into this pattern.
58 * Entities other than lines are ignored.
60 * @param filename File name of the pattern file (without path and
61 * extension or full path.
63 bool RS_Pattern::loadPattern()
68 RS_DEBUG->print("RS_Pattern::loadPattern");
72 // Search for the appropriate pattern if we have only the name of the pattern:
73 if (!fileName.toLower().contains(".dxf"))
75 QStringList patterns = RS_SYSTEM->getPatternList();
78 for(QStringList::Iterator it=patterns.begin(); it!=patterns.end(); it++)
80 if (QFileInfo(*it).baseName().toLower() == fileName.toLower())
83 RS_DEBUG->print("Pattern found: %s", path.toLatin1().data());
88 // We have the full path of the pattern:
94 // No pattern paths found:
97 RS_DEBUG->print("No pattern \"%s\"available.", fileName.toLatin1().data());
101 Drawing * gr = new Drawing();
103 // TODO: Find out why the new dxf filter doesn't work for patterns:
104 RS_FILEIO->fileImport(*gr, path, RS2::FormatDXF1);
106 for(RS_Entity * e=gr->firstEntity(); e!=NULL; e=gr->nextEntity())
108 if (e->rtti() == RS2::EntityLine || e->rtti() == RS2::EntityArc)
110 RS_Layer * l = e->getLayer();
111 RS_Entity * cl = e->clone();
116 cl->setLayer(l->getName());
125 RS_DEBUG->print("RS_Pattern::loadPattern: OK");
130 /** @return the fileName of this pattern. */
131 QString RS_Pattern::getFileName() const