// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only

/*!
    \module QtGraphs
    \title Qt Graphs C++ Classes
    \ingroup modules
    \qtcmakepackage Graphs
    \qtvariable graphs
    \modulestate Technical Preview

    \brief C++ classes for the Qt Graphs API.

    The Qt Graphs functionality can be accessed via these C++ classes.
*/

/*!
    \qmlmodule QtGraphs \QtMajorVersion.\QtMinorVersion
    \title Qt Graphs QML Types
    \ingroup qmlmodules
    \modulestate Technical Preview

    \brief QML types for the Qt Graphs API.

    The Qt Graphs functionality can be accessed via these QML types.

    \section1 QML Types
*/

/*!
    \group graphs_examples
    \ingroup all-examples
    \title Qt Graphs Examples

    \brief Examples for the Qt Graphs.

    For some code examples, see one of the Qt Graphs examples:

    \section1 Examples

    \annotatedlist qtgraphs_qmlexamples
    The following example shows how to use widgets to visualize data:
    \annotatedlist qtgraphs_examples
*/

/*!
    \page qtgraphs_data_handling.html
    \title Qt Graphs Data Handling

    \section1 Series

    A series is a combination of a logically connected set of data items (handled by a data proxy)
    and visual properties that describe how the data items should be rendered, such as item
    meshes and colors. Each graphs type has its own series type. For example, bar graphs
    use QBar3DSeries. All graphs can have multiple series added simultaneously.

    This code snippet shows how to use QBar3DSeries to render bars as cylinders and with a
    gradient instead of a uniform color:

    \snippet doc_src_qtgraphs.cpp 11

    \section1 Data Proxies

    The data that users wish to visualize comes in many formats, all of which cannot obviously be
    directly supported. Therefore, Qt Graphs implements data proxies into which
    user can feed their data in a known format. Each graphs type has a basic proxy type,
    which takes data in a format suitable for that graph.
    For example, the basic proxy for QBar3DSeries is QBarDataProxy, which stores rows of QBarDataItem
    objects. Each QBarDataItem stores a single bar value. Additional typedefs are provided for
    \c QBarDataArray and \c QBarDataRow containers.

    This code snippet shows how to use basic proxy when your data is stored in some hypothetical
    \c myData object:

    \snippet doc_src_qtgraphs.cpp 10

    \note Series objects can own only a single proxy at a time. The existing proxy is deleted
    when another is set to the series. Graphs can contain multiple series, though.
    If you need to switch back and forth between two different sets of data,
    it is usually more efficient to store each set in a different series and just change the series,
    rather than reset the data in one proxy every time you need to switch.

    \section1 Item Models and Data Mapping

    For common use cases, Qt Graphs offers specialized proxies. One such case is having
    data in an item model (QAbstractItemModel subclass), which is a common way to store data in
    Qt applications. Each of the graphs types offers a special proxy class for this purpose,
    for example, QItemModelBarDataProxy for QBar3DSeries.
    These proxies are simple to use: just give them a pointer to the item model containing the
    data and the rules how to map the data into format the basic proxy can digest.

    Mapping works with item model roles. Each data item in the model can have different
    values for different roles. For example, with QItemModelBarDataProxy you can specify which
    role is used to determine which row the item belongs to, which role does the same for columns,
    and which role specifies the value of the item. When the proxy resolves the data from the model,
    it uses these mappings to generate the rows and columns of the bar graph.

    Often the item models will have a single role that contains information you want to map to
    multiple values. A typical example of this is a timestamp field when generating a bar graph
    with two time related axes, for example years and months. To enable mapping a single item
    model role to more than one data field, pattern matching and replacing mechanism is provided
    by item model proxies. You can also use this mechanism to reformat data even in one-to-one
    mapping cases.

    Depending on the grpahs type, proxies may support other functionalities as well,
    such as QItemModelBarDataProxy optionally mapping QAbstractItemModel rows and columns directly
    into bar graph rows and columns.

    See individual proxy classes for more information and examples
    about how to use them: QItemModelBarDataProxy, QItemModelScatterDataProxy, and
    QItemModelSurfaceDataProxy.

    \section1 Other Custom Proxies

    QHeightMapSurfaceDataProxy is a specialized proxy for generating a surface graph from a
    heightmap image. See the QHeightMapSurfaceDataProxy documentation for more information.

    The \l{Graph Gallery} example shows how a custom proxy can be created, under the
    \uicontrol {Bar Graph} tab. It defines a custom data set based on variant lists and an
    extension of the basic proxy to resolve that data with an associated mapper.

    \section1 Dealing with Real-time Data

    When you have a data set that updates rapidly, it is important to handle data properly to
    ensure good performance. Since memory allocation is a costly operation, always use
    QList::reserve() and QList::resize() where possible to avoid unnecessary reallocations when
    constructing the array to give to the proxy. If you need to change the entire data set
    for each frame, it is in most cases best to reuse the existing array - especially if the
    array dimensions do not change. If you need to add, insert, remove, or change several
    rows or items for each frame, it is always more efficient to do it with one method call
    instead of multiple calls affecting a single row or item each. For example, adding ten
    rows with a single QBarDataProxy::addRows() call is much more efficient than ten
    separate QBarDataProxy::addRow() calls.

    Bars renderer is optimized to access only data that is within the data window and thus
    should not suffer noticeable slowdown even if more data is continually added to the proxy.

    Due to the unsorted nature of the scatter data, any change in the data window ranges requires
    all data points to be checked for visibility, which can cause increasing slowdown if data is
    continually added to the proxy. For the best performance with the scatter graphs, only keep
    the data you need in the proxy.

    Surface data, while on item level similar to scatter data, is already assigned into rows and
    columns, so the surface renderer can optimize drawing by making the assumption that
    the data in the rows and columns is sorted along their respective axes. It is not quite as
    efficient as in the bars case, but nearly so.
*/

