home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / msdos / plotting / pcgplots / gptcgm2.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-24  |  4.0 KB  |  124 lines

  1. // GptCGM2.cpp -  more cgmObject class funtions
  2. // copyright 1992 Pittsburgh Supercomputing Center
  3.  
  4. #include  "gpt.h"
  5. #include  "cgm.h" // basic display classes
  6. #include  "cgmdisp.h" // basic display classes
  7. #include  "gptDisp.h"
  8.  
  9.  
  10. // *** CgmObject::DisplayCurPic - display current picture
  11. void cgmObject::DisplayCurPic(HWND hWnd, RECT *rect, Scroller *sbars)
  12.     {
  13.     PAINTSTRUCT ps;
  14.     pcDisplay *myPC;
  15.     HDC hdcMeta;
  16.     HDC hdc   = BeginPaint(hWnd, &ps);
  17.  
  18.     if (hMeta)        // if Metafile exists  ( so does hMemDC)
  19.         {
  20.         StretchBlt( hdc, 0, 0,rect->right, rect->bottom, hMemDC,
  21.                   +sbars->getnHscrollPos(),+sbars->getnVscrollPos(),
  22.                     rect->right, rect->bottom,SRCCOPY);
  23.         EndPaint(hWnd, &ps);
  24.         //MakeBitmapMeta(hWnd, rect, sbars);  OBSOLETE CODE
  25.         return;
  26.         }
  27.  
  28.     // no metafile
  29.     if (!curPic)     // Bad CGM ??
  30.         {
  31.         EndPaint(hWnd,&ps);
  32.         return;
  33.         }
  34.  
  35.     HourGlass(hWnd);    // Turn on hourglass cursor
  36.     HDC hdcInfo = CreateDC("DISPLAY", NULL, NULL, NULL);
  37.     hdcMeta     = CreateMetaFile(NULL);
  38.     myPC        = new pcDisplay(cgmWin,hdc,hdcMeta, hdcInfo,rect);
  39.     myPC->setExtent(rect);   // Set Extent for GPlot code
  40.     myPC->backColr2();       // Make Background white
  41.  
  42.     curPic->display( (BaseDisplayPt)myPC);  // Display using myPC's functions
  43.     lastPic = curPic;
  44.     //MakeStar(hdc , hdcMeta);    // for fun
  45.     myPC->clip( FALSE);         // turn off clipping
  46.     myPC->ExtentRect();         // And draw border
  47.     delete myPC;
  48.     EndPaint(hWnd, &ps);
  49.     hMeta = CloseMetaFile(hdcMeta);
  50.     DeleteDC( hdcInfo);
  51.  
  52.     if (!curPic->next)  cgmMeta->setIndexed();
  53.  
  54.     // At this point have a Windows Metafile which is bunch of drawing
  55.     // primatives.  This should be device independent, but it draws slowly
  56.     // and also clip rectangels do not seem to scroll along with other
  57.     // graphics when metafile is played.
  58.  
  59.     // Play metafile on a memory device - use memory device to scroll picture
  60.     hdc         = GetDC(hWnd);
  61.     hCompBit = CreateCompatibleBitmap(hdc,GetSystemMetrics(SM_CXSCREEN),
  62.                     GetSystemMetrics(SM_CYSCREEN) - GetSystemMetrics(SM_CYCAPTION)
  63.                                                             - GetSystemMetrics(SM_CYMENU));
  64.     hMemDC   = CreateCompatibleDC(hdc);
  65.     hOldBit = SelectObject( hMemDC, hCompBit);
  66.     PlayMetaFile(hMemDC,hMeta);    // Play metafile in memory
  67.     ReleaseDC(hWnd, hdc);
  68.     HourGlass(hWnd);
  69.     }
  70. // ************************** Junk for Test ****************************
  71. // *** CgmObject::MakeStar - Draw Star in left hand corner of picture
  72. //Not Used
  73. void cgmObject::MakeStar(HDC hdc, HDC hdcMeta)
  74.     {
  75.     POINT *points = new POINT[20];
  76.     points[0].x = 32;    points[0].y = 0;
  77.     points[1].x = 16;    points[1].y = 63;
  78.     points[2].x = 63; points[2].y = 16;
  79.     points[3].x = 0;    points[3].y = 16;
  80.     points[4].x = 48;    points[4].y = 63;
  81.     HDC hMemoryDC = CreateCompatibleDC(hdc);
  82.     HBITMAP hBitmap, hOldBitmap;
  83.     hBitmap = CreateCompatibleBitmap(hdc, 64,64);
  84.     hOldBitmap = SelectObject(hMemoryDC, hBitmap);
  85.     PatBlt(hMemoryDC,0,0,64,64,WHITENESS);
  86.     Polygon(hMemoryDC, points,5);
  87.     BitBlt(hdc,0,0,64,64,hMemoryDC,0,0,SRCCOPY);
  88.     BitBlt(hdcMeta,0,0,64,64,hMemoryDC,0,0,SRCCOPY);
  89.     SelectObject(hMemoryDC, hOldBitmap);
  90.     DeleteDC(hMemoryDC);
  91.     DeleteObject(hBitmap);
  92.     delete []points;
  93.     }
  94. // !!! Not Used
  95. // *** CgmObject::MakeBitmapMeta - Make Metafile which is copy of screen bitmap
  96. void cgmObject::MakeBitmapMeta(HWND hWnd, RECT *rect, Scroller *sbars)
  97.     {
  98.     HDC hdcMeta, hdc;
  99.     if (!DidFullMeta  && sbars->IsFullSize())   // can make bit metafile
  100.         {
  101.         // Make new Metafile which is just bitmap xfer
  102.         DidFullMeta = TRUE;
  103.         DeleteMetaFile(hMeta);
  104.         hdcMeta = CreateMetaFile(NULL);
  105.         hdc = GetDC(hWnd);
  106.         HBITMAP hBit= CreateCompatibleBitmap(hdc,rect->right, rect->bottom);
  107.         HDC hMemoryDC   = CreateCompatibleDC(hdc);
  108.         HBITMAP hBitOld = SelectObject( hMemoryDC, hBit);
  109.         BOOL foobar =
  110.             StretchBlt(hMemoryDC, 0, 0,rect->right, rect->bottom, hdc,0,0,
  111.                                             rect->right, rect->bottom,SRCCOPY);
  112.         foobar =
  113.             StretchBlt(hdcMeta, 0, 0,rect->right, rect->bottom, hMemDC,0,0,
  114.                                             rect->right, rect->bottom,SRCCOPY);
  115.         hMeta = CloseMetaFile(hdcMeta);
  116.         SelectObject(hMemoryDC, hBitOld);
  117.         DeleteDC(hMemoryDC);
  118.         DeleteObject(hBit);
  119.         ReleaseDC(hWnd, hdc);
  120.         }
  121.     }
  122.  
  123.  
  124.