setting up display for round screens
This commit is contained in:
parent
43d4edebee
commit
e549aab7c4
|
@ -161,21 +161,63 @@ void AircraftLabel::calculateForces(Aircraft *check_p) {
|
||||||
|
|
||||||
// screen edge
|
// screen edge
|
||||||
|
|
||||||
if(p_left < edge_margin) {
|
if(roundScreen) {
|
||||||
ddx += boundary_force * static_cast<float>(edge_margin - p_left);
|
float radius = screen_width >> 1;
|
||||||
|
|
||||||
|
//left top
|
||||||
|
|
||||||
|
if((p_left - radius) * (p_left - radius) + (p_top - radius) * (p_top - radius) > ((radius - edge_margin) * (radius - edge_margin))) {
|
||||||
|
float pointnorm = sqrt((p_left - radius) * (p_left - radius) + (p_top - radius) * (p_top - radius));
|
||||||
|
|
||||||
|
ddx += boundary_force * (radius * (p_left - radius) / pointnorm - (p_left - radius));
|
||||||
|
ddy += boundary_force * (radius * (p_top - radius) / pointnorm - (p_top - radius));
|
||||||
|
}
|
||||||
|
|
||||||
|
//left bottom
|
||||||
|
|
||||||
|
if((p_left - radius) * (p_left - radius) + (p_bottom - radius) * (p_bottom - radius) > ((radius - edge_margin) * (radius - edge_margin))) {
|
||||||
|
float pointnorm = sqrt((p_left - radius) * (p_left - radius) + (p_bottom - radius) * (p_bottom - radius));
|
||||||
|
|
||||||
|
ddx += boundary_force * (radius * (p_left - radius) / pointnorm - (p_left - radius));
|
||||||
|
ddy += boundary_force * (radius * (p_bottom - radius) / pointnorm - (p_bottom - radius));
|
||||||
|
}
|
||||||
|
|
||||||
|
//right top
|
||||||
|
|
||||||
|
if((p_right - radius) * (p_right - radius) + (p_top - radius) * (p_top - radius) > ((radius - edge_margin) * (radius - edge_margin))) {
|
||||||
|
float pointnorm = sqrt((p_right - radius) * (p_right - radius) + (p_top - radius) * (p_top - radius));
|
||||||
|
|
||||||
|
ddx += boundary_force * (radius * (p_right - radius) / pointnorm - (p_right - radius));
|
||||||
|
ddy += boundary_force * (radius * (p_top - radius) / pointnorm - (p_top - radius));
|
||||||
|
}
|
||||||
|
|
||||||
|
//right bottom
|
||||||
|
|
||||||
|
if((p_right - radius) * (p_right - radius) + (p_bottom - radius) * (p_bottom - radius) > ((radius - edge_margin) * (radius - edge_margin))) {
|
||||||
|
float pointnorm = sqrt((p_right - radius) * (p_right - radius) + (p_bottom - radius) * (p_bottom - radius));
|
||||||
|
|
||||||
|
ddx += boundary_force * (radius * (p_right - radius) / pointnorm - (p_right- radius));
|
||||||
|
ddy += boundary_force * (radius * (p_bottom - radius) / pointnorm - (p_bottom - radius));
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if(p_left < edge_margin) {
|
||||||
|
ddx += boundary_force * static_cast<float>(edge_margin - p_left);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(p_right > screen_width - edge_margin) {
|
||||||
|
ddx += boundary_force * static_cast<float>(screen_width - edge_margin - p_right);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(p_top < edge_margin) {
|
||||||
|
ddy += boundary_force * static_cast<float>(edge_margin - p_top);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(p_bottom > screen_height - edge_margin) {
|
||||||
|
ddy += boundary_force * static_cast<float>(screen_height - edge_margin - p_bottom);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(p_right > screen_width - edge_margin) {
|
|
||||||
ddx += boundary_force * static_cast<float>(screen_width - edge_margin - p_right);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(p_top < edge_margin) {
|
|
||||||
ddy += boundary_force * static_cast<float>(edge_margin - p_top);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(p_bottom > screen_height - edge_margin) {
|
|
||||||
ddy += boundary_force * static_cast<float>(screen_height - edge_margin - p_bottom);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
float all_x = 0;
|
float all_x = 0;
|
||||||
|
@ -253,7 +295,7 @@ void AircraftLabel::calculateForces(Aircraft *check_p) {
|
||||||
// snprintf(buff, sizeof(buff), "%2.2f", labelLevel);
|
// snprintf(buff, sizeof(buff), "%2.2f", labelLevel);
|
||||||
// debugLabel.setText(buff);
|
// debugLabel.setText(buff);
|
||||||
|
|
||||||
float density_mult = 0.5f;
|
float density_mult = 0.9f;
|
||||||
float level_rate = 0.25f;
|
float level_rate = 0.25f;
|
||||||
|
|
||||||
if(elapsed(lastLevelChange) > 1000.0) {
|
if(elapsed(lastLevelChange) > 1000.0) {
|
||||||
|
@ -504,10 +546,11 @@ void AircraftLabel::draw(SDL_Renderer *renderer, bool selected) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AircraftLabel::AircraftLabel(Aircraft *p, bool metric, int screen_width, int screen_height, TTF_Font *font) {
|
AircraftLabel::AircraftLabel(Aircraft *p, bool metric, bool roundScreen, int screen_width, int screen_height, TTF_Font *font) {
|
||||||
this->p = p;
|
this->p = p;
|
||||||
|
|
||||||
this->metric = metric;
|
this->metric = metric;
|
||||||
|
this->roundScreen = roundScreen;
|
||||||
|
|
||||||
x = p->x;
|
x = p->x;
|
||||||
y = p->y + 20; //*screen_uiscale
|
y = p->y + 20; //*screen_uiscale
|
||||||
|
@ -535,4 +578,4 @@ AircraftLabel::AircraftLabel(Aircraft *p, bool metric, int screen_width, int scr
|
||||||
debugLabel.setFont(font);
|
debugLabel.setFont(font);
|
||||||
|
|
||||||
lastLevelChange = now();
|
lastLevelChange = now();
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ class AircraftLabel {
|
||||||
|
|
||||||
void draw(SDL_Renderer *renderer, bool selected);
|
void draw(SDL_Renderer *renderer, bool selected);
|
||||||
|
|
||||||
AircraftLabel(Aircraft *p, bool metric, int screen_width, int screen_height, TTF_Font *font);
|
AircraftLabel(Aircraft *p, bool metric, bool roundScreen, int screen_width, int screen_height, TTF_Font *font);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SDL_Rect getFullRect(int labelLevel);
|
SDL_Rect getFullRect(int labelLevel);
|
||||||
|
@ -35,6 +35,8 @@ class AircraftLabel {
|
||||||
|
|
||||||
bool metric;
|
bool metric;
|
||||||
|
|
||||||
|
bool roundScreen;
|
||||||
|
|
||||||
float x;
|
float x;
|
||||||
float y;
|
float y;
|
||||||
float w;
|
float w;
|
||||||
|
|
14
Style.h
14
Style.h
|
@ -39,11 +39,11 @@ typedef struct Style {
|
||||||
//
|
//
|
||||||
// todo separate style stuff
|
// todo separate style stuff
|
||||||
//
|
//
|
||||||
|
|
||||||
Style() {
|
Style() {
|
||||||
|
|
||||||
SDL_Color pink = {249,38,114,255};
|
SDL_Color pink = {249,38,114,255};
|
||||||
|
|
||||||
SDL_Color purple = {85, 0, 255,255};
|
SDL_Color purple = {85, 0, 255,255};
|
||||||
SDL_Color purple_dark = {33, 0, 122,255};
|
SDL_Color purple_dark = {33, 0, 122,255};
|
||||||
|
|
||||||
|
@ -68,15 +68,15 @@ typedef struct Style {
|
||||||
blue = {0,0,255,255};
|
blue = {0,0,255,255};
|
||||||
|
|
||||||
|
|
||||||
backgroundColor = black;
|
backgroundColor = {0,0,0,255};
|
||||||
|
|
||||||
selectedColor = pink;
|
selectedColor = pink;
|
||||||
planeColor = yellow;
|
planeColor = {0,255,174};
|
||||||
planeGoneColor = grey;
|
planeGoneColor = grey;
|
||||||
trailColor = yellow_dark;
|
trailColor = {0,255,174};
|
||||||
|
|
||||||
geoColor = purple_dark;
|
geoColor = grey_dark;
|
||||||
airportColor = purple;
|
airportColor = grey;
|
||||||
|
|
||||||
labelColor = white;
|
labelColor = white;
|
||||||
labelLineColor = grey_dark;
|
labelLineColor = grey_dark;
|
||||||
|
|
68
View.cpp
68
View.cpp
|
@ -135,7 +135,11 @@ void View::screenCoords(int *outX, int *outY, float dx, float dy) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int View::outOfBounds(int x, int y) {
|
int View::outOfBounds(int x, int y) {
|
||||||
return outOfBounds(x, y, 0, 0, screen_width, screen_height);
|
if(roundScreen) {
|
||||||
|
return outOfBounds(x, y, screen_width >> 1);
|
||||||
|
} else {
|
||||||
|
return outOfBounds(x, y, 0, 0, screen_width, screen_height);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int View::outOfBounds(int x, int y, int left, int top, int right, int bottom) {
|
int View::outOfBounds(int x, int y, int left, int top, int right, int bottom) {
|
||||||
|
@ -146,6 +150,21 @@ int View::outOfBounds(int x, int y, int left, int top, int right, int bottom) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int View::outOfBounds(int x, int y, int radius) {
|
||||||
|
float f_radius = static_cast<float>(radius);
|
||||||
|
float f_x = static_cast<float>(x);
|
||||||
|
float f_y = static_cast<float>(y);
|
||||||
|
|
||||||
|
if((f_x - f_radius) * (f_x - f_radius) + (f_y - f_radius) * (f_y - f_radius) > (f_radius * f_radius)) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Fonts should probably go in Style
|
// Fonts should probably go in Style
|
||||||
//
|
//
|
||||||
|
@ -290,6 +309,10 @@ void View::drawStatusBox(int *left, int *top, std::string label, std::string mes
|
||||||
|
|
||||||
void View::drawStatus() {
|
void View::drawStatus() {
|
||||||
|
|
||||||
|
if(roundScreen) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int left = PAD;
|
int left = PAD;
|
||||||
int top = screen_height - messageFontHeight - PAD;
|
int top = screen_height - messageFontHeight - PAD;
|
||||||
|
|
||||||
|
@ -321,28 +344,35 @@ void View::drawPlaneOffMap(int x, int y, int *returnx, int *returny, SDL_Color p
|
||||||
|
|
||||||
float inx = x - (screen_width>>1);
|
float inx = x - (screen_width>>1);
|
||||||
float iny = y - (screen_height>>1);
|
float iny = y - (screen_height>>1);
|
||||||
|
|
||||||
float outx, outy;
|
float outx, outy;
|
||||||
outx = inx;
|
outx = inx;
|
||||||
outy = iny;
|
outy = iny;
|
||||||
|
|
||||||
if(abs(inx) > abs(y - (screen_height>>1)) * static_cast<float>(screen_width>>1) / static_cast<float>(screen_height>>1)) { //left / right quadrants
|
|
||||||
outx = (screen_width>>1) * ((inx > 0) ? 1.0 : -1.0);
|
|
||||||
outy = (outx) * iny / (inx);
|
|
||||||
} else { // up / down quadrants
|
|
||||||
outy = screen_height * ((iny > 0) ? 0.5 : -0.5 );
|
|
||||||
outx = (outy) * inx / (iny);
|
|
||||||
}
|
|
||||||
|
|
||||||
// circleRGBA (renderer,(screen_width>>1) + outx, screen_height * CENTEROFFSET + outy,50,planeColor.r,planeColor.g,planeColor.b,SDL_ALPHA_OPAQUE);
|
|
||||||
// thickLineRGBA(renderer,screen_width>>1,screen_height * CENTEROFFSET, (screen_width>>1) + outx, screen_height * CENTEROFFSET + outy,arrowWidth,planeColor.r,planeColor.g,planeColor.b,SDL_ALPHA_OPAQUE);
|
|
||||||
|
|
||||||
float inmag = sqrt(inx *inx + iny*iny);
|
float inmag = sqrt(inx *inx + iny*iny);
|
||||||
float vec[3];
|
float vec[3];
|
||||||
vec[0] = inx / inmag;
|
vec[0] = inx / inmag;
|
||||||
vec[1] = iny /inmag;
|
vec[1] = iny /inmag;
|
||||||
vec[2] = 0;
|
vec[2] = 0;
|
||||||
|
|
||||||
|
if(roundScreen) {
|
||||||
|
outx = vec[0] * (screen_width>>1);
|
||||||
|
outy = vec[1] * (screen_width>>1);
|
||||||
|
} else {
|
||||||
|
if(abs(inx) > abs(y - (screen_height>>1)) * static_cast<float>(screen_width>>1) / static_cast<float>(screen_height>>1)) { //left / right quadrants
|
||||||
|
outx = (screen_width>>1) * ((inx > 0) ? 1.0 : -1.0);
|
||||||
|
outy = (outx) * iny / (inx);
|
||||||
|
} else { // up / down quadrants
|
||||||
|
outy = screen_height * ((iny > 0) ? 0.5 : -0.5 );
|
||||||
|
outx = (outy) * inx / (iny);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// circleRGBA (renderer,(screen_width>>1) + outx, screen_height * CENTEROFFSET + outy,50,planeColor.r,planeColor.g,planeColor.b,SDL_ALPHA_OPAQUE);
|
||||||
|
// thickLineRGBA(renderer,screen_width>>1,screen_height * CENTEROFFSET, (screen_width>>1) + outx, screen_height * CENTEROFFSET + outy,arrowWidth,planeColor.r,planeColor.g,planeColor.b,SDL_ALPHA_OPAQUE);
|
||||||
|
|
||||||
|
|
||||||
float up[] = {0,0,1};
|
float up[] = {0,0,1};
|
||||||
|
|
||||||
float out[3];
|
float out[3];
|
||||||
|
@ -487,6 +517,10 @@ void View::drawTrails(int left, int top, int right, int bottom) {
|
||||||
|
|
||||||
void View::drawScaleBars()
|
void View::drawScaleBars()
|
||||||
{
|
{
|
||||||
|
if(roundScreen) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int scalePower = 0;
|
int scalePower = 0;
|
||||||
int scaleBarDist = screenDist((float)pow(10,scalePower));
|
int scaleBarDist = screenDist((float)pow(10,scalePower));
|
||||||
|
|
||||||
|
@ -737,7 +771,7 @@ void View::drawGeography() {
|
||||||
|
|
||||||
void View::drawPlaneText(Aircraft *p) {
|
void View::drawPlaneText(Aircraft *p) {
|
||||||
if(!p->label) {
|
if(!p->label) {
|
||||||
p->label = new AircraftLabel(p,metric,screen_width, screen_height, mapFont);
|
p->label = new AircraftLabel(p,metric, roundScreen, screen_width, screen_height, mapFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
p->label->update();
|
p->label->update();
|
||||||
|
@ -838,7 +872,7 @@ void View::drawPlanes() {
|
||||||
|
|
||||||
//show latlon ping
|
//show latlon ping
|
||||||
if(elapsed(p->msSeenLatLon) < 500) {
|
if(elapsed(p->msSeenLatLon) < 500) {
|
||||||
circleRGBA(renderer, p->x, p->y, elapsed(p->msSeenLatLon) * screen_width / (8192), 127,127, 127, 255 - (uint8_t)(255.0 * elapsed(p->msSeenLatLon) / 500.0));
|
circleRGBA(renderer, p->x, p->y, 20 * elapsed(p->msSeenLatLon) / 500, 127,127, 127, 255 - (uint8_t)(255.0 * elapsed(p->msSeenLatLon) / 500.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
drawPlaneText(p);
|
drawPlaneText(p);
|
||||||
|
@ -1092,6 +1126,10 @@ View::View(AppData *appData){
|
||||||
fullscreen = 0;
|
fullscreen = 0;
|
||||||
screen_index = 0;
|
screen_index = 0;
|
||||||
|
|
||||||
|
metric = 0;
|
||||||
|
|
||||||
|
roundScreen = 0;
|
||||||
|
|
||||||
centerLon = 0;
|
centerLon = 0;
|
||||||
centerLat = 0;
|
centerLat = 0;
|
||||||
|
|
||||||
|
|
3
View.h
3
View.h
|
@ -97,6 +97,7 @@ class View {
|
||||||
void screenCoords(int *outX, int *outY, float dx, float dy);
|
void screenCoords(int *outX, int *outY, float dx, float dy);
|
||||||
int outOfBounds(int x, int y);
|
int outOfBounds(int x, int y);
|
||||||
int outOfBounds(int x, int y, int left, int top, int right, int bottom);
|
int outOfBounds(int x, int y, int left, int top, int right, int bottom);
|
||||||
|
int outOfBounds(int x, int y, int radius);
|
||||||
void drawPlaneOffMap(int x, int y, int *returnx, int *returny, SDL_Color planeColor);
|
void drawPlaneOffMap(int x, int y, int *returnx, int *returny, SDL_Color planeColor);
|
||||||
void drawPlaneIcon(int x, int y, float heading, SDL_Color planeColor);
|
void drawPlaneIcon(int x, int y, float heading, SDL_Color planeColor);
|
||||||
void drawTrails(int left, int top, int right, int bottom);
|
void drawTrails(int left, int top, int right, int bottom);
|
||||||
|
@ -130,6 +131,8 @@ class View {
|
||||||
////////////////
|
////////////////
|
||||||
bool metric;
|
bool metric;
|
||||||
|
|
||||||
|
bool roundScreen;
|
||||||
|
|
||||||
bool fps;
|
bool fps;
|
||||||
|
|
||||||
float maxDist;
|
float maxDist;
|
||||||
|
|
|
@ -55,6 +55,7 @@ void showHelp(void) {
|
||||||
"--lon <longitude> Longitude in degrees\n"
|
"--lon <longitude> Longitude in degrees\n"
|
||||||
"--metric Use metric units\n"
|
"--metric Use metric units\n"
|
||||||
"--port <port> TCP Beast output listen port (default: 30005)\n"
|
"--port <port> TCP Beast output listen port (default: 30005)\n"
|
||||||
|
"--round Use round display outline (assumes square screen size\n"
|
||||||
"--server <IPv4/hosname> TCP Beast output listen IPv4 (default: 127.0.0.1)\n"
|
"--server <IPv4/hosname> TCP Beast output listen IPv4 (default: 127.0.0.1)\n"
|
||||||
"--screensize <width> <height> Set frame buffer resolution (default: screen resolution)\n"
|
"--screensize <width> <height> Set frame buffer resolution (default: screen resolution)\n"
|
||||||
"--screenindex <i> Set the index of the display to use (default: 0)\n"
|
"--screenindex <i> Set the index of the display to use (default: 0)\n"
|
||||||
|
@ -99,6 +100,8 @@ int main(int argc, char **argv) {
|
||||||
view.fps = 1;
|
view.fps = 1;
|
||||||
} else if (!strcmp(argv[j],"--fullscreen")) {
|
} else if (!strcmp(argv[j],"--fullscreen")) {
|
||||||
view.fullscreen = 1;
|
view.fullscreen = 1;
|
||||||
|
} else if (!strcmp(argv[j],"--round")) {
|
||||||
|
view.roundScreen = 1;
|
||||||
} else if (!strcmp(argv[j],"--screenindex")) {
|
} else if (!strcmp(argv[j],"--screenindex")) {
|
||||||
view.screen_index = atoi(argv[++j]);
|
view.screen_index = atoi(argv[++j]);
|
||||||
} else if (!strcmp(argv[j],"--uiscale") && more) {
|
} else if (!strcmp(argv[j],"--uiscale") && more) {
|
||||||
|
|
Loading…
Reference in a new issue