summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorMika Salmela <mika.salmela@digia.com>2013-09-06 15:38:22 +0300
committerMika Salmela <mika.salmela@digia.com>2013-09-06 16:26:05 +0300
commit078a13fdeb00c055dbc0dfed23492a1963b71de3 (patch)
tree4752a54df875061fe567529da1643deed9e94c40 /examples
parentb288ecc4c08e97c1b09b8a253de4931616bd3d91 (diff)
Example improvements
CheckBoxes for selecting sample type changed to RadioButtons. Sliders change the sample amount on the fly. Change-Id: I27c8e9d84165a9b3f9a13d961d609da613c1e4e3 Reviewed-by: Mika Salmela <mika.salmela@digia.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/surfacechart/chartmodifier.cpp29
-rw-r--r--examples/surfacechart/chartmodifier.h8
-rw-r--r--examples/surfacechart/main.cpp14
3 files changed, 44 insertions, 7 deletions
diff --git a/examples/surfacechart/chartmodifier.cpp b/examples/surfacechart/chartmodifier.cpp
index 30df0998..48a4bcce 100644
--- a/examples/surfacechart/chartmodifier.cpp
+++ b/examples/surfacechart/chartmodifier.cpp
@@ -29,7 +29,8 @@ QT_DATAVIS3D_USE_NAMESPACE
ChartModifier::ChartModifier(Q3DSurface *chart)
: m_chart(chart),
m_xCount(10),
- m_zCount(10)
+ m_zCount(10),
+ m_activeSample(0)
{
m_chart->setAxisX(new Q3DValueAxis);
m_chart->setAxisY(new Q3DValueAxis);
@@ -87,6 +88,8 @@ void ChartModifier::toggleSqrtSin(bool enable)
m_chart->axisZ()->setRange(0.0, qreal(m_zCount - 1));
m_chart->activeDataProxy()->resetArray(dataArray);
+ m_activeSample = ChartModifier::SqrtSin;
+
//qDebug() << "biggest = " << biggest << ", smallest = " << smallest;
} else {
qDebug() << "Remove surface";
@@ -116,6 +119,8 @@ void ChartModifier::togglePlane(bool enable)
m_chart->axisZ()->setRange(0.0, qreal(m_zCount - 1));
m_chart->activeDataProxy()->resetArray(dataArray);
+
+ m_activeSample = ChartModifier::Plane;
}
}
@@ -142,6 +147,8 @@ void ChartModifier::setHeightMapData(bool enable)
m_chart->axisZ()->setRange(0.0, qreal(image.height() - 1));
m_chart->activeDataProxy()->resetArray(dataArray);
+
+ m_activeSample = ChartModifier::Map;
}
}
@@ -162,6 +169,8 @@ void ChartModifier::adjustXCount(int count)
if (m_gridSlidersLocked)
m_gridSliderZ->setValue(count);
+ updateSamples();
+
qDebug() << "X count = " << count;
}
@@ -169,6 +178,24 @@ void ChartModifier::adjustZCount(int count)
{
m_zCount = count;
+ updateSamples();
+
qDebug() << "Z count = " << count;
}
+void ChartModifier::updateSamples()
+{
+ switch (m_activeSample) {
+ case SqrtSin:
+ toggleSqrtSin(true);
+ break;
+
+ case Plane:
+ togglePlane(true);
+ break;
+
+ default:
+ break;
+ }
+}
+
diff --git a/examples/surfacechart/chartmodifier.h b/examples/surfacechart/chartmodifier.h
index 3c0f8ad9..cb0a20a6 100644
--- a/examples/surfacechart/chartmodifier.h
+++ b/examples/surfacechart/chartmodifier.h
@@ -28,6 +28,12 @@ class ChartModifier : public QObject
{
Q_OBJECT
public:
+ enum Samples {
+ SqrtSin = 1,
+ Plane,
+ Map
+ };
+
explicit ChartModifier(Q3DSurface *chart);
~ChartModifier();
@@ -41,6 +47,7 @@ public:
void setGridSliderZ(QSlider *slider) { m_gridSliderZ = slider; }
void adjustXCount(int count);
void adjustZCount(int count);
+ void updateSamples();
private:
Q3DSurface *m_chart;
@@ -49,6 +56,7 @@ private:
bool m_gridSlidersLocked;
int m_xCount;
int m_zCount;
+ int m_activeSample;
};
#endif // CHARTMODIFIER_H
diff --git a/examples/surfacechart/main.cpp b/examples/surfacechart/main.cpp
index 00fd8627..660ed25c 100644
--- a/examples/surfacechart/main.cpp
+++ b/examples/surfacechart/main.cpp
@@ -25,6 +25,7 @@
#include <QVBoxLayout>
#include <QPushButton>
#include <QCheckBox>
+#include <QRadioButton>
#include <QSlider>
#include <QLabel>
#include <QScreen>
@@ -64,15 +65,16 @@ int main(int argc, char *argv[])
surfaceGridCB->setText(QStringLiteral("Surface Grid"));
surfaceGridCB->setChecked(true);
- QCheckBox *sqrtSinCB = new QCheckBox(widget);
+ //QCheckBox *sqrtSinCB = new QCheckBox(widget);
+ QRadioButton *sqrtSinCB = new QRadioButton(widget);
sqrtSinCB->setText(QStringLiteral("Sqrt & Sin"));
sqrtSinCB->setChecked(false);
- QCheckBox *planeCB = new QCheckBox(widget);
+ QRadioButton *planeCB = new QRadioButton(widget);
planeCB->setText(QStringLiteral("Plane"));
planeCB->setChecked(false);
- QCheckBox *heightMapCB = new QCheckBox(widget);
+ QRadioButton *heightMapCB = new QRadioButton(widget);
heightMapCB->setText(QStringLiteral("Height map"));
heightMapCB->setChecked(false);
@@ -130,11 +132,11 @@ int main(int argc, char *argv[])
modifier, &ChartModifier::toggleSmooth);
QObject::connect(surfaceGridCB, &QCheckBox::stateChanged,
modifier, &ChartModifier::toggleSurfaceGrid);
- QObject::connect(sqrtSinCB, &QCheckBox::stateChanged,
+ QObject::connect(sqrtSinCB, &QRadioButton::toggled,
modifier, &ChartModifier::toggleSqrtSin);
- QObject::connect(planeCB, &QCheckBox::stateChanged,
+ QObject::connect(planeCB, &QCheckBox::toggled,
modifier, &ChartModifier::togglePlane);
- QObject::connect(heightMapCB, &QCheckBox::stateChanged,
+ QObject::connect(heightMapCB, &QCheckBox::toggled,
modifier, &ChartModifier::setHeightMapData);
QObject::connect(gridSlidersLockCB, &QCheckBox::stateChanged,
modifier, &ChartModifier::toggleGridSliderLock);