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
674bf254
Commit
674bf254
authored
Oct 10, 2015
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for lines between items
parent
9c5a4938
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
90 additions
and
6 deletions
+90
-6
MissionEditor.cc
src/MissionEditor/MissionEditor.cc
+31
-1
MissionEditor.h
src/MissionEditor/MissionEditor.h
+9
-3
MissionEditor.qml
src/MissionEditor/MissionEditor.qml
+50
-2
No files found.
src/MissionEditor/MissionEditor.cc
View file @
674bf254
...
...
@@ -26,6 +26,7 @@ This file is part of the QGROUNDCONTROL project
#include "MultiVehicleManager.h"
#include "MissionManager.h"
#include "QGCFileDialog.h"
#include "CoordinateVector.h"
#include <QQmlContext>
#include <QQmlEngine>
...
...
@@ -51,6 +52,7 @@ MissionEditor::MissionEditor(QWidget *parent)
_newMissionItemsAvailable
();
}
else
{
_missionItems
=
new
QmlObjectListModel
(
this
);
connect
(
_missionItems
,
&
QmlObjectListModel
::
dirtyChanged
,
this
,
&
MissionEditor
::
_missionListDirtyChanged
);
}
setContextPropertyObject
(
"controller"
,
this
);
...
...
@@ -75,6 +77,9 @@ void MissionEditor::_newMissionItemsAvailable(void)
_reSequence
();
_missionItems
->
setDirty
(
false
);
connect
(
_missionItems
,
&
QmlObjectListModel
::
dirtyChanged
,
this
,
&
MissionEditor
::
_missionListDirtyChanged
);
_rebuildWaypointLines
();
emit
missionItemsChanged
();
emit
canEditChanged
(
_canEdit
);
}
...
...
@@ -190,7 +195,11 @@ void MissionEditor::loadMissionFromFile(void)
return
;
}
_missionItems
->
clear
();
if
(
_missionItems
)
{
_missionItems
->
deleteLater
();
}
_missionItems
=
new
QmlObjectListModel
(
this
);
_canEdit
=
true
;
QFile
file
(
filename
);
...
...
@@ -229,6 +238,9 @@ void MissionEditor::loadMissionFromFile(void)
_missionItems
->
setDirty
(
false
);
emit
canEditChanged
(
_canEdit
);
connect
(
_missionItems
,
&
QmlObjectListModel
::
dirtyChanged
,
this
,
&
MissionEditor
::
_missionListDirtyChanged
);
_rebuildWaypointLines
();
}
void
MissionEditor
::
saveMissionToFile
(
void
)
...
...
@@ -256,3 +268,21 @@ void MissionEditor::saveMissionToFile(void)
_missionItems
->
setDirty
(
false
);
}
void
MissionEditor
::
_rebuildWaypointLines
(
void
)
{
_waypointLines
.
clear
();
for
(
int
i
=
1
;
i
<
_missionItems
->
count
();
i
++
)
{
MissionItem
*
item1
=
qobject_cast
<
MissionItem
*>
(
_missionItems
->
get
(
i
-
1
));
MissionItem
*
item2
=
qobject_cast
<
MissionItem
*>
(
_missionItems
->
get
(
i
));
_waypointLines
.
append
(
new
CoordinateVector
(
item1
->
coordinate
(),
item2
->
coordinate
()));
}
emit
waypointLinesChanged
();
}
void
MissionEditor
::
_missionListDirtyChanged
(
bool
dirty
)
{
Q_UNUSED
(
dirty
);
_rebuildWaypointLines
();
}
src/MissionEditor/MissionEditor.h
View file @
674bf254
...
...
@@ -35,7 +35,8 @@ public:
MissionEditor
(
QWidget
*
parent
=
NULL
);
~
MissionEditor
();
Q_PROPERTY
(
QmlObjectListModel
*
missionItems
READ
missionItemsModel
NOTIFY
missionItemsChanged
)
Q_PROPERTY
(
QmlObjectListModel
*
missionItems
READ
missionItems
NOTIFY
missionItemsChanged
)
Q_PROPERTY
(
QmlObjectListModel
*
waypointLines
READ
waypointLines
NOTIFY
waypointLinesChanged
)
Q_PROPERTY
(
bool
canEdit
READ
canEdit
NOTIFY
canEditChanged
)
Q_INVOKABLE
int
addMissionItem
(
QGeoCoordinate
coordinate
);
...
...
@@ -49,21 +50,26 @@ public:
// Property accessors
QmlObjectListModel
*
missionItemsModel
(
void
)
{
return
_missionItems
;
}
QmlObjectListModel
*
missionItems
(
void
)
{
return
_missionItems
;
}
QmlObjectListModel
*
waypointLines
(
void
)
{
return
&
_waypointLines
;
}
bool
canEdit
(
void
)
{
return
_canEdit
;
}
signals:
void
missionItemsChanged
(
void
);
void
canEditChanged
(
bool
canEdit
);
void
waypointLinesChanged
(
void
);
private
slots
:
void
_newMissionItemsAvailable
();
void
_missionListDirtyChanged
(
bool
dirty
);
private:
void
_reSequence
(
void
);
void
_rebuildWaypointLines
(
void
);
private:
QmlObjectListModel
*
_missionItems
;
QmlObjectListModel
_waypointLines
;
bool
_canEdit
;
///< true: UI can edit these items, false: can't edit, can only send to vehicle or save
static
const
char
*
_settingsGroup
;
...
...
src/MissionEditor/MissionEditor.qml
View file @
674bf254
...
...
@@ -383,6 +383,7 @@ This code will need to wait for Qml 5.5 support since Map.visibleRegion is only
label
:
"
H
"
isCurrentItem
:
_showHomePositionManager
coordinate
:
_homePositionCoordinate
z
:
2
onClicked
:
_showHomePositionManager
=
true
}
...
...
@@ -396,13 +397,59 @@ This code will need to wait for Qml 5.5 support since Map.visibleRegion is only
label
:
object
.
sequenceNumber
isCurrentItem
:
!
_showHomePositionManager
&&
object
.
isCurrentItem
coordinate
:
object
.
coordinate
z
:
2
onClicked
:
{
_showHomePositionManager
=
false
setCurrentItem
(
object
.
sequenceNumber
)
}
}
}
MapPolyline
{
id
:
homePositionLine
line.width
:
3
line.color
:
"
orange
"
z
:
1
property
var
homePositionCoordinate
:
_homePositionCoordinate
function
update
()
{
while
(
homePositionLine
.
path
.
length
!=
0
)
{
homePositionLine
.
removeCoordinate
(
homePositionLine
.
path
[
0
])
}
if
(
_missionItems
&&
_missionItems
.
count
!=
0
)
{
homePositionLine
.
addCoordinate
(
homePositionCoordinate
)
homePositionLine
.
addCoordinate
(
_missionItems
.
get
(
0
).
coordinate
)
}
}
onHomePositionCoordinateChanged
:
update
()
Component.onCompleted
:
console
.
log
(
"
Indicator
"
,
object
.
coordinate
)
Connections
{
target
:
controller
onWaypointLinesChanged
:
homePositionLine
.
update
()
}
Component.onCompleted
:
homePositionLine
.
update
()
}
// Add lines between waypoints
MapItemView
{
model
:
controller
.
waypointLines
delegate
:
MapPolyline
{
line.width
:
3
line.color
:
"
orange
"
z
:
1
path
:
[
{
latitude
:
object
.
coordinate1
.
latitude
,
longitude
:
object
.
coordinate1
.
longitude
},
{
latitude
:
object
.
coordinate2
.
latitude
,
longitude
:
object
.
coordinate2
.
longitude
},
]
}
}
...
...
@@ -630,7 +677,8 @@ This code will need to wait for Qml 5.5 support since Map.visibleRegion is only
text
:
"
Add/Update
"
onClicked
:
{
_homePositionManager
.
updateHomePosition
(
nameField
.
text
,
QtPositioning
.
coordinate
(
latitudeField
.
text
,
longitudeField
.
text
,
altitudeField
.
text
))
_homePositionCoordinate
=
QtPositioning
.
coordinate
(
latitudeField
.
text
,
longitudeField
.
text
,
altitudeField
.
text
)
_homePositionManager
.
updateHomePosition
(
nameField
.
text
,
_homePositionCoordinate
)
homePosCombo
.
currentIndex
=
homePosCombo
.
find
(
nameField
.
text
)
}
}
...
...
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