|
From: <dhu...@us...> - 2007-01-06 15:21:41
|
Revision: 106
http://svn.sourceforge.net/qcell/?rev=106&view=rev
Author: dhubleizh
Date: 2007-01-06 07:21:38 -0800 (Sat, 06 Jan 2007)
Log Message:
-----------
- preliminary debugged and checked N in parsing
- uncommented some test things in MainWindow
- bugs during parsing in MainWindow
Modified Paths:
--------------
trunk/qcell/parsers/N/NParserPlugin.cpp
trunk/qcell/visgui/MainWindow.cpp
Modified: trunk/qcell/parsers/N/NParserPlugin.cpp
===================================================================
--- trunk/qcell/parsers/N/NParserPlugin.cpp 2007-01-06 13:39:10 UTC (rev 105)
+++ trunk/qcell/parsers/N/NParserPlugin.cpp 2007-01-06 15:21:38 UTC (rev 106)
@@ -35,6 +35,8 @@
// Basic sanity check
result = QString(content).split('\n');
+ // Trim empty last line
+ result.removeLast();
if(result.count() < 4)
{
qDebug(tr("The input file is to short!").toAscii());
@@ -64,14 +66,14 @@
format = QRegExp("^([0-9a-Z] ){" + QString::number(dimensions) + "}[0-9a-Z]$");
if(format.exactMatch(result[0]))
{
- neighbours_nr = result[0][result.count()].toAscii() - '0';
- columns = result[0][0].toAscii() - '0';
+ neighbours_nr = result[0][result[0].count()-1].toAscii() - '0';
+ lines = (int)result[0][0].toAscii() - '0';
- if(result.count() > 3 )
+ if(result[0].count() > 3 )
{
- lines = result[0][2].toAscii() - '0';
+ columns = result[0][2].toAscii() - '0';
- if(result.count() == 7)
+ if(result[0].count() == 7)
{
walls = result[0][4].toAscii() - '0';
}
@@ -101,7 +103,7 @@
// Zero point coordinates
result[0] = result[0].trimmed();
- format.setPattern("^(([0-9a-Z] ){" + QString::number(dimensions-1) + "}[0-9a-Z]$");
+ format.setPattern("^([0-9a-Z] ){" + QString::number(dimensions-1) + "}[0-9a-Z]$");
if(format.exactMatch(result[0]))
{
pos0_x = result[0][0].toAscii() - '0';
@@ -135,10 +137,12 @@
.arg(format.pattern())
.toAscii()
);
+
+ return QString();
}
// Further sanity check
- if(result.count() != lines * walls)
+ if(result.count() != (lines * walls))
{
qDebug(tr("The number of lines in file doesn't correspond to declared dimensions sizes.").toAscii());
return QString();
@@ -148,6 +152,7 @@
result[0] = result[0].trimmed();
format.setPattern("^([\\-1-9a-Z]){" + QString::number(columns) + "}$");
int tmp_neighbour;
+ QVector<int> coordinates(3,0);
foreach(QString line, result)
{
x = 0;
@@ -165,18 +170,18 @@
// Adding to a map is so much cool, as we can get the values sorted
// instatly
- foreach(QChar sign, result.first())
+ foreach(QChar sign, line)
{
if(sign.toAscii() != '-')
{
- QVector<int> coordinates(x);
+ coordinates[0] = x - pos0_x;
if(dimensions > 1)
{
- coordinates.append(y);
+ coordinates[1] = y - pos0_y;
if(dimensions == 3)
{
- coordinates.append(z);
+ coordinates[2] = z - pos0_z;
}
}
@@ -193,10 +198,10 @@
return QString();
}
- neighbours[sign.toAscii()-'0'] = coordinates;
+ neighbours[tmp_neighbour] = coordinates;
// Sanity check - number of neighbours exceeding declared one
- if(neighbours_nr > neighbours.count())
+ if(neighbours.count() > neighbours_nr)
{
qDebug(tr("In line %1 the number of neighbours (%2) exceeded the one declared in the header (%3).")
.arg(line_nr)
@@ -254,6 +259,7 @@
N.addNeighbour(difs);
}
+ qDebug(N.toXmlString().toAscii());
return N.toXmlString();
}
Modified: trunk/qcell/visgui/MainWindow.cpp
===================================================================
--- trunk/qcell/visgui/MainWindow.cpp 2007-01-06 13:39:10 UTC (rev 105)
+++ trunk/qcell/visgui/MainWindow.cpp 2007-01-06 15:21:38 UTC (rev 106)
@@ -226,6 +226,8 @@
);
}
+ file_content = file.readAll();
+
if (type == "Neighbourhood")
{
if (!neighbourhood_parsers.contains(subtype))
@@ -276,34 +278,32 @@
void MainWindow::callSaver(const QString filename, const QString type)
{
-// QFile file(filename);
+ QFile file(filename);
QString XMLString;
-// QString subtype = filename.section('.', -1);
- QString subtype;
+ QString subtype = filename.section('.', -1);
-// if (!file.open(QIODevice::Truncate | QIODevice::Text))
-// {
-// qDebug(tr("Error opnening file %1.")
-// .arg(filename)
-// .toAscii()
-// );
-//
-// return;
-// }
+ if (!file.open(QIODevice::Truncate | QIODevice::Text))
+ {
+ qDebug(tr("Error opnening file %1.")
+ .arg(filename)
+ .toAscii()
+ );
+ return;
+ }
+
if (type == "Neighbourhood")
{
-// if (!neighbourhood_parsers.contains(subtype))
-// {
-// qDebug(tr("The file extensions %1 isn't supported.")
-// .arg(subtype)
-// .toAscii()
-// );
-// return;
-// }
+ if (!neighbourhood_parsers.contains(subtype))
+ {
+ qDebug(tr("The file extensions %1 isn't supported.")
+ .arg(subtype)
+ .toAscii()
+ );
+ return;
+ }
-// neighbourhood_parsers[subtype]->parseOut(neighbourhood->toXmlString(), type, subtype);
- neighbourhood_parsers["N"]->parseOut("Kupa", "typ", "subtyp");
+ neighbourhood_parsers[subtype]->parseOut(neighbourhood->toXmlString(), type, subtype);
}
else if (type == "LocalFunction")
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|