Commit 6485d280 authored by Valentin Platzgummer's avatar Valentin Platzgummer

flightpathSegments added to MeasurementComplexItem

parent 5f9f30c2
......@@ -20,8 +20,6 @@
#include <boost/units/io.hpp>
#include <boost/units/systems/si.hpp>
#define CLIPPER_SCALE 1000000
QGC_LOGGING_CATEGORY(MeasurementComplexItemLog, "MeasurementComplexItemLog")
template <typename T>
......@@ -39,8 +37,7 @@ const QString MeasurementComplexItem::name(tr("Measurement"));
MeasurementComplexItem::MeasurementComplexItem(
PlanMasterController *masterController, bool flyView,
const QString &kmlOrShpFile, QObject *parent)
: ComplexMissionItem(masterController, flyView, parent),
_masterController(masterController), _sequenceNumber(0),
: ComplexMissionItem(masterController, flyView, parent), _sequenceNumber(0),
_followTerrain(false), _state(STATE::IDLE),
_metaDataMap(FactMetaData::createMapFromJsonFile(
QStringLiteral(":/json/MeasurementComplexItem.SettingsGroup.json"),
......@@ -86,9 +83,15 @@ MeasurementComplexItem::MeasurementComplexItem(
}
}
});
// Connect readyForSave
connect(this, &MeasurementComplexItem::idleChanged, this,
&MeasurementComplexItem::readyForSaveStateChanged);
// Connect flightPathSegments
connect(this, &MeasurementComplexItem::routeChanged, this,
&MeasurementComplexItem::_updateFlightpathSegments);
// Connect complexDistance.
connect(this, &MeasurementComplexItem::routeChanged,
[this] { emit this->complexDistanceChanged(); });
......@@ -385,6 +388,43 @@ bool MeasurementComplexItem::_idle(MeasurementComplexItem::STATE state) {
return state == STATE::IDLE;
}
void MeasurementComplexItem::_updateFlightpathSegments() {
if (_cTerrainCollisionSegments != 0) {
_cTerrainCollisionSegments = 0;
emit terrainCollisionChanged(false);
qCritical() << "add alt color here...";
}
_flightPathSegments.beginReset();
_flightPathSegments.clearAndDeleteContents();
if (_route.size() > 2) {
bool ok = false;
double alt = _altitude.rawValue().toDouble(&ok) +
_masterController->missionController()
->plannedHomePosition()
.altitude();
if (ok) {
auto prev = _route.cbegin();
for (auto next = _route.cbegin() + 1; next != _route.end(); ++next) {
auto v1 = prev->value<QGeoCoordinate>();
auto v2 = next->value<QGeoCoordinate>();
_appendFlightPathSegment(v1, alt, v2, alt);
prev = next;
}
} else {
qCCritical(MeasurementComplexItemLog) << "_altitude fact not ok.";
}
}
_flightPathSegments.endReset();
if (_cTerrainCollisionSegments != 0) {
emit terrainCollisionChanged(true);
}
_masterController->missionController()->recalcTerrainProfile();
}
void MeasurementComplexItem::_setAreaData(
MeasurementComplexItem::PtrAreaData data) {
if (_pCurrentData != data) {
......
......@@ -174,9 +174,9 @@ private:
static bool _calculating(STATE state);
static bool _editing(STATE state);
static bool _idle(STATE state);
void _updateFlightpathSegments();
// Hirarcical stuff.
PlanMasterController *_masterController;
int _sequenceNumber;
bool _followTerrain;
......
......@@ -58,7 +58,15 @@ ColumnLayout {
columns: 2
visible: generalHeader.checked
QGCLabel { text: qsTr("Altitude!!!") }
QGCLabel {
text: qsTr("Altitude")
Layout.fillWidth: true
}
FactTextField {
fact: missionItem.altitude
Layout.fillWidth: true
}
QGCLabel { text: qsTr("Relative Altitude!!!") }
QGCLabel {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment