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
3b7e0db1
Commit
3b7e0db1
authored
Jan 04, 2011
by
Lionel Heng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved custom widget functionality.
parent
a9bd26d9
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
111 additions
and
26 deletions
+111
-26
UAS.cc
src/uas/UAS.cc
+13
-0
UAS.h
src/uas/UAS.h
+3
-0
UASInterface.h
src/uas/UASInterface.h
+3
-0
QGCActionButton.cc
src/ui/designer/QGCActionButton.cc
+75
-1
QGCActionButton.h
src/ui/designer/QGCActionButton.h
+8
-0
QGCActionButton.ui
src/ui/designer/QGCActionButton.ui
+9
-25
No files found.
src/uas/UAS.cc
View file @
3b7e0db1
...
...
@@ -1290,6 +1290,19 @@ void UAS::setParameter(int component, QString id, float value)
sendMessage
(
msg
);
}
/**
* Sets an action
*
**/
void
UAS
::
setAction
(
MAV_ACTION
action
)
{
mavlink_message_t
msg
;
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
);
sendMessage
(
msg
);
}
/**
* Launches the system
*
...
...
src/uas/UAS.h
View file @
3b7e0db1
...
...
@@ -174,6 +174,9 @@ public:
void
setAutopilotType
(
int
apType
)
{
autopilot
=
apType
;}
public
slots
:
/** @brief Sets an action **/
void
setAction
(
MAV_ACTION
action
);
/** @brief Launches the system **/
void
launch
();
/** @brief Write this waypoint to the list of waypoints */
...
...
src/uas/UASInterface.h
View file @
3b7e0db1
...
...
@@ -162,6 +162,9 @@ public:
public
slots
:
/** @brief Sets an action **/
virtual
void
setAction
(
MAV_ACTION
action
)
=
0
;
/** @brief Launches the system/Liftof **/
virtual
void
launch
()
=
0
;
/** @brief Set a new waypoint **/
...
...
src/ui/designer/QGCActionButton.cc
View file @
3b7e0db1
#include "QGCActionButton.h"
#include "ui_QGCActionButton.h"
#include "MAVLinkProtocol.h"
#include "UASManager.h"
const
char
*
kActionLabels
[
MAV_ACTION_NB
]
=
{
"HOLD"
,
"START MOTORS"
,
"LAUNCH"
,
"RETURN"
,
"EMERGENCY LAND"
,
"EMERGENCY KILL"
,
"CONFIRM KILL"
,
"CONTINUE"
,
"STOP MOTORS"
,
"HALT"
,
"SHUTDOWN"
,
"REBOOT"
,
"SET MANUAL"
,
"SET AUTO"
,
"READ STORAGE"
,
"WRITE STORAGE"
,
"CALIBRATE RC"
,
"CALIBRATE GYRO"
,
"CALIBRATE MAG"
,
"CALIBRATE PRESSURE"
,
"START REC"
,
"PAUSE REC"
,
"STOP REC"
,
"TAKEOFF"
,
"NAVIGATE"
,
"LAND"
,
"LOITER"
,
"SET ORIGIN"
,
"RELAY ON"
,
"RELAY OFF"
,
"GET IMAGE"
,
"START VIDEO"
,
"STOP VIDEO"
,
"RESET MAP"
};
QGCActionButton
::
QGCActionButton
(
QWidget
*
parent
)
:
QGCToolWidgetItem
(
parent
),
ui
(
new
Ui
::
QGCActionButton
)
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
)));
connect
(
ui
->
editActionComboBox
,
SIGNAL
(
currentIndexChanged
(
QString
)),
ui
->
nameLabel
,
SLOT
(
setText
(
QString
)));
endEditMode
();
// add action labels to combobox
for
(
int
i
=
0
;
i
<
MAV_ACTION_NB
;
i
++
)
{
ui
->
editActionComboBox
->
addItem
(
kActionLabels
[
i
]);
}
}
QGCActionButton
::~
QGCActionButton
()
...
...
@@ -15,6 +68,22 @@ QGCActionButton::~QGCActionButton()
delete
ui
;
}
void
QGCActionButton
::
sendAction
()
{
if
(
uas
)
{
MAV_ACTION
action
=
static_cast
<
MAV_ACTION
>
(
ui
->
editActionComboBox
->
currentIndex
());
uas
->
setAction
(
action
);
}
}
void
QGCActionButton
::
setActionButtonName
(
QString
text
)
{
ui
->
actionButton
->
setText
(
text
);
}
void
QGCActionButton
::
startEditMode
()
{
ui
->
editActionComboBox
->
show
();
...
...
@@ -30,3 +99,8 @@ void QGCActionButton::endEditMode()
ui
->
editFinishButton
->
hide
();
isInEditMode
=
false
;
}
void
QGCActionButton
::
setActiveUAS
(
UASInterface
*
uas
)
{
this
->
uas
=
uas
;
}
src/ui/designer/QGCActionButton.h
View file @
3b7e0db1
...
...
@@ -7,6 +7,8 @@ namespace Ui {
class
QGCActionButton
;
}
class
UASInterface
;
class
QGCActionButton
:
public
QGCToolWidgetItem
{
Q_OBJECT
...
...
@@ -16,11 +18,17 @@ public:
~
QGCActionButton
();
public
slots
:
void
sendAction
();
void
setActionButtonName
(
QString
text
);
void
startEditMode
();
void
endEditMode
();
private
slots
:
void
setActiveUAS
(
UASInterface
*
uas
);
private:
Ui
::
QGCActionButton
*
ui
;
UASInterface
*
uas
;
};
#endif // QGCACTIONBUTTON_H
src/ui/designer/QGCActionButton.ui
View file @
3b7e0db1
...
...
@@ -21,13 +21,6 @@
</property>
</widget>
</item>
<item
row=
"1"
column=
"2"
>
<widget
class=
"QPushButton"
name=
"actionButton"
>
<property
name=
"text"
>
<string>
Button name
</string>
</property>
</widget>
</item>
<item
row=
"2"
column=
"0"
>
<widget
class=
"QComboBox"
name=
"editActionComboBox"
/>
</item>
...
...
@@ -59,26 +52,17 @@
</property>
</widget>
</item>
<item
row=
"1"
column=
"2"
>
<widget
class=
"QPushButton"
name=
"actionButton"
>
<property
name=
"text"
>
<string>
Button name
</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>
editButtonName
</sender>
<signal>
textChanged(QString)
</signal>
<receiver>
actionButton
</receiver>
<slot>
setWindowTitle(QString)
</slot>
<hints>
<hint
type=
"sourcelabel"
>
<x>
310
</x>
<y>
22
</y>
</hint>
<hint
type=
"destinationlabel"
>
<x>
310
</x>
<y>
55
</y>
</hint>
</hints>
</connection>
<connection>
<sender>
editNameLabel
</sender>
<signal>
textChanged(QString)
</signal>
...
...
@@ -86,11 +70,11 @@
<slot>
setText(QString)
</slot>
<hints>
<hint
type=
"sourcelabel"
>
<x>
11
6
</x>
<x>
11
4
</x>
<y>
22
</y>
</hint>
<hint
type=
"destinationlabel"
>
<x>
11
6
</x>
<x>
11
4
</x>
<y>
55
</y>
</hint>
</hints>
...
...
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