我现在做了一个gis绘图软件,其中关于怎么实现拉框放大的问题不懂了。请各位高手指教!!! 谢谢 基本实现思路是,我在绘制图形的区域中用鼠标拉个矩形框,然后把这个矩形框中的图形扩大到整个绘图区域,这样就可以实现放大效果了。
解决方案 »
- CString问题
- VC6编写的应用程序图标怎样变为Win7样式的大图标?
- 没有找到MFC80UD.DLL,因此这个程序未能启动
- 新手问题,请各位数据库高手们指教,谢谢!!
- 请教:如何在一幅BMP图片上面叠加文字,然后再保存成另外一幅BMP, 请使用数字图像变换的方式来解决,不要使用DC
- 什么时候要DECLARE_DYNCREATE.........
- 大侠帮忙:如何实现将void*类型的数据转换为CString类型?顶者有分
- 怎样删除LisCtrl中的多个Item
- 请问在MDI中如何遍历已打开的所有子窗口的VIEW指针?
- 怎么控制ToolBar中Button的按下和弹起?
- 基础问题
- 一个输入输出流问题。
HDC hdcDest, // handle to destination DC
int nXOriginDest, // x-coord of destination upper-left corner
int nYOriginDest, // y-coord of destination upper-left corner
int nWidthDest, // width of destination rectangle
int nHeightDest, // height of destination rectangle
HDC hdcSrc, // handle to source DC
int nXOriginSrc, // x-coord of source upper-left corner
int nYOriginSrc, // y-coord of source upper-left corner
int nWidthSrc, // width of source rectangle
int nHeightSrc, // height of source rectangle
DWORD dwRop // raster operation code
);
{
#ifdef _DEBUG
if (m_nMapMode == MM_NONE)
{
TRACE(_T("Error: must call SetScrollSizes() before calling ZoomTo.\n"));
ASSERT(FALSE);
return 1.0f;
}
#endif //_DEBUG if (zoom < ZOOM_MIN) zoom = ZOOM_MIN;
else if (zoom > ZOOM_MAX) zoom = ZOOM_MAX; TRACE1(_T("Zoom factor = %f\n"), zoom); float prevZoom = m_Zoom; if (m_Zoom != zoom)
{
m_Zoom = zoom; CClientDC dc(this);
OnPrepareDC(& dc); m_totalDev = m_totalLog;
dc.LPtoDP(& m_totalDev); m_pageDev.cx = m_totalDev.cx / 10;
m_pageDev.cy = m_totalDev.cy / 10;
m_lineDev.cx = m_pageDev.cx / 10;
m_lineDev.cy = m_pageDev.cy / 10; UpdateBars();
OnZoom(zoom, prevZoom);
Invalidate();
}
m_WheelDelta = 0;
return prevZoom;
}void QZoomView::ZoomToRectangle(CRect logRect)
{
CRect rcClient;
GetClientRect(rcClient); // Compensate for scrollbars after zooming
DWORD dwStyle = GetStyle(); CSize szSB;
GetScrollBarSizes(szSB); if(!(dwStyle & WS_VSCROLL))
rcClient.right -= szSB.cx;
if(!(dwStyle & WS_HSCROLL))
rcClient.bottom -= szSB.cy; CRect devRect(logRect); // Original mapmode gives 100% zoom
CClientDC dc(this);
dc.SetMapMode(m_nMapMode); // Rect for 100% zoom in device coordinates:
dc.LPtoDP(devRect);
devRect.NormalizeRect(); // We need to compare devRect.Width()/rcClient.right to devRect.Height()/rcClient.bottom.
// Give them common denominators and compare just the numerators (assume all
// numbers are positive):
int nx = devRect.Width() * rcClient.bottom;
int ny = devRect.Height() * rcClient.right; float zoom;
if (nx < ny)
{
if (devRect.Width() < rcClient.right)
rcClient.bottom += szSB.cy;
// We probably don't need a horizontal scrollbar,
// but we can't be sure. // -1 compensates for roundof errors
zoom = (float)(rcClient.bottom - 1) /(float)devRect.Height();
}
else
{
if (devRect.Height() < rcClient.bottom)
rcClient.right += szSB.cx;
zoom = (float)(rcClient.right - 1) / (float)devRect.Width();
}
ZoomTo(zoom);
m_PresetIndex = -1;
}
若要字体相应变大,线相应变宽就用CDC的SetViewportExt(),SetViewportOrg()来实现。
我觉得做GIS应该采用这种方法比较好吧,不但容易实现,而且不用在内存中建立很大的位图来往屏幕上贴。