1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
|
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtGraphs/QAbstractAxis>
#include <private/qabstractaxis_p.h>
QT_BEGIN_NAMESPACE
/*!
\class QAbstractAxis
\inmodule QtGraphs
\ingroup graphs_2D
\brief The QAbstractAxis class is a base class used for specialized axis classes.
Each series can be bound to only one horizontal and vertical axis.
The properties and visibility of various axis elements, such as axis line, title, labels,
and grid lines, can be individually controlled.
*/
/*!
\qmltype AbstractAxis
\nativetype QAbstractAxis
\inqmlmodule QtGraphs
\ingroup graphs_qml_2D
\brief A base type used for specialized axis types.
Each series can be bound to only one horizontal and vertical axis.
The properties and visibility of various axis elements, such as axis line, title, labels,
and grid lines, can be individually controlled.
*/
/*!
\enum QAbstractAxis::AxisType
This enum type specifies the type of the axis object.
\value Value
\value BarCategory
\value DateTime
*/
/*!
\fn void QAbstractAxis::type() const
Returns the type of the axis.
*/
/*!
\property QAbstractAxis::visible
\brief The visibility of the axis.
By default, the value is \c true.
*/
/*!
\qmlproperty bool AbstractAxis::visible
The visibility of the axis. By default, the value is \c true.
*/
/*!
\property QAbstractAxis::lineVisible
\brief The visibility of the axis line.
By default, the value is \c true.
*/
/*!
\qmlproperty bool AbstractAxis::lineVisible
The visibility of the axis line. By default, the value is \c true.
*/
/*!
\property QAbstractAxis::labelsVisible
\brief Whether axis labels are visible.
By default, the value is \c true.
*/
/*!
\qmlproperty bool AbstractAxis::labelsVisible
The visibility of axis labels. By default, the value is \c true.
*/
/*!
\property QAbstractAxis::labelsAngle
\brief The angle of the axis labels in degrees.
*/
/*!
\qmlproperty real AbstractAxis::labelsAngle
The angle of the axis labels in degrees.
*/
/*!
\property QAbstractAxis::labelDelegate
\brief A custom QML Component used as a label for the axis.
This component should either be a \a Text component or contain "property string text",
so that this property will be assigned the value of the label.
*/
/*!
\qmlproperty Component AbstractAxis::labelDelegate
A custom QML Component used as a label for the axis.
This component should either be a \a Text component or contain "property string text",
so that this property will be assigned the value of the label.
*/
/*!
\property QAbstractAxis::gridVisible
\brief The visibility of the grid lines.
By default, the value is \c true.
*/
/*!
\qmlproperty bool AbstractAxis::gridVisible
The visibility of the grid lines. By default, the value is \c true.
*/
/*!
\property QAbstractAxis::subGridVisible
\brief The visibility of the subgrid lines.
Applies only to axes that support subgrid lines.
By default, the value is \c true.
*/
/*!
\qmlproperty bool AbstractAxis::subGridVisible
The visibility of the subgrid lines. Applies only to axes that support
subgrid lines. By default, the value is \c true.
*/
/*!
\property QAbstractAxis::titleText
\brief The title of the axis.
Empty by default. Axis titles support HTML formatting.
*/
/*!
\qmlproperty string AbstractAxis::titleText
The title of the axis. Empty by default. Axis titles support HTML formatting.
*/
/*!
\property QAbstractAxis::titleColor
\brief The color used to draw the title text.
*/
/*!
\qmlproperty color AbstractAxis::titleColor
The color used to draw the title text.
*/
/*!
\property QAbstractAxis::titleVisible
\brief The visibility of the axis title.
By default, the value is \c true.
*/
/*!
\qmlproperty bool AbstractAxis::titleVisible
The visibility of the axis title. By default, the value is \c true.
*/
/*!
\property QAbstractAxis::titleFont
\brief The font of the title of the axis.
*/
/*!
\qmlproperty font AbstractAxis::titleFont
The font of the title of the axis.
*/
/*!
\property QAbstractAxis::alignment
\since 6.9
\brief The alignment of the axis.
Can be Qt::AlignLeft, Qt::AlignRight, Qt::AlignBottom, or Qt::AlignTop.
*/
/*!
\qmlproperty alignment AbstractAxis::alignment
\since 6.9
The alignment of the axis. Can be \l{Qt::AlignLeft}{Qt.AlignLeft},
\l{Qt::AlignRight}{Qt.AlignRight}, \l{Qt::AlignBottom}{Qt.AlignBottom}, or
\l{Qt::AlignTop}{Qt.AlignTop}.
*/
/*!
\property QAbstractAxis::textElide
\since 6.10
\brief The textElide of the axis labels.
Can be Qt::ElideLeft, Qt::ElideRight, Qt::ElideMiddle, or Qt::ElideNone.
By default, the value is \c Qt::ElideNone.
*/
/*!
\qmlproperty enumeration AbstractAxis::textElide
\since 6.10
The textElide of the axis labels. Can be \l{Qt::ElideLeft}{Qt.ElideLeft},
\l{Qt::ElideRight}{Qt.ElideRight}, \l{Qt::ElideMiddle}{Qt.ElideMiddle}, or
\l{Qt::ElideNone}{Qt.ElideNone}. By default, the value is \c Qt.ElideNone.
*/
/*!
\fn void QAbstractAxis::update()
This signal is emitted when the axis needs to be updated.
*/
/*!
\qmlsignal AbstractAxis::visibleChanged(bool visible)
This signal is emitted when the visibility of the axis changes to \a visible.
*/
/*!
\qmlsignal AbstractAxis::lineVisibleChanged(bool visible)
This signal is emitted when the visibility of the axis line changes to \a visible.
*/
/*!
\qmlsignal AbstractAxis::labelsVisibleChanged(bool visible)
This signal is emitted when the visibility of the labels of the axis changes to \a visible.
*/
/*!
\qmlsignal AbstractAxis::labelsAngleChanged(string angle)
This signal is emitted when the angle of the axis labels changes to \a angle.
*/
/*!
\qmlsignal AbstractAxis::gridVisibleChanged(bool visible)
This signal is emitted when the visibility of the grid lines of the axis changes to \a visible.
*/
/*!
\qmlsignal AbstractAxis::minorGridVisibleChanged(bool visible)
This signal is emitted when the visibility of the minor grid lines of the axis
changes to \a visible.
*/
/*!
\qmlsignal AbstractAxis::titleTextChanged(string text)
This signal is emitted when the text of the axis title changes to \a text.
*/
/*!
\qmlsignal AbstractAxis::titleColorChanged(color color)
This signal is emitted when the color used to draw the axis title changes to \a color.
*/
/*!
\qmlsignal AbstractAxis::titleVisibleChanged(bool visible)
This signal is emitted when the visibility of the title text of the axis changes to \a visible.
*/
/*!
\qmlsignal AbstractAxis::titleFontChanged(Font font)
This signal is emitted when the font of the axis title changes to \a font.
*/
/*!
\qmlsignal AbstractAxis::rangeChanged(string min, string max)
This signal is emitted when the axis range changes. \a min and \a max are
the min and max of the new range.
*/
/*!
\qmlsignal AbstractAxis::textElideChanged(enumeration elide)
This signal is emitted when the \l textElide changes. \a elide is the
new value of the \l Qt::TextElideMode type.
*/
/*!
\internal
Constructs a new axis object that is a child of \a parent. The ownership is taken by
graph when the axis is added.
*/
Q_LOGGING_CATEGORY(lcAxis2D, "qt.graphs2d.axis.properties")
QAbstractAxis::QAbstractAxis(QAbstractAxisPrivate &dd, QObject *parent)
: QObject(dd, parent)
{}
/*!
Destructs the axis object. When the axis is added to a graph, the graph object takes ownership.
*/
QAbstractAxis::~QAbstractAxis()
{
}
/*!
Determines whether the axis line and tick marks are \a visible.
*/
void QAbstractAxis::setLineVisible(bool visible)
{
Q_D(QAbstractAxis);
if (d->m_lineVisible != visible) {
d->m_lineVisible = visible;
emit update();
emit lineVisibleChanged(visible);
} else {
qCDebug(lcAxis2D) << "QAbstractAxis::setLineVisible. Visibility is already set to:"
<< visible;
}
}
bool QAbstractAxis::isLineVisible() const
{
Q_D(const QAbstractAxis);
return d->m_lineVisible;
}
void QAbstractAxis::setGridVisible(bool visible)
{
Q_D(QAbstractAxis);
if (d->m_gridVisible != visible) {
d->m_gridVisible = visible;
emit update();
emit gridVisibleChanged(visible);
} else {
qCDebug(lcAxis2D) << "QAbstractAxis::setGridVisible. Visibility is already set to:"
<< visible;
}
}
bool QAbstractAxis::isGridVisible() const
{
Q_D(const QAbstractAxis);
return d->m_gridVisible;
}
void QAbstractAxis::setSubGridVisible(bool visible)
{
Q_D(QAbstractAxis);
if (d->m_subGridVisible != visible) {
d->m_subGridVisible = visible;
emit update();
emit subGridVisibleChanged(visible);
} else {
qCDebug(lcAxis2D) << "QAbstractAxis::setSubGridVisible. Visibility is already set to:"
<< visible;
}
}
bool QAbstractAxis::isSubGridVisible() const
{
Q_D(const QAbstractAxis);
return d->m_subGridVisible;
}
void QAbstractAxis::setLabelsVisible(bool visible)
{
Q_D(QAbstractAxis);
if (d->m_labelsVisible != visible) {
d->m_labelsVisible = visible;
emit update();
emit labelsVisibleChanged(visible);
} else {
qCDebug(lcAxis2D) << "QAbstractAxis::setLabelsVisible. Visibility is already set to:"
<< visible;
}
}
bool QAbstractAxis::labelsVisible() const
{
Q_D(const QAbstractAxis);
return d->m_labelsVisible;
}
void QAbstractAxis::setLabelsAngle(qreal angle)
{
Q_D(QAbstractAxis);
if (d->m_labelsAngle != angle) {
d->m_labelsAngle = angle;
emit update();
emit labelsAngleChanged(angle);
} else {
qCDebug(lcAxis2D, "QAbstractAxis::setLabelsAngle. Angle is already set to: %f",
angle);
}
}
qreal QAbstractAxis::labelsAngle() const
{
Q_D(const QAbstractAxis);
return d->m_labelsAngle;
}
QQmlComponent *QAbstractAxis::labelDelegate() const
{
Q_D(const QAbstractAxis);
return d->m_labelDelegate;
}
void QAbstractAxis::setLabelDelegate(QQmlComponent *newLabelDelegate)
{
Q_D(QAbstractAxis);
if (d->m_labelDelegate == newLabelDelegate) {
qCDebug(lcAxis2D) << "QAbstractAxis::setLabelDelegate. LabelDelegate is already set to:"
<< newLabelDelegate;
return;
}
d->m_labelDelegate = newLabelDelegate;
emit labelDelegateChanged();
emit update();
}
void QAbstractAxis::setTitleVisible(bool visible)
{
Q_D(QAbstractAxis);
if (d->m_titleVisible != visible) {
d->m_titleVisible = visible;
emit update();
emit titleVisibleChanged(visible);
} else {
qCDebug(lcAxis2D) << "QAbstractAxis::setTitleVisible. visibility is already set to:"
<< visible;
}
}
bool QAbstractAxis::isTitleVisible() const
{
Q_D(const QAbstractAxis);
return d->m_titleVisible;
}
/*!
Sets the color used to draw titles to \a color.
*/
void QAbstractAxis::setTitleColor(QColor color)
{
Q_D(QAbstractAxis);
if (!color.isValid())
qCWarning(lcAxis2D) << "QAbstractAxis::setTitleColor. Tried to use invalid color.";
if (d->m_titleColor != color) {
d->m_titleColor = color;
emit update();
emit titleColorChanged(color);
} else {
qCDebug(lcAxis2D) << "QAbstractAxis::setTitleColor. Color is already set to:"
<< color;
}
}
/*!
Returns the color used to draw titles.
*/
QColor QAbstractAxis::titleColor() const
{
Q_D(const QAbstractAxis);
return d->m_titleColor;
}
/*!
Sets the font used to draw titles to \a font.
*/
void QAbstractAxis::setTitleFont(const QFont &font)
{
Q_D(QAbstractAxis);
if (d->m_titleFont != font) {
d->m_titleFont = font;
emit update();
emit titleFontChanged(font);
} else {
qCDebug(lcAxis2D) << "QAbstractAxis::setTitleFont. Font is already set to:"
<< font;
}
}
/*!
Returns the font used to draw titles.
*/
QFont QAbstractAxis::titleFont() const
{
Q_D(const QAbstractAxis);
return d->m_titleFont;
}
void QAbstractAxis::setTitleText(const QString &title)
{
Q_D(QAbstractAxis);
if (d->m_title != title) {
d->m_title = title;
emit update();
emit titleTextChanged(title);
} else {
qCDebug(lcAxis2D, "QAbstractAxis::setTitleText. Title is already set to: %s",
qPrintable(title));
}
}
QString QAbstractAxis::titleText() const
{
Q_D(const QAbstractAxis);
return d->m_title;
}
bool QAbstractAxis::isVisible() const
{
Q_D(const QAbstractAxis);
return d->m_visible;
}
/*!
Sets the visibility of the axis, labels, and grid lines to \a visible.
*/
void QAbstractAxis::setVisible(bool visible)
{
Q_D(QAbstractAxis);
if (d->m_visible != visible) {
d->m_visible = visible;
emit update();
emit visibleChanged(visible);
} else {
qCDebug(lcAxis2D) << "QAbstractAxis::setVisible. axis, labels and grid visibility is already set to:"
<< visible;
}
}
/*!
Makes the axis, labels, and grid lines visible.
*/
void QAbstractAxis::show()
{
setVisible(true);
}
/*!
Makes the axis, labels, and grid lines invisible.
*/
void QAbstractAxis::hide()
{
setVisible(false);
}
/*!
Sets the minimum value shown on the axis.
Depending on the actual axis type, the \a min parameter is converted to the appropriate type
of value. If the conversion is impossible, the function call does nothing.
*/
void QAbstractAxis::setMin(const QVariant &min)
{
Q_D(QAbstractAxis);
d->setMin(min);
}
/*!
Sets the maximum value shown on the axis.
Depending on the actual axis type, the \a max parameter is converted to the appropriate type
of value. If the conversion is impossible, the function call does nothing.
*/
void QAbstractAxis::setMax(const QVariant &max)
{
Q_D(QAbstractAxis);
d->setMax(max);
}
/*!
Sets the range shown on the axis.
Depending on the actual axis type, the \a min and \a max parameters are converted to
appropriate types of values. If the conversion is impossible, the function call does nothing.
*/
void QAbstractAxis::setRange(const QVariant &min, const QVariant &max)
{
Q_D(QAbstractAxis);
d->setRange(min, max);
}
Qt::Alignment QAbstractAxis::alignment() const
{
const Q_D(QAbstractAxis);
return d->m_alignment;
}
void QAbstractAxis::setAlignment(Qt::Alignment alignment)
{
Q_D(QAbstractAxis);
if (d->m_alignment == alignment) {
qCDebug(lcAxis2D) << "QAbstractAxis::setAlignment. Alignment is already set to:"
<< alignment;
return;
}
switch (alignment) {
case Qt::AlignTop:
case Qt::AlignBottom:
case Qt::AlignLeft:
case Qt::AlignRight:
d->m_alignment = alignment;
if (d->m_graph)
d->m_graph->updateComponentSizes();
emit update();
emit alignmentChanged(alignment);
break;
default:
qCWarning(lcAxis2D, "invalid alignment.");
break;
}
}
Qt::TextElideMode QAbstractAxis::textElide() const
{
Q_D(const QAbstractAxis);
return d->m_textElide;
}
void QAbstractAxis::setTextElide(Qt::TextElideMode elide)
{
Q_D(QAbstractAxis);
if (d->m_textElide == elide) {
qCDebug(lcAxis2D) << "QAbstractAxis::setTextElide. Text elide is already set to:"
<< elide;
return;
}
d->m_textElide = elide;
Q_EMIT textElideChanged(d->m_textElide);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
QAbstractAxisPrivate::QAbstractAxisPrivate() {}
QAbstractAxisPrivate::~QAbstractAxisPrivate()
{
Q_Q(QAbstractAxis);
if (m_graph)
m_graph->removeAxis(q);
}
void QAbstractAxisPrivate::handleRangeChanged(qreal min, qreal max)
{
setRange(min,max);
}
QT_END_NAMESPACE
|