Beispiel #1
0
void MapWindow::DrawGPSStatus(Canvas &canvas, const RECT rc)
{

  if (Basic().Connected
      && !Basic().NAVWarning
      && Basic().SatellitesUsed)
    // nothing to do, all OK
    return;

  TCHAR gpswarningtext1[] = TEXT("GPS not connected");
  TCHAR gpswarningtext2[] = TEXT("GPS waiting for fix");
  TextInBoxMode_t TextInBoxMode = {2};
  TCHAR *txt=NULL;
  Bitmap *bmp=NULL;

  if (!Basic().Connected) {
    bmp = &MapGfx.hGPSStatus2;
    txt = gpswarningtext1;
  } else
    if (Basic().NAVWarning || (Basic().SatellitesUsed == 0)) {
      bmp = &MapGfx.hGPSStatus2;
      txt = gpswarningtext2;
    } else {
      return; // early exit
    }
  draw_bitmap(canvas, *bmp,
	      rc.left + IBLSCALE(2),
	      rc.bottom +IBLSCALE(Appearance.GPSStatusOffset.y - 22),
	      0, 0, 20, 20, false);
  TextInBox(canvas, gettext(txt),
	    rc.left+IBLSCALE(24),
	    rc.bottom+IBLSCALE(Appearance.GPSStatusOffset.y-19),
	    TextInBoxMode, rc);
}
Beispiel #2
0
void
Chart::DrawYGrid(const fixed tic_step, const fixed zero, enum Style Style,
                 const fixed unit_step, bool draw_units)
{
  if (!tic_step)
    return;

  POINT line[2];

  int xmin, ymin, xmax, ymax;

  for (fixed yval = zero; yval <= y_max; yval += tic_step) {
    xmin = rc.left;
    ymin = (int)((y_max - yval) * yscale) + rc.top;
    xmax = rc.right;
    ymax = ymin;
    line[0].x = xmin + BORDER_X;
    line[0].y = ymin;
    line[1].x = xmax;
    line[1].y = ymax;

    // STYLE_THINDASHPAPER
    if ((yval < y_max) && (ymin >= rc.top) && (ymin <= rc.bottom - BORDER_Y)) {
      StyleLine(line[0], line[1], Style);

      if (draw_units) {
        TCHAR unit_text[MAX_PATH];
        FormatTicText(unit_text, yval * unit_step / tic_step, unit_step);

        canvas.background_transparent();
        canvas.text(xmin + IBLSCALE(8), ymin, unit_text);
      }
    }
  }

  for (fixed yval = zero - tic_step; yval >= y_min; yval -= tic_step) {
    xmin = rc.left;
    ymin = (int)((y_max - yval) * yscale) + rc.top;
    xmax = rc.right;
    ymax = ymin;
    line[0].x = xmin + BORDER_X;
    line[0].y = ymin;
    line[1].x = xmax;
    line[1].y = ymax;

    // STYLE_THINDASHPAPER
    if ((yval > y_min) && (ymin >= rc.top) && (ymin <= rc.bottom - BORDER_Y)) {
      StyleLine(line[0], line[1], Style);

      if (draw_units) {
        TCHAR unit_text[MAX_PATH];
        FormatTicText(unit_text, yval * unit_step / tic_step, unit_step);

        canvas.background_transparent();
        canvas.text(xmin + IBLSCALE(8), ymin, unit_text);
      }
    }
  }
}
Beispiel #3
0
void 
TaskProgressRenderer::DrawTaskProgress(const TaskSummary& summary,
                                       Canvas &canvas, 
                                       const PixelRect &rc)
{
  const int radius = std::min(rc.right-rc.left, rc.bottom-rc.top)/2-IBLSCALE(3);
  RasterPoint center;
  center.x = (rc.left+rc.right)/2;
  center.y = (rc.bottom+rc.top)/2;

  const fixed sweep = fixed_two_pi*fixed(0.9);
  Pen pen_f(1, Appearance.InverseInfoBox ? COLOR_WHITE : COLOR_BLACK);

  if (summary.p_remaining<fixed(0.99)) {
    canvas.select(Graphics::hbWind);
    canvas.null_pen();
    canvas.segment(center.x, center.y, radius, Angle::radians(fixed_zero),
                   Angle::radians(sweep*(fixed_one-summary.p_remaining)));
  }

  canvas.select(pen_f);
  canvas.hollow_brush();
  canvas.circle(center.x, center.y, radius);

  unsigned i=0;
  canvas.select(pen_f);
  for (TaskSummary::TaskSummaryPointVector::const_iterator it= summary.pts.begin();
       it != summary.pts.end(); ++it, ++i) {
    Angle a= Angle::radians(it->p*sweep);
    int x = center.x+(int)(radius*a.fastsine());
    int y = center.y-(int)(radius*a.fastcosine());
    int w;
    if (i== summary.active) {
      if (it->achieved) {
        canvas.select(Graphics::hbGreen);
      } else {
        canvas.select(Graphics::hbOrange);
      }
      w = IBLSCALE(3);
    } else if (i< summary.active) {
      if (it->achieved) {
        canvas.select(Graphics::hbGreen);
      } else {
        canvas.select(Graphics::hbNotReachableTerrain);
      }
      w = IBLSCALE(2);
    } else {
      if (it->achieved) {
        canvas.select(Graphics::hbGreen);
      } else {
        canvas.select(Graphics::hbLightGray);
      }
      w = IBLSCALE(1);
    }
    canvas.rectangle(x-w, y-w, x+w, y+w);
  }
}
Beispiel #4
0
void MapWindow::DrawBitmapIn(LKSurface& Surface, const POINT &sc, const LKIcon& Icon, const bool autostretch) {
    if (!Icon) return; // don't draw Bitmap if no bitmap
    if (!PointVisible(sc)) return;

    assert(Icon.GetSize().cx == 10);
    assert(Icon.GetSize().cy == 10);
    
    if (autostretch) {
        Icon.Draw(Surface, sc.x - NIBLSCALE(5), sc.y - NIBLSCALE(5), IBLSCALE(10), IBLSCALE(10));
    } else {
        Icon.Draw(Surface, sc.x - NIBLSCALE(5), sc.y - NIBLSCALE(5), 10, 10);
    }
}
RenderObservationZone::RenderObservationZone(Canvas &_canvas,
                                             const Projection &_projection,
                                             const SETTINGS_MAP &_settings_map)
  :m_buffer(_canvas), m_proj(_projection),
   m_settings_map(_settings_map),
   pen_boundary_current(Pen::SOLID, IBLSCALE(2), Graphics::TaskColor),
   pen_boundary_active(Pen::SOLID, IBLSCALE(1), Graphics::TaskColor),
   pen_boundary_inactive(Pen::SOLID, IBLSCALE(1), Color(127, 127, 127)),
   m_past(false),
   m_current(false),
   m_background(false)
{
}
void Statistics::DrawBarChart(LKSurface& Surface, const RECT& rc, LeastSquares* lsdata) {
  int i;
LKColor Col;
  if (unscaled_x || unscaled_y) {
    return;
  }

if(INVERTCOLORS)
  Col = RGB_GREEN.ChangeBrightness(0.5);
else
  Col = RGB_WHITE;

  LKPen hpBar(PEN_SOLID, IBLSCALE(1), Col);
  LKBrush hbBar(Col);
  const auto oldpen = Surface.SelectObject(hpBar);
  const auto oldbrush = Surface.SelectObject(hbBar);


  int xmin, ymin, xmax, ymax;

  for (i= 0; i<lsdata->sum_n; i++) {
    xmin = (int)((i+1+0.2)*xscale)+rc.left+BORDER_X;
    ymin = (int)((y_max-y_min)*yscale)+rc.top;
    xmax = (int)((i+1+0.8)*xscale)+rc.left+BORDER_X;
    ymax = (int)((y_max-lsdata->ystore[i])*yscale)+rc.top;
    Surface.Rectangle(xmin, ymin, xmax, ymax);
  }

  Surface.SelectObject(oldpen);
  Surface.SelectObject(oldbrush);
}
Beispiel #7
0
static void OnPaintListItem(WindowControl * Sender, LKSurface& Surface) {
    if (!Sender) {
        return;
    }

    unsigned int n = UpLimit - LowLimit;
    TCHAR sTmp[50];

    Surface.SetTextColor(RGB_BLACK);

    const int LineHeight = Sender->GetHeight();
    const int TextHeight = Surface.GetTextHeight(_T("dp"));

    const int TextPos = (LineHeight - TextHeight) / 2; // offset for text vertical center

    if (DrawListIndex < n) {

        const size_t i = (FullFlag) ? StrIndex[LowLimit + DrawListIndex] : (LowLimit + DrawListIndex);

        // Poco::Thread::sleep(100);

        const int width = Sender->GetWidth(); // total width

        const int w0 = LineHeight; // Picto Width
        const int w2 = Surface.GetTextWidth(TEXT(" 000km")); // distance Width
        _stprintf(sTmp, _T(" 000%s "), MsgToken(2179));
        const int w3 = Surface.GetTextWidth(sTmp); // bearing width

        const int w1 = width - w0 - 2*w2 - w3; // Max Name width

        // Draw Picto
        const RECT PictoRect = {0, 0, w0, LineHeight};

        AirspaceSelectInfo[i].airspace->DrawPicto(Surface, PictoRect);


        // Draw Name
        Surface.DrawTextClip(w0, TextPos, AirspaceSelectInfo[i].airspace->Name() , w1);

        LK_tcsncpy(sTmp,  CAirspaceManager::GetAirspaceTypeShortText(AirspaceSelectInfo[i].Type) , 4);
        const int w4 = Surface.GetTextWidth(sTmp);

        Surface.DrawTextClip(w1+w2, TextPos, sTmp,w4);

        // Draw Distance : right justified after waypoint Name
        _stprintf(sTmp, TEXT("%.0f%s"), AirspaceSelectInfo[i].Distance  , Units::GetDistanceName());
        const int x2 = width - w3 - Surface.GetTextWidth(sTmp);
        Surface.DrawText(x2, TextPos, sTmp);

        // Draw Bearing right justified after distance
        _stprintf(sTmp, TEXT("%d%s"), iround(AirspaceSelectInfo[i].Direction), MsgToken(2179));
        const int x3 = width - Surface.GetTextWidth(sTmp);
        Surface.DrawText(x3, TextPos, sTmp);
    } else {
        if (DrawListIndex == 0) {
            // LKTOKEN  _@M466_ = "No Match!"
            Surface.DrawText(IBLSCALE(2), TextPos, MsgToken(466));
        }
    }
}
void
InfoBoxFullWindow::on_paint(Canvas &canvas)
{
  canvas.clear_white();

  for (unsigned i = 0; i < InfoBoxManager::layout.count; i++) {
    // JMW TODO: make these calculated once only.
    int x, y;
    int rx, ry;
    int rw;
    int rh;
    double fw, fh;

    if (Layout::landscape) {
      rw = 84;
      rh = 68;
    } else {
      rw = 120;
      rh = 80;
    }

    fw = rw / (double)InfoBoxManager::layout.control_width;
    fh = rh / (double)InfoBoxManager::layout.control_height;

    double f = std::min(fw, fh);
    rw = (int)(f * InfoBoxManager::layout.control_width);
    rh = (int)(f * InfoBoxManager::layout.control_height);

    if (Layout::landscape) {
      rx = i % 3;
      ry = i / 3;

      x = (rw + 4) * rx;
      y = (rh + 3) * ry;
    } else {
      rx = i % 2;
      ry = i / 4;

      x = (rw) * rx;
      y = (rh) * ry;
    }

    assert(InfoBoxes[i] != NULL);
    InfoBoxes[i]->PaintInto(canvas, IBLSCALE(x), IBLSCALE(y),
                            IBLSCALE(rw), IBLSCALE(rh));
  }
}
Beispiel #9
0
void MapWindow::DrawBitmapX(const HDC hdc, const int x, const int y,
                            const int sizex, const int sizey,
                            const HDC source,
                            const int offsetx, const int offsety,
                            const DWORD mode, const bool autostretch) {

  if (autostretch && ScreenScale>1) {
    StretchBlt(hdc, x, y, 
               IBLSCALE(sizex), 
               IBLSCALE(sizey), 
               source,
               offsetx, offsety, sizex, sizey,
               mode);
  } else {
    BitBlt(hdc, x, y, sizex, sizey, source, offsetx, offsety, mode); 
  }
}
Beispiel #10
0
void
MapWindow::DrawProjectedTrack(Canvas &canvas)
{
  if (task == NULL || !task->Valid() || !task->getSettings().AATEnabled ||
      task->getActiveIndex() ==0)
    return;

  if (Calculated().Circling || task->TaskIsTemporary()) {
    // don't display in various modes
    return;
  }

  // TODO feature: maybe have this work even if no task?
  // TODO feature: draw this also when in target pan mode

  GEOPOINT start = Basic().Location;
  GEOPOINT previous_loc = task->getTargetLocation(task->getActiveIndex() - 1);

  double distance_from_previous, bearing;
  DistanceBearing(previous_loc, start,
		  &distance_from_previous,
		  &bearing);

  if (distance_from_previous < 100.0) {
    bearing = Basic().TrackBearing;
    // too short to have valid data
  }
  POINT pt[2] = {{0,-75},{0,-400}};
  if (SettingsMap().TargetPan) {
    double screen_range = GetScreenDistanceMeters();
    double f_low = 0.4;
    double f_high = 1.5;
    screen_range = max(screen_range, Calculated().WaypointDistance);

    GEOPOINT p1, p2;
    FindLatitudeLongitude(start,
			  bearing, f_low*screen_range,
			  &p1);
    FindLatitudeLongitude(start,
			  bearing, f_high*screen_range,
			  &p2);
    LonLat2Screen(p1, pt[0]);
    LonLat2Screen(p2, pt[1]);
  } else if (fabs(bearing-Calculated().WaypointBearing)<10) {
    // too small an error to bother
    return;
  } else {
    pt[1].y = (long)(-max(MapRectBig.right-MapRectBig.left,
			  MapRectBig.bottom-MapRectBig.top)*1.2);
    PolygonRotateShift(pt, 2, Orig_Aircraft.x, Orig_Aircraft.y,
		       bearing-DisplayAngle);
  }

  Pen dash_pen(Pen::DASH, IBLSCALE(2), Color(0, 0, 0));
  canvas.select(dash_pen);
  canvas.line(pt[0], pt[1]);
}
Beispiel #11
0
double MapWindow::StepMapScale(int Step){
  if (abs(Step)>=4) {
    ScaleCurrent += Step/4;
  } else {
    ScaleCurrent += Step;
  }
  ScaleCurrent = max(0,min(ScaleListCount-1, ScaleCurrent));
  return((ScaleList[ScaleCurrent]*GetMapResolutionFactor())
         /(IBLSCALE(/*Appearance.DefaultMapWidth*/ MapRect.right)));
}
Beispiel #12
0
void
MapWindow::DrawAbortedTask(Canvas &canvas)
{
  if (way_points == NULL || task == NULL)
    return;

  Pen dash_pen(Pen::DASH, IBLSCALE(1), MapGfx.TaskColor);
  canvas.select(dash_pen);
  DrawAbortedTaskVisitor dv(canvas, Orig_Aircraft, *way_points);
  task->scan_point_forward(dv, false); // read lock
}
void Statistics::DrawXLabel(LKSurface& Surface, const RECT& rc, const TCHAR *text) {
  SIZE tsize;
  const auto hfOld = Surface.SelectObject(LK8GenericVar03Font);
  Surface.GetTextSize(text, _tcslen(text), &tsize);
  int x = rc.right-tsize.cx-IBLSCALE(3);
  int y = rc.bottom-tsize.cy;
  if(INVERTCOLORS)
    Surface.SelectObject(LK_BLACK_PEN);

  Surface.DrawText(x, y, text, _tcslen(text));
  Surface.SelectObject(hfOld);
}
Beispiel #14
0
void
MapCanvas::offset_line(GeoPoint a, GeoPoint b)
{
  if (!clip.clip_line(a, b))
    return;

  RasterPoint pts[3];
  pts[0] = projection.GeoToScreen(a);
  pts[1] = projection.GeoToScreen(b);
  ScreenClosestPoint(pts[0], pts[1], pts[0], &pts[2], IBLSCALE(20));
  canvas.line(pts[2], pts[1]);
}
Beispiel #15
0
  DrawTaskVisitor(MapWindow &_map_window,
		  Canvas &_canvas,
		  POINT &_orig,
		  TaskScreen_t &_task_screen,
		  StartScreen_t &_start_screen,
                  unsigned _activeIndex,
                  const WayPointList &_way_points):
    map_window(&_map_window),
    canvas(&_canvas),
    orig(_orig),
    task_screen(&_task_screen),
    start_screen(&_start_screen),
    pent1(Pen::SOLID, IBLSCALE(1), MapGfx.TaskColor),
    penb2(Pen::SOLID, IBLSCALE(2), Color(0,0,255)),
    dash_pen3(Pen::DASH, IBLSCALE(3), MapGfx.TaskColor),
    dash_pen5(Pen::DASH, IBLSCALE(5), MapGfx.TaskColor),
    dash_pen2(Pen::DASH, IBLSCALE(2), Color(127, 127, 127)),
    activeIndex(_activeIndex),
    way_points(_way_points)
  {
  }
