Qt Virtual Chart Table (QVCT)
CVesselCourse.cpp
Go to the documentation of this file.
1 // INDENTING (emacs/vi): -*- mode:c++; tab-width:2; c-basic-offset:2; intent-tabs-mode:nil; -*- ex: set tabstop=2 expandtab:
2 
3 /*
4  * Qt Virtual Chart Table (QVCT)
5  * Copyright (C) 2012 Cedric Dufour <http://cedric.dufour.name>
6  * Author: Cedric Dufour <http://cedric.dufour.name>
7  *
8  * The Qt Virtual Chart Table (QVCT) is free software:
9  * you can redistribute it and/or modify it under the terms of the GNU General
10  * Public License as published by the Free Software Foundation, Version 3.
11  *
12  * The Qt Virtual Chart Table (QVCT) is distributed in the hope
13  * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
14  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15  *
16  * See the GNU General Public License for more details.
17  */
18 
19 // QT
20 #include <QDockWidget>
21 #include <QWidget>
22 
23 // QVCT
24 #include "QVCTRuntime.hpp"
28 
29 
30 //------------------------------------------------------------------------------
31 // CONSTRUCTORS / DESTRUCTOR
32 //------------------------------------------------------------------------------
33 
34 CVesselCourse::CVesselCourse( QWidget* _pqParent )
35  : CVesselWidget( tr("Vessel Course"), _pqParent )
36 {
37  QDockWidget::setObjectName( "VesselCourse" ); // required to save main window's state
38  QDockWidget::setAllowedAreas( Qt::AllDockWidgetAreas );
40  QObject::connect( this, SIGNAL(dockLocationChanged(Qt::DockWidgetArea)), this, SLOT( slotLocationChanged(Qt::DockWidgetArea) ) );
41  QObject::connect( this, SIGNAL(topLevelChanged(bool)), this, SLOT( slotTopLevelChanged(bool) ) );
42 }
43 
45 {
46  // Add data
47  // ... course
49  poTextBearing->setToolTip( tr("Bearing") );
50  poTextBearing->setAlignment( Qt::AlignCenter );
52  pqBoxLayout->addWidget( poTextBearing );
53  poTextSpeed = new COverlayText();
54  poTextSpeed->setToolTip( tr("Speed (horizontal)") );
55  poTextSpeed->setAlignment( Qt::AlignCenter );
57  pqBoxLayout->addWidget( poTextSpeed );
59  poTextSpeedVertical->setToolTip( tr("Speed (vertical)") );
60  poTextSpeedVertical->setAlignment( Qt::AlignCenter );
62  pqBoxLayout->addWidget( poTextSpeedVertical );
63 }
64 
65 
66 //------------------------------------------------------------------------------
67 // METHODS: CVesselWidget (implement/override)
68 //------------------------------------------------------------------------------
69 
70 void CVesselCourse::setFont( QFont _qFont )
71 {
72  poTextBearing->setFont( _qFont );
73  poTextSpeed->setFont( _qFont );
74  poTextSpeedVertical->setFont( _qFont );
75 }
76 
78 {
79  if( !poVesselPoint || !QWidget::isVisible() ) return;
82  {
83 
84  // ... bearing
85  {
86  QString __qsText;
87  bool __bInvalid = false;
89  {
92  }
94  {
95  if( __qsText.isEmpty() ) __qsText += " ";
98  }
99  poTextBearing->setText( __qsText, __bInvalid );
100  }
101 
102  // ... horizontal speed
103  {
104  QString __qsText;
105  bool __bInvalid = false;
107  {
110  }
112  {
113  if( __qsText.isEmpty() ) __qsText += " ";
114  __qsText += "("+CUnitSpeed::toString( poVesselPoint->ApparentCourse.getSpeed() )+")";
116  }
117  poTextSpeed->setText( __qsText, __bInvalid );
118  }
119 
120  // ... vertical speed
121  {
122  QString __qsText;
123  bool __bInvalid = false;
125  {
128  }
130  {
131  if( __qsText.isEmpty() ) __qsText += " ";
134  }
135  poTextSpeedVertical->setText( __qsText, __bInvalid );
136  }
137 
138  }
139  else
140  resetContent();
141 }
142 
144 {
148 }
CDataCourse ApparentCourse
Apparent course.
CDataCourse GroundCourse
Ground course.
CDataCourseValidity GroundCourseValidity
Ground course validity.
CDataCourseValidity ApparentCourseValidity
Apparent 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.
double getSpeedVertical() const
Returns this course's vertical speed, in meters per second.
static constexpr double UNDEFINED_BEARING
Specific value for an undefined bearing.
Definition: CDataCourse.hpp:42
static constexpr double UNDEFINED_SPEED
Specific value for an undefined speed.
Definition: CDataCourse.hpp:44
double getBearing() const
Returns this course's bearing, in degrees.
static const CDataCourse UNDEFINED
Specific value for an undefined course.
Definition: CDataCourse.hpp:46
double getSpeed() const
Returns this course's horizontal speed, in meters per second.
[UI] Overlay-specific text label
void setText(const QString &_rqsText)
[override] QLabel::setText( const QString& )
void resetText()
Resets (clears) the underlying QLabel's text.
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...
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...
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...
Definition: CUnitSpeed.cpp:78
COverlayText * poTextSpeed
[UI:Label] Speed (horizontal)
void constructLayout()
Constructs the layout of the user-interface.
virtual void setFont(QFont _qFont)
Sets the font for the content of the underlying widget.
virtual void refreshContent()
Refreshes the content of the underlying widget.
COverlayText * poTextSpeedVertical
[UI:Label] Speed (vertical)
CVesselCourse(QWidget *_pqParent=0)
virtual void resetContent()
Resets (clears) the content of the underlying widget.
COverlayText * poTextBearing
[UI:Label] Bearing
[UI] Generic vessel (dock) widget
CVesselPoint * poVesselPoint
Overlay course being displayed.
void slotTopLevelChanged(bool _bTopLevel)
Slot to handle floating change.
void slotLocationChanged(Qt::DockWidgetArea _qDockWidgetArea)
Slot to handle dock area change.
QBoxLayout * pqBoxLayout
[UI:Layout] Layout