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
20723799
Commit
20723799
authored
Feb 26, 2011
by
lm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added command button
parent
bed216dd
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
265 additions
and
4 deletions
+265
-4
UAS.cc
src/uas/UAS.cc
+9
-0
UAS.h
src/uas/UAS.h
+2
-0
UASInterface.h
src/uas/UASInterface.h
+2
-0
QGCCommandButton.cc
src/ui/designer/QGCCommandButton.cc
+97
-0
QGCCommandButton.h
src/ui/designer/QGCCommandButton.h
+33
-0
QGCCommandButton.ui
src/ui/designer/QGCCommandButton.ui
+91
-0
QGCToolWidget.cc
src/ui/designer/QGCToolWidget.cc
+28
-4
QGCToolWidget.h
src/ui/designer/QGCToolWidget.h
+3
-0
No files found.
src/uas/UAS.cc
View file @
20723799
...
@@ -1766,6 +1766,15 @@ void UAS::setUASName(const QString& name)
...
@@ -1766,6 +1766,15 @@ void UAS::setUASName(const QString& name)
emit
systemSpecsChanged
(
uasId
);
emit
systemSpecsChanged
(
uasId
);
}
}
void
UAS
::
executeCommand
(
MAV_CMD
command
)
{
mavlink_message_t
msg
;
mavlink_command_t
cmd
;
//mavlink_msg_action_pack(mavlink->getSystemId(), mavlink->getComponentId(), &msg, this->getUASID(), 0, action);
// Send message twice to increase chance that it reaches its goal
sendMessage
(
msg
);
}
/**
/**
* Sets an action
* Sets an action
*
*
...
...
src/uas/UAS.h
View file @
20723799
...
@@ -214,6 +214,8 @@ public slots:
...
@@ -214,6 +214,8 @@ public slots:
void
setUASName
(
const
QString
&
name
);
void
setUASName
(
const
QString
&
name
);
/** @brief Executes an action **/
/** @brief Executes an action **/
void
setAction
(
MAV_ACTION
action
);
void
setAction
(
MAV_ACTION
action
);
/** @brief Executes a command **/
void
executeCommand
(
MAV_CMD
command
);
/** @brief Set the current battery type and voltages */
/** @brief Set the current battery type and voltages */
void
setBatterySpecs
(
const
QString
&
specs
);
void
setBatterySpecs
(
const
QString
&
specs
);
/** @brief Get the current battery type and specs */
/** @brief Get the current battery type and specs */
...
...
src/uas/UASInterface.h
View file @
20723799
...
@@ -189,6 +189,8 @@ public slots:
...
@@ -189,6 +189,8 @@ public slots:
virtual
void
setUASName
(
const
QString
&
name
)
=
0
;
virtual
void
setUASName
(
const
QString
&
name
)
=
0
;
/** @brief Sets an action **/
/** @brief Sets an action **/
virtual
void
setAction
(
MAV_ACTION
action
)
=
0
;
virtual
void
setAction
(
MAV_ACTION
action
)
=
0
;
/** @brief Execute command immediately **/
virtual
void
executeCommand
(
MAV_CMD
command
)
=
0
;
/** @brief Selects the airframe */
/** @brief Selects the airframe */
virtual
void
setAirframe
(
int
airframe
)
=
0
;
virtual
void
setAirframe
(
int
airframe
)
=
0
;
...
...
src/ui/designer/QGCCommandButton.cc
0 → 100644
View file @
20723799
#include "QGCCommandButton.h"
#include "ui_QGCCommandButton.h"
#include "MAVLinkProtocol.h"
#include "UASManager.h"
QGCCommandButton
::
QGCCommandButton
(
QWidget
*
parent
)
:
QGCToolWidgetItem
(
"CommandButton"
,
parent
),
ui
(
new
Ui
::
QGCCommandButton
),
uas
(
NULL
)
{
ui
->
setupUi
(
this
);
connect
(
ui
->
commandButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
sendCommand
()));
connect
(
ui
->
editFinishButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
endEditMode
()));
connect
(
ui
->
editButtonName
,
SIGNAL
(
textChanged
(
QString
)),
this
,
SLOT
(
setCommandButtonName
(
QString
)));
connect
(
ui
->
editCommandComboBox
,
SIGNAL
(
currentIndexChanged
(
QString
)),
ui
->
nameLabel
,
SLOT
(
setText
(
QString
)));
// Hide all edit items
ui
->
editCommandComboBox
->
hide
();
ui
->
editFinishButton
->
hide
();
ui
->
editNameLabel
->
hide
();
ui
->
editButtonName
->
hide
();
// Add commands to combo box
ui
->
editCommandComboBox
->
addItem
(
"DO: Control Video"
,
MAV_CMD_DO_CONTROL_VIDEO
);
ui
->
editCommandComboBox
->
addItem
(
"PREFLIGHT: Calibration"
,
MAV_CMD_PREFLIGHT_CALIBRATION
);
}
QGCCommandButton
::~
QGCCommandButton
()
{
delete
ui
;
}
void
QGCCommandButton
::
sendCommand
()
{
if
(
QGCToolWidgetItem
::
uas
)
{
// FIXME
int
index
=
0
;
//ui->editCommandComboBox->userData()
MAV_CMD
command
=
static_cast
<
MAV_CMD
>
(
index
);
QGCToolWidgetItem
::
uas
->
executeCommand
(
command
);
}
else
{
qDebug
()
<<
__FILE__
<<
__LINE__
<<
"NO UAS SET, DOING NOTHING"
;
}
}
void
QGCCommandButton
::
setCommandButtonName
(
QString
text
)
{
ui
->
commandButton
->
setText
(
text
);
}
void
QGCCommandButton
::
startEditMode
()
{
ui
->
editCommandComboBox
->
show
();
ui
->
editFinishButton
->
show
();
ui
->
editNameLabel
->
show
();
ui
->
editButtonName
->
show
();
isInEditMode
=
true
;
}
void
QGCCommandButton
::
endEditMode
()
{
ui
->
editCommandComboBox
->
hide
();
ui
->
editFinishButton
->
hide
();
ui
->
editNameLabel
->
hide
();
ui
->
editButtonName
->
hide
();
// Write to settings
emit
editingFinished
();
isInEditMode
=
false
;
}
void
QGCCommandButton
::
writeSettings
(
QSettings
&
settings
)
{
settings
.
setValue
(
"TYPE"
,
"COMMANDBUTTON"
);
settings
.
setValue
(
"QGC_ACTION_BUTTON_DESCRIPTION"
,
ui
->
nameLabel
->
text
());
settings
.
setValue
(
"QGC_ACTION_BUTTON_BUTTONTEXT"
,
ui
->
commandButton
->
text
());
settings
.
setValue
(
"QGC_ACTION_BUTTON_ACTIONID"
,
ui
->
editCommandComboBox
->
currentIndex
());
settings
.
sync
();
}
void
QGCCommandButton
::
readSettings
(
const
QSettings
&
settings
)
{
ui
->
editNameLabel
->
setText
(
settings
.
value
(
"QGC_ACTION_BUTTON_DESCRIPTION"
,
"ERROR LOADING BUTTON"
).
toString
());
ui
->
editButtonName
->
setText
(
settings
.
value
(
"QGC_ACTION_BUTTON_BUTTONTEXT"
,
"UNKNOWN"
).
toString
());
ui
->
editCommandComboBox
->
setCurrentIndex
(
settings
.
value
(
"QGC_ACTION_BUTTON_ACTIONID"
,
0
).
toInt
());
ui
->
nameLabel
->
setText
(
settings
.
value
(
"QGC_ACTION_BUTTON_DESCRIPTION"
,
"ERROR LOADING BUTTON"
).
toString
());
ui
->
commandButton
->
setText
(
settings
.
value
(
"QGC_ACTION_BUTTON_BUTTONTEXT"
,
"UNKNOWN"
).
toString
());
ui
->
editCommandComboBox
->
setCurrentIndex
(
settings
.
value
(
"QGC_ACTION_BUTTON_ACTIONID"
,
0
).
toInt
());
qDebug
()
<<
"DONE READING SETTINGS"
;
}
src/ui/designer/QGCCommandButton.h
0 → 100644
View file @
20723799
#ifndef QGCCOMMANDBUTTON_H
#define QGCCOMMANDBUTTON_H
#include "QGCToolWidgetItem.h"
namespace
Ui
{
class
QGCCommandButton
;
}
class
UASInterface
;
class
QGCCommandButton
:
public
QGCToolWidgetItem
{
Q_OBJECT
public:
explicit
QGCCommandButton
(
QWidget
*
parent
=
0
);
~
QGCCommandButton
();
public
slots
:
void
sendCommand
();
void
setCommandButtonName
(
QString
text
);
void
startEditMode
();
void
endEditMode
();
void
writeSettings
(
QSettings
&
settings
);
void
readSettings
(
const
QSettings
&
settings
);
private:
Ui
::
QGCCommandButton
*
ui
;
UASInterface
*
uas
;
};
#endif // QGCCOMMANDBUTTON_H
src/ui/designer/QGCCommandButton.ui
0 → 100644
View file @
20723799
<?xml version="1.0" encoding="UTF-8"?>
<ui
version=
"4.0"
>
<class>
QGCCommandButton
</class>
<widget
class=
"QWidget"
name=
"QGCCommandButton"
>
<property
name=
"geometry"
>
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
400
</width>
<height>
111
</height>
</rect>
</property>
<property
name=
"windowTitle"
>
<string>
Form
</string>
</property>
<layout
class=
"QGridLayout"
name=
"gridLayout"
columnstretch=
"100,100,50"
>
<item
row=
"1"
column=
"0"
colspan=
"2"
>
<widget
class=
"QLabel"
name=
"nameLabel"
>
<property
name=
"minimumSize"
>
<size>
<width>
50
</width>
<height>
0
</height>
</size>
</property>
<property
name=
"text"
>
<string>
Description
</string>
</property>
<property
name=
"alignment"
>
<set>
Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
</set>
</property>
</widget>
</item>
<item
row=
"2"
column=
"0"
colspan=
"2"
>
<widget
class=
"QComboBox"
name=
"editCommandComboBox"
/>
</item>
<item
row=
"2"
column=
"2"
>
<widget
class=
"QPushButton"
name=
"editFinishButton"
>
<property
name=
"text"
>
<string>
Done
</string>
</property>
</widget>
</item>
<item
row=
"0"
column=
"2"
>
<widget
class=
"QLineEdit"
name=
"editButtonName"
>
<property
name=
"text"
>
<string>
Unnamed
</string>
</property>
</widget>
</item>
<item
row=
"0"
column=
"0"
colspan=
"2"
>
<widget
class=
"QLineEdit"
name=
"editNameLabel"
>
<property
name=
"text"
>
<string>
Description
</string>
</property>
</widget>
</item>
<item
row=
"1"
column=
"2"
>
<widget
class=
"QPushButton"
name=
"commandButton"
>
<property
name=
"minimumSize"
>
<size>
<width>
30
</width>
<height>
0
</height>
</size>
</property>
<property
name=
"text"
>
<string>
Unnamed
</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>
editNameLabel
</sender>
<signal>
textChanged(QString)
</signal>
<receiver>
nameLabel
</receiver>
<slot>
setText(QString)
</slot>
<hints>
<hint
type=
"sourcelabel"
>
<x>
114
</x>
<y>
22
</y>
</hint>
<hint
type=
"destinationlabel"
>
<x>
114
</x>
<y>
55
</y>
</hint>
</hints>
</connection>
</connections>
</ui>
src/ui/designer/QGCToolWidget.cc
View file @
20723799
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
#include "QGCParamSlider.h"
#include "QGCParamSlider.h"
#include "QGCActionButton.h"
#include "QGCActionButton.h"
#include "QGCCommandButton.h"
#include "UASManager.h"
#include "UASManager.h"
QGCToolWidget
::
QGCToolWidget
(
const
QString
&
title
,
QWidget
*
parent
)
:
QGCToolWidget
::
QGCToolWidget
(
const
QString
&
title
,
QWidget
*
parent
)
:
...
@@ -106,6 +107,11 @@ QList<QGCToolWidget*> QGCToolWidget::createWidgetsFromSettings(QWidget* parent)
...
@@ -106,6 +107,11 @@ QList<QGCToolWidget*> QGCToolWidget::createWidgetsFromSettings(QWidget* parent)
item
=
new
QGCActionButton
(
newWidgets
.
at
(
i
));
item
=
new
QGCActionButton
(
newWidgets
.
at
(
i
));
qDebug
()
<<
"CREATED BUTTON"
;
qDebug
()
<<
"CREATED BUTTON"
;
}
}
else
if
(
type
==
"COMMANDBUTTON"
)
{
item
=
new
QGCCommandButton
(
newWidgets
.
at
(
i
));
qDebug
()
<<
"CREATED COMMANDBUTTON"
;
}
else
if
(
type
==
"SLIDER"
)
else
if
(
type
==
"SLIDER"
)
{
{
item
=
new
QGCParamSlider
(
newWidgets
.
at
(
i
));
item
=
new
QGCParamSlider
(
newWidgets
.
at
(
i
));
...
@@ -182,9 +188,11 @@ void QGCToolWidget::contextMenuEvent (QContextMenuEvent* event)
...
@@ -182,9 +188,11 @@ void QGCToolWidget::contextMenuEvent (QContextMenuEvent* event)
{
{
QMenu
menu
(
this
);
QMenu
menu
(
this
);
menu
.
addAction
(
addParamAction
);
menu
.
addAction
(
addParamAction
);
menu
.
addAction
(
add
Button
Action
);
menu
.
addAction
(
add
Command
Action
);
menu
.
addAction
(
setTitleAction
);
menu
.
addAction
(
setTitleAction
);
menu
.
addAction
(
deleteAction
);
menu
.
addAction
(
deleteAction
);
menu
.
addSeparator
();
menu
.
addAction
(
addButtonAction
);
menu
.
exec
(
event
->
globalPos
());
menu
.
exec
(
event
->
globalPos
());
}
}
...
@@ -194,9 +202,9 @@ void QGCToolWidget::createActions()
...
@@ -194,9 +202,9 @@ void QGCToolWidget::createActions()
addParamAction
->
setStatusTip
(
tr
(
"Add a parameter setting slider widget to the tool"
));
addParamAction
->
setStatusTip
(
tr
(
"Add a parameter setting slider widget to the tool"
));
connect
(
addParamAction
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
addParam
()));
connect
(
addParamAction
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
addParam
()));
add
Button
Action
=
new
QAction
(
tr
(
"New MAV &Command Button"
),
this
);
add
Command
Action
=
new
QAction
(
tr
(
"New MAV &Command Button"
),
this
);
add
Button
Action
->
setStatusTip
(
tr
(
"Add a new action button to the tool"
));
add
Command
Action
->
setStatusTip
(
tr
(
"Add a new action button to the tool"
));
connect
(
add
ButtonAction
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
addAction
()));
connect
(
add
CommandAction
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
addCommand
()));
setTitleAction
=
new
QAction
(
tr
(
"Set Widget Title"
),
this
);
setTitleAction
=
new
QAction
(
tr
(
"Set Widget Title"
),
this
);
setTitleAction
->
setStatusTip
(
tr
(
"Set the title caption of this tool widget"
));
setTitleAction
->
setStatusTip
(
tr
(
"Set the title caption of this tool widget"
));
...
@@ -213,6 +221,10 @@ void QGCToolWidget::createActions()
...
@@ -213,6 +221,10 @@ void QGCToolWidget::createActions()
importAction
=
new
QAction
(
tr
(
"Import widget"
),
this
);
importAction
=
new
QAction
(
tr
(
"Import widget"
),
this
);
importAction
->
setStatusTip
(
tr
(
"Import this widget from a file (current content will be removed)"
));
importAction
->
setStatusTip
(
tr
(
"Import this widget from a file (current content will be removed)"
));
connect
(
exportAction
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
importWidget
()));
connect
(
exportAction
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
importWidget
()));
addButtonAction
=
new
QAction
(
tr
(
"New MAV Action Button (Deprecated)"
),
this
);
addButtonAction
->
setStatusTip
(
tr
(
"Add a new action button to the tool"
));
connect
(
addButtonAction
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
addAction
()));
}
}
QMap
<
QString
,
QGCToolWidget
*>*
QGCToolWidget
::
instances
()
QMap
<
QString
,
QGCToolWidget
*>*
QGCToolWidget
::
instances
()
...
@@ -253,6 +265,18 @@ void QGCToolWidget::addAction()
...
@@ -253,6 +265,18 @@ void QGCToolWidget::addAction()
button
->
startEditMode
();
button
->
startEditMode
();
}
}
void
QGCToolWidget
::
addCommand
()
{
QGCCommandButton
*
button
=
new
QGCCommandButton
(
this
);
if
(
ui
->
hintLabel
)
{
ui
->
hintLabel
->
deleteLater
();
ui
->
hintLabel
=
NULL
;
}
toolLayout
->
addWidget
(
button
);
button
->
startEditMode
();
}
void
QGCToolWidget
::
addToolWidget
(
QGCToolWidgetItem
*
widget
)
void
QGCToolWidget
::
addToolWidget
(
QGCToolWidgetItem
*
widget
)
{
{
if
(
ui
->
hintLabel
)
if
(
ui
->
hintLabel
)
...
...
src/ui/designer/QGCToolWidget.h
View file @
20723799
...
@@ -45,6 +45,7 @@ signals:
...
@@ -45,6 +45,7 @@ signals:
protected:
protected:
QAction
*
addParamAction
;
QAction
*
addParamAction
;
QAction
*
addButtonAction
;
QAction
*
addButtonAction
;
QAction
*
addCommandAction
;
QAction
*
setTitleAction
;
QAction
*
setTitleAction
;
QAction
*
deleteAction
;
QAction
*
deleteAction
;
QAction
*
exportAction
;
QAction
*
exportAction
;
...
@@ -62,7 +63,9 @@ protected:
...
@@ -62,7 +63,9 @@ protected:
protected
slots
:
protected
slots
:
void
addParam
();
void
addParam
();
/** @deprecated */
void
addAction
();
void
addAction
();
void
addCommand
();
void
setTitle
();
void
setTitle
();
...
...
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