From: <dhu...@us...> - 2007-02-13 15:26:20
|
Revision: 311 http://svn.sourceforge.net/qcell/?rev=311&view=rev Author: dhubleizh Date: 2007-02-13 07:26:13 -0800 (Tue, 13 Feb 2007) Log Message: ----------- - implemented and slightly tested REAK and ZIFW inparsing - seems to work - added the libs to main - visualisation every n-iterations mode Modified Paths: -------------- trunk/qcell/basesources/LocalFunction.cpp trunk/qcell/parsers/LTFL/LTFLParserPlugin.cpp trunk/qcell/parsers/REAK/REAKParserPlugin.cpp trunk/qcell/parsers/ZIFW/ZIFWParserPlugin.cpp trunk/qcell/visgui/ExperimentSetup.ui trunk/qcell/visgui/MainWindow.cpp trunk/qcell/visgui/MainWindow.h trunk/qcell/visgui/main.cpp trunk/qcell/visgui/visgui.pro Modified: trunk/qcell/basesources/LocalFunction.cpp =================================================================== --- trunk/qcell/basesources/LocalFunction.cpp 2007-02-12 10:45:28 UTC (rev 310) +++ trunk/qcell/basesources/LocalFunction.cpp 2007-02-13 15:26:13 UTC (rev 311) @@ -233,9 +233,16 @@ { sumVector.clear(); elements = list[i].split(',', QString::SkipEmptyParts); - for(int j=0;j<elements.size();++j) + if (elements.size() == 1 && elements[0].toInt() == 0) { + setSumArguments(QVector<int>()); + } + else + { + for(int j=0;j<elements.size();++j) + { sumVector.append((elements[j]).toInt()); + } } if(!sumVector.isEmpty()) { @@ -281,8 +288,15 @@ if(mainSplit.size()==2) { argumentsSplit = mainSplit[0].split(',', QString::SkipEmptyParts); - for(int i=0;i<argumentsSplit.size();++i) + if (argumentsSplit.first().toInt() == 0 && sumArguments.isEmpty()) + { + setSumArguments(QVector<int>()); + } + else + { + for(int i=0;i<argumentsSplit.size();++i) sums.append((argumentsSplit[i]).toInt()); + } argumentsSplit = mainSplit[1].split(',', QString::SkipEmptyParts); for(int i=0;i<argumentsSplit.size();++i) @@ -572,14 +586,22 @@ int index; if(sumArguments.size()==0 || freeArguments.size()==0) return 0; - if(valueTable.empty()) + if(valueTable.isEmpty()) resizeValueTable(); switch(functionMode) { case LocalFunction::SUM_AND_SWITCH: - index = calculateSumsIndex(sums) + calculateSwitchIndex(freeArgs); - valueTable[index] = value; - break; + { + index = calculateSumsIndex(sums) + calculateSwitchIndex(freeArgs); + valueTable[index] = value; + break; + } + case LocalFunction::SWITCH: + { + index = calculateSwitchIndex(freeArgs); + valueTable[index] = value; + break; + } default: return 0; } @@ -647,18 +669,26 @@ root = doc.createElement("LocalFunction"); root.setAttribute("ArgumentsNumber", getNumberOfArgs()); root.setAttribute("InputAlphabet", getAlphabetSize()); - if(sumArguments.size()>0) + if(sumArguments.size() > 0) { element = doc.createElement("Sums"); temp.clear(); for(int i=0;i<sumArguments.size();++i) { + if (sumArguments[i].isEmpty()) + { + temp += QString("\n%1").arg(0); + } + else + { temp += QString("\n%1").arg((sumArguments[i])[0]); - for(int j=1;j<sumArguments[i].size();++j) - { - temp += QString(",%1").arg((sumArguments[i])[j]); - } - temp += ";\n"; + } + + for(int j=1;j<sumArguments[i].size();++j) + { + temp += QString(",%1").arg((sumArguments[i])[j]); + } + temp += ";\n"; } text = doc.createTextNode(temp); element.appendChild(text); @@ -713,8 +743,7 @@ { element = node.toElement(); if(element.tagName()=="Sums") - setSumsFromString(element.text()); - + setSumsFromString(element.text()); if(element.tagName()=="Values") { if(element.hasAttribute("FillValue")) Modified: trunk/qcell/parsers/LTFL/LTFLParserPlugin.cpp =================================================================== --- trunk/qcell/parsers/LTFL/LTFLParserPlugin.cpp 2007-02-12 10:45:28 UTC (rev 310) +++ trunk/qcell/parsers/LTFL/LTFLParserPlugin.cpp 2007-02-13 15:26:13 UTC (rev 311) @@ -6,6 +6,7 @@ * Last Update: wto 28 lis 2006 11:23:55 CET */ #include "LTFLParserPlugin.h" +#include <QDebug> LTFLParserPlugin::LTFLParserPlugin() { @@ -50,20 +51,20 @@ result[0] = result[0].trimmed(); if(format.exactMatch(result[0])) { - splitted = result[0].section("FL",1); - dimensions = splitted.toInt(); +// splitted = result[0].section("FL",1); +// dimensions = splitted.toInt(); +// +// // dimensions sanity check +// if ((dimensions < 1) || (dimensions > 3)) +// { +// qDebug(tr("You should specify dimensions number from 1-3 in line %1") +// .arg(line_nr) +// .toAscii() +// ); +// +// return QString(); +// } - // dimensions sanity check - if ((dimensions < 1) || (dimensions > 3)) - { - qDebug(tr("You should specify dimensions number from 1-3 in line %1") - .arg(line_nr) - .toAscii() - ); - - return QString(); - } - result.removeFirst(); line_nr++; } @@ -79,11 +80,12 @@ // Dimensions sizes and number of neighbours result[0] = result[0].trimmed(); format = QRegExp("^(\\d)+ (\\d)+$"); + qDebug(result[0].toAscii()); if(format.exactMatch(result[0])) { splitted_list = result[0].split(' '); - alphabet_size = splitted_list.first().toInt(); - arguments = splitted_list.last().toInt(); + arguments = splitted_list.first().toInt(); + alphabet_size = splitted_list.last().toInt(); // alphabet_size sanity check. int max_alphabet_size = (int)'z'-(int)'A'+10; @@ -112,7 +114,7 @@ // The real function parsing result[0] = result[0].trimmed(); - format.setPattern("^([\\-0-9A-z]){" + QString::number(alphabet_size) + "} [0-9A-z]$"); + format.setPattern("^([\\-0-9A-z]){" + QString::number(arguments) + "} [0-9A-z]$"); int tmp_result, tmp_argument; QVector<int> tmp_arguments; foreach(QString line, result) @@ -209,10 +211,24 @@ line_nr++; } - /// @todo input the retrieved data into LF + // setting the number of arguments the function will take + // and the alphabet size + lf.init(arguments, alphabet_size, alphabet_size); + // setting the type of function +// lf.setFunctonType(LocalFunction::SWITCH); + lf.setSwitchFunction(); + lf.setSumArguments(QVector<int>()); -// return lf.toXmlString(); - return QString(); + QMapIterator<QVector<int>, int> iter(function); + while (iter.hasNext()) + { + iter.next(); + lf.setFunctionValue(iter.value(), iter.key()); + qDebug() << iter.value() << " : " << iter.key(); + } + + qDebug(lf.toXmlString().toAscii()); + return lf.toXmlString(); } QByteArray LTFLParserPlugin::parseOut(QString content, const QString type, const QString subtype) Modified: trunk/qcell/parsers/REAK/REAKParserPlugin.cpp =================================================================== --- trunk/qcell/parsers/REAK/REAKParserPlugin.cpp 2007-02-12 10:45:28 UTC (rev 310) +++ trunk/qcell/parsers/REAK/REAKParserPlugin.cpp 2007-02-13 15:26:13 UTC (rev 311) @@ -227,8 +227,8 @@ /// @todo input the retrieved data into LF // Init the function lf.init(arguments, alphabet_size, alphabet_size); - lf.setFunctonType(LocalFunction::SWITCH); -// lf.setSumArguments(QVector<int>(1,0)); +// lf.setFunctonType(LocalFunction::SWITCH); + lf.setSumArguments(QVector<int>()); // Finally pass the function to the engine QHashIterator<int, QVector<int> > i(function); @@ -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(); } Modified: trunk/qcell/parsers/ZIFW/ZIFWParserPlugin.cpp =================================================================== --- trunk/qcell/parsers/ZIFW/ZIFWParserPlugin.cpp 2007-02-12 10:45:28 UTC (rev 310) +++ trunk/qcell/parsers/ZIFW/ZIFWParserPlugin.cpp 2007-02-13 15:26:13 UTC (rev 311) @@ -46,7 +46,7 @@ } // Function type - format = QRegExp("^ZIFWP[1-3]?$"); + format = QRegExp("^ZIFW[1-3]?$"); lines[0] = lines[0].trimmed(); if(format.exactMatch(lines[0])) { @@ -115,7 +115,7 @@ // Main function parsing lines[0] = lines[0].trimmed(); - format = QRegExp("^[0-9A-z]: \\{([\\-0-9A-z]{" + QString::number(arguments_nr) + "})*,([\\-0-9A-z]{" + QString::number(arguments_nr) + ")?\\}$"); + format = QRegExp("^[0-9A-z]: \\{(([\\-0-9A-z]){" + QString::number(arguments_nr) + "},)*(([\\-0-9A-z]){" + QString::number(arguments_nr) + "})?\\}$"); int tmp_result, tmp_sign, argument_index, set_nr; QVector<QVector <int> > tmp_arguments; foreach(QString line, lines) @@ -152,14 +152,16 @@ // First clearing tmp values tmp_arguments.clear(); set_nr = 0; - // Remove space after separator ':' - splitted[1].remove(0, 1); + // Remove space and '{' after separator ':' + splitted[1].remove(0, 2); + // Remove '}' + splitted[1].chop(1); foreach(QString set, splitted[1].split(',')) { // Keep track of the set set_nr++; // Reset argument index counter - argument_index = 0; + argument_index = -1; if (set.isEmpty()) { @@ -183,7 +185,6 @@ if(tmp_sign >= (int)'A') { tmp_sign = tmp_sign - (int)'A' + 10; - } else { @@ -192,11 +193,12 @@ if(tmp_sign >= output_alphabet_size) { - qDebug(tr("The value number %1 in set %2 in line %3 is larger then the input alphabet size declared in the header (%4).") + qDebug(tr("The value number %1(%2) in set %3 in line %4 is larger then the input alphabet size declared in the header (%5).") .arg(argument_index) + .arg(tmp_sign) .arg(set) .arg(line_nr) - .arg(input_alphabet_size) + .arg(output_alphabet_size) .toAscii() ); @@ -204,7 +206,11 @@ } // Finally add the argument - tmp_arguments.append(QVector<int>(1, tmp_sign)); + if (value.toAscii() != '-') + { + tmp_arguments.last()[argument_index] = tmp_sign; + } +// tmp_arguments.append(QVector<int>(1, tmp_sign)); } } @@ -232,10 +238,22 @@ // and the alphabet size lf.init(arguments_nr, input_alphabet_size, output_alphabet_size); // setting the type of function - lf.setFunctonType(LocalFunction::SWITCH); +// lf.setFunctonType(LocalFunction::SWITCH); + lf.setSwitchFunction(); + lf.setSumArguments(QVector<int>()); - /// @todo How the fuck set ZIFW function parameters eh? + QMapIterator<int, QVector<QVector< int> > > iter(function); + while (iter.hasNext()) + { + iter.next(); + for (int i = 0; i < iter.value().size(); i++) + { + lf.setFunctionValue(iter.key(), iter.value()[i]); +// qDebug() << iter.key() << " : " << iter.value()[i]; + } + } +// qDebug(lf.toXmlString().toAscii()); return lf.toXmlString(); } Modified: trunk/qcell/visgui/ExperimentSetup.ui =================================================================== --- trunk/qcell/visgui/ExperimentSetup.ui 2007-02-12 10:45:28 UTC (rev 310) +++ trunk/qcell/visgui/ExperimentSetup.ui 2007-02-13 15:26:13 UTC (rev 311) @@ -6,7 +6,7 @@ <x>0</x> <y>0</y> <width>400</width> - <height>231</height> + <height>289</height> </rect> </property> <property name="windowTitle" > @@ -68,6 +68,54 @@ </widget> </item> <item> + <widget class="QGroupBox" name="stepBox" > + <property name="title" > + <string>Visualization step</string> + </property> + <layout class="QHBoxLayout" > + <property name="margin" > + <number>9</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="QLabel" name="stepLabel" > + <property name="text" > + <string>Step</string> + </property> + <property name="buddy" > + <cstring>stepSpinBox</cstring> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="stepSpinBox" > + <property name="maximum" > + <number>99999</number> + </property> + <property name="minimum" > + <number>1</number> + </property> + </widget> + </item> + <item> + <spacer> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" > + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + </item> + <item> <widget class="QGroupBox" name="speedBox" > <property name="title" > <string>Delay between iterations</string> Modified: trunk/qcell/visgui/MainWindow.cpp =================================================================== --- trunk/qcell/visgui/MainWindow.cpp 2007-02-12 10:45:28 UTC (rev 310) +++ trunk/qcell/visgui/MainWindow.cpp 2007-02-13 15:26:13 UTC (rev 311) @@ -77,8 +77,8 @@ dock3D, SLOT(setVisible(bool)) ); - connect(view3DTools, SIGNAL(newPositionZ(float)), sw->getRenderer(), SLOT(setZValue(float))); - connect( sw->getRenderer(), SIGNAL(newPositionSet(float, float, float)), view3DTools, SLOT(PositionChange(float, float, float))); + connect(view3DTools, SIGNAL(newPositionZ(float)), sw->getRenderer(), SLOT(setZValue(float))); + connect( sw->getRenderer(), SIGNAL(newPositionSet(float, float, float)), view3DTools, SLOT(PositionChange(float, float, float))); // View 2D Tools dock2D = new BetterDockWidget(this); @@ -139,7 +139,6 @@ dock1D, SLOT(setVisible(bool)) ); - // add Neigborhood Tools dockNtools = new BetterDockWidget(this); dockNtools->hide(); @@ -156,16 +155,16 @@ vnt_action->setText(tr("&Neigborhood Tools")); menu_View->addAction(vnt_action); - connect(sw, SIGNAL(setNToolsVisible(bool)), - dockNtools, SLOT(setVisible(bool)) - ); + connect(sw, SIGNAL(setNToolsVisible(bool)), + dockNtools, SLOT(setVisible(bool)) + ); - connect(neigborhoodTools, SIGNAL(ViewModeUpdated(int)), sw, SLOT(NViewModeChange(int))); - connect(this, SIGNAL(neigborhoodSet(int, int, int)), neigborhoodTools, SLOT(setRange(int, int, int))); - connect(neigborhoodTools, SIGNAL(maskSet(int, int, int)), sw, SLOT(NViewMaskSet(int, int, int))); - connect(this, SIGNAL(neigborCount(int)), neigborhoodTools, SLOT(setNeigborNumber(int))); + connect(neigborhoodTools, SIGNAL(ViewModeUpdated(int)), sw, SLOT(NViewModeChange(int))); + connect(this, SIGNAL(neigborhoodSet(int, int, int)), neigborhoodTools, SLOT(setRange(int, int, int))); + connect(neigborhoodTools, SIGNAL(maskSet(int, int, int)), sw, SLOT(NViewMaskSet(int, int, int))); + connect(this, SIGNAL(neigborCount(int)), neigborhoodTools, SLOT(setNeigborNumber(int))); - connect(neigborhoodTools, SIGNAL(setSelectedPress(int)), sw->getNeighbourhoodEditor(), SLOT(fillSelected(int))); + connect(neigborhoodTools, SIGNAL(setSelectedPress(int)), sw->getNeighbourhoodEditor(), SLOT(fillSelected(int))); // Adding delay setup // An interlinked pair of QDoubleSpinBox and a QSlider // delaySlider = new QSlider(Qt::Horizontal); @@ -757,6 +756,7 @@ working = false; iteration = 0; msec_delay = 0; + step = 1; // Set all data pointers to NULL, as unlockExperiment depends on it! neighbourhood = NULL; @@ -832,10 +832,15 @@ void MainWindow::update() { + static int counter = 0; // *sw->getStorage() = *data[iteration]; // sw->getStorage()->resizeData(data[iteration]->getSize(), data[iteration]->getDataPointer(), 1); //calc.resizeData(data[iteration]->getSize(), data[iteration]->getDataPointer(), 1); + if (++counter == step) + { + counter = 0; sw->getStorage()->resizeData(calc.getSize(), calc.getDataPointer(), 1); + } iterationLCD->display(iteration); } @@ -895,6 +900,7 @@ if(es.exec() == QDialog::Accepted) { working = true; + step = es.stepSpinBox->value(); // msec_delay = (uint)(es.delaySpinBox->value() * 100.00); // delaySpinBox->setValue(es.delaySpinBox->value()); if(es.continiuosCheckBox->isChecked()) Modified: trunk/qcell/visgui/MainWindow.h =================================================================== --- trunk/qcell/visgui/MainWindow.h 2007-02-12 10:45:28 UTC (rev 310) +++ trunk/qcell/visgui/MainWindow.h 2007-02-13 15:26:13 UTC (rev 311) @@ -111,6 +111,7 @@ bool working; int iteration; uint msec_delay; + int step; Calculator calc; ElementalRules* elemental_rules; @@ -118,7 +119,7 @@ BetterDockWidget* dock3D; BetterDockWidget* dock2D; BetterDockWidget* dock1D; - BetterDockWidget* dockNtools; + BetterDockWidget* dockNtools; BetterDockWidget* baseDock; QList<CalculationData*> data; LocalFunction* local_function; Modified: trunk/qcell/visgui/main.cpp =================================================================== --- trunk/qcell/visgui/main.cpp 2007-02-12 10:45:28 UTC (rev 310) +++ trunk/qcell/visgui/main.cpp 2007-02-13 15:26:13 UTC (rev 311) @@ -12,9 +12,9 @@ Q_IMPORT_PLUGIN(NFileParser); Q_IMPORT_PLUGIN(FQTFileParser); Q_IMPORT_PLUGIN(KIFileParser); -//Q_IMPORT_PLUGIN(REAKFileParser); +Q_IMPORT_PLUGIN(REAKFileParser); //Q_IMPORT_PLUGIN(LTFLFileParser); -//Q_IMPORT_PLUGIN(ZIFWFileParser); +Q_IMPORT_PLUGIN(ZIFWFileParser); //Q_IMPORT_PLUGIN(ZIFWPFileParser); Q_IMPORT_PLUGIN(Life105FileParser); Modified: trunk/qcell/visgui/visgui.pro =================================================================== --- trunk/qcell/visgui/visgui.pro 2007-02-12 10:45:28 UTC (rev 310) +++ trunk/qcell/visgui/visgui.pro 2007-02-13 15:26:13 UTC (rev 311) @@ -67,7 +67,7 @@ ../basesources/functiontable.cpp \ ../basesources/neigborhoodtools.cpp -LIBS = -L../libs -lN -lFQT -lKI -lLife105 +LIBS = -L../libs -lN -lFQT -lKI -lLife105 -lREAK -lZIFW TRANSLATIONS = visgui_pl.ts This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |