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

Merge pull request #6404 from DonLakeFlyer/TransectStyle

Convert Survey complex item to use TransectStyleComplexItem
parents 215d3049 c8dadd86
...@@ -121,8 +121,8 @@ bool CameraSpec::load(const QJsonObject& json, QString& errorString) ...@@ -121,8 +121,8 @@ bool CameraSpec::load(const QJsonObject& json, QString& errorString)
_sensorWidthFact.setRawValue (json[_sensorWidthName].toDouble()); _sensorWidthFact.setRawValue (json[_sensorWidthName].toDouble());
_sensorHeightFact.setRawValue (json[_sensorHeightName].toDouble()); _sensorHeightFact.setRawValue (json[_sensorHeightName].toDouble());
_imageWidthFact.setRawValue (json[_imageWidthName].toDouble()); _imageWidthFact.setRawValue (json[_imageWidthName].toInt());
_imageHeightFact.setRawValue (json[_imageHeightName].toDouble()); _imageHeightFact.setRawValue (json[_imageHeightName].toInt());
_focalLengthFact.setRawValue (json[_focalLengthName].toDouble()); _focalLengthFact.setRawValue (json[_focalLengthName].toDouble());
_landscapeFact.setRawValue (json[_landscapeName].toBool()); _landscapeFact.setRawValue (json[_landscapeName].toBool());
_fixedOrientationFact.setRawValue (json[_fixedOrientationName].toBool()); _fixedOrientationFact.setRawValue (json[_fixedOrientationName].toBool());
......
...@@ -64,10 +64,6 @@ void CorridorScanComplexItem::save(QJsonArray& planItems) ...@@ -64,10 +64,6 @@ void CorridorScanComplexItem::save(QJsonArray& planItems)
saveObject[corridorWidthName] = _corridorWidthFact.rawValue().toDouble(); saveObject[corridorWidthName] = _corridorWidthFact.rawValue().toDouble();
saveObject[_jsonEntryPointKey] = _entryPoint; saveObject[_jsonEntryPointKey] = _entryPoint;
QJsonObject cameraCalcObject;
_cameraCalc.save(cameraCalcObject);
saveObject[_jsonCameraCalcKey] = cameraCalcObject;
_corridorPolyline.saveToJson(saveObject); _corridorPolyline.saveToJson(saveObject);
planItems.append(saveObject); planItems.append(saveObject);
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include "QGCLoggingCategory.h" #include "QGCLoggingCategory.h"
#include "QGCMapPolyline.h" #include "QGCMapPolyline.h"
#include "QGCMapPolygon.h" #include "QGCMapPolygon.h"
#include "CameraCalc.h"
Q_DECLARE_LOGGING_CATEGORY(CorridorScanComplexItemLog) Q_DECLARE_LOGGING_CATEGORY(CorridorScanComplexItemLog)
...@@ -26,7 +25,6 @@ class CorridorScanComplexItem : public TransectStyleComplexItem ...@@ -26,7 +25,6 @@ class CorridorScanComplexItem : public TransectStyleComplexItem
public: public:
CorridorScanComplexItem(Vehicle* vehicle, QObject* parent = NULL); CorridorScanComplexItem(Vehicle* vehicle, QObject* parent = NULL);
Q_PROPERTY(CameraCalc* cameraCalc READ cameraCalc CONSTANT)
Q_PROPERTY(QGCMapPolyline* corridorPolyline READ corridorPolyline CONSTANT) Q_PROPERTY(QGCMapPolyline* corridorPolyline READ corridorPolyline CONSTANT)
Q_PROPERTY(Fact* corridorWidth READ corridorWidth CONSTANT) Q_PROPERTY(Fact* corridorWidth READ corridorWidth CONSTANT)
...@@ -46,6 +44,9 @@ public: ...@@ -46,6 +44,9 @@ public:
void applyNewAltitude (double newAltitude) final; void applyNewAltitude (double newAltitude) final;
// Overrides from VisualMissionionItem // Overrides from VisualMissionionItem
QString commandDescription (void) const final { return tr("Corridor Scan"); }
QString commandName (void) const final { return tr("Corridor Scan"); }
QString abbreviation (void) const final { return tr("C"); }
bool readyForSave (void) const; bool readyForSave (void) const;
static const char* jsonComplexItemTypeValue; static const char* jsonComplexItemTypeValue;
......
...@@ -265,25 +265,21 @@ bool MissionController::_convertToMissionItems(QmlObjectListModel* visualMission ...@@ -265,25 +265,21 @@ bool MissionController::_convertToMissionItems(QmlObjectListModel* visualMission
void MissionController::convertToKMLDocument(QDomDocument& document) void MissionController::convertToKMLDocument(QDomDocument& document)
{ {
QJsonObject missionJson; QObject* deleteParent = new QObject();
QmlObjectListModel* visualItems = new QmlObjectListModel(); QList<MissionItem*> rgMissionItems;
QList<MissionItem*> missionItems;
QString error; _convertToMissionItems(_visualItems, rgMissionItems, deleteParent);
save(missionJson); if (rgMissionItems.count() == 0) {
_loadItemsFromJson(missionJson, visualItems, error);
_convertToMissionItems(visualItems, missionItems, this);
if (missionItems.count() == 0) {
return; return;
} }
float homeAltitude = missionJson[_jsonPlannedHomePositionKey].toArray()[2].toDouble(); const double homePositionAltitude = _settingsItem->coordinate().altitude();
QString coord; QString coord;
QStringList coords; QStringList coords;
// Drop home position // Drop home position
bool dropPoint = true; bool dropPoint = true;
for(const auto& item : missionItems) { for(const auto& item : rgMissionItems) {
if(dropPoint) { if(dropPoint) {
dropPoint = false; dropPoint = false;
continue; continue;
...@@ -292,7 +288,7 @@ void MissionController::convertToKMLDocument(QDomDocument& document) ...@@ -292,7 +288,7 @@ void MissionController::convertToKMLDocument(QDomDocument& document)
qgcApp()->toolbox()->missionCommandTree()->getUIInfo(_controllerVehicle, item->command()); qgcApp()->toolbox()->missionCommandTree()->getUIInfo(_controllerVehicle, item->command());
if (uiInfo && uiInfo->specifiesCoordinate() && !uiInfo->isStandaloneCoordinate()) { if (uiInfo && uiInfo->specifiesCoordinate() && !uiInfo->isStandaloneCoordinate()) {
double amslAltitude = item->param7() + (item->frame() == MAV_FRAME_GLOBAL ? 0 : homeAltitude); double amslAltitude = item->param7() + (item->frame() == MAV_FRAME_GLOBAL ? 0 : homePositionAltitude);
coord = QString::number(item->param6(),'f',7) \ coord = QString::number(item->param6(),'f',7) \
+ "," \ + "," \
+ QString::number(item->param5(),'f',7) \ + QString::number(item->param5(),'f',7) \
...@@ -301,6 +297,9 @@ void MissionController::convertToKMLDocument(QDomDocument& document) ...@@ -301,6 +297,9 @@ void MissionController::convertToKMLDocument(QDomDocument& document)
coords.append(coord); coords.append(coord);
} }
} }
deleteParent->deleteLater();
Kml kml; Kml kml;
kml.points(coords); kml.points(coords);
kml.save(document); kml.save(document);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -30,42 +30,37 @@ protected: ...@@ -30,42 +30,37 @@ protected:
private slots: private slots:
void _testDirty(void); void _testDirty(void);
void _testCameraValueChanged(void);
void _testCameraTrigger(void);
void _testGridAngle(void); void _testGridAngle(void);
void _testEntryLocation(void); void _testEntryLocation(void);
void _testItemCount(void); void _testItemCount(void);
private: private:
double _clampGridAngle180(double gridAngle); double _clampGridAngle180(double gridAngle);
void _setPolygon(void); void _setPolygon(void);
// SurveyComplexItem signals
enum { enum {
gridPointsChangedIndex = 0, surveyVisualTransectPointsChangedIndex = 0,
cameraShotsChangedIndex, surveyCameraShotsChangedIndex,
coveredAreaChangedIndex, surveyCoveredAreaChangedIndex,
cameraValueChangedIndex, surveyTimeBetweenShotsChangedIndex,
gridTypeChangedIndex, surveyRefly90DegreesChangedIndex,
timeBetweenShotsChangedIndex, surveyDirtyChangedIndex,
cameraOrientationFixedChangedIndex, surveyMaxSignalIndex
refly90DegreesChangedIndex,
dirtyChangedIndex,
maxSignalIndex
}; };
enum { enum {
gridPointsChangedMask = 1 << gridPointsChangedIndex, surveyVisualTransectPointsChangedMask = 1 << surveyVisualTransectPointsChangedIndex,
cameraShotsChangedMask = 1 << cameraShotsChangedIndex, surveyCameraShotsChangedMask = 1 << surveyCameraShotsChangedIndex,
coveredAreaChangedMask = 1 << coveredAreaChangedIndex, surveyCoveredAreaChangedMask = 1 << surveyCoveredAreaChangedIndex,
cameraValueChangedMask = 1 << cameraValueChangedIndex, surveyTimeBetweenShotsChangedMask = 1 << surveyTimeBetweenShotsChangedIndex,
gridTypeChangedMask = 1 << gridTypeChangedIndex, surveyRefly90DegreesChangedMask = 1 << surveyRefly90DegreesChangedIndex,
timeBetweenShotsChangedMask = 1 << timeBetweenShotsChangedIndex, surveyDirtyChangedMask = 1 << surveyDirtyChangedIndex
cameraOrientationFixedChangedMask = 1 << cameraOrientationFixedChangedIndex,
refly90DegreesChangedMask = 1 << refly90DegreesChangedIndex,
dirtyChangedMask = 1 << dirtyChangedIndex
}; };
static const size_t _cSurveySignals = maxSignalIndex; static const size_t _cSurveySignals = surveyMaxSignalIndex;
const char* _rgSurveySignals[_cSurveySignals]; const char* _rgSurveySignals[_cSurveySignals];
Vehicle* _offlineVehicle; Vehicle* _offlineVehicle;
......
...@@ -101,8 +101,13 @@ TransectStyleComplexItem::TransectStyleComplexItem(Vehicle* vehicle, QString set ...@@ -101,8 +101,13 @@ TransectStyleComplexItem::TransectStyleComplexItem(Vehicle* vehicle, QString set
connect(&_surveyAreaPolygon, &QGCMapPolygon::pathChanged, this, &TransectStyleComplexItem::coveredAreaChanged); connect(&_surveyAreaPolygon, &QGCMapPolygon::pathChanged, this, &TransectStyleComplexItem::coveredAreaChanged);
connect(&_cameraCalc, &CameraCalc::distanceToSurfaceRelativeChanged, this, &TransectStyleComplexItem::coordinateHasRelativeAltitudeChanged);
connect(&_cameraCalc, &CameraCalc::distanceToSurfaceRelativeChanged, this, &TransectStyleComplexItem::exitCoordinateHasRelativeAltitudeChanged);
connect(this, &TransectStyleComplexItem::visualTransectPointsChanged, this, &TransectStyleComplexItem::complexDistanceChanged); connect(this, &TransectStyleComplexItem::visualTransectPointsChanged, this, &TransectStyleComplexItem::complexDistanceChanged);
connect(this, &TransectStyleComplexItem::visualTransectPointsChanged, this, &TransectStyleComplexItem::greatestDistanceToChanged); connect(this, &TransectStyleComplexItem::visualTransectPointsChanged, this, &TransectStyleComplexItem::greatestDistanceToChanged);
connect(this, &TransectStyleComplexItem::followTerrainChanged, this, &TransectStyleComplexItem::_followTerrainChanged);
} }
void TransectStyleComplexItem::_setCameraShots(int cameraShots) void TransectStyleComplexItem::_setCameraShots(int cameraShots)
...@@ -693,3 +698,21 @@ int TransectStyleComplexItem::lastSequenceNumber(void) const ...@@ -693,3 +698,21 @@ int TransectStyleComplexItem::lastSequenceNumber(void) const
} }
} }
bool TransectStyleComplexItem::coordinateHasRelativeAltitude(void) const
{
return _cameraCalc.distanceToSurfaceRelative();
}
bool TransectStyleComplexItem::exitCoordinateHasRelativeAltitude(void) const
{
return coordinateHasRelativeAltitude();
}
void TransectStyleComplexItem::_followTerrainChanged(bool followTerrain)
{
if (followTerrain) {
_cameraCalc.setDistanceToSurfaceRelative(false);
_refly90DegreesFact.setRawValue(false);
_hoverAndCaptureFact.setRawValue(false);
}
}
...@@ -87,9 +87,6 @@ public: ...@@ -87,9 +87,6 @@ public:
bool isSimpleItem (void) const final { return false; } bool isSimpleItem (void) const final { return false; }
bool isStandaloneCoordinate (void) const final { return false; } bool isStandaloneCoordinate (void) const final { return false; }
bool specifiesAltitudeOnly (void) const final { return false; } bool specifiesAltitudeOnly (void) const final { return false; }
QString commandDescription (void) const final { return tr("Corridor Scan"); }
QString commandName (void) const final { return tr("Corridor Scan"); }
QString abbreviation (void) const final { return "S"; }
QGeoCoordinate coordinate (void) const final { return _coordinate; } QGeoCoordinate coordinate (void) const final { return _coordinate; }
QGeoCoordinate exitCoordinate (void) const final { return _exitCoordinate; } QGeoCoordinate exitCoordinate (void) const final { return _exitCoordinate; }
int sequenceNumber (void) const final { return _sequenceNumber; } int sequenceNumber (void) const final { return _sequenceNumber; }
...@@ -98,9 +95,12 @@ public: ...@@ -98,9 +95,12 @@ public:
double specifiedGimbalPitch (void) final { return std::numeric_limits<double>::quiet_NaN(); } double specifiedGimbalPitch (void) final { return std::numeric_limits<double>::quiet_NaN(); }
void setMissionFlightStatus (MissionController::MissionFlightStatus_t& missionFlightStatus) final; void setMissionFlightStatus (MissionController::MissionFlightStatus_t& missionFlightStatus) final;
bool readyForSave (void) const override; bool readyForSave (void) const override;
QString commandDescription (void) const override { return tr("Transect"); }
QString commandName (void) const override { return tr("Transect"); }
QString abbreviation (void) const override { return tr("T"); }
bool coordinateHasRelativeAltitude (void) const final { return true /*_altitudeRelative*/; } bool coordinateHasRelativeAltitude (void) const final;
bool exitCoordinateHasRelativeAltitude (void) const final { return true /*_altitudeRelative*/; } bool exitCoordinateHasRelativeAltitude (void) const final;
bool exitCoordinateSameAsEntry (void) const final { return false; } bool exitCoordinateSameAsEntry (void) const final { return false; }
void setDirty (bool dirty) final; void setDirty (bool dirty) final;
...@@ -200,6 +200,7 @@ protected: ...@@ -200,6 +200,7 @@ protected:
private slots: private slots:
void _reallyQueryTransectsPathHeightInfo(void); void _reallyQueryTransectsPathHeightInfo(void);
void _followTerrainChanged (bool followTerrain);
private: private:
void _queryTransectsPathHeightInfo (void); void _queryTransectsPathHeightInfo (void);
......
...@@ -13,7 +13,6 @@ import QGroundControl.FactControls 1.0 ...@@ -13,7 +13,6 @@ import QGroundControl.FactControls 1.0
import QGroundControl.Palette 1.0 import QGroundControl.Palette 1.0
import QGroundControl.FlightMap 1.0 import QGroundControl.FlightMap 1.0
// Editor for Survery mission items
Rectangle { Rectangle {
id: _root id: _root
height: visible ? (editorColumn.height + (_margin * 2)) : 0 height: visible ? (editorColumn.height + (_margin * 2)) : 0
...@@ -56,11 +55,6 @@ Rectangle { ...@@ -56,11 +55,6 @@ Rectangle {
anchors.right: parent.right anchors.right: parent.right
spacing: _margin spacing: _margin
QGCLabel {
text: "WIP: Careful!"
color: qgcPal.warningText
}
QGCLabel { QGCLabel {
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
...@@ -115,7 +109,7 @@ Rectangle { ...@@ -115,7 +109,7 @@ Rectangle {
anchors.left: parent.left anchors.left: parent.left
text: qsTr("Relative altitude") text: qsTr("Relative altitude")
checked: missionItem.cameraCalc.distanceToSurfaceRelative checked: missionItem.cameraCalc.distanceToSurfaceRelative
enabled: missionItem.cameraCalc.isManualCamera enabled: missionItem.cameraCalc.isManualCamera && !missionItem.followTerrain
Layout.columnSpan: 2 Layout.columnSpan: 2
onClicked: missionItem.cameraCalc.distanceToSurfaceRelative = checked onClicked: missionItem.cameraCalc.distanceToSurfaceRelative = checked
...@@ -158,12 +152,6 @@ Rectangle { ...@@ -158,12 +152,6 @@ Rectangle {
columns: 2 columns: 2
visible: followsTerrainCheckBox.checked visible: followsTerrainCheckBox.checked
QGCLabel {
text: "WIP: Careful!"
color: qgcPal.warningText
Layout.columnSpan: 2
}
QGCLabel { text: qsTr("Tolerance") } QGCLabel { text: qsTr("Tolerance") }
FactTextField { FactTextField {
fact: missionItem.terrainAdjustTolerance fact: missionItem.terrainAdjustTolerance
......
This diff is collapsed.
...@@ -26,24 +26,24 @@ Item { ...@@ -26,24 +26,24 @@ Item {
property var qgcView ///< QGCView to use for popping dialogs property var qgcView ///< QGCView to use for popping dialogs
property var _missionItem: object property var _missionItem: object
property var _mapPolygon: object.mapPolygon property var _mapPolygon: object.surveyAreaPolygon
property var _gridComponent property var _visualTransectsComponent
property var _entryCoordinate property var _entryCoordinate
property var _exitCoordinate property var _exitCoordinate
signal clicked(int sequenceNumber) signal clicked(int sequenceNumber)
function _addVisualElements() { function _addVisualElements() {
_gridComponent = gridComponent.createObject(map) _visualTransectsComponent = visualTransectsComponent.createObject(map)
_entryCoordinate = entryPointComponent.createObject(map) _entryCoordinate = entryPointComponent.createObject(map)
_exitCoordinate = exitPointComponent.createObject(map) _exitCoordinate = exitPointComponent.createObject(map)
map.addMapItem(_gridComponent) map.addMapItem(_visualTransectsComponent)
map.addMapItem(_entryCoordinate) map.addMapItem(_entryCoordinate)
map.addMapItem(_exitCoordinate) map.addMapItem(_exitCoordinate)
} }
function _destroyVisualElements() { function _destroyVisualElements() {
_gridComponent.destroy() _visualTransectsComponent.destroy()
_entryCoordinate.destroy() _entryCoordinate.destroy()
_exitCoordinate.destroy() _exitCoordinate.destroy()
} }
...@@ -100,14 +100,14 @@ Item { ...@@ -100,14 +100,14 @@ Item {
interiorOpacity: 0.5 interiorOpacity: 0.5
} }
// Survey grid lines // Transect lines
Component { Component {
id: gridComponent id: visualTransectsComponent
MapPolyline { MapPolyline {
line.color: "white" line.color: "white"
line.width: 2 line.width: 2
path: _missionItem.gridPoints path: _missionItem.visualTransectPoints
} }
} }
......
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