X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fbase%2Fpattern.cpp;fp=src%2Fbase%2Fpattern.cpp;h=0000000000000000000000000000000000000000;hb=9f6ad3fe0b9cb30115a5d38e8af3aebed0d70c08;hp=b1f404623178ead5a330954d2f9e1e03eb822755;hpb=43c13b052d069ba435277d93867380d00c04931f;p=architektonas diff --git a/src/base/pattern.cpp b/src/base/pattern.cpp deleted file mode 100644 index b1f4046..0000000 --- a/src/base/pattern.cpp +++ /dev/null @@ -1,114 +0,0 @@ -// pattern.cpp -// -// Part of the Architektonas Project -// Originally part of QCad Community Edition by Andrew Mustun -// Extensively rewritten and refactored by James L. Hammons -// Portions copyright (C) 2001-2003 RibbonSoft -// Copyright (C) 2010 Underground Software -// See the README and GPLv2 files for licensing and warranty information -// -// JLH = James L. Hammons -// -// Who When What -// --- ---------- ----------------------------------------------------------- -// JLH 06/01/2010 Added this text. :-) -// - -#include "pattern.h" - -#include -#include "system.h" -#include "fileio.h" -#include "drawing.h" - -/** - * Constructor. - * - * @param fileName File name of a DXF file defining the pattern - */ -Pattern::Pattern(const QString & file): EntityContainer(NULL), - filename(file), loaded(false) -{ - DEBUG->print("Pattern::Pattern() "); -} - -Pattern::~Pattern() -{ -} - -/** - * Loads the given pattern file into this pattern. - * Entities other than lines are ignored. - * - * @param filename File name of the pattern file (without path and - * extension or full path. - */ -bool Pattern::loadPattern() -{ - if (loaded) - return true; - - DEBUG->print("Pattern::loadPattern"); - QString path; - - // Search for the appropriate pattern if we have only the name of the pattern: - if (!filename.toLower().contains(".dxf")) - { - QStringList patterns = SYSTEM->getPatternList(); - QFileInfo file; - - for(QStringList::Iterator it=patterns.begin(); it!=patterns.end(); it++) - { - if (QFileInfo(*it).baseName().toLower() == filename.toLower()) - { - path = *it; - DEBUG->print("Pattern found: %s", path.toAscii().data()); - break; - } - } - } - // We have the full path of the pattern: - else - { - path = filename; - } - - // No pattern paths found: - if (path.isEmpty()) - { - DEBUG->print("No pattern \"%s\"available.", filename.toAscii().data()); - return false; - } - - Drawing * drawing = new Drawing(); - - // TODO: Find out why the new dxf filter doesn't work for patterns: - FILEIO->fileImport(*drawing, path, RS2::FormatDXF1); - - for(Entity * e=drawing->firstEntity(); e!=NULL; e=drawing->nextEntity()) - { - if (e->rtti() == RS2::EntityLine || e->rtti() == RS2::EntityArc) - { - Entity * clone = e->clone(); - clone->reparent(this); - Layer * layer = e->getLayer(); - - if (layer) - clone->setLayer(layer->getName()); - - addEntity(clone); - } - } - - delete drawing; - loaded = true; - DEBUG->print("Pattern::loadPattern: OK"); - - return true; -} - -/** @return the fileName of this pattern. */ -QString Pattern::getFileName() const -{ - return filename; -}