static void copy_col (int dest, int src) { int y; for (y = 0; y < STONE_LINES; y++) field [mapx(dest)][mapy(y)] = field [mapx(src)][mapy(y)]; }
static void clean_last_col (void) { int y; for (y = 0; y < STONE_LINES; y++){ field [mapx(STONE_COLS-1)][mapy(y)].color = 0; field [mapx(STONE_COLS-1)][mapy(y)].tag = 0; } }
static void compress_column (int x) { int y, ym; for (y = STONE_LINES - 1; y >= 0; y--){ if (!field [mapx(x)][mapy(y)].tag) continue; for (ym = y; ym < STONE_LINES - 1; ym++) field [mapx(x)][mapy(ym)] = field [mapx(x)][mapy(ym+1)]; field [mapx(x)][mapy(ym)].color = 0; field [mapx(x)][mapy(ym)].tag = 0; } }
void BasicDrawPanel::Paint(wxDC &dc) { dc.SetPen( wxPen( wxColor(255,0,0), 3 ) ); switch(mMeassure) { case M_DIFF: dc.SetPen( wxPen( wxColor(255,0,0), 3 ) ); dc.DrawLine( mapx(mMStartX), mapy(mMStartY), mapx(mMEndX), mapy(mMEndY)); break; case M_POINT: dc.DrawCircle(mapx(mMStartX), mapy(mMStartY),3); break; default: break; } }
void setViewPort(int minx, int miny, int maxx, int maxy) { rx = (double)getmaxx()/(double)(maxx-minx); ry = (double)getmaxy()/(double)(maxy-miny); mix = minx; miy = miny; // Y-axis for(int j=miny;j<maxy;j++) putpixel((int)mapx(0),(int)mapy(j),10); // X-axis for(int k=minx;k<maxx;k++) putpixel((int)mapx(k),(int)mapy(0),10); }
KCanvasWindow::KCanvasWindow(HINSTANCE hInst, HWND hWnd, int x, int y, int w, int h) { scale = 1; hMetaFile = NULL; hNTMetaFile = NULL; page_margin = 10; canvas_backcolor = RGB(0xFF, 0xFF, 0x80); hInstance = hInst; Createwindow("CanvasClass", IDI_COLIVE, 0, "Canvas", WS_VISIBLE | WS_CHILD | WS_BORDER, mapx(x), mapy(y), mapx(w), mapy(h), hWnd, hInst, NULL, 0, (HBRUSH) GetStockObject(WHITE_BRUSH) ); }
static void compress_x (void) { int x, xm, l; for (x = 0; x < STONE_COLS; x++){ for (l = STONE_COLS; field [mapx(x)][mapy(0)].color == 0 && l; l--){ for (xm = x; xm < STONE_COLS-1; xm++) copy_col (xm, xm+1); clean_last_col (); } } }
void TScale::pdraw(QPainter& p, const QRect& r) { int y = r.y(); int h = r.height(); QString s; for (int i = 30000; i <= 250000; i += 10000) { int yy = mapy(280000 - i); if (yy < y) break; if (yy-15 > y+h) continue; p.drawLine(0, yy, width(), yy); s.setNum(i/1000); p.drawText(width() - fontMetrics().width(s) - 1, yy-2, s); // Use the window font. Tim p4.0.31 } }
QPoint View::map(const QPoint& p) const { /* int x, y; if (xmag < 0) { x = lrint(double(p.x())/double(-xmag) - rmapx_f(xorg)) - xpos; } else { x = p.x()*xmag - xpos - lrint(rmapx_f(xorg)); } if (ymag < 0) { y = lrint(double(p.y())/double(-ymag) - rmapy_f(yorg)) - ypos; } else { y = p.y()*ymag - ypos - lrint(rmapy_f(yorg)); } return QPoint(x, y); */ return QPoint(mapx(p.x()), mapy(p.y())); }
void TScale::pdraw(QPainter& p, const QRect& r) { int y = r.y(); int h = r.height(); QColor colTimeLine = QColor(172,181,176); p.setPen(colTimeLine); //p.setFont(config.fonts[4]); p.setFont(QFont("fixed-width", 8, QFont::Bold)); QString s; for (int i = 30000; i <= 250000; i += 10000) { int yy = mapy(280000 - i); if (yy < y) break; if (yy - 15 > y + h) continue; p.drawLine(0, yy, width(), yy); s.setNum(i / 1000); p.drawText(QRect(0, yy, width(), 15), s, QTextOption(Qt::AlignVCenter|Qt::AlignRight)); } }
void T3DObjectStarMap::calculate() { double x0,y0,z0,gr,fc; double hx,hy,hz,vx,vy,vz; T4color col2,col2L,col2R; double sx=sizex->G_val(); double sy=sizey->G_val(); double ssize=starsize->G_val(); if (calculated) return; Tdoublearray &stars_MAG=G_3DCosmos().stars_MAG; Tdoublearray &stars_E1=G_3DCosmos().stars_E1; Tdoublearray &stars_E2=G_3DCosmos().stars_E2; Tarray<QString> &const_code=G_3DCosmos().const_code; Tdoublearray &const_E1_1=G_3DCosmos().const_E1_1; Tdoublearray &const_E1_2=G_3DCosmos().const_E1_2; Tdoublearray &const_E2_1=G_3DCosmos().const_E2_1; Tdoublearray &const_E2_2=G_3DCosmos().const_E2_2; //for stars starvertexbuffer.reset();starcolorbufferL.reset();starcolorbufferR.reset();startexturebuffer.reset(); if (ssize>0) { for (int i=0; i<stars_E1.G_count(); i++) { x0=mapx(stars_E1[i]); y0=mapy(stars_E2[i]); z0=0; gr=(7-stars_MAG[i])/7; gr=sqrt(gr); if (gr<0.15) gr=0.15; if (gr>1.0) gr=1.0; fc=ssize*gr; hx=fc;hy=0;hz=0; vx=0;vy=fc;vz=0; col2.r=gr*color->G_R(); col2.g=gr*color->G_G(); col2.b=gr*color->G_B(); col2.a=1*color->G_A(); col2L=col2;col2L.ColMapL(); col2R=col2;col2R.ColMapR(); startexturebuffer.add(T2textureidx(0,0)); starvertexbuffer.add(Tvec3d(x0-hx-vx,y0-hy-vy,z0-hz-vz)); startexturebuffer.add(T2textureidx(0,1)); starvertexbuffer.add(Tvec3d(x0-hx+vx,y0-hy+vy,z0-hz+vz)); startexturebuffer.add(T2textureidx(1,1)); starvertexbuffer.add(Tvec3d(x0+hx+vx,y0+hy+vy,z0+hz+vz)); startexturebuffer.add(T2textureidx(1,0)); starvertexbuffer.add(Tvec3d(x0+hx-vx,y0+hy-vy,z0+hz-vz)); starcolorbufferL.add(col2L);starcolorbufferL.add(col2L);starcolorbufferL.add(col2L);starcolorbufferL.add(col2L); starcolorbufferR.add(col2R);starcolorbufferR.add(col2R);starcolorbufferR.add(col2R);starcolorbufferR.add(col2R); } } //for constellation lines conlinesvertexbuffer.reset(); conlinestexturebuffer.reset(); QString constname=singleconstellationname->G_string(); double linesize=conlinesize->G_val(); if (linesize>1.0e-9) { for (int i=0; i<const_E1_1.G_count(); i++) if ((qstrlen(constname)==0)||(issame(*const_code[i],constname))) { double xx1=mapx(const_E1_1[i]); double xx2=mapx(const_E1_2[i]); double yy1=mapy(const_E2_1[i]); double yy2=mapy(const_E2_2[i]); if (xx1>xx2) { double tmp=xx1; xx1=xx2; xx2=tmp; tmp=yy1; yy1=yy2; yy2=tmp; } if (fabs(xx1-xx2)<sx/2) { addline(xx1,yy1,xx2,yy2); } else { addline(xx2-sx,yy1,xx1,yy2); addline(xx2,yy1,xx1+sx,yy2); } } } calculated=true; }
void View::drawTickRaster(QPainter& p, int x, int y, int w, int h, int raster) { // Changed to draw in device coordinate space instead of virtual, transformed space. Tim. p4.0.30 //int mx = mapx(x); int my = mapy(y); //int mw = mapx(x + w) - mx; //int mw = mapx(x + w) - mx - 1; //int mh = mapy(y + h) - my; //int mh = mapy(y + h) - my - 1; //p.save(); bool wmtxen = p.worldMatrixEnabled(); p.setWorldMatrixEnabled(false); int xx,bar1, bar2, beat; unsigned tick; AL::sigmap.tickValues(x, &bar1, &beat, &tick); AL::sigmap.tickValues(x+w, &bar2, &beat, &tick); ++bar2; ///int y2 = y + h; //int y2 = my + mh; int y2 = mapy(y + h) - 1; //printf("View::drawTickRaster x:%d y:%d w:%d h:%d mx:%d my:%d mw:%d mh:%d y2:%d bar1:%d bar2:%d\n", x, y, w, h, mx, my, mw, mh, y2, bar1, bar2); //printf("View::drawTickRaster x:%d y:%d w:%d h:%d my:%d mh:%d y2:%d bar1:%d bar2:%d\n", x, y, w, h, my, mh, y2, bar1, bar2); for (int bar = bar1; bar < bar2; ++bar) { ///unsigned x = AL::sigmap.bar2tick(bar, 0, 0); unsigned xb = AL::sigmap.bar2tick(bar, 0, 0); int xt = mapx(xb); p.setPen(Qt::black); ///p.drawLine(x, y, x, y2); p.drawLine(xt, my, xt, y2); int z, n; ///AL::sigmap.timesig(x, z, n); AL::sigmap.timesig(xb, z, n); ///int q = p.xForm(QPoint(raster, 0)).x() - p.xForm(QPoint(0, 0)).x(); ///int q = p.combinedTransform().map(QPoint(raster, 0)).x() - p.combinedTransform().map(QPoint(0, 0)).x(); //int q = rmapx(raster); int qq = raster; //if (q < 8) // grid too dense if (rmapx(raster) < 8) // grid too dense qq *= 2; p.setPen(Qt::lightGray); if (raster>=4) { ///int xx = x + qq; //int xx = mapx(xb + qq); xx = xb + qq; int xxx = AL::sigmap.bar2tick(bar, z, 0); //int xxx = mapx(AL::sigmap.bar2tick(bar, z, 0)); while (xx <= xxx) { ///p.drawLine(xx, y, xx, y2); int x = mapx(xx); p.drawLine(x, my, x, y2); xx += qq; //xx += rmapx(qq); } //xx = xxx; } p.setPen(Qt::darkGray); for (int beat = 1; beat < z; beat++) { ///int xx = AL::sigmap.bar2tick(bar, beat, 0); xx = mapx(AL::sigmap.bar2tick(bar, beat, 0)); //printf(" bar:%d z:%d beat:%d xx:%d\n", bar, z, beat, xx); ///p.drawLine(xx, y, xx, y2); p.drawLine(xx, my, xx, y2); } } //p.setWorldMatrixEnabled(true); p.setWorldMatrixEnabled(wmtxen); //p.restore(); }