*
* @param fileName File name of a DXF file defining the pattern
*/
-RS_Pattern::RS_Pattern(const QString & fileName): RS_EntityContainer(NULL)
+Pattern::Pattern(const QString & file): EntityContainer(NULL),
+ filename(file), loaded(false)
{
- RS_DEBUG->print("RS_Pattern::RS_Pattern() ");
-
- this->fileName = fileName;
- loaded = false;
+ DEBUG->print("Pattern::Pattern() ");
}
-/**
- * Constructor.
- *
- * @param fileName File name of a PAT file which defines this
- * pattern among others.
- * @param name Pattern name.
- *
- */
-/*RS_Pattern::RS_Pattern(const QString& fileName, const QString& name)
- : RS_EntityContainer(NULL) {
- this->fileName = fileName;
- this->name = name;
- loaded = false;
-}*/
-
-RS_Pattern::~RS_Pattern()
+Pattern::~Pattern()
{
}
* @param filename File name of the pattern file (without path and
* extension or full path.
*/
-bool RS_Pattern::loadPattern()
+bool Pattern::loadPattern()
{
if (loaded)
return true;
- RS_DEBUG->print("RS_Pattern::loadPattern");
-
+ 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 = RS_SYSTEM->getPatternList();
+ 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;
- RS_DEBUG->print("Pattern found: %s", path.toLatin1().data());
+ DEBUG->print("Pattern found: %s", path.toAscii().data());
break;
}
}
// We have the full path of the pattern:
else
{
- path = fileName;
+ path = filename;
}
// No pattern paths found:
if (path.isEmpty())
{
- RS_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:
- RS_FILEIO->fileImport(*gr, path, RS2::FormatDXF1);
+ FILEIO->fileImport(*drawing, path, RS2::FormatDXF1);
- for(RS_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)
{
- RS_Layer * l = e->getLayer();
- RS_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;
- RS_DEBUG->print("RS_Pattern::loadPattern: OK");
+ DEBUG->print("Pattern::loadPattern: OK");
return true;
}
/** @return the fileName of this pattern. */
-QString RS_Pattern::getFileName() const
+QString Pattern::getFileName() const
{
- return fileName;
+ return filename;
}