diff options
Diffstat (limited to 'examples/bars')
-rw-r--r-- | examples/bars/doc/images/bars-example.png | bin | 149324 -> 135242 bytes | |||
-rw-r--r-- | examples/bars/doc/src/bars.qdoc | 8 | ||||
-rw-r--r-- | examples/bars/graphmodifier.cpp | 108 | ||||
-rw-r--r-- | examples/bars/graphmodifier.h | 17 | ||||
-rw-r--r-- | examples/bars/main.cpp | 38 |
5 files changed, 80 insertions, 91 deletions
diff --git a/examples/bars/doc/images/bars-example.png b/examples/bars/doc/images/bars-example.png Binary files differindex e8b91314..6cc94455 100644 --- a/examples/bars/doc/images/bars-example.png +++ b/examples/bars/doc/images/bars-example.png diff --git a/examples/bars/doc/src/bars.qdoc b/examples/bars/doc/src/bars.qdoc index 79cfb270..9c80b804 100644 --- a/examples/bars/doc/src/bars.qdoc +++ b/examples/bars/doc/src/bars.qdoc @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc +** Copyright (C) 2014 Digia Plc ** All rights reserved. ** For any questions to Digia, please use contact form at http://qt.digia.com ** @@ -75,7 +75,7 @@ Let's take a closer look at parts of the code. - First we're creating the axes and the proxy into member variables to support changing them + First we're creating the axes and the series into member variables to support changing them easily later on, if we want to: \snippet ../examples/bars/graphmodifier.cpp 1 @@ -88,8 +88,8 @@ \snippet ../examples/bars/graphmodifier.cpp 3 - Next we create two series for the graph, giving each one a data proxy. Here we also initialize - some of the visual properties of the series. Note that the second series is initially not visible: + Next we initialize the visual properties of the series. + Note that the second series is initially not visible: \snippet ../examples/bars/graphmodifier.cpp 8 diff --git a/examples/bars/graphmodifier.cpp b/examples/bars/graphmodifier.cpp index 13e4d3e7..06b36b7f 100644 --- a/examples/bars/graphmodifier.cpp +++ b/examples/bars/graphmodifier.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc +** Copyright (C) 2014 Digia Plc ** All rights reserved. ** For any questions to Digia, please use contact form at http://qt.digia.com ** @@ -17,8 +17,8 @@ ****************************************************************************/ #include "graphmodifier.h" -#include <QtDataVisualization/q3dcategoryaxis.h> -#include <QtDataVisualization/q3dvalueaxis.h> +#include <QtDataVisualization/qcategory3daxis.h> +#include <QtDataVisualization/qvalue3daxis.h> #include <QtDataVisualization/qbardataproxy.h> #include <QtDataVisualization/q3dscene.h> #include <QtDataVisualization/q3dcamera.h> @@ -27,7 +27,7 @@ #include <QTime> #include <QComboBox> -QT_DATAVISUALIZATION_USE_NAMESPACE +using namespace QtDataVisualization; const QString celsiusString = QString(QChar(0xB0)) + "C"; @@ -42,21 +42,21 @@ GraphModifier::GraphModifier(Q3DBars *bargraph) m_minval(-20.0f), m_maxval(20.0f), //! [1] - m_temperatureAxis(new Q3DValueAxis), - m_yearAxis(new Q3DCategoryAxis), - m_monthAxis(new Q3DCategoryAxis), - m_primaryData(new QBarDataProxy), - m_secondaryData(new QBarDataProxy), + m_temperatureAxis(new QValue3DAxis), + m_yearAxis(new QCategory3DAxis), + m_monthAxis(new QCategory3DAxis), + m_primarySeries(new QBar3DSeries), + m_secondarySeries(new QBar3DSeries), //! [1] - m_primaryStyle(QAbstract3DSeries::MeshBevelBar), - m_secondaryStyle(QAbstract3DSeries::MeshSphere), + m_barMesh(QAbstract3DSeries::MeshBevelBar), m_smooth(false) { //! [2] - m_graph->setShadowQuality(QDataVis::ShadowQualitySoftMedium); - m_graph->theme()->setBackgroundEnabled(false); - m_graph->theme()->setFont(QFont("Times New Roman", m_fontSize)); - m_graph->theme()->setLabelBackgroundEnabled(true); + m_graph->setShadowQuality(QAbstract3DGraph::ShadowQualitySoftMedium); + m_graph->activeTheme()->setBackgroundEnabled(false); + m_graph->activeTheme()->setFont(QFont("Times New Roman", m_fontSize)); + m_graph->activeTheme()->setLabelBackgroundEnabled(true); + m_graph->setMultiSeriesUniform(true); //! [2] m_months << "January" << "February" << "March" << "April" << "May" << "June" << "July" << "August" << "September" << "October" << "November" << "December"; @@ -78,21 +78,19 @@ GraphModifier::GraphModifier(Q3DBars *bargraph) //! [3] //! [8] - QBar3DSeries *series = new QBar3DSeries(m_primaryData); - series->setItemLabelFormat(QStringLiteral("Oulu - @colLabel @rowLabel: @valueLabel")); - series->setMesh(QAbstract3DSeries::MeshBevelBar); - series->setMeshSmooth(false); - - QBar3DSeries *series2 = new QBar3DSeries(m_secondaryData); - series2->setItemLabelFormat(QStringLiteral("Helsinki - @colLabel @rowLabel: @valueLabel")); - series2->setMesh(QAbstract3DSeries::MeshSphere); - series2->setMeshSmooth(false); - series2->setVisible(false); + m_primarySeries->setItemLabelFormat(QStringLiteral("Oulu - @colLabel @rowLabel: @valueLabel")); + m_primarySeries->setMesh(QAbstract3DSeries::MeshBevelBar); + m_primarySeries->setMeshSmooth(false); + + m_secondarySeries->setItemLabelFormat(QStringLiteral("Helsinki - @colLabel @rowLabel: @valueLabel")); + m_secondarySeries->setMesh(QAbstract3DSeries::MeshBevelBar); + m_secondarySeries->setMeshSmooth(false); + m_secondarySeries->setVisible(false); //! [8] //! [4] - m_graph->addSeries(series); - m_graph->addSeries(series2); + m_graph->addSeries(m_primarySeries); + m_graph->addSeries(m_secondarySeries); //! [4] //! [6] @@ -155,9 +153,9 @@ void GraphModifier::resetTemperatureData() dataSet2->append(dataRow2); } - // Add data to the graph (the graph assumes ownership of it) - m_primaryData->resetArray(dataSet, m_years, m_months); - m_secondaryData->resetArray(dataSet2, m_years, m_months); + // Add data to the data proxy (the data proxy assumes ownership of it) + m_primarySeries->dataProxy()->resetArray(dataSet, m_years, m_months); + m_secondarySeries->dataProxy()->resetArray(dataSet2, m_years, m_months); //! [5] } @@ -165,9 +163,9 @@ void GraphModifier::changeStyle(int style) { QComboBox *comboBox = qobject_cast<QComboBox *>(sender()); if (comboBox) { - m_primaryStyle = QAbstract3DSeries::Mesh(comboBox->itemData(style).toInt()); - if (m_graph->seriesList().size()) - m_graph->seriesList().at(0)->setMesh(m_primaryStyle); + m_barMesh = QAbstract3DSeries::Mesh(comboBox->itemData(style).toInt()); + m_primarySeries->setMesh(m_barMesh); + m_secondarySeries->setMesh(m_barMesh); } } @@ -185,16 +183,17 @@ void GraphModifier::changePresetCamera() void GraphModifier::changeTheme(int theme) { - m_graph->setTheme(new Q3DTheme(Q3DTheme::Theme(theme))); - emit backgroundEnabledChanged(m_graph->theme()->isBackgroundEnabled()); - emit gridEnabledChanged(m_graph->theme()->isGridEnabled()); - emit fontChanged(m_graph->theme()->font()); - emit fontSizeChanged(m_graph->theme()->font().pointSize()); + Q3DTheme *currentTheme = m_graph->activeTheme(); + currentTheme->setType(Q3DTheme::Theme(theme)); + emit backgroundEnabledChanged(currentTheme->isBackgroundEnabled()); + emit gridEnabledChanged(currentTheme->isGridEnabled()); + emit fontChanged(currentTheme->font()); + emit fontSizeChanged(currentTheme->font().pointSize()); } void GraphModifier::changeLabelBackground() { - m_graph->theme()->setLabelBackgroundEnabled(!m_graph->theme()->isLabelBackgroundEnabled()); + m_graph->activeTheme()->setLabelBackgroundEnabled(!m_graph->activeTheme()->isLabelBackgroundEnabled()); } void GraphModifier::changeSelectionMode(int selectionMode) @@ -202,25 +201,25 @@ void GraphModifier::changeSelectionMode(int selectionMode) QComboBox *comboBox = qobject_cast<QComboBox *>(sender()); if (comboBox) { int flags = comboBox->itemData(selectionMode).toInt(); - m_graph->setSelectionMode(QDataVis::SelectionFlags(flags)); + m_graph->setSelectionMode(QAbstract3DGraph::SelectionFlags(flags)); } } void GraphModifier::changeFont(const QFont &font) { QFont newFont = font; - m_graph->theme()->setFont(newFont); + m_graph->activeTheme()->setFont(newFont); } void GraphModifier::changeFontSize(int fontsize) { m_fontSize = fontsize; - QFont font = m_graph->theme()->font(); + QFont font = m_graph->activeTheme()->font(); font.setPointSize(m_fontSize); - m_graph->theme()->setFont(font); + m_graph->activeTheme()->setFont(font); } -void GraphModifier::shadowQualityUpdatedByVisual(QDataVis::ShadowQuality sq) +void GraphModifier::shadowQualityUpdatedByVisual(QAbstract3DGraph::ShadowQuality sq) { int quality = int(sq); // Updates the UI component to show correct shadow quality @@ -229,7 +228,7 @@ void GraphModifier::shadowQualityUpdatedByVisual(QDataVis::ShadowQuality sq) void GraphModifier::changeShadowQuality(int quality) { - QDataVis::ShadowQuality sq = QDataVis::ShadowQuality(quality); + QAbstract3DGraph::ShadowQuality sq = QAbstract3DGraph::ShadowQuality(quality); m_graph->setShadowQuality(sq); emit shadowQualityChanged(quality); } @@ -250,31 +249,22 @@ void GraphModifier::rotateY(int rotation) void GraphModifier::setBackgroundEnabled(int enabled) { - m_graph->theme()->setBackgroundEnabled(bool(enabled)); + m_graph->activeTheme()->setBackgroundEnabled(bool(enabled)); } void GraphModifier::setGridEnabled(int enabled) { - m_graph->theme()->setGridEnabled(bool(enabled)); + m_graph->activeTheme()->setGridEnabled(bool(enabled)); } void GraphModifier::setSmoothBars(int smooth) { m_smooth = bool(smooth); - if (m_graph->seriesList().size()) { - m_graph->seriesList().at(0)->setMeshSmooth(m_smooth); - m_graph->seriesList().at(1)->setMeshSmooth(m_smooth); - } + m_primarySeries->setMeshSmooth(m_smooth); + m_secondarySeries->setMeshSmooth(m_smooth); } void GraphModifier::setSeriesVisibility(int enabled) { - m_graph->seriesList().at(1)->setVisible(bool(enabled)); - if (enabled) { - m_graph->setBarThickness(2.0f); - m_graph->setBarSpacing(QSizeF(1.0, 3.0)); - } else { - m_graph->setBarThickness(1.0f); - m_graph->setBarSpacing(QSizeF(1.0, 1.0)); - } + m_secondarySeries->setVisible(bool(enabled)); } diff --git a/examples/bars/graphmodifier.h b/examples/bars/graphmodifier.h index f7c0acaf..cfb1ceec 100644 --- a/examples/bars/graphmodifier.h +++ b/examples/bars/graphmodifier.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc +** Copyright (C) 2014 Digia Plc ** All rights reserved. ** For any questions to Digia, please use contact form at http://qt.digia.com ** @@ -54,7 +54,7 @@ public slots: void changeSelectionMode(int selectionMode); void changeTheme(int theme); void changeShadowQuality(int quality); - void shadowQualityUpdatedByVisual(QDataVis::ShadowQuality shadowQuality); + void shadowQualityUpdatedByVisual(QAbstract3DGraph::ShadowQuality shadowQuality); signals: void shadowQualityChanged(int quality); @@ -74,13 +74,12 @@ private: float m_maxval; QStringList m_months; QStringList m_years; - Q3DValueAxis *m_temperatureAxis; - Q3DCategoryAxis *m_yearAxis; - Q3DCategoryAxis *m_monthAxis; - QBarDataProxy *m_primaryData; - QBarDataProxy *m_secondaryData; - QAbstract3DSeries::Mesh m_primaryStyle; - QAbstract3DSeries::Mesh m_secondaryStyle; + QValue3DAxis *m_temperatureAxis; + QCategory3DAxis *m_yearAxis; + QCategory3DAxis *m_monthAxis; + QBar3DSeries *m_primarySeries; + QBar3DSeries *m_secondarySeries; + QAbstract3DSeries::Mesh m_barMesh; bool m_smooth; }; diff --git a/examples/bars/main.cpp b/examples/bars/main.cpp index 21a4e0e6..0b934aac 100644 --- a/examples/bars/main.cpp +++ b/examples/bars/main.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc +** Copyright (C) 2014 Digia Plc ** All rights reserved. ** For any questions to Digia, please use contact form at http://qt.digia.com ** @@ -86,38 +86,38 @@ int main(int argc, char **argv) QComboBox *selectionModeList = new QComboBox(widget); selectionModeList->addItem(QStringLiteral("None"), - int(QDataVis::SelectionNone)); + int(QAbstract3DGraph::SelectionNone)); selectionModeList->addItem(QStringLiteral("Bar"), - int(QDataVis::SelectionItem)); + int(QAbstract3DGraph::SelectionItem)); selectionModeList->addItem(QStringLiteral("Row"), - int(QDataVis::SelectionRow)); + int(QAbstract3DGraph::SelectionRow)); selectionModeList->addItem(QStringLiteral("Bar and Row"), - int(QDataVis::SelectionItemAndRow)); + int(QAbstract3DGraph::SelectionItemAndRow)); selectionModeList->addItem(QStringLiteral("Column"), - int(QDataVis::SelectionColumn)); + int(QAbstract3DGraph::SelectionColumn)); selectionModeList->addItem(QStringLiteral("Bar and Column"), - int(QDataVis::SelectionItemAndColumn)); + int(QAbstract3DGraph::SelectionItemAndColumn)); selectionModeList->addItem(QStringLiteral("Row and Column"), - int(QDataVis::SelectionRowAndColumn)); + int(QAbstract3DGraph::SelectionRowAndColumn)); selectionModeList->addItem(QStringLiteral("Bar, Row and Column"), - int(QDataVis::SelectionItemRowAndColumn)); + int(QAbstract3DGraph::SelectionItemRowAndColumn)); selectionModeList->addItem(QStringLiteral("Slice into Row"), - int(QDataVis::SelectionSlice | QDataVis::SelectionRow)); + int(QAbstract3DGraph::SelectionSlice | QAbstract3DGraph::SelectionRow)); selectionModeList->addItem(QStringLiteral("Slice into Row and Item"), - int(QDataVis::SelectionSlice | QDataVis::SelectionItemAndRow)); + int(QAbstract3DGraph::SelectionSlice | QAbstract3DGraph::SelectionItemAndRow)); selectionModeList->addItem(QStringLiteral("Slice into Column"), - int(QDataVis::SelectionSlice | QDataVis::SelectionColumn)); + int(QAbstract3DGraph::SelectionSlice | QAbstract3DGraph::SelectionColumn)); selectionModeList->addItem(QStringLiteral("Slice into Column and Item"), - int(QDataVis::SelectionSlice | QDataVis::SelectionItemAndColumn)); + int(QAbstract3DGraph::SelectionSlice | QAbstract3DGraph::SelectionItemAndColumn)); selectionModeList->addItem(QStringLiteral("Multi: Bar, Row, Col"), - int(QDataVis::SelectionItemRowAndColumn - | QDataVis::SelectionMultiSeries)); + int(QAbstract3DGraph::SelectionItemRowAndColumn + | QAbstract3DGraph::SelectionMultiSeries)); selectionModeList->addItem(QStringLiteral("Multi, Slice: Row, Item"), - int(QDataVis::SelectionSlice | QDataVis::SelectionItemAndRow - | QDataVis::SelectionMultiSeries)); + int(QAbstract3DGraph::SelectionSlice | QAbstract3DGraph::SelectionItemAndRow + | QAbstract3DGraph::SelectionMultiSeries)); selectionModeList->addItem(QStringLiteral("Multi, Slice: Col, Item"), - int(QDataVis::SelectionSlice | QDataVis::SelectionItemAndColumn - | QDataVis::SelectionMultiSeries)); + int(QAbstract3DGraph::SelectionSlice | QAbstract3DGraph::SelectionItemAndColumn + | QAbstract3DGraph::SelectionMultiSeries)); selectionModeList->setCurrentIndex(1); QCheckBox *backgroundCheckBox = new QCheckBox(widget); |