From: <dhu...@us...> - 2007-01-05 16:06:43
|
Revision: 102 http://svn.sourceforge.net/qcell/?rev=102&view=rev Author: dhubleizh Date: 2007-01-05 08:06:41 -0800 (Fri, 05 Jan 2007) Log Message: ----------- - NParser Fucked inability to parseOut Modified Paths: -------------- trunk/qcell/parsers/N/NParserPlugin.cpp trunk/qcell/parsers/N/NParserPlugin.h trunk/qcell/visgui/MainWindow.cpp trunk/qcell/visgui/MainWindow.h trunk/qcell/visgui/MainWindow.ui Modified: trunk/qcell/parsers/N/NParserPlugin.cpp =================================================================== --- trunk/qcell/parsers/N/NParserPlugin.cpp 2007-01-05 16:06:12 UTC (rev 101) +++ trunk/qcell/parsers/N/NParserPlugin.cpp 2007-01-05 16:06:41 UTC (rev 102) @@ -257,5 +257,59 @@ return N.toXmlString(); } +QByteArray NParserPlugin::parseOut(QString content, const QString type, const QString subtype) +{ + // The resulting array to write to file by the end backend + QByteArray result; + // Generic class for parsing out XMLString + Neighbourhood N; + QVector<NContainer> neighbours; + // Maximum found dimensions + int max_x, max_y,max_z; + // Needs to be set to 1, as there needs to be at least one of each + // dimensions for this implementation + max_x = max_y = max_z = 1; + + if(!N.fromXmlString(&content)) + { + qDebug(tr("Unable to parse out internal data!").toAscii()); + } + + // Filetype and dimensions declaration + result.append('N'); + result.append(N.getDimension()); + result.append('\n'); + + // Sizes of dimensions + + //Od tego momentu le\xBF\xEA + + //Determin the maximum of each supported dimension + foreach(NContainer tmp, neighbours) + { + if(tmp.x > max_x) + { + max_x = tmp.x; + } + else if(tmp.y > max_y) + { + max_y = tmp.y; + } + else if (tmp.z > max_z) + { + max_z = tmp.z; + } + } + + // Construct a space of max_x x max_y x max_z filled with '-'; + // At least one is needed always, even when the rest of dimensions is 0 + QVector<QVector<QVector<char> > > table(max_z, QVector<QVector<char> >(max_y, QVector<char>(max_x, '-'))); + + foreach(NContainer tmp, neighbours) + { + + } +} + Q_EXPORT_PLUGIN2(NFileParser, NParserPlugin) Modified: trunk/qcell/parsers/N/NParserPlugin.h =================================================================== --- trunk/qcell/parsers/N/NParserPlugin.h 2007-01-05 16:06:12 UTC (rev 101) +++ trunk/qcell/parsers/N/NParserPlugin.h 2007-01-05 16:06:41 UTC (rev 102) @@ -19,7 +19,7 @@ { protected: QString realParser(const QByteArray content, const QString type, const QString subtype); - + QByteArray parseOut(QString content, const QString type, const QString subtype); public: NParserPlugin(); Modified: trunk/qcell/visgui/MainWindow.cpp =================================================================== --- trunk/qcell/visgui/MainWindow.cpp 2007-01-05 16:06:12 UTC (rev 101) +++ trunk/qcell/visgui/MainWindow.cpp 2007-01-05 16:06:41 UTC (rev 102) @@ -274,14 +274,114 @@ } +void MainWindow::callSaver(const QString filename, const QString type) +{ +// QFile file(filename); + QString XMLString; +// QString subtype = filename.section('.', -1); + QString subtype; + +// 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; +// } + +// neighbourhood_parsers[subtype]->parseOut(neighbourhood->toXmlString(), type, subtype); + neighbourhood_parsers["N"]->parseOut("Kupa", "typ", "subtyp"); + + } + else if (type == "LocalFunction") + { + if (!function_parsers.contains(subtype)) + { + qDebug(tr("The file extensions %1 isn't supported.") + .arg(subtype) + .toAscii() + ); + return; + } + + qDebug("Przed"); + function_parsers[subtype]->parseOut(local_function->toXmlString(), type, subtype); + } + else if (type == "World") + { + if (!world_parsers.contains(subtype)) + { + qDebug(tr("The file extensions %1 isn't supported.") + .arg(subtype) + .toAscii() + ); + return; + } + + /// @todo Wait for toXmlString +// world_parsers[subtype]->parseOut(data.last().toXmlString(), type, subtype); + } + else + { + qDebug(tr("Unsupported file type to parse.").toAscii()); + return; + } +} + void MainWindow::setupEngine() { working = false; + iteration = 0; } -void MainWindow::oneStep() +void MainWindow::oneStep(int direction) { /// @todo Write oneStep + switch (direction) + { + case Forward: + { + if(iteration < (data.count()-1)) + { + /// @todo moving through the list + } + else + { + /// @todo processing + } + + iteration++; + break; + + } + case Back: + { + if(iteration == 0) + { + qDebug(tr("You cannot step back beyond the beginning of the experiment!").toAscii()); + return; + } + + /// @todo actuall going back + + iteration--; + } + + } + iterationLCD->display(iteration); } void MainWindow::stepForward(int step) @@ -327,6 +427,7 @@ void MainWindow::on_action_Back_activated() { /// @todo Handle back movement + oneStep( Back); } void MainWindow::on_action_Start_activated() @@ -358,6 +459,67 @@ void MainWindow::on_action_Restart_activated() { /// @todo Handle restarting the experiment - CalculationData backup = data.first(); + iteration = 0; + this->iterationLCD->display(iteration); + +// CalculationData backup = data.first(); } +void MainWindow::on_action_World_save_activated() +{ + if(world_parsers.count() == 0) + { + QMessageBox::warning( + /*parent*/ this, + /*title*/ tr("Plugins warning"), + /*message*/ tr("There are no plugins loaded to handle World saving.") + ); + + return; + + } + + QFileDialog fd( + /*parent*/ this, + /*cation*/ tr("Save World"), + /*dir*/ "." + ); + + fd.setAcceptMode(QFileDialog::AcceptSave); + fd.setFileMode(QFileDialog::AnyFile); + + QStringList filters; + QString filter; + // Add filter in format %{name} files (*.%{name}) + foreach(QString key, world_parsers.keys()) + { + // Don't shorten this, as it is made for translations + // purposes + filter = key + " " + tr("files") + " (*." + key + ")"; + filters << filter; + } + fd.setFilters(filters); + + fd.exec(); + + if(!fd.selectedFiles().isEmpty()) + { + callSaver(fd.selectedFiles().first(), "World"); + + } + +} + +void MainWindow::on_action_Neighbourhood_save_activated() +{ + qDebug("UngaBunga!!!!!"); + callSaver("A cokolwiek", "Neighbourhood"); + + +} + +void MainWindow::on_action_Function_save_activated() +{ + +} + Modified: trunk/qcell/visgui/MainWindow.h =================================================================== --- trunk/qcell/visgui/MainWindow.h 2007-01-05 16:06:12 UTC (rev 101) +++ trunk/qcell/visgui/MainWindow.h 2007-01-05 16:06:41 UTC (rev 102) @@ -41,6 +41,10 @@ void on_action_Function_activated(); void on_action_World_activated(); + void on_action_World_save_activated(); + void on_action_Neighbourhood_save_activated(); + void on_action_Function_save_activated(); + /// @todo not here! void on_action_Forward_activated(); void on_action_Back_activated(); @@ -55,9 +59,17 @@ void callParser(QString filename, QString type); + void callSaver(const QString filename, const QString type); /// @todo Not in here! + enum Direction + { + Forward = 1, + Back, + }; + bool working; + int iteration; QList<CalculationData> data; LocalFunction* local_function; @@ -66,7 +78,7 @@ void setupEngine(); - void oneStep(); + void oneStep(int direction = Forward); void stepForward(int step); void continousSteps(); Modified: trunk/qcell/visgui/MainWindow.ui =================================================================== --- trunk/qcell/visgui/MainWindow.ui 2007-01-05 16:06:12 UTC (rev 101) +++ trunk/qcell/visgui/MainWindow.ui 2007-01-05 16:06:41 UTC (rev 102) @@ -5,7 +5,7 @@ <rect> <x>0</x> <y>0</y> - <width>553</width> + <width>532</width> <height>538</height> </rect> </property> @@ -23,6 +23,59 @@ <property name="spacing" > <number>6</number> </property> + <item> + <spacer> + <property name="orientation" > + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" > + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + <item> + <layout class="QHBoxLayout" > + <property name="margin" > + <number>0</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <spacer> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" > + <size> + <width>321</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QLabel" name="iterationLabel" > + <property name="text" > + <string>Iteration</string> + </property> + </widget> + </item> + <item> + <widget class="QLCDNumber" name="iterationLCD" > + <property name="numDigits" > + <number>5</number> + </property> + <property name="segmentStyle" > + <enum>QLCDNumber::Flat</enum> + </property> + </widget> + </item> + </layout> + </item> </layout> </widget> <widget class="QMenuBar" name="mainMenubar" > @@ -30,10 +83,26 @@ <rect> <x>0</x> <y>0</y> - <width>553</width> + <width>532</width> <height>30</height> </rect> </property> + <widget class="QMenu" name="menu_Edit" > + <property name="title" > + <string>&Edit</string> + </property> + </widget> + <widget class="QMenu" name="menu_Experiment" > + <property name="title" > + <string>&Experiment</string> + </property> + <addaction name="action_Start" /> + <addaction name="action_Stop" /> + <addaction name="action_Restart" /> + <addaction name="separator" /> + <addaction name="action_Forward" /> + <addaction name="action_Back" /> + </widget> <widget class="QMenu" name="menu_Help" > <property name="title" > <string>&Help</string> @@ -41,11 +110,6 @@ <addaction name="separator" /> <addaction name="action_About" /> </widget> - <widget class="QMenu" name="menu_Edit" > - <property name="title" > - <string>&Edit</string> - </property> - </widget> <widget class="QMenu" name="menu_File" > <property name="title" > <string>&File</string> @@ -57,27 +121,25 @@ <property name="title" > <string>&Open</string> </property> + <addaction name="action_World" /> <addaction name="action_Neighbourhood" /> <addaction name="action_Function" /> - <addaction name="action_World" /> </widget> + <widget class="QMenu" name="menu_Save_experiment" > + <property name="title" > + <string>&Save experiment</string> + </property> + <addaction name="action_World_save" /> + <addaction name="action_Neighbourhood_save" /> + <addaction name="action_Function_save" /> + </widget> <addaction name="menu_Open" /> <addaction name="action_Open_experiment" /> <addaction name="action_Continiue_experiment" /> + <addaction name="menu_Save_experiment" /> <addaction name="separator" /> <addaction name="action_Quit" /> </widget> - <widget class="QMenu" name="menu_Experiment" > - <property name="title" > - <string>&Experiment</string> - </property> - <addaction name="action_Start" /> - <addaction name="action_Stop" /> - <addaction name="action_Restart" /> - <addaction name="separator" /> - <addaction name="action_Forward" /> - <addaction name="action_Back" /> - </widget> <addaction name="menu_File" /> <addaction name="menu_Edit" /> <addaction name="menu_Experiment" /> @@ -95,8 +157,8 @@ <addaction name="action_Stop" /> <addaction name="action_Restart" /> <addaction name="separator" /> + <addaction name="action_Back" /> <addaction name="action_Forward" /> - <addaction name="action_Back" /> </widget> <action name="action_Quit" > <property name="text" > @@ -212,6 +274,21 @@ <string>Iterates one setp back.</string> </property> </action> + <action name="action_World_save" > + <property name="text" > + <string>&World</string> + </property> + </action> + <action name="action_Neighbourhood_save" > + <property name="text" > + <string>&Neighbourhood</string> + </property> + </action> + <action name="action_Function_save" > + <property name="text" > + <string>&Function</string> + </property> + </action> </widget> <resources/> <connections/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |