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
8f69ce2d
Commit
8f69ce2d
authored
Feb 05, 2018
by
DonLakeFlyer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Complex item unit test work
parent
e445ccf1
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
448 additions
and
118 deletions
+448
-118
qgroundcontrol.pro
qgroundcontrol.pro
+4
-0
CameraCalc.cc
src/MissionManager/CameraCalc.cc
+15
-0
CameraCalc.h
src/MissionManager/CameraCalc.h
+1
-0
CameraCalcTest.cc
src/MissionManager/CameraCalcTest.cc
+91
-0
CameraCalcTest.h
src/MissionManager/CameraCalcTest.h
+56
-0
CorridorScanComplexItem.cc
src/MissionManager/CorridorScanComplexItem.cc
+2
-3
CorridorScanComplexItemTest.cc
src/MissionManager/CorridorScanComplexItemTest.cc
+20
-80
CorridorScanComplexItemTest.h
src/MissionManager/CorridorScanComplexItemTest.h
+0
-28
TransectStyleComplexItem.cc
src/MissionManager/TransectStyleComplexItem.cc
+24
-6
TransectStyleComplexItem.h
src/MissionManager/TransectStyleComplexItem.h
+1
-1
TransectStyleComplexItemTest.cc
src/MissionManager/TransectStyleComplexItemTest.cc
+118
-0
TransectStyleComplexItemTest.h
src/MissionManager/TransectStyleComplexItemTest.h
+99
-0
UnitTest.cc
src/qgcunittest/UnitTest.cc
+9
-0
UnitTest.h
src/qgcunittest/UnitTest.h
+4
-0
UnitTestList.cc
src/qgcunittest/UnitTestList.cc
+4
-0
No files found.
qgroundcontrol.pro
View file @
8f69ce2d
...
...
@@ -415,6 +415,7 @@ DebugBuild { PX4FirmwarePlugin { PX4FirmwarePluginFactory { APMFirmwarePlugin {
src
/
FactSystem
/
FactSystemTestGeneric
.
h
\
src
/
FactSystem
/
FactSystemTestPX4
.
h
\
src
/
FactSystem
/
ParameterManagerTest
.
h
\
src
/
MissionManager
/
CameraCalcTest
.
h
\
src
/
MissionManager
/
CameraSectionTest
.
h
\
src
/
MissionManager
/
CorridorScanComplexItemTest
.
h
\
src
/
MissionManager
/
MissionCommandTreeTest
.
h
\
...
...
@@ -431,6 +432,7 @@ DebugBuild { PX4FirmwarePlugin { PX4FirmwarePluginFactory { APMFirmwarePlugin {
src
/
MissionManager
/
SpeedSectionTest
.
h
\
src
/
MissionManager
/
StructureScanComplexItemTest
.
h
\
src
/
MissionManager
/
SurveyMissionItemTest
.
h
\
src
/
MissionManager
/
TransectStyleComplexItemTest
.
h
\
src
/
MissionManager
/
VisualMissionItemTest
.
h
\
src
/
qgcunittest
/
FileDialogTest
.
h
\
src
/
qgcunittest
/
FileManagerTest
.
h
\
...
...
@@ -454,6 +456,7 @@ DebugBuild { PX4FirmwarePlugin { PX4FirmwarePluginFactory { APMFirmwarePlugin {
src
/
FactSystem
/
FactSystemTestGeneric
.
cc
\
src
/
FactSystem
/
FactSystemTestPX4
.
cc
\
src
/
FactSystem
/
ParameterManagerTest
.
cc
\
src
/
MissionManager
/
CameraCalcTest
.
cc
\
src
/
MissionManager
/
CameraSectionTest
.
cc
\
src
/
MissionManager
/
CorridorScanComplexItemTest
.
cc
\
src
/
MissionManager
/
MissionCommandTreeTest
.
cc
\
...
...
@@ -470,6 +473,7 @@ DebugBuild { PX4FirmwarePlugin { PX4FirmwarePluginFactory { APMFirmwarePlugin {
src
/
MissionManager
/
SpeedSectionTest
.
cc
\
src
/
MissionManager
/
StructureScanComplexItemTest
.
cc
\
src
/
MissionManager
/
SurveyMissionItemTest
.
cc
\
src
/
MissionManager
/
TransectStyleComplexItemTest
.
cc
\
src
/
MissionManager
/
VisualMissionItemTest
.
cc
\
src
/
qgcunittest
/
FileDialogTest
.
cc
\
src
/
qgcunittest
/
FileManagerTest
.
cc
\
...
...
src/MissionManager/CameraCalc.cc
View file @
8f69ce2d
...
...
@@ -54,6 +54,16 @@ CameraCalc::CameraCalc(Vehicle* vehicle, QObject* parent)
_adjustedFootprintSideFact
.
setMetaData
(
_metaDataMap
[
_adjustedFootprintSideName
],
true
);
_adjustedFootprintFrontalFact
.
setMetaData
(
_metaDataMap
[
_adjustedFootprintFrontalName
],
true
);
connect
(
&
_valueSetIsDistanceFact
,
&
Fact
::
valueChanged
,
this
,
&
CameraCalc
::
_setDirty
);
connect
(
&
_distanceToSurfaceFact
,
&
Fact
::
valueChanged
,
this
,
&
CameraCalc
::
_setDirty
);
connect
(
&
_imageDensityFact
,
&
Fact
::
valueChanged
,
this
,
&
CameraCalc
::
_setDirty
);
connect
(
&
_frontalOverlapFact
,
&
Fact
::
valueChanged
,
this
,
&
CameraCalc
::
_setDirty
);
connect
(
&
_sideOverlapFact
,
&
Fact
::
valueChanged
,
this
,
&
CameraCalc
::
_setDirty
);
connect
(
&
_adjustedFootprintSideFact
,
&
Fact
::
valueChanged
,
this
,
&
CameraCalc
::
_setDirty
);
connect
(
&
_adjustedFootprintFrontalFact
,
&
Fact
::
valueChanged
,
this
,
&
CameraCalc
::
_setDirty
);
connect
(
this
,
&
CameraCalc
::
cameraNameChanged
,
this
,
&
CameraCalc
::
_setDirty
);
connect
(
this
,
&
CameraCalc
::
distanceToSurfaceRelativeChanged
,
this
,
&
CameraCalc
::
_setDirty
);
connect
(
this
,
&
CameraCalc
::
cameraNameChanged
,
this
,
&
CameraCalc
::
_recalcTriggerDistance
);
connect
(
this
,
&
CameraCalc
::
cameraNameChanged
,
this
,
&
CameraCalc
::
_adjustDistanceToSurfaceRelative
);
...
...
@@ -279,3 +289,8 @@ void CameraCalc::setDistanceToSurfaceRelative(bool distanceToSurfaceRelative)
emit
distanceToSurfaceRelativeChanged
(
distanceToSurfaceRelative
);
}
}
void
CameraCalc
::
_setDirty
(
void
)
{
setDirty
(
true
);
}
src/MissionManager/CameraCalc.h
View file @
8f69ce2d
...
...
@@ -80,6 +80,7 @@ signals:
private
slots
:
void
_recalcTriggerDistance
(
void
);
void
_adjustDistanceToSurfaceRelative
(
void
);
void
_setDirty
(
void
);
private:
Vehicle
*
_vehicle
;
...
...
src/MissionManager/CameraCalcTest.cc
0 → 100644
View file @
8f69ce2d
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
#include "CameraCalcTest.h"
#include "QGCApplication.h"
CameraCalcTest
::
CameraCalcTest
(
void
)
:
_offlineVehicle
(
NULL
)
{
}
void
CameraCalcTest
::
init
(
void
)
{
UnitTest
::
init
();
_offlineVehicle
=
new
Vehicle
(
MAV_AUTOPILOT_PX4
,
MAV_TYPE_QUADROTOR
,
qgcApp
()
->
toolbox
()
->
firmwarePluginManager
(),
this
);
_cameraCalc
=
new
CameraCalc
(
_offlineVehicle
,
this
);
_rgSignals
[
cameraNameChangedIndex
]
=
SIGNAL
(
cameraNameChanged
(
QString
));
_rgSignals
[
dirtyChangedIndex
]
=
SIGNAL
(
dirtyChanged
(
bool
));
_rgSignals
[
imageFootprintSideChangedIndex
]
=
SIGNAL
(
imageFootprintSideChanged
(
double
));
_rgSignals
[
imageFootprintFrontalChangedIndex
]
=
SIGNAL
(
imageFootprintFrontalChanged
(
double
));
_rgSignals
[
distanceToSurfaceRelativeChangedIndex
]
=
SIGNAL
(
distanceToSurfaceRelativeChanged
(
bool
));
_multiSpy
=
new
MultiSignalSpy
();
QCOMPARE
(
_multiSpy
->
init
(
_cameraCalc
,
_rgSignals
,
_cSignals
),
true
);
}
void
CameraCalcTest
::
cleanup
(
void
)
{
delete
_cameraCalc
;
delete
_offlineVehicle
;
delete
_multiSpy
;
}
void
CameraCalcTest
::
_testDirty
(
void
)
{
QVERIFY
(
!
_cameraCalc
->
dirty
());
_cameraCalc
->
setDirty
(
false
);
QVERIFY
(
!
_cameraCalc
->
dirty
());
QVERIFY
(
_multiSpy
->
checkNoSignals
());
_cameraCalc
->
setDirty
(
true
);
QVERIFY
(
_cameraCalc
->
dirty
());
QVERIFY
(
_multiSpy
->
checkOnlySignalByMask
(
dirtyChangedMask
));
QVERIFY
(
_multiSpy
->
pullBoolFromSignalIndex
(
dirtyChangedIndex
));
_multiSpy
->
clearAllSignals
();
_cameraCalc
->
setDirty
(
false
);
QVERIFY
(
!
_cameraCalc
->
dirty
());
QVERIFY
(
_multiSpy
->
checkOnlySignalByMask
(
dirtyChangedMask
));
_multiSpy
->
clearAllSignals
();
// These facts should set dirty when changed
QList
<
Fact
*>
rgFacts
;
rgFacts
<<
_cameraCalc
->
valueSetIsDistance
()
<<
_cameraCalc
->
distanceToSurface
()
<<
_cameraCalc
->
imageDensity
()
<<
_cameraCalc
->
frontalOverlap
()
<<
_cameraCalc
->
sideOverlap
()
<<
_cameraCalc
->
adjustedFootprintSide
()
<<
_cameraCalc
->
adjustedFootprintFrontal
();
foreach
(
Fact
*
fact
,
rgFacts
)
{
qDebug
()
<<
fact
->
name
();
QVERIFY
(
!
_cameraCalc
->
dirty
());
if
(
fact
->
typeIsBool
())
{
fact
->
setRawValue
(
!
fact
->
rawValue
().
toBool
());
}
else
{
fact
->
setRawValue
(
fact
->
rawValue
().
toDouble
()
+
1
);
}
QVERIFY
(
_multiSpy
->
checkSignalByMask
(
dirtyChangedMask
));
_cameraCalc
->
setDirty
(
false
);
_multiSpy
->
clearAllSignals
();
}
rgFacts
.
clear
();
_cameraCalc
->
setCameraName
(
_cameraCalc
->
customCameraName
());
QVERIFY
(
_cameraCalc
->
dirty
());
_multiSpy
->
clearAllSignals
();
_cameraCalc
->
setDistanceToSurfaceRelative
(
!
_cameraCalc
->
distanceToSurfaceRelative
());
QVERIFY
(
_cameraCalc
->
dirty
());
_multiSpy
->
clearAllSignals
();
}
src/MissionManager/CameraCalcTest.h
0 → 100644
View file @
8f69ce2d
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
#pragma once
#include "UnitTest.h"
#include "MultiSignalSpy.h"
#include "CameraCalc.h"
#include <QGeoCoordinate>
class
CameraCalcTest
:
public
UnitTest
{
Q_OBJECT
public:
CameraCalcTest
(
void
);
protected:
void
init
(
void
)
final
;
void
cleanup
(
void
)
final
;
private
slots
:
void
_testDirty
(
void
);
private:
enum
{
cameraNameChangedIndex
=
0
,
dirtyChangedIndex
,
imageFootprintSideChangedIndex
,
imageFootprintFrontalChangedIndex
,
distanceToSurfaceRelativeChangedIndex
,
maxSignalIndex
};
enum
{
cameraNameChangedMask
=
1
<<
cameraNameChangedIndex
,
dirtyChangedMask
=
1
<<
dirtyChangedIndex
,
imageFootprintSideChangedMask
=
1
<<
imageFootprintSideChangedIndex
,
imageFootprintFrontalChangedMask
=
1
<<
imageFootprintFrontalChangedIndex
,
distanceToSurfaceRelativeChangedMask
=
1
<<
distanceToSurfaceRelativeChangedIndex
,
};
static
const
size_t
_cSignals
=
maxSignalIndex
;
const
char
*
_rgSignals
[
_cSignals
];
Vehicle
*
_offlineVehicle
;
MultiSignalSpy
*
_multiSpy
;
CameraCalc
*
_cameraCalc
;
};
src/MissionManager/CorridorScanComplexItem.cc
View file @
8f69ce2d
...
...
@@ -38,10 +38,9 @@ CorridorScanComplexItem::CorridorScanComplexItem(Vehicle* vehicle, QObject* pare
connect
(
&
_corridorWidthFact
,
&
Fact
::
valueChanged
,
this
,
&
CorridorScanComplexItem
::
_setDirty
);
connect
(
&
_corridorPolyline
,
&
QGCMapPolyline
::
pathChanged
,
this
,
&
CorridorScanComplexItem
::
_setDirty
);
connect
(
this
,
&
CorridorScanComplexItem
::
altitudeRelativeChanged
,
this
,
&
CorridorScanComplexItem
::
_setDirty
);
connect
(
this
,
&
CorridorScanComplexItem
::
altitudeRelativeChanged
,
this
,
&
CorridorScanComplexItem
::
coordinateHasRelativeAltitudeChanged
);
connect
(
this
,
&
CorridorScanComplexItem
::
altitudeRelativeChanged
,
this
,
&
CorridorScanComplexItem
::
exitCoordinateHasRelativeAltitudeChanged
);
connect
(
&
_cameraCalc
,
&
CameraCalc
::
distanceToSurfaceRelativeChanged
,
this
,
&
CorridorScanComplexItem
::
coordinateHasRelativeAltitudeChanged
);
connect
(
&
_cameraCalc
,
&
CameraCalc
::
distanceToSurfaceRelativeChanged
,
this
,
&
CorridorScanComplexItem
::
exitCoordinateHasRelativeAltitudeChanged
);
connect
(
&
_corridorPolyline
,
&
QGCMapPolyline
::
dirtyChanged
,
this
,
&
CorridorScanComplexItem
::
_polylineDirtyChanged
);
connect
(
&
_corridorPolyline
,
&
QGCMapPolyline
::
countChanged
,
this
,
&
CorridorScanComplexItem
::
_polylineCountChanged
);
...
...
src/MissionManager/CorridorScanComplexItemTest.cc
View file @
8f69ce2d
...
...
@@ -25,20 +25,8 @@ void CorridorScanComplexItemTest::init(void)
_offlineVehicle
=
new
Vehicle
(
MAV_AUTOPILOT_PX4
,
MAV_TYPE_QUADROTOR
,
qgcApp
()
->
toolbox
()
->
firmwarePluginManager
(),
this
);
_corridorItem
=
new
CorridorScanComplexItem
(
_offlineVehicle
,
this
);
// _corridorItem->setTurnaroundDist(0); // Unit test written for no turnaround distance
_setPolyline
();
_corridorItem
->
setDirty
(
false
);
_mapPolyline
=
_corridorItem
->
corridorPolyline
();
_rgSignals
[
complexDistanceChangedIndex
]
=
SIGNAL
(
complexDistanceChanged
());
_rgSignals
[
greatestDistanceToChangedIndex
]
=
SIGNAL
(
greatestDistanceToChanged
());
_rgSignals
[
additionalTimeDelayChangedIndex
]
=
SIGNAL
(
additionalTimeDelayChanged
());
_rgSignals
[
transectPointsChangedIndex
]
=
SIGNAL
(
transectPointsChanged
());
_rgSignals
[
cameraShotsChangedIndex
]
=
SIGNAL
(
cameraShotsChanged
());
_rgSignals
[
coveredAreaChangedIndex
]
=
SIGNAL
(
coveredAreaChanged
());
_rgSignals
[
timeBetweenShotsChangedIndex
]
=
SIGNAL
(
timeBetweenShotsChanged
());
_rgSignals
[
dirtyChangedIndex
]
=
SIGNAL
(
dirtyChanged
(
bool
));
_multiSpy
=
new
MultiSignalSpy
();
QCOMPARE
(
_multiSpy
->
init
(
_corridorItem
,
_rgSignals
,
_cSignals
),
true
);
_rgCorridorPolygonSignals
[
corridorPolygonPathChangedIndex
]
=
SIGNAL
(
pathChanged
());
...
...
@@ -50,69 +38,24 @@ void CorridorScanComplexItemTest::cleanup(void)
{
delete
_corridorItem
;
delete
_offlineVehicle
;
delete
_multiSpy
;
}
void
CorridorScanComplexItemTest
::
_testDirty
(
void
)
{
QVERIFY
(
!
_corridorItem
->
dirty
());
Fact
*
fact
=
_corridorItem
->
corridorWidth
();
fact
->
setRawValue
(
fact
->
rawValue
().
toDouble
()
+
1
);
QVERIFY
(
_corridorItem
->
dirty
());
_corridorItem
->
setDirty
(
false
);
QVERIFY
(
!
_corridorItem
->
dirty
());
QVERIFY
(
_multiSpy
->
checkNoSignals
());
_corridorItem
->
setDirty
(
true
);
changeFactValue
(
_corridorItem
->
cameraCalc
()
->
distanceToSurface
()
);
QVERIFY
(
_corridorItem
->
dirty
());
QVERIFY
(
_multiSpy
->
checkOnlySignalByMask
(
dirtyChangedMask
));
QVERIFY
(
_multiSpy
->
pullBoolFromSignalIndex
(
dirtyChangedIndex
));
_multiSpy
->
clearAllSignals
();
_corridorItem
->
setDirty
(
false
);
QVERIFY
(
!
_corridorItem
->
dirty
());
QVERIFY
(
_multiSpy
->
checkOnlySignalByMask
(
dirtyChangedMask
));
QVERIFY
(
!
_multiSpy
->
pullBoolFromSignalIndex
(
dirtyChangedIndex
));
_multiSpy
->
clearAllSignals
();
// These facts should set dirty when changed
QList
<
Fact
*>
rgFacts
;
#if 0
rgFacts << _corridorItem->gridAltitude() << _corridorItem->gridAngle() << _corridorItem->gridSpacing() << _corridorItem->turnaroundDist() << _corridorItem->cameraTriggerDistance() <<
_corridorItem->gridAltitudeRelative() << _corridorItem->cameraTriggerInTurnaround() << _corridorItem->hoverAndCapture();
#endif
rgFacts
<<
_corridorItem
->
corridorWidth
();
foreach
(
Fact
*
fact
,
rgFacts
)
{
qDebug
()
<<
fact
->
name
();
QVERIFY
(
!
_corridorItem
->
dirty
());
if
(
fact
->
typeIsBool
())
{
fact
->
setRawValue
(
!
fact
->
rawValue
().
toBool
());
}
else
{
fact
->
setRawValue
(
fact
->
rawValue
().
toDouble
()
+
1
);
}
QVERIFY
(
_multiSpy
->
checkSignalByMask
(
dirtyChangedMask
));
QVERIFY
(
_multiSpy
->
pullBoolFromSignalIndex
(
dirtyChangedIndex
));
_corridorItem
->
setDirty
(
false
);
_multiSpy
->
clearAllSignals
();
}
rgFacts
.
clear
();
// These facts should not change dirty bit
#if 0
rgFacts << _corridorItem->groundResolution() << _corridorItem->frontalOverlap() << _corridorItem->sideOverlap() << _corridorItem->cameraSensorWidth() << _corridorItem->cameraSensorHeight() <<
_corridorItem->cameraResolutionWidth() << _corridorItem->cameraResolutionHeight() << _corridorItem->cameraFocalLength() << _corridorItem->cameraOrientationLandscape() <<
_corridorItem->fixedValueIsAltitude() << _corridorItem->camera() << _corridorItem->manualGrid();
#endif
foreach
(
Fact
*
fact
,
rgFacts
)
{
qDebug
()
<<
fact
->
name
();
QVERIFY
(
!
_corridorItem
->
dirty
());
if
(
fact
->
typeIsBool
())
{
fact
->
setRawValue
(
!
fact
->
rawValue
().
toBool
());
}
else
{
fact
->
setRawValue
(
fact
->
rawValue
().
toDouble
()
+
1
);
}
QVERIFY
(
_multiSpy
->
checkNoSignalByMask
(
dirtyChangedMask
));
QVERIFY
(
!
_corridorItem
->
dirty
());
_multiSpy
->
clearAllSignals
();
}
rgFacts
.
clear
();
QGeoCoordinate
coord
=
_corridorItem
->
corridorPolyline
()
->
vertexCoordinate
(
0
);
coord
.
setLatitude
(
coord
.
latitude
()
+
1
);
_corridorItem
->
corridorPolyline
()
->
adjustVertex
(
1
,
coord
);
QVERIFY
(
_corridorItem
->
dirty
());
_corridorItem
->
setDirty
(
false
);
}
void
CorridorScanComplexItemTest
::
_testCameraTrigger
(
void
)
...
...
@@ -155,7 +98,7 @@ void CorridorScanComplexItemTest::_setPolyline(void)
{
for
(
int
i
=
0
;
i
<
_linePoints
.
count
();
i
++
)
{
QGeoCoordinate
&
vertex
=
_linePoints
[
i
];
_
mapPolyline
->
appendVertex
(
vertex
);
_
corridorItem
->
corridorPolyline
()
->
appendVertex
(
vertex
);
}
}
...
...
@@ -191,9 +134,14 @@ void CorridorScanComplexItemTest::_testItemCount(void)
{
QList
<
MissionItem
*>
items
;
_
setPolyline
(
);
_
corridorItem
->
turnAroundDistance
()
->
setRawValue
(
20
);
// _corridorItem->cameraTriggerInTurnaround()->setRawValue(false);
_corridorItem
->
cameraTriggerInTurnAround
()
->
setRawValue
(
false
);
_corridorItem
->
appendMissionItems
(
items
,
this
);
QCOMPARE
(
items
.
count
(),
_corridorItem
->
lastSequenceNumber
());
items
.
clear
();
_corridorItem
->
cameraTriggerInTurnAround
()
->
setRawValue
(
true
);
_corridorItem
->
appendMissionItems
(
items
,
this
);
QCOMPARE
(
items
.
count
(),
_corridorItem
->
lastSequenceNumber
());
items
.
clear
();
...
...
@@ -201,17 +149,9 @@ void CorridorScanComplexItemTest::_testItemCount(void)
void
CorridorScanComplexItemTest
::
_testPathChanges
(
void
)
{
_setPolyline
();
_corridorItem
->
setDirty
(
false
);
_multiSpy
->
clearAllSignals
();
_multiSpyCorridorPolygon
->
clearAllSignals
();
QGeoCoordinate
vertex
=
_mapPolyline
->
vertexCoordinate
(
1
);
QGeoCoordinate
vertex
=
_corridorItem
->
corridorPolyline
()
->
vertexCoordinate
(
1
);
vertex
.
setLatitude
(
vertex
.
latitude
()
+
0.01
);
_
mapPolyline
->
adjustVertex
(
1
,
vertex
);
_
corridorItem
->
corridorPolyline
()
->
adjustVertex
(
1
,
vertex
);
QVERIFY
(
_corridorItem
->
dirty
());
QVERIFY
(
_multiSpy
->
checkOnlySignalsByMask
(
dirtyChangedMask
|
transectPointsChangedMask
|
cameraShotsChangedMask
|
coveredAreaChangedMask
|
complexDistanceChangedMask
|
greatestDistanceToChangedMask
));
QVERIFY
(
_multiSpyCorridorPolygon
->
checkSignalsByMask
(
corridorPolygonPathChangedMask
));
_multiSpy
->
clearAllSignals
();
}
src/MissionManager/CorridorScanComplexItemTest.h
View file @
8f69ce2d
...
...
@@ -37,32 +37,6 @@ private slots:
private:
void
_setPolyline
(
void
);
enum
{
complexDistanceChangedIndex
=
0
,
greatestDistanceToChangedIndex
,
additionalTimeDelayChangedIndex
,
transectPointsChangedIndex
,
cameraShotsChangedIndex
,
coveredAreaChangedIndex
,
timeBetweenShotsChangedIndex
,
dirtyChangedIndex
,
maxSignalIndex
};
enum
{
complexDistanceChangedMask
=
1
<<
complexDistanceChangedIndex
,
greatestDistanceToChangedMask
=
1
<<
greatestDistanceToChangedIndex
,
additionalTimeDelayChangedMask
=
1
<<
additionalTimeDelayChangedIndex
,
transectPointsChangedMask
=
1
<<
transectPointsChangedIndex
,
cameraShotsChangedMask
=
1
<<
cameraShotsChangedIndex
,
coveredAreaChangedMask
=
1
<<
coveredAreaChangedIndex
,
timeBetweenShotsChangedMask
=
1
<<
timeBetweenShotsChangedIndex
,
dirtyChangedMask
=
1
<<
dirtyChangedIndex
};
static
const
size_t
_cSignals
=
maxSignalIndex
;
const
char
*
_rgSignals
[
_cSignals
];
enum
{
corridorPolygonPathChangedIndex
=
0
,
maxCorridorPolygonSignalIndex
...
...
@@ -76,9 +50,7 @@ private:
const
char
*
_rgCorridorPolygonSignals
[
_cCorridorPolygonSignals
];
Vehicle
*
_offlineVehicle
;
MultiSignalSpy
*
_multiSpy
;
MultiSignalSpy
*
_multiSpyCorridorPolygon
;
CorridorScanComplexItem
*
_corridorItem
;
QGCMapPolyline
*
_mapPolyline
;
QList
<
QGeoCoordinate
>
_linePoints
;
};
src/MissionManager/TransectStyleComplexItem.cc
View file @
8f69ce2d
...
...
@@ -45,15 +45,22 @@ TransectStyleComplexItem::TransectStyleComplexItem(Vehicle* vehicle, QString set
,
_hoverAndCaptureFact
(
_settingsGroup
,
_metaDataMap
[
hoverAndCaptureName
])
,
_refly90DegreesFact
(
_settingsGroup
,
_metaDataMap
[
refly90DegreesName
])
{
connect
(
this
,
&
TransectStyleComplexItem
::
altitudeRelativeChanged
,
this
,
&
TransectStyleComplexItem
::
_setDirty
);
connect
(
this
,
&
TransectStyleComplexItem
::
altitudeRelativeChanged
,
this
,
&
TransectStyleComplexItem
::
coordinateHasRelativeAltitudeChanged
);
connect
(
this
,
&
TransectStyleComplexItem
::
altitudeRelativeChanged
,
this
,
&
TransectStyleComplexItem
::
exitCoordinateHasRelativeAltitudeChanged
);
connect
(
_cameraCalc
.
adjustedFootprintSide
(),
&
Fact
::
valueChanged
,
this
,
&
TransectStyleComplexItem
::
_rebuildTransects
);
connect
(
_cameraCalc
.
adjustedFootprintSide
(),
&
Fact
::
valueChanged
,
this
,
&
TransectStyleComplexItem
::
_signalLastSequenceNumberChanged
);
connect
(
&
_turnAroundDistanceFact
,
&
Fact
::
valueChanged
,
this
,
&
TransectStyleComplexItem
::
_rebuildTransects
);
connect
(
&
_turnAroundDistanceFact
,
&
Fact
::
valueChanged
,
this
,
&
TransectStyleComplexItem
::
_rebuildTransects
);
connect
(
&
_hoverAndCaptureFact
,
&
Fact
::
valueChanged
,
this
,
&
TransectStyleComplexItem
::
_rebuildTransects
);
connect
(
&
_refly90DegreesFact
,
&
Fact
::
valueChanged
,
this
,
&
TransectStyleComplexItem
::
_rebuildTransects
);
connect
(
&
_surveyAreaPolygon
,
&
QGCMapPolygon
::
pathChanged
,
this
,
&
TransectStyleComplexItem
::
_rebuildTransects
);
connect
(
&
_turnAroundDistanceFact
,
&
Fact
::
valueChanged
,
this
,
&
TransectStyleComplexItem
::
_setDirty
);
connect
(
&
_cameraTriggerInTurnAroundFact
,
&
Fact
::
valueChanged
,
this
,
&
TransectStyleComplexItem
::
_setDirty
);
connect
(
&
_hoverAndCaptureFact
,
&
Fact
::
valueChanged
,
this
,
&
TransectStyleComplexItem
::
_setDirty
);
connect
(
&
_refly90DegreesFact
,
&
Fact
::
valueChanged
,
this
,
&
TransectStyleComplexItem
::
_setDirty
);
connect
(
&
_surveyAreaPolygon
,
&
QGCMapPolygon
::
pathChanged
,
this
,
&
TransectStyleComplexItem
::
_setDirty
);
connect
(
&
_surveyAreaPolygon
,
&
QGCMapPolygon
::
dirtyChanged
,
this
,
&
TransectStyleComplexItem
::
_setIfDirty
);
connect
(
&
_cameraCalc
,
&
CameraCalc
::
dirtyChanged
,
this
,
&
TransectStyleComplexItem
::
_setIfDirty
);
connect
(
&
_surveyAreaPolygon
,
&
QGCMapPolygon
::
pathChanged
,
this
,
&
TransectStyleComplexItem
::
coveredAreaChanged
);
...
...
@@ -79,6 +86,10 @@ void TransectStyleComplexItem::_setCameraShots(int cameraShots)
void
TransectStyleComplexItem
::
setDirty
(
bool
dirty
)
{
if
(
!
dirty
)
{
_surveyAreaPolygon
.
setDirty
(
false
);
_cameraCalc
.
setDirty
(
false
);
}
if
(
_dirty
!=
dirty
)
{
_dirty
=
dirty
;
emit
dirtyChanged
(
_dirty
);
...
...
@@ -159,6 +170,13 @@ void TransectStyleComplexItem::_setDirty(void)
setDirty
(
true
);
}
void
TransectStyleComplexItem
::
_setIfDirty
(
bool
dirty
)
{
if
(
dirty
)
{
setDirty
(
true
);
}
}
void
TransectStyleComplexItem
::
applyNewAltitude
(
double
newAltitude
)
{
Q_UNUSED
(
newAltitude
);
...
...
src/MissionManager/TransectStyleComplexItem.h
View file @
8f69ce2d
...
...
@@ -104,7 +104,6 @@ signals:
void
cameraShotsChanged
(
void
);
void
timeBetweenShotsChanged
(
void
);
void
cameraMinTriggerIntervalChanged
(
double
cameraMinTriggerInterval
);
void
altitudeRelativeChanged
(
bool
altitudeRelative
);
void
transectPointsChanged
(
void
);
void
coveredAreaChanged
(
void
);
...
...
@@ -112,6 +111,7 @@ protected slots:
virtual
void
_rebuildTransects
(
void
)
=
0
;
void
_setDirty
(
void
);
void
_setIfDirty
(
bool
dirty
);
void
_updateCoordinateAltitudes
(
void
);
void
_signalLastSequenceNumberChanged
(
void
);
...
...
src/MissionManager/TransectStyleComplexItemTest.cc
0 → 100644
View file @
8f69ce2d
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
#include "TransectStyleComplexItemTest.h"
#include "QGCApplication.h"
TransectStyleComplexItemTest
::
TransectStyleComplexItemTest
(
void
)
:
_offlineVehicle
(
NULL
)
{
_linePoints
<<
QGeoCoordinate
(
47.633550640000003
,
-
122.08982199
)
<<
QGeoCoordinate
(
47.634129020000003
,
-
122.08887249
)
<<
QGeoCoordinate
(
47.633619320000001
,
-
122.08811074
);
}
void
TransectStyleComplexItemTest
::
init
(
void
)
{
UnitTest
::
init
();
_offlineVehicle
=
new
Vehicle
(
MAV_AUTOPILOT_PX4
,
MAV_TYPE_QUADROTOR
,
qgcApp
()
->
toolbox
()
->
firmwarePluginManager
(),
this
);
_transectStyleItem
=
new
TransectStyleItem
(
_offlineVehicle
,
this
);
_rgSignals
[
cameraShotsChangedIndex
]
=
SIGNAL
(
cameraShotsChanged
());
_rgSignals
[
timeBetweenShotsChangedIndex
]
=
SIGNAL
(
timeBetweenShotsChanged
());
_rgSignals
[
cameraMinTriggerIntervalChangedIndex
]
=
SIGNAL
(
cameraMinTriggerIntervalChanged
(
double
));
_rgSignals
[
transectPointsChangedIndex
]
=
SIGNAL
(
transectPointsChanged
());
_rgSignals
[
coveredAreaChangedIndex
]
=
SIGNAL
(
coveredAreaChanged
());
_rgSignals
[
dirtyChangedIndex
]
=
SIGNAL
(
dirtyChanged
(
bool
));
_rgSignals
[
complexDistanceChangedIndex
]
=
SIGNAL
(
complexDistanceChanged
());
_rgSignals
[
greatestDistanceToChangedIndex
]
=
SIGNAL
(
greatestDistanceToChanged
());
_rgSignals
[
additionalTimeDelayChangedIndex
]
=
SIGNAL
(
additionalTimeDelayChanged
());
_multiSpy
=
new
MultiSignalSpy
();
QCOMPARE
(
_multiSpy
->
init
(
_transectStyleItem
,
_rgSignals
,
_cSignals
),
true
);
}
void
TransectStyleComplexItemTest
::
cleanup
(
void
)
{
delete
_transectStyleItem
;
delete
_offlineVehicle
;
delete
_multiSpy
;
}
void
TransectStyleComplexItemTest
::
_testDirty
(
void
)
{
QVERIFY
(
!
_transectStyleItem
->
dirty
());
_transectStyleItem
->
setDirty
(
false
);
QVERIFY
(
!
_transectStyleItem
->
dirty
());
QVERIFY
(
_multiSpy
->
checkNoSignals
());
_transectStyleItem
->
setDirty
(
true
);
QVERIFY
(
_transectStyleItem
->
dirty
());
QVERIFY
(
_multiSpy
->
checkOnlySignalByMask
(
dirtyChangedMask
));
QVERIFY
(
_multiSpy
->
pullBoolFromSignalIndex
(
dirtyChangedIndex
));
_multiSpy
->
clearAllSignals
();
_transectStyleItem
->
setDirty
(
false
);
QVERIFY
(
!
_transectStyleItem
->
dirty
());
QVERIFY
(
_multiSpy
->
checkOnlySignalByMask
(
dirtyChangedMask
));
_multiSpy
->
clearAllSignals
();
// These facts should set dirty when changed
QList
<
Fact
*>
rgFacts
;
rgFacts
<<
_transectStyleItem
->
turnAroundDistance
()
<<
_transectStyleItem
->
cameraTriggerInTurnAround
()
<<
_transectStyleItem
->
hoverAndCapture
()
<<
_transectStyleItem
->
refly90Degrees
();
foreach
(
Fact
*
fact
,
rgFacts
)
{
qDebug
()
<<
fact
->
name
();
QVERIFY
(
!
_transectStyleItem
->
dirty
());
if
(
fact
->
typeIsBool
())
{
fact
->
setRawValue
(
!
fact
->
rawValue
().
toBool
());
}
else
{
fact
->
setRawValue
(
fact
->
rawValue
().
toDouble
()
+
1
);
}
QVERIFY
(
_multiSpy
->
checkSignalByMask
(
dirtyChangedMask
));
_transectStyleItem
->
setDirty
(
false
);
_multiSpy
->
clearAllSignals
();
}
rgFacts
.
clear
();
_setPolyline
();
QVERIFY
(
_transectStyleItem
->
dirty
());
_transectStyleItem
->
setDirty
(
false
);
QVERIFY
(
!
_transectStyleItem
->
surveyAreaPolygon
()
->
dirty
());
_multiSpy
->
clearAllSignals
();
_transectStyleItem
->
cameraCalc
()
->
distanceToSurface
()
->
setRawValue
(
_transectStyleItem
->
cameraCalc
()
->
distanceToSurface
()
->
rawValue
().
toDouble
()
+
1
);
QVERIFY
(
_transectStyleItem
->
dirty
());
_transectStyleItem
->
setDirty
(
false
);
QVERIFY
(
!
_transectStyleItem
->
cameraCalc
()
->
dirty
());
_multiSpy
->
clearAllSignals
();
}
void
TransectStyleComplexItemTest
::
_setPolyline
(
void
)
{
for
(
int
i
=
0
;
i
<
_linePoints
.
count
();
i
++
)
{
QGeoCoordinate
&
vertex
=
_linePoints
[
i
];
_transectStyleItem
->
surveyAreaPolygon
()
->
appendVertex
(
vertex
);
}
}
TransectStyleItem
::
TransectStyleItem
(
Vehicle
*
vehicle
,
QObject
*
parent
)
:
TransectStyleComplexItem
(
vehicle
,
QStringLiteral
(
"UnitTestTransect"
),
parent
)
,
_rebuildTransectsCalled
(
false
)
{
}
void
TransectStyleItem
::
_rebuildTransects
(
void
)
{
_rebuildTransectsCalled
=
true
;
}
src/MissionManager/TransectStyleComplexItemTest.h
0 → 100644
View file @
8f69ce2d
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
#pragma once
#include "UnitTest.h"
#include "MultiSignalSpy.h"
#include "CorridorScanComplexItem.h"
#include <QGeoCoordinate>
class
TransectStyleItem
;
class
TransectStyleComplexItemTest
:
public
UnitTest
{
Q_OBJECT
public:
TransectStyleComplexItemTest
(
void
);
protected:
void
init
(
void
)
final
;
void
cleanup
(
void
)
final
;
private
slots
:
void
_testDirty
(
void
);
private:
void
_setPolyline
(
void
);
enum
{
// These signals are from TransectStyleComplexItem
cameraShotsChangedIndex
=
0
,
timeBetweenShotsChangedIndex
,
cameraMinTriggerIntervalChangedIndex
,
transectPointsChangedIndex
,
coveredAreaChangedIndex
,
// These signals are from ComplexItem
dirtyChangedIndex
,
complexDistanceChangedIndex
,
greatestDistanceToChangedIndex
,
additionalTimeDelayChangedIndex
,
maxSignalIndex
};
enum
{
// These signals are from TransectStyleComplexItem
cameraShotsChangedMask
=
1
<<
cameraShotsChangedIndex
,
timeBetweenShotsChangedMask
=
1
<<
timeBetweenShotsChangedIndex
,
cameraMinTriggerIntervalChangedMask
=
1
<<
cameraMinTriggerIntervalChangedIndex
,
transectPointsChangedMask
=
1
<<
transectPointsChangedIndex
,
coveredAreaChangedMask
=
1
<<
coveredAreaChangedIndex
,
// These signals are from ComplexItem
dirtyChangedMask
=
1
<<
dirtyChangedIndex
,
complexDistanceChangedMask
=
1
<<
complexDistanceChangedIndex
,
greatestDistanceToChangedMask
=
1
<<
greatestDistanceToChangedIndex
,
additionalTimeDelayChangedMask
=
1
<<
additionalTimeDelayChangedIndex
,
};
static
const
size_t
_cSignals
=
maxSignalIndex
;
const
char
*
_rgSignals
[
_cSignals
];
Vehicle
*
_offlineVehicle
;
MultiSignalSpy
*
_multiSpy
;
QList
<
QGeoCoordinate
>
_linePoints
;
TransectStyleItem
*
_transectStyleItem
;
};
class
TransectStyleItem
:
public
TransectStyleComplexItem
{
Q_OBJECT
public:
TransectStyleItem
(
Vehicle
*
vehicle
,
QObject
*
parent
=
NULL
);
// Overrides from ComplexMissionItem
int
lastSequenceNumber
(
void
)
const
final
{
return
_sequenceNumber
;
}
QString
mapVisualQML
(
void
)
const
final
{
return
QString
();
}
bool
load
(
const
QJsonObject
&
complexObject
,
int
sequenceNumber
,
QString
&
errorString
)
final
{
Q_UNUSED
(
complexObject
);
Q_UNUSED
(
sequenceNumber
);
Q_UNUSED
(
errorString
);
return
false
;
}
// Overrides from VisualMissionItem
void
save
(
QJsonArray
&
missionItems
)
final
{
Q_UNUSED
(
missionItems
);
}
bool
specifiesCoordinate
(
void
)
const
final
{
return
true
;
}
void
appendMissionItems
(
QList
<
MissionItem
*>&
items
,
QObject
*
missionItemParent
)
final
{
Q_UNUSED
(
items
);
Q_UNUSED
(
missionItemParent
);
}