Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
62b3a020
Commit
62b3a020
authored
Sep 14, 2019
by
Valentin Platzgummer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changing borderpolygon...
parent
ee3e60cb
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
97 additions
and
79 deletions
+97
-79
qgroundcontrol.qrc
qgroundcontrol.qrc
+1
-0
WimaArea.SettingsGroup.json
src/Wima/WimaArea.SettingsGroup.json
+17
-0
WimaArea.cc
src/Wima/WimaArea.cc
+42
-1
WimaArea.h
src/Wima/WimaArea.h
+30
-8
WimaMeasurementArea.cc
src/Wima/WimaMeasurementArea.cc
+0
-37
WimaMeasurementArea.h
src/Wima/WimaMeasurementArea.h
+1
-15
WimaItemEditor.qml
src/WimaView/WimaItemEditor.qml
+1
-1
WimaMeasurementAreaMapVisual.qml
src/WimaView/WimaMeasurementAreaMapVisual.qml
+5
-17
No files found.
qgroundcontrol.qrc
View file @
62b3a020
...
...
@@ -272,6 +272,7 @@
<file alias="Video.SettingsGroup.json">src/Settings/Video.SettingsGroup.json</file>
<file alias="WimaMeasurementArea.SettingsGroup.json">src/Wima/WimaMeasurementArea.SettingsGroup.json</file>
<file alias="CircularSurvey.SettingsGroup.json">src/Wima/CircularSurvey.SettingsGroup.json</file>
<file>src/Wima/WimaArea.SettingsGroup.json</file>
</qresource>
<qresource prefix="/MockLink">
<file alias="APMArduCopterMockLink.params">src/comm/APMArduCopterMockLink.params</file>
...
...
src/Wima/WimaArea.SettingsGroup.json
0 → 100644
View file @
62b3a020
[
{
"name"
:
"BorderPolygonOffset"
,
"shortDescription"
:
"The distance between the measurement area and it's surrounding polygon"
,
"type"
:
"double"
,
"units"
:
"m"
,
"min"
:
0
,
"decimalPlaces"
:
1
,
"defaultValue"
:
5
},
{
"name"
:
"showBorderPolygon"
,
"shortDescription"
:
"Border polygon will be displayed if checked."
,
"type"
:
"bool"
,
"defaultValue"
:
true
}
]
src/Wima/WimaArea.cc
View file @
62b3a020
...
...
@@ -23,6 +23,8 @@ const char* WimaArea::wimaAreaName = "WimaArea";
const
char
*
WimaArea
::
areaTypeName
=
"AreaType"
;
const
char
*
WimaArea
::
borderPolygonOffsetName
=
"BorderPolygonOffset"
;
const
char
*
WimaArea
::
settingsGroup
=
"MeasurementArea"
;
// Constructors
WimaArea
::
WimaArea
(
QObject
*
parent
)
...
...
@@ -34,6 +36,8 @@ WimaArea::WimaArea(QObject *parent)
WimaArea
::
WimaArea
(
const
WimaArea
&
other
,
QObject
*
parent
)
:
QGCMapPolygon
(
parent
)
,
_metaDataMap
(
FactMetaData
::
createMapFromJsonFile
(
QStringLiteral
(
":/json/WimaArea.SettingsGroup.json"
),
this
/* QObject parent */
))
,
_borderPolygonOffset
(
SettingsFact
(
settingsGroup
,
_metaDataMap
[
borderPolygonOffsetName
],
this
/* QObject parent */
))
{
init
();
*
this
=
other
;
...
...
@@ -69,6 +73,25 @@ void WimaArea::setMaxAltitude(double altitude)
}
}
void
WimaArea
::
setBorderPolygonOffset
(
double
offset
)
{
if
(
!
qFuzzyCompare
(
_borderPolygonOffset
.
rawValue
().
toDouble
(),
offset
)
)
{
_borderPolygonOffset
.
setRawValue
(
offset
);
emit
borderPolygonOffsetChanged
();
}
}
void
WimaArea
::
recalcMeasurementPolygon
()
{
this
->
setPath
(
_borderPolygon
.
coordinateList
());
this
->
offset
(
-
_borderPolygonOffset
.
rawValue
().
toDouble
());
emit
borderPolygonChanged
();
}
/*!
* \fn int WimaArea::getClosestVertexIndex(const QGeoCoordinate &coordinate) const
* Returns the index of the vertex (element of the polygon path)
...
...
@@ -313,6 +336,7 @@ void WimaArea::saveToJson(QJsonObject &json)
{
this
->
QGCMapPolygon
::
saveToJson
(
json
);
json
[
maxAltitudeName
]
=
_maxAltitude
;
json
[
borderPolygonOffsetName
]
=
_borderPolygonOffset
.
rawValue
().
toDouble
();
json
[
areaTypeName
]
=
wimaAreaName
;
// add WimaVehicle if necessary..
}
...
...
@@ -330,15 +354,23 @@ bool WimaArea::loadFromJson(const QJsonObject &json, QString& errorString)
if
(
this
->
QGCMapPolygon
::
loadFromJson
(
json
,
false
/*no poly required*/
,
errorString
)
)
{
if
(
json
.
contains
(
maxAltitudeName
)
&&
json
[
maxAltitudeName
].
isDouble
())
{
_maxAltitude
=
json
[
maxAltitudeName
].
toDouble
();
return
true
;
}
else
{
errorString
.
append
(
tr
(
"Could not load Maximum Altitude value!
\n
"
));
return
false
;
}
if
(
json
.
contains
(
borderPolygonOffsetName
)
&&
json
[
borderPolygonOffsetName
].
isDouble
())
{
_borderPolygonOffset
.
setRawValue
(
json
[
borderPolygonOffsetName
].
toDouble
());
}
else
{
errorString
.
append
(
tr
(
"Could not load border polygon offset value!
\n
"
));
return
false
;
}
}
else
{
qWarning
()
<<
errorString
;
return
false
;
}
return
true
;
}
/*!
...
...
@@ -348,6 +380,8 @@ bool WimaArea::loadFromJson(const QJsonObject &json, QString& errorString)
void
WimaArea
::
init
()
{
this
->
setObjectName
(
wimaAreaName
);
connect
(
&
_borderPolygon
,
&
QGCMapPolygon
::
pathChanged
,
this
,
&
WimaArea
::
recalcPolygons
);
connect
(
&
_borderPolygonOffset
,
&
SettingsFact
::
rawValueChanged
,
this
,
&
WimaArea
::
recalcPolygons
);
}
/*!
...
...
@@ -370,6 +404,13 @@ void print(const WimaArea &area, QString &outputString)
outputString
.
append
(
QString
(
"Type: %1
\n
"
).
arg
(
area
.
objectName
()));
print
(
static_cast
<
const
QGCMapPolygon
&>
(
area
),
outputString
);
outputString
.
append
(
QString
(
"Maximum Altitude: %1
\n
"
).
arg
(
area
.
_maxAltitude
));
outputString
.
append
(
QString
(
"Border Polygon Offset: %1
\n
"
).
arg
(
area
.
_borderPolygonOffset
.
rawValue
().
toDouble
()));
outputString
.
append
(
QString
(
"Border Polygon Coordinates
\n
"
).
arg
(
area
.
_borderPolygonOffset
.
rawValue
().
toDouble
()));
for
(
int
i
=
0
;
i
<
area
.
_borderPolygon
.
count
();
i
++
)
{
QGeoCoordinate
coordinate
=
area
.
_borderPolygon
.
vertexCoordinate
(
i
);
outputString
.
append
(
QString
(
"%1
\n
"
).
arg
(
coordinate
.
toString
(
QGeoCoordinate
::
Degrees
)));
}
}
...
...
src/Wima/WimaArea.h
View file @
62b3a020
...
...
@@ -23,12 +23,20 @@ public:
WimaArea
&
operator
=
(
const
WimaArea
&
other
);
Q_PROPERTY
(
double
maxAltitude
READ
maxAltitude
WRITE
setMaxAltitude
NOTIFY
maxAltitudeChanged
)
Q_PROPERTY
(
QString
mapVisualQML
READ
mapVisualQML
CONSTANT
)
Q_PROPERTY
(
QString
editorQML
READ
editorQML
CONSTANT
)
Q_PROPERTY
(
double
maxAltitude
READ
maxAltitude
WRITE
setMaxAltitude
NOTIFY
maxAltitudeChanged
)
Q_PROPERTY
(
QString
mapVisualQML
READ
mapVisualQML
CONSTANT
)
Q_PROPERTY
(
QString
editorQML
READ
editorQML
CONSTANT
)
Q_PROPERTY
(
Fact
*
borderPolygonOffset
READ
borderPolygonOffsetFact
CONSTANT
)
Q_PROPERTY
(
QGCMapPolygon
*
borderPolygon
READ
borderPolygon
NOTIFY
borderPolygonChanged
)
Q_PROPERTY
(
Fact
*
showBorderPolygon
READ
showBorderPolygon
CONSTANT
)
//Property accessors
double
maxAltitude
(
void
)
const
{
return
_maxAltitude
;}
double
maxAltitude
(
void
)
const
{
return
_maxAltitude
;}
Fact
*
borderPolygonOffsetFact
(
void
)
{
return
&
_borderPolygonOffset
;}
Fact
*
showBorderPolygon
(
void
)
{
return
&
_showBorderPolygon
;}
double
borderPolygonOffset
(
void
)
const
{
return
_borderPolygonOffset
.
rawValue
().
toDouble
();}
QGCMapPolygon
*
borderPolygon
(
void
)
{
return
&
_borderPolygon
;}
// overrides from WimaArea
virtual
QString
mapVisualQML
(
void
)
const
{
return
""
;
}
...
...
@@ -62,19 +70,33 @@ public:
static
const
double
epsilonMeter
;
static
const
char
*
maxAltitudeName
;
static
const
char
*
wimaAreaName
;
static
const
char
*
areaTypeName
;
static
const
char
*
areaTypeName
;
static
const
char
*
borderPolygonOffsetName
;
static
const
char
*
settingsGroup
;
signals:
void
maxAltitudeChanged
(
void
);
void
borderPolygonChanged
(
void
);
void
borderPolygonOffsetChanged
(
void
);
public
slots
:
void
setMaxAltitude
(
double
altitude
);
void
setMaxAltitude
(
double
altitude
);
void
setShowBorderPolygon
(
bool
showBorderPolygon
);
void
setBorderPolygonOffset
(
double
offset
);
private:
double
_maxAltitude
;
private
slots
:
void
recalcPolygons
(
void
)
;
private:
void
init
();
double
_maxAltitude
;
QMap
<
QString
,
FactMetaData
*>
_metaDataMap
;
SettingsFact
_borderPolygonOffset
;
SettingsFact
_showBorderPolygon
;
QGCMapPolygon
_borderPolygon
;
};
...
...
src/Wima/WimaMeasurementArea.cc
View file @
62b3a020
...
...
@@ -5,7 +5,6 @@ const char* WimaMeasurementArea::settingsGroup = "MeasurementA
const
char
*
WimaMeasurementArea
::
bottomLayerAltitudeName
=
"BottomLayerAltitude"
;
const
char
*
WimaMeasurementArea
::
numberOfLayersName
=
"NumberOfLayers"
;
const
char
*
WimaMeasurementArea
::
layerDistanceName
=
"LayerDistance"
;
const
char
*
WimaMeasurementArea
::
borderPolygonOffsetName
=
"BorderPolygonOffset"
;
const
char
*
WimaMeasurementArea
::
WimaMeasurementAreaName
=
"Measurement Area"
;
...
...
@@ -15,7 +14,6 @@ WimaMeasurementArea::WimaMeasurementArea(QObject *parent)
,
_bottomLayerAltitude
(
SettingsFact
(
settingsGroup
,
_metaDataMap
[
bottomLayerAltitudeName
],
this
/* QObject parent */
))
,
_numberOfLayers
(
SettingsFact
(
settingsGroup
,
_metaDataMap
[
numberOfLayersName
],
this
/* QObject parent */
))
,
_layerDistance
(
SettingsFact
(
settingsGroup
,
_metaDataMap
[
layerDistanceName
],
this
/* QObject parent */
))
,
_borderPolygonOffset
(
SettingsFact
(
settingsGroup
,
_metaDataMap
[
borderPolygonOffsetName
],
this
/* QObject parent */
))
{
init
();
}
...
...
@@ -26,7 +24,6 @@ WimaMeasurementArea::WimaMeasurementArea(const WimaMeasurementArea &other, QObje
,
_bottomLayerAltitude
(
SettingsFact
(
settingsGroup
,
_metaDataMap
[
bottomLayerAltitudeName
],
this
/* QObject parent */
))
,
_numberOfLayers
(
SettingsFact
(
settingsGroup
,
_metaDataMap
[
numberOfLayersName
],
this
/* QObject parent */
))
,
_layerDistance
(
SettingsFact
(
settingsGroup
,
_metaDataMap
[
layerDistanceName
],
this
/* QObject parent */
))
,
_borderPolygonOffset
(
SettingsFact
(
settingsGroup
,
_metaDataMap
[
borderPolygonOffsetName
],
this
/* QObject parent */
))
{
init
();
}
...
...
@@ -49,7 +46,6 @@ void WimaMeasurementArea::saveToJson(QJsonObject &json)
json
[
bottomLayerAltitudeName
]
=
_bottomLayerAltitude
.
rawValue
().
toDouble
();
json
[
numberOfLayersName
]
=
_numberOfLayers
.
rawValue
().
toInt
();
json
[
layerDistanceName
]
=
_layerDistance
.
rawValue
().
toDouble
();
json
[
borderPolygonOffsetName
]
=
_borderPolygonOffset
.
rawValue
().
toDouble
();
json
[
areaTypeName
]
=
WimaMeasurementAreaName
;
}
...
...
@@ -79,13 +75,6 @@ bool WimaMeasurementArea::loadFromJson(const QJsonObject &json, QString& errorSt
retVal
=
false
;
}
if
(
json
.
contains
(
borderPolygonOffsetName
)
&&
json
[
borderPolygonOffsetName
].
isDouble
()
)
{
_borderPolygonOffset
.
setRawValue
(
json
[
borderPolygonOffsetName
].
toDouble
());
}
else
{
errorString
.
append
(
tr
(
"Could not load Border Polygon Offset!
\n
"
));
retVal
=
false
;
}
return
retVal
;
}
else
{
return
false
;
...
...
@@ -119,15 +108,6 @@ void WimaMeasurementArea::setLayerDistance(double layerDistance)
}
}
void
WimaMeasurementArea
::
setBorderPolygonOffset
(
double
offset
)
{
if
(
!
qFuzzyCompare
(
_borderPolygonOffset
.
rawValue
().
toDouble
(),
offset
)
)
{
_borderPolygonOffset
.
setRawValue
(
offset
);
emit
borderPolygonOffsetChanged
();
}
}
void
print
(
const
WimaMeasurementArea
&
area
)
{
QString
message
;
...
...
@@ -141,28 +121,11 @@ void print(const WimaMeasurementArea &area, QString outputStr)
outputStr
.
append
(
QString
(
"Bottom Layer Altitude: %1
\n
"
).
arg
(
area
.
_bottomLayerAltitude
.
rawValue
().
toDouble
()));
outputStr
.
append
(
QString
(
"Number of Layers: %1
\n
"
).
arg
(
area
.
_numberOfLayers
.
rawValue
().
toInt
()));
outputStr
.
append
(
QString
(
"Layer Distance: %1
\n
"
).
arg
(
area
.
_layerDistance
.
rawValue
().
toDouble
()));
outputStr
.
append
(
QString
(
"Border Polygon Offset: %1
\n
"
).
arg
(
area
.
_borderPolygonOffset
.
rawValue
().
toDouble
()));
outputStr
.
append
(
QString
(
"Border Polygon Coordinates
\n
"
).
arg
(
area
.
_borderPolygonOffset
.
rawValue
().
toDouble
()));
for
(
int
i
=
0
;
i
<
area
.
_borderPolygon
.
count
();
i
++
)
{
QGeoCoordinate
coordinate
=
area
.
_borderPolygon
.
vertexCoordinate
(
i
);
outputStr
.
append
(
QString
(
"%1
\n
"
).
arg
(
coordinate
.
toString
(
QGeoCoordinate
::
Degrees
)));
}
}
void
WimaMeasurementArea
::
recalcBorderPolygon
()
{
_borderPolygon
=
this
->
toQGCPolygon
(
*
this
);
_borderPolygon
.
offset
(
_borderPolygonOffset
.
rawValue
().
toDouble
());
emit
borderPolygonChanged
();
}
void
WimaMeasurementArea
::
init
()
{
this
->
setObjectName
(
WimaMeasurementAreaName
);
connect
(
this
,
&
WimaMeasurementArea
::
pathChanged
,
this
,
&
WimaMeasurementArea
::
recalcBorderPolygon
);
connect
(
&
_borderPolygonOffset
,
&
SettingsFact
::
rawValueChanged
,
this
,
&
WimaMeasurementArea
::
recalcBorderPolygon
);
}
/*!
...
...
src/Wima/WimaMeasurementArea.h
View file @
62b3a020
...
...
@@ -19,8 +19,6 @@ public:
Q_PROPERTY
(
Fact
*
bottomLayerAltitude
READ
bottomLayerAltitudeFact
CONSTANT
)
Q_PROPERTY
(
Fact
*
numberOfLayers
READ
numberOfLayersFact
CONSTANT
)
Q_PROPERTY
(
Fact
*
layerDistance
READ
layerDistanceFact
CONSTANT
)
Q_PROPERTY
(
Fact
*
borderPolygonOffset
READ
borderPolygonOffsetFact
CONSTANT
)
Q_PROPERTY
(
QGCMapPolygon
*
borderPolygon
READ
borderPolygon
NOTIFY
borderPolygonChanged
)
// Overrides from WimaPolygon
QString
mapVisualQML
(
void
)
const
{
return
"WimaMeasurementAreaMapVisual.qml"
;}
...
...
@@ -30,12 +28,9 @@ public:
Fact
*
bottomLayerAltitudeFact
(
void
)
{
return
&
_bottomLayerAltitude
;}
Fact
*
numberOfLayersFact
(
void
)
{
return
&
_numberOfLayers
;}
Fact
*
layerDistanceFact
(
void
)
{
return
&
_layerDistance
;}
Fact
*
borderPolygonOffsetFact
(
void
)
{
return
&
_borderPolygonOffset
;}
double
bottomLayerAltitude
(
void
)
const
{
return
_bottomLayerAltitude
.
rawValue
().
toDouble
();}
int
numberOfLayers
(
void
)
const
{
return
_numberOfLayers
.
rawValue
().
toInt
();}
double
layerDistance
(
void
)
const
{
return
_layerDistance
.
rawValue
().
toDouble
();}
double
borderPolygonOffset
(
void
)
const
{
return
_borderPolygonOffset
.
rawValue
().
toDouble
();}
QGCMapPolygon
*
borderPolygon
(
void
)
{
return
&
_borderPolygon
;}
// Member Methodes
void
saveToJson
(
QJsonObject
&
json
);
...
...
@@ -50,25 +45,19 @@ public:
static
const
char
*
bottomLayerAltitudeName
;
static
const
char
*
numberOfLayersName
;
static
const
char
*
layerDistanceName
;
static
const
char
*
borderPolygonOffsetName
;
static
const
char
*
WimaMeasurementAreaName
;
signals:
void
bottomLayerAltitudeChanged
(
void
);
void
numberOfLayersChanged
(
void
);
void
layerDistanceChanged
(
void
);
void
polylineChanged
(
void
);
void
vehicleCorridorChanged
(
WimaVCorridor
*
corridor
);
void
borderPolygonChanged
(
void
);
void
borderPolygonOffsetChanged
(
void
);
public
slots
:
void
setBottomLayerAltitude
(
double
altitude
);
void
setNumberOfLayers
(
double
numLayers
);
void
setLayerDistance
(
double
layerDistance
);
void
setBorderPolygonOffset
(
double
offset
);
private
slots
:
void
recalcBorderPolygon
(
void
);
private:
// Member Methodes
void
init
();
...
...
@@ -79,9 +68,6 @@ private:
SettingsFact
_bottomLayerAltitude
;
SettingsFact
_numberOfLayers
;
SettingsFact
_layerDistance
;
SettingsFact
_borderPolygonOffset
;
QGCMapPolygon
_borderPolygon
;
};
src/WimaView/WimaItemEditor.qml
View file @
62b3a020
...
...
@@ -140,7 +140,7 @@ Rectangle {
}
}
onClicked
:
qgcView
.
showDialog
(
commandDialog
,
qsTr
(
"
Select Mission Command
"
),
qgcView
.
showDialogDefaultWidth
,
StandardButton
.
Cancel
)
//
onClicked: qgcView.showDialog(commandDialog, qsTr("Select Mission Command"), qgcView.showDialogDefaultWidth, StandardButton.Cancel)
}
QGCLabel
{
...
...
src/WimaView/WimaMeasurementAreaMapVisual.qml
View file @
62b3a020
...
...
@@ -32,7 +32,7 @@ Item {
/// Add an initial 4 sided polygon if there is none
function
_addInitialPolygon
()
{
if
(
_p
olygon
.
count
<
3
)
{
if
(
areaItem
.
borderP
olygon
.
count
<
3
)
{
// Initial polygon is inset to take 2/3rds space
var
rect
=
Qt
.
rect
(
map
.
centerViewport
.
x
,
map
.
centerViewport
.
y
,
map
.
centerViewport
.
width
,
map
.
centerViewport
.
height
)
rect
.
x
+=
(
rect
.
width
*
0.25
)
/
2
...
...
@@ -55,10 +55,10 @@ Item {
bottomLeftCoord
=
centerCoord
.
atDistanceAndAzimuth
(
halfWidthMeters
,
-
90
).
atDistanceAndAzimuth
(
halfHeightMeters
,
180
)
bottomRightCoord
=
centerCoord
.
atDistanceAndAzimuth
(
halfWidthMeters
,
90
).
atDistanceAndAzimuth
(
halfHeightMeters
,
180
)
_p
olygon
.
appendVertex
(
topLeftCoord
)
_p
olygon
.
appendVertex
(
topRightCoord
)
_p
olygon
.
appendVertex
(
bottomRightCoord
)
_p
olygon
.
appendVertex
(
bottomLeftCoord
)
areaItem
.
borderP
olygon
.
appendVertex
(
topLeftCoord
)
areaItem
.
borderP
olygon
.
appendVertex
(
topRightCoord
)
areaItem
.
borderP
olygon
.
appendVertex
(
bottomRightCoord
)
areaItem
.
borderP
olygon
.
appendVertex
(
bottomLeftCoord
)
}
}
...
...
@@ -98,16 +98,4 @@ Item {
interiorOpacity
:
1
}
/*WimaMapPolylineVisuals {
qgcView: _root.qgcView
mapControl: map
mapPolyline: _polyline
lineWidth: 4
lineColor: interactive ? "white" : "green"
enableSplitHandels: false
enableDragHandels: true
edgeHandelsOnly: true
}*/
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment