QFlightInstruments
QFlightInstruments is a Qt library containing flight instruments widgets.
qfi_EHSI.h
1 /****************************************************************************//*
2  * Copyright (C) 2021 Marek M. Cel
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining
5  * a copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom
9  * the Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included
12  * in all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20  * IN THE SOFTWARE.
21  ******************************************************************************/
22 #ifndef QFI_EHSI_H
23 #define QFI_EHSI_H
24 
26 
27 #include <QGraphicsView>
28 #include <QGraphicsSvgItem>
29 
31 
35 class qfi_EHSI : public QGraphicsView
36 {
37  Q_OBJECT
38 
39 public:
40 
42  enum class CDI
43  {
44  Off = 0,
45  TO,
46  FROM
47  };
48 
50  explicit qfi_EHSI( QWidget *parent = Q_NULLPTR );
51 
53  virtual ~qfi_EHSI();
54 
56  void reinit();
57 
59  void redraw();
60 
62  void setHeading( double heading );
63 
65  void setCourse( double course );
66 
68  void setBearing( double bearing, bool visible = false );
69 
71  void setDeviation( double deviation, CDI cdi = CDI::Off );
72 
74  void setDistance( double distance, bool visible = false );
75 
77  void setHeadingSel( double heading );
78 
79 protected:
80 
82  void resizeEvent( QResizeEvent *event );
83 
84 private:
85 
86  QGraphicsScene *_scene;
87 
88  QGraphicsSvgItem *_itemBack;
89  QGraphicsSvgItem *_itemMask;
90  QGraphicsSvgItem *_itemMark;
91 
92  QGraphicsSvgItem *_itemBrgArrow;
93  QGraphicsSvgItem *_itemCrsArrow;
94  QGraphicsSvgItem *_itemDevBar;
95  QGraphicsSvgItem *_itemDevScale;
96  QGraphicsSvgItem *_itemHdgBug;
97  QGraphicsSvgItem *_itemHdgScale;
98  QGraphicsSvgItem *_itemCdiTo;
99  QGraphicsSvgItem *_itemCdiFrom;
100 
101  QGraphicsTextItem *_itemCrsText;
102  QGraphicsTextItem *_itemHdgText;
103  QGraphicsTextItem *_itemDmeText;
104 
105  double _heading;
106  double _course;
107  double _bearing;
108  double _deviation;
109  double _distance;
110 
111  double _heading_sel;
112 
113  CDI _cdi;
114 
115  bool _bearingVisible;
116  bool _distanceVisible;
117 
118  double _devBarDeltaX_new;
119  double _devBarDeltaX_old;
120  double _devBarDeltaY_new;
121  double _devBarDeltaY_old;
122 
123  double _scaleX;
124  double _scaleY;
125 
126  double _originalPixPerDev;
127 
128  QPointF _originalNavCtr;
129 
130  QPointF _originalCrsTextCtr;
131  QPointF _originalHdgTextCtr;
132  QPointF _originalDmeTextCtr;
133 
134  const int _originalHeight;
135  const int _originalWidth;
136 
137  const int _backZ;
138  const int _maskZ;
139  const int _markZ;
140 
141  const int _brgArrowZ;
142  const int _crsArrowZ;
143  const int _crsTextZ;
144  const int _devBarZ;
145  const int _devScaleZ;
146  const int _hdgBugZ;
147  const int _hdgScaleZ;
148  const int _hdgTextZ;
149  const int _dmeTextZ;
150 
152  void init();
153 
155  void reset();
156 
158  void updateView();
159 };
160 
162 
163 #endif // QFI_EHSI_H
qfi_EHSI::setCourse
void setCourse(double course)
Definition: qfi_EHSI.cpp:166
qfi_EHSI::reinit
void reinit()
Definition: qfi_EHSI.cpp:131
qfi_EHSI::setHeadingSel
void setHeadingSel(double heading)
Definition: qfi_EHSI.cpp:206
qfi_EHSI::setDistance
void setDistance(double distance, bool visible=false)
Definition: qfi_EHSI.cpp:198
qfi_EHSI::CDI
CDI
Definition: qfi_EHSI.h:42
qfi_EHSI::redraw
void redraw()
Definition: qfi_EHSI.cpp:143
qfi_EHSI::qfi_EHSI
qfi_EHSI(QWidget *parent=Q_NULLPTR)
Constructor.
Definition: qfi_EHSI.cpp:37
qfi_EHSI
This class provides EHSI widget class.
Definition: qfi_EHSI.h:35
qfi_EHSI::setDeviation
void setDeviation(double deviation, CDI cdi=CDI::Off)
Definition: qfi_EHSI.cpp:187
qfi_EHSI::setHeading
void setHeading(double heading)
Definition: qfi_EHSI.cpp:156
qfi_EHSI::setBearing
void setBearing(double bearing, bool visible=false)
Definition: qfi_EHSI.cpp:176
qfi_EHSI::~qfi_EHSI
virtual ~qfi_EHSI()
Destructor.
Definition: qfi_EHSI.cpp:117