Commit 309fbf58 authored by Michael Carpenter's avatar Michael Carpenter

Addition of new RadioChannel displays for radio calibration

parent e72400d1
......@@ -384,6 +384,7 @@ HEADERS += src/MG.h \
src/ui/uas/UASQuickViewItemSelect.h \
src/ui/uas/UASQuickViewTextItem.h \
src/ui/uas/UASActionsWidget.h \
src/ui/designer/QGCRadioChannelDisplay.h \
src/ui/QGCTabbedInfoView.h \
src/ui/UASRawStatusView.h
......@@ -557,6 +558,7 @@ SOURCES += src/main.cc \
src/ui/uas/UASQuickViewTextItem.cc \
src/ui/uas/UASQuickViewItemSelect.cc \
src/ui/uas/UASActionsWidget.cpp \
src/ui/designer/QGCRadioChannelDisplay.cpp \
src/ui/QGCTabbedInfoView.cpp \
src/ui/UASRawStatusView.cpp
......
......@@ -122,21 +122,38 @@ Config</string>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="page">
<layout class="QVBoxLayout" name="verticalLayout_15">
<item>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>9</x>
<y>9</y>
<width>68</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>RC Calibration</string>
</property>
</widget>
</item>
<item>
<widget class="QGCRadioChannelDisplay" name="widget" native="true">
<property name="geometry">
<rect>
<x>270</x>
<y>410</y>
<width>51</width>
<height>211</height>
</rect>
</property>
</widget>
<widget class="QWidget" name="">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QComboBox" name="rcTypeComboBox">
......@@ -181,21 +198,8 @@ Config</string>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
</widget>
<widget class="QWidget" name="">
<layout class="QGridLayout" name="gridLayout_2">
<item row="2" column="1">
<widget class="QLabel" name="chanLabel_3">
......@@ -522,8 +526,8 @@ Config</string>
</widget>
</item>
</layout>
</item>
<item>
</widget>
<widget class="QWidget" name="">
<layout class="QHBoxLayout" name="horizontalLayout_14">
<item>
<layout class="QGridLayout" name="gridLayout_3">
......@@ -738,21 +742,7 @@ Config</string>
</layout>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
<widget class="QWidget" name="page_2">
<layout class="QVBoxLayout" name="verticalLayout_14">
......@@ -788,8 +778,8 @@ p, li { white-space: pre-wrap; }
<rect>
<x>0</x>
<y>0</y>
<width>98</width>
<height>28</height>
<width>20</width>
<height>20</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_10">
......@@ -863,8 +853,8 @@ p, li { white-space: pre-wrap; }
<rect>
<x>0</x>
<y>0</y>
<width>98</width>
<height>28</height>
<width>16</width>
<height>16</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
......@@ -900,8 +890,8 @@ p, li { white-space: pre-wrap; }
<rect>
<x>0</x>
<y>0</y>
<width>98</width>
<height>28</height>
<width>16</width>
<height>16</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5">
......@@ -979,8 +969,8 @@ p, li { white-space: pre-wrap; }
<rect>
<x>0</x>
<y>0</y>
<width>98</width>
<height>28</height>
<width>16</width>
<height>16</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
......@@ -1016,8 +1006,8 @@ p, li { white-space: pre-wrap; }
<rect>
<x>0</x>
<y>0</y>
<width>98</width>
<height>28</height>
<width>16</width>
<height>16</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
......@@ -1040,8 +1030,6 @@ p, li { white-space: pre-wrap; }
</widget>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QLabel" name="statusLabel">
<property name="text">
......@@ -1287,6 +1275,14 @@ p, li { white-space: pre-wrap; }
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QGCRadioChannelDisplay</class>
<extends>QWidget</extends>
<header>ui/designer/QGCRadioChannelDisplay.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../../qgroundcontrol.qrc"/>
</resources>
......
#include "QGCRadioChannelDisplay.h"
#include <QPainter>
QGCRadioChannelDisplay::QGCRadioChannelDisplay(QWidget *parent) : QWidget(parent)
{
m_showMinMax = true;
m_min = 500;
m_max = 1600;
m_value = 1500;
m_orientation = Qt::Vertical;
m_name = "Yaw";
}
void QGCRadioChannelDisplay::setOrientation(Qt::Orientation orient)
{
m_orientation = orient;
update();
}
void QGCRadioChannelDisplay::paintEvent(QPaintEvent *event)
{
//Values range from 0-3000.
//1500 is the middle, static servo value.
QPainter painter(this);
if (m_orientation == Qt::Vertical)
{
painter.drawRect(0,0,width()-1,(height()-1) - (painter.fontMetrics().height() * 2));
painter.setBrush(Qt::SolidPattern);
painter.setPen(QColor::fromRgb(50,255,50));
int newval = (height()-2) * ((float)m_value / 3000.0);
painter.drawRect(1,newval,width()-3,((height()-2) - newval) - (painter.fontMetrics().height() * 2));
}
else
{
painter.drawRect(0,0,width()-1,(height()-1) - (painter.fontMetrics().height() * 2));
painter.setBrush(Qt::SolidPattern);
painter.setPen(QColor::fromRgb(50,255,50));
painter.drawRect(1,1,(width()-1) * ((float)m_value / 3000.0),(height()-3) - (painter.fontMetrics().height() * 2));
painter.setPen(QColor::fromRgb(255,255,255));
QString valstr = QString::number(m_value);
painter.drawText((width()/2.0) - (painter.fontMetrics().width(m_name)/2.0),((height()-3) - (painter.fontMetrics().height()*1)),m_name);
painter.drawText((width()/2.0) - (painter.fontMetrics().width(valstr)/2.0),((height()-3) - (painter.fontMetrics().height() * 0)),valstr);
if (m_showMinMax)
{
painter.setBrush(Qt::NoBrush);
painter.setPen(QColor::fromRgb(255,0,0));
painter.drawRect(width() * ((float)m_min / 3000.0),2,((width()-1) * ((float)m_max / 3000.0)) - (width() * ((float)m_min / 3000.0)),(height()-5) - (painter.fontMetrics().height() * 2));
QString minstr = QString::number(m_min);
painter.drawText((width() * ((float)m_min / 3000.0)) - (painter.fontMetrics().width("min")/2.0),((height()-3) - (painter.fontMetrics().height()*1)),"min");
painter.drawText((width() * ((float)m_min / 3000.0)) - (painter.fontMetrics().width(minstr)/2.0),((height()-3) - (painter.fontMetrics().height() * 0)),minstr);
QString maxstr = QString::number(m_max);
painter.drawText((width() * ((float)m_max / 3000.0)) - (painter.fontMetrics().width("max")/2.0),((height()-3) - (painter.fontMetrics().height()*1)),"max");
painter.drawText((width() * ((float)m_max / 3000.0)) - (painter.fontMetrics().width(maxstr)/2.0),((height()-3) - (painter.fontMetrics().height() * 0)),maxstr);
}
}
}
void QGCRadioChannelDisplay::setValue(int value)
{
m_value = value;
update();
}
void QGCRadioChannelDisplay::showMinMax()
{
m_showMinMax = true;
update();
}
void QGCRadioChannelDisplay::hideMinMax()
{
m_showMinMax = false;
update();
}
void QGCRadioChannelDisplay::setMin(int value)
{
m_min = value;
update();
}
void QGCRadioChannelDisplay::setMax(int value)
{
m_max = value;
update();
}
#ifndef QGCRADIOCHANNELDISPLAY_H
#define QGCRADIOCHANNELDISPLAY_H
#include <QWidget>
class QGCRadioChannelDisplay : public QWidget
{
Q_OBJECT
public:
explicit QGCRadioChannelDisplay(QWidget *parent = 0);
void setOrientation(Qt::Orientation orient);
void setValue(int value);
void showMinMax();
void hideMinMax();
void setMin(int value);
void setMax(int value);
int value() { return m_value; }
int min() { return m_min; }
int max() { return m_max; }
protected:
void paintEvent(QPaintEvent *event);
private:
Qt::Orientation m_orientation;
int m_value;
int m_min;
int m_max;
bool m_showMinMax;
QString m_name;
signals:
public slots:
};
#endif // QGCRADIOCHANNELDISPLAY_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment