Skip to content
Permalink
Browse files

.

  • Loading branch information...
ri
ri committed Apr 14, 2019
1 parent 84087c5 commit 144ada258127fd7b605a74ab7f381da890da4cab
@@ -1,4 +1,4 @@
**TODO list**
## TODO list:
- [ ] netfont select dialog
- [ ] merge list_net and list_map
- [ ] locList coords as radians
@@ -12,3 +12,6 @@
- [ ] \n \r\n in .obj
- [ ] small indent in html
- [ ] libpng warning: iCCP: known incorrect sRGB profile
- [ ] remove crd.h, satogl.h
- [ ] move current cursor on paused click
- [ ] radians - degrees conversions
@@ -13,7 +13,7 @@
SWindow::SWindow(SatViewer *satviewer) {
widget.setupUi(this);
originalPalette = qApp->palette();

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

@@ -105,7 +105,7 @@ SWindow::SWindow(SatViewer *satviewer) {
// readSettings();
// enumSatModelList();

RadarWidget *radarWidget = new RadarWidget(satviewer, this);
radarWidget = new RadarWidget(satviewer, this);
radarWidget->resize(512, 512);
radarWidget->move(128, 128);
radarWidget->setWindowFlag(Qt::Window);
@@ -340,7 +340,7 @@ void SWindow::onTimer() {
}

m_satviewer->setTime(time);
satWidget->update();// TODO remove this?

}

void SWindow::onPlayClick() {
@@ -38,6 +38,7 @@ class SWindow: public QMainWindow {
Ui::MainWindow widget;
QPalette originalPalette;
GLSatAbstractWidget *satWidget;
RadarWidget *radarWidget;
double time, timeStep, timeX;
int timeType;
QShortcut *shcFullScreen, *shcEscFullScreen;
@@ -120,3 +120,52 @@ void SatViewer::setTime(double value) {
m_time = value;
emit timeChanged();
}

void SatViewer::aerv() {
// double aerv[4];
// double m[3][3];
// Satellite *sat;
// sat->xyz_g()
// double d[3];
// double p = sqrt(xyzLoc[0] * xyzLoc[0] + xyzLoc[1] * xyzLoc[1]);
// double r = sqrt(xyzLoc[0] * xyzLoc[0] + xyzLoc[1] * xyzLoc[1] + xyzLoc[2] * xyzLoc[2]);
//
// double dd[] = {
// xyzLoc[0] - xyzSat[0],
// xyzLoc[1] - xyzSat[1],
// xyzLoc[2] - xyzSat[2],
// xyzLoc[3] - xyzSat[3],
// xyzLoc[4] - xyzSat[4],
// xyzLoc[5] - xyzSat[5]
// };
//
// aerv[2] = sqrt(dd[0] * dd[0] + dd[1] * dd[1] + dd[2] * dd[2]);
//
// if (p < Number.EPSILON || r < Number.EPSILON) {
// return aerv;
// }
//
// m[0][0] = -xyzLoc[1] / p;
// m[0][1] = xyzLoc[0] / p;
// m[0][2] = 0.0;
// m[1][0] = -(xyzLoc[0] * xyzLoc[2] / (p * r));
// m[1][1] = -(xyzLoc[1] * xyzLoc[2] / (p * r));
// m[1][2] = p / r;
// m[2][0] = xyzLoc[0] / r;
// m[2][1] = xyzLoc[1] / r;
// m[2][2] = xyzLoc[2] / r;
//
// for (size_t j = 0; j < 3; j++) {
// for (size_t i = 0; i < 3; i++) {
// d[j] += (xyzSat[i] - xyzLoc[i]) * m[j][i];
// }
// }
//
// double s = d[2] / sqrt(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]);
//
// aerv[1] = atan2(s, sqrt(1.0 - s * s));
// aerv[0] = atan2(d[0], d[1]);
// aerv[3] = (dd[0] * dd[3] + dd[1] * dd[4] + dd[2] * dd[5]) / aerv[2];
//
// return aerv;
}
@@ -45,6 +45,7 @@ class SatViewer : public QObject {
Location *m_currentLocation;
double m_time;
ZrvIoList m_ioList;
static void aerv();

};

@@ -48,11 +48,9 @@ void SScriptFrame::reload() {
QJSValue ascSat = engine.newArray(6);
QJSValue ascLoc = engine.newArray(6);

for (int i = 0; i < 3; i++) {
ascSat.setProperty(i, m_sat->xyz_g()[i]);
ascSat.setProperty(i + 3, m_sat->vxyz_g()[i]);
ascLoc.setProperty(i, m_loc->xyz()[i]);
ascLoc.setProperty(i + 3, 0.0);
for (int i = 0; i < 6; i++) {
ascSat.setProperty(i, m_sat->rg()[i]);
ascLoc.setProperty(i, m_loc->rg()[i]);
}

engine.globalObject().setProperty("ascSat", ascSat);
@@ -14,7 +14,7 @@
#include <QDebug>

SWidget::SWidget(QWidget *parent, QString fileName) {
m_sat = 0;
m_sat = 0; //TODO nullptr, fileName - const
m_loc = 0;
m_time = 0;
m_maskColor = Qt::magenta;
@@ -171,11 +171,9 @@ void SWidget::setVars() {
engine.globalObject().setProperty("nameLoc", m_loc->name());
QJSValue ascSat = engine.newArray(6);
QJSValue ascLoc = engine.newArray(6);
for (int i = 0; i < 3; i++) {
ascSat.setProperty(i , m_sat->xyz_g()[i] );
ascSat.setProperty(i + 3, m_sat->vxyz_g()[i]);
ascLoc.setProperty(i , m_loc->xyz()[i] );
ascLoc.setProperty(i + 3, 0.0 );
for (int i = 0; i < 6; i++) {
ascSat.setProperty(i, m_sat->rg()[i]);
ascLoc.setProperty(i, m_loc->rg()[i]);
}
engine.globalObject().setProperty("ascSat", ascSat);
engine.globalObject().setProperty("ascLoc", ascLoc);
@@ -43,9 +43,12 @@ Location::Location(void) {
_zrlWidth = 0.0;
_zrlAzimuth = 0.0;
_zrlRange = 0.0;
r[0] = 0.0;
r[1] = 0.0;
r[2] = 0.0;
m_rg[0] = 0.0;
m_rg[1] = 0.0;
m_rg[2] = 0.0;
m_rg[3] = 0.0;
m_rg[4] = 0.0;
m_rg[5] = 0.0;
}

Location::~Location(void) {
@@ -89,10 +92,10 @@ void Location::calcXYZ() {
double const b_axis = 6356752.31; //WGS-84 earth's semi minor axis
double const e1sqr = ((a_axis * a_axis - b_axis * b_axis) / (a_axis * a_axis));
double N = a_axis / sqrt(1.0 - e1sqr * sin(lat*M_PI/180.0) * sin(lat*M_PI/180.0));

r[0] = (N + _height)*cos(lat*M_PI/180.0)*cos(lon*M_PI/180.0);
r[1] = (N + _height)*cos(lat*M_PI/180.0)*sin(lon*M_PI/180.0);
r[2] = (N*(1.0 - e1sqr) + _height)*sin(lat*M_PI/180.0);
//TODO
m_rg[0] = (N + _height)*cos(lat*M_PI/180.0)*cos(lon*M_PI/180.0);
m_rg[1] = (N + _height)*cos(lat*M_PI/180.0)*sin(lon*M_PI/180.0);
m_rg[2] = (N*(1.0 - e1sqr) + _height)*sin(lat*M_PI/180.0);
}

void Location::setLatitude(double latitude) {
@@ -40,7 +40,7 @@ class Location {
inline double latitude () { return lat; }
inline double longitude() { return lon; }
inline double height () { return _height; }
inline double *xyz () { return r; }
inline double *rg () { return m_rg; }

inline double zrlWidth () { return _zrlWidth; }
inline double zrlAzimuth() { return _zrlAzimuth; }
@@ -87,6 +87,6 @@ class Location {
double lines_width;
double lat, lon, _height;
double _zrlWidth, _zrlAzimuth, _zrlRange;
double r[3];
double m_rg[6];
};
#endif /* LOCATION_H_ */
@@ -43,6 +43,8 @@ void copyDefault() {
}

int main(int argc, char *argv[]) {
// QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
QApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
QApplication app(argc, argv);

// QSurfaceFormat format;
@@ -78,16 +78,15 @@ bool Sgp4Model::model(double time) {
bool result;

time = (2440587.5 - state.jdsatepoch + time / 86400.0) * 1440.0;
result = SGP4Funcs::sgp4(elset, time, r, v);
result = SGP4Funcs::sgp4(elset, time, m_r, m_r + 3);

r[0] *= 1000.0;
r[1] *= 1000.0;
r[2] *= 1000.0;
m_r[0] *= 1000.0;
m_r[1] *= 1000.0;
m_r[2] *= 1000.0;
m_r[3] *= 1000.0;
m_r[4] *= 1000.0;
m_r[5] *= 1000.0;

v[0] *= 1000.0;
v[1] *= 1000.0;
v[2] *= 1000.0;

getGeod();

return result;
@@ -56,7 +56,6 @@ GLSatAbstractWidget::GLSatAbstractWidget(SatViewer *satviewer, QWidget *parent)
list_loc_ready = true;
list_sat_ready = true;
list_labels_ready = true;
connect(m_satviewer, SIGNAL(timeChanged()), this, SLOT(refresh()));
// setSunModel();
// sun = getSunModel();
// sun->modelInit(WGS84, 0, 0, 0, 0, 0, 0, 0, 0);
@@ -79,7 +78,7 @@ void GLSatAbstractWidget::initializeGL() {
bool ok = initializeOpenGLFunctions();

assert(ok);

// setAutoBufferSwap(false); //TODO
glClearColor(0.1, 0.1, 0.1, 0.0);
//glShadeModel(GL_FLAT);
@@ -94,10 +93,10 @@ void GLSatAbstractWidget::initializeGL() {
glBlendFunc(GL_SRC_COLOR, GL_DST_COLOR);
// glBlendFunc(GL_DST_COLOR, GL_SRC_COLOR);
// loadTexture();
list_map = glGenLists(6);

list_map = glGenLists(6);
qWarning() << "list_map" << list_map << endl;
assert(list_map > 0);

list_net = list_map + 1;
list_sat = list_map + 2;
list_loc = list_map + 3;
@@ -107,6 +106,8 @@ void GLSatAbstractWidget::initializeGL() {
emit initialized();

readSettings();

connect(m_satviewer, SIGNAL(timeChanged()), this, SLOT(refresh()));
}

void GLSatAbstractWidget::paintGL() {
@@ -138,7 +139,7 @@ void GLSatAbstractWidget::refreshAll() {
compileLocList();
compileEventsList();
compileSunList();
paintGL();
update();
}

void GLSatAbstractWidget::loadTexture(QString filePath) {
@@ -157,12 +158,13 @@ void GLSatAbstractWidget::refresh() {
return;
}
// compileMapList();
compileSatList();
compileEventsList();
compileSatList();
compileEventsList();
// compileLocList();
compileSunList();
compileSunList();
// refreshAll();
paintGL();
// paintGL();
update();
}

void GLSatAbstractWidget::setFontNet(QFont font) {
@@ -274,18 +274,18 @@ bool GLSatWidget::testShadow(Satellite *sat, Satellite *sun) {
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]);
double r_sat = sqrt(sat->r()[0] * sat->r()[0]
+ sat->r()[1] * sat->r()[1] + sat->r()[2] * sat->r()[2]);
double r_sun = sqrt(sun->r()[0] * sun->r()[0]
+ sun->r()[1] * sun->r()[1] + sun->r()[2] * sun->r()[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])
double l = M_PI - acos((sat->r()[0] * sun->r()[0]
+ sat->r()[1] * sun->r()[1] + sat->r()[2] * sun->r()[2])
/ (r_sat * r_sun));

if ((-f < l) && (l < f)) {
@@ -198,31 +198,31 @@ void GLSatWidget3d::compileSatList() {
trackEnd = sat->track()*(0.5*tper + tper/180.0);
for (double i = trackBegin; i < trackEnd; i += tper/180.0) {
sat->model(i + m_satviewer->time());
glVertex3f(sat->xyz_g()[0]/radiusEarth, sat->xyz_g()[1]/radiusEarth, sat->xyz_g()[2]/radiusEarth);
glVertex3f(sat->rg()[0]/radiusEarth, sat->rg()[1]/radiusEarth, sat->rg()[2]/radiusEarth);
}
glEnd();
glPopAttrib();
}

sat->model(m_satviewer->time());
float r = sqrtf(sat->xyz_g()[0]*sat->xyz_g()[0] + sat->xyz_g()[1]*sat->xyz_g()[1] + sat->xyz_g()[2]*sat->xyz_g()[2]);
float rz = sqrtf(sat->xyz_g()[0]*sat->xyz_g()[0] + sat->xyz_g()[1]*sat->xyz_g()[1]);
float r = sqrtf(sat->rg()[0]*sat->rg()[0] + sat->rg()[1]*sat->rg()[1] + sat->rg()[2]*sat->rg()[2]);
float rz = sqrtf(sat->rg()[0]*sat->rg()[0] + sat->rg()[1]*sat->rg()[1]);
glPushMatrix();
globjSat->move(0, 0, 0);
globjSat->rotateX(0);
globjSat->rotateY(0);
globjSat->rotateY(0);
float arzx = acosf(sat->xyz_g()[0]/rz)*180/M_PI;
float az = acosf(sat->xyz_g()[2]/r)*180/M_PI;
if (sat->xyz_g()[1] < 0) arzx = -arzx;
float arzx = acosf(sat->rg()[0]/rz)*180/M_PI;
float az = acosf(sat->rg()[2]/r)*180/M_PI;
if (sat->rg()[1] < 0) arzx = -arzx;
glRotatef(arzx, 0, 0, 1);
glRotatef(az, 0, 1, 0);
glRotatef(-arzx, 0, 0, 1);
glTranslatef(0, 0, r/radiusEarth);
globjSat->exec();
glPopMatrix();
}
glEndList();
glEndList();
}

void GLSatWidget3d::renderText(float x, float y, const QString& text, int color, const QFont &font) {
@@ -18,7 +18,7 @@ RadarWidget::~RadarWidget() {
}

void RadarWidget::compileMapList() {

glNewList(list_map, GL_COMPILE);
glEndList();

@@ -23,7 +23,7 @@ class RadarWidget : public GLSatAbstractWidget {
void compileMapList();
void compileSatList();
// void compileLocList() {}
// void compileSunList() {}
// void compileSunList() {GLSatAbstractWidget::compileSunList();}
// void compileEventsList() {}
// float zoom(float value = 0.0) {}
// float moveX(float value = 0.0) {}
Oops, something went wrong.

0 comments on commit 144ada2

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