/*!
    \page qtgraphs_interacting_with_data.html
    \title Qt Graphs Interacting with Data

    \section1 Interacting with Data

    End users can interact with the rendered graph by using either the mouse or
    touch to rotate, zoom, or select data. Graphs can be rotated freely by
    holding down the right mouse button and moving the mouse. Zooming is done by
    rolling the mouse wheel. Selecting, if enabled, is done by pressing the left
    mouse button. The scene can be reset to the default camera view by clicking
    the mouse wheel. In touch devices, rotation is done by tap-and-move,
    selection by tap-and-hold, and zoom by pinch.

    Qt Graphs has default handlers for mouse actions and touch
    gestures. For the default mouse controls, see Q3DInputHandler, and for
    the default touch controls, see QTouch3DInputHandler. The default handlers
    must be disabled when using customized input handlers.

    The \l{Graph Gallery} example, under \uicontrol {Scatter Graph} tab, illustrates how to use
    a custom input handler to drag an axis label to move the visible part of the data.

    In addition to perspective projection, orthographic projection can be used
    to create 2D graphs by replacing the default input handler with one that
    does not allow rotating the graph and setting the camera to view the graph
    directly from the side or from the top.

    \section1 Data Selection Modes

    All graphs types support selecting a single data item - a bar, a scatter item, or a surface
    vertex - using mouse, touch, and programmatically via the series APIs. The selected item is highlighted
    in the rendered graph, and selecting causes emission of a series specific signal for this purpose,
    for example, QBar3DSeries::selectedBarChanged(), which the application can handle.

    Bar and surface graphs support slice selection modes, where the selected row or column is drawn
    in a separate viewport as a pseudo-2D graph. This makes it easier to see the actual values of
    a single row or column.

    Bar graph additionally supports simply highlighting the whole row and/or column of the selected bar
    without opening the slice view. Bar graph also supports selecting/slicing a whole row and/or
    column by clicking the axis label, based on selection mode.

    When multiple series are added to a graph, selecting an item in one of them will clear the selection
    on other series.
*/

/*!
    \page qtgraphs_known_issues.html
    \title Qt Graphs Known Issues

    \section1 Generic issues

    \list
        \li Surfaces with non-straight rows and columns do not always render properly.
        \li Q3DLight class (and Light3D QML item) are currently not usable for anything.
        \li Changing most of Q3DScene properties affecting subviewports currently has no effect.
        \li Widget based examples layout incorrectly in iOS.
        \li Reparenting a graph to an item in another QQuickWindow is not supported.
        \li Android qmake builds of QML applications importing QtGraphs also require
            "QT += graphs" in the pro file. This is because Qt Graphs
            QML plugin has a dependency to Qt Graphs C++ library, which Qt Creator
            doesn't automatically add to the deployment package.
    \endlist

    \section1 Unresolved JIRA tickets in Qt 6.6.0
    \list
        \li Main graph enlarges on top of slice view for a one frame - \l https://bugreports.qt.io/browse/QTBUG-116628
        \li Item label is shown as an empty label in topography example - \l https://bugreports.qt.io/browse/QTBUG-116602
        \li Highlighting the selection does not work correctly in texture topography example - \l https://bugreports.qt.io/browse/QTBUG-116479
        \li widgetgraphgallery: surfacegraph should open slice view immediately - \l https://bugreports.qt.io/browse/QTBUG-116429
        \li Toggling surface grid on causes labels to jump out of place - \l https://bugreports.qt.io/browse/QTBUG-116397
        \li Shadows do not work on Surface3D - \l https://bugreports.qt.io/browse/QTBUG-115780
        \li Graph goes to empty slice view automatically - \l https://bugreports.qt.io/browse/QTBUG-115772
        \li Vertical grids are still visible on top view - \l https://bugreports.qt.io/browse/QTBUG-115736
        \li tst_itemmodel: selection from table does not work - \l https://bugreports.qt.io/browse/QTBUG-114122
        \li Volume texture formats not handled - \l https://bugreports.qt.io/browse/QTBUG-113837
        \li Slice view is sometimes empty in Bars3D - \l https://bugreports.qt.io/browse/QTBUG-113675
        \li Selection is sometimes incorrect in Bars3D - \l https://bugreports.qt.io/browse/QTBUG-113650
        \li renderToImage does nothing - \l https://bugreports.qt.io/browse/QTBUG-111712
        \li Reflection support does not work - \l https://bugreports.qt.io/browse/QTBUG-99816
    \endlist
*/

