]> Shamusworld >> Repos - architektonas/blobdiff - src/base/pattern.cpp
Fixed hatch dialog, added snap/preview to circle tools.
[architektonas] / src / base / pattern.cpp
index 26af65b4593b35a13a209940d2308f6d1f983ee5..b1f404623178ead5a330954d2f9e1e03eb822755 100644 (file)
  *
  * @param fileName File name of a DXF file defining the pattern
  */
-Pattern::Pattern(const QString & fileName): EntityContainer(NULL)
+Pattern::Pattern(const QString & file): EntityContainer(NULL),
+       filename(file), loaded(false)
 {
        DEBUG->print("Pattern::Pattern() ");
-
-       this->fileName = fileName;
-       loaded = false;
 }
 
-/**
- * Constructor.
- *
- * @param fileName File name of a PAT file which defines this
- *         pattern among others.
- * @param name Pattern name.
- *
- */
-/*Pattern::Pattern(const QString& fileName, const QString& name)
-        : EntityContainer(NULL) {
-       this->fileName = fileName;
-       this->name = name;
-       loaded = false;
-}*/
-
 Pattern::~Pattern()
 {
 }
@@ -66,21 +49,20 @@ bool Pattern::loadPattern()
                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"))
+       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())
+                       if (QFileInfo(*it).baseName().toLower() == filename.toLower())
                        {
                                path = *it;
-                               DEBUG->print("Pattern found: %s", path.toLatin1().data());
+                               DEBUG->print("Pattern found: %s", path.toAscii().data());
                                break;
                        }
                }
@@ -88,39 +70,37 @@ bool Pattern::loadPattern()
        // We have the full path of the pattern:
        else
        {
-               path = fileName;
+               path = filename;
        }
 
        // No pattern paths found:
        if (path.isEmpty())
        {
-               DEBUG->print("No pattern \"%s\"available.", fileName.toLatin1().data());
+               DEBUG->print("No pattern \"%s\"available.", filename.toAscii().data());
                return false;
        }
 
-       Drawing * gr = new Drawing();
+       Drawing * drawing = new Drawing();
 
        // TODO: Find out why the new dxf filter doesn't work for patterns:
-       FILEIO->fileImport(*gr, path, RS2::FormatDXF1);
+       FILEIO->fileImport(*drawing, path, RS2::FormatDXF1);
 
-       for(Entity * e=gr->firstEntity(); e!=NULL; e=gr->nextEntity())
+       for(Entity * e=drawing->firstEntity(); e!=NULL; e=drawing->nextEntity())
        {
                if (e->rtti() == RS2::EntityLine || e->rtti() == RS2::EntityArc)
                {
-                       Layer * l = e->getLayer();
-                       Entity * cl = e->clone();
-                       cl->reparent(this);
+                       Entity * clone = e->clone();
+                       clone->reparent(this);
+                       Layer * layer = e->getLayer();
 
-                       if (l != NULL)
-                       {
-                               cl->setLayer(l->getName());
-                       }
+                       if (layer)
+                               clone->setLayer(layer->getName());
 
-                       addEntity(cl);
+                       addEntity(clone);
                }
        }
 
-       delete gr;
+       delete drawing;
        loaded = true;
        DEBUG->print("Pattern::loadPattern: OK");
 
@@ -130,5 +110,5 @@ bool Pattern::loadPattern()
 /** @return the fileName of this pattern. */
 QString Pattern::getFileName() const
 {
-       return fileName;
+       return filename;
 }