@@ -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 | 32 | nesteddonuts \ |
|
33 | 33 | chartinteractions \ |
|
34 | 34 | callout \ |
|
35 | chartthemes | |
|
35 | chartthemes \ | |
|
36 | colormap | |
|
36 | 37 | |
|
37 | 38 | qtHaveModule(quick) { |
|
38 | 39 | SUBDIRS += qmlboxplot \ |
@@ -354,9 +354,9 void QChart::zoomIn() | |||
|
354 | 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 | 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 | /*! |
@@ -422,7 +422,7 void QChart::zoomReset() | |||
|
422 | 422 | */ |
|
423 | 423 | bool QChart::isZoomed() |
|
424 | 424 | { |
|
425 | return d_ptr->isZoomed(); | |
|
425 | return d_ptr->isZoomed(); | |
|
426 | 426 | } |
|
427 | 427 | |
|
428 | 428 | /*! |
@@ -844,10 +844,13 void QChartPrivate::zoomIn(qreal factor) | |||
|
844 | 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 | 849 | QRectF rect = m_presenter->geometry(); |
|
850 | rect.setWidth(rect.width() / factor); | |
|
850 | if(orientation == Qt::Vertical) | |
|
851 | rect.setHeight(rect.height() / factor); | |
|
852 | else | |
|
853 | rect.setWidth(rect.width() / factor); | |
|
851 | 854 | rect.moveCenter(m_presenter->geometry().center()); |
|
852 | 855 | zoomIn(rect); |
|
853 | 856 | } |
@@ -897,13 +900,16 void QChartPrivate::zoomOut(qreal factor) | |||
|
897 | 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 | 905 | const QRectF geometry = m_presenter->geometry(); |
|
903 | 906 | |
|
904 | 907 | QRectF r; |
|
905 | 908 | QSizeF size = geometry.size(); |
|
906 | size.setWidth(size.width()/factor); | |
|
909 | if(orientation == Qt::Vertical) | |
|
910 | size.setHeight(size.height()/factor); | |
|
911 | else | |
|
912 | size.setWidth(size.width()/factor); | |
|
907 | 913 | r.setSize(size); |
|
908 | 914 | r.moveCenter(QPointF(geometry.size().width()/2 ,geometry.size().height()/2)); |
|
909 | 915 | if (!r.isValid()) |
@@ -147,9 +147,9 public: | |||
|
147 | 147 | QEasingCurve animationEasingCurve() const; |
|
148 | 148 | |
|
149 | 149 | void zoomIn(); |
|
150 | void zoomIn2(double factor); | |
|
150 | void zoomIn2(double factor, Qt::Orientation orientation); | |
|
151 | 151 | void zoomOut(); |
|
152 | void zoomOut2(double factor); | |
|
152 | void zoomOut2(double factor, Qt::Orientation orientation); | |
|
153 | 153 | |
|
154 | 154 | void zoomIn(const QRectF &rect); |
|
155 | 155 | void zoom(qreal factor); |
@@ -68,9 +68,9 public: | |||
|
68 | 68 | |
|
69 | 69 | void init(); |
|
70 | 70 | void zoomIn(qreal factor); |
|
71 | void zoomIn2(qreal factor); | |
|
71 | void zoomIn2(qreal factor, Qt::Orientation orientation); | |
|
72 | 72 | void zoomOut(qreal factor); |
|
73 | void zoomOut2(qreal factor); | |
|
73 | void zoomOut2(qreal factor, Qt::Orientation orientation); | |
|
74 | 74 | void zoomIn(const QRectF &rect); |
|
75 | 75 | void zoomReset(); |
|
76 | 76 | bool isZoomed(); |
General Comments 0
You need to be logged in to leave comments.
Login now