From: <dhu...@us...> - 2007-02-15 09:12:10
|
Revision: 327 http://svn.sourceforge.net/qcell/?rev=327&view=rev Author: dhubleizh Date: 2007-02-15 01:12:09 -0800 (Thu, 15 Feb 2007) Log Message: ----------- - KI parsed out ok - function parsing in (REAK, ZIFW, FQT), out (FQT) - function table edditing made clear Modified Paths: -------------- trunk/qcell/basesources/LocalFunction.cpp trunk/qcell/basesources/functiontable.cpp trunk/qcell/parsers/FQT/FQTParserPlugin.cpp trunk/qcell/parsers/KI/KIParserPlugin.cpp trunk/qcell/parsers/REAK/REAKParserPlugin.cpp Modified: trunk/qcell/basesources/LocalFunction.cpp =================================================================== --- trunk/qcell/basesources/LocalFunction.cpp 2007-02-15 00:21:48 UTC (rev 326) +++ trunk/qcell/basesources/LocalFunction.cpp 2007-02-15 09:12:09 UTC (rev 327) @@ -669,7 +669,7 @@ root = doc.createElement("LocalFunction"); root.setAttribute("ArgumentsNumber", getNumberOfArgs()); root.setAttribute("InputAlphabet", getAlphabetSize()); - if(sumArguments.size() > 0) + if(sumArguments.size() > 0 && sumArguments[0].size() > 0) { element = doc.createElement("Sums"); temp.clear(); @@ -677,7 +677,7 @@ { if (sumArguments[i].isEmpty()) { - temp += QString("\n%1").arg(0); + temp += QString("\n%1").arg(-1); } else { @@ -696,7 +696,8 @@ } element = doc.createElement("Values"); - mpv = mostPopularValue(); +// mpv = mostPopularValue(); + mpv = -1; element.setAttribute("FillValue", mpv); temp = "\n"; for(int i=0;i<valueTable.size();++i) @@ -739,21 +740,36 @@ { init(xmlElement->attribute("ArgumentsNumber").toInt(), xmlElement->attribute("InputAlphabet").toInt(), 666); node = xmlElement->firstChild(); - while(!node.isNull()) + element = node.toElement(); + if(element.tagName()=="Sums") { - element = node.toElement(); - if(element.tagName()=="Sums") - setSumsFromString(element.text()); - if(element.tagName()=="Values") - { - if(element.hasAttribute("FillValue")) - { - setDefaultValue(element.attribute("FillValue").toInt()); - setValuesFromString(element.text()); - } - } - node = node.nextSibling(); + setSumsFromString(element.text()); + node = node.nextSibling(); + element = node.toElement(); } + else + { + setSumArguments(QVector<int>()); + } + if(element.hasAttribute("FillValue")) + { + setDefaultValue(element.attribute("FillValue").toInt()); + setValuesFromString(element.text()); + } + +// while(!node.isNull()) +// { +// element = node.toElement(); +// if(element.tagName()=="Values") +// { +// if(element.hasAttribute("FillValue")) +// { +// setDefaultValue(element.attribute("FillValue").toInt()); +// setValuesFromString(element.text()); +// } +// } +// node = node.nextSibling(); +// } return 1; } return 0; Modified: trunk/qcell/basesources/functiontable.cpp =================================================================== --- trunk/qcell/basesources/functiontable.cpp 2007-02-15 00:21:48 UTC (rev 326) +++ trunk/qcell/basesources/functiontable.cpp 2007-02-15 09:12:09 UTC (rev 327) @@ -1,4 +1,5 @@ #include "../baseheaders/functiontable.h" +#include <QDebug> void FunctionTable::init(void) { @@ -65,7 +66,7 @@ { item = ui.functionTable->item( index / ui.functionTable->columnCount(), - index % ui.functionTable->columnCount() % index + index % ui.functionTable->columnCount() ); } else @@ -92,11 +93,22 @@ function->setValueAt(-1, row * ui.functionTable->columnCount() + column); item->setText("?"); } - else + else if(temp.toInt() <= function->getAlphabetSize()) { item->setText(temp); function->setValueAt(temp.toInt(), row * ui.functionTable->columnCount() + column); } + else + { + // Reset original value + item->setText(QString::number(function->getValueAt( + row * ui.functionTable->columnCount() + column)) + ); + qDebug(tr("The inputed return value is greater than the one declared in function header(%1)") + .arg(function->getAlphabetSize()) + .toAscii() + ); + } } } Modified: trunk/qcell/parsers/FQT/FQTParserPlugin.cpp =================================================================== --- trunk/qcell/parsers/FQT/FQTParserPlugin.cpp 2007-02-15 00:21:48 UTC (rev 326) +++ trunk/qcell/parsers/FQT/FQTParserPlugin.cpp 2007-02-15 09:12:09 UTC (rev 327) @@ -6,6 +6,7 @@ * Last Update: czw lis 30 14:19:22 CET 2006 */ #include "FQTParserPlugin.h" +#include <QDebug> FQTParserPlugin::FQTParserPlugin() { @@ -348,7 +349,7 @@ } // Get rid of the penging `,' result.chop(1); -// result.append('\n'); + result.append('\n'); /// @todo Get it right next time - this is ugly! QMap<QString, QString> fqt; @@ -364,11 +365,13 @@ int index = 0; QString values_txt = values.text(); values_txt.chop(1); + values_txt.remove(0, 1); foreach(QString sum_line, values_txt.split(";\n")) { QStringList tokens = sum_line.split('='); QStringList sum_and_free = tokens[0].split('+'); QString sum = sum_and_free.takeFirst(); + QStringList free = sum_and_free.first().split(','); if (!fqt.contains(sum)) { @@ -376,9 +379,12 @@ } index = num_combinations-1; - for (int i = 0; i < sum_and_free.size(); i++) + for (int i = 0; i < free.count(); i++) { - index -= sum_and_free[i].toInt() * (pow(lf.getAlphabetSize(), (free_args - i)) - 1); + int farg = free[i].toInt(); + int alphs = lf.getAlphabetSize(); + int wynik = pow(lf.getAlphabetSize(), free_args-i-1); + index -= free[i].toInt() * (pow(lf.getAlphabetSize(), (free_args - i - 1))); } fqt[sum][index] = tokens[1][0]; } Modified: trunk/qcell/parsers/KI/KIParserPlugin.cpp =================================================================== --- trunk/qcell/parsers/KI/KIParserPlugin.cpp 2007-02-15 00:21:48 UTC (rev 326) +++ trunk/qcell/parsers/KI/KIParserPlugin.cpp 2007-02-15 09:12:09 UTC (rev 327) @@ -31,7 +31,7 @@ // 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 = new CalculationData(); + CalculationData cd; // Maximum dimensions values int max_x, max_y, max_z; max_x = max_y = max_z = 0; @@ -95,7 +95,7 @@ } // 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 ) @@ -103,10 +103,10 @@ // no Y dimension if (world.first().count() == 1 ) { - cd->resizeData(world.first().first().count()); + 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); } } @@ -114,7 +114,7 @@ else { max_y = world.first().count(); - cd->resizeData(max_x, max_y); + 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++ ) @@ -122,9 +122,9 @@ if (world.first()[i].count() > max_x) { max_x = world.first()[i].count(); - cd->resizeData(max_x, max_y); + cd.resizeData(max_x, max_y); } - cd->setValueAt(world.first()[i][j], j, i); + cd.setValueAt(world.first()[i][j], j, i); } } @@ -136,13 +136,13 @@ else { max_z = world.count(); - cd->resizeData(max_x, max_y, max_z); + cd.resizeData(max_x, max_y, max_z); for ( int i = 0; i < world.count(); i++ ) { if (world[i].count() > max_y) { max_y = world[i].count(); - cd->resizeData(max_x, max_y, max_z); + cd.resizeData(max_x, max_y, max_z); } for ( int j = 0; j < world[i].count(); j++ ) @@ -152,10 +152,10 @@ if (world[i][j].count() > max_x) { max_x = world[i][j].count(); - cd->resizeData(max_x, max_y, max_z); + cd.resizeData(max_x, max_y, max_z); } - cd->setValueAt(world[i][j][k], k, j, i); + cd.setValueAt(world[i][j][k], k, j, i); } } @@ -164,7 +164,7 @@ } - return cd->toXmlString(); + return cd.toXmlString(); } QByteArray KIParserPlugin::parseOut(QString content, const QString type, const QString subtype) @@ -172,23 +172,22 @@ // The resulting array to write to file by the backend QByteArray result; // Generic type to parse XML request - CalculationData* cd = (CalculationData*)content.toInt(); + CalculationData cd; // Check if we can use the generic type from the XML string /// @todo Unhack this! -// if(!cd.setFromXmlString(&content)) - if(cd == NULL) + if(!cd.setFromXmlString(&content)) { qDebug(tr("Unable to parse out internal data!").toAscii()); } - switch (cd->getDimension()) + switch (cd.getDimension()) { case 1: { - for (int x = 0; x < cd->getSizeX(); x++) + for (int x = 0; x < cd.getSizeX(); x++) { - result.append((char)('0' + cd->getValueAt_i(x))); + result.append((char)('0' + cd.getValueAt_i(x))); } result.append('\n'); @@ -196,11 +195,11 @@ } 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((char)('0' + cd->getValueAt_i(x,y))); + result.append((char)('0' + cd.getValueAt_i(x,y))); } result.append('\n'); @@ -210,13 +209,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((char)('0' + cd->getValueAt_d(x, y, z))); + result.append((char)('0' + cd.getValueAt_d(x, y, z))); } result.append('\n'); Modified: trunk/qcell/parsers/REAK/REAKParserPlugin.cpp =================================================================== --- trunk/qcell/parsers/REAK/REAKParserPlugin.cpp 2007-02-15 00:21:48 UTC (rev 326) +++ trunk/qcell/parsers/REAK/REAKParserPlugin.cpp 2007-02-15 09:12:09 UTC (rev 327) @@ -236,10 +236,10 @@ { i.next(); lf.setFunctionValue(i.key(), i.value()); -// qDebug() << i.key() << " : " << i.value(); + qDebug() << i.key() << " : " << i.value(); } -// qDebug(lf.toXmlString().toAscii()); + qDebug(lf.toXmlString().toAscii()); return lf.toXmlString(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |