|
From: <dhu...@us...> - 2007-01-22 15:01:10
|
Revision: 229
http://svn.sourceforge.net/qcell/?rev=229&view=rev
Author: dhubleizh
Date: 2007-01-22 07:01:07 -0800 (Mon, 22 Jan 2007)
Log Message:
-----------
- ElementalRules limited only to one iteration
- selecting rules handled
- a lot of tweaking to optimize the flow
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/ElementalRulesWidget.cpp
trunk/qcell/visgui/ElementalRulesWidget.h
trunk/qcell/visgui/ElementalRulesWidget.ui
trunk/qcell/visgui/MainWindow.cpp
Modified: trunk/qcell/baseheaders/Calculator.h
===================================================================
--- trunk/qcell/baseheaders/Calculator.h 2007-01-21 23:35:58 UTC (rev 228)
+++ trunk/qcell/baseheaders/Calculator.h 2007-01-22 15:01:07 UTC (rev 229)
@@ -71,6 +71,8 @@
void setupSpace(void);
signals:
+ void calculationBegin();
+ void calculationEnd();
void calculated(QVector<int> coordinates, QVector<int> arguments, int result);
void freeze(Calculator *calculator, int index);
Modified: trunk/qcell/baseheaders/ElementalRules.h
===================================================================
--- trunk/qcell/baseheaders/ElementalRules.h 2007-01-21 23:35:58 UTC (rev 228)
+++ trunk/qcell/baseheaders/ElementalRules.h 2007-01-22 15:01:07 UTC (rev 229)
@@ -22,6 +22,8 @@
void newOccurance(int id, QVector<int> coordinates);
public slots:
void possibleRule(QVector<int> coordinates, QVector<int> neighbours, int return_value);
+ void resetList();
+ void rulesSelected(QVector<int>);
protected:
int neighbours_count;
int index;
Modified: trunk/qcell/basesources/Calculator.cpp
===================================================================
--- trunk/qcell/basesources/Calculator.cpp 2007-01-21 23:35:58 UTC (rev 228)
+++ trunk/qcell/basesources/Calculator.cpp 2007-01-22 15:01:07 UTC (rev 229)
@@ -79,6 +79,8 @@
}
}
}
+
+ emit calculationEnd();
}
bool Calculator::resizeTempDataBuffer(bool dataCopy, char *dataPointer)
@@ -239,6 +241,7 @@
char temp[8] = {0,0,0,0,0,0,0,0};
int sx = sizeX, sy = sizeY, sz = sizeZ, st = sizeT;
QVector<int> coordinates(dimension, 0);
+ emit calculationBegin();
if(sy==0)
sy=1;
Modified: trunk/qcell/basesources/ElementalRules.cpp
===================================================================
--- trunk/qcell/basesources/ElementalRules.cpp 2007-01-21 23:35:58 UTC (rev 228)
+++ trunk/qcell/basesources/ElementalRules.cpp 2007-01-22 15:01:07 UTC (rev 229)
@@ -72,3 +72,18 @@
rules_mask.insert(rule_index, coordinates);
}
+void ElementalRules::resetList()
+{
+ /// @todo Actually write this
+ index = 0;
+ return_values.clear();
+ neighbours.clear();
+ rules.clear();
+ rules_mask.clear();
+}
+
+void ElementalRules::rulesSelected(QVector<int>)
+{
+ /// @todo Search the database bout these rules
+}
+
Modified: trunk/qcell/visgui/ElementalRulesWidget.cpp
===================================================================
--- trunk/qcell/visgui/ElementalRulesWidget.cpp 2007-01-21 23:35:58 UTC (rev 228)
+++ trunk/qcell/visgui/ElementalRulesWidget.cpp 2007-01-22 15:01:07 UTC (rev 229)
@@ -6,6 +6,7 @@
*/
#include "ElementalRulesWidget.h"
+#include <QDebug>
ElementalRulesWidget::ElementalRulesWidget()
{
@@ -14,6 +15,9 @@
QStringList labels;
labels << tr("Rule") << tr("Occur");
rulesTree->setHeaderLabels(labels);
+ connect(rulesTree, SIGNAL(itemSelectionChanged()),
+ this, SLOT(selectionChanged())
+ );
}
void ElementalRulesWidget::addRule(int id, QVector<int> neighbrous, int result, QVector<int> coordinates)
@@ -56,3 +60,30 @@
return coord_string.append(')');
}
+void ElementalRulesWidget::resetList()
+{
+ rulesTree->clear();
+// rulesTree->blockSignals(true);
+}
+
+void ElementalRulesWidget::display()
+{
+// rulesTree->blockSignals(false);
+// for (int i = 0; i < rulesTree->columnCount(); i++)
+// {
+// rulesTree->resizeColumnToContents(i);
+// }
+}
+
+void ElementalRulesWidget::selectionChanged()
+{
+ QVector<int> rules;
+ foreach(QTreeWidgetItem* item, rulesTree->selectedItems())
+ {
+ rules.append(item->text(0).toInt());
+ }
+
+ emit rulesSelected(rules);
+}
+
+
Modified: trunk/qcell/visgui/ElementalRulesWidget.h
===================================================================
--- trunk/qcell/visgui/ElementalRulesWidget.h 2007-01-21 23:35:58 UTC (rev 228)
+++ trunk/qcell/visgui/ElementalRulesWidget.h 2007-01-22 15:01:07 UTC (rev 229)
@@ -17,11 +17,16 @@
class ElementalRulesWidget: public QWidget, public Ui::ElementalRulesForm
{
Q_OBJECT
-protected:
- QString parseCoordinates(QVector<int> coordinates);
+signals:
+ void rulesSelected(QVector<int> rules);
public slots:
+ void resetList();
+ void display();
void addRule(int id, QVector<int> neighbours, int result, QVector<int> coordinates);
void addOccurance(int id, QVector<int> coordinates);
+ void selectionChanged();
+protected:
+ QString parseCoordinates(QVector<int> coordinates);
public:
ElementalRulesWidget();
Modified: trunk/qcell/visgui/ElementalRulesWidget.ui
===================================================================
--- trunk/qcell/visgui/ElementalRulesWidget.ui 2007-01-21 23:35:58 UTC (rev 228)
+++ trunk/qcell/visgui/ElementalRulesWidget.ui 2007-01-22 15:01:07 UTC (rev 229)
@@ -21,19 +21,23 @@
</property>
<item>
<widget class="QTreeWidget" name="rulesTree" >
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="selectionBehavior" >
+ <enum>QAbstractItemView::SelectRows</enum>
+ </property>
+ <property name="horizontalScrollMode" >
+ <enum>QAbstractItemView::ScrollPerItem</enum>
+ </property>
<property name="columnCount" >
- <number>2</number>
+ <number>0</number>
</property>
- <column>
- <property name="text" >
- <string>1</string>
- </property>
- </column>
- <column>
- <property name="text" >
- <string>1</string>
- </property>
- </column>
</widget>
</item>
</layout>
Modified: trunk/qcell/visgui/MainWindow.cpp
===================================================================
--- trunk/qcell/visgui/MainWindow.cpp 2007-01-21 23:35:58 UTC (rev 228)
+++ trunk/qcell/visgui/MainWindow.cpp 2007-01-22 15:01:07 UTC (rev 229)
@@ -380,9 +380,28 @@
*(CalculationData*)&calc = *data.last();
// Creating elemental rules accroding to DATA_TYPE
elemental_rules = new ElementalRules;
+
+ // Pass the calculation result to rules selection
connect(&calc, SIGNAL(calculated(QVector<int>, QVector<int>, int)),
elemental_rules, SLOT(possibleRule(QVector<int>, QVector<int>, int))
);
+
+ // Notify things connected with rules to reset the list
+ // as we hold only one iteration rules
+ connect(&calc, SIGNAL(calculationBegin()),
+ elemental_rules, SLOT(resetList())
+ );
+ connect(&calc, SIGNAL(calculationBegin()),
+ ((ElementalRulesWidget*)elemental_dock->widget()), SLOT(resetList())
+ );
+
+ // Display the results (there is no need to refresh the table before
+ // the end of one iteration)
+ connect(&calc, SIGNAL(calculationEnd()),
+ ((ElementalRulesWidget*)elemental_dock->widget()), SLOT(display())
+ );
+
+ // Notify the GUI 'bout new items
connect(elemental_rules, SIGNAL(newRule(int, QVector<int>, int, QVector<int>)),
((ElementalRulesWidget*)elemental_dock->widget()), SLOT(addRule(int, QVector<int>, int, QVector<int>))
);
@@ -390,6 +409,11 @@
((ElementalRulesWidget*)elemental_dock->widget()), SLOT(addOccurance(int, QVector<int>))
);
+ // Pass rules selection from GUI to engine
+ connect(((ElementalRulesWidget*)elemental_dock->widget()), SIGNAL(rulesSelected()),
+ elemental_rules, SLOT(rulesSelected(QVector<int>))
+ );
+
iteration=0;
// visualization update
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|