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
de439a7c
Commit
de439a7c
authored
Jan 11, 2011
by
pixhawk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Working on param slider
parent
50a34cae
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
128 additions
and
82 deletions
+128
-82
QGCParamSlider.cc
src/ui/designer/QGCParamSlider.cc
+79
-24
QGCParamSlider.h
src/ui/designer/QGCParamSlider.h
+10
-0
QGCParamSlider.ui
src/ui/designer/QGCParamSlider.ui
+39
-58
No files found.
src/ui/designer/QGCParamSlider.cc
View file @
de439a7c
...
...
@@ -16,8 +16,22 @@ QGCParamSlider::QGCParamSlider(QWidget *parent) :
ui
(
new
Ui
::
QGCParamSlider
)
{
ui
->
setupUi
(
this
);
endEditMode
();
connect
(
ui
->
doneButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
endEditMode
()));
scaledInt
=
ui
->
valueSlider
->
maximum
()
-
ui
->
valueSlider
->
minimum
();
ui
->
editDoneButton
->
show
();
ui
->
editMaxLabel
->
show
();
ui
->
editMinLabel
->
show
();
ui
->
editNameLineEdit
->
show
();
ui
->
editInstructionsLabel
->
show
();
ui
->
editRefreshParamsButton
->
show
();
ui
->
editSelectParamComboBox
->
show
();
ui
->
editSelectComponentComboBox
->
show
();
ui
->
editStatusLabel
->
show
();
ui
->
editMinSpinBox
->
show
();
ui
->
editMaxSpinBox
->
show
();
ui
->
editTypeComboBox
->
show
();
connect
(
ui
->
editDoneButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
endEditMode
()));
}
QGCParamSlider
::~
QGCParamSlider
()
...
...
@@ -27,31 +41,34 @@ QGCParamSlider::~QGCParamSlider()
void
QGCParamSlider
::
startEditMode
()
{
ui
->
doneButton
->
show
();
ui
->
maxLabel
->
show
();
ui
->
minLabel
->
show
();
ui
->
nameLineEdit
->
show
();
ui
->
instructionsLabel
->
show
();
ui
->
refreshParamsButton
->
show
();
ui
->
selectParamComboBox
->
show
();
ui
->
minSpinBox
->
show
();
ui
->
maxSpinBox
->
show
();
ui
->
typeComboBox
->
show
();
ui
->
editDoneButton
->
show
();
ui
->
editMaxLabel
->
show
();
ui
->
editMinLabel
->
show
();
ui
->
editNameLineEdit
->
show
();
ui
->
editInstructionsLabel
->
show
();
ui
->
editRefreshParamsButton
->
show
();
ui
->
editSelectParamComboBox
->
show
();
ui
->
editSelectComponentComboBox
->
show
();
ui
->
editStatusLabel
->
show
();
ui
->
editMinSpinBox
->
show
();
ui
->
editMaxSpinBox
->
show
();
isInEditMode
=
true
;
}
void
QGCParamSlider
::
endEditMode
()
{
ui
->
doneButton
->
hide
();
ui
->
maxLabel
->
hide
();
ui
->
minLabel
->
hide
();
ui
->
nameLineEdit
->
hide
();
ui
->
instructionsLabel
->
hide
();
ui
->
refreshParamsButton
->
hide
();
ui
->
selectParamComboBox
->
hide
();
ui
->
minSpinBox
->
hide
();
ui
->
maxSpinBox
->
hide
();
ui
->
typeComboBox
->
hide
();
ui
->
editDoneButton
->
hide
();
ui
->
editMaxLabel
->
hide
();
ui
->
editMinLabel
->
hide
();
ui
->
editNameLineEdit
->
hide
();
ui
->
editInstructionsLabel
->
hide
();
ui
->
editRefreshParamsButton
->
hide
();
ui
->
editSelectParamComboBox
->
hide
();
ui
->
editSelectComponentComboBox
->
hide
();
ui
->
editStatusLabel
->
hide
();
ui
->
editMinSpinBox
->
hide
();
ui
->
editMaxSpinBox
->
hide
();
ui
->
editTypeComboBox
->
hide
();
isInEditMode
=
false
;
emit
editingFinished
();
}
...
...
@@ -68,6 +85,21 @@ void QGCParamSlider::sendParameter()
}
}
void
QGCParamSlider
::
setSliderValue
(
int
sliderValue
)
{
parameterValue
=
scaledIntToFloat
(
sliderValue
);
QString
unit
(
""
);
ui
->
valueLabel
->
setText
(
QString
(
"%1 %2"
).
arg
(
parameterValue
,
0
,
'f'
,
3
).
arg
(
unit
));
}
void
QGCParamSlider
::
setParameterValue
(
int
uas
,
int
component
,
QString
parameterName
,
float
value
)
{
parameterValue
=
value
;
QString
unit
(
""
);
ui
->
valueLabel
->
setText
(
QString
(
"%1 %2"
).
arg
(
value
,
0
,
'f'
,
3
).
arg
(
unit
));
ui
->
valueSlider
->
setValue
(
floatToScaledInt
(
value
));
}
void
QGCParamSlider
::
changeEvent
(
QEvent
*
e
)
{
QWidget
::
changeEvent
(
e
);
...
...
@@ -80,12 +112,35 @@ void QGCParamSlider::changeEvent(QEvent *e)
}
}
void
QGCParamSlider
::
writeSettings
(
QSettings
&
settings
)
float
QGCParamSlider
::
scaledIntToFloat
(
int
sliderValue
)
{
return
(((
double
)
sliderValue
)
/
scaledInt
)
*
(
parameterMax
-
parameterMin
);
}
int
QGCParamSlider
::
floatToScaledInt
(
float
value
)
{
return
((
value
-
parameterMin
)
/
(
parameterMax
-
parameterMin
))
*
scaledInt
;
}
void
QGCParamSlider
::
readSettings
(
const
QSettings
&
settings
)
void
QGCParamSlider
::
writeSettings
(
QSettings
&
settings
)
{
settings
.
setValue
(
"TYPE"
,
"SLIDER"
);
settings
.
setValue
(
"QGC_PARAM_SLIDER_DESCRIPTION"
,
ui
->
nameLabel
->
text
());
//settings.setValue("QGC_PARAM_SLIDER_BUTTONTEXT", ui->actionButton->text());
settings
.
setValue
(
"QGC_PARAM_SLIDER_PARAMID"
,
ui
->
editSelectParamComboBox
->
currentText
());
settings
.
setValue
(
"QGC_PARAM_SLIDER_COMPONENTID"
,
ui
->
editSelectComponentComboBox
->
currentText
());
settings
.
setValue
(
"QGC_PARAM_SLIDER_MIN"
,
ui
->
editMinSpinBox
->
value
());
settings
.
setValue
(
"QGC_PARAM_SLIDER_MAX"
,
ui
->
editMaxSpinBox
->
value
());
settings
.
sync
();
}
void
QGCParamSlider
::
readSettings
(
const
QSettings
&
settings
)
{
ui
->
nameLabel
->
setText
(
settings
.
value
(
"QGC_PARAM_SLIDER_DESCRIPTION"
).
toString
());
//settings.setValue("QGC_PARAM_SLIDER_BUTTONTEXT", ui->actionButton->text());
ui
->
editSelectParamComboBox
->
setCurrentText
(
settings
.
value
(
"QGC_PARAM_SLIDER_PARAMID"
).
toString
());
ui
->
editSelectComponentsComboBox
->
setCurrentText
(
settings
.
value
(
"QGC_PARAM_SLIDER_COMPONENTID"
).
toString
());
ui
->
editMinSpinBox
(
settings
.
value
(
"QGC_PARAM_SLIDER_MIN"
).
toFloat
());
ui
->
editMaxSpinBox
(
settings
.
value
(
"QGC_PARAM_SLIDER_MAX"
).
toFloat
());
qDebug
()
<<
"DONE READING SETTINGS"
;
}
src/ui/designer/QGCParamSlider.h
View file @
de439a7c
...
...
@@ -24,6 +24,10 @@ public slots:
void
endEditMode
();
/** @brief Send the parameter to the MAV */
void
sendParameter
();
/** @brief Set the slider value as parameter value */
void
setSliderValue
(
int
sliderValue
);
/** @brief Update the UI with the new parameter value */
void
setParameterValue
(
int
uas
,
int
component
,
QString
parameterName
,
float
value
);
void
writeSettings
(
QSettings
&
settings
);
void
readSettings
(
const
QSettings
&
settings
);
...
...
@@ -34,8 +38,14 @@ protected:
float
parameterMin
;
float
parameterMax
;
int
component
;
///< ID of the MAV component to address
double
scaledInt
;
void
changeEvent
(
QEvent
*
e
);
/** @brief Convert scaled int to float */
float
scaledIntToFloat
(
int
sliderValue
);
int
floatToScaledInt
(
float
value
);
private:
Ui
::
QGCParamSlider
*
ui
;
};
...
...
src/ui/designer/QGCParamSlider.ui
View file @
de439a7c
...
...
@@ -6,8 +6,8 @@
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
4
36
</width>
<height>
1
36
</height>
<width>
4
99
</width>
<height>
1
73
</height>
</rect>
</property>
<property
name=
"windowTitle"
>
...
...
@@ -15,50 +15,21 @@
</property>
<layout
class=
"QGridLayout"
name=
"gridLayout"
>
<item
row=
"1"
column=
"0"
>
<widget
class=
"QLineEdit"
name=
"
nameLineEdit
"
>
<widget
class=
"QLineEdit"
name=
"
editNameLabel
"
>
<property
name=
"text"
>
<string>
Informal Name..
</string>
</property>
</widget>
</item>
<item
row=
"1"
column=
"1"
colspan=
"2"
>
<widget
class=
"QComboBox"
name=
"typeComboBox"
>
<item>
<property
name=
"text"
>
<string>
Float
</string>
</property>
</item>
<item>
<property
name=
"text"
>
<string>
Integer
</string>
</property>
</item>
<item>
<property
name=
"text"
>
<string>
Double
</string>
</property>
</item>
<item>
<property
name=
"text"
>
<string>
Short
</string>
</property>
</item>
<item>
<property
name=
"text"
>
<string>
Byte/Char
</string>
</property>
</item>
</widget>
</item>
<item
row=
"1"
column=
"3"
>
<widget
class=
"QLabel"
name=
"minLabel"
>
<item
row=
"1"
column=
"4"
>
<widget
class=
"QLabel"
name=
"editMinLabel"
>
<property
name=
"text"
>
<string>
Min
</string>
</property>
</widget>
</item>
<item
row=
"1"
column=
"
5
"
>
<widget
class=
"QLabel"
name=
"
m
axLabel"
>
<item
row=
"1"
column=
"
6
"
>
<widget
class=
"QLabel"
name=
"
editM
axLabel"
>
<property
name=
"text"
>
<string>
Max
</string>
</property>
...
...
@@ -78,37 +49,45 @@
</property>
</widget>
</item>
<item
row=
"2"
column=
"
2
"
colspan=
"2"
>
<widget
class=
"QDoubleSpinBox"
name=
"
m
inSpinBox"
/>
<item
row=
"2"
column=
"
3
"
colspan=
"2"
>
<widget
class=
"QDoubleSpinBox"
name=
"
editM
inSpinBox"
/>
</item>
<item
row=
"2"
column=
"
4
"
>
<item
row=
"2"
column=
"
5
"
>
<widget
class=
"QSlider"
name=
"valueSlider"
>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
</widget>
</item>
<item
row=
"2"
column=
"
5
"
>
<widget
class=
"QDoubleSpinBox"
name=
"
m
axSpinBox"
/>
<item
row=
"2"
column=
"
6
"
>
<widget
class=
"QDoubleSpinBox"
name=
"
editM
axSpinBox"
/>
</item>
<item
row=
"
3"
column=
"5
"
>
<widget
class=
"Q
PushButton"
name=
"doneButton
"
>
<item
row=
"
0"
column=
"0"
colspan=
"7
"
>
<widget
class=
"Q
Label"
name=
"editInstructionsLabel
"
>
<property
name=
"text"
>
<string>
Done
</string>
<string>
Please configure the parameter slider now:
</string>
</property>
</widget>
</item>
<item
row=
"3"
column=
"0"
colspan=
"2"
>
<widget
class=
"QComboBox"
name=
"selectParamComboBox"
>
<item>
<property
name=
"text"
>
<string>
Select Parameter..
</string>
</property>
</item>
<item
row=
"5"
column=
"0"
colspan=
"6"
>
<widget
class=
"QLabel"
name=
"editStatusLabel"
>
<property
name=
"text"
>
<string>
TextLabel
</string>
</property>
</widget>
</item>
<item
row=
"3"
column=
"2"
colspan=
"2"
>
<widget
class=
"QPushButton"
name=
"refreshParamsButton"
>
<item
row=
"3"
column=
"0"
colspan=
"3"
>
<widget
class=
"QComboBox"
name=
"editSelectComponentComboBox"
/>
</item>
<item
row=
"5"
column=
"6"
>
<widget
class=
"QPushButton"
name=
"editDoneButton"
>
<property
name=
"text"
>
<string>
Done
</string>
</property>
</widget>
</item>
<item
row=
"3"
column=
"6"
>
<widget
class=
"QPushButton"
name=
"editRefreshParamsButton"
>
<property
name=
"enabled"
>
<bool>
true
</bool>
</property>
...
...
@@ -117,11 +96,13 @@
</property>
</widget>
</item>
<item
row=
"0"
column=
"0"
colspan=
"6"
>
<widget
class=
"QLabel"
name=
"instructionsLabel"
>
<property
name=
"text"
>
<string>
Please configure the parameter slider now:
</string>
</property>
<item
row=
"3"
column=
"4"
colspan=
"2"
>
<widget
class=
"QComboBox"
name=
"editSelectParamComboBox"
>
<item>
<property
name=
"text"
>
<string>
Select Parameter..
</string>
</property>
</item>
</widget>
</item>
</layout>
...
...
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