|
From: <dhu...@us...> - 2007-01-10 19:57:16
|
Revision: 141
http://svn.sourceforge.net/qcell/?rev=141&view=rev
Author: dhubleizh
Date: 2007-01-10 11:57:11 -0800 (Wed, 10 Jan 2007)
Log Message:
-----------
- seperate ExperimetSetup class to handle delay settings
- dalay tweaking from inside of MainWindow
Modified Paths:
--------------
trunk/qcell/visgui/ExperimentSetup.ui
trunk/qcell/visgui/MainWindow.cpp
trunk/qcell/visgui/MainWindow.h
trunk/qcell/visgui/visgui.pro
Added Paths:
-----------
trunk/qcell/visgui/ExperimentSetup.cpp
trunk/qcell/visgui/ExperimentSetup.h
Added: trunk/qcell/visgui/ExperimentSetup.cpp
===================================================================
--- trunk/qcell/visgui/ExperimentSetup.cpp (rev 0)
+++ trunk/qcell/visgui/ExperimentSetup.cpp 2007-01-10 19:57:11 UTC (rev 141)
@@ -0,0 +1,44 @@
+/**@file ExperimentSetup.cpp
+ * @author czarny
+ * @date
+ * Created: ?ro 10 sty 2007 19:17:46 CET \n
+ * Last Update: ?ro 10 sty 2007 19:17:46 CET
+ */
+
+#include "ExperimentSetup.h"
+
+ExperimentSetup::ExperimentSetup()
+{
+ setupUi(this);
+ connect(delaySlider, SIGNAL(valueChanged(int)),
+ SLOT(sliderChanged(int))
+ );
+ connect(delaySpinBox, SIGNAL(valueChanged(double)),
+ this, SLOT(spinBoxChanged(double)));
+}
+
+void ExperimentSetup::sliderChanged(int value)
+{
+ // Anti slider->spinBox value change lock
+ delaySpinBox->blockSignals(true);
+ // Set the spinBox to value from slider proportional to the spinBox range
+ delaySpinBox->setValue(
+ ((delaySpinBox->maximum() - delaySpinBox->minimum()) / 100)
+ * value
+ );
+ // release lock
+ delaySpinBox->blockSignals(false);
+}
+
+void ExperimentSetup::spinBoxChanged(double value)
+{
+ // Anti spinBox->slider value change lock
+ delaySlider->blockSignals(true);
+ // Set the slider proportional to spinBox range
+ delaySlider->setValue(
+ (value / (delaySpinBox->maximum() - delaySpinBox->minimum()))
+ * 100);
+ // release lock
+ delaySlider->blockSignals(false);
+}
+
Added: trunk/qcell/visgui/ExperimentSetup.h
===================================================================
--- trunk/qcell/visgui/ExperimentSetup.h (rev 0)
+++ trunk/qcell/visgui/ExperimentSetup.h 2007-01-10 19:57:11 UTC (rev 141)
@@ -0,0 +1,25 @@
+/**@file ExperimentDialog.h
+ * @author czarny
+ * @date
+ * Created: ?ro 10 sty 2007 19:13:42 CET \n
+ * Last Update: ?ro 10 sty 2007 19:13:42 CET
+ * @brief Events for ExperimentSettings
+ */
+
+#ifndef __EXPERIMENTSETUP_H__
+#define __EXPERIMENTSETUP_H__
+
+#include "ui_ExperimentSetup.h"
+
+class ExperimentSetup: public QDialog, public Ui::ExperimentSetupDialog
+{
+ Q_OBJECT
+public slots:
+ void sliderChanged(int value);
+ void spinBoxChanged(double value);
+public:
+ ExperimentSetup();
+
+};
+
+#endif // __EXPERIMENTSETUP_H__
Modified: trunk/qcell/visgui/ExperimentSetup.ui
===================================================================
--- trunk/qcell/visgui/ExperimentSetup.ui 2007-01-10 19:50:10 UTC (rev 140)
+++ trunk/qcell/visgui/ExperimentSetup.ui 2007-01-10 19:57:11 UTC (rev 141)
@@ -6,7 +6,7 @@
<x>0</x>
<y>0</y>
<width>400</width>
- <height>133</height>
+ <height>231</height>
</rect>
</property>
<property name="windowTitle" >
@@ -20,47 +20,97 @@
<number>6</number>
</property>
<item>
- <layout class="QHBoxLayout" >
- <property name="margin" >
- <number>0</number>
+ <widget class="QGroupBox" name="iterationsBox" >
+ <property name="title" >
+ <string>Iterations</string>
</property>
- <property name="spacing" >
- <number>6</number>
+ <layout class="QHBoxLayout" >
+ <property name="margin" >
+ <number>9</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="iterationsNumberLabel" >
+ <property name="text" >
+ <string>Number of iterations</string>
+ </property>
+ <property name="buddy" >
+ <cstring>iterationsSpinBox</cstring>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="iterationsSpinBox" >
+ <property name="alignment" >
+ <set>Qt::AlignRight</set>
+ </property>
+ <property name="maximum" >
+ <number>10000</number>
+ </property>
+ <property name="minimum" >
+ <number>2</number>
+ </property>
+ <property name="value" >
+ <number>10</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="continiuosCheckBox" >
+ <property name="text" >
+ <string>Continuos Experiment</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="speedBox" >
+ <property name="title" >
+ <string>Delay between iterations</string>
</property>
- <item>
- <widget class="QLabel" name="iterationsNumberLabel" >
- <property name="text" >
- <string>Number of iterations</string>
- </property>
- <property name="buddy" >
- <cstring>iterationsSpinBox</cstring>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QSpinBox" name="iterationsSpinBox" >
- <property name="alignment" >
- <set>Qt::AlignRight</set>
- </property>
- <property name="maximum" >
- <number>10000</number>
- </property>
- <property name="minimum" >
- <number>2</number>
- </property>
- <property name="value" >
- <number>10</number>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="continiuosCheckBox" >
- <property name="text" >
- <string>Continuos Experiment</string>
- </property>
- </widget>
- </item>
- </layout>
+ <layout class="QHBoxLayout" >
+ <property name="margin" >
+ <number>9</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <widget class="QSlider" name="delaySlider" >
+ <property name="maximum" >
+ <number>100</number>
+ </property>
+ <property name="singleStep" >
+ <number>0</number>
+ </property>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDoubleSpinBox" name="delaySpinBox" >
+ <property name="maximum" >
+ <double>5.000000000000000</double>
+ </property>
+ <property name="singleStep" >
+ <double>0.100000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="msLabel" >
+ <property name="text" >
+ <string>s</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
</item>
<item>
<spacer>
@@ -96,8 +146,8 @@
<slot>accept()</slot>
<hints>
<hint type="sourcelabel" >
- <x>227</x>
- <y>110</y>
+ <x>236</x>
+ <y>221</y>
</hint>
<hint type="destinationlabel" >
<x>157</x>
@@ -112,8 +162,8 @@
<slot>reject()</slot>
<hints>
<hint type="sourcelabel" >
- <x>295</x>
- <y>116</y>
+ <x>304</x>
+ <y>221</y>
</hint>
<hint type="destinationlabel" >
<x>286</x>
@@ -128,12 +178,12 @@
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel" >
- <x>262</x>
- <y>24</y>
+ <x>243</x>
+ <y>52</y>
</hint>
<hint type="destinationlabel" >
- <x>215</x>
- <y>25</y>
+ <x>216</x>
+ <y>50</y>
</hint>
</hints>
</connection>
Modified: trunk/qcell/visgui/MainWindow.cpp
===================================================================
--- trunk/qcell/visgui/MainWindow.cpp 2007-01-10 19:50:10 UTC (rev 140)
+++ trunk/qcell/visgui/MainWindow.cpp 2007-01-10 19:57:11 UTC (rev 141)
@@ -17,12 +17,35 @@
sw = new simulationWindow(this);
centralWidget()->layout()->addWidget(sw);
+ // Adding delay setup
+ // An interlinked pair of QDoubleSpinBox and a QSlider
+ delaySlider = new QSlider(Qt::Horizontal);
+ delaySlider->setStatusTip(tr("Sets the dleay between iteration steps in ms."));
+ delaySlider->setFixedWidth(100);
+ delaySpinBox = new QDoubleSpinBox();
+ delaySpinBox->setStatusTip(delaySlider->statusTip());
+ delaySpinBox->setMinimum(MIN_DELAY);
+ delaySpinBox->setMaximum(MAX_DELAY);
+ delaySpinBox->setSingleStep(DELAY_STEP);
+ QLabel* tmp_label = new QLabel(tr("Delay"));
+ tmp_label->setStatusTip(delaySlider->statusTip());
+ statusBar()->addPermanentWidget(tmp_label);
+ statusBar()->addPermanentWidget(delaySlider);
+ statusBar()->addPermanentWidget(delaySpinBox);
+ statusBar()->addPermanentWidget(new QLabel("ms"));
+ // Interconnect both widgets - change in one will change the other as well
+ connect(delaySlider, SIGNAL(valueChanged(int)),
+ SLOT(sliderChanged(int))
+ );
+ connect(delaySpinBox, SIGNAL(valueChanged(double)),
+ this, SLOT(spinBoxChanged(double)));
+
// Adding iteration counter
// Creating LCD counter
iterationLCD = new QLCDNumber();
iterationLCD->setSegmentStyle(QLCDNumber::Flat);
iterationLCD->setStatusTip(tr("Shows the current iteration number."));
- QLabel* tmp_label = new QLabel(tr("Iteration"));
+ tmp_label = new QLabel(tr("Iteration"));
tmp_label->setBuddy(iterationLCD);
tmp_label->setStatusTip(iterationLCD->statusTip());
statusBar()->addPermanentWidget(tmp_label);
@@ -535,13 +558,12 @@
void MainWindow::on_action_Start_activated()
{
- QDialog* dialog = new QDialog(this);
- Ui::ExperimentSetupDialog es;
- es.setupUi(dialog);
+ ExperimentSetup es;
- if(dialog->exec() == QDialog::Accepted)
+ if(es.exec() == QDialog::Accepted)
{
working = true;
+ msec_delay = (int)(es.delaySpinBox->value() * 100.00);
if(es.continiuosCheckBox->isChecked())
{
continousSteps();
@@ -827,3 +849,31 @@
statusBar()->showMessage(tr("Sucessfully loaded experiment for continuation.").toAscii());
}
+void MainWindow::sliderChanged(int value)
+{
+ // Anti slider->spinBox value change lock
+ delaySpinBox->blockSignals(true);
+ // Set the spinBox to value from slider proportional to the spinBox range
+ delaySpinBox->setValue(
+ ((delaySpinBox->maximum() - delaySpinBox->minimum()) / 100)
+ * value
+ );
+ // release lock
+ delaySpinBox->blockSignals(false);
+}
+
+void MainWindow::spinBoxChanged(double value)
+{
+ // Anti spinBox->slider value change lock
+ delaySlider->blockSignals(true);
+ // Setting it here is easier
+ // When the value is set by slider, this function will be called anywayz
+ msec_delay = value * 100.00;
+ // Set the slider proportional to spinBox range
+ delaySlider->setValue(
+ (value / (delaySpinBox->maximum() - delaySpinBox->minimum()))
+ * 100);
+ // release lock
+ delaySlider->blockSignals(false);
+}
+
Modified: trunk/qcell/visgui/MainWindow.h
===================================================================
--- trunk/qcell/visgui/MainWindow.h 2007-01-10 19:50:10 UTC (rev 140)
+++ trunk/qcell/visgui/MainWindow.h 2007-01-10 19:57:11 UTC (rev 141)
@@ -1,6 +1,6 @@
/**@file MainWindow.h
* @author czarny
- * @version gg
+ * @version 0.7
* @date
* Created: ?ro 22 lis 2006 14:14:17 CET \n
* Last Update: ?ro 22 lis 2006 14:14:17 CET
@@ -11,7 +11,7 @@
#include "ui_MainWindow.h"
#include "ui_AboutDialog.h"
-#include "ui_ExperimentSetup.h"
+#include "ExperimentSetup.h"
#include <QPluginLoader>
#include "GenericParserPlugin.h"
#include <QFileDialog>
@@ -24,6 +24,10 @@
#include <simulationwindow.h>
#include <Calculator.h>
+#define MIN_DELAY 0.0
+#define MAX_DELAY 5.0
+#define DELAY_STEP 0.1
+
typedef QString (*parser_fun)(QByteArray content, QString type, QString subtype);
class MainWindow : public QMainWindow, private Ui::MainWindow
@@ -47,6 +51,9 @@
void on_action_Save_experiment_activated();
void on_action_Continue_experiment_activated();
+ void sliderChanged(int value);
+ void spinBoxChanged(double value);
+
/// @todo not here!
void on_action_Forward_activated();
void on_action_Back_activated();
@@ -59,6 +66,8 @@
private:
simulationWindow* sw;
QLCDNumber* iterationLCD;
+ QSlider* delaySlider;
+ QDoubleSpinBox* delaySpinBox;
QMap<QString, ParserInterface*> neighbourhood_parsers;
QMap<QString, ParserInterface*> function_parsers;
QMap<QString, ParserInterface*> world_parsers;
@@ -77,6 +86,7 @@
bool working;
int iteration;
+ uint msec_delay;
Calculator calc;
QList<CalculationData*> data;
Modified: trunk/qcell/visgui/visgui.pro
===================================================================
--- trunk/qcell/visgui/visgui.pro 2007-01-10 19:50:10 UTC (rev 140)
+++ trunk/qcell/visgui/visgui.pro 2007-01-10 19:57:11 UTC (rev 141)
@@ -10,6 +10,7 @@
ExperimentSetup.ui \
../baseheaders/simulationwindow.ui
HEADERS = MainWindow.h \
+ ExperimentSetup.h \
../baseheaders/Client.h \
../baseheaders/ClientInfo.h \
../baseheaders/BaseDataTypes.h \
@@ -25,6 +26,7 @@
SOURCES = ../basesources/GenericParserPlugin.cpp \
main.cpp \
MainWindow.cpp \
+ ExperimentSetup.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.
|