You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
622 lines
17 KiB
622 lines
17 KiB
#include "OSDWidget.h"
|
|
sdlOsdVideoWidget::sdlOsdVideoWidget(CSTR path, int x, int y, int width, int height, bool decor, sdlCoreWidget* pParent) : videoWidget(path,x,y,width,height,true, pParent){
|
|
m_pVisorTex = NULL;
|
|
m_pParamProtector = SDL_CreateMutex();
|
|
m_fRollAngle = 0.f;
|
|
m_fPitchAngle = 0.f;
|
|
m_fYawAngle = 0.f;
|
|
m_fAlt = 0.f;
|
|
m_fAirSpeed = 0.f;
|
|
m_fGroundSpeed = 0.f;
|
|
m_fClimbRate = 0.f;
|
|
m_bThrottle = 0;
|
|
m_nHeadingDeg = 0;
|
|
m_fBatVoltage = 0.f;
|
|
m_fTemperature = 0.f;
|
|
m_dJoyAxisRoll = 0;
|
|
m_dJoyAxisPitch = 0;
|
|
m_dJoyAxisYaw = 0;
|
|
m_dJoyAxisThrottle = -32767;
|
|
m_pRects = NULL;
|
|
//m_pRects = (SDL_Rect *)malloc(OSD_FIELD_RECT_COUNTS *sizeof(SDL_Rect));
|
|
if (m_pRects != NULL) {
|
|
init_field();
|
|
};
|
|
};
|
|
|
|
sdlOsdVideoWidget::~sdlOsdVideoWidget() {
|
|
if (m_pParamProtector != NULL) SDL_DestroyMutex(m_pParamProtector);
|
|
if (m_pRects != NULL)free(m_pRects);
|
|
};
|
|
|
|
void sdlOsdVideoWidget::init_field() {
|
|
int i;
|
|
float hfov_sin = sin(CAMERA_HFOV_RAD);
|
|
float vfov_sin = sin(CAMERA_VFOV_RAD);
|
|
|
|
for (int j = 0; j < 10; j++) {
|
|
for (int k = 0; k < 10; k++) {
|
|
i = j * k;
|
|
m_pRects[i].x = (rand() * m_sGeometry.w) / RAND_MAX;
|
|
m_pRects[i].y = (rand() * m_sGeometry.h) / RAND_MAX;
|
|
m_pRects[i].w = m_pRects[i].h = (rand() * 10) / RAND_MAX;
|
|
};
|
|
};
|
|
};
|
|
static int pows10[10] = { 1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000 };
|
|
static float powsf10[10] = { 1.f,10.f,100.f,1000.f,10000.f,100000.f,1000000.f,10000000.f,100000000.f,1000000000.f };
|
|
|
|
void sdlOsdVideoWidget::printInteger(SDL_Renderer* pRenderer, int x, int y, int number, int papa) {
|
|
if (pRenderer != NULL) {
|
|
SDL_Rect sR, tR;
|
|
int cc, oc, cn;
|
|
if (number < 0) number = -number;
|
|
cn = number;
|
|
tR.x = x;
|
|
tR.y = y;
|
|
tR.h = sR.h = 7;
|
|
sR.y = 263;
|
|
tR.w = sR.w = 5;
|
|
for (int i = 9; i>-1; i--) {
|
|
if (papa == -1) {
|
|
if (number < pows10[i]) continue;
|
|
} else {
|
|
if (i > (papa - 1)) continue;
|
|
};
|
|
cc = cn / pows10[i];
|
|
oc = cn % pows10[i];
|
|
switch (cc) {
|
|
case 0: sR.x = 296; break;
|
|
case 1: sR.x = 251; break;
|
|
case 2: sR.x = 256; break;
|
|
case 3: sR.x = 261; break;
|
|
case 4: sR.x = 266; break;
|
|
case 5: sR.x = 271; break;
|
|
case 6: sR.x = 276; break;
|
|
case 7: sR.x = 281; break;
|
|
case 8: sR.x = 286; break;
|
|
case 9: sR.x = 291; break;
|
|
};
|
|
SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &sR, &tR);
|
|
tR.x += 5;
|
|
cn = oc;
|
|
};
|
|
};
|
|
};
|
|
|
|
void sdlOsdVideoWidget::printFloat(SDL_Renderer* pRenderer, int x, int y, float number, int dec, int papa) {
|
|
if (pRenderer != NULL) {
|
|
SDL_Rect sR, tR;
|
|
int cc, oc, cn;
|
|
if (number < 0)number = -number;
|
|
cn = (int)number;
|
|
tR.x = x;
|
|
tR.y = y;
|
|
tR.h = sR.h = 7;
|
|
sR.y = 263;
|
|
tR.w = sR.w = 5;
|
|
for (int i = 9; i > -1; i--) {
|
|
if (papa == -1) {
|
|
if (number < pows10[i]) continue;
|
|
} else {
|
|
if (i > (papa - 1)) continue;
|
|
};
|
|
cc = cn / pows10[i];
|
|
oc = cn % pows10[i];
|
|
switch (cc) {
|
|
case 0: sR.x = 296; break;
|
|
case 1: sR.x = 251; break;
|
|
case 2: sR.x = 256; break;
|
|
case 3: sR.x = 261; break;
|
|
case 4: sR.x = 266; break;
|
|
case 5: sR.x = 271; break;
|
|
case 6: sR.x = 276; break;
|
|
case 7: sR.x = 281; break;
|
|
case 8: sR.x = 286; break;
|
|
case 9: sR.x = 291; break;
|
|
};
|
|
SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &sR, &tR);
|
|
tR.x += sR.w;
|
|
cn = oc;
|
|
};
|
|
sR.x = 301;
|
|
tR.w = sR.w = 3;
|
|
SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &sR, &tR);
|
|
tR.x += sR.w;
|
|
tR.w = sR.w = 5;
|
|
float pp = exp(10 * log(dec));
|
|
cn = ((int)(number * pp)) % ((int)pp);
|
|
for (int i = dec - 1; i> -1; i--) {
|
|
cc = cn / pows10[i];
|
|
oc = cn % pows10[i];
|
|
switch (cc) {
|
|
case 0: sR.x = 296; break;
|
|
case 1: sR.x = 251; break;
|
|
case 2: sR.x = 256; break;
|
|
case 3: sR.x = 261; break;
|
|
case 4: sR.x = 266; break;
|
|
case 5: sR.x = 271; break;
|
|
case 6: sR.x = 276; break;
|
|
case 7: sR.x = 281; break;
|
|
case 8: sR.x = 286; break;
|
|
case 9: sR.x = 291; break;
|
|
};
|
|
SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &sR, &tR);
|
|
tR.x += 5;
|
|
cn = oc;
|
|
};
|
|
};
|
|
};
|
|
|
|
void sdlOsdVideoWidget::drawAfter(SDL_Renderer* pRenderer) {
|
|
if (pRenderer == NULL) return;
|
|
if (m_pVisorTex == NULL)return;
|
|
SDL_Point cp;
|
|
SDL_Rect tS, tD;
|
|
|
|
SDL_LockMutex(m_pParamProtector);
|
|
//Draw field
|
|
if (m_pRects != NULL) {
|
|
SDL_SetRenderDrawColor(pRenderer, 0, 0, 0, 255);
|
|
SDL_RenderFillRects(pRenderer, m_pRects, OSD_FIELD_RECT_COUNTS);
|
|
};
|
|
SDL_Texture* tText = SDL_CreateTexture(pRenderer, 0, SDL_TEXTUREACCESS_TARGET, 92, 92);
|
|
if (tText != NULL) {
|
|
float jAng = m_dJoyAxisRoll * 0.0054931640625f;
|
|
SDL_Texture* tBackup = SDL_GetRenderTarget(pRenderer);
|
|
SDL_SetTextureBlendMode(tText, SDL_BLENDMODE_BLEND);
|
|
SDL_SetRenderTarget(pRenderer, tText);
|
|
SDL_SetRenderDrawColor(pRenderer, 0, 0, 0, 0);
|
|
SDL_RenderClear(pRenderer);
|
|
cp.x = 45;
|
|
cp.y = 45;
|
|
if (m_dJoyAxisRoll > 0) {
|
|
tS.x = 200;tS.y = 0;tS.w = 45;tS.h = 90;tD.x = -46;tD.y = 0;tD.w = 45;tD.h = 90;
|
|
SDL_RenderCopyEx(pRenderer, m_pVisorTex->texture, &tS, &tD, jAng, &cp, SDL_FLIP_NONE);
|
|
tD.x = 46;tD.y = 0;tD.w = 45;tD.h = 90;
|
|
SDL_RenderCopyEx(pRenderer, m_pVisorTex->texture, &tS, &tD, 180.+jAng, &cp, SDL_FLIP_NONE);
|
|
} else if (m_dJoyAxisRoll < 0) {
|
|
tS.x = 290;tS.y = 0;tS.w = 45;tS.h = 89;tD.x = -46;tD.y = 0;tD.w = 45;tD.h = 90;
|
|
SDL_RenderCopyEx(pRenderer, m_pVisorTex->texture, &tS, &tD, jAng, &cp, SDL_FLIP_NONE);
|
|
tD.x = 46;tD.y = 0;tD.w = 45;tD.h = 90;
|
|
SDL_RenderCopyEx(pRenderer, m_pVisorTex->texture, &tS, &tD, 180. + jAng, &cp, SDL_FLIP_NONE);
|
|
};
|
|
SDL_SetRenderTarget(pRenderer, tBackup);
|
|
tS.x = 46;tS.y = 0;tS.w = 45;tS.h = 90;tD.x = ( m_sGeometry.w >> 1 ) - 45;tD.y = (m_sGeometry.h - 90) >> 1;tD.w = 45;tD.h = 90;
|
|
SDL_RenderCopy(pRenderer, tText, &tS, &tD);
|
|
tS.x = 0;tS.y = 0;tS.w = 45;tS.h = 90;tD.x = m_sGeometry.w >> 1;tD.y = (m_sGeometry.h - 90) >> 1;tD.w = 45;tD.h = 90;
|
|
SDL_RenderCopy(pRenderer, tText, &tS, &tD);
|
|
SDL_DestroyTexture(tText);
|
|
};
|
|
//Pitch
|
|
if (m_dJoyAxisPitch > 0) {
|
|
tS.x = 290;
|
|
tS.h = (90 * m_dJoyAxisPitch) / 32768;
|
|
tS.y = 210 - tS.h;
|
|
tS.w = 14;
|
|
tD.w = tS.w;
|
|
tD.h = tS.h;
|
|
tD.x = (m_sGeometry.w - tS.w) >> 1;
|
|
tD.y = (m_sGeometry.h >> 1) + 3;//+ tS.h + 3;
|
|
SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
|
|
} else if (m_dJoyAxisPitch < 0) {
|
|
tS.x = 305;
|
|
tS.y = 120;
|
|
tS.w = 14;
|
|
tS.h = -(90 * m_dJoyAxisPitch) / 32768;
|
|
tD.w = tS.w;
|
|
tD.h = tS.h;
|
|
tD.x = (m_sGeometry.w - tS.w) >> 1;
|
|
tD.y = (m_sGeometry.h >> 1) - tS.h + 3;
|
|
SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
|
|
};
|
|
//Yaw
|
|
if (m_dJoyAxisYaw > 0) {
|
|
tS.w = (90 * m_dJoyAxisYaw) / 32768;
|
|
tS.x = 379 - tS.w;
|
|
tS.h = 14;
|
|
tS.y = 105;
|
|
tD.w = tS.w;
|
|
tD.h = tS.h;
|
|
tD.x = (m_sGeometry.w >> 1);
|
|
tD.y = (m_sGeometry.h >> 1) + 3;//+ tS.h + 3;
|
|
SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
|
|
} else if (m_dJoyAxisYaw < 0) {
|
|
tS.x = 290;
|
|
tS.h = 14;
|
|
tS.y = 90;
|
|
tS.w = -(90 * m_dJoyAxisYaw) / 32768;
|
|
tD.w = tS.w;
|
|
tD.h = tS.h;
|
|
tD.x = (m_sGeometry.w >> 1) - tS.w;
|
|
tD.y = (m_sGeometry.h >> 1) + 3;//+ tS.h + 3;
|
|
SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
|
|
};
|
|
//Throttle
|
|
if (m_dJoyAxisThrottle > -32767) {
|
|
tS.w = (90 * (32767 + m_dJoyAxisThrottle)) / 65536;
|
|
tS.x = 379 - tS.w;
|
|
tS.h = 14;
|
|
tS.y = 105;
|
|
tD.w = (m_sGeometry.w * (32767 + m_dJoyAxisThrottle)) / 65536;
|
|
tD.h = tS.h;
|
|
tD.x = 0;
|
|
tD.y = m_sGeometry.h - 20;
|
|
SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
|
|
};
|
|
if (m_dJoyAxisThrottle > 0) {
|
|
tS.x = 200;
|
|
tS.y = 90;
|
|
tS.w = 76;
|
|
tS.h = 62;
|
|
tD.w = tS.w;
|
|
tD.h = tS.h;
|
|
tD.x = 0;
|
|
tD.y = m_sGeometry.h - 63;
|
|
SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
|
|
if (m_dJoyAxisThrottle > 32760) {
|
|
tS.x = 100;
|
|
tS.y = 206;
|
|
tS.w = 162;
|
|
tS.h = 43;
|
|
tD.w = tS.w;
|
|
tD.h = tS.h;
|
|
tD.x = m_sGeometry.w - 170;
|
|
tD.y = m_sGeometry.h - 47;
|
|
SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
|
|
};
|
|
};
|
|
|
|
drawVizorParams(pRenderer);
|
|
|
|
SDL_UnlockMutex(m_pParamProtector);
|
|
//Static Visor
|
|
//printInteger(pRenderer, 20, 20, 19281);
|
|
|
|
tS.x = 0;
|
|
SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
|
|
};
|
|
void sdlOsdVideoWidget::drawVizorParams(SDL_Renderer* pRenderer) {
|
|
SDL_Rect ttr, tS, tD;
|
|
SDL_Point cp;
|
|
int hh = (m_sGeometry.h >> 1);
|
|
int ww = (m_sGeometry.w >> 1);
|
|
// Alt
|
|
SDL_SetRenderDrawColor(pRenderer, 0, 255, 0, 255);
|
|
ttr.x = ((m_sGeometry.w - 30) >> 1) - 2;
|
|
ttr.y = ((m_sGeometry.h - 7) >> 1) - 2;
|
|
ttr.w = 31;
|
|
ttr.h = 11;
|
|
SDL_RenderDrawRect(pRenderer, &ttr);
|
|
printFloat(pRenderer, (m_sGeometry.w - 30) >> 1, (m_sGeometry.h - 7) >> 1, m_fAlt);
|
|
|
|
tS.x = 432;
|
|
tS.y = 197;
|
|
tD.w = tS.w = 71;
|
|
tD.h = tS.h = 47;
|
|
tD.x = ((m_sGeometry.w - tD.w) >> 1) - 1;
|
|
int n = ( hh / 47 ) << 1;
|
|
int meters = m_fAlt + (n >> 1) + 1;
|
|
int shift = 47 - ( ( hh + (int)(m_fAlt * 47) ) % 47 );
|
|
for (int i = 0; i < (n + 2); i++) {
|
|
tD.y = -shift + (i * 47);
|
|
if (meters > 0 && ((tD.y > hh + 23) || (tD.y < hh - 23))) printInteger(pRenderer, tD.x - 16, tD.y - 4, meters);
|
|
SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
|
|
meters--;
|
|
};
|
|
if ((m_fClimbRate < 0.1f) && (m_fClimbRate > -0.1f)) {
|
|
tS.x = 306;
|
|
tS.y = 257;
|
|
tD.w = tS.w = 10;
|
|
tD.h = tS.h = 13;
|
|
tD.x = ww + 47;
|
|
tD.y = hh - 53;
|
|
SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
|
|
} else if (m_fClimbRate > 0.f) {
|
|
tS.x = 518;
|
|
tS.y = 117;
|
|
tD.w = tS.w = 8;
|
|
tD.h = tS.h = 13;
|
|
tD.x = ww + 47;
|
|
tD.y = hh - 53;
|
|
SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
|
|
} else {
|
|
tS.x = 530;
|
|
tS.y = 117;
|
|
tD.w = tS.w = 8;
|
|
tD.h = tS.h = 13;
|
|
tD.x = ww + 47;
|
|
tD.y = hh - 53;
|
|
SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
|
|
};
|
|
printFloat(pRenderer, ww + 60, hh - 50, m_fClimbRate);
|
|
tS.x = 220;
|
|
tS.y = 263;
|
|
tD.w = tS.w = 16;
|
|
tD.h = tS.h = 7;
|
|
tD.x = ww + 90;
|
|
tD.y = hh - 50;
|
|
SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
|
|
//Air Speed
|
|
tS.x = 317;
|
|
tS.y = 244;
|
|
tD.w = tS.w = 15;
|
|
tD.h = tS.h = 10;
|
|
tD.x = ww + 112;
|
|
tD.y = hh - 52;
|
|
SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
|
|
printFloat(pRenderer, ww + 130, hh - 50, m_fAirSpeed);
|
|
tS.x = 220;
|
|
tS.y = 263;
|
|
tD.w = tS.w = 16;
|
|
tD.h = tS.h = 7;
|
|
tD.x = ww + 160;
|
|
tD.y = hh - 50;
|
|
SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
|
|
//Ground Speed
|
|
tS.x = 335;
|
|
tS.y = 244;
|
|
tD.w = tS.w = 15;
|
|
tD.h = tS.h = 10;
|
|
tD.x = ww + 112;
|
|
tD.y = hh - 40;
|
|
SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
|
|
printFloat(pRenderer, ww + 130, hh - 38, m_fGroundSpeed);
|
|
tS.x = 220;
|
|
tS.y = 263;
|
|
tD.w = tS.w = 16;
|
|
tD.h = tS.h = 7;
|
|
tD.x = ww + 160;
|
|
tD.y = hh - 38;
|
|
SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
|
|
//Throttle
|
|
tS.x = 353;
|
|
tS.y = 244;
|
|
tD.w = tS.w = 15;
|
|
tD.h = tS.h = 10;
|
|
tD.x = ww + 112;
|
|
tD.y = hh - 28;
|
|
SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
|
|
printInteger(pRenderer, ww + 130, hh - 26, m_bThrottle,3);
|
|
tS.x = 392;
|
|
tS.y = 263;
|
|
tD.w = tS.w = 16;
|
|
tD.h = tS.h = 7;
|
|
tD.x = ww + 147;
|
|
tD.y = hh - 26;
|
|
SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
|
|
//voltage
|
|
tS.x = 371;
|
|
tS.y = 244;
|
|
tD.w = tS.w = 14;
|
|
tD.h = tS.h = 10;
|
|
tD.x = ww - 170;
|
|
tD.y = hh - 52;
|
|
SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
|
|
printFloat(pRenderer, ww - 150, hh - 50, m_fBatVoltage,2,2);
|
|
tS.x = 408;
|
|
tS.y = 263;
|
|
tD.w = tS.w = 6;
|
|
tD.h = tS.h = 7;
|
|
tD.x = ww - 125;
|
|
tD.y = hh - 50;
|
|
SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
|
|
//Temperature
|
|
tS.x = 388;
|
|
tS.y = 244;
|
|
tD.w = tS.w = 14;
|
|
tD.h = tS.h = 10;
|
|
tD.x = ww - 170;
|
|
tD.y = hh - 40;
|
|
SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
|
|
printFloat(pRenderer, ww - 150, hh - 38, m_fTemperature, 2, 2);
|
|
tS.x = 416;
|
|
tS.y = 263;
|
|
tD.w = tS.w = 9;
|
|
tD.h = tS.h = 7;
|
|
tD.x = ww - 125;
|
|
tD.y = hh - 38;
|
|
SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
|
|
// Compas Band
|
|
tS.x = 440;
|
|
tS.y = 0;
|
|
tD.w = tS.w = 47;
|
|
tD.h = tS.h = 17;
|
|
tD.x = ww - 23;
|
|
tD.y = 0;
|
|
n = (ww / 47) << 1;
|
|
int degreeses = (m_nHeadingDeg / 5) + (n >> 1) + 1;
|
|
shift = 47 - ((ww + (int)(((float)m_nHeadingDeg / 5.f) * 47)) % 47)+3;
|
|
for (int i = 0; i < (n + 2); i++) {
|
|
tD.x = -shift + (i * 47);
|
|
if ((degreeses * 5) % 45 == 0) {
|
|
switch (abs((degreeses*5)%360)) {
|
|
case 0: {
|
|
SDL_Rect ss, dd;
|
|
ss.x = 395;
|
|
ss.y = 49;
|
|
dd.w = ss.w = 7;
|
|
dd.h = ss.h = 9;
|
|
dd.x = tD.x - 2;
|
|
dd.y = tD.y + 20;
|
|
SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &ss, &dd);
|
|
break;
|
|
};
|
|
case 45: {
|
|
SDL_Rect ss, dd;
|
|
ss.x = 405;
|
|
ss.y = 49;
|
|
dd.w = ss.w = 13;
|
|
dd.h = ss.h = 9;
|
|
dd.x = tD.x - 7;
|
|
dd.y = tD.y + 20;
|
|
SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &ss, &dd);
|
|
};
|
|
case 90: {
|
|
SDL_Rect ss, dd;
|
|
ss.x = 405;
|
|
ss.y = 49;
|
|
dd.w = ss.w = 13;
|
|
dd.h = ss.h = 9;
|
|
dd.x = tD.x - 7;
|
|
dd.y = tD.y + 20;
|
|
SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &ss, &dd);
|
|
};
|
|
case 135: {
|
|
SDL_Rect ss, dd;
|
|
ss.x = 405;
|
|
ss.y = 49;
|
|
dd.w = ss.w = 13;
|
|
dd.h = ss.h = 9;
|
|
dd.x = tD.x - 7;
|
|
dd.y = tD.y + 20;
|
|
SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &ss, &dd);
|
|
};
|
|
case 180: {
|
|
SDL_Rect ss, dd;
|
|
ss.x = 405;
|
|
ss.y = 49;
|
|
dd.w = ss.w = 13;
|
|
dd.h = ss.h = 9;
|
|
dd.x = tD.x - 7;
|
|
dd.y = tD.y + 20;
|
|
SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &ss, &dd);
|
|
};
|
|
case 225: {
|
|
SDL_Rect ss, dd;
|
|
ss.x = 405;
|
|
ss.y = 49;
|
|
dd.w = ss.w = 13;
|
|
dd.h = ss.h = 9;
|
|
dd.x = tD.x - 7;
|
|
dd.y = tD.y + 20;
|
|
SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &ss, &dd);
|
|
};
|
|
case 270: {
|
|
SDL_Rect ss, dd;
|
|
ss.x = 405;
|
|
ss.y = 49;
|
|
dd.w = ss.w = 13;
|
|
dd.h = ss.h = 9;
|
|
dd.x = tD.x - 6;
|
|
dd.y = tD.y + 20;
|
|
SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &ss, &dd);
|
|
};
|
|
case 315: {
|
|
SDL_Rect ss, dd;
|
|
ss.x = 405;
|
|
ss.y = 49;
|
|
dd.w = ss.w = 13;
|
|
dd.h = ss.h = 9;
|
|
dd.x = tD.x - 6;
|
|
dd.y = tD.y + 20;
|
|
SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &ss, &dd);
|
|
};
|
|
};
|
|
} else {
|
|
printInteger(pRenderer, tD.x, tD.y + 20, degreeses * 5);
|
|
};
|
|
SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
|
|
degreeses--;
|
|
};
|
|
tS.x = 486;
|
|
tS.y = 22;
|
|
tD.w = tS.w = 7;
|
|
tD.h = tS.h = 4;
|
|
tD.x = ww - 5;
|
|
tD.y = 30;
|
|
SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
|
|
//Visors
|
|
tS.y = 268;
|
|
tS.x = 0;
|
|
tS.w = 154;
|
|
tS.h = 32;
|
|
tD.w = tS.w;
|
|
tD.h = tS.h;
|
|
tD.x = (m_sGeometry.w - tS.w) >> 1;
|
|
tD.y = (m_sGeometry.h >> 1) - tS.h + 3;
|
|
cp.x = 77;
|
|
cp.y = 29;
|
|
//Moving Visor
|
|
SDL_RenderCopyEx(pRenderer, m_pVisorTex->texture, &tS, &tD, m_fRollAngle, &cp, SDL_FLIP_NONE);
|
|
|
|
};
|
|
bool sdlOsdVideoWidget::create(void) {
|
|
m_pVisorTex = m_pGUI->loadTexture((CSTR)"visor.png");
|
|
return videoWidget::create();
|
|
};
|
|
void sdlOsdVideoWidget::setRoll(float Angle) {
|
|
SDL_LockMutex(m_pParamProtector);
|
|
m_fRollAngle = Angle * 57.295779513082320876798154814105f;
|
|
SDL_UnlockMutex(m_pParamProtector);
|
|
};
|
|
void sdlOsdVideoWidget::setPitch(float Angle) {
|
|
SDL_LockMutex(m_pParamProtector);
|
|
m_fPitchAngle = Angle * 57.295779513082320876798154814105f;
|
|
SDL_UnlockMutex(m_pParamProtector);
|
|
};
|
|
void sdlOsdVideoWidget::setYaw(float Angle) {
|
|
SDL_LockMutex(m_pParamProtector);
|
|
m_fYawAngle = Angle * 57.295779513082320876798154814105f;
|
|
SDL_UnlockMutex(m_pParamProtector);
|
|
};
|
|
void sdlOsdVideoWidget::setAlt(float Angle) {
|
|
SDL_LockMutex(m_pParamProtector);
|
|
m_fAlt = Angle;
|
|
SDL_UnlockMutex(m_pParamProtector);
|
|
};
|
|
void sdlOsdVideoWidget::setJoystickRoll(uint16_t value) {
|
|
SDL_LockMutex(m_pParamProtector);
|
|
m_dJoyAxisRoll = value;
|
|
SDL_UnlockMutex(m_pParamProtector);
|
|
};
|
|
void sdlOsdVideoWidget::setJoystickPitch(uint16_t value) {
|
|
SDL_LockMutex(m_pParamProtector);
|
|
m_dJoyAxisPitch = value;
|
|
SDL_UnlockMutex(m_pParamProtector);
|
|
};
|
|
void sdlOsdVideoWidget::setJoystickYaw(uint16_t value) {
|
|
SDL_LockMutex(m_pParamProtector);
|
|
m_dJoyAxisYaw = value;
|
|
SDL_UnlockMutex(m_pParamProtector);
|
|
};
|
|
void sdlOsdVideoWidget::setJoistickThrottle(uint16_t value) {
|
|
SDL_LockMutex(m_pParamProtector);
|
|
m_dJoyAxisThrottle = value;
|
|
SDL_UnlockMutex(m_pParamProtector);
|
|
};
|
|
void sdlOsdVideoWidget::setTemperature(float t) {
|
|
SDL_LockMutex(m_pParamProtector);
|
|
m_fTemperature = t;
|
|
SDL_UnlockMutex(m_pParamProtector);
|
|
};
|
|
void sdlOsdVideoWidget::setVoltage(float v) {
|
|
SDL_LockMutex(m_pParamProtector);
|
|
m_fBatVoltage = v;
|
|
SDL_UnlockMutex(m_pParamProtector);
|
|
};
|
|
void sdlOsdVideoWidget::setGroundSpeed(float s) {
|
|
SDL_LockMutex(m_pParamProtector);
|
|
m_fGroundSpeed = s;
|
|
SDL_UnlockMutex(m_pParamProtector);
|
|
};
|
|
void sdlOsdVideoWidget::setAirSpeed(float s) {
|
|
SDL_LockMutex(m_pParamProtector);
|
|
m_fAirSpeed = s;
|
|
SDL_UnlockMutex(m_pParamProtector);
|
|
};
|
|
void sdlOsdVideoWidget::setClimbRate(float cr) {
|
|
SDL_LockMutex(m_pParamProtector);
|
|
m_fClimbRate = cr;
|
|
SDL_UnlockMutex(m_pParamProtector);
|
|
};
|
|
void sdlOsdVideoWidget::setMagHeading(int mh) {
|
|
SDL_LockMutex(m_pParamProtector);
|
|
m_nHeadingDeg = mh;
|
|
SDL_UnlockMutex(m_pParamProtector);
|
|
};
|
|
void sdlOsdVideoWidget::setThrottle(int tp) {
|
|
SDL_LockMutex(m_pParamProtector);
|
|
m_bThrottle = tp;
|
|
SDL_UnlockMutex(m_pParamProtector);
|
|
};
|