mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-08 03:35:35 +08:00
Ref T717, UI for relative positions
This commit is contained in:
58
src/blackgui/editors/relativeaircraftposition.cpp
Normal file
58
src/blackgui/editors/relativeaircraftposition.cpp
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
/* Copyright (C) 2019
|
||||||
|
* swift project Community / Contributors
|
||||||
|
*
|
||||||
|
* This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||||
|
* directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated,
|
||||||
|
* or distributed except according to the terms contained in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "relativeaircraftposition.h"
|
||||||
|
#include "ui_relativeaircraftposition.h"
|
||||||
|
|
||||||
|
using namespace BlackMisc::Geo;
|
||||||
|
using namespace BlackMisc::PhysicalQuantities;
|
||||||
|
|
||||||
|
namespace BlackGui
|
||||||
|
{
|
||||||
|
namespace Editors
|
||||||
|
{
|
||||||
|
CRelativeAircraftPosition::CRelativeAircraftPosition(QWidget *parent) :
|
||||||
|
CForm(parent),
|
||||||
|
ui(new Ui::CRelativeAircraftPosition)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
CRelativeAircraftPosition::~CRelativeAircraftPosition()
|
||||||
|
{ }
|
||||||
|
|
||||||
|
void CRelativeAircraftPosition::setReadOnly(bool readOnly)
|
||||||
|
{
|
||||||
|
ui->sb_Distance->setReadOnly(readOnly);
|
||||||
|
ui->sb_RelativeBearing->setReadOnly(readOnly);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CRelativeAircraftPosition::setDistance(const CLength &distance)
|
||||||
|
{
|
||||||
|
const int distMeters = distance.valueInteger(CLengthUnit::m());
|
||||||
|
ui->sb_Distance->setValue(distMeters);
|
||||||
|
}
|
||||||
|
|
||||||
|
CCoordinateGeodetic CRelativeAircraftPosition::getRelativeCoordinate(const CAngle &bearingOffset) const
|
||||||
|
{
|
||||||
|
if (m_originCoordinate.isNull()) { return CCoordinateGeodetic::null(); }
|
||||||
|
const CLength distance(ui->sb_Distance->value(), CLengthUnit::m());
|
||||||
|
CAngle relBearing(ui->sb_RelativeBearing->value(), CAngleUnit::deg());
|
||||||
|
if (!bearingOffset.isNull()) { relBearing += bearingOffset; }
|
||||||
|
return m_originCoordinate.calculatePosition(distance, relBearing);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CRelativeAircraftPosition::displayInfo(const CCoordinateGeodetic &relPos)
|
||||||
|
{
|
||||||
|
const CCoordinateGeodetic p = relPos.isNull() ? this->getRelativeCoordinate() : relPos;
|
||||||
|
ui->le_Info->setText(
|
||||||
|
QStringLiteral("%1 / %2").arg(m_originCoordinate.toQString(true), p.toQString(true))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} // ns
|
||||||
|
} // ns
|
||||||
59
src/blackgui/editors/relativeaircraftposition.h
Normal file
59
src/blackgui/editors/relativeaircraftposition.h
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
/* Copyright (C) 2019
|
||||||
|
* swift project Community / Contributors
|
||||||
|
*
|
||||||
|
* This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||||
|
* directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated,
|
||||||
|
* or distributed except according to the terms contained in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//! \file
|
||||||
|
|
||||||
|
#ifndef BLACKGUI_EDITORS_RELATIVEAIRCRAFTPOSITION_H
|
||||||
|
#define BLACKGUI_EDITORS_RELATIVEAIRCRAFTPOSITION_H
|
||||||
|
|
||||||
|
#include <QFrame>
|
||||||
|
#include <QScopedPointer>
|
||||||
|
|
||||||
|
#include "blackmisc/geo/coordinategeodetic.h"
|
||||||
|
#include "blackgui/editors/form.h"
|
||||||
|
|
||||||
|
namespace Ui { class CRelativeAircraftPosition; }
|
||||||
|
namespace BlackGui
|
||||||
|
{
|
||||||
|
namespace Editors
|
||||||
|
{
|
||||||
|
//! Position relative to other aircraft
|
||||||
|
class CRelativeAircraftPosition : public CForm
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
//! Constructor
|
||||||
|
explicit CRelativeAircraftPosition(QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
//! Destructor
|
||||||
|
virtual ~CRelativeAircraftPosition() override;
|
||||||
|
|
||||||
|
//! \copydoc CForm::setReadOnly
|
||||||
|
virtual void setReadOnly(bool readOnly) override;
|
||||||
|
|
||||||
|
//! Set origin coordinate
|
||||||
|
void setOriginCoordinate(const BlackMisc::Geo::CCoordinateGeodetic &originCoordinate) { m_originCoordinate = originCoordinate; }
|
||||||
|
|
||||||
|
//! Set the distance
|
||||||
|
void setDistance(const BlackMisc::PhysicalQuantities::CLength &distance);
|
||||||
|
|
||||||
|
//! Relative coordinate based on entered data
|
||||||
|
BlackMisc::Geo::CCoordinateGeodetic getRelativeCoordinate(const BlackMisc::PhysicalQuantities::CAngle &bearingOffset = BlackMisc::PhysicalQuantities::CAngle::null()) const;
|
||||||
|
|
||||||
|
//! Display coordinate info
|
||||||
|
void displayInfo(const BlackMisc::Geo::CCoordinateGeodetic &relPos = BlackMisc::Geo::CCoordinateGeodetic::null());
|
||||||
|
|
||||||
|
private:
|
||||||
|
QScopedPointer<Ui::CRelativeAircraftPosition> ui;
|
||||||
|
BlackMisc::Geo::CCoordinateGeodetic m_originCoordinate;
|
||||||
|
};
|
||||||
|
} // ns
|
||||||
|
} // ns
|
||||||
|
|
||||||
|
#endif // guard
|
||||||
83
src/blackgui/editors/relativeaircraftposition.ui
Normal file
83
src/blackgui/editors/relativeaircraftposition.ui
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>CRelativeAircraftPosition</class>
|
||||||
|
<widget class="QFrame" name="CRelativeAircraftPosition">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>298</width>
|
||||||
|
<height>24</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Relative coordinate</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gl_RelativeAircraftPosition">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="lbl_Distance">
|
||||||
|
<property name="text">
|
||||||
|
<string>distance:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QLabel" name="lbl_RelativeBearing">
|
||||||
|
<property name="text">
|
||||||
|
<string>rel.bearing</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="3">
|
||||||
|
<widget class="QSpinBox" name="sb_RelativeBearing">
|
||||||
|
<property name="suffix">
|
||||||
|
<string> deg.</string>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>359</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QSpinBox" name="sb_Distance">
|
||||||
|
<property name="suffix">
|
||||||
|
<string> m</string>
|
||||||
|
</property>
|
||||||
|
<property name="minimum">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>5000</number>
|
||||||
|
</property>
|
||||||
|
<property name="singleStep">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
|
<property name="stepType">
|
||||||
|
<enum>QAbstractSpinBox::DefaultStepType</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="4">
|
||||||
|
<widget class="QLineEdit" name="le_Info">
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
Reference in New Issue
Block a user