Unverified Commit ed73b5a5 authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #7364 from lichenyuneec/StructureScan_Distance

the battery and distance of structure scan always show 0
parents d20bd666 59ef1c02
......@@ -83,6 +83,9 @@ StructureScanComplexItem::StructureScanComplexItem(Vehicle* vehicle, bool flyVie
connect(&_cameraCalc, &CameraCalc::isManualCameraChanged, this, &StructureScanComplexItem::_updateGimbalPitch);
connect(&_layersFact, &Fact::valueChanged, this, &StructureScanComplexItem::_recalcScanDistance);
connect(&_flightPolygon, &QGCMapPolygon::pathChanged, this, &StructureScanComplexItem::_recalcScanDistance);
_recalcLayerInfo();
if (!kmlOrShpFile.isEmpty()) {
......@@ -93,14 +96,6 @@ StructureScanComplexItem::StructureScanComplexItem(Vehicle* vehicle, bool flyVie
setDirty(false);
}
void StructureScanComplexItem::_setScanDistance(double scanDistance)
{
if (!qFuzzyCompare(_scanDistance, scanDistance)) {
_scanDistance = scanDistance;
emit complexDistanceChanged();
}
}
void StructureScanComplexItem::_setCameraShots(int cameraShots)
{
if (_cameraShots != cameraShots) {
......@@ -519,6 +514,7 @@ void StructureScanComplexItem::_rebuildFlightPolygon(void)
} else {
_entryVertex = savedEntryVertex;
}
emit coordinateChanged(coordinate());
emit exitCoordinateChanged(exitCoordinate());
}
......@@ -598,3 +594,26 @@ void StructureScanComplexItem::_signalTopBottomAltChanged(void)
emit topFlightAltChanged();
emit bottomFlightAltChanged();
}
void StructureScanComplexItem::_recalcScanDistance()
{
double scanDistance = 0;
QList<QGeoCoordinate> vertices = _flightPolygon.coordinateList();
for (int i=0; i<vertices.count() - 1; i++) {
scanDistance += vertices[i].distanceTo(vertices[i+1]);
}
scanDistance *= _layersFact.rawValue().toInt();
double surfaceHeight = qMax(_structureHeightFact.rawValue().toDouble() - _scanBottomAltFact.rawValue().toDouble(), 0.0);
scanDistance += surfaceHeight;
if (!qFuzzyCompare(_scanDistance, scanDistance)) {
_scanDistance = scanDistance;
emit complexDistanceChanged();
}
qCDebug(StructureScanComplexItemLog) << "StructureScanComplexItem--_recalcScanDistance layers: "
<< _layersFact.rawValue().toInt() << " structure height: " << surfaceHeight
<< " scanDistance: " << _scanDistance;
}
......@@ -125,11 +125,11 @@ private slots:
void _recalcLayerInfo (void);
void _updateLastSequenceNumber (void);
void _updateGimbalPitch (void);
void _signalTopBottomAltChanged (void);
void _signalTopBottomAltChanged (void);
void _recalcScanDistance (void);
private:
void _setExitCoordinate(const QGeoCoordinate& coordinate);
void _setScanDistance(double scanDistance);
void _setCameraShots(int cameraShots);
double _triggerDistance(void) const;
......
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