/*!
    \page qtgraphs_migration_guide.html
    \title Qt Graphs Migration from Qt DataVisualization

    The API and functionality between Qt DataVisualization and Qt Graphs has been kept mostly
    unchanged. However, there are some differences that need to be taken into consideration
    when migrating your application from Qt DataVisualization to Qt Graphs:

    \list
        \li QML import statement
        \li CMake module inclusion
        \li qmake module inclusion
        \li Widget application creation
        \li Requirement to use OpenGL backend
        \li Removed APIs
        \li Changed APIs
    \endlist

    \section1 QML Import Statement

    The import statement in Qt DataVisualization:
    \code
    import QtDataVisualization
    \endcode
    has to be changed to:
    \code
    import QtGraphs
    \endcode
    for Qt Graphs.

    \section1 CMake Module Inclusion

    The inclusion in Qt DataVisualization:
    \code
    find_package(Qt6 REQUIRED COMPONENTS DataVisualization)
    target_link_libraries(mytarget PRIVATE Qt6::DataVisualization)
    \endcode
    has to be changed to:
    \code
    find_package(Qt6 REQUIRED COMPONENTS Graphs)
    target_link_libraries(mytarget PRIVATE Qt6::Graphs)
    \endcode
    for Qt Graphs.

    \section1 Qmake Module Inclusion

    The inclusion in Qt DataVisualization:
    \code
    QT += datavisualization
    \endcode
    has to be changed to:
    \code
    QT += graphs
    \endcode
    for Qt Graphs.

    \section1 Widget Application Creation

    Instead of creating your widget application like this:
    \code
    QGuiApplication app(argc, argv);
    Q3DScatter scatter;
    scatter.setFlags(scatter.flags() ^ Qt::FramelessWindowHint);
    \endcode
    you should create it like this:
    \code
    QApplication app(argc, argv);
    Q3DScatter scatter;
    scatter.setMinimumSize(QSize(256, 256));
    scatter.setResizeMode(QQuickWidget::SizeRootObjectToView);
    \endcode

    \section1 Requirement to Use OpenGL Backend

    Adding the forced OpenGL backend usage:
    \code
    qputenv("QSG_RHI_BACKEND", "opengl");
    \endcode
    is no longer required. Qt Graphs uses Qt Quick 3D for rendering, and as such supports the
    rendering backends native to the platform it is being run on.

    \section1 Removed APIs

    \list
        \li hasContext
        \li shadowsSupported
     \endlist

    \section1 Changed APIs

    \list
        \li optimizationHints
        \li renderingMode
    \endlist

    \section2 optimizationHints

    \c OptimizationLegacy is now the mode that was \c OptimizationDefault in QtDataVisualization.
    \c OptimizationDefault uses instancing, and should be used for all targets that support it.

    \section2 renderingMode

    \c RenderDirectToBackground_NoClear has been removed, as it was already obsolete in
    QtDataVisualization in Qt 6.
*/

/*!
 * \fn QSurfaceFormat qDefaultSurfaceFormat(bool antialias)
 * \relates QAbstract3DGraph
 *
 * This convenience function can be used to create a custom surface format suitable for use by
 * Qt Graphs graphs.
 *
 * The \a antialias parameter specifies whether or not antialiasing is activated.
 *
 * Give the surface format returned by this function to the graph constructor (C++) or set
 * it as the window format for QQuickView (QML) before calling \c show() on it.
 *
 * For example, disable antialiasing on C++ application:
 *
 * \code
 * #include <QtGraphs/qutils.h>
 *
 * // ...
 *
 * Q3DBars *graph = new Q3DBars(qDefaultSurfaceFormat(false));
 * \endcode
 *
 * For example, enable antialiasing for direct rendering modes on QML application:
 *
 * \code
 * #include <QtGraphs/qutils.h>
 *
 * // ...
 *
 * QQuickView viewer;
 * viewer.setFormat(qDefaultSurfaceFormat(true));
 * \endcode
 *
 * \note Antialiasing is not supported in OpenGL ES2 environments.
 */
