refactor in progress, builds currently
Former-commit-id: ad23161c72900be5a595ad004e133c67fa37df92 Former-commit-id: 284f7c0acd3b4322e33c215aa8a559c35f6daa65
This commit is contained in:
parent
af9cfce3ff
commit
8b23d25dd1
|
@ -1,5 +1,6 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
|
#include "dump1090.h"
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
class Aircraft {
|
class Aircraft {
|
||||||
|
|
|
@ -86,7 +86,7 @@ void AircraftData::update() {
|
||||||
|
|
||||||
interactiveRemoveStaleAircrafts(&modes);
|
interactiveRemoveStaleAircrafts(&modes);
|
||||||
|
|
||||||
aircraftList.update();
|
aircraftList.update(&modes);
|
||||||
}
|
}
|
||||||
|
|
||||||
AircraftData::AircraftData(){
|
AircraftData::AircraftData(){
|
||||||
|
|
|
@ -21,10 +21,9 @@ Aircraft *AircraftList::find(uint32_t addr) {
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AircraftList::update
|
|
||||||
() {
|
|
||||||
//instead of this, net_io should call this class directly to update info
|
//instead of this, net_io should call this class directly to update info
|
||||||
struct aircraft *a = modes.aircrafts;
|
void AircraftList::update(Modes *modes) {
|
||||||
|
struct aircraft *a = modes->aircrafts;
|
||||||
|
|
||||||
Aircraft *p = head;
|
Aircraft *p = head;
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ class AircraftList {
|
||||||
Aircraft *head;
|
Aircraft *head;
|
||||||
|
|
||||||
Aircraft *find(uint32_t addr);
|
Aircraft *find(uint32_t addr);
|
||||||
void update();
|
void update(Modes *modes);
|
||||||
|
|
||||||
AircraftList();
|
AircraftList();
|
||||||
~AircraftList();
|
~AircraftList();
|
||||||
|
|
135
View.cpp
135
View.cpp
|
@ -148,7 +148,7 @@ int View::screenDist(float d) {
|
||||||
return round(0.95 * scale_factor * 0.5 * fabs(d) / appData.maxDist);
|
return round(0.95 * scale_factor * 0.5 * fabs(d) / appData.maxDist);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pxFromLonLat(float *dx, float *dy, float lon, float lat) {
|
void View::pxFromLonLat(float *dx, float *dy, float lon, float lat) {
|
||||||
if(!lon || !lat) {
|
if(!lon || !lat) {
|
||||||
*dx = 0;
|
*dx = 0;
|
||||||
*dy = 0;
|
*dy = 0;
|
||||||
|
@ -391,7 +391,7 @@ void View::drawScaleBars()
|
||||||
while(scaleBarDist < appData.screen_width) {
|
while(scaleBarDist < appData.screen_width) {
|
||||||
lineRGBA(appData.renderer,10+scaleBarDist,8,10+scaleBarDist,16*appData.screen_uiscale,style.scaleBarColor.r, style.scaleBarColor.g, style.scaleBarColor.b, 255);
|
lineRGBA(appData.renderer,10+scaleBarDist,8,10+scaleBarDist,16*appData.screen_uiscale,style.scaleBarColor.r, style.scaleBarColor.g, style.scaleBarColor.b, 255);
|
||||||
|
|
||||||
if (modes.metric) {
|
if (aircraftData->modes.metric) {
|
||||||
snprintf(scaleLabel,13,"%dkm", (int)pow(10,scalePower));
|
snprintf(scaleLabel,13,"%dkm", (int)pow(10,scalePower));
|
||||||
} else {
|
} else {
|
||||||
snprintf(scaleLabel,13,"%dmi", (int)pow(10,scalePower));
|
snprintf(scaleLabel,13,"%dmi", (int)pow(10,scalePower));
|
||||||
|
@ -549,7 +549,7 @@ void View::drawPlaneText(Aircraft *p) {
|
||||||
|
|
||||||
if(p->pressure * appData.screen_width < 0.2f) {
|
if(p->pressure * appData.screen_width < 0.2f) {
|
||||||
char alt[10] = " ";
|
char alt[10] = " ";
|
||||||
if (modes.metric) {
|
if (aircraftData->modes.metric) {
|
||||||
currentCharCount = snprintf(alt,10," %dm", (int) (p->altitude / 3.2828));
|
currentCharCount = snprintf(alt,10," %dm", (int) (p->altitude / 3.2828));
|
||||||
} else {
|
} else {
|
||||||
currentCharCount = snprintf(alt,10," %d'", p->altitude);
|
currentCharCount = snprintf(alt,10," %d'", p->altitude);
|
||||||
|
@ -565,7 +565,7 @@ void View::drawPlaneText(Aircraft *p) {
|
||||||
}
|
}
|
||||||
|
|
||||||
char speed[10] = " ";
|
char speed[10] = " ";
|
||||||
if (modes.metric) {
|
if (aircraftData->modes.metric) {
|
||||||
currentCharCount = snprintf(speed,10," %dkm/h", (int) (p->speed * 1.852));
|
currentCharCount = snprintf(speed,10," %dkm/h", (int) (p->speed * 1.852));
|
||||||
} else {
|
} else {
|
||||||
currentCharCount = snprintf(speed,10," %dmph", p->speed);
|
currentCharCount = snprintf(speed,10," %dmph", p->speed);
|
||||||
|
@ -627,7 +627,7 @@ void View::drawSelectedAircraftText(Aircraft *p) {
|
||||||
}
|
}
|
||||||
|
|
||||||
char alt[10] = " ";
|
char alt[10] = " ";
|
||||||
if (modes.metric) {
|
if (aircraftData->modes.metric) {
|
||||||
currentCharCount = snprintf(alt,10," %dm", (int) (p->altitude / 3.2828));
|
currentCharCount = snprintf(alt,10," %dm", (int) (p->altitude / 3.2828));
|
||||||
} else {
|
} else {
|
||||||
currentCharCount = snprintf(alt,10," %d'", p->altitude);
|
currentCharCount = snprintf(alt,10," %d'", p->altitude);
|
||||||
|
@ -643,7 +643,7 @@ void View::drawSelectedAircraftText(Aircraft *p) {
|
||||||
}
|
}
|
||||||
|
|
||||||
char speed[10] = " ";
|
char speed[10] = " ";
|
||||||
if (modes.metric) {
|
if (aircraftData->modes.metric) {
|
||||||
currentCharCount = snprintf(speed,10," %dkm/h", (int) (p->speed * 1.852));
|
currentCharCount = snprintf(speed,10," %dkm/h", (int) (p->speed * 1.852));
|
||||||
} else {
|
} else {
|
||||||
currentCharCount = snprintf(speed,10," %dmph", p->speed);
|
currentCharCount = snprintf(speed,10," %dmph", p->speed);
|
||||||
|
@ -853,10 +853,7 @@ void View::drawPlanes() {
|
||||||
// draw all trails first so they don't cover up planes and text
|
// draw all trails first so they don't cover up planes and text
|
||||||
// also find closest plane to selection point
|
// also find closest plane to selection point
|
||||||
while(p) {
|
while(p) {
|
||||||
if ((now - p->seen) < modes.interactive_display_ttl) {
|
drawTrail(p->oldLon, p->oldLat, p->oldHeading, p->oldSeen, p->oldIdx);
|
||||||
drawTrail(p->oldLon, p->oldLat, p->oldHeading, p->oldSeen, p->oldIdx);
|
|
||||||
}
|
|
||||||
|
|
||||||
p = p->next;
|
p = p->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -868,80 +865,78 @@ void View::drawPlanes() {
|
||||||
p = aircraftData->aircraftList.head;
|
p = aircraftData->aircraftList.head;
|
||||||
|
|
||||||
while(p) {
|
while(p) {
|
||||||
if ((now - p->seen) < modes.interactive_display_ttl) {
|
if (p->lon && p->lat) {
|
||||||
if (p->lon && p->lat) {
|
int x, y;
|
||||||
int x, y;
|
|
||||||
|
|
||||||
float dx, dy;
|
float dx, dy;
|
||||||
pxFromLonLat(&dx, &dy, p->lon, p->lat);
|
pxFromLonLat(&dx, &dy, p->lon, p->lat);
|
||||||
screenCoords(&x, &y, dx, dy);
|
screenCoords(&x, &y, dx, dy);
|
||||||
|
|
||||||
if(p->created == 0) {
|
if(p->created == 0) {
|
||||||
p->created = mstime();
|
p->created = mstime();
|
||||||
}
|
}
|
||||||
|
|
||||||
float age_ms = (float)(mstime() - p->created);
|
float age_ms = (float)(mstime() - p->created);
|
||||||
if(age_ms < 500) {
|
if(age_ms < 500) {
|
||||||
circleRGBA(appData.renderer, x, y, 500 - age_ms, 255,255, 255, (uint8_t)(255.0 * age_ms / 500.0));
|
circleRGBA(appData.renderer, x, y, 500 - age_ms, 255,255, 255, (uint8_t)(255.0 * age_ms / 500.0));
|
||||||
} else {
|
} else {
|
||||||
if(MODES_ACFLAGS_HEADING_VALID) {
|
if(MODES_ACFLAGS_HEADING_VALID) {
|
||||||
int usex = x;
|
int usex = x;
|
||||||
int usey = y;
|
int usey = y;
|
||||||
|
|
||||||
if(p->seenLatLon > p->oldSeen[p->oldIdx]) {
|
if(p->seenLatLon > p->oldSeen[p->oldIdx]) {
|
||||||
int oldx, oldy;
|
int oldx, oldy;
|
||||||
int idx = (p->oldIdx - 1) % TRAIL_LENGTH;
|
int idx = (p->oldIdx - 1) % TRAIL_LENGTH;
|
||||||
|
|
||||||
pxFromLonLat(&dx, &dy, p->oldLon[idx], p->oldLat[idx]);
|
pxFromLonLat(&dx, &dy, p->oldLon[idx], p->oldLat[idx]);
|
||||||
screenCoords(&oldx, &oldy, dx, dy);
|
screenCoords(&oldx, &oldy, dx, dy);
|
||||||
|
|
||||||
float velx = (x - oldx) / (1000.0 * (p->seenLatLon - p->oldSeen[idx]));
|
float velx = (x - oldx) / (1000.0 * (p->seenLatLon - p->oldSeen[idx]));
|
||||||
float vely = (y - oldy) / (1000.0 * (p->seenLatLon - p->oldSeen[idx]));
|
float vely = (y - oldy) / (1000.0 * (p->seenLatLon - p->oldSeen[idx]));
|
||||||
|
|
||||||
usex = x + (mstime() - p->msSeenLatLon) * velx;
|
usex = x + (mstime() - p->msSeenLatLon) * velx;
|
||||||
usey = y + (mstime() - p->msSeenLatLon) * vely;
|
usey = y + (mstime() - p->msSeenLatLon) * vely;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(p == aircraftData->selectedAircraft) {
|
if(p == aircraftData->selectedAircraft) {
|
||||||
// this logic should be in input, register a callback for click?
|
// this logic should be in input, register a callback for click?
|
||||||
float elapsed = mstime() - appData.touchDownTime;
|
float elapsed = mstime() - appData.touchDownTime;
|
||||||
|
|
||||||
int boxSize;
|
int boxSize;
|
||||||
if(elapsed < 300) {
|
if(elapsed < 300) {
|
||||||
boxSize = (int)(20.0 * (1.0 - (1.0 - elapsed / 300.0) * cos(sqrt(elapsed))));
|
boxSize = (int)(20.0 * (1.0 - (1.0 - elapsed / 300.0) * cos(sqrt(elapsed))));
|
||||||
} else {
|
|
||||||
boxSize = 20;
|
|
||||||
}
|
|
||||||
//rectangleRGBA(appData.renderer, usex - boxSize, usey - boxSize, usex + boxSize, usey + boxSize, pink.r, pink.g, pink.b, 255);
|
|
||||||
lineRGBA(appData.renderer, usex - boxSize, usey - boxSize, usex - boxSize/2, usey - boxSize, pink.r, pink.g, pink.b, 255);
|
|
||||||
lineRGBA(appData.renderer, usex - boxSize, usey - boxSize, usex - boxSize, usey - boxSize/2, pink.r, pink.g, pink.b, 255);
|
|
||||||
|
|
||||||
lineRGBA(appData.renderer, usex + boxSize, usey - boxSize, usex + boxSize/2, usey - boxSize, pink.r, pink.g, pink.b, 255);
|
|
||||||
lineRGBA(appData.renderer, usex + boxSize, usey - boxSize, usex + boxSize, usey - boxSize/2, pink.r, pink.g, pink.b, 255);
|
|
||||||
|
|
||||||
lineRGBA(appData.renderer, usex + boxSize, usey + boxSize, usex + boxSize/2, usey + boxSize, pink.r, pink.g, pink.b, 255);
|
|
||||||
lineRGBA(appData.renderer, usex + boxSize, usey + boxSize, usex + boxSize, usey + boxSize/2, pink.r, pink.g, pink.b, 255);
|
|
||||||
|
|
||||||
lineRGBA(appData.renderer, usex - boxSize, usey + boxSize, usex - boxSize/2, usey + boxSize, pink.r, pink.g, pink.b, 255);
|
|
||||||
lineRGBA(appData.renderer, usex - boxSize, usey + boxSize, usex - boxSize, usey + boxSize/2, pink.r, pink.g, pink.b, 255);
|
|
||||||
planeColor = lerpColor(style.selectedColor, style.planeGoneColor, (now - p->seen) / (float) DISPLAY_ACTIVE);
|
|
||||||
} else {
|
} else {
|
||||||
planeColor = lerpColor(style.planeColor, style.planeGoneColor, (now - p->seen) / (float) DISPLAY_ACTIVE);
|
boxSize = 20;
|
||||||
}
|
}
|
||||||
|
//rectangleRGBA(appData.renderer, usex - boxSize, usey - boxSize, usex + boxSize, usey + boxSize, pink.r, pink.g, pink.b, 255);
|
||||||
|
lineRGBA(appData.renderer, usex - boxSize, usey - boxSize, usex - boxSize/2, usey - boxSize, pink.r, pink.g, pink.b, 255);
|
||||||
|
lineRGBA(appData.renderer, usex - boxSize, usey - boxSize, usex - boxSize, usey - boxSize/2, pink.r, pink.g, pink.b, 255);
|
||||||
|
|
||||||
if(outOfBounds(x,y)) {
|
lineRGBA(appData.renderer, usex + boxSize, usey - boxSize, usex + boxSize/2, usey - boxSize, pink.r, pink.g, pink.b, 255);
|
||||||
drawPlaneOffMap(x, y, &(p->cx), &(p->cy), planeColor);
|
lineRGBA(appData.renderer, usex + boxSize, usey - boxSize, usex + boxSize, usey - boxSize/2, pink.r, pink.g, pink.b, 255);
|
||||||
} else {
|
|
||||||
drawPlaneIcon(usex, usey, p->track, planeColor);
|
|
||||||
p->cx = usex;
|
|
||||||
p->cy = usey;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(p != aircraftData->selectedAircraft) {
|
|
||||||
drawPlaneText(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
lineRGBA(appData.renderer, usex + boxSize, usey + boxSize, usex + boxSize/2, usey + boxSize, pink.r, pink.g, pink.b, 255);
|
||||||
|
lineRGBA(appData.renderer, usex + boxSize, usey + boxSize, usex + boxSize, usey + boxSize/2, pink.r, pink.g, pink.b, 255);
|
||||||
|
|
||||||
|
lineRGBA(appData.renderer, usex - boxSize, usey + boxSize, usex - boxSize/2, usey + boxSize, pink.r, pink.g, pink.b, 255);
|
||||||
|
lineRGBA(appData.renderer, usex - boxSize, usey + boxSize, usex - boxSize, usey + boxSize/2, pink.r, pink.g, pink.b, 255);
|
||||||
|
planeColor = lerpColor(style.selectedColor, style.planeGoneColor, (now - p->seen) / (float) DISPLAY_ACTIVE);
|
||||||
|
} else {
|
||||||
|
planeColor = lerpColor(style.planeColor, style.planeGoneColor, (now - p->seen) / (float) DISPLAY_ACTIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(outOfBounds(x,y)) {
|
||||||
|
drawPlaneOffMap(x, y, &(p->cx), &(p->cy), planeColor);
|
||||||
|
} else {
|
||||||
|
drawPlaneIcon(usex, usey, p->track, planeColor);
|
||||||
|
p->cx = usex;
|
||||||
|
p->cy = usey;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(p != aircraftData->selectedAircraft) {
|
||||||
|
drawPlaneText(p);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
2
View.h
2
View.h
|
@ -34,6 +34,8 @@ public:
|
||||||
void draw();
|
void draw();
|
||||||
|
|
||||||
View(AircraftData *aircraftData);
|
View(AircraftData *aircraftData);
|
||||||
|
|
||||||
|
bool metric;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
1
map1090.REMOVED.git-id
Normal file
1
map1090.REMOVED.git-id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
a18a4bc87ddef182cd7d61470daf952ae025186b
|
|
@ -124,8 +124,7 @@ int main(int argc, char **argv) {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int go;
|
int go;
|
||||||
|
|
||||||
aircraftData.connect();
|
aircraftData.connect();
|
||||||
|
|
Loading…
Reference in a new issue