Beispiel #16
0
void Statistics::DrawXLabel(HDC hdc, const RECT rc, const TCHAR *text) {
    SIZE tsize;
    HFONT hfOld = (HFONT)SelectObject(hdc, MapLabelFont);
    GetTextExtentPoint(hdc, text, _tcslen(text), &tsize);
    int x = rc.right-tsize.cx-IBLSCALE(3);
    int y = rc.bottom-tsize.cy;
    if(INVERTCOLORS)
        SelectObject(hdc, GetStockObject(BLACK_PEN));

    ExtTextOut(hdc, x, y, ETO_OPAQUE, NULL, text, _tcslen(text), NULL);
    SelectObject(hdc, hfOld);
}
Beispiel #17
0
void
Chart::DrawXLabel(const TCHAR *text)
{
  canvas.select(Fonts::MapLabel);

  SIZE tsize = canvas.text_size(text);
  int x = rc.right - tsize.cx - IBLSCALE(3);
  int y = rc.bottom - tsize.cy;

  canvas.background_transparent();
  canvas.text(x, y, text);
}
Beispiel #18
0
double MapWindow::FindMapScale(double Value){

  int    i;
  double BestFit = 99999;
  int    BestFitIdx=-1;
  double DesiredScale = 
    (Value*IBLSCALE(/*Appearance.DefaultMapWidth*/ MapRect.right))/GetMapResolutionFactor();

  LKASSERT(DesiredScale!=0);
  for (i=0; i<ScaleListCount; i++){
    double err = fabs(DesiredScale - ScaleList[i])/DesiredScale;
    if (err < BestFit){
      BestFit = err;
      BestFitIdx = i;
    }
  }

  if (BestFitIdx != -1){
    ScaleCurrent = BestFitIdx;
    return((ScaleList[ScaleCurrent]*GetMapResolutionFactor())
           /IBLSCALE(/*Appearance.DefaultMapWidth*/ MapRect.right));
  }
  return(Value);
}
Beispiel #19
0
void
InfoBoxManager::Create(RECT rc)
{
  info_box_look.value.fg_color
    = info_box_look.title.fg_color
    = info_box_look.comment.fg_color
    = Appearance.InverseInfoBox ? Color::WHITE : Color::BLACK;
  info_box_look.background_brush.set(Appearance.InverseInfoBox
                                     ? Color::BLACK : Color::WHITE);

  Color border_color = Color(80, 80, 80);
  info_box_look.border_pen.set(InfoBoxWindow::BORDER_WIDTH, border_color);
  info_box_look.selector_pen.set(IBLSCALE(1) + 2,
                                 info_box_look.value.fg_color);

  info_box_look.value.font = &Fonts::InfoBox;
  info_box_look.title.font = &Fonts::Title;
  info_box_look.comment.font = &Fonts::Title;
  info_box_look.small_font = &Fonts::InfoBoxSmall;

  info_box_look.colors[0] = border_color;
  info_box_look.colors[1] = Appearance.InverseInfoBox
    ? Graphics::inv_redColor : Color::RED;
  info_box_look.colors[2] = Appearance.InverseInfoBox
    ? Graphics::inv_blueColor : Color::BLUE;
  info_box_look.colors[3] = Appearance.InverseInfoBox
    ? Graphics::inv_greenColor : Color::GREEN;
  info_box_look.colors[4] = Appearance.InverseInfoBox
    ? Graphics::inv_yellowColor : Color::YELLOW;
  info_box_look.colors[5] = Appearance.InverseInfoBox
    ? Graphics::inv_magentaColor : Color::MAGENTA;

  WindowStyle style;
  style.hide();
  full_window.set(XCSoarInterface::main_window, rc.left, rc.top,
                  rc.right - rc.left, rc.bottom - rc.top);

  // create infobox windows
  for (unsigned i = 0; i < InfoBoxLayout::numInfoWindows; i++) {
    int xoff, yoff, sizex, sizey;
    InfoBoxLayout::GetInfoBoxPosition(i, rc, &xoff, &yoff, &sizex, &sizey);
    int Border = GetInfoBoxBorder(i);

    InfoBoxes[i] = new InfoBoxWindow(XCSoarInterface::main_window,
                                     xoff, yoff, sizex, sizey,
                                     Border, info_box_look);
  }
}
Beispiel #20
0
    void Show() {
        TCHAR filename[MAX_PATH];
        const TCHAR *resName = NULL;
        if (!ScreenLandscape) {
            LocalPathS(filename, TEXT("dlgBluetooth_L.xml"));
            resName = TEXT("IDR_XML_BLUETOOTH_L");
        } else {
            LocalPathS(filename, TEXT("dlgBluetooth.xml"));
            resName = TEXT("IDR_XML_BLUETOOTH");
        }
        wfBth = dlgLoadFromXML(CallBackTable, filename, resName);
        if (wfBth) {

            WndListFrame* BthList = (WndListFrame*) wfBth->FindByName(TEXT("frmBthList"));
            if (BthList) {
                BthList->SetBorderKind(BORDERLEFT | BORDERTOP | BORDERRIGHT | BORDERBOTTOM);
                BthList->SetWidth(wfBth->GetWidth() - BthList->GetLeft() - IBLSCALE(4));

                // Bug : we need ClientHeight, but Cleint Rect is Calculated by OnPaint
                // BthList->SetHeight(wfBth->GetHeight() - BthList->GetTop() - 2);
                if (BthList->ScrollbarWidth == -1) {
                    BthList->ScrollbarWidth = (int) (SCROLLBARWIDTH_INITIAL * ScreenDScale);
                }

                WndOwnerDrawFrame* BthListEntry = (WndOwnerDrawFrame*) wfBth->FindByName(TEXT("frmBthListEntry"));
                if (BthListEntry) {
                    BthListEntry->SetCanFocus(true);
                    BthListEntry->SetWidth(BthList->GetWidth() - BthList->ScrollbarWidth - 5);
                }

                BthList->ResetList();
                BthList->Redraw();
            }

            if (wfBth->ShowModal()) {
                CBtHandler * pBtHandler = CBtHandler::Get();
                if (pBtHandler) {
                    pBtHandler->ClearDevices();
                    pBtHandler->FillDevices();
                }
                RefreshComPortList();
            }

            delete wfBth;
            wfBth = NULL;
        }
    }
