Skip to content
Permalink
Browse files

radar

  • Loading branch information...
ri
ri committed Apr 13, 2019
1 parent 00aaaab commit 92153f313b3470018531ac29dba1d41c6256881f
Showing with 216 additions and 125 deletions.
  1. +21 −12 SLocDialog.cpp
  2. +3 −0 SLocDialog.h
  3. +16 −12 dialogs/sgp4/Sgp4Dialog.cpp
  4. +1 −0 dialogs/sgp4/Sgp4Dialog.h
  5. +6 −6 ogl/GLSatAbstractWidget.h
  6. +54 −24 ogl/GLSatWidget.cpp
  7. +1 −1 ogl/GLSatWidget.h
  8. +1 −1 ogl/GLSatWidget3d.h
  9. +18 −0 ogl/RadarWidget.cpp
  10. +21 −0 ogl/RadarWidget.h
  11. +74 −69 satviewer.pro
@@ -11,16 +11,19 @@
#include <QtMath>

SLocDialog::SLocDialog(GLSatAbstractWidget *satWidget) {
m_loc = NULL;
widget.setupUi(this);
setSatWidget(satWidget);

widget.lineEditAzimuth->setValidator(new QDoubleValidator());
widget.lineEditHeight->setValidator (new QDoubleValidator());
widget.lineEditLat->setValidator (new QDoubleValidator());
widget.lineEditLon->setValidator (new QDoubleValidator());
widget.lineEditRange->setValidator (new QDoubleValidator());
widget.lineEditWidth->setValidator (new QDoubleValidator());
m_loc = nullptr;

setSatWidget(satWidget);

m_doubleValidator.setLocale(QLocale::C);
widget.lineEditAzimuth->setValidator(&m_doubleValidator);
widget.lineEditHeight->setValidator (&m_doubleValidator);
widget.lineEditLat->setValidator (&m_doubleValidator);
widget.lineEditLon->setValidator (&m_doubleValidator);
widget.lineEditRange->setValidator (&m_doubleValidator);
widget.lineEditWidth->setValidator (&m_doubleValidator);

connect(widget.btnColorName , SIGNAL(clicked()), this, SLOT(setColorLocName ()));
connect(widget.btnColorZrv , SIGNAL(clicked()), this, SLOT(setColorLocZrv ()));
@@ -48,7 +51,7 @@ uint32_t SLocDialog::flipRgb(uint32_t rgb) {
void SLocDialog::showEvent(QShowEvent * event) {
Q_UNUSED(event)

if (m_loc == NULL) {
if (m_loc == nullptr) {
return;
}

@@ -92,10 +95,16 @@ void SLocDialog::showEvent(QShowEvent * event) {
}

void SLocDialog::makeLoc(Location *loc) {
if (loc == NULL) return;

if (loc == nullptr) {
return;
}

setLoc(loc);
if (exec() == QDialog::Rejected) return;

if (exec() == QDialog::Rejected) {
return;
}

double lat = widget.lineEditLat->text().toDouble();
double lon = widget.lineEditLon->text().toDouble();
@@ -182,7 +191,7 @@ void SLocDialog::setIcon() {
this,
"Open PNG Image",
dir.path(),
"PNG Images (*.png)", NULL,
"PNG Images (*.png)", nullptr,
QFileDialog::DontUseNativeDialog);
if (!filePath.isEmpty()) {
widget.btnIcon->setIcon(QPixmap(filePath));
@@ -15,6 +15,8 @@
#include <QFileDialog>
#include <QFontDialog>
#include <QColorDialog>
#include <QValidator>

#include "locutils/Location.h"
#include "ogl/GLSatAbstractWidget.h"

@@ -37,6 +39,7 @@ class SLocDialog: public QDialog {
Ui::LocDialog widget;
Location *m_loc;
GLSatAbstractWidget *satWidget;
QDoubleValidator m_doubleValidator;
void setBtnColor(QWidget *widget);
uint32_t flipRgb(uint32_t rgb);

@@ -16,15 +16,19 @@

Sgp4Dialog::Sgp4Dialog(GLSatAbstractWidget *satWidget) {
widget.setupUi(this);
widget.lineEditBStar->setValidator(new QDoubleValidator());
widget.lineEditE->setValidator (new QDoubleValidator());
widget.lineEditI->setValidator (new QDoubleValidator());
widget.lineEditM0->setValidator (new QDoubleValidator());
widget.lineEditN->setValidator (new QDoubleValidator());
widget.lineEditOmg->setValidator (new QDoubleValidator());
widget.lineEditTime->setValidator (new QDoubleValidator());
widget.lineEditW->setValidator (new QDoubleValidator());
m_sat = 0;

m_sat = nullptr;

m_doubleValidator.setLocale(QLocale::C);
widget.lineEditBStar->setValidator(&m_doubleValidator);
widget.lineEditE->setValidator (&m_doubleValidator);
widget.lineEditI->setValidator (&m_doubleValidator);
widget.lineEditM0->setValidator (&m_doubleValidator);
widget.lineEditN->setValidator (&m_doubleValidator);
widget.lineEditOmg->setValidator (&m_doubleValidator);
widget.lineEditTime->setValidator (&m_doubleValidator);
widget.lineEditW->setValidator (&m_doubleValidator);

setSatWidget(satWidget);
connect(widget.btnIcon, SIGNAL(clicked()), this, SLOT(setIcon()));
connect(widget.btnColorName , SIGNAL(clicked()), this, SLOT(setColorSatName ()));
@@ -54,7 +58,7 @@ uint32_t Sgp4Dialog::flipRgb(uint32_t rgb) {
void Sgp4Dialog::showEvent(QShowEvent * event) {
Q_UNUSED(event)

if (m_sat == NULL) {
if (m_sat == nullptr) {
return;
}

@@ -134,7 +138,7 @@ void Sgp4Dialog::makeSat(Satellite *sat, bool fromlist) {
return;
}

if (m_sat == NULL) {
if (m_sat == nullptr) {
return;
}

@@ -230,7 +234,7 @@ void Sgp4Dialog::setIcon() {
QDir dir = QDir::home();
dir.cd("satviewer/icons");
QString filePath = QFileDialog::getOpenFileName(this, "Open PNG Image",
dir.path(), "PNG Images (*.png)", NULL,
dir.path(), "PNG Images (*.png)", nullptr,
QFileDialog::DontUseNativeDialog);
if (filePath.isEmpty()) {
widget.btnIcon->setIcon(QPixmap(filePath));
@@ -32,6 +32,7 @@ class Sgp4Dialog: public QDialog {
Ui::SatDialog widget;
Sgp4Model *m_sat;
GLSatAbstractWidget *satWidget;
QDoubleValidator m_doubleValidator;
void setBtnColor(QWidget *widget);
uint32_t flipRgb(uint32_t rgb);

@@ -28,7 +28,7 @@ class GLSatAbstractWidget : public QOpenGLWidget, protected QOpenGLFunctions_2_0
QWidget *settingsWidget;
typedef Satellite * (*CustomSat)();
CustomSat getSatModel, getSunModel;
GLSatAbstractWidget(QWidget *parent = NULL);
GLSatAbstractWidget(QWidget *parent = nullptr);
virtual ~GLSatAbstractWidget();
virtual void readSettings() {}
virtual void writeSettings(QSettings *settings) { Q_UNUSED(settings); }
@@ -71,12 +71,12 @@ class GLSatAbstractWidget : public QOpenGLWidget, protected QOpenGLFunctions_2_0
int indexLoc() const {return m_indexLoc;}

Satellite * currentSat() {
if ((m_indexSat < 0) || (m_indexSat >= satList.count())) return NULL; // TODO move to cpp
if ((m_indexSat < 0) || (m_indexSat >= satList.count())) return nullptr; // TODO move to cpp
return satList.at(m_indexSat);
}

Location * currentLoc() {
if ((m_indexLoc < 0) || (m_indexLoc >= locList.count())) return NULL; // TODO move to cpp
if ((m_indexLoc < 0) || (m_indexLoc >= locList.count())) return nullptr; // TODO move to cpp
return locList.at(m_indexLoc);
}

@@ -117,9 +117,9 @@ class GLSatAbstractWidget : public QOpenGLWidget, protected QOpenGLFunctions_2_0
virtual void compileLocList() {}
virtual void compileSunList() {}
virtual void compileEventsList() {}
virtual float zoom(float value = 0);
virtual float moveX(float value = 0);
virtual float moveY(float value = 0);
virtual float zoom(float value = 0.0);
virtual float moveX(float value = 0.0);
virtual float moveY(float value = 0.0);
// virtual void compileSatIcon(Satellite *sat) {}
// virtual void compileLocIcon(Location *loc) {}
private:
@@ -23,6 +23,7 @@

GLSatWidget::GLSatWidget(QWidget *parent) : GLSatAbstractWidget(parent) {
ui.setupUi(settingsWidget);

initSatOgl();

connect(ui.btnColor , SIGNAL(clicked()), this, SLOT(btnColorClicked ()));
@@ -172,7 +173,7 @@ bool GLSatWidget::testZRV(double* crd1, double* crd2, double fiz) {

int GLSatWidget::testIOZRV(Satellite *sat, Location *loc, ZrvIoList *list, double &time) {
int result = -1;
if (time == 0) return result; // o_O
if (time == 0) return result; //TODO: o_O
bool inZRV;
double fiz = 0;
double z = sat->zrvWidth();
@@ -268,13 +269,29 @@ void GLSatWidget::compileZrl(Location *loc) {
}

bool GLSatWidget::testShadow(Satellite *sat, Satellite *sun) {
if ((sat == 0) || (sun == 0)) return true;
double r_sat = sqrt(sat->xyz()[0]*sat->xyz()[0] + sat->xyz()[1]*sat->xyz()[1] + sat->xyz()[2]*sat->xyz()[2]);
double r_sun = sqrt(sun->xyz()[0]*sun->xyz()[0] + sun->xyz()[1]*sun->xyz()[1] + sun->xyz()[2]*sun->xyz()[2]);
if ((r_sat == 0) || (r_sun == 0) || (sat->radiusEarth() > r_sat)) return true;
double f = asin(sat->radiusEarth()/r_sat);
double l = M_PI - acos((sat->xyz()[0]*sun->xyz()[0] + sat->xyz()[1]*sun->xyz()[1] + sat->xyz()[2]*sun->xyz()[2])/(r_sat*r_sun));
if ((-f < l) && (l < f)) return false;

if ((sat == nullptr) || (sun == nullptr)) {
return true;
}

double r_sat = sqrt(sat->xyz()[0] * sat->xyz()[0]
+ sat->xyz()[1] * sat->xyz()[1] + sat->xyz()[2] * sat->xyz()[2]);
double r_sun = sqrt(sun->xyz()[0] * sun->xyz()[0]
+ sun->xyz()[1] * sun->xyz()[1] + sun->xyz()[2] * sun->xyz()[2]);

if ((r_sat == 0.0) || (r_sun == 0.0) || (sat->radiusEarth() > r_sat)) { // TODO: compare with epsilon
return true;
}

double f = asin(sat->radiusEarth() / r_sat);
double l = M_PI - acos((sat->xyz()[0] * sun->xyz()[0]
+ sat->xyz()[1] * sun->xyz()[1] + sat->xyz()[2] * sun->xyz()[2])
/ (r_sat * r_sun));

if ((-f < l) && (l < f)) {
return false;
}

return true;
}

@@ -464,30 +481,45 @@ void GLSatWidget::writeSettings(QSettings *settings) {

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

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

void GLSatWidget::setIcon(Satellite *sat, const QString& fileName) {
if (sat->satWObject != 0) delete sat->satWObject;
if (!fileName.isEmpty()) sat->setIcon(fileName);
if (sat->satWObject != nullptr) {
delete sat->satWObject;
}
if (!fileName.isEmpty()) {
sat->setIcon(fileName);
}
sat->satWObject = new GLSprite(sat->iconName(), this);
}

void GLSatWidget::setIcon(Location *loc, const QString& fileName) {
if (loc->satWObject != 0) delete loc->satWObject;
if (!fileName.isEmpty()) loc->setIcon(fileName);
if (loc->satWObject != nullptr) {
delete loc->satWObject;
}
if (!fileName.isEmpty()) {
loc->setIcon(fileName);
}
loc->satWObject = new GLSprite(loc->iconName(), this);
}

void GLSatWidget::btnColorClicked() {
QPalette pal = ui.btnColor->palette();
QColor color = QColorDialog::getColor(pal.color(QPalette::Button), this, 0, QColorDialog::ShowAlphaChannel);
if (!color.isValid()) return;
QColor color = QColorDialog::getColor(pal.color(QPalette::Button), this, "", // TODO: set caption
QColorDialog::ShowAlphaChannel);
if (!color.isValid()) {
return;
}

pal.setColor(QPalette::Button, color);
ui.btnColor->setPalette(pal);
@@ -556,7 +588,7 @@ void GLSatWidget::onBtnMapFileClicked() {
QDir dir = QDir::home();
dir.cd("satviewer");
QString filePath = QFileDialog::getOpenFileName(this, "Open Map File",
dir.path(), "Images (*.jpg *.png *.svg)", NULL,
dir.path(), "Images (*.jpg *.png *.svg)", nullptr,
QFileDialog::DontUseNativeDialog);
if (filePath == "") return;
loadTexture(filePath);
@@ -645,9 +677,8 @@ void GLSatWidget::compileMapList() {
void GLSatWidget::compileSatList() {
float px, py, tmpx, tmpy, tper = 0;
float trackBegin, trackEnd;
uint8_t shadow_state, shadow_tmp;
uint32_t clr;
Satellite *sat = NULL;
Satellite *sat = nullptr;

if (satList.count() < 1) {
glNewList(list_sat, GL_COMPILE);
@@ -657,7 +688,7 @@ void GLSatWidget::compileSatList() {

glNewList(list_sat, GL_COMPILE);
for (const auto& sat : satList) {
shadow_state = 2;
bool shadow_state = testShadow(sat, nullptr); //TODO: check sun shadow
sat->model(m_time);

if (sat->isVisibleZrv() || sat->isVisibleLines()) {
@@ -681,11 +712,10 @@ void GLSatWidget::compileSatList() {
trackEnd = sat->track() * (0.5 * tper + tper / 180.0);
sat->model(trackBegin + m_time);
tmpx = sat->longitude() / M_PI;
tmpy = -2*sat->latitude() / M_PI;
tmpy = -2.0 * sat->latitude() / M_PI;
for (float i = trackBegin; i < trackEnd; i += tper / 180.0) {
sat->model(i + m_time);
if (sat->isVisibleTrackShadow()) {
shadow_tmp = shadow_state;
if (shadow_state) {
clr = sat->colorTrack();
glColor4ubv((GLubyte *)&clr);
@@ -732,7 +762,7 @@ void GLSatWidget::compileSatList() {
}

sat = currentSat();
if (sat == NULL) {
if (sat == nullptr) {
sat = satList.first();
}
sat->model(m_time);
@@ -759,7 +789,7 @@ void GLSatWidget::compileLocList() {
}

loc = currentLoc();
if (loc == NULL) {
if (loc == nullptr) {
loc = locList.first();
}
px = loc->longitude() / 180.0;
@@ -14,7 +14,7 @@
#include "glsprite/GLSprite.h"

class GLSatWidget : public GLSatAbstractWidget {
Q_OBJECT
Q_OBJECT
public:
GLSatWidget(QWidget *parent = 0);
virtual ~GLSatWidget();
@@ -22,7 +22,7 @@ class GLSatWidget3d : public GLSatAbstractWidget {
Q_OBJECT

public:
GLSatWidget3d(QWidget *parent = 0);
GLSatWidget3d(QWidget *parent = nullptr);
virtual ~GLSatWidget3d();
void readSettings(QSettings *settings);
void writeSettings(QSettings *settings);
@@ -0,0 +1,18 @@
/*
* File: RadarWidget.cpp
* Author: Ivan Ryazanov
*
* Created on April 13, 2019, 6:58 PM
*/

#include "RadarWidget.h"

RadarWidget::RadarWidget() {
}

RadarWidget::RadarWidget(const RadarWidget& orig) {
}

RadarWidget::~RadarWidget() {
}

Oops, something went wrong.

0 comments on commit 92153f3

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