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

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #include "OSDWidget.h"
  2. sdlOsdVideoWidget::sdlOsdVideoWidget(CSTR path, int x, int y, int width, int height, bool decor, sdlCoreWidget* pParent) : videoWidget(path,x,y,width,height,true, pParent){
  3. m_pVisorTex = NULL;
  4. m_pParamProtector = SDL_CreateMutex();
  5. m_fRollAngle = 0.f;
  6. m_fPitchAngle = 0.f;
  7. m_fYawAngle = 0.f;
  8. m_fAlt = 0.f;
  9. m_fAirSpeed = 0.f;
  10. m_fGroundSpeed = 0.f;
  11. m_fClimbRate = 0.f;
  12. m_bThrottle = 0;
  13. m_nHeadingDeg = 0;
  14. m_fBatVoltage = 0.f;
  15. m_fTemperature = 0.f;
  16. m_dJoyAxisRoll = 0;
  17. m_dJoyAxisPitch = 0;
  18. m_dJoyAxisYaw = 0;
  19. m_dJoyAxisThrottle = -32767;
  20. m_pRects = NULL;
  21. //m_pRects = (SDL_Rect *)malloc(OSD_FIELD_RECT_COUNTS *sizeof(SDL_Rect));
  22. if (m_pRects != NULL) {
  23. init_field();
  24. };
  25. };
  26. sdlOsdVideoWidget::~sdlOsdVideoWidget() {
  27. if (m_pParamProtector != NULL) SDL_DestroyMutex(m_pParamProtector);
  28. if (m_pRects != NULL)free(m_pRects);
  29. };
  30. void sdlOsdVideoWidget::init_field() {
  31. int i;
  32. float hfov_sin = sin(CAMERA_HFOV_RAD);
  33. float vfov_sin = sin(CAMERA_VFOV_RAD);
  34. for (int j = 0; j < 10; j++) {
  35. for (int k = 0; k < 10; k++) {
  36. i = j * k;
  37. m_pRects[i].x = (rand() * m_sGeometry.w) / RAND_MAX;
  38. m_pRects[i].y = (rand() * m_sGeometry.h) / RAND_MAX;
  39. m_pRects[i].w = m_pRects[i].h = (rand() * 10) / RAND_MAX;
  40. };
  41. };
  42. };
  43. static int pows10[10] = { 1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000 };
  44. static float powsf10[10] = { 1.f,10.f,100.f,1000.f,10000.f,100000.f,1000000.f,10000000.f,100000000.f,1000000000.f };
  45. void sdlOsdVideoWidget::printInteger(SDL_Renderer* pRenderer, int x, int y, int number, int papa) {
  46. if (pRenderer != NULL) {
  47. SDL_Rect sR, tR;
  48. int cc, oc, cn;
  49. if (number < 0) number = -number;
  50. cn = number;
  51. tR.x = x;
  52. tR.y = y;
  53. tR.h = sR.h = 7;
  54. sR.y = 263;
  55. tR.w = sR.w = 5;
  56. for (int i = 9; i>-1; i--) {
  57. if (papa == -1) {
  58. if (number < pows10[i]) continue;
  59. } else {
  60. if (i > (papa - 1)) continue;
  61. };
  62. cc = cn / pows10[i];
  63. oc = cn % pows10[i];
  64. switch (cc) {
  65. case 0: sR.x = 296; break;
  66. case 1: sR.x = 251; break;
  67. case 2: sR.x = 256; break;
  68. case 3: sR.x = 261; break;
  69. case 4: sR.x = 266; break;
  70. case 5: sR.x = 271; break;
  71. case 6: sR.x = 276; break;
  72. case 7: sR.x = 281; break;
  73. case 8: sR.x = 286; break;
  74. case 9: sR.x = 291; break;
  75. };
  76. SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &sR, &tR);
  77. tR.x += 5;
  78. cn = oc;
  79. };
  80. };
  81. };
  82. void sdlOsdVideoWidget::printFloat(SDL_Renderer* pRenderer, int x, int y, float number, int dec, int papa) {
  83. if (pRenderer != NULL) {
  84. SDL_Rect sR, tR;
  85. int cc, oc, cn;
  86. if (number < 0)number = -number;
  87. cn = (int)number;
  88. tR.x = x;
  89. tR.y = y;
  90. tR.h = sR.h = 7;
  91. sR.y = 263;
  92. tR.w = sR.w = 5;
  93. for (int i = 9; i > -1; i--) {
  94. if (papa == -1) {
  95. if (number < pows10[i]) continue;
  96. } else {
  97. if (i > (papa - 1)) continue;
  98. };
  99. cc = cn / pows10[i];
  100. oc = cn % pows10[i];
  101. switch (cc) {
  102. case 0: sR.x = 296; break;
  103. case 1: sR.x = 251; break;
  104. case 2: sR.x = 256; break;
  105. case 3: sR.x = 261; break;
  106. case 4: sR.x = 266; break;
  107. case 5: sR.x = 271; break;
  108. case 6: sR.x = 276; break;
  109. case 7: sR.x = 281; break;
  110. case 8: sR.x = 286; break;
  111. case 9: sR.x = 291; break;
  112. };
  113. SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &sR, &tR);
  114. tR.x += sR.w;
  115. cn = oc;
  116. };
  117. sR.x = 301;
  118. tR.w = sR.w = 3;
  119. SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &sR, &tR);
  120. tR.x += sR.w;
  121. tR.w = sR.w = 5;
  122. float pp = exp(10 * log(dec));
  123. cn = ((int)(number * pp)) % ((int)pp);
  124. for (int i = dec - 1; i> -1; i--) {
  125. cc = cn / pows10[i];
  126. oc = cn % pows10[i];
  127. switch (cc) {
  128. case 0: sR.x = 296; break;
  129. case 1: sR.x = 251; break;
  130. case 2: sR.x = 256; break;
  131. case 3: sR.x = 261; break;
  132. case 4: sR.x = 266; break;
  133. case 5: sR.x = 271; break;
  134. case 6: sR.x = 276; break;
  135. case 7: sR.x = 281; break;
  136. case 8: sR.x = 286; break;
  137. case 9: sR.x = 291; break;
  138. };
  139. SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &sR, &tR);
  140. tR.x += 5;
  141. cn = oc;
  142. };
  143. };
  144. };
  145. void sdlOsdVideoWidget::drawAfter(SDL_Renderer* pRenderer) {
  146. if (pRenderer == NULL) return;
  147. if (m_pVisorTex == NULL)return;
  148. SDL_Point cp;
  149. SDL_Rect tS, tD;
  150. SDL_LockMutex(m_pParamProtector);
  151. //Draw field
  152. if (m_pRects != NULL) {
  153. SDL_SetRenderDrawColor(pRenderer, 0, 0, 0, 255);
  154. SDL_RenderFillRects(pRenderer, m_pRects, OSD_FIELD_RECT_COUNTS);
  155. };
  156. SDL_Texture* tText = SDL_CreateTexture(pRenderer, 0, SDL_TEXTUREACCESS_TARGET, 92, 92);
  157. if (tText != NULL) {
  158. float jAng = m_dJoyAxisRoll * 0.0054931640625f;
  159. SDL_Texture* tBackup = SDL_GetRenderTarget(pRenderer);
  160. SDL_SetTextureBlendMode(tText, SDL_BLENDMODE_BLEND);
  161. SDL_SetRenderTarget(pRenderer, tText);
  162. SDL_SetRenderDrawColor(pRenderer, 0, 0, 0, 0);
  163. SDL_RenderClear(pRenderer);
  164. cp.x = 45;
  165. cp.y = 45;
  166. if (m_dJoyAxisRoll > 0) {
  167. tS.x = 200;tS.y = 0;tS.w = 45;tS.h = 90;tD.x = -46;tD.y = 0;tD.w = 45;tD.h = 90;
  168. SDL_RenderCopyEx(pRenderer, m_pVisorTex->texture, &tS, &tD, jAng, &cp, SDL_FLIP_NONE);
  169. tD.x = 46;tD.y = 0;tD.w = 45;tD.h = 90;
  170. SDL_RenderCopyEx(pRenderer, m_pVisorTex->texture, &tS, &tD, 180.+jAng, &cp, SDL_FLIP_NONE);
  171. } else if (m_dJoyAxisRoll < 0) {
  172. tS.x = 290;tS.y = 0;tS.w = 45;tS.h = 89;tD.x = -46;tD.y = 0;tD.w = 45;tD.h = 90;
  173. SDL_RenderCopyEx(pRenderer, m_pVisorTex->texture, &tS, &tD, jAng, &cp, SDL_FLIP_NONE);
  174. tD.x = 46;tD.y = 0;tD.w = 45;tD.h = 90;
  175. SDL_RenderCopyEx(pRenderer, m_pVisorTex->texture, &tS, &tD, 180. + jAng, &cp, SDL_FLIP_NONE);
  176. };
  177. SDL_SetRenderTarget(pRenderer, tBackup);
  178. 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;
  179. SDL_RenderCopy(pRenderer, tText, &tS, &tD);
  180. 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;
  181. SDL_RenderCopy(pRenderer, tText, &tS, &tD);
  182. SDL_DestroyTexture(tText);
  183. };
  184. //Pitch
  185. if (m_dJoyAxisPitch > 0) {
  186. tS.x = 290;
  187. tS.h = (90 * m_dJoyAxisPitch) / 32768;
  188. tS.y = 210 - tS.h;
  189. tS.w = 14;
  190. tD.w = tS.w;
  191. tD.h = tS.h;
  192. tD.x = (m_sGeometry.w - tS.w) >> 1;
  193. tD.y = (m_sGeometry.h >> 1) + 3;//+ tS.h + 3;
  194. SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
  195. } else if (m_dJoyAxisPitch < 0) {
  196. tS.x = 305;
  197. tS.y = 120;
  198. tS.w = 14;
  199. tS.h = -(90 * m_dJoyAxisPitch) / 32768;
  200. tD.w = tS.w;
  201. tD.h = tS.h;
  202. tD.x = (m_sGeometry.w - tS.w) >> 1;
  203. tD.y = (m_sGeometry.h >> 1) - tS.h + 3;
  204. SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
  205. };
  206. //Yaw
  207. if (m_dJoyAxisYaw > 0) {
  208. tS.w = (90 * m_dJoyAxisYaw) / 32768;
  209. tS.x = 379 - tS.w;
  210. tS.h = 14;
  211. tS.y = 105;
  212. tD.w = tS.w;
  213. tD.h = tS.h;
  214. tD.x = (m_sGeometry.w >> 1);
  215. tD.y = (m_sGeometry.h >> 1) + 3;//+ tS.h + 3;
  216. SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
  217. } else if (m_dJoyAxisYaw < 0) {
  218. tS.x = 290;
  219. tS.h = 14;
  220. tS.y = 90;
  221. tS.w = -(90 * m_dJoyAxisYaw) / 32768;
  222. tD.w = tS.w;
  223. tD.h = tS.h;
  224. tD.x = (m_sGeometry.w >> 1) - tS.w;
  225. tD.y = (m_sGeometry.h >> 1) + 3;//+ tS.h + 3;
  226. SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
  227. };
  228. //Throttle
  229. if (m_dJoyAxisThrottle > -32767) {
  230. tS.w = (90 * (32767 + m_dJoyAxisThrottle)) / 65536;
  231. tS.x = 379 - tS.w;
  232. tS.h = 14;
  233. tS.y = 105;
  234. tD.w = (m_sGeometry.w * (32767 + m_dJoyAxisThrottle)) / 65536;
  235. tD.h = tS.h;
  236. tD.x = 0;
  237. tD.y = m_sGeometry.h - 20;
  238. SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
  239. };
  240. if (m_dJoyAxisThrottle > 0) {
  241. tS.x = 200;
  242. tS.y = 90;
  243. tS.w = 76;
  244. tS.h = 62;
  245. tD.w = tS.w;
  246. tD.h = tS.h;
  247. tD.x = 0;
  248. tD.y = m_sGeometry.h - 63;
  249. SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
  250. if (m_dJoyAxisThrottle > 32760) {
  251. tS.x = 100;
  252. tS.y = 206;
  253. tS.w = 162;
  254. tS.h = 43;
  255. tD.w = tS.w;
  256. tD.h = tS.h;
  257. tD.x = m_sGeometry.w - 170;
  258. tD.y = m_sGeometry.h - 47;
  259. SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
  260. };
  261. };
  262. drawVizorParams(pRenderer);
  263. SDL_UnlockMutex(m_pParamProtector);
  264. //Static Visor
  265. //printInteger(pRenderer, 20, 20, 19281);
  266. tS.x = 0;
  267. SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
  268. };
  269. void sdlOsdVideoWidget::drawVizorParams(SDL_Renderer* pRenderer) {
  270. SDL_Rect ttr, tS, tD;
  271. SDL_Point cp;
  272. int hh = (m_sGeometry.h >> 1);
  273. int ww = (m_sGeometry.w >> 1);
  274. // Alt
  275. SDL_SetRenderDrawColor(pRenderer, 0, 255, 0, 255);
  276. ttr.x = ((m_sGeometry.w - 30) >> 1) - 2;
  277. ttr.y = ((m_sGeometry.h - 7) >> 1) - 2;
  278. ttr.w = 31;
  279. ttr.h = 11;
  280. SDL_RenderDrawRect(pRenderer, &ttr);
  281. printFloat(pRenderer, (m_sGeometry.w - 30) >> 1, (m_sGeometry.h - 7) >> 1, m_fAlt);
  282. tS.x = 432;
  283. tS.y = 197;
  284. tD.w = tS.w = 71;
  285. tD.h = tS.h = 47;
  286. tD.x = ((m_sGeometry.w - tD.w) >> 1) - 1;
  287. int n = ( hh / 47 ) << 1;
  288. int meters = m_fAlt + (n >> 1) + 1;
  289. int shift = 47 - ( ( hh + (int)(m_fAlt * 47) ) % 47 );
  290. for (int i = 0; i < (n + 2); i++) {
  291. tD.y = -shift + (i * 47);
  292. if (meters > 0 && ((tD.y > hh + 23) || (tD.y < hh - 23))) printInteger(pRenderer, tD.x - 16, tD.y - 4, meters);
  293. SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
  294. meters--;
  295. };
  296. if ((m_fClimbRate < 0.1f) && (m_fClimbRate > -0.1f)) {
  297. tS.x = 306;
  298. tS.y = 257;
  299. tD.w = tS.w = 10;
  300. tD.h = tS.h = 13;
  301. tD.x = ww + 47;
  302. tD.y = hh - 53;
  303. SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
  304. } else if (m_fClimbRate > 0.f) {
  305. tS.x = 518;
  306. tS.y = 117;
  307. tD.w = tS.w = 8;
  308. tD.h = tS.h = 13;
  309. tD.x = ww + 47;
  310. tD.y = hh - 53;
  311. SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
  312. } else {
  313. tS.x = 530;
  314. tS.y = 117;
  315. tD.w = tS.w = 8;
  316. tD.h = tS.h = 13;
  317. tD.x = ww + 47;
  318. tD.y = hh - 53;
  319. SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
  320. };
  321. printFloat(pRenderer, ww + 60, hh - 50, m_fClimbRate);
  322. tS.x = 220;
  323. tS.y = 263;
  324. tD.w = tS.w = 16;
  325. tD.h = tS.h = 7;
  326. tD.x = ww + 90;
  327. tD.y = hh - 50;
  328. SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
  329. //Air Speed
  330. tS.x = 317;
  331. tS.y = 244;
  332. tD.w = tS.w = 15;
  333. tD.h = tS.h = 10;
  334. tD.x = ww + 112;
  335. tD.y = hh - 52;
  336. SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
  337. printFloat(pRenderer, ww + 130, hh - 50, m_fAirSpeed);
  338. tS.x = 220;
  339. tS.y = 263;
  340. tD.w = tS.w = 16;
  341. tD.h = tS.h = 7;
  342. tD.x = ww + 160;
  343. tD.y = hh - 50;
  344. SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
  345. //Ground Speed
  346. tS.x = 335;
  347. tS.y = 244;
  348. tD.w = tS.w = 15;
  349. tD.h = tS.h = 10;
  350. tD.x = ww + 112;
  351. tD.y = hh - 40;
  352. SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
  353. printFloat(pRenderer, ww + 130, hh - 38, m_fGroundSpeed);
  354. tS.x = 220;
  355. tS.y = 263;
  356. tD.w = tS.w = 16;
  357. tD.h = tS.h = 7;
  358. tD.x = ww + 160;
  359. tD.y = hh - 38;
  360. SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
  361. //Throttle
  362. tS.x = 353;
  363. tS.y = 244;
  364. tD.w = tS.w = 15;
  365. tD.h = tS.h = 10;
  366. tD.x = ww + 112;
  367. tD.y = hh - 28;
  368. SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
  369. printInteger(pRenderer, ww + 130, hh - 26, m_bThrottle,3);
  370. tS.x = 392;
  371. tS.y = 263;
  372. tD.w = tS.w = 16;
  373. tD.h = tS.h = 7;
  374. tD.x = ww + 147;
  375. tD.y = hh - 26;
  376. SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
  377. //voltage
  378. tS.x = 371;
  379. tS.y = 244;
  380. tD.w = tS.w = 14;
  381. tD.h = tS.h = 10;
  382. tD.x = ww - 170;
  383. tD.y = hh - 52;
  384. SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
  385. printFloat(pRenderer, ww - 150, hh - 50, m_fBatVoltage,2,2);
  386. tS.x = 408;
  387. tS.y = 263;
  388. tD.w = tS.w = 6;
  389. tD.h = tS.h = 7;
  390. tD.x = ww - 125;
  391. tD.y = hh - 50;
  392. SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
  393. //Temperature
  394. tS.x = 388;
  395. tS.y = 244;
  396. tD.w = tS.w = 14;
  397. tD.h = tS.h = 10;
  398. tD.x = ww - 170;
  399. tD.y = hh - 40;
  400. SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
  401. printFloat(pRenderer, ww - 150, hh - 38, m_fTemperature, 2, 2);
  402. tS.x = 416;
  403. tS.y = 263;
  404. tD.w = tS.w = 9;
  405. tD.h = tS.h = 7;
  406. tD.x = ww - 125;
  407. tD.y = hh - 38;
  408. SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
  409. // Compas Band
  410. tS.x = 440;
  411. tS.y = 0;
  412. tD.w = tS.w = 47;
  413. tD.h = tS.h = 17;
  414. tD.x = ww - 23;
  415. tD.y = 0;
  416. n = (ww / 47) << 1;
  417. int degreeses = (m_nHeadingDeg / 5) + (n >> 1) + 1;
  418. shift = 47 - ((ww + (int)(((float)m_nHeadingDeg / 5.f) * 47)) % 47)+3;
  419. for (int i = 0; i < (n + 2); i++) {
  420. tD.x = -shift + (i * 47);
  421. if ((degreeses * 5) % 45 == 0) {
  422. switch (abs((degreeses*5)%360)) {
  423. case 0: {
  424. SDL_Rect ss, dd;
  425. ss.x = 395;
  426. ss.y = 49;
  427. dd.w = ss.w = 7;
  428. dd.h = ss.h = 9;
  429. dd.x = tD.x - 2;
  430. dd.y = tD.y + 20;
  431. SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &ss, &dd);
  432. break;
  433. };
  434. case 45: {
  435. SDL_Rect ss, dd;
  436. ss.x = 405;
  437. ss.y = 49;
  438. dd.w = ss.w = 13;
  439. dd.h = ss.h = 9;
  440. dd.x = tD.x - 7;
  441. dd.y = tD.y + 20;
  442. SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &ss, &dd);
  443. };
  444. case 90: {
  445. SDL_Rect ss, dd;
  446. ss.x = 405;
  447. ss.y = 49;
  448. dd.w = ss.w = 13;
  449. dd.h = ss.h = 9;
  450. dd.x = tD.x - 7;
  451. dd.y = tD.y + 20;
  452. SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &ss, &dd);
  453. };
  454. case 135: {
  455. SDL_Rect ss, dd;
  456. ss.x = 405;
  457. ss.y = 49;
  458. dd.w = ss.w = 13;
  459. dd.h = ss.h = 9;
  460. dd.x = tD.x - 7;
  461. dd.y = tD.y + 20;
  462. SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &ss, &dd);
  463. };
  464. case 180: {
  465. SDL_Rect ss, dd;
  466. ss.x = 405;
  467. ss.y = 49;
  468. dd.w = ss.w = 13;
  469. dd.h = ss.h = 9;
  470. dd.x = tD.x - 7;
  471. dd.y = tD.y + 20;
  472. SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &ss, &dd);
  473. };
  474. case 225: {
  475. SDL_Rect ss, dd;
  476. ss.x = 405;
  477. ss.y = 49;
  478. dd.w = ss.w = 13;
  479. dd.h = ss.h = 9;
  480. dd.x = tD.x - 7;
  481. dd.y = tD.y + 20;
  482. SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &ss, &dd);
  483. };
  484. case 270: {
  485. SDL_Rect ss, dd;
  486. ss.x = 405;
  487. ss.y = 49;
  488. dd.w = ss.w = 13;
  489. dd.h = ss.h = 9;
  490. dd.x = tD.x - 6;
  491. dd.y = tD.y + 20;
  492. SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &ss, &dd);
  493. };
  494. case 315: {
  495. SDL_Rect ss, dd;
  496. ss.x = 405;
  497. ss.y = 49;
  498. dd.w = ss.w = 13;
  499. dd.h = ss.h = 9;
  500. dd.x = tD.x - 6;
  501. dd.y = tD.y + 20;
  502. SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &ss, &dd);
  503. };
  504. };
  505. } else {
  506. printInteger(pRenderer, tD.x, tD.y + 20, degreeses * 5);
  507. };
  508. SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
  509. degreeses--;
  510. };
  511. tS.x = 486;
  512. tS.y = 22;
  513. tD.w = tS.w = 7;
  514. tD.h = tS.h = 4;
  515. tD.x = ww - 5;
  516. tD.y = 30;
  517. SDL_RenderCopy(pRenderer, m_pVisorTex->texture, &tS, &tD);
  518. //Visors
  519. tS.y = 268;
  520. tS.x = 0;
  521. tS.w = 154;
  522. tS.h = 32;
  523. tD.w = tS.w;
  524. tD.h = tS.h;
  525. tD.x = (m_sGeometry.w - tS.w) >> 1;
  526. tD.y = (m_sGeometry.h >> 1) - tS.h + 3;
  527. cp.x = 77;
  528. cp.y = 29;
  529. //Moving Visor
  530. SDL_RenderCopyEx(pRenderer, m_pVisorTex->texture, &tS, &tD, m_fRollAngle, &cp, SDL_FLIP_NONE);
  531. };
  532. bool sdlOsdVideoWidget::create(void) {
  533. m_pVisorTex = m_pGUI->loadTexture((CSTR)"visor.png");
  534. return videoWidget::create();
  535. };
  536. void sdlOsdVideoWidget::setRoll(float Angle) {
  537. SDL_LockMutex(m_pParamProtector);
  538. m_fRollAngle = Angle * 57.295779513082320876798154814105f;
  539. SDL_UnlockMutex(m_pParamProtector);
  540. };
  541. void sdlOsdVideoWidget::setPitch(float Angle) {
  542. SDL_LockMutex(m_pParamProtector);
  543. m_fPitchAngle = Angle * 57.295779513082320876798154814105f;
  544. SDL_UnlockMutex(m_pParamProtector);
  545. };
  546. void sdlOsdVideoWidget::setYaw(float Angle) {
  547. SDL_LockMutex(m_pParamProtector);
  548. m_fYawAngle = Angle * 57.295779513082320876798154814105f;
  549. SDL_UnlockMutex(m_pParamProtector);
  550. };
  551. void sdlOsdVideoWidget::setAlt(float Angle) {
  552. SDL_LockMutex(m_pParamProtector);
  553. m_fAlt = Angle;
  554. SDL_UnlockMutex(m_pParamProtector);
  555. };
  556. void sdlOsdVideoWidget::setJoystickRoll(uint16_t value) {
  557. SDL_LockMutex(m_pParamProtector);
  558. m_dJoyAxisRoll = value;
  559. SDL_UnlockMutex(m_pParamProtector);
  560. };
  561. void sdlOsdVideoWidget::setJoystickPitch(uint16_t value) {
  562. SDL_LockMutex(m_pParamProtector);
  563. m_dJoyAxisPitch = value;
  564. SDL_UnlockMutex(m_pParamProtector);
  565. };
  566. void sdlOsdVideoWidget::setJoystickYaw(uint16_t value) {
  567. SDL_LockMutex(m_pParamProtector);
  568. m_dJoyAxisYaw = value;
  569. SDL_UnlockMutex(m_pParamProtector);
  570. };
  571. void sdlOsdVideoWidget::setJoistickThrottle(uint16_t value) {
  572. SDL_LockMutex(m_pParamProtector);
  573. m_dJoyAxisThrottle = value;
  574. SDL_UnlockMutex(m_pParamProtector);
  575. };
  576. void sdlOsdVideoWidget::setTemperature(float t) {
  577. SDL_LockMutex(m_pParamProtector);
  578. m_fTemperature = t;
  579. SDL_UnlockMutex(m_pParamProtector);
  580. };
  581. void sdlOsdVideoWidget::setVoltage(float v) {
  582. SDL_LockMutex(m_pParamProtector);
  583. m_fBatVoltage = v;
  584. SDL_UnlockMutex(m_pParamProtector);
  585. };
  586. void sdlOsdVideoWidget::setGroundSpeed(float s) {
  587. SDL_LockMutex(m_pParamProtector);
  588. m_fGroundSpeed = s;
  589. SDL_UnlockMutex(m_pParamProtector);
  590. };
  591. void sdlOsdVideoWidget::setAirSpeed(float s) {
  592. SDL_LockMutex(m_pParamProtector);
  593. m_fAirSpeed = s;
  594. SDL_UnlockMutex(m_pParamProtector);
  595. };
  596. void sdlOsdVideoWidget::setClimbRate(float cr) {
  597. SDL_LockMutex(m_pParamProtector);
  598. m_fClimbRate = cr;
  599. SDL_UnlockMutex(m_pParamProtector);
  600. };
  601. void sdlOsdVideoWidget::setMagHeading(int mh) {
  602. SDL_LockMutex(m_pParamProtector);
  603. m_nHeadingDeg = mh;
  604. SDL_UnlockMutex(m_pParamProtector);
  605. };
  606. void sdlOsdVideoWidget::setThrottle(int tp) {
  607. SDL_LockMutex(m_pParamProtector);
  608. m_bThrottle = tp;
  609. SDL_UnlockMutex(m_pParamProtector);
  610. };