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
c019b132
Commit
c019b132
authored
May 14, 2010
by
lm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed parameter interface, now transmits minimum data
parent
da50fb07
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
25 deletions
+68
-25
QGCParamWidget.cc
src/ui/QGCParamWidget.cc
+67
-24
QGCParamWidget.h
src/ui/QGCParamWidget.h
+1
-1
No files found.
src/ui/QGCParamWidget.cc
View file @
c019b132
...
...
@@ -83,7 +83,7 @@ QGCParamWidget::QGCParamWidget(UASInterface* uas, QWidget *parent) :
// Connect signals/slots
connect
(
this
,
SIGNAL
(
parameterChanged
(
int
,
QString
,
float
)),
mav
,
SLOT
(
setParameter
(
int
,
QString
,
float
)));
connect
(
tree
,
SIGNAL
(
currentItemChanged
(
QTreeWidgetItem
*
,
QTreeWidgetItem
*
)),
this
,
SLOT
(
parameterItemChanged
(
QTreeWidgetItem
*
,
QTreeWidgetItem
*
)));
connect
(
tree
,
SIGNAL
(
itemChanged
(
QTreeWidgetItem
*
,
int
)),
this
,
SLOT
(
parameterItemChanged
(
QTreeWidgetItem
*
,
int
)));
// New parameters from UAS
connect
(
uas
,
SIGNAL
(
parameterChanged
(
int
,
int
,
QString
,
float
)),
this
,
SLOT
(
addParameter
(
int
,
int
,
QString
,
float
)));
...
...
@@ -141,9 +141,25 @@ void QGCParamWidget::addParameter(int uas, int component, QString parameterName,
{
addComponent
(
uas
,
component
,
"Component #"
+
QString
::
number
(
component
));
}
// TODO Replace old value
components
->
value
(
component
)
->
addChild
(
item
);
item
->
setFlags
(
item
->
flags
()
|
Qt
::
ItemIsEditable
);
bool
found
=
false
;
QTreeWidgetItem
*
parent
=
components
->
value
(
component
);
for
(
int
i
=
0
;
i
<
parent
->
childCount
();
i
++
)
{
QTreeWidgetItem
*
child
=
parent
->
child
(
i
);
QString
key
=
child
->
data
(
0
,
Qt
::
DisplayRole
).
toString
();
if
(
key
==
parameterName
)
{
child
->
setData
(
1
,
Qt
::
DisplayRole
,
value
);
found
=
true
;
}
}
if
(
!
found
)
{
components
->
value
(
component
)
->
addChild
(
item
);
item
->
setFlags
(
item
->
flags
()
|
Qt
::
ItemIsEditable
);
}
//connect(item, SIGNAL())
tree
->
expandAll
();
tree
->
update
();
...
...
@@ -160,31 +176,38 @@ void QGCParamWidget::requestParameterList()
mav
->
requestParameters
();
}
void
QGCParamWidget
::
parameterItemChanged
(
QTreeWidgetItem
*
current
,
QTreeWidgetItem
*
previous
)
void
QGCParamWidget
::
parameterItemChanged
(
QTreeWidgetItem
*
current
,
int
column
)
{
/*
int key;
if (!changedValues.contains(key))
{
changedValues.insert(key, new QMap<QString, float>());
}
QMap<QString, float>* map = changedValues.value(key, NULL);
if (map)
if
(
current
&&
column
>
0
)
{
bool ok;
QString str = current->data(0, Qt::DisplayRole).toString();
float value = current->data(1, Qt::DisplayRole).toDouble(&ok);
// Send parameter to MAV
if (ok)
QTreeWidgetItem
*
parent
=
current
->
parent
();
while
(
parent
->
parent
()
!=
NULL
)
{
parent
=
parent
->
parent
();
}
// Parent is now top-level component
int
key
=
components
->
key
(
parent
);
if
(
!
changedValues
.
contains
(
key
))
{
changedValues
.
insert
(
key
,
new
QMap
<
QString
,
float
>
());
}
QMap
<
QString
,
float
>*
map
=
changedValues
.
value
(
key
,
NULL
);
if
(
map
)
{
float oldvalue = current->data(1, Qt::DisplayRole).toDouble(&ok);
if (ok && (oldvalue != value))
bool
ok
;
QString
str
=
current
->
data
(
0
,
Qt
::
DisplayRole
).
toString
();
float
value
=
current
->
data
(
1
,
Qt
::
DisplayRole
).
toDouble
(
&
ok
);
// Send parameter to MAV
if
(
ok
)
{
qDebug() << "PARAM CHANGED: KEY:" << str << "VALUE:" << value;
map->insert(str, value);
if
(
ok
)
{
qDebug
()
<<
"PARAM CHANGED: COMP:"
<<
key
<<
"KEY:"
<<
str
<<
"VALUE:"
<<
value
;
map
->
insert
(
str
,
value
);
}
}
}
}
*/
}
}
/**
...
...
@@ -202,6 +225,25 @@ void QGCParamWidget::setParameter(int component, QString parameterName, float va
*/
void
QGCParamWidget
::
setParameters
()
{
// Iterate through all components, through all parameters and emit them
QMap
<
int
,
QMap
<
QString
,
float
>*>::
iterator
i
;
for
(
i
=
changedValues
.
begin
();
i
!=
changedValues
.
end
();
++
i
)
{
// Iterate through the parameters of the component
int
compid
=
i
.
key
();
QMap
<
QString
,
float
>*
comp
=
i
.
value
();
{
QMap
<
QString
,
float
>::
iterator
j
;
for
(
j
=
comp
->
begin
();
j
!=
comp
->
end
();
++
j
)
{
emit
parameterChanged
(
compid
,
j
.
key
(),
j
.
value
());
}
}
}
/*
//mav->setParameter(component, parameterName, value);
// Iterate through all components, through all parameters and emit them
QMap<int, QTreeWidgetItem*>::iterator i;
...
...
@@ -222,7 +264,7 @@ void QGCParamWidget::setParameters()
if (ok)
{
emit parameterChanged(compid, key, value);
qDebug
()
<<
"KEY:"
<<
key
<<
"VALUE:"
<<
value
;
qDebug() << "
SET PARAM:
KEY:" << key << "VALUE:" << value;
}
else
{
...
...
@@ -234,6 +276,7 @@ void QGCParamWidget::setParameters()
// TODO Instead of clearing, keep parameter list and wait for individual update messages
clear();
*/
//mav->requestParameters();
qDebug
()
<<
__FILE__
<<
__LINE__
<<
"SETTING ALL PARAMETERS"
;
}
...
...
src/ui/QGCParamWidget.h
View file @
c019b132
...
...
@@ -68,7 +68,7 @@ public slots:
/** @brief Clear the parameter list */
void
clear
();
/** @brief Update when user changes parameters */
void
parameterItemChanged
(
QTreeWidgetItem
*
prev
,
QTreeWidgetItem
*
curr
);
void
parameterItemChanged
(
QTreeWidgetItem
*
prev
,
int
column
);
protected:
UASInterface
*
mav
;
///< The MAV this widget is controlling
QTreeWidget
*
tree
;
///< The parameter tree
...
...
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