first commit
This commit is contained in:
378
project/fm_viewer/ui/rm_gps_position.cpp
Normal file
378
project/fm_viewer/ui/rm_gps_position.cpp
Normal file
@@ -0,0 +1,378 @@
|
||||
#include "rm_gps_position.h"
|
||||
#if (MODEL_BBVIEWER)
|
||||
#include <QStyleOption>
|
||||
#include <QPainter>
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include "../data/rm_sensordata.h"
|
||||
#include "../core/rm_player.h"
|
||||
#include "../data/rm_video_item_2ch.h"
|
||||
#include "../core/rm_language.h"
|
||||
|
||||
#if (MODEL_WATEX)
|
||||
RMGPSPosition::RMGPSPosition(QWidget *parent, bool map) : RMWidgetStyleBase(parent,"",false)
|
||||
{
|
||||
setFixedWidth(map ? 350 : 192);
|
||||
//setFixedSize(map ? 240 : 192,map ? 50 : 34);
|
||||
|
||||
QHBoxLayout* layout = new QHBoxLayout(this);
|
||||
ZERO_LAYOUT(layout);
|
||||
layout->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
||||
|
||||
RMLayout::addSpacer(layout,19,0);
|
||||
|
||||
QWidget* iconParent = new QWidget(this);
|
||||
iconParent->setFixedSize(38,55);
|
||||
layout->addWidget(iconParent);
|
||||
QVBoxLayout* iconLayout = new QVBoxLayout(iconParent);
|
||||
iconLayout->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
|
||||
ZERO_LAYOUT(iconLayout);
|
||||
|
||||
QLabel* iconLabel = new QLabel(iconParent);
|
||||
iconLabel->setAlignment(Qt::AlignCenter);
|
||||
iconLabel->setObjectName("title_gps");
|
||||
iconLabel->setText("GPS");
|
||||
iconLabel->setFixedSize(38,18);
|
||||
iconLayout->addWidget(iconLabel);
|
||||
|
||||
gpsIcon = new QLabel(iconParent);
|
||||
gpsIcon->setPixmap(QPixmap(":/image/gps_icon_gps_off.png"));
|
||||
gpsIcon->setFixedSize(38,34);
|
||||
iconLayout->addWidget(gpsIcon);
|
||||
|
||||
RMLayout::addSpacer(layout,19,0);
|
||||
|
||||
lonLatWidget = new QWidget(this);
|
||||
lonLatWidget->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Preferred);
|
||||
lonLatWidget->setFixedWidth(map ? (115*2 + 10) : 115);
|
||||
layout->addWidget(lonLatWidget);
|
||||
layout->addSpacerItem(new QSpacerItem(2,0));
|
||||
|
||||
|
||||
if(map)
|
||||
{
|
||||
QVBoxLayout* layoutV = new QVBoxLayout(lonLatWidget);
|
||||
ZERO_LAYOUT(layoutV);
|
||||
QLabel* latLonLabel = new QLabel(lonLatWidget);
|
||||
latLonLabel->setAlignment(Qt::AlignCenter);
|
||||
latLonLabel->setObjectName("title_gps");
|
||||
latLonLabel->setText(MKU8("\x47\x50\x53\xe5\xba\xa7\xe6\xa8\x99")); // GPS座標
|
||||
latLonLabel->setFixedHeight(18);
|
||||
layoutV->addWidget(latLonLabel);
|
||||
|
||||
QWidget* w = new QWidget(lonLatWidget);
|
||||
layoutV->addWidget(w);
|
||||
QHBoxLayout* lw = new QHBoxLayout(w);
|
||||
ZERO_LAYOUT(lw);
|
||||
|
||||
_addLine(w,lw,true);
|
||||
RMLayout::addSpacer(lw,10,0);
|
||||
_addLine(w,lw,false);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
QVBoxLayout* layoutV = new QVBoxLayout(lonLatWidget);
|
||||
ZERO_LAYOUT(layoutV);
|
||||
QLabel* latLonLabel = new QLabel(lonLatWidget);
|
||||
latLonLabel->setAlignment(Qt::AlignCenter);
|
||||
latLonLabel->setObjectName("title_gps");
|
||||
latLonLabel->setText(MKU8("\x47\x50\x53\xe5\xba\xa7\xe6\xa8\x99")); // GPS座標
|
||||
latLonLabel->setFixedHeight(18);
|
||||
layoutV->addWidget(latLonLabel);
|
||||
|
||||
_addLine(lonLatWidget,layoutV,true);
|
||||
if(map)
|
||||
{
|
||||
layoutV->addSpacerItem(new QSpacerItem(0,6));
|
||||
}
|
||||
_addLine(lonLatWidget,layoutV,false);
|
||||
}
|
||||
_clearLabels();
|
||||
|
||||
_showLabels(false);
|
||||
|
||||
connect(RMPlayer::instance(),SIGNAL(positionChanged(qint64,qint64)),SLOT(onPositionChanged(qint64,qint64)));
|
||||
connect(RMPlayer::instance(),SIGNAL(playEvent(PLAY_EVENT,RMVideoItem*)),SLOT(onPlayEvent(PLAY_EVENT,RMVideoItem*)));
|
||||
}
|
||||
void RMGPSPosition::_addLine(QWidget* parent, QBoxLayout* layout,bool lat)
|
||||
{
|
||||
QWidget* widget = new QWidget(parent);
|
||||
|
||||
widget->setObjectName(lat ? "degree_line0" : "degree_line1");
|
||||
widget->setFixedSize(115,17);
|
||||
layout->addWidget(widget);
|
||||
QHBoxLayout* lineLayout = new QHBoxLayout(widget);
|
||||
ZERO_LAYOUT(lineLayout);
|
||||
|
||||
QLabel* l0 = new QLabel(widget);
|
||||
l0->setObjectName("degree");
|
||||
lineLayout->addWidget(l0);
|
||||
|
||||
l0->setText(lat ? " N" : " E");
|
||||
l0->setFixedSize(42,17);
|
||||
l0->setAlignment(Qt::AlignVCenter);
|
||||
|
||||
QLabel* ld = new QLabel(widget);
|
||||
ld->setObjectName("degree");
|
||||
lineLayout->addWidget(ld);
|
||||
ld->setAlignment(Qt::AlignVCenter | Qt::AlignRight);
|
||||
ld->setFixedSize(35,17);
|
||||
|
||||
QLabel* lm = new QLabel(widget);
|
||||
lm->setObjectName("degree");
|
||||
lineLayout->addWidget(lm);
|
||||
//lm->setText("'");
|
||||
lm->setAlignment(Qt::AlignVCenter | Qt::AlignRight);
|
||||
lm->setFixedWidth(22);
|
||||
|
||||
QLabel* ls = new QLabel(widget);
|
||||
ls->setObjectName("degree");
|
||||
lineLayout->addWidget(ls);
|
||||
//ls->setText("\"");
|
||||
ls->setAlignment(Qt::AlignVCenter | Qt::AlignRight);
|
||||
ls->setFixedWidth(25);
|
||||
|
||||
if(lat)
|
||||
{
|
||||
latLabel = l0;
|
||||
latLabelD = ld;
|
||||
latLabelM = lm;
|
||||
latLabelS = ls;
|
||||
}
|
||||
else
|
||||
{
|
||||
lonLabel = l0;
|
||||
lonLabelD = ld;
|
||||
lonLabelM = lm;
|
||||
lonLabelS = ls;
|
||||
}
|
||||
|
||||
}
|
||||
#else
|
||||
RMGPSPosition::RMGPSPosition(QWidget *parent, bool map) : RMWidgetStyleBase(parent,"",false)
|
||||
{
|
||||
setObjectName("all_border_dark");
|
||||
setFixedSize(map ? 240 : 192,map ? 50 : 34);
|
||||
|
||||
QHBoxLayout* layout = new QHBoxLayout(this);
|
||||
layout->setMargin(0);
|
||||
layout->setSpacing(0);
|
||||
layout->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
||||
|
||||
layout->addSpacerItem(new QSpacerItem(5,0));
|
||||
|
||||
gpsIcon = new QLabel(this);
|
||||
gpsIcon->setPixmap(QPixmap(":/image/gps_icon_gps_off.png"));
|
||||
layout->addWidget(gpsIcon);
|
||||
|
||||
layout->addSpacerItem(new QSpacerItem(2,0));
|
||||
|
||||
lonLatWidget = new QWidget(this);
|
||||
lonLatWidget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
|
||||
layout->addWidget(lonLatWidget);
|
||||
layout->addSpacerItem(new QSpacerItem(2,0));
|
||||
|
||||
//ll->setObjectName("test_widget");
|
||||
|
||||
//
|
||||
QVBoxLayout* layoutV = new QVBoxLayout(lonLatWidget);
|
||||
layoutV->setSpacing(0);
|
||||
layoutV->setMargin(0);
|
||||
|
||||
_addLine(lonLatWidget,layoutV,true);
|
||||
if(map)
|
||||
{
|
||||
layoutV->addSpacerItem(new QSpacerItem(0,6));
|
||||
}
|
||||
_addLine(lonLatWidget,layoutV,false);
|
||||
_clearLabels();
|
||||
|
||||
lonLatWidget->setHidden(true);
|
||||
|
||||
connect(RMPlayer::instance(),SIGNAL(positionChanged(qint64,qint64)),SLOT(onPositionChanged(qint64,qint64)));
|
||||
connect(RMPlayer::instance(),SIGNAL(playEvent(PLAY_EVENT,RMVideoItem*)),SLOT(onPlayEvent(PLAY_EVENT,RMVideoItem*)));
|
||||
}
|
||||
void RMGPSPosition::_addLine(QWidget* parent, QVBoxLayout* layout,bool lat)
|
||||
{
|
||||
QWidget* widget = new QWidget(parent);
|
||||
//widget->setObjectName("test_widget");
|
||||
layout->addWidget(widget);
|
||||
QHBoxLayout* lineLayout = new QHBoxLayout(widget);
|
||||
lineLayout->setMargin(0);
|
||||
lineLayout->setSpacing(0);
|
||||
|
||||
QLabel* l0 = new QLabel(widget);
|
||||
l0->setObjectName("degree");
|
||||
lineLayout->addWidget(l0);
|
||||
|
||||
QString jp = lat ? MKU8("\xe7\xb7\xaf\xe5\xba\xa6 \x3a \x4e") : MKU8("\xe7\xb5\x8c\xe5\xba\xa6 \x3a \x45");
|
||||
QString en = lat ? "Lat : N" : "Lon : E";
|
||||
|
||||
// 緯度(\xe7\xb7\xaf\xe5\xba\xa6),위도
|
||||
// 経度(\xe7\xb5\x8c\xe5\xba\xa6),경도
|
||||
l0->setText(RMLanguage::instance()->isJP() ? jp : en);
|
||||
l0->setFixedWidth(60);
|
||||
|
||||
RMLanguage::instance()->append(RMLanguage::LANGUAGE_JP,RMLanguage::TITLE_TEXT,l0,jp);
|
||||
#if !(LANGUAGE_REMOVE_ENG) // WATEX
|
||||
RMLanguage::instance()->append(RMLanguage::LANGUAGE_EN,RMLanguage::TITLE_TEXT,l0,en);
|
||||
#endif
|
||||
QLabel* ld = new QLabel(widget);
|
||||
ld->setObjectName("degree");
|
||||
lineLayout->addWidget(ld);
|
||||
//ld->setText(QString::fromUtf8("\xc2\xb0"));
|
||||
ld->setAlignment(Qt::AlignVCenter | Qt::AlignRight);
|
||||
ld->setFixedWidth(45);
|
||||
|
||||
QLabel* lm = new QLabel(widget);
|
||||
lm->setObjectName("degree");
|
||||
lineLayout->addWidget(lm);
|
||||
//lm->setText("'");
|
||||
lm->setAlignment(Qt::AlignVCenter | Qt::AlignRight);
|
||||
lm->setFixedWidth(22);
|
||||
|
||||
QLabel* ls = new QLabel(widget);
|
||||
ls->setObjectName("degree");
|
||||
lineLayout->addWidget(ls);
|
||||
//ls->setText("\"");
|
||||
ls->setAlignment(Qt::AlignVCenter | Qt::AlignRight);
|
||||
ls->setFixedWidth(25);
|
||||
|
||||
if(lat)
|
||||
{
|
||||
latLabel = l0;
|
||||
latLabelD = ld;
|
||||
latLabelM = lm;
|
||||
latLabelS = ls;
|
||||
}
|
||||
else
|
||||
{
|
||||
lonLabel = l0;
|
||||
lonLabelD = ld;
|
||||
lonLabelM = lm;
|
||||
lonLabelS = ls;
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (MODEL_WATEX)
|
||||
void RMGPSPosition::_showLabels(bool bShow)
|
||||
{
|
||||
latLabel->setHidden(!bShow);
|
||||
latLabelD->setHidden(!bShow);
|
||||
latLabelM->setHidden(!bShow);
|
||||
latLabelS->setHidden(!bShow);
|
||||
|
||||
lonLabel->setHidden(!bShow);
|
||||
lonLabelD->setHidden(!bShow);
|
||||
lonLabelM->setHidden(!bShow);
|
||||
lonLabelS->setHidden(!bShow);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void RMGPSPosition::onPositionChanged(qint64 position,qint64 duration)
|
||||
{
|
||||
if(_sensor != NULL)
|
||||
{
|
||||
double ratio = ((double)position) / ((double)duration);
|
||||
|
||||
double lonX = 0;
|
||||
double latY = 0;
|
||||
double speed = 0;
|
||||
_sensor->getGPSPosition(ratio,&lonX,&latY,&speed);
|
||||
#if (FORCE_VALID_LOCATION)
|
||||
if(TRUE)
|
||||
#else
|
||||
if(IS_VALID_LOCATION(lonX,latY))
|
||||
#endif
|
||||
{
|
||||
int d = (int)latY;
|
||||
latLabelD->setText(QString().sprintf("%d",d) + QString::fromUtf8("\xc2\xb0"));
|
||||
int m = (int)((latY * 60.0) - (d * 60));
|
||||
latLabelM->setText(QString().sprintf("%d'",m));
|
||||
int s = (int)((latY * 3600.0) - (d * 3600) - (m * 60));
|
||||
latLabelS->setText(QString().sprintf("%d\"",s));
|
||||
|
||||
d = (int)lonX;
|
||||
lonLabelD->setText(QString().sprintf("%d",d) + QString::fromUtf8("\xc2\xb0"));
|
||||
m = (int)((lonX * 60.0) - (d * 60));
|
||||
lonLabelM->setText(QString().sprintf("%d'",m));
|
||||
s = (int)((lonX * 3600.0) - (d * 3600) - (m * 60));
|
||||
lonLabelS->setText(QString().sprintf("%d\"",s));
|
||||
}
|
||||
else
|
||||
{
|
||||
_clearLabels();
|
||||
}
|
||||
}
|
||||
}
|
||||
void RMGPSPosition::_clearLabels()
|
||||
{
|
||||
latLabelD->setText(QString::fromUtf8("\xc2\xb0"));
|
||||
latLabelM->setText("'");
|
||||
latLabelS->setText("\"");
|
||||
|
||||
lonLabelD->setText(QString::fromUtf8("\xc2\xb0"));
|
||||
lonLabelM->setText("'");
|
||||
lonLabelS->setText("\"");
|
||||
|
||||
}
|
||||
void RMGPSPosition::onPlayEvent(PLAY_EVENT event,RMVideoItem* item)
|
||||
{
|
||||
// 사용자 STOP 일 경우 PLAY ITEM CLEAR
|
||||
// if(event == PLAY_DID_CLEARED || event == PLAY_DID_LOADED)
|
||||
if(event == PLAY_DID_LOADED) {
|
||||
|
||||
_sensor = item->getSensorData();
|
||||
|
||||
QString pixmap = ":/image/gps_icon_gps_off.png";
|
||||
if(item->getSensorData() != NULL && item->getSensorData()->getGPSCount() > 0)
|
||||
{
|
||||
pixmap = ":/image/gps_icon_gps_on.png";
|
||||
#if (MODEL_WATEX)
|
||||
_showLabels(true);
|
||||
#else
|
||||
lonLatWidget->setHidden(false);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#if (MODEL_WATEX)
|
||||
_showLabels(false);
|
||||
#else
|
||||
lonLatWidget->setHidden(true);
|
||||
#endif
|
||||
}
|
||||
gpsIcon->setPixmap(QPixmap(pixmap));
|
||||
}
|
||||
else if (event == PLAY_DID_CLEARED)
|
||||
{
|
||||
_sensor = NULL;
|
||||
}
|
||||
else if (event == PLAY_DID_USER_STOP)
|
||||
{
|
||||
_sensor = NULL;
|
||||
#if (MODEL_WATEX)
|
||||
_showLabels(false);
|
||||
#else
|
||||
lonLatWidget->setHidden(true);
|
||||
#endif
|
||||
_clearLabels();
|
||||
gpsIcon->setPixmap(QPixmap(":/image/gps_icon_gps_off.png"));
|
||||
}
|
||||
}
|
||||
void RMGPSPosition::paintEvent(QPaintEvent *pe)
|
||||
{
|
||||
Q_UNUSED(pe);
|
||||
QStyleOption o;
|
||||
o.initFrom(this);
|
||||
QPainter painter(this);
|
||||
style()->drawPrimitive(QStyle::PE_Widget, &o, &painter, this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif // #if (MODEL_BBVIEWER)
|
||||
Reference in New Issue
Block a user