void Statistics::RenderGlidePolar(HDC hdc, RECT rc) { ResetScale(); ScaleYFromValue(rc, 0); ScaleYFromValue(rc, GlidePolar::SinkRateFast(0,(int)(SAFTEYSPEED-1))); ScaleXFromValue(rc, 0); // GlidePolar::Vminsink); ScaleXFromValue(rc, SAFTEYSPEED); DrawXGrid(hdc, rc, 10.0/SPEEDMODIFY, 0, STYLE_THINDASHPAPER); DrawYGrid(hdc, rc, 1.0/LIFTMODIFY, 0, STYLE_THINDASHPAPER); int i; double sinkrate0, sinkrate1; for (i= GlidePolar::Vminsink; i< SAFTEYSPEED-1; i++) { sinkrate0 = GlidePolar::SinkRateFast(0,i); sinkrate1 = GlidePolar::SinkRateFast(0,i+1); DrawLine(hdc, rc, i, sinkrate0 , i+1, sinkrate1, STYLE_MEDIUMBLACK); } DrawXLabel(hdc, rc, TEXT("V")); DrawYLabel(hdc, rc, TEXT("w")); }
void Statistics::RenderClimb(HDC hdc, RECT rc) { ResetScale(); ScaleYFromData(rc, &flightstats.ThermalAverage); ScaleYFromValue(rc, MACCREADY); ScaleYFromValue(rc, 0); ScaleXFromValue(rc, 0); ScaleXFromValue(rc, flightstats.ThermalAverage.sum_n+1); DrawYGrid(hdc, rc, 1.0/LIFTMODIFY, 0, STYLE_THINDASHPAPER); DrawBarChart(hdc, rc, &flightstats.ThermalAverage); DrawLine(hdc, rc, 0, MACCREADY, flightstats.ThermalAverage.sum_n+1, MACCREADY, STYLE_REDTHICK); DrawTrendN(hdc, rc, &flightstats.ThermalAverage, STYLE_BLUETHIN); DrawXLabel(hdc, rc, TEXT("n")); DrawYLabel(hdc, rc, TEXT("w")); }
void Statistics::RenderTemperature(HDC hdc, RECT rc) { ResetScale(); int i; float hmin= 10000; float hmax= -10000; float tmin= (float)CuSonde::maxGroundTemperature; //RB Type cast fixed float tmax= (float)CuSonde::maxGroundTemperature; //RB Type cast fixed // find range for scaling of graph for (i=0; i<CUSONDE_NUMLEVELS-1; i++) { if (CuSonde::cslevels[i].nmeasurements) { hmin = min(hmin, i); hmax = max(hmax, i); tmin = (float)min(tmin, min(CuSonde::cslevels[i].tempDry, min(CuSonde::cslevels[i].airTemp, CuSonde::cslevels[i].dewpoint))); // RB fix casts tmax = (float)max(tmax, max(CuSonde::cslevels[i].tempDry, max(CuSonde::cslevels[i].airTemp, CuSonde::cslevels[i].dewpoint))); // RB fix casts } } ScaleYFromValue(rc, hmin); ScaleYFromValue(rc, hmax); ScaleXFromValue(rc, tmin); ScaleXFromValue(rc, tmax); for (i=0; i<CUSONDE_NUMLEVELS; i++) { if (CuSonde::cslevels[i].nmeasurements && CuSonde::cslevels[i+1].nmeasurements) { DrawLine(hdc, rc, CuSonde::cslevels[i].tempDry, i, CuSonde::cslevels[i+1].tempDry, (i+1), STYLE_REDTHICK); DrawLine(hdc, rc, CuSonde::cslevels[i].airTemp, i, CuSonde::cslevels[i+1].airTemp, (i+1), STYLE_MEDIUMBLACK); DrawLine(hdc, rc, CuSonde::cslevels[i].dewpoint, i, CuSonde::cslevels[i+1].dewpoint, i+1, STYLE_BLUETHIN); } } DrawXLabel(hdc, rc, TEXT("T°")); DrawYLabel(hdc, rc, TEXT("h")); }
void ChartRenderer::DrawYLabel(const TCHAR *text, const TCHAR *unit) { assert(text != nullptr); assert(unit != nullptr); StaticString<64> buffer; buffer.UnsafeFormat(_T("%s [%s]"), text, unit); DrawYLabel(buffer); }
void Statistics::RenderBarograph(HDC hdc, RECT rc) { ResetScale(); ScaleXFromData(rc, &flightstats.Altitude); ScaleYFromData(rc, &flightstats.Altitude); ScaleXFromData(rc, &flightstats.Altitude_Base); ScaleYFromData(rc, &flightstats.Altitude_Base); ScaleXFromData(rc, &flightstats.Altitude_Ceiling); ScaleYFromData(rc, &flightstats.Altitude_Ceiling); DrawXGrid(hdc, rc, 0.25, flightstats.Altitude.x_min, STYLE_THINDASHPAPER); DrawYGrid(hdc, rc, 1000/ALTITUDEMODIFY, 0, STYLE_THINDASHPAPER); DrawLineGraph(hdc, rc, &flightstats.Altitude, STYLE_MEDIUMBLACK); LockTaskData(); for(int j=0;j<MAXTASKPOINTS;j++) { if (ValidTaskPoint(j) && (LegStartTime[j]>=0)) { double xx = (LegStartTime[j]-Calculated->TakeOffTime)/3600; if (xx>=0) { DrawLine(hdc, rc, xx, flightstats.Altitude.y_min, xx, flightstats.Altitude.y_max, STYLE_THINDASHPAPER); } } } UnlockTaskData(); DrawTrend(hdc, rc, &flightstats.Altitude_Base, STYLE_BLUETHIN); DrawTrend(hdc, rc, &flightstats.Altitude_Ceiling, STYLE_BLUETHIN); DrawXLabel(hdc, rc, TEXT("t")); DrawYLabel(hdc, rc, TEXT("h")); }
void Statistics::RenderTemperature(HDC hdc, const RECT rc) { ResetScale(); int i; float hmin= 10000; float hmax= -10000; float tmin= (float)CuSonde::maxGroundTemperature; float tmax= (float)CuSonde::maxGroundTemperature; // find range for scaling of graph for (i=0; i<CUSONDE_NUMLEVELS-1; i++) { if (CuSonde::cslevels[i].nmeasurements) { hmin = min(hmin, (float)i); hmax = max(hmax, (float)i); tmin = min(tmin, (float)min(CuSonde::cslevels[i].tempDry, (double)min(CuSonde::cslevels[i].airTemp, (double)CuSonde::cslevels[i].dewpoint))); tmax = max(tmax, (float)max(CuSonde::cslevels[i].tempDry, (double)max(CuSonde::cslevels[i].airTemp, (double)CuSonde::cslevels[i].dewpoint))); } } if (hmin>= hmax) { DrawNoData(hdc, rc); return; } ScaleYFromValue(rc, hmin); ScaleYFromValue(rc, hmax); ScaleXFromValue(rc, tmin); ScaleXFromValue(rc, tmax); bool labelDry = false; bool labelAir = false; bool labelDew = false; int ipos = 0; for (i=0; i<CUSONDE_NUMLEVELS-1; i++) { if (CuSonde::cslevels[i].nmeasurements && CuSonde::cslevels[i+1].nmeasurements) { ipos++; DrawLine(hdc, rc, CuSonde::cslevels[i].tempDry, i, CuSonde::cslevels[i+1].tempDry, (i+1), STYLE_REDTHICK); DrawLine(hdc, rc, CuSonde::cslevels[i].airTemp, i, CuSonde::cslevels[i+1].airTemp, (i+1), STYLE_MEDIUMBLACK); DrawLine(hdc, rc, CuSonde::cslevels[i].dewpoint, i, CuSonde::cslevels[i+1].dewpoint, i+1, STYLE_BLUETHIN); if (ipos> 2) { if (!labelDry) { DrawLabel(hdc, rc, TEXT("DALR"), CuSonde::cslevels[i+1].tempDry, i); labelDry = true; } else { if (!labelAir) { DrawLabel(hdc, rc, TEXT("Air"), CuSonde::cslevels[i+1].airTemp, i); labelAir = true; } else { if (!labelDew) { DrawLabel(hdc, rc, TEXT("Dew"), CuSonde::cslevels[i+1].dewpoint, i); labelDew = true; } } } } } } if(INVERTCOLORS) SetTextColor(hdc,RGB_DARKGREEN); else SetTextColor(hdc,RGB_GREEN); SetBkMode(hdc, OPAQUE); TCHAR text[80]; _stprintf(text,TEXT(" T/°C ")); DrawXLabel(hdc, rc, text); _stprintf(text,TEXT(" h/%s "),Units::GetAltitudeName()); DrawYLabel(hdc, rc, text); // DrawXLabel(hdc, rc, TEXT("T")TEXT(DEG)); // DrawYLabel(hdc, rc, TEXT("h")); }
void Statistics::RenderWind(HDC hdc, RECT rc) { int numsteps=10; int i; double h; Vector wind; bool found=true; double mag; LeastSquares windstats_mag; if (fabs(flightstats.Altitude_Ceiling.y_max -flightstats.Altitude_Base.y_min)<1) return; for (i=0; i<numsteps ; i++) { h = (flightstats.Altitude_Ceiling.y_max-flightstats.Altitude_Base.y_min)* i/(double)(numsteps-1)+flightstats.Altitude_Base.y_min; wind = windanalyser->windstore.getWind(h, &found); mag = sqrt(wind.x*wind.x+wind.y*wind.y); windstats_mag.least_squares_update(mag, h); } // ResetScale(); ScaleXFromValue(rc, 0); ScaleXFromData(rc, &windstats_mag); ScaleYFromData(rc, &windstats_mag); DrawYGrid(hdc, rc, 1000/ALTITUDEMODIFY, 0, STYLE_THINDASHPAPER); DrawXGrid(hdc, rc, 5/LIFTMODIFY, 0, STYLE_THINDASHPAPER); DrawLineGraph(hdc, rc, &windstats_mag, STYLE_MEDIUMBLACK); #define WINDVECTORMAG 25 numsteps = (int)((rc.bottom-rc.top)/WINDVECTORMAG)-1; // draw direction vectors POINT wv[4]; double dX, dY; double angle; double hfact; for (i=0; i<numsteps ; i++) { hfact = (i+1)/(double)(numsteps+1); h = (flightstats.Altitude_Ceiling.y_max-flightstats.Altitude_Base.y_min)* hfact+flightstats.Altitude_Base.y_min; wind = windanalyser->windstore.getWind(h, &found); if (windstats_mag.x_max == 0) windstats_mag.x_max=1; // prevent /0 problems wind.x /= windstats_mag.x_max; wind.y /= windstats_mag.x_max; mag = sqrt(wind.x*wind.x+wind.y*wind.y); if (mag<= 0.0) continue; angle = atan2(wind.x,-wind.y)*RAD_TO_DEG; wv[0].y = (int)((1-hfact)*(rc.bottom-rc.top))+rc.top; wv[0].x = (rc.right+rc.left)/2; dX = (mag*WINDVECTORMAG); dY = 0; rotate(dX,dY,angle); wv[1].x = (int)(wv[0].x + dX); wv[1].y = (int)(wv[0].y + dY); StyleLine(hdc, wv[0], wv[1], STYLE_MEDIUMBLACK); dX = (mag*WINDVECTORMAG-5); dY = -3; rotate(dX,dY,angle); wv[2].x = (int)(wv[0].x + dX); wv[2].y = (int)(wv[0].y + dY); StyleLine(hdc, wv[1], wv[2], STYLE_MEDIUMBLACK); dX = (mag*WINDVECTORMAG-5); dY = 3; rotate(dX,dY,angle); wv[3].x = (int)(wv[0].x + dX); wv[3].y = (int)(wv[0].y + dY); StyleLine(hdc, wv[1], wv[3], STYLE_MEDIUMBLACK); } DrawXLabel(hdc, rc, TEXT("w")); DrawYLabel(hdc, rc, TEXT("h")); }
void Statistics::RenderSpeed(LKSurface& Surface, const RECT& rc) { if ((flightstats.Task_Speed.sum_n<2) || !ValidTaskPoint(ActiveTaskPoint)) { DrawNoData(Surface, rc); return; } ResetScale(); ScaleXFromData(rc, &flightstats.Task_Speed); ScaleYFromData(rc, &flightstats.Task_Speed); ScaleYFromValue(rc, 0); ScaleXFromValue(rc, flightstats.Task_Speed.x_min+1.0); // in case no data ScaleXFromValue(rc, flightstats.Task_Speed.x_min); for(int j=1;j<MAXTASKPOINTS;j++) { if (ValidTaskPoint(j) && (flightstats.LegStartTime[j]>=0)) { double xx = (flightstats.LegStartTime[j]-CALCULATED_INFO.TaskStartTime)/3600.0; if (xx>=0) { DrawLine(Surface, rc, xx, y_min, xx, y_max, STYLE_REDTHICK); } } } DrawXGrid(Surface, rc, 0.5, flightstats.Task_Speed.x_min, STYLE_THINDASHPAPER, 0.5, true); /* DrawYGrid(hdc, rc, 10/TASKSPEEDMODIFY, 0, STYLE_THINDASHPAPER, 10, true);*/ if(Units::GetUserHorizontalSpeedUnit() == unStatuteMilesPerHour) { DrawYGrid(Surface, rc, 5.0/TASKSPEEDMODIFY, 0, STYLE_THINDASHPAPER, 5.0, true); } else { DrawYGrid(Surface, rc, 10/TASKSPEEDMODIFY, 0, STYLE_THINDASHPAPER, 10, true); } DrawLineGraph(Surface, rc, &flightstats.Task_Speed,STYLE_MEDIUMBLACK); DrawTrend(Surface, rc, &flightstats.Task_Speed, STYLE_BLUETHIN); if(INVERTCOLORS || IsDithered()) Surface.SetTextColor(RGB_DARKGREEN); else Surface.SetTextColor(RGB_GREEN); Surface.SetBackgroundOpaque(); TCHAR text[80]; DrawXLabel(Surface, rc, TEXT(" t/h ")); _stprintf(text,TEXT(" v/%s "),Units::GetHorizontalSpeedName()); DrawYLabel(Surface, rc, text); // DrawXLabel(hdc, rc, TEXT("t")); // DrawYLabel(hdc, rc, TEXT("V")); }