27 #include <QPainterPath>
46 , bForceRedraw( true )
74 && fabs( __fdSpeed ) > 5.0 )
76 __fdPitch = atan( __fdSpeedVertical / __fdSpeed ) *
QVCT::RAD2DEG;
84 if( __fdTime -
fdTime > 0.0 )
86 double __fdSpeedAngular = ( __fdBearing -
fdBearing ) / ( __fdTime -
fdTime );
109 drawDynamic( __poVesselPoint, __fdPitch, __fdRoll );
119 __qPainter.begin(
this );
120 __qPainter.setRenderHints( QPainter::SmoothPixmapTransform | QPainter::Antialiasing | QPainter::TextAntialiasing );
137 QPointF __qPointFCenter = QPointF( QRectF( QWidget::rect() ).center() );
138 double __fdSizeFactor = ( QWidget::width() < QWidget::height() ? (double)QWidget::width() : (double)QWidget::height() ) / 1200.0;
143 QTransform __qTransform;
144 __qTransform.translate( __qPointFCenter.x(), __qPointFCenter.y() );
145 __qTransform.scale( __fdSizeFactor, __fdSizeFactor );
153 __qPainter.setRenderHints( QPainter::Antialiasing | QPainter::TextAntialiasing );
154 __qPainter.setWorldTransform( __qTransform );
159 __qPen.setColor( Qt::white );
160 __qPen.setWidth( 10.0 );
161 __qPainter.setPen( __qPen );
162 __qPainter.setBrush( QColor( 32, 32, 32, 255 ) );
163 __qPainter.drawEllipse( QPointF( 0.0, 0.0 ), 495.0, 495.0 );
166 for(
int __i=-3; __i<=3; __i++ )
168 double __fdAngle = (double)__i *
QVCT::PI / 18.0;
169 QPointF __qPointFAngle( sin( __fdAngle ), -cos( __fdAngle ) );
170 __qPainter.drawLine( 450.0*__qPointFAngle, 480.0*__qPointFAngle );
174 for(
int __i=-3; __i<=3; __i++ )
176 double __fdAngle = (double)__i *
QVCT::PI / 6.0;
177 QPointF __qPointFAngle( sin( __fdAngle ), -cos( __fdAngle ) );
178 __qPainter.drawLine( 420.0*__qPointFAngle, 480.0*__qPointFAngle );
182 __qPen.setWidth( 15.0 );
183 __qPainter.setPen( __qPen );
184 for(
int __i=-1; __i<=1; __i++ )
187 double __fdAngle = (double)__i *
QVCT::PI / 2.0;
188 QPointF __qPointFAngle( sin( __fdAngle ), -cos( __fdAngle ) );
189 __qPainter.drawLine( 390.0*__qPointFAngle, 480.0*__qPointFAngle );
193 __qPen.setColor( Qt::white );
194 __qPen.setWidth( 0 );
195 __qPainter.setPen( __qPen );
196 __qPainter.setBrush( Qt::white );
197 __qPainter.rotate( -45.0 );
198 for(
int __i=0; __i<3; __i++ )
200 static const QPointF __pqPointFPolygon[3] =
202 QPointF( -30.0, -480.0 ),
203 QPointF( 0.0, -410.0 ),
204 QPointF( +30.0, -480.0 ),
206 __qPainter.drawConvexPolygon( __pqPointFPolygon, 3 );
207 __qPainter.rotate( 45.0 );
211 __qPen.setColor( Qt::lightGray );
212 __qPen.setWidth( 5.0 );
213 __qPainter.setPen( __qPen );
214 __qPainter.setBrush( QColor( 32, 32, 32, 255 ) );
215 __qFont.setPixelSize( 50.0 );
216 __qFont.setBold(
false );
217 __qPainter.setFont( __qFont );
218 __qPainter.setWorldTransform( __qTransform );
220 QRectF __qRectFFrame( QPointF( -150.0, -60.0 ), QSizeF( 300.0, 120.0 ) );
221 QRectF __qRectFText( QPointF( -125.0, -30.0 ), QSizeF( 250.0, 60.0 ) );
222 __qPainter.drawRoundedRect( __qRectFFrame.translated( QPointF( -425.0, +515.0 ) ), 10.0, 10.0 );
223 __qPainter.drawText( __qRectFText.translated( QPointF( -440.0, +540.0 ) ), Qt::AlignLeft,
"PITCH" );
224 __qPainter.drawRoundedRect( __qRectFFrame.translated( QPointF( +425.0, +515.0 ) ), 10.0, 10.0 );
225 __qPainter.drawText( __qRectFText.translated( QPointF( +440.0, +540.0 ) ), Qt::AlignRight,
"ROLL" );
232 QTransform __qTransform;
233 __qTransform.translate( __qPointFCenter.x()*2.0, __qPointFCenter.y()*2.0 );
234 __qTransform.scale( __fdSizeFactor, __fdSizeFactor );
242 __qPainter.setRenderHints( QPainter::Antialiasing | QPainter::TextAntialiasing );
243 __qPainter.setWorldTransform( __qTransform );
248 __qPen.setColor( Qt::white );
249 __qPen.setWidth( 0 );
250 __qPainter.setPen( __qPen );
251 __qPainter.setBrush( QColor( 0, 192, 255 ) );
252 __qPainter.drawRect( -1000.0, -1000.0, 2000.0, 1000.0 );
255 __qPen.setWidth( 10.0 );
256 __qPainter.setPen( __qPen );
257 for(
int __i=-6; __i<=6; __i++ )
259 __qPainter.drawLine( QPointF( -30.0, __i*30.0 ), QPointF( +30.0, __i*30.0 ) );
261 __qFont.setPixelSize( 40.0 );
262 __qFont.setBold(
true );
263 __qPainter.setFont( __qFont );
264 for(
int __i=-3; __i<=3; __i++ )
266 int __j = fabs( __i );
267 __qPainter.drawLine( QPointF( -75.0-__j*25.0, __i*60.0 ), QPointF( +75.0+__j*25.0, __i*60.0 ) );
269 QRectF __qRectFText( QPointF( -40.0, -20.0 ), QSizeF( 80.0, 40.0 ) );
270 __qPainter.drawText( __qRectFText.translated( QPointF( -125.0-__j*25.0, __i*60.0 ) ), Qt::AlignCenter, QString::number( __j*10 ) );
271 __qPainter.drawText( __qRectFText.translated( QPointF( +125.0+__j*25.0, __i*60.0 ) ), Qt::AlignCenter, QString::number( __j*10 ) );
275 __qPen.setWidth( 15.0 );
276 __qPainter.setPen( __qPen );
277 __qPainter.drawLine( QPointF( -1000.0, 0.0 ), QPointF( +1000.0, 0.0 ) );
288 QPointF __qPointFCenter = QPointF( QRectF( QWidget::rect() ).center() );
289 double __fdSizeFactor = ( QWidget::width() < QWidget::height() ? (double)QWidget::width() : (double)QWidget::height() ) / 1200.0;
290 QTransform __qTransformNonScaled;
291 __qTransformNonScaled.translate( __qPointFCenter.x(), __qPointFCenter.y() );
292 QTransform __qTransformScaled;
293 __qTransformScaled.translate( __qPointFCenter.x(), __qPointFCenter.y() );
294 __qTransformScaled.scale( __fdSizeFactor, __fdSizeFactor );
301 __qPainter.setRenderHints( QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform );
306 QPainterPath __qPainterPath;
307 __qPainterPath.addEllipse( __qPointFCenter, 390.0*__fdSizeFactor, 390.0*__fdSizeFactor );
308 __qPainter.setClipPath( __qPainterPath );
309 __qPainter.setWorldTransform( __qTransformNonScaled );
310 __qPainter.translate( 0.0, __fdPitchConverted*6.0*__fdSizeFactor );
311 __qPainter.rotate( -__fdRollConverted );
313 __qPainter.setClipping(
false );
314 __qPen.setColor( Qt::black );
315 __qPen.setWidth( 10.0 );
316 __qPainter.setPen( __qPen );
317 __qPainter.setWorldTransform( __qTransformScaled );
318 __qPainter.drawEllipse( QPointF( 0.0, 0.0 ), 390.0, 390.0 );
321 __qPen.setColor( Qt::black );
322 __qPen.setWidth( 0 );
323 __qPen.setCapStyle( Qt::SquareCap );
324 __qPainter.setPen( __qPen );
325 __qPainter.setBrush( QColor( 255, 224, 0 ) );
326 __qPainter.setPen( __qPen );
327 __qPainter.drawRoundedRect( QRectF( QPointF( -175.0, -10.0 ), QPointF( -50.0, +10.0 ) ), 10.0, 10.0 );
328 __qPainter.drawEllipse( QPointF( 0.0, 0.0 ), 10.0, 10.0 );
329 __qPainter.drawRoundedRect( QRectF( QPointF( +50.0, -10.0 ), QPointF( +175.0, +10.0 ) ), 10.0, 10.0 );
330 __qPainter.rotate( -__fdRollConverted );
332 static const QPointF __pqPointFPolygon[3] =
334 QPointF( -30.0, -310.0 ),
335 QPointF( 0.0, -380.0 ),
336 QPointF( +30.0, -310.0 ),
338 __qPainter.drawConvexPolygon( __pqPointFPolygon, 3 );
342 __qPen.setColor( Qt::white );
343 __qPainter.setPen( __qPen );
344 __qFont.setPixelSize( 50.0 );
345 __qFont.setBold(
false );
346 __qPainter.setFont( __qFont );
347 __qPainter.setWorldTransform( __qTransformScaled );
349 QRectF __qRectFText( QPointF( -125.0, -30.0 ), QSizeF( 250.0, 60.0 ) );
350 QString __qsPITCH(
"n/a" ), __qsROLL(
"n/a" );
359 __qPainter.setFont( __qFont );
360 __qPainter.drawText( __qRectFText.translated( QPointF( -425.0, +490.0 ) ), Qt::AlignCenter, __qsPITCH );
362 __qPainter.setFont( __qFont );
363 __qPainter.drawText( __qRectFText.translated( QPointF( +425.0, +490.0 ) ), Qt::AlignCenter, __qsROLL );
367 if( !_poVesselPoint )
369 __qPen.setColor( Qt::black );
370 __qPen.setWidth( 0 );
371 __qPainter.setPen( __qPen );
372 __qPainter.setBrush( QBrush( Qt::red ) );
373 __qFont.setBold(
true );
374 __qFont.setItalic(
false );
375 __qPainter.setFont( __qFont );
376 QRectF __qRectFText( QPointF( -75.0, -30.0 ), QSizeF( 150.0, 60.0 ) );
377 __qPainter.drawRect( __qRectFText.translated( QPointF( +150.0, -50.0 ) ) );
378 __qPainter.drawText( __qRectFText.translated( QPointF( +150.0, -50.0 ) ), Qt::AlignCenter,
"OFF" );
CDataCourse GroundCourse
Ground course.
CDataCourseValidity GroundCourseValidity
Ground course validity.
bool isValidSpeedVertical() const
Returns the vertical speed's (global) validity status.
bool isValidSpeed() const
Returns the horizontal speed's (global) validity status.
bool isValidBearing() const
Returns the bearing's (global) validity status.
(Geographical) Course data [bearing, horizontal/vertical speeds]
double getSpeedVertical() const
Returns this course's vertical speed, in meters per second.
static constexpr double UNDEFINED_BEARING
Specific value for an undefined bearing.
static constexpr double UNDEFINED_SPEED
Specific value for an undefined speed.
double getBearing() const
Returns this course's bearing, in degrees.
double getSpeed() const
Returns this course's horizontal speed, in meters per second.
double getTime() const
Returns this time's time, in seconds from Unix epoch.
static constexpr double UNDEFINED_TIME
Specific value for an undefined time.
QPixmap qPixmapBufferBackground
Pixmap buffer used to render and cache the instrument's (static) background.
double fdRoll
Roll (angle) at which the last rendering was achieved.
double fdBearing
Bearing at which the last rendering was achieved.
double fdTime
Time at which the last rendering was achieved.
double fdPitch
Pitch (angle) at which the last rendering was achieved.
bool bForceRedraw
Forces the redraw of the instrument (not matter its cache content)
CInstrumentGAArtificialHorizon(CVesselCockpit *_poVesselCockpit)
QPixmap qPixmapBuffer
Pixmap buffer used to render and cache the instrument.
virtual void draw()
Draws the instrument (resets if the vessel is undefined)
QPixmap qPixmapBufferForeground
Pixmap buffer used to render and cache the instrument's (static) foreground.
void drawDynamic(const CVesselPoint *_poVesselPoint, double _fdPitch, double _fdRoll)
CVesselPoint * useVesselPoint()
Returns parent cockpit's associated vessel (0 if the vessel is undefined)
static QString toString(double _fdValue, EUnit _eUnit, int _iPrecision=0)
Returns the formatted represention of the given value, using the specified format/unit and decimal pr...
[UI] Generic vessel's cockpit view (window)
[UI] Vessel overlay point (item) / vessel
static constexpr double PI
static constexpr double RAD2DEG
static constexpr double DEG2RAD