|
From: Tatsuro M. <tma...@ya...> - 2010-02-08 02:39:38
|
Hello I have confirmed that your patch works for 3d plots. I have upload binaries with the patch on the web. http://www.tatsuromatsuoka.com/gnuplot/Eng/winbin/ Regards Tatsuro --- Benjamin Lindner wrote: > Tatsuro MATSUOKA wrote: > > Hello > > > > I have tried the patch. > > > > set term windows enhanced font ",14" > > set label 1 "e^{i{/symbol p}} = -1" at graph 0.1,0.5 > > plot sin(x) with linespoints, cos(x) with linespoints > > > > worked fine!!!!!!!. > > > > > > However, I have tried > > set xrange [-pi:pi] > > set yrange [-pi:pi] > > splot sin(x*x+y*y)/(x*x+y*y) > > > > was broken as a attachment file. > > Thanks for the report. > > I modified my patch and now I see the expected behaviour > with plot (lines + image), splot (surface+pm3d). > > I also added the keyboard shortcut Ctrl+C for copying to clipboard. > > benjamin > > > > testing EMF clipboard copying > > diff --git a/src/win/wgraph.c b/src/win/wgraph.c > --- a/src/win/wgraph.c > +++ b/src/win/wgraph.c > @@ -389,7 +389,7 @@ > M_GRAPH_TO_TOP, "Bring to &Top"); > AppendMenu(lpgw->hPopMenu, MF_STRING | (lpgw->color ? MF_CHECKED : MF_UNCHECKED), > M_COLOR, "C&olor"); > - AppendMenu(lpgw->hPopMenu, MF_STRING, M_COPY_CLIP, "&Copy to Clipboard"); > + AppendMenu(lpgw->hPopMenu, MF_STRING, M_COPY_CLIP, "&Copy to Clipboard (Ctrl+C)"); > #if WINVER >= 0x030a > AppendMenu(lpgw->hPopMenu, MF_STRING, M_BACKGROUND, "&Background..."); > AppendMenu(lpgw->hPopMenu, MF_STRING, M_CHOOSE_FONT, "Choose &Font..."); > @@ -646,6 +646,38 @@ > if (rect->bottom < rect->top) rect->bottom = rect->top; > } > > +static void > +GetPlotRectInMM(LPGW lpgw, LPRECT rect, HDC hdc) > +{ > + GetPlotRect (lpgw, rect); > + > + /* Taken from > + http://msdn.microsoft.com/en-us/library/dd183519(VS.85).aspx > + */ > + > + // Determine the picture frame dimensions. > + // iWidthMM is the display width in millimeters. > + // iHeightMM is the display height in millimeters. > + // iWidthPels is the display width in pixels. > + // iHeightPels is the display height in pixels > + > + int iWidthMM = GetDeviceCaps(hdc, HORZSIZE); > + int iHeightMM = GetDeviceCaps(hdc, VERTSIZE); > + int iWidthPels = GetDeviceCaps(hdc, HORZRES); > + int iHeightPels = GetDeviceCaps(hdc, VERTRES); > + > + // Convert client coordinates to .01-mm units. > + // Use iWidthMM, iWidthPels, iHeightMM, and > + // iHeightPels to determine the number of > + // .01-millimeter units per pixel in the x- > + // and y-directions. > + > + rect->left = (rect->left * iWidthMM * 100)/iWidthPels; > + rect->top = (rect->top * iHeightMM * 100)/iHeightPels; > + rect->right = (rect->right * iWidthMM * 100)/iWidthPels; > + rect->bottom = (rect->bottom * iHeightMM * 100)/iHeightPels; > +} > + > > static void > MakeFonts(LPGW lpgw, LPRECT lprect, HDC hdc) > @@ -1362,12 +1394,10 @@ > static void > CopyClip(LPGW lpgw) > { > - RECT rect; > - HDC mem; > + RECT rect, mfrect; > + HDC mem, hmf; > HBITMAP bitmap; > - HANDLE hmf; > - GLOBALHANDLE hGMem; > - LPMETAFILEPICT lpMFP; > + HENHMETAFILE hemf; > HWND hwnd; > HDC hdc; > > @@ -1400,49 +1430,23 @@ > } > DeleteDC(mem); > > - /* OK, bitmap done, now create a Metafile context at full theoretical resolution > - * of the Windows terminal (24000 x 18000 pixels), and redraw the whole > - * plot into that. */ > + /* OK, bitmap done, now create an enhanced Metafile context > + * and redraw the whole plot into that. > + */ > { > /* make copy of window's main status struct for modification */ > GW gwclip = *lpgw; > - int windowfontsize = MulDiv(lpgw->fontsize, GetDeviceCaps(hdc, LOGPIXELSY), 72); > - int i; > > - gwclip.fontsize = MulDiv(windowfontsize, lpgw->ymax, rect.bottom); > gwclip.hfonth = gwclip.hfontv = 0; > - > - /* HBB 981203: scale up pens as well... */ > - for (i = 0; i < WGNUMPENS + 2; i++) { > - if(gwclip.monopen[i].lopnWidth.x > 1) > - gwclip.monopen[i].lopnWidth.x = > - MulDiv(gwclip.monopen[i].lopnWidth.x, > - gwclip.xmax, rect.right-rect.left); > - if(gwclip.colorpen[i].lopnWidth.x > 1) > - gwclip.colorpen[i].lopnWidth.x = > - MulDiv(gwclip.colorpen[i].lopnWidth.x, > - gwclip.xmax, rect.right-rect.left); > - } > - > - rect.right = lpgw->xmax; > - rect.bottom = lpgw->ymax; > - > MakePens(&gwclip, hdc); > MakeFonts(&gwclip, &rect, hdc); > > - ReleaseDC(hwnd, hdc); > + GetPlotRectInMM(lpgw, &mfrect, hdc); > > - hdc = CreateMetaFile((LPSTR)NULL); > + hmf = CreateEnhMetaFile(hdc, (LPCTSTR)NULL, &mfrect, (LPCTSTR)NULL); > + drawgraph(&gwclip, hmf, (LPRECT) &rect); > + hemf = CloseEnhMetaFile(hmf); > > -/* HBB 981203: According to Petzold, Metafiles shouldn't contain SetMapMode() calls: */ > - /*SetMapMode(hdc, MM_ANISOTROPIC);*/ > -#ifdef WIN32 > - SetWindowExtEx(hdc, rect.right, rect.bottom, (LPSIZE)NULL); > -#else > - SetWindowExt(hdc, rect.right, rect.bottom); > -#endif > - drawgraph(&gwclip, hdc, (LPRECT) &rect); > - hmf = CloseMetaFile(hdc); > DestroyFonts(&gwclip); > DestroyPens(&gwclip); > } > @@ -1450,23 +1454,13 @@ > /* Now we have the Metafile and Bitmap prepared, post their contents to > * the Clipboard */ > > - hGMem = GlobalAlloc(GMEM_MOVEABLE, (DWORD)sizeof(METAFILEPICT)); > - lpMFP = (LPMETAFILEPICT) GlobalLock(hGMem); > - hdc = GetDC(hwnd); /* get window size */ > - GetPlotRect(lpgw, &rect); > - /* in MM_ANISOTROPIC, xExt & yExt give suggested size in 0.01mm units */ > - lpMFP->mm = MM_ANISOTROPIC; > - lpMFP->xExt = MulDiv(rect.right-rect.left, 2540, GetDeviceCaps(hdc, LOGPIXELSX)); > - lpMFP->yExt = MulDiv(rect.bottom-rect.top, 2540, GetDeviceCaps(hdc, LOGPIXELSY)); > - lpMFP->hMF = hmf; > - ReleaseDC(hwnd, hdc); > - GlobalUnlock(hGMem); > - > OpenClipboard(hwnd); > EmptyClipboard(); > - SetClipboardData(CF_METAFILEPICT,hGMem); > + SetClipboardData(CF_ENHMETAFILE,hemf); > SetClipboardData(CF_BITMAP, bitmap); > CloseClipboard(); > + ReleaseDC(hwnd, hdc); > + DeleteEnhMetaFile(hemf); > return; > } > > @@ -2244,6 +2238,15 @@ > break; > case WM_KEYDOWN: > { > + if (GetKeyState(VK_CONTROL) < 0) { > + switch(wParam) { > + case 'C': > + /* Ctrl-C: Copy to Clipboard */ > + SendMessage(hwnd,WM_COMMAND,M_COPY_CLIP,0L); > + break; > + } /* switch(wparam) */ > + } /* if(Ctrl) */ > + else { > /* First, look for a change in modifier status */ > unsigned int modifier_mask = 0; > modifier_mask = ((GetKeyState(VK_SHIFT) < 0) ? Mod_Shift : 0 ) > @@ -2254,6 +2257,7 @@ > last_modifier_mask = modifier_mask; > } > } > + } > switch (wParam) { > case VK_BACK: > Wnd_exec_event(lpgw, lParam, GE_keypress, GP_BackSpace); > diff --git a/term/win.trm b/term/win.trm > --- a/term/win.trm > +++ b/term/win.trm > @@ -982,7 +982,7 @@ > " `Color` when checked enables color linestyles. When unchecked it forces", > " monochrome linestyles.", > "", > -" `Copy to Clipboard` copies a bitmap and a Metafile picture.", > +" `Copy to Clipboard` copies a bitmap and an enhanced Metafile picture.", > "", > " `Background...` sets the window background color.", > "", > -------------------------------------- VANCOUVER 2010 Olympic News [Yahoo! Sports/sportsnavi] http://pr.mail.yahoo.co.jp/olympic/ |