added touch to center and track planes

Former-commit-id: 86d982e51aef694aa509793340d5596eeba59ef4
Former-commit-id: b8d2b83f47121d34ad0c9cfbdd7c8f71bd90b679
This commit is contained in:
nathan 2020-02-17 18:11:05 -08:00
parent 0d01589322
commit 72763a5ba7
13 changed files with 63 additions and 31 deletions

70
draw.c
View file

@ -48,6 +48,23 @@ SDL_Color signalToColor(int signal) {
return planeColor;
}
SDL_Color lerpColor(SDL_Color aColor, SDL_Color bColor, float factor) {
if(factor > 1.0f) {
factor = 1.0f;
}
if(factor < 0.0f) {
factor = 0.0f;
}
SDL_Color out;
out.r = (1.0f - factor) * aColor.r + factor * bColor.r;
out.g = (1.0f - factor) * aColor.g + factor * bColor.g;
out.b = (1.0f - factor) * aColor.b + factor * bColor.b;
return out;
}
SDL_Color hsv2SDLColor(double h, double s, double v)
{
double hh, p, q, t, ff;
@ -519,9 +536,11 @@ void drawPolys(QuadTree *tree, double screen_lat_min, double screen_lat_max, dou
double d2 = dx* dx + dy * dy;
double alpha = 1.0 - (d1+d2) / (3* appData.maxDist * appData.maxDist);
double factor = 1.0 - (d1+d2) / (3* appData.maxDist * appData.maxDist);
lineRGBA(appData.renderer, x1, y1, x2, y2, alpha * purple.r + (1.0-alpha) * blue.r, alpha * purple.g + (1.0-alpha) * blue.g, alpha * purple.b + (1.0-alpha) * blue.b, 255 * alpha);
SDL_Color lineColor = lerpColor(blue, purple, factor);
lineRGBA(appData.renderer, x1, y1, x2, y2, lineColor.r, lineColor.g, lineColor.b, 255);
prevPoint = currentPoint;
currentPoint = currentPoint->next;
@ -881,17 +900,6 @@ void drawMap() {
pxFromLonLat(&dx, &dy, p->lon, p->lat);
screenCoords(&x, &y, dx, dy);
if((int)(now - p->seen) > DISPLAY_ACTIVE) {
planeColor = grey;
} else {
planeColor = green;
//srand(p->addr);
// planeColor = hsv2SDLColor(255.0 * (double)rand()/(double)RAND_MAX, 255.0, 200.0);
//planeColor = signalToColor((int)(255.0f * (float)rand()/(float)RAND_MAX));
//fprintf("%d %d %d\n", planeColor.r, planeColor.g, planeColor.b);
}
if(p->created == 0) {
p->created = mstime();
}
@ -901,7 +909,7 @@ void drawMap() {
circleRGBA(appData.renderer, x, y, 500 - age_ms, 255,255, 255, (uint8_t)(255.0 * age_ms / 500.0));
} else {
if(MODES_ACFLAGS_HEADING_VALID) {
int usex = x;
int usex = x;
int usey = y;
if(p->seenLatLon > p->oldSeen[p->oldIdx]) {
@ -918,6 +926,34 @@ void drawMap() {
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) {
appData.centerLon += 0.1 * (p->lon - appData.centerLon);
appData.centerLat += 0.1 * (p->lat - appData.centerLat);
thickLineRGBA(appData.renderer, x - 40, y - 40, x - 10, y - 40, 4, 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);
thickLineRGBA(appData.renderer, x + 40, y - 40, x + 10, y - 40, 4, 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);
thickLineRGBA(appData.renderer, x + 40, y + 40, x + 10, y + 40, 4, 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);
thickLineRGBA(appData.renderer, x - 40, y + 40, x - 10, y + 40, 4, 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);
planeColor = lerpColor(pink, grey, (now - p->seen) / (float) DISPLAY_ACTIVE);
} else {
planeColor = lerpColor(green, grey, (now - p->seen) / (float) DISPLAY_ACTIVE);
}
// if((int)(now - p->seen) > DISPLAY_ACTIVE) {
// planeColor = grey;
// }
if(outOfBounds(x,y)) {
drawPlaneOffMap(x, y, &(p->cx), &(p->cy), planeColor);
@ -950,15 +986,15 @@ void drawMap() {
if(appData.touchx && appData.touchy) {
int radius = (mstime() - appData.touchDownTime);
int alpha = 255 - (int)(0.5 * (mstime() - appData.touchDownTime));
int radius = .25 * (mstime() - appData.touchDownTime);
int alpha = 128 - (int)(0.5 * (mstime() - appData.touchDownTime));
if(alpha < 0 ) {
alpha = 0;
appData.touchx = 0;
appData.touchy = 0;
}
circleRGBA(appData.renderer, appData.touchx, appData.touchy, radius, white.r, white.g, white.b, alpha);
filledCircleRGBA(appData.renderer, appData.touchx, appData.touchy, radius, white.r, white.g, white.b, alpha);
}
}

View file

@ -1 +1 @@
1d914216fcda8f2b793acf12bfbfddfb24809c94
d08aaa37cf2b39ef11671ed4f318ae82fcf0c1dd

BIN
font.o

Binary file not shown.

BIN
init.o

Binary file not shown.

11
input.c
View file

@ -83,17 +83,10 @@ void getInput()
case SDL_FINGERUP:
if(mstime() - appData.touchDownTime < 30) {
//latLonFromScreenCoords(&(appData.touchLat), &(appData.touchLon), event.tfinger.x, event.tfinger.y);
// double scale_factor = (appData.screen_width > appData.screen_height) ? appData.screen_width : appData.screen_height;
// double dx = -1.0 * (0.75*(double)appData.screen_width / (double)appData.screen_height) * appData.screen_width * event.tfinger.x * appData.maxDist / (0.95 * scale_factor * 0.5);
// double dy = 1.0 * appData.screen_height * event.tfinger.y * appData.maxDist / (0.95 * scale_factor * 0.5);
// appData.touchLat = dy * (1.0/6371.0) * (180.0f / M_PI);
// appData.touchLon = dx * (1.0/6371.0) * (180.0f / M_PI) / cos(((appData.centerLat)/2.0f) * M_PI / 180.0f);
appData.touchx = appData.screen_width * event.tfinger.x;
appData.touchy = appData.screen_height * event.tfinger.y;
selectedPlane = NULL;
} else {
appData.touchx = 0;
appData.touchy = 0;

View file

@ -1 +1 @@
4014ada04a2708aebb111395550edf352c684f96
71b217637379d15bac063de1731f31a46620dce5

BIN
list.o

Binary file not shown.

BIN
monokai.o

Binary file not shown.

Binary file not shown.

View file

@ -1 +1 @@
ec8f0fb7706c5fa30afa98ef72cf1c6277615e5c
006a8fe10b2ac3777a05e5056d4166533ad2fae5

View file

@ -86,6 +86,9 @@ struct planeObj {
struct planeObj *planes;
struct planeObj *selectedPlane;
struct {
double msgRate;
double avgSig;

View file

@ -1 +1 @@
4c1cc2ef49ee01e71918440dd30dd506c50f2a13
607b9efc8cc81bbdd0c6f524632fc9b69ab1e244

View file

@ -1 +1 @@
c32a44e5918f8a87926408a39f094f258c9f76e6
188de208d70a8a746cda5dd29c243ac3053a9c0c