diff options
author | Tomi Korpipää <tomi.korpipaa@digia.com> | 2014-04-22 13:19:49 +0300 |
---|---|---|
committer | Mika Salmela <mika.salmela@digia.com> | 2014-04-22 13:24:16 +0300 |
commit | a11dcce773b9ad2a913a32efe0c51b1221694659 (patch) | |
tree | 5cec5b3957af99cf7d4d65540c08827487edd604 /examples/datavisualization/customitems/main.cpp | |
parent | bf8ed99fb5a474aa6a56d61c9e3a1b5e44d6b6cf (diff) |
Custom Item Example added
Task-number: QTRD-3043
+ surface selection bug fix
- snapshot to be added
Change-Id: I17276e39c304cbf1a58eaa2334eff2268656dbf4
Reviewed-by: Mika Salmela <mika.salmela@digia.com>
Diffstat (limited to 'examples/datavisualization/customitems/main.cpp')
-rw-r--r-- | examples/datavisualization/customitems/main.cpp | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/examples/datavisualization/customitems/main.cpp b/examples/datavisualization/customitems/main.cpp new file mode 100644 index 00000000..a37cc76f --- /dev/null +++ b/examples/datavisualization/customitems/main.cpp @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** 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 "customitemgraph.h" + +#include <QtWidgets/QApplication> +#include <QtWidgets/QWidget> +#include <QtWidgets/QHBoxLayout> +#include <QtWidgets/QVBoxLayout> +#include <QtWidgets/QCheckBox> +#include <QtWidgets/QLabel> + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + Q3DSurface *graph = new Q3DSurface(); + QWidget *container = QWidget::createWindowContainer(graph); + + container->setMinimumSize(QSize(1280, 768)); + container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + container->setFocusPolicy(Qt::StrongFocus); + + QWidget *widget = new QWidget; + QHBoxLayout *hLayout = new QHBoxLayout(widget); + QVBoxLayout *vLayoutLeft = new QVBoxLayout(); + vLayoutLeft->setAlignment(Qt::AlignTop); + QVBoxLayout *vLayoutRight = new QVBoxLayout(); + vLayoutRight->setAlignment(Qt::AlignTop); + hLayout->addLayout(vLayoutLeft); + hLayout->addWidget(container, 1); + hLayout->addLayout(vLayoutRight); + + QFont font = QFont("Century Gothic", 14); + QLabel *label = new QLabel("Show:"); + font.setBold(true); + label->setFont(font); + vLayoutLeft->addWidget(label); + + font.setBold(false); + QCheckBox *checkboxOne = new QCheckBox("Oil Rig 1"); + checkboxOne->setFont(font); + vLayoutLeft->addWidget(checkboxOne); + + QCheckBox *checkboxTwo = new QCheckBox("Oil Rig 2"); + checkboxTwo->setFont(font); + vLayoutLeft->addWidget(checkboxTwo); + + QCheckBox *checkboxThree = new QCheckBox("Refinery"); + checkboxThree->setFont(font); + vLayoutLeft->addWidget(checkboxThree); + + QLabel *label2 = new QLabel("Visuals:"); + label2->setFont(font); + vLayoutRight->addWidget(label2); + + QCheckBox *checkboxOneRight = new QCheckBox("See-Through"); + checkboxOneRight->setFont(font); + vLayoutRight->addWidget(checkboxOneRight); + + QCheckBox *checkboxTwoRight = new QCheckBox("Highlight Oil"); + checkboxTwoRight->setFont(font); + vLayoutRight->addWidget(checkboxTwoRight); + + QCheckBox *checkboxThreeRight = new QCheckBox("Shadows"); + checkboxThreeRight->setFont(font); + checkboxThreeRight->setChecked(true); + vLayoutRight->addWidget(checkboxThreeRight); + + widget->setWindowTitle(QStringLiteral("Custom Items Example")); + + widget->show(); + + CustomItemGraph *modifier = new CustomItemGraph(graph); + + QObject::connect(checkboxOne, &QCheckBox::stateChanged, + modifier, &CustomItemGraph::toggleItemOne); + QObject::connect(checkboxTwo, &QCheckBox::stateChanged, + modifier, &CustomItemGraph::toggleItemTwo); + QObject::connect(checkboxThree, &QCheckBox::stateChanged, + modifier, &CustomItemGraph::toggleItemThree); + + QObject::connect(checkboxOneRight, &QCheckBox::stateChanged, + modifier, &CustomItemGraph::toggleSeeThrough); + QObject::connect(checkboxTwoRight, &QCheckBox::stateChanged, + modifier, &CustomItemGraph::toggleOilHighlight); + QObject::connect(checkboxThreeRight, &QCheckBox::stateChanged, + modifier, &CustomItemGraph::toggleShadows); + + return app.exec(); +} |