|
From: <dhu...@us...> - 2007-01-07 12:32:34
|
Revision: 111
http://svn.sourceforge.net/qcell/?rev=111&view=rev
Author: dhubleizh
Date: 2007-01-07 04:32:30 -0800 (Sun, 07 Jan 2007)
Log Message:
-----------
- typo in CalculationData
- nasty hack in Calculating data enablign createXmlHeader (NASTY!)
- KIParserPlugin debugged (1-3d, save; load)
- MainWindow is able to call proper parser(in and out) and finally save every format
Modified Paths:
--------------
trunk/qcell/basesources/CalculationData.cpp
trunk/qcell/parsers/KI/KIParserPlugin.cpp
trunk/qcell/visgui/MainWindow.cpp
trunk/qcell/visgui/MainWindow.h
Modified: trunk/qcell/basesources/CalculationData.cpp
===================================================================
--- trunk/qcell/basesources/CalculationData.cpp 2007-01-06 20:18:51 UTC (rev 110)
+++ trunk/qcell/basesources/CalculationData.cpp 2007-01-07 12:32:30 UTC (rev 111)
@@ -531,7 +531,7 @@
return sizeX;
}
-int CalculationData::getSizeY(void)
+int CalculationData::getSizeY(void)
{
return sizeY;
}
@@ -645,7 +645,8 @@
QString CalculationData::createXmlHeader(void)
{
- return QString();
+ /// @todo The nasties thing to do - change that!!!
+ return QString::number((int)this);
}
bool CalculationData::setFromXmlString(QString *xmlString)
Modified: trunk/qcell/parsers/KI/KIParserPlugin.cpp
===================================================================
--- trunk/qcell/parsers/KI/KIParserPlugin.cpp 2007-01-06 20:18:51 UTC (rev 110)
+++ trunk/qcell/parsers/KI/KIParserPlugin.cpp 2007-01-07 12:32:30 UTC (rev 111)
@@ -7,6 +7,7 @@
*/
#include "KIParserPlugin.h"
+#include <QDebug>
KIParserPlugin::KIParserPlugin()
{
@@ -30,7 +31,10 @@
// dimensions and how large it is, so we need to track counts
QVector<QVector<QVector <int> > > world;
// Generic type for outputing XML strings
- CalculationData cd;
+ CalculationData* cd = new CalculationData();
+ // Maximum dimensions values
+ int max_x, max_y, max_z;
+ max_x = max_y = max_z = 0;
// Basic sanity check
lines = QString(content).split('\n');
@@ -53,7 +57,6 @@
}
else
{
-
// A new verse for each line
world.last().append(QVector<int>());
// Reset columnt ocunter for each line
@@ -84,9 +87,11 @@
// Keep track of line nr
line_nr++;
}
+ // Pending line
+ world.remove(world.count()-1);
// Char is the maximum value we can get from this file type
- cd.setDataType(baseDataTypes::CHAR);
+ cd->setDataType(baseDataTypes::CHAR);
// no Z dimenzion
if ( world.count() == 1 )
@@ -94,20 +99,28 @@
// no Y dimension
if (world.first().count() == 1 )
{
+ cd->resizeData(world.first().first().count());
for (int i = 0; i < world.first().first().count(); i++)
{
- cd.setValueAt(world.first().first()[i], i);
+ cd->setValueAt(world.first().first()[i], i);
}
}
// X and Y dimensions present
else
{
+ max_y = world.first().count();
+ cd->resizeData(max_x, max_y);
for ( int i = 0; i < world.first().count(); i++ )
{
for ( int j = 0; j < world.first().first().count(); j++ )
{
- cd.setValueAt(world.first()[i][j], j, i);
+ if (world.first()[i].count() > max_x)
+ {
+ max_x = world.first()[i].count();
+ cd->resizeData(max_x, max_y);
+ }
+ cd->setValueAt(world.first()[i][j], j, i);
}
}
@@ -118,13 +131,27 @@
// X, Y and Z present
else
{
+ max_z = world.count();
+ cd->resizeData(max_x, max_y, max_z);
for ( int i = 0; i < world.count(); i++ )
{
- for ( int j = 0; j < world.first().count(); j++ )
+ if (world[i].count() > max_y)
{
- for ( int k; k < world.first().first().count(); k++ )
+ max_y = world[i].count();
+ cd->resizeData(max_x, max_y, max_z);
+ }
+
+ for ( int j = 0; j < world[i].count(); j++ )
+ {
+ for ( int k = 0; k < world[i][j].count(); k++ )
{
- cd.setValueAt(world[i][j][k], k, j, i);
+ if (world[i][j].count() > max_x)
+ {
+ max_x = world[i][j].count();
+ cd->resizeData(max_x, max_y, max_z);
+ }
+
+ cd->setValueAt(world[i][j][k], k, j, i);
}
}
@@ -133,7 +160,7 @@
}
- return cd.createXmlHeader();
+ return cd->createXmlHeader();
}
QByteArray KIParserPlugin::parseOut(QString content, const QString type, const QString subtype)
@@ -141,32 +168,35 @@
// The resulting array to write to file by the backend
QByteArray result;
// Generic type to parse XML request
- CalculationData cd;
+ CalculationData* cd = (CalculationData*)content.toInt();
// Check if we can use the generic type from the XML string
- if(!cd.setFromXmlString(&content))
+ /// @todo Unhack this!
+// if(!cd.setFromXmlString(&content))
+ if(cd == NULL)
{
qDebug(tr("Unable to parse out internal data!").toAscii());
}
- switch (cd.getDimension())
+ switch (cd->getDimension())
{
case 1:
{
- for (int x = 0; x < cd.getDataSize(); x++)
+ for (int x = 0; x < cd->getSizeX(); x++)
{
- result.append(cd.getValueAt_i(x));
+ result.append((char)('0' + cd->getValueAt_i(x)));
}
+ result.append('\n');
break;
}
case 2:
{
- for(int y = 0; y < cd.getSizeY(); y++)
+ for(int y = 0; y < cd->getSizeY(); y++)
{
- for (int x = 0; x < cd.getSizeX(); x++)
+ for (int x = 0; x < cd->getSizeX(); x++)
{
- result.append(cd.getValueAt_i(x,y));
+ result.append((char)('0' + cd->getValueAt_i(x,y)));
}
result.append('\n');
@@ -176,13 +206,13 @@
}
case 3:
{
- for(int z = 0; z < cd.getSizeZ(); z++)
+ for(int z = 0; z < cd->getSizeZ(); z++)
{
- for (int y = 0; y < cd.getSizeY(); y++)
+ for (int y = 0; y < cd->getSizeY(); y++)
{
- for (int x = 0; x < cd.getSizeX(); x++)
+ for (int x = 0; x < cd->getSizeX(); x++)
{
- result.append(cd.getValueAt_d(x, y, z));
+ result.append((char)('0' + cd->getValueAt_d(x, y, z)));
}
result.append('\n');
@@ -190,6 +220,8 @@
result.append('\n');
}
+ // Remove last pending '\n'
+ result.chop(1);
break;
}
Modified: trunk/qcell/visgui/MainWindow.cpp
===================================================================
--- trunk/qcell/visgui/MainWindow.cpp 2007-01-06 20:18:51 UTC (rev 110)
+++ trunk/qcell/visgui/MainWindow.cpp 2007-01-07 12:32:30 UTC (rev 111)
@@ -272,11 +272,9 @@
return;
}
-// data.clear();
/// @todo Fix that!
-// CalculationData* tmp_cd = new CalculationData();
-// data.append(*tmp_cd);
- world_parsers[subtype]->parse(file_content, type, subtype);
+ data.clear();
+ data.append((CalculationData*)world_parsers[subtype]->parse(file_content, type, subtype).toInt());
}
else
{
@@ -327,8 +325,7 @@
return;
}
- qDebug("Przed");
- function_parsers[subtype]->parseOut(local_function->toXmlString(), type, subtype);
+ file.write(function_parsers[subtype]->parseOut(local_function->toXmlString(), type, subtype));
}
else if (type == "World")
{
@@ -342,7 +339,7 @@
}
/// @todo Wait for toXmlString
-// world_parsers[subtype]->parseOut(data.last().toXmlString(), type, subtype);
+ file.write(world_parsers[subtype]->parseOut(data.last()->createXmlHeader(), type, subtype));
}
else
{
@@ -509,13 +506,16 @@
filters << filter;
}
fd.setFilters(filters);
+ /// @todo Forge some real suffix adding
+ fd.setDefaultSuffix("KI");
- fd.exec();
-
- if(!fd.selectedFiles().isEmpty())
+ if(fd.exec())
{
- callSaver(fd.selectedFiles().first(), "World");
+ if(!fd.selectedFiles().isEmpty())
+ {
+ callSaver(fd.selectedFiles().first(), "World");
+ }
}
}
Modified: trunk/qcell/visgui/MainWindow.h
===================================================================
--- trunk/qcell/visgui/MainWindow.h 2007-01-06 20:18:51 UTC (rev 110)
+++ trunk/qcell/visgui/MainWindow.h 2007-01-07 12:32:30 UTC (rev 111)
@@ -22,9 +22,6 @@
#include <Neighbourhood.h>
#include <Renderer.h>
-#include <iostream>
-using namespace std;
-
typedef QString (*parser_fun)(QByteArray content, QString type, QString subtype);
class MainWindow : public QMainWindow, private Ui::MainWindow
@@ -71,7 +68,7 @@
bool working;
int iteration;
- QList<CalculationData> data;
+ QList<CalculationData*> data;
LocalFunction* local_function;
Neighbourhood* neighbourhood;
Renderer* renderer;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|