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
1b6606bc
Commit
1b6606bc
authored
Jul 10, 2011
by
lm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bogus gitignore file
parent
eab5a16a
Changes
24
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
1265 additions
and
97 deletions
+1265
-97
.gitignore
.gitignore
+0
-1
Waypoint.cc
src/Waypoint.cc
+3
-2
Waypoint.h
src/Waypoint.h
+8
-0
opmaps.h
src/libs/opmapcontrol/src/core/opmaps.h
+1
-1
core.cpp
src/libs/opmapcontrol/src/internals/core.cpp
+15
-2
mapgraphicitem.h
src/libs/opmapcontrol/src/mapwidget/mapgraphicitem.h
+2
-1
opmapwidget.h
src/libs/opmapcontrol/src/mapwidget/opmapwidget.h
+2
-1
waypointitem.cpp
src/libs/opmapcontrol/src/mapwidget/waypointitem.cpp
+41
-13
waypointitem.h
src/libs/opmapcontrol/src/mapwidget/waypointitem.h
+7
-10
waypointlineitem.cpp
src/libs/opmapcontrol/src/mapwidget/waypointlineitem.cpp
+9
-1
waypointlineitem.h
src/libs/opmapcontrol/src/mapwidget/waypointlineitem.h
+2
-0
QtConcurrentTools
src/libs/qtconcurrent/QtConcurrentTools
+31
-0
multitask.h
src/libs/qtconcurrent/multitask.h
+196
-0
qtconcurrent.pri
src/libs/qtconcurrent/qtconcurrent.pri
+1
-0
qtconcurrent.pro
src/libs/qtconcurrent/qtconcurrent.pro
+10
-0
qtconcurrent_global.h
src/libs/qtconcurrent/qtconcurrent_global.h
+40
-0
runextensions.h
src/libs/qtconcurrent/runextensions.h
+393
-0
qtcassert.h
src/libs/utils/qtcassert.h
+44
-0
qtcolorbutton.cpp
src/libs/utils/qtcolorbutton.cpp
+285
-0
qtcolorbutton.h
src/libs/utils/qtcolorbutton.h
+78
-0
utils_external.pri
src/libs/utils/utils_external.pri
+1
-2
QGCMapWidget.cc
src/ui/map/QGCMapWidget.cc
+9
-8
Waypoint2DIcon.cc
src/ui/map/Waypoint2DIcon.cc
+85
-44
Waypoint2DIcon.h
src/ui/map/Waypoint2DIcon.h
+2
-11
No files found.
.gitignore
View file @
1b6606bc
...
...
@@ -8,7 +8,6 @@ Info.plist
obj
*.log
*~
*qtc*
bin/*.exe
bin/*.txt
bin/mac
...
...
src/Waypoint.cc
View file @
1b6606bc
...
...
@@ -49,7 +49,8 @@ Waypoint::Waypoint(quint16 _id, double _x, double _y, double _z, double _param1,
param1
(
_param1
),
param2
(
_param2
),
name
(
QString
(
"WP%1"
).
arg
(
id
,
2
,
10
,
QChar
(
'0'
))),
description
(
_description
)
description
(
_description
),
reachedTime
(
0
)
{
}
...
...
@@ -79,7 +80,7 @@ void Waypoint::save(QTextStream &saveStream)
bool
Waypoint
::
load
(
QTextStream
&
loadStream
)
{
const
QStringList
&
wpParams
=
loadStream
.
readLine
().
split
(
"
\t
"
);
if
(
wpParams
.
size
()
==
1
3
)
{
if
(
wpParams
.
size
()
==
1
2
)
{
this
->
id
=
wpParams
[
0
].
toInt
();
this
->
current
=
(
wpParams
[
1
].
toInt
()
==
1
?
true
:
false
);
this
->
frame
=
(
MAV_FRAME
)
wpParams
[
2
].
toInt
();
...
...
src/Waypoint.h
View file @
1b6606bc
...
...
@@ -37,6 +37,7 @@ This file is part of the PIXHAWK project
#include <QString>
#include <QTextStream>
#include "QGCMAVLink.h"
#include "QGC.h"
class
Waypoint
:
public
QObject
{
...
...
@@ -145,6 +146,7 @@ protected:
int
turns
;
QString
name
;
QString
description
;
quint64
reachedTime
;
public
slots
:
void
setId
(
quint16
id
);
...
...
@@ -177,6 +179,12 @@ public slots:
void
setHoldTime
(
double
holdTime
);
/** @brief Number of turns for loiter waypoints */
void
setTurns
(
int
turns
);
/** @brief Set waypoint as reached */
void
setReached
()
{
reachedTime
=
QGC
::
groundTimeMilliseconds
();
}
/** @brief Wether this waypoint has been reached yet */
bool
isReached
()
{
return
(
reachedTime
>
0
);
}
/** @brief Get the time this waypoint was reached */
quint64
getReachedTime
()
{
return
reachedTime
;
}
signals:
/** @brief Announces a change to the waypoint data */
...
...
src/libs/opmapcontrol/src/core/opmaps.h
View file @
1b6606bc
...
...
@@ -78,7 +78,7 @@ namespace core {
// PureImageCache ImageCacheLocal;//TODO Criar acesso Get Set
TileCacheQueue
TileDBcacheQueue
;
OPMaps
();
OPMaps
(
OPMaps
const
&
){}
//
OPMaps(OPMaps const&){}
OPMaps
&
operator
=
(
OPMaps
const
&
){
return
*
this
;
}
static
OPMaps
*
m_pInstance
;
diagnostics
diag
;
...
...
src/libs/opmapcontrol/src/internals/core.cpp
View file @
1b6606bc
...
...
@@ -33,8 +33,21 @@ qlonglong internals::Core::debugcounter=0;
using
namespace
projections
;
namespace
internals
{
Core
::
Core
()
:
MouseWheelZooming
(
false
),
currentPosition
(
0
,
0
),
currentPositionPixel
(
0
,
0
),
LastLocationInBounds
(
-
1
,
-
1
),
sizeOfMapArea
(
0
,
0
)
,
minOfTiles
(
0
,
0
),
maxOfTiles
(
0
,
0
),
zoom
(
0
),
isDragging
(
false
),
TooltipTextPadding
(
10
,
10
),
loaderLimit
(
5
),
maxzoom
(
21
),
started
(
false
),
runningThreads
(
0
)
Core
::
Core
()
:
MouseWheelZooming
(
false
),
currentPosition
(
0
,
0
),
currentPositionPixel
(
0
,
0
),
LastLocationInBounds
(
-
1
,
-
1
),
sizeOfMapArea
(
0
,
0
),
minOfTiles
(
0
,
0
),
maxOfTiles
(
0
,
0
),
zoom
(
0
),
isDragging
(
false
),
TooltipTextPadding
(
10
,
10
),
loaderLimit
(
5
),
maxzoom
(
21
),
runningThreads
(
0
),
started
(
false
)
{
mousewheelzoomtype
=
MouseWheelZoomType
::
MousePositionAndCenter
;
SetProjection
(
new
MercatorProjection
());
...
...
src/libs/opmapcontrol/src/mapwidget/mapgraphicitem.h
View file @
1b6606bc
...
...
@@ -169,6 +169,7 @@ namespace mapcontrol
internals
::
PointLatLng
selectionStart
;
internals
::
PointLatLng
selectionEnd
;
double
zoomReal
;
qreal
rotation
;
double
zoomDigi
;
QRectF
maprect
;
bool
isSelected
;
...
...
@@ -176,7 +177,7 @@ namespace mapcontrol
QPixmap
dragons
;
void
SetIsMouseOverMarker
(
bool
const
&
value
){
isMouseOverMarker
=
value
;}
qreal
rotation
;
/**
* @brief Creates a rectangle that represents the "view" of the cuurent map, to compensate
* rotation
...
...
src/libs/opmapcontrol/src/mapwidget/opmapwidget.h
View file @
1b6606bc
...
...
@@ -391,8 +391,9 @@ namespace mapcontrol
bool
showuav
;
bool
showhome
;
QTimer
*
diagTimer
;
QGraphicsTextItem
*
diagGraphItem
;
bool
showDiag
;
QGraphicsTextItem
*
diagGraphItem
;
private
slots
:
void
diagRefresh
();
// WayPointItem* item;//apagar
...
...
src/libs/opmapcontrol/src/mapwidget/waypointitem.cpp
View file @
1b6606bc
...
...
@@ -27,7 +27,7 @@
#include "waypointitem.h"
namespace
mapcontrol
{
WayPointItem
::
WayPointItem
(
const
internals
::
PointLatLng
&
coord
,
double
const
&
altitude
,
MapGraphicItem
*
map
)
:
coord
(
coord
),
reached
(
false
),
description
(
""
),
shownumber
(
true
),
isDragging
(
false
),
altitude
(
altitude
),
heading
(
0
),
map
(
map
)
WayPointItem
::
WayPointItem
(
const
internals
::
PointLatLng
&
coord
,
double
const
&
altitude
,
MapGraphicItem
*
map
)
:
coord
(
coord
),
reached
(
false
),
description
(
""
),
shownumber
(
true
),
isDragging
(
false
),
altitude
(
altitude
),
heading
(
0
),
map
(
map
)
,
autoreachedEnabled
(
true
)
{
text
=
0
;
numberI
=
0
;
...
...
@@ -169,28 +169,53 @@ namespace mapcontrol
}
void
WayPointItem
::
SetReached
(
const
bool
&
value
)
{
reached
=
value
;
emit
WPValuesChanged
(
this
);
if
(
value
)
picture
.
load
(
QString
::
fromUtf8
(
":/markers/images/bigMarkerGreen.png"
));
else
picture
.
load
(
QString
::
fromUtf8
(
":/markers/images/marker.png"
));
this
->
update
();
if
(
autoreachedEnabled
)
{
reached
=
value
;
emit
WPValuesChanged
(
this
);
if
(
value
)
picture
.
load
(
QString
::
fromUtf8
(
":/markers/images/bigMarkerGreen.png"
));
else
picture
.
load
(
QString
::
fromUtf8
(
":/markers/images/marker.png"
));
this
->
update
();
}
}
void
WayPointItem
::
SetShowNumber
(
const
bool
&
value
)
{
// shownumber=value;
// if((numberI==0) && value)
// {
// numberI=new QGraphicsSimpleTextItem(this);
// numberIBG=new QGraphicsRectItem(this);
// numberIBG->setBrush(Qt::white);
// numberIBG->setOpacity(0.5);
// numberI->setZValue(3);
// numberI->setPen(QPen(Qt::blue));
// numberI->setPos(0,-13-picture.height());
// numberIBG->setPos(0,-13-picture.height());
// numberI->setText(QString::number(number));
// numberIBG->setRect(numberI->boundingRect().adjusted(-2,0,1,0));
// }
// else if (!value && numberI)
// {
// delete numberI;
// delete numberIBG;
// }
// this->update();
shownumber
=
value
;
if
((
numberI
==
0
)
&&
value
)
{
numberI
=
new
QGraphicsSimpleTextItem
(
this
);
numberIBG
=
new
QGraphicsRectItem
(
this
);
numberIBG
->
setBrush
(
Qt
::
white
);
numberIBG
->
setBrush
(
Qt
::
black
);
numberIBG
->
setOpacity
(
0.5
);
numberI
->
setZValue
(
3
);
numberI
->
setPen
(
QPen
(
Qt
::
blu
e
));
numberI
->
setPos
(
0
,
-
13
-
picture
.
height
()
);
numberIBG
->
setPos
(
0
,
-
13
-
picture
.
height
()
);
numberI
->
setPen
(
QPen
(
Qt
::
whit
e
));
numberI
->
setPos
(
18
,
-
picture
.
height
()
/
2
-
2
);
numberIBG
->
setPos
(
18
,
-
picture
.
height
()
/
2
-
2
);
numberI
->
setText
(
QString
::
number
(
number
));
numberIBG
->
setRect
(
numberI
->
boundingRect
().
adjusted
(
-
2
,
0
,
1
,
0
));
}
...
...
@@ -200,6 +225,9 @@ namespace mapcontrol
delete
numberIBG
;
}
this
->
update
();
}
void
WayPointItem
::
WPDeleted
(
const
int
&
onumber
)
{
...
...
src/libs/opmapcontrol/src/mapwidget/waypointitem.h
View file @
1b6606bc
...
...
@@ -121,7 +121,7 @@ public:
*
* @param value
*/
void
SetShowNumber
(
bool
const
&
value
);
v
irtual
v
oid
SetShowNumber
(
bool
const
&
value
);
/**
* @brief Returns the WayPoint altitude in meters
*
...
...
@@ -162,8 +162,12 @@ protected:
void
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
);
MapGraphicItem
*
map
;
private:
bool
autoreachedEnabled
;
///< If the waypoint should change appearance once it has been reached
QGraphicsSimpleTextItem
*
text
;
QGraphicsRectItem
*
textBG
;
QGraphicsSimpleTextItem
*
numberI
;
QGraphicsRectItem
*
numberIBG
;
QTransform
transf
;
internals
::
PointLatLng
coord
;
//coordinates of this WayPoint
bool
reached
;
QString
description
;
...
...
@@ -173,13 +177,6 @@ private:
float
heading
;
int
number
;
QGraphicsSimpleTextItem
*
text
;
QGraphicsRectItem
*
textBG
;
QGraphicsSimpleTextItem
*
numberI
;
QGraphicsRectItem
*
numberIBG
;
QTransform
transf
;
public
slots
:
/**
* @brief Called when a WayPoint is deleted
...
...
src/libs/opmapcontrol/src/mapwidget/waypointlineitem.cpp
View file @
1b6606bc
...
...
@@ -3,12 +3,13 @@
namespace
mapcontrol
{
WaypointLineItem
::
WaypointLineItem
(
WayPointItem
*
wp1
,
WayPointItem
*
wp2
,
QColor
color
,
mapcontrol
::
MapGraphicItem
*
map
)
:
QGraphicsLineItem
(
map
),
wp1
(
wp1
),
wp2
(
wp2
),
map
(
map
)
{
// Make sure this stick to the map
this
->
setFlag
(
QGraphicsItem
::
ItemIgnoresTransformations
,
true
);
//this->setFlag(QGraphicsItem::Item
,true);
setParentItem
(
map
);
// Set up the pen for this icon with the UAV color
...
...
@@ -30,6 +31,8 @@ WaypointLineItem::WaypointLineItem(WayPointItem* wp1, WayPointItem* wp2, QColor
// Delete line if one of the waypoints get deleted
connect
(
wp1
,
SIGNAL
(
destroyed
()),
this
,
SLOT
(
deleteLater
()));
connect
(
wp2
,
SIGNAL
(
destroyed
()),
this
,
SLOT
(
deleteLater
()));
// Map Zoom and move
}
void
WaypointLineItem
::
updateWPValues
(
WayPointItem
*
waypoint
)
...
...
@@ -50,4 +53,9 @@ void WaypointLineItem::updateWPValues(WayPointItem* waypoint)
}
}
int
WaypointLineItem
::
type
()
const
{
return
Type
;
}
}
src/libs/opmapcontrol/src/mapwidget/waypointlineitem.h
View file @
1b6606bc
...
...
@@ -10,7 +10,9 @@ class WaypointLineItem : public QObject,public QGraphicsLineItem
Q_OBJECT
Q_INTERFACES
(
QGraphicsItem
)
public:
enum
{
Type
=
UserType
+
7
};
WaypointLineItem
(
WayPointItem
*
wp1
,
WayPointItem
*
wp2
,
QColor
color
=
QColor
(
Qt
::
red
),
MapGraphicItem
*
parent
=
0
);
int
type
()
const
;
public
slots
:
/**
...
...
src/libs/qtconcurrent/QtConcurrentTools
0 → 100644
View file @
1b6606bc
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#include "qtconcurrent/multitask.h"
#include "qtconcurrent/runextensions.h"
src/libs/qtconcurrent/multitask.h
0 → 100644
View file @
1b6606bc
/**
******************************************************************************
*
* @file multitask.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
* @brief
* @see The GNU Public License (GPL) Version 3
* @defgroup
* @{
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef MULTITASK_H
#define MULTITASK_H
#include "qtconcurrent_global.h"
#include "runextensions.h"
#include <QtCore/QObject>
#include <QtCore/QList>
#include <QtCore/QEventLoop>
#include <QtCore/QFutureWatcher>
#include <QtCore/QtConcurrentRun>
#include <QtCore/QThreadPool>
#include <QtDebug>
QT_BEGIN_NAMESPACE
namespace
QtConcurrent
{
class
QTCONCURRENT_EXPORT
MultiTaskBase
:
public
QObject
,
public
QRunnable
{
Q_OBJECT
protected
slots
:
virtual
void
cancelSelf
()
=
0
;
virtual
void
setFinished
()
=
0
;
virtual
void
setProgressRange
(
int
min
,
int
max
)
=
0
;
virtual
void
setProgressValue
(
int
value
)
=
0
;
virtual
void
setProgressText
(
QString
value
)
=
0
;
};
template
<
typename
Class
,
typename
R
>
class
MultiTask
:
public
MultiTaskBase
{
public:
MultiTask
(
void
(
Class
::*
fn
)(
QFutureInterface
<
R
>
&
),
const
QList
<
Class
*>
&
objects
)
:
fn
(
fn
),
objects
(
objects
)
{
maxProgress
=
100
*
objects
.
size
();
}
QFuture
<
R
>
future
()
{
futureInterface
.
reportStarted
();
return
futureInterface
.
future
();
}
void
run
()
{
QThreadPool
::
globalInstance
()
->
releaseThread
();
futureInterface
.
setProgressRange
(
0
,
maxProgress
);
foreach
(
Class
*
object
,
objects
)
{
QFutureWatcher
<
R
>
*
watcher
=
new
QFutureWatcher
<
R
>
();
watchers
.
insert
(
object
,
watcher
);
finished
.
insert
(
watcher
,
false
);
connect
(
watcher
,
SIGNAL
(
finished
()),
this
,
SLOT
(
setFinished
()));
connect
(
watcher
,
SIGNAL
(
progressRangeChanged
(
int
,
int
)),
this
,
SLOT
(
setProgressRange
(
int
,
int
)));
connect
(
watcher
,
SIGNAL
(
progressValueChanged
(
int
)),
this
,
SLOT
(
setProgressValue
(
int
)));
connect
(
watcher
,
SIGNAL
(
progressTextChanged
(
QString
)),
this
,
SLOT
(
setProgressText
(
QString
)));
watcher
->
setFuture
(
QtConcurrent
::
run
(
fn
,
object
));
}
selfWatcher
=
new
QFutureWatcher
<
R
>
();
connect
(
selfWatcher
,
SIGNAL
(
canceled
()),
this
,
SLOT
(
cancelSelf
()));
selfWatcher
->
setFuture
(
futureInterface
.
future
());
loop
=
new
QEventLoop
;
loop
->
exec
();
futureInterface
.
reportFinished
();
QThreadPool
::
globalInstance
()
->
reserveThread
();
qDeleteAll
(
watchers
.
values
());
delete
selfWatcher
;
delete
loop
;
}
protected:
void
cancelSelf
()
{
foreach
(
QFutureWatcher
<
R
>
*
watcher
,
watchers
)
watcher
->
future
().
cancel
();
}
void
setFinished
()
{
updateProgress
();
QFutureWatcher
<
R
>
*
watcher
=
static_cast
<
QFutureWatcher
<
R
>
*>
(
sender
());
if
(
finished
.
contains
(
watcher
))
finished
[
watcher
]
=
true
;
bool
allFinished
=
true
;
const
QList
<
bool
>
finishedValues
=
finished
.
values
();
foreach
(
bool
isFinished
,
finishedValues
)
{
if
(
!
isFinished
)
{
allFinished
=
false
;
break
;
}
}
if
(
allFinished
)
loop
->
quit
();
}
void
setProgressRange
(
int
min
,
int
max
)
{
Q_UNUSED
(
min
)
Q_UNUSED
(
max
)
updateProgress
();
}
void
setProgressValue
(
int
value
)
{
Q_UNUSED
(
value
)
updateProgress
();
}
void
setProgressText
(
QString
value
)
{
Q_UNUSED
(
value
)
updateProgressText
();
}
private:
void
updateProgress
()
{
int
progressSum
=
0
;
const
QList
<
QFutureWatcher
<
R
>
*>
watchersValues
=
watchers
.
values
();
foreach
(
QFutureWatcher
<
R
>
*
watcher
,
watchersValues
)
{
if
(
watcher
->
progressMinimum
()
==
watcher
->
progressMaximum
())
{
if
(
watcher
->
future
().
isFinished
()
&&
!
watcher
->
future
().
isCanceled
())
progressSum
+=
100
;
}
else
{
progressSum
+=
100
*
(
watcher
->
progressValue
()
-
watcher
->
progressMinimum
())
/
(
watcher
->
progressMaximum
()
-
watcher
->
progressMinimum
());
}
}
futureInterface
.
setProgressValue
(
progressSum
);
}
void
updateProgressText
()
{
QString
text
;
const
QList
<
QFutureWatcher
<
R
>
*>
watchersValues
=
watchers
.
values
();
foreach
(
QFutureWatcher
<
R
>
*
watcher
,
watchersValues
)
{
if
(
!
watcher
->
progressText
().
isEmpty
())
text
+=
watcher
->
progressText
()
+
"
\n
"
;
}
text
=
text
.
trimmed
();
futureInterface
.
setProgressValueAndText
(
futureInterface
.
progressValue
(),
text
);
}
QFutureInterface
<
R
>
futureInterface
;
void
(
Class
::*
fn
)(
QFutureInterface
<
R
>
&
);
QList
<
Class
*>
objects
;
QFutureWatcher
<
R
>
*
selfWatcher
;
QMap
<
Class
*
,
QFutureWatcher
<
R
>
*>
watchers
;
QMap
<
QFutureWatcher
<
R
>
*
,
bool
>
finished
;
QEventLoop
*
loop
;
int
maxProgress
;
};
template
<
typename
Class
,
typename
T
>
QFuture
<
T
>
run
(
void
(
Class
::*
fn
)(
QFutureInterface
<
T
>
&
),
const
QList
<
Class
*>
&
objects
,
int
priority
=
0
)
{
MultiTask
<
Class
,
T
>
*
task
=
new
MultiTask
<
Class
,
T
>
(
fn
,
objects
);
QFuture
<
T
>
future
=
task
->
future
();
QThreadPool
::
globalInstance
()
->
start
(
task
,
priority
);
return
future
;
}
}
// namespace QtConcurrent
QT_END_NAMESPACE
#endif // MULTITASK_H
src/libs/qtconcurrent/qtconcurrent.pri
0 → 100644
View file @
1b6606bc
LIBS *= -l$$qtLibraryTarget(QtConcurrent)
src/libs/qtconcurrent/qtconcurrent.pro
0 → 100644
View file @
1b6606bc
TEMPLATE
=
lib
TARGET
=
QtConcurrent
DEFINES
+=
BUILD_QTCONCURRENT
include
(..
/../
openpilotgcslibrary
.
pri
)
HEADERS
+=
\
qtconcurrent_global
.
h
\
multitask
.
h
\
runextensions
.
h
src/libs/qtconcurrent/qtconcurrent_global.h
0 → 100644
View file @
1b6606bc
/**
******************************************************************************
*
* @file qtconcurrent_global.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
* @brief
* @see The GNU Public License (GPL) Version 3
* @defgroup
* @{
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef QTCONCURRENT_GLOBAL_H
#define QTCONCURRENT_GLOBAL_H
#include <QtCore/qglobal.h>
#if defined(BUILD_QTCONCURRENT)
# define QTCONCURRENT_EXPORT Q_DECL_EXPORT
#else
# define QTCONCURRENT_EXPORT Q_DECL_IMPORT
#endif
#endif // QTCONCURRENT_GLOBAL_H
src/libs/qtconcurrent/runextensions.h
0 → 100644
View file @
1b6606bc
This diff is collapsed.
Click to expand it.
src/libs/utils/qtcassert.h
0 → 100644
View file @
1b6606bc
/**
******************************************************************************
*
* @file qtcassert.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
* @brief
* @see The GNU Public License (GPL) Version 3
* @defgroup
* @{
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef QTC_ASSERT_H
#define QTC_ASSERT_H
#include <QtCore/QDebug>
#define QTC_ASSERT_STRINGIFY_INTERNAL(x) #x
#define QTC_ASSERT_STRINGIFY(x) QTC_ASSERT_STRINGIFY_INTERNAL(x)
// we do not use the 'do {...} while (0)' idiom here to be able to use
// 'break' and 'continue' as 'actions'.
#define QTC_ASSERT(cond, action) \
if(cond){}else{qDebug()<<"ASSERTION " #cond " FAILED AT " __FILE__ ":" QTC_ASSERT_STRINGIFY(__LINE__);action;}
#endif // QTC_ASSERT_H
src/libs/utils/qtcolorbutton.cpp
0 → 100644
View file @
1b6606bc
/**
******************************************************************************
*
* @file qtcolorbutton.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
* @brief
* @see The GNU Public License (GPL) Version 3
* @defgroup
* @{
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "qtcolorbutton.h"
#include <QtCore/QMimeData>
#include <QtGui/QApplication>
#include <QtGui/QColorDialog>
#include <QtGui/QDragEnterEvent>
#include <QtGui/QPainter>
namespace
Utils
{
class
QtColorButtonPrivate
{
QtColorButton
*
q_ptr
;
Q_DECLARE_PUBLIC
(
QtColorButton
)
public:
QColor
m_color
;
#ifndef QT_NO_DRAGANDDROP
QColor
m_dragColor
;
QPoint
m_dragStart
;
bool
m_dragging
;
#endif
bool
m_backgroundCheckered
;
bool
m_alphaAllowed
;
void
slotEditColor
();
QColor
shownColor
()
const
;
QPixmap
generatePixmap
()
const
;
};
void
QtColorButtonPrivate
::
slotEditColor
()
{
QColor
newColor
;
if
(
m_alphaAllowed
)
{
bool
ok
;
const
QRgb
rgba
=
QColorDialog
::
getRgba
(
m_color
.
rgba
(),
&
ok
,
q_ptr
);
if
(
!
ok
)
return
;
newColor
=
QColor
::
fromRgba
(
rgba
);
}
else
{
newColor
=
QColorDialog
::
getColor
(
m_color
,
q_ptr
);
if
(
!
newColor
.
isValid
())
return
;
}
if
(
newColor
==
q_ptr
->
color
())
return
;
q_ptr
->
setColor
(
newColor
);
emit
q_ptr
->
colorChanged
(
m_color
);
}
QColor
QtColorButtonPrivate
::
shownColor
()
const
{
#ifndef QT_NO_DRAGANDDROP
if
(
m_dragging
)
return
m_dragColor
;
#endif
return
m_color
;
}
QPixmap
QtColorButtonPrivate
::
generatePixmap
()
const
{
QPixmap
pix
(
24
,
24
);
int
pixSize
=
20
;
QBrush
br
(
shownColor
());
QPixmap
pm
(
2
*
pixSize
,
2
*
pixSize
);
QPainter
pmp
(
&
pm
);
pmp
.
fillRect
(
0
,
0
,
pixSize
,
pixSize
,
Qt
::
lightGray
);
pmp
.
fillRect
(
pixSize
,
pixSize
,
pixSize
,
pixSize
,
Qt
::
lightGray
);
pmp
.
fillRect
(
0
,
pixSize
,
pixSize
,
pixSize
,
Qt
::
darkGray
);
pmp
.
fillRect
(
pixSize
,
0
,
pixSize
,
pixSize
,
Qt
::
darkGray
);
pmp
.
fillRect
(
0
,
0
,
2
*
pixSize
,
2
*
pixSize
,
shownColor
());
br
=
QBrush
(
pm
);
QPainter
p
(
&
pix
);
int
corr
=
1
;
QRect
r
=
pix
.
rect
().
adjusted
(
corr
,
corr
,
-
corr
,
-
corr
);
p
.
setBrushOrigin
((
r
.
width
()
%
pixSize
+
pixSize
)
/
2
+
corr
,
(
r
.
height
()
%
pixSize
+
pixSize
)
/
2
+
corr
);
p
.
fillRect
(
r
,
br
);
p
.
fillRect
(
r
.
width
()
/
4
+
corr
,
r
.
height
()
/
4
+
corr
,
r
.
width
()
/
2
,
r
.
height
()
/
2
,
QColor
(
shownColor
().
rgb
()));
p
.
drawRect
(
pix
.
rect
().
adjusted
(
0
,
0
,
-
1
,
-
1
));
return
pix
;
}
///////////////
QtColorButton
::
QtColorButton
(
QWidget
*
parent
)
:
QToolButton
(
parent
)
{
d_ptr
=
new
QtColorButtonPrivate
;
d_ptr
->
q_ptr
=
this
;
d_ptr
->
m_dragging
=
false
;
d_ptr
->
m_backgroundCheckered
=
true
;
d_ptr
->
m_alphaAllowed
=
true
;
setAcceptDrops
(
true
);
connect
(
this
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
slotEditColor
()));
setSizePolicy
(
QSizePolicy
(
QSizePolicy
::
Preferred
,
QSizePolicy
::
Preferred
));
}
QtColorButton
::~
QtColorButton
()
{
delete
d_ptr
;
}
void
QtColorButton
::
setColor
(
const
QColor
&
color
)
{
if
(
d_ptr
->
m_color
==
color
)
return
;
d_ptr
->
m_color
=
color
;
update
();
}
QColor
QtColorButton
::
color
()
const
{
return
d_ptr
->
m_color
;
}
void
QtColorButton
::
setBackgroundCheckered
(
bool
checkered
)
{
if
(
d_ptr
->
m_backgroundCheckered
==
checkered
)
return
;
d_ptr
->
m_backgroundCheckered
=
checkered
;
update
();
}
bool
QtColorButton
::
isBackgroundCheckered
()
const
{
return
d_ptr
->
m_backgroundCheckered
;
}
void
QtColorButton
::
setAlphaAllowed
(
bool
allowed
)
{
d_ptr
->
m_alphaAllowed
=
allowed
;
}
bool
QtColorButton
::
isAlphaAllowed
()
const
{
return
d_ptr
->
m_alphaAllowed
;
}
void
QtColorButton
::
paintEvent
(
QPaintEvent
*
event
)
{
QToolButton
::
paintEvent
(
event
);
if
(
!
isEnabled
())
return
;
const
int
pixSize
=
10
;
QBrush
br
(
d_ptr
->
shownColor
());
if
(
d_ptr
->
m_backgroundCheckered
)
{
QPixmap
pm
(
2
*
pixSize
,
2
*
pixSize
);
QPainter
pmp
(
&
pm
);
pmp
.
fillRect
(
0
,
0
,
pixSize
,
pixSize
,
Qt
::
white
);
pmp
.
fillRect
(
pixSize
,
pixSize
,
pixSize
,
pixSize
,
Qt
::
white
);
pmp
.
fillRect
(
0
,
pixSize
,
pixSize
,
pixSize
,
Qt
::
black
);
pmp
.
fillRect
(
pixSize
,
0
,
pixSize
,
pixSize
,
Qt
::
black
);
pmp
.
fillRect
(
0
,
0
,
2
*
pixSize
,
2
*
pixSize
,
d_ptr
->
shownColor
());
br
=
QBrush
(
pm
);
}
QPainter
p
(
this
);
const
int
corr
=
5
;
QRect
r
=
rect
().
adjusted
(
corr
,
corr
,
-
corr
,
-
corr
);
p
.
setBrushOrigin
((
r
.
width
()
%
pixSize
+
pixSize
)
/
2
+
corr
,
(
r
.
height
()
%
pixSize
+
pixSize
)
/
2
+
corr
);
p
.
fillRect
(
r
,
br
);
//const int adjX = qRound(r.width() / 4.0);
//const int adjY = qRound(r.height() / 4.0);
//p.fillRect(r.adjusted(adjX, adjY, -adjX, -adjY),
// QColor(d_ptr->shownColor().rgb()));
/*
p.fillRect(r.adjusted(0, r.height() * 3 / 4, 0, 0),
QColor(d_ptr->shownColor().rgb()));
p.fillRect(r.adjusted(0, 0, 0, -r.height() * 3 / 4),
QColor(d_ptr->shownColor().rgb()));
*/
/*
const QColor frameColor0(0, 0, 0, qRound(0.2 * (0xFF - d_ptr->shownColor().alpha())));
p.setPen(frameColor0);
p.drawRect(r.adjusted(adjX, adjY, -adjX - 1, -adjY - 1));
*/
const
QColor
frameColor1
(
0
,
0
,
0
,
26
);
p
.
setPen
(
frameColor1
);
p
.
drawRect
(
r
.
adjusted
(
1
,
1
,
-
2
,
-
2
));
const
QColor
frameColor2
(
0
,
0
,
0
,
51
);
p
.
setPen
(
frameColor2
);
p
.
drawRect
(
r
.
adjusted
(
0
,
0
,
-
1
,
-
1
));
}
void
QtColorButton
::
mousePressEvent
(
QMouseEvent
*
event
)
{
#ifndef QT_NO_DRAGANDDROP
if
(
event
->
button
()
==
Qt
::
LeftButton
)
d_ptr
->
m_dragStart
=
event
->
pos
();
#endif
QToolButton
::
mousePressEvent
(
event
);
}
void
QtColorButton
::
mouseMoveEvent
(
QMouseEvent
*
event
)
{
#ifndef QT_NO_DRAGANDDROP
if
(
event
->
buttons
()
&
Qt
::
LeftButton
&&
(
d_ptr
->
m_dragStart
-
event
->
pos
()).
manhattanLength
()
>
QApplication
::
startDragDistance
())
{
QMimeData
*
mime
=
new
QMimeData
;
mime
->
setColorData
(
color
());
QDrag
*
drg
=
new
QDrag
(
this
);
drg
->
setMimeData
(
mime
);
drg
->
setPixmap
(
d_ptr
->
generatePixmap
());
setDown
(
false
);
event
->
accept
();
drg
->
start
();
return
;
}
#endif
QToolButton
::
mouseMoveEvent
(
event
);
}
#ifndef QT_NO_DRAGANDDROP
void
QtColorButton
::
dragEnterEvent
(
QDragEnterEvent
*
event
)
{
const
QMimeData
*
mime
=
event
->
mimeData
();
if
(
!
mime
->
hasColor
())
return
;
event
->
accept
();
d_ptr
->
m_dragColor
=
qvariant_cast
<
QColor
>
(
mime
->
colorData
());
d_ptr
->
m_dragging
=
true
;
update
();
}
void
QtColorButton
::
dragLeaveEvent
(
QDragLeaveEvent
*
event
)
{
event
->
accept
();
d_ptr
->
m_dragging
=
false
;
update
();
}
void
QtColorButton
::
dropEvent
(
QDropEvent
*
event
)
{
event
->
accept
();
d_ptr
->
m_dragging
=
false
;
if
(
d_ptr
->
m_dragColor
==
color
())
return
;
setColor
(
d_ptr
->
m_dragColor
);
emit
colorChanged
(
color
());
}
#endif
}
// namespace Utils
#include "moc_qtcolorbutton.cpp"
src/libs/utils/qtcolorbutton.h
0 → 100644
View file @
1b6606bc
/**
******************************************************************************
*
* @file qtcolorbutton.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
* @brief
* @see The GNU Public License (GPL) Version 3
* @defgroup
* @{
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef QTCOLORBUTTON_H
#define QTCOLORBUTTON_H
#include "utils_global.h"
#include <QtGui/QToolButton>
namespace
Utils
{
class
QTCREATOR_UTILS_EXPORT
QtColorButton
:
public
QToolButton
{
Q_OBJECT
Q_PROPERTY
(
bool
backgroundCheckered
READ
isBackgroundCheckered
WRITE
setBackgroundCheckered
)
Q_PROPERTY
(
bool
alphaAllowed
READ
isAlphaAllowed
WRITE
setAlphaAllowed
)
public:
QtColorButton
(
QWidget
*
parent
=
0
);
~
QtColorButton
();
bool
isBackgroundCheckered
()
const
;
void
setBackgroundCheckered
(
bool
checkered
);
bool
isAlphaAllowed
()
const
;
void
setAlphaAllowed
(
bool
allowed
);
QColor
color
()
const
;
public
slots
:
void
setColor
(
const
QColor
&
color
);
signals:
void
colorChanged
(
const
QColor
&
color
);
protected:
void
paintEvent
(
QPaintEvent
*
event
);
void
mousePressEvent
(
QMouseEvent
*
event
);
void
mouseMoveEvent
(
QMouseEvent
*
event
);
#ifndef QT_NO_DRAGANDDROP
void
dragEnterEvent
(
QDragEnterEvent
*
event
);
void
dragLeaveEvent
(
QDragLeaveEvent
*
event
);
void
dropEvent
(
QDropEvent
*
event
);
#endif
private:
class
QtColorButtonPrivate
*
d_ptr
;
friend
class
QtColorButtonPrivate
;
Q_DISABLE_COPY
(
QtColorButton
)
Q_PRIVATE_SLOT
(
d_ptr
,
void
slotEditColor
())
};
}
// namespace Utils
#endif // QTCOLORBUTTON_H
src/libs/utils/utils_external.pri
View file @
1b6606bc
...
...
@@ -55,8 +55,7 @@ HEADERS += abstractprocess.h \
xmlconfig.h
win32 {
HEADERS += winutils.h \
qwineventnotifier_p.h
HEADERS += winutils.h
}
FORMS += checkablemessagebox.ui \
...
...
src/ui/map/QGCMapWidget.cc
View file @
1b6606bc
...
...
@@ -155,19 +155,18 @@ void QGCMapWidget::storeSettings()
void
QGCMapWidget
::
mouseDoubleClickEvent
(
QMouseEvent
*
event
)
{
OPMapWidget
::
mouseDoubleClickEvent
(
event
);
// FIXME HACK!
currEditMode
=
EDIT_MODE_WAYPOINTS
;
if
(
currEditMode
==
EDIT_MODE_WAYPOINTS
)
//if (currEditMode == EDIT_MODE_WAYPOINTS)
{
// If a waypoint manager is available
if
(
currWPManager
)
{
// Create new waypoint
internals
::
PointLatLng
pos
=
this
->
currentMousePosition
(
);
internals
::
PointLatLng
pos
=
map
->
FromLocalToLatLng
(
event
->
pos
().
x
(),
event
->
pos
().
y
()
);
Waypoint
*
wp
=
currWPManager
->
createWaypoint
();
// wp->blockSignals(true);
wp
->
setFrame
(
MAV_FRAME_GLOBAL_RELATIVE_ALT
);
//
wp->setFrame(MAV_FRAME_GLOBAL_RELATIVE_ALT);
wp
->
setLatitude
(
pos
.
Lat
());
wp
->
setLongitude
(
pos
.
Lng
());
wp
->
setAltitude
(
0
);
...
...
@@ -175,6 +174,7 @@ void QGCMapWidget::mouseDoubleClickEvent(QMouseEvent* event)
// currWPManager->notifyOfChange(wp);
}
}
OPMapWidget
::
mouseDoubleClickEvent
(
event
);
}
...
...
@@ -471,12 +471,13 @@ void QGCMapWidget::updateWaypoint(int uas, Waypoint* wp)
if
(
prevIcon
)
{
mapcontrol
::
WaypointLineItem
*
line
=
new
mapcontrol
::
WaypointLineItem
(
prevIcon
,
icon
,
wpColor
,
map
);
line
->
setParentItem
(
map
);
QGraphicsItemGroup
*
group
=
waypointLines
.
value
(
uas
,
NULL
);
if
(
group
)
{
group
->
addToGroup
(
line
);
group
->
setParentItem
(
map
);
}
line
->
setVisible
(
true
);
}
}
}
else
{
...
...
@@ -588,13 +589,13 @@ void QGCMapWidget::updateWaypointList(int uas)
QColor
wpColor
(
Qt
::
red
);
if
(
uasInstance
)
wpColor
=
uasInstance
->
getColor
();
mapcontrol
::
WaypointLineItem
*
line
=
new
mapcontrol
::
WaypointLineItem
(
prevIcon
,
currIcon
,
wpColor
,
map
);
line
->
setParentItem
(
map
);
QGraphicsItemGroup
*
group
=
waypointLines
.
value
(
uas
,
NULL
);
if
(
group
)
{
group
->
addToGroup
(
line
);
qDebug
()
<<
"ADDED LINE!"
;
group
->
setParentItem
(
map
)
;
}
line
->
setVisible
(
true
);
}
prevIcon
=
currIcon
;
}
...
...
src/ui/map/Waypoint2DIcon.cc
View file @
1b6606bc
#include "Waypoint2DIcon.h"
#include <QPainter>
#include "opmapcontrol.h"
#include "QGC.h"
Waypoint2DIcon
::
Waypoint2DIcon
(
mapcontrol
::
MapGraphicItem
*
map
,
mapcontrol
::
OPMapWidget
*
parent
,
qreal
latitude
,
qreal
longitude
,
qreal
altitude
,
int
listindex
,
QString
name
,
QString
description
,
int
radius
)
:
mapcontrol
::
WayPointItem
(
internals
::
PointLatLng
(
latitude
,
longitude
),
altitude
,
description
,
map
),
...
...
@@ -13,10 +14,11 @@ Waypoint2DIcon::Waypoint2DIcon(mapcontrol::MapGraphicItem* map, mapcontrol::OPMa
{
SetHeading
(
0
);
SetNumber
(
listindex
);
if
(
mypen
==
NULL
)
mypen
=
new
QPen
(
Qt
::
red
);
// drawIcon(mypen);
this
->
setFlag
(
QGraphicsItem
::
ItemIgnoresTransformations
,
true
);
picture
=
QPixmap
(
radius
+
1
,
radius
+
1
);
autoreachedEnabled
=
false
;
// In contrast to the use in OpenPilot, we don't
// want to let the map interfere with the actual mission logic
// wether a WP is reached depends solely on the UAV's state machine
drawIcon
();
}
...
...
@@ -31,22 +33,16 @@ Waypoint2DIcon::Waypoint2DIcon(mapcontrol::MapGraphicItem* map, mapcontrol::OPMa
{
SetHeading
(
wp
->
getYaw
());
SetNumber
(
listindex
);
if
(
mypen
==
NULL
)
mypen
=
new
QPen
(
Qt
::
red
);
// drawIcon(mypen);
this
->
setFlag
(
QGraphicsItem
::
ItemIgnoresTransformations
,
true
);
picture
=
QPixmap
(
radius
+
1
,
radius
+
1
);
autoreachedEnabled
=
false
;
// In contrast to the use in OpenPilot, we don't
// want to let the map interfere with the actual mission logic
// wether a WP is reached depends solely on the UAV's state machine
updateWaypoint
();
}
Waypoint2DIcon
::~
Waypoint2DIcon
()
{
delete
&
picture
;
}
void
Waypoint2DIcon
::
setPen
(
QPen
*
pen
)
{
mypen
=
pen
;
// drawIcon(pen);
}
void
Waypoint2DIcon
::
SetHeading
(
float
heading
)
...
...
@@ -114,45 +110,43 @@ QRectF Waypoint2DIcon::boundingRect() const
return
QRectF
(
-
width
,
-
height
,
2
*
width
,
2
*
height
);
}
void
Waypoint2DIcon
::
SetReached
(
const
bool
&
value
)
{
// DO NOTHING
Q_UNUSED
(
value
);
// reached=value;
// emit WPValuesChanged(this);
// if(value)
// picture.load(QString::fromUtf8(":/markers/images/bigMarkerGreen.png"));
// else
// picture.load(QString::fromUtf8(":/markers/images/marker.png"));
// this->update();
}
void
Waypoint2DIcon
::
drawIcon
()
{
picture
.
fill
(
Qt
::
transparent
);
QPainter
painter
(
&
picture
);
painter
.
setRenderHint
(
QPainter
::
TextAntialiasing
,
true
);
painter
.
setRenderHint
(
QPainter
::
Antialiasing
,
true
);
painter
.
setRenderHint
(
QPainter
::
HighQualityAntialiasing
,
true
);
QFont
font
(
"Bitstream Vera Sans"
);
int
fontSize
=
picture
.
height
()
*
0.8
f
;
font
.
setPixelSize
(
fontSize
);
QFontMetrics
metrics
=
QFontMetrics
(
font
);
int
border
=
qMax
(
4
,
metrics
.
leading
());
painter
.
setFont
(
font
);
painter
.
setRenderHint
(
QPainter
::
TextAntialiasing
);
QPen
pen1
(
Qt
::
black
);
pen1
.
setWidth
(
4
);
QPen
pen2
(
color
);
pen2
.
setWidth
(
2
);
painter
.
setBrush
(
Qt
::
NoBrush
);
int
penWidth
=
pen1
.
width
();
// DRAW WAYPOINT
QPointF
p
(
picture
.
width
()
/
2
,
picture
.
height
()
/
2
);
QPolygonF
poly
(
4
);
// Top point
poly
.
replace
(
0
,
QPointF
(
p
.
x
(),
p
.
y
()
-
picture
.
height
()
/
2.0
f
+
8
*
painter
.
pen
().
width
()
));
poly
.
replace
(
0
,
QPointF
(
p
.
x
(),
p
.
y
()
-
picture
.
height
()
/
2.0
f
+
penWidth
/
2
));
// Right point
poly
.
replace
(
1
,
QPointF
(
p
.
x
()
+
picture
.
width
()
/
2.0
f
-
8
*
painter
.
pen
().
width
()
,
p
.
y
()));
poly
.
replace
(
1
,
QPointF
(
p
.
x
()
+
picture
.
width
()
/
2.0
f
-
penWidth
/
2
,
p
.
y
()));
// Bottom point
poly
.
replace
(
2
,
QPointF
(
p
.
x
(),
p
.
y
()
+
picture
.
height
()
/
2.0
f
-
8
*
painter
.
pen
().
width
()
));
poly
.
replace
(
3
,
QPointF
(
p
.
x
()
-
picture
.
width
()
/
2.0
f
+
8
*
painter
.
pen
().
width
()
,
p
.
y
()));
poly
.
replace
(
2
,
QPointF
(
p
.
x
(),
p
.
y
()
+
picture
.
height
()
/
2.0
f
-
penWidth
/
2
));
poly
.
replace
(
3
,
QPointF
(
p
.
x
()
-
picture
.
width
()
/
2.0
f
+
penWidth
/
2
,
p
.
y
()));
int
waypointSize
=
qMin
(
picture
.
width
(),
picture
.
height
());
float
rad
=
(
waypointSize
/
2.0
f
)
*
0.7
f
*
(
1
/
sqrt
(
2.0
f
));
...
...
@@ -178,28 +172,36 @@ void Waypoint2DIcon::drawIcon()
if
((
waypoint
!=
NULL
)
&&
(
waypoint
->
getAction
()
==
(
int
)
MAV_CMD_NAV_TAKEOFF
))
{
// Takeoff waypoint
int
width
=
picture
.
width
()
-
2
*
painter
.
pen
().
width
();
int
height
=
picture
.
height
()
-
2
*-
painter
.
pen
().
width
();
painter
.
drawRect
(
painter
.
pen
().
width
()
/
2
,
painter
.
pen
().
width
()
/
2
,
width
,
height
);
painter
.
drawRect
(
width
*
0.2
+
painter
.
pen
().
width
()
/
2
,
height
*
0.2
f
+
painter
.
pen
().
width
()
/
2
,
width
*
0.6
f
,
height
*
0.6
f
);
int
width
=
picture
.
width
()
-
penWidth
;
int
height
=
picture
.
height
()
-
penWidth
;
painter
.
setPen
(
pen1
);
painter
.
drawRect
(
penWidth
/
2
,
penWidth
/
2
,
width
,
height
);
painter
.
setPen
(
pen2
);
painter
.
drawRect
(
penWidth
/
2
,
penWidth
/
2
,
width
,
height
);
painter
.
setPen
(
pen1
);
painter
.
drawRect
(
width
*
0.3
,
height
*
0.3
f
,
width
*
0.6
f
,
height
*
0.6
f
);
painter
.
setPen
(
pen2
);
painter
.
drawRect
(
width
*
0.3
,
height
*
0.3
f
,
width
*
0.6
f
,
height
*
0.6
f
);
}
else
if
((
waypoint
!=
NULL
)
&&
(
waypoint
->
getAction
()
==
(
int
)
MAV_CMD_NAV_LAND
))
{
// Landing waypoint
int
width
=
(
picture
.
width
())
/
2
-
p
ainter
.
pen
().
width
()
;
int
height
=
(
picture
.
height
())
/
2
-
p
ainter
.
pen
().
width
()
;
int
width
=
(
picture
.
width
())
/
2
-
p
enWidth
;
int
height
=
(
picture
.
height
())
/
2
-
p
enWidth
;
painter
.
setPen
(
pen1
);
painter
.
drawEllipse
(
p
,
width
,
height
);
painter
.
drawLine
(
p
.
x
()
-
width
/
2
,
p
.
y
()
-
height
/
2
,
width
,
height
);
painter
.
drawLine
(
p
.
x
()
-
width
/
2
,
p
.
y
()
-
height
/
2
,
2
*
width
,
2
*
height
);
painter
.
setPen
(
pen2
);
painter
.
drawEllipse
(
p
,
width
,
height
);
painter
.
drawLine
(
p
.
x
()
-
width
/
2
,
p
.
y
()
-
height
/
2
,
width
,
height
);
painter
.
drawLine
(
p
.
x
()
-
width
/
2
,
p
.
y
()
-
height
/
2
,
2
*
width
,
2
*
height
);
}
else
if
((
waypoint
!=
NULL
)
&&
((
waypoint
->
getAction
()
==
(
int
)
MAV_CMD_NAV_LOITER_UNLIM
)
||
(
waypoint
->
getAction
()
==
(
int
)
MAV_CMD_NAV_LOITER_TIME
)
||
(
waypoint
->
getAction
()
==
(
int
)
MAV_CMD_NAV_LOITER_TURNS
)))
{
// Loiter waypoint
int
width
=
(
picture
.
width
()
)
/
2
-
9
*
painter
.
pen
().
width
()
;
int
height
=
(
picture
.
height
()
)
/
2
-
9
*
painter
.
pen
().
width
()
;
int
width
=
(
picture
.
width
()
-
penWidth
)
/
2
;
int
height
=
(
picture
.
height
()
-
penWidth
)
/
2
;
painter
.
setPen
(
pen1
);
painter
.
drawEllipse
(
p
,
width
,
height
);
painter
.
drawPoint
(
p
);
...
...
@@ -210,10 +212,24 @@ void Waypoint2DIcon::drawIcon()
else
if
((
waypoint
!=
NULL
)
&&
(
waypoint
->
getAction
()
==
(
int
)
MAV_CMD_NAV_RETURN_TO_LAUNCH
))
{
// Return to launch waypoint
int
width
=
picture
.
width
()
-
2
*
painter
.
pen
().
width
();
int
height
=
picture
.
height
()
-
2
*-
painter
.
pen
().
width
();
painter
.
drawRect
(
painter
.
pen
().
width
()
/
2
,
painter
.
pen
().
width
()
/
2
,
width
,
height
);
painter
.
drawText
(
width
/
10
,
width
/
10
,
width
/
10
*
8
,
width
/
10
*
8
,
0
,
QString
(
"R"
));
int
width
=
picture
.
width
()
-
penWidth
;
int
height
=
picture
.
height
()
-
penWidth
;
painter
.
setPen
(
pen1
);
painter
.
drawRect
(
penWidth
/
2
,
penWidth
/
2
,
width
,
height
);
painter
.
setPen
(
pen2
);
painter
.
drawRect
(
penWidth
/
2
,
penWidth
/
2
,
width
,
height
);
QString
text
(
"R"
);
painter
.
setPen
(
pen1
);
QRect
rect
=
metrics
.
boundingRect
(
0
,
0
,
width
-
2
*
border
,
height
,
Qt
::
AlignLeft
|
Qt
::
TextWordWrap
,
text
);
painter
.
drawText
(
width
/
4
,
height
/
6
,
rect
.
width
(),
rect
.
height
(),
Qt
::
AlignCenter
|
Qt
::
TextWordWrap
,
text
);
painter
.
setPen
(
pen2
);
font
.
setPixelSize
(
fontSize
*
0.85
f
);
painter
.
setFont
(
font
);
painter
.
drawText
(
width
/
4
,
height
/
6
,
rect
.
width
(),
rect
.
height
(),
Qt
::
AlignCenter
|
Qt
::
TextWordWrap
,
text
);
}
else
{
...
...
@@ -225,6 +241,30 @@ void Waypoint2DIcon::drawIcon()
}
}
void
Waypoint2DIcon
::
SetShowNumber
(
const
bool
&
value
)
{
shownumber
=
value
;
if
((
numberI
==
0
)
&&
value
)
{
numberI
=
new
QGraphicsSimpleTextItem
(
this
);
numberIBG
=
new
QGraphicsRectItem
(
this
);
numberIBG
->
setBrush
(
Qt
::
black
);
numberIBG
->
setOpacity
(
0.5
);
numberI
->
setZValue
(
3
);
numberI
->
setPen
(
QPen
(
QGC
::
colorCyan
));
numberI
->
setPos
(
5
,
-
picture
.
height
());
numberIBG
->
setPos
(
5
,
-
picture
.
height
());
numberI
->
setText
(
QString
::
number
(
number
));
numberIBG
->
setRect
(
numberI
->
boundingRect
().
adjusted
(
-
2
,
0
,
1
,
0
));
}
else
if
(
!
value
&&
numberI
)
{
delete
numberI
;
delete
numberIBG
;
}
this
->
update
();
}
void
Waypoint2DIcon
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
)
{
Q_UNUSED
(
option
);
...
...
@@ -246,6 +286,7 @@ void Waypoint2DIcon::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
{
QPen
redPen
=
QPen
(
pen
);
redPen
.
setColor
(
Qt
::
yellow
);
redPen
.
setWidth
(
1
);
painter
->
setPen
(
redPen
);
const
int
acceptance
=
map
->
metersToPixels
(
waypoint
->
getAcceptanceRadius
(),
Coord
());
painter
->
setPen
(
penBlack
);
...
...
src/ui/map/Waypoint2DIcon.h
View file @
1b6606bc
...
...
@@ -26,14 +26,6 @@ public:
virtual
~
Waypoint2DIcon
();
//! sets the QPen which is used for drawing the circle
/*!
* A QPen can be used to modify the look of the drawn circle
* @param pen the QPen which should be used for drawing
* @see http://doc.trolltech.com/4.3/qpen.html
*/
virtual
void
setPen
(
QPen
*
pen
);
void
SetHeading
(
float
heading
);
/** @brief Rectangle to be updated on changes */
...
...
@@ -42,8 +34,8 @@ public:
void
drawIcon
();
/** @brief Draw the icon on a QPainter device (map) */
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
/** @brief
UNUSED FUNCTION: Waypoints in QGC are purely passive
*/
void
Set
Reached
(
const
bool
&
value
);
/** @brief
Enable and format the waypoint number display
*/
void
Set
ShowNumber
(
const
bool
&
value
);
public:
void
updateWaypoint
();
...
...
@@ -52,7 +44,6 @@ protected:
mapcontrol
::
OPMapWidget
*
parent
;
///< Parent widget
int
radius
;
///< Radius / diameter of the icon in pixels
Waypoint
*
waypoint
;
///< Waypoint data container this icon represents
QPen
*
mypen
;
QColor
color
;
bool
showAcceptanceRadius
;
bool
showOrbit
;
...
...
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