Qt Virtual Chart Table (QVCT)
CVesselPosition.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 CVesselPosition::CVesselPosition( QWidget* _pqParent )
35  : CVesselWidget( tr("Vessel Position"), _pqParent )
36 {
37  QDockWidget::setObjectName( "VesselPosition" ); // 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  // ... position
49  poTextLongitude->setToolTip( tr("Longitude") );
50  poTextLongitude->setAlignment( Qt::AlignCenter );
52  pqBoxLayout->addWidget( poTextLongitude );
54  poTextLatitude->setToolTip( tr("Latitude") );
55  poTextLatitude->setAlignment( Qt::AlignCenter );
57  pqBoxLayout->addWidget( poTextLatitude );
59  poTextElevation->setToolTip( tr("Elevation") );
60  poTextElevation->setAlignment( Qt::AlignCenter );
62  pqBoxLayout->addWidget( poTextElevation );
63 }
64 
65 
66 //------------------------------------------------------------------------------
67 // METHODS: CVesselWidget (implement/override)
68 //------------------------------------------------------------------------------
69 
70 void CVesselPosition::setFont( QFont _qFont )
71 {
72  poTextLongitude->setFont( _qFont );
73  poTextLatitude->setFont( _qFont );
74  poTextElevation->setFont( _qFont );
75 }
76 
78 {
79  if( !poVesselPoint || !QWidget::isVisible() ) return;
80 
81  // ... position
84  {
87  }
88  else
89  {
92  }
93 
94  // ... elevation
97  else
99 }
100 
102 {
106 }
bool isValidPosition() const
Returns the position's (global) validity status.
bool isValidElevation() const
Returns the elevation's (global) validity status.
double getLongitude() const
Returns this position's longitude, in degrees.
static constexpr double UNDEFINED_LATITUDE
Specific value for an undefined latitude.
double getElevation() const
Returns this position's elevation, in meters.
double getLatitude() const
Returns this position's latitude, in degrees.
static constexpr double UNDEFINED_LONGITUDE
Specific value for an undefined longitude.
static constexpr double UNDEFINED_ELEVATION
Specific value for an undefined elevation.
[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, EType _eType, EUnit _eUnit, int _iPrecision=0)
Returns the formatted represention of the given value, using the specified format/unit and decimal pr...
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 * poTextElevation
[UI:Label] Elevation
COverlayText * poTextLatitude
[UI:Label] Latitude
void constructLayout()
Constructs the layout of the user-interface.
COverlayText * poTextLongitude
[UI:Label] Longitude
CVesselPosition(QWidget *_pqParent=0)
virtual void resetContent()
Resets (clears) the content of the underlying widget.
[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