fixed issues with selected plane label, can now select off screen plane
Former-commit-id: 00f02a8125
[formerly ab5ab5d0d3fb7f0bdb12ff5a21a6d0e249ceab6f] [formerly 969a11c7c843c43ec231673c9d15ed227414fc68]
Former-commit-id: bb74b98444dc3f22d156d9b518156a74b79457a2
Former-commit-id: 4d08d9777512eea19eec90e49019c0840a20a620
This commit is contained in:
parent
49c4b4e4a6
commit
617b1af43e
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,4 +1,4 @@
|
||||||
.o
|
*.o
|
||||||
view1090
|
view1090
|
||||||
|
|
||||||
*.swp
|
*.swp
|
||||||
|
|
110
draw.c
110
draw.c
|
@ -17,6 +17,10 @@ static uint64_t mstime(void) {
|
||||||
return mst;
|
return mst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float sign(float x) {
|
||||||
|
return (x > 0) - (x < 0);
|
||||||
|
}
|
||||||
|
|
||||||
void CROSSVP(double *v, double *u, double *w)
|
void CROSSVP(double *v, double *u, double *w)
|
||||||
{
|
{
|
||||||
v[0] = u[1]*w[2] - u[2]*(w)[1];
|
v[0] = u[1]*w[2] - u[2]*(w)[1];
|
||||||
|
@ -380,10 +384,12 @@ void drawScaleBars()
|
||||||
|
|
||||||
char scaleLabel[8] = "";
|
char scaleLabel[8] = "";
|
||||||
|
|
||||||
thickLineRGBA(appData.renderer,10,10,10,10*appData.screen_uiscale,2,pink.r, pink.g, pink.b, 255);
|
// thickLineRGBA(appData.renderer,10,10,10,10*appData.screen_uiscale,2,pink.r, pink.g, pink.b, 255);
|
||||||
|
lineRGBA(appData.renderer,10,10,10,10*appData.screen_uiscale,pink.r, pink.g, pink.b, 255);
|
||||||
|
|
||||||
while(scaleBarDist < appData.screen_width) {
|
while(scaleBarDist < appData.screen_width) {
|
||||||
thickLineRGBA(appData.renderer,10+scaleBarDist,10,10+scaleBarDist,10*appData.screen_uiscale,2,pink.r, pink.g, pink.b, 255);
|
// thickLineRGBA(appData.renderer,10+scaleBarDist,10,10+scaleBarDist,10*appData.screen_uiscale,2,pink.r, pink.g, pink.b, 255);
|
||||||
|
lineRGBA(appData.renderer,10+scaleBarDist,8,10+scaleBarDist,16*appData.screen_uiscale,pink.r, pink.g, pink.b, 255);
|
||||||
|
|
||||||
if (Modes.metric) {
|
if (Modes.metric) {
|
||||||
snprintf(scaleLabel,8,"%dkm", (int)pow(10,scalePower));
|
snprintf(scaleLabel,8,"%dkm", (int)pow(10,scalePower));
|
||||||
|
@ -391,7 +397,7 @@ void drawScaleBars()
|
||||||
snprintf(scaleLabel,8,"%dmi", (int)pow(10,scalePower));
|
snprintf(scaleLabel,8,"%dmi", (int)pow(10,scalePower));
|
||||||
}
|
}
|
||||||
|
|
||||||
drawString(scaleLabel, 10+scaleBarDist, 10*appData.screen_uiscale, appData.mapFont, pink);
|
drawString(scaleLabel, 10+scaleBarDist, 15*appData.screen_uiscale, appData.mapFont, pink);
|
||||||
|
|
||||||
scalePower++;
|
scalePower++;
|
||||||
scaleBarDist = screenDist((float)pow(10,scalePower));
|
scaleBarDist = screenDist((float)pow(10,scalePower));
|
||||||
|
@ -400,8 +406,8 @@ void drawScaleBars()
|
||||||
scalePower--;
|
scalePower--;
|
||||||
scaleBarDist = screenDist((float)pow(10,scalePower));
|
scaleBarDist = screenDist((float)pow(10,scalePower));
|
||||||
|
|
||||||
thickLineRGBA(appData.renderer,10,10+5*appData.screen_uiscale,10+scaleBarDist,10+5*appData.screen_uiscale,2,pink.r, pink.g, pink.b, 255);
|
// thickLineRGBA(appData.renderer,10,10+5*appData.screen_uiscale,10+scaleBarDist,10+5*appData.screen_uiscale,2,pink.r, pink.g, pink.b, 255);
|
||||||
|
lineRGBA(appData.renderer,10,10+5*appData.screen_uiscale,10+scaleBarDist,10+5*appData.screen_uiscale,pink.r, pink.g, pink.b, 255);
|
||||||
|
|
||||||
// int p1km = screenDist(1.0);
|
// int p1km = screenDist(1.0);
|
||||||
// int p10km = screenDist(10.0);
|
// int p10km = screenDist(10.0);
|
||||||
|
@ -608,7 +614,7 @@ void drawPlaneText(struct planeObj *p) {
|
||||||
char flight[10] = " ";
|
char flight[10] = " ";
|
||||||
maxCharCount = snprintf(flight,10," %s", p->flight);
|
maxCharCount = snprintf(flight,10," %s", p->flight);
|
||||||
|
|
||||||
if(maxCharCount > 0) {
|
if(maxCharCount > 1) {
|
||||||
drawStringBG(flight, p->x, p->y, appData.mapBoldFont, white, black);
|
drawStringBG(flight, p->x, p->y, appData.mapBoldFont, white, black);
|
||||||
//roundedRectangleRGBA(appData.renderer, p->x, p->y, p->x + maxCharCount * appData.mapFontWidth, p->y + appData.mapFontHeight, ROUND_RADIUS, white.r, white.g, white.b, SDL_ALPHA_OPAQUE);
|
//roundedRectangleRGBA(appData.renderer, p->x, p->y, p->x + maxCharCount * appData.mapFontWidth, p->y + appData.mapFontHeight, ROUND_RADIUS, white.r, white.g, white.b, SDL_ALPHA_OPAQUE);
|
||||||
//drawString(flight, p->x, p->y, appData.mapBoldFont, white);
|
//drawString(flight, p->x, p->y, appData.mapBoldFont, white);
|
||||||
|
@ -624,7 +630,7 @@ void drawPlaneText(struct planeObj *p) {
|
||||||
currentCharCount = snprintf(alt,10," %d'", p->altitude);
|
currentCharCount = snprintf(alt,10," %d'", p->altitude);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(currentCharCount > 0) {
|
if(currentCharCount > 1) {
|
||||||
drawStringBG(alt, p->x, p->y + currentLine * appData.mapFontHeight, appData.mapFont, grey, black);
|
drawStringBG(alt, p->x, p->y + currentLine * appData.mapFontHeight, appData.mapFont, grey, black);
|
||||||
currentLine++;
|
currentLine++;
|
||||||
}
|
}
|
||||||
|
@ -640,7 +646,7 @@ void drawPlaneText(struct planeObj *p) {
|
||||||
currentCharCount = snprintf(speed,10," %dmph", p->speed);
|
currentCharCount = snprintf(speed,10," %dmph", p->speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(currentCharCount > 0) {
|
if(currentCharCount > 1) {
|
||||||
drawStringBG(speed, p->x, p->y + currentLine * appData.mapFontHeight, appData.mapFont, grey, black);
|
drawStringBG(speed, p->x, p->y + currentLine * appData.mapFontHeight, appData.mapFont, grey, black);
|
||||||
currentLine++;
|
currentLine++;
|
||||||
}
|
}
|
||||||
|
@ -650,7 +656,7 @@ void drawPlaneText(struct planeObj *p) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(maxCharCount > 0) {
|
if(maxCharCount > 1) {
|
||||||
|
|
||||||
Sint16 vx[4] = {p->cx, p->cx + (p->x - p->cx) / 2, p->x, p->x};
|
Sint16 vx[4] = {p->cx, p->cx + (p->x - p->cx) / 2, p->x, p->x};
|
||||||
Sint16 vy[4] = {p->cy, p->cy + (p->y - p->cy) / 2, p->y - appData.mapFontHeight, p->y};
|
Sint16 vy[4] = {p->cy, p->cy + (p->y - p->cy) / 2, p->y - appData.mapFontHeight, p->y};
|
||||||
|
@ -670,10 +676,59 @@ void drawPlaneText(struct planeObj *p) {
|
||||||
p->h = currentLine * appData.mapFontHeight;
|
p->h = currentLine * appData.mapFontHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
float sign(float x) {
|
void drawSelectedPlaneText(struct planeObj *p) {
|
||||||
return (x > 0) - (x < 0);
|
if(p == NULL) {
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int x = p->cx - 20;
|
||||||
|
int y = p->cy + 22;
|
||||||
|
|
||||||
|
int maxCharCount = 0;
|
||||||
|
int currentCharCount;
|
||||||
|
|
||||||
|
int currentLine = 0;
|
||||||
|
|
||||||
|
drawSignalMarks(p, x, y);
|
||||||
|
|
||||||
|
char flight[10] = " ";
|
||||||
|
maxCharCount = snprintf(flight,10," %s", p->flight);
|
||||||
|
|
||||||
|
if(maxCharCount > 1) {
|
||||||
|
drawStringBG(flight, x, y, appData.mapBoldFont, white, black);
|
||||||
|
//roundedRectangleRGBA(appData.renderer, p->x, p->y, p->x + maxCharCount * appData.mapFontWidth, p->y + appData.mapFontHeight, ROUND_RADIUS, white.r, white.g, white.b, SDL_ALPHA_OPAQUE);
|
||||||
|
//drawString(flight, p->x, p->y, appData.mapBoldFont, white);
|
||||||
|
currentLine++;
|
||||||
|
}
|
||||||
|
|
||||||
|
char alt[10] = " ";
|
||||||
|
if (Modes.metric) {
|
||||||
|
currentCharCount = snprintf(alt,10," %dm", (int) (p->altitude / 3.2828));
|
||||||
|
} else {
|
||||||
|
currentCharCount = snprintf(alt,10," %d'", p->altitude);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(currentCharCount > 1) {
|
||||||
|
drawStringBG(alt, x, y + currentLine * appData.mapFontHeight, appData.mapFont, grey, black);
|
||||||
|
currentLine++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(currentCharCount > maxCharCount) {
|
||||||
|
maxCharCount = currentCharCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
char speed[10] = " ";
|
||||||
|
if (Modes.metric) {
|
||||||
|
currentCharCount = snprintf(speed,10," %dkm/h", (int) (p->speed * 1.852));
|
||||||
|
} else {
|
||||||
|
currentCharCount = snprintf(speed,10," %dmph", p->speed);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(currentCharCount > 1) {
|
||||||
|
drawStringBG(speed, x, y + currentLine * appData.mapFontHeight, appData.mapFont, grey, black);
|
||||||
|
currentLine++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void resolveLabelConflicts() {
|
void resolveLabelConflicts() {
|
||||||
struct planeObj *p = planes;
|
struct planeObj *p = planes;
|
||||||
|
@ -828,7 +883,7 @@ void resolveLabelConflicts() {
|
||||||
p = planes;
|
p = planes;
|
||||||
|
|
||||||
while(p) {
|
while(p) {
|
||||||
//incorporate accelerate from label conflict resolution
|
//incorporate acceleration from label conflict resolution
|
||||||
|
|
||||||
p->dox += p->ddox;
|
p->dox += p->ddox;
|
||||||
p->doy += p->ddoy;
|
p->doy += p->ddoy;
|
||||||
|
@ -919,30 +974,26 @@ void drawPlanes() {
|
||||||
usey = y + (mstime() - p->msSeenLatLon) * vely;
|
usey = y + (mstime() - p->msSeenLatLon) * vely;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((usex - appData.touchx) * (usex - appData.touchx) + (usey - appData.touchy) * (usey - appData.touchy) < 900) {
|
|
||||||
selectedPlane = p;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(p == selectedPlane) {
|
if(p == selectedPlane) {
|
||||||
|
|
||||||
if(fabs(p->lon - appData.centerLon) > 0.0001 || fabs(p->lat - appData.centerLat) > .0001) {
|
if(fabs(p->lon - appData.centerLon) > 0.0001 || fabs(p->lat - appData.centerLat) > 0.0001) {
|
||||||
appData.centerLon += 0.1 * (p->lon - appData.centerLon);
|
appData.centerLon += 0.1 * (p->lon - appData.centerLon);
|
||||||
appData.centerLat += 0.1 * (p->lat - appData.centerLat);
|
appData.centerLat += 0.1 * (p->lat - appData.centerLat);
|
||||||
|
|
||||||
appData.mapMoved = 1;
|
appData.mapMoved = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
thickLineRGBA(appData.renderer, x - 40, y - 40, x - 10, y - 40, 4, pink.r, pink.g, pink.b, 255);
|
lineRGBA(appData.renderer, usex - 20, usey - 20, usex - 5, usey - 20, pink.r, pink.g, pink.b, 255);
|
||||||
thickLineRGBA(appData.renderer, x - 40, y - 40, x - 40, y - 10, 4, pink.r, pink.g, pink.b, 255);
|
lineRGBA(appData.renderer, usex - 20, usey - 20, usex - 20, usey - 5, pink.r, pink.g, pink.b, 255);
|
||||||
|
|
||||||
thickLineRGBA(appData.renderer, x + 40, y - 40, x + 10, y - 40, 4, pink.r, pink.g, pink.b, 255);
|
lineRGBA(appData.renderer, usex + 20, usey - 20, usex + 5, usey - 20, pink.r, pink.g, pink.b, 255);
|
||||||
thickLineRGBA(appData.renderer, x + 40, y - 40, x + 40, y - 10, 4, pink.r, pink.g, pink.b, 255);
|
lineRGBA(appData.renderer, usex + 20, usey - 20, usex + 20, usey - 5, pink.r, pink.g, pink.b, 255);
|
||||||
|
|
||||||
thickLineRGBA(appData.renderer, x + 40, y + 40, x + 10, y + 40, 4, pink.r, pink.g, pink.b, 255);
|
lineRGBA(appData.renderer, usex + 20, usey + 20, usex + 5, usey + 20, pink.r, pink.g, pink.b, 255);
|
||||||
thickLineRGBA(appData.renderer, x + 40, y + 40, x + 40, y + 10, 4, pink.r, pink.g, pink.b, 255);
|
lineRGBA(appData.renderer, usex + 20, usey + 20, usex + 20, usey + 5, pink.r, pink.g, pink.b, 255);
|
||||||
|
|
||||||
thickLineRGBA(appData.renderer, x - 40, y + 40, x - 10, y + 40, 4, pink.r, pink.g, pink.b, 255);
|
lineRGBA(appData.renderer, usex - 20, usey + 20, usex - 5, usey + 20, pink.r, pink.g, pink.b, 255);
|
||||||
thickLineRGBA(appData.renderer, x - 40, y + 40, x - 40, y + 10, 4, pink.r, pink.g, pink.b, 255);
|
lineRGBA(appData.renderer, usex - 20, usey + 20, usex - 20, usey + 5, pink.r, pink.g, pink.b, 255);
|
||||||
planeColor = lerpColor(pink, grey, (now - p->seen) / (float) DISPLAY_ACTIVE);
|
planeColor = lerpColor(pink, grey, (now - p->seen) / (float) DISPLAY_ACTIVE);
|
||||||
} else {
|
} else {
|
||||||
planeColor = lerpColor(green, grey, (now - p->seen) / (float) DISPLAY_ACTIVE);
|
planeColor = lerpColor(green, grey, (now - p->seen) / (float) DISPLAY_ACTIVE);
|
||||||
|
@ -967,9 +1018,13 @@ void drawPlanes() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if((p->cx - appData.touchx) * (p->cx - appData.touchx) + (p->cy - appData.touchy) * (p->cy - appData.touchy) < 900) {
|
||||||
|
selectedPlane = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(p != selectedPlane) {
|
||||||
drawPlaneText(p);
|
drawPlaneText(p);
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
//drawPlane(x, y, planeColor);
|
//drawPlane(x, y, planeColor);
|
||||||
|
@ -980,6 +1035,7 @@ void drawPlanes() {
|
||||||
p = p->next;
|
p = p->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
drawSelectedPlaneText(selectedPlane);
|
||||||
|
|
||||||
if(appData.touchx && appData.touchy) {
|
if(appData.touchx && appData.touchy) {
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
e35f478e482bb67eed7951d8c622b7fc5ad06aa7
|
4ae8e7876cd2e093957fa204a0d05b37b84446e9
|
|
@ -1 +1 @@
|
||||||
8796641d884a28c9d0b97396f099bd3333607849
|
edf88a35375fe1494f482826638f6a8879c9f1cb
|
Loading…
Reference in a new issue