|
From: <dhu...@us...> - 2007-01-21 17:21:17
|
Revision: 219
http://svn.sourceforge.net/qcell/?rev=219&view=rev
Author: dhubleizh
Date: 2007-01-21 09:21:10 -0800 (Sun, 21 Jan 2007)
Log Message:
-----------
- new ElementalRulesWidget to display rules
- MainWindow uses the new widget
- Calculator signals bout results
Modified Paths:
--------------
trunk/qcell/baseheaders/Calculator.h
trunk/qcell/baseheaders/ElementalRules.h
trunk/qcell/basesources/Calculator.cpp
trunk/qcell/basesources/ElementalRules.cpp
trunk/qcell/visgui/MainWindow.cpp
trunk/qcell/visgui/MainWindow.h
trunk/qcell/visgui/MainWindow.ui
trunk/qcell/visgui/visgui.pro
Added Paths:
-----------
trunk/qcell/visgui/ElementalRulesWidget.cpp
trunk/qcell/visgui/ElementalRulesWidget.h
trunk/qcell/visgui/ElementalRulesWidget.ui
Modified: trunk/qcell/baseheaders/Calculator.h
===================================================================
--- trunk/qcell/baseheaders/Calculator.h 2007-01-21 13:41:18 UTC (rev 218)
+++ trunk/qcell/baseheaders/Calculator.h 2007-01-21 17:21:10 UTC (rev 219)
@@ -55,6 +55,8 @@
protected slots:
void setupSpace(void);
+signals:
+ void calculated(QVector<int> coordinates, QVector<int> arguments, int result);
};
#endif
Modified: trunk/qcell/baseheaders/ElementalRules.h
===================================================================
--- trunk/qcell/baseheaders/ElementalRules.h 2007-01-21 13:41:18 UTC (rev 218)
+++ trunk/qcell/baseheaders/ElementalRules.h 2007-01-21 17:21:10 UTC (rev 219)
@@ -17,6 +17,9 @@
class ElementalRules : public QObject
{
Q_OBJECT
+signals:
+ void newRule(int id, QVector<int> coordinates);
+ void newOccurance(int id, QVector<int> coordinates);
public slots:
void possibleRule(QVector<int> coordinates, QVector<int> neighbours, int result);
protected:
Modified: trunk/qcell/basesources/Calculator.cpp
===================================================================
--- trunk/qcell/basesources/Calculator.cpp 2007-01-21 13:41:18 UTC (rev 218)
+++ trunk/qcell/basesources/Calculator.cpp 2007-01-21 17:21:10 UTC (rev 219)
@@ -225,6 +225,7 @@
int counter = 0;
char temp[8] = {0,0,0,0,0,0,0,0};
int sx = sizeX, sy = sizeY, sz = sizeZ, st = sizeT;
+ QVector<int> coordinates(4, 0);
if(sy==0)
sy=1;
@@ -239,12 +240,16 @@
for(int t=0;t<st;++t)
{
+ coordinates[3] = t;
for(int z=0;z<sz;++z)
{
+ coordinates[2] = z;
for(int y=0;y<sy;++y)
{
+ coordinates[1] = y;
for(int x=0;x<sx;++x)
{
+ coordinates[0] = x;
neighbourhood->resolveValues(tempData + (x - minBorder[0]) + ((y - minBorder[1]) * tempDataSize[0]) + (z - minBorder[2]) * (tempDataSize[0] * tempDataSize[1]) + (t - minBorder[3]) * (tempDataSize[0] * tempDataSize[1] * tempDataSize[2]) * dataSize);
switch(dataType)
{
@@ -262,7 +267,8 @@
*((double *)temp) = localfunction->resolve(neighbourhood->valuesToVector_d());
break;
}
-
+
+ emit calculated(coordinates, neighbourhood->valuesToVector_i(), (int)temp);
memcpy(data + counter, temp, dataSize);
counter += dataSize;
}
Modified: trunk/qcell/basesources/ElementalRules.cpp
===================================================================
--- trunk/qcell/basesources/ElementalRules.cpp 2007-01-21 13:41:18 UTC (rev 218)
+++ trunk/qcell/basesources/ElementalRules.cpp 2007-01-21 17:21:10 UTC (rev 219)
@@ -18,12 +18,12 @@
// where do things reside
int value_index, neighbour_index, rule_index;
// Is this a new rule case?
- bool newRule = false;
+ bool isNewRule = false;
// search if we haven't already have this return value
// or this neighbours configuration in databse
value_index = return_values.indexOf(return_value);
- this->neighbours.indexOf(neighbours);
+ neighbour_index = this->neighbours.indexOf(neighbours);
// if we don't have the return vale, let's add it
// and modify the value_index accordingly
@@ -31,7 +31,7 @@
{
return_values.append(return_value);
value_index = return_values.count() - 1;
- newRule = true;
+ isNewRule = true;
}
// same thing with neighbours
@@ -39,16 +39,19 @@
{
this->neighbours.append(neighbours);
neighbour_index = this->neighbours.count() - 1;
- newRule = true;
+ isNewRule = true;
}
// If neighbours or return_value is new
- if (newRule)
+ if (isNewRule)
{
// bumb the index
rule_index = ++index;
// and insert a new rule
rules.insert(rule_index, rulePair(&return_values[value_index], &this->neighbours[neighbour_index]));
+
+ // Notify the GUI
+ emit newRule(rule_index, coordinates);
}
// If both were present
else
@@ -59,10 +62,14 @@
&this->neighbours[this->neighbours.indexOf(neighbours)]
)
);
+
+ // Notify the GUI
+ emit newOccurance(rule_index, coordinates);
}
// At the end we note the coordinates
rules_mask.insert(rule_index, coordinates);
+ emit
}
void ElementalRules::possibleRule(QVector<int> coordinates, QVector<int> neighbours, int result)
Added: trunk/qcell/visgui/ElementalRulesWidget.cpp
===================================================================
--- trunk/qcell/visgui/ElementalRulesWidget.cpp (rev 0)
+++ trunk/qcell/visgui/ElementalRulesWidget.cpp 2007-01-21 17:21:10 UTC (rev 219)
@@ -0,0 +1,57 @@
+/**@file ElementalRulesWidget.cpp
+ * @author czarny
+ * @date
+ * Created: nie 21 sty 2007 16:48:37 CET \n
+ * Last Update: nie 21 sty 2007 16:48:37 CET
+ */
+
+#include "ElementalRulesWidget.h"
+
+ElementalRulesWidget::ElementalRulesWidget()
+{
+ setupUi(this);
+ treeWidget->setColumnCount(2);
+ QStringList labels;
+ labels << tr("Rule") << tr("Occur");
+ treeWidget->setHeaderLabels(labels);
+}
+
+void ElementalRulesWidget::addRule(int id, QVector<int> coordinates)
+{
+ // Values to be added
+ QStringList values;
+
+ values << "";
+ // Add coordinates
+ values << parserCoordinates(coordinates);
+
+ // Add top-level id
+ QTreeWidgetItem* item = new QTreeWidgetItem(QStringList(QString::number(id)));
+ item->addChild(new QTreeWidgetItem(values));
+ treeWidget->addTopLevelItem(item);
+}
+
+void ElementalRulesWidget::addOccurance(int id, QVector<int> coordinates)
+{
+ QTreeWidgetItem* item = treeWidget->findItems(
+ QString::number(id),
+ Qt::MatchExactly)
+ .first();
+
+ item->addChild(new QTreeWidgetItem(QStringList(parserCoordinates(coordinates))));
+}
+
+QString ElementalRulesWidget::parserCoordinates(QVector<int> coordinates)
+{
+ // Construct a string with coordinates
+ // (x, y, z, t)
+ QString coord_string('(');
+ foreach(int value, coordinates)
+ {
+ coord_string.append(QString::number(value)+',');
+ }
+ // Remove pending `,'
+ coord_string.chop(1);
+ return coord_string.append(')');
+}
+
Added: trunk/qcell/visgui/ElementalRulesWidget.h
===================================================================
--- trunk/qcell/visgui/ElementalRulesWidget.h (rev 0)
+++ trunk/qcell/visgui/ElementalRulesWidget.h 2007-01-21 17:21:10 UTC (rev 219)
@@ -0,0 +1,29 @@
+/**@file ElementalRulesWidget.h
+ * @author czarny
+ * @date
+ * Created: nie 21 sty 2007 16:44:42 CET \n
+ * Last Update: nie 21 sty 2007 16:44:42 CET
+ * @brief Widget containing elemantal rules list
+ */
+
+#ifndef __ELEMENTALRULESWIDGET_H__
+#define __ELEMENTALRULESWIDGET_H__
+
+#include "ui_ElementalRules.h"
+#include <QDockWidget>
+#include <QStringList>
+
+class ElementalRulesWidget: public QWidget, public Ui::ElementalRulesForm
+{
+ Q_OBJECT
+protected:
+ QString parserCoordinates(QVector<int> coordinates);
+public slots:
+ void addRule(int id, QVector<int> coordinates);
+ void addOccurance(int id, QVector<int> coordinates);
+public:
+ ElementalRulesWidget();
+
+};
+
+#endif // __ELEMENTALRULESWIDGET_H__
Added: trunk/qcell/visgui/ElementalRulesWidget.ui
===================================================================
--- trunk/qcell/visgui/ElementalRulesWidget.ui (rev 0)
+++ trunk/qcell/visgui/ElementalRulesWidget.ui 2007-01-21 17:21:10 UTC (rev 219)
@@ -0,0 +1,43 @@
+<ui version="4.0" >
+ <class>ElementalRulesForm</class>
+ <widget class="QWidget" name="ElementalRulesForm" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>467</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Form</string>
+ </property>
+ <layout class="QVBoxLayout" >
+ <property name="margin" >
+ <number>9</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <widget class="QTreeWidget" name="rulesTree" >
+ <property name="columnCount" >
+ <number>2</number>
+ </property>
+ <column>
+ <property name="text" >
+ <string>1</string>
+ </property>
+ </column>
+ <column>
+ <property name="text" >
+ <string>1</string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
Modified: trunk/qcell/visgui/MainWindow.cpp
===================================================================
--- trunk/qcell/visgui/MainWindow.cpp 2007-01-21 13:41:18 UTC (rev 218)
+++ trunk/qcell/visgui/MainWindow.cpp 2007-01-21 17:21:10 UTC (rev 219)
@@ -56,6 +56,22 @@
ParserInterface* iParser;
QStringList parser_types, file_types;
+ elemental_dock = new QDockWidget(this);
+ elemental_dock->setWidget(new ElementalRulesWidget());
+ addDockWidget(Qt::LeftDockWidgetArea, elemental_dock);
+ elemental_dock->hide();
+// // Setting up content
+// QWidget* w = new QWidget();
+// Ui::elemntalRulesForm ui;
+// ui.setupUi(w);
+//
+// // Creating new dock widget
+// elemental_dock = new QDockWidget();
+// elemental_dock->setWidget(w);
+//
+// // Place the widget on the lef
+// addDockWidget(Qt::LeftDockWidgetArea, elemental_dock);
+
// We check each static plugin if it is a parser plugin
// and if it is we register each parsing fucntion
// according to supported types and file extensions
@@ -376,7 +392,16 @@
*(CalculationData*)&calc = *data.last();
// Creating elemental rules accroding to DATA_TYPE
elemental_rules = new ElementalRules;
+ connect(&calc, SIGNAL(calculated(QVector<int>, QVector<int>, int)),
+ elemental_rules, SLOT(possibleRule(QVector<int>, QVector<int>, int))
+ );
+ connect(elemental_rules, SIGNAL(newRule(int, QVector<int>)),
+ ((ElementalRulesWidget*)elemental_dock->widget()), SLOT(addRule(int, QVector<int>))
+ );
+
+// void newOccurance(int id, QVector<int> coordinates);
+
iteration=0;
// visualization update
@@ -938,3 +963,15 @@
delaySlider->blockSignals(false);
}
+void MainWindow::on_action_Elemental_rules_toggled(bool checked)
+{
+ if (checked)
+ {
+ elemental_dock->show();
+ }
+ else
+ {
+ elemental_dock->hide();
+ }
+}
+
Modified: trunk/qcell/visgui/MainWindow.h
===================================================================
--- trunk/qcell/visgui/MainWindow.h 2007-01-21 13:41:18 UTC (rev 218)
+++ trunk/qcell/visgui/MainWindow.h 2007-01-21 17:21:10 UTC (rev 219)
@@ -12,6 +12,7 @@
#include "ui_MainWindow.h"
#include "ui_AboutDialog.h"
#include "ExperimentSetup.h"
+#include "ElementalRulesWidget.h"
#include "ElementalRules.h"
#include <QPluginLoader>
#include "GenericParserPlugin.h"
@@ -55,6 +56,7 @@
void sliderChanged(int value);
void spinBoxChanged(double value);
+
void update();
/// @todo not here!
void on_action_Forward_activated();
@@ -64,6 +66,8 @@
void on_action_Stop_activated();
void on_action_Restart_activated();
+ void on_action_Elemental_rules_toggled(bool checked);
+
void loadingSuccess(QString filetype);
private:
simulationWindow* sw;
@@ -92,6 +96,7 @@
Calculator calc;
ElementalRules* elemental_rules;
+ QDockWidget* elemental_dock;
QList<CalculationData*> data;
LocalFunction* local_function;
Neighbourhood* neighbourhood;
Modified: trunk/qcell/visgui/MainWindow.ui
===================================================================
--- trunk/qcell/visgui/MainWindow.ui 2007-01-21 13:41:18 UTC (rev 218)
+++ trunk/qcell/visgui/MainWindow.ui 2007-01-21 17:21:10 UTC (rev 219)
@@ -89,7 +89,14 @@
<addaction name="separator" />
<addaction name="action_Quit" />
</widget>
+ <widget class="QMenu" name="menu_View" >
+ <property name="title" >
+ <string>&View</string>
+ </property>
+ <addaction name="action_Elemental_rules" />
+ </widget>
<addaction name="menu_File" />
+ <addaction name="menu_View" />
<addaction name="menu_Experiment" />
<addaction name="menu_Help" />
</widget>
@@ -281,6 +288,14 @@
<string>Saves the whole experiment with history for later continuation.</string>
</property>
</action>
+ <action name="action_Elemental_rules" >
+ <property name="checkable" >
+ <bool>true</bool>
+ </property>
+ <property name="text" >
+ <string>&Elemental rules</string>
+ </property>
+ </action>
</widget>
<resources/>
<connections/>
Modified: trunk/qcell/visgui/visgui.pro
===================================================================
--- trunk/qcell/visgui/visgui.pro 2007-01-21 13:41:18 UTC (rev 218)
+++ trunk/qcell/visgui/visgui.pro 2007-01-21 17:21:10 UTC (rev 219)
@@ -8,14 +8,17 @@
FORMS = MainWindow.ui \
AboutDialog.ui \
ExperimentSetup.ui \
+ ElementalRulesWidget.ui \
../baseheaders/simulationwindow.ui \
../baseheaders/basetools.ui \
../baseheaders/view3dtools.ui \
../baseheaders/view2dtexttools.ui \
../baseheaders/view1dtexttools.ui \
../baseheaders/functiontable.ui
+
HEADERS = MainWindow.h \
ExperimentSetup.h \
+ ElementalRulesWidget.h \
../baseheaders/Client.h \
../baseheaders/ClientInfo.h \
../baseheaders/BaseDataTypes.h \
@@ -38,6 +41,7 @@
main.cpp \
MainWindow.cpp \
ExperimentSetup.cpp \
+ ElementalRulesWidget.cpp \
../basesources/Client.cpp \
../basesources/ClientInfo.cpp \
../basesources/Neighbourhood.cpp \
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|