// **************************************************************************** // Method: QvisScribbleOpacityBar::paintToPixmap // // Purpose: // // // Programmer: Jeremy Meredith // Creation: January 31, 2001 // // **************************************************************************** void QvisScribbleOpacityBar::paintToPixmap(int w, int h) { if (w != nvalues) { int nvalues2 = w; float *values2 = new float[nvalues2]; if (nvalues2 > nvalues) { for (int i=0; i<nvalues2; i++) values2[i] = values[(i * nvalues) / nvalues2]; } else { for (int i=0; i<nvalues; i++) values2[(i * nvalues2) / nvalues] = values[i]; } delete[] values; values = values2; nvalues = nvalues2; } QColor white(255, 255, 255 ); QColor black(0, 0, 0 ); QPen whitepen(Qt::white, 2); QPainter painter(pix); this->paintBackground(painter,w,h); painter.setPen(whitepen); for (int _x=0; _x<w; _x++) { float yval = values[_x]; painter.drawLine(_x, h-1, _x, int((h-1) - float(yval)*(h-1))); } }
void C2DMap::OnPaint() { CPaintDC dc(this); CRect rect; GetClientRect(rect); CBrush brwhite(RGB(0xFF,0xFF,0xFF)); CBrush brred(RGB(0xFF,0,0)); CBrush brback(RGB(0,0,0)); // black gd, red frame dc.FillRect(rect, &brback); dc.FrameRect(rect, &brred); if (igcmap == NULL) return; // display help here ? dc.SetBkColor(RGB(0,0,0)); CPen redpen(PS_SOLID,1,RGB(0xFF,0,0)); // red CPen whitepen(PS_SOLID,1,RGB(0xFF,0xFF,0xFF)); // white CPen alephpen(PS_SOLID,2,RGB(0x00,0x00,0xFF)); // blue CPen createalephpen(PS_SOLID,2,RGB(0xFF,0xFF,0x00)); //yellow CPen createalephpenvalid(PS_SOLID,2,RGB(0x00,0xFF,0x00)); //green CPen *oldpen = NULL; CBrush whitebrush; whitebrush.CreateSolidBrush(RGB(0xFF,0xFF,0xFF)); CBrush redbrush; redbrush.CreateSolidBrush(RGB(0xFF,0x00,0x00)); CBrush *oldbrush = NULL; oldpen = (CPen *)dc.SelectObject(&whitepen); oldbrush = (CBrush *)dc.SelectObject(&whitebrush); if (bGrid) { int cx = (maxx/10); // 0.1 step -> /10) int cy = (maxy/10); for (int x=MAP2DWFB;x<=MapW-MAP2DWFB;x+=cx) { dc.MoveTo(x,MAP2DHFB); dc.LineTo(x,MapH-MAP2DHFB); } for (int y=MapH-MAP2DHFB;y>=MAP2DHFB;y-=cy) { dc.MoveTo(MAP2DWFB,y); dc.LineTo(MapW-MAP2DWFB,y); } dc.SelectObject(&redpen); y = MAP2DSCALEY(1.5,maxy,MapH); x = MAP2DSCALEX(2.0,maxx); if (y >= 0) { dc.MoveTo(MAP2DWFB,MapH-MAP2DHFB); dc.LineTo(x,MapH-MAP2DHFB); dc.LineTo(x,y); dc.LineTo(MAP2DWFB,y); dc.LineTo(MAP2DWFB,MapH-MAP2DHFB); } } dc.SetTextColor(RGB(0xFF,0xFF,0xFF)); dc.SetBkColor(RGB(0,0,0)); if (sDispSectName != "") { dc.TextOut(1,1,sDispSectName); } // paint alephs dc.SelectObject(&alephpen); POSITION pos = mapalephs.GetHeadPosition(); for (int i=0;i < mapalephs.GetCount();i++) { SMapAleph *mapa = &(mapalephs.GetNext(pos)); dc.MoveTo(mapa->sect1->pos2D.x,mapa->sect1->pos2D.y); dc.LineTo(mapa->sect2->pos2D.x,mapa->sect2->pos2D.y); } CBrush brushTeam1,brushTeam2,brushTeam3,brushTeam4,brushTeam5,brushTeam6; brushTeam1.CreateSolidBrush(IGCTEAM1COL); brushTeam2.CreateSolidBrush(IGCTEAM2COL); brushTeam3.CreateSolidBrush(IGCTEAM3COL); brushTeam4.CreateSolidBrush(IGCTEAM4COL); brushTeam5.CreateSolidBrush(IGCTEAM5COL); brushTeam6.CreateSolidBrush(IGCTEAM6COL); CBrush * brushbases[7] = {&whitebrush,&brushTeam1,&brushTeam2,&brushTeam3,&brushTeam4,&brushTeam5,&brushTeam6}; //paint sectors pos = igcmap->cl_sectors.GetHeadPosition(); for (int i=0;i < igcmap->cl_sectors.GetCount();i++) { CIGCSector *psector; psector = &(igcmap->cl_sectors.GetNext(pos)); int x = psector->pos2D.x; int y = psector->pos2D.y; if (psector == igccursect) { dc.SelectObject(&redpen); dc.SelectObject(&redbrush); } else { dc.SelectObject(&whitepen); dc.SelectObject(brushbases[psector->igcsector.team]); } //dc.RoundRect(x-SDOTSECT/2,y-SDOTSECT/2,x+SDOTSECT/2,y+SDOTSECT/2,SDOTSECT,SDOTSECT); dc.Ellipse(x-SDOTSECT/2,y-SDOTSECT/2,x+SDOTSECT/2,y+SDOTSECT/2); } if (createaleph) { PtrSector psectundermouse = IsOverSector(createalephTOpos2D); if (psectundermouse && (psectundermouse != createaleph)) dc.SelectObject(&createalephpenvalid); else dc.SelectObject(&createalephpen); dc.MoveTo(createaleph->pos2D.x,createaleph->pos2D.y); dc.LineTo(createalephTOpos2D.x,createalephTOpos2D.y); } dc.SelectObject(oldpen); dc.SelectObject(oldbrush); }