1 // RouteDiagram.hxx - show a route graphically 2 // 3 // Written by James Turner, started August 2018. 4 // 5 // Copyright (C) 2018 James Turner <james@flightgear.org> 6 // 7 // This program is free software; you can redistribute it and/or 8 // modify it under the terms of the GNU General Public License as 9 // published by the Free Software Foundation; either version 2 of the 10 // License, or (at your option) any later version. 11 // 12 // This program is distributed in the hope that it will be useful, but 13 // WITHOUT ANY WARRANTY; without even the implied warranty of 14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 // General Public License for more details. 16 // 17 // You should have received a copy of the GNU General Public License 18 // along with this program; if not, write to the Free Software 19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 21 #ifndef GUI_ROUTE_DIAGRAM_HXX 22 #define GUI_ROUTE_DIAGRAM_HXX 23 24 #include "BaseDiagram.hxx" 25 #include "QmlPositioned.hxx" 26 #include "UnitsModel.hxx" 27 28 #include <Navaids/navrecord.hxx> 29 #include <Navaids/routePath.hxx> 30 31 #include <simgear/math/sg_geodesy.hxx> 32 33 class FlightPlanController; 34 35 class RouteDiagram : public BaseDiagram 36 { 37 Q_OBJECT 38 39 Q_PROPERTY(FlightPlanController* flightplan READ flightplan WRITE setFlightplan NOTIFY flightplanChanged) 40 41 Q_PROPERTY(int activeLegIndex READ activeLegIndex WRITE setActiveLegIndex NOTIFY legIndexChanged) 42 Q_PROPERTY(int numLegs READ numLegs NOTIFY flightplanChanged) 43 public: 44 RouteDiagram(QQuickItem* pr = nullptr); 45 flightplan() const46 FlightPlanController* flightplan() const 47 { 48 return m_flightplan; 49 } 50 51 void setFlightplan(FlightPlanController* fp); 52 53 int numLegs() const; 54 activeLegIndex() const55 int activeLegIndex() const 56 { 57 return m_activeLegIndex; 58 } 59 60 public slots: 61 void setActiveLegIndex(int activeLegIndex); 62 63 signals: 64 void flightplanChanged(FlightPlanController* flightplan); 65 66 void legIndexChanged(int activeLegIndex); 67 68 protected: 69 void paintContents(QPainter *) override; 70 71 void doComputeBounds() override; 72 private: 73 void fpChanged(); 74 75 FlightPlanController* m_flightplan = nullptr; 76 77 std::unique_ptr<RoutePath> m_path; 78 int m_activeLegIndex = 0; 79 }; 80 81 #endif // of GUI_ROUTE_DIAGRAM_HXX 82