| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #include "qabstract3dseries_p.h" |
| 5 | #include "qabstractdataproxy_p.h" |
| 6 | #include "abstract3dcontroller_p.h" |
| 7 | |
| 8 | QT_BEGIN_NAMESPACE |
| 9 | |
| 10 | /*! |
| 11 | * \class QAbstract3DSeries |
| 12 | * \inmodule QtDataVisualization |
| 13 | * \brief The QAbstract3DSeries class is a base class for all data series. |
| 14 | * \since QtDataVisualization 1.0 |
| 15 | * |
| 16 | * There are inherited classes for each supported series type: QBar3DSeries, |
| 17 | * QScatter3DSeries, and QSurface3DSeries. |
| 18 | * |
| 19 | * For more information, see \l{Qt Data Visualization Data Handling}. |
| 20 | */ |
| 21 | |
| 22 | /*! |
| 23 | * \class QAbstract3DSeriesChangeBitField |
| 24 | * \internal |
| 25 | */ |
| 26 | |
| 27 | /*! |
| 28 | * \class QAbstract3DSeriesThemeOverrideBitField |
| 29 | * \internal |
| 30 | */ |
| 31 | |
| 32 | /*! |
| 33 | * \qmltype Abstract3DSeries |
| 34 | * \inqmlmodule QtDataVisualization |
| 35 | * \since QtDataVisualization 1.0 |
| 36 | * \ingroup datavisualization_qml |
| 37 | * \nativetype QAbstract3DSeries |
| 38 | * \brief A base type for all data series. |
| 39 | * |
| 40 | * This type is uncreatable, but contains properties that are exposed via the |
| 41 | * following subtypes: Bar3DSeries, Scatter3DSeries, and Surface3DSeries. |
| 42 | * |
| 43 | * For more information, see \l{Qt Data Visualization Data Handling}. |
| 44 | */ |
| 45 | |
| 46 | /*! |
| 47 | * \enum QAbstract3DSeries::SeriesType |
| 48 | * |
| 49 | * Type of the series. |
| 50 | * |
| 51 | * \value SeriesTypeNone |
| 52 | * No series type. |
| 53 | * \value SeriesTypeBar |
| 54 | * Series type for Q3DBars. |
| 55 | * \value SeriesTypeScatter |
| 56 | * Series type for Q3DScatter. |
| 57 | * \value SeriesTypeSurface |
| 58 | * Series type for Q3DSurface. |
| 59 | */ |
| 60 | |
| 61 | /*! |
| 62 | * \enum QAbstract3DSeries::Mesh |
| 63 | * |
| 64 | * Predefined mesh types. All styles are not usable with all visualization types. |
| 65 | * |
| 66 | * \value MeshUserDefined |
| 67 | * User defined mesh, set via QAbstract3DSeries::userDefinedMesh property. |
| 68 | * \value MeshBar |
| 69 | * Basic rectangular bar. |
| 70 | * \value MeshCube |
| 71 | * Basic cube. |
| 72 | * \value MeshPyramid |
| 73 | * Four-sided pyramid. |
| 74 | * \value MeshCone |
| 75 | * Basic cone. |
| 76 | * \value MeshCylinder |
| 77 | * Basic cylinder. |
| 78 | * \value MeshBevelBar |
| 79 | * Slightly beveled (rounded) rectangular bar. |
| 80 | * \value MeshBevelCube |
| 81 | * Slightly beveled (rounded) cube. |
| 82 | * \value MeshSphere |
| 83 | * Sphere. |
| 84 | * \value MeshMinimal |
| 85 | * The minimal 3D mesh: a triangular pyramid. Usable only with Q3DScatter. |
| 86 | * \value MeshArrow |
| 87 | * Arrow pointing upwards. |
| 88 | * \value MeshPoint |
| 89 | * 2D point. Usable only with Q3DScatter. |
| 90 | * Shadows do not affect this style. Color style Q3DTheme::ColorStyleObjectGradient |
| 91 | * is not supported by this style. |
| 92 | */ |
| 93 | |
| 94 | /*! |
| 95 | * \qmlproperty Abstract3DSeries.SeriesType Abstract3DSeries::type |
| 96 | * The type of the series. One of the QAbstract3DSeries::SeriesType values. |
| 97 | * |
| 98 | */ |
| 99 | |
| 100 | /*! |
| 101 | * \qmlproperty string Abstract3DSeries::itemLabelFormat |
| 102 | * |
| 103 | * The label format for data items in this series. This format is used for single item labels, |
| 104 | * for example, when an item is selected. How the format is interpreted depends |
| 105 | * on series type: Bar3DSeries, Scatter3DSeries, Surface3DSeries. |
| 106 | */ |
| 107 | |
| 108 | /*! |
| 109 | * \qmlproperty bool Abstract3DSeries::visible |
| 110 | * Sets the visibility of the series. If \c false, the series is not rendered. |
| 111 | */ |
| 112 | |
| 113 | /*! |
| 114 | * \qmlproperty Abstract3DSeries.Mesh Abstract3DSeries::mesh |
| 115 | * |
| 116 | * Sets the mesh of the items in the series, or the selection pointer in case of |
| 117 | * Surface3DSeries. If the mesh is \l{QAbstract3DSeries::MeshUserDefined}{Abstract3DSeries.MeshUserDefined}, |
| 118 | * then the userDefinedMesh property must also be set for items to render properly. |
| 119 | * The default value depends on the graph type. |
| 120 | * |
| 121 | * \sa QAbstract3DSeries::Mesh |
| 122 | */ |
| 123 | |
| 124 | /*! |
| 125 | * \qmlproperty bool Abstract3DSeries::meshSmooth |
| 126 | * |
| 127 | * If \c true, smooth versions of predefined meshes set via the \l mesh property are used. |
| 128 | * This property does not affect custom meshes used when the mesh is set to |
| 129 | * \l{QAbstract3DSeries::MeshUserDefined}{Abstract3DSeries.MeshUserDefined}. |
| 130 | * Defaults to \c{false}. |
| 131 | */ |
| 132 | |
| 133 | /*! |
| 134 | * \qmlproperty quaternion Abstract3DSeries::meshRotation |
| 135 | * |
| 136 | * Sets the mesh rotation that is applied to all items of the series. |
| 137 | * The rotation should be a normalized quaternion. |
| 138 | * For those series types that support item specific rotation, the rotations are |
| 139 | * multiplied together. |
| 140 | * Bar3DSeries ignores any rotation that is not around the y-axis. |
| 141 | * Surface3DSeries applies the rotation only to the selection pointer. |
| 142 | * Defaults to no rotation. |
| 143 | */ |
| 144 | |
| 145 | /*! |
| 146 | * \qmlproperty string Abstract3DSeries::userDefinedMesh |
| 147 | * |
| 148 | * Sets the filename for a user defined custom mesh for objects that is used when \l mesh |
| 149 | * is \l{QAbstract3DSeries::MeshUserDefined}{Abstract3DSeries.MeshUserDefined}. |
| 150 | * \note The file needs to be in the Wavefront OBJ format and include |
| 151 | * vertices, normals, and UVs. It also needs to be in triangles. |
| 152 | */ |
| 153 | |
| 154 | /*! |
| 155 | * \qmlproperty Theme3D.ColorStyle Abstract3DSeries::colorStyle |
| 156 | * |
| 157 | * Sets the color style for the series. |
| 158 | * |
| 159 | * \sa {Theme3D::colorStyle}{Theme3D.colorStyle} |
| 160 | */ |
| 161 | |
| 162 | /*! |
| 163 | * \qmlproperty color Abstract3DSeries::baseColor |
| 164 | * |
| 165 | * Sets the base color of the series. |
| 166 | * |
| 167 | * \sa colorStyle, {Theme3D::baseColors}{Theme3D.baseColors} |
| 168 | */ |
| 169 | |
| 170 | /*! |
| 171 | * \qmlproperty ColorGradient Abstract3DSeries::baseGradient |
| 172 | * |
| 173 | * Sets the base gradient of the series. |
| 174 | * |
| 175 | * \sa colorStyle, {Theme3D::baseGradients}{Theme3D.baseGradients} |
| 176 | */ |
| 177 | |
| 178 | /*! |
| 179 | * \qmlproperty color Abstract3DSeries::singleHighlightColor |
| 180 | * |
| 181 | * Sets the single item highlight color of the series. |
| 182 | * |
| 183 | * \sa colorStyle, {Theme3D::singleHighlightColor}{Theme3D.singleHighlightColor} |
| 184 | */ |
| 185 | |
| 186 | /*! |
| 187 | * \qmlproperty ColorGradient Abstract3DSeries::singleHighlightGradient |
| 188 | * |
| 189 | * Sets the single item highlight gradient of the series. |
| 190 | * |
| 191 | * \sa colorStyle, {Theme3D::singleHighlightGradient}{Theme3D.singleHighlightGradient} |
| 192 | */ |
| 193 | |
| 194 | /*! |
| 195 | * \qmlproperty color Abstract3DSeries::multiHighlightColor |
| 196 | * |
| 197 | * Sets the multiple item highlight color of the series. |
| 198 | * |
| 199 | * \sa colorStyle, {Theme3D::multiHighlightColor}{Theme3D.multiHighlightColor} |
| 200 | */ |
| 201 | |
| 202 | /*! |
| 203 | * \qmlproperty ColorGradient Abstract3DSeries::multiHighlightGradient |
| 204 | * |
| 205 | * Sets the multiple item highlight gradient of the series. |
| 206 | * |
| 207 | * \sa colorStyle, {Theme3D::multiHighlightGradient}{Theme3D.multiHighlightGradient} |
| 208 | */ |
| 209 | |
| 210 | /*! |
| 211 | * \qmlproperty string Abstract3DSeries::name |
| 212 | * |
| 213 | * The series name. |
| 214 | * It can be used in item label format with the tag \c{@seriesName}. |
| 215 | * |
| 216 | * \sa itemLabelFormat |
| 217 | */ |
| 218 | |
| 219 | /*! |
| 220 | * \qmlproperty string Abstract3DSeries::itemLabel |
| 221 | * \since QtDataVisualization 1.1 |
| 222 | * |
| 223 | * The formatted item label. If there is no selected item or the selected item is not |
| 224 | * visible, returns an empty string. |
| 225 | * |
| 226 | * \sa itemLabelFormat |
| 227 | */ |
| 228 | |
| 229 | /*! |
| 230 | * \qmlproperty bool Abstract3DSeries::itemLabelVisible |
| 231 | * \since QtDataVisualization 1.1 |
| 232 | * |
| 233 | * If \c true, item labels are drawn as floating labels in the graph. Otherwise, |
| 234 | * item labels are not drawn. To show the item label in an external control, |
| 235 | * this property is set to \c false. Defaults to \c true. |
| 236 | * |
| 237 | * \sa itemLabelFormat, itemLabel |
| 238 | */ |
| 239 | |
| 240 | /*! |
| 241 | * \qmlmethod void Abstract3DSeries::setMeshAxisAndAngle(vector3d axis, real angle) |
| 242 | * |
| 243 | * A convenience function to construct a mesh rotation quaternion from \a axis |
| 244 | * and \a angle. |
| 245 | * |
| 246 | * \sa meshRotation |
| 247 | */ |
| 248 | |
| 249 | /*! |
| 250 | * \internal |
| 251 | */ |
| 252 | QAbstract3DSeries::QAbstract3DSeries(QAbstract3DSeriesPrivate *d, QObject *parent) : |
| 253 | QObject(parent), |
| 254 | d_ptr(d) |
| 255 | { |
| 256 | } |
| 257 | |
| 258 | /*! |
| 259 | * Deletes the abstract 3D series. |
| 260 | */ |
| 261 | QAbstract3DSeries::~QAbstract3DSeries() |
| 262 | { |
| 263 | } |
| 264 | |
| 265 | /*! |
| 266 | * \property QAbstract3DSeries::type |
| 267 | * |
| 268 | * \brief The type of the series. |
| 269 | */ |
| 270 | QAbstract3DSeries::SeriesType QAbstract3DSeries::type() const |
| 271 | { |
| 272 | return d_ptr->m_type; |
| 273 | } |
| 274 | |
| 275 | /*! |
| 276 | * \property QAbstract3DSeries::itemLabelFormat |
| 277 | * |
| 278 | * \brief The label format for data items in this series. |
| 279 | * |
| 280 | * This format is used for single item labels, |
| 281 | * for example, when an item is selected. How the format is interpreted depends |
| 282 | * on series type: QBar3DSeries, QScatter3DSeries, QSurface3DSeries. |
| 283 | */ |
| 284 | void QAbstract3DSeries::setItemLabelFormat(const QString &format) |
| 285 | { |
| 286 | if (d_ptr->m_itemLabelFormat != format) { |
| 287 | d_ptr->setItemLabelFormat(format); |
| 288 | emit itemLabelFormatChanged(format); |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | QString QAbstract3DSeries::itemLabelFormat() const |
| 293 | { |
| 294 | return d_ptr->m_itemLabelFormat; |
| 295 | } |
| 296 | |
| 297 | /*! |
| 298 | * \property QAbstract3DSeries::visible |
| 299 | * |
| 300 | * \brief The visibility of the series. |
| 301 | * |
| 302 | * If this property is \c false, the series is not rendered. |
| 303 | * Defaults to \c{true}. |
| 304 | */ |
| 305 | void QAbstract3DSeries::setVisible(bool visible) |
| 306 | { |
| 307 | if (d_ptr->m_visible != visible) { |
| 308 | d_ptr->setVisible(visible); |
| 309 | emit visibilityChanged(visible); |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | bool QAbstract3DSeries::isVisible() const |
| 314 | { |
| 315 | return d_ptr->m_visible; |
| 316 | } |
| 317 | |
| 318 | /*! |
| 319 | * \property QAbstract3DSeries::mesh |
| 320 | * |
| 321 | * \brief The mesh of the items in the series. |
| 322 | * |
| 323 | * For QSurface3DSeries, this property holds the selection pointer. |
| 324 | * |
| 325 | * If the mesh is MeshUserDefined, then the userDefinedMesh property |
| 326 | * must also be set for items to render properly. The default value depends on the graph type. |
| 327 | */ |
| 328 | void QAbstract3DSeries::setMesh(QAbstract3DSeries::Mesh mesh) |
| 329 | { |
| 330 | if ((mesh == QAbstract3DSeries::MeshPoint || mesh == QAbstract3DSeries::MeshMinimal |
| 331 | || mesh == QAbstract3DSeries::MeshArrow) |
| 332 | && type() != QAbstract3DSeries::SeriesTypeScatter) { |
| 333 | qWarning() << "Specified style is only supported for QScatter3DSeries." ; |
| 334 | } else if (d_ptr->m_mesh != mesh) { |
| 335 | d_ptr->setMesh(mesh); |
| 336 | emit meshChanged(mesh); |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | QAbstract3DSeries::Mesh QAbstract3DSeries::mesh() const |
| 341 | { |
| 342 | return d_ptr->m_mesh; |
| 343 | } |
| 344 | |
| 345 | /*! |
| 346 | * \property QAbstract3DSeries::meshSmooth |
| 347 | * |
| 348 | * \brief Whether smooth versions of predefined meshes are used. |
| 349 | * |
| 350 | * If \c true, smooth versions set via the \l mesh property are used. |
| 351 | * This property does not affect custom meshes used when the mesh is set to |
| 352 | * MeshUserDefined. Defaults to \c{false}. |
| 353 | */ |
| 354 | void QAbstract3DSeries::setMeshSmooth(bool enable) |
| 355 | { |
| 356 | if (d_ptr->m_meshSmooth != enable) { |
| 357 | d_ptr->setMeshSmooth(enable); |
| 358 | emit meshSmoothChanged(enabled: enable); |
| 359 | } |
| 360 | } |
| 361 | |
| 362 | bool QAbstract3DSeries::isMeshSmooth() const |
| 363 | { |
| 364 | return d_ptr->m_meshSmooth; |
| 365 | } |
| 366 | |
| 367 | /*! |
| 368 | * \property QAbstract3DSeries::meshRotation |
| 369 | * |
| 370 | * \brief The mesh rotation that is applied to all items of the series. |
| 371 | * |
| 372 | * The rotation should be a normalized QQuaternion. |
| 373 | * For those series types that support item specific rotation, the rotations are |
| 374 | * multiplied together. |
| 375 | * QBar3DSeries ignores any rotation that is not around the y-axis. |
| 376 | * QSurface3DSeries applies the rotation only to the selection pointer. |
| 377 | * Defaults to no rotation. |
| 378 | */ |
| 379 | void QAbstract3DSeries::setMeshRotation(const QQuaternion &rotation) |
| 380 | { |
| 381 | if (d_ptr->m_meshRotation != rotation) { |
| 382 | d_ptr->setMeshRotation(rotation); |
| 383 | emit meshRotationChanged(rotation); |
| 384 | } |
| 385 | } |
| 386 | |
| 387 | QQuaternion QAbstract3DSeries::meshRotation() const |
| 388 | { |
| 389 | return d_ptr->m_meshRotation; |
| 390 | } |
| 391 | |
| 392 | /*! |
| 393 | * A convenience function to construct a mesh rotation quaternion from |
| 394 | * \a axis and \a angle. |
| 395 | * |
| 396 | * \sa meshRotation |
| 397 | */ |
| 398 | void QAbstract3DSeries::setMeshAxisAndAngle(const QVector3D &axis, float angle) |
| 399 | { |
| 400 | setMeshRotation(QQuaternion::fromAxisAndAngle(axis, angle)); |
| 401 | } |
| 402 | |
| 403 | /*! |
| 404 | * \property QAbstract3DSeries::userDefinedMesh |
| 405 | * |
| 406 | * \brief The filename for a user defined custom mesh for objects. |
| 407 | * |
| 408 | * The custom mesh is used when \l mesh is MeshUserDefined. |
| 409 | * \note The file needs to be in the Wavefront OBJ format and include |
| 410 | * vertices, normals, and UVs. It also needs to be in triangles. |
| 411 | */ |
| 412 | void QAbstract3DSeries::setUserDefinedMesh(const QString &fileName) |
| 413 | { |
| 414 | if (d_ptr->m_userDefinedMesh != fileName) { |
| 415 | d_ptr->setUserDefinedMesh(fileName); |
| 416 | emit userDefinedMeshChanged(fileName); |
| 417 | } |
| 418 | } |
| 419 | |
| 420 | QString QAbstract3DSeries::userDefinedMesh() const |
| 421 | { |
| 422 | return d_ptr->m_userDefinedMesh; |
| 423 | } |
| 424 | |
| 425 | /*! |
| 426 | * \property QAbstract3DSeries::colorStyle |
| 427 | * |
| 428 | * \brief The color style for the series. |
| 429 | * |
| 430 | * \sa Q3DTheme::ColorStyle |
| 431 | */ |
| 432 | void QAbstract3DSeries::setColorStyle(Q3DTheme::ColorStyle style) |
| 433 | { |
| 434 | if (d_ptr->m_colorStyle != style) { |
| 435 | d_ptr->setColorStyle(style); |
| 436 | emit colorStyleChanged(style); |
| 437 | } |
| 438 | d_ptr->m_themeTracker.colorStyleOverride = true; |
| 439 | } |
| 440 | |
| 441 | Q3DTheme::ColorStyle QAbstract3DSeries::colorStyle() const |
| 442 | { |
| 443 | return d_ptr->m_colorStyle; |
| 444 | } |
| 445 | |
| 446 | /*! |
| 447 | * \property QAbstract3DSeries::baseColor |
| 448 | * |
| 449 | * \brief The base color of the series. |
| 450 | * |
| 451 | * \sa colorStyle, Q3DTheme::baseColors |
| 452 | */ |
| 453 | void QAbstract3DSeries::setBaseColor(const QColor &color) |
| 454 | { |
| 455 | if (d_ptr->m_baseColor != color) { |
| 456 | d_ptr->setBaseColor(color); |
| 457 | emit baseColorChanged(color); |
| 458 | } |
| 459 | d_ptr->m_themeTracker.baseColorOverride = true; |
| 460 | } |
| 461 | |
| 462 | QColor QAbstract3DSeries::baseColor() const |
| 463 | { |
| 464 | return d_ptr->m_baseColor; |
| 465 | } |
| 466 | |
| 467 | /*! |
| 468 | * \property QAbstract3DSeries::baseGradient |
| 469 | * |
| 470 | * \brief The base gradient of the series. |
| 471 | * |
| 472 | * \sa colorStyle, Q3DTheme::baseGradients |
| 473 | */ |
| 474 | void QAbstract3DSeries::setBaseGradient(const QLinearGradient &gradient) |
| 475 | { |
| 476 | if (d_ptr->m_baseGradient != gradient) { |
| 477 | d_ptr->setBaseGradient(gradient); |
| 478 | emit baseGradientChanged(gradient); |
| 479 | } |
| 480 | d_ptr->m_themeTracker.baseGradientOverride = true; |
| 481 | } |
| 482 | |
| 483 | QLinearGradient QAbstract3DSeries::baseGradient() const |
| 484 | { |
| 485 | return d_ptr->m_baseGradient; |
| 486 | } |
| 487 | |
| 488 | /*! |
| 489 | * \property QAbstract3DSeries::singleHighlightColor |
| 490 | * |
| 491 | * \brief The single item highlight color of the series. |
| 492 | * |
| 493 | * \sa colorStyle, Q3DTheme::singleHighlightColor |
| 494 | */ |
| 495 | void QAbstract3DSeries::setSingleHighlightColor(const QColor &color) |
| 496 | { |
| 497 | if (d_ptr->m_singleHighlightColor != color) { |
| 498 | d_ptr->setSingleHighlightColor(color); |
| 499 | emit singleHighlightColorChanged(color); |
| 500 | } |
| 501 | d_ptr->m_themeTracker.singleHighlightColorOverride = true; |
| 502 | } |
| 503 | |
| 504 | QColor QAbstract3DSeries::singleHighlightColor() const |
| 505 | { |
| 506 | return d_ptr->m_singleHighlightColor; |
| 507 | } |
| 508 | |
| 509 | /*! |
| 510 | * \property QAbstract3DSeries::singleHighlightGradient |
| 511 | * |
| 512 | * \brief The single item highlight gradient of the series. |
| 513 | * |
| 514 | * \sa colorStyle, Q3DTheme::singleHighlightGradient |
| 515 | */ |
| 516 | void QAbstract3DSeries::setSingleHighlightGradient(const QLinearGradient &gradient) |
| 517 | { |
| 518 | if (d_ptr->m_singleHighlightGradient != gradient) { |
| 519 | d_ptr->setSingleHighlightGradient(gradient); |
| 520 | emit singleHighlightGradientChanged(gradient); |
| 521 | } |
| 522 | d_ptr->m_themeTracker.singleHighlightGradientOverride = true; |
| 523 | } |
| 524 | |
| 525 | QLinearGradient QAbstract3DSeries::singleHighlightGradient() const |
| 526 | { |
| 527 | return d_ptr->m_singleHighlightGradient; |
| 528 | } |
| 529 | |
| 530 | /*! |
| 531 | * \property QAbstract3DSeries::multiHighlightColor |
| 532 | * |
| 533 | * \brief The multiple item highlight color of the series. |
| 534 | * |
| 535 | * \sa colorStyle, Q3DTheme::multiHighlightColor |
| 536 | */ |
| 537 | void QAbstract3DSeries::setMultiHighlightColor(const QColor &color) |
| 538 | { |
| 539 | if (d_ptr->m_multiHighlightColor != color) { |
| 540 | d_ptr->setMultiHighlightColor(color); |
| 541 | emit multiHighlightColorChanged(color); |
| 542 | } |
| 543 | d_ptr->m_themeTracker.multiHighlightColorOverride = true; |
| 544 | } |
| 545 | |
| 546 | QColor QAbstract3DSeries::multiHighlightColor() const |
| 547 | { |
| 548 | return d_ptr->m_multiHighlightColor; |
| 549 | } |
| 550 | |
| 551 | /*! |
| 552 | * \property QAbstract3DSeries::multiHighlightGradient |
| 553 | * |
| 554 | * \brief The multiple item highlight gradient of the series. |
| 555 | * |
| 556 | * \sa colorStyle, Q3DTheme::multiHighlightGradient |
| 557 | */ |
| 558 | void QAbstract3DSeries::setMultiHighlightGradient(const QLinearGradient &gradient) |
| 559 | { |
| 560 | if (d_ptr->m_multiHighlightGradient != gradient) { |
| 561 | d_ptr->setMultiHighlightGradient(gradient); |
| 562 | emit multiHighlightGradientChanged(gradient); |
| 563 | } |
| 564 | d_ptr->m_themeTracker.multiHighlightGradientOverride = true; |
| 565 | } |
| 566 | |
| 567 | QLinearGradient QAbstract3DSeries::multiHighlightGradient() const |
| 568 | { |
| 569 | return d_ptr->m_multiHighlightGradient; |
| 570 | } |
| 571 | |
| 572 | /*! |
| 573 | * \property QAbstract3DSeries::name |
| 574 | * |
| 575 | * \brief The series name. |
| 576 | * |
| 577 | * The series name can be used in item label format with the tag \c{@seriesName}. |
| 578 | * |
| 579 | * \sa itemLabelFormat |
| 580 | */ |
| 581 | void QAbstract3DSeries::setName(const QString &name) |
| 582 | { |
| 583 | if (d_ptr->m_name != name) { |
| 584 | d_ptr->setName(name); |
| 585 | emit nameChanged(name); |
| 586 | } |
| 587 | } |
| 588 | |
| 589 | QString QAbstract3DSeries::name() const |
| 590 | { |
| 591 | return d_ptr->m_name; |
| 592 | } |
| 593 | |
| 594 | /*! |
| 595 | * \property QAbstract3DSeries::itemLabel |
| 596 | * \since QtDataVisualization 1.1 |
| 597 | * |
| 598 | * \brief The formatted item label. |
| 599 | * |
| 600 | * If there is no selected item or the selected item is not |
| 601 | * visible, returns an empty string. |
| 602 | * |
| 603 | * \sa itemLabelFormat |
| 604 | */ |
| 605 | QString QAbstract3DSeries::itemLabel() const |
| 606 | { |
| 607 | return d_ptr->itemLabel(); |
| 608 | } |
| 609 | |
| 610 | /*! |
| 611 | * \property QAbstract3DSeries::itemLabelVisible |
| 612 | * \since QtDataVisualization 1.1 |
| 613 | * |
| 614 | * \brief The visibility of item labels in the graph. |
| 615 | * |
| 616 | * If \c true, item labels are drawn as floating labels in the graph. Otherwise, |
| 617 | * item labels are not drawn. To show the item label in an external control, |
| 618 | * this property is set to \c false. Defaults to \c true. |
| 619 | * |
| 620 | * \sa itemLabelFormat, itemLabel |
| 621 | */ |
| 622 | void QAbstract3DSeries::setItemLabelVisible(bool visible) |
| 623 | { |
| 624 | if (d_ptr->m_itemLabelVisible != visible) { |
| 625 | d_ptr->setItemLabelVisible(visible); |
| 626 | emit itemLabelVisibilityChanged(visible); |
| 627 | } |
| 628 | } |
| 629 | |
| 630 | bool QAbstract3DSeries::isItemLabelVisible() const |
| 631 | { |
| 632 | return d_ptr->m_itemLabelVisible; |
| 633 | } |
| 634 | |
| 635 | // QAbstract3DSeriesPrivate |
| 636 | |
| 637 | QAbstract3DSeriesPrivate::QAbstract3DSeriesPrivate(QAbstract3DSeries *q, |
| 638 | QAbstract3DSeries::SeriesType type) |
| 639 | : QObject(0), |
| 640 | q_ptr(q), |
| 641 | m_type(type), |
| 642 | m_dataProxy(0), |
| 643 | m_visible(true), |
| 644 | m_controller(0), |
| 645 | m_mesh(QAbstract3DSeries::MeshCube), |
| 646 | m_meshSmooth(false), |
| 647 | m_colorStyle(Q3DTheme::ColorStyleUniform), |
| 648 | m_baseColor(Qt::black), |
| 649 | m_singleHighlightColor(Qt::black), |
| 650 | m_multiHighlightColor(Qt::black), |
| 651 | m_itemLabelDirty(true), |
| 652 | m_itemLabelVisible(true) |
| 653 | { |
| 654 | } |
| 655 | |
| 656 | QAbstract3DSeriesPrivate::~QAbstract3DSeriesPrivate() |
| 657 | { |
| 658 | } |
| 659 | |
| 660 | QAbstractDataProxy *QAbstract3DSeriesPrivate::dataProxy() const |
| 661 | { |
| 662 | return m_dataProxy; |
| 663 | } |
| 664 | |
| 665 | void QAbstract3DSeriesPrivate::setDataProxy(QAbstractDataProxy *proxy) |
| 666 | { |
| 667 | Q_ASSERT(proxy && proxy != m_dataProxy && !proxy->d_ptr->series()); |
| 668 | |
| 669 | delete m_dataProxy; |
| 670 | m_dataProxy = proxy; |
| 671 | |
| 672 | proxy->d_ptr->setSeries(q_ptr); // also sets parent |
| 673 | |
| 674 | if (m_controller) { |
| 675 | connectControllerAndProxy(newController: m_controller); |
| 676 | m_controller->markDataDirty(); |
| 677 | } |
| 678 | } |
| 679 | |
| 680 | void QAbstract3DSeriesPrivate::setController(Abstract3DController *controller) |
| 681 | { |
| 682 | connectControllerAndProxy(newController: controller); |
| 683 | m_controller = controller; |
| 684 | q_ptr->setParent(controller); |
| 685 | markItemLabelDirty(); |
| 686 | } |
| 687 | |
| 688 | void QAbstract3DSeriesPrivate::setItemLabelFormat(const QString &format) |
| 689 | { |
| 690 | m_itemLabelFormat = format; |
| 691 | markItemLabelDirty(); |
| 692 | } |
| 693 | |
| 694 | void QAbstract3DSeriesPrivate::setVisible(bool visible) |
| 695 | { |
| 696 | m_visible = visible; |
| 697 | markItemLabelDirty(); |
| 698 | } |
| 699 | |
| 700 | void QAbstract3DSeriesPrivate::setMesh(QAbstract3DSeries::Mesh mesh) |
| 701 | { |
| 702 | m_mesh = mesh; |
| 703 | m_changeTracker.meshChanged = true; |
| 704 | if (m_controller) { |
| 705 | m_controller->markSeriesVisualsDirty(); |
| 706 | |
| 707 | if (m_controller->optimizationHints().testFlag(flag: QAbstract3DGraph::OptimizationStatic)) |
| 708 | m_controller->markDataDirty(); |
| 709 | } |
| 710 | } |
| 711 | |
| 712 | void QAbstract3DSeriesPrivate::setMeshSmooth(bool enable) |
| 713 | { |
| 714 | m_meshSmooth = enable; |
| 715 | m_changeTracker.meshSmoothChanged = true; |
| 716 | if (m_controller) { |
| 717 | m_controller->markSeriesVisualsDirty(); |
| 718 | |
| 719 | if (m_controller->optimizationHints().testFlag(flag: QAbstract3DGraph::OptimizationStatic)) |
| 720 | m_controller->markDataDirty(); |
| 721 | } |
| 722 | } |
| 723 | |
| 724 | void QAbstract3DSeriesPrivate::setMeshRotation(const QQuaternion &rotation) |
| 725 | { |
| 726 | m_meshRotation = rotation; |
| 727 | m_changeTracker.meshRotationChanged = true; |
| 728 | if (m_controller) { |
| 729 | m_controller->markSeriesVisualsDirty(); |
| 730 | |
| 731 | if (m_controller->optimizationHints().testFlag(flag: QAbstract3DGraph::OptimizationStatic)) |
| 732 | m_controller->markDataDirty(); |
| 733 | } |
| 734 | } |
| 735 | |
| 736 | void QAbstract3DSeriesPrivate::setUserDefinedMesh(const QString &meshFile) |
| 737 | { |
| 738 | m_userDefinedMesh = meshFile; |
| 739 | m_changeTracker.userDefinedMeshChanged = true; |
| 740 | if (m_controller) { |
| 741 | m_controller->markSeriesVisualsDirty(); |
| 742 | |
| 743 | if (m_controller->optimizationHints().testFlag(flag: QAbstract3DGraph::OptimizationStatic)) |
| 744 | m_controller->markDataDirty(); |
| 745 | } |
| 746 | } |
| 747 | |
| 748 | void QAbstract3DSeriesPrivate::setColorStyle(Q3DTheme::ColorStyle style) |
| 749 | { |
| 750 | m_colorStyle = style; |
| 751 | m_changeTracker.colorStyleChanged = true; |
| 752 | if (m_controller) |
| 753 | m_controller->markSeriesVisualsDirty(); |
| 754 | } |
| 755 | |
| 756 | void QAbstract3DSeriesPrivate::setBaseColor(const QColor &color) |
| 757 | { |
| 758 | m_baseColor = color; |
| 759 | m_changeTracker.baseColorChanged = true; |
| 760 | if (m_controller) |
| 761 | m_controller->markSeriesVisualsDirty(); |
| 762 | } |
| 763 | |
| 764 | void QAbstract3DSeriesPrivate::setBaseGradient(const QLinearGradient &gradient) |
| 765 | { |
| 766 | m_baseGradient = gradient; |
| 767 | m_changeTracker.baseGradientChanged = true; |
| 768 | if (m_controller) |
| 769 | m_controller->markSeriesVisualsDirty(); |
| 770 | } |
| 771 | |
| 772 | void QAbstract3DSeriesPrivate::setSingleHighlightColor(const QColor &color) |
| 773 | { |
| 774 | m_singleHighlightColor = color; |
| 775 | m_changeTracker.singleHighlightColorChanged = true; |
| 776 | if (m_controller) |
| 777 | m_controller->markSeriesVisualsDirty(); |
| 778 | } |
| 779 | |
| 780 | void QAbstract3DSeriesPrivate::setSingleHighlightGradient(const QLinearGradient &gradient) |
| 781 | { |
| 782 | m_singleHighlightGradient = gradient; |
| 783 | m_changeTracker.singleHighlightGradientChanged = true; |
| 784 | if (m_controller) |
| 785 | m_controller->markSeriesVisualsDirty(); |
| 786 | } |
| 787 | |
| 788 | void QAbstract3DSeriesPrivate::setMultiHighlightColor(const QColor &color) |
| 789 | { |
| 790 | m_multiHighlightColor = color; |
| 791 | m_changeTracker.multiHighlightColorChanged = true; |
| 792 | if (m_controller) |
| 793 | m_controller->markSeriesVisualsDirty(); |
| 794 | } |
| 795 | |
| 796 | void QAbstract3DSeriesPrivate::setMultiHighlightGradient(const QLinearGradient &gradient) |
| 797 | { |
| 798 | m_multiHighlightGradient = gradient; |
| 799 | m_changeTracker.multiHighlightGradientChanged = true; |
| 800 | if (m_controller) |
| 801 | m_controller->markSeriesVisualsDirty(); |
| 802 | } |
| 803 | |
| 804 | void QAbstract3DSeriesPrivate::setName(const QString &name) |
| 805 | { |
| 806 | m_name = name; |
| 807 | markItemLabelDirty(); |
| 808 | m_changeTracker.nameChanged = true; |
| 809 | } |
| 810 | |
| 811 | void QAbstract3DSeriesPrivate::resetToTheme(const Q3DTheme &theme, int seriesIndex, bool force) |
| 812 | { |
| 813 | int themeIndex = seriesIndex; |
| 814 | if (force || !m_themeTracker.colorStyleOverride) { |
| 815 | q_ptr->setColorStyle(theme.colorStyle()); |
| 816 | m_themeTracker.colorStyleOverride = false; |
| 817 | } |
| 818 | if (force || !m_themeTracker.baseColorOverride) { |
| 819 | if (theme.baseColors().size() <= seriesIndex) |
| 820 | themeIndex = seriesIndex % theme.baseColors().size(); |
| 821 | q_ptr->setBaseColor(theme.baseColors().at(i: themeIndex)); |
| 822 | m_themeTracker.baseColorOverride = false; |
| 823 | } |
| 824 | if (force || !m_themeTracker.baseGradientOverride) { |
| 825 | if (theme.baseGradients().size() <= seriesIndex) |
| 826 | themeIndex = seriesIndex % theme.baseGradients().size(); |
| 827 | q_ptr->setBaseGradient(theme.baseGradients().at(i: themeIndex)); |
| 828 | m_themeTracker.baseGradientOverride = false; |
| 829 | } |
| 830 | if (force || !m_themeTracker.singleHighlightColorOverride) { |
| 831 | q_ptr->setSingleHighlightColor(theme.singleHighlightColor()); |
| 832 | m_themeTracker.singleHighlightColorOverride = false; |
| 833 | } |
| 834 | if (force || !m_themeTracker.singleHighlightGradientOverride) { |
| 835 | q_ptr->setSingleHighlightGradient(theme.singleHighlightGradient()); |
| 836 | m_themeTracker.singleHighlightGradientOverride = false; |
| 837 | } |
| 838 | if (force || !m_themeTracker.multiHighlightColorOverride) { |
| 839 | q_ptr->setMultiHighlightColor(theme.multiHighlightColor()); |
| 840 | m_themeTracker.multiHighlightColorOverride = false; |
| 841 | } |
| 842 | if (force || !m_themeTracker.multiHighlightGradientOverride) { |
| 843 | q_ptr->setMultiHighlightGradient(theme.multiHighlightGradient()); |
| 844 | m_themeTracker.multiHighlightGradientOverride = false; |
| 845 | } |
| 846 | } |
| 847 | |
| 848 | QString QAbstract3DSeriesPrivate::itemLabel() |
| 849 | { |
| 850 | if (m_itemLabelDirty) { |
| 851 | QString oldLabel = m_itemLabel; |
| 852 | if (m_controller && m_visible) |
| 853 | createItemLabel(); |
| 854 | else |
| 855 | m_itemLabel = QString(); |
| 856 | m_itemLabelDirty = false; |
| 857 | |
| 858 | if (oldLabel != m_itemLabel) |
| 859 | emit q_ptr->itemLabelChanged(label: m_itemLabel); |
| 860 | } |
| 861 | |
| 862 | return m_itemLabel; |
| 863 | } |
| 864 | |
| 865 | void QAbstract3DSeriesPrivate::markItemLabelDirty() |
| 866 | { |
| 867 | m_itemLabelDirty = true; |
| 868 | m_changeTracker.itemLabelChanged = true; |
| 869 | if (m_controller) |
| 870 | m_controller->markSeriesVisualsDirty(); |
| 871 | } |
| 872 | |
| 873 | void QAbstract3DSeriesPrivate::setItemLabelVisible(bool visible) |
| 874 | { |
| 875 | m_itemLabelVisible = visible; |
| 876 | markItemLabelDirty(); |
| 877 | m_changeTracker.itemLabelVisibilityChanged = true; |
| 878 | } |
| 879 | |
| 880 | QT_END_NAMESPACE |
| 881 | |