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

/*!
    \page robotarm-example.html
    \ingroup gstutorials

    \title Creating a C++ Backend for a \QDS Application

    \brief Illustrates how to create an application in \QDS and add a backend
    in Qt Creator.

    \image robotarm-example.webp

    The \e Robotarm example demonstrates adding a C++ backend to a 3D project created in \QDS.

    The example itself consists of an interactive industrial robot arm in a Qt Quick 3D scene.
    The 2D UI to control the robot arm is implemented using Qt Quick Controls.

    You can open the example from the \uicontrol Examples tab on the \uicontrol Welcome page
    in \QDS.

    To complete this tutorial, you need experience in using \QDS and Qt Creator as well as knowledge
    in C++ programming.

    \section1 The Designer-Developer Workflow

    This section describes the high-level steps for creating the robot arm example.

    \section2 Creating the User Interface

    First, the designer creates the user interface in \QDS.

    \list 1
      \li Create a new 3D project.
      \li Import the 3D asset (RoboticArm).
      \li Create the following custom components:
        \list
          \li NodeIndicator: This component consists of a rounded rectangle and a label. It is used
          to indicate which joint in the robotic arm is currently active. Located in the 3D
          scene, it follows the movement of the 3D model.
          \li LabeledSlider: This component is a slider with a label. It is connected to the
          rotation of the different robot arm parts so that you can use it to control the rotation
          of those parts.
          \li Toggle: This component consists of a switch and a label. It is used in two places; to
          toggle dark mode and to toggle the claw of the robotic arm.
          \li Backend: This serves as a mock backend for the \QDS application. Once you open,
          compile, and run the application in Qt Creator, it uses the C++ backend.
      \endlist
      \li Add the 3D model and lights to the \uicontrol View3D scene.
        \image robotarm-3d-view.png
      \li Create the 2D UI controls:
        \list
          \li Four buttons for preset positions. As you can see from the \uicontrol Connections tab
          in the \uicontrol Connections view, each button changes the rotation of the robot arm
          parts.
          \image robotarm-button-connections.png
          \li Four sliders for controlling the robot arm parts individually. The \uicontrol Backend
          component uses these sliders to control the robot arm position.
          \li A switch to control the robot arm claw. This is also done through the
          \uicontrol Backend component.
          \li A switch to toggle dark mode of the application.
          \li A label to display the status of the robot arm through the \uicontrol Backend
          component.
        \endlist
    \endlist

    \section2 Creating the C++ Backend

    With the frontend and user interface created, it is time to create the C++ backend.

    To open the project in Qt Creator:
    \list 1
      \li Open \c CMakeLists.txt located in the root folder of the robot arm example. This is the
      CMake project file.
      \li In Qt Creator, add the empty C++ backend classes in the \c backend folder.
      \li Ensure that the \c CMakeLists.txt file in the \c backend folder has the classes in it. It
      should look something like this:
      \code
      find_package(Qt6 REQUIRED COMPONENTS Gui)

      qt_add_qml_module(backend
          URI Backend
          VERSION 1.0
          SOURCES
              animatedparam.cpp
              animatedparam.h
              backend.cpp
              backend.h
      )

      target_link_libraries(backend PRIVATE Qt6::Gui)
     \endcode
      \li Add the backend logic to the created backend classes.
    \endlist

*/
