void wipvfield(float x[], float y[], float r[], float phi[], int npts, float angle, float vent) { register int i; int fill; float x1, y1, x2, y2; double darg; LOGICAL error; darg = wipgetvar("fill", &error); fill = (error == TRUE) ? 1 : NINT(darg); cpgbbuf(); cpgsah(fill, angle, vent); for (i = 0; i < npts; i++) { x1 = x[i]; y1 = y[i]; x2 = x1 + (r[i] * COS(phi[i] * RPDEG)); y2 = y1 + (r[i] * SIN(phi[i] * RPDEG)); cpgarro(x1, y1, x2, y2); } cpgebuf(); return; }
/* * Arrow draws one arrow from the current cursor position to the * specified position (xp, yp). The acute angle of the arrow point, * in degrees, is specified by the input "angle"; angles in the * range 20.0 to 90.0 give reasonable results. The default angle * is 45.0 degrees. The fraction of the triangular arrow-head that * is cut away from the back is specified by the input "vent". A * value of 0.0 gives a triangular wedge arrow-head; 1.0 gives an * open >. Values of 0.3 to 0.7 give reasonable results. The * default value for "vent" is 0.3. */ void wiparrow(float xp, float yp, float angle, float vent) { int fill; float cx, cy; double darg; LOGICAL error; wipgetcxy(&cx, &cy); darg = wipgetvar("fill", &error); fill = (error == TRUE) ? 1 : NINT(darg); cpgsah(fill, angle, vent); cpgarro(cx, cy, xp, yp); return; }
int UVES_pgenv_init(plotenv *plenv, cplot *cp) { float vpy; plenv->wwidth=W_WIDTH; plenv->wasp=W_ASP; plenv->ch=C_H; plenv->lw=L_W; plenv->nxsub=N_X_SUB; plenv->nysub=N_Y_SUB; plenv->vpu=VPU; plenv->vpd=VPD; plenv->vpl=VPL; plenv->vpr=VPR; /* Arrow head style */ cpgsah(1,45.0,0.3); /** Combined plot defaults **/ if (cp!=NULL) { /* Set up plot geometry */ vpy=plenv->vpu-plenv->vpd; cp->vpd0=plenv->vpd+VPD0*vpy; cp->vpu0=plenv->vpd+VPU0*vpy; cp->vpd1=plenv->vpd+VPD1*vpy; cp->vpu1=plenv->vpd+VPU1*vpy; cp->vpd2=plenv->vpd+VPD2*vpy; cp->vpu2=plenv->vpd+VPU2*vpy; cp->vpd3=plenv->vpd+VPD3*vpy; cp->vpu3=plenv->vpd+VPU3*vpy; cp->vpd4=plenv->vpd+VPD4*vpy; cp->vpu4=plenv->vpd+VPU4*vpy; /* Set wavelength and plotting limits */ cp->swl=cp->ewl=0.0; cp->ymx=cp->ymn=0.0; cp->sp=cp->ep=0; cp->np=CP_NP; /* Set degradation factor for low resolution plot */ cp->sfac=SFAC; /* Set plotting modes */ cp->irank=cp->plval=0; /* Initialise exit codes */ cp->exit=0; cp->refre=cp->rccsp=cp->rscsp=0; /* Initialise auto-rescaling parameters */ cp->scalclip=cp->scalerr=0.0; sprintf(plenv->xlab[0],"%s","Vacuum-heliocentric wavelength [\\A]"); sprintf(plenv->ylab[1],"%s","N\\dpix\\u"); sprintf(plenv->ylab[2],"%s","\\gx\\d\\gn\\u\\u2\\d"); sprintf(plenv->ylab[3],"%s","Flux"); sprintf(plenv->ylab[4],"%s","Normalized flux"); } return 1; }
int SDSS_pgenv_init() { extern plotenv plenv; plenv.wwidth=W_WIDTH; plenv.wasp=W_ASP; plenv.ch=C_H; plenv.lw=L_W; plenv.nxsub=N_X_SUB; plenv.nysub=N_Y_SUB; plenv.vpu=VPU; plenv.vpd=VPD; plenv.vpl=VPL; plenv.vpr=VPR; strcpy(plenv.xlab[0],""); strcpy(plenv.ylab[0],""); strcpy(plenv.title[0],""); /* Arrow head style */ cpgsah(1,45.0,0.3); return 1; }
void Plotter2::plot() { open(); if ((width > 0.0) && (aspect > 0.0)) { cpgpap(width, aspect); } cpgscr(0, 1.0, 1.0, 1.0); // set background color white cpgscr(1, 0.0, 0.0, 0.0); // set foreground color black for (unsigned int i = 0; i < vInfo.size(); ++i) { Plotter2ViewportInfo vi = vInfo[i]; if (vi.showViewport) { resetAttributes(vi); // setup viewport cpgsvp(vi.vpPosXMin, vi.vpPosXMax, vi.vpPosYMin, vi.vpPosYMax); cpgswin(vi.vpRangeXMin, vi.vpRangeXMax, vi.vpRangeYMin, vi.vpRangeYMax); // background color (default is transparent) if (vi.vpBColor >= 0) { cpgsci(vi.vpBColor); cpgrect(vi.vpRangeXMin, vi.vpRangeXMax, vi.vpRangeYMin, vi.vpRangeYMax); cpgsci(1); // reset foreground colour to the initial one (black) } // data for (unsigned int j = 0; j < vi.vData.size(); ++j) { resetAttributes(vi); Plotter2DataInfo di = vi.vData[j]; std::vector<float> vxdata = di.xData; int ndata = vxdata.size(); float* pxdata = new float[ndata]; float* pydata = new float[ndata]; for (int k = 0; k < ndata; ++k) { pxdata[k] = di.xData[k]; pydata[k] = di.yData[k]; } if (di.drawLine) { cpgsls(di.lineStyle); cpgslw(di.lineWidth); int colorIdx = di.lineColor; if (colorIdx < 0) { colorIdx = (j + 1) % 15 + 1; } cpgsci(colorIdx); cpgline(ndata, pxdata, pydata); } if (di.drawMarker) { cpgsch(di.markerSize); cpgsci(di.markerColor); cpgpt(ndata, pxdata, pydata, di.markerType); } delete [] pxdata; delete [] pydata; } //calculate y-range of xmasks std::vector<float> yrange = vi.getRangeY(); float yexcess = 0.1*(yrange[1] - yrange[0]); float xmaskymin = yrange[0] - yexcess; float xmaskymax = yrange[1] + yexcess; // masks for (unsigned int j = 0; j < vi.vRect.size(); ++j) { resetAttributes(vi); Plotter2RectInfo ri = vi.vRect[j]; cpgsci(ri.color); cpgsfs(ri.fill); cpgslw(ri.width); cpgshs(45.0, ri.hsep, 0.0); float* mxdata = new float[4]; float* mydata = new float[4]; mxdata[0] = ri.xmin; mxdata[1] = ri.xmax; mxdata[2] = ri.xmax; mxdata[3] = ri.xmin; mydata[0] = xmaskymin; mydata[1] = xmaskymin; mydata[2] = xmaskymax; mydata[3] = xmaskymax; cpgpoly(4, mxdata, mydata); } // arrows for (unsigned int j = 0; j < vi.vArro.size(); ++j) { resetAttributes(vi); Plotter2ArrowInfo ai = vi.vArro[j]; cpgsci(ai.color); cpgslw(ai.width); cpgsls(ai.lineStyle); cpgsch(ai.headSize); cpgsah(ai.headFillStyle, ai.headAngle, ai.headVent); cpgarro(ai.xtail, ai.ytail, ai.xhead, ai.yhead); } // arbitrary texts for (unsigned int j = 0; j < vi.vText.size(); ++j) { resetAttributes(vi); Plotter2TextInfo ti = vi.vText[j]; cpgsch(ti.size); cpgsci(ti.color); cpgstbg(ti.bgcolor); cpgptxt(ti.posx, ti.posy, ti.angle, ti.fjust, ti.text.c_str()); } // viewport outline and ticks resetAttributes(vi); cpgbox("BCTS", vi.majorTickIntervalX, vi.nMinorTickWithinMajorTicksX, "BCTSV", vi.majorTickIntervalY, vi.nMinorTickWithinMajorTicksY); // viewport numberings std::string numformatx, numformaty; if (vi.numLocationX == "b") { numformatx = "N"; } else if (vi.numLocationX == "t") { numformatx = "M"; } else if (vi.numLocationX == "") { numformatx = ""; } if (vi.numLocationY == "l") { numformaty = "NV"; } else if (vi.numLocationY == "r") { numformaty = "MV"; } else if (vi.numLocationY == "") { numformaty = ""; } cpgbox(numformatx.c_str(), vi.majorTickIntervalX * vi.nMajorTickWithinTickNumsX, 0, numformaty.c_str(), vi.majorTickIntervalY * vi.nMajorTickWithinTickNumsY, 0); float xpos, ypos; // x-label vi.getWorldCoordByWindowCoord(vi.labelXPosX, vi.labelXPosY, &xpos, &ypos); cpgsch(vi.labelXSize); cpgsci(vi.labelXColor); cpgstbg(vi.labelXBColor); //outside viewports, works ONLY with /xwindow cpgptxt(xpos, ypos, vi.labelXAngle, vi.labelXFJust, vi.labelXString.c_str()); // y-label vi.getWorldCoordByWindowCoord(vi.labelYPosX, vi.labelYPosY, &xpos, &ypos); cpgsch(vi.labelYSize); cpgsci(vi.labelYColor); cpgstbg(vi.labelYBColor); //outside viewports, works ONLY with /xwindow cpgptxt(xpos, ypos, vi.labelYAngle, vi.labelYFJust, vi.labelYString.c_str()); // title vi.getWorldCoordByWindowCoord(vi.titlePosX, vi.titlePosY, &xpos, &ypos); cpgsch(vi.titleSize); cpgsci(vi.titleColor); cpgstbg(vi.titleBColor); //outside viewports, works ONLY with /xwindow cpgptxt(xpos, ypos, vi.titleAngle, vi.titleFJust, vi.titleString.c_str()); } } close(); }
/* set arrow-head style */ static void _pgsah (int *i, double *x, double *y) { cpgsah(*i, (float) *x, (float) *y); }