Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
9cc031aa
Commit
9cc031aa
authored
Jan 07, 2011
by
lm
Browse files
Merge branch 'experimental' of git@pixhawk.ethz.ch:qgroundcontrol into dev
parents
18b44cbe
7fa3071d
Changes
32
Hide whitespace changes
Inline
Side-by-side
src/ui/designer/QGCActionButton.cc
View file @
9cc031aa
...
...
@@ -42,15 +42,12 @@ const char* kActionLabels[MAV_ACTION_NB] =
"RESET MAP"
};
QGCActionButton
::
QGCActionButton
(
QWidget
*
parent
)
:
QGCToolWidgetItem
(
parent
),
QGCToolWidgetItem
(
"Button"
,
parent
),
ui
(
new
Ui
::
QGCActionButton
),
uas
(
NULL
)
{
ui
->
setupUi
(
this
);
connect
(
UASManager
::
instance
(),
SIGNAL
(
activeUASSet
(
UASInterface
*
)),
this
,
SLOT
(
setActiveUAS
(
UASInterface
*
)));
connect
(
ui
->
actionButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
sendAction
()));
connect
(
ui
->
editFinishButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
endEditMode
()));
connect
(
ui
->
editButtonName
,
SIGNAL
(
textChanged
(
QString
)),
this
,
SLOT
(
setActionButtonName
(
QString
)));
...
...
@@ -71,12 +68,16 @@ QGCActionButton::~QGCActionButton()
void
QGCActionButton
::
sendAction
()
{
if
(
uas
)
if
(
QGCToolWidgetItem
::
uas
)
{
MAV_ACTION
action
=
static_cast
<
MAV_ACTION
>
(
ui
->
editActionComboBox
->
currentIndex
());
uas
->
setAction
(
action
);
QGCToolWidgetItem
::
uas
->
setAction
(
action
);
}
else
{
qDebug
()
<<
__FILE__
<<
__LINE__
<<
"NO UAS SET, DOING NOTHING"
;
}
}
...
...
@@ -90,6 +91,8 @@ void QGCActionButton::startEditMode()
ui
->
editActionComboBox
->
show
();
ui
->
editActionsRefreshButton
->
show
();
ui
->
editFinishButton
->
show
();
ui
->
editNameLabel
->
show
();
ui
->
editButtonName
->
show
();
isInEditMode
=
true
;
}
...
...
@@ -98,10 +101,11 @@ void QGCActionButton::endEditMode()
ui
->
editActionComboBox
->
hide
();
ui
->
editActionsRefreshButton
->
hide
();
ui
->
editFinishButton
->
hide
();
isInEditMode
=
false
;
}
ui
->
editNameLabel
->
hide
()
;
ui
->
editButtonName
->
hide
();
void
QGCActionButton
::
setActiveUAS
(
UASInterface
*
uas
)
{
this
->
uas
=
uas
;
// Write to settings
isInEditMode
=
false
;
}
src/ui/designer/QGCActionButton.h
View file @
9cc031aa
...
...
@@ -23,9 +23,6 @@ public slots:
void
startEditMode
();
void
endEditMode
();
private
slots
:
void
setActiveUAS
(
UASInterface
*
uas
);
private:
Ui
::
QGCActionButton
*
ui
;
UASInterface
*
uas
;
...
...
src/ui/designer/QGCParamSlider.cc
View file @
9cc031aa
...
...
@@ -3,9 +3,16 @@
#include
"QGCParamSlider.h"
#include
"ui_QGCParamSlider.h"
#include
"UASInterface.h"
QGCParamSlider
::
QGCParamSlider
(
QWidget
*
parent
)
:
QGCToolWidgetItem
(
parent
),
QGCToolWidgetItem
(
"Slider"
,
parent
),
parameterName
(
""
),
parameterValue
(
0.0
f
),
parameterScalingFactor
(
0.0
),
parameterMin
(
0.0
f
),
parameterMax
(
0.0
f
),
component
(
0
),
ui
(
new
Ui
::
QGCParamSlider
)
{
ui
->
setupUi
(
this
);
...
...
@@ -48,6 +55,18 @@ void QGCParamSlider::endEditMode()
isInEditMode
=
false
;
}
void
QGCParamSlider
::
sendParameter
()
{
if
(
QGCToolWidgetItem
::
uas
)
{
QGCToolWidgetItem
::
uas
->
setParameter
(
component
,
parameterName
,
parameterValue
);
}
else
{
qDebug
()
<<
__FILE__
<<
__LINE__
<<
"NO UAS SET, DOING NOTHING"
;
}
}
void
QGCParamSlider
::
changeEvent
(
QEvent
*
e
)
{
QWidget
::
changeEvent
(
e
);
...
...
src/ui/designer/QGCParamSlider.h
View file @
9cc031aa
...
...
@@ -22,8 +22,16 @@ public:
public
slots
:
void
startEditMode
();
void
endEditMode
();
/** @brief Send the parameter to the MAV */
void
sendParameter
();
protected:
QString
parameterName
;
///< Key/Name of the parameter
float
parameterValue
;
///< Value of the parameter
double
parameterScalingFactor
;
///< Factor to scale the parameter between slider and true value
float
parameterMin
;
float
parameterMax
;
int
component
;
///< ID of the MAV component to address
void
changeEvent
(
QEvent
*
e
);
private:
...
...
src/ui/designer/QGCToolWidget.cc
View file @
9cc031aa
...
...
@@ -50,7 +50,7 @@ void QGCToolWidget::addUAS(UASInterface* uas)
void
QGCToolWidget
::
contextMenuEvent
(
QContextMenuEvent
*
event
)
{
QMenu
menu
(
this
);
menu
.
addAction
(
addParamAction
);
//
menu.addAction(addParamAction);
menu
.
addAction
(
addButtonAction
);
menu
.
addAction
(
setTitleAction
);
menu
.
exec
(
event
->
globalPos
());
...
...
src/ui/designer/QGCToolWidgetItem.cc
View file @
9cc031aa
...
...
@@ -3,16 +3,25 @@
#include
<QMenu>
#include
<QContextMenuEvent>
QGCToolWidgetItem
::
QGCToolWidgetItem
(
QWidget
*
parent
)
:
#include
"UASManager.h"
QGCToolWidgetItem
::
QGCToolWidgetItem
(
const
QString
&
name
,
QWidget
*
parent
)
:
QWidget
(
parent
),
isInEditMode
(
false
),
qgcToolWidgetItemName
(
name
),
uas
(
NULL
),
_component
(
-
1
)
{
startEditAction
=
new
QAction
(
"Edit
Slider"
,
this
);
startEditAction
=
new
QAction
(
"Edit
"
+
qgcToolWidgetItemName
,
this
);
connect
(
startEditAction
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
startEditMode
()));
stopEditAction
=
new
QAction
(
"Finish Editing Slider"
,
this
);
connect
(
stopEditAction
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
endEditMode
()));
connect
(
UASManager
::
instance
(),
SIGNAL
(
activeUASSet
(
UASInterface
*
)),
this
,
SLOT
(
setActiveUAS
(
UASInterface
*
)));
// Set first UAS if it exists
setActiveUAS
(
UASManager
::
instance
()
->
getActiveUAS
());
endEditMode
();
}
...
...
@@ -35,3 +44,8 @@ void QGCToolWidgetItem::contextMenuEvent (QContextMenuEvent* event)
}
menu
.
exec
(
event
->
globalPos
());
}
void
QGCToolWidgetItem
::
setActiveUAS
(
UASInterface
*
uas
)
{
this
->
uas
=
uas
;
}
src/ui/designer/QGCToolWidgetItem.h
View file @
9cc031aa
...
...
@@ -4,11 +4,13 @@
#include
<QWidget>
#include
<QAction>
#include
"UASInterface.h"
class
QGCToolWidgetItem
:
public
QWidget
{
Q_OBJECT
public:
explicit
QGCToolWidgetItem
(
QWidget
*
parent
=
0
);
QGCToolWidgetItem
(
const
QString
&
name
,
QWidget
*
parent
=
0
);
~
QGCToolWidgetItem
();
int
component
()
{
return
_component
;}
...
...
@@ -17,12 +19,14 @@ public slots:
virtual
void
startEditMode
()
{}
virtual
void
endEditMode
()
{}
virtual
void
setComponent
(
int
comp
)
{
_component
=
comp
;}
void
setActiveUAS
(
UASInterface
*
uas
);
protected:
QAction
*
startEditAction
;
QAction
*
stopEditAction
;
bool
isInEditMode
;
QString
qgcToolWidgetItemName
;
UASInterface
*
uas
;
int
_component
;
///< The MAV component (the process or device ID)
void
contextMenuEvent
(
QContextMenuEvent
*
event
);
...
...
src/ui/linechart/LinechartPlot.cc
View file @
9cc031aa
...
...
@@ -228,7 +228,8 @@ void LinechartPlot::appendData(QString dataname, quint64 ms, double value)
datalock
.
lock
();
/* Check if dataset identifier already exists */
if
(
!
data
.
contains
(
dataname
))
{
if
(
!
data
.
contains
(
dataname
))
{
addCurve
(
dataname
);
}
...
...
src/ui/linechart/LinechartWidget.cc
View file @
9cc031aa
...
...
@@ -35,6 +35,7 @@ This file is part of the PIXHAWK project
#include
<QGridLayout>
#include
<QComboBox>
#include
<QToolButton>
#include
<QSizePolicy>
#include
<QScrollBar>
#include
<QLabel>
#include
<QMenu>
...
...
@@ -69,6 +70,7 @@ curveMenu(new QMenu(this)),
logFile
(
new
QFile
()),
logindex
(
1
),
logging
(
false
),
logStartTime
(
0
),
updateTimer
(
new
QTimer
())
{
// Add elements defined in Qt Designer
...
...
@@ -78,47 +80,57 @@ updateTimer(new QTimer())
// Add and customize curve list elements (left side)
curvesWidget
=
new
QWidget
(
ui
.
curveListWidget
);
ui
.
curveListWidget
->
setWidget
(
curvesWidget
);
curvesWidgetLayout
=
new
Q
VBox
Layout
(
curvesWidget
);
curvesWidgetLayout
=
new
Q
Grid
Layout
(
curvesWidget
);
curvesWidgetLayout
->
setMargin
(
2
);
curvesWidgetLayout
->
setSpacing
(
4
);
curvesWidgetLayout
->
setSizeConstraint
(
Q
Layout
::
SetMinimumSize
);
//
curvesWidgetLayout->setSizeConstraint(Q
SizePolicy::Expanding
);
curvesWidgetLayout
->
setAlignment
(
Qt
::
AlignTop
);
curvesWidgetLayout
->
setColumnStretch
(
0
,
0
);
curvesWidgetLayout
->
setColumnStretch
(
1
,
0
);
curvesWidgetLayout
->
setColumnStretch
(
2
,
80
);
curvesWidgetLayout
->
setColumnStretch
(
3
,
50
);
curvesWidgetLayout
->
setColumnStretch
(
4
,
50
);
curvesWidgetLayout
->
setColumnStretch
(
5
,
50
);
// horizontalLayout->setColumnStretch(median, 50);
curvesWidgetLayout
->
setColumnStretch
(
6
,
50
);
curvesWidget
->
setLayout
(
curvesWidgetLayout
);
// Create curve list headings
QWidget
*
form
=
new
QWidget
(
this
);
QHBoxLayout
*
horizontalLayout
;
QLabel
*
label
;
QLabel
*
value
;
QLabel
*
mean
;
QLabel
*
variance
;
form
->
setAutoFillBackground
(
false
);
horizontalLayout
=
new
QHBoxLayout
(
form
);
horizontalLayout
->
setSpacing
(
5
);
horizontalLayout
->
setMargin
(
0
);
horizontalLayout
->
setSizeConstraint
(
QLayout
::
SetMinimumSize
);
//horizontalLayout->addWidget(checkBox);
label
=
new
QLabel
(
form
);
int
labelRow
=
curvesWidgetLayout
->
rowCount
();
curvesWidgetLayout
->
addWidget
(
new
QLabel
(
tr
(
"On"
)),
labelRow
,
0
,
1
,
2
);
label
=
new
QLabel
(
this
);
label
->
setText
(
"Name"
);
horizontal
Layout
->
addWidget
(
label
);
curvesWidget
Layout
->
addWidget
(
label
,
labelRow
,
2
);
// Value
value
=
new
QLabel
(
form
);
value
=
new
QLabel
(
this
);
value
->
setText
(
"Val"
);
horizontalLayout
->
addWidget
(
value
);
curvesWidgetLayout
->
addWidget
(
value
,
labelRow
,
3
);
// Unit
label
->
setText
(
"Unit"
);
curvesWidgetLayout
->
addWidget
(
new
QLabel
(
tr
(
"Unit"
)),
labelRow
,
4
);
// Mean
mean
=
new
QLabel
(
form
);
mean
=
new
QLabel
(
this
);
mean
->
setText
(
"Mean"
);
horizontal
Layout
->
addWidget
(
mean
);
curvesWidget
Layout
->
addWidget
(
mean
,
labelRow
,
5
);
// Variance
variance
=
new
QLabel
(
form
);
variance
=
new
QLabel
(
this
);
variance
->
setText
(
"Variance"
);
horizontalLayout
->
addWidget
(
variance
);
curvesWidgetLayout
->
addWidget
(
form
);
curvesWidgetLayout
->
addWidget
(
variance
,
labelRow
,
6
);
// Add and customize plot elements (right side)
...
...
@@ -260,14 +272,83 @@ void LinechartWidget::createLayout()
void
LinechartWidget
::
appendData
(
int
uasId
,
QString
curve
,
double
value
,
quint64
usec
)
{
// Order matters here, first append to plot, then update curve list
activePlot
->
appendData
(
curve
,
usec
,
value
);
// Store data
QLabel
*
label
=
curveLabels
->
value
(
curve
,
NULL
);
// Make sure the curve will be created if it does not yet exist
if
(
!
label
)
static
const
QString
unit
(
"-"
);
if
(
isVisible
())
{
// Order matters here, first append to plot, then update curve list
activePlot
->
appendData
(
curve
+
unit
,
usec
,
value
);
// Store data
QLabel
*
label
=
curveLabels
->
value
(
curve
+
unit
,
NULL
);
// Make sure the curve will be created if it does not yet exist
if
(
!
label
)
{
addCurve
(
curve
,
unit
);
}
}
// Log data
if
(
logging
)
{
if
(
activePlot
->
isVisible
(
curve
))
{
if
(
logStartTime
==
0
)
logStartTime
=
usec
;
qint64
time
=
usec
-
logStartTime
;
if
(
time
<
0
)
time
=
0
;
logFile
->
write
(
QString
(
QString
::
number
(
time
)
+
"
\t
"
+
QString
::
number
(
uasId
)
+
"
\t
"
+
curve
+
"
\t
"
+
QString
::
number
(
value
)
+
"
\n
"
).
toLatin1
());
logFile
->
flush
();
}
}
}
void
LinechartWidget
::
appendData
(
int
uasId
,
const
QString
&
curve
,
const
QString
&
unit
,
double
value
,
quint64
usec
)
{
if
(
isVisible
())
{
// Order matters here, first append to plot, then update curve list
activePlot
->
appendData
(
curve
+
unit
,
usec
,
value
);
// Store data
QLabel
*
label
=
curveLabels
->
value
(
curve
+
unit
,
NULL
);
// Make sure the curve will be created if it does not yet exist
if
(
!
label
)
{
qDebug
()
<<
"ADDING CURVE IN APPENDDATE DOUBLE"
;
addCurve
(
curve
,
unit
);
}
}
// Log data
if
(
logging
)
{
if
(
activePlot
->
isVisible
(
curve
+
unit
))
{
if
(
logStartTime
==
0
)
logStartTime
=
usec
;
qint64
time
=
usec
-
logStartTime
;
if
(
time
<
0
)
time
=
0
;
logFile
->
write
(
QString
(
QString
::
number
(
time
)
+
"
\t
"
+
QString
::
number
(
uasId
)
+
"
\t
"
+
curve
+
"
\t
"
+
QString
::
number
(
value
)
+
"
\n
"
).
toLatin1
());
logFile
->
flush
();
}
}
}
void
LinechartWidget
::
appendData
(
int
uasId
,
const
QString
&
curve
,
const
QString
&
unit
,
int
value
,
quint64
usec
)
{
if
(
isVisible
())
{
addCurve
(
curve
);
// Order matters here, first append to plot, then update curve list
activePlot
->
appendData
(
curve
+
unit
,
usec
,
value
);
// Store data
QLabel
*
label
=
curveLabels
->
value
(
curve
+
unit
,
NULL
);
// Make sure the curve will be created if it does not yet exist
if
(
!
label
)
{
addCurve
(
curve
,
unit
);
}
// Add int data
intData
.
insert
(
curve
+
unit
,
value
);
}
// Log data
...
...
@@ -275,16 +356,9 @@ void LinechartWidget::appendData(int uasId, QString curve, double value, quint64
{
if
(
activePlot
->
isVisible
(
curve
))
{
quint64
time
=
0
;
// Adjust time
if
(
activePlot
->
groundTime
())
{
time
=
QGC
::
groundTimeUsecs
()
-
logStartTime
;
}
else
{
time
=
usec
-
logStartTime
;
}
if
(
logStartTime
==
0
)
logStartTime
=
usec
;
qint64
time
=
usec
-
logStartTime
;
if
(
time
<
0
)
time
=
0
;
logFile
->
write
(
QString
(
QString
::
number
(
time
)
+
"
\t
"
+
QString
::
number
(
uasId
)
+
"
\t
"
+
curve
+
"
\t
"
+
QString
::
number
(
value
)
+
"
\n
"
).
toLatin1
());
logFile
->
flush
();
...
...
@@ -295,11 +369,28 @@ void LinechartWidget::appendData(int uasId, QString curve, double value, quint64
void
LinechartWidget
::
refresh
()
{
QString
str
;
// Value
QMap
<
QString
,
QLabel
*>::
iterator
i
;
for
(
i
=
curveLabels
->
begin
();
i
!=
curveLabels
->
end
();
++
i
)
{
str
.
sprintf
(
"%+.2f"
,
activePlot
->
getCurrentValue
(
i
.
key
()));
double
val
=
activePlot
->
getCurrentValue
(
i
.
key
());
int
intval
=
static_cast
<
int
>
(
val
);
if
(
intval
>=
100000
||
intval
<=
-
100000
)
{
str
.
sprintf
(
"% 11i"
,
intval
);
}
else
if
(
intval
>=
10000
||
intval
<=
-
10000
)
{
str
.
sprintf
(
"% 11.2f"
,
val
);
}
else
if
(
intval
>=
1000
||
intval
<=
-
1000
)
{
str
.
sprintf
(
"% 11.4f"
,
val
);
}
else
{
str
.
sprintf
(
"% 11.6f"
,
val
);
}
// Value
i
.
value
()
->
setText
(
str
);
}
...
...
@@ -307,7 +398,19 @@ void LinechartWidget::refresh()
QMap
<
QString
,
QLabel
*>::
iterator
j
;
for
(
j
=
curveMeans
->
begin
();
j
!=
curveMeans
->
end
();
++
j
)
{
str
.
sprintf
(
"%+.2f"
,
activePlot
->
getMean
(
j
.
key
()));
double
val
=
activePlot
->
getCurrentValue
(
j
.
key
());
if
(
val
>
9999
||
val
<
-
9999
)
{
str
.
sprintf
(
"% 11.2f"
,
val
);
}
else
if
(
val
>
99999
||
val
<
-
99999
)
{
str
.
sprintf
(
"% 11d"
,
(
int
)
val
);
}
else
{
str
.
sprintf
(
"% 11.6f"
,
val
);
}
j
.
value
()
->
setText
(
str
);
}
// QMap<QString, QLabel*>::iterator k;
...
...
@@ -321,7 +424,7 @@ void LinechartWidget::refresh()
for
(
l
=
curveVariances
->
begin
();
l
!=
curveVariances
->
end
();
++
l
)
{
// Variance
str
.
sprintf
(
"%
.2
e"
,
activePlot
->
getVariance
(
l
.
key
()));
str
.
sprintf
(
"%
9.4
e"
,
activePlot
->
getVariance
(
l
.
key
()));
l
.
value
()
->
setText
(
str
);
}
}
...
...
@@ -381,7 +484,8 @@ void LinechartWidget::startLogging()
if
(
logFile
->
open
(
QIODevice
::
WriteOnly
|
QIODevice
::
Text
))
{
logging
=
true
;
logStartTime
=
QGC
::
groundTimeUsecs
();
logStartTime
=
0
;
curvesWidget
->
setEnabled
(
false
);
logindex
++
;
logButton
->
setText
(
tr
(
"Stop logging"
));
disconnect
(
logButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
startLogging
()));
...
...
@@ -393,12 +497,13 @@ void LinechartWidget::startLogging()
void
LinechartWidget
::
stopLogging
()
{
logging
=
false
;
curvesWidget
->
setEnabled
(
true
);
if
(
logFile
->
isOpen
())
{
logFile
->
flush
();
logFile
->
close
();
// Postprocess log file
compressor
=
new
LogCompressor
(
logFile
->
fileName
());
compressor
=
new
LogCompressor
(
logFile
->
fileName
(),
logFile
->
fileName
());
connect
(
compressor
,
SIGNAL
(
finishedFile
(
QString
)),
this
,
SIGNAL
(
logfileWritten
(
QString
)));
connect
(
compressor
,
SIGNAL
(
logProcessingStatusChanged
(
QString
)),
MainWindow
::
instance
(),
SLOT
(
showStatusMessage
(
QString
)));
MainWindow
::
instance
()
->
showInfoMessage
(
"Logging ended"
,
"QGroundControl is now compressing the logfile in a consistent CVS file. This may take a while, you can continue to use QGroundControl. Status updates appear at the bottom of the window."
);
...
...
@@ -432,47 +537,41 @@ void LinechartWidget::createActions()
* @param curve The id-string of the curve
* @see removeCurve()
**/
void
LinechartWidget
::
addCurve
(
QString
curve
)
void
LinechartWidget
::
addCurve
(
const
QString
&
curve
,
const
QString
&
unit
)
{
curvesWidgetLayout
->
addWidget
(
createCurveItem
(
curve
));
}
intData
.
insert
(
curve
+
unit
,
0
);
QWidget
*
LinechartWidget
::
createCurveItem
(
QString
curve
)
{
LinechartPlot
*
plot
=
activePlot
;
QWidget
*
form
=
new
QWidget
(
this
);
QHBoxLayout
*
horizontalLayout
;
// QHBoxLayout *horizontalLayout;
QCheckBox
*
checkBox
;
QLabel
*
label
;
QLabel
*
value
;
QLabel
*
unitLabel
;
QLabel
*
mean
;
QLabel
*
variance
;
form
->
setAutoFillBackground
(
false
);
horizontalLayout
=
new
QHBoxLayout
(
form
);
horizontalLayout
->
setSpacing
(
5
);
horizontalLayout
->
setMargin
(
0
);
horizontalLayout
->
setSizeConstraint
(
QLayout
::
SetMinimumSize
);
checkBox
=
new
QCheckBox
(
form
);
int
labelRow
=
curvesWidgetLayout
->
rowCount
();
checkBox
=
new
QCheckBox
(
this
);
checkBox
->
setCheckable
(
true
);
checkBox
->
setObjectName
(
curve
);
checkBox
->
setObjectName
(
curve
+
unit
);
checkBox
->
setToolTip
(
tr
(
"Enable the curve in the graph window"
));
checkBox
->
setWhatsThis
(
tr
(
"Enable the curve in the graph window"
));
horizontal
Layout
->
addWidget
(
checkBox
);
curvesWidget
Layout
->
addWidget
(
checkBox
,
labelRow
,
0
);
QWidget
*
colorIcon
=
new
QWidget
(
form
);
QWidget
*
colorIcon
=
new
QWidget
(
this
);
colorIcon
->
setMinimumSize
(
QSize
(
5
,
14
));
colorIcon
->
setMaximumSize
(
4
,
14
);
horizontal
Layout
->
addWidget
(
colorIcon
);
curvesWidget
Layout
->
addWidget
(
colorIcon
,
labelRow
,
1
);
label
=
new
QLabel
(
form
);
horizontal
Layout
->
addWidget
(
label
);
label
=
new
QLabel
(
this
);
curvesWidget
Layout
->
addWidget
(
label
,
labelRow
,
2
);
//checkBox->setText(QString());
label
->
setText
(
curve
);
QColor
color
=
plot
->
getColorForCurve
(
curve
);
QColor
color
=
plot
->
getColorForCurve
(
curve
+
unit
);
if
(
color
.
isValid
())
{
QString
colorstyle
;
colorstyle
=
colorstyle
.
sprintf
(
"QWidget { background-color: #%X%X%X; }"
,
color
.
red
(),
color
.
green
(),
color
.
blue
());
...
...
@@ -481,20 +580,30 @@ QWidget* LinechartWidget::createCurveItem(QString curve)
}
// Value
value
=
new
QLabel
(
form
);
value
=
new
QLabel
(
this
);
value
->
setNum
(
0.00
);
value
->
setStyleSheet
(
QString
(
"QLabel {font-family:
\"
Courier
\"
; font-weight: bold;}"
));
value
->
setToolTip
(
tr
(
"Current value of "
)
+
curve
);
value
->
setWhatsThis
(
tr
(
"Current value of "
)
+
curve
);
curveLabels
->
insert
(
curve
,
value
);
horizontalLayout
->
addWidget
(
value
);
curveLabels
->
insert
(
curve
+
unit
,
value
);
curvesWidgetLayout
->
addWidget
(
value
,
labelRow
,
3
);
// Unit
unitLabel
=
new
QLabel
(
this
);
unitLabel
->
setText
(
unit
);
unitLabel
->
setStyleSheet
(
QString
(
"QLabel {color: %1;}"
).
arg
(
"#AAAAAA"
));
qDebug
()
<<
"UNIT"
<<
unit
;
unitLabel
->
setToolTip
(
tr
(
"Unit of "
)
+
curve
);
unitLabel
->
setWhatsThis
(
tr
(
"Unit of "
)
+
curve
);
curvesWidgetLayout
->
addWidget
(
unitLabel
,
labelRow
,
4
);
// Mean
mean
=
new
QLabel
(
form
);
mean
=
new
QLabel
(
this
);
mean
->
setNum
(
0.00
);
mean
->
setToolTip
(
tr
(
"Arithmetic mean of "
)
+
curve
);
mean
->
setWhatsThis
(
tr
(
"Arithmetic mean of "
)
+
curve
);
curveMeans
->
insert
(
curve
,
mean
);
horizontal
Layout
->
addWidget
(
mean
);
curveMeans
->
insert
(
curve
+
unit
,
mean
);
curvesWidget
Layout
->
addWidget
(
mean
,
labelRow
,
5
);
// // Median
// median = new QLabel(form);
...
...
@@ -503,12 +612,12 @@ QWidget* LinechartWidget::createCurveItem(QString curve)
// horizontalLayout->addWidget(median);
// Variance
variance
=
new
QLabel
(
form
);
variance
=
new
QLabel
(
this
);
variance
->
setNum
(
0.00
);
variance
->
setToolTip
(
tr
(
"Variance of "
)
+
curve
);
variance
->
setWhatsThis
(
tr
(
"Variance of "
)
+
curve
);
curveVariances
->
insert
(
curve
,
variance
);
horizontal
Layout
->
addWidget
(
variance
);
curveVariances
->
insert
(
curve
+
unit
,
variance
);
curvesWidget
Layout
->
addWidget
(
variance
,
labelRow
,
6
);
/* Color picker
QColor color = QColorDialog::getColor(Qt::green, this);
...
...
@@ -520,13 +629,6 @@ QWidget* LinechartWidget::createCurveItem(QString curve)
*/
// Set stretch factors so that the label gets the whole space
horizontalLayout
->
setStretchFactor
(
checkBox
,
0
);
horizontalLayout
->
setStretchFactor
(
colorIcon
,
0
);
horizontalLayout
->
setStretchFactor
(
label
,
80
);
horizontalLayout
->
setStretchFactor
(
value
,
50
);
horizontalLayout
->
setStretchFactor
(
mean
,
50
);
// horizontalLayout->setStretchFactor(median, 50);
horizontalLayout
->
setStretchFactor
(
variance
,
50
);
// Connect actions
QObject
::
connect
(
checkBox
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
takeButtonClick
(
bool
)));
...
...
@@ -534,9 +636,7 @@ QWidget* LinechartWidget::createCurveItem(QString curve)
// Set UI components to initial state
checkBox
->
setChecked
(
false
);
plot
->
setVisible
(
curve
,
false
);
return
form
;
plot
->
setVisible
(
curve
+
unit
,
false
);
}
/**
...
...
src/ui/linechart/LinechartWidget.h
View file @
9cc031aa
...
...
@@ -70,9 +70,14 @@ public:
static
const
int
MAX_TIME_SCROLLBAR_VALUE
=
16383
;
///< The maximum scrollbar value
public
slots
:
void
addCurve
(
QString
curve
);
void
addCurve
(
const
QString
&
curve
,
const
QString
&
unit
);
void
removeCurve
(
QString
curve
);
/** @brief Append data without unit */
void
appendData
(
int
uasId
,
QString
curve
,
double
data
,
quint64
usec
);
/** @brief Append data with unit */
void
appendData
(
int
uasId
,
const
QString
&
curve
,
const
QString
&
unit
,
double
value
,
quint64
usec
);
/** @brief Append data as int with unit */
void
appendData
(
int
uasId
,
const
QString
&
curve
,
const
QString
&
unit
,
int
value
,
quint64
usec
);
void
takeButtonClick
(
bool
checked
);
void
setPlotWindowPosition
(
int
scrollBarValue
);
void
setPlotWindowPosition
(
quint64
position
);
...
...
@@ -95,7 +100,7 @@ protected:
void
addCurveToList
(
QString
curve
);
void
removeCurveFromList
(
QString
curve
);
QToolButton
*
createButton
(
QWidget
*
parent
);
QWidget
*
createCurveItem
(
QString
curve
);
void
createCurveItem
(
QString
curve
);
void
createLayout
();
int
sysid
;
///< ID of the unmanned system this plot belongs to
...
...
@@ -110,9 +115,10 @@ protected:
QMap
<
QString
,
QLabel
*>*
curveMeans
;
///< References to the curve means
QMap
<
QString
,
QLabel
*>*
curveMedians
;
///< References to the curve medians
QMap
<
QString
,
QLabel
*>*
curveVariances
;
///< References to the curve variances
QMap
<
QString
,
int
>
intData
;
///< Current values for integer-valued curves
QWidget
*
curvesWidget
;
///< The QWidget containing the curve selection button
Q
VBox
Layout
*
curvesWidgetLayout
;
///< The layout for the curvesWidget QWidget
Q
Grid
Layout
*
curvesWidgetLayout
;
///< The layout for the curvesWidget QWidget
QScrollBar
*
scrollbar
;
///< The plot window scroll bar
QSpinBox
*
averageSpinBox
;
///< Spin box to setup average window filter size
...
...
@@ -130,9 +136,9 @@ protected:
QFile
*
logFile
;
unsigned
int
logindex
;
bool
logging
;
quint64
logStartTime
;
QTimer
*
updateTimer
;
LogCompressor
*
compressor
;
quint64
logStartTime
;
static
const
int
MAX_CURVE_MENUITEM_NUMBER
=
8
;
static
const
int
PAGESTEP_TIME_SCROLLBAR_VALUE
=
(
MAX_TIME_SCROLLBAR_VALUE
-
MIN_TIME_SCROLLBAR_VALUE
)
/
10
;
...
...
src/ui/linechart/Linecharts.cc
View file @
9cc031aa
...
...
@@ -96,7 +96,12 @@ void Linecharts::addSystem(UASInterface* uas)
addWidget
(
widget
);
plots
.
insert
(
uas
->
getUASID
(),
widget
);
#ifndef MAVLINK_ENABLED_SLUGS
connect
(
uas
,
SIGNAL
(
valueChanged
(
int
,
QString
,
double
,
quint64
)),
widget
,
SLOT
(
appendData
(
int
,
QString
,
double
,
quint64
)));
// Values without unit
//connect(uas, SIGNAL(valueChanged(int,QString,double,quint64)), widget, SLOT(appendData(int,QString,double,quint64)));
// Values with unit as double
connect
(
uas
,
SIGNAL
(
valueChanged
(
int
,
QString
,
QString
,
double
,
quint64
)),
widget
,
SLOT
(
appendData
(
int
,
QString
,
QString
,
double
,
quint64
)));
// Values with unit as integer
connect
(
uas
,
SIGNAL
(
valueChanged
(
int
,
QString
,
QString
,
double
,
quint64
)),
widget
,
SLOT
(
appendData
(
int
,
QString
,
QString
,
double
,
quint64
)));
#endif
connect
(
widget
,
SIGNAL
(
logfileWritten
(
QString
)),
this
,
SIGNAL
(
logfileWritten
(
QString
)));
// Set system active if this is the only system
...
...
src/ui/uas/UASControlWidget.cc
View file @
9cc031aa
...
...
@@ -114,18 +114,18 @@ void UASControlWidget::setUAS(UASInterface* uas)
// Check if additional controls should be loaded
UAS
*
mav
=
dynamic_cast
<
UAS
*>
(
uas
);
if
(
mav
)
{
{
QPushButton
*
startRecButton
=
new
QPushButton
(
tr
(
"Record"
));
connect
(
startRecButton
,
SIGNAL
(
clicked
()),
mav
,
SLOT
(
startDataRecording
()));
ui
.
gridLayout
->
addWidget
(
startRecButton
,
10
,
0
,
0
,
2
);
ui
.
gridLayout
->
addWidget
(
startRecButton
,
7
,
1
);
QPushButton
*
pauseRecButton
=
new
QPushButton
(
tr
(
"Pause"
));
connect
(
pauseRecButton
,
SIGNAL
(
clicked
()),
mav
,
SLOT
(
pauseDataRecording
()));
ui
.
gridLayout
->
addWidget
(
pauseRecButton
,
10
,
2
,
0
,
2
);
ui
.
gridLayout
->
addWidget
(
pauseRecButton
,
7
,
3
);
QPushButton
*
stopRecButton
=
new
QPushButton
(
tr
(
"Stop"
));
connect
(
stopRecButton
,
SIGNAL
(
clicked
()),
mav
,
SLOT
(
stopDataRecording
()));
ui
.
gridLayout
->
addWidget
(
stopRecButton
,
10
,
4
,
0
,
2
);
ui
.
gridLayout
->
addWidget
(
stopRecButton
,
7
,
4
);
}
...
...
Prev
1
2
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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