diff options
author | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2014-02-13 09:59:52 +0200 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2014-02-13 10:09:17 +0200 |
commit | 88cd10aa7b3559b092cf5575b0a17d002dc100ae (patch) | |
tree | 9d6e7efdec49419558bb4ef4a9bc02ae3cb1cfc4 /examples/bars | |
parent | ecabd51692b476567dc42a745f51996ec665b385 (diff) |
Fix examples installation
Had to add one folder to the examples structure so
installation works correctly.
Change-Id: Ic92dfe9997413a6243abcf5eeba12744ba9e938c
Reviewed-by: Tomi Korpipää <tomi.korpipaa@digia.com>
Diffstat (limited to 'examples/bars')
-rw-r--r-- | examples/bars/bars.pro | 13 | ||||
-rw-r--r-- | examples/bars/doc/images/bars-example.png | bin | 151337 -> 0 bytes | |||
-rw-r--r-- | examples/bars/doc/src/bars.qdoc | 172 | ||||
-rw-r--r-- | examples/bars/graphmodifier.cpp | 280 | ||||
-rw-r--r-- | examples/bars/graphmodifier.h | 87 | ||||
-rw-r--r-- | examples/bars/main.cpp | 271 |
6 files changed, 0 insertions, 823 deletions
diff --git a/examples/bars/bars.pro b/examples/bars/bars.pro deleted file mode 100644 index e4e2c5fa..00000000 --- a/examples/bars/bars.pro +++ /dev/null @@ -1,13 +0,0 @@ -!include( ../examples.pri ) { - error( "Couldn't find the examples.pri file!" ) -} - -SOURCES += main.cpp graphmodifier.cpp -HEADERS += graphmodifier.h - -QT += widgets - -INSTALLS += target - -OTHER_FILES += doc/src/* \ - doc/images/* diff --git a/examples/bars/doc/images/bars-example.png b/examples/bars/doc/images/bars-example.png Binary files differdeleted file mode 100644 index 5bd2c7d9..00000000 --- a/examples/bars/doc/images/bars-example.png +++ /dev/null diff --git a/examples/bars/doc/src/bars.qdoc b/examples/bars/doc/src/bars.qdoc deleted file mode 100644 index 3cfc72b1..00000000 --- a/examples/bars/doc/src/bars.qdoc +++ /dev/null @@ -1,172 +0,0 @@ -/**************************************************************************** -** -** 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 bars - \title Bars Example - \ingroup qtdatavisualization_examples - \brief Using Q3DBars in a widget application. - - The bars example shows how to make a 3D bar graph using Q3DBars and combining the use of - widgets for adjusting several adjustable qualities. The example shows how to: - - \list - \li Create an application with Q3DBars and some widgets - \li Use QBar3DSeries and QBarDataProxy to set data to the graph - \li Adjust some graph and series properties using widget controls - \endlist - - It also demonstrates how having negative bar values affects the graph. - - For instructions about how to interact with the graph, see \l{Qt Data Visualization Interacting with Data}{this page}. - - \image bars-example.png - - \section1 Creating the application - - First, in main.cpp, we create a QApplication, instantiate Q3DBars and a window container - for it: - - \snippet ../examples/bars/main.cpp 0 - - The call to QWidget::createWindowContainer is required, as all data visualization types - (Q3DBars, Q3DScatter, Q3DSurface) inherit QWindow. Any class inheriting QWindow cannot be used - as a widget any other way. - - Then we'll create horizontal and vertical layouts. We'll add the graph and the vertical - layout into the horizontal one: - - \snippet ../examples/bars/main.cpp 1 - - We're not using the vertical layout for anything yet, but we'll get back to it in - \l {Using widgets to control the graph} - - Next, let's create another class to handle the data addition and other interaction with the - graph. Let's call it \c GraphModifier (See \l {Setting up the graph} and - \l {Adding data to the graph} for details): - - \snippet ../examples/bars/main.cpp 2 - - The application main is done and we can show the graph and start the event loop: - - \snippet ../examples/bars/main.cpp 3 - - \section1 Setting up the graph - - Let's set up the graph in the constructor of the \c GraphModifier class we instantiated in the - application main: - - \snippet ../examples/bars/graphmodifier.cpp 0 - - Let's take a closer look at parts of the code. - - 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 - - Then we're setting some of the visual qualities for the graph: - - \snippet ../examples/bars/graphmodifier.cpp 2 - - We're also setting up the axes and setting them to the graph as active axes: - - \snippet ../examples/bars/graphmodifier.cpp 3 - - Next we initialize the visual properties of the series. - Note that the second series is initially not visible: - - \snippet ../examples/bars/graphmodifier.cpp 8 - - The series need to be added to the graph to show them: - - \snippet ../examples/bars/graphmodifier.cpp 4 - - Finally, we set the camera angle by calling the same method the camera angle change button - in the UI uses to cycle through various camera angles: - - \snippet ../examples/bars/graphmodifier.cpp 6 - - There you can see that the camera is controlled via the scene object of the graph: - - \snippet ../examples/bars/graphmodifier.cpp 10 - - For more information about using scene and cameras, see Q3DScene and Q3DCamera. - - That concludes setting up the graph. - - \section1 Adding data to the graph - - At the end of the constructor there's a call: - - \snippet ../examples/bars/graphmodifier.cpp 9 - - This method is used to add data to the proxies of the two series: - - \snippet ../examples/bars/graphmodifier.cpp 5 - - Now the series have data to show. - - \section1 Using widgets to control the graph - - There isn't much interaction yet, so let's continue by adding some widgets back in the - application main. Let's just focus on two as an example: - - \snippet ../examples/bars/main.cpp 4 - - We can use these slider widgets to rotate the graph instead of just using the mouse or - touch. - - Let's add them to the vertical layout we created earlier: - - \snippet ../examples/bars/main.cpp 5 - - Then we'll connect them to methods in \c GraphModifier: - - \snippet ../examples/bars/main.cpp 6 - - Here are the methods in \c GraphModifier the signals were connected to. The camera - is controlled via the scene object. This time we specify the actual camera position - along the orbit around the center point, instead of specifying a preset camera angle: - - \snippet ../examples/bars/graphmodifier.cpp 7 - - Now these two sliders can be used to rotate the graph. - - And so we have an application in which we can control: - - \list - \li Graph rotation - \li Label style - \li Camera preset - \li Background visibility - \li Grid visibility - \li Bar shading smoothness - \li Visibility of the second bar series - \li Data range to be shown - \li Bar style - \li Selection mode - \li Theme - \li Shadow quality - \li Font - \li Font size - \endlist - - \section1 Example contents - -*/ diff --git a/examples/bars/graphmodifier.cpp b/examples/bars/graphmodifier.cpp deleted file mode 100644 index 55f52580..00000000 --- a/examples/bars/graphmodifier.cpp +++ /dev/null @@ -1,280 +0,0 @@ -/**************************************************************************** -** -** 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 "graphmodifier.h" -#include <QtDataVisualization/qcategory3daxis.h> -#include <QtDataVisualization/qvalue3daxis.h> -#include <QtDataVisualization/qbardataproxy.h> -#include <QtDataVisualization/q3dscene.h> -#include <QtDataVisualization/q3dcamera.h> -#include <QtDataVisualization/qbar3dseries.h> -#include <QtDataVisualization/q3dtheme.h> -#include <QTime> -#include <QComboBox> - -using namespace QtDataVisualization; - -const QString celsiusString = QString(QChar(0xB0)) + "C"; - -//! [0] -GraphModifier::GraphModifier(Q3DBars *bargraph) - : m_graph(bargraph), - m_xRotation(0.0f), - m_yRotation(0.0f), - m_fontSize(30), - m_segments(4), - m_subSegments(3), - m_minval(-20.0f), - m_maxval(20.0f), - //! [1] - m_temperatureAxis(new QValue3DAxis), - m_yearAxis(new QCategory3DAxis), - m_monthAxis(new QCategory3DAxis), - m_primarySeries(new QBar3DSeries), - m_secondarySeries(new QBar3DSeries), - //! [1] - m_barMesh(QAbstract3DSeries::MeshBevelBar), - m_smooth(false) -{ - //! [2] - 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"; - m_years << "2006" << "2007" << "2008" << "2009" << "2010" << "2011" << "2012" << "2013"; - - //! [3] - m_temperatureAxis->setTitle("Average temperature"); - m_temperatureAxis->setSegmentCount(m_segments); - m_temperatureAxis->setSubSegmentCount(m_subSegments); - m_temperatureAxis->setRange(m_minval, m_maxval); - m_temperatureAxis->setLabelFormat(QString(QStringLiteral("%.1f ") + celsiusString)); - - m_yearAxis->setTitle("Year"); - m_monthAxis->setTitle("Month"); - - m_graph->setValueAxis(m_temperatureAxis); - m_graph->setRowAxis(m_yearAxis); - m_graph->setColumnAxis(m_monthAxis); - //! [3] - - //! [8] - 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(m_primarySeries); - m_graph->addSeries(m_secondarySeries); - //! [4] - - //! [6] - changePresetCamera(); - //! [6] - - //! [9] - resetTemperatureData(); - //! [9] -} -//! [0] - -GraphModifier::~GraphModifier() -{ - delete m_graph; -} - -void GraphModifier::resetTemperatureData() -{ - //! [5] - // Set up data - static const float tempOulu[8][12] = { - {-6.7f, -11.7f, -9.7f, 3.3f, 9.2f, 14.0f, 16.3f, 17.8f, 10.2f, 2.1f, -2.6f, -0.3f}, // 2006 - {-6.8f, -13.3f, 0.2f, 1.5f, 7.9f, 13.4f, 16.1f, 15.5f, 8.2f, 5.4f, -2.6f, -0.8f}, // 2007 - {-4.2f, -4.0f, -4.6f, 1.9f, 7.3f, 12.5f, 15.0f, 12.8f, 7.6f, 5.1f, -0.9f, -1.3f}, // 2008 - {-7.8f, -8.8f, -4.2f, 0.7f, 9.3f, 13.2f, 15.8f, 15.5f, 11.2f, 0.6f, 0.7f, -8.4f}, // 2009 - {-14.4f, -12.1f, -7.0f, 2.3f, 11.0f, 12.6f, 18.8f, 13.8f, 9.4f, 3.9f, -5.6f, -13.0f}, // 2010 - {-9.0f, -15.2f, -3.8f, 2.6f, 8.3f, 15.9f, 18.6f, 14.9f, 11.1f, 5.3f, 1.8f, -0.2f}, // 2011 - {-8.7f, -11.3f, -2.3f, 0.4f, 7.5f, 12.2f, 16.4f, 14.1f, 9.2f, 3.1f, 0.3f, -12.1f}, // 2012 - {-7.9f, -5.3f, -9.1f, 0.8f, 11.6f, 16.6f, 15.9f, 15.5f, 11.2f, 4.0f, 0.1f, -1.9f} // 2013 - }; - - static const float tempHelsinki[8][12] = { - {-3.7f, -7.8f, -5.4f, 3.4f, 10.7f, 15.4f, 18.6f, 18.7f, 14.3f, 8.5f, 2.9f, 4.1f}, // 2006 - {-1.2f, -7.5f, 3.1f, 5.5f, 10.3f, 15.9f, 17.4f, 17.9f, 11.2f, 7.3f, 1.1f, 0.5f}, // 2007 - {-0.6f, 1.2f, 0.2f, 6.3f, 10.2f, 13.8f, 18.1f, 15.1f, 10.1f, 9.4f, 2.5f, 0.4f}, // 2008 - {-2.9f, -3.5f, -0.9f, 4.7f, 10.9f, 14.0f, 17.4f, 16.8f, 13.2f, 4.1f, 2.6f, -2.3f}, // 2009 - {-10.2f, -8.0f, -1.9f, 6.6f, 11.3f, 14.5f, 21.0f, 18.8f, 12.6f, 6.1f, -0.5f, -7.3f}, // 2010 - {-4.4f, -9.1f, -2.0f, 5.5f, 9.9f, 15.6f, 20.8f, 17.8f, 13.4f, 8.9f, 3.6f, 1.5f}, // 2011 - {-3.5f, -3.2f, -0.7f, 4.0f, 11.1f, 13.4f, 17.3f, 15.8f, 13.1f, 6.4f, 4.1f, -5.1f}, // 2012 - {-4.8f, -1.8f, -5.0f, 2.9f, 12.8f, 17.2f, 18.0f, 17.1f, 12.5f, 7.5f, 4.5f, 2.3f} // 2013 - }; - - // Create data arrays - QBarDataArray *dataSet = new QBarDataArray; - QBarDataArray *dataSet2 = new QBarDataArray; - QBarDataRow *dataRow; - QBarDataRow *dataRow2; - - dataSet->reserve(m_years.size()); - for (int year = 0; year < m_years.size(); year++) { - // Create a data row - dataRow = new QBarDataRow(m_months.size()); - dataRow2 = new QBarDataRow(m_months.size()); - for (int month = 0; month < m_months.size(); month++) { - // Add data to the row - (*dataRow)[month].setValue(tempOulu[year][month]); - (*dataRow2)[month].setValue(tempHelsinki[year][month]); - } - // Add the row to the set - dataSet->append(dataRow); - dataSet2->append(dataRow2); - } - - // 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] -} - -void GraphModifier::changeRange(int range) -{ - if (range >= m_years.count()) - m_yearAxis->setRange(0, m_years.count() - 1); - else - m_yearAxis->setRange(range, range); -} - -void GraphModifier::changeStyle(int style) -{ - QComboBox *comboBox = qobject_cast<QComboBox *>(sender()); - if (comboBox) { - m_barMesh = QAbstract3DSeries::Mesh(comboBox->itemData(style).toInt()); - m_primarySeries->setMesh(m_barMesh); - m_secondarySeries->setMesh(m_barMesh); - } -} - -void GraphModifier::changePresetCamera() -{ - //! [10] - static int preset = Q3DCamera::CameraPresetFront; - - m_graph->scene()->activeCamera()->setCameraPreset((Q3DCamera::CameraPreset)preset); - - if (++preset > Q3DCamera::CameraPresetDirectlyBelow) - preset = Q3DCamera::CameraPresetFrontLow; - //! [10] -} - -void GraphModifier::changeTheme(int theme) -{ - 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->activeTheme()->setLabelBackgroundEnabled(!m_graph->activeTheme()->isLabelBackgroundEnabled()); -} - -void GraphModifier::changeSelectionMode(int selectionMode) -{ - QComboBox *comboBox = qobject_cast<QComboBox *>(sender()); - if (comboBox) { - int flags = comboBox->itemData(selectionMode).toInt(); - m_graph->setSelectionMode(QAbstract3DGraph::SelectionFlags(flags)); - } -} - -void GraphModifier::changeFont(const QFont &font) -{ - QFont newFont = font; - m_graph->activeTheme()->setFont(newFont); -} - -void GraphModifier::changeFontSize(int fontsize) -{ - m_fontSize = fontsize; - QFont font = m_graph->activeTheme()->font(); - font.setPointSize(m_fontSize); - m_graph->activeTheme()->setFont(font); -} - -void GraphModifier::shadowQualityUpdatedByVisual(QAbstract3DGraph::ShadowQuality sq) -{ - int quality = int(sq); - // Updates the UI component to show correct shadow quality - emit shadowQualityChanged(quality); -} - -void GraphModifier::changeShadowQuality(int quality) -{ - QAbstract3DGraph::ShadowQuality sq = QAbstract3DGraph::ShadowQuality(quality); - m_graph->setShadowQuality(sq); - emit shadowQualityChanged(quality); -} - -//! [7] -void GraphModifier::rotateX(int rotation) -{ - m_xRotation = rotation; - m_graph->scene()->activeCamera()->setCameraPosition(m_xRotation, m_yRotation); -} - -void GraphModifier::rotateY(int rotation) -{ - m_yRotation = rotation; - m_graph->scene()->activeCamera()->setCameraPosition(m_xRotation, m_yRotation); -} -//! [7] - -void GraphModifier::setBackgroundEnabled(int enabled) -{ - m_graph->activeTheme()->setBackgroundEnabled(bool(enabled)); -} - -void GraphModifier::setGridEnabled(int enabled) -{ - m_graph->activeTheme()->setGridEnabled(bool(enabled)); -} - -void GraphModifier::setSmoothBars(int smooth) -{ - m_smooth = bool(smooth); - m_primarySeries->setMeshSmooth(m_smooth); - m_secondarySeries->setMeshSmooth(m_smooth); -} - -void GraphModifier::setSeriesVisibility(int enabled) -{ - m_secondarySeries->setVisible(bool(enabled)); -} diff --git a/examples/bars/graphmodifier.h b/examples/bars/graphmodifier.h deleted file mode 100644 index 674c3262..00000000 --- a/examples/bars/graphmodifier.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** 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 -** -****************************************************************************/ - -#ifndef GRAPHMODIFIER_H -#define GRAPHMODIFIER_H - -#include <QtDataVisualization/q3dbars.h> -#include <QtDataVisualization/qbardataproxy.h> -#include <QtDataVisualization/qabstract3dseries.h> - -#include <QFont> -#include <QDebug> -#include <QStringList> -#include <QPointer> - -using namespace QtDataVisualization; - -class GraphModifier : public QObject -{ - Q_OBJECT -public: - explicit GraphModifier(Q3DBars *bargraph); - ~GraphModifier(); - - void resetTemperatureData(); - void changePresetCamera(); - void changeLabelBackground(); - void changeFont(const QFont &font); - void changeFontSize(int fontsize); - void rotateX(int rotation); - void rotateY(int rotation); - void setBackgroundEnabled(int enabled); - void setGridEnabled(int enabled); - void setSmoothBars(int smooth); - void setSeriesVisibility(int enabled); - -public slots: - void changeRange(int range); - void changeStyle(int style); - void changeSelectionMode(int selectionMode); - void changeTheme(int theme); - void changeShadowQuality(int quality); - void shadowQualityUpdatedByVisual(QAbstract3DGraph::ShadowQuality shadowQuality); - -signals: - void shadowQualityChanged(int quality); - void backgroundEnabledChanged(bool enabled); - void gridEnabledChanged(bool enabled); - void fontChanged(QFont font); - void fontSizeChanged(int size); - -private: - Q3DBars *m_graph; - float m_xRotation; - float m_yRotation; - int m_fontSize; - int m_segments; - int m_subSegments; - float m_minval; - float m_maxval; - QStringList m_months; - QStringList m_years; - QValue3DAxis *m_temperatureAxis; - QCategory3DAxis *m_yearAxis; - QCategory3DAxis *m_monthAxis; - QBar3DSeries *m_primarySeries; - QBar3DSeries *m_secondarySeries; - QAbstract3DSeries::Mesh m_barMesh; - bool m_smooth; -}; - -#endif diff --git a/examples/bars/main.cpp b/examples/bars/main.cpp deleted file mode 100644 index f04e501d..00000000 --- a/examples/bars/main.cpp +++ /dev/null @@ -1,271 +0,0 @@ -/**************************************************************************** -** -** 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 "graphmodifier.h" - -#include <QApplication> -#include <QWidget> -#include <QHBoxLayout> -#include <QVBoxLayout> -#include <QPushButton> -#include <QCheckBox> -#include <QSlider> -#include <QFontComboBox> -#include <QLabel> -#include <QScreen> -#include <QFontDatabase> - -int main(int argc, char **argv) -{ - //! [0] - QApplication app(argc, argv); - Q3DBars *widgetgraph = new Q3DBars(); - QWidget *container = QWidget::createWindowContainer(widgetgraph); - //! [0] - - QSize screenSize = widgetgraph->screen()->size(); - container->setMinimumSize(QSize(screenSize.width() / 2, screenSize.height() / 1.5)); - container->setMaximumSize(screenSize); - container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - container->setFocusPolicy(Qt::StrongFocus); - - //! [1] - QWidget *widget = new QWidget; - QHBoxLayout *hLayout = new QHBoxLayout(widget); - QVBoxLayout *vLayout = new QVBoxLayout(); - hLayout->addWidget(container, 1); - hLayout->addLayout(vLayout); - //! [1] - - widget->setWindowTitle(QStringLiteral("Average temperatures in Oulu and Helsinki, Finland (2006-2013)")); - - QComboBox *themeList = new QComboBox(widget); - themeList->addItem(QStringLiteral("Qt")); - themeList->addItem(QStringLiteral("Primary Colors")); - themeList->addItem(QStringLiteral("Digia")); - themeList->addItem(QStringLiteral("Stone Moss")); - themeList->addItem(QStringLiteral("Army Blue")); - themeList->addItem(QStringLiteral("Retro")); - themeList->addItem(QStringLiteral("Ebony")); - themeList->addItem(QStringLiteral("Isabelle")); - themeList->setCurrentIndex(0); - - QPushButton *labelButton = new QPushButton(widget); - labelButton->setText(QStringLiteral("Change label style")); - - QCheckBox *smoothCheckBox = new QCheckBox(widget); - smoothCheckBox->setText(QStringLiteral("Smooth bars")); - smoothCheckBox->setChecked(false); - - QComboBox *barStyleList = new QComboBox(widget); - barStyleList->addItem(QStringLiteral("Bar"), int(QAbstract3DSeries::MeshBar)); - barStyleList->addItem(QStringLiteral("Pyramid"), int(QAbstract3DSeries::MeshPyramid)); - barStyleList->addItem(QStringLiteral("Cone"), int(QAbstract3DSeries::MeshCone)); - barStyleList->addItem(QStringLiteral("Cylinder"), int(QAbstract3DSeries::MeshCylinder)); - barStyleList->addItem(QStringLiteral("Bevel bar"), int(QAbstract3DSeries::MeshBevelBar)); - barStyleList->addItem(QStringLiteral("Sphere"), int(QAbstract3DSeries::MeshSphere)); - barStyleList->setCurrentIndex(4); - - QPushButton *cameraButton = new QPushButton(widget); - cameraButton->setText(QStringLiteral("Change camera preset")); - - QComboBox *selectionModeList = new QComboBox(widget); - selectionModeList->addItem(QStringLiteral("None"), - int(QAbstract3DGraph::SelectionNone)); - selectionModeList->addItem(QStringLiteral("Bar"), - int(QAbstract3DGraph::SelectionItem)); - selectionModeList->addItem(QStringLiteral("Row"), - int(QAbstract3DGraph::SelectionRow)); - selectionModeList->addItem(QStringLiteral("Bar and Row"), - int(QAbstract3DGraph::SelectionItemAndRow)); - selectionModeList->addItem(QStringLiteral("Column"), - int(QAbstract3DGraph::SelectionColumn)); - selectionModeList->addItem(QStringLiteral("Bar and Column"), - int(QAbstract3DGraph::SelectionItemAndColumn)); - selectionModeList->addItem(QStringLiteral("Row and Column"), - int(QAbstract3DGraph::SelectionRowAndColumn)); - selectionModeList->addItem(QStringLiteral("Bar, Row and Column"), - int(QAbstract3DGraph::SelectionItemRowAndColumn)); - selectionModeList->addItem(QStringLiteral("Slice into Row"), - int(QAbstract3DGraph::SelectionSlice | QAbstract3DGraph::SelectionRow)); - selectionModeList->addItem(QStringLiteral("Slice into Row and Item"), - int(QAbstract3DGraph::SelectionSlice | QAbstract3DGraph::SelectionItemAndRow)); - selectionModeList->addItem(QStringLiteral("Slice into Column"), - int(QAbstract3DGraph::SelectionSlice | QAbstract3DGraph::SelectionColumn)); - selectionModeList->addItem(QStringLiteral("Slice into Column and Item"), - int(QAbstract3DGraph::SelectionSlice | QAbstract3DGraph::SelectionItemAndColumn)); - selectionModeList->addItem(QStringLiteral("Multi: Bar, Row, Col"), - int(QAbstract3DGraph::SelectionItemRowAndColumn - | QAbstract3DGraph::SelectionMultiSeries)); - selectionModeList->addItem(QStringLiteral("Multi, Slice: Row, Item"), - int(QAbstract3DGraph::SelectionSlice | QAbstract3DGraph::SelectionItemAndRow - | QAbstract3DGraph::SelectionMultiSeries)); - selectionModeList->addItem(QStringLiteral("Multi, Slice: Col, Item"), - int(QAbstract3DGraph::SelectionSlice | QAbstract3DGraph::SelectionItemAndColumn - | QAbstract3DGraph::SelectionMultiSeries)); - selectionModeList->setCurrentIndex(1); - - QCheckBox *backgroundCheckBox = new QCheckBox(widget); - backgroundCheckBox->setText(QStringLiteral("Show background")); - backgroundCheckBox->setChecked(false); - - QCheckBox *gridCheckBox = new QCheckBox(widget); - gridCheckBox->setText(QStringLiteral("Show grid")); - gridCheckBox->setChecked(true); - - QCheckBox *seriesCheckBox = new QCheckBox(widget); - seriesCheckBox->setText(QStringLiteral("Show second series")); - seriesCheckBox->setChecked(false); - - //! [4] - QSlider *rotationSliderX = new QSlider(Qt::Horizontal, widget); - rotationSliderX->setTickInterval(30); - rotationSliderX->setTickPosition(QSlider::TicksBelow); - rotationSliderX->setMinimum(-180); - rotationSliderX->setValue(0); - rotationSliderX->setMaximum(180); - QSlider *rotationSliderY = new QSlider(Qt::Horizontal, widget); - rotationSliderY->setTickInterval(15); - rotationSliderY->setTickPosition(QSlider::TicksAbove); - rotationSliderY->setMinimum(-90); - rotationSliderY->setValue(0); - rotationSliderY->setMaximum(90); - //! [4] - - QSlider *fontSizeSlider = new QSlider(Qt::Horizontal, widget); - fontSizeSlider->setTickInterval(10); - fontSizeSlider->setTickPosition(QSlider::TicksBelow); - fontSizeSlider->setMinimum(1); - fontSizeSlider->setValue(30); - fontSizeSlider->setMaximum(100); - - QFontComboBox *fontList = new QFontComboBox(widget); - fontList->setCurrentFont(QFont("Times New Roman")); - - QComboBox *shadowQuality = new QComboBox(widget); - shadowQuality->addItem(QStringLiteral("None")); - shadowQuality->addItem(QStringLiteral("Low")); - shadowQuality->addItem(QStringLiteral("Medium")); - shadowQuality->addItem(QStringLiteral("High")); - shadowQuality->addItem(QStringLiteral("Low Soft")); - shadowQuality->addItem(QStringLiteral("Medium Soft")); - shadowQuality->addItem(QStringLiteral("High Soft")); - shadowQuality->setCurrentIndex(5); - - QComboBox *rangeList = new QComboBox(widget); - rangeList->addItem(QStringLiteral("2006")); - rangeList->addItem(QStringLiteral("2007")); - rangeList->addItem(QStringLiteral("2008")); - rangeList->addItem(QStringLiteral("2009")); - rangeList->addItem(QStringLiteral("2010")); - rangeList->addItem(QStringLiteral("2011")); - rangeList->addItem(QStringLiteral("2012")); - rangeList->addItem(QStringLiteral("2013")); - rangeList->addItem(QStringLiteral("All")); - rangeList->setCurrentIndex(8); - - //! [5] - vLayout->addWidget(new QLabel(QStringLiteral("Rotate horizontally"))); - vLayout->addWidget(rotationSliderX, 0, Qt::AlignTop); - vLayout->addWidget(new QLabel(QStringLiteral("Rotate vertically"))); - vLayout->addWidget(rotationSliderY, 0, Qt::AlignTop); - //! [5] - vLayout->addWidget(labelButton, 0, Qt::AlignTop); - vLayout->addWidget(cameraButton, 0, Qt::AlignTop); - vLayout->addWidget(backgroundCheckBox); - vLayout->addWidget(gridCheckBox); - vLayout->addWidget(smoothCheckBox); - vLayout->addWidget(seriesCheckBox); - vLayout->addWidget(new QLabel(QStringLiteral("Show year"))); - vLayout->addWidget(rangeList); - vLayout->addWidget(new QLabel(QStringLiteral("Change bar style"))); - vLayout->addWidget(barStyleList); - vLayout->addWidget(new QLabel(QStringLiteral("Change selection mode"))); - vLayout->addWidget(selectionModeList); - vLayout->addWidget(new QLabel(QStringLiteral("Change theme"))); - vLayout->addWidget(themeList); - vLayout->addWidget(new QLabel(QStringLiteral("Adjust shadow quality"))); - vLayout->addWidget(shadowQuality); - vLayout->addWidget(new QLabel(QStringLiteral("Change font"))); - vLayout->addWidget(fontList); - vLayout->addWidget(new QLabel(QStringLiteral("Adjust font size"))); - vLayout->addWidget(fontSizeSlider, 1, Qt::AlignTop); - - //! [2] - GraphModifier *modifier = new GraphModifier(widgetgraph); - //! [2] - - //! [6] - QObject::connect(rotationSliderX, &QSlider::valueChanged, modifier, &GraphModifier::rotateX); - QObject::connect(rotationSliderY, &QSlider::valueChanged, modifier, &GraphModifier::rotateY); - //! [6] - - QObject::connect(labelButton, &QPushButton::clicked, modifier, - &GraphModifier::changeLabelBackground); - QObject::connect(cameraButton, &QPushButton::clicked, modifier, - &GraphModifier::changePresetCamera); - - QObject::connect(backgroundCheckBox, &QCheckBox::stateChanged, modifier, - &GraphModifier::setBackgroundEnabled); - QObject::connect(gridCheckBox, &QCheckBox::stateChanged, modifier, - &GraphModifier::setGridEnabled); - QObject::connect(smoothCheckBox, &QCheckBox::stateChanged, modifier, - &GraphModifier::setSmoothBars); - QObject::connect(seriesCheckBox, &QCheckBox::stateChanged, modifier, - &GraphModifier::setSeriesVisibility); - - QObject::connect(modifier, &GraphModifier::backgroundEnabledChanged, - backgroundCheckBox, &QCheckBox::setChecked); - QObject::connect(modifier, &GraphModifier::gridEnabledChanged, - gridCheckBox, &QCheckBox::setChecked); - - QObject::connect(rangeList, SIGNAL(currentIndexChanged(int)), modifier, - SLOT(changeRange(int))); - - QObject::connect(barStyleList, SIGNAL(currentIndexChanged(int)), modifier, - SLOT(changeStyle(int))); - - QObject::connect(selectionModeList, SIGNAL(currentIndexChanged(int)), modifier, - SLOT(changeSelectionMode(int))); - - QObject::connect(themeList, SIGNAL(currentIndexChanged(int)), modifier, - SLOT(changeTheme(int))); - - QObject::connect(shadowQuality, SIGNAL(currentIndexChanged(int)), modifier, - SLOT(changeShadowQuality(int))); - - QObject::connect(modifier, &GraphModifier::shadowQualityChanged, shadowQuality, - &QComboBox::setCurrentIndex); - QObject::connect(widgetgraph, &Q3DBars::shadowQualityChanged, modifier, - &GraphModifier::shadowQualityUpdatedByVisual); - - QObject::connect(fontSizeSlider, &QSlider::valueChanged, modifier, - &GraphModifier::changeFontSize); - QObject::connect(fontList, &QFontComboBox::currentFontChanged, modifier, - &GraphModifier::changeFont); - - QObject::connect(modifier, &GraphModifier::fontSizeChanged, fontSizeSlider, - &QSlider::setValue); - QObject::connect(modifier, &GraphModifier::fontChanged, fontList, - &QFontComboBox::setCurrentFont); - - //! [3] - widget->show(); - return app.exec(); - //! [3] -} |