Commit 869f7c1a authored by Mariano Lizarraga's avatar Mariano Lizarraga
parents 9460d463 42161c97
#include "WaypointGlobalView.h"
#include "ui_WaypointGlobalView.h"
#include <math.h>
WaypointGlobalView::WaypointGlobalView(Waypoint* wp,QWidget *parent) :
QWidget(parent),
ui(new Ui::WaypointGlobalView)
{
ui->setupUi(this);
this->wp = wp;
ui->m_orbitalSpinBox->hide();
connect(ui->m_orbitalSpinBox, SIGNAL(valueChanged(double)), wp, SLOT(setOrbit(double)));
connect(ui->m_heigthSpinBox, SIGNAL(valueChanged(double)), wp, SLOT(setZ(double)));
connect(ui->m_orbitCheckBox, SIGNAL(stateChanged(int)), this, SLOT(changeOrbitalState(int)));
// Read values and set user interface
updateValues();
// connect(m_ui->xSpinBox, SIGNAL(valueChanged(double)), wp, SLOT(setX(double)));
// connect(m_ui->ySpinBox, SIGNAL(valueChanged(double)), wp, SLOT(setY(double)));
// connect(m_ui->zSpinBox, SIGNAL(valueChanged(double)), wp, SLOT(setZ(double)));
// //hidden degree to radian conversion of the yaw angle
// connect(m_ui->yawSpinBox, SIGNAL(valueChanged(int)), this, SLOT(setYaw(int)));
// connect(this, SIGNAL(setYaw(double)), wp, SLOT(setYaw(double)));
// connect(m_ui->upButton, SIGNAL(clicked()), this, SLOT(moveUp()));
// connect(m_ui->downButton, SIGNAL(clicked()), this, SLOT(moveDown()));
// connect(m_ui->removeButton, SIGNAL(clicked()), this, SLOT(remove()));
// connect(m_ui->autoContinue, SIGNAL(stateChanged(int)), this, SLOT(changedAutoContinue(int)));
// connect(m_ui->selectedBox, SIGNAL(stateChanged(int)), this, SLOT(changedCurrent(int)));
//
// connect(m_ui->holdTimeSpinBox, SIGNAL(valueChanged(int)), wp, SLOT(setHoldTime(int)));
}
WaypointGlobalView::~WaypointGlobalView()
{
delete ui;
}
void WaypointGlobalView::updateValues()
{
ui->m_latitudtextEdit->setText(getLatitudString(wp->getY()));
ui->m_longitudtextEdit->setText(getLongitudString(wp->getX()));
ui->idWP_label->setText(QString("%1").arg(wp->getId()));\
}
void WaypointGlobalView::changeEvent(QEvent *e)
{
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}
void WaypointGlobalView::remove()
{
emit removeWaypoint(wp);
delete this;
}
QString WaypointGlobalView::getLatitudString(float latitud)
{
QString tempNS ="";
QString stringLatitudTemp = "";
float minutos = 0;
float grados = 0;
float entero = 0;
float dec = 0;
if (latitud<0){tempNS="S"; latitud = latitud * -1;}
else {tempNS="N";}
if(latitud< 90 || latitud > -90)
{
dec = latitud - (entero = ::floor(latitud));;
minutos = dec * 60;
grados = entero;
if(grados < 0) grados = grados * (-1);
if(minutos < 0) minutos = minutos * (-1);
stringLatitudTemp = QString::number(grados)+ " "+ QString::number(minutos)+"' "+ tempNS;
return stringLatitudTemp;
}
else
{
stringLatitudTemp = "erroneous latitude";
return stringLatitudTemp;
}
}
QString WaypointGlobalView::getLongitudString(float longitud)
{
QString tempEW ="";
QString stringLongitudTemp = "";
float minutos = 0;
float grados = 0;
float entero = 0;
float dec = 0;
if (longitud<0){tempEW="W"; longitud = longitud * -1;}
else {tempEW="E";}
if(longitud<180 || longitud > -180)
{
dec = longitud - (entero = ::floor(longitud));;
minutos = dec * 60;
grados = entero;
if(grados < 0) grados = grados * (-1);
if(minutos < 0) minutos = minutos * (-1);
stringLongitudTemp = QString::number(grados)+ " "+ QString::number(minutos)+"' "+ tempEW;
return stringLongitudTemp;
}
else
{
stringLongitudTemp = "erroneous longitude";
return stringLongitudTemp;
}
}
void WaypointGlobalView::changeOrbitalState(int state)
{
Q_UNUSED(state);
if(ui->m_orbitCheckBox->isChecked())
{
ui->m_orbitalSpinBox->setEnabled(true);
ui->m_orbitalSpinBox->show();
}
else
{
ui->m_orbitalSpinBox->setEnabled(false);
ui->m_orbitalSpinBox->hide();
}
}
#ifndef WAYPOINTGLOBALVIEW_H
#define WAYPOINTGLOBALVIEW_H
#include <QWidget>
#include "Waypoint.h"
namespace Ui {
class WaypointGlobalView;
}
class WaypointGlobalView : public QWidget
{
Q_OBJECT
public:
explicit WaypointGlobalView(Waypoint* wp, QWidget *parent = 0);
~WaypointGlobalView();
public slots:
void updateValues(void);
void remove();
QString getLatitudString(float lat);
QString getLongitudString(float lon);
void changeOrbitalState(int state);
signals:
void removeWaypoint(Waypoint*);
protected:
virtual void changeEvent(QEvent *e);
Waypoint* wp;
private:
Ui::WaypointGlobalView *ui;
private slots:
};
#endif // WAYPOINTGLOBALVIEW_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>WaypointGlobalView</class>
<widget class="QWidget" name="WaypointGlobalView">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>869</width>
<height>60</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<property name="styleSheet">
<string notr="true">QWidget#colorIcon {}
QWidget {
background-color: #252528;
color: #DDDDDF;
border-color: #EEEEEE;
background-clip: border;
}
QCheckBox {
background-color: #252528;
color: #454545;
}
QGroupBox {
border: 1px solid #EEEEEE;
border-radius: 5px;
padding: 0px 0px 0px 0px;
margin-top: 1ex; /* leave space at the top for the title */
margin: 0px;
}
QGroupBox::title {
subcontrol-origin: margin;
subcontrol-position: top center; /* position at the top center */
margin: 0 3px 0px 3px;
padding: 0 3px 0px 0px;
font: bold 8px;
}
QGroupBox#heartbeatIcon {
background-color: red;
}
QDockWidget {
font: bold;
border: 1px solid #32345E;
}
QPushButton {
font-weight: bold;
font-size: 12px;
border: 1px solid #999999;
border-radius: 10px;
min-width:22px;
max-width: 36px;
min-height: 16px;
max-height: 16px;
padding: 2px;
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #777777, stop: 1 #555555);
}
QPushButton:pressed {
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #444444, stop: 1 #555555);
}
QPushButton#landButton {
color: #000000;
background: qlineargradient(x1:0, y1:0, x2:0, y2:1,
stop:0 #ffee01, stop:1 #ae8f00) url(&quot;ICONDIR/control/emergency-button.png&quot;);
}
QPushButton:pressed#landButton {
color: #000000;
background: qlineargradient(x1:0, y1:0, x2:0, y2:1,
stop:0 #bbaa00, stop:1 #a05b00) url(&quot;ICONDIR/control/emergency-button.png&quot;);
}
QPushButton#killButton {
color: #000000;
background: qlineargradient(x1:0, y1:0, x2:0, y2:1,
stop:0 #ffb917, stop:1 #b37300) url(&quot;ICONDIR/control/emergency-button.png&quot;);
}
QPushButton:pressed#killButton {
color: #000000;
background: qlineargradient(x1:0, y1:0, x2:0, y2:1,
stop:0 #bb8500, stop:1 #903000) url(&quot;ICONDIR/control/emergency-button.png&quot;);
}
QProgressBar {
border: 1px solid white;
border-radius: 4px;
text-align: center;
padding: 2px;
color: white;
background-color: #111111;
}
QProgressBar:horizontal {
height: 12px;
}
QProgressBar QLabel {
font-size: 8px;
}
QProgressBar:vertical {
width: 12px;
}
QProgressBar::chunk {
background-color: #656565;
}
QProgressBar::chunk#batteryBar {
background-color: green;
}
QProgressBar::chunk#speedBar {
background-color: yellow;
}
QProgressBar::chunk#thrustBar {
background-color: orange;
}</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string/>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="idWP_label">
<property name="text">
<string>WP_id</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>135</width>
<height>13</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="Latitud_label">
<property name="text">
<string>Lat:</string>
</property>
</widget>
</item>
<item>
<widget class="QTextEdit" name="m_latitudtextEdit">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>120</width>
<height>25</height>
</size>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>50</width>
<height>30</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="Longitud_label">
<property name="text">
<string>Lon:</string>
</property>
</widget>
</item>
<item>
<widget class="QTextEdit" name="m_longitudtextEdit">
<property name="maximumSize">
<size>
<width>120</width>
<height>25</height>
</size>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>50</width>
<height>30</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="height_label">
<property name="text">
<string>Heigth</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="m_heigthSpinBox"/>
</item>
<item>
<widget class="QCheckBox" name="m_orbitCheckBox">
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>69</red>
<green>69</green>
<blue>69</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>37</red>
<green>37</green>
<blue>40</blue>
</color>
</brush>
</colorrole>
<colorrole role="Text">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>69</red>
<green>69</green>
<blue>69</blue>
</color>
</brush>
</colorrole>
<colorrole role="ButtonText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>69</red>
<green>69</green>
<blue>69</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>37</red>
<green>37</green>
<blue>40</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>37</red>
<green>37</green>
<blue>40</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>69</red>
<green>69</green>
<blue>69</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>37</red>
<green>37</green>
<blue>40</blue>
</color>
</brush>
</colorrole>
<colorrole role="Text">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>69</red>
<green>69</green>
<blue>69</blue>
</color>
</brush>
</colorrole>
<colorrole role="ButtonText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>69</red>
<green>69</green>
<blue>69</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>37</red>
<green>37</green>
<blue>40</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>37</red>
<green>37</green>
<blue>40</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>69</red>
<green>69</green>
<blue>69</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>37</red>
<green>37</green>
<blue>40</blue>
</color>
</brush>
</colorrole>
<colorrole role="Text">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>69</red>
<green>69</green>
<blue>69</blue>
</color>
</brush>
</colorrole>
<colorrole role="ButtonText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>69</red>
<green>69</green>
<blue>69</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>37</red>
<green>37</green>
<blue>40</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>37</red>
<green>37</green>
<blue>40</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="text">
<string>Orbital</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="m_orbitalSpinBox">
<property name="enabled">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
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