From: <dhu...@us...> - 2007-02-13 19:36:36
|
Revision: 318 http://svn.sourceforge.net/qcell/?rev=318&view=rev Author: dhubleizh Date: 2007-02-13 11:36:33 -0800 (Tue, 13 Feb 2007) Log Message: ----------- - some totally basic view interpretation Modified Paths: -------------- trunk/qcell/baseheaders/ElementalRules.h trunk/qcell/basesources/CalculationData.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 trunk/qcell/visgui/MainWindow.h Modified: trunk/qcell/baseheaders/ElementalRules.h =================================================================== --- trunk/qcell/baseheaders/ElementalRules.h 2007-02-13 17:24:47 UTC (rev 317) +++ trunk/qcell/baseheaders/ElementalRules.h 2007-02-13 19:36:33 UTC (rev 318) @@ -14,6 +14,8 @@ #include <QMultiHash> #include <QPair> +#include "CalculationData.h" + class ElementalRules : public QObject { Q_OBJECT @@ -29,6 +31,7 @@ int neighbours_count; int index; bool should_work; + CalculationData cd; QVector<int> return_values; QVector<QVector<int> > neighbours; @@ -45,6 +48,8 @@ void setNeighoursCount(const int neighbours); inline int getNeighbourCount(); + void setCDSize(int x, int y, int z); + CalculationData* getCalculationData(); }; Modified: trunk/qcell/basesources/CalculationData.cpp =================================================================== --- trunk/qcell/basesources/CalculationData.cpp 2007-02-13 17:24:47 UTC (rev 317) +++ trunk/qcell/basesources/CalculationData.cpp 2007-02-13 19:36:33 UTC (rev 318) @@ -225,6 +225,24 @@ } } +void CalculationData::setValueAt(int val, QVector<int> pos) +{ + if (pos.size() == 3) + { + setValueAt(val, pos[0], pos[1], pos[2]); + } + else + { + if (pos.size() == 2) + { + setValueAt(val, pos[0], pos[1]); + } + else + { + setValueAt(val, pos[0]); + } + } +} double CalculationData::getValueAt_d(int x) { @@ -744,4 +762,4 @@ resizeData(cData.getSize()); fillData(cData.getDataPointer()); return *this; -} \ No newline at end of file +} Modified: trunk/qcell/basesources/ElementalRules.cpp =================================================================== --- trunk/qcell/basesources/ElementalRules.cpp 2007-02-13 17:24:47 UTC (rev 317) +++ trunk/qcell/basesources/ElementalRules.cpp 2007-02-13 19:36:33 UTC (rev 318) @@ -6,6 +6,7 @@ */ #include "ElementalRules.h" +#include <QDebug> ElementalRules::ElementalRules() : QObject() @@ -77,6 +78,8 @@ // At the end we note the coordinates rules_mask.insert(rule_index, coordinates); + // Write to the internal interpreted World + cd.setValueAt(rule_index, coordinates); } void ElementalRules::resetList() @@ -105,3 +108,27 @@ should_work = flag; } +void ElementalRules::setCDSize(int x, int y, int z) +{ + if (z > 1) + { + cd.resizeData(x, y, z); + } + else + { + if (y > 1) + { + cd.resizeData(x, y); + } + else + { + cd.resizeData(x); + } + } +} + +CalculationData* ElementalRules::getCalculationData() +{ + return &cd; +} + Modified: trunk/qcell/visgui/ElementalRulesWidget.cpp =================================================================== --- trunk/qcell/visgui/ElementalRulesWidget.cpp 2007-02-13 17:24:47 UTC (rev 317) +++ trunk/qcell/visgui/ElementalRulesWidget.cpp 2007-02-13 19:36:33 UTC (rev 318) @@ -22,6 +22,9 @@ connect(rulesTree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), this, SLOT(ruleDoubleClicked(QTreeWidgetItem*, int)) ); + connect(interpretedCheckBox, SIGNAL(toggled(bool)), + this, SLOT(interpretedView_toggled(bool)) + ); } void ElementalRulesWidget::addRule(int id, QVector<int> neighbrous, int result, QVector<int> coordinates) @@ -156,3 +159,8 @@ // //} +void ElementalRulesWidget::interpretedView_toggled(bool toggled) +{ + emit interpret(toggled); +} + Modified: trunk/qcell/visgui/ElementalRulesWidget.h =================================================================== --- trunk/qcell/visgui/ElementalRulesWidget.h 2007-02-13 17:24:47 UTC (rev 317) +++ trunk/qcell/visgui/ElementalRulesWidget.h 2007-02-13 19:36:33 UTC (rev 318) @@ -24,6 +24,7 @@ Q_OBJECT signals: void visible(bool visible); + void interpret(bool interpretedView); // void rulesSelected(QHash<int, QList<QVector<int> > > rules); public slots: void setVisible(bool visible); @@ -35,6 +36,8 @@ void addOccurance(int id, QVector<int> coordinates); void selectionChanged(); void ruleDoubleClicked(QTreeWidgetItem* item, int column); +protected slots: + void interpretedView_toggled(bool); protected: QString parseCoordinates(QVector<int> coordinates); public: Modified: trunk/qcell/visgui/ElementalRulesWidget.ui =================================================================== --- trunk/qcell/visgui/ElementalRulesWidget.ui 2007-02-13 17:24:47 UTC (rev 317) +++ trunk/qcell/visgui/ElementalRulesWidget.ui 2007-02-13 19:36:33 UTC (rev 318) @@ -20,6 +20,36 @@ <number>6</number> </property> <item> + <layout class="QHBoxLayout" > + <property name="margin" > + <number>0</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <spacer> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" > + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QCheckBox" name="interpretedCheckBox" > + <property name="text" > + <string>Interpreted view</string> + </property> + </widget> + </item> + </layout> + </item> + <item> <widget class="QTreeWidget" name="rulesTree" > <property name="sizePolicy" > <sizepolicy> Modified: trunk/qcell/visgui/MainWindow.cpp =================================================================== --- trunk/qcell/visgui/MainWindow.cpp 2007-02-13 17:24:47 UTC (rev 317) +++ trunk/qcell/visgui/MainWindow.cpp 2007-02-13 19:36:33 UTC (rev 318) @@ -228,6 +228,10 @@ QAction* elemental_action = elemental_dock->toggleViewAction(); elemental_action->setText("&" + elemental_dock->windowTitle()); menu_View->addAction(elemental_action); + // Interpretation view on/off + connect((ElementalRulesWidget*)elemental_dock->widget(), SIGNAL(interpret(bool)), + this, SLOT(interpretationChanged(bool)) + ); foreach(QObject* plugin, QPluginLoader::staticInstances()) { @@ -754,6 +758,7 @@ void MainWindow::setupEngine() { working = false; + interpretedView = false; iteration = 0; msec_delay = 0; step = 1; @@ -839,7 +844,17 @@ if (++counter == step) { counter = 0; - sw->getStorage()->resizeData(calc.getSize(), calc.getDataPointer(), 1); + if (interpretedView) + { + sw->getStorage()->resizeData(elemental_rules->getCalculationData()->getSize(), + elemental_rules->getCalculationData()->getDataPointer(), + 1 + ); + } + else + { + sw->getStorage()->resizeData(calc.getSize(), calc.getDataPointer(), 1); + } } iterationLCD->display(iteration); } @@ -1540,6 +1555,11 @@ // Creating elemental rules according to DATA_TYPE elemental_rules = new ElementalRules; + elemental_rules->setCDSize( + data.last()->getSizeX(), + data.last()->getSizeY(), + data.last()->getSizeZ() + ); // Pass the calculation result to rules selection connect(&calc, SIGNAL(calculated(QVector<int>, QVector<int>, int)), @@ -1580,6 +1600,7 @@ elemental_rules, SLOT(work(bool)) ); + iteration=data.count()-1; // visualization update @@ -1663,3 +1684,12 @@ } } +void MainWindow::interpretationChanged(bool interpret) +{ + interpretedView = interpret; + sw->getStorage()->resizeData(elemental_rules->getCalculationData()->getSize(), + elemental_rules->getCalculationData()->getDataPointer(), + 1 + ); +} + Modified: trunk/qcell/visgui/MainWindow.h =================================================================== --- trunk/qcell/visgui/MainWindow.h 2007-02-13 17:24:47 UTC (rev 317) +++ trunk/qcell/visgui/MainWindow.h 2007-02-13 19:36:33 UTC (rev 318) @@ -50,6 +50,8 @@ public: MainWindow(QWidget* parent = 0); +public slots: + void interpretationChanged(bool interpret); private slots: void on_action_About_activated(); void on_action_Quit_activated(); @@ -110,6 +112,7 @@ bool working; int iteration; + bool interpretedView; uint msec_delay; int step; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |