|
From: <dhu...@us...> - 2007-01-24 17:06:38
|
Revision: 251
http://svn.sourceforge.net/qcell/?rev=251&view=rev
Author: dhubleizh
Date: 2007-01-24 09:06:29 -0800 (Wed, 24 Jan 2007)
Log Message:
-----------
- serialization works now
Modified Paths:
--------------
trunk/qcell/visgui/MainWindow.cpp
trunk/qcell/visgui/MainWindow.h
trunk/qcell/visgui/MainWindow.ui
Modified: trunk/qcell/visgui/MainWindow.cpp
===================================================================
--- trunk/qcell/visgui/MainWindow.cpp 2007-01-24 16:23:56 UTC (rev 250)
+++ trunk/qcell/visgui/MainWindow.cpp 2007-01-24 17:06:29 UTC (rev 251)
@@ -25,6 +25,7 @@
BaseTools* basetools = new BaseTools(baseDock);
baseDock->setWindowTitle(tr("Base tools"));
baseDock->setWidget(basetools);
+ baseDock->setDisabled(true);
((QVBoxLayout*)baseDock->layout())->addStretch();
addDockWidget(Qt::RightDockWidgetArea, baseDock);
@@ -171,6 +172,15 @@
statusBar()->addPermanentWidget(tmp_label);
statusBar()->addPermanentWidget(iterationLCD);
+ // Model elements loaded indicator
+ world_check = new QCheckBox(tr("World"), this);
+// world_check->setBackgroundColor(QColor(Qt::red));
+ neighbourhood_check = new QCheckBox(tr("Neighbourhood"), this);
+ local_function_check = new QCheckBox(tr("Local Function"), this);
+ statusBar()->addPermanentWidget(world_check);
+ statusBar()->addPermanentWidget(neighbourhood_check);
+ statusBar()->addPermanentWidget(local_function_check);
+
// Plugin parsing
/// @todo get that code out of here!
ParserInterface* iParser;
@@ -438,7 +448,7 @@
}
//***************************************************
- *sw->getNeighbourhoodEditor()->getStorage() = neighbourhood->toCalculationData();
+// *sw->getNeighbourhoodEditor()->getStorage() = neighbourhood->toCalculationData();
sw->getNeighbourhoodEditor()->setTranslation(0.0f, 0.0f, -10.0f);
sw->getNeighbourhoodEditor()->setSymbolColor(1, QColor(128, 128, 128));
//***************************************************
@@ -651,7 +661,11 @@
// Whole experiment saving
action_Save_experiment->setEnabled(true);
+ // Menus
+ menu_View->setEnabled(true);
+
// Docks unlocking
+ baseDock->setEnabled(true);
dock3D->setEnabled(true);
dock2D->setEnabled(true);
dock1D->setEnabled(true);
@@ -1037,24 +1051,51 @@
QByteArray MainWindow::serialize()
{
- /// @todo wait for CalculationData toXml method and serialize using XML
- QByteArray result, data_portion;
- QDataStream ds(&result, QIODevice::WriteOnly);
+ QDomDocument doc;
+ QDomDocument *element;
+ QDomElement root;
- // Neighbourhood
- data_portion = neighbourhood->toXmlString().toAscii();
- ds << (qint32)data_portion.size();
- ds.writeRawData(data_portion.data(), (int)data_portion.size());
+ // Creating root
+ root = doc.createElement("Experiment");
+ root.setAttribute("iterations", iteration);
- // LocalFunction
- data_portion = local_function->toXmlString().toAscii();
- ds << (qint32)data_portion.size();
- ds.writeRawData(data_portion.data(), (int)data_portion.size());
+ // Try to parse Neighbourhood
+ element = new QDomDocument();
+ if(!element->setContent(neighbourhood->toXmlString()))
+ {
+ qDebug(tr("Internal error: unable to serialize Neighbourhood.").toAscii());
+ return QByteArray();
+ }
+ root.appendChild(*element);
- // CalculationData
- /// @todo write CalculationData serialization
+ // Try serializing Local Function
+ element = new QDomDocument();
+ if (!element->setContent(local_function->toXmlString()))
+ {
+ qDebug(tr("Internal error: unable to serialize Local Function.").toAscii());
+ return QByteArray();
+ }
+ root.appendChild(*element);
- return result;
+ // Now the hardest part - serializing calculation data history
+ for (int i = 0; i < iteration+1; i++)
+ {
+ element = new QDomDocument();
+ if (!element->setContent(data[i]->toXmlString()))
+ {
+ qDebug(tr("Internal error: unable to serialize Calculation Data in the %1th iteration.")
+ .arg(i)
+ .toAscii()
+ );
+ return QByteArray();
+ }
+
+ root.appendChild(*element);
+ }
+
+ doc.appendChild(root);
+
+ return doc.toByteArray();
}
void MainWindow::deserialize(QByteArray content)
Modified: trunk/qcell/visgui/MainWindow.h
===================================================================
--- trunk/qcell/visgui/MainWindow.h 2007-01-24 16:23:56 UTC (rev 250)
+++ trunk/qcell/visgui/MainWindow.h 2007-01-24 17:06:29 UTC (rev 251)
@@ -85,6 +85,7 @@
QLCDNumber* iterationLCD;
QSlider* delaySlider;
QDoubleSpinBox* delaySpinBox;
+ QCheckBox* world_check, *neighbourhood_check, *local_function_check;
QMap<QString, ParserInterface*> neighbourhood_parsers;
QMap<QString, ParserInterface*> function_parsers;
QMap<QString, ParserInterface*> world_parsers;
Modified: trunk/qcell/visgui/MainWindow.ui
===================================================================
--- trunk/qcell/visgui/MainWindow.ui 2007-01-24 16:23:56 UTC (rev 250)
+++ trunk/qcell/visgui/MainWindow.ui 2007-01-24 17:06:29 UTC (rev 251)
@@ -56,6 +56,9 @@
<addaction name="action_About" />
</widget>
<widget class="QMenu" name="menu_View" >
+ <property name="enabled" >
+ <bool>false</bool>
+ </property>
<property name="title" >
<string>&View</string>
</property>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|