##// END OF EJS Templates
Added colormap chart examples...
jeandet -
r2901:d2a7a7849617
parent child
Show More
@@ -0,0 +1,8
1 !include( ../examples.pri ) {
2 error( "Couldn't find the examples.pri file!" )
3 }
4
5 TARGET = colormap
6 SOURCES += main.cpp
7
8 HEADERS +=
@@ -0,0 +1,80
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the ColorMapChart API
3 -- Copyright (C) 2016, Plasma Physics Laboratory - CNRS
4 --
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 2 of the License, or
8 -- (at your option) any later version.
9 --
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
14 --
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Hugo Winter
20 -- Mail : hugo.winter@lpp.polytechnique.fr
21 ----------------------------------------------------------------------------*/
22
23 #include <QtWidgets/QApplication>
24 #include <QtWidgets/QMainWindow>
25 #include <QtCharts/QChartView>
26 #include <QtCharts/QColorMapSeries>
27 #include <QtCharts/colormapdatapart.h>
28
29 QT_CHARTS_USE_NAMESPACE
30
31 int main(int argc, char *argv[])
32 {
33 QApplication a(argc, argv);
34
35 QVector<double> *xSeries = new QVector<double>();
36 xSeries->reserve(1028);
37 for(int i=0;i<1028;i++)
38 {
39 xSeries->append(i);
40 }
41 QVector<double> *ySeries = new QVector<double>();
42 ySeries->reserve(768);
43 for(int i=0;i<768;i++)
44 {
45 ySeries->append(i);
46 }
47 QVector<double> *zSeries = new QVector<double>();
48 zSeries->reserve(1028*768);
49 for(int i=0;i<1028*768;i++)
50 {
51 zSeries->append(i);
52 }
53
54 ColorMapDataPart * data = new ColorMapDataPart(xSeries,ySeries,zSeries);
55
56 QColorMapSeries *series = new QColorMapSeries();
57 series->append(data);
58
59 QChart *chart = new QChart();
60 chart->addSeries(series);
61
62 chart->createDefaultAxes();
63
64 chart->setTitle("Simple Colormap Example");
65
66 chart->axisX()->setGridLineVisible(false);
67 chart->axisY()->setGridLineVisible(false);
68
69 chart->legend()->setVisible(false);
70
71 QChartView *chartView = new QChartView(chart);
72 chartView->setRenderHint(QPainter::Antialiasing);
73
74 QMainWindow window;
75 window.setCentralWidget(chartView);
76 window.resize(400, 400);
77 window.show();
78
79 return a.exec();
80 }
@@ -32,7 +32,8 SUBDIRS += areachart \
32 nesteddonuts \
32 nesteddonuts \
33 chartinteractions \
33 chartinteractions \
34 callout \
34 callout \
35 chartthemes
35 chartthemes \
36 colormap
36
37
37 qtHaveModule(quick) {
38 qtHaveModule(quick) {
38 SUBDIRS += qmlboxplot \
39 SUBDIRS += qmlboxplot \
@@ -354,9 +354,9 void QChart::zoomIn()
354 d_ptr->zoomIn(2.0);
354 d_ptr->zoomIn(2.0);
355 }
355 }
356
356
357 void QChart::zoomIn2(double factor)
357 void QChart::zoomIn2(double factor, Qt::Orientation orientation)
358 {
358 {
359 d_ptr->zoomIn2(factor);
359 d_ptr->zoomIn2(factor, orientation);
360 }
360 }
361
361
362 /*!
362 /*!
@@ -378,9 +378,9 void QChart::zoomOut()
378 d_ptr->zoomOut(2.0);
378 d_ptr->zoomOut(2.0);
379 }
379 }
380
380
381 void QChart::zoomOut2(double factor)
381 void QChart::zoomOut2(double factor, Qt::Orientation orientation)
382 {
382 {
383 d_ptr->zoomOut2(factor);
383 d_ptr->zoomOut2(factor, orientation);
384 }
384 }
385
385
386 /*!
386 /*!
@@ -844,9 +844,12 void QChartPrivate::zoomIn(qreal factor)
844 zoomIn(rect);
844 zoomIn(rect);
845 }
845 }
846
846
847 void QChartPrivate::zoomIn2(qreal factor)
847 void QChartPrivate::zoomIn2(qreal factor, Qt::Orientation orientation)
848 {
848 {
849 QRectF rect = m_presenter->geometry();
849 QRectF rect = m_presenter->geometry();
850 if(orientation == Qt::Vertical)
851 rect.setHeight(rect.height() / factor);
852 else
850 rect.setWidth(rect.width() / factor);
853 rect.setWidth(rect.width() / factor);
851 rect.moveCenter(m_presenter->geometry().center());
854 rect.moveCenter(m_presenter->geometry().center());
852 zoomIn(rect);
855 zoomIn(rect);
@@ -897,12 +900,15 void QChartPrivate::zoomOut(qreal factor)
897 m_presenter->setState(ChartPresenter::ShowState,QPointF());
900 m_presenter->setState(ChartPresenter::ShowState,QPointF());
898 }
901 }
899
902
900 void QChartPrivate::zoomOut2(qreal factor)
903 void QChartPrivate::zoomOut2(qreal factor, Qt::Orientation orientation)
901 {
904 {
902 const QRectF geometry = m_presenter->geometry();
905 const QRectF geometry = m_presenter->geometry();
903
906
904 QRectF r;
907 QRectF r;
905 QSizeF size = geometry.size();
908 QSizeF size = geometry.size();
909 if(orientation == Qt::Vertical)
910 size.setHeight(size.height()/factor);
911 else
906 size.setWidth(size.width()/factor);
912 size.setWidth(size.width()/factor);
907 r.setSize(size);
913 r.setSize(size);
908 r.moveCenter(QPointF(geometry.size().width()/2 ,geometry.size().height()/2));
914 r.moveCenter(QPointF(geometry.size().width()/2 ,geometry.size().height()/2));
@@ -147,9 +147,9 public:
147 QEasingCurve animationEasingCurve() const;
147 QEasingCurve animationEasingCurve() const;
148
148
149 void zoomIn();
149 void zoomIn();
150 void zoomIn2(double factor);
150 void zoomIn2(double factor, Qt::Orientation orientation);
151 void zoomOut();
151 void zoomOut();
152 void zoomOut2(double factor);
152 void zoomOut2(double factor, Qt::Orientation orientation);
153
153
154 void zoomIn(const QRectF &rect);
154 void zoomIn(const QRectF &rect);
155 void zoom(qreal factor);
155 void zoom(qreal factor);
@@ -68,9 +68,9 public:
68
68
69 void init();
69 void init();
70 void zoomIn(qreal factor);
70 void zoomIn(qreal factor);
71 void zoomIn2(qreal factor);
71 void zoomIn2(qreal factor, Qt::Orientation orientation);
72 void zoomOut(qreal factor);
72 void zoomOut(qreal factor);
73 void zoomOut2(qreal factor);
73 void zoomOut2(qreal factor, Qt::Orientation orientation);
74 void zoomIn(const QRectF &rect);
74 void zoomIn(const QRectF &rect);
75 void zoomReset();
75 void zoomReset();
76 bool isZoomed();
76 bool isZoomed();
General Comments 0
You need to be logged in to leave comments. Login now