Beispiel #21
0
static int rescale(int n) {
  switch (use_rescale) {
      case 0:
          return n;
          break;
      case 1:
          return IBLSCALE(n);
          break;
      case 2:
          return (n*newscale);
          break;
      default:
          break;
  }
  LKASSERT(0);
  return n; // impossible
}
Beispiel #22
0
dlgProgress::dlgProgress() {
    
    _WndForm = dlgLoadFromXML(CallBackTable, ScreenLandscape ? IDR_XML_PROGRESS_L : IDR_XML_PROGRESS_P);
    LKASSERT(_WndForm);
    if(_WndForm) {
        WindowControl* wSplash = _WndForm->FindByName(TEXT("frmSplash")); 
        if(wSplash) {
            wSplash->SetWidth(_WndForm->GetWidth());
        }
        WindowControl* wText = _WndForm->FindByName(TEXT("frmText")); 
        if(wText) {
            wText->SetWidth(_WndForm->GetWidth());
            wText->SetTop(ScreenSizeY - IBLSCALE(35));
        }
        _WndForm->Show();
        _WndForm->Redraw();
    }
}
Beispiel #23
0
  void
  visit_leg_final(TASK_POINT &point0, const unsigned index0,
                  TASK_POINT &point1, const unsigned index1)
  {
    bool is_first = (point0.Index < point1.Index);
    int imin = min(point0.Index,point1.Index);
    int imax = max(point0.Index,point1.Index);
    // JMW AAT!
    double bearing = point0.OutBound;
    POINT sct1, sct2;

    canvas->select(dash_pen3);

    if (_task->getSettings().AATEnabled && !map_window->SettingsMap().TargetPan) {
      map_window->LonLat2Screen(point0.AATTargetLocation, sct1);
      map_window->LonLat2Screen(point1.AATTargetLocation, sct2);
      bearing = Bearing(point0.AATTargetLocation, point1.AATTargetLocation);

      // draw nominal track line
      canvas->line(way_points.get_calc(imin).Screen,
                   way_points.get_calc(imax).Screen);
    } else {
      sct1 = way_points.get_calc(point0.Index).Screen;
      sct2 = way_points.get_calc(point1.Index).Screen;
    }

    if (is_first) {
      canvas->line(sct1, sct2);
    } else {
      canvas->line(sct2, sct1);
    }

    // draw small arrow along task direction
    POINT p_p;
    POINT Arrow[3] = { {6,6}, {-6,6}, {0,0} };
    ScreenClosestPoint(sct1, sct2, orig, &p_p, IBLSCALE(25));
    PolygonRotateShift(Arrow, 2, p_p.x, p_p.y,
		       bearing-map_window->GetDisplayAngle());
    Arrow[2] = Arrow[1];
    Arrow[1] = p_p;

    canvas->select(pent1);
    canvas->polyline(Arrow, 3);
  };
