int main( int argc, char *argv[] ) { PLINT digmax, cur_strm, new_strm; char ver[80]; // plplot initialization // Parse and process command line arguments plMergeOpts( options, "x01c options", notes ); plparseopts( &argc, argv, PL_PARSE_FULL ); // Get version number, just for kicks plgver( ver ); fprintf( stdout, "PLplot library version: %s\n", ver ); // Initialize plplot // Divide page into 2x2 plots // Note: calling plstar replaces separate calls to plssub and plinit plstar( 2, 2 ); // Select font set as per input flag if ( fontset ) plfontld( 1 ); else plfontld( 0 ); // Set up the data // Original case xscale = 6.; yscale = 1.; xoff = 0.; yoff = 0.; // Do a plot plot1( 0 ); // Set up the data xscale = 1.; yscale = 0.0014; yoff = 0.0185; // Do a plot digmax = 5; plsyax( digmax, 0 ); plot1( 1 ); plot2(); plot3(); // // Show how to save a plot: // Open a new device, make it current, copy parameters, // and replay the plot buffer // if ( f_name ) // command line option '-save filename' { printf( "The current plot was saved in color Postscript under the name `%s'.\n", f_name ); plgstrm( &cur_strm ); // get current stream plmkstrm( &new_strm ); // create a new one plsfnam( f_name ); // file name plsdev( "psc" ); // device type plcpstrm( cur_strm, 0 ); // copy old stream parameters to new stream plreplot(); // do the save by replaying the plot buffer plend1(); // finish the device plsstrm( cur_strm ); // return to previous stream } // Let's get some user input if ( locate_mode ) { for (;; ) { if ( !plGetCursor( &gin ) ) break; if ( gin.keysym == PLK_Escape ) break; pltext(); printf( "subwin = %d, wx = %f, wy = %f, dx = %f, dy = %f\n", gin.subwindow, gin.wX, gin.wY, gin.dX, gin.dY ); printf( "keysym = 0x%02x, button = 0x%02x, string = '%s', type = 0x%02x, state = 0x%02x\n", gin.keysym, gin.button, gin.string, gin.type, gin.state ); plgra(); } } // Don't forget to call plend() to finish off! plend(); exit( 0 ); }
void plD_esc_win3(PLStream *pls, PLINT op , void *ptr) { WinDev *dev = (WinDev *)pls->dev; HCURSOR holdcursor,hnewcursor; switch (op) { case PLESC_GETC: hnewcursor = LoadCursor(NULL,IDC_CROSS); holdcursor = (HCURSOR)GetClassLong(GetActiveWindow(),GCL_HCURSOR); SetClassLong(GetActiveWindow(),GCL_HCURSOR,(long)hnewcursor); SetCursor(hnewcursor); dev->newCursor = 0; dev->button = 0; dev->state = 0; while (!dev->newCursor) { GetMessage(&msg,NULL,0,0); TranslateMessage(&msg); DispatchMessage(&msg); } ((PLGraphicsIn *)ptr)->dX = float(dev->cursorX)/float(PIXELS_X*dev->xScale); ((PLGraphicsIn *)ptr)->dY = float(PIXELS_Y*dev->yScale - dev->cursorY) / float(PIXELS_Y*dev->yScale); ((PLGraphicsIn *)ptr)->button = dev->button; ((PLGraphicsIn *)ptr)->state = dev->state; SetClassLong(GetActiveWindow(),GCL_HCURSOR,(long)holdcursor); break; case PLESC_FILL: FillPolygonCmd(pls); break; case PLESC_XORMOD: if (*(PLINT*)(ptr) == 0) SetROP2(dev->hdc,R2_COPYPEN); else SetROP2(dev->hdc,R2_XORPEN); break; case PLESC_REDRAW: break; case PLESC_RESIZE: { RECT rect; dev->hdc = GetDC(dev->hwnd); GetClientRect(dev->hwnd,&rect); dev->xPhMax = rect.right; dev->yPhMax = rect.bottom; dev->xScale = rect.right / ((float)PIXELS_X); dev->yScale = rect.bottom / ((float)PIXELS_Y); { PLFLT pxlx = DPMM/dev->xScale; PLFLT pxly = DPMM/dev->yScale; plP_setpxl(pxlx, pxly); } if (pls->db) { //SetBitmapDimensionEx(dev->db_bmp,rect.right,rect.bottom,NULL); DeleteObject(dev->db_bmp); dev->db_bmp = CreateCompatibleBitmap(dev->hdc, rect.right,rect.bottom); SelectObject(dev->db_hdc, dev->db_bmp); dev->hdc = dev->db_hdc; HBRUSH hbr = CreateSolidBrush( dev->backGroundColor); FillRect(dev->hdc, &rect,hbr); plreplot (); } else InvalidateRect(dev->hwnd,NULL,TRUE); } break; case PLESC_EXPOSE: if (pls->db) { PAINTSTRUCT ps; HDC winDC; RECT r; // Set up a display context to begin painting winDC = BeginPaint(dev->hwnd, &ps); GetClientRect(dev->hwnd, &r); // copy the buffer to the screen BitBlt(GetDC(dev->hwnd), 0, 0, r.right, r.bottom, dev->db_hdc, 0, 0, SRCCOPY); // Tell Windows you are done painting EndPaint(dev->hwnd, &ps); } else plreplot (); break; case PLESC_IMAGE: plD_DrawImage_win3(pls); break; case PLESC_IMAGEOPS: imageops(pls, (PLINT *) ptr); break; } }