#include "fm_frame_gps.h" #include "fm_layer.h" #if (USE_FRAME_GPS) #include "../data/rm_video_item_2ch.h" #include "../data/rm_sensordata.h" #include "../core/fm_strings.h" #include "../core/rm_player.h" #include "fm_colors.h" #include #include #define NULL_GPS_COORDINATE "--.------" FMFrameGPS::FMFrameGPS(QWidget *parent) : QWidget(parent) { FMWidgetBorder(this,"frame_gps",0x666666); layout = new QHBoxLayout(this); layout->setAlignment(Qt::AlignVCenter); ZERO_LAYOUT(layout); // QWidget* sw = new QWidget(this); // layout->addWidget(sw); // QHBoxLayout* swl = new QHBoxLayout(sw); // ZERO_LAYOUT(swl); // swl->setAlignment(Qt::AlignVCenter | Qt::AlignLeading); // swl->setContentsMargins(10,0,0,0); // speed = new QLabel(sw); // swl->addWidget(speed); // speed->setStyleSheet("font-family: Arial;font-size: 13px; color : #BBBBBB"); // speed->setText("---"); // QLabel* kmh = new QLabel(sw); // swl->addWidget(kmh); // kmh->setStyleSheet("font-family: Arial; font-size: 11px; color : #BBBBBB"); // kmh->setText(" km/h"); // LAYOUT_SPACE(swl,8,0); // QLabel* speedWarning = new QLabel(sw); // speedWarning->setText(FMS::txt("speed_warning")); // speedWarning->setStyleSheet("font-family: Arial; font-size: 12px; color : #c59433"); // swl->addWidget(speedWarning); //QWidget* locw = new QWidget(this); //layout->addWidget(locw); //QHBoxLayout* locwl = new QHBoxLayout(locw); //ZERO_LAYOUT(locwl); //locwl->setAlignment(Qt::AlignVCenter); //layout->setAlignment(Qt::AlignVCenter); //ZERO_LAYOUT(layout); layout->setContentsMargins(10,0,0,0); layout->setSpacing(10); QSize bs = QSize(50,18); QLabel* lb = new QLabel(this); lb->setAlignment(Qt::AlignCenter); FMLabelBackground(lb,"lonlat_title","MS PGothic",FM_SELECTED_TEXT_COLOR,12,false,0x3c3c3c); layout->addWidget(lb); lb->setFixedSize(bs); lb->setText(FMS::txt("lat")); lat = new QLabel(this); FMLabel(lat,"lonlat_label","Arial",0xf5f5f5,13,false); lat->setText(NULL_GPS_COORDINATE); layout->addWidget(lat); lb = new QLabel(this); lb->setText(FMS::txt("lon")); lb->setFixedSize(bs); lb->setAlignment(Qt::AlignCenter); FMLabelBackground(lb,"lonlat_title","MS PGothic",FM_SELECTED_TEXT_COLOR,12,false,0x3c3c3c); layout->addWidget(lb); lon = new QLabel(this); FMLabel(lon,"lonlat_label","Arial",0xf5f5f5,13,false); lon->setText(NULL_GPS_COORDINATE); layout->addWidget(lon); _sensor = NULL; 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 FMFrameGPS::onPositionChanged(qint64 position,qint64 duration) { if(_sensor != NULL) { double ratio = ((double)position) / ((double)duration); double lonV,latV; if(_sensor->getGPSCoord(ratio,&latV,&lonV)) { lon->setText(QString().sprintf("%.06f",latV)); lat->setText(QString().sprintf("%.06f",lonV)); } else { lon->setText(NULL_GPS_COORDINATE); lat->setText(NULL_GPS_COORDINATE); } // int rspd = _sensor->getGPSSpeed(ratio); // if(rspd >= 0 && rspd < 500) // { // speed->setText(QString().sprintf("%03d",rspd)); // } // else // { // speed->setText("---"); // } } } void FMFrameGPS::onPlayEvent(PLAY_EVENT event,RMVideoItem* item) { // 사용자 STOP 일 경우 PLAY ITEM CLEAR // if(event == PLAY_DID_CLEARED || event == PLAY_DID_LOADED) if(event == PLAY_DID_LOADED) { if(item->getSensorData() != NULL && item->getSensorData()->getGPSCount() > 0) { _sensor = item->getSensorData(); } else { _sensor = NULL; lon->setText(NULL_GPS_COORDINATE); lat->setText(NULL_GPS_COORDINATE); } } else if (event == PLAY_DID_CLEARED) { _sensor = NULL; // speed->setText("---"); } else if (event == PLAY_DID_USER_STOP) { lon->setText(NULL_GPS_COORDINATE); lat->setText(NULL_GPS_COORDINATE); } } void FMFrameGPS::paintEvent(QPaintEvent *pe) { Q_UNUSED(pe); QStyleOption o; o.initFrom(this); QPainter p(this); style()->drawPrimitive(QStyle::PE_Widget, &o, &p, this); } #endif // #if (USE_FRAME_GPS)