Beispiel #1
0
void TankGameWidget::Reset()
{
    UpdatePaintConstants();

    m_backgroundPainter.reset();
    m_backgroundPixmap.reset(new QPixmap(m_const.boardPixelSizeFloat.x()+2, m_const.boardPixelSizeFloat.y()+2));
    m_backgroundPixmap->fill(Qt::transparent);
    m_backgroundPainter.reset(new QPainter(m_backgroundPixmap.get()));
    m_backgroundPainter->setRenderHint(QPainter::Antialiasing);
    PaintGrid(*m_backgroundPainter);
}
void
CrossSectionWindow::Paint(Canvas &canvas, const PixelRect rc)
{
  fixed hmin = max(fixed_zero, gps_info.nav_altitude - fixed(3300));
  fixed hmax = max(fixed(3300), gps_info.nav_altitude + fixed(1000));

  Chart chart(chart_look, canvas, rc);
  chart.ResetScale();
  chart.ScaleXFromValue(fixed_zero);
  chart.ScaleXFromValue(vec.distance);
  chart.ScaleYFromValue(hmin);
  chart.ScaleYFromValue(hmax);

  PaintAirspaces(canvas, chart);
  PaintTerrain(canvas, chart);
  PaintGlide(chart);
  PaintAircraft(canvas, chart, rc);
  PaintGrid(canvas, chart);
}
Beispiel #3
0
void
CrossSectionRenderer::Paint(Canvas &canvas, const PixelRect rc) const
{
  DrawVerticalGradient(canvas, rc,
                       look.sky_color, look.background_color,
                       look.background_color);

  canvas.SetTextColor(look.text_color);
  canvas.Select(*look.grid_font);

  ChartRenderer chart(chart_look, canvas, rc);

  if (!vec.IsValid() || !start.IsValid()) {
    chart.DrawNoData();
    return;
  }

  const fixed nav_altitude = gps_info.NavAltitudeAvailable()
    ? gps_info.nav_altitude
    : fixed(0);
  fixed hmin = std::max(fixed(0), nav_altitude - fixed(3300));
  fixed hmax = std::max(fixed(3300), nav_altitude + fixed(1000));

  chart.ResetScale();
  chart.ScaleXFromValue(fixed(0));
  chart.ScaleXFromValue(vec.distance);
  chart.ScaleYFromValue(hmin);
  chart.ScaleYFromValue(hmax);

  short elevations[NUM_SLICES];
  UpdateTerrain(elevations);

  if (airspace_database != nullptr) {
    const AircraftState aircraft = ToAircraftState(Basic(), Calculated());
    airspace_renderer.Draw(canvas, chart, *airspace_database, start, vec,
                           aircraft);
  }

  terrain_renderer.Draw(canvas, chart, elevations);
  PaintGlide(chart);
  PaintAircraft(canvas, chart, rc);
  PaintGrid(canvas, chart);
}
void CLineGraph::Paint(CDC* pDC, CRect* pRect)
{
	if ( m_pGridPen.m_hObject == NULL ) m_pGridPen.CreatePen( PS_SOLID, 1, m_crGrid );

	DWORD nWidth = (DWORD)pRect->Width() / m_nScale + 2;

	if ( pRect->Width() > 64 )
	{
		for ( POSITION pos = GetItemIterator() ; pos ; )
		{
			CGraphItem* pItem = GetNextItem( pos );
			pItem->SetHistory( nWidth );
		}
	}

	pDC->FillSolidRect( pRect, m_crBack );

	if ( m_pItems.IsEmpty() || m_nMaximum == 0 ) return;

	CFont* pOldFont = (CFont*)pDC->SelectObject( &theApp.m_gdiFont );
	pDC->SetBkMode( TRANSPARENT );

	if ( m_bShowGrid ) PaintGrid( pDC, pRect );

	for ( POSITION pos = m_pItems.GetHeadPosition() ; pos ; )
	{
		CGraphItem* pItem = (CGraphItem*)m_pItems.GetNext( pos );

		DWORD nPoints	= min( pItem->m_nLength, nWidth );
		POINT* pPoints	= new POINT[ nPoints ];

		for ( DWORD nPos = 0 ; nPos < nPoints ; nPos++ )
		{
			DWORD nValue = pItem->GetValueAt( nPos );

			nValue = pRect->bottom - nValue * ( pRect->Height() - TOP_MARGIN ) / m_nMaximum;

			pPoints[ nPos ].x = pRect->right - nPos * m_nScale - 1;
			pPoints[ nPos ].y = nValue + 4;
		}

		pItem->MakeGradient( m_crBack );

		CPen* pOldPen = (CPen*)pDC->SelectObject( &pItem->m_pPen[3] );

		for ( int nLayer = 4 ; nLayer ; nLayer-- )
		{
			pDC->Polyline( pPoints, nPoints );

			if ( nLayer > 1 )
			{
				for ( DWORD nPos = 0 ; nPos < nPoints ; nPos++ ) pPoints[ nPos ].y --;
				pDC->SelectObject( &pItem->m_pPen[ nLayer - 2 ] );
			}
		}

		pDC->SelectObject( pOldPen );

		delete [] pPoints;
	}

	if ( m_bShowLegend ) PaintLegend( pDC, pRect );

	pDC->SelectObject( pOldFont );
}
Beispiel #5
0
void s3DWindow::OnPaint3D()
{
  if(Enable)
  {
    // initial setup

    QuakeCam();                   // quake cam
    PrepareView();                // viewport
  }

  sScreenMode sm;
  sGetScreenMode(sm);

  if(Enable && !Client.IsEmpty())
  {
    // repare rendertarget spec

    sTargetSpec spec;
#if sRENDERER==sRENDER_DX11       // blit back
    sInt xs = Client.SizeX();
    sInt ys = Client.SizeY();
    if(ColorRT==0 || xs!=ColorRT->SizeX || ys!=ColorRT->SizeY || sm.MultiLevel!=RTMultiLevel)
    {
      sDelete(ColorRT);
      sDelete(DepthRT);
      ColorRT = new sTexture2D(xs,ys,sTEX_2D|sTEX_ARGB8888|sTEX_RENDERTARGET|sTEX_MSAA,1);
      DepthRT = new sTexture2D(xs,ys,sTEX_2D|sTEX_DEPTH24|sTEX_RENDERTARGET|sTEX_MSAA,1);
      RTMultiLevel = sm.MultiLevel;
    }
    spec.Depth = DepthRT;
    spec.Color = ColorRT;
    spec.Window.Init(0,0,xs,ys);
#else
    spec.Init(Client);
#endif

    // painting

    Paint(View);                  // paint 3d
    Paint(View,spec);

    View.Model.Init();            // prepare for wireframe
    View.SetTargetCurrent(&Client);
    View.Prepare();

    GridUnit = 0;                 // pain t grid
    if(Grid)
    {
      sEnableGraphicsStats(0);
      sSetTarget(sTargetPara(0,0,spec));
      PaintGrid();
      sEnableGraphicsStats(1);
    }

    PaintWire(View);                // custom wireframe
    PaintWire(View,spec);

    // screenshots

    if(ScreenshotFlag)
    {
      const sU8 *data;
      sS32 pitch;
      sTextureFlags flags;
      sImage img;

      sRect r=spec.Window;
      img.Init(r.SizeX(),r.SizeY());
      img.Fill(0xffff0000);

      sBeginReadTexture(data,pitch,flags,spec.Color2D);
      if(flags==sTEX_ARGB8888)
      {
        data += r.x0*4 + r.y0*pitch;
        sU32 *dest = img.Data;
        for(sInt y=r.y0;y<r.y1;y++)
        {
          sCopyMem(dest,data,r.SizeX()*4);
          dest += img.SizeX;
          data += pitch;
        }
      }
      sEndReadTexture();

      if(flags==sTEX_ARGB8888)
      {
        sInt nr = 0;
        sArray<sDirEntry> dir;
        sDirEntry *ent;
        sInt len = sGetStringLen(SCREENSHOTNAME);
        if(sLoadDir(dir,SCREENSHOTDIR))
        {
          sFORALL(dir,ent)
          {
            if(sCmpStringILen(ent->Name,SCREENSHOTNAME,len)==0)
            {
              sInt newnr;
              const sChar *scan = ent->Name+len;
              if(sScanInt(scan,newnr))
                nr = sMax(nr,newnr);
            }
          }
        }
        else
        {
          sMakeDirAll(SCREENSHOTDIR);
        }
        sString<64> name;
        sSPrintF(name,SCREENSHOTDIR L"/" SCREENSHOTNAME L"%04d.bmp",nr+1);
        img.SaveBMP(name);
      }