Skip to content
Permalink
Browse files

radar labels

  • Loading branch information...
taran
taran committed Apr 16, 2019
1 parent d62f995 commit 47b38071edda7e49f62eb8d9b66918c10bb521c0
Showing with 84 additions and 20 deletions.
  1. +10 −5 SWindow.cpp
  2. +1 −0 SWindow.h
  3. +0 −14 ogl/GLSatWidget.cpp
  4. +1 −1 ogl/GLSatWidget.h
  5. +68 −0 ogl/RadarWidget.cpp
  6. +4 −0 ogl/RadarWidget.h
@@ -16,7 +16,7 @@ SWindow::SWindow(SatViewer *satviewer) {

m_satviewer = satviewer;
language = tr("English");

labelLoc.setMinimumWidth(32);
labelSat.setMinimumWidth(32);
labelLoc.setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
@@ -104,12 +104,12 @@ SWindow::SWindow(SatViewer *satviewer) {
this, SLOT(setSwlVars(Satellite*, Location*, double*)));
// readSettings();
// enumSatModelList();

radarWidget = new RadarWidget(satviewer, this);
radarWidget->resize(512, 512);
radarWidget->move(128, 128);
radarWidget->setWindowFlag(Qt::Window);
radarWidget->show();
radarWidget->move(0, 0);
// radarWidget->setWindowFlags(Qt::Tool);
// radarWidget->show();
QTimer::singleShot(0, this, SLOT(onStart()));
}

SWindow::~SWindow() {
@@ -319,6 +319,11 @@ void SWindow::addZRVMessage(QString text) {
dlgOptions->getWidget()->textZRVList->append(msg);
}

void SWindow::onStart() {
// radarWidget->setWindowFlags(Qt::Tool);
// radarWidget->show();
}

void SWindow::onTimer() {
if (widget.tlBtnTime->isChecked()) {
time = widget.dateTimeEdit->dateTime().toTime_t();
@@ -56,6 +56,7 @@ private slots:
void onTimeTypeChanged(int index);
void addZRVMessage(QString text);
void checkVersion(bool checked);
void onStart();
void onTimer();
void onPlayClick();
void onTimeClick();
@@ -479,20 +479,6 @@ void GLSatWidget::writeSettings(QSettings *settings) {
settings->setValue("cylindrical/mapY" , ui.spinY->value ());
}

//void GLSatWidget::addSat(Satellite *sat) {
// GLSatAbstractWidget::addSat(sat);
// if (sat->satWObject == nullptr) {
// setIcon(sat);
// }
//}
//
//void GLSatWidget::addLoc(Location* loc) {
// GLSatAbstractWidget::addLoc(loc);
// if (loc->satWObject == nullptr) {
// setIcon(loc);
// }
//}

void GLSatWidget::setIcon(Satellite *sat, const QString& fileName) {
if (sat->satWObject != nullptr) {
delete sat->satWObject;
@@ -58,7 +58,7 @@ class GLSatWidget : public GLSatAbstractWidget {
bool testShadow(Satellite *sat, Satellite *sun);

protected:
void paintEvent(QPaintEvent *event) override;
void paintEvent(QPaintEvent *event) override;

private slots:
void btnColorClicked();
@@ -5,6 +5,8 @@
* Created on April 13, 2019, 6:58 PM
*/

#include <QPainter>

#include "RadarWidget.h"
#include "../models/sun/sunmodel.h"

@@ -181,3 +183,69 @@ void RadarWidget::compileSunList() {

glEndList();
}

void RadarWidget::paintEvent(QPaintEvent *event) {
GLSatAbstractWidget::paintEvent(event);

Location *loc = m_satviewer->currentLocation();
if (loc == nullptr) {
return;
}

QPainter painter(this);
// painter.setPen(clrNetFont);
// painter.setFont(fntNet);
// painter.setCompositionMode(QPainter::CompositionMode_Screen); // TODO
painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing);

int w = width();
int h = height();
double aerv[4];
GLfloat px, py;

// double dx = width() / 12.0;
// double dy = height() / 6.0;
//
// QFontMetrics fm(fntNet);
// int bw = fm.width("00");
// int bh = fm.height();
//
// for (int i = 1; i < 6; i++) {
// painter.drawText(0 , dy * i, QString().number(abs(i * 30 - 90)));
// painter.drawText(w - bw, dy * i, QString().number(abs(i * 30 - 90)));
// }
//
// for (int i = 1; i < 12; i++) {
// painter.drawText(dx * i, bh, QString().number(abs(i * 30 - 180)));
// painter.drawText(dx * i, h, QString().number(abs(i * 30 - 180)));
// }

for (const auto& sat : m_satviewer->satellites()) {
if (sat->isVisibleLabel()) {
painter.setPen(sat->colorLabel());
painter.setFont(sat->font());

SatViewer::aerv(loc->rg(), sat->rg(), aerv);
if (aerv[1] >= 0.0) {
polar2ortho(aerv[0], aerv[1], px, py);
double dx = 0.5 * w * (1.0 + px) + sat->nameX();
double dy = 0.5 * h * (1.0 + py) - sat->nameY();
painter.drawText(dx, dy, sat->name());
}
}
}

// for (const auto& loc : m_satviewer->locations()) {
// if (loc->isVisibleLabel()) {
// painter.setPen(loc->colorLabel());
// painter.setFont(loc->font());
//
// double dx = 0.5 * w * (1.0 + loc->longitude() / 180.0) + loc->nameX();
// double dy = h * (0.5 - loc->latitude() / 180.0) - loc->nameY();
//
// painter.drawText(dx, dy, loc->name());
// }
// }

painter.end();
}
@@ -17,6 +17,10 @@ class RadarWidget : public GLSatAbstractWidget {
RadarWidget(SatViewer *satviewer, QWidget *parent = nullptr);
// RadarWidget(const RadarWidget& orig);
virtual ~RadarWidget();

protected:
void paintEvent(QPaintEvent *event);

private:
GLSprite sprite_current, sprite_sun;
void initializeGL();

0 comments on commit 47b3807

Please sign in to comment.
You can’t perform that action at this time.