diff options
author | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2014-01-27 13:10:44 +0200 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2014-01-27 13:13:58 +0200 |
commit | b368e57e59351736f9ad06834a743a7c1b49d368 (patch) | |
tree | 3b7d42569905d8cde0ca7571cd664428354a50dd /examples | |
parent | eb3d0514ca886db33776522ea00f27b69bc86ad1 (diff) | |
parent | 05d06fbc61f07e400b519a9b020c2473398627c1 (diff) |
Merge branch 'develop'v1.0.0-beta1
Change-Id: I1c9a255eb8f30a24b665856d3711f0abe77c6ef4
Diffstat (limited to 'examples')
97 files changed, 1989 insertions, 319 deletions
diff --git a/examples/audiolevels/audiolevels.cpp b/examples/audiolevels/audiolevels.cpp index 3677c1f1..18c1342a 100644 --- a/examples/audiolevels/audiolevels.cpp +++ b/examples/audiolevels/audiolevels.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 ** @@ -20,7 +20,7 @@ #include "audiolevels.h" #include <QtDataVisualization/qbardataproxy.h> -#include <QtDataVisualization/q3dvalueaxis.h> +#include <QtDataVisualization/qvalue3daxis.h> #include <QtDataVisualization/q3dscene.h> #include <QtDataVisualization/q3dcamera.h> #include <QtDataVisualization/qbar3dseries.h> @@ -29,7 +29,7 @@ #include <QAudioDeviceInfo> #include <QAudioInput> -QT_DATAVISUALIZATION_USE_NAMESPACE +using namespace QtDataVisualization; AudioLevels::AudioLevels(Q3DBars *graph, QObject *parent) : QObject(parent), @@ -43,30 +43,31 @@ AudioLevels::AudioLevels(Q3DBars *graph, QObject *parent) m_graph->valueAxis()->setRange(-100.0f, 100.0f); m_graph->valueAxis()->setSegmentCount(20); m_graph->valueAxis()->setLabelFormat(QStringLiteral("%d%%")); - m_graph->setShadowQuality(QDataVis::ShadowQualityNone); - m_graph->setSelectionMode(QDataVis::SelectionNone); + m_graph->setShadowQuality(QAbstract3DGraph::ShadowQualityNone); + m_graph->setSelectionMode(QAbstract3DGraph::SelectionNone); m_graph->scene()->activeCamera()->setCameraPosition(-25.0f, 10.0f, 190.0f); - m_graph->setTheme(new Q3DTheme(Q3DTheme::ThemeIsabelle)); - m_graph->theme()->setGridEnabled(true); - m_graph->theme()->setBackgroundEnabled(false); - QFont font = m_graph->theme()->font(); + m_graph->activeTheme()->setType(Q3DTheme::ThemeIsabelle); + m_graph->activeTheme()->setGridEnabled(true); + m_graph->activeTheme()->setBackgroundEnabled(false); + QFont font = m_graph->activeTheme()->font(); font.setPointSize(10); - m_graph->theme()->setFont(font); + m_graph->activeTheme()->setFont(font); QBar3DSeries *series = new QBar3DSeries; series->setMesh(QAbstract3DSeries::MeshBar); m_graph->addSeries(series); //! [0] + QAudioDeviceInfo inputDevice = QAudioDeviceInfo::defaultInputDevice(); + QAudioFormat formatAudio; - formatAudio.setSampleRate(8000); - formatAudio.setChannelCount(1); - formatAudio.setSampleSize(8); - formatAudio.setCodec("audio/pcm"); + formatAudio.setSampleRate(inputDevice.supportedSampleRates().at(0)); + formatAudio.setChannelCount(inputDevice.supportedChannelCounts().at(0)); + formatAudio.setSampleSize(inputDevice.supportedSampleSizes().at(0)); + formatAudio.setCodec(inputDevice.supportedCodecs().at(0)); formatAudio.setByteOrder(QAudioFormat::LittleEndian); formatAudio.setSampleType(QAudioFormat::UnSignedInt); - QAudioDeviceInfo inputDevices = QAudioDeviceInfo::defaultInputDevice(); - m_audioInput = new QAudioInput(inputDevices, formatAudio, this); + m_audioInput = new QAudioInput(inputDevice, formatAudio, this); #ifdef Q_OS_MAC // Mac seems to wait for entire buffer to fill before calling writeData, so use smaller buffer m_audioInput->setBufferSize(256); diff --git a/examples/audiolevels/audiolevels.h b/examples/audiolevels/audiolevels.h index db1d8936..84d9b4c4 100644 --- a/examples/audiolevels/audiolevels.h +++ b/examples/audiolevels/audiolevels.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 ** @@ -21,7 +21,7 @@ #include <QtDataVisualization/q3dbars.h> -QT_DATAVISUALIZATION_USE_NAMESPACE +using namespace QtDataVisualization; class AudioLevelsIODevice; class QAudioInput; diff --git a/examples/audiolevels/audiolevelsiodevice.cpp b/examples/audiolevels/audiolevelsiodevice.cpp index e4576638..c0cd70e3 100644 --- a/examples/audiolevels/audiolevelsiodevice.cpp +++ b/examples/audiolevels/audiolevelsiodevice.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 ** @@ -19,7 +19,7 @@ #include "audiolevelsiodevice.h" #include <QDebug> -QT_DATAVISUALIZATION_USE_NAMESPACE +using namespace QtDataVisualization; //! [1] static const int resolution = 8; diff --git a/examples/audiolevels/audiolevelsiodevice.h b/examples/audiolevels/audiolevelsiodevice.h index 8d665fe8..45f17626 100644 --- a/examples/audiolevels/audiolevelsiodevice.h +++ b/examples/audiolevels/audiolevelsiodevice.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 ** @@ -22,7 +22,7 @@ #include <QtDataVisualization/qbardataproxy.h> #include <QIODevice> -QT_DATAVISUALIZATION_USE_NAMESPACE +using namespace QtDataVisualization; class AudioLevelsIODevice : public QIODevice { diff --git a/examples/audiolevels/doc/images/audiolevels-example.png b/examples/audiolevels/doc/images/audiolevels-example.png Binary files differindex 58566545..ec79eb5a 100644 --- a/examples/audiolevels/doc/images/audiolevels-example.png +++ b/examples/audiolevels/doc/images/audiolevels-example.png diff --git a/examples/audiolevels/doc/src/audiolevels.qdoc b/examples/audiolevels/doc/src/audiolevels.qdoc index d52b2e25..189db184 100644 --- a/examples/audiolevels/doc/src/audiolevels.qdoc +++ b/examples/audiolevels/doc/src/audiolevels.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 ** diff --git a/examples/audiolevels/main.cpp b/examples/audiolevels/main.cpp index 36922aa6..9dd07b1b 100644 --- a/examples/audiolevels/main.cpp +++ b/examples/audiolevels/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 ** 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); diff --git a/examples/custominput/custominputhandler.cpp b/examples/custominput/custominputhandler.cpp index 3b050fda..a5734e16 100644 --- a/examples/custominput/custominputhandler.cpp +++ b/examples/custominput/custominputhandler.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 ** diff --git a/examples/custominput/custominputhandler.h b/examples/custominput/custominputhandler.h index 1fecb8d8..60c88ef7 100644 --- a/examples/custominput/custominputhandler.h +++ b/examples/custominput/custominputhandler.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 ** diff --git a/examples/custominput/doc/images/custominput-example.png b/examples/custominput/doc/images/custominput-example.png Binary files differindex 083bac58..b2656b69 100644 --- a/examples/custominput/doc/images/custominput-example.png +++ b/examples/custominput/doc/images/custominput-example.png diff --git a/examples/custominput/doc/src/custominput.qdoc b/examples/custominput/doc/src/custominput.qdoc index 9bb5607f..88c53b4d 100644 --- a/examples/custominput/doc/src/custominput.qdoc +++ b/examples/custominput/doc/src/custominput.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 ** diff --git a/examples/custominput/main.cpp b/examples/custominput/main.cpp index 8b1aa033..069a5b0a 100644 --- a/examples/custominput/main.cpp +++ b/examples/custominput/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 ** diff --git a/examples/custominput/scatterdatamodifier.cpp b/examples/custominput/scatterdatamodifier.cpp index aabb1b3a..a2a5bea9 100644 --- a/examples/custominput/scatterdatamodifier.cpp +++ b/examples/custominput/scatterdatamodifier.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 ** @@ -19,7 +19,7 @@ #include "scatterdatamodifier.h" #include <QtDataVisualization/QScatterDataProxy> -#include <QtDataVisualization/Q3DValueAxis> +#include <QtDataVisualization/QValue3DAxis> #include <QtDataVisualization/Q3DScene> #include <QtDataVisualization/Q3DCamera> #include <QtDataVisualization/QScatter3DSeries> @@ -32,20 +32,20 @@ ScatterDataModifier::ScatterDataModifier(Q3DScatter *scatter) : m_graph(scatter), m_inputHandler(new CustomInputHandler()) { - m_graph->setTheme(new Q3DTheme(Q3DTheme::ThemeDigia)); - m_graph->setShadowQuality(QDataVis::ShadowQualityMedium); + m_graph->activeTheme()->setType(Q3DTheme::ThemeDigia); + m_graph->setShadowQuality(QAbstract3DGraph::ShadowQualityMedium); m_graph->scene()->activeCamera()->setCameraPreset(Q3DCamera::CameraPresetFront); - m_graph->setAxisX(new Q3DValueAxis); - m_graph->setAxisY(new Q3DValueAxis); - m_graph->setAxisZ(new Q3DValueAxis); + m_graph->setAxisX(new QValue3DAxis); + m_graph->setAxisY(new QValue3DAxis); + m_graph->setAxisZ(new QValue3DAxis); m_graph->axisX()->setRange(-10.0f, 10.0f); m_graph->axisY()->setRange(-5.0f, 5.0f); m_graph->axisZ()->setRange(-5.0f, 5.0f); QScatter3DSeries *series = new QScatter3DSeries; - series->setItemLabelFormat("@xLabel, @yLabel, @zLabel"); + series->setItemLabelFormat(QStringLiteral("@xLabel, @yLabel, @zLabel")); series->setMesh(QAbstract3DSeries::MeshCube); series->setItemSize(0.15f); m_graph->addSeries(series); @@ -159,7 +159,7 @@ void ScatterDataModifier::triggerSelection() m_graph->scene()->setSelectionQueryPosition(m_inputHandler->inputPosition()); } -void ScatterDataModifier::shadowQualityUpdatedByVisual(QDataVis::ShadowQuality sq) +void ScatterDataModifier::shadowQualityUpdatedByVisual(QAbstract3DGraph::ShadowQuality sq) { int quality = int(sq); emit shadowQualityChanged(quality); // connected to a checkbox in main.cpp @@ -167,6 +167,6 @@ void ScatterDataModifier::shadowQualityUpdatedByVisual(QDataVis::ShadowQuality s void ScatterDataModifier::changeShadowQuality(int quality) { - QDataVis::ShadowQuality sq = QDataVis::ShadowQuality(quality); + QAbstract3DGraph::ShadowQuality sq = QAbstract3DGraph::ShadowQuality(quality); m_graph->setShadowQuality(sq); } diff --git a/examples/custominput/scatterdatamodifier.h b/examples/custominput/scatterdatamodifier.h index fc0bc789..9ea6a5c8 100644 --- a/examples/custominput/scatterdatamodifier.h +++ b/examples/custominput/scatterdatamodifier.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 ** @@ -43,7 +43,7 @@ public: public slots: void changeShadowQuality(int quality); - void shadowQualityUpdatedByVisual(QDataVis::ShadowQuality shadowQuality); + void shadowQualityUpdatedByVisual(QAbstract3DGraph::ShadowQuality shadowQuality); void triggerSelection(); signals: diff --git a/examples/customproxy/doc/images/customproxy-example.png b/examples/customproxy/doc/images/customproxy-example.png Binary files differindex 3dc65bbb..753b8951 100644 --- a/examples/customproxy/doc/images/customproxy-example.png +++ b/examples/customproxy/doc/images/customproxy-example.png diff --git a/examples/customproxy/doc/src/customproxy.qdoc b/examples/customproxy/doc/src/customproxy.qdoc index dacedb80..8b506583 100644 --- a/examples/customproxy/doc/src/customproxy.qdoc +++ b/examples/customproxy/doc/src/customproxy.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 ** diff --git a/examples/customproxy/main.cpp b/examples/customproxy/main.cpp index 58b43873..dd74721e 100644 --- a/examples/customproxy/main.cpp +++ b/examples/customproxy/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 ** diff --git a/examples/customproxy/rainfallgraph.cpp b/examples/customproxy/rainfallgraph.cpp index ad45d016..e2f04923 100644 --- a/examples/customproxy/rainfallgraph.cpp +++ b/examples/customproxy/rainfallgraph.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 "rainfallgraph.h" -#include <QtDataVisualization/q3dcategoryaxis.h> -#include <QtDataVisualization/q3dvalueaxis.h> +#include <QtDataVisualization/qcategory3daxis.h> +#include <QtDataVisualization/qvalue3daxis.h> #include <QtDataVisualization/q3dscene.h> #include <QtDataVisualization/q3dcamera.h> #include <QtDataVisualization/qbar3dseries.h> @@ -66,20 +66,22 @@ RainfallGraph::RainfallGraph(Q3DBars *rainfall) series->setMesh(QAbstract3DSeries::MeshCylinder); // Set shadows to medium - m_graph->setShadowQuality(QDataVis::ShadowQualityMedium); + m_graph->setShadowQuality(QAbstract3DGraph::ShadowQualityMedium); // Set selection mode to bar and column - m_graph->setSelectionMode(QDataVis::SelectionItemAndColumn | QDataVis::SelectionSlice); + m_graph->setSelectionMode(QAbstract3DGraph::SelectionItemAndColumn | QAbstract3DGraph::SelectionSlice); // Set theme - m_graph->setTheme(new Q3DTheme(Q3DTheme::ThemeArmyBlue)); + m_graph->activeTheme()->setType(Q3DTheme::ThemeArmyBlue); - // Set font to theme - m_graph->theme()->setFont(QFont("Century Gothic", 30)); + // Override font in theme + m_graph->activeTheme()->setFont(QFont("Century Gothic", 30)); + + // Override label background for theme + m_graph->activeTheme()->setLabelBackgroundEnabled(false); // Set camera position and zoom m_graph->scene()->activeCamera()->setCameraPreset(Q3DCamera::CameraPresetIsometricRightHigh); - m_graph->scene()->activeCamera()->setZoomLevel(75); // Set window title m_graph->setTitle(QStringLiteral("Monthly rainfall in Northern Finland")); diff --git a/examples/customproxy/rainfallgraph.h b/examples/customproxy/rainfallgraph.h index 6317ab71..6116eb9b 100644 --- a/examples/customproxy/rainfallgraph.h +++ b/examples/customproxy/rainfallgraph.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 ** diff --git a/examples/customproxy/variantbardatamapping.cpp b/examples/customproxy/variantbardatamapping.cpp index 0c2f146c..c8369b6e 100644 --- a/examples/customproxy/variantbardatamapping.cpp +++ b/examples/customproxy/variantbardatamapping.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 ** diff --git a/examples/customproxy/variantbardatamapping.h b/examples/customproxy/variantbardatamapping.h index 9ccf1610..3a145d9a 100644 --- a/examples/customproxy/variantbardatamapping.h +++ b/examples/customproxy/variantbardatamapping.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 ** @@ -19,11 +19,8 @@ #ifndef VARIANTBARDATAMAPPING_H #define VARIANTBARDATAMAPPING_H -#include "qdatavisualizationenums.h" #include <QStringList> -using namespace QtDataVisualization; - class VariantBarDataMapping : public QObject { Q_OBJECT diff --git a/examples/customproxy/variantbardataproxy.cpp b/examples/customproxy/variantbardataproxy.cpp index 2997810f..cf1e1f90 100644 --- a/examples/customproxy/variantbardataproxy.cpp +++ b/examples/customproxy/variantbardataproxy.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 ** diff --git a/examples/customproxy/variantbardataproxy.h b/examples/customproxy/variantbardataproxy.h index 6f6ba763..b83f8a71 100644 --- a/examples/customproxy/variantbardataproxy.h +++ b/examples/customproxy/variantbardataproxy.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 ** diff --git a/examples/customproxy/variantdataset.cpp b/examples/customproxy/variantdataset.cpp index f73d83f8..3576aaab 100644 --- a/examples/customproxy/variantdataset.cpp +++ b/examples/customproxy/variantdataset.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 ** diff --git a/examples/customproxy/variantdataset.h b/examples/customproxy/variantdataset.h index 6beb852f..f5eb5863 100644 --- a/examples/customproxy/variantdataset.h +++ b/examples/customproxy/variantdataset.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 ** @@ -19,12 +19,9 @@ #ifndef VARIANTDATASET_H #define VARIANTDATASET_H -#include "qdatavisualizationenums.h" #include <QScopedPointer> #include <QVariantList> -using namespace QtDataVisualization; - //! [1] typedef QVariantList VariantDataItem; typedef QList<VariantDataItem *> VariantDataItemList; diff --git a/examples/examples.pri b/examples/examples.pri index ca91aad0..046d6cd1 100644 --- a/examples/examples.pri +++ b/examples/examples.pri @@ -19,10 +19,17 @@ TEMPLATE = app QT += datavisualization +!static:android { + # Add Qt library to be loaded in shared android build + vis_lib_name = DataVisualization + vis_src_lib = lib$${vis_lib_name}.so + vis_lib_dir = $$OUT_PWD/../../lib/$$vis_src_lib + ANDROID_EXTRA_LIBS = $$vis_lib_dir +} + contains(TARGET, qml.*) { uri = QtDataVisualization lib_name = datavisualizationqml2 - vis_lib_name = DataVisualization uri_replaced = $$replace(uri, \\., $$QMAKE_DIR_SEP) make_qmldir_path = $$DESTDIR/$$uri_replaced @@ -37,32 +44,53 @@ contains(TARGET, qml.*) { QMAKE_EXTRA_TARGETS += copy_qmldir PRE_TARGETDEPS += $$copy_qmldir.target + static:contains(QT_CONFIG, static) { + # Make import scan find our copied qmldir & statically built qml lib + !win32 { + LIB_EXTENSION = a + } else { + LIB_EXTENSION = lib + } + QMLPATHS += $$DESTDIR + # We need to copy the qmldir & lib already at qmake run stage as import scan is done then + exists($$copy_qmldir.depends): system($$QMAKE_COPY $$copy_qmldir_formatted) + } else { + win32 { + LIB_EXTENSION = dll + } else { + mac|ios { + LIB_EXTENSION = dylib + } else { + LIB_EXTENSION = so + } + } + } + win32 { CONFIG(debug, release|debug) { - src_dir = debug - src_lib = $${lib_name}d.dll + src_dir = /debug + src_lib = $${lib_name}d.$$LIB_EXTENSION } CONFIG(release, release|debug){ - src_dir = release - src_lib = $${lib_name}.dll + src_dir = /release + src_lib = $${lib_name}.$$LIB_EXTENSION } } else { - src_dir = . - mac { + src_dir = + mac|ios { CONFIG(debug, release|debug) { - src_lib = lib$${lib_name}_debug.dylib + src_lib = lib$${lib_name}_debug.$$LIB_EXTENSION } CONFIG(release, release|debug){ - src_lib = lib$${lib_name}.dylib + src_lib = lib$${lib_name}.$$LIB_EXTENSION } } else { # linux, android - src_lib = lib$${lib_name}.so - vis_src_lib = lib$${vis_lib_name}.so + src_lib = lib$${lib_name}.$$LIB_EXTENSION } } copy_lib.target = $$make_qmldir_path/$$src_lib - copy_lib.depends = $$OUT_PWD/../../src/$$lib_name/$$src_dir/$$src_lib + copy_lib.depends = $$OUT_PWD/../../src/$$lib_name$$src_dir/$$src_lib copy_lib_formatted = \"$$replace(copy_lib.depends, /, $$QMAKE_DIR_SEP)\" \"$$replace(copy_lib.target, /, $$QMAKE_DIR_SEP)\" copy_lib.commands = $(COPY_FILE) $$copy_lib_formatted QMAKE_EXTRA_TARGETS += copy_lib @@ -70,14 +98,14 @@ contains(TARGET, qml.*) { android { system($$QMAKE_COPY $$copy_qmldir_formatted) - system($$QMAKE_COPY $$copy_lib_formatted) android_qmldir.files = $$copy_qmldir.target android_qmldir.path = /assets/qml/$$uri_replaced + INSTALLS += android_qmldir + } + android|ios { + system($$QMAKE_COPY $$copy_lib_formatted) android_qmlplugin.files = $$copy_lib.target android_qmlplugin.path = $$target.path - vis_lib_dir = $$OUT_PWD/../../lib/$$vis_src_lib - vis_lib_formatted = $$replace(vis_lib_dir, /, $$QMAKE_DIR_SEP) - ANDROID_EXTRA_LIBS = $$vis_lib_formatted - INSTALLS += android_qmldir android_qmlplugin + INSTALLS += android_qmlplugin } } diff --git a/examples/examples.pro b/examples/examples.pro index d126b26d..4dd3edef 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -2,8 +2,11 @@ TEMPLATE = subdirs SUBDIRS += qmlbars \ qmlscatter \ qmlsurface \ - qmlcustominput -!android: { + qmlcustominput \ + qmllegend \ + qmlmultigraph + +!android:!ios { SUBDIRS += bars \ custominput \ customproxy \ diff --git a/examples/itemmodel/doc/images/itemmodel-example-2.png b/examples/itemmodel/doc/images/itemmodel-example-2.png Binary files differindex f8a0535a..677b7eec 100644 --- a/examples/itemmodel/doc/images/itemmodel-example-2.png +++ b/examples/itemmodel/doc/images/itemmodel-example-2.png diff --git a/examples/itemmodel/doc/images/itemmodel-example.png b/examples/itemmodel/doc/images/itemmodel-example.png Binary files differindex 68a4d970..c042f84d 100644 --- a/examples/itemmodel/doc/images/itemmodel-example.png +++ b/examples/itemmodel/doc/images/itemmodel-example.png diff --git a/examples/itemmodel/doc/src/itemmodel.qdoc b/examples/itemmodel/doc/src/itemmodel.qdoc index 6812c374..16cd1974 100644 --- a/examples/itemmodel/doc/src/itemmodel.qdoc +++ b/examples/itemmodel/doc/src/itemmodel.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 ** @@ -88,8 +88,8 @@ means there will be a gap of 20% of the bar's thickness between the bars in both directions. We want to be able to select rows of data for a closer inspection, so we set the selection mode - to slice row. This means that whenever we select a bar in the graph, the whole row will be - displayed separately. + to slice item and row. This means that whenever we select a bar in the graph, the whole row will be + displayed separately and the selected bar will be highlighted. We don't want to use the default colors, so we set one of the predefined themes as the active theme. diff --git a/examples/itemmodel/main.cpp b/examples/itemmodel/main.cpp index 46aa8bb8..b6b67f85 100644 --- a/examples/itemmodel/main.cpp +++ b/examples/itemmodel/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 ** @@ -17,9 +17,9 @@ ****************************************************************************/ #include <QtDataVisualization/q3dbars.h> -#include <QtDataVisualization/q3dcategoryaxis.h> +#include <QtDataVisualization/qcategory3daxis.h> #include <QtDataVisualization/qitemmodelbardataproxy.h> -#include <QtDataVisualization/q3dvalueaxis.h> +#include <QtDataVisualization/qvalue3daxis.h> #include <QtDataVisualization/q3dscene.h> #include <QtDataVisualization/q3dcamera.h> #include <QtDataVisualization/qbar3dseries.h> @@ -84,22 +84,23 @@ GraphDataGenerator::GraphDataGenerator(Q3DBars *bargraph, QTableWidget *tableWid #ifndef USE_STATIC_DATA // Set up sample space; make it as deep as it's wide - m_graph->setDataWindow(m_rowCount, m_columnCount); + m_graph->rowAxis()->setRange(0, m_rowCount); + m_graph->columnAxis()->setRange(0, m_columnCount); m_tableWidget->setColumnCount(m_columnCount); // Set selection mode to full - m_graph->setSelectionMode(QDataVis::SelectionItemRowAndColumn); + m_graph->setSelectionMode(QAbstract3DGraph::SelectionItemRowAndColumn); // Hide axis labels by explicitly setting one empty string as label list - m_graph->rowAxis()->setCategoryLabels(QStringList(QString())); - m_graph->columnAxis()->setCategoryLabels(QStringList(QString())); + m_graph->rowAxis()->setLabels(QStringList(QString())); + m_graph->columnAxis()->setLabels(QStringList(QString())); - m_graph->activeDataProxy()->setItemLabelFormat(QStringLiteral("@valueLabel")); + m_graph->seriesList().at(0)->setItemLabelFormat(QStringLiteral("@valueLabel")); #else //! [6] // Set selection mode to slice row - m_graph->setSelectionMode(QDataVis::SelectionItemAndRow | QDataVis::SelectionSlice); + m_graph->setSelectionMode(QAbstract3DGraph::SelectionItemAndRow | QAbstract3DGraph::SelectionSlice); //! [6] #endif @@ -107,10 +108,10 @@ GraphDataGenerator::GraphDataGenerator(Q3DBars *bargraph, QTableWidget *tableWid //! [7] // Set theme - m_graph->setTheme(new Q3DTheme(Q3DTheme::ThemeDigia)); + m_graph->activeTheme()->setType(Q3DTheme::ThemeDigia); // Set font - m_graph->theme()->setFont(QFont("Impact", 20)); + m_graph->activeTheme()->setFont(QFont("Impact", 20)); // Set preset camera position m_graph->scene()->activeCamera()->setCameraPreset(Q3DCamera::CameraPresetFront); diff --git a/examples/qmlbars/doc/images/qmlbars-example.png b/examples/qmlbars/doc/images/qmlbars-example.png Binary files differindex 00fb4a4f..64ad6b0e 100644 --- a/examples/qmlbars/doc/images/qmlbars-example.png +++ b/examples/qmlbars/doc/images/qmlbars-example.png diff --git a/examples/qmlbars/doc/src/qmlbars.qdoc b/examples/qmlbars/doc/src/qmlbars.qdoc index d56253d0..ecd8055a 100644 --- a/examples/qmlbars/doc/src/qmlbars.qdoc +++ b/examples/qmlbars/doc/src/qmlbars.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 ** diff --git a/examples/qmlbars/main.cpp b/examples/qmlbars/main.cpp index 889e2fa4..001c5625 100644 --- a/examples/qmlbars/main.cpp +++ b/examples/qmlbars/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 ** @@ -16,6 +16,7 @@ ** ****************************************************************************/ +#include <QtDataVisualization/qutils.h> #include <QtGui/QGuiApplication> #include "qtquick2applicationviewer.h" #ifdef Q_OS_ANDROID @@ -30,15 +31,8 @@ int main(int argc, char *argv[]) QtQuick2ApplicationViewer viewer; -#if !defined(QT_OPENGL_ES_2) // Enable antialiasing - QSurfaceFormat surfaceFormat; - surfaceFormat.setDepthBufferSize(24); - surfaceFormat.setSamples(8); - surfaceFormat.setRenderableType(QSurfaceFormat::OpenGL); - surfaceFormat.setSwapBehavior(QSurfaceFormat::DoubleBuffer); - viewer.setFormat(surfaceFormat); -#endif + viewer.setFormat(QtDataVisualization::qDefaultSurfaceFormat()); #ifdef Q_OS_ANDROID viewer.addImportPath(QString::fromLatin1("assets:/qml")); diff --git a/examples/qmlbars/qml/qmlbars/axes.qml b/examples/qmlbars/qml/qmlbars/axes.qml index f5eb8d26..29979e1b 100644 --- a/examples/qmlbars/qml/qmlbars/axes.qml +++ b/examples/qmlbars/qml/qmlbars/axes.qml @@ -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 ** diff --git a/examples/qmlbars/qml/qmlbars/data.qml b/examples/qmlbars/qml/qmlbars/data.qml index 5a17bcd1..7e0978c6 100644 --- a/examples/qmlbars/qml/qmlbars/data.qml +++ b/examples/qmlbars/qml/qmlbars/data.qml @@ -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,7 +17,6 @@ ****************************************************************************/ import QtQuick 2.1 -import QtDataVisualization 1.0 Item { property alias model: dataModel diff --git a/examples/qmlbars/qml/qmlbars/main.qml b/examples/qmlbars/qml/qmlbars/main.qml index 0581f834..0ff060ca 100644 --- a/examples/qmlbars/qml/qmlbars/main.qml +++ b/examples/qmlbars/qml/qmlbars/main.qml @@ -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 ** @@ -43,7 +43,7 @@ Item { selectedSeries: barSeries function handleSelectionChange(series, position) { - if (position != series.invalidSelectionPosition()) { + if (position != series.invalidSelectionPosition) { selectedSeries = series } @@ -76,7 +76,7 @@ Item { anchors.bottom: mainview.bottom Bars3D { - id: testGraph + id: barGraph width: dataView.width height: dataView.height shadowQuality: AbstractGraph3D.ShadowQualityMedium @@ -189,7 +189,7 @@ Item { clip: true //! [1] onClicked: { - if (testGraph.rowAxis.max !== 6) { + if (barGraph.rowAxis.max !== 6) { text = "Show 2010 - 2012" modelProxy.autoRowCategories = true secondaryProxy.autoRowCategories = true @@ -213,11 +213,11 @@ Item { text: "Hide Shadows" clip: true onClicked: { - if (testGraph.shadowQuality == AbstractGraph3D.ShadowQualityNone) { - testGraph.shadowQuality = AbstractGraph3D.ShadowQualityMedium; + if (barGraph.shadowQuality == AbstractGraph3D.ShadowQualityNone) { + barGraph.shadowQuality = AbstractGraph3D.ShadowQualityMedium; text = "Hide Shadows" } else { - testGraph.shadowQuality = AbstractGraph3D.ShadowQualityNone; + barGraph.shadowQuality = AbstractGraph3D.ShadowQualityNone; text = "Show Shadows" } } @@ -233,17 +233,17 @@ Item { onClicked: { if (!secondarySeries.visible) { text = "Show Both" - testGraph.valueAxis = graphAxes.expenses + barGraph.valueAxis = graphAxes.expenses barSeries.visible = false secondarySeries.visible = true } else if (!barSeries.visible){ barSeries.visible = true text = "Show Income" - testGraph.valueAxis = graphAxes.income + barGraph.valueAxis = graphAxes.income } else { secondarySeries.visible = false text = "Show Expenses" - testGraph.valueAxis = graphAxes.income + barGraph.valueAxis = graphAxes.income } } //! [0] diff --git a/examples/qmlcustominput/doc/images/qmlcustominput-example.png b/examples/qmlcustominput/doc/images/qmlcustominput-example.png Binary files differindex 436f4da5..1de740ea 100644 --- a/examples/qmlcustominput/doc/images/qmlcustominput-example.png +++ b/examples/qmlcustominput/doc/images/qmlcustominput-example.png diff --git a/examples/qmlcustominput/doc/src/qmlcustominput.qdoc b/examples/qmlcustominput/doc/src/qmlcustominput.qdoc index 14943aa0..7702dadf 100644 --- a/examples/qmlcustominput/doc/src/qmlcustominput.qdoc +++ b/examples/qmlcustominput/doc/src/qmlcustominput.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 ** diff --git a/examples/qmlcustominput/main.cpp b/examples/qmlcustominput/main.cpp index 8724e511..fcdd0035 100644 --- a/examples/qmlcustominput/main.cpp +++ b/examples/qmlcustominput/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 ** @@ -16,6 +16,7 @@ ** ****************************************************************************/ +#include <QtDataVisualization/qutils.h> #include <QtGui/QGuiApplication> #include "qtquick2applicationviewer.h" #ifdef Q_OS_ANDROID @@ -30,15 +31,8 @@ int main(int argc, char *argv[]) QtQuick2ApplicationViewer viewer; -#if !defined(QT_OPENGL_ES_2) // Enable antialiasing - QSurfaceFormat surfaceFormat; - surfaceFormat.setDepthBufferSize(24); - surfaceFormat.setSamples(8); - surfaceFormat.setRenderableType(QSurfaceFormat::OpenGL); - surfaceFormat.setSwapBehavior(QSurfaceFormat::DoubleBuffer); - viewer.setFormat(surfaceFormat); -#endif + viewer.setFormat(QtDataVisualization::qDefaultSurfaceFormat()); #ifdef Q_OS_ANDROID viewer.addImportPath(QString::fromLatin1("assets:/qml")); diff --git a/examples/qmlcustominput/qml/qmlcustominput/data.qml b/examples/qmlcustominput/qml/qmlcustominput/data.qml index 1de07998..201247f1 100644 --- a/examples/qmlcustominput/qml/qmlcustominput/data.qml +++ b/examples/qmlcustominput/qml/qmlcustominput/data.qml @@ -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,7 +17,6 @@ ****************************************************************************/ import QtQuick 2.1 -import QtDataVisualization 1.0 Item { property alias model: dataModel diff --git a/examples/qmlcustominput/qml/qmlcustominput/main.qml b/examples/qmlcustominput/qml/qmlcustominput/main.qml index 54ec3342..cfac0f15 100644 --- a/examples/qmlcustominput/qml/qmlcustominput/main.qml +++ b/examples/qmlcustominput/qml/qmlcustominput/main.qml @@ -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 ** diff --git a/examples/qmlcustominput/qml/qmlcustominput/newbutton.qml b/examples/qmlcustominput/qml/qmlcustominput/newbutton.qml index e44c9d1a..e4fb99d2 100644 --- a/examples/qmlcustominput/qml/qmlcustominput/newbutton.qml +++ b/examples/qmlcustominput/qml/qmlcustominput/newbutton.qml @@ -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 ** diff --git a/examples/qmllegend/doc/images/qmllegend-example.png b/examples/qmllegend/doc/images/qmllegend-example.png Binary files differnew file mode 100644 index 00000000..ee546077 --- /dev/null +++ b/examples/qmllegend/doc/images/qmllegend-example.png diff --git a/examples/qmllegend/doc/src/qmllegend.qdoc b/examples/qmllegend/doc/src/qmllegend.qdoc new file mode 100644 index 00000000..14bacf06 --- /dev/null +++ b/examples/qmllegend/doc/src/qmllegend.qdoc @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the QtDataVisualization module. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ + +/*! + \example qmllegend + \title Qt Quick 2 Legend Example + \ingroup qtdatavisualization_examples + \brief Showing graph legend in a QML application. + + The Qt Quick 2 legend example shows how to make an interactive legend for a graph. + + \image qmllegend-example.png + + The interesting thing about this example is displaying the legend. We'll concentrate on + that and skip explaining the basic functionality - for + more detailed QML example documentation, see \l{Qt Quick 2 Scatter Example}. + + \section1 Legend + + The legend is simply a column of custom \c LegendItem items inside a transparent rectangle. + Each item is supplied with a series and the graph theme: + + \snippet ../examples/qmllegend/qml/qmllegend/main.qml 0 + + The legend items consist of a marker rectangle, which indicates the color of the series, + and a text field, which shows the name of the series. The colors we get from the series and + the theme supplied at legend item initialization: + + \snippet ../examples/qmllegend/qml/qmllegend/legenditem.qml 0 + \dots 4 + \snippet ../examples/qmllegend/qml/qmllegend/legenditem.qml 1 + + We want the legend to be interactive, so we add additional logic to enable selection of a + series by clicking on a legend item, as well as highlighting the legend item corresponding + to the selected series. + + The highlight depends on the selection state of the series, so we define two states, which + follow the Bar3DSeries::selectedBar property and adjust the \c legendItem color appropriately: + + \snippet ../examples/qmllegend/qml/qmllegend/legenditem.qml 3 + + To make the legend item interactive, we define a MouseArea to detect clicks on it and adjust + the series selection accordingly: + + \snippet ../examples/qmllegend/qml/qmllegend/legenditem.qml 2 + + The \c previousSelection used above is another custom property of \c LegendItem, which we update + whenever selection changes on the series. This way we remember the last selected bar of + each series: + + \snippet ../examples/qmllegend/qml/qmllegend/legenditem.qml 4 +*/ diff --git a/examples/qmllegend/main.cpp b/examples/qmllegend/main.cpp new file mode 100644 index 00000000..954affe4 --- /dev/null +++ b/examples/qmllegend/main.cpp @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the QtDataVisualization module. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ + +#include <QtDataVisualization/qutils.h> +#include <QtGui/QGuiApplication> +#include "qtquick2applicationviewer.h" +#ifdef Q_OS_ANDROID +#include <QDir> +#include <QQmlEngine> +#endif +#include <QDebug> + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + QtQuick2ApplicationViewer viewer; + + // Enable antialiasing + viewer.setFormat(QtDataVisualization::qDefaultSurfaceFormat()); + +#ifdef Q_OS_ANDROID + viewer.addImportPath(QString::fromLatin1("assets:/qml")); + viewer.engine()->addPluginPath(QString::fromLatin1("%1/../%2").arg(QDir::homePath(), + QString::fromLatin1("lib"))); +#endif + viewer.setTitle(QStringLiteral("Legend example")); + + viewer.setSource(QUrl("qrc:/qml/main.qml")); + viewer.setResizeMode(QQuickView::SizeRootObjectToView); + viewer.show(); + + return app.exec(); +} diff --git a/examples/qmllegend/qml/qmllegend/data.qml b/examples/qmllegend/qml/qmllegend/data.qml new file mode 100644 index 00000000..4681c61c --- /dev/null +++ b/examples/qmllegend/qml/qmllegend/data.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the QtDataVisualization module. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ + +import QtQuick 2.1 + +Item { + property alias model: dataModel + + ListModel { + id: dataModel + ListElement{ year: "2010"; month: "Jan"; s1: "-14"; s2: "-15"; s3: "-15" } + ListElement{ year: "2010"; month: "Feb"; s1: "-15"; s2: "-16"; s3: "-9" } + ListElement{ year: "2010"; month: "Mar"; s1: "-7"; s2: "-4"; s3: "-2" } + ListElement{ year: "2010"; month: "Apr"; s1: "3"; s2: "2"; s3: "2" } + ListElement{ year: "2010"; month: "May"; s1: "7"; s2: "9"; s3: "10" } + ListElement{ year: "2010"; month: "Jun"; s1: "12"; s2: "13"; s3: "22" } + ListElement{ year: "2010"; month: "Jul"; s1: "18"; s2: "19"; s3: "24" } + ListElement{ year: "2010"; month: "Aug"; s1: "15"; s2: "13"; s3: "16" } + ListElement{ year: "2010"; month: "Sep"; s1: "6"; s2: "3"; s3: "4" } + ListElement{ year: "2010"; month: "Oct"; s1: "1"; s2: "2"; s3: "-2" } + ListElement{ year: "2010"; month: "Nov"; s1: "-2"; s2: "-5"; s3: "-6" } + ListElement{ year: "2010"; month: "Dec"; s1: "-3"; s2: "-3"; s3: "-9" } + + ListElement{ year: "2011"; month: "Jan"; s1: "-12"; s2: "-11"; s3: "-14" } + ListElement{ year: "2011"; month: "Feb"; s1: "-13"; s2: "-12"; s3: "-10" } + ListElement{ year: "2011"; month: "Mar"; s1: "-6"; s2: "-4"; s3: "-3" } + ListElement{ year: "2011"; month: "Apr"; s1: "0"; s2: "1"; s3: "3" } + ListElement{ year: "2011"; month: "May"; s1: "4"; s2: "12"; s3: "11" } + ListElement{ year: "2011"; month: "Jun"; s1: "9"; s2: "17"; s3: "23" } + ListElement{ year: "2011"; month: "Jul"; s1: "15"; s2: "22"; s3: "25" } + ListElement{ year: "2011"; month: "Aug"; s1: "12"; s2: "15"; s3: "12" } + ListElement{ year: "2011"; month: "Sep"; s1: "2"; s2: "4"; s3: "7" } + ListElement{ year: "2011"; month: "Oct"; s1: "-2"; s2: "4"; s3: "-4" } + ListElement{ year: "2011"; month: "Nov"; s1: "-4"; s2: "-8"; s3: "-5" } + ListElement{ year: "2011"; month: "Dec"; s1: "-6"; s2: "-6"; s3: "-7" } + + ListElement{ year: "2012"; month: "Jan"; s1: "-10"; s2: "-19"; s3: "-11" } + ListElement{ year: "2012"; month: "Feb"; s1: "-11"; s2: "-17"; s3: "-4" } + ListElement{ year: "2012"; month: "Mar"; s1: "-6"; s2: "-3"; s3: "-1" } + ListElement{ year: "2012"; month: "Apr"; s1: "5"; s2: "1"; s3: "2" } + ListElement{ year: "2012"; month: "May"; s1: "9"; s2: "12"; s3: "13" } + ListElement{ year: "2012"; month: "Jun"; s1: "11"; s2: "16"; s3: "26" } + ListElement{ year: "2012"; month: "Jul"; s1: "18"; s2: "20"; s3: "23" } + ListElement{ year: "2012"; month: "Aug"; s1: "19"; s2: "12"; s3: "12" } + ListElement{ year: "2012"; month: "Sep"; s1: "9"; s2: "1"; s3: "3" } + ListElement{ year: "2012"; month: "Oct"; s1: "-3"; s2: "2"; s3: "-1" } + ListElement{ year: "2012"; month: "Nov"; s1: "-5"; s2: "-4"; s3: "-3" } + ListElement{ year: "2012"; month: "Dec"; s1: "-7"; s2: "-2"; s3: "-4" } + + ListElement{ year: "2013"; month: "Jan"; s1: "-18"; s2: "-19"; s3: "-19" } + ListElement{ year: "2013"; month: "Feb"; s1: "-17"; s2: "-19"; s3: "-12" } + ListElement{ year: "2013"; month: "Mar"; s1: "-9"; s2: "-6"; s3: "-5" } + ListElement{ year: "2013"; month: "Apr"; s1: "0"; s2: "0"; s3: "0" } + ListElement{ year: "2013"; month: "May"; s1: "4"; s2: "7"; s3: "9" } + ListElement{ year: "2013"; month: "Jun"; s1: "9"; s2: "11"; s3: "18" } + ListElement{ year: "2013"; month: "Jul"; s1: "13"; s2: "15"; s3: "20" } + ListElement{ year: "2013"; month: "Aug"; s1: "10"; s2: "11"; s3: "13" } + ListElement{ year: "2013"; month: "Sep"; s1: "3"; s2: "1"; s3: "2" } + ListElement{ year: "2013"; month: "Oct"; s1: "0"; s2: "1"; s3: "-4" } + ListElement{ year: "2013"; month: "Nov"; s1: "-5"; s2: "-6"; s3: "-5" } + ListElement{ year: "2013"; month: "Dec"; s1: "-6"; s2: "-7"; s3: "-10" } + } +} diff --git a/examples/qmllegend/qml/qmllegend/legenditem.qml b/examples/qmllegend/qml/qmllegend/legenditem.qml new file mode 100644 index 00000000..50be7a8d --- /dev/null +++ b/examples/qmllegend/qml/qmllegend/legenditem.qml @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the QtDataVisualization module. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ + +import QtQuick 2.1 +import QtQuick.Layouts 1.0 +import QtQuick.Window 2.1 +import QtDataVisualization 1.0 + +Rectangle { + //! [0] + property Theme3D theme + property Bar3DSeries series + //! [0] + property point previousSelection + + id: legendItem + state: "unselected" + + //! [1] + RowLayout { + anchors.fill: parent + spacing: 0 + clip: true + Item { + id: markerSpace + Layout.minimumWidth: 20 + Layout.minimumHeight: 20 + Layout.fillWidth: true + Layout.fillHeight: true + Layout.alignment: Qt.AlignVCenter + Rectangle { + x: parent.x + parent.width / 4 + y: parent.y + parent.height / 4 + width: parent.width / 2 + height: width + border.color: "black" + color: series.baseColor + } + } + Item { + height: markerSpace.height + Layout.fillWidth: true + Layout.fillHeight: true + Layout.alignment: Qt.AlignVCenter + Layout.minimumWidth: 100 + Text { + anchors.fill: parent + text: series.name + verticalAlignment: Text.AlignVCenter + clip: true + color: theme.labelTextColor + font: theme.font + } + } + } + //! [1] + + //! [2] + MouseArea { + id: mouseArea + anchors.fill: legendItem + onClicked: { + if (legendItem.state === "selected") { + series.selectedBar = series.invalidSelectionPosition + } else { + series.selectedBar = previousSelection + } + } + } + //! [2] + + //! [4] + Connections { + target: series + onSelectedBarChanged: { + if (position != series.invalidSelectionPosition) { + previousSelection = position + } + } + } + //! [4] + + //! [3] + states: [ + State { + name: "selected" + when: series.selectedBar != series.invalidSelectionPosition + PropertyChanges { + target: legendItem + color: series.singleHighlightColor + } + }, + State { + name: "unselected" + when: series.selectedBar == series.invalidSelectionPosition + PropertyChanges { + target: legendItem + color: theme.labelBackgroundColor + } + } + ] + //! [3] +} diff --git a/examples/qmllegend/qml/qmllegend/main.qml b/examples/qmllegend/qml/qmllegend/main.qml new file mode 100644 index 00000000..6c488d6a --- /dev/null +++ b/examples/qmllegend/qml/qmllegend/main.qml @@ -0,0 +1,239 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the QtDataVisualization module. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ + +import QtQuick 2.1 +import QtQuick.Controls 1.0 +import QtQuick.Layouts 1.0 +import QtDataVisualization 1.0 +import "." + +Item { + id: mainView + width: 800 + height: 600 + + property int buttonLayoutHeight: 180; + + Data { + id: graphData + } + + Theme3D { + id: firstTheme + type: Theme3D.ThemeQt + } + + Theme3D { + id: secondTheme + type: Theme3D.ThemeEbony + } + + Item { + id: dataView + anchors.top: buttonLayout.bottom + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.right: parent.right + + Bars3D { + id: barGraph + anchors.fill: parent + selectionMode: AbstractGraph3D.SelectionItemAndRow + scene.activeCamera.cameraPreset: Camera3D.CameraPresetIsometricLeftHigh + theme: firstTheme + valueAxis.labelFormat: "%d\u00B0C" + + Bar3DSeries { + id: station1 + name: "Station 1" + itemLabelFormat: "Temperature at @seriesName for @colLabel, @rowLabel: @valueLabel" + + ItemModelBarDataProxy { + itemModel: graphData.model + rowRole: "year" + columnRole: "month" + valueRole: "s1" + } + } + Bar3DSeries { + id: station2 + name: "Station 2" + itemLabelFormat: "Temperature at @seriesName for @colLabel, @rowLabel: @valueLabel" + + ItemModelBarDataProxy { + itemModel: graphData.model + rowRole: "year" + columnRole: "month" + valueRole: "s2" + } + } + Bar3DSeries { + id: station3 + name: "Station 3" + itemLabelFormat: "Temperature at @seriesName for @colLabel, @rowLabel: @valueLabel" + + ItemModelBarDataProxy { + itemModel: graphData.model + rowRole: "year" + columnRole: "month" + valueRole: "s2" + } + } + } + } + + Rectangle { + property int legendLocation: 3 + + id: legendPanel + width: 200 + height: 100 + border.color: barGraph.theme.labelTextColor + border.width: 2 + color: "#00000000" // Transparent + + //! [0] + ColumnLayout { + anchors.fill: parent + anchors.margins: parent.border.width + spacing: 0 + clip: true + LegendItem { + Layout.fillWidth: true + Layout.fillHeight: true + series: station1 + theme: barGraph.theme + onColorChanged: legendPanel.relayout() + } + LegendItem { + Layout.fillWidth: true + Layout.fillHeight: true + series: station2 + theme: barGraph.theme + onColorChanged: legendPanel.relayout() + } + LegendItem { + Layout.fillWidth: true + Layout.fillHeight: true + series: station3 + theme: barGraph.theme + onColorChanged: legendPanel.relayout() + } + } + //! [0] + + function relayout() { + // Workaround for a layout bug that causes transparent colors to use black background + // instead of what is actually under the items if just the color changes. + // Forcing a relayout by adjusting layout's available area fixes the background. + var originalWidth = border.width + border.width = originalWidth + 1 + border.width = originalWidth + } + + states: [ + State { + name: "topleft" + when: legendPanel.legendLocation === 1 + AnchorChanges { + target: legendPanel + anchors.top: dataView.top + anchors.bottom: undefined + anchors.left: dataView.left + anchors.right: undefined + } + }, + State { + name: "topright" + when: legendPanel.legendLocation === 2 + AnchorChanges { + target: legendPanel + anchors.top: dataView.top + anchors.bottom: undefined + anchors.left: undefined + anchors.right: dataView.right + } + }, + State { + name: "bottomleft" + when: legendPanel.legendLocation === 3 + AnchorChanges { + target: legendPanel + anchors.top: undefined + anchors.bottom: dataView.bottom + anchors.left: dataView.left + anchors.right: undefined + } + }, + State { + name: "bottomright" + when: legendPanel.legendLocation === 4 + AnchorChanges { + target: legendPanel + anchors.top: undefined + anchors.bottom: dataView.bottom + anchors.left: undefined + anchors.right: dataView.right + } + } + ] + } + + RowLayout { + id: buttonLayout + Layout.minimumHeight: themeToggle.height + width: parent.width + anchors.left: parent.left + spacing: 0 + + NewButton { + id: themeToggle + Layout.fillHeight: true + Layout.fillWidth: true + text: "Change Theme" + onClicked: { + if (barGraph.theme === firstTheme) { + barGraph.theme = secondTheme + } else { + barGraph.theme = firstTheme + } + } + } + NewButton { + id: repositionLegend + Layout.fillHeight: true + Layout.fillWidth: true + text: "Reposition Legend" + onClicked: { + if (legendPanel.legendLocation === 4) { + legendPanel.legendLocation = 1 + } else { + legendPanel.legendLocation++ + } + } + } + NewButton { + id: exitButton + Layout.fillHeight: true + Layout.fillWidth: true + text: "Quit" + onClicked: Qt.quit(0); + } + } + +} diff --git a/examples/qmllegend/qml/qmllegend/newbutton.qml b/examples/qmllegend/qml/qmllegend/newbutton.qml new file mode 100644 index 00000000..e4fb99d2 --- /dev/null +++ b/examples/qmllegend/qml/qmllegend/newbutton.qml @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the QtDataVisualization module. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ + +import QtQuick 2.1 +import QtQuick.Controls 1.0 +import QtQuick.Controls.Styles 1.0 + +Item { + id: newbutton + + property alias text: buttonText.text + + signal clicked + + implicitWidth: buttonText.implicitWidth + 5 + implicitHeight: buttonText.implicitHeight + 10 + + Button { + id: buttonText + width: parent.width + height: parent.height + + style: ButtonStyle { + label: Component { + Text { + text: buttonText.text + clip: true + wrapMode: Text.WordWrap + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + anchors.fill: parent + } + } + } + onClicked: newbutton.clicked() + } +} diff --git a/examples/qmllegend/qmllegend.desktop b/examples/qmllegend/qmllegend.desktop new file mode 100644 index 00000000..6ad68edd --- /dev/null +++ b/examples/qmllegend/qmllegend.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Encoding=UTF-8 +Version=1.0 +Type=Application +Terminal=false +Name=qmllegend +Exec=/opt/qmllegend/bin/qmllegend +Icon=qmllegend64 +X-Window-Icon= +X-HildonDesk-ShowInToolbar=true +X-Osso-Type=application/x-executable diff --git a/examples/qmllegend/qmllegend.pro b/examples/qmllegend/qmllegend.pro new file mode 100644 index 00000000..d896e7ac --- /dev/null +++ b/examples/qmllegend/qmllegend.pro @@ -0,0 +1,25 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} + +QT += widgets + +# Add more folders to ship with the application, here +folder_01.source = qml/qmllegend +folder_01.target = qml +DEPLOYMENTFOLDERS = folder_01 + +# Additional import path used to resolve QML modules in Creator's code model +QML_IMPORT_PATH = + +# The .cpp file which was generated for your project. Feel free to hack it. +SOURCES += main.cpp + +# Please do not modify the following two lines. Required for deployment. +include(qtquick2applicationviewer/qtquick2applicationviewer.pri) +qtcAddDeployment() + +RESOURCES += qmllegend.qrc + +OTHER_FILES += doc/src/* \ + doc/images/* diff --git a/examples/qmllegend/qmllegend.qrc b/examples/qmllegend/qmllegend.qrc new file mode 100644 index 00000000..6496cfdb --- /dev/null +++ b/examples/qmllegend/qmllegend.qrc @@ -0,0 +1,8 @@ +<RCC> + <qresource prefix="/qml"> + <file alias="Data.qml">qml/qmllegend/data.qml</file> + <file alias="main.qml">qml/qmllegend/main.qml</file> + <file alias="LegendItem.qml">qml/qmllegend/legenditem.qml</file> + <file alias="NewButton.qml">qml/qmllegend/newbutton.qml</file> + </qresource> +</RCC> diff --git a/examples/qmllegend/qmllegend64.png b/examples/qmllegend/qmllegend64.png Binary files differnew file mode 100644 index 00000000..707d5c4e --- /dev/null +++ b/examples/qmllegend/qmllegend64.png diff --git a/examples/qmllegend/qtquick2applicationviewer/qtquick2applicationviewer.cpp b/examples/qmllegend/qtquick2applicationviewer/qtquick2applicationviewer.cpp new file mode 100644 index 00000000..10709d7a --- /dev/null +++ b/examples/qmllegend/qtquick2applicationviewer/qtquick2applicationviewer.cpp @@ -0,0 +1,81 @@ +// checksum 0x4f6f version 0x90005 +/* + This file was generated by the Qt Quick 2 Application wizard of Qt Creator. + QtQuick2ApplicationViewer is a convenience class containing mobile device specific + code such as screen orientation handling. Also QML paths and debugging are + handled here. + It is recommended not to modify this file, since newer versions of Qt Creator + may offer an updated version of it. +*/ + +#include "qtquick2applicationviewer.h" + +#include <QtCore/QCoreApplication> +#include <QtCore/QDir> +#include <QtQml/QQmlEngine> + +class QtQuick2ApplicationViewerPrivate +{ + QString mainQmlFile; + friend class QtQuick2ApplicationViewer; + static QString adjustPath(const QString &path); +}; + +QString QtQuick2ApplicationViewerPrivate::adjustPath(const QString &path) +{ +#if defined(Q_OS_MAC) + if (!QDir::isAbsolutePath(path)) + return QString::fromLatin1("%1/../Resources/%2") + .arg(QCoreApplication::applicationDirPath(), path); +#elif defined(Q_OS_BLACKBERRY) + if (!QDir::isAbsolutePath(path)) + return QString::fromLatin1("app/native/%1").arg(path); +#elif !defined(Q_OS_ANDROID) + QString pathInInstallDir = + QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); + if (QFileInfo(pathInInstallDir).exists()) + return pathInInstallDir; + pathInInstallDir = + QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); + if (QFileInfo(pathInInstallDir).exists()) + return pathInInstallDir; +#endif + return path; +} + +QtQuick2ApplicationViewer::QtQuick2ApplicationViewer(QWindow *parent) + : QQuickView(parent) + , d(new QtQuick2ApplicationViewerPrivate()) +{ + connect(engine(), SIGNAL(quit()), SLOT(close())); + setResizeMode(QQuickView::SizeRootObjectToView); +} + +QtQuick2ApplicationViewer::~QtQuick2ApplicationViewer() +{ + delete d; +} + +void QtQuick2ApplicationViewer::setMainQmlFile(const QString &file) +{ + d->mainQmlFile = QtQuick2ApplicationViewerPrivate::adjustPath(file); +#ifdef Q_OS_ANDROID + setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); +#else + setSource(QUrl::fromLocalFile(d->mainQmlFile)); +#endif +} + +void QtQuick2ApplicationViewer::addImportPath(const QString &path) +{ + engine()->addImportPath(QtQuick2ApplicationViewerPrivate::adjustPath(path)); +} + +void QtQuick2ApplicationViewer::showExpanded() +{ +#if defined(Q_WS_SIMULATOR) || defined(Q_OS_QNX) + showFullScreen(); +#else + show(); +#endif +} diff --git a/examples/qmllegend/qtquick2applicationviewer/qtquick2applicationviewer.h b/examples/qmllegend/qtquick2applicationviewer/qtquick2applicationviewer.h new file mode 100644 index 00000000..cf66f140 --- /dev/null +++ b/examples/qmllegend/qtquick2applicationviewer/qtquick2applicationviewer.h @@ -0,0 +1,33 @@ +// checksum 0xfde6 version 0x90005 +/* + This file was generated by the Qt Quick 2 Application wizard of Qt Creator. + QtQuick2ApplicationViewer is a convenience class containing mobile device specific + code such as screen orientation handling. Also QML paths and debugging are + handled here. + It is recommended not to modify this file, since newer versions of Qt Creator + may offer an updated version of it. +*/ + +#ifndef QTQUICK2APPLICATIONVIEWER_H +#define QTQUICK2APPLICATIONVIEWER_H + +#include <QtQuick/QQuickView> + +class QtQuick2ApplicationViewer : public QQuickView +{ + Q_OBJECT + +public: + explicit QtQuick2ApplicationViewer(QWindow *parent = 0); + virtual ~QtQuick2ApplicationViewer(); + + void setMainQmlFile(const QString &file); + void addImportPath(const QString &path); + + void showExpanded(); + +private: + class QtQuick2ApplicationViewerPrivate *d; +}; + +#endif // QTQUICK2APPLICATIONVIEWER_H diff --git a/examples/qmllegend/qtquick2applicationviewer/qtquick2applicationviewer.pri b/examples/qmllegend/qtquick2applicationviewer/qtquick2applicationviewer.pri new file mode 100644 index 00000000..e5f7990f --- /dev/null +++ b/examples/qmllegend/qtquick2applicationviewer/qtquick2applicationviewer.pri @@ -0,0 +1,180 @@ +# checksum 0x7b0d version 0x90005 +# This file was generated by the Qt Quick 2 Application wizard of Qt Creator. +# The code below adds the QtQuick2ApplicationViewer to the project and handles +# the activation of QML debugging. +# It is recommended not to modify this file, since newer versions of Qt Creator +# may offer an updated version of it. + +QT += qml quick + +SOURCES += $$PWD/qtquick2applicationviewer.cpp +HEADERS += $$PWD/qtquick2applicationviewer.h +INCLUDEPATH += $$PWD +# This file was generated by an application wizard of Qt Creator. +# The code below handles deployment to Android and Maemo, aswell as copying +# of the application data to shadow build directories on desktop. +# It is recommended not to modify this file, since newer versions of Qt Creator +# may offer an updated version of it. + +defineTest(qtcAddDeployment) { +for(deploymentfolder, DEPLOYMENTFOLDERS) { + item = item$${deploymentfolder} + greaterThan(QT_MAJOR_VERSION, 4) { + itemsources = $${item}.files + } else { + itemsources = $${item}.sources + } + $$itemsources = $$eval($${deploymentfolder}.source) + itempath = $${item}.path + $$itempath= $$eval($${deploymentfolder}.target) + export($$itemsources) + export($$itempath) + DEPLOYMENT += $$item +} + +MAINPROFILEPWD = $$PWD + +android-no-sdk { + for(deploymentfolder, DEPLOYMENTFOLDERS) { + item = item$${deploymentfolder} + itemfiles = $${item}.files + $$itemfiles = $$eval($${deploymentfolder}.source) + itempath = $${item}.path + $$itempath = /data/user/qt/$$eval($${deploymentfolder}.target) + export($$itemfiles) + export($$itempath) + INSTALLS += $$item + } + + target.path = /data/user/qt + + export(target.path) + INSTALLS += target +} else:android { + for(deploymentfolder, DEPLOYMENTFOLDERS) { + item = item$${deploymentfolder} + itemfiles = $${item}.files + $$itemfiles = $$eval($${deploymentfolder}.source) + itempath = $${item}.path + $$itempath = /assets/$$eval($${deploymentfolder}.target) + export($$itemfiles) + export($$itempath) + INSTALLS += $$item + } + + x86 { + target.path = /libs/x86 + } else: armeabi-v7a { + target.path = /libs/armeabi-v7a + } else { + target.path = /libs/armeabi + } + + export(target.path) + INSTALLS += target +} else:win32 { + copyCommand = + for(deploymentfolder, DEPLOYMENTFOLDERS) { + source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source) + source = $$replace(source, /, \\) + sourcePathSegments = $$split(source, \\) + target = $$OUT_PWD/$$eval($${deploymentfolder}.target)/$$last(sourcePathSegments) + target = $$replace(target, /, \\) + target ~= s,\\\\\\.?\\\\,\\, + !isEqual(source,$$target) { + !isEmpty(copyCommand):copyCommand += && + isEqual(QMAKE_DIR_SEP, \\) { + copyCommand += $(COPY_DIR) \"$$source\" \"$$target\" + } else { + source = $$replace(source, \\\\, /) + target = $$OUT_PWD/$$eval($${deploymentfolder}.target) + target = $$replace(target, \\\\, /) + copyCommand += test -d \"$$target\" || mkdir -p \"$$target\" && cp -r \"$$source\" \"$$target\" + } + } + } + !isEmpty(copyCommand) { + copyCommand = @echo Copying application data... && $$copyCommand + copydeploymentfolders.commands = $$copyCommand + first.depends = $(first) copydeploymentfolders + export(first.depends) + export(copydeploymentfolders.commands) + QMAKE_EXTRA_TARGETS += first copydeploymentfolders + } +} else:unix { + maemo5 { + desktopfile.files = $${TARGET}.desktop + desktopfile.path = /usr/share/applications/hildon + icon.files = $${TARGET}64.png + icon.path = /usr/share/icons/hicolor/64x64/apps + } else:!isEmpty(MEEGO_VERSION_MAJOR) { + desktopfile.files = $${TARGET}_harmattan.desktop + desktopfile.path = /usr/share/applications + icon.files = $${TARGET}80.png + icon.path = /usr/share/icons/hicolor/80x80/apps + } else { # Assumed to be a Desktop Unix + copyCommand = + for(deploymentfolder, DEPLOYMENTFOLDERS) { + source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source) + source = $$replace(source, \\\\, /) + macx { + target = $$OUT_PWD/$${TARGET}.app/Contents/Resources/$$eval($${deploymentfolder}.target) + } else { + target = $$OUT_PWD/$$eval($${deploymentfolder}.target) + } + target = $$replace(target, \\\\, /) + sourcePathSegments = $$split(source, /) + targetFullPath = $$target/$$last(sourcePathSegments) + targetFullPath ~= s,/\\.?/,/, + !isEqual(source,$$targetFullPath) { + !isEmpty(copyCommand):copyCommand += && + copyCommand += $(MKDIR) \"$$target\" + copyCommand += && $(COPY_DIR) \"$$source\" \"$$target\" + } + } + !isEmpty(copyCommand) { + copyCommand = @echo Copying application data... && $$copyCommand + copydeploymentfolders.commands = $$copyCommand + first.depends = $(first) copydeploymentfolders + export(first.depends) + export(copydeploymentfolders.commands) + QMAKE_EXTRA_TARGETS += first copydeploymentfolders + } + } + !isEmpty(target.path) { + installPrefix = $${target.path} + } else { + installPrefix = /opt/$${TARGET} + } + for(deploymentfolder, DEPLOYMENTFOLDERS) { + item = item$${deploymentfolder} + itemfiles = $${item}.files + $$itemfiles = $$eval($${deploymentfolder}.source) + itempath = $${item}.path + $$itempath = $${installPrefix}/$$eval($${deploymentfolder}.target) + export($$itemfiles) + export($$itempath) + INSTALLS += $$item + } + + !isEmpty(desktopfile.path) { + export(icon.files) + export(icon.path) + export(desktopfile.files) + export(desktopfile.path) + INSTALLS += icon desktopfile + } + + isEmpty(target.path) { + target.path = $${installPrefix}/bin + export(target.path) + } + INSTALLS += target +} + +export (ICON) +export (INSTALLS) +export (DEPLOYMENT) +export (LIBS) +export (QMAKE_EXTRA_TARGETS) +} diff --git a/examples/qmlmultigraph/doc/images/qmlmultigraph-example.png b/examples/qmlmultigraph/doc/images/qmlmultigraph-example.png Binary files differnew file mode 100644 index 00000000..d4e524e2 --- /dev/null +++ b/examples/qmlmultigraph/doc/images/qmlmultigraph-example.png diff --git a/examples/qmlmultigraph/doc/src/qmlmultigraph.qdoc b/examples/qmlmultigraph/doc/src/qmlmultigraph.qdoc new file mode 100644 index 00000000..f3ba172d --- /dev/null +++ b/examples/qmlmultigraph/doc/src/qmlmultigraph.qdoc @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the QtDataVisualization module. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ + +/*! + \example qmlmultigraph + \title Qt Quick 2 Multiple Graphs Example + \ingroup qtdatavisualization_examples + \brief Showing multiple graphs simultaneously in a QML application. + + The Qt Quick 2 multiple graphs example demonstrates using multiple graphs in single window. + + \image qmlmultigraph-example.png + + The interesting thing about this example is demonstrating that multiple graphs can be used + simultaneously, so most functionality is not explained in detail. + For more detailed QML example documentation, see \l{Qt Quick 2 Scatter Example}. + + \section1 Multiple Graphs + + Using multiple graphs in a single application doesn't require anything special, simply define + and position the graphs as normal. In this example the graphs are shown side by side in a RowLayout: + + \snippet ../examples/qmlmultigraph/qml/qmlmultigraph/main.qml 0 + + Each graph has a parent Rectangle item to provide it with a border. The color of the rectangle is set + to fully transparent, because otherwise the rectangles would hide the graphs, which are always drawn behind + all other QML elements. +*/ diff --git a/examples/qmlmultigraph/main.cpp b/examples/qmlmultigraph/main.cpp new file mode 100644 index 00000000..25cd5d9c --- /dev/null +++ b/examples/qmlmultigraph/main.cpp @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the QtDataVisualization module. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ + +#include <QtDataVisualization/qutils.h> +#include <QtGui/QGuiApplication> +#include "qtquick2applicationviewer.h" +#ifdef Q_OS_ANDROID +#include <QDir> +#include <QQmlEngine> +#endif +#include <QDebug> + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + QtQuick2ApplicationViewer viewer; + + // Enable antialiasing + viewer.setFormat(QtDataVisualization::qDefaultSurfaceFormat()); + +#ifdef Q_OS_ANDROID + viewer.addImportPath(QString::fromLatin1("assets:/qml")); + viewer.engine()->addPluginPath(QString::fromLatin1("%1/../%2").arg(QDir::homePath(), + QString::fromLatin1("lib"))); +#endif + viewer.setTitle(QStringLiteral("QML multigraph example")); + viewer.setSource(QUrl("qrc:/qml/main.qml")); + viewer.setResizeMode(QQuickView::SizeRootObjectToView); + viewer.showExpanded(); + + return app.exec(); +} diff --git a/examples/qmlmultigraph/qml/qmlmultigraph/data.qml b/examples/qmlmultigraph/qml/qmlmultigraph/data.qml new file mode 100644 index 00000000..679cb067 --- /dev/null +++ b/examples/qmlmultigraph/qml/qmlmultigraph/data.qml @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the QtDataVisualization module. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ + +import QtQuick 2.1 + +Item { + property alias barData: barDataModel + property alias scatterData: scatterDataModel + property alias surfaceData: surfaceDataModel + + ListModel { + id: barDataModel + ListElement{ year: "2012"; city: "Oulu"; expenses: "4200"; income: "8300"; } + ListElement{ year: "2012"; city: "Kemi"; expenses: "2100"; income: "6500"; } + ListElement{ year: "2012"; city: "Helsinki"; expenses: "7040"; income: "7500"; } + ListElement{ year: "2012"; city: "Tampere"; expenses: "4330"; income: "5800"; } + ListElement{ year: "2013"; city: "Oulu"; expenses: "3960"; income: "9000"; } + ListElement{ year: "2013"; city: "Kemi"; expenses: "1990"; income: "3000"; } + ListElement{ year: "2013"; city: "Helsinki"; expenses: "7230"; income: "9900"; } + ListElement{ year: "2013"; city: "Tampere"; expenses: "4650"; income: "7600"; } + } + + ListModel { + id: scatterDataModel + ListElement{ xPos: "2.754"; yPos: "1.000"; zPos: "3.362"; } + ListElement{ xPos: "3.164"; yPos: "2.022"; zPos: "4.348"; } + ListElement{ xPos: "4.564"; yPos: "1.865"; zPos: "1.000"; } + ListElement{ xPos: "1.000"; yPos: "1.224"; zPos: "2.983"; } + ListElement{ xPos: "2.323"; yPos: "2.502"; zPos: "3.133"; } + ListElement{ xPos: "3.663"; yPos: "3.186"; zPos: "2.843"; } + ListElement{ xPos: "4.190"; yPos: "4.875"; zPos: "3.942"; } + ListElement{ xPos: "3.569"; yPos: "3.685"; zPos: "1.456"; } + ListElement{ xPos: "5.000"; yPos: "5.000"; zPos: "4.678"; } + ListElement{ xPos: "4.349"; yPos: "3.850"; zPos: "5.000"; } + } + + ListModel { + id: surfaceDataModel + ListElement{ longitude: "20"; latitude: "10"; pop_density: "4.75"; } + ListElement{ longitude: "21"; latitude: "10"; pop_density: "3.00"; } + ListElement{ longitude: "22"; latitude: "10"; pop_density: "1.24"; } + ListElement{ longitude: "23"; latitude: "10"; pop_density: "2.53"; } + ListElement{ longitude: "20"; latitude: "11"; pop_density: "3.55"; } + ListElement{ longitude: "21"; latitude: "11"; pop_density: "3.03"; } + ListElement{ longitude: "22"; latitude: "11"; pop_density: "3.46"; } + ListElement{ longitude: "23"; latitude: "11"; pop_density: "4.12"; } + ListElement{ longitude: "20"; latitude: "12"; pop_density: "3.37"; } + ListElement{ longitude: "21"; latitude: "12"; pop_density: "2.98"; } + ListElement{ longitude: "22"; latitude: "12"; pop_density: "3.33"; } + ListElement{ longitude: "23"; latitude: "12"; pop_density: "3.23"; } + ListElement{ longitude: "20"; latitude: "13"; pop_density: "5.34"; } + ListElement{ longitude: "21"; latitude: "13"; pop_density: "4.54"; } + ListElement{ longitude: "22"; latitude: "13"; pop_density: "4.65"; } + ListElement{ longitude: "23"; latitude: "13"; pop_density: "6.67"; } + ListElement{ longitude: "20"; latitude: "14"; pop_density: "6.01"; } + ListElement{ longitude: "21"; latitude: "14"; pop_density: "5.83"; } + ListElement{ longitude: "22"; latitude: "14"; pop_density: "5.90"; } + ListElement{ longitude: "23"; latitude: "14"; pop_density: "7.32"; } + } +} + diff --git a/examples/qmlmultigraph/qml/qmlmultigraph/main.qml b/examples/qmlmultigraph/qml/qmlmultigraph/main.qml new file mode 100644 index 00000000..bc2f7fe3 --- /dev/null +++ b/examples/qmlmultigraph/qml/qmlmultigraph/main.qml @@ -0,0 +1,169 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the QtDataVisualization module. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ + +import QtQuick 2.1 +import QtQuick.Layouts 1.0 +import QtDataVisualization 1.0 +import "." + +Item { + id: mainView + width: 1280 + height: 400 + + Data { + id: data + } + + //! [0] + RowLayout { + id: graphLayout + spacing: 1 + anchors.top: buttonLayout.bottom + anchors.bottom: mainView.bottom + anchors.left: mainView.left + anchors.right: mainView.right + + Rectangle { + Layout.fillHeight: true + Layout.fillWidth: true + border.color: surfaceGraph.theme.gridLineColor + border.width: 2 + color: "#00000000" // Transparent + + Surface3D { + id: surfaceGraph + anchors.fill: parent + anchors.margins: parent.border.width + theme: Theme3D { type: Theme3D.ThemePrimaryColors } + scene.activeCamera.cameraPreset: Camera3D.CameraPresetIsometricLeftHigh + + Surface3DSeries { + itemLabelFormat: "Pop density at (@xLabel N, @zLabel E): @yLabel" + ItemModelSurfaceDataProxy { + itemModel: data.surfaceData + // Mapping model roles to surface series rows, columns, and values. + rowRole: "longitude" + columnRole: "latitude" + valueRole: "pop_density" + } + } + } + } + + + Rectangle { + Layout.fillHeight: true + Layout.fillWidth: true + border.color: scatterGraph.theme.gridLineColor + border.width: 2 + color: "#00000000" // Transparent + + Scatter3D { + id: scatterGraph + anchors.fill: parent + anchors.margins: parent.border.width + theme: Theme3D { type: Theme3D.ThemeDigia } + scene.activeCamera.cameraPreset: Camera3D.CameraPresetIsometricLeftHigh + + Scatter3DSeries { + ItemModelScatterDataProxy { + itemModel: data.scatterData + // Mapping model roles to scatter series item coordinates. + xPosRole: "xPos" + yPosRole: "yPos" + zPosRole: "zPos" + } + } + } + } + + Rectangle { + Layout.fillHeight: true + Layout.fillWidth: true + border.color: barGraph.theme.gridLineColor + border.width: 2 + color: "#00000000" // Transparent + + Bars3D { + id: barGraph + anchors.fill: parent + anchors.margins: parent.border.width + theme: Theme3D { type: Theme3D.ThemeQt } + selectionMode: AbstractGraph3D.SelectionItemAndRow | AbstractGraph3D.SelectionSlice + scene.activeCamera.cameraPreset: Camera3D.CameraPresetIsometricLeftHigh + + Bar3DSeries { + itemLabelFormat: "@seriesName for @colLabel, @rowLabel: @valueLabel" + name: "Yearly expenses" + + ItemModelBarDataProxy { + itemModel: data.barData + // Mapping model roles to bar series rows, columns, and values. + rowRole: "year" + columnRole: "city" + valueRole: "expenses" + } + } + + Bar3DSeries { + itemLabelFormat: "@seriesName for @colLabel, @rowLabel: @valueLabel" + name: "Yearly income" + + ItemModelBarDataProxy { + itemModel: data.barData + // Mapping model roles to bar series rows, columns, and values. + rowRole: "year" + columnRole: "city" + valueRole: "income" + } + } + } + } + } + //! [0] + + RowLayout { + id: buttonLayout + Layout.minimumHeight: exitButton.height + width: parent.width + anchors.left: parent.left + anchors.top: parent.top + spacing: 0 + + NewButton { + id: clearSelectionsButton + Layout.fillHeight: true + Layout.fillWidth: true + text: "Clear Selections" + onClicked: { + barGraph.clearSelection() + scatterGraph.clearSelection() + surfaceGraph.clearSelection() + } + } + + NewButton { + id: exitButton + Layout.fillHeight: true + Layout.fillWidth: true + text: "Quit" + onClicked: Qt.quit(0); + } + } +} diff --git a/examples/qmlmultigraph/qml/qmlmultigraph/newbutton.qml b/examples/qmlmultigraph/qml/qmlmultigraph/newbutton.qml new file mode 100644 index 00000000..e4fb99d2 --- /dev/null +++ b/examples/qmlmultigraph/qml/qmlmultigraph/newbutton.qml @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the QtDataVisualization module. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ + +import QtQuick 2.1 +import QtQuick.Controls 1.0 +import QtQuick.Controls.Styles 1.0 + +Item { + id: newbutton + + property alias text: buttonText.text + + signal clicked + + implicitWidth: buttonText.implicitWidth + 5 + implicitHeight: buttonText.implicitHeight + 10 + + Button { + id: buttonText + width: parent.width + height: parent.height + + style: ButtonStyle { + label: Component { + Text { + text: buttonText.text + clip: true + wrapMode: Text.WordWrap + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + anchors.fill: parent + } + } + } + onClicked: newbutton.clicked() + } +} diff --git a/examples/qmlmultigraph/qmlmultigraph.desktop b/examples/qmlmultigraph/qmlmultigraph.desktop new file mode 100644 index 00000000..90b16a4e --- /dev/null +++ b/examples/qmlmultigraph/qmlmultigraph.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Encoding=UTF-8 +Version=1.0 +Type=Application +Terminal=false +Name=qmlmultigraph +Exec=/opt/qmlmultigraph/bin/qmlmultigraph +Icon=qmlmultigraph64 +X-Window-Icon= +X-HildonDesk-ShowInToolbar=true +X-Osso-Type=application/x-executable diff --git a/examples/qmlmultigraph/qmlmultigraph.pro b/examples/qmlmultigraph/qmlmultigraph.pro new file mode 100644 index 00000000..af4e0d90 --- /dev/null +++ b/examples/qmlmultigraph/qmlmultigraph.pro @@ -0,0 +1,25 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} + +QT += widgets + +# Add more folders to ship with the application, here +folder_01.source = qml/qmlmultigraph +folder_01.target = qml +DEPLOYMENTFOLDERS = folder_01 + +# Additional import path used to resolve QML modules in Creator's code model +QML_IMPORT_PATH = + +# The .cpp file which was generated for your project. Feel free to hack it. +SOURCES += main.cpp + +# Please do not modify the following two lines. Required for deployment. +include(qtquick2applicationviewer/qtquick2applicationviewer.pri) +qtcAddDeployment() + +RESOURCES += qmlmultigraph.qrc + +OTHER_FILES += doc/src/* \ + doc/images/* diff --git a/examples/qmlmultigraph/qmlmultigraph.qrc b/examples/qmlmultigraph/qmlmultigraph.qrc new file mode 100644 index 00000000..02e0c682 --- /dev/null +++ b/examples/qmlmultigraph/qmlmultigraph.qrc @@ -0,0 +1,7 @@ +<RCC> + <qresource prefix="/qml"> + <file alias="main.qml">qml/qmlmultigraph/main.qml</file> + <file alias="NewButton.qml">qml/qmlmultigraph/newbutton.qml</file> + <file alias="Data.qml">qml/qmlmultigraph/data.qml</file> + </qresource> +</RCC> diff --git a/examples/qmlmultigraph/qmlmultigraph64.png b/examples/qmlmultigraph/qmlmultigraph64.png Binary files differnew file mode 100644 index 00000000..707d5c4e --- /dev/null +++ b/examples/qmlmultigraph/qmlmultigraph64.png diff --git a/examples/qmlmultigraph/qtquick2applicationviewer/qtquick2applicationviewer.cpp b/examples/qmlmultigraph/qtquick2applicationviewer/qtquick2applicationviewer.cpp new file mode 100644 index 00000000..10709d7a --- /dev/null +++ b/examples/qmlmultigraph/qtquick2applicationviewer/qtquick2applicationviewer.cpp @@ -0,0 +1,81 @@ +// checksum 0x4f6f version 0x90005 +/* + This file was generated by the Qt Quick 2 Application wizard of Qt Creator. + QtQuick2ApplicationViewer is a convenience class containing mobile device specific + code such as screen orientation handling. Also QML paths and debugging are + handled here. + It is recommended not to modify this file, since newer versions of Qt Creator + may offer an updated version of it. +*/ + +#include "qtquick2applicationviewer.h" + +#include <QtCore/QCoreApplication> +#include <QtCore/QDir> +#include <QtQml/QQmlEngine> + +class QtQuick2ApplicationViewerPrivate +{ + QString mainQmlFile; + friend class QtQuick2ApplicationViewer; + static QString adjustPath(const QString &path); +}; + +QString QtQuick2ApplicationViewerPrivate::adjustPath(const QString &path) +{ +#if defined(Q_OS_MAC) + if (!QDir::isAbsolutePath(path)) + return QString::fromLatin1("%1/../Resources/%2") + .arg(QCoreApplication::applicationDirPath(), path); +#elif defined(Q_OS_BLACKBERRY) + if (!QDir::isAbsolutePath(path)) + return QString::fromLatin1("app/native/%1").arg(path); +#elif !defined(Q_OS_ANDROID) + QString pathInInstallDir = + QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); + if (QFileInfo(pathInInstallDir).exists()) + return pathInInstallDir; + pathInInstallDir = + QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); + if (QFileInfo(pathInInstallDir).exists()) + return pathInInstallDir; +#endif + return path; +} + +QtQuick2ApplicationViewer::QtQuick2ApplicationViewer(QWindow *parent) + : QQuickView(parent) + , d(new QtQuick2ApplicationViewerPrivate()) +{ + connect(engine(), SIGNAL(quit()), SLOT(close())); + setResizeMode(QQuickView::SizeRootObjectToView); +} + +QtQuick2ApplicationViewer::~QtQuick2ApplicationViewer() +{ + delete d; +} + +void QtQuick2ApplicationViewer::setMainQmlFile(const QString &file) +{ + d->mainQmlFile = QtQuick2ApplicationViewerPrivate::adjustPath(file); +#ifdef Q_OS_ANDROID + setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); +#else + setSource(QUrl::fromLocalFile(d->mainQmlFile)); +#endif +} + +void QtQuick2ApplicationViewer::addImportPath(const QString &path) +{ + engine()->addImportPath(QtQuick2ApplicationViewerPrivate::adjustPath(path)); +} + +void QtQuick2ApplicationViewer::showExpanded() +{ +#if defined(Q_WS_SIMULATOR) || defined(Q_OS_QNX) + showFullScreen(); +#else + show(); +#endif +} diff --git a/examples/qmlmultigraph/qtquick2applicationviewer/qtquick2applicationviewer.h b/examples/qmlmultigraph/qtquick2applicationviewer/qtquick2applicationviewer.h new file mode 100644 index 00000000..cf66f140 --- /dev/null +++ b/examples/qmlmultigraph/qtquick2applicationviewer/qtquick2applicationviewer.h @@ -0,0 +1,33 @@ +// checksum 0xfde6 version 0x90005 +/* + This file was generated by the Qt Quick 2 Application wizard of Qt Creator. + QtQuick2ApplicationViewer is a convenience class containing mobile device specific + code such as screen orientation handling. Also QML paths and debugging are + handled here. + It is recommended not to modify this file, since newer versions of Qt Creator + may offer an updated version of it. +*/ + +#ifndef QTQUICK2APPLICATIONVIEWER_H +#define QTQUICK2APPLICATIONVIEWER_H + +#include <QtQuick/QQuickView> + +class QtQuick2ApplicationViewer : public QQuickView +{ + Q_OBJECT + +public: + explicit QtQuick2ApplicationViewer(QWindow *parent = 0); + virtual ~QtQuick2ApplicationViewer(); + + void setMainQmlFile(const QString &file); + void addImportPath(const QString &path); + + void showExpanded(); + +private: + class QtQuick2ApplicationViewerPrivate *d; +}; + +#endif // QTQUICK2APPLICATIONVIEWER_H diff --git a/examples/qmlmultigraph/qtquick2applicationviewer/qtquick2applicationviewer.pri b/examples/qmlmultigraph/qtquick2applicationviewer/qtquick2applicationviewer.pri new file mode 100644 index 00000000..e5f7990f --- /dev/null +++ b/examples/qmlmultigraph/qtquick2applicationviewer/qtquick2applicationviewer.pri @@ -0,0 +1,180 @@ +# checksum 0x7b0d version 0x90005 +# This file was generated by the Qt Quick 2 Application wizard of Qt Creator. +# The code below adds the QtQuick2ApplicationViewer to the project and handles +# the activation of QML debugging. +# It is recommended not to modify this file, since newer versions of Qt Creator +# may offer an updated version of it. + +QT += qml quick + +SOURCES += $$PWD/qtquick2applicationviewer.cpp +HEADERS += $$PWD/qtquick2applicationviewer.h +INCLUDEPATH += $$PWD +# This file was generated by an application wizard of Qt Creator. +# The code below handles deployment to Android and Maemo, aswell as copying +# of the application data to shadow build directories on desktop. +# It is recommended not to modify this file, since newer versions of Qt Creator +# may offer an updated version of it. + +defineTest(qtcAddDeployment) { +for(deploymentfolder, DEPLOYMENTFOLDERS) { + item = item$${deploymentfolder} + greaterThan(QT_MAJOR_VERSION, 4) { + itemsources = $${item}.files + } else { + itemsources = $${item}.sources + } + $$itemsources = $$eval($${deploymentfolder}.source) + itempath = $${item}.path + $$itempath= $$eval($${deploymentfolder}.target) + export($$itemsources) + export($$itempath) + DEPLOYMENT += $$item +} + +MAINPROFILEPWD = $$PWD + +android-no-sdk { + for(deploymentfolder, DEPLOYMENTFOLDERS) { + item = item$${deploymentfolder} + itemfiles = $${item}.files + $$itemfiles = $$eval($${deploymentfolder}.source) + itempath = $${item}.path + $$itempath = /data/user/qt/$$eval($${deploymentfolder}.target) + export($$itemfiles) + export($$itempath) + INSTALLS += $$item + } + + target.path = /data/user/qt + + export(target.path) + INSTALLS += target +} else:android { + for(deploymentfolder, DEPLOYMENTFOLDERS) { + item = item$${deploymentfolder} + itemfiles = $${item}.files + $$itemfiles = $$eval($${deploymentfolder}.source) + itempath = $${item}.path + $$itempath = /assets/$$eval($${deploymentfolder}.target) + export($$itemfiles) + export($$itempath) + INSTALLS += $$item + } + + x86 { + target.path = /libs/x86 + } else: armeabi-v7a { + target.path = /libs/armeabi-v7a + } else { + target.path = /libs/armeabi + } + + export(target.path) + INSTALLS += target +} else:win32 { + copyCommand = + for(deploymentfolder, DEPLOYMENTFOLDERS) { + source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source) + source = $$replace(source, /, \\) + sourcePathSegments = $$split(source, \\) + target = $$OUT_PWD/$$eval($${deploymentfolder}.target)/$$last(sourcePathSegments) + target = $$replace(target, /, \\) + target ~= s,\\\\\\.?\\\\,\\, + !isEqual(source,$$target) { + !isEmpty(copyCommand):copyCommand += && + isEqual(QMAKE_DIR_SEP, \\) { + copyCommand += $(COPY_DIR) \"$$source\" \"$$target\" + } else { + source = $$replace(source, \\\\, /) + target = $$OUT_PWD/$$eval($${deploymentfolder}.target) + target = $$replace(target, \\\\, /) + copyCommand += test -d \"$$target\" || mkdir -p \"$$target\" && cp -r \"$$source\" \"$$target\" + } + } + } + !isEmpty(copyCommand) { + copyCommand = @echo Copying application data... && $$copyCommand + copydeploymentfolders.commands = $$copyCommand + first.depends = $(first) copydeploymentfolders + export(first.depends) + export(copydeploymentfolders.commands) + QMAKE_EXTRA_TARGETS += first copydeploymentfolders + } +} else:unix { + maemo5 { + desktopfile.files = $${TARGET}.desktop + desktopfile.path = /usr/share/applications/hildon + icon.files = $${TARGET}64.png + icon.path = /usr/share/icons/hicolor/64x64/apps + } else:!isEmpty(MEEGO_VERSION_MAJOR) { + desktopfile.files = $${TARGET}_harmattan.desktop + desktopfile.path = /usr/share/applications + icon.files = $${TARGET}80.png + icon.path = /usr/share/icons/hicolor/80x80/apps + } else { # Assumed to be a Desktop Unix + copyCommand = + for(deploymentfolder, DEPLOYMENTFOLDERS) { + source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source) + source = $$replace(source, \\\\, /) + macx { + target = $$OUT_PWD/$${TARGET}.app/Contents/Resources/$$eval($${deploymentfolder}.target) + } else { + target = $$OUT_PWD/$$eval($${deploymentfolder}.target) + } + target = $$replace(target, \\\\, /) + sourcePathSegments = $$split(source, /) + targetFullPath = $$target/$$last(sourcePathSegments) + targetFullPath ~= s,/\\.?/,/, + !isEqual(source,$$targetFullPath) { + !isEmpty(copyCommand):copyCommand += && + copyCommand += $(MKDIR) \"$$target\" + copyCommand += && $(COPY_DIR) \"$$source\" \"$$target\" + } + } + !isEmpty(copyCommand) { + copyCommand = @echo Copying application data... && $$copyCommand + copydeploymentfolders.commands = $$copyCommand + first.depends = $(first) copydeploymentfolders + export(first.depends) + export(copydeploymentfolders.commands) + QMAKE_EXTRA_TARGETS += first copydeploymentfolders + } + } + !isEmpty(target.path) { + installPrefix = $${target.path} + } else { + installPrefix = /opt/$${TARGET} + } + for(deploymentfolder, DEPLOYMENTFOLDERS) { + item = item$${deploymentfolder} + itemfiles = $${item}.files + $$itemfiles = $$eval($${deploymentfolder}.source) + itempath = $${item}.path + $$itempath = $${installPrefix}/$$eval($${deploymentfolder}.target) + export($$itemfiles) + export($$itempath) + INSTALLS += $$item + } + + !isEmpty(desktopfile.path) { + export(icon.files) + export(icon.path) + export(desktopfile.files) + export(desktopfile.path) + INSTALLS += icon desktopfile + } + + isEmpty(target.path) { + target.path = $${installPrefix}/bin + export(target.path) + } + INSTALLS += target +} + +export (ICON) +export (INSTALLS) +export (DEPLOYMENT) +export (LIBS) +export (QMAKE_EXTRA_TARGETS) +} diff --git a/examples/qmlscatter/doc/images/qmlscatter-example.png b/examples/qmlscatter/doc/images/qmlscatter-example.png Binary files differindex ff9df1fc..65ec4816 100644 --- a/examples/qmlscatter/doc/images/qmlscatter-example.png +++ b/examples/qmlscatter/doc/images/qmlscatter-example.png diff --git a/examples/qmlscatter/doc/src/qmlscatter.qdoc b/examples/qmlscatter/doc/src/qmlscatter.qdoc index 06719ffc..366b02ea 100644 --- a/examples/qmlscatter/doc/src/qmlscatter.qdoc +++ b/examples/qmlscatter/doc/src/qmlscatter.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 ** @@ -46,8 +46,13 @@ \snippet ../examples/qmlscatter/main.cpp 0 - This will help us when deploying the application to Android. We'll also change the application - to be shown maximized by replacing + This will help us when deploying the application to Android. + + We'll enable anti-aliasing for our application in environments that support it: + + \snippet ../examples/qmlscatter/main.cpp 2 + + We'll also change the application to be shown maximized by replacing \code viewer.showExpanded(); \endcode @@ -112,19 +117,22 @@ \snippet ../examples/qmlscatter/qml/qmlscatter/main.qml 3 - We added a built-in Theme3D and changed the font in it. We also changed the shadow quality. + We added a customized theme and changed the shadow quality. We're happy with the other visual properties, so we won't change them. + The custom theme is based on a predefined theme, but we change the font in it: + + \snippet ../examples/qmlscatter/qml/qmlscatter/main.qml 13 + Then it's time to start feeding the graph some data. \section1 Adding data to the graph - Let's create a \c Data item inside the \c mainView and name it \c {seriesOneData}: + Let's create a \c Data item inside the \c mainView and name it \c seriesData: \snippet ../examples/qmlscatter/qml/qmlscatter/main.qml 4 - We'll add two more of these: \c seriesTwoData and \c seriesThreeData to add to the three series - we're going to have. They are added similarly as \c {seriesOneData}. + The \c seriesData item contains the data models for all three series we use in this example. This is the component that holds our data in \c {data.qml}. It has an \c Item as the main component. diff --git a/examples/qmlscatter/main.cpp b/examples/qmlscatter/main.cpp index 159612e9..4ecefdc1 100644 --- a/examples/qmlscatter/main.cpp +++ b/examples/qmlscatter/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 ** @@ -16,6 +16,7 @@ ** ****************************************************************************/ +#include <QtDataVisualization/qutils.h> #include <QtGui/QGuiApplication> #include "qtquick2applicationviewer.h" #ifdef Q_OS_ANDROID @@ -30,15 +31,10 @@ int main(int argc, char *argv[]) QtQuick2ApplicationViewer viewer; -#if !defined(QT_OPENGL_ES_2) // Enable antialiasing - QSurfaceFormat surfaceFormat; - surfaceFormat.setDepthBufferSize(24); - surfaceFormat.setSamples(8); - surfaceFormat.setRenderableType(QSurfaceFormat::OpenGL); - surfaceFormat.setSwapBehavior(QSurfaceFormat::DoubleBuffer); - viewer.setFormat(surfaceFormat); -#endif + //! [2] + viewer.setFormat(QtDataVisualization::qDefaultSurfaceFormat()); + //! [2] #ifdef Q_OS_ANDROID viewer.addImportPath(QString::fromLatin1("assets:/qml")); diff --git a/examples/qmlscatter/qml/qmlscatter/data.qml b/examples/qmlscatter/qml/qmlscatter/data.qml index bf4853df..23c4e5d5 100644 --- a/examples/qmlscatter/qml/qmlscatter/data.qml +++ b/examples/qmlscatter/qml/qmlscatter/data.qml @@ -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,7 +17,6 @@ ****************************************************************************/ import QtQuick 2.1 -import QtDataVisualization 1.0 Item { //! [1] diff --git a/examples/qmlscatter/qml/qmlscatter/main.qml b/examples/qmlscatter/qml/qmlscatter/main.qml index 62727f84..beb4ccaa 100644 --- a/examples/qmlscatter/qml/qmlscatter/main.qml +++ b/examples/qmlscatter/qml/qmlscatter/main.qml @@ -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 ** @@ -30,16 +30,22 @@ Item { //! [4] Data { - id: seriesOneData + id: seriesData } //! [4] - Data { - id: seriesTwoData + //! [13] + Theme3D { + id: themeIsabelle + type: Theme3D.ThemeIsabelle + font.family: "Lucida Handwriting" + font.pointSize: 40 } + //! [13] - Data { - id: seriesThreeData + Theme3D { + id: themeArmyBlue + type: Theme3D.ThemeArmyBlue } //! [8] @@ -59,11 +65,7 @@ Item { height: dataView.height //! [2] //! [3] - theme: Theme3D { - type: Theme3D.ThemeIsabelle - font.family: "Lucida Handwriting" - font.pointSize: 40 - } + theme: themeIsabelle shadowQuality: AbstractGraph3D.ShadowQualitySoftLow //! [3] //! [6] @@ -87,7 +89,7 @@ Item { //! [11] ItemModelScatterDataProxy { - itemModel: seriesOneData.model + itemModel: seriesData.model xPosRole: "xPos" yPosRole: "yPos" zPosRole: "zPos" @@ -104,7 +106,7 @@ Item { //! [12] ItemModelScatterDataProxy { - itemModel: seriesTwoData.modelTwo + itemModel: seriesData.modelTwo xPosRole: "xPos" yPosRole: "yPos" zPosRole: "zPos" @@ -117,7 +119,7 @@ Item { mesh: Abstract3DSeries.MeshMinimal ItemModelScatterDataProxy { - itemModel: seriesThreeData.modelThree + itemModel: seriesData.modelThree xPosRole: "xPos" yPosRole: "yPos" zPosRole: "zPos" @@ -188,14 +190,14 @@ Item { text: "Change Theme" onClicked: { if (scatterGraph.theme.type === Theme3D.ThemeArmyBlue) { - // Ownership of the theme is transferred and old theme is destroyed when setting - // a new one, so we need to create them dynamically - scatterGraph.theme = Qt.createQmlObject('import QtDataVisualization 1.0; - Theme3D {type: Theme3D.ThemeIsabelle; font.family: "Lucida Handwriting"; - font.pointSize: 40}', parent); + scatterGraph.theme = themeIsabelle + } else { + scatterGraph.theme = themeArmyBlue + } + if (scatterGraph.theme.backgroundEnabled === true) { + backgroundToggle.text = "Hide Background"; } else { - scatterGraph.theme = Qt.createQmlObject('import QtDataVisualization 1.0; - Theme3D {type: Theme3D.ThemeArmyBlue}', parent); + backgroundToggle.text = "Show Background"; } } } diff --git a/examples/qmlscatter/qml/qmlscatter/newbutton.qml b/examples/qmlscatter/qml/qmlscatter/newbutton.qml index e44c9d1a..e4fb99d2 100644 --- a/examples/qmlscatter/qml/qmlscatter/newbutton.qml +++ b/examples/qmlscatter/qml/qmlscatter/newbutton.qml @@ -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 ** diff --git a/examples/qmlsurface/doc/images/qmlsurface-example.png b/examples/qmlsurface/doc/images/qmlsurface-example.png Binary files differindex 57b2633b..d8d394fa 100644 --- a/examples/qmlsurface/doc/images/qmlsurface-example.png +++ b/examples/qmlsurface/doc/images/qmlsurface-example.png diff --git a/examples/qmlsurface/doc/src/qmlsurface.qdoc b/examples/qmlsurface/doc/src/qmlsurface.qdoc index ffbdf305..78f9c745 100644 --- a/examples/qmlsurface/doc/src/qmlsurface.qdoc +++ b/examples/qmlsurface/doc/src/qmlsurface.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 ** diff --git a/examples/qmlsurface/main.cpp b/examples/qmlsurface/main.cpp index 21c987b3..03518d00 100644 --- a/examples/qmlsurface/main.cpp +++ b/examples/qmlsurface/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 ** @@ -16,6 +16,7 @@ ** ****************************************************************************/ +#include <QtDataVisualization/qutils.h> #include <QtGui/QGuiApplication> #include "qtquick2applicationviewer.h" @@ -30,15 +31,8 @@ int main(int argc, char *argv[]) QtQuick2ApplicationViewer viewer; -#if !defined(QT_OPENGL_ES_2) // Enable antialiasing - QSurfaceFormat surfaceFormat; - surfaceFormat.setDepthBufferSize(24); - surfaceFormat.setSamples(8); - surfaceFormat.setRenderableType(QSurfaceFormat::OpenGL); - surfaceFormat.setSwapBehavior(QSurfaceFormat::DoubleBuffer); - viewer.setFormat(surfaceFormat); -#endif + viewer.setFormat(QtDataVisualization::qDefaultSurfaceFormat()); #ifdef Q_OS_ANDROID viewer.addImportPath(QString::fromLatin1("assets:/qml")); diff --git a/examples/qmlsurface/qml/qmlsurface/data.qml b/examples/qmlsurface/qml/qmlsurface/data.qml index 8637c29c..5fd4ece8 100644 --- a/examples/qmlsurface/qml/qmlsurface/data.qml +++ b/examples/qmlsurface/qml/qmlsurface/data.qml @@ -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,7 +17,6 @@ ****************************************************************************/ import QtQuick 2.1 -import QtDataVisualization 1.0 Item { property alias model: dataModel diff --git a/examples/qmlsurface/qml/qmlsurface/main.qml b/examples/qmlsurface/qml/qmlsurface/main.qml index 9f37a3f5..da608aa7 100644 --- a/examples/qmlsurface/qml/qmlsurface/main.qml +++ b/examples/qmlsurface/qml/qmlsurface/main.qml @@ -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 ** diff --git a/examples/qmlsurface/qml/qmlsurface/newbutton.qml b/examples/qmlsurface/qml/qmlsurface/newbutton.qml index e44c9d1a..e4fb99d2 100644 --- a/examples/qmlsurface/qml/qmlsurface/newbutton.qml +++ b/examples/qmlsurface/qml/qmlsurface/newbutton.qml @@ -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 ** diff --git a/examples/scatter/doc/images/scatter-example.png b/examples/scatter/doc/images/scatter-example.png Binary files differindex d1a3c7d9..97a9ba78 100644 --- a/examples/scatter/doc/images/scatter-example.png +++ b/examples/scatter/doc/images/scatter-example.png diff --git a/examples/scatter/doc/src/scatter.qdoc b/examples/scatter/doc/src/scatter.qdoc index 9bef441c..31cfeb09 100644 --- a/examples/scatter/doc/src/scatter.qdoc +++ b/examples/scatter/doc/src/scatter.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 ** diff --git a/examples/scatter/main.cpp b/examples/scatter/main.cpp index af95dd05..dc71667f 100644 --- a/examples/scatter/main.cpp +++ b/examples/scatter/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 ** diff --git a/examples/scatter/scatterdatamodifier.cpp b/examples/scatter/scatterdatamodifier.cpp index 6cdb1458..db2426ce 100644 --- a/examples/scatter/scatterdatamodifier.cpp +++ b/examples/scatter/scatterdatamodifier.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 ** @@ -18,7 +18,7 @@ #include "scatterdatamodifier.h" #include <QtDataVisualization/qscatterdataproxy.h> -#include <QtDataVisualization/q3dvalueaxis.h> +#include <QtDataVisualization/qvalue3daxis.h> #include <QtDataVisualization/q3dscene.h> #include <QtDataVisualization/q3dcamera.h> #include <QtDataVisualization/qscatter3dseries.h> @@ -39,24 +39,24 @@ ScatterDataModifier::ScatterDataModifier(Q3DScatter *scatter) m_smooth(true) { //! [0] - m_graph->setTheme(new Q3DTheme(Q3DTheme::ThemeEbony)); - QFont font = m_graph->theme()->font(); + m_graph->activeTheme()->setType(Q3DTheme::ThemeEbony); + QFont font = m_graph->activeTheme()->font(); font.setPointSize(m_fontSize); - m_graph->theme()->setFont(font); - m_graph->setShadowQuality(QDataVis::ShadowQualitySoftLow); + m_graph->activeTheme()->setFont(font); + m_graph->setShadowQuality(QAbstract3DGraph::ShadowQualitySoftLow); m_graph->scene()->activeCamera()->setCameraPreset(Q3DCamera::CameraPresetFront); //! [0] //! [1] - m_graph->setAxisX(new Q3DValueAxis); - m_graph->setAxisY(new Q3DValueAxis); - m_graph->setAxisZ(new Q3DValueAxis); + m_graph->setAxisX(new QValue3DAxis); + m_graph->setAxisY(new QValue3DAxis); + m_graph->setAxisZ(new QValue3DAxis); //! [1] //! [2] QScatterDataProxy *proxy = new QScatterDataProxy; QScatter3DSeries *series = new QScatter3DSeries(proxy); - series->setItemLabelFormat("@xTitle: @xLabel @yTitle: @yLabel @zTitle: @zLabel"); + series->setItemLabelFormat(QStringLiteral("@xTitle: @xLabel @yTitle: @yLabel @zTitle: @zLabel")); series->setMeshSmooth(m_smooth); m_graph->addSeries(series); //! [2] @@ -131,10 +131,11 @@ void ScatterDataModifier::setSmoothDots(int smooth) void ScatterDataModifier::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()); + Q3DTheme *currentTheme = m_graph->activeTheme(); + currentTheme->setType(Q3DTheme::Theme(theme)); + emit backgroundEnabledChanged(currentTheme->isBackgroundEnabled()); + emit gridEnabledChanged(currentTheme->isGridEnabled()); + emit fontChanged(currentTheme->font()); } void ScatterDataModifier::changePresetCamera() @@ -149,17 +150,17 @@ void ScatterDataModifier::changePresetCamera() void ScatterDataModifier::changeLabelStyle() { - m_graph->theme()->setLabelBackgroundEnabled(!m_graph->theme()->isLabelBackgroundEnabled()); + m_graph->activeTheme()->setLabelBackgroundEnabled(!m_graph->activeTheme()->isLabelBackgroundEnabled()); } void ScatterDataModifier::changeFont(const QFont &font) { QFont newFont = font; newFont.setPointSizeF(m_fontSize); - m_graph->theme()->setFont(newFont); + m_graph->activeTheme()->setFont(newFont); } -void ScatterDataModifier::shadowQualityUpdatedByVisual(QDataVis::ShadowQuality sq) +void ScatterDataModifier::shadowQualityUpdatedByVisual(QAbstract3DGraph::ShadowQuality sq) { int quality = int(sq); emit shadowQualityChanged(quality); // connected to a checkbox in main.cpp @@ -167,18 +168,18 @@ void ScatterDataModifier::shadowQualityUpdatedByVisual(QDataVis::ShadowQuality s void ScatterDataModifier::changeShadowQuality(int quality) { - QDataVis::ShadowQuality sq = QDataVis::ShadowQuality(quality); + QAbstract3DGraph::ShadowQuality sq = QAbstract3DGraph::ShadowQuality(quality); m_graph->setShadowQuality(sq); } void ScatterDataModifier::setBackgroundEnabled(int enabled) { - m_graph->theme()->setBackgroundEnabled((bool)enabled); + m_graph->activeTheme()->setBackgroundEnabled((bool)enabled); } void ScatterDataModifier::setGridEnabled(int enabled) { - m_graph->theme()->setGridEnabled((bool)enabled); + m_graph->activeTheme()->setGridEnabled((bool)enabled); } //! [8] diff --git a/examples/scatter/scatterdatamodifier.h b/examples/scatter/scatterdatamodifier.h index 78dd45e3..e22f24c7 100644 --- a/examples/scatter/scatterdatamodifier.h +++ b/examples/scatter/scatterdatamodifier.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 ** @@ -47,7 +47,7 @@ public slots: void changeStyle(int style); void changeTheme(int theme); void changeShadowQuality(int quality); - void shadowQualityUpdatedByVisual(QDataVis::ShadowQuality shadowQuality); + void shadowQualityUpdatedByVisual(QAbstract3DGraph::ShadowQuality shadowQuality); signals: void backgroundEnabledChanged(bool enabled); diff --git a/examples/surface/doc/images/surface-example.png b/examples/surface/doc/images/surface-example.png Binary files differindex 77c1f900..c323df78 100644 --- a/examples/surface/doc/images/surface-example.png +++ b/examples/surface/doc/images/surface-example.png diff --git a/examples/surface/doc/src/surface.qdoc b/examples/surface/doc/src/surface.qdoc index 6f49a3dc..4b0ec63d 100644 --- a/examples/surface/doc/src/surface.qdoc +++ b/examples/surface/doc/src/surface.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 ** @@ -124,7 +124,8 @@ Q3DSurface supports all the themes Qt Data Visualization has. The example has a pull down menu for selecting the theme. The following method is connected to the - menu to activate the selected theme. + menu to activate the selected theme. The theme type is changed to another predefined theme, + which overwrites all theme properties to predefined values: \snippet ../examples/surface/surfacegraph.cpp 6 diff --git a/examples/surface/main.cpp b/examples/surface/main.cpp index 313ddf6d..4e82eca8 100644 --- a/examples/surface/main.cpp +++ b/examples/surface/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 ** diff --git a/examples/surface/surfacegraph.cpp b/examples/surface/surfacegraph.cpp index 7ebb6b72..5dd64c1f 100644 --- a/examples/surface/surfacegraph.cpp +++ b/examples/surface/surfacegraph.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 ** @@ -18,7 +18,7 @@ #include "surfacegraph.h" -#include <QtDataVisualization/Q3DValueAxis> +#include <QtDataVisualization/QValue3DAxis> #include <QtDataVisualization/Q3DTheme> #include <QtGui/QImage> #include <QtCore/qmath.h> @@ -35,9 +35,9 @@ const float sampleMax = 8.0f; SurfaceGraph::SurfaceGraph(Q3DSurface *surface) : m_graph(surface) { - m_graph->setAxisX(new Q3DValueAxis); - m_graph->setAxisY(new Q3DValueAxis); - m_graph->setAxisZ(new Q3DValueAxis); + m_graph->setAxisX(new QValue3DAxis); + m_graph->setAxisY(new QValue3DAxis); + m_graph->setAxisZ(new QValue3DAxis); //! [0] m_sqrtSinProxy = new QSurfaceDataProxy(); @@ -229,7 +229,7 @@ void SurfaceGraph::setAxisZRange(float min, float max) //! [6] void SurfaceGraph::changeTheme(int theme) { - m_graph->setTheme(new Q3DTheme(Q3DTheme::Theme(theme))); + m_graph->activeTheme()->setType(Q3DTheme::Theme(theme)); } //! [6] diff --git a/examples/surface/surfacegraph.h b/examples/surface/surfacegraph.h index ecdec672..8047be11 100644 --- a/examples/surface/surfacegraph.h +++ b/examples/surface/surfacegraph.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 ** @@ -38,12 +38,12 @@ public: void enableSqrtSinModel(bool enable); //! [0] - void toggleModeNone() { m_graph->setSelectionMode(QDataVis::SelectionNone); } - void toggleModeItem() { m_graph->setSelectionMode(QDataVis::SelectionItem); } - void toggleModeSliceRow() { m_graph->setSelectionMode(QDataVis::SelectionItemAndRow - | QDataVis::SelectionSlice); } - void toggleModeSliceColumn() { m_graph->setSelectionMode(QDataVis::SelectionItemAndColumn - | QDataVis::SelectionSlice); } + void toggleModeNone() { m_graph->setSelectionMode(QAbstract3DGraph::SelectionNone); } + void toggleModeItem() { m_graph->setSelectionMode(QAbstract3DGraph::SelectionItem); } + void toggleModeSliceRow() { m_graph->setSelectionMode(QAbstract3DGraph::SelectionItemAndRow + | QAbstract3DGraph::SelectionSlice); } + void toggleModeSliceColumn() { m_graph->setSelectionMode(QAbstract3DGraph::SelectionItemAndColumn + | QAbstract3DGraph::SelectionSlice); } //! [0] void setBlackToYellowGradient(); |