From 9b5cab173eb485c8848f6faf2201bf6a14b636fb Mon Sep 17 00:00:00 2001 From: nathan Date: Wed, 18 Mar 2020 22:38:00 -0700 Subject: [PATCH] removed defs.h and structs.h Former-commit-id: 63229bbc5bf3fb105b945f7b3e3025e624324193 Former-commit-id: f37adedb0101d03a37bfe83f09165dc83adf12cd --- Aircraft.h | 1 - AppData.cpp | 1 + AppData.h | 4 +++- Input.cpp | 14 ++++++------ Input.h | 1 - View.cpp | 8 +++---- View.h | 44 ++++++++++++++++++++++++++++++++++++-- defs.h | 21 ------------------ map1090.REMOVED.git-id | 2 +- map1090.cpp | 2 -- monokai.h | 2 +- structs.h | 48 ------------------------------------------ 12 files changed, 58 insertions(+), 90 deletions(-) delete mode 100644 defs.h delete mode 100644 structs.h diff --git a/Aircraft.h b/Aircraft.h index 68c94e0..2a0c857 100644 --- a/Aircraft.h +++ b/Aircraft.h @@ -1,5 +1,4 @@ #include -#include "defs.h" #include "dump1090.h" #include #include diff --git a/AppData.cpp b/AppData.cpp index 568ef20..20b7578 100644 --- a/AppData.cpp +++ b/AppData.cpp @@ -97,6 +97,7 @@ void AppData::updateStatus() { // struct aircraft *a = Modes.aircrafts; numVisiblePlanes = 0; + numPlanes = 0; maxDist = 0; totalCount = 0; sigAccumulate = 0.0; diff --git a/AppData.h b/AppData.h index 10e2e30..1471568 100644 --- a/AppData.h +++ b/AppData.h @@ -3,7 +3,6 @@ #include "dump1090.h" #include "view1090.h" -#include "structs.h" #include "AircraftList.h" @@ -33,9 +32,12 @@ class AppData { char server[32]; int numVisiblePlanes; + int numPlanes; double maxDist; int totalCount; + double avgSig; double sigAccumulate; + double msgRate; double msgRateAccumulate; }; diff --git a/Input.cpp b/Input.cpp index 2b42cc1..490ba05 100644 --- a/Input.cpp +++ b/Input.cpp @@ -55,10 +55,14 @@ void Input::getInput() view->maxDist /=1.0 + 4.0*event.mgesture.dDist; view->mapTargetMaxDist = 0; view->mapMoved = 1; + + if(mstime() - touchDownTime > 100) { + touchDownTime = 0; + } break; case SDL_FINGERMOTION:; - isDragging = 1; + touchDownTime = 0; view->moveCenterRelative( view->screen_width * event.tfinger.dx, view->screen_height * event.tfinger.dy); break; @@ -70,9 +74,7 @@ void Input::getInput() break; case SDL_FINGERUP: - if(isDragging) { - isDragging = 0; - } else if(mstime() - touchDownTime < 120) { + if(mstime() - touchDownTime < 120) { touchx = view->screen_width * event.tfinger.x; touchy = view->screen_height * event.tfinger.y; tapCount++; @@ -99,7 +101,6 @@ void Input::getInput() touchx = event.motion.x; touchy = event.motion.y; tapCount = event.button.clicks; - isDragging = 0; view->registerClick(tapCount, touchx, touchy); } @@ -111,7 +112,6 @@ void Input::getInput() view->registerMouseMove(event.motion.x, event.motion.y); if (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_LEFT)) { - isDragging = 1; view->moveCenterRelative(event.motion.xrel, event.motion.yrel); } } @@ -123,8 +123,6 @@ void Input::getInput() Input::Input(AppData *appData, View *view) { this->view = view; this->appData = appData; - - isDragging = 0; } diff --git a/Input.h b/Input.h index cfb6bcb..9e6e6f0 100644 --- a/Input.h +++ b/Input.h @@ -18,7 +18,6 @@ public: int touchx; int touchy; int tapCount; - int isDragging; }; #endif \ No newline at end of file diff --git a/View.cpp b/View.cpp index 0e5df96..702e4cd 100644 --- a/View.cpp +++ b/View.cpp @@ -1,5 +1,5 @@ #include "dump1090.h" -#include "structs.h" + #include "SDL2/SDL2_rotozoom.h" #include "SDL2/SDL2_gfxPrimitives.h" //color schemes @@ -400,15 +400,15 @@ void View::drawStatus() { drawStatusBox(&left, &top, "loc", strLoc, style.buttonColor); char strPlaneCount[10] = " "; - snprintf(strPlaneCount, 10,"%d/%d", Status.numVisiblePlanes, Status.numPlanes); + snprintf(strPlaneCount, 10,"%d/%d", appData->numVisiblePlanes, appData->numPlanes); drawStatusBox(&left, &top, "disp", strPlaneCount, style.buttonColor); char strMsgRate[18] = " "; - snprintf(strMsgRate, 18,"%.0f/s", Status.msgRate); + snprintf(strMsgRate, 18,"%.0f/s", appData->msgRate); drawStatusBox(&left, &top, "rate", strMsgRate, style.buttonColor); char strSig[18] = " "; - snprintf(strSig, 18, "%.0f%%", 100.0 * Status.avgSig / 1024.0); + snprintf(strSig, 18, "%.0f%%", 100.0 * appData->avgSig / 1024.0); drawStatusBox(&left, &top, "sAvg", strSig, style.buttonColor); } diff --git a/View.h b/View.h index c3e87a9..d8a12ba 100644 --- a/View.h +++ b/View.h @@ -1,10 +1,47 @@ #ifndef VIEW_H #define VIEW_H -#include "AppData.h" +#include "AppData.h" #include "Map.h" #include "SDL2/SDL.h" -#include "SDL2/SDL_ttf.h" +#include "SDL2/SDL_ttf.h" + +//defs - should all move to config file setup +#define ROUND_RADIUS 3 //radius of text box corners + +#define CENTEROFFSET .375 //vertical offset for middle of screen + +#define TRAIL_LENGTH 120 +#define TRAIL_TTL 240.0 +#define DISPLAY_ACTIVE 30 +#define TRAIL_TTL_STEP 2 + +#define MIN_MAP_FEATURE 2 + +#define FRAMETIME 33 + +#define PAD 5 + + + +// +// This should go to a full theming class +// +typedef struct Style { + SDL_Color backgroundColor; + + SDL_Color selectedColor; + SDL_Color planeColor; + SDL_Color planeGoneColor; + + SDL_Color mapInnerColor; + SDL_Color mapOuterColor; + SDL_Color scaleBarColor; + + SDL_Color buttonColor; +} Style; + + class View { @@ -28,6 +65,9 @@ class View { void drawStatus(); Aircraft *selectedAircraft; + + Style style; + public: int screenDist(float d); void pxFromLonLat(float *dx, float *dy, float lon, float lat); diff --git a/defs.h b/defs.h deleted file mode 100644 index 7492ac0..0000000 --- a/defs.h +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include -#include -#include -#include "SDL2/SDL.h" -#include "SDL2/SDL_ttf.h" - -#define ROUND_RADIUS 3 //radius of text box corners - -#define CENTEROFFSET .375 //vertical offset for middle of screen - -#define TRAIL_LENGTH 120 -#define TRAIL_TTL 240.0 -#define DISPLAY_ACTIVE 30 -#define TRAIL_TTL_STEP 2 - -#define MIN_MAP_FEATURE 2 - -#define FRAMETIME 33 - -#define PAD 5 diff --git a/map1090.REMOVED.git-id b/map1090.REMOVED.git-id index b6680c5..bf3a173 100644 --- a/map1090.REMOVED.git-id +++ b/map1090.REMOVED.git-id @@ -1 +1 @@ -eddfb25457316beaa3ba58e14e88f2e187c4acaf \ No newline at end of file +c64f58d5a0b612b1c29e1585a52d19dfa7ac4b92 \ No newline at end of file diff --git a/map1090.cpp b/map1090.cpp index 22e651e..e02a391 100644 --- a/map1090.cpp +++ b/map1090.cpp @@ -29,11 +29,9 @@ // #include "view1090.h" -#include "structs.h" #include "AppData.h" #include "View.h" #include "Input.h" - #include //time utility, might change to std::chrono diff --git a/monokai.h b/monokai.h index 969ec5d..e03ec57 100644 --- a/monokai.h +++ b/monokai.h @@ -1,4 +1,4 @@ -#include "structs.h" +#include "SDL2/SDL.h" extern SDL_Color pink; extern SDL_Color purple; diff --git a/structs.h b/structs.h deleted file mode 100644 index dd92a05..0000000 --- a/structs.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef STRUCTS -#define STRUCTS - -#include "defs.h" - -// #include "AircraftData.h" - - -struct { - double msgRate; - double avgSig; - int numPlanes; - int numVisiblePlanes; - double maxDist; - struct aircraft *closeCall; -} Status; -typedef struct Style { - SDL_Color backgroundColor; - - SDL_Color selectedColor; - SDL_Color planeColor; - SDL_Color planeGoneColor; - - SDL_Color mapInnerColor; - SDL_Color mapOuterColor; - SDL_Color scaleBarColor; - - SDL_Color buttonColor; -} Style; - -// globals -//extern AppData appData; -extern Style style; - -// functions -#ifdef __cplusplus -extern "C" { -#endif - -//status.c -void updateStatus(); -void drawStatus(); - -#ifdef __cplusplus -} -#endif - -#endif \ No newline at end of file