From 06dd7be52f2bcd23b9a622a17d3d0e8963a7dd17 Mon Sep 17 00:00:00 2001 From: Mika Salmela Date: Mon, 13 Jan 2014 14:51:10 +0200 Subject: Direction for scatter items Task-number: QTRD-2654 Change-Id: Ib21e6d75fa43de45387ad6225973aa8a11ffc0c9 Reviewed-by: Miikka Heikkinen --- tests/directional/main.cpp | 164 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 tests/directional/main.cpp (limited to 'tests/directional/main.cpp') diff --git a/tests/directional/main.cpp b/tests/directional/main.cpp new file mode 100644 index 00000000..359868cc --- /dev/null +++ b/tests/directional/main.cpp @@ -0,0 +1,164 @@ +/**************************************************************************** +** +** Copyright (C) 2013 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 "scatterdatamodifier.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int main(int argc, char **argv) +{ + //! [0] + QApplication app(argc, argv); + Q3DScatter *graph = new Q3DScatter(); + QWidget *container = QWidget::createWindowContainer(graph); + //! [0] + + QSize screenSize = graph->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("Directional scatter")); + + //! [4] + 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(6); + + QPushButton *labelButton = new QPushButton(widget); + labelButton->setText(QStringLiteral("Change label style")); + + QComboBox *itemStyleList = new QComboBox(widget); + itemStyleList->addItem(QStringLiteral("Arrow"), int(QAbstract3DSeries::MeshArrow)); + itemStyleList->addItem(QStringLiteral("Cube"), int(QAbstract3DSeries::MeshCube)); + itemStyleList->addItem(QStringLiteral("Minimal"), int(QAbstract3DSeries::MeshMinimal)); + itemStyleList->setCurrentIndex(-1); + + QPushButton *cameraButton = new QPushButton(widget); + cameraButton->setText(QStringLiteral("Change camera preset")); + + QCheckBox *backgroundCheckBox = new QCheckBox(widget); + backgroundCheckBox->setText(QStringLiteral("Show background")); + backgroundCheckBox->setChecked(true); + + QCheckBox *gridCheckBox = new QCheckBox(widget); + gridCheckBox->setText(QStringLiteral("Show grid")); + gridCheckBox->setChecked(true); + + 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(4); + + QFontComboBox *fontList = new QFontComboBox(widget); + fontList->setCurrentFont(QFont("Arial")); + //! [4] + + //! [5] + vLayout->addWidget(labelButton, 0, Qt::AlignTop); + vLayout->addWidget(cameraButton, 0, Qt::AlignTop); + vLayout->addWidget(backgroundCheckBox); + vLayout->addWidget(gridCheckBox); + vLayout->addWidget(new QLabel(QStringLiteral("Change dot style"))); + vLayout->addWidget(itemStyleList); + 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, 1, Qt::AlignTop); + //! [5] + + //! [2] + ScatterDataModifier *modifier = new ScatterDataModifier(graph); + //! [2] + + //! [6] + QObject::connect(cameraButton, &QPushButton::clicked, modifier, + &ScatterDataModifier::changePresetCamera); + QObject::connect(labelButton, &QPushButton::clicked, modifier, + &ScatterDataModifier::changeLabelStyle); + + QObject::connect(backgroundCheckBox, &QCheckBox::stateChanged, modifier, + &ScatterDataModifier::setBackgroundEnabled); + QObject::connect(gridCheckBox, &QCheckBox::stateChanged, modifier, + &ScatterDataModifier::setGridEnabled); + + QObject::connect(modifier, &ScatterDataModifier::backgroundEnabledChanged, + backgroundCheckBox, &QCheckBox::setChecked); + QObject::connect(modifier, &ScatterDataModifier::gridEnabledChanged, + gridCheckBox, &QCheckBox::setChecked); + QObject::connect(itemStyleList, SIGNAL(currentIndexChanged(int)), modifier, + SLOT(changeStyle(int))); + + QObject::connect(themeList, SIGNAL(currentIndexChanged(int)), modifier, + SLOT(changeTheme(int))); + + QObject::connect(shadowQuality, SIGNAL(currentIndexChanged(int)), modifier, + SLOT(changeShadowQuality(int))); + + QObject::connect(modifier, &ScatterDataModifier::shadowQualityChanged, shadowQuality, + &QComboBox::setCurrentIndex); + QObject::connect(graph, &Q3DScatter::shadowQualityChanged, modifier, + &ScatterDataModifier::shadowQualityUpdatedByVisual); + + QObject::connect(fontList, &QFontComboBox::currentFontChanged, modifier, + &ScatterDataModifier::changeFont); + + QObject::connect(modifier, &ScatterDataModifier::fontChanged, fontList, + &QFontComboBox::setCurrentFont); + //! [6] + + itemStyleList->setCurrentIndex(0); + + //! [3] + widget->show(); + return app.exec(); + //! [3] +} -- cgit v1.2.3