├── .github └── workflows │ ├── appimage.yml │ └── doc.yml ├── .gitignore ├── .gitmodules ├── CHANGELOG.md ├── CMakeLists.txt ├── Readme.md ├── appimage-amd64.yml ├── assets ├── 128-apps-pprzgcs.png ├── 16-apps-pprzgcs.png ├── 32-apps-pprzgcs.png ├── 48-apps-pprzgcs.png ├── 64-apps-pprzgcs.png ├── CMakeLists.txt ├── org.paparazzi.pprzgcs.appdata.xml.in ├── org.paparazzi.pprzgcs.desktop └── pprzgcs.svg ├── build.sh ├── build_deb.sh ├── data ├── default_layout.xml ├── default_style.qss ├── fp_editor_layout.xml ├── gvf_layout.xml ├── pictures │ ├── aircraft_icons │ │ ├── fixedwing.svg │ │ ├── flyingwing.svg │ │ ├── quadrotor_x.svg │ │ ├── rotorcraft.svg │ │ └── rover.svg │ ├── chat.svg │ ├── checklist.svg │ ├── flight_plan.svg │ ├── gps.svg │ ├── gvf.svg │ ├── icon.svg │ ├── link.png │ ├── link_nok.svg │ ├── link_ok.svg │ ├── map_layers_hover.svg │ ├── map_layers_normal.svg │ ├── map_layers_pressed.svg │ ├── map_thumbnails │ │ ├── DroneRestrict.png │ │ ├── Google Hybrid.png │ │ ├── Google.png │ │ ├── Hiking.png │ │ ├── ICAO.png │ │ ├── OpenStreetMap.png │ │ └── default.png │ ├── nav.svg │ ├── pfd.svg │ ├── plotter.svg │ └── settings.svg └── tile_sources.xml ├── debian ├── Readme.md ├── changelog ├── compat ├── control └── rules ├── docs ├── Makefile ├── requirements.txt └── source │ ├── conf.py │ ├── developer_guide │ ├── aircraft.rst │ ├── concepts.rst │ ├── how_to_build.rst │ ├── index_developer.rst │ ├── map.rst │ ├── pprzapplication.rst │ ├── settings.rst │ └── widgets.rst │ ├── icon.svg │ ├── index.rst │ └── user_guide │ ├── PFD.png │ ├── commands.png │ ├── flightplan_blocks.png │ ├── flightplan_details.png │ ├── index_user.rst │ ├── layout.rst │ ├── layout_example.png │ ├── map2d_configure.png │ ├── map_tile_sources.rst │ ├── plotter.png │ ├── settings.png │ ├── strip.png │ └── widgets.rst ├── examples ├── cpp │ ├── CMakeLists.txt │ ├── Readme.md │ └── greeter_client.cpp └── grpc_example.py ├── pprzgcs_version.sh ├── protos ├── CMakeLists.txt └── pprzgcs.proto ├── resources ├── pictures │ ├── agl.svg │ ├── airspeed.svg │ ├── bat_catastrophic.svg │ ├── bat_critic.svg │ ├── bat_low.svg │ ├── bat_ok.svg │ ├── block_time.svg │ ├── cursor_circle_black.svg │ ├── cursor_path_black.svg │ ├── cursor_waypoint_black.svg │ ├── displayed.svg │ ├── flight_time.svg │ ├── gps_nok.svg │ ├── gps_ok.svg │ ├── green_led.svg │ ├── ground_speed.svg │ ├── hidden.svg │ ├── icon.svg │ ├── imu_nok.svg │ ├── imu_ok.svg │ ├── link.png │ ├── link_nok.svg │ ├── link_ok.svg │ ├── link_warning.svg │ ├── lock.svg │ ├── lock_dark.svg │ ├── lock_warning.svg │ ├── map_layers_hover.svg │ ├── map_layers_normal.svg │ ├── map_layers_pressed.svg │ ├── msl.svg │ ├── no_ac.svg │ ├── pfd_aircraft_pitch.svg │ ├── pfd_aircraft_pitch_rotorcraft.svg │ ├── pfd_aircraft_roll.svg │ ├── pfd_aircraft_roll_rotorcraft.svg │ ├── pfd_aircraft_yaw.svg │ ├── pfd_aircraft_yaw_rotorcraft.svg │ ├── pfd_rover_pitch.svg │ ├── pfd_rover_roll.svg │ ├── pfd_rover_yaw.svg │ ├── rc_nok.svg │ ├── rc_ok.svg │ ├── red_led.svg │ ├── settings.svg │ ├── stage_time.svg │ ├── throttle_killed.svg │ ├── throttle_on.svg │ ├── unlocked.svg │ ├── vertical_speed.svg │ ├── wind_rose.svg │ ├── windsock.svg │ └── windsock_no_wind.svg └── ressources.qrc ├── screenshots └── screenshot.png └── src ├── CMakeLists.txt ├── PprzApplication.cpp ├── PprzApplication.h ├── PprzToolbox.cpp ├── PprzToolbox.h ├── app_settings.cpp ├── app_settings.h ├── common ├── CMakeLists.txt ├── aircraft.cpp ├── aircraft.h ├── aircraft_status.cpp ├── aircraft_status.h ├── aircraft_watcher.cpp ├── aircraft_watcher.h ├── airframe.cpp ├── airframe.h ├── block.cpp ├── block.h ├── configurable.h ├── flightplan.cpp ├── flightplan.h ├── gcs_utils.cpp ├── gcs_utils.h ├── pprzpalette.cpp ├── pprzpalette.h ├── sector.cpp ├── sector.h ├── setting.cpp ├── setting.h ├── setting_menu.cpp ├── setting_menu.h ├── tuple_helpers.h ├── waypoint.cpp └── waypoint.h ├── configurator.cpp ├── configurator.h ├── geometry ├── CMakeLists.txt ├── point2dlatlon.cpp ├── point2dlatlon.h ├── point2dpseudomercator.cpp ├── point2dpseudomercator.h ├── point2dtile.cpp └── point2dtile.h ├── globalconfig.cpp ├── globalconfig.h ├── main.cpp ├── pprzmain.cpp ├── pprzmain.h ├── pprzmain.ui ├── tools ├── AircraftManager.cpp ├── AircraftManager.h ├── CMakeLists.txt ├── coordinatestransform.cpp ├── coordinatestransform.h ├── dispatcher_ui.cpp ├── dispatcher_ui.h ├── grpcconnector.cpp ├── grpcconnector.h ├── pprz_dispatcher.cpp ├── pprz_dispatcher.h ├── speaker.cpp ├── speaker.h ├── srtm_manager.cpp ├── srtm_manager.h ├── units.cpp ├── units.h ├── watcher.cpp └── watcher.h ├── uisignals.h ├── utils.h └── widgets ├── CMakeLists.txt ├── ac_selector.cpp ├── ac_selector.h ├── basics ├── CMakeLists.txt ├── chatbubble.cpp ├── chatbubble.h ├── chatbubble.ui ├── colorbar.cpp ├── colorbar.h ├── colorlabel.cpp ├── colorlabel.h ├── double_slider.cpp ├── double_slider.h ├── flowlayout.cpp ├── flowlayout.h ├── graphlabel.cpp ├── graphlabel.h ├── graphwidget.cpp ├── graphwidget.h ├── imagebutton.cpp ├── imagebutton.h ├── jaugelabel.cpp ├── jaugelabel.h ├── lock_button.cpp ├── lock_button.h ├── mbpushbutton.cpp ├── mbpushbutton.h ├── switch.cpp └── switch.h ├── chat.cpp ├── chat.h ├── chat.ui ├── checklist.cpp ├── checklist.h ├── checklist.ui ├── commands.cpp ├── commands.h ├── flightplan_viewerv2.cpp ├── flightplan_viewerv2.h ├── flightplaneditor.cpp ├── flightplaneditor.h ├── flightplaneditor.ui ├── gps_classic_viewer.cpp ├── gps_classic_viewer.h ├── gvf_viewer.cpp ├── gvf_viewer.h ├── layer_combo.cpp ├── layer_combo.h ├── link_status.cpp ├── link_status.h ├── listcontainer.cpp ├── listcontainer.h ├── map ├── CMakeLists.txt ├── acitemmanager.cpp ├── acitemmanager.h ├── fpedit_statemachines │ ├── CMakeLists.txt │ ├── circleitem_sm.cpp │ ├── circleitem_sm.h │ ├── item_edit_state_machine.cpp │ ├── item_edit_state_machine.h │ ├── pathitem_sm.cpp │ ├── pathitem_sm.h │ ├── waypointitem_sm.cpp │ └── waypointitem_sm.h ├── graphics_objects │ ├── CMakeLists.txt │ ├── graphics_aircraft.cpp │ ├── graphics_aircraft.h │ ├── graphics_circle.cpp │ ├── graphics_circle.h │ ├── graphics_group.cpp │ ├── graphics_group.h │ ├── graphics_icon.cpp │ ├── graphics_icon.h │ ├── graphics_intruder.cpp │ ├── graphics_intruder.h │ ├── graphics_line.cpp │ ├── graphics_line.h │ ├── graphics_object.cpp │ ├── graphics_object.h │ ├── graphics_point.cpp │ ├── graphics_point.h │ ├── graphics_quiver.cpp │ ├── graphics_quiver.h │ ├── graphics_text.cpp │ └── graphics_text.h ├── gvf_trajectories │ ├── CMakeLists.txt │ ├── gvf_traj_3D_ellipse.cpp │ ├── gvf_traj_3D_ellipse.h │ ├── gvf_traj_3D_lissajous.cpp │ ├── gvf_traj_3D_lissajous.h │ ├── gvf_traj_bezier.cpp │ ├── gvf_traj_bezier.h │ ├── gvf_traj_ellipse.cpp │ ├── gvf_traj_ellipse.h │ ├── gvf_traj_line.cpp │ ├── gvf_traj_line.h │ ├── gvf_traj_sin.cpp │ ├── gvf_traj_sin.h │ ├── gvf_traj_trefoil.cpp │ ├── gvf_traj_trefoil.h │ ├── gvf_trajectory.cpp │ └── gvf_trajectory.h ├── map2d.cpp ├── map2d.h ├── map_items │ ├── CMakeLists.txt │ ├── aircraft_item.cpp │ ├── aircraft_item.h │ ├── arrow_item.cpp │ ├── arrow_item.h │ ├── circle_item.cpp │ ├── circle_item.h │ ├── intruder_item.cpp │ ├── intruder_item.h │ ├── map_item.cpp │ ├── map_item.h │ ├── path_item.cpp │ ├── path_item.h │ ├── quiver_item.cpp │ ├── quiver_item.h │ ├── waypoint_item.cpp │ └── waypoint_item.h ├── maplayercontrol.cpp ├── maplayercontrol.h ├── mapscene.cpp ├── mapscene.h ├── maputils.cpp ├── maputils.h ├── mapwidget.cpp ├── mapwidget.h ├── papget.cpp ├── papget.h ├── papgetconfig.cpp ├── papgetconfig.h ├── tileitem.cpp ├── tileitem.h ├── tileprovider.cpp ├── tileprovider.h ├── tileproviderconfig.cpp ├── tileproviderconfig.h ├── waypointeditor.cpp └── waypointeditor.h ├── mini_strip.cpp ├── mini_strip.h ├── pfd.cpp ├── pfd.h ├── plotter.cpp ├── plotter.h ├── pprzmap.cpp ├── pprzmap.h ├── pprzmap.ui ├── settings_viewer.cpp ├── settings_viewer.h ├── stackcontainer.cpp ├── stackcontainer.h ├── strip.cpp ├── strip.h ├── widget_utils.cpp ├── widget_utils.h ├── windindicator.cpp └── windindicator.h /.github/workflows/doc.yml: -------------------------------------------------------------------------------- 1 | name: Doc 2 | 3 | on: 4 | push: 5 | branches: 6 | - 'master' 7 | paths: 8 | - 'docs/**' 9 | 10 | jobs: 11 | # This workflow contains a single job called "build" 12 | build: 13 | # The type of runner that the job will run on 14 | runs-on: ubuntu-latest 15 | 16 | # Steps represent a sequence of tasks that will be executed as part of the job 17 | steps: 18 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it 19 | - name: checkout 20 | uses: actions/checkout@v2 21 | 22 | - name: build sphinx doc 23 | uses: ammaraskar/sphinx-action@master 24 | with: 25 | build-command: "make html" 26 | docs-folder: "docs" 27 | 28 | - name: Check files 29 | run: ls docs/build 30 | 31 | 32 | - name: Commit documentation changes 33 | run: | 34 | git clone https://github.com/$GITHUB_REPOSITORY.git --branch gh-pages --single-branch gh-pages 35 | rm -r gh-pages/* 36 | cp -r docs/build/html/* gh-pages/ 37 | cd gh-pages 38 | git config --local user.email "action@github.com" 39 | git config --local user.name "GitHub Action" 40 | git add . 41 | git commit -m "Update PprzGCS doc" -a || true 42 | # The above command will fail if no changes were present, so we ignore 43 | # the return code. 44 | - name: Push changes 45 | uses: ad-m/github-push-action@master 46 | with: 47 | branch: gh-pages 48 | directory: gh-pages 49 | github_token: ${{ secrets.GITHUB_TOKEN }} 50 | #force: true 51 | 52 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # This file is used to ignore files which are generated 2 | # ---------------------------------------------------------------------------- 3 | 4 | *~ 5 | *.autosave 6 | *.a 7 | *.core 8 | *.moc 9 | *.o 10 | *.obj 11 | *.orig 12 | *.rej 13 | *.so 14 | *.so.* 15 | *_pch.h.cpp 16 | *_resource.rc 17 | *.qm 18 | .#* 19 | *.*# 20 | core 21 | !core/ 22 | tags 23 | .DS_Store 24 | .directory 25 | *.debug 26 | Makefile* 27 | *.prl 28 | *.app 29 | moc_*.cpp 30 | ui_*.h 31 | qrc_*.cpp 32 | Thumbs.db 33 | *.res 34 | *.rc 35 | /.qmake.cache 36 | /.qmake.stash 37 | 38 | # qtcreator generated files 39 | *.pro.user* 40 | 41 | # xemacs temporary files 42 | *.flc 43 | 44 | # Vim temporary files 45 | .*.swp 46 | 47 | # Visual Studio generated files 48 | *.ib_pdb_index 49 | *.idb 50 | *.ilk 51 | *.pdb 52 | *.sln 53 | *.suo 54 | *.vcproj 55 | *vcproj.*.*.user 56 | *.ncb 57 | *.sdf 58 | *.opensdf 59 | *.vcxproj 60 | *vcxproj.* 61 | 62 | # MinGW generated files 63 | *.Debug 64 | *.Release 65 | 66 | # Python byte code 67 | *.pyc 68 | 69 | # Binaries 70 | # -------- 71 | *.dll 72 | *.exe 73 | 74 | # build directory for manual build 75 | build/ 76 | 77 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "ext/pprzlinkQt"] 2 | path = ext/pprzlinkQt 3 | url = https://github.com/Fabien-B/pprzlinkQt.git 4 | [submodule "ext/IvyQt"] 5 | path = ext/IvyQt 6 | url = https://gitlab.com/ivybus/IvyQt.git 7 | -------------------------------------------------------------------------------- /assets/128-apps-pprzgcs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paparazzi/PprzGCS/df4be571069813f7619b92959421e756378c9432/assets/128-apps-pprzgcs.png -------------------------------------------------------------------------------- /assets/16-apps-pprzgcs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paparazzi/PprzGCS/df4be571069813f7619b92959421e756378c9432/assets/16-apps-pprzgcs.png -------------------------------------------------------------------------------- /assets/32-apps-pprzgcs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paparazzi/PprzGCS/df4be571069813f7619b92959421e756378c9432/assets/32-apps-pprzgcs.png -------------------------------------------------------------------------------- /assets/48-apps-pprzgcs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paparazzi/PprzGCS/df4be571069813f7619b92959421e756378c9432/assets/48-apps-pprzgcs.png -------------------------------------------------------------------------------- /assets/64-apps-pprzgcs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paparazzi/PprzGCS/df4be571069813f7619b92959421e756378c9432/assets/64-apps-pprzgcs.png -------------------------------------------------------------------------------- /assets/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | find_package(ECM 1.0.0 REQUIRED NO_MODULE) 3 | set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) 4 | include(ECMInstallIcons) 5 | include(KDEInstallDirs) 6 | 7 | ecm_install_icons( 8 | ICONS 9 | 16-apps-pprzgcs.png 10 | 32-apps-pprzgcs.png 11 | 48-apps-pprzgcs.png 12 | 64-apps-pprzgcs.png 13 | 128-apps-pprzgcs.png 14 | 15 | THEME 16 | hicolor 17 | 18 | DESTINATION 19 | ${KDE_INSTALL_ICONDIR} 20 | ) 21 | 22 | configure_file( 23 | org.paparazzi.pprzgcs.appdata.xml.in 24 | org.paparazzi.pprzgcs.appdata.xml 25 | ) 26 | 27 | install(FILES ${CMAKE_BINARY_DIR}/assets/org.paparazzi.pprzgcs.appdata.xml 28 | DESTINATION ${KDE_INSTALL_METAINFODIR} 29 | ) 30 | 31 | 32 | install(FILES pprzgcs.svg 33 | DESTINATION ${KDE_INSTALL_FULL_ICONDIR}/hicolor/scalable/apps 34 | ) 35 | 36 | 37 | install(FILES "org.paparazzi.pprzgcs.desktop" 38 | DESTINATION ${KDE_INSTALL_APPDIR} 39 | ) 40 | 41 | -------------------------------------------------------------------------------- /assets/org.paparazzi.pprzgcs.appdata.xml.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.paparazzi.pprzgcs 4 | CC0-1.0 5 | PprzGCS 6 | Paparazzi UAV GCS 7 | org.paparazzi.pprzgcs.desktop 8 | 9 | Paparazzi UAV 10 | 11 | pprzgcs 12 | 13 | 14 | 15 | 16 | 17 | GPL-3.0-or-later 18 | 19 |

PprzGCS is a ground control station for Paparazzi UAV.

