|
From: <dhu...@us...> - 2007-01-23 10:21:11
|
Revision: 236
http://svn.sourceforge.net/qcell/?rev=236&view=rev
Author: dhubleizh
Date: 2007-01-23 02:21:09 -0800 (Tue, 23 Jan 2007)
Log Message:
-----------
- tried to make ER work only on demand
Modified Paths:
--------------
trunk/qcell/baseheaders/ElementalRules.h
trunk/qcell/basesources/ElementalRules.cpp
trunk/qcell/visgui/ElementalRulesWidget.cpp
trunk/qcell/visgui/ElementalRulesWidget.h
trunk/qcell/visgui/MainWindow.cpp
trunk/qcell/visgui/MainWindow.h
trunk/qcell/visgui/MainWindow.ui
Modified: trunk/qcell/baseheaders/ElementalRules.h
===================================================================
--- trunk/qcell/baseheaders/ElementalRules.h 2007-01-23 09:37:16 UTC (rev 235)
+++ trunk/qcell/baseheaders/ElementalRules.h 2007-01-23 10:21:09 UTC (rev 236)
@@ -24,9 +24,11 @@
void possibleRule(QVector<int> coordinates, QVector<int> neighbours, int return_value);
void resetList();
void rulesSelected(QVector<int>);
+ void work(bool flag);
protected:
int neighbours_count;
int index;
+ bool should_work;
QVector<int> return_values;
QVector<QVector<int> > neighbours;
Modified: trunk/qcell/basesources/ElementalRules.cpp
===================================================================
--- trunk/qcell/basesources/ElementalRules.cpp 2007-01-23 09:37:16 UTC (rev 235)
+++ trunk/qcell/basesources/ElementalRules.cpp 2007-01-23 10:21:09 UTC (rev 236)
@@ -6,15 +6,23 @@
*/
#include "ElementalRules.h"
+#include <QDebug>
ElementalRules::ElementalRules()
: QObject()
{
index = 0;
+ should_work = false;
}
void ElementalRules::possibleRule(QVector<int> coordinates, QVector<int> neighbours, int return_value)
{
+ // Only work if the user wants to
+ if (!should_work)
+ {
+ return;
+ }
+
// where do things reside
int value_index, neighbour_index, rule_index;
// Is this a new rule case?
@@ -74,6 +82,12 @@
void ElementalRules::resetList()
{
+ // Only process when the user wants
+ if (!should_work)
+ {
+ return;
+ }
+
/// @todo Actually write this
index = 0;
return_values.clear();
@@ -87,3 +101,9 @@
/// @todo Search the database bout these rules
}
+void ElementalRules::work(bool flag)
+{
+ qDebug() << "Should work: " << flag;
+ should_work = flag;
+}
+
Modified: trunk/qcell/visgui/ElementalRulesWidget.cpp
===================================================================
--- trunk/qcell/visgui/ElementalRulesWidget.cpp 2007-01-23 09:37:16 UTC (rev 235)
+++ trunk/qcell/visgui/ElementalRulesWidget.cpp 2007-01-23 10:21:09 UTC (rev 236)
@@ -63,12 +63,12 @@
void ElementalRulesWidget::resetList()
{
rulesTree->clear();
-// rulesTree->blockSignals(true);
+ rulesTree->setUpdatesEnabled(false);
}
void ElementalRulesWidget::display()
{
-// rulesTree->blockSignals(false);
+ rulesTree->setUpdatesEnabled(true);
// for (int i = 0; i < rulesTree->columnCount(); i++)
// {
// rulesTree->resizeColumnToContents(i);
@@ -86,4 +86,22 @@
emit rulesSelected(rules);
}
+void ElementalRulesWidget::setVisible(bool visible)
+{
+ emit ElementalRulesWidget::visible(visible);
+ QWidget::setVisible(visible);
+}
+void ElementalRulesWidget::show()
+{
+ emit visible(true);
+ QWidget::show();
+}
+
+void ElementalRulesWidget::hide()
+{
+ emit visible(false);
+ QWidget::hide();
+}
+
+
Modified: trunk/qcell/visgui/ElementalRulesWidget.h
===================================================================
--- trunk/qcell/visgui/ElementalRulesWidget.h 2007-01-23 09:37:16 UTC (rev 235)
+++ trunk/qcell/visgui/ElementalRulesWidget.h 2007-01-23 10:21:09 UTC (rev 236)
@@ -18,8 +18,13 @@
{
Q_OBJECT
signals:
+ void visible(bool visible);
void rulesSelected(QVector<int> rules);
public slots:
+ void setVisible(bool visible);
+ void show();
+ void hide();
+public slots:
void resetList();
void display();
void addRule(int id, QVector<int> neighbours, int result, QVector<int> coordinates);
Modified: trunk/qcell/visgui/MainWindow.cpp
===================================================================
--- trunk/qcell/visgui/MainWindow.cpp 2007-01-23 09:37:16 UTC (rev 235)
+++ trunk/qcell/visgui/MainWindow.cpp 2007-01-23 10:21:09 UTC (rev 236)
@@ -61,7 +61,13 @@
// We don't want it appear at the beginning
elemental_dock->hide();
elemental_dock->setWidget(new ElementalRulesWidget());
+ elemental_dock->setWindowTitle(tr("Elemental rules"));
+
addDockWidget(Qt::LeftDockWidgetArea, elemental_dock);
+ // We want to be able to show or hide the widget from View menu
+ QAction* elemental_action = elemental_dock->toggleViewAction();
+ elemental_action->setText("&" + elemental_dock->windowTitle());
+ menu_View->addAction(elemental_action);
foreach(QObject* plugin, QPluginLoader::staticInstances())
{
@@ -410,10 +416,16 @@
);
// Pass rules selection from GUI to engine
- connect(((ElementalRulesWidget*)elemental_dock->widget()), SIGNAL(rulesSelected()),
+ connect(((ElementalRulesWidget*)elemental_dock->widget()), SIGNAL(rulesSelected(QVector<int>)),
elemental_rules, SLOT(rulesSelected(QVector<int>))
);
+ // We should only work when the rules list is visible, as it slows
+ // the calculation considerably
+ connect(((ElementalRulesWidget*)elemental_dock->widget()), SIGNAL(visible(bool)),
+ elemental_rules, SLOT(work(bool))
+ );
+
iteration=0;
// visualization update
@@ -983,15 +995,3 @@
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-23 09:37:16 UTC (rev 235)
+++ trunk/qcell/visgui/MainWindow.h 2007-01-23 10:21:09 UTC (rev 236)
@@ -66,8 +66,6 @@
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;
Modified: trunk/qcell/visgui/MainWindow.ui
===================================================================
--- trunk/qcell/visgui/MainWindow.ui 2007-01-23 09:37:16 UTC (rev 235)
+++ trunk/qcell/visgui/MainWindow.ui 2007-01-23 10:21:09 UTC (rev 236)
@@ -93,7 +93,6 @@
<property name="title" >
<string>&View</string>
</property>
- <addaction name="action_Elemental_rules" />
</widget>
<addaction name="menu_File" />
<addaction name="menu_View" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|