|
From: <dhu...@us...> - 2007-01-23 18:36:38
|
Revision: 237
http://svn.sourceforge.net/qcell/?rev=237&view=rev
Author: dhubleizh
Date: 2007-01-23 10:36:35 -0800 (Tue, 23 Jan 2007)
Log Message:
-----------
- RuleProperties dialog to setup symbol and color
- ElementalRules widget is able to set everything now
Modified Paths:
--------------
trunk/qcell/basesources/ElementalRules.cpp
trunk/qcell/visgui/ElementalRulesWidget.cpp
trunk/qcell/visgui/ElementalRulesWidget.h
trunk/qcell/visgui/ExperimentSetup.cpp
trunk/qcell/visgui/MainWindow.cpp
trunk/qcell/visgui/visgui.pro
Added Paths:
-----------
trunk/qcell/visgui/RuleProperties.cpp
trunk/qcell/visgui/RuleProperties.h
trunk/qcell/visgui/RulePropertiesDialog.ui
Modified: trunk/qcell/basesources/ElementalRules.cpp
===================================================================
--- trunk/qcell/basesources/ElementalRules.cpp 2007-01-23 10:21:09 UTC (rev 236)
+++ trunk/qcell/basesources/ElementalRules.cpp 2007-01-23 18:36:35 UTC (rev 237)
@@ -6,7 +6,6 @@
*/
#include "ElementalRules.h"
-#include <QDebug>
ElementalRules::ElementalRules()
: QObject()
@@ -103,7 +102,6 @@
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 10:21:09 UTC (rev 236)
+++ trunk/qcell/visgui/ElementalRulesWidget.cpp 2007-01-23 18:36:35 UTC (rev 237)
@@ -11,13 +11,17 @@
ElementalRulesWidget::ElementalRulesWidget()
{
setupUi(this);
- rulesTree->setColumnCount(2);
+ rulesTree->setColumnCount(3);
QStringList labels;
- labels << tr("Rule") << tr("Occur");
+ labels << tr("Rule") << tr("Symbol") << tr("Coordinates");
rulesTree->setHeaderLabels(labels);
+ rulesTree->resizeColumnToContents(1);
connect(rulesTree, SIGNAL(itemSelectionChanged()),
this, SLOT(selectionChanged())
);
+ connect(rulesTree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)),
+ this, SLOT(ruleDoubleClicked(QTreeWidgetItem*, int))
+ );
}
void ElementalRulesWidget::addRule(int id, QVector<int> neighbrous, int result, QVector<int> coordinates)
@@ -25,14 +29,18 @@
// Values to be added
QStringList values;
- values << QString();
+ values
+ << QString()
+ << QString();
// Add coordinates
values << parseCoordinates(coordinates);
// Add top-level id
- QStringList rule(QString::number(id));
- rule <<
- QString("%1 => %2").arg(parseCoordinates(neighbrous)).arg(QString::number(result));
+ QStringList rule;
+ rule
+ << QString::number(id)
+ << QString()
+ << QString("%1 => %2").arg(parseCoordinates(neighbrous)).arg(QString::number(result));
QTreeWidgetItem* item = new QTreeWidgetItem(rule);
item->addChild(new QTreeWidgetItem(values));
rulesTree->addTopLevelItem(item);
@@ -41,8 +49,11 @@
void ElementalRulesWidget::addOccurance(int id, QVector<int> coordinates)
{
QTreeWidgetItem* item = rulesTree->findItems( QString::number(id), Qt::MatchExactly).first();
- QStringList values("");
- values << parseCoordinates(coordinates);
+ QStringList values;
+ values
+ << QString()
+ << QString()
+ << parseCoordinates(coordinates);
item->addChild(new QTreeWidgetItem(values));
}
@@ -104,4 +115,39 @@
QWidget::hide();
}
+void ElementalRulesWidget::ruleDoubleClicked(QTreeWidgetItem* item, int column)
+{
+ RuleProperties rp;
+ QTableWidgetItem* field;
+ // Rule number
+ field = new QTableWidgetItem(QString(item->text(0)));
+ field->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
+ rp.rulePropertiesTable->setItem(0, 0, field);
+ // Symbol
+ field = new QTableWidgetItem(QString(item->text(1)));
+ rp.rulePropertiesTable->setItem(0, 1, field);
+ // Colour
+ field = new QTableWidgetItem();
+ field->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
+ field->setBackground(item->background(1));
+ rp.rulePropertiesTable->setItem(0, 2, field);
+ // Actual rule
+ field = new QTableWidgetItem(QString(item->text(2)));
+ field->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
+ rp.rulePropertiesTable->setItem(0, 3, field);
+
+ // Make it look good
+ rp.rulePropertiesTable->resizeColumnsToContents();
+
+ // Finally if the dialog is accepted, set the resulg
+ // in the tree
+ if (rp.exec() == QDialog::Accepted)
+ {
+ item->setText(1, rp.rulePropertiesTable->item(0, 1)->text());
+ QColor color = rp.rulePropertiesTable->item(0, 2)->background().color();
+ item->setBackground(1, QBrush(color));
+ item->setTextAlignment(1, Qt::AlignCenter);
+ }
+}
+
Modified: trunk/qcell/visgui/ElementalRulesWidget.h
===================================================================
--- trunk/qcell/visgui/ElementalRulesWidget.h 2007-01-23 10:21:09 UTC (rev 236)
+++ trunk/qcell/visgui/ElementalRulesWidget.h 2007-01-23 18:36:35 UTC (rev 237)
@@ -12,7 +12,9 @@
#include <QDockWidget>
#include <QStringList>
#include <QTreeWidgetItem>
+#include <QTableWidgetItem>
#include "ui_ElementalRulesWidget.h"
+#include "RuleProperties.h"
class ElementalRulesWidget: public QWidget, public Ui::ElementalRulesForm
{
@@ -24,12 +26,12 @@
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);
void addOccurance(int id, QVector<int> coordinates);
void selectionChanged();
+ void ruleDoubleClicked(QTreeWidgetItem* item, int column);
protected:
QString parseCoordinates(QVector<int> coordinates);
public:
Modified: trunk/qcell/visgui/ExperimentSetup.cpp
===================================================================
--- trunk/qcell/visgui/ExperimentSetup.cpp 2007-01-23 10:21:09 UTC (rev 236)
+++ trunk/qcell/visgui/ExperimentSetup.cpp 2007-01-23 18:36:35 UTC (rev 237)
@@ -10,6 +10,7 @@
ExperimentSetup::ExperimentSetup()
{
setupUi(this);
+ speedBox->hide();
connect(delaySlider, SIGNAL(valueChanged(int)),
SLOT(sliderChanged(int))
);
Modified: trunk/qcell/visgui/MainWindow.cpp
===================================================================
--- trunk/qcell/visgui/MainWindow.cpp 2007-01-23 10:21:09 UTC (rev 236)
+++ trunk/qcell/visgui/MainWindow.cpp 2007-01-23 18:36:35 UTC (rev 237)
@@ -32,7 +32,13 @@
statusBar()->addPermanentWidget(tmp_label);
statusBar()->addPermanentWidget(delaySlider);
statusBar()->addPermanentWidget(delaySpinBox);
- statusBar()->addPermanentWidget(new QLabel("ms"));
+// statusBar()->addPermanentWidget(new QLabel("ms"));
+
+ /// @todo I won't make it in time, so commenting this out
+ delaySlider->hide();
+ delaySpinBox->hide();
+ tmp_label->hide();
+
// Interconnect both widgets - change in one will change the other as well
connect(delaySlider, SIGNAL(valueChanged(int)),
SLOT(sliderChanged(int))
@@ -422,7 +428,7 @@
// We should only work when the rules list is visible, as it slows
// the calculation considerably
- connect(((ElementalRulesWidget*)elemental_dock->widget()), SIGNAL(visible(bool)),
+ connect(elemental_dock->toggleViewAction(), SIGNAL(toggled(bool)),
elemental_rules, SLOT(work(bool))
);
Added: trunk/qcell/visgui/RuleProperties.cpp
===================================================================
--- trunk/qcell/visgui/RuleProperties.cpp (rev 0)
+++ trunk/qcell/visgui/RuleProperties.cpp 2007-01-23 18:36:35 UTC (rev 237)
@@ -0,0 +1,26 @@
+/**@file RuleProperties.cpp
+ * @author czarny
+ * @date
+ * Created: wto 23 sty 2007 17:36:11 CET \n
+ * Last Update: wto 23 sty 2007 17:36:11 CET
+ */
+
+#include "RuleProperties.h"
+
+RuleProperties::RuleProperties()
+ : QDialog(), ElementalRuleSetupDialog()
+{
+ setupUi(this);
+ connect(rulePropertiesTable, SIGNAL(itemDoubleClicked(QTableWidgetItem*)),
+ this, SLOT(colourDoubleClicked(QTableWidgetItem*))
+ );
+}
+
+void RuleProperties::colourDoubleClicked(QTableWidgetItem* item)
+{
+ if (item->column() == 2)
+ {
+ item->setBackground(QColorDialog::getColor(Qt::white, this));
+ }
+}
+
Added: trunk/qcell/visgui/RuleProperties.h
===================================================================
--- trunk/qcell/visgui/RuleProperties.h (rev 0)
+++ trunk/qcell/visgui/RuleProperties.h 2007-01-23 18:36:35 UTC (rev 237)
@@ -0,0 +1,26 @@
+/**@file RuleProperties.h
+ * @author czarny
+ * @date
+ * Created: wto 23 sty 2007 17:34:54 CET \n
+ * Last Update: wto 23 sty 2007 17:34:54 CET
+ * @brief Minimal dialog to set up ElementalRules properties
+ */
+
+#ifndef __RULEPROPERTIES_H__
+#define __RULEPROPERTIES_H__
+
+#include "ui_RulePropertiesDialog.h"
+#include <QDialog>
+#include <QColorDialog>
+
+class RuleProperties: public QDialog, public Ui::ElementalRuleSetupDialog
+{
+ Q_OBJECT
+public slots:
+ void colourDoubleClicked(QTableWidgetItem* item);
+public:
+ RuleProperties();
+
+};
+
+#endif // __RULEPROPERTIES_H__
Added: trunk/qcell/visgui/RulePropertiesDialog.ui
===================================================================
--- trunk/qcell/visgui/RulePropertiesDialog.ui (rev 0)
+++ trunk/qcell/visgui/RulePropertiesDialog.ui 2007-01-23 18:36:35 UTC (rev 237)
@@ -0,0 +1,141 @@
+<ui version="4.0" >
+ <class>ElementalRuleSetupDialog</class>
+ <widget class="QDialog" name="ElementalRuleSetupDialog" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Rule properties</string>
+ </property>
+ <layout class="QVBoxLayout" >
+ <property name="margin" >
+ <number>9</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="label" >
+ <property name="text" >
+ <string>Choose a symbol or colour to represent the rule with.</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>382</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QTableWidget" name="rulePropertiesTable" >
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="rowCount" >
+ <number>1</number>
+ </property>
+ <property name="columnCount" >
+ <number>4</number>
+ </property>
+ <row/>
+ <column>
+ <property name="text" >
+ <string>Rule nr</string>
+ </property>
+ </column>
+ <column>
+ <property name="text" >
+ <string>Symbol</string>
+ </property>
+ </column>
+ <column>
+ <property name="text" >
+ <string>Colour</string>
+ </property>
+ </column>
+ <column>
+ <property name="text" >
+ <string>Rule</string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ <item>
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>20</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons" >
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>ElementalRuleSetupDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>ElementalRuleSetupDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
Modified: trunk/qcell/visgui/visgui.pro
===================================================================
--- trunk/qcell/visgui/visgui.pro 2007-01-23 10:21:09 UTC (rev 236)
+++ trunk/qcell/visgui/visgui.pro 2007-01-23 18:36:35 UTC (rev 237)
@@ -9,6 +9,7 @@
AboutDialog.ui \
ExperimentSetup.ui \
ElementalRulesWidget.ui \
+ RulePropertiesDialog.ui \
../baseheaders/simulationwindow.ui \
../baseheaders/basetools.ui \
../baseheaders/view3dtools.ui \
@@ -19,6 +20,7 @@
HEADERS = MainWindow.h \
ExperimentSetup.h \
ElementalRulesWidget.h \
+ RuleProperties.h \
../baseheaders/Client.h \
../baseheaders/ClientInfo.h \
../baseheaders/BaseDataTypes.h \
@@ -42,6 +44,7 @@
MainWindow.cpp \
ExperimentSetup.cpp \
ElementalRulesWidget.cpp \
+ RuleProperties.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.
|