1 | NO CONTENT: new file 100644, binary diff hidden |
|
NO CONTENT: new file 100644, binary diff hidden |
1 | NO CONTENT: new file 100644, binary diff hidden |
|
NO CONTENT: new file 100644, binary diff hidden |
1 | NO CONTENT: new file 100644, binary diff hidden |
|
NO CONTENT: new file 100644, binary diff hidden |
@@ -28,24 +28,16 int main(int argc, char *argv[]) | |||||
28 | // Add another scatter series |
|
28 | // Add another scatter series | |
29 | // - more data with random component |
|
29 | // - more data with random component | |
30 | QScatterSeries *scatter2 = new QScatterSeries(); |
|
30 | QScatterSeries *scatter2 = new QScatterSeries(); | |
31 |
for (qreal i(0.0); i < 20; i += 0. |
|
31 | for (qreal i(0.0); i < 20; i += 0.15) { | |
32 | (*scatter2) << QPointF(i + (qreal)(rand() % 100) / 100.0, |
|
32 | (*scatter2) << QPointF(i + (qreal)(rand() % 100) / 100.0, | |
33 | i + (qreal)(rand() % 100) / 100.0); |
|
33 | i + (qreal)(rand() % 100) / 100.0); | |
34 | } |
|
34 | } | |
35 | chartView->addSeries(scatter2); |
|
35 | QBrush brush(QColor(255, 0, 0, 100), Qt::SolidPattern); | |
36 | // Custom pen and brush (not those defined by the chart theme) |
|
|||
37 | // - uses opaque color |
|
|||
38 | QColor color("#2685BF"); |
|
|||
39 | color.setAlpha(80); |
|
|||
40 | QBrush brush(Qt::SolidPattern); |
|
|||
41 | brush.setColor(color); |
|
|||
42 | scatter2->setMarkerBrush(brush); |
|
36 | scatter2->setMarkerBrush(brush); | |
43 | QPen pen; |
|
37 | QPen pen(QColor(0, 255, 0, 80), 3); | |
44 | pen.setColor(color); |
|
|||
45 | pen.setWidth(2); |
|
|||
46 | scatter2->setMarkerPen(pen); |
|
38 | scatter2->setMarkerPen(pen); | |
47 | // use a rectangle as the marker shape |
|
|||
48 | scatter2->setMarkerShape(QScatterSeries::MarkerShapeRectangle); |
|
39 | scatter2->setMarkerShape(QScatterSeries::MarkerShapeRectangle); | |
|
40 | chartView->addSeries(scatter2); | |||
49 |
|
41 | |||
50 | // Use the chart widget as the central widget |
|
42 | // Use the chart widget as the central widget | |
51 | QMainWindow w; |
|
43 | QMainWindow w; |
@@ -16,6 +16,20 QScatterSeriesPrivate::QScatterSeriesPrivate() : | |||||
16 | } |
|
16 | } | |
17 |
|
17 | |||
18 | /*! |
|
18 | /*! | |
|
19 | \enum QScatterSeries::MarkerShape | |||
|
20 | ||||
|
21 | This enum describes the shape used when rendering marker items. | |||
|
22 | ||||
|
23 | \value MarkerShapeDefault | |||
|
24 | \value MarkerShapePoint | |||
|
25 | \value MarkerShapeX | |||
|
26 | \value MarkerShapeRectangle | |||
|
27 | \value MarkerShapeTiltedRectangle | |||
|
28 | \value MarkerShapeTriangle | |||
|
29 | \value MarkerShapeCircle | |||
|
30 | */ | |||
|
31 | ||||
|
32 | /*! | |||
19 | \class QScatterSeries |
|
33 | \class QScatterSeries | |
20 | \brief QtCommercial Chart series API for showing scatter series. |
|
34 | \brief QtCommercial Chart series API for showing scatter series. | |
21 |
|
35 | |||
@@ -39,6 +53,10 QScatterSeriesPrivate::QScatterSeriesPrivate() : | |||||
39 |
|
53 | |||
40 | \image scatter_example1.jpg |
|
54 | \image scatter_example1.jpg | |
41 | */ |
|
55 | */ | |
|
56 | ||||
|
57 | /*! | |||
|
58 | Constructs a series object which is a child of \a parent. | |||
|
59 | */ | |||
42 | QScatterSeries::QScatterSeries(QObject *parent) : |
|
60 | QScatterSeries::QScatterSeries(QObject *parent) : | |
43 | QChartSeries(parent), |
|
61 | QChartSeries(parent), | |
44 | d(new QScatterSeriesPrivate()) |
|
62 | d(new QScatterSeriesPrivate()) | |
@@ -46,7 +64,7 QScatterSeries::QScatterSeries(QObject *parent) : | |||||
46 | } |
|
64 | } | |
47 |
|
65 | |||
48 | /*! |
|
66 | /*! | |
49 | Destructor |
|
67 | Destroys the object. Note that adding series to QChart transfers the ownership to the chart. | |
50 | */ |
|
68 | */ | |
51 | QScatterSeries::~QScatterSeries() |
|
69 | QScatterSeries::~QScatterSeries() | |
52 | { |
|
70 | { | |
@@ -55,6 +73,10 QScatterSeries::~QScatterSeries() | |||||
55 |
|
73 | |||
56 | /*! |
|
74 | /*! | |
57 | Add single data point to the series. |
|
75 | Add single data point to the series. | |
|
76 | For example: | |||
|
77 | \code | |||
|
78 | mySeries.addData(QPointF(0.5, 5.0)); | |||
|
79 | \endcode | |||
58 | */ |
|
80 | */ | |
59 | void QScatterSeries::addData(QPointF value) |
|
81 | void QScatterSeries::addData(QPointF value) | |
60 | { |
|
82 | { | |
@@ -90,7 +112,7 void QScatterSeries::setData(QList<QPointF> data) | |||||
90 | } |
|
112 | } | |
91 |
|
113 | |||
92 | /*! |
|
114 | /*! | |
93 |
|
|
115 | Returns the current list of data points of the series. | |
94 | */ |
|
116 | */ | |
95 | QList<QPointF> QScatterSeries::data() |
|
117 | QList<QPointF> QScatterSeries::data() | |
96 | { |
|
118 | { | |
@@ -98,8 +120,20 QList<QPointF> QScatterSeries::data() | |||||
98 | } |
|
120 | } | |
99 |
|
121 | |||
100 | /*! |
|
122 | /*! | |
101 | Customizes the graphical presentation of the marker items. Replaces the default pen used for |
|
123 | Overrides the default pen used for drawing a marker item with a user defined pen. The default | |
102 | drawing a marker item with a user defined pen. |
|
124 | pen is defined by chart theme setting. | |
|
125 | ||||
|
126 | For example: | |||
|
127 | \code | |||
|
128 | QPen pen(QColor(0, 255, 0, 80), 3); | |||
|
129 | myScatter->setMarkerPen(pen); | |||
|
130 | \endcode | |||
|
131 | ||||
|
132 | Would present your scatter markers with an opaque, uglyish green outlines: | |||
|
133 | \image scatter_example_pen.jpg | |||
|
134 | ||||
|
135 | \sa setMarkerBrush() | |||
|
136 | \sa QChart::setTheme() | |||
103 | */ |
|
137 | */ | |
104 | void QScatterSeries::setMarkerPen(QPen pen) |
|
138 | void QScatterSeries::setMarkerPen(QPen pen) | |
105 | { |
|
139 | { | |
@@ -107,28 +141,62 void QScatterSeries::setMarkerPen(QPen pen) | |||||
107 | } |
|
141 | } | |
108 |
|
142 | |||
109 | /*! |
|
143 | /*! | |
110 |
|
144 | Returns the pen used for drawing markers. | ||
111 | */ |
|
145 | */ | |
112 | QPen QScatterSeries::markerPen() |
|
146 | QPen QScatterSeries::markerPen() | |
113 | { |
|
147 | { | |
114 | return d->m_markerPen; |
|
148 | return d->m_markerPen; | |
115 | } |
|
149 | } | |
116 |
|
150 | |||
|
151 | /*! | |||
|
152 | Overrides the default brush of the marker items with a user defined brush. The default | |||
|
153 | brush is defined by chart theme setting. | |||
|
154 | ||||
|
155 | For example: | |||
|
156 | \code | |||
|
157 | QBrush brush(QColor(255, 0, 0, 100), Qt::SolidPattern); | |||
|
158 | myRandomScatter->setMarkerBrush(brush); | |||
|
159 | \endcode | |||
|
160 | ||||
|
161 | Would fill your scatter markers with an opaque red color: | |||
|
162 | \image scatter_example_brush.jpg | |||
|
163 | ||||
|
164 | \sa setMarkerPen() | |||
|
165 | \sa QChart::setTheme() | |||
|
166 | */ | |||
117 | void QScatterSeries::setMarkerBrush(QBrush brush) |
|
167 | void QScatterSeries::setMarkerBrush(QBrush brush) | |
118 | { |
|
168 | { | |
119 | d->m_markerBrush = brush; |
|
169 | d->m_markerBrush = brush; | |
120 | } |
|
170 | } | |
121 |
|
171 | |||
|
172 | /*! | |||
|
173 | Returns the brush used for drawing markers. | |||
|
174 | */ | |||
122 | QBrush QScatterSeries::markerBrush() |
|
175 | QBrush QScatterSeries::markerBrush() | |
123 | { |
|
176 | { | |
124 | return d->m_markerBrush; |
|
177 | return d->m_markerBrush; | |
125 | } |
|
178 | } | |
126 |
|
179 | |||
|
180 | /*! | |||
|
181 | Overrides the default shape of the marker items with a user defined shape. The default | |||
|
182 | shape is defined by chart theme setting. | |||
|
183 | ||||
|
184 | For example: | |||
|
185 | \code | |||
|
186 | myScatter->setMarkerShape(QScatterSeries::MarkerShapeRectangle); | |||
|
187 | \endcode | |||
|
188 | ||||
|
189 | Would make your scatter marker items rectangle: | |||
|
190 | \image scatter_example_shape.jpg | |||
|
191 | */ | |||
127 | void QScatterSeries::setMarkerShape(MarkerShape shape) |
|
192 | void QScatterSeries::setMarkerShape(MarkerShape shape) | |
128 | { |
|
193 | { | |
129 | d->m_markerShape = shape; |
|
194 | d->m_markerShape = shape; | |
130 | } |
|
195 | } | |
131 |
|
196 | |||
|
197 | /*! | |||
|
198 | Returns the shape used for drawing markers. | |||
|
199 | */ | |||
132 | QScatterSeries::MarkerShape QScatterSeries::markerShape() |
|
200 | QScatterSeries::MarkerShape QScatterSeries::markerShape() | |
133 | { |
|
201 | { | |
134 | return (QScatterSeries::MarkerShape) d->m_markerShape; |
|
202 | return (QScatterSeries::MarkerShape) d->m_markerShape; |
@@ -45,13 +45,15 void ScatterPresenter::paint(QPainter *painter, const QStyleOptionGraphicsItem * | |||||
45 | { |
|
45 | { | |
46 | // TODO: Optimization: avoid setting on every paint method call? |
|
46 | // TODO: Optimization: avoid setting on every paint method call? | |
47 | // The custom settings in series override those defined by the theme |
|
47 | // The custom settings in series override those defined by the theme | |
48 |
if (m_series->markerPen().color().isValid()) |
|
48 | if (m_series->markerPen().color().isValid()) | |
49 | painter->setPen(m_series->markerPen()); |
|
49 | painter->setPen(m_series->markerPen()); | |
50 | painter->setBrush(m_series->markerBrush()); |
|
50 | else | |
51 | } else { |
|
|||
52 | painter->setPen(m_markerPen); |
|
51 | painter->setPen(m_markerPen); | |
|
52 | ||||
|
53 | if (m_series->markerBrush().color().isValid()) | |||
|
54 | painter->setBrush(m_series->markerBrush()); | |||
|
55 | else | |||
53 | painter->setBrush(m_markerBrush); |
|
56 | painter->setBrush(m_markerBrush); | |
54 | } |
|
|||
55 |
|
57 | |||
56 | int shape = m_series->markerShape(); |
|
58 | int shape = m_series->markerShape(); | |
57 |
|
59 |
General Comments 0
You need to be logged in to leave comments.
Login now