예제 #1
0
void MapWindow::DrawWaypoints(Canvas &canvas)
{
  if (way_points == NULL)
    return;

  TCHAR Buffer[32];
  TCHAR Buffer2[32];
  TCHAR sAltUnit[4];
  TextInBoxMode_t TextDisplayMode;

  // if pan mode, show full names
  int pDisplayTextType = SettingsMap().DisplayTextType;
  if (SettingsMap().EnablePan) {
    pDisplayTextType = DISPLAYNAME;
  }

  _tcscpy(sAltUnit, Units::GetAltitudeName());

  MapWaypointLabelClear();

  for (unsigned i = 0; way_points->verify_index(i); ++i) {
    const WAYPOINT &way_point = way_points->get(i);
    const WPCALC &wpcalc = way_points->get_calc(i);

    if (wpcalc.Visible) {

      bool irange = false;
      bool islandable = false;
      bool dowrite;

      dowrite = wpcalc.InTask;

      TextDisplayMode.AsInt = 0;

      irange = WaypointInScaleFilter(way_point);

      Bitmap *wp_bmp = &MapGfx.hSmall;

      if(GetMapScaleKM() > 20) {
        wp_bmp = &MapGfx.hSmall;
      } else if( ((way_point.Flags & AIRPORT) == AIRPORT)
                 || ((way_point.Flags & LANDPOINT) == LANDPOINT) ) {
        islandable = true; // so we can always draw them
        if (wpcalc.Reachable) {

          TextDisplayMode.AsFlag.Reachable = 1;

          if ((SettingsMap().DeclutterLabels<2)||wpcalc.InTask) {

            if (wpcalc.InTask || (SettingsMap().DeclutterLabels<1)) {
              TextDisplayMode.AsFlag.Border = 1;
            }
            // show all reachable landing fields unless we want a decluttered
            // screen.
            dowrite = true;
          }

          if ((way_point.Flags & AIRPORT) == AIRPORT)
            wp_bmp = &MapGfx.hBmpAirportReachable;
          else
            wp_bmp = &MapGfx.hBmpFieldReachable;
        } else {
          if ((way_point.Flags & AIRPORT) == AIRPORT)
            wp_bmp = &MapGfx.hBmpAirportUnReachable;
          else
            wp_bmp = &MapGfx.hBmpFieldUnReachable;
        }
      } else {
        if (GetMapScaleKM()>4) {
          wp_bmp = &MapGfx.hTurnPoint;
        } else {
          wp_bmp = &MapGfx.hSmall;
        }
      }

      if (wpcalc.InTask) { // VNT
        TextDisplayMode.AsFlag.WhiteBold = 1;
      }

      if(irange || wpcalc.InTask || islandable || dowrite) {
        draw_masked_bitmap(canvas, *wp_bmp,
                           wpcalc.Screen.x, wpcalc.Screen.y,
                           20, 20);
      }

      if(wpcalc.InTask || irange || dowrite) {
        bool draw_alt = TextDisplayMode.AsFlag.Reachable
          && ((SettingsMap().DeclutterLabels<1) || wpcalc.InTask);

        switch(pDisplayTextType) {
        case DISPLAYNAMEIFINTASK:
          dowrite = wpcalc.InTask;
          if (wpcalc.InTask) {
            if (draw_alt)
              _stprintf(Buffer, TEXT("%s:%d%s"),
                        way_point.Name,
                        (int)(wpcalc.AltArrivalAGL*ALTITUDEMODIFY),
                        sAltUnit);
            else
              _stprintf(Buffer, TEXT("%s"),way_point.Name);
          }
          break;
        case DISPLAYNAME:
          dowrite = (SettingsMap().DeclutterLabels<2) || wpcalc.InTask;
          if (draw_alt)
            _stprintf(Buffer, TEXT("%s:%d%s"),
                      way_point.Name,
                      (int)(wpcalc.AltArrivalAGL*ALTITUDEMODIFY),
                      sAltUnit);
          else
            _stprintf(Buffer, TEXT("%s"),way_point.Name);

          break;
        case DISPLAYNUMBER:
          dowrite = (SettingsMap().DeclutterLabels<2) || wpcalc.InTask;
          if (draw_alt)
            _stprintf(Buffer, TEXT("%d:%d%s"),
                      way_point.Number,
                      (int)(wpcalc.AltArrivalAGL*ALTITUDEMODIFY),
                      sAltUnit);
          else
            _stprintf(Buffer, TEXT("%d"),way_point.Number);

          break;
        case DISPLAYFIRSTFIVE:
          dowrite = (SettingsMap().DeclutterLabels<2) || wpcalc.InTask;
          _tcsncpy(Buffer2, way_point.Name, 5);
          Buffer2[5] = '\0';
          if (draw_alt)
            _stprintf(Buffer, TEXT("%s:%d%s"),
                      Buffer2,
                      (int)(wpcalc.AltArrivalAGL*ALTITUDEMODIFY),
                      sAltUnit);
          else
            _stprintf(Buffer, TEXT("%s"),Buffer2);

          break;
        case DISPLAYFIRSTTHREE:
          dowrite = (SettingsMap().DeclutterLabels<2) || wpcalc.InTask;
          _tcsncpy(Buffer2, way_point.Name, 3);
          Buffer2[3] = '\0';
          if (draw_alt)
            _stprintf(Buffer, TEXT("%s:%d%s"),
                      Buffer2,
                      (int)(wpcalc.AltArrivalAGL*ALTITUDEMODIFY),
                      sAltUnit);
          else
            _stprintf(Buffer, TEXT("%s"),Buffer2);

          break;
        case DISPLAYNONE:
          dowrite = (SettingsMap().DeclutterLabels<2) || wpcalc.InTask;
          if (draw_alt)
            _stprintf(Buffer, TEXT("%d%s"),
                      (int)(wpcalc.AltArrivalAGL*ALTITUDEMODIFY),
                      sAltUnit);
          else
            Buffer[0]= '\0';
          break;
        default:
          assert(0);
          break;
        }

        if (dowrite) {
          MapWaypointLabelAdd(
            Buffer,
            wpcalc.Screen.x + 5, wpcalc.Screen.y,
            TextDisplayMode,
            (int)(wpcalc.AltArrivalAGL*ALTITUDEMODIFY),
            wpcalc.InTask,false,false,false,
            MapRect);
        }
      }
    }
  }
  MapWaypointLabelSortAndRender(canvas);
}
예제 #2
0
void MapWindow::DrawFlightMode(Canvas &canvas, const RECT rc)
{
  static bool flip= true;
  static double LastTime = 0;
  bool drawlogger = true;
  static bool lastLoggerActive=false;
  int offset = -1;

  if (!Appearance.DontShowLoggerIndicator){

    // has GPS time advanced?
    if(Basic().Time <= LastTime) {
      LastTime = Basic().Time;
    } else {
      flip = !flip;

      // don't bother drawing logger if not active for more than one second
      if ((!logger.isLoggerActive())&&(!lastLoggerActive)) {
        drawlogger = false;
      }
      lastLoggerActive = logger.isLoggerActive();
    }

    if (drawlogger) {
      offset -= 7;

      draw_masked_bitmap(canvas,
			 (logger.isLoggerActive() && flip)
			 ? MapGfx.hLogger : MapGfx.hLoggerOff,
			 rc.right + IBLSCALE(offset + Appearance.FlightModeOffset.x),
			 rc.bottom + IBLSCALE(-7 + Appearance.FlightModeOffset.y),
			 7, 7, false);
    }
  }

  if (Appearance.FlightModeIcon == apFlightModeIconDefault){
    Bitmap *bmp;
    if (task.isTaskAborted()) {
      bmp = &MapGfx.hAbort;
    } else if (DisplayMode == dmCircling) {
      bmp = &MapGfx.hClimb;
    } else if (DisplayMode == dmFinalGlide) {
      bmp = &MapGfx.hFinalGlide;
    } else {
      bmp = &MapGfx.hCruise;
    }

    offset -= 24;

    draw_masked_bitmap(canvas, *bmp,
		       rc.right + IBLSCALE(offset - 1 + Appearance.FlightModeOffset.x),
		       rc.bottom + IBLSCALE(-20 - 1 + Appearance.FlightModeOffset.y),
		       24, 20, false);

  } else if (Appearance.FlightModeIcon == apFlightModeIconAltA){

#define SetPoint(Idx,X,Y) Arrow[Idx].x = X; Arrow[Idx].y = Y

    POINT Arrow[3];
    POINT Center;

    Center.x = rc.right-10;
    Center.y = rc.bottom-10;

    if (DisplayMode == dmCircling) {

      SetPoint(0,
               Center.x,
               Center.y-IBLSCALE(4));
      SetPoint(1,
               Center.x-IBLSCALE(8),
               Center.y+IBLSCALE(4));
      SetPoint(2,
               Center.x+IBLSCALE(8),
               Center.y+IBLSCALE(4));

    } else if (DisplayMode == dmFinalGlide) {

      SetPoint(0,
               Center.x,
               Center.y+IBLSCALE(4));
      SetPoint(1,
               Center.x-IBLSCALE(8),
               Center.y-IBLSCALE(4));
      SetPoint(2,
               Center.x+IBLSCALE(8),
               Center.y-IBLSCALE(4));
    } else {

      SetPoint(0,
               Center.x+IBLSCALE(4),
               Center.y);
      SetPoint(1,
               Center.x-IBLSCALE(4),
               Center.y+IBLSCALE(8));
      SetPoint(2,
               Center.x-IBLSCALE(4),
               Center.y-IBLSCALE(8));

    }

    if (task.isTaskAborted())
      canvas.select(MapGfx.hBrushFlyingModeAbort);
    else
      canvas.select(MapGfx.hbCompass);

    canvas.select(MapGfx.hpCompassBorder);
    canvas.polygon(Arrow, 3);

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


  if (!Appearance.DontShowAutoMacCready && SettingsComputer().AutoMacCready) {

    offset -= 24;

    //changed draw mode & icon for higher opacity 12aug -st

    draw_masked_bitmap(canvas, MapGfx.hAutoMacCready,
		       rc.right + IBLSCALE(offset - 3 + Appearance.FlightModeOffset.x),
		       rc.bottom + IBLSCALE(-20 - 3 + Appearance.FlightModeOffset.y),
		       24, 20, false);
  };

}