20 |
21 | 22 | Science 23 | 24 | https://docs.paparazziuav.org/PprzGCS/ 25 | https://github.com/paparazzi/PprzGCS/issues 26 | https://docs.paparazziuav.org/PprzGCS/ 27 |
28 | 29 | -------------------------------------------------------------------------------- /assets/org.paparazzi.pprzgcs.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=PprzGCS 3 | Comment=GCS for PaparazziUAV 4 | Exec=/usr/bin/pprzgcs 5 | Terminal=false 6 | Type=Application 7 | Icon=pprzgcs 8 | StartupNotify=true 9 | Categories=Robotics;Science;Qt; 10 | 11 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | WD="${WD:-$(pwd)}" 4 | build_libs="${1:-false}" 5 | 6 | # try getting 2nd argument, then the first one 7 | build_app="${2:-$1}" 8 | build_app="${build_app:-false}" 9 | 10 | install_prefix="${install_prefix:-$WD/build/install}" 11 | 12 | echo "install_prefix set to $install_prefix." 13 | 14 | # exit on error 15 | set -e 16 | 17 | #export QT_DIR="/path/to/Qt/5.12.5/gcc_64/lib/cmake/Qt5" 18 | 19 | export MAKEFLAGS=-j$(nproc) 20 | 21 | if [ $build_libs = "libs" ] 22 | then 23 | ivyqt_src=$WD/ext/IvyQt 24 | ivyqt_build=$WD/build/ext/IvyQt 25 | 26 | pprzlinkqt_src=$WD/ext/pprzlinkQt/ 27 | pprzlinkqt_build=$WD/build/ext/pprzlinkQt 28 | 29 | cmake -S $ivyqt_src -B $ivyqt_build -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$install_prefix 30 | cmake --build $ivyqt_build 31 | cmake --install $ivyqt_build 32 | 33 | cmake -S $pprzlinkqt_src -B $pprzlinkqt_build -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$install_prefix 34 | cmake --build $pprzlinkqt_build 35 | cmake --install $pprzlinkqt_build 36 | fi 37 | 38 | if [ $build_app = "app" ] 39 | then 40 | cmake -S . -B $WD/build/pprzgcs -DCMAKE_INSTALL_PREFIX="$install_prefix" -DDEFAULT_APP_DATA_PATH="$WD/data" -DCMAKE_BUILD_TYPE=RelWithDebInfo 41 | cmake --build $WD/build/pprzgcs 42 | fi 43 | 44 | -------------------------------------------------------------------------------- /build_deb.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -z ${1} ]; 4 | then 5 | echo "Usage: ./build_deb.sh " 6 | exit 1 7 | fi 8 | 9 | version=$(echo $1 | sed 's/.*v\(.*\)/\1/g') 10 | 11 | 12 | WD="${WD:-$(pwd)}" 13 | 14 | install_prefix=$WD/build/install 15 | 16 | debian=$WD/misc/debian/pprzgcs 17 | deb_install_prefix=$debian/usr/local 18 | 19 | 20 | echo "install_prefix set to $install_prefix." 21 | 22 | # exit on error 23 | set -e 24 | 25 | 26 | ivyqt_src=$WD/ext/IvyQt 27 | ivyqt_build=$WD/build/IvyQt 28 | 29 | pprzlinkqt_src=$WD/ext/pprzlinkQt/ 30 | pprzlinkqt_build=$WD/build/ext/pprzlinkQt 31 | 32 | cmake -S $ivyqt_src -B $ivyqt_build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$install_prefix 33 | cmake --build $ivyqt_build 34 | cmake --install $ivyqt_build 35 | 36 | cmake -S $pprzlinkqt_src -B $pprzlinkqt_build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$install_prefix 37 | cmake --build $pprzlinkqt_build 38 | cmake --install $pprzlinkqt_build 39 | 40 | cmake -S . -B $WD/build/pprzgcs -DCMAKE_INSTALL_PREFIX=$deb_install_prefix -DCMAKE_PREFIX_PATH=$install_prefix -DCMAKE_BUILD_TYPE=Release -DPPRZGCS_VERSION=$(git describe --tags) 41 | cmake --build $WD/build/pprzgcs 42 | cmake --install $WD/build/pprzgcs 43 | 44 | strip --strip-unneeded $deb_install_prefix/bin/pprzgcs 45 | 46 | # Add changelog 47 | cp $WD/CHANGELOG.md changelog.Debian 48 | gzip changelog.Debian 49 | mv changelog.Debian.gz $deb_install_prefix/share/doc/pprzgcs/ 50 | 51 | # set correct version 52 | echo "Setting version to $version" 53 | sed -i "s/__VERSION__/$version/g" $debian/DEBIAN/control 54 | 55 | # set correct size 56 | size=$(du -s $debian/usr/ | cut -f 1) 57 | echo "Setting installed size to $size" 58 | sed -i "s/__SIZE__/$size/g" $debian/DEBIAN/control 59 | 60 | dpkg-deb --root-owner-group --build misc/debian/pprzgcs 61 | 62 | 63 | -------------------------------------------------------------------------------- /data/default_layout.xml: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /data/default_style.qss: -------------------------------------------------------------------------------- 1 | 2 | /* Buttons on the map */ 3 | LockButton { 4 | qproperty-color_idle: #b0252525; 5 | qproperty-color_hover: #b0404040; 6 | qproperty-color_pressed: #b0000000; 7 | qproperty-size: 80; 8 | } 9 | 10 | WindIndicator { 11 | qproperty-arrow_color: #ff0000; 12 | qproperty-pen_color: #000000; 13 | qproperty-background_color: #6046d0ff; 14 | qproperty-size: 100; 15 | } 16 | 17 | MiniStrip { 18 | qproperty-size: 30; 19 | } 20 | 21 | MapWidget { 22 | qproperty-color_background: #404040; 23 | qproperty-ac_arrow_size: 50; 24 | qproperty-show_hidden_waypoints: false; 25 | } 26 | 27 | -------------------------------------------------------------------------------- /data/fp_editor_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /data/gvf_layout.xml: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /data/pictures/link.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paparazzi/PprzGCS/df4be571069813f7619b92959421e756378c9432/data/pictures/link.png -------------------------------------------------------------------------------- /data/pictures/map_thumbnails/DroneRestrict.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paparazzi/PprzGCS/df4be571069813f7619b92959421e756378c9432/data/pictures/map_thumbnails/DroneRestrict.png -------------------------------------------------------------------------------- /data/pictures/map_thumbnails/Google Hybrid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paparazzi/PprzGCS/df4be571069813f7619b92959421e756378c9432/data/pictures/map_thumbnails/Google Hybrid.png -------------------------------------------------------------------------------- /data/pictures/map_thumbnails/Google.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paparazzi/PprzGCS/df4be571069813f7619b92959421e756378c9432/data/pictures/map_thumbnails/Google.png -------------------------------------------------------------------------------- /data/pictures/map_thumbnails/Hiking.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paparazzi/PprzGCS/df4be571069813f7619b92959421e756378c9432/data/pictures/map_thumbnails/Hiking.png -------------------------------------------------------------------------------- /data/pictures/map_thumbnails/ICAO.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paparazzi/PprzGCS/df4be571069813f7619b92959421e756378c9432/data/pictures/map_thumbnails/ICAO.png -------------------------------------------------------------------------------- /data/pictures/map_thumbnails/OpenStreetMap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paparazzi/PprzGCS/df4be571069813f7619b92959421e756378c9432/data/pictures/map_thumbnails/OpenStreetMap.png -------------------------------------------------------------------------------- /data/pictures/map_thumbnails/default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paparazzi/PprzGCS/df4be571069813f7619b92959421e756378c9432/data/pictures/map_thumbnails/default.png -------------------------------------------------------------------------------- /data/pictures/nav.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /data/pictures/settings.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 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 | -------------------------------------------------------------------------------- /data/tile_sources.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 16 | 23 | 30 | 38 | 46 | 53 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /debian/Readme.md: -------------------------------------------------------------------------------- 1 | 2 | How to make a new release 3 | ========================= 4 | 5 | 1. Update `debian/changelog` with: `$ dch`. Makes sure the author name and email matches one of your gpg keys (get the list with `gpg --list-secret-keys`). 6 | 2. Update `pprzgcs_version.sh` with the correct DEFAULT_VERSION. (TODO: use version from debian/changelog) 7 | 3. Commit your changes and tag the commit. 8 | 4. `git ls-files --recurse-submodules | tar -cvf pprzgcs.tar -T -` 9 | 5. `mkdir ../pprzgcs_release && src=$(pwd) && cd ../pprzgcs_release` 10 | 6. `tar -xvf "$src/pprzgcs.tar"` 11 | 7. Install dependencies: `sudo apt install ivy-qt-dev` 12 | 8. `debuild -S` 13 | 9. `dput ppa:paparazzi-uav/ppa ` 14 | 10. Update changelog minor version number and distribution name in the release directory to build for other distributions, and restart from step 8. Do not commit those changes. 15 | 16 | 17 | 18 | Building with pbuilder-dist 19 | =========================== 20 | pbuilder-dist is a wrapper that makes it easy to use pbuilder with many 21 | different versions of Ubuntu and/or Debian. 22 | 23 | Setup pbuilder-dist 24 | ------------------- 25 | - Create the pbuilder environment for your desired distributions and architectures, e.g.: 26 | 27 | pbuilder-dist focal create 28 | 29 | - To update a pbuilder environment: 30 | 31 | pbuilder-dist focal update --override-config --release-only 32 | 33 | Build the debian package 34 | ------------------------ 35 | See the respective package directory on how the get the source. 36 | 37 | - First build a source package if not already available: 38 | 39 | cd package 40 | debuild -S 41 | 42 | - Build the binary package from the source package: 43 | 44 | pbuilder-dist focal build ../.dsc 45 | 46 | You will find the finished packages in ~/pbuilder/ 47 | 48 | 49 | -------------------------------------------------------------------------------- /debian/compat: -------------------------------------------------------------------------------- 1 | 9 2 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: pprzgcs 2 | Maintainer: Fabien Bonneval 3 | Section: devel 4 | Priority: optional 5 | Build-Depends: debhelper (>= 8.0.0), cmake, git, libsqlite3-dev, libzip-dev, qtbase5-dev, libqt5svg5-dev, libqt5texttospeech5-dev, libproj-dev, mesa-common-dev, libglu1-mesa-dev, libxml2-dev, ivy-qt-dev, extra-cmake-modules 6 | Standards-Version: 4.0.0 7 | Homepage: https://paparazzi.github.io/PprzGCS/ 8 | Vcs-Git: https://github.com/paparazzi/PprzGCS 9 | Rules-Requires-Root: binary-targets 10 | 11 | 12 | Package: pprzgcs 13 | Architecture: any 14 | Section: devel 15 | Priority: optional 16 | Depends: ${shlibs:Depends}, ${misc:Depends}, ivy-qt, appmenu-gtk3-module 17 | Homepage: https://paparazzi.github.io/PprzGCS/ 18 | Description: Ground Control Station for PaparazziUAV 19 | 20 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # -*- makefile -*- 3 | 4 | pprzlinkqt_src=ext/pprzlinkQt/ 5 | pprzlinkqt_build=build/ext/pprzlinkQt 6 | install_prefix=build/install 7 | #export MAKEFLAGS=-j$(nproc) 8 | prefix = /usr 9 | DESTDIR=debian/pprzgcs 10 | 11 | %: 12 | dh $@ 13 | 14 | override_dh_auto_configure: 15 | cmake -S $(pprzlinkqt_src) -B $(pprzlinkqt_build) -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$(install_prefix) 16 | cmake --build $(pprzlinkqt_build) 17 | cmake --install $(pprzlinkqt_build) 18 | cmake -S . -B build/pprzgcs -DCMAKE_INSTALL_PREFIX=$(DESTDIR)$(prefix) -DCMAKE_PREFIX_PATH=$(install_prefix) -DCMAKE_BUILD_TYPE=RelWithDebInfo 19 | 20 | override_dh_auto_build: 21 | 22 | cmake --build build/pprzgcs 23 | 24 | override_dh_auto_install: 25 | cmake --install build/pprzgcs 26 | 27 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | SPHINXPROJ = PprzGCS 8 | SOURCEDIR = source 9 | BUILDDIR = build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | 22 | -------------------------------------------------------------------------------- /docs/requirements.txt: -------------------------------------------------------------------------------- 1 | sphinx_rtd_theme 2 | 3 | -------------------------------------------------------------------------------- /docs/source/developer_guide/aircraft.rst: -------------------------------------------------------------------------------- 1 | .. developer_guide aircraft 2 | 3 | Aircrafts 4 | ========= 5 | 6 | AircraftManager 7 | --------------- 8 | 9 | Aircrafts are uniquely identified by their ID. 10 | 11 | Get an aircraft with the ``Aircraft* AircraftManager::getAircraft(QString id)`` method. 12 | 13 | .. _aircraft: 14 | 15 | Aircraft 16 | -------- 17 | 18 | The ``Aircraft`` class is central in PprzGCS. It holds all the data relative to a given aircraft: 19 | 20 | + AC ID 21 | + name 22 | + flight plan 23 | + airframe 24 | + settings 25 | + position 26 | + status 27 | + config 28 | 29 | 30 | 31 | Status 32 | ------ 33 | 34 | Get the status with the ``Aircraft::getStatus()`` method. 35 | 36 | The ``AircraftStatus`` class store some of the most used aircraft's messages: 37 | 38 | + AP_STATUS 39 | + NAV_STATUS 40 | + CIRCLE_STATUS 41 | + SEGMENT_STATUS 42 | + ENGINE_STATUS 43 | + DL_VALUES 44 | + TELEMETRY_STATUS 45 | + FLY_BY_WIRE 46 | + FLIGHT_PARAM 47 | + SVSINFO 48 | 49 | Use the ``getMessage(QString name)`` method to get the last received message. 50 | 51 | This class also emit a signal for each of the above messages when a new one is received. 52 | 53 | 54 | -------------------------------------------------------------------------------- /docs/source/developer_guide/concepts.rst: -------------------------------------------------------------------------------- 1 | .. developer_guide concepts 2 | 3 | Arborescence 4 | ============ 5 | 6 | Root directory 7 | -------------- 8 | 9 | The essential directories are these ones : 10 | 11 | .. code-block:: 12 | 13 | PprzGCS 14 | ├── data 15 | ├── docs 16 | ├── ext 17 | ├── resources 18 | └── src 19 | 20 | + ``data`` holds all customizable resources. It will usually be installed in ``/usr/share/pprzgcs``. 21 | Files in this directory are overridden by files with similar path in user's directory ``$HOME/.local/share/pprzgcs`` (See AppDataLocation `QStandardPaths `_). 22 | + ``docs`` contains the documentation consultable at `https://docs.paparazziuav.org/PprzGCS/ `_. 23 | + ``ext`` contains external dependencies 24 | + ``resources`` holds static resources. PprzGCS must be rebuild when changes are made in this directory. 25 | + ``src`` contains all the source code. 26 | 27 | 28 | Sources 29 | ------- 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /docs/source/developer_guide/index_developer.rst: -------------------------------------------------------------------------------- 1 | .. developer_guide index_developer 2 | 3 | Developer guide 4 | =============== 5 | 6 | This part will guide you through the code of PprzGCS, and some desing choices that have been made. 7 | 8 | .. toctree:: 9 | :maxdepth: 1 10 | 11 | how_to_build 12 | concepts 13 | pprzapplication 14 | settings 15 | aircraft 16 | widgets 17 | map 18 | 19 | -------------------------------------------------------------------------------- /docs/source/developer_guide/map.rst: -------------------------------------------------------------------------------- 1 | .. developer_guide widgets 2 | 3 | Map 4 | === 5 | 6 | The map is by far the most complex widget. Let's see how is works! 7 | 8 | Map2D 9 | ----- 10 | 11 | First, let focus on the map itself, without all the elements that populates it. 12 | 13 | The *Map2D* widget inherits *QGraphicsView*, and holds a *MapScene* (that inherits *QGraphicsScene*). 14 | 15 | This widget only support maps in the Pseudo-Mercator projected coordinate system, a.k.a *EPSG:3857*. There are plans to support other coordinate systems in the future. 16 | 17 | See ``_ to learn how this kind of map works. 18 | 19 | In our case, the QGraphicsScene coordinates are directly related to the tiles coordinates, multiplied by the size of the tiles. 20 | 21 | 22 | .. admonition:: Example 23 | 24 | + At zoom level 0, the map's bottom right coordinate is (256, 256), 25 | + At zoom level 1, it's (512, 512), 26 | + At zoom level 1, it's (1024, 1024), 27 | + ... 28 | 29 | See ``src/widgets/map/maputils.cpp`` for some helper functions. 30 | 31 | There is a *TileProvider*, associated with each map layers. New tile providers can be added in the ``tile_sources.xml`` file. 32 | 33 | Tiles are fist opened from local cache directory, or downloaded from the net is not present locally. Remove local cache to get the latest tiles. 34 | 35 | 36 | Downloading tile can take a few seconds, or can fail. Before a tile is downloaded succesfully, it is recreated by assembling its 4 child tiles (at zoom n+1), or by scaling up its parent's tile. 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /docs/source/developer_guide/pprzapplication.rst: -------------------------------------------------------------------------------- 1 | .. developer_guide pprzapplication 2 | 3 | PprzApplication 4 | =============== 5 | 6 | ``PprzApplication`` subclass ``QApplication`` to add two attributes: the toolbox and the main window. 7 | 8 | There should be only one instance of ``PprzApplication``. 9 | 10 | Get the PprzApplication instance from anywhere with the ``pprzApp()`` function. 11 | 12 | 13 | Toolbox 14 | ------- 15 | 16 | The toolbox holds these tools: 17 | 18 | + **AircraftManager**: manage the list of aircrafts 19 | + **SRTMManager**: holds STRM data (ground elevation data) 20 | + **PprzDispatcher**: Handle Ivy communication 21 | + **CoordinatesTransform**: Use PROJ to convert coordinates across different coordinates reference systems 22 | + **Units**: Manage units conversions 23 | + **DispatcherUi**: propagate specific events across all the application 24 | + **Speaker**: Handles text to speech. 25 | 26 | 27 | Get the tools from the toolbox getters, e.g. : ``pprzApp()->toolbox()->aircraftManager()`` 28 | 29 | 30 | PprzMain 31 | -------- 32 | 33 | PprzMain is the main window of the application. 34 | 35 | -------------------------------------------------------------------------------- /docs/source/developer_guide/settings.rst: -------------------------------------------------------------------------------- 1 | 2 | Settings and config 3 | =================== 4 | 5 | Settings and global configurations are both global and accessible from anywhere in the application. They differ only by the intended lifespan. 6 | 7 | Settings 8 | -------- 9 | 10 | Settings are stored in a file and are saved accross sessions. 11 | 12 | It uses the QSettings interface, with a file named ``settings.conf`` at the standard path ``QStandardPaths::AppDataLocation``. 13 | Thus, it's most probably corresponds to ``$HOME/.local/share/pprzgcs/settings.conf``. 14 | 15 | 16 | Use the helper function ``QSettings getAppSettings()`` from ``gcs_utils.h`` to start using them. 17 | 18 | 19 | GlobalConfig 20 | ------------ 21 | 22 | The global config is a singleton holding a key/value configuration. 23 | 24 | It lives only for the current session. 25 | 26 | Use the helper function ``GlobalConfig* appConfig()`` from ``gcs_utils.h`` to start using it. 27 | 28 | Like the settings, it uses QVariant type to hold its items. 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /docs/source/index.rst: -------------------------------------------------------------------------------- 1 | .. PprzGCS documentation master file, created by 2 | sphinx-quickstart on Mon Mar 22 16:44:25 2021. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | PprzGCS's documentation 7 | ======================= 8 | 9 | .. image:: icon.svg 10 | :align: center 11 | :width: 50% 12 | 13 | 14 | **PprzGCS** is a new GCS for `Paparazzi UAV `_ using C++ and Qt. 15 | It aims at replacing the old one which use deprecated OCaml libraries. 16 | 17 | .. toctree:: 18 | :maxdepth: 2 19 | 20 | developer_guide/index_developer 21 | user_guide/index_user 22 | 23 | 24 | Indices and tables 25 | ================== 26 | 27 | * :ref:`genindex` 28 | * :ref:`modindex` 29 | * :ref:`search` 30 | -------------------------------------------------------------------------------- /docs/source/user_guide/PFD.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paparazzi/PprzGCS/df4be571069813f7619b92959421e756378c9432/docs/source/user_guide/PFD.png -------------------------------------------------------------------------------- /docs/source/user_guide/commands.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paparazzi/PprzGCS/df4be571069813f7619b92959421e756378c9432/docs/source/user_guide/commands.png -------------------------------------------------------------------------------- /docs/source/user_guide/flightplan_blocks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paparazzi/PprzGCS/df4be571069813f7619b92959421e756378c9432/docs/source/user_guide/flightplan_blocks.png -------------------------------------------------------------------------------- /docs/source/user_guide/flightplan_details.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paparazzi/PprzGCS/df4be571069813f7619b92959421e756378c9432/docs/source/user_guide/flightplan_details.png -------------------------------------------------------------------------------- /docs/source/user_guide/index_user.rst: -------------------------------------------------------------------------------- 1 | .. developer_guide index_developer 2 | 3 | User guide 4 | =============== 5 | 6 | What can you do with PprzGCS ? 7 | How to configure it the way you want ? 8 | Learn everything here! 9 | 10 | .. toctree:: 11 | :maxdepth: 2 12 | 13 | layout 14 | widgets 15 | map_tile_sources 16 | 17 | -------------------------------------------------------------------------------- /docs/source/user_guide/layout_example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paparazzi/PprzGCS/df4be571069813f7619b92959421e756378c9432/docs/source/user_guide/layout_example.png -------------------------------------------------------------------------------- /docs/source/user_guide/map2d_configure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paparazzi/PprzGCS/df4be571069813f7619b92959421e756378c9432/docs/source/user_guide/map2d_configure.png -------------------------------------------------------------------------------- /docs/source/user_guide/plotter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paparazzi/PprzGCS/df4be571069813f7619b92959421e756378c9432/docs/source/user_guide/plotter.png -------------------------------------------------------------------------------- /docs/source/user_guide/settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paparazzi/PprzGCS/df4be571069813f7619b92959421e756378c9432/docs/source/user_guide/settings.png -------------------------------------------------------------------------------- /docs/source/user_guide/strip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paparazzi/PprzGCS/df4be571069813f7619b92959421e756378c9432/docs/source/user_guide/strip.png -------------------------------------------------------------------------------- /examples/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | 3 | project(TestGRPC) 4 | 5 | # find protobuf 6 | find_package(Protobuf CONFIG REQUIRED) 7 | message(STATUS "Using protobuf ${Protobuf_VERSION}") 8 | 9 | # Find gRPC installation 10 | # Looks for gRPCConfig.cmake file installed by gRPC's cmake installation. 11 | find_package(gRPC CONFIG REQUIRED) 12 | message(STATUS "Using gRPC ${gRPC_VERSION}") 13 | 14 | find_package(PprzgcsGRCP CONFIG REQUIRED) 15 | 16 | add_executable(greeter_client "greeter_client.cpp") 17 | 18 | target_link_libraries(greeter_client 19 | PprzgcsGRCP 20 | gRPC::grpc++_reflection 21 | gRPC::grpc++ 22 | protobuf::libprotobuf 23 | ) 24 | 25 | -------------------------------------------------------------------------------- /examples/cpp/Readme.md: -------------------------------------------------------------------------------- 1 | # C++ gRPC example 2 | 3 | ## prerequisites 4 | 5 | - Install [gRPC](https://grpc.io/docs/languages/cpp/quickstart/) 6 | - Install PprzGCS with `cmake --install` 7 | 8 | ## Build 9 | 10 | - `mkdir build && cd build` 11 | - Configure with `cmake .. -D CMAKE_PREFIX_PATH=";"` 12 | - `make` 13 | 14 | 15 | -------------------------------------------------------------------------------- /examples/cpp/greeter_client.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "pprzgcs.grpc.pb.h" 6 | 7 | using grpc::Channel; 8 | using grpc::ClientContext; 9 | using grpc::Status; 10 | using pprzgcs::GCSService; 11 | using pprzgcs::CenterOnRequest; 12 | using pprzgcs::CenterOnResponse; 13 | 14 | class PprzgcsClient { 15 | public: 16 | PprzgcsClient(std::shared_ptr channel): stub_(GCSService::NewStub(channel)) {} 17 | 18 | // Assembles the client's payload, sends it and presents the response back 19 | // from the server. 20 | void CenterOn(double lat, double lon) { 21 | // Data we are sending to the server. 22 | CenterOnRequest request; 23 | auto coor = request.mutable_coordinate(); 24 | coor->set_crs("WGS84"); 25 | coor->set_lat(lat); 26 | coor->set_lon(lon); 27 | //request.mutable_aircraft()->set_ac_name("JP"); 28 | 29 | // Container for the data we expect from the server. 30 | CenterOnResponse reply; 31 | 32 | // Context for the client. It could be used to convey extra information to 33 | // the server and/or tweak certain RPC behaviors. 34 | ClientContext context; 35 | 36 | // The actual RPC. 37 | Status status = stub_->CenterOn(&context, request, &reply); 38 | 39 | // Act upon its status. 40 | if (status.ok()) { 41 | std::cout << reply.status() << " " << reply.msg() << std::endl; 42 | } else { 43 | std::cout << status.error_code() << ": " << status.error_message()<< std::endl; 44 | } 45 | } 46 | 47 | private: 48 | std::unique_ptr stub_; 49 | }; 50 | 51 | int main(int argc, char** argv) { 52 | std::string target_str = "localhost:50051"; 53 | 54 | PprzgcsClient greeter(grpc::CreateChannel(target_str, grpc::InsecureChannelCredentials())); 55 | 56 | greeter.CenterOn(43.5, 1.2); 57 | 58 | return 0; 59 | } 60 | 61 | -------------------------------------------------------------------------------- /pprzgcs_version.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | 4 | DEFAULT_VERSION="v1.0.13" 5 | 6 | if test -d .git -o -f .git 7 | then 8 | GIT_VN=$(git describe --tags) 9 | if echo "$GIT_VN" | grep -Eq "^v[0-9].*" 10 | then 11 | VN="$GIT_VN" 12 | else 13 | VN="$DEFAULT_VERSION"-none-g"$GIT_VN" 14 | fi 15 | else 16 | VN="$DEFAULT_VERSION" 17 | fi 18 | 19 | echo $VN 20 | 21 | 22 | -------------------------------------------------------------------------------- /resources/pictures/ground_speed.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /resources/pictures/link.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paparazzi/PprzGCS/df4be571069813f7619b92959421e756378c9432/resources/pictures/link.png -------------------------------------------------------------------------------- /resources/pictures/lock.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 20 | 22 | image/svg+xml 23 | 25 | 26 | 27 | 28 | 30 | 50 | 52 | lock 53 | 54 | 58 | 59 | -------------------------------------------------------------------------------- /resources/pictures/lock_dark.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 20 | 22 | image/svg+xml 23 | 25 | 26 | 27 | 28 | 30 | 50 | 52 | lock 53 | 54 | 58 | 59 | -------------------------------------------------------------------------------- /resources/pictures/lock_warning.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 20 | 22 | image/svg+xml 23 | 25 | 26 | 27 | 28 | 30 | 50 | 52 | lock 53 | 54 | 58 | 59 | -------------------------------------------------------------------------------- /resources/pictures/red_led.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 40 | 42 | 43 | 45 | image/svg+xml 46 | 48 | 49 | 50 | 51 | 52 | 57 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /resources/pictures/unlocked.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 20 | 22 | image/svg+xml 23 | 25 | 26 | 27 | 28 | 30 | 50 | 52 | lock 53 | 54 | 58 | 59 | -------------------------------------------------------------------------------- /screenshots/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paparazzi/PprzGCS/df4be571069813f7619b92959421e756378c9432/screenshots/screenshot.png -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | set(SOURCE 3 | ${SOURCE} 4 | ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp 5 | ${CMAKE_CURRENT_SOURCE_DIR}/PprzToolbox.cpp 6 | ${CMAKE_CURRENT_SOURCE_DIR}/PprzApplication.cpp 7 | ${CMAKE_CURRENT_SOURCE_DIR}/app_settings.cpp 8 | ${CMAKE_CURRENT_SOURCE_DIR}/configurator.cpp 9 | ${CMAKE_CURRENT_SOURCE_DIR}/pprzmain.cpp 10 | ${CMAKE_CURRENT_SOURCE_DIR}/globalconfig.cpp 11 | ) 12 | 13 | set(INC_DIRS ${INC_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}) 14 | 15 | add_subdirectory(widgets) 16 | add_subdirectory(common) 17 | add_subdirectory(geometry) 18 | add_subdirectory(tools) 19 | 20 | set(SOURCE ${SOURCE} PARENT_SCOPE) 21 | set(INC_DIRS ${INC_DIRS} PARENT_SCOPE) 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/PprzApplication.cpp: -------------------------------------------------------------------------------- 1 | #include "PprzApplication.h" 2 | #include "PprzToolbox.h" 3 | #include "pprzmain.h" 4 | #include "point2dlatlon.h" 5 | 6 | PprzApplication* PprzApplication::_app = nullptr; 7 | 8 | PprzApplication::PprzApplication(int &argc, char **argv, int flags) : QApplication(argc, argv, flags) 9 | { 10 | _app = this; 11 | _toolbox = new PprzToolbox(this); 12 | //_toolbox->setChildToolboxes(); 13 | _mainWindow = new PprzMain(); 14 | qRegisterMetaType(); 15 | } 16 | 17 | /// @brief Returns the PprzApplication object singleton. 18 | PprzApplication* pprzApp(void) 19 | { 20 | return PprzApplication::_app; 21 | } 22 | 23 | void PprzApplication::init() { 24 | _toolbox->setChildToolboxes(); 25 | } 26 | 27 | void PprzApplication::_shutdown() { 28 | delete _toolbox; 29 | delete _mainWindow; 30 | } 31 | 32 | PprzApplication::~PprzApplication() { 33 | _app = nullptr; 34 | } 35 | -------------------------------------------------------------------------------- /src/PprzApplication.h: -------------------------------------------------------------------------------- 1 | #ifndef PPRZAPPLICATION_H 2 | #define PPRZAPPLICATION_H 3 | 4 | #include 5 | 6 | class PprzToolbox; 7 | class PprzMain; 8 | 9 | class PprzApplication : public QApplication 10 | { 11 | Q_OBJECT 12 | public: 13 | explicit PprzApplication(int &argc, char **argv, int = ApplicationFlags); 14 | ~PprzApplication(); 15 | 16 | static PprzApplication* _app; 17 | void init(); 18 | 19 | void _shutdown(); 20 | 21 | PprzToolbox* toolbox() {return _toolbox;} 22 | PprzMain* mainWindow() {return _mainWindow;} 23 | 24 | private: 25 | PprzToolbox* _toolbox = nullptr; 26 | PprzMain* _mainWindow = nullptr; 27 | 28 | signals: 29 | 30 | }; 31 | 32 | /// @brief Returns the PprzApplication object singleton. 33 | PprzApplication* pprzApp(void); 34 | 35 | #endif // PPRZAPPLICATION_H 36 | -------------------------------------------------------------------------------- /src/PprzToolbox.cpp: -------------------------------------------------------------------------------- 1 | #include "PprzToolbox.h" 2 | #include "AircraftManager.h" 3 | #include "srtm_manager.h" 4 | #include "pprz_dispatcher.h" 5 | #include "coordinatestransform.h" 6 | #include "units.h" 7 | #include "dispatcher_ui.h" 8 | #include "watcher.h" 9 | 10 | #if defined(SPEECH_ENABLED) 11 | #include "speaker.h" 12 | #endif 13 | #if GRPC_ENABLED 14 | #include "grpcconnector.h" 15 | #endif 16 | 17 | PprzToolbox::PprzToolbox(PprzApplication* app) 18 | { 19 | _aircraftManager = new AircraftManager (app, this); 20 | _srtmManager = new SRTMManager (app, this); 21 | _pprzDispatcher = new PprzDispatcher (app, this); 22 | _coordinatesTransform = new CoordinatesTransform(app, this); 23 | _units = new Units (app, this); 24 | _dispatcherUi = new DispatcherUi (app, this); 25 | _watcher = new Watcher (app, this); 26 | #if defined(SPEECH_ENABLED) 27 | _speaker = new Speaker (app, this); 28 | #endif 29 | #if GRPC_ENABLED 30 | _connector = new GRPCConnector (app, this); 31 | #endif 32 | } 33 | 34 | void PprzToolbox::setChildToolboxes(void) { 35 | _aircraftManager->setToolbox(this); 36 | _srtmManager->setToolbox(this); 37 | _pprzDispatcher->setToolbox(this); 38 | _coordinatesTransform->setToolbox(this); 39 | _units->setToolbox(this); 40 | _dispatcherUi->setToolbox(this); 41 | _watcher->setToolbox(this); 42 | #if defined(SPEECH_ENABLED) 43 | _speaker->setToolbox(this); 44 | #endif 45 | #if GRPC_ENABLED 46 | _connector->setToolbox(this); 47 | #endif 48 | } 49 | 50 | 51 | PprzTool::PprzTool(PprzApplication* app, PprzToolbox* toolbox) : 52 | QObject(toolbox), 53 | _app(app), _toolbox(nullptr) 54 | { 55 | (void)toolbox; 56 | } 57 | 58 | void PprzTool::setToolbox(PprzToolbox* toolbox) 59 | { 60 | _toolbox = toolbox; 61 | } 62 | -------------------------------------------------------------------------------- /src/app_settings.h: -------------------------------------------------------------------------------- 1 | #ifndef CONFIGURE_H 2 | #define CONFIGURE_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | void set_app_settings(); 9 | 10 | class SettingsEditor : public QDialog 11 | { 12 | Q_OBJECT 13 | public: 14 | explicit SettingsEditor(bool standalone = false, QWidget *parent = nullptr); 15 | 16 | 17 | 18 | private: 19 | 20 | enum Type { 21 | STRING, 22 | INT, 23 | DOUBLE, 24 | PATH_DIR, 25 | PATH_FILE, 26 | STRING_COMBO, 27 | }; 28 | 29 | std::function addSetting(QString name, QString key, QWidget* w, QGridLayout* gl, int &row, Type type, QVariant data = QVariant()); 30 | 31 | QList> callbacks; 32 | 33 | }; 34 | 35 | #endif // CONFIGURE_H 36 | -------------------------------------------------------------------------------- /src/common/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | set(SOURCE 3 | ${SOURCE} 4 | ${CMAKE_CURRENT_SOURCE_DIR}/aircraft.cpp 5 | ${CMAKE_CURRENT_SOURCE_DIR}/waypoint.cpp 6 | ${CMAKE_CURRENT_SOURCE_DIR}/sector.cpp 7 | ${CMAKE_CURRENT_SOURCE_DIR}/block.cpp 8 | ${CMAKE_CURRENT_SOURCE_DIR}/flightplan.cpp 9 | ${CMAKE_CURRENT_SOURCE_DIR}/setting_menu.cpp 10 | ${CMAKE_CURRENT_SOURCE_DIR}/setting.cpp 11 | ${CMAKE_CURRENT_SOURCE_DIR}/airframe.cpp 12 | ${CMAKE_CURRENT_SOURCE_DIR}/aircraft_status.cpp 13 | ${CMAKE_CURRENT_SOURCE_DIR}/gcs_utils.cpp 14 | ${CMAKE_CURRENT_SOURCE_DIR}/pprzpalette.cpp 15 | ${CMAKE_CURRENT_SOURCE_DIR}/aircraft_watcher.cpp 16 | ) 17 | 18 | set(INC_DIRS ${INC_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}) 19 | 20 | set(SOURCE ${SOURCE} PARENT_SCOPE) 21 | set(INC_DIRS ${INC_DIRS} PARENT_SCOPE) 22 | -------------------------------------------------------------------------------- /src/common/aircraft.h: -------------------------------------------------------------------------------- 1 | #ifndef AIRCRAFT_H 2 | #define AIRCRAFT_H 3 | 4 | #include 5 | #include 6 | #include "flightplan.h" 7 | #include "setting_menu.h" 8 | #include "airframe.h" 9 | #include "point2dlatlon.h" 10 | #include "pprz_dispatcher.h" 11 | #include "aircraft_status.h" 12 | 13 | class ConfigData; 14 | 15 | class Aircraft: public QObject 16 | { 17 | Q_OBJECT 18 | public: 19 | Aircraft(ConfigData* config, QObject* parent=nullptr); 20 | QColor getColor(){return color;} 21 | QString getId(){return ac_id;} 22 | QString getIcon(){return icon;} 23 | QString name() {return _name;} 24 | FlightPlan* getFlightPlan() {return flight_plan;} 25 | //SettingMenu& getSettingMenu() {return setting_menu;} 26 | SettingMenu* getSettingMenu() {return setting_menu;} 27 | Airframe* getAirframe() {return airframe;} 28 | AircraftStatus* getStatus() {return status;} 29 | ConfigData* getConfig() {return config;} 30 | QList getChecklist() {return checklist;} 31 | void setConfig(ConfigData* c) {config = c;} 32 | 33 | Point2DLatLon getPosition() {return position;} 34 | void setPosition(Point2DLatLon pos) {position = pos;} 35 | 36 | void setSetting(Setting*, QString value); 37 | void setSetting(Setting*, float value); 38 | void setSetting(uint8_t setting_no, float value); 39 | 40 | bool isReal() {return real;} 41 | bool checklistFinished(); 42 | 43 | private: 44 | QString ac_id; 45 | QColor color; 46 | QString icon; 47 | QString _name; 48 | FlightPlan* flight_plan; 49 | SettingMenu* setting_menu; 50 | Airframe* airframe; 51 | ConfigData* config; 52 | QList checklist; 53 | 54 | Point2DLatLon position; 55 | 56 | AircraftStatus* status; 57 | 58 | // false if this is a "flight plan only" AC. Just to edit the flight plan. 59 | bool real; 60 | 61 | }; 62 | 63 | #endif // AIRCRAFT_H 64 | -------------------------------------------------------------------------------- /src/common/aircraft_status.h: -------------------------------------------------------------------------------- 1 | #ifndef AIRCRAFTSTATUS_H 2 | #define AIRCRAFTSTATUS_H 3 | 4 | #include 5 | #include 6 | #include "pprz_dispatcher.h" 7 | #include 8 | #include "aircraft_watcher.h" 9 | 10 | 11 | class AircraftStatus : public QObject 12 | { 13 | Q_OBJECT 14 | public: 15 | explicit AircraftStatus(QString ac_id, QObject *parent = nullptr); 16 | 17 | void updateMessage(pprzlink::Message msg); 18 | std::optional getMessage(QString name); 19 | QMap getTelemetryMessages() {return telemetry_messages;} 20 | 21 | AircraftWatcher* getWatcher() {return watcher;} 22 | 23 | signals: 24 | void flight_param(); 25 | void ap_status(); 26 | void nav_status(); 27 | void circle_status(); 28 | void segment_status(); 29 | void engine_status(); 30 | void waypoint_moved(); 31 | void dl_values(); 32 | void telemetry_status(); 33 | void fly_by_wire(); 34 | void svsinfo(); 35 | 36 | public slots: 37 | 38 | private: 39 | QString ac_id; 40 | 41 | QMap last_messages; 42 | QMap telemetry_messages; 43 | 44 | AircraftWatcher* watcher; 45 | }; 46 | 47 | #endif // AIRCRAFTSTATUS_H 48 | -------------------------------------------------------------------------------- /src/common/aircraft_watcher.cpp: -------------------------------------------------------------------------------- 1 | #include "aircraft_watcher.h" 2 | #include "AircraftManager.h" 3 | 4 | AircraftWatcher::AircraftWatcher(QString ac_id, QObject *parent) : QObject(parent), 5 | ac_id(ac_id) 6 | { 7 | } 8 | 9 | void AircraftWatcher::init() { 10 | auto airframe = pprzApp()->toolbox()->aircraftManager()->getAircraft(ac_id)->getAirframe(); 11 | auto lbl = airframe->getDefine("LOW_BAT_LEVEL"); 12 | auto cbl = airframe->getDefine("CRITIC_BAT_LEVEL"); 13 | auto ctbl = airframe->getDefine("CATASTROPHIC_BAT_LEVEL"); 14 | 15 | bat_low = lbl.has_value() ? lbl->value.toDouble() : 10.5; 16 | bat_critic = cbl.has_value() ? cbl->value.toDouble() : 10.; 17 | bat_catastrophic = ctbl.has_value() ? ctbl->value.toDouble() : 9.; 18 | } 19 | 20 | void AircraftWatcher::watch_bat(pprzlink::Message msg) { 21 | float bat; 22 | msg.getField("bat", bat); 23 | 24 | BatStatus bs; 25 | if(bat < bat_catastrophic) { 26 | bs = BatStatus::CATASTROPHIC; 27 | } else if(bat < bat_critic) { 28 | bs = BatStatus::CRITIC; 29 | } else if(bat < bat_low) { 30 | bs = BatStatus::LOW; 31 | } else { 32 | bs = BatStatus::OK; 33 | } 34 | 35 | emit bat_status(bs); 36 | } 37 | 38 | void AircraftWatcher::watch_links(pprzlink::Message msg) { 39 | QString link_id; 40 | float time_since_last_msg; 41 | msg.getField("link_id", link_id); 42 | msg.getField("time_since_last_msg", time_since_last_msg); 43 | link_times[link_id] = time_since_last_msg; 44 | 45 | int nb_link_losts = std::accumulate(link_times.begin(), link_times.end(), 0, 46 | [](int n, auto t){ 47 | if(t>5) { ++n; } 48 | return n; 49 | } 50 | ); 51 | 52 | LinkStatus status; 53 | if(nb_link_losts == 0) { 54 | status = LinkStatus::LINK_OK; 55 | } else if (nb_link_losts == link_times.size()) { 56 | status = LinkStatus::LINK_LOST; 57 | } else { 58 | status = LinkStatus::LINK_PARTIALY_LOST; 59 | } 60 | 61 | emit link_status(status); 62 | } 63 | -------------------------------------------------------------------------------- /src/common/aircraft_watcher.h: -------------------------------------------------------------------------------- 1 | #ifndef AIRCRAFTWATCHER_H 2 | #define AIRCRAFTWATCHER_H 3 | 4 | #include 5 | #include "pprz_dispatcher.h" 6 | 7 | class AircraftWatcher : public QObject 8 | { 9 | Q_OBJECT 10 | public: 11 | explicit AircraftWatcher(QString ac_id, QObject *parent = nullptr); 12 | void init(); 13 | 14 | void watch_bat(pprzlink::Message msg); 15 | void watch_links(pprzlink::Message msg); 16 | 17 | enum BatStatus{ 18 | OK, 19 | LOW, 20 | CRITIC, 21 | CATASTROPHIC, 22 | }; 23 | 24 | enum LinkStatus { 25 | LINK_OK, 26 | LINK_LOST, 27 | LINK_PARTIALY_LOST 28 | }; 29 | 30 | signals: 31 | void bat_status(BatStatus); 32 | void link_status(LinkStatus); 33 | 34 | private: 35 | 36 | 37 | QString ac_id; 38 | 39 | float bat_low; 40 | float bat_critic; 41 | float bat_catastrophic; 42 | 43 | QMap link_times; 44 | 45 | }; 46 | 47 | #endif // AIRCRAFTWATCHER_H 48 | -------------------------------------------------------------------------------- /src/common/airframe.h: -------------------------------------------------------------------------------- 1 | #ifndef AIRFRAME_H 2 | #define AIRFRAME_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | struct Param { 9 | QString name; 10 | QString unit; 11 | QString value; 12 | }; 13 | 14 | struct ChecklistItem { 15 | QString name; 16 | QString description; 17 | QString type; 18 | QString value; 19 | }; 20 | 21 | class Airframe: public QObject 22 | { 23 | Q_OBJECT 24 | public: 25 | 26 | Airframe(QDomDocument doc, QObject* parent=nullptr); 27 | 28 | QString getFirmware() {return firmware;} 29 | QString getIconName(); 30 | float getAltShiftPlus(); 31 | float getAltShiftPlusPlus(); 32 | float getAltShiftMinus(); 33 | std::optional getDefine(QString name, QString section=""); 34 | 35 | void saveSettings(QString filename); 36 | void setParams(QMap changed_params); 37 | QList getParams(); 38 | QList getChecklistItems(); 39 | 40 | private: 41 | QString name; 42 | QString firmware; 43 | 44 | QDomDocument doc; 45 | 46 | static constexpr float ALT_PLUS_FW = 10; 47 | static constexpr float ALT_MINUS_FW = -10; 48 | static constexpr float ALT_PLUS_PLUS_FW = 30; 49 | 50 | static constexpr float ALT_PLUS_RC = 1; 51 | static constexpr float ALT_MINUS_RC = -1; 52 | static constexpr float ALT_PLUS_PLUS_RC = 3; 53 | }; 54 | 55 | #endif // AIRFRAME_H 56 | -------------------------------------------------------------------------------- /src/common/block.cpp: -------------------------------------------------------------------------------- 1 | #include "block.h" 2 | #include 3 | #include 4 | #include 5 | 6 | Block::Block(QString name, uint8_t no) : 7 | name(name), no(no) 8 | { 9 | 10 | } 11 | 12 | Block::Block(QDomElement blk) { 13 | 14 | assert(blk.hasAttribute("name")); 15 | 16 | name = blk.attribute("name"); 17 | no = blk.attribute("no", "0").toUInt(); 18 | 19 | setIcon(blk.attribute("strip_icon", "")); 20 | setText(blk.attribute("strip_button", "")); 21 | setKey(blk.attribute("key", "")); 22 | setGroup(blk.attribute("group", "")); 23 | 24 | 25 | auto attr = blk.attributes(); 26 | for(int i=0; i < attr.count(); i++) { 27 | auto att = attr.item(i).toAttr(); 28 | attributes[att.name()] = att.value(); 29 | } 30 | 31 | parse_block_stages(blk); 32 | } 33 | 34 | void Block::parse_block_stages(QDomElement blk) { 35 | for(auto stel=blk.firstChildElement(); 36 | !stel.isNull(); 37 | stel = stel.nextSiblingElement()) { 38 | Stage stage; 39 | stage.no = 255; 40 | stage.instruction = stel.tagName(); 41 | 42 | auto attr = stel.attributes(); 43 | for(int i=0; i < attr.count(); i++) { 44 | auto att = attr.item(i).toAttr(); 45 | stage.attributes[att.name()] = att.value(); 46 | } 47 | 48 | stage.no = stel.attribute("no", "0").toUInt(); 49 | stages.push_back(stage); 50 | } 51 | } 52 | 53 | 54 | ostream& operator<<(ostream& os, const Block& bk) { 55 | 56 | os << "{" << bk.name.toStdString() << ", no: " << to_string(bk.no); 57 | 58 | if(bk.strip_icon != "") { 59 | os << " icon: " << bk.strip_icon.toStdString(); 60 | } 61 | 62 | if(bk.strip_button_txt != "") { 63 | os << " text: " << bk.strip_button_txt.toStdString(); 64 | } 65 | 66 | if(bk.key != "") { 67 | os << " key: " << bk.key.toStdString(); 68 | } 69 | 70 | if(bk.group != "") { 71 | os << " group: " << bk.group.toStdString(); 72 | } 73 | 74 | os << "}"; 75 | 76 | return os; 77 | } 78 | -------------------------------------------------------------------------------- /src/common/block.h: -------------------------------------------------------------------------------- 1 | #ifndef BLOCK_H 2 | #define BLOCK_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | using namespace std; 9 | 10 | struct Stage { 11 | QString instruction; 12 | map attributes; 13 | uint8_t no; 14 | }; 15 | 16 | class Block 17 | { 18 | public: 19 | Block(QDomElement blk); 20 | Block(QString name, uint8_t no); 21 | 22 | void setIcon(QString icon) {strip_icon = icon;} 23 | void setText(QString text) {strip_button_txt = text;} 24 | void setKey(QString key) {this->key = key;} 25 | void setGroup(QString group) {this->group = group;} 26 | 27 | QString getName() {return name;} 28 | uint8_t getNo() {return no;} 29 | QString getIcon() {return strip_icon;} 30 | QString getText() {return strip_button_txt ;} 31 | QString getKey() {return key;} 32 | QString getGroup() {return group;} 33 | QList& getStages() {return stages;} 34 | 35 | friend ostream& operator<<(ostream& os, const Block& wp); 36 | 37 | private: 38 | void parse_block_stages(QDomElement blk); 39 | 40 | QString name; 41 | uint8_t no; 42 | 43 | QString strip_icon; 44 | QString strip_button_txt; 45 | QString key; 46 | QString group; 47 | 48 | map attributes; 49 | 50 | QList stages; 51 | }; 52 | 53 | #endif // BLOCK_H 54 | -------------------------------------------------------------------------------- /src/common/configurable.h: -------------------------------------------------------------------------------- 1 | #ifndef CONFIGURABLEWIDGET_H 2 | #define CONFIGURABLEWIDGET_H 3 | 4 | #include 5 | 6 | class Configurable 7 | { 8 | public: 9 | virtual void configure(QDomElement) = 0; 10 | }; 11 | 12 | #endif // CONFIGURABLEWIDGET_H 13 | -------------------------------------------------------------------------------- /src/common/gcs_utils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "globalconfig.h" 7 | #include 8 | 9 | enum LogLevel { 10 | LOG_LOW, 11 | LOG_MID, 12 | LOG_HIGH, 13 | }; 14 | 15 | QString user_or_app_path(QString data_path); 16 | 17 | double parse_coordinate(QString str); 18 | 19 | double getFloatingField(pprzlink::Message &msg, const QString &field); 20 | 21 | QSettings getAppSettings(); 22 | GlobalConfig* appConfig(); 23 | 24 | bool verbose(); 25 | void setVerbose(bool v); 26 | bool speech(); 27 | void setSpeech(bool s); 28 | 29 | void logDebug(QString log_class, QString msg, LogLevel level = LogLevel::LOG_MID); 30 | QStringList getLayoutFiles(QString location); 31 | -------------------------------------------------------------------------------- /src/common/pprzpalette.cpp: -------------------------------------------------------------------------------- 1 | #include "pprzpalette.h" 2 | 3 | PprzPalette::PprzPalette() 4 | { 5 | 6 | } 7 | 8 | PprzPalette::PprzPalette(QColor color): main_color(color), main_brush(color) 9 | { 10 | makeVariants(); 11 | } 12 | 13 | 14 | PprzPalette::PprzPalette(QColor color, QBrush brush): main_color(color), main_brush(brush) 15 | { 16 | makeVariants(); 17 | } 18 | 19 | void PprzPalette::makeVariants() { 20 | 21 | variants.append(main_color); 22 | 23 | int h, s, v, a; 24 | main_color.getHsv(&h, &s, &v, &a); 25 | 26 | int v1 = qMin(static_cast(v/1.2), 255); 27 | QColor c1 = QColor(main_color); 28 | c1.setHsv(h, s, v1, a); 29 | variants.append(c1); 30 | 31 | int a2 = qMin(static_cast(a/2), 255); 32 | QColor c2 = QColor(main_color); 33 | c2.setHsv(h, s, v, a2); 34 | variants.append(c2); 35 | 36 | 37 | int s3 = static_cast(s/2); 38 | QColor c3 = QColor(main_color); 39 | //c3.setHsv(h, s3, v, a); 40 | c3.setHsv(h, s3, v, a2); 41 | variants.append(c3); 42 | } 43 | -------------------------------------------------------------------------------- /src/common/pprzpalette.h: -------------------------------------------------------------------------------- 1 | #ifndef PPRZPALETTE_H 2 | #define PPRZPALETTE_H 3 | 4 | #include 5 | #include 6 | 7 | class PprzPalette 8 | { 9 | public: 10 | PprzPalette(); 11 | PprzPalette(QColor color); 12 | PprzPalette(QColor color, QBrush brush); 13 | 14 | QColor getColor() {return main_color;} 15 | QBrush getBrush() {return main_brush;} 16 | bool isValid() {return main_color.isValid();} 17 | QList getVariants() {return variants;} 18 | QColor getVariant(int i) {return variants[i];} 19 | 20 | private: 21 | void makeVariants(); 22 | 23 | QColor main_color; 24 | QBrush main_brush; 25 | 26 | QList variants; 27 | }; 28 | 29 | #endif // PPRZPALETTE_H 30 | -------------------------------------------------------------------------------- /src/common/sector.cpp: -------------------------------------------------------------------------------- 1 | #include "sector.h" 2 | 3 | Sector::Sector(QList corners, QString name, QString color_str): 4 | name(name), corners(corners) 5 | { 6 | color = QColor(color_str); 7 | } 8 | -------------------------------------------------------------------------------- /src/common/sector.h: -------------------------------------------------------------------------------- 1 | #ifndef SECTOR_H 2 | #define SECTOR_H 3 | 4 | #include 5 | #include "waypoint.h" 6 | #include 7 | #include 8 | 9 | using namespace std; 10 | class Sector 11 | { 12 | public: 13 | Sector(QList corners, QString name, QString color); 14 | 15 | QString getName() {return name;} 16 | QList getCorners() {return corners;} 17 | QColor getColor(){return color;} 18 | 19 | 20 | private: 21 | QString name; 22 | QColor color; // override AC color 23 | QList corners; 24 | }; 25 | 26 | #endif // SECTOR_H 27 | -------------------------------------------------------------------------------- /src/common/setting_menu.h: -------------------------------------------------------------------------------- 1 | #ifndef SETTINGS_H 2 | #define SETTINGS_H 3 | 4 | #include 5 | #include "setting.h" 6 | #include 7 | #include 8 | 9 | using namespace std; 10 | 11 | class SettingMenu: public QObject 12 | { 13 | Q_OBJECT 14 | public: 15 | 16 | struct ButtonGroup { 17 | QString group_name; 18 | QList> buttons; 19 | }; 20 | 21 | SettingMenu(QDomDocument doc, QObject* parent); 22 | SettingMenu(QDomElement setel, uint8_t& setting_no, QObject* parent); 23 | 24 | QList getSettingMenus() {return setting_menus;} 25 | QList getSettings() {return settings;} 26 | QList getAllSettings(); 27 | QList> getButtonGroups(); 28 | 29 | QString getName() {return name;} 30 | 31 | private: 32 | void init(QDomElement setel, uint8_t& setting_no); 33 | 34 | QString name; 35 | QList setting_menus; 36 | QList settings; 37 | }; 38 | 39 | #endif // SETTINGS_H 40 | -------------------------------------------------------------------------------- /src/common/tuple_helpers.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | // helper template to get the index of a type in a tuple at compile time 6 | // See https://devblogs.microsoft.com/oldnewthing/20200629-00/?p=103910 7 | // usage: 8 | // constexpr std::size_t index = tuple_element_index_v>; // = 1 9 | 10 | 11 | template 12 | struct tuple_element_index_helper; 13 | 14 | template 15 | struct tuple_element_index_helper> 16 | { 17 | static constexpr std::size_t value = 0; 18 | }; 19 | 20 | template 21 | struct tuple_element_index_helper> 22 | { 23 | static constexpr std::size_t value = 0; 24 | using RestTuple = std::tuple; 25 | static_assert( 26 | tuple_element_index_helper::value == 27 | std::tuple_size_v, 28 | "type appears more than once in tuple"); 29 | }; 30 | 31 | template 32 | struct tuple_element_index_helper> 33 | { 34 | using RestTuple = std::tuple; 35 | static constexpr std::size_t value = 1 + 36 | tuple_element_index_helper::value; 37 | }; 38 | 39 | template 40 | struct tuple_element_index 41 | { 42 | static constexpr std::size_t value = 43 | tuple_element_index_helper::value; 44 | static_assert(value < std::tuple_size_v, 45 | "type does not appear in tuple"); 46 | }; 47 | 48 | template 49 | inline constexpr std::size_t tuple_element_index_v 50 | = tuple_element_index::value; 51 | -------------------------------------------------------------------------------- /src/common/waypoint.h: -------------------------------------------------------------------------------- 1 | #ifndef WAYPOINT_H 2 | #define WAYPOINT_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | class Point2DLatLon; 12 | class FlightPlan; 13 | 14 | class Waypoint: public QObject 15 | { 16 | Q_OBJECT 17 | public: 18 | 19 | enum WpFrame { 20 | WGS84, 21 | UTM, 22 | LTP 23 | }; 24 | 25 | Waypoint(Waypoint* original, QObject* parent=nullptr); 26 | Waypoint(QString name, uint8_t id, Point2DLatLon pos, double alt, QObject* parent=nullptr); 27 | Waypoint(QDomElement wp, uint8_t wp_id, Waypoint* orig, double defaultAlt, double ground_alt, WpFrame frame_type, QObject* parent=nullptr); 28 | 29 | uint8_t getId() const {return id;} 30 | double getLat() const; 31 | double getLon() const; 32 | void setLat (double lat); 33 | void setLon(double lon); 34 | void setRelative(WpFrame frame, double dx, double dy, Waypoint* wp=nullptr); 35 | void getRelative(WpFrame frame, double &dx, double &dy, Waypoint* wp=nullptr); 36 | 37 | void setAlt(double alt) {this->alt = alt;} 38 | double getAlt() const {return alt;} 39 | WpFrame getType() const {return type;} 40 | QString getName() const {return name;} 41 | void setName(QString new_name); 42 | Waypoint* getOrigin() {return origin;} 43 | void setOrigin(Waypoint* wp) {origin = wp;} 44 | QMap& getXmlAttributes() { return xml_attibutes;} 45 | FlightPlan* getFlightPlan() {return flight_plan;} 46 | 47 | friend std::ostream& operator<<(std::ostream& os, const Waypoint& wp); 48 | 49 | private: 50 | 51 | void affectFlightPlan(); 52 | 53 | FlightPlan* flight_plan; 54 | 55 | WpFrame type; 56 | 57 | uint8_t id; 58 | 59 | double lat; 60 | double lon; 61 | 62 | Waypoint* origin; 63 | 64 | double alt; 65 | 66 | QString name; 67 | 68 | QMap xml_attibutes; 69 | }; 70 | 71 | 72 | #endif // WAYPOINT_H 73 | -------------------------------------------------------------------------------- /src/configurator.h: -------------------------------------------------------------------------------- 1 | #ifndef LAYOUT_BUILDER_H 2 | #define LAYOUT_BUILDER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include "pprzmain.h" 8 | 9 | #define DECLARE_LAYOUT_EXCEPT(a) class a : public layout_exception {\ 10 | public:\ 11 | explicit a(const std::string &arg) :\ 12 | layout_exception(arg) {}\ 13 | }; 14 | 15 | 16 | class layout_exception : public std::runtime_error { 17 | public: 18 | layout_exception(const std::string &arg) : runtime_error(arg){} 19 | }; 20 | 21 | DECLARE_LAYOUT_EXCEPT(invalid_widget_name) 22 | DECLARE_LAYOUT_EXCEPT(invalid_tag) 23 | DECLARE_LAYOUT_EXCEPT(file_error) 24 | DECLARE_LAYOUT_EXCEPT(invalid_node) 25 | DECLARE_LAYOUT_EXCEPT(unknown_widget) 26 | 27 | PprzMain* configure(QString filename); 28 | QWidget* rec_layout_build(QDomNode &node, QSplitter* parent, int* size); 29 | 30 | 31 | #endif // LAYOUT_BUILDER_H 32 | -------------------------------------------------------------------------------- /src/geometry/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | set(SOURCE 3 | ${SOURCE} 4 | ${CMAKE_CURRENT_SOURCE_DIR}/point2dlatlon.cpp 5 | ${CMAKE_CURRENT_SOURCE_DIR}/point2dtile.cpp 6 | ${CMAKE_CURRENT_SOURCE_DIR}/point2dpseudomercator.cpp 7 | ) 8 | 9 | set(INC_DIRS ${INC_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}) 10 | 11 | set(SOURCE ${SOURCE} PARENT_SCOPE) 12 | set(INC_DIRS ${INC_DIRS} PARENT_SCOPE) 13 | -------------------------------------------------------------------------------- /src/geometry/point2dlatlon.cpp: -------------------------------------------------------------------------------- 1 | #include "point2dlatlon.h" 2 | #include "math.h" 3 | 4 | Point2DLatLon::Point2DLatLon() : latp(0), lonp(0) 5 | { 6 | } 7 | 8 | Point2DLatLon::Point2DLatLon(double lat, double lon) { 9 | setLat(lat); 10 | setLon(lon); 11 | } 12 | 13 | //Point2DLatLon::Point2DLatLon(Point2DTile pt) { 14 | // double lon = pt.x() / static_cast(1 << pt.zoom()) * 360.0 - 180; 15 | // double n = M_PI - 2.0 * M_PI * pt.y() / static_cast(1 << pt.zoom()); 16 | // double lat = 180.0 / M_PI * atan(0.5 * (exp(n) - exp(-n))); 17 | // setLat(lat); 18 | // setLon(lon); 19 | //} 20 | 21 | Point2DLatLon::Point2DLatLon(Waypoint* wp) { 22 | latp = wp->getLat(); 23 | lonp = wp->getLon(); 24 | } 25 | 26 | 27 | QString Point2DLatLon::toString(bool sexagesimal) { 28 | if(sexagesimal) { 29 | auto sexformat = [](double nb) { 30 | int deg = static_cast(nb); 31 | int min = static_cast((nb - deg) * 60); 32 | int sec = static_cast((((nb - deg) * 60) - min)*60); 33 | QString txt = QString("%1").arg(deg, 3, 10, QChar(' ')) + "° " + QString("%1").arg(min, 2, 10, QChar('0')) + "' " + QString("%1").arg(sec, 2, 10, QChar('0')) + "\""; 34 | return txt; 35 | }; 36 | 37 | QString txtLat = sexformat(abs(latp)); 38 | QString txtLon = sexformat(abs(lonp)); 39 | 40 | QString latGeo = latp > 0 ? "N" : "S"; 41 | QString lonGeo = lonp > 0 ? "E" : "W"; 42 | 43 | QString txt = txtLat + latGeo + " " + txtLon + lonGeo; 44 | return txt; 45 | } else { 46 | // Why 6 digits ? Its smaller than a person, and bigger than a waldo: https://xkcd.com/2170/ 47 | QString txt = QString("%1").arg(latp, 10, 'f', 6, QChar(' ')) + "," + QString("%1").arg(lonp, 11, 'f', 6, QChar(' ')); 48 | return txt; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/geometry/point2dlatlon.h: -------------------------------------------------------------------------------- 1 | #ifndef POINT2DLATLON_H 2 | #define POINT2DLATLON_H 3 | 4 | #include "waypoint.h" 5 | #include 6 | 7 | class Point2DTile; 8 | 9 | class Point2DLatLon 10 | { 11 | public: 12 | Point2DLatLon(); 13 | Point2DLatLon(double lat, double lon); 14 | //Point2DLatLon(Point2DTile pt); 15 | Point2DLatLon(Waypoint* wp); 16 | 17 | double lat() {return latp;} 18 | double lon() {return lonp;} 19 | void setLat(double lat) {latp = std::clamp(lat, -90., 90.);} 20 | void setLon(double lon) {lonp = std::clamp(lon, -180., 180.);} 21 | 22 | QString toString(bool sexagesimal=false); 23 | 24 | private: 25 | double latp; 26 | double lonp; 27 | }; 28 | 29 | Q_DECLARE_METATYPE(Point2DLatLon) 30 | 31 | #endif // POINT2DLATLON_H 32 | -------------------------------------------------------------------------------- /src/geometry/point2dpseudomercator.cpp: -------------------------------------------------------------------------------- 1 | #include "point2dpseudomercator.h" 2 | #include "point2dtile.h" 3 | 4 | constexpr double EXTENT = 20037508.342789244; 5 | 6 | const QString Point2DPseudoMercator::EPSG = "EPSG:3857"; 7 | //EPSG:900913 8 | 9 | Point2DPseudoMercator::Point2DPseudoMercator(): _x(0), _y(0) 10 | { 11 | } 12 | 13 | Point2DPseudoMercator::Point2DPseudoMercator(double x, double y): _x(x), _y(y) 14 | { 15 | } 16 | 17 | Point2DPseudoMercator::Point2DPseudoMercator(Point2DTile pt) { 18 | _x = (2*pt.x()/(1< 5 | #include 6 | 7 | class Point2DTile; 8 | 9 | class Point2DPseudoMercator 10 | { 11 | public: 12 | Point2DPseudoMercator(); 13 | Point2DPseudoMercator(double _x, double _y); 14 | Point2DPseudoMercator(Point2DTile); 15 | 16 | double x() const { return _x; } 17 | double y() const { return _y; } 18 | 19 | Point2DPseudoMercator operator-(const Point2DPseudoMercator& other) const; 20 | Point2DPseudoMercator operator+(const Point2DPseudoMercator& other) const; 21 | Point2DPseudoMercator operator/(double d) const; 22 | Point2DPseudoMercator operator*(double d) const; 23 | 24 | 25 | 26 | static QRectF getBounds(); 27 | 28 | 29 | Point2DTile toTile(int zoom); 30 | 31 | static const QString EPSG; 32 | private: 33 | //unit: meters 34 | double _x; 35 | double _y; 36 | }; 37 | 38 | #endif // POINT2DPSEUDOMERCATOR_H 39 | -------------------------------------------------------------------------------- /src/geometry/point2dtile.cpp: -------------------------------------------------------------------------------- 1 | #include "point2dtile.h" 2 | #include "point2dlatlon.h" 3 | #include "math.h" 4 | 5 | Point2DTile::Point2DTile(double x, double y, int zoom) : 6 | xp(x), yp(y), zoomp(zoom) 7 | { 8 | } 9 | 10 | Point2DTile::Point2DTile(Point2DLatLon latLon, int zoom): 11 | zoomp(zoom) 12 | { 13 | double tileX = (latLon.lon() + 180.0) / 360.0 * (1 << zoom); 14 | double latrad = latLon.lat() * M_PI/180.0; 15 | double tileY = (1.0 - asinh(tan(latrad)) / M_PI) / 2.0 * (1 << zoom); 16 | xp = tileX; 17 | yp = tileY; 18 | } 19 | 20 | void Point2DTile::changeZoom(int zoom) { 21 | int oldZoom = zoomp; 22 | zoomp = zoom; 23 | int zoom_delta = zoomp - oldZoom; 24 | xp *= pow(2, zoom_delta); 25 | yp *= pow(2, zoom_delta); 26 | } 27 | 28 | QString Point2DTile::to_istring() { 29 | QString pStr = "X" + QString::number(xi()) + "Y" + QString::number(yi()) + "Z" + QString::number(zoomp); 30 | return QString(pStr); 31 | } 32 | 33 | bool Point2DTile::isValid() { 34 | int max = 1 << zoomp; 35 | bool ret = xp >= 0 && xp < max && 36 | yp >= 0 && yp < max; 37 | return ret; 38 | } 39 | 40 | Point2DTile Point2DTile::childPoint(int i, int j) { 41 | Point2DTile child(xp*2+i, yp*2+j, zoomp+1); 42 | return child; 43 | } 44 | -------------------------------------------------------------------------------- /src/geometry/point2dtile.h: -------------------------------------------------------------------------------- 1 | #ifndef POINT2DTILE_H 2 | #define POINT2DTILE_H 3 | 4 | #include "utils.h" 5 | #include "QString" 6 | #include "QPointF" 7 | 8 | class Point2DLatLon; 9 | class TileProvider; 10 | 11 | class Point2DTile 12 | { 13 | 14 | public: 15 | Point2DTile(double x, double y, int zoom); 16 | Point2DTile(Point2DLatLon latLon, int zoom); 17 | 18 | double x() {return xp;} 19 | double y() {return yp;} 20 | int xi() {return static_cast(xp);} 21 | int yi() {return static_cast(yp);} 22 | 23 | int zoom() {return zoomp;} 24 | void setX(double x) {xp = x;} 25 | void setY(double y) {yp = y;} 26 | void setZoom(int zoom) { zoomp = zoom; } 27 | 28 | bool isValid(); 29 | 30 | QString to_istring(); 31 | void changeZoom(int zoom); 32 | Point2DTile childPoint(int i, int j); 33 | 34 | private: 35 | double xp; 36 | double yp; 37 | int zoomp; 38 | }; 39 | 40 | 41 | #endif // POINT2DTILE_H 42 | -------------------------------------------------------------------------------- /src/globalconfig.cpp: -------------------------------------------------------------------------------- 1 | #include "globalconfig.h" 2 | 3 | 4 | GlobalConfig* GlobalConfig::singleton = nullptr; 5 | 6 | GlobalConfig::GlobalConfig(QObject *parent) : QObject(parent) 7 | { 8 | 9 | } 10 | 11 | void GlobalConfig::setValue(const QString &key, const QVariant &value) { 12 | map[key] = value; 13 | } 14 | 15 | QVariant GlobalConfig::value(const QString &key, const QVariant &default_value) { 16 | if(map.contains(key)) { 17 | return map[key]; 18 | } else { 19 | return default_value; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/globalconfig.h: -------------------------------------------------------------------------------- 1 | #ifndef GLOBALCONFIG_H 2 | #define GLOBALCONFIG_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class GlobalConfig : public QObject 9 | { 10 | Q_OBJECT 11 | public: 12 | static GlobalConfig* get() { 13 | if(singleton == nullptr) { 14 | singleton = new GlobalConfig(); 15 | } 16 | return singleton; 17 | } 18 | 19 | void setValue(const QString &key, const QVariant &value); 20 | QVariant value(const QString &key, const QVariant &default_value=QVariant()); 21 | bool contains(const QString &key) { 22 | return map.contains(key); 23 | } 24 | 25 | signals: 26 | 27 | private: 28 | static GlobalConfig* singleton; 29 | explicit GlobalConfig(QObject *parent = nullptr); 30 | 31 | QMap map; 32 | 33 | 34 | 35 | }; 36 | 37 | #endif // GLOBALCONFIG_H 38 | -------------------------------------------------------------------------------- /src/pprzmain.h: -------------------------------------------------------------------------------- 1 | #ifndef PPRZMAIN_H 2 | #define PPRZMAIN_H 3 | 4 | #include 5 | #include 6 | 7 | enum LaunchTypes { 8 | DEFAULT, 9 | NORMAL, 10 | FLIGHTPLAN_EDIT, 11 | CONFIGURE, 12 | QUIT, 13 | }; 14 | 15 | class PprzMain : public QMainWindow 16 | { 17 | Q_OBJECT 18 | 19 | public: 20 | explicit PprzMain(QWidget *parent = nullptr); 21 | static LaunchTypes launch_type; 22 | static int const EXIT_CODE_REBOOT = -123456; 23 | void setupUi(int width, int height, QWidget* centralWidget); 24 | 25 | void setServerStatus(bool active); 26 | 27 | signals: 28 | void ready(); 29 | 30 | 31 | private: 32 | void newAC(QString ac_id); 33 | void removeAC(QString ac_id); 34 | void delete_ac(QString ac_id); 35 | 36 | void populate_menu(); 37 | 38 | QMenuBar *menu_bar; 39 | QToolBar *mainToolBar; 40 | QStatusBar *statusBar; 41 | 42 | QMenu* aircraftsTopMenu; 43 | QMap acMenus; 44 | QMap acActions; 45 | QLabel* serverStatusLed; 46 | }; 47 | 48 | 49 | #endif // PPRZMAIN_H 50 | -------------------------------------------------------------------------------- /src/tools/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | set(SOURCE ${SOURCE}) 3 | 4 | 5 | list(APPEND SOURCE 6 | ${CMAKE_CURRENT_SOURCE_DIR}/srtm_manager.cpp 7 | ${CMAKE_CURRENT_SOURCE_DIR}/coordinatestransform.cpp 8 | ${CMAKE_CURRENT_SOURCE_DIR}/dispatcher_ui.cpp 9 | ${CMAKE_CURRENT_SOURCE_DIR}/pprz_dispatcher.cpp 10 | ${CMAKE_CURRENT_SOURCE_DIR}/AircraftManager.cpp 11 | ${CMAKE_CURRENT_SOURCE_DIR}/units.cpp 12 | ${CMAKE_CURRENT_SOURCE_DIR}/watcher.cpp 13 | ) 14 | 15 | if(${SPEECH}) 16 | list(APPEND SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/speaker.cpp) 17 | endif() 18 | 19 | if(${GRPC}) 20 | list(APPEND SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/grpcconnector.cpp) 21 | endif() 22 | 23 | set(INC_DIRS ${INC_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}) 24 | 25 | set(SOURCE ${SOURCE} PARENT_SCOPE) 26 | set(INC_DIRS ${INC_DIRS} PARENT_SCOPE) 27 | -------------------------------------------------------------------------------- /src/tools/coordinatestransform.h: -------------------------------------------------------------------------------- 1 | #ifndef COORDINATESTRANSFORM_H 2 | #define COORDINATESTRANSFORM_H 3 | 4 | //#pragma once 5 | 6 | #include 7 | #include 8 | #include "point2dlatlon.h" 9 | #include "point2dpseudomercator.h" 10 | #include "point2dtile.h" 11 | #include 12 | #include 13 | #include 14 | #include "PprzToolbox.h" 15 | #include "PprzApplication.h" 16 | 17 | class CoordinatesTransform : public PprzTool 18 | { 19 | public: 20 | 21 | CoordinatesTransform(PprzApplication* app, PprzToolbox* toolbox); 22 | 23 | static inline const QString TRANSFORM_WGS84_WEB_MERCATOR = "WGS84_WEB_MERCATOR"; 24 | static inline const QString TRANSFORM_NONE = "NO_TRANSFORM"; 25 | 26 | static CoordinatesTransform* get() { 27 | return pprzApp()->toolbox()->coordinatesTransform(); 28 | } 29 | 30 | 31 | ~CoordinatesTransform(); 32 | 33 | Point2DPseudoMercator WGS84_to_pseudoMercator(Point2DLatLon); 34 | Point2DLatLon pseudoMercator_to_WGS84(Point2DPseudoMercator); 35 | Point2DLatLon wgs84_from_scene(QPointF scenePoint, int zoom, int tile_size); 36 | 37 | Point2DLatLon relative_utm_to_wgs84(Point2DLatLon origin, double x, double y); 38 | void wgs84_to_relative_utm(Point2DLatLon origin, Point2DLatLon geo, double& x, double& y); 39 | Point2DLatLon ltp_to_wgs84(Point2DLatLon origin, double x, double y); 40 | void wgs84_to_ltp(Point2DLatLon origin, Point2DLatLon geo, double& x, double& y); 41 | Point2DLatLon utm_to_wgs84(double east, double north, int zone, bool isNorth); 42 | 43 | void distance_azimut(Point2DLatLon pt1, Point2DLatLon pt2, double& distance, double& azimut); 44 | 45 | void add_projector(QString name, QString source, QString target); 46 | 47 | PJ_COORD apply_transfrom(QString name, PJ_COORD in, PJ_DIRECTION direction=PJ_FWD); 48 | 49 | 50 | private: 51 | static QString utm_epsg(double lat, double lon); 52 | static QString utm_epsg(int zone, bool isNorth); 53 | 54 | PJ_CONTEXT* pj_context; 55 | QMap projectors; 56 | 57 | }; 58 | 59 | #endif // COORDINATESTRANSFORM_H 60 | -------------------------------------------------------------------------------- /src/tools/dispatcher_ui.cpp: -------------------------------------------------------------------------------- 1 | #include "dispatcher_ui.h" 2 | 3 | DispatcherUi::DispatcherUi(PprzApplication* app, PprzToolbox* toolbox) : PprzTool(app, toolbox), 4 | selected_ac_id("") 5 | { 6 | connect(this, &DispatcherUi::ac_selected, [=](QString ac_id){ 7 | selected_ac_id = ac_id; 8 | }); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/tools/dispatcher_ui.h: -------------------------------------------------------------------------------- 1 | #ifndef UI_DISPATCHER_H 2 | #define UI_DISPATCHER_H 3 | 4 | #include 5 | #include "waypoint.h" 6 | #include "point2dlatlon.h" 7 | #include "PprzToolbox.h" 8 | #include "PprzApplication.h" 9 | 10 | class Setting; 11 | 12 | class DispatcherUi : public PprzTool 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | explicit DispatcherUi(PprzApplication* app, PprzToolbox* toolbox); 18 | static DispatcherUi* get() { 19 | return pprzApp()->toolbox()->dispatcherUi(); 20 | } 21 | 22 | QString getSelectedAcId() { return selected_ac_id;} 23 | 24 | signals: 25 | void ac_selected(QString); 26 | void ac_deleted(QString); 27 | void new_ac_config(QString); 28 | void move_waypoint_ui(Waypoint*, QString ac_id); //wp moved from UI 29 | void settingUpdated(QString ac_id, Setting*, float value); 30 | void mapRotated(double); // map view rotation in degrees 31 | void centerMap(Point2DLatLon pos); 32 | //void create_waypoint(Waypoint*); 33 | 34 | // GVF viewer signals 35 | void gvf_settingUpdated(QString ac_id, QVector *gvfViewer_config); 36 | void gvf_defaultFieldSettings(QString ac_id, int area, int xpts, int ypts); 37 | void gvf_zlimits(QString ac_id, float minz, float maxz); 38 | 39 | public slots: 40 | 41 | private: 42 | QString selected_ac_id; 43 | 44 | }; 45 | 46 | #endif // UI_DISPATCHER_H 47 | -------------------------------------------------------------------------------- /src/tools/grpcconnector.h: -------------------------------------------------------------------------------- 1 | #ifndef GRPCCONNECTOR_H 2 | #define GRPCCONNECTOR_H 3 | 4 | #include 5 | #include "PprzToolbox.h" 6 | #include "PprzApplication.h" 7 | #include 8 | #include 9 | #include "pprzgcs.grpc.pb.h" 10 | 11 | using grpc::Server; 12 | using grpc::Status; 13 | using grpc::ServerContext; 14 | 15 | namespace p = pprzgcs; 16 | 17 | 18 | class GRPCConnector : public PprzTool, public p::GCSService::Service 19 | { 20 | Q_OBJECT 21 | public: 22 | explicit GRPCConnector(PprzApplication* app, PprzToolbox* toolbox); 23 | static GRPCConnector* get() { 24 | return pprzApp()->toolbox()->connector(); 25 | } 26 | 27 | virtual void setToolbox(PprzToolbox* toolbox) override; 28 | 29 | Status LoadSRTM([[maybe_unused]] ServerContext* context, 30 | const p::SRTMRequest* request, p::SRTMReply* reply) override; 31 | Status CenterOn(grpc::ServerContext *context, 32 | const p::CenterOnRequest *request,p::CenterOnResponse *response) override; 33 | Status SetWidgetProperty(grpc::ServerContext *context, 34 | const p::WidgetProperty *request, ::google::protobuf::Empty *response) override; 35 | 36 | signals: 37 | void dl_srtm(); 38 | 39 | private: 40 | void runServer(); 41 | 42 | std::unique_ptr server; 43 | 44 | }; 45 | 46 | #endif // GRPCCONNECTOR_H 47 | -------------------------------------------------------------------------------- /src/tools/speaker.h: -------------------------------------------------------------------------------- 1 | #ifndef SPEAKER_H 2 | #define SPEAKER_H 3 | 4 | #include 5 | #include 6 | #include "PprzToolbox.h" 7 | #include "PprzApplication.h" 8 | #include "pprz_dispatcher.h" 9 | 10 | 11 | 12 | class Speaker : public PprzTool 13 | { 14 | Q_OBJECT 15 | public: 16 | explicit Speaker(PprzApplication* app, PprzToolbox* toolbox); 17 | void setToolbox(PprzToolbox* toolbox) override; 18 | void addSentence(QString txt, int priority=0, int validity=30); 19 | void registerMessage(QString name, QString text, int period, int expire, int priority, bool onChange, QString postprocessing); 20 | void setLocale(QString l); 21 | signals: 22 | 23 | public slots: 24 | void enableSpeech(bool s); 25 | 26 | private: 27 | 28 | struct Sentence { 29 | QString text; 30 | int priority; 31 | QTime expiration; 32 | }; 33 | 34 | struct Message { 35 | QString name; 36 | QString text; 37 | int timeout; 38 | int expire; 39 | int priority; 40 | bool onChange; 41 | QString postprocessing; 42 | }; 43 | 44 | 45 | void bindMessage(struct Message msg); 46 | void handleMsg(struct Message msg, QString sender, pprzlink::Message pprz_msg); 47 | 48 | template 49 | QString value_to_string(T val); 50 | 51 | QString value_to_string(double val); 52 | QString value_to_string(float val); 53 | QString value_to_string(QString val); 54 | 55 | QString postprocess(QString process, QString valstr, QString ac_id); 56 | 57 | template 58 | void make_sentence(struct Message msg, QString field, pprzlink::Message pprz_msg, QString ac_id); 59 | 60 | void say(); 61 | 62 | QTextToSpeech* tts; 63 | QString locale; 64 | 65 | QList sentences; 66 | QList messages; 67 | QList bids; 68 | QMap msg_times; 69 | QMap last_values; 70 | 71 | QTimer* timer; 72 | 73 | }; 74 | 75 | #endif // SPEAKER_H 76 | -------------------------------------------------------------------------------- /src/tools/srtm_manager.h: -------------------------------------------------------------------------------- 1 | #ifndef SRTM_MANAGER_H 2 | #define SRTM_MANAGER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include "PprzToolbox.h" 13 | #include "PprzApplication.h" 14 | 15 | using namespace std; 16 | 17 | class SRTMManager : public PprzTool 18 | { 19 | Q_OBJECT 20 | public: 21 | explicit SRTMManager(PprzApplication* app, PprzToolbox* toolbox); 22 | ~SRTMManager(); 23 | static SRTMManager* get() { 24 | return pprzApp()->toolbox()->srtmManager(); 25 | } 26 | 27 | optional get_elevation(double lat, double lon); 28 | void load_tiles(QList names, bool local_only=false); 29 | int load_tile(QString name, bool dl); 30 | QList get_tile_names(double _lat_min, double _lat_max, double _lon_min, double _lon_max); 31 | 32 | private slots: 33 | void handleReply(QNetworkReply *reply); 34 | 35 | private: 36 | QString get_tile_name(int lat, int lon); 37 | optional get_tile_region(QString name); 38 | 39 | static const QString srtm_url; 40 | 41 | map tiles; // key example: "N43E001" 42 | 43 | QNetworkAccessManager* manager; 44 | QNetworkDiskCache* diskCache; 45 | QList pending_downloads; 46 | }; 47 | 48 | 49 | class SRTMDialog : public QDialog{ 50 | Q_OBJECT 51 | public: 52 | explicit SRTMDialog(QList tiles_names, QWidget *parent = nullptr); 53 | 54 | signals: 55 | void tilesConfirmed(QList); 56 | 57 | protected: 58 | void keyPressEvent(QKeyEvent *e) override; 59 | }; 60 | 61 | #endif // SRTM_MANAGER_H 62 | -------------------------------------------------------------------------------- /src/tools/units.cpp: -------------------------------------------------------------------------------- 1 | #include "units.h" 2 | #include 3 | #include 4 | #include 5 | #include "iostream" 6 | #include 7 | #include "gcs_utils.h" 8 | 9 | using namespace std; 10 | 11 | Units::Units(PprzApplication* app, PprzToolbox* toolbox) : PprzTool(app, toolbox) 12 | { 13 | 14 | } 15 | 16 | void Units::setToolbox(PprzToolbox* toolbox) { 17 | PprzTool::setToolbox(toolbox); 18 | auto settings = getAppSettings(); 19 | auto filename = appConfig()->value("PAPARAZZI_HOME").toString() + "/var/units.xml"; 20 | 21 | 22 | QDomDocument doc; 23 | QFile f(filename); 24 | if(!f.open(QIODevice::ReadOnly)) { 25 | throw std::runtime_error("Error while loading unit file"); 26 | } 27 | doc.setContent(&f); 28 | f.close(); 29 | 30 | auto units_root = doc.firstChildElement("units"); 31 | for(auto unit=units_root.firstChildElement(); 32 | !unit.isNull(); 33 | unit=unit.nextSiblingElement()) { 34 | 35 | assert(unit.hasAttribute("from")); 36 | assert(unit.hasAttribute("to")); 37 | assert(unit.hasAttribute("coef")); 38 | auto from = unit.attribute("from"); 39 | auto to = unit.attribute("to"); 40 | auto _coef = unit.attribute("coef"); 41 | 42 | // auto _auto = unit.attribute("auto"); 43 | auto coef = _coef.toDouble(); 44 | QPair key(from, to); 45 | coefs[key] = coef; 46 | } 47 | 48 | 49 | } 50 | 51 | std::optional Units::getCoef(QString inputUnit, QString outputUnit) { 52 | QPair key(inputUnit, outputUnit); 53 | if(coefs.find(key) != coefs.end()) { 54 | return coefs[key]; 55 | } else { 56 | return std::nullopt; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/tools/units.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITS_H 2 | #define UNITS_H 3 | #include 4 | #include 5 | #include "PprzToolbox.h" 6 | #include "PprzApplication.h" 7 | 8 | class Units : public PprzTool { 9 | public: 10 | explicit Units(PprzApplication* app, PprzToolbox* toolbox); 11 | static Units* get() { 12 | return pprzApp()->toolbox()->units(); 13 | } 14 | 15 | virtual void setToolbox(PprzToolbox* toolbox) override; 16 | 17 | std::optional getCoef(QString inputUnit, QString outputUnit); 18 | 19 | private: 20 | QMap, float> coefs; 21 | }; 22 | #endif // UNITS_H 23 | -------------------------------------------------------------------------------- /src/tools/watcher.cpp: -------------------------------------------------------------------------------- 1 | #include "watcher.h" 2 | 3 | Watcher::Watcher(PprzApplication* app, PprzToolbox* toolbox) : PprzTool(app, toolbox) 4 | { 5 | 6 | } 7 | 8 | void Watcher::setToolbox(PprzToolbox* toolbox) { 9 | PprzTool::setToolbox(toolbox); 10 | } 11 | 12 | -------------------------------------------------------------------------------- /src/tools/watcher.h: -------------------------------------------------------------------------------- 1 | #ifndef WATCHER_H 2 | #define WATCHER_H 3 | 4 | #include 5 | #include "PprzToolbox.h" 6 | #include "PprzApplication.h" 7 | #include "pprz_dispatcher.h" 8 | 9 | class Watcher : public PprzTool 10 | { 11 | Q_OBJECT 12 | public: 13 | explicit Watcher(PprzApplication* app, PprzToolbox* toolbox); 14 | void setToolbox(PprzToolbox* toolbox) override; 15 | 16 | signals: 17 | 18 | private: 19 | 20 | }; 21 | 22 | #endif // WATCHER_H 23 | -------------------------------------------------------------------------------- /src/uisignals.h: -------------------------------------------------------------------------------- 1 | #ifndef UISIGNALS_H 2 | #define UISIGNALS_H 3 | #include 4 | #include "pprzmessage.h" 5 | 6 | class Waypoint; 7 | 8 | class UiSignals : public virtual QObject 9 | { 10 | Q_OBJECT 11 | signals: 12 | void ac_selected(int); 13 | void create_waypoint(Waypoint*); 14 | }; 15 | 16 | #endif // UISIGNALS_H 17 | -------------------------------------------------------------------------------- /src/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef UTILS_H 2 | #define UTILS_H 3 | 4 | #include 5 | #include 6 | 7 | 8 | //template 9 | //const T& clamp( const T& v, const T& lo, const T& hi ) 10 | //{ 11 | // assert( !(hi < lo) ); 12 | // return std::min(hi, std::max(v, lo)); 13 | //} 14 | 15 | 16 | #endif // UTILS_H 17 | -------------------------------------------------------------------------------- /src/widgets/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | set(SOURCE 3 | ${SOURCE} 4 | ${CMAKE_CURRENT_SOURCE_DIR}/strip.cpp 5 | ${CMAKE_CURRENT_SOURCE_DIR}/ac_selector.cpp 6 | ${CMAKE_CURRENT_SOURCE_DIR}/settings_viewer.cpp 7 | ${CMAKE_CURRENT_SOURCE_DIR}/pprzmap.cpp 8 | ${CMAKE_CURRENT_SOURCE_DIR}/pfd.cpp 9 | ${CMAKE_CURRENT_SOURCE_DIR}/listcontainer.cpp 10 | ${CMAKE_CURRENT_SOURCE_DIR}/mini_strip.cpp 11 | ${CMAKE_CURRENT_SOURCE_DIR}/flightplan_viewerv2.cpp 12 | ${CMAKE_CURRENT_SOURCE_DIR}/stackcontainer.cpp 13 | ${CMAKE_CURRENT_SOURCE_DIR}/layer_combo.cpp 14 | ${CMAKE_CURRENT_SOURCE_DIR}/widget_utils.cpp 15 | ${CMAKE_CURRENT_SOURCE_DIR}/pprzmap.ui 16 | ${CMAKE_CURRENT_SOURCE_DIR}/commands.cpp 17 | ${CMAKE_CURRENT_SOURCE_DIR}/gps_classic_viewer.cpp 18 | ${CMAKE_CURRENT_SOURCE_DIR}/flightplaneditor.ui 19 | ${CMAKE_CURRENT_SOURCE_DIR}/flightplaneditor.cpp 20 | ${CMAKE_CURRENT_SOURCE_DIR}/plotter.cpp 21 | ${CMAKE_CURRENT_SOURCE_DIR}/windindicator.cpp 22 | ${CMAKE_CURRENT_SOURCE_DIR}/link_status.cpp 23 | ${CMAKE_CURRENT_SOURCE_DIR}/gvf_viewer.cpp 24 | ${CMAKE_CURRENT_SOURCE_DIR}/chat.cpp 25 | ${CMAKE_CURRENT_SOURCE_DIR}/chat.ui 26 | ${CMAKE_CURRENT_SOURCE_DIR}/checklist.cpp 27 | ${CMAKE_CURRENT_SOURCE_DIR}/checklist.ui 28 | ) 29 | 30 | set(INC_DIRS ${INC_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}) 31 | 32 | add_subdirectory(map) 33 | add_subdirectory(basics) 34 | 35 | set(SOURCE ${SOURCE} PARENT_SCOPE) 36 | set(INC_DIRS ${INC_DIRS} PARENT_SCOPE) 37 | -------------------------------------------------------------------------------- /src/widgets/ac_selector.h: -------------------------------------------------------------------------------- 1 | #ifndef AC_SELECTOR_H 2 | #define AC_SELECTOR_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | class ACSelector : public QWidget, public Configurable 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit ACSelector(QWidget *parent = nullptr); 16 | void configure(QDomElement) {}; 17 | 18 | QSize sizeHint() const; 19 | QSize minimumSizeHint() const; 20 | 21 | void removeAC(QString ac_id); 22 | 23 | protected: 24 | // virtual void enterEvent(QEvent* e); 25 | // virtual void leaveEvent(QEvent* e); 26 | virtual void paintEvent(QPaintEvent* e); 27 | virtual void mousePressEvent(QMouseEvent *e); 28 | virtual void mouseReleaseEvent(QMouseEvent *e); 29 | virtual void wheelEvent(QWheelEvent *event); 30 | 31 | private: 32 | void handleNewAC(QString ac_id); 33 | 34 | 35 | static int const ARROW_WIDTH = 20; 36 | 37 | QList ac_ids; 38 | QString current_ac_id; 39 | 40 | }; 41 | 42 | #endif // AC_SELECTOR_H 43 | -------------------------------------------------------------------------------- /src/widgets/basics/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | set(SOURCE 3 | ${SOURCE} 4 | ${CMAKE_CURRENT_SOURCE_DIR}/imagebutton.cpp 5 | ${CMAKE_CURRENT_SOURCE_DIR}/double_slider.cpp 6 | ${CMAKE_CURRENT_SOURCE_DIR}/switch.cpp 7 | ${CMAKE_CURRENT_SOURCE_DIR}/graphlabel.cpp 8 | ${CMAKE_CURRENT_SOURCE_DIR}/jaugelabel.cpp 9 | ${CMAKE_CURRENT_SOURCE_DIR}/colorlabel.cpp 10 | ${CMAKE_CURRENT_SOURCE_DIR}/flowlayout.cpp 11 | ${CMAKE_CURRENT_SOURCE_DIR}/mbpushbutton.cpp 12 | ${CMAKE_CURRENT_SOURCE_DIR}/lock_button.cpp 13 | ${CMAKE_CURRENT_SOURCE_DIR}/graphwidget.cpp 14 | ${CMAKE_CURRENT_SOURCE_DIR}/colorbar.cpp 15 | ${CMAKE_CURRENT_SOURCE_DIR}/chatbubble.cpp 16 | ${CMAKE_CURRENT_SOURCE_DIR}/chatbubble.ui 17 | ) 18 | 19 | set(INC_DIRS ${INC_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}) 20 | 21 | set(SOURCE ${SOURCE} PARENT_SCOPE) 22 | set(INC_DIRS ${INC_DIRS} PARENT_SCOPE) 23 | -------------------------------------------------------------------------------- /src/widgets/basics/chatbubble.h: -------------------------------------------------------------------------------- 1 | #ifndef CHATBUBBLE_H 2 | #define CHATBUBBLE_H 3 | 4 | #include 5 | #include 6 | 7 | namespace Ui { 8 | class ChatBubble; 9 | } 10 | 11 | class ChatBubble : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit ChatBubble(QString source, QString dest, QString msg, bool sent=false, QWidget *parent = nullptr); 17 | ~ChatBubble(); 18 | 19 | QString getSource() {return source;} 20 | QString getDest() {return dest;} 21 | QTime getTime() {return chat_time;} 22 | void addText(QString text); 23 | 24 | protected: 25 | bool eventFilter(QObject *obj, QEvent *ev) override; 26 | 27 | private: 28 | Ui::ChatBubble *ui; 29 | 30 | QString source; 31 | QString dest; 32 | QTime chat_time; 33 | }; 34 | 35 | #endif // CHATBUBBLE_H 36 | -------------------------------------------------------------------------------- /src/widgets/basics/colorbar.h: -------------------------------------------------------------------------------- 1 | #ifndef COLORBAR_H 2 | #define COLORBAR_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class ColorBar : public QWidget 10 | { 11 | Q_OBJECT 12 | public: 13 | explicit ColorBar(qreal bar_height = 20, QWidget *parent = nullptr); 14 | 15 | void set_zlimits(float minz, float maxz); 16 | QSize minimumSizeHint() const override; 17 | 18 | protected: 19 | void paintEvent(QPaintEvent* e) override; 20 | 21 | private: 22 | float max_value = 0; 23 | float min_value = 0; 24 | 25 | QColor min_color; 26 | QColor max_color; 27 | 28 | qreal bar_height; 29 | QSize minSize; 30 | }; 31 | 32 | #endif //COLORBAR_H 33 | -------------------------------------------------------------------------------- /src/widgets/basics/colorlabel.cpp: -------------------------------------------------------------------------------- 1 | #include "colorlabel.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | ColorLabel::ColorLabel(qreal radius, QWidget *parent) : QWidget(parent), 9 | text(""), brush(Qt::red), minSize(QSize(10, 10)), radius(radius) 10 | { 11 | 12 | } 13 | 14 | void ColorLabel::paintEvent(QPaintEvent *e) { 15 | (void)e; 16 | QPainter p(this); 17 | // Set bold font 18 | QFont font = p.font(); 19 | font.setBold(true); 20 | auto fm = QFontMetricsF(font); 21 | // Compute minimum widget size based of text size. 22 | auto txt_rect = fm.boundingRect(text != "" ? text:"00"); 23 | 24 | int minWidth = static_cast(ceil(txt_rect.width()))+6; 25 | int minHeigth = static_cast(ceil(txt_rect.height())); 26 | minSize = QSize(minWidth, minHeigth); 27 | setMinimumSize(minSize); 28 | 29 | // Draw background 30 | p.setPen(Qt::NoPen); 31 | p.setBrush(brush); 32 | p.drawRoundedRect(rect(), radius, radius); 33 | 34 | // Draw text 35 | p.setFont(font); 36 | p.setPen(Qt::black); 37 | p.drawText(rect(), Qt::AlignCenter, text); 38 | } 39 | 40 | QSize ColorLabel::minimumSizeHint() const 41 | { 42 | return minSize; 43 | } 44 | -------------------------------------------------------------------------------- /src/widgets/basics/colorlabel.h: -------------------------------------------------------------------------------- 1 | #ifndef COLORLABEL_H 2 | #define COLORLABEL_H 3 | 4 | #include 5 | 6 | class ColorLabel : public QWidget 7 | { 8 | Q_OBJECT 9 | public: 10 | explicit ColorLabel(qreal radius, QWidget *parent = nullptr); 11 | void setText(QString t) {text = t; update();} 12 | void setBrush(QBrush b) {brush = b; update();} 13 | void setMinSize(QSize s) {minSize = s;} 14 | 15 | QSize minimumSizeHint() const override; 16 | 17 | signals: 18 | 19 | public slots: 20 | 21 | protected: 22 | void paintEvent(QPaintEvent*) override; 23 | 24 | private: 25 | QString text; 26 | QBrush brush; 27 | QSize minSize; 28 | qreal radius; 29 | }; 30 | 31 | #endif // COLORLABEL_H 32 | -------------------------------------------------------------------------------- /src/widgets/basics/double_slider.cpp: -------------------------------------------------------------------------------- 1 | #include "double_slider.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | DoubleSlider::DoubleSlider(Qt::Orientation orientation, QWidget *parent) : QSlider(orientation, parent) 9 | { 10 | connect(this, &QSlider::valueChanged, this, &DoubleSlider::notifyValueChanged); 11 | } 12 | 13 | 14 | void DoubleSlider::notifyValueChanged(int value) { 15 | double doubleValue = value * step + min; 16 | emit doubleValueChanged(doubleValue); 17 | } 18 | 19 | 20 | void DoubleSlider::setDoubleRange(double mi, double ma, double sp) { 21 | min = mi; 22 | max = ma; 23 | step = sp; 24 | int nb_steps = ceil((max - min) / step); 25 | setRange(0, nb_steps); 26 | if(nb_steps < 20) { 27 | setTickPosition(QSlider::TicksBelow); 28 | } 29 | } 30 | 31 | void DoubleSlider::setDoubleValue(double v) { 32 | setValue((v - min)/step); 33 | } 34 | 35 | double DoubleSlider::doubleValue() { 36 | return value()*step + min; 37 | } 38 | 39 | void DoubleSlider::sliderChange(QAbstractSlider::SliderChange change) 40 | { 41 | QSlider::sliderChange(change); 42 | 43 | if (change == QAbstractSlider::SliderValueChange ) 44 | { 45 | QStyleOptionSlider opt; 46 | initStyleOption(&opt); 47 | } 48 | } 49 | 50 | void DoubleSlider::wheelEvent(QWheelEvent* e) { 51 | if(e->angleDelta().y() > 0) { 52 | setValue(value()+1); 53 | } else { 54 | setValue(value()-1); 55 | } 56 | e->accept(); 57 | } 58 | -------------------------------------------------------------------------------- /src/widgets/basics/double_slider.h: -------------------------------------------------------------------------------- 1 | #ifndef DOUBLE_SLIDER_H 2 | #define DOUBLE_SLIDER_H 3 | 4 | #include 5 | #include 6 | 7 | class DoubleSlider : public QSlider 8 | { 9 | Q_OBJECT 10 | public: 11 | explicit DoubleSlider(Qt::Orientation orientation, QWidget *parent = nullptr); 12 | 13 | void setDoubleRange(double min, double max, double step); 14 | double doubleValue(); 15 | void setDoubleValue(double value); 16 | 17 | signals: 18 | void doubleValueChanged(double value); 19 | 20 | public slots: 21 | 22 | protected: 23 | virtual void sliderChange(SliderChange change) override; 24 | virtual void wheelEvent(QWheelEvent *e) override; 25 | 26 | private slots: 27 | void notifyValueChanged(int value); 28 | 29 | private: 30 | double min; 31 | double max; 32 | double step; 33 | }; 34 | 35 | #endif // DOUBLE_SLIDER_H 36 | -------------------------------------------------------------------------------- /src/widgets/basics/graphlabel.h: -------------------------------------------------------------------------------- 1 | #ifndef GRAPHLABEL_H 2 | #define GRAPHLABEL_H 3 | 4 | #include 5 | #include 6 | 7 | class GraphLabel : public QWidget 8 | { 9 | Q_OBJECT 10 | public: 11 | explicit GraphLabel(QWidget *parent = nullptr); 12 | explicit GraphLabel(double min, double max, QWidget *parent = nullptr); 13 | 14 | void pushData(double value); 15 | void setDualText(bool d) {dual_text = d;} 16 | void setSecondayText(QString t) {secondary_text = t;} 17 | void setPrecision(int p) {precision = p;} 18 | void setUnit(QString u) {unit = u;} 19 | 20 | void setIndicator(bool i) {indicator = i;} 21 | void setIndicatorAngle(double angle) {indicator_angle = angle;} 22 | 23 | 24 | QSize minimumSizeHint() const override; 25 | 26 | protected: 27 | void paintEvent(QPaintEvent*) override; 28 | //void enterEvent(QEvent*) override; 29 | 30 | signals: 31 | 32 | public slots: 33 | 34 | private: 35 | QBrush brushTop, brushBottom; 36 | double timespan; // total time the graph represent (in seconds) 37 | double min, max; 38 | 39 | QList> data; 40 | QString unit; 41 | 42 | int precision; 43 | 44 | bool dual_text; 45 | QString secondary_text; 46 | 47 | bool indicator; 48 | double indicator_angle; 49 | }; 50 | 51 | #endif // GRAPHLABEL_H 52 | -------------------------------------------------------------------------------- /src/widgets/basics/graphwidget.h: -------------------------------------------------------------------------------- 1 | #ifndef GRAPHWIDGET_H 2 | #define GRAPHWIDGET_H 3 | 4 | #include 5 | 6 | class GraphWidget : public QWidget 7 | { 8 | Q_OBJECT 9 | public: 10 | 11 | struct DataPoint { 12 | double value; 13 | QTime time; 14 | }; 15 | 16 | struct Params { 17 | double max; 18 | double min; 19 | bool autoscale; 20 | double scale; 21 | }; 22 | 23 | explicit GraphWidget(QWidget *parent = nullptr); 24 | 25 | void setParams(struct Params p) { 26 | if(p.min > p.max) { 27 | auto min = p.max; 28 | p.max = p.min; 29 | p.min = min; 30 | } 31 | params = p; 32 | if(p.autoscale == true && !data.isEmpty()) { 33 | params.min = data.last().value; 34 | params.max = params.min; 35 | } 36 | } 37 | struct Params getParams() {return params;} 38 | void setAutoscale(bool a) { 39 | auto new_params = params; 40 | new_params.autoscale = a; 41 | params = new_params; 42 | } 43 | 44 | void setHistory(int h) {history = h; update();} 45 | int getHistory() {return history;} 46 | void pushData(double d); 47 | void clearData(); 48 | 49 | QSize minimumSizeHint() const override; 50 | 51 | protected: 52 | void paintEvent(QPaintEvent*) override; 53 | void mousePressEvent(QMouseEvent *event) override; 54 | void mouseReleaseEvent(QMouseEvent *event) override; 55 | void mouseDoubleClickEvent(QMouseEvent *event) override; 56 | void mouseMoveEvent(QMouseEvent *event) override; 57 | void leaveEvent(QEvent *event) override; 58 | void wheelEvent(QWheelEvent *event) override; 59 | 60 | signals: 61 | void autoscaleChanged(bool); 62 | 63 | private: 64 | struct Params params; 65 | 66 | QList data; 67 | int history; 68 | 69 | QPoint mousePos; 70 | 71 | std::function val_of_y; 72 | double val_last_move; 73 | bool moving; 74 | int wheelAccumulator; 75 | }; 76 | 77 | #endif // GRAPHWIDGET_H 78 | -------------------------------------------------------------------------------- /src/widgets/basics/imagebutton.cpp: -------------------------------------------------------------------------------- 1 | #include "imagebutton.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | ImageButton::ImageButton(QIcon normal, QSize size, bool mask, QWidget *parent) : QPushButton(parent) 9 | { 10 | icon_normal = normal; 11 | setIcon(icon_normal); 12 | setIconSize(size); 13 | 14 | if(mask) { 15 | QPixmap p = icon().pixmap(iconSize()); 16 | setMask(p.mask()); 17 | } 18 | } 19 | 20 | void ImageButton::enterEvent(QEvent* e) { 21 | QPushButton::enterEvent( e ); 22 | if(icon_hover.isNull()) { 23 | setIcon(icon_normal); 24 | } else { 25 | setIcon(icon_hover); 26 | } 27 | } 28 | 29 | void ImageButton::leaveEvent(QEvent* e) { 30 | QPushButton::leaveEvent( e ); 31 | setIcon(icon_normal); 32 | } 33 | 34 | void ImageButton::mousePressEvent(QMouseEvent *e) { 35 | QPushButton::mousePressEvent(e); 36 | QPushButton::enterEvent( e ); 37 | if(icon_pressed.isNull()) { 38 | setIcon(icon_normal); 39 | } else { 40 | setIcon(icon_pressed); 41 | } 42 | } 43 | 44 | void ImageButton::mouseReleaseEvent(QMouseEvent *e) { 45 | QPushButton::mouseReleaseEvent(e); 46 | if(icon_hover.isNull()) { 47 | setIcon(icon_normal); 48 | } else { 49 | setIcon(icon_hover); 50 | } 51 | } 52 | 53 | void ImageButton::paintEvent(QPaintEvent* e) { 54 | (void)e; 55 | QPainter painter(this); 56 | icon().paint(&painter,rect()); 57 | } 58 | -------------------------------------------------------------------------------- /src/widgets/basics/imagebutton.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAGEBUTTON_H 2 | #define IMAGEBUTTON_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class ImageButton : public QPushButton 9 | { 10 | Q_OBJECT 11 | public: 12 | explicit ImageButton(QIcon normal, QSize size, bool mask, QWidget *parent = nullptr); 13 | 14 | void setNormalIcon(QIcon ic) {icon_normal = ic;} 15 | void setHoverIcon(QIcon ic) {icon_hover = ic;} 16 | void setPressedIcon(QIcon ic) {icon_pressed = ic;} 17 | 18 | protected: 19 | virtual void enterEvent(QEvent* e); 20 | virtual void leaveEvent(QEvent* e); 21 | virtual void paintEvent(QPaintEvent* e); 22 | virtual void mousePressEvent(QMouseEvent *e); 23 | virtual void mouseReleaseEvent(QMouseEvent *e); 24 | 25 | signals: 26 | 27 | public slots: 28 | 29 | private: 30 | QIcon icon_normal; 31 | QIcon icon_hover; 32 | QIcon icon_pressed; 33 | }; 34 | 35 | #endif // IMAGEBUTTON_H 36 | -------------------------------------------------------------------------------- /src/widgets/basics/jaugelabel.cpp: -------------------------------------------------------------------------------- 1 | #include "jaugelabel.h" 2 | #include 3 | #include 4 | #include 5 | 6 | JaugeLabel::JaugeLabel(QWidget *parent) : JaugeLabel(0, 1, "%", parent) 7 | { 8 | } 9 | 10 | JaugeLabel::JaugeLabel(double min, double max, QString unit, QWidget *parent) : 11 | QWidget(parent), min(min), max(max), unit(unit), precision(2), minSize(20,10) 12 | { 13 | brushBackEnabled = QColor(0xffa500); 14 | brushLeft = QColor(0x7ef17e); 15 | brushBackDisabled = Qt::red; 16 | } 17 | 18 | QSize JaugeLabel::minimumSizeHint() const 19 | { 20 | return minSize; 21 | //return QSize(60, 18); 22 | } 23 | 24 | void JaugeLabel::paintEvent(QPaintEvent *e) { 25 | (void)e; 26 | QPainter p(this); 27 | p.setPen(Qt::NoPen); 28 | 29 | if(status) { 30 | p.setBrush(brushBackEnabled); 31 | } else { 32 | p.setBrush(brushBackDisabled); 33 | } 34 | p.drawRect(rect()); 35 | 36 | 37 | 38 | p.setBrush(brushLeft); 39 | int x = static_cast(std::clamp((value - min) / (max - min), 0., 1.) * rect().width()); 40 | p.drawRect(0, 0, x, rect().height()); 41 | 42 | 43 | 44 | QFont font = p.font(); 45 | font.setPointSize(12); 46 | font.setBold(true); 47 | p.setFont(font); 48 | p.setPen(Qt::black); 49 | QString txt = QString::number(value, 'f', precision) + unit; 50 | p.drawText(rect(), Qt::AlignCenter, txt); 51 | 52 | auto fm = QFontMetricsF(font); 53 | // Compute minimum widget size based of text size. 54 | auto txt_rect = fm.boundingRect(txt); 55 | minSize = QSize(static_cast(txt_rect.width())+6, static_cast(txt_rect.height())); 56 | setMinimumSize(minSize); 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/widgets/basics/jaugelabel.h: -------------------------------------------------------------------------------- 1 | #ifndef JAUGELABEL_H 2 | #define JAUGELABEL_H 3 | 4 | #include 5 | 6 | class JaugeLabel : public QWidget 7 | { 8 | Q_OBJECT 9 | public: 10 | explicit JaugeLabel(QWidget *parent = nullptr); 11 | explicit JaugeLabel(double min, double max, QString unit, QWidget *parent = nullptr); 12 | QSize minimumSizeHint() const override; 13 | 14 | 15 | void setValue(double v) {value = v; update();} 16 | void setStatus(bool s) {status = s; update();} 17 | void setPrecision(int p) {precision = p;} 18 | 19 | protected: 20 | void paintEvent(QPaintEvent*) override; 21 | 22 | private: 23 | QBrush brushLeft; 24 | QBrush brushBackEnabled; 25 | QBrush brushBackDisabled; 26 | double min, max; 27 | QString unit; 28 | int precision; 29 | 30 | double value; 31 | bool status; 32 | 33 | QSize minSize; 34 | 35 | }; 36 | 37 | #endif // JAUGELABEL_H 38 | -------------------------------------------------------------------------------- /src/widgets/basics/lock_button.h: -------------------------------------------------------------------------------- 1 | #ifndef LOCK_BUTTON_H 2 | #define LOCK_BUTTON_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | class LockButton : public QWidget 11 | { 12 | Q_OBJECT 13 | Q_PROPERTY(QColor color_hover MEMBER m_color_hover DESIGNABLE true) 14 | Q_PROPERTY(QColor color_idle MEMBER m_color_idle DESIGNABLE true) 15 | Q_PROPERTY(QColor color_pressed MEMBER m_color_pressed DESIGNABLE true) 16 | Q_PROPERTY(int size READ getSizeProperty WRITE setSizeProperty DESIGNABLE true) 17 | public: 18 | explicit LockButton(QIcon icon, QWidget *parent = nullptr); 19 | void setSizeProperty(int s) {setSize(QSize(s,s));} 20 | int getSizeProperty() {return _size.width();} 21 | 22 | QSize sizeHint() const; 23 | QSize minimumSizeHint() const; 24 | 25 | void setActive(bool a) { active = a; repaint();} 26 | bool isActive() {return active;} 27 | bool isLocked(){return _locked;} 28 | void setWidget(QWidget* w) {_widget = w;} 29 | QWidget* widget(){return _widget;} 30 | void setSize(QSize s); 31 | void setActiveSide(bool activeLeft); 32 | 33 | protected: 34 | virtual void enterEvent(QEvent* e); 35 | virtual void leaveEvent(QEvent* e); 36 | virtual void paintEvent(QPaintEvent* e); 37 | virtual void mousePressEvent(QMouseEvent *e); 38 | virtual void mouseReleaseEvent(QMouseEvent *e); 39 | 40 | signals: 41 | void clicked(bool); 42 | void locked(bool); 43 | 44 | public slots: 45 | 46 | private: 47 | 48 | enum State { 49 | IDLE, 50 | HOVER, 51 | PRESSED 52 | }; 53 | 54 | State state; 55 | 56 | QSize _size; 57 | QMargins icon_margins; 58 | 59 | QIcon icon; 60 | QIcon icon_lock; 61 | QIcon icon_unlocked; 62 | bool activeSide; 63 | 64 | bool _locked; 65 | bool active; 66 | 67 | QColor m_color_idle; 68 | QColor m_color_hover; 69 | QColor m_color_pressed; 70 | 71 | QRect lock_rect; 72 | QRect active_rect; 73 | 74 | QWidget* _widget; 75 | }; 76 | 77 | #endif // LOCK_BUTTON_H 78 | -------------------------------------------------------------------------------- /src/widgets/basics/mbpushbutton.cpp: -------------------------------------------------------------------------------- 1 | #include "mbpushbutton.h" 2 | #include 3 | #include 4 | 5 | MbPushButton::MbPushButton(QWidget *parent) : QPushButton(parent) 6 | { 7 | 8 | } 9 | 10 | MbPushButton::MbPushButton(QString txt, QWidget *parent) : QPushButton (txt, parent) 11 | { 12 | 13 | } 14 | 15 | 16 | void MbPushButton::mousePressEvent(QMouseEvent *e) { 17 | QPushButton::mousePressEvent(e); 18 | } 19 | 20 | void MbPushButton::mouseReleaseEvent(QMouseEvent *e) { 21 | QPushButton::mouseReleaseEvent(e); 22 | if(e->button() == Qt::RightButton) { 23 | emit rightClicked(); 24 | } 25 | } 26 | 27 | void MbPushButton::mouseMoveEvent(QMouseEvent *e) { 28 | QPushButton::mouseMoveEvent(e); 29 | } 30 | 31 | void MbPushButton::enterEvent(QEvent *event) { 32 | emit enter(); 33 | QPushButton::enterEvent(event); 34 | } 35 | 36 | void MbPushButton::leaveEvent(QEvent *event) { 37 | emit leave(); 38 | QPushButton::leaveEvent(event); 39 | } 40 | -------------------------------------------------------------------------------- /src/widgets/basics/mbpushbutton.h: -------------------------------------------------------------------------------- 1 | #ifndef MBPUSHBUTTON_H 2 | #define MBPUSHBUTTON_H 3 | 4 | #include 5 | #include 6 | 7 | class MbPushButton : public QPushButton 8 | { 9 | Q_OBJECT 10 | public: 11 | explicit MbPushButton(QWidget *parent = nullptr); 12 | explicit MbPushButton(QString txt, QWidget *parent = nullptr); 13 | 14 | protected: 15 | void mousePressEvent(QMouseEvent *e); 16 | void mouseReleaseEvent(QMouseEvent *e); 17 | void mouseMoveEvent(QMouseEvent *e); 18 | void enterEvent(QEvent *event); 19 | void leaveEvent(QEvent *event); 20 | 21 | signals: 22 | void rightClicked(); 23 | void enter(); 24 | void leave(); 25 | 26 | public slots: 27 | }; 28 | 29 | #endif // MBPUSHBUTTON_H 30 | -------------------------------------------------------------------------------- /src/widgets/basics/switch.cpp: -------------------------------------------------------------------------------- 1 | #include "switch.h" 2 | 3 | Switch::Switch(QWidget *parent) : QAbstractButton(parent), 4 | _opacity(0.000), 5 | _height(16), 6 | _margin(3) 7 | { 8 | setOffset(_height / 2); 9 | _y = _height / 2; 10 | setBrush(QColor("#009688")); 11 | setCheckable(true); 12 | } 13 | 14 | Switch::Switch(const QBrush &brush, QWidget *parent) : QAbstractButton(parent), 15 | _opacity(0.000), 16 | _height(16), 17 | _margin(3) 18 | { 19 | setOffset(_height / 2); 20 | _y = _height / 2; 21 | setBrush(brush); 22 | setCheckable(true); 23 | } 24 | 25 | void Switch::paintEvent(QPaintEvent *e) { 26 | (void)e; 27 | QPainter p(this); 28 | p.setPen(Qt::NoPen); 29 | if (isEnabled()) { 30 | setOffset(isChecked() ? width() - (_height) : _height / 2); 31 | p.setBrush(isChecked() ? brush() : Qt::black); 32 | p.setOpacity(isChecked() ? 0.5 : 0.38); 33 | p.setRenderHint(QPainter::Antialiasing, true); 34 | p.drawRoundedRect(QRect(_margin, _margin, width() - 2 * _margin, height() - 2 * _margin), 8.0, 8.0); 35 | p.setBrush(isChecked() ? brush() : QBrush("#d5d5d5")); 36 | p.setOpacity(1.0); 37 | p.drawEllipse(QRectF(offset() - (_height / 2), _y - (_height / 2), height(), height())); 38 | } else { 39 | p.setBrush(Qt::black); 40 | p.setOpacity(0.12); 41 | p.drawRoundedRect(QRect(_margin, _margin, width() - 2 * _margin, height() - 2 * _margin), 8.0, 8.0); 42 | p.setOpacity(1.0); 43 | p.setBrush(QColor("#BDBDBD")); 44 | p.drawEllipse(QRectF(offset() - (_height / 2), _y - (_height / 2), height(), height())); 45 | } 46 | } 47 | 48 | void Switch::enterEvent(QEvent *e) { 49 | setCursor(Qt::PointingHandCursor); 50 | QAbstractButton::enterEvent(e); 51 | } 52 | 53 | QSize Switch::sizeHint() const { 54 | return QSize(2 * (_height + _margin), _height + 2 * _margin); 55 | } 56 | -------------------------------------------------------------------------------- /src/widgets/basics/switch.h: -------------------------------------------------------------------------------- 1 | #ifndef SWITCH_H 2 | #define SWITCH_H 3 | 4 | #include 5 | 6 | class Switch : public QAbstractButton { 7 | Q_OBJECT 8 | Q_PROPERTY(int offset READ offset WRITE setOffset) 9 | Q_PROPERTY(QBrush brush READ brush WRITE setBrush) 10 | 11 | public: 12 | Switch(QWidget* parent = nullptr); 13 | Switch(const QBrush& brush, QWidget* parent = nullptr); 14 | 15 | QSize sizeHint() const override; 16 | 17 | QBrush brush() const { 18 | return _brush; 19 | } 20 | void setBrush(const QBrush &brsh) { 21 | _brush = brsh; 22 | } 23 | 24 | int offset() const { 25 | return _x; 26 | } 27 | void setOffset(int o) { 28 | _x = o; 29 | update(); 30 | } 31 | 32 | protected: 33 | void paintEvent(QPaintEvent*) override; 34 | void enterEvent(QEvent*) override; 35 | 36 | private: 37 | qreal _opacity; 38 | int _x, _y, _height, _margin; 39 | QBrush _brush; 40 | }; 41 | 42 | #endif // SWITCH_H 43 | -------------------------------------------------------------------------------- /src/widgets/chat.h: -------------------------------------------------------------------------------- 1 | #ifndef CHAT_H 2 | #define CHAT_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class Chat; 8 | } 9 | 10 | class Chat : public QFrame 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit Chat(QWidget *parent = nullptr); 16 | ~Chat(); 17 | 18 | private: 19 | 20 | void onSend(); 21 | //void onNewMessage(); 22 | void addMessage(QString txt, QString source, QString dst=QString(), bool sent=false); 23 | 24 | void onNewAircraft(QString ac_id); 25 | void onAcDeleted(QString ac_id); 26 | 27 | QString chat_id; 28 | 29 | Ui::Chat *ui; 30 | }; 31 | 32 | #endif // CHAT_H 33 | -------------------------------------------------------------------------------- /src/widgets/checklist.h: -------------------------------------------------------------------------------- 1 | #ifndef CHECKLIST_H 2 | #define CHECKLIST_H 3 | 4 | #include 5 | #include "airframe.h" 6 | 7 | namespace Ui { 8 | class Checklist; 9 | } 10 | 11 | class Checklist : public QFrame 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit Checklist(QString ac_id, QWidget *parent = nullptr); 17 | ~Checklist(); 18 | 19 | private: 20 | void sendMessage(QString ac_id, ChecklistItem *item); 21 | 22 | QString pprzlink_id; 23 | Ui::Checklist *ui; 24 | }; 25 | 26 | #endif // CHECKLIST_H 27 | -------------------------------------------------------------------------------- /src/widgets/checklist.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Checklist 4 | 5 | 6 | 7 | 0 8 | 0 9 | 350 10 | 30 11 | 12 | 13 | 14 | 15 | 350 16 | 30 17 | 18 | 19 | 20 | Form 21 | 22 | 23 | QFrame::StyledPanel 24 | 25 | 26 | QFrame::Sunken 27 | 28 | 29 | 30 | 9 31 | 32 | 33 | 34 | 35 | font-weight:bold; 36 | 37 | 38 | Checklist 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /src/widgets/commands.h: -------------------------------------------------------------------------------- 1 | #ifndef COMMANDS_H 2 | #define COMMANDS_H 3 | 4 | #include 5 | #include "setting.h" 6 | #include "pprz_dispatcher.h" 7 | 8 | class Commands : public QWidget 9 | { 10 | Q_OBJECT 11 | public: 12 | explicit Commands(QString ac_id, QWidget *parent = nullptr); 13 | 14 | signals: 15 | 16 | public slots: 17 | 18 | protected: 19 | void paintEvent(QPaintEvent*) override; 20 | 21 | private: 22 | void addFlightPlanButtons(QGridLayout* fp_buttons_layout); 23 | void addSettingsButtons(QGridLayout* settings_buttons_layout); 24 | void addSpecialCommands(QGridLayout* special_commands_layout); 25 | void addCommandButton(QGridLayout*, QString icon, int row, int col, std::function callback, QString tootltip=""); 26 | 27 | void updateTargetAlt(pprzlink::Message msg); 28 | 29 | QString ac_id; 30 | 31 | float target_alt; 32 | }; 33 | 34 | #endif // COMMANDS_H 35 | -------------------------------------------------------------------------------- /src/widgets/flightplan_viewerv2.h: -------------------------------------------------------------------------------- 1 | #ifndef FLIGHTPLAN_VIEWERV2_H 2 | #define FLIGHTPLAN_VIEWERV2_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "pprz_dispatcher.h" 9 | 10 | class FlightPlanViewerV2 : public QTabWidget 11 | { 12 | Q_OBJECT 13 | public: 14 | explicit FlightPlanViewerV2(QString ac_id, QWidget *parent = nullptr); 15 | 16 | signals: 17 | 18 | public slots: 19 | 20 | private: 21 | void handleNavStatus(); 22 | void updateNavStatus(uint8_t cur_block, uint8_t cur_stage); 23 | 24 | QWidget* make_blocks_tab(); 25 | QString ac_id; 26 | uint8_t current_block, current_stage; 27 | 28 | QList block_labels; 29 | 30 | QString labels_stylesheet; 31 | }; 32 | 33 | #endif // FLIGHTPLAN_VIEWERV2_H 34 | -------------------------------------------------------------------------------- /src/widgets/flightplaneditor.h: -------------------------------------------------------------------------------- 1 | #ifndef FLIGHTPLANEDITOR_H 2 | #define FLIGHTPLANEDITOR_H 3 | 4 | #include 5 | #include 6 | #include "waypoint.h" 7 | 8 | namespace Ui { 9 | class FlightPlanEditor; 10 | } 11 | 12 | struct AttributeDef { 13 | const xmlChar* name; 14 | bool required; 15 | }; 16 | 17 | class FlightPlanEditor : public QWidget 18 | { 19 | Q_OBJECT 20 | public: 21 | explicit FlightPlanEditor(QString ac_id, QWidget *parent = nullptr); 22 | ~FlightPlanEditor(); 23 | 24 | int parse(QString filename); 25 | 26 | bool validate(); 27 | QByteArray output(); 28 | 29 | signals: 30 | void waypointEdited(Waypoint*); 31 | 32 | private: 33 | Ui::FlightPlanEditor *ui; 34 | 35 | static void applyRecursive(QTreeWidgetItem* item, std::function f); 36 | 37 | void onItemClicked(QTreeWidgetItem *item, int column); 38 | void onItemDoubleClicked(QTreeWidgetItem *item, int column); 39 | void onAttributeChanged(QTreeWidgetItem *item, int column); 40 | void onNavStatus(); 41 | 42 | void onMoveWaypointUi(Waypoint*, QString ac_id); 43 | void onWaypointAdded(Waypoint*, QString ac_id); 44 | 45 | QTreeWidgetItem* populate(xmlNodePtr node, QTreeWidgetItem* parent=nullptr, QTreeWidgetItem* prev=nullptr); 46 | 47 | void openElementsContextMenu(QPoint pos); 48 | void openAttributesContextMenu(QPoint pos); 49 | void onArrowClicked(bool up); 50 | 51 | QString sumaryFromNode(xmlNodePtr node); 52 | 53 | QList attributeDefs(const xmlChar* nodeName); 54 | QStringList elementDefs(xmlElementContentPtr c); 55 | 56 | QString ac_id; 57 | 58 | xmlDocPtr doc; 59 | xmlDtdPtr dtd; 60 | 61 | QMap nodes; 62 | QMap attributes_nodes; 63 | QMap waypoints; 64 | QMap blocks; 65 | 66 | uint8_t last_block; 67 | 68 | QTreeWidgetItem* waypoints_item; 69 | 70 | bool readOnly; 71 | 72 | }; 73 | 74 | #endif // FLIGHTPLANEDITOR_H 75 | -------------------------------------------------------------------------------- /src/widgets/gps_classic_viewer.h: -------------------------------------------------------------------------------- 1 | #ifndef GPS_CLASSIC_VIEWER_H 2 | #define GPS_CLASSIC_VIEWER_H 3 | 4 | #include 5 | 6 | class GPSClassicViewer : public QWidget 7 | { 8 | Q_OBJECT 9 | public: 10 | explicit GPSClassicViewer(QString ac_id, QWidget *parent = nullptr); 11 | 12 | QSize sizeHint() const; 13 | QSize minimumSizeHint() const; 14 | 15 | protected: 16 | void paintEvent(QPaintEvent *event); 17 | virtual void mousePressEvent(QMouseEvent *event); 18 | 19 | signals: 20 | 21 | public slots: 22 | 23 | private: 24 | 25 | struct SvInfo { 26 | int id; 27 | int flags; 28 | int cno; 29 | int age; 30 | }; 31 | 32 | std::tuple> getData(); 33 | 34 | static const int SV_WIDTH = 30; 35 | 36 | QString ac_id; 37 | 38 | QSize minSize; 39 | 40 | bool reduced; 41 | }; 42 | 43 | #endif // GPS_CLASSIC_VIEWER_H 44 | -------------------------------------------------------------------------------- /src/widgets/gvf_viewer.h: -------------------------------------------------------------------------------- 1 | #ifndef GVF_SETTINGS_H 2 | #define GVF_SETTINGS_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "colorbar.h" 9 | 10 | class GVFViewer : public QWidget 11 | { 12 | Q_OBJECT 13 | public: 14 | explicit GVFViewer(QString ac_id, QWidget *parent = nullptr); 15 | 16 | private: 17 | void init(); 18 | 19 | QString ac_id; 20 | 21 | QVector gvfV_config; 22 | QVector gvfV_default_Vfield_config; 23 | QVector gvfV_parametric_config; 24 | 25 | QString viewer_mode; 26 | }; 27 | 28 | #endif // GVF_SETTINGS_H -------------------------------------------------------------------------------- /src/widgets/layer_combo.h: -------------------------------------------------------------------------------- 1 | #ifndef LAYER_COMBO_H 2 | #define LAYER_COMBO_H 3 | 4 | #include 5 | #include 6 | #include "maplayercontrol.h" 7 | 8 | class LayerCombo : public QWidget 9 | { 10 | Q_OBJECT 11 | public: 12 | explicit LayerCombo(QWidget *parent = nullptr); 13 | 14 | void addLayerControl(MapLayerControl* mlc); 15 | void makeLayerControl(QString name, bool initialState, int z); 16 | bool eventFilter(QObject *object, QEvent *event); 17 | 18 | void setPopo(QPoint p) {_pos = p;} 19 | 20 | signals: 21 | void showLayer(QString name, bool state, int zValue, qreal opacity); 22 | void layerOpacityChanged(QString name, qreal opacity); 23 | void zValueChanged(QString name, int z); 24 | 25 | public slots: 26 | 27 | protected: 28 | virtual void mouseMoveEvent(QMouseEvent* e); 29 | virtual void mousePressEvent(QMouseEvent* e); 30 | virtual void mouseReleaseEvent(QMouseEvent* e); 31 | 32 | private: 33 | 34 | 35 | QScrollArea* scroll; 36 | QWidget* scroll_content; 37 | QVBoxLayout* content_layout; 38 | QVBoxLayout* main_layout; 39 | 40 | QPoint _pos; 41 | 42 | QList map_layer_controls; 43 | 44 | MapLayerControl* moved_layer_control; 45 | QPoint press_pos; 46 | QLabel* moved_thumbnail; 47 | }; 48 | 49 | #endif // LAYER_COMBO_H 50 | -------------------------------------------------------------------------------- /src/widgets/link_status.h: -------------------------------------------------------------------------------- 1 | #ifndef LINKSTATUS_H 2 | #define LINKSTATUS_H 3 | 4 | #include 5 | #include "colorlabel.h" 6 | 7 | class LinkStatus : public QWidget 8 | { 9 | Q_OBJECT 10 | public: 11 | explicit LinkStatus(QString ac_id, QWidget *parent = nullptr); 12 | 13 | signals: 14 | 15 | private: 16 | 17 | void updateData(); 18 | 19 | struct Status { 20 | QLabel* link_id; 21 | ColorLabel* status; 22 | QLabel* ping_time; 23 | QLabel* link_rx; 24 | QLabel* downlink; 25 | QLabel* uplink_lost; 26 | }; 27 | 28 | QString ac_id; 29 | 30 | QGridLayout* grid_layout; 31 | 32 | QLabel* t_link_id; 33 | QLabel* t_status; 34 | QLabel* t_ping_time; 35 | QLabel* t_link_rx; 36 | QLabel* t_downlink; 37 | QLabel* t_uplink_lost; 38 | 39 | QMap links; 40 | 41 | }; 42 | 43 | #endif // LINKSTATUS_H 44 | -------------------------------------------------------------------------------- /src/widgets/listcontainer.h: -------------------------------------------------------------------------------- 1 | #ifndef LISTCONTAINER_H 2 | #define LISTCONTAINER_H 3 | 4 | #include 5 | #include 6 | #include "configurable.h" 7 | #include "strip.h" 8 | 9 | class ListContainer : public QScrollArea, public Configurable 10 | { 11 | Q_OBJECT 12 | public: 13 | explicit ListContainer(std::function constructor,std::function alt_constructor, QWidget *parent = nullptr); 14 | explicit ListContainer(std::function constructor, QWidget *parent = nullptr); 15 | void configure(QDomElement c) override {conf = c;} 16 | 17 | signals: 18 | 19 | private: 20 | void handleNewAC(QString ac_id); 21 | void removeAC(QString ac_id); 22 | 23 | std::function constructor; 24 | std::function alt_constructor; 25 | 26 | QMap widgets; 27 | QMap alt_widgets; 28 | 29 | QMap buttons; 30 | QGridLayout* grid_layout; 31 | 32 | QDomElement conf; 33 | 34 | public slots: 35 | }; 36 | 37 | #endif // LISTCONTAINER_H 38 | -------------------------------------------------------------------------------- /src/widgets/map/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | set(SOURCE 3 | ${SOURCE} 4 | ${CMAKE_CURRENT_SOURCE_DIR}/tileprovider.cpp 5 | ${CMAKE_CURRENT_SOURCE_DIR}/tileproviderconfig.cpp 6 | ${CMAKE_CURRENT_SOURCE_DIR}/tileitem.cpp 7 | ${CMAKE_CURRENT_SOURCE_DIR}/map2d.cpp 8 | ${CMAKE_CURRENT_SOURCE_DIR}/mapwidget.cpp 9 | ${CMAKE_CURRENT_SOURCE_DIR}/maplayercontrol.cpp 10 | ${CMAKE_CURRENT_SOURCE_DIR}/mapscene.cpp 11 | ${CMAKE_CURRENT_SOURCE_DIR}/maputils.cpp 12 | ${CMAKE_CURRENT_SOURCE_DIR}/waypointeditor.cpp 13 | ${CMAKE_CURRENT_SOURCE_DIR}/acitemmanager.cpp 14 | ${CMAKE_CURRENT_SOURCE_DIR}/papget.cpp 15 | ${CMAKE_CURRENT_SOURCE_DIR}/papgetconfig.cpp 16 | ) 17 | 18 | add_subdirectory(map_items) 19 | add_subdirectory(graphics_objects) 20 | add_subdirectory(fpedit_statemachines) 21 | add_subdirectory(gvf_trajectories) 22 | 23 | set(INC_DIRS ${INC_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}) 24 | 25 | set(SOURCE ${SOURCE} PARENT_SCOPE) 26 | set(INC_DIRS ${INC_DIRS} PARENT_SCOPE) 27 | -------------------------------------------------------------------------------- /src/widgets/map/acitemmanager.h: -------------------------------------------------------------------------------- 1 | #ifndef ACITEMMANAGER_H 2 | #define ACITEMMANAGER_H 3 | 4 | #include "map_item.h" 5 | #include "waypoint_item.h" 6 | #include "aircraft_item.h" 7 | #include "path_item.h" 8 | #include "mapwidget.h" 9 | #include "circle_item.h" 10 | #include "arrow_item.h" 11 | #include "gvf_trajectory.h" 12 | 13 | class ACItemManager: public QObject 14 | { 15 | Q_OBJECT 16 | public: 17 | ACItemManager(QString ac_id, WaypointItem* target, AircraftItem* aircraft_item, ArrowItem* arrow_item, WaypointItem* crash_item, QObject* parent=nullptr); 18 | 19 | void addWaypointItem(WaypointItem*); 20 | void addPathItem(PathItem*); 21 | void setCurrentNavShape(MapItem*); 22 | void setMaxDistCircle(CircleItem*); 23 | void setCurrentGVF(GVF_trajectory*); 24 | 25 | QList getWaypointsItems() {return waypointItems;} 26 | WaypointItem* getTarget() {return target;} 27 | MapItem* getCurrentNavShape() {return current_nav_shape;} 28 | AircraftItem* getAircraftItem() {return aircraft_item;} 29 | ArrowItem* getArrowItem() {return arrow_item;} 30 | WaypointItem* getCrashItem() {return crash_item;} 31 | void removeItems(MapWidget* map); 32 | 33 | private: 34 | QString ac_id; 35 | QList waypointItems; 36 | QList pathItems; 37 | WaypointItem* target; 38 | AircraftItem* aircraft_item; 39 | MapItem* current_nav_shape; 40 | CircleItem* max_dist_circle; 41 | ArrowItem* arrow_item; 42 | WaypointItem* crash_item; 43 | 44 | GVF_trajectory* gvf_trajectory; 45 | }; 46 | 47 | #endif // ACITEMMANAGER_H 48 | -------------------------------------------------------------------------------- /src/widgets/map/fpedit_statemachines/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | #set(SOURCE 3 | # ${SOURCE} 4 | # ${CMAKE_CURRENT_SOURCE_DIR}/item_edit_state_machine.cpp 5 | # ${CMAKE_CURRENT_SOURCE_DIR}/waypointitem_sm.cpp 6 | # ${CMAKE_CURRENT_SOURCE_DIR}/circleitem_sm.cpp 7 | # ${CMAKE_CURRENT_SOURCE_DIR}/pathitem_sm.cpp 8 | #) 9 | 10 | set(INC_DIRS ${INC_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}) 11 | 12 | set(SOURCE ${SOURCE} PARENT_SCOPE) 13 | set(INC_DIRS ${INC_DIRS} PARENT_SCOPE) 14 | 15 | -------------------------------------------------------------------------------- /src/widgets/map/fpedit_statemachines/circleitem_sm.h: -------------------------------------------------------------------------------- 1 | #ifndef SMCIRCLEITEM_H 2 | #define SMCIRCLEITEM_H 3 | 4 | #include "item_edit_state_machine.h" 5 | #include "circle_item.h" 6 | 7 | class SmCircleItem : public ItemEditStateMachine 8 | { 9 | public: 10 | SmCircleItem(MapWidget* map); 11 | ~SmCircleItem(); 12 | virtual MapItem* update(SmEditEvent event_type, QGraphicsSceneMouseEvent* mouseEvent, WaypointItem* waypoint, QString ac_id, MapItem* item = nullptr); 13 | 14 | private: 15 | enum State { 16 | IDLE, 17 | PRESSED, // mouse pressed, move < hysteresis. 18 | DRAGING, // mouse dragged after the press. expand the circle according to mouse moves 19 | RELEASED, // mouse released after the press. Wait for next press event to set circle radius. 20 | }; 21 | 22 | void adjustCircleRadius(QGraphicsSceneMouseEvent* mouseEvent); 23 | QPointF pressPos; 24 | CircleItem* cir; 25 | State state; 26 | }; 27 | 28 | #endif // SMCIRCLEITEM_H 29 | -------------------------------------------------------------------------------- /src/widgets/map/fpedit_statemachines/item_edit_state_machine.cpp: -------------------------------------------------------------------------------- 1 | #include "item_edit_state_machine.h" 2 | 3 | ItemEditStateMachine::ItemEditStateMachine(MapWidget* map) : 4 | map(map) 5 | { 6 | 7 | } 8 | 9 | ItemEditStateMachine::~ItemEditStateMachine(){ 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/widgets/map/fpedit_statemachines/item_edit_state_machine.h: -------------------------------------------------------------------------------- 1 | #ifndef FPEDITSTATEMACHINE_H 2 | #define FPEDITSTATEMACHINE_H 3 | 4 | #include "map_item.h" 5 | #include 6 | #include 7 | #include "coordinatestransform.h" 8 | 9 | class MapWidget; 10 | class WaypointItem; 11 | 12 | enum SmEditEvent { 13 | FPEE_SC_PRESS, 14 | FPEE_SC_MOVE, 15 | FPEE_SC_RELEASE, 16 | FPEE_SC_DOUBLE_CLICK, 17 | FPEE_WP_CLICKED, 18 | FPEE_CANCEL, 19 | }; 20 | 21 | class ItemEditStateMachine 22 | { 23 | public: 24 | ItemEditStateMachine(MapWidget* map); 25 | virtual ~ItemEditStateMachine(); 26 | /// 27 | /// \brief update 28 | /// \param event_type 29 | /// \param mouseEvent: mouse event if applicable. Must point to valid data if @event_type is FPEE_SC_*. (can be null otherwise) 30 | /// \param waypoint: base waypoint for the item (eg. center of a circle, waypoint in a path...). Must point to valid data if @event_type is FPEE_WP_CLICKED. (can be null otherwise) 31 | /// \param color 32 | /// \param item: item to edit (only applicable for the path?) 33 | /// \return 34 | /// 35 | virtual MapItem* update(SmEditEvent event_type, QGraphicsSceneMouseEvent* mouseEvent, WaypointItem* waypoint, QString ac_id, MapItem* item = nullptr) = 0; 36 | 37 | protected: 38 | MapWidget* map; 39 | }; 40 | 41 | #endif // FPEDITSTATEMACHINE_H 42 | -------------------------------------------------------------------------------- /src/widgets/map/fpedit_statemachines/pathitem_sm.h: -------------------------------------------------------------------------------- 1 | #ifndef SMPATHITEM_H 2 | #define SMPATHITEM_H 3 | 4 | #include "item_edit_state_machine.h" 5 | #include "path_item.h" 6 | #include "waypoint_item.h" 7 | 8 | class SmPathItem : public ItemEditStateMachine 9 | { 10 | public: 11 | SmPathItem(MapWidget* map); 12 | ~SmPathItem(); 13 | virtual MapItem* update(SmEditEvent event_type, QGraphicsSceneMouseEvent* mouseEvent, WaypointItem* waypoint, QString ac_id, MapItem* item = nullptr); 14 | 15 | private: 16 | 17 | enum State { 18 | IDLE, 19 | PRESS_INI, 20 | MOVE_INI, 21 | MOVING, 22 | }; 23 | 24 | PathItem* path; 25 | WaypointItem* lastWp; 26 | WaypointItem* previousWp; 27 | State state; 28 | QPointF pressPos; 29 | 30 | QString ac_id; 31 | 32 | }; 33 | 34 | #endif // SMPATHITEM_H 35 | -------------------------------------------------------------------------------- /src/widgets/map/fpedit_statemachines/waypointitem_sm.h: -------------------------------------------------------------------------------- 1 | #ifndef SMWAYPOINTITEM_H 2 | #define SMWAYPOINTITEM_H 3 | 4 | #include "item_edit_state_machine.h" 5 | #include "waypoint_item.h" 6 | 7 | class SmWaypointItem : public ItemEditStateMachine 8 | { 9 | public: 10 | SmWaypointItem(MapWidget* map); 11 | ~SmWaypointItem(); 12 | virtual MapItem* update(SmEditEvent event_type, QGraphicsSceneMouseEvent* mouseEvent, WaypointItem* waypoint, QString ac_id, MapItem* item = nullptr); 13 | 14 | private: 15 | 16 | enum State { 17 | IDLE, 18 | MOVING, 19 | }; 20 | 21 | WaypointItem* wp; 22 | State state; 23 | }; 24 | 25 | #endif // SMWAYPOINTITEM_H 26 | -------------------------------------------------------------------------------- /src/widgets/map/graphics_objects/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | set(SOURCE 3 | ${SOURCE} 4 | ${CMAKE_CURRENT_SOURCE_DIR}/graphics_object.cpp 5 | ${CMAKE_CURRENT_SOURCE_DIR}/graphics_point.cpp 6 | ${CMAKE_CURRENT_SOURCE_DIR}/graphics_line.cpp 7 | ${CMAKE_CURRENT_SOURCE_DIR}/graphics_circle.cpp 8 | ${CMAKE_CURRENT_SOURCE_DIR}/graphics_aircraft.cpp 9 | ${CMAKE_CURRENT_SOURCE_DIR}/graphics_text.cpp 10 | ${CMAKE_CURRENT_SOURCE_DIR}/graphics_intruder.cpp 11 | ${CMAKE_CURRENT_SOURCE_DIR}/graphics_group.cpp 12 | ${CMAKE_CURRENT_SOURCE_DIR}/graphics_icon.cpp 13 | ${CMAKE_CURRENT_SOURCE_DIR}/graphics_quiver.cpp 14 | 15 | ) 16 | 17 | set(INC_DIRS ${INC_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}) 18 | 19 | set(SOURCE ${SOURCE} PARENT_SCOPE) 20 | set(INC_DIRS ${INC_DIRS} PARENT_SCOPE) 21 | 22 | -------------------------------------------------------------------------------- /src/widgets/map/graphics_objects/graphics_aircraft.h: -------------------------------------------------------------------------------- 1 | #ifndef GRAPHICS_AIRCRAFT_H 2 | #define GRAPHICS_AIRCRAFT_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include "graphics_object.h" 8 | 9 | class GraphicsAircraft : public GraphicsObject, public QGraphicsItem 10 | { 11 | Q_OBJECT 12 | Q_INTERFACES(QGraphicsItem) 13 | public: 14 | GraphicsAircraft(PprzPalette palette, QString icon_path, int size, QObject *parent = nullptr); 15 | 16 | QRectF boundingRect() const override; 17 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; 18 | 19 | protected: 20 | virtual void changeFocus() override; 21 | 22 | private: 23 | void loadSvg(QString path); 24 | void changeColor(QColor color); 25 | 26 | int size; 27 | QPixmap pixmap; 28 | QDomDocument svgdoc; 29 | }; 30 | 31 | #endif // GRAPHICS_AIRCRAFT_H 32 | -------------------------------------------------------------------------------- /src/widgets/map/graphics_objects/graphics_circle.h: -------------------------------------------------------------------------------- 1 | #ifndef GRAPHICSCIRCLE_H 2 | #define GRAPHICSCIRCLE_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include "graphics_object.h" 8 | #include "pprzpalette.h" 9 | 10 | enum CircleScaleState { 11 | CSS_IDLE, 12 | CSS_PRESSED, 13 | CSS_SCALED, 14 | }; 15 | 16 | class GraphicsCircle : public GraphicsObject, public QGraphicsItem 17 | { 18 | Q_OBJECT 19 | Q_INTERFACES(QGraphicsItem) 20 | public: 21 | explicit GraphicsCircle(double radius, PprzPalette palette, int stroke, QObject *parent = nullptr); 22 | void setRadius(double r); 23 | void displayRadius(bool dpr) {display_radius = dpr;} 24 | void setTextPos(QPointF pos) {textPos = pos;} 25 | void setText(QString t) {text = t;} 26 | void setFilled(bool f) {filled = f;} 27 | 28 | QRectF boundingRect() const override; 29 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; 30 | QPainterPath shape() const override; 31 | 32 | signals: 33 | void circleScaled(qreal size); 34 | void circleScaleFinished(); 35 | 36 | protected: 37 | virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) override; 38 | virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override; 39 | virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override; 40 | virtual void changeFocus() override; 41 | 42 | 43 | public slots: 44 | 45 | private: 46 | 47 | double dr; 48 | QPointF textPos; 49 | double radius; 50 | CircleScaleState scale_state; 51 | QFont font_radius; 52 | 53 | int current_color; 54 | 55 | int base_stroke; 56 | int stroke; 57 | QPainterPath path_draw; 58 | QPainterPath path_shape; 59 | QString text; 60 | 61 | bool display_radius; 62 | QRectF last_bounding_rect; 63 | 64 | bool filled; 65 | }; 66 | 67 | #endif // GRAPHICSCIRCLE_H 68 | 69 | 70 | -------------------------------------------------------------------------------- /src/widgets/map/graphics_objects/graphics_group.cpp: -------------------------------------------------------------------------------- 1 | #include "graphics_group.h" 2 | #include 3 | #include 4 | 5 | GraphicsGroup::GraphicsGroup(QObject *parent) : 6 | GraphicsGroup(PprzPalette(), parent) 7 | {} 8 | 9 | GraphicsGroup::GraphicsGroup(PprzPalette palette, QObject *parent) : 10 | GraphicsObject(palette, parent), 11 | QGraphicsItemGroup() 12 | { 13 | 14 | } 15 | 16 | void GraphicsGroup::arrange() { 17 | auto items = childItems(); 18 | 19 | QSizeF max_size = std::accumulate(items.begin(), items.end(), QSizeF(0, 0), [](QSizeF s, QGraphicsItem* i) { 20 | auto is = i->boundingRect().size(); 21 | return s.expandedTo(is); 22 | }); 23 | 24 | int x = 0; 25 | for(auto &item: childItems()) { 26 | auto s = item->boundingRect().size(); 27 | auto h = s.height(); 28 | int y = (max_size.height() - h) / 2; 29 | 30 | if(item->isVisible()) { 31 | item->setPos(x, y); 32 | x += s.width(); 33 | } else { 34 | item->setPos(0, y); 35 | } 36 | } 37 | } 38 | 39 | QRectF GraphicsGroup::boundingRect() const 40 | { 41 | return childrenBoundingRect(); 42 | } 43 | 44 | void GraphicsGroup::mousePressEvent(QGraphicsSceneMouseEvent *event) { 45 | emit mousePressed(event); 46 | } 47 | 48 | void GraphicsGroup::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { 49 | emit mouseMoved(event); 50 | } 51 | 52 | void GraphicsGroup::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { 53 | emit mouseReleased(event); 54 | } 55 | 56 | void GraphicsGroup::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) { 57 | emit mouseDoubleClicked(event); 58 | } 59 | 60 | void GraphicsGroup::changeFocus() { 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/widgets/map/graphics_objects/graphics_group.h: -------------------------------------------------------------------------------- 1 | #ifndef GRAPHICS_GROUP_H 2 | #define GRAPHICS_GROUP_H 3 | 4 | #include 5 | #include 6 | #include "graphics_object.h" 7 | #include 8 | #include "pprzpalette.h" 9 | 10 | class GraphicsGroup : public GraphicsObject, public QGraphicsItemGroup 11 | { 12 | Q_OBJECT 13 | Q_INTERFACES(QGraphicsItem) 14 | public: 15 | explicit GraphicsGroup(QObject *parent = nullptr); 16 | explicit GraphicsGroup(PprzPalette palette, QObject *parent = nullptr); 17 | 18 | QRectF boundingRect() const override; 19 | 20 | void arrange(); 21 | 22 | signals: 23 | void mousePressed(QGraphicsSceneMouseEvent *event); 24 | void mouseMoved(QGraphicsSceneMouseEvent *event); 25 | void mouseReleased(QGraphicsSceneMouseEvent *event); 26 | void mouseDoubleClicked(QGraphicsSceneMouseEvent *event); 27 | 28 | protected: 29 | virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) override; 30 | virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override; 31 | virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override; 32 | virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override; 33 | virtual void changeFocus() override; 34 | 35 | }; 36 | 37 | #endif // GRAPHICS_GROUP_H 38 | -------------------------------------------------------------------------------- /src/widgets/map/graphics_objects/graphics_icon.cpp: -------------------------------------------------------------------------------- 1 | #include "graphics_icon.h" 2 | #include 3 | #include 4 | 5 | GraphicsIcon::GraphicsIcon(QString icon_path, int size, QObject *parent) : 6 | GraphicsObject(PprzPalette(), parent), 7 | size(size) 8 | { 9 | renderer = new QSvgRenderer(icon_path, this); 10 | } 11 | 12 | QRectF GraphicsIcon::boundingRect() const { 13 | return QRectF(0, 0, size*scale_factor, size*scale_factor); 14 | } 15 | 16 | void GraphicsIcon::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { 17 | (void)option; 18 | (void)widget; 19 | painter->setRenderHint(QPainter::Antialiasing); 20 | renderer->render(painter, QRect(0, 0, size*scale_factor, size*scale_factor)); 21 | } 22 | 23 | void GraphicsIcon::changeFocus() { 24 | update(); 25 | } 26 | 27 | void GraphicsIcon::setIcon(QString filename) { 28 | renderer->deleteLater(); 29 | renderer = new QSvgRenderer(filename, this); 30 | } 31 | -------------------------------------------------------------------------------- /src/widgets/map/graphics_objects/graphics_icon.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include "graphics_object.h" 6 | #include 7 | #include 8 | 9 | class GraphicsIcon : public GraphicsObject, public QGraphicsItem 10 | { 11 | Q_OBJECT 12 | Q_INTERFACES(QGraphicsItem) 13 | public: 14 | GraphicsIcon(QString icon_path, int size, QObject *parent = nullptr); 15 | void setIcon(QString filename); 16 | 17 | QRectF boundingRect() const override; 18 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; 19 | 20 | protected: 21 | virtual void changeFocus() override; 22 | 23 | private: 24 | int size; 25 | QSvgRenderer* renderer; 26 | }; 27 | -------------------------------------------------------------------------------- /src/widgets/map/graphics_objects/graphics_intruder.cpp: -------------------------------------------------------------------------------- 1 | #include "graphics_intruder.h" 2 | #include 3 | #include 4 | 5 | GraphicsIntruder::GraphicsIntruder(int size, PprzPalette palette, QObject *parent) : 6 | GraphicsObject(palette, parent), 7 | QGraphicsItem (), 8 | size(size) 9 | { 10 | 11 | } 12 | 13 | QRectF GraphicsIntruder::boundingRect() const { 14 | return QRectF(-size, -size, 2*size, 2*size); 15 | } 16 | 17 | void GraphicsIntruder::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { 18 | (void)option; 19 | (void)widget; 20 | painter->setPen(QPen(Qt::red, 3)); 21 | 22 | painter->drawEllipse(QPoint(0, 0), size/3, size/3); 23 | 24 | painter->drawLine(0, 0, 0, -size); 25 | 26 | painter->drawLine(0, -size, -size/10, -9*size/10); 27 | painter->drawLine(0, -size, size/10, -9*size/10); 28 | } 29 | 30 | 31 | void GraphicsIntruder::changeFocus() { 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/widgets/map/graphics_objects/graphics_intruder.h: -------------------------------------------------------------------------------- 1 | #ifndef GRAPHICSINTRUDER_H 2 | #define GRAPHICSINTRUDER_H 3 | 4 | #include 5 | #include "graphics_object.h" 6 | 7 | class GraphicsIntruder : public GraphicsObject, public QGraphicsItem 8 | { 9 | Q_OBJECT 10 | Q_INTERFACES(QGraphicsItem) 11 | public: 12 | explicit GraphicsIntruder(int size, PprzPalette palette, QObject *parent = nullptr); 13 | 14 | QRectF boundingRect() const override; 15 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; 16 | //QPainterPath shape() const override; 17 | 18 | protected: 19 | virtual void changeFocus() override; 20 | 21 | private: 22 | int size; 23 | }; 24 | 25 | #endif // GRAPHICSINTRUDER_H 26 | -------------------------------------------------------------------------------- /src/widgets/map/graphics_objects/graphics_line.h: -------------------------------------------------------------------------------- 1 | #ifndef GRAPHICSLINE_H 2 | #define GRAPHICSLINE_H 3 | 4 | #include 5 | #include 6 | #include "graphics_object.h" 7 | #include 8 | #include "pprzpalette.h" 9 | 10 | class GraphicsLine : public GraphicsObject, public QGraphicsItem 11 | { 12 | Q_OBJECT 13 | Q_INTERFACES(QGraphicsItem) 14 | public: 15 | 16 | explicit GraphicsLine(QPointF a, QPointF b, PprzPalette palette, int stroke, QObject *parent = nullptr); 17 | virtual void changeFocus() override; 18 | void setIgnoreEvent(bool ignore) {ignore_events = ignore;} 19 | //void setText(QString t) {text = t;} 20 | void setLine(QPointF a, QPointF b); 21 | 22 | QRectF boundingRect() const override; 23 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; 24 | QPainterPath shape() const override; 25 | 26 | 27 | signals: 28 | 29 | protected: 30 | virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) override; 31 | virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override; 32 | virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override; 33 | 34 | private: 35 | QPointF A; 36 | QPointF B; 37 | 38 | int current_color; 39 | 40 | int base_stroke; 41 | int stroke; 42 | 43 | QRectF last_bounding_rect; 44 | 45 | bool ignore_events; 46 | //QString text; 47 | }; 48 | 49 | #endif // GRAPHICSLINE_H 50 | -------------------------------------------------------------------------------- /src/widgets/map/graphics_objects/graphics_object.cpp: -------------------------------------------------------------------------------- 1 | #include "graphics_object.h" 2 | #include 3 | 4 | GraphicsObject::GraphicsObject(PprzPalette palette, QObject *parent) : QObject(parent), 5 | editable(true), scale_factor(1.0), ignore_events(false), style(DEFAULT), animation(NONE), palette(palette), highlighted(true) 6 | { 7 | animation_timer = new QTimer(this); 8 | } 9 | 10 | 11 | void GraphicsObject::mousePressEvent(QGraphicsSceneMouseEvent *event) { 12 | (void)event; 13 | if(!highlighted && !forbid_highlight) { 14 | highlighted = true; 15 | emit objectGainedHighlight(); 16 | } 17 | } 18 | 19 | void GraphicsObject::setHighlighted(bool h) { 20 | highlighted = h; 21 | changeFocus(); 22 | } 23 | 24 | void GraphicsObject::setAnimation(Animation a) { 25 | animation = a; 26 | if(a == NONE && animation_timer->isActive()) { 27 | animation_timer->stop(); 28 | } else if(a != NONE && !animation_timer->isActive()) { 29 | animation_timer->start(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/widgets/map/graphics_objects/graphics_object.h: -------------------------------------------------------------------------------- 1 | #ifndef GRAPHICSOBJECT_H 2 | #define GRAPHICSOBJECT_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "pprzpalette.h" 9 | 10 | class GraphicsObject : public QObject 11 | { 12 | Q_OBJECT 13 | public: 14 | 15 | enum Style { 16 | DEFAULT, 17 | CURRENT_NAV, 18 | CARROT, 19 | GCS, 20 | DCSHOT, 21 | CRASH, 22 | }; 23 | 24 | enum Animation { 25 | NONE, 26 | WP_MOVING, 27 | }; 28 | 29 | explicit GraphicsObject(PprzPalette palette, QObject *parent = nullptr); 30 | bool isHighlighted() {return highlighted;} 31 | virtual void setHighlighted(bool h); 32 | void setForbidHighlight(bool fh) {forbid_highlight = fh;} 33 | void setEditable(bool ed) {editable = ed;} 34 | void setScaleFactor(double s) {scale_factor = s;} 35 | void setIgnoreEvent(bool ignore) {ignore_events = ignore;} 36 | void setStyle(Style s) {style = s;} 37 | void setAnimation(Animation a); 38 | 39 | protected: 40 | virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); 41 | virtual void changeFocus() = 0; 42 | bool forbid_highlight; 43 | bool editable; 44 | double scale_factor; 45 | bool ignore_events; 46 | Style style; 47 | Animation animation; 48 | QTimer* animation_timer; 49 | PprzPalette palette; 50 | 51 | signals: 52 | void objectClicked(QPointF scene_pos); 53 | void objectDoubleClicked(QPointF scene_pos); 54 | void objectGainedHighlight(); 55 | 56 | private: 57 | bool highlighted; 58 | 59 | 60 | 61 | }; 62 | 63 | #endif // GRAPHICSOBJECT_H 64 | -------------------------------------------------------------------------------- /src/widgets/map/graphics_objects/graphics_point.h: -------------------------------------------------------------------------------- 1 | #ifndef GRAPHICSPOINT_H 2 | #define GRAPHICSPOINT_H 3 | 4 | #include 5 | #include 6 | #include "graphics_object.h" 7 | #include 8 | #include "pprzpalette.h" 9 | 10 | enum PointMoveState { 11 | PMS_IDLE, 12 | PMS_PRESSED, 13 | PMS_MOVED, 14 | }; 15 | 16 | class GraphicsPoint : public GraphicsObject, public QGraphicsItem 17 | { 18 | Q_OBJECT 19 | Q_INTERFACES(QGraphicsItem) 20 | Q_PROPERTY(int size MEMBER halfSize) 21 | public: 22 | explicit GraphicsPoint(int size, PprzPalette palette, QObject *parent = nullptr); 23 | 24 | QRectF boundingRect() const override; 25 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; 26 | QPainterPath shape() const override; 27 | 28 | signals: 29 | void pointMoved(QPointF scenePos); 30 | void pointMoveFinished(QPointF scenePos); 31 | 32 | protected: 33 | virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) override; 34 | virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override; 35 | virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override; 36 | virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override; 37 | virtual void changeFocus() override; 38 | 39 | 40 | 41 | public slots: 42 | 43 | private: 44 | int halfSize; 45 | QPointF pressPos; 46 | PointMoveState move_state; 47 | 48 | int current_color; 49 | 50 | int animation_couter; 51 | }; 52 | 53 | #endif // GRAPHICSPOINT_H 54 | -------------------------------------------------------------------------------- /src/widgets/map/graphics_objects/graphics_quiver.cpp: -------------------------------------------------------------------------------- 1 | #include "graphics_quiver.h" 2 | #include 3 | 4 | GraphicsQuiver::GraphicsQuiver(PprzPalette palette, float width, QObject *parent) : 5 | GraphicsObject(palette, parent), 6 | QGraphicsItem (), 7 | width(width*2) 8 | { 9 | 10 | } 11 | 12 | QRectF GraphicsQuiver::boundingRect() const 13 | { 14 | return QRectF(-size, -size, 2*size, 2*size); 15 | } 16 | 17 | void GraphicsQuiver::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) 18 | { 19 | (void)option; 20 | (void)widget; 21 | painter->setPen(QPen(palette.getVariant(current_color),width)); 22 | painter->drawLine(0, 0, 0, -size + size/40); 23 | 24 | painter->drawLine(0, -size, -size/10, -9*size/10); 25 | painter->drawLine(0, -size, size/10, -9*size/10); 26 | } 27 | 28 | void GraphicsQuiver::changeFocus() { 29 | 30 | if(isHighlighted()) { 31 | current_color = COLOR_IDLE; 32 | //setVisible(true); 33 | } else { 34 | current_color = COLOR_UNFOCUSED; 35 | //setVisible(false); 36 | } 37 | 38 | update(); 39 | } -------------------------------------------------------------------------------- /src/widgets/map/graphics_objects/graphics_quiver.h: -------------------------------------------------------------------------------- 1 | #ifndef GRAPHICSQUIVER_H 2 | #define GRAPHICSQUIVER_H 3 | 4 | #include 5 | #include 6 | #include "graphics_object.h" 7 | 8 | #define COLOR_IDLE 0 9 | #define COLOR_UNFOCUSED 1 10 | 11 | class GraphicsQuiver : public GraphicsObject, public QGraphicsItem 12 | { 13 | Q_OBJECT 14 | Q_INTERFACES(QGraphicsItem) 15 | public: 16 | explicit GraphicsQuiver(PprzPalette palette, float width, QObject *parent = nullptr); 17 | 18 | QRectF boundingRect() const override; 19 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; 20 | 21 | float size = 20; 22 | 23 | protected: 24 | virtual void changeFocus() override; 25 | 26 | private: 27 | float width; 28 | uint8_t current_color = COLOR_IDLE; 29 | }; 30 | 31 | #endif // GRAPHICSQUIVER_H -------------------------------------------------------------------------------- /src/widgets/map/graphics_objects/graphics_text.cpp: -------------------------------------------------------------------------------- 1 | #include "graphics_text.h" 2 | #include 3 | 4 | GraphicsText::GraphicsText(const QString &text, PprzPalette palette,QObject *parent): 5 | GraphicsObject(palette, parent), 6 | QGraphicsTextItem (text) 7 | 8 | { 9 | setDefaultTextColor(palette.getColor()); 10 | } 11 | 12 | void GraphicsText::changeFocus() { 13 | switch (style) { 14 | case DEFAULT: 15 | if(isHighlighted()) { 16 | setVisible(true); 17 | } else { 18 | setVisible(false); 19 | } 20 | 21 | break; 22 | case CARROT: 23 | setVisible(false); 24 | break; 25 | case CURRENT_NAV: 26 | setVisible(false); 27 | break; 28 | case GCS: 29 | setVisible(false); 30 | break; 31 | case DCSHOT: 32 | setVisible(false); 33 | break; 34 | case CRASH: 35 | setVisible(false); 36 | break; 37 | } 38 | 39 | update(); 40 | } 41 | 42 | void GraphicsText::setStyle(Style s) { 43 | GraphicsObject::setStyle(s); 44 | changeFocus(); 45 | } 46 | 47 | 48 | //void GraphicsText::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { 49 | // qDebug() << "highlited: " << isHighlighted(); 50 | 51 | 52 | 53 | // QGraphicsTextItem::paint(painter, option, widget); 54 | //} 55 | -------------------------------------------------------------------------------- /src/widgets/map/graphics_objects/graphics_text.h: -------------------------------------------------------------------------------- 1 | #ifndef GRAPHICS_TEXT_H 2 | #define GRAPHICS_TEXT_H 3 | 4 | #include 5 | #include "graphics_object.h" 6 | 7 | class GraphicsText : public GraphicsObject, public QGraphicsTextItem 8 | { 9 | public: 10 | GraphicsText(const QString &text, PprzPalette palette,QObject *parent = nullptr); 11 | void setStyle(Style s); 12 | //void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; 13 | 14 | protected: 15 | virtual void changeFocus() override; 16 | 17 | }; 18 | 19 | #endif // GRAPHICS_TEXT_H 20 | -------------------------------------------------------------------------------- /src/widgets/map/gvf_trajectories/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | set(SOURCE 3 | ${SOURCE} 4 | ${CMAKE_CURRENT_SOURCE_DIR}/gvf_trajectory.cpp 5 | ${CMAKE_CURRENT_SOURCE_DIR}/gvf_traj_line.cpp 6 | ${CMAKE_CURRENT_SOURCE_DIR}/gvf_traj_ellipse.cpp 7 | ${CMAKE_CURRENT_SOURCE_DIR}/gvf_traj_sin.cpp 8 | ${CMAKE_CURRENT_SOURCE_DIR}/gvf_traj_trefoil.cpp 9 | ${CMAKE_CURRENT_SOURCE_DIR}/gvf_traj_3D_ellipse.cpp 10 | ${CMAKE_CURRENT_SOURCE_DIR}/gvf_traj_3D_lissajous.cpp 11 | ${CMAKE_CURRENT_SOURCE_DIR}/gvf_traj_bezier.cpp 12 | ) 13 | 14 | set(INC_DIRS ${INC_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}) 15 | 16 | set(SOURCE ${SOURCE} PARENT_SCOPE) 17 | set(INC_DIRS ${INC_DIRS} PARENT_SCOPE) 18 | 19 | -------------------------------------------------------------------------------- /src/widgets/map/gvf_trajectories/gvf_traj_3D_ellipse.cpp: -------------------------------------------------------------------------------- 1 | #include "gvf_traj_3D_ellipse.h" 2 | 3 | GVF_traj_3D_ellipse::GVF_traj_3D_ellipse(QString id, QList param, QList _phi, QVector *gvf_settings) : 4 | GVF_trajectory(id, gvf_settings) 5 | { 6 | set_param(param, _phi); 7 | generate_trajectory(); 8 | 9 | } 10 | 11 | // 3D ellipse trajectory (parametric representation) 12 | void GVF_traj_3D_ellipse::genTraj() { 13 | QList xy_points; 14 | QList z_points; 15 | 16 | float dt = 0.005*2*M_PI; 17 | for (float t = 0; t <= 2*M_PI + dt/2; t+=dt) { 18 | auto point = traj_point(t); 19 | 20 | xy_points.append(QPointF(point.x(),point.y())); 21 | z_points.append(point.z()); 22 | } 23 | 24 | createTrajItem(xy_points, z_points); 25 | } 26 | 27 | // do nothing... 28 | void GVF_traj_3D_ellipse::genVField() { 29 | 30 | } 31 | 32 | /////////////// PRIVATE FUNCTIONS /////////////// 33 | void GVF_traj_3D_ellipse::set_param(QList param, QList _phi) { 34 | 35 | if (param.size()>6) { // gvf_parametric_3D_ellipse_wp() 36 | auto ac = pprzApp()->toolbox()->aircraftManager()->getAircraft(ac_id); 37 | Waypoint::WpFrame frame = ac->getFlightPlan()->getFrame(); 38 | ac->getFlightPlan()->getWaypoint((uint8_t)param[6])->getRelative(frame, xy_off.rx(), xy_off.ry()); 39 | 40 | } else { // gvf_parametric_3D_ellipse_XYZ() 41 | xy_off = QPointF(param[0], param[1]); 42 | } 43 | 44 | r = param[2]; 45 | zl = param[3]; 46 | zh = param[4]; 47 | alpha = param[5]; 48 | 49 | phi = QVector3D(_phi[0], _phi[1], _phi[2]); //TODO: Display error in GVF viewer?? 50 | } 51 | 52 | QVector3D GVF_traj_3D_ellipse::traj_point(float t) { 53 | QVector3D point; 54 | 55 | point.setX(xy_off.x() + r*cos(t)); 56 | point.setY(xy_off.y() + r*sin(t)); 57 | point.setZ(0.5 * (zh + zl + (zl - zh) * sin(alpha - t))); 58 | return point; 59 | } -------------------------------------------------------------------------------- /src/widgets/map/gvf_trajectories/gvf_traj_3D_ellipse.h: -------------------------------------------------------------------------------- 1 | #ifndef GVF_TRAJ_3D_ELLIPSE_H 2 | #define GVF_TRAJ_3D_ELLIPSE_H 3 | 4 | #include "gvf_trajectory.h" 5 | 6 | class GVF_traj_3D_ellipse : public GVF_trajectory 7 | { 8 | Q_OBJECT 9 | public: 10 | explicit GVF_traj_3D_ellipse(QString id, QList param, QList _phi, QVector *gvf_settings); 11 | 12 | protected: 13 | virtual void genTraj() override; 14 | virtual void genVField() override; 15 | 16 | private: 17 | void set_param(QList param, QList _phi); // GVF PARAMETRIC 18 | QVector3D traj_point(float t); 19 | 20 | float r; 21 | float zl; 22 | float zh; 23 | float alpha; 24 | 25 | QVector3D phi; 26 | }; 27 | 28 | #endif // GVF_TRAJ_3D_ELLIPSE_H -------------------------------------------------------------------------------- /src/widgets/map/gvf_trajectories/gvf_traj_3D_lissajous.h: -------------------------------------------------------------------------------- 1 | #ifndef GVF_TRAJ_3D_LISSAJOUS_H 2 | #define GVF_TRAJ_3D_LISSAJOUS_H 3 | 4 | #include "gvf_trajectory.h" 5 | 6 | class GVF_traj_3D_lissajous : public GVF_trajectory 7 | { 8 | Q_OBJECT 9 | public: 10 | explicit GVF_traj_3D_lissajous(QString id, QList param, QList _phi, QVector *gvf_settings); 11 | 12 | protected: 13 | virtual void genTraj() override; 14 | virtual void genVField() override; 15 | 16 | private: 17 | void set_param(QList param, QList _phi); // GVF PARAMETRIC 18 | QVector3D traj_point(float t); 19 | 20 | double alt; 21 | QVector3D c; 22 | QVector3D w; 23 | QVector3D d; 24 | float alpha; 25 | 26 | QVector3D phi; 27 | }; 28 | 29 | #endif // GVF_TRAJ_3D_LISSAJOUS_H -------------------------------------------------------------------------------- /src/widgets/map/gvf_trajectories/gvf_traj_bezier.h: -------------------------------------------------------------------------------- 1 | #ifndef GVF_TRAJ_BEZIER_H 2 | #define GVF_TRAJ_BEZIER_H 3 | 4 | #include "gvf_trajectory.h" 5 | 6 | class GVF_traj_bezier : public GVF_trajectory 7 | { 8 | Q_OBJECT 9 | public: 10 | explicit GVF_traj_bezier(QString id, QList param, QList _phi, 11 | float wb, QVector *gvf_settings); 12 | 13 | protected: 14 | virtual void genTraj() override; 15 | virtual void genVField() override; 16 | 17 | private: 18 | void set_param(QList param, QList _phi, float wb); // GVF PARAMETRIC 19 | QPointF traj_point(float t); 20 | QPointF traj_point_deriv(float t); 21 | 22 | // Maximum data size from gvf_parametric is 16 elements. 23 | float xx[16]; 24 | float yy[16]; 25 | int n_seg; 26 | float w; 27 | float kx; 28 | float ky; 29 | float beta; 30 | QPointF phi; 31 | }; 32 | 33 | #endif // GVF_TRAJ_bezier_H 34 | -------------------------------------------------------------------------------- /src/widgets/map/gvf_trajectories/gvf_traj_ellipse.h: -------------------------------------------------------------------------------- 1 | #ifndef GVF_TRAJ_ELLIPSE_H 2 | #define GVF_TRAJ_ELLIPSE_H 3 | 4 | #include "gvf_trajectory.h" 5 | 6 | class GVF_traj_ellipse : public GVF_trajectory 7 | { 8 | Q_OBJECT 9 | public: 10 | explicit GVF_traj_ellipse(QString id, QList param, int8_t _s, float _ke, QVector *gvf_settings); 11 | 12 | protected: 13 | virtual void genTraj() override; 14 | virtual void genVField() override; 15 | 16 | private: 17 | void set_param(QList param, int8_t _s, float _ke); 18 | 19 | float a; 20 | float b; 21 | float alpha; 22 | 23 | int8_t s; 24 | float ke; 25 | }; 26 | 27 | #endif // GVF_TRAJ_ELLIPSE_H -------------------------------------------------------------------------------- /src/widgets/map/gvf_trajectories/gvf_traj_line.h: -------------------------------------------------------------------------------- 1 | #ifndef GVF_TRAJ_LINE_H 2 | #define GVF_TRAJ_LINE_H 3 | 4 | #include "gvf_trajectory.h" 5 | 6 | class GVF_traj_line : public GVF_trajectory 7 | { 8 | Q_OBJECT 9 | public: 10 | explicit GVF_traj_line(QString id, QList param, int8_t _s, float _ke, QVector *gvf_settings); 11 | 12 | protected: 13 | virtual void genTraj() override; 14 | virtual void genVField() override; 15 | 16 | private: 17 | void set_param(QList param, int8_t _s, float _ke); 18 | 19 | float a; 20 | float b; 21 | float course; 22 | float d1 = 0; 23 | float d2 = 0; 24 | 25 | int8_t s; 26 | double ke; 27 | 28 | float dx; 29 | float dy; 30 | }; 31 | 32 | #endif // GVF_TRAJ_LINE_H -------------------------------------------------------------------------------- /src/widgets/map/gvf_trajectories/gvf_traj_sin.h: -------------------------------------------------------------------------------- 1 | #ifndef GVF_TRAJ_SIN_H 2 | #define GVF_TRAJ_SIN_H 3 | 4 | #include "gvf_trajectory.h" 5 | 6 | class GVF_traj_sin : public GVF_trajectory 7 | { 8 | Q_OBJECT 9 | public: 10 | explicit GVF_traj_sin(QString id, QList param, int8_t _s, float _ke, QVector *gvf_settings); 11 | 12 | protected: 13 | virtual void genTraj() override; 14 | virtual void genVField() override; 15 | 16 | private: 17 | void set_param(QList param, int8_t _s, float _ke); 18 | 19 | float a; 20 | float b; 21 | float course; 22 | float w; 23 | float off; 24 | float A; 25 | 26 | int8_t s; 27 | double ke; 28 | 29 | float dx; 30 | float dy; 31 | }; 32 | 33 | #endif // GVF_TRAJ_SIN_H -------------------------------------------------------------------------------- /src/widgets/map/gvf_trajectories/gvf_traj_trefoil.h: -------------------------------------------------------------------------------- 1 | #ifndef GVF_TRAJ_TREFOIL_H 2 | #define GVF_TRAJ_TREFOIL_H 3 | 4 | #include "gvf_trajectory.h" 5 | 6 | class GVF_traj_trefoil : public GVF_trajectory 7 | { 8 | Q_OBJECT 9 | public: 10 | explicit GVF_traj_trefoil(QString id, QList param, QList _phi, QVector *gvf_settings); 11 | 12 | protected: 13 | virtual void genTraj() override; 14 | virtual void genVField() override; 15 | 16 | private: 17 | void set_param(QList param, QList _phi); // GVF PARAMETRIC 18 | QPointF traj_point(float t); 19 | 20 | float w1; 21 | float w2; 22 | float ratio; 23 | float r; 24 | float alpha; 25 | 26 | QPointF phi; 27 | 28 | float gcd(int a, int b); 29 | }; 30 | 31 | #endif // GVF_TRAJ_TREFOIL_H -------------------------------------------------------------------------------- /src/widgets/map/gvf_trajectories/gvf_trajectory.h: -------------------------------------------------------------------------------- 1 | #ifndef GVF_TRAJECTORY_H 2 | #define GVF_TRAJECTORY_H 3 | 4 | #include 5 | #include "coordinatestransform.h" 6 | #include "AircraftManager.h" 7 | #include "dispatcher_ui.h" 8 | #include "quiver_item.h" 9 | #include "path_item.h" 10 | 11 | 12 | class GVF_trajectory : public QObject 13 | { 14 | Q_OBJECT 15 | public: 16 | explicit GVF_trajectory(QString id, QVector *gvf_settings); 17 | 18 | Point2DLatLon getCarrot(); 19 | QuiverItem* getVField(); 20 | PathItem* getTraj(); 21 | 22 | void setVFiledVis(bool vis); 23 | void setTrajVis(bool vis); 24 | 25 | void purge_trajectory(); 26 | void generate_trajectory(); 27 | void update_VField(); 28 | void update_origin(); 29 | 30 | protected: 31 | QString ac_id; 32 | Point2DLatLon ltp_origin; 33 | QPointF xy_off; 34 | QPointF traj_grad; 35 | 36 | QList xy_mesh; 37 | QList vxy_mesh; 38 | 39 | void createTrajItem(QList points); 40 | void createTrajItem(QList xy_points, QList z_points); 41 | void createVFieldItem(QList points, QList vpoints, float ref_area = 500); 42 | QList meshGrid(); 43 | QPointF getACpos(); 44 | 45 | virtual void genTraj() = 0; 46 | virtual void genVField() = 0; 47 | 48 | // GVF viewer config 49 | int field_area; 50 | int field_xpts; 51 | int field_ypts; 52 | 53 | private: 54 | QuiverItem* field_item; 55 | PathItem* traj_item; 56 | QList traj_waypoints; 57 | 58 | // GVF viewer config 59 | bool field_item_vis; 60 | bool traj_item_vis; 61 | }; 62 | 63 | #endif // GVF_TRAJECTORY_H -------------------------------------------------------------------------------- /src/widgets/map/map_items/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | set(SOURCE 3 | ${SOURCE} 4 | ${CMAKE_CURRENT_SOURCE_DIR}/map_item.cpp 5 | ${CMAKE_CURRENT_SOURCE_DIR}/waypoint_item.cpp 6 | ${CMAKE_CURRENT_SOURCE_DIR}/path_item.cpp 7 | ${CMAKE_CURRENT_SOURCE_DIR}/circle_item.cpp 8 | ${CMAKE_CURRENT_SOURCE_DIR}/aircraft_item.cpp 9 | ${CMAKE_CURRENT_SOURCE_DIR}/intruder_item.cpp 10 | ${CMAKE_CURRENT_SOURCE_DIR}/arrow_item.cpp 11 | ${CMAKE_CURRENT_SOURCE_DIR}/quiver_item.cpp 12 | ) 13 | 14 | set(INC_DIRS ${INC_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}) 15 | 16 | set(SOURCE ${SOURCE} PARENT_SCOPE) 17 | set(INC_DIRS ${INC_DIRS} PARENT_SCOPE) 18 | 19 | -------------------------------------------------------------------------------- /src/widgets/map/map_items/aircraft_item.h: -------------------------------------------------------------------------------- 1 | #ifndef AIRCRAFT_ITEM_H 2 | #define AIRCRAFT_ITEM_H 3 | 4 | #include "map_item.h" 5 | #include "graphics_aircraft.h" 6 | #include "graphics_text.h" 7 | #include "QGraphicsTextItem" 8 | #include "graphics_line.h" 9 | #include "graphics_icon.h" 10 | #include "aircraft_watcher.h" 11 | #include "graphics_group.h" 12 | 13 | 14 | class AircraftItem : public MapItem 15 | { 16 | Q_OBJECT 17 | public: 18 | explicit AircraftItem(Point2DLatLon pt, QString ac_id, double neutral_scale_zoom = 15, QObject *parent = nullptr); 19 | 20 | virtual void setHighlighted(bool h); 21 | virtual void updateZValue(); 22 | virtual void setVisible(bool visible); 23 | virtual void setForbidHighlight(bool fh); 24 | virtual void setEditable(bool ed){(void)ed;} 25 | virtual void removeFromScene(MapWidget* map); 26 | virtual void addToMap(MapWidget* mw); 27 | 28 | void setPosition(Point2DLatLon pt); 29 | void setHeading(double h); 30 | void clearTrack(); 31 | 32 | signals: 33 | 34 | public slots: 35 | 36 | protected: 37 | virtual void updateGraphics(MapWidget* map, uint32_t update_event); 38 | void handle_bat_alarm(AircraftWatcher::BatStatus bs); 39 | void handle_link_alarm(AircraftWatcher::LinkStatus ls); 40 | 41 | private: 42 | GraphicsAircraft* graphics_aircraft; 43 | GraphicsText* graphics_text; 44 | GraphicsGroup* alarms; 45 | GraphicsIcon* bat_alarm; 46 | GraphicsIcon* link_alarm; 47 | 48 | Point2DLatLon latlon; 49 | double heading; 50 | QList graphics_lines; 51 | 52 | QColor color_idle; 53 | QColor color_unfocused; 54 | 55 | QList track_points; 56 | }; 57 | 58 | #endif // AIRCRAFT_ITEM_H 59 | -------------------------------------------------------------------------------- /src/widgets/map/map_items/arrow_item.h: -------------------------------------------------------------------------------- 1 | #ifndef ARROWITEM_H 2 | #define ARROWITEM_H 3 | 4 | #include 5 | #include "map_item.h" 6 | #include "graphics_group.h" 7 | 8 | class ArrowItem : public MapItem 9 | { 10 | Q_OBJECT 11 | //Q_PROPERTY(int size MEMBER m_size) 12 | Q_PROPERTY(int size MEMBER m_size DESIGNABLE true) 13 | public: 14 | explicit ArrowItem(QString ac_id, double neutral_scale_zoom = 15, QObject *parent = nullptr); 15 | 16 | virtual void setHighlighted(bool h); 17 | virtual void updateZValue(); 18 | virtual void setVisible(bool visible); 19 | virtual void setForbidHighlight(bool fh); 20 | virtual void setEditable(bool ed){(void)ed;} 21 | virtual void removeFromScene(MapWidget* map); 22 | virtual void addToMap(MapWidget* mw); 23 | 24 | void setAcPos(Point2DLatLon pos) { 25 | ac_pos = pos; 26 | emit itemChanged(); 27 | } 28 | 29 | signals: 30 | void centerAC(); 31 | 32 | protected: 33 | virtual void updateGraphics(MapWidget* map, uint32_t update_event); 34 | 35 | private: 36 | 37 | std::tuple intersect(QRect rect, QPoint p); 38 | QPolygonF make_polygon(double distance); 39 | 40 | int m_size; 41 | GraphicsGroup* scene_item; 42 | QGraphicsPolygonItem* polygon; 43 | Point2DLatLon ac_pos; 44 | 45 | }; 46 | 47 | #endif // ARROWITEM_H 48 | -------------------------------------------------------------------------------- /src/widgets/map/map_items/circle_item.h: -------------------------------------------------------------------------------- 1 | #ifndef CIRCLEITEM_H 2 | #define CIRCLEITEM_H 3 | 4 | #include "map_item.h" 5 | #include "waypoint_item.h" 6 | #include "graphics_circle.h" 7 | 8 | class MapWidget; 9 | 10 | class CircleItem : public MapItem 11 | { 12 | Q_OBJECT 13 | public: 14 | explicit CircleItem(WaypointItem* center, double radius, QString ac_id, double neutral_scale_zoom = 15); 15 | explicit CircleItem(WaypointItem* center, double radius, QString ac_id, PprzPalette palette, double neutral_scale_zoom = 15); 16 | WaypointItem* getCenter() { return center;} 17 | GraphicsCircle* getGraphicsCircle() {return circle;} 18 | void setOwnCenter(bool own) { if(own) {center->setParent(this);} } 19 | bool ownCenter() {return center->parent() == this;} 20 | void setScalable(bool scalable) { 21 | circle->setIgnoreEvent(!scalable); 22 | } 23 | void setFilled(bool f) {circle->setFilled(f);} 24 | virtual void addToMap(MapWidget* mw); 25 | virtual void setHighlighted(bool h); 26 | void setForbidHighlight(bool fh); 27 | virtual void setEditable(bool ed); 28 | virtual void updateZValue(); 29 | virtual void setVisible(bool visible); 30 | virtual void updateGraphics(MapWidget* map, uint32_t update_event); 31 | virtual void removeFromScene(MapWidget* map); 32 | void setText(QString text); 33 | double radius() {return _radius;} 34 | /// 35 | /// \brief setRadius 36 | /// \param radius in meters 37 | /// 38 | void setRadius(double radius); 39 | 40 | void setStyle(GraphicsCircle::Style s); 41 | 42 | signals: 43 | void circleMoved(Point2DLatLon latlon_pos); 44 | void circleScaled(double radius); 45 | 46 | protected: 47 | 48 | private: 49 | void init(WaypointItem* center); 50 | WaypointItem* center; 51 | GraphicsCircle* circle; 52 | GraphicsText* graphics_text; 53 | double _radius; 54 | int altitude; 55 | int stroke; 56 | 57 | bool highlighted; 58 | }; 59 | 60 | #endif // CIRCLEITEM_H 61 | -------------------------------------------------------------------------------- /src/widgets/map/map_items/intruder_item.h: -------------------------------------------------------------------------------- 1 | #ifndef INTRUDERITEM_H 2 | #define INTRUDERITEM_H 3 | 4 | #include "map_item.h" 5 | #include "graphics_intruder.h" 6 | #include "graphics_text.h" 7 | 8 | class IntruderItem : public MapItem 9 | { 10 | Q_OBJECT 11 | public: 12 | explicit IntruderItem(QString name, Point2DLatLon pt, double course, double neutral_scale_zoom = 15, QObject *parent = nullptr); 13 | virtual void addToMap(MapWidget* map) override; 14 | virtual void updateGraphics(MapWidget* map, uint32_t update_event) override; 15 | virtual void removeFromScene(MapWidget* map) override; 16 | virtual void setForbidHighlight(bool fh) override; 17 | virtual void setEditable(bool ed) override; 18 | virtual void updateZValue() override; 19 | virtual void setVisible(bool visible) override; 20 | 21 | void setPosition(Point2DLatLon pt); 22 | void setCourse(double c); 23 | 24 | signals: 25 | 26 | private: 27 | GraphicsIntruder* graphics_intruder; 28 | GraphicsText* graphics_text; 29 | 30 | QString name; 31 | Point2DLatLon latlon; 32 | double course; 33 | 34 | }; 35 | 36 | #endif // INTRUDERITEM_H 37 | -------------------------------------------------------------------------------- /src/widgets/map/map_items/map_item.cpp: -------------------------------------------------------------------------------- 1 | #include "map_item.h" 2 | #include "math.h" 3 | #include 4 | #include 5 | #include 6 | #include "mapwidget.h" 7 | 8 | #include "AircraftManager.h" 9 | 10 | MapItem::MapItem(QString ac_id, double neutral_scale_zoom, QObject *parent) : 11 | QObject(parent), 12 | ac_id(ac_id), 13 | zoom_factor(1), neutral_scale_zoom(neutral_scale_zoom), 14 | z_value(0), 15 | visible(true) 16 | { 17 | auto color = AircraftManager::get()->getAircraft(ac_id)->getColor(); 18 | this->palette = PprzPalette(color); 19 | } 20 | 21 | MapItem::MapItem(QString ac_id, PprzPalette palette, double neutral_scale_zoom, QObject *parent) : 22 | QObject(parent), 23 | ac_id(ac_id), palette(palette), 24 | zoom_factor(1), neutral_scale_zoom(neutral_scale_zoom), 25 | z_value(0), 26 | visible(true) 27 | { 28 | } 29 | 30 | QColor MapItem::unfocusedColor(const QColor &color) { 31 | int h, s, v, a; 32 | color.getHsv(&h, &s, &v, &a); 33 | 34 | int a2 = qMin(static_cast(a/2), 255); 35 | int s3 = static_cast(s/2); 36 | QColor c = QColor(color); 37 | c.setHsv(h, s3, v, a2); 38 | 39 | return c; 40 | } 41 | 42 | QColor MapItem::trackUnfocusedColor(const QColor &color) { 43 | int h, s, v, a; 44 | color.getHsv(&h, &s, &v, &a); 45 | 46 | int s3 = static_cast(s/2); 47 | QColor c = QColor(color); 48 | c.setHsv(h, s3, v, a); 49 | 50 | return c; 51 | } 52 | 53 | QColor MapItem::labelUnfocusedColor(const QColor &color) { 54 | int h, s, v, a; 55 | color.getHsv(&h, &s, &v, &a); 56 | 57 | int v2 = static_cast(v/2); 58 | QColor c = QColor(color); 59 | c.setHsv(h, s, v2, a); 60 | 61 | return c; 62 | } 63 | 64 | double MapItem::getScale(double zoom, double scale_factor) { 65 | return pow(zoom_factor, zoom - neutral_scale_zoom)/scale_factor; 66 | } 67 | 68 | -------------------------------------------------------------------------------- /src/widgets/map/map_items/path_item.h: -------------------------------------------------------------------------------- 1 | #ifndef SEGMENT_H 2 | #define SEGMENT_H 3 | 4 | #include "map_item.h" 5 | #include 6 | #include "waypoint_item.h" 7 | #include "graphics_line.h" 8 | #include 9 | 10 | class PathItem : public MapItem 11 | { 12 | Q_OBJECT 13 | public: 14 | explicit PathItem(QString ac_id, QColor color=QColor(), double neutral_scale_zoom = 15, QObject *parent = nullptr); 15 | explicit PathItem(QString ac_id, PprzPalette palette, double neutral_scale_zoom = 15, QObject *parent = nullptr); 16 | void addPoint(WaypointItem* waypoint, QColor line_color=QColor(), bool own=false); 17 | void setClosedPath(bool closed); 18 | virtual void setHighlighted(bool h); 19 | virtual void setForbidHighlight(bool sh); 20 | virtual void setEditable(bool ed); 21 | virtual void updateZValue(); 22 | virtual void updateGraphics(MapWidget* map, uint32_t update_event); 23 | virtual void removeFromScene(MapWidget* map); 24 | virtual void addToMap(MapWidget* mw); 25 | virtual void setVisible(bool vis) ; 26 | void setText(QString text) {graphics_text->setPlainText(text);} 27 | WaypointItem* getLastWaypoint() {return waypoints.last();} 28 | QList getWaypoints() {return waypoints;} 29 | int count() {return waypoints.size();} 30 | // void setLinesIgnoreEvents(bool ignore); 31 | // void setLastLineIgnoreEvents(bool ignore); 32 | void removeLastWaypoint(); 33 | void setFilled(bool f); 34 | 35 | void setStyle(GraphicsLine::Style s); 36 | 37 | signals: 38 | 39 | public slots: 40 | 41 | protected: 42 | 43 | 44 | private: 45 | QList waypoints; 46 | QList lines; 47 | QList to_be_added; 48 | QList to_be_removed; 49 | QList waypoints_to_remove; 50 | GraphicsLine* closing_line; 51 | GraphicsText* graphics_text; 52 | int line_width; 53 | QColor color; 54 | 55 | QGraphicsPolygonItem* polygon; 56 | }; 57 | 58 | #endif // SEGMENT_H 59 | -------------------------------------------------------------------------------- /src/widgets/map/map_items/quiver_item.h: -------------------------------------------------------------------------------- 1 | #ifndef QUIVERITEM_H 2 | #define QUIVERITEM_H 3 | 4 | #include "map_item.h" 5 | #include "graphics_quiver.h" 6 | 7 | class QuiverItem : public MapItem 8 | { 9 | Q_OBJECT 10 | public: 11 | QuiverItem(QString id, QColor = Qt::red, float width = 0.5, QObject *parent = nullptr, double neutral_scale_zoom = 15); 12 | QuiverItem(Point2DLatLon pos, Point2DLatLon vpos, QString id, QColor = Qt::red, float width = 0.5, QObject *parent = nullptr, double neutral_scale_zoom = 15); 13 | QuiverItem(QList pos, QList vpos, QString id, QColor = Qt::red, float width = 0.5, QObject *parent = nullptr, double neutral_scale_zoom = 15); 14 | 15 | virtual void addToMap(MapWidget* map) override; 16 | virtual void updateGraphics(MapWidget* map, uint32_t update_event) override; 17 | virtual void removeFromScene(MapWidget* map) override; 18 | virtual void setHighlighted(bool sh) override; 19 | virtual void setForbidHighlight(bool fh) override; 20 | virtual void updateZValue() override; 21 | virtual void setEditable(bool ed) override; 22 | 23 | virtual void setVisible(bool vis); 24 | void addQuiver(Point2DLatLon pos, Point2DLatLon vpos); 25 | void removeQuivers(); 26 | 27 | private: 28 | float pen_width; 29 | QList graphics_quiver_l; 30 | 31 | QList latlon_l; 32 | QList vlatlon_l; 33 | QList distance_l; 34 | }; 35 | 36 | #endif // QUIVERITEM_H 37 | -------------------------------------------------------------------------------- /src/widgets/map/maplayercontrol.h: -------------------------------------------------------------------------------- 1 | #ifndef MAPLAYERCONTROL_H 2 | #define MAPLAYERCONTROL_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "imagebutton.h" 9 | 10 | class MapLayerControl : public QWidget 11 | { 12 | Q_OBJECT 13 | public: 14 | explicit MapLayerControl(QString name, QPixmap pixmap, bool initialState, int z, QWidget *parent = nullptr); 15 | 16 | void setShowState(bool state); 17 | void setOpacitySlider(qreal opacity); 18 | qreal opacity() {return static_cast(opacitySlider->value())/opacitySlider->maximum();} 19 | int zValue() {return z_value;} 20 | void setZValue(int z); 21 | QPixmap pixmap() { 22 | #if QT_VERSION_MAJOR == 5 && QT_VERSION_MINOR < 15 23 | QPixmap p = *imageLabel->pixmap(); 24 | #else 25 | QPixmap p = imageLabel->pixmap(Qt::ReturnByValue); 26 | #endif 27 | return p; 28 | } 29 | QString name() {return _name;} 30 | 31 | bool operator <(const MapLayerControl& mlc) const 32 | { 33 | return (z_value < mlc.z_value); 34 | } 35 | 36 | //ImageButton* button() {return show_button;} 37 | 38 | signals: 39 | void showLayer(bool); 40 | void layerOpacityChanged(qreal); 41 | void zValueChanged(int); 42 | 43 | 44 | public slots: 45 | 46 | private: 47 | void toggleShowState(); 48 | 49 | QVBoxLayout* verticalLayout; 50 | QLabel* nameLabel; 51 | QLabel* imageLabel; 52 | QSlider* opacitySlider; 53 | ImageButton *show_button; 54 | 55 | QString _name; 56 | bool showState; 57 | int z_value; 58 | }; 59 | 60 | #endif // MAPLAYERCONTROL_H 61 | -------------------------------------------------------------------------------- /src/widgets/map/mapscene.cpp: -------------------------------------------------------------------------------- 1 | #include "mapscene.h" 2 | #include 3 | 4 | MapScene::MapScene(QObject *parent) : QGraphicsScene(parent), shortcut_items(false) 5 | { 6 | } 7 | 8 | 9 | MapScene::MapScene(qreal x, qreal y, qreal width, qreal height, QObject *parent) : 10 | QGraphicsScene(x, y, width, height, parent), shortcut_items(false) 11 | { 12 | } 13 | 14 | 15 | MapScene::MapScene(const QRectF &sceneRect, QObject *parent) : 16 | QGraphicsScene(sceneRect, parent), shortcut_items(false) 17 | { 18 | } 19 | 20 | 21 | void MapScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) { 22 | if(!shortcut_items) { 23 | QGraphicsScene::mousePressEvent(mouseEvent); 24 | } 25 | if(!mouseEvent->isAccepted()) { 26 | emit eventScene(FPEE_SC_PRESS, mouseEvent); 27 | } 28 | } 29 | 30 | void MapScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) { 31 | if(!shortcut_items) { 32 | QGraphicsScene::mouseMoveEvent(mouseEvent); 33 | } 34 | if(!mouseEvent->isAccepted()) { 35 | emit eventScene(FPEE_SC_MOVE, mouseEvent); 36 | } 37 | } 38 | 39 | void MapScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent) { 40 | if(!shortcut_items) { 41 | QGraphicsScene::mouseReleaseEvent(mouseEvent); 42 | } 43 | if(!mouseEvent->isAccepted()) { 44 | emit eventScene(FPEE_SC_RELEASE, mouseEvent); 45 | } 46 | } 47 | 48 | void MapScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *mouseEvent) { 49 | if(!shortcut_items) { 50 | QGraphicsScene::mouseDoubleClickEvent(mouseEvent); 51 | } 52 | if(!mouseEvent->isAccepted()) { 53 | emit eventScene(FPEE_SC_DOUBLE_CLICK, mouseEvent); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/widgets/map/mapscene.h: -------------------------------------------------------------------------------- 1 | #ifndef MAPSCENE_H 2 | #define MAPSCENE_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include "item_edit_state_machine.h" 8 | 9 | class MapScene : public QGraphicsScene 10 | { 11 | Q_OBJECT 12 | public: 13 | explicit MapScene(QObject *parent = nullptr); 14 | explicit MapScene(qreal x, qreal y, qreal width, qreal height, QObject *parent = nullptr); 15 | explicit MapScene(const QRectF &sceneRect, QObject *parent = nullptr); 16 | 17 | void setShortcutItems(bool si) {shortcut_items = si;} 18 | 19 | protected: 20 | virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent); 21 | virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent); 22 | virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent); 23 | virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *mouseEvent); 24 | 25 | signals: 26 | void eventScene(SmEditEvent, QGraphicsSceneMouseEvent*); 27 | 28 | public slots: 29 | 30 | private: 31 | bool shortcut_items; 32 | }; 33 | 34 | #endif // MAPSCENE_H 35 | -------------------------------------------------------------------------------- /src/widgets/map/maputils.cpp: -------------------------------------------------------------------------------- 1 | #include "maputils.h" 2 | #include 3 | #include "coordinatestransform.h" 4 | #include "point2dpseudomercator.h" 5 | 6 | constexpr double EARTH_RADIUS = 6378137.0; 7 | 8 | Point2DTile tilePoint(QPointF scenePos, int zoom, int tileSize) { 9 | return Point2DTile(scenePos.x()/tileSize, scenePos.y()/tileSize, zoom); 10 | } 11 | 12 | QPointF scenePoint(Point2DTile tilePoint, int tileSize) { 13 | return QPointF(tilePoint.x()*tileSize, tilePoint.y()*tileSize); 14 | } 15 | 16 | QPointF scenePoint(Point2DLatLon latlon, int zoomLvl, int tileSize) { 17 | Point2DPseudoMercator pm = CoordinatesTransform::get()->WGS84_to_pseudoMercator(latlon); 18 | Point2DTile tile_pos = pm.toTile(zoomLvl); 19 | return scenePoint(tile_pos, tileSize); 20 | } 21 | 22 | QPointF scenePoint(Point2DPseudoMercator pm, int zoomLvl, int tileSize) { 23 | Point2DTile tile_pos = pm.toTile(zoomLvl); 24 | return scenePoint(tile_pos, tileSize); 25 | } 26 | 27 | int zoomLevel(double zoom) { 28 | return static_cast(ceil(zoom)); 29 | } 30 | 31 | /// 32 | /// \brief distMeters2Tile convert real world meters to tile coordinates. Use only for "small" distances compared to earth radius 33 | /// \param distance in meters 34 | /// \param lat mean latitude 35 | /// \param zoom zoomLevel 36 | /// \return distance in tile coordinates representing the distance in meters. 37 | /// 38 | double distMeters2Tile(double distance, double lat, int zoom) { 39 | double latrad = lat * M_PI/180.0; 40 | 41 | double latrad1 = latrad - distance/(2*EARTH_RADIUS); 42 | double latrad2 = latrad + distance/(2*EARTH_RADIUS); 43 | 44 | double dy = (asinh(tan(latrad2)) - asinh(tan(latrad1))) * (1 << (zoom-1)) / M_PI; 45 | return dy; 46 | } 47 | 48 | double distTile2Meters(double y, double d, int zoom) { 49 | double y1 = y + d/2; 50 | double y2 = y - d/2; 51 | 52 | double n1 = M_PI - 2.0 * M_PI * y1 / static_cast(1 << zoom); 53 | double n2 = M_PI - 2.0 * M_PI * y2 / static_cast(1 << zoom); 54 | 55 | double dlatrad = atan(0.5 * (exp(n2) - exp(-n2))) - atan(0.5 * (exp(n1) - exp(-n1))); 56 | return dlatrad * EARTH_RADIUS; 57 | } 58 | -------------------------------------------------------------------------------- /src/widgets/map/maputils.h: -------------------------------------------------------------------------------- 1 | #ifndef MAPUTILS_H 2 | #define MAPUTILS_H 3 | 4 | #include 5 | #include "point2dlatlon.h" 6 | #include "point2dtile.h" 7 | #include "point2dpseudomercator.h" 8 | #include "math.h" 9 | 10 | Point2DTile tilePoint(QPointF scenePos, int zoom, int tileSize); 11 | QPointF scenePoint(Point2DTile tilePoint, int tileSize); 12 | QPointF scenePoint(Point2DPseudoMercator pm, int zoomLvl, int tileSize); 13 | QPointF scenePoint(Point2DLatLon latlon, int zoomLvl, int tileSize); 14 | Point2DLatLon latlonPoint(QPointF scenePos, int zoom, int tileSize); 15 | int zoomLevel(double zoom); 16 | double distMeters2Tile(double distance, double lat, int zoom); 17 | double distTile2Meters(double y, double d, int zoom); 18 | //Point2DLatLon latlonFromView(QPoint viewPos, int zoom); 19 | 20 | 21 | 22 | #endif // MAPUTILS_H 23 | -------------------------------------------------------------------------------- /src/widgets/map/papgetconfig.h: -------------------------------------------------------------------------------- 1 | #ifndef PAPGETCONFIG_H 2 | #define PAPGETCONFIG_H 3 | 4 | #include 5 | #include "papget.h" 6 | 7 | class PapgetConfig : public QDialog 8 | { 9 | Q_OBJECT 10 | public: 11 | explicit PapgetConfig(Papget::DataDef datadef, Papget::Params params, QWidget *parent = nullptr); 12 | 13 | signals: 14 | void paramsChanged(Papget::Params); 15 | 16 | public slots: 17 | 18 | private: 19 | Papget::DataDef datadef; 20 | QList> callbacks; 21 | int current_index; 22 | 23 | std::function config_text(QWidget* w); 24 | 25 | Papget::Params params; 26 | 27 | }; 28 | 29 | 30 | #endif // PAPGETCONFIG_H 31 | -------------------------------------------------------------------------------- /src/widgets/map/tileitem.h: -------------------------------------------------------------------------------- 1 | #ifndef TILEITEM_H 2 | #define TILEITEM_H 3 | 4 | #include 5 | #include "point2dtile.h" 6 | #include 7 | 8 | enum TileRequestStatus { 9 | TILE_NOT_REQUESTED, // tile has not been loaded yet 10 | TILE_NOT_ON_DISK, // tile not on disk 11 | TILE_REQUESTED, // tile was not on disk, request sent 12 | TILE_REQUEST_FAILED, // network request failed 13 | TILE_OK, // tile loaded 14 | TILE_ERROR, // other generic error 15 | TILE_DO_NOT_EXISTS, // tile not in the extent 16 | }; 17 | 18 | class TileItem : public QGraphicsPixmapItem 19 | { 20 | 21 | public: 22 | TileItem(TileItem* mother, int size, Point2DTile coordinates, QGraphicsItem *parent = nullptr); 23 | ~TileItem(); 24 | 25 | int tileSize() {return SIZE;} 26 | bool isInScene() { return inScene;} 27 | bool hasData() {return _hasData;} 28 | void setInScene(bool in_s) {inScene = in_s;} 29 | TileRequestStatus requestStatus() {return request_status;} 30 | void setRequestStatus(TileRequestStatus rs) {request_status = rs;} 31 | 32 | Point2DTile coordinates() {return _coordinates;} 33 | TileItem* child(int x, int y) {return _childs[x][y];} 34 | void setChild(TileItem* t, int x, int y) {_childs[x][y] = t;} 35 | TileItem* mother() {return _mother;} 36 | bool setInheritedData(); 37 | bool paintPixmapFromAncestors(QPixmap* altPixmap); 38 | bool paintPixmapFromOffspring(QPixmap* altPixmap); 39 | 40 | virtual void setPixmap(const QPixmap &pixmap); 41 | void setAltPixmap(const QPixmap &pixmap); 42 | 43 | 44 | private: 45 | const int SIZE; 46 | bool inScene; 47 | bool _hasData; 48 | TileRequestStatus request_status; 49 | const Point2DTile _coordinates; 50 | TileItem* _childs[2][2]; 51 | TileItem* _mother; 52 | }; 53 | 54 | void tileApplyRecursive(TileItem* base, std::function fn); 55 | 56 | Q_DECLARE_METATYPE(TileItem*) 57 | 58 | #endif // TILEITEM_H 59 | -------------------------------------------------------------------------------- /src/widgets/map/tileproviderconfig.cpp: -------------------------------------------------------------------------------- 1 | #include "tileproviderconfig.h" 2 | #include 3 | #include "point2dpseudomercator.h" 4 | 5 | TileProviderConfig::TileProviderConfig(QDomElement ele) { 6 | zoomMin = ele.attribute("zoomMin", "0").toInt(); 7 | zoomMax = ele.attribute("zoomMax", "19").toInt(); 8 | 9 | 10 | if(ele.hasAttribute("xMin")) { 11 | xMin = ele.attribute("xMin").toDouble(); 12 | } else { 13 | xMin = Point2DPseudoMercator::getBounds().left(); 14 | } 15 | 16 | if(ele.hasAttribute("xMax")) { 17 | xMax = ele.attribute("xMax").toDouble(); 18 | } else { 19 | xMax = Point2DPseudoMercator::getBounds().right(); 20 | } 21 | 22 | // top and bottom are reversed because of the direction of the y axis 23 | if(ele.hasAttribute("yMin")) { 24 | yMin = ele.attribute("yMin").toDouble(); 25 | } else { 26 | yMin = Point2DPseudoMercator::getBounds().top(); 27 | } 28 | 29 | if(ele.hasAttribute("yMax")) { 30 | yMax = ele.attribute("yMax").toDouble(); 31 | } else { 32 | yMax = Point2DPseudoMercator::getBounds().bottom(); 33 | } 34 | 35 | dir = ele.attribute("dir"); 36 | addr = ele.attribute("addr"); 37 | 38 | name = ele.attribute("name"); 39 | 40 | tileSize = ele.attribute("tileSize").toInt(); 41 | format = ele.attribute("format"); 42 | } 43 | 44 | 45 | void TileProviderConfig::printConfig() { 46 | std::cout << 47 | "Name: " << name.toStdString() << 48 | " Dir: " << dir.toStdString() << 49 | " Addr: " << addr.toStdString() << 50 | std::endl; 51 | } 52 | 53 | bool TileProviderConfig::isValid(Point2DTile pt_tile) { 54 | // check if zoom is in range 55 | if(pt_tile.zoom() < zoomMin || pt_tile.zoom() > zoomMax) { 56 | return false; 57 | } 58 | 59 | Point2DPseudoMercator pm(pt_tile); 60 | // check is position is in the extent 61 | return pm.x() <= xMax && 62 | pm.x() >= xMin && 63 | pm.y() <= yMax && 64 | pm.y() >= yMin; 65 | } 66 | -------------------------------------------------------------------------------- /src/widgets/map/tileproviderconfig.h: -------------------------------------------------------------------------------- 1 | #ifndef TILEPROVIDERCONFIG_H 2 | #define TILEPROVIDERCONFIG_H 3 | 4 | #include 5 | #include 6 | #include "point2dtile.h" 7 | #include 8 | 9 | class TileProviderConfig 10 | { 11 | public: 12 | 13 | TileProviderConfig(QDomElement ele); 14 | TileProviderConfig(QString name, QString dir, QString addr, 15 | int zoomMin, int zoomMax, double xMin, double xMax, double yMin, double yMax, 16 | int tileSize, QString format): 17 | name(name), dir(dir), addr(addr), 18 | zoomMin(zoomMin), zoomMax(zoomMax), xMin(xMin), xMax(xMax), yMin(yMin), yMax(yMax), 19 | tileSize(tileSize), format(format) 20 | { 21 | } 22 | 23 | void printConfig(); 24 | bool isValid(Point2DTile pt_tile); 25 | 26 | QString name; 27 | QString dir; 28 | QString addr; 29 | int zoomMin; 30 | int zoomMax; 31 | double xMin; 32 | double xMax; 33 | double yMin; 34 | double yMax; 35 | int tileSize; 36 | QString format; 37 | 38 | int initial_rank; // kind of the oposite of zValue... 39 | }; 40 | 41 | #endif // TILEPROVIDERCONFIG_H 42 | -------------------------------------------------------------------------------- /src/widgets/map/waypointeditor.h: -------------------------------------------------------------------------------- 1 | #ifndef WAYPOINTEDITOR_H 2 | #define WAYPOINTEDITOR_H 3 | 4 | #include 5 | #include 6 | #include "waypoint.h" 7 | #include "waypoint_item.h" 8 | #include "dispatcher_ui.h" 9 | 10 | class WaypointEditor : public QDialog 11 | { 12 | Q_OBJECT 13 | public: 14 | explicit WaypointEditor(WaypointItem* wi, QString ac_id, QWidget *parent = nullptr); 15 | 16 | signals: 17 | 18 | public slots: 19 | 20 | private: 21 | WaypointItem* wi; 22 | QString ac_id; 23 | }; 24 | 25 | #endif // WAYPOINTEDITOR_H 26 | -------------------------------------------------------------------------------- /src/widgets/pfd.h: -------------------------------------------------------------------------------- 1 | #ifndef PFD_H 2 | #define PFD_H 3 | 4 | #include 5 | #include "pprz_dispatcher.h" 6 | #include "configurable.h" 7 | 8 | class Pfd : public QWidget, public Configurable 9 | { 10 | Q_OBJECT 11 | public: 12 | 13 | struct Eulers { 14 | float roll; 15 | float pitch; 16 | float yaw; 17 | }; 18 | 19 | explicit Pfd(QWidget *parent = nullptr); 20 | 21 | QSize sizeHint() const; 22 | QSize minimumSizeHint() const; 23 | void configure(QDomElement) {}; 24 | 25 | protected: 26 | void paintEvent(QPaintEvent *event); 27 | virtual void mousePressEvent(QMouseEvent *event); 28 | // virtual void mouseMoveEvent(QMouseEvent *event); 29 | // virtual void mouseReleaseEvent(QMouseEvent *event); 30 | void resizeEvent(QResizeEvent *event); 31 | 32 | void paintPitch(QRect rect, QPointF center, QColor ac_color, float pitch, float roll); 33 | void paintRoll(QRect rect, QPointF center, QColor ac_color, float pitch, float roll); 34 | void paintYaw(QRect rect, QPointF center, QColor ac_color, float yaw); 35 | 36 | 37 | 38 | 39 | signals: 40 | 41 | public slots: 42 | 43 | private: 44 | enum Axis { 45 | ROLL, 46 | PITCH, 47 | YAW 48 | }; 49 | 50 | void changeCurrentAC(QString id); 51 | void updateEulers(pprzlink::Message msg); 52 | void setRotation(double rot); 53 | 54 | QRect placeRect(int i); 55 | QPointF placeCenter(int i); 56 | 57 | QPixmap* getIcon(Axis axis); 58 | 59 | 60 | Axis places[3]; 61 | std::map eulers; 62 | double rotation; 63 | 64 | QString current_ac; 65 | 66 | QPixmap pix_roll_fixedwing; 67 | QPixmap pix_pitch_fixedwing; 68 | QPixmap pix_yaw_fixedwing; 69 | QPixmap pix_no_ac; 70 | 71 | QPixmap pix_roll_rotorcraft; 72 | QPixmap pix_pitch_rotorcraft; 73 | QPixmap pix_yaw_rotorcraft; 74 | 75 | QPixmap pix_roll_rover; 76 | QPixmap pix_pitch_rover; 77 | QPixmap pix_yaw_rover; 78 | 79 | int border_stroke; 80 | 81 | }; 82 | 83 | #endif // PFD_H 84 | -------------------------------------------------------------------------------- /src/widgets/plotter.h: -------------------------------------------------------------------------------- 1 | #ifndef PLOTTER_H 2 | #define PLOTTER_H 3 | 4 | #include 5 | #include "graphwidget.h" 6 | #include "pprz_dispatcher.h" 7 | #include "configurable.h" 8 | 9 | class Plotter : public QWidget, public Configurable 10 | { 11 | Q_OBJECT 12 | public: 13 | explicit Plotter(QString ac_id, QWidget *parent = nullptr); 14 | 15 | void configure(QDomElement c); 16 | void addGraph(QString name, GraphWidget::Params p); 17 | void removeGraph(QString name); 18 | 19 | void changeGraph(QString name); 20 | 21 | signals: 22 | 23 | protected: 24 | virtual void dragEnterEvent(QDragEnterEvent *event) override; 25 | virtual void dropEvent(QDropEvent *event) override; 26 | virtual void dragMoveEvent(QDragMoveEvent *event) override; 27 | 28 | private: 29 | struct DataId { 30 | QString msg_class; 31 | QString msg_name; 32 | QString field; 33 | }; 34 | 35 | private slots: 36 | void onOpenContextMenu(); 37 | void handleMsg(QString name, QString sender, pprzlink::Message msg); 38 | 39 | private: 40 | 41 | template 42 | void feedGraph(GraphWidget* graph, QString field, pprzlink::Message msg); 43 | 44 | QLabel* title; 45 | QStackedWidget* graph_stack; 46 | QMap graphs; 47 | QMap bids; 48 | QString current_name; 49 | 50 | QToolButton* var_button; 51 | QCheckBox* autoscale_checkbox; 52 | QSpinBox* history_spinbox; 53 | 54 | QString ac_id; 55 | }; 56 | 57 | #endif // PLOTTER_H 58 | -------------------------------------------------------------------------------- /src/widgets/pprzmap.h: -------------------------------------------------------------------------------- 1 | #ifndef PPRZMAP_H 2 | #define PPRZMAP_H 3 | 4 | #include 5 | #include 6 | #include "map_item.h" 7 | #include "item_edit_state_machine.h" 8 | #include "aircraft_item.h" 9 | #include 10 | #include "coordinatestransform.h" 11 | #include "QScrollArea" 12 | #include "layer_combo.h" 13 | #include "maplayercontrol.h" 14 | #include "configurable.h" 15 | #include "acitemmanager.h" 16 | 17 | namespace Ui { 18 | class PprzMap; 19 | } 20 | 21 | 22 | 23 | class PprzMap : public QWidget, public Configurable 24 | { 25 | Q_OBJECT 26 | 27 | public: 28 | explicit PprzMap(QWidget *parent = nullptr); 29 | MapLayerControl* makeLayerControl(QString name, bool initialState, int z); 30 | void configure(QDomElement e); 31 | 32 | protected: 33 | // void scenePressEvent(QGraphicsSceneMouseEvent *mouseEvent); 34 | // void sceneMoveEvent(QGraphicsSceneMouseEvent *mouseEvent); 35 | // void sceneReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent); 36 | 37 | 38 | protected slots: 39 | void handleMouseMove(QPointF scenePos); 40 | 41 | private slots: 42 | void changeCurrentAC(QString id); 43 | 44 | private: 45 | void setEditorMode(); 46 | Ui::PprzMap *ui; 47 | QMap combo_indexes; 48 | 49 | QString current_ac; 50 | 51 | //CoordinatesTransform ct_wgs84_utm; 52 | }; 53 | 54 | #endif // PPRZMAP_H 55 | -------------------------------------------------------------------------------- /src/widgets/stackcontainer.h: -------------------------------------------------------------------------------- 1 | #ifndef STACKCONTAINER_H 2 | #define STACKCONTAINER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include "configurable.h" 8 | #include "ac_selector.h" 9 | 10 | class StackContainer : public QWidget, public Configurable 11 | { 12 | Q_OBJECT 13 | public: 14 | explicit StackContainer(std::function constructor, QWidget *parent = nullptr); 15 | explicit StackContainer(std::function constructor, 16 | std::function alt_constructor, 17 | QWidget *parent = nullptr); 18 | void configure(QDomElement c) { conf = c;} 19 | 20 | private: 21 | void handleNewAC(QString ac_id); 22 | void removeAC(QString ac_id); 23 | 24 | QMap viewers_widgets; 25 | 26 | QVBoxLayout* vLayout; 27 | ACSelector* ac_selector; 28 | QVBoxLayout* stackLayout; 29 | 30 | QDomElement conf; 31 | 32 | std::function constructor; 33 | }; 34 | 35 | #endif // STACKCONTAINER_H 36 | -------------------------------------------------------------------------------- /src/widgets/strip.h: -------------------------------------------------------------------------------- 1 | #ifndef STRIP_H 2 | #define STRIP_H 3 | 4 | #include 5 | #include 6 | #include "pprz_dispatcher.h" 7 | #include "graphlabel.h" 8 | #include "jaugelabel.h" 9 | #include "colorlabel.h" 10 | 11 | class Strip : public QWidget 12 | { 13 | Q_OBJECT 14 | public: 15 | explicit Strip(QString ac_id, QWidget *parent = nullptr, bool full = false); 16 | 17 | void setCompact(bool); 18 | 19 | signals: 20 | 21 | public slots: 22 | 23 | protected: 24 | void paintEvent(QPaintEvent*) override; 25 | virtual void mousePressEvent(QMouseEvent *e) override; 26 | virtual void mouseReleaseEvent(QMouseEvent *e) override; 27 | 28 | private: 29 | void build_full_strip(); 30 | void build_short_strip(); 31 | 32 | void updateEngineStatus(); 33 | void updateApStatus(); 34 | void updateAltTargetDiff(); 35 | void updateFlightParams(); 36 | void updateTelemetryStatus(); 37 | void updateFBW(); 38 | 39 | QString _ac_id; 40 | QColor ac_color; 41 | 42 | QWidget* full_strip; 43 | QWidget* short_strip; 44 | 45 | GraphLabel* full_bat_graph; 46 | GraphLabel* full_alt_graph; 47 | JaugeLabel* full_throttle_label; 48 | JaugeLabel* full_speed_label; 49 | ColorLabel* full_link_label; 50 | ColorLabel* full_ap_mode_label; 51 | ColorLabel* full_fbw_mode_label; 52 | ColorLabel* full_gps_mode_label; 53 | QLabel* full_flight_time_label; 54 | 55 | 56 | JaugeLabel* short_jl_bat; 57 | QLabel* short_flight_time_label; 58 | QLabel* short_speed_label; 59 | QLabel* short_alt_label; 60 | QLabel* short_vspeed_indicator; 61 | QLabel* short_vspeed_label; 62 | QLabel* short_target_label; 63 | ColorLabel* short_ap_mode_label; 64 | ColorLabel* short_fbw_mode_label; 65 | ColorLabel* short_gps_mode_label; 66 | }; 67 | 68 | #endif // STRIP_H 69 | -------------------------------------------------------------------------------- /src/widgets/widget_utils.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_UTILS_H 2 | #define WIDGET_UTILS_H 3 | 4 | #include "QWidget" 5 | 6 | QWidget* makeWidget(QWidget* parent, QString container, QString name, QString alt=""); 7 | 8 | 9 | 10 | #endif // WIDGET_UTILS_H 11 | --------------------------------------------------------------------------------