Beispiel #24
0
void RenderCircleSky(HDC hdc, const RECT rc, COLORREF Col1, COLORREF Col2 , int iSteps)
{
RECT rcd;
int i;


double fdy = (double)(rc.top - rc.bottom)/(double)iSteps;
HPEN   hpHorizon;
HBRUSH hbHorizon;
COLORREF Col;
double fTop;
LKASSERT(iSteps!=0);

/* just take something in order to store the old brush and pen for restoring them */
HPEN OldPen     = (HPEN)   SelectObject(hdc, GetStockObject(WHITE_PEN));
HBRUSH OldBrush = (HBRUSH) SelectObject(hdc, GetStockObject(BLACK_BRUSH));
	rcd = rc;

	fTop = (double)rcd.bottom;
	for(i=0 ; i < iSteps ; i++)
	{
	  rcd.bottom  = rcd.top ;
	  fTop += fdy;
	  rcd.top     = (long)fTop;

	  Col = MixColors( Col2, Col1,  (double) i / (double) iSteps);

//	  rcd = RectIntersect(rcd,rc);
	  hpHorizon = (HPEN)CreatePen(PS_SOLID, IBLSCALE(1), Col);
	  hbHorizon = (HBRUSH)CreateSolidBrush(Col);
	  SelectObject(hdc, hpHorizon);
	  SelectObject(hdc, hbHorizon);

	//  Rectangle(hdc,rcd.left,rcd.top,rcd.right,rcd.bottom);
	//  Circle(hdc,rcd.left,rcd.top,rcd.right,rcd.bottom);
	//  int Circle(HDC hdc, long x, long y, int radius, RECT rc, bool clip, bool fill)
	  SelectObject(hdc, OldPen);
	  SelectObject(hdc, OldBrush);

	  DeleteObject(hpHorizon);
	  DeleteObject(hbHorizon);
   }
}
Beispiel #25
0
void Statistics::DrawBarChart(HDC hdc, const RECT rc, LeastSquares* lsdata) {
    int i;
    COLORREF Col;
    if (unscaled_x || unscaled_y) {
        return;
    }

    if(INVERTCOLORS)
        Col = ChangeBrightness(RGB_GREEN, 0.5);
    else
        Col = RGB_WHITE;

    HPEN    hpBar = (HPEN)CreatePen(PS_SOLID, IBLSCALE(1), Col);
    HBRUSH  hbBar = (HBRUSH)CreateSolidBrush(Col);
    HPEN   oldpen   = (HPEN)   SelectObject(hdc, hpBar);
    HBRUSH oldbrush = (HBRUSH) SelectObject(hdc, hbBar);


    int xmin, ymin, xmax, ymax;

    for (i= 0; i<lsdata->sum_n; i++) {
        xmin = (int)((i+1+0.2)*xscale)+rc.left+BORDER_X;
        ymin = (int)((y_max-y_min)*yscale)+rc.top;
        xmax = (int)((i+1+0.8)*xscale)+rc.left+BORDER_X;
        ymax = (int)((y_max-lsdata->ystore[i])*yscale)+rc.top;
        Rectangle(hdc,
                  xmin,
                  ymin,
                  xmax,
                  ymax);
    }

    SelectObject(hdc, oldpen);
    SelectObject(hdc, oldbrush);
    DeleteObject (hpBar);
    DeleteObject (hbBar);
}
Beispiel #26
0
// returns true if really wrote something
bool
TextInBox(Canvas &canvas, const TCHAR* Value, int x, int y,
    TextInBoxMode_t Mode, const RECT MapRect, LabelBlock *label_block)
{
  RECT brect;
  POINT org;

  bool drawn = false;

  if ((x<MapRect.left-WPCIRCLESIZE) ||
      (x>MapRect.right+(WPCIRCLESIZE*3)) ||
      (y<MapRect.top-WPCIRCLESIZE) ||
      (y>MapRect.bottom+WPCIRCLESIZE))
    return drawn; // FIX Not drawn really


  org.x = x;
  org.y = y;

  canvas.white_brush();

  if (Mode.AsFlag.Reachable){
    if (Appearance.IndLandable == wpLandableDefault)
      // make space for the green circle
      x += 5;
    else if (Appearance.IndLandable == wpLandableAltA)
      x += 0;
  }

  // landable waypoint label inside white box
  if (!Mode.AsFlag.NoSetFont) {
    // VENTA5 predefined font from calling function
    canvas.select(Mode.AsFlag.Border ? MapWindowBoldFont : MapWindowFont);
  }

  SIZE tsize = canvas.text_size(Value);

  if (Mode.AsFlag.AlignRight) {
    x -= tsize.cx;
  } else if (Mode.AsFlag.AlignCenter) {
    x -= tsize.cx / 2;
    y -= tsize.cy / 2;
  }

  bool notoverlapping = true;

  if (Mode.AsFlag.Border || Mode.AsFlag.WhiteBorder){
    POINT offset;

    brect.left = x - 2;
    brect.right = brect.left + tsize.cx + 4;
    brect.top = y + ((tsize.cy + 4) >> 3) - 2;
    brect.bottom = brect.top + 3 + tsize.cy - ((tsize.cy + 4) >> 3);

    if (Mode.AsFlag.AlignRight)
      x -= 3;

    if (TextInBoxMoveInView(&offset, &brect, MapRect)) {
      x += offset.x;
      y += offset.y;
    }

    if (label_block)
      notoverlapping = label_block->check(brect);
    else
      notoverlapping = true;

    if (notoverlapping) {
      if (Mode.AsFlag.Border)
        canvas.select(MapGfx.hpMapScale);
      else
        canvas.white_pen();


      canvas.round_rectangle(brect.left, brect.top, brect.right, brect.bottom,
                             IBLSCALE(8), IBLSCALE(8));
#ifdef WINDOWSPC
      canvas.background_transparent();
      canvas.text(x, y, Value);
#else
      canvas.text_opaque(x, y, Value);
#endif
      drawn = true;
    }
  } else if (Mode.AsFlag.FillBackground) {
Beispiel #27
0
void
ScreenGraphics::Initialise(HINSTANCE hInstance, const SETTINGS_MAP &settings_map)
{
  int i;

  StartupStore(TEXT("Initialise graphics\n"));

  LoadUnitSymbols();

  infoSelectedBrush.set(MapGfx.ColorSelected);
  infoUnselectedBrush.set(MapGfx.ColorUnselected);
  buttonBrush.set(MapGfx.ColorButton);

  redBrush.set(Color::RED);
  yellowBrush.set(Color::YELLOW);
  greenBrush.set(Color::GREEN);

  hBackgroundBrush.set(BackgroundColor);

  hFLARMTraffic.load(IDB_FLARMTRAFFIC);
  hTerrainWarning.load(IDB_TERRAINWARNING);
  hTurnPoint.load(IDB_TURNPOINT);
  hSmall.load(IDB_SMALL);
  hAutoMacCready.load(IDB_AUTOMACCREADY);
  hGPSStatus1.load(IDB_GPSSTATUS1);
  hGPSStatus2.load(IDB_GPSSTATUS2);
  hLogger.load(IDB_LOGGER);
  hLoggerOff.load(IDB_LOGGEROFF);
  hBmpTeammatePosition.load(IDB_TEAMMATE_POS);

  hCruise.load(IDB_CRUISE);
  hClimb.load(IDB_CLIMB);
  hFinalGlide.load(IDB_FINALGLIDE);
  hAbort.load(IDB_ABORT);

  // airspace brushes and colors
  hAirspaceBitmap[0].load(IDB_AIRSPACE0);
  hAirspaceBitmap[1].load(IDB_AIRSPACE1);
  hAirspaceBitmap[2].load(IDB_AIRSPACE2);
  hAirspaceBitmap[3].load(IDB_AIRSPACE3);
  hAirspaceBitmap[4].load(IDB_AIRSPACE4);
  hAirspaceBitmap[5].load(IDB_AIRSPACE5);
  hAirspaceBitmap[6].load(IDB_AIRSPACE6);
  hAirspaceBitmap[7].load(IDB_AIRSPACE7);

  hAboveTerrainBitmap.load(IDB_ABOVETERRAIN);

  for (i = 0; i < NUMAIRSPACEBRUSHES; i++) {
    hAirspaceBrushes[i].set(hAirspaceBitmap[i]);
  }
  hAboveTerrainBrush.set(hAboveTerrainBitmap);

#if (MONOCHROME_SCREEN > 0)
  hbWind.set(Color(0x80, 0x80, 0x80));
#else
  hbWind.set(Color(0x80, 0x80, 0x80));
#endif

  hBmpMapScale.load(IDB_MAPSCALE_A);
  hBrushFlyingModeAbort.set(Color::RED);

  hBmpThermalSource.load(IDB_THERMALSOURCE);
  hBmpTarget.load(IDB_TARGET);

#if (MONOCHROME_SCREEN > 0)
  hbCompass.set(Color::WHITE);
#else
  hbCompass.set(Color(0x40, 0x40, 0xFF));
#endif
  hbThermalBand.set(Color(0x80, 0x80, 0xFF));
  hbBestCruiseTrack.set(Color::BLUE);
  hbFinalGlideBelow.set(Color::RED);
  hbFinalGlideBelowLandable.set(Color(0xFF, 180, 0x00));
  hbFinalGlideAbove.set(Color::GREEN);

  // all below depend on settings!

  BYTE Red,Green,Blue;

  int iwidth;
  int minwidth;
  minwidth = max(IBLSCALE(2),IBLSCALE(settings_map.SnailWidthScale)/16);

  for (i = 0; i < NUMSNAILCOLORS; i++) {
    short ih = i * 200 / (NUMSNAILCOLORS - 1);
    ColorRampLookup(ih, Red, Green, Blue, snail_colors, NUMSNAILRAMP, 6);

    if (i < NUMSNAILCOLORS / 2) {
      iwidth = minwidth;
    } else {
      iwidth = max(minwidth,
                   (i - NUMSNAILCOLORS/2)
                   * IBLSCALE(settings_map.SnailWidthScale) / NUMSNAILCOLORS);
    }

    hSnailColours[i] = Color((BYTE)Red, (BYTE)Green, (BYTE)Blue);
    hSnailPens[i].set(iwidth, hSnailColours[i]);
  }

  hpCompassBorder.set(IBLSCALE(3), Color::WHITE);

  if (Appearance.InverseAircraft) {
    hpAircraft.set(IBLSCALE(3), Color::BLACK);
    hpAircraftBorder.set(IBLSCALE(1), Color::WHITE);
  } else {
    hpAircraft.set(IBLSCALE(3), Color::WHITE);
    hpAircraftBorder.set(IBLSCALE(1), Color::BLACK);
  }

#if (MONOCHROME_SCREEN > 0)
  hpWind.set(IBLSCALE(2), Color::BLACK);
#else
  hpWind.set(IBLSCALE(2), Color::RED);
#endif

  hpWindThick.set(IBLSCALE(4), Color(255, 220, 220));

  hpBearing.set(IBLSCALE(2), Color(0, 0, 0));
  hpBestCruiseTrack.set(IBLSCALE(1), Color::BLUE);
#if (MONOCHROME_SCREEN > 0)
  hpCompass.set(IBLSCALE(1), Color::BLACK);
  //hpCompass.set(1, Color(0xff,0xff,0xff));
#else
  hpCompass.set(IBLSCALE(1), Color(0xcf, 0xcf, 0xFF));
#endif
  hpThermalBand.set(IBLSCALE(2), Color(0x40, 0x40, 0xFF));
  hpThermalBandGlider.set(IBLSCALE(2), Color(0x00, 0x00, 0x30));

  hpFinalGlideBelow.set(IBLSCALE(1), Color(0xFF, 0xA0, 0xA0));
  hpFinalGlideBelowLandable.set(IBLSCALE(1), Color(255, 196, 0));

  // TODO enhancement: support red/green Color blind
  hpFinalGlideAbove.set(IBLSCALE(1), Color(0xA0, 0xFF, 0xA0));

  hpSpeedSlow.set(IBLSCALE(1), Color::RED);
  hpSpeedFast.set(IBLSCALE(1), Color::GREEN);

  hpStartFinishThick.set(IBLSCALE(5), TaskColor);

  hpStartFinishThin.set(IBLSCALE(1), Color(255, 0, 0));

  hpMapScale.set(IBLSCALE(1), Color(0, 0, 0));
  hpTerrainLine.set(Pen::DASH, IBLSCALE(1), Color(0x30, 0x30, 0x30));
  hpTerrainLineBg.set(IBLSCALE(1), Color::WHITE);
  // VENTA3
  hpVisualGlideLightBlack.set(Pen::DASH, IBLSCALE(1), Color(0x0, 0x0, 0x0));
  hpVisualGlideHeavyBlack.set(Pen::DASH, IBLSCALE(2), Color(0x0, 0x0, 0x0));
  hpVisualGlideLightRed.set(Pen::DASH, IBLSCALE(1), Color::RED);
  hpVisualGlideHeavyRed.set(Pen::DASH, IBLSCALE(2), Color::RED);

  if (Appearance.IndLandable == wpLandableDefault) {
    hBmpAirportReachable.load(IDB_REACHABLE);
    hBmpAirportUnReachable.load(IDB_LANDABLE);
    hBmpFieldReachable.load(IDB_REACHABLE);
    hBmpFieldUnReachable.load(IDB_LANDABLE);
  } else if (Appearance.IndLandable == wpLandableAltA){
    hBmpAirportReachable.load(IDB_AIRPORT_REACHABLE);
    hBmpAirportUnReachable.load(IDB_AIRPORT_UNREACHABLE);
    hBmpFieldReachable.load(IDB_OUTFILED_REACHABLE);
    hBmpFieldUnReachable.load(IDB_OUTFILED_UNREACHABLE);
  }

  for (int i = 0; i < AIRSPACECLASSCOUNT; i++) {
    hAirspacePens[i].set(IBLSCALE(2), GetAirspaceColourByClass(i, settings_map));
  }
}
Beispiel #28
0
void MapWindow::FillScaleListForEngineeringUnits(void)
{
  int i;

  // Fill up discrete map scales
  // Consider scalelist size!!!
  switch (Units::GetUserDistanceUnit()) {
    default:
      ScaleListCount = 0;
      ScaleList[ScaleListCount++] = 0.01;		// km
      ScaleList[ScaleListCount++] = 0.015;
      ScaleList[ScaleListCount++] = 0.025;
      ScaleList[ScaleListCount++] = 0.040;
      ScaleList[ScaleListCount++] = 0.070;
      ScaleList[ScaleListCount++] = 0.1;
      ScaleList[ScaleListCount++] = 0.15;
      ScaleList[ScaleListCount++] = 0.2;
      ScaleList[ScaleListCount++] = 0.35;
      ScaleList[ScaleListCount++] = 0.5;
      ScaleList[ScaleListCount++] = 0.75;
      ScaleList[ScaleListCount++] = 1.0;
      ScaleList[ScaleListCount++] = 1.5;
      ScaleList[ScaleListCount++] = 2.0;
      ScaleList[ScaleListCount++] = 3.5;
      ScaleList[ScaleListCount++] = 5.0;
      ScaleList[ScaleListCount++] = 7.5;
      ScaleList[ScaleListCount++] = 10.0;
      ScaleList[ScaleListCount++] = 15.0;
      ScaleList[ScaleListCount++] = 20.0;
      ScaleList[ScaleListCount++] = 25.0;
      ScaleList[ScaleListCount++] = 40.0;
      ScaleList[ScaleListCount++] = 50.0;
      ScaleList[ScaleListCount++] = 75.0;
      break;
      
    case unStatuteMiles:
      ScaleListCount = 0;
      ScaleList[ScaleListCount++] = 50.0  * (0.0006214 / 3.281);		// to ft;
      ScaleList[ScaleListCount++] = 80.0  * (0.0006214 / 3.281);	// to ft
      ScaleList[ScaleListCount++] = 130.0 * (0.0006214 / 3.281);	// to ft
      ScaleList[ScaleListCount++] = 200.0 * (0.0006214 / 3.281);	// to ft
      ScaleList[ScaleListCount++] = 350.0 * (0.0006214 / 3.281);	// to ft
      ScaleList[ScaleListCount++] = 500.0 * (0.0006214 / 3.281);	// to ft
      ScaleList[ScaleListCount++] = 800.0 * (0.0006214 / 3.281);	// to ft
      ScaleList[ScaleListCount++] = 0.2;
      ScaleList[ScaleListCount++] = 0.35;
      ScaleList[ScaleListCount++] = 0.5;
      ScaleList[ScaleListCount++] = 0.75;
      ScaleList[ScaleListCount++] = 1.0;
      ScaleList[ScaleListCount++] = 1.5;
      ScaleList[ScaleListCount++] = 2.0;
      ScaleList[ScaleListCount++] = 3.5;
      ScaleList[ScaleListCount++] = 5.0;
      ScaleList[ScaleListCount++] = 7.5;
      ScaleList[ScaleListCount++] = 10.0;
      ScaleList[ScaleListCount++] = 15.0;
      ScaleList[ScaleListCount++] = 20.0;
      ScaleList[ScaleListCount++] = 25.0;
      ScaleList[ScaleListCount++] = 40.0;
      break;

    case unNauticalMiles:
      ScaleListCount = 0;
      ScaleList[ScaleListCount++] = 50.0  * (0.00053996 / 3.281);	// to ft;
      ScaleList[ScaleListCount++] = 100.0 * (0.00053996 / 3.281);	// to ft;
      ScaleList[ScaleListCount++] = 150.0 * (0.00053996 / 3.281);	// to ft
      ScaleList[ScaleListCount++] = 250.0 * (0.00053996 / 3.281);	// to ft
      ScaleList[ScaleListCount++] = 400.0 * (0.00053996 / 3.281);	// to ft
      ScaleList[ScaleListCount++] = 600.0 * (0.00053996 / 3.281);	// to ft
      ScaleList[ScaleListCount++] = 900.0 * (0.00053996 / 3.281);	// to ft
      ScaleList[ScaleListCount++] = 0.2;
      ScaleList[ScaleListCount++] = 0.35;
      ScaleList[ScaleListCount++] = 0.5;
      ScaleList[ScaleListCount++] = 0.75;
      ScaleList[ScaleListCount++] = 1.0;
      ScaleList[ScaleListCount++] = 1.5;
      ScaleList[ScaleListCount++] = 2.0;
      ScaleList[ScaleListCount++] = 3.5;
      ScaleList[ScaleListCount++] = 5.0;
      ScaleList[ScaleListCount++] = 7.5;
      ScaleList[ScaleListCount++] = 10.0;
      ScaleList[ScaleListCount++] = 15.0;
      ScaleList[ScaleListCount++] = 20.0;
      ScaleList[ScaleListCount++] = 25.0;
      ScaleList[ScaleListCount++] = 40.0;
      break;
  } //sw units
  
  double scalefactor = (double)GetMapResolutionFactor() / (double)IBLSCALE(/*Appearance.DefaultMapWidth*/ MapRect.right) * 1.4;
  for (i=0; i<ScaleListCount; i++) ScaleList[i] /= scalefactor;
}
Beispiel #29
0
void MapWindow::DrawCompass(Canvas &canvas, const RECT rc)
{
  POINT Start;

  if (Appearance.CompassAppearance == apCompassDefault){

    Start.y = IBLSCALE(19)+rc.top;
    Start.x = rc.right - IBLSCALE(19);

    if (SettingsMap().EnableVarioGauge && MapRectBig.right == rc.right)
        Start.x -= InfoBoxLayout::ControlWidth;

    POINT Arrow[5] = { {0,-18}, {-6,10}, {0,0}, {6,10}, {0,-18}};

    canvas.select(MapGfx.hpCompass);
    canvas.select(MapGfx.hbCompass);

    // North arrow
    PolygonRotateShift(Arrow, 5, Start.x, Start.y, -DisplayAngle);
    canvas.polygon(Arrow, 5);

  } else if (Appearance.CompassAppearance == apCompassAltA) {

    static double lastDisplayAngle = 9999.9;
    static int lastRcRight = 0;
    static POINT Arrow[5] = { {0,-11}, {-5,9}, {0,3}, {5,9}, {0,-11}};

    if (lastDisplayAngle != DisplayAngle || lastRcRight != rc.right){

      Arrow[0].x  = 0;
      Arrow[0].y  = -11;
      Arrow[1].x  = -5;
      Arrow[1].y  = 9;
      Arrow[2].x  = 0;
      Arrow[2].y  = 3;
      Arrow[3].x  = 5;
      Arrow[3].y  = 9;
      Arrow[4].x  = 0;
      Arrow[4].y  = -11;

      Start.y = rc.top + IBLSCALE(10);
      Start.x = rc.right - IBLSCALE(11);

      if (SettingsMap().EnableVarioGauge && MapRectBig.right == rc.right) {
        Start.x -= InfoBoxLayout::ControlWidth;
      }

      // North arrow
      PolygonRotateShift(Arrow, 5, Start.x, Start.y,
                         -DisplayAngle);

      lastDisplayAngle = DisplayAngle;
      lastRcRight = rc.right;
    }

    canvas.polygon(Arrow, 5);

    canvas.select(MapGfx.hpCompass);
    canvas.polygon(Arrow, 5);
  }

}
Beispiel #30
0
void MapWindow::DrawTeammate(LKSurface& Surface, const RECT& rc, const ScreenProjection& _Proj) {
    if (TeammateCodeValid) {
        if (PointVisible(TeammateLongitude, TeammateLatitude)) {
            const POINT point = _Proj.LonLat2Screen(TeammateLongitude, TeammateLatitude);
            hBmpTeammatePosition.Draw(Surface, point.x - NIBLSCALE(10), point.y - NIBLSCALE(10), IBLSCALE(20), IBLSCALE(20));
        }
    }
}