diff options
author | Tomi Korpipää <tomi.korpipaa@digia.com> | 2013-11-28 06:40:59 +0200 |
---|---|---|
committer | Tomi Korpipää <tomi.korpipaa@digia.com> | 2013-11-28 08:10:29 +0200 |
commit | 5fde532408da5b6b3ddef13aff5e07f32015e7d9 (patch) | |
tree | 8a243126c37a92be3ca14734adc5074a9642c129 /examples | |
parent | 964897e316c0fd524cba3a3cbb3c32fad53f965a (diff) |
Visual properties moved to theme
Task-number: QTRD-2632
Change-Id: I91eaa8fa26e232de24fe89ef0c8a2fc53f31fb8c
Reviewed-by: Tomi Korpipää <tomi.korpipaa@digia.com>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/audiolevels/audiolevels.cpp | 6 | ||||
-rw-r--r-- | examples/bars/graphmodifier.cpp | 25 | ||||
-rw-r--r-- | examples/bars/graphmodifier.h | 2 | ||||
-rw-r--r-- | examples/bars/main.cpp | 2 | ||||
-rw-r--r-- | examples/customproxy/rainfallgraph.cpp | 6 | ||||
-rw-r--r-- | examples/itemmodel/main.cpp | 6 | ||||
-rw-r--r-- | examples/qmlbars/qml/qmlbars/main.qml | 9 | ||||
-rw-r--r-- | examples/qmlscatter/qml/qmlscatter/main.qml | 14 | ||||
-rw-r--r-- | examples/qmlsurface/qml/qmlsurface/main.qml | 20 | ||||
-rw-r--r-- | examples/scatter/scatterdatamodifier.cpp | 19 | ||||
-rw-r--r-- | examples/surface/surfacegraph.cpp | 1 |
11 files changed, 53 insertions, 57 deletions
diff --git a/examples/audiolevels/audiolevels.cpp b/examples/audiolevels/audiolevels.cpp index 13a9c8c5..9f6658b9 100644 --- a/examples/audiolevels/audiolevels.cpp +++ b/examples/audiolevels/audiolevels.cpp @@ -40,16 +40,16 @@ AudioLevels::AudioLevels(Q3DBars *graph, QObject *parent) // Set up the graph m_graph->setBarThickness(0.5f); m_graph->setBarSpacing(QSizeF(0.0, 1.0)); - m_graph->setGridVisible(true); - m_graph->setBackgroundVisible(false); 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->scene()->activeCamera()->setCameraPosition(-25.0f, 10.0f, 190.0f); - m_graph->setTheme(new Q3DTheme(QDataVis::ThemeIsabelle)); m_graph->setBarType(QDataVis::MeshStyleBars); + m_graph->setTheme(new Q3DTheme(QDataVis::ThemeIsabelle)); + m_graph->theme()->setGridEnabled(true); + m_graph->theme()->setBackgroundEnabled(false); m_graph->addSeries(new QBar3DSeries); //! [0] diff --git a/examples/bars/graphmodifier.cpp b/examples/bars/graphmodifier.cpp index 8d9c9e88..a27782c5 100644 --- a/examples/bars/graphmodifier.cpp +++ b/examples/bars/graphmodifier.cpp @@ -52,10 +52,10 @@ GraphModifier::GraphModifier(Q3DBars *bargraph) m_smooth(false) { //! [2] - m_graph->setBackgroundVisible(false); m_graph->setShadowQuality(QDataVis::ShadowQualitySoftMedium); - m_graph->setFont(QFont("Times New Roman", m_fontSize)); - m_graph->setLabelStyle(QDataVis::LabelStyleFromTheme); + m_graph->theme()->setBackgroundEnabled(false); + m_graph->theme()->setFont(QFont("Times New Roman", m_fontSize)); + m_graph->theme()->setLabelBackgroundEnabled(true); //! [2] m_months << "January" << "February" << "March" << "April" << "May" << "June" << "July" << "August" << "September" << "October" << "November" << "December"; @@ -178,14 +178,9 @@ void GraphModifier::changeTheme(int theme) m_graph->setTheme(new Q3DTheme(QDataVis::Theme(theme))); } -void GraphModifier::changeLabelStyle() +void GraphModifier::changeLabelBackground() { - static int style = QDataVis::LabelStyleFromTheme; - - m_graph->setLabelStyle((QDataVis::LabelStyle)style); - - if (++style > QDataVis::LabelStyleTransparent) - style = QDataVis::LabelStyleOpaque; + m_graph->theme()->setLabelBackgroundEnabled(!m_graph->theme()->isBackgroundEnabled()); } void GraphModifier::changeSelectionMode(int selectionMode) @@ -201,15 +196,15 @@ void GraphModifier::changeFont(const QFont &font) { QFont newFont = font; newFont.setPointSize(m_fontSize); - m_graph->setFont(newFont); + m_graph->theme()->setFont(newFont); } void GraphModifier::changeFontSize(int fontsize) { m_fontSize = fontsize; - QFont font = m_graph->font(); + QFont font = m_graph->theme()->font(); font.setPointSize(m_fontSize); - m_graph->setFont(font); + m_graph->theme()->setFont(font); } void GraphModifier::shadowQualityUpdatedByVisual(QDataVis::ShadowQuality sq) @@ -242,12 +237,12 @@ void GraphModifier::rotateY(int rotation) void GraphModifier::setBackgroundEnabled(int enabled) { - m_graph->setBackgroundVisible(bool(enabled)); + m_graph->theme()->setBackgroundEnabled(bool(enabled)); } void GraphModifier::setGridEnabled(int enabled) { - m_graph->setGridVisible(bool(enabled)); + m_graph->theme()->setGridEnabled(bool(enabled)); } void GraphModifier::setSmoothBars(int smooth) diff --git a/examples/bars/graphmodifier.h b/examples/bars/graphmodifier.h index 2e84790c..b48451cd 100644 --- a/examples/bars/graphmodifier.h +++ b/examples/bars/graphmodifier.h @@ -38,7 +38,7 @@ public: void resetTemperatureData(); void changePresetCamera(); - void changeLabelStyle(); + void changeLabelBackground(); void changeFont(const QFont &font); void changeFontSize(int fontsize); void rotateX(int rotation); diff --git a/examples/bars/main.cpp b/examples/bars/main.cpp index 3bac58b2..7a74473b 100644 --- a/examples/bars/main.cpp +++ b/examples/bars/main.cpp @@ -201,7 +201,7 @@ int main(int argc, char **argv) //! [6] QObject::connect(labelButton, &QPushButton::clicked, modifier, - &GraphModifier::changeLabelStyle); + &GraphModifier::changeLabelBackground); QObject::connect(cameraButton, &QPushButton::clicked, modifier, &GraphModifier::changePresetCamera); diff --git a/examples/customproxy/rainfallgraph.cpp b/examples/customproxy/rainfallgraph.cpp index 71463103..1be61440 100644 --- a/examples/customproxy/rainfallgraph.cpp +++ b/examples/customproxy/rainfallgraph.cpp @@ -68,15 +68,15 @@ RainfallGraph::RainfallGraph(Q3DBars *rainfall) // Set shadows to medium m_graph->setShadowQuality(QDataVis::ShadowQualityMedium); - // Set font - m_graph->setFont(QFont("Century Gothic", 30)); - // Set selection mode to bar and column m_graph->setSelectionMode(QDataVis::SelectionItemAndColumn | QDataVis::SelectionSlice); // Set theme m_graph->setTheme(new Q3DTheme(QDataVis::ThemeArmyBlue)); + // Set font to theme + m_graph->theme()->setFont(QFont("Century Gothic", 30)); + // Set camera position and zoom m_graph->scene()->activeCamera()->setCameraPreset(QDataVis::CameraPresetIsometricRightHigh); m_graph->scene()->activeCamera()->setZoomLevel(75); diff --git a/examples/itemmodel/main.cpp b/examples/itemmodel/main.cpp index d6263c7c..1ee6ca25 100644 --- a/examples/itemmodel/main.cpp +++ b/examples/itemmodel/main.cpp @@ -105,9 +105,6 @@ GraphDataGenerator::GraphDataGenerator(Q3DBars *bargraph, QTableWidget *tableWid // Set selection mode to slice row m_graph->setSelectionMode(QDataVis::SelectionItemAndRow | QDataVis::SelectionSlice); - // Set font - m_graph->setFont(QFont("Impact", 20)); - //! [6] #endif @@ -116,6 +113,9 @@ GraphDataGenerator::GraphDataGenerator(Q3DBars *bargraph, QTableWidget *tableWid // Set theme m_graph->setTheme(new Q3DTheme(QDataVis::ThemeDigia)); + // Set font + m_graph->theme()->setFont(QFont("Impact", 20)); + // Set preset camera position m_graph->scene()->activeCamera()->setCameraPreset(QDataVis::CameraPresetFront); //! [7] diff --git a/examples/qmlbars/qml/qmlbars/main.qml b/examples/qmlbars/qml/qmlbars/main.qml index c7ec4f71..7f9c8039 100644 --- a/examples/qmlbars/qml/qmlbars/main.qml +++ b/examples/qmlbars/qml/qmlbars/main.qml @@ -78,9 +78,12 @@ Item { height: dataView.height shadowQuality: AbstractGraph3D.ShadowQualityMedium selectionMode: AbstractGraph3D.SelectionItem - font.pointSize: 35 - theme: Theme3D { type: AbstractGraph3D.ThemeRetro; labelBorderEnabled: true } - labelStyle: AbstractGraph3D.LabelStyleFromTheme + theme: Theme3D { + type: AbstractGraph3D.ThemeRetro + labelBorderEnabled: true + font.pointSize: 35 + labelBackgroundEnabled: true + } barThickness: 0.7 barSpacing: Qt.size(0.5, 0.5) barSpacingRelative: false diff --git a/examples/qmlscatter/qml/qmlscatter/main.qml b/examples/qmlscatter/qml/qmlscatter/main.qml index 92809297..7893ae56 100644 --- a/examples/qmlscatter/qml/qmlscatter/main.qml +++ b/examples/qmlscatter/qml/qmlscatter/main.qml @@ -51,9 +51,11 @@ Item { height: dataView.height //! [2] //! [3] - font.family: "Lucida Handwriting" - font.pointSize: 40 - theme: Theme3D { type: AbstractGraph3D.ThemeIsabelle } + theme: Theme3D { + type: AbstractGraph3D.ThemeIsabelle + font.family: "Lucida Handwriting" + font.pointSize: 40 + } shadowQuality: AbstractGraph3D.ShadowQualitySoftLow //! [3] //! [6] @@ -153,11 +155,11 @@ Item { text: "Hide Background" anchors.left: themeToggle.right onClicked: { - if (scatterGraph.backgroundVisible === true) { - scatterGraph.backgroundVisible = false; + if (scatterGraph.theme.backgroundEnabled === true) { + scatterGraph.theme.backgroundEnabled = false; text = "Show Background"; } else { - scatterGraph.backgroundVisible = true; + scatterGraph.theme.backgroundEnabled = true; text = "Hide Background"; } } diff --git a/examples/qmlsurface/qml/qmlsurface/main.qml b/examples/qmlsurface/qml/qmlsurface/main.qml index f83dc9a9..49cfb148 100644 --- a/examples/qmlsurface/qml/qmlsurface/main.qml +++ b/examples/qmlsurface/qml/qmlsurface/main.qml @@ -49,13 +49,15 @@ Item { id: surfaceplot width: surfaceView.width height: surfaceView.height - theme: Theme3D { type: AbstractGraph3D.ThemeStoneMoss } + theme: Theme3D { + type: AbstractGraph3D.ThemeStoneMoss + font.family: "STCaiyun" + font.pointSize: 35 + } shadowQuality: AbstractGraph3D.ShadowQualityMedium selectionMode: AbstractGraph3D.SelectionSlice | AbstractGraph3D.SelectionItemAndRow smoothSurfaceEnabled: true surfaceGridEnabled: false - font.family: "STCaiyun" - font.pointSize: 35 scene.activeCamera.cameraPreset: AbstractGraph3D.CameraPresetIsometricLeft axisY.min: 0.0 axisY.max: 500.0 @@ -167,11 +169,11 @@ Item { width: smoothSurfaceToggle.width text: "Hide Background" onClicked: { - if (surfaceplot.backgroundVisible === true) { - surfaceplot.backgroundVisible = false; + if (surfaceplot.theme.backgroundEnabled === true) { + surfaceplot.theme.backgroundEnabled = false; text = "Show Background" } else { - surfaceplot.backgroundVisible = true; + surfaceplot.theme.backgroundEnabled = true; text = "Hide Background" } } @@ -183,11 +185,11 @@ Item { width: backgroundToggle.width text: "Hide Grid" onClicked: { - if (surfaceplot.gridVisible === true) { - surfaceplot.gridVisible = false; + if (surfaceplot.theme.gridEnabled === true) { + surfaceplot.theme.gridEnabled = false; text = "Show Grid" } else { - surfaceplot.gridVisible = true; + surfaceplot.theme.gridEnabled = true; text = "Hide Grid" } } diff --git a/examples/scatter/scatterdatamodifier.cpp b/examples/scatter/scatterdatamodifier.cpp index ce4eaa03..5a46b0ec 100644 --- a/examples/scatter/scatterdatamodifier.cpp +++ b/examples/scatter/scatterdatamodifier.cpp @@ -37,11 +37,11 @@ ScatterDataModifier::ScatterDataModifier(Q3DScatter *scatter) m_smooth(true) { //! [0] - QFont font = m_graph->font(); + m_graph->setTheme(new Q3DTheme(QDataVis::ThemeEbony)); + QFont font = m_graph->theme()->font(); font.setPointSize(m_fontSize); - m_graph->setFont(font); + m_graph->theme()->setFont(font); m_graph->setObjectType(QDataVis::MeshStyleSpheres, true); - m_graph->setTheme(new Q3DTheme(QDataVis::ThemeEbony)); m_graph->setShadowQuality(QDataVis::ShadowQualitySoftLow); m_graph->scene()->activeCamera()->setCameraPreset(QDataVis::CameraPresetFront); //! [0] @@ -144,19 +144,14 @@ void ScatterDataModifier::changePresetCamera() void ScatterDataModifier::changeLabelStyle() { - static int style = QDataVis::LabelStyleFromTheme; - - m_graph->setLabelStyle((QDataVis::LabelStyle)style); - - if (++style > QDataVis::LabelStyleTransparent) - style = QDataVis::LabelStyleOpaque; + m_graph->theme()->setLabelBackgroundEnabled(!m_graph->theme()->isLabelBackgroundEnabled()); } void ScatterDataModifier::changeFont(const QFont &font) { QFont newFont = font; newFont.setPointSizeF(m_fontSize); - m_graph->setFont(newFont); + m_graph->theme()->setFont(newFont); } void ScatterDataModifier::shadowQualityUpdatedByVisual(QDataVis::ShadowQuality sq) @@ -173,12 +168,12 @@ void ScatterDataModifier::changeShadowQuality(int quality) void ScatterDataModifier::setBackgroundEnabled(int enabled) { - m_graph->setBackgroundVisible((bool)enabled); + m_graph->theme()->setBackgroundEnabled((bool)enabled); } void ScatterDataModifier::setGridEnabled(int enabled) { - m_graph->setGridVisible((bool)enabled); + m_graph->theme()->setGridEnabled((bool)enabled); } //! [8] diff --git a/examples/surface/surfacegraph.cpp b/examples/surface/surfacegraph.cpp index d7def123..d54bf9ff 100644 --- a/examples/surface/surfacegraph.cpp +++ b/examples/surface/surfacegraph.cpp @@ -38,7 +38,6 @@ SurfaceGraph::SurfaceGraph(Q3DSurface *surface) m_graph->setAxisX(new Q3DValueAxis); m_graph->setAxisY(new Q3DValueAxis); m_graph->setAxisZ(new Q3DValueAxis); - m_graph->setLabelStyle(QDataVis::LabelStyleFromTheme); //! [0] m_sqrtSinProxy = new QSurfaceDataProxy(); |