公司网站设计网络公司,广西南宁人才招聘网站,p2p网站建设的步骤过程,百度快照和广告的区别前文链接#xff1a;QGraphicsView实现简易地图3『局部加载-地图缩放』 当鼠标拖动地图移动时#xff0c;需要实时增补和删减瓦片地图#xff0c;大致思路是计算地图从各方向移动时进出视口的瓦片坐标值#xff0c;根据变化后的瓦片坐标值来增减地图瓦片#xff0c;以下将…前文链接QGraphicsView实现简易地图3『局部加载-地图缩放』 当鼠标拖动地图移动时需要实时增补和删减瓦片地图大致思路是计算地图从各方向移动时进出视口的瓦片坐标值根据变化后的瓦片坐标值来增减地图瓦片以下将提供实现此需求的核心代码。 1、动态演示效果 2、静态展示图片 核心代码 
void MapView::moveScene()
{QString appPath  QApplication::applicationDirPath();QString dirPath  QString(%1/MapData/GaoDeMap/Map/MapPng/L0%2).arg(appPath).arg(m_curLevel  1);// 视口宽度和高度int w  viewport()-width();int h  viewport()-height();// 计算呈现的瓦片地图左上角的场景坐标和视口坐标、呈现的瓦片地图右下角的场景坐标和视口坐标QPoint topLeftScenePos(m_topLeftTileCoord.x * PIXMAP_SIZE, m_topLeftTileCoord.y * PIXMAP_SIZE);QPointF topLeftViewPos  mapFromScene(topLeftScenePos);QPoint bottomRightScenePos(m_bottomRightTileCoord.x * PIXMAP_SIZE, m_bottomRightTileCoord.y * PIXMAP_SIZE);QPointF bottomRightViewPos  mapFromScene(bottomRightScenePos);// 1、水平瓦片坐标控制判断最左侧瓦片是否完全进入视口、最右侧瓦片是否完全离开视口if (topLeftViewPos.x()  0){int count  qCeil(topLeftViewPos.x() / PIXMAP_SIZE);	// 左侧进入视口瓦片数量int oldLeftTileCoordX  m_topLeftTileCoord.x;			// 保存原左侧瓦片坐标Xm_topLeftTileCoord.x - count;							// 更新现左侧瓦片坐标X// 增加从左侧进入视口的图片for (int row  m_topLeftTileCoord.y; row  m_bottomRightTileCoord.y; row){for (int col  m_topLeftTileCoord.x; col  oldLeftTileCoordX; col){QString fileName  QString(%1/Map_%2-%3.png).arg(dirPath).arg(QString::number(row  1).rightJustified(2, 0)).arg(QString::number(col  1).rightJustified(2, 0));QPixmap pixmap(fileName);QGraphicsPixmapItem *item  new QGraphicsPixmapItem(pixmap);item-setPos(PIXMAP_SIZE * col, PIXMAP_SIZE * row);m_scene-addItem(item);m_mapItems[row][col]  item;}}}if (bottomRightViewPos.x()  w){int count  qFloor((bottomRightViewPos.x() - w) / PIXMAP_SIZE)  1;	// 右侧离开视口瓦片数量int oldRightTileCoordX  m_bottomRightTileCoord.x;					// 保存原右侧瓦片坐标Xm_bottomRightTileCoord.x - count;									// 更新现右侧瓦片坐标X// 删除从右侧离开视口的图片for (int row  m_topLeftTileCoord.y; row  m_bottomRightTileCoord.y; row){for (int col  oldRightTileCoordX; col  m_bottomRightTileCoord.x; --col){QGraphicsPixmapItem *item  m_mapItems[row][col];m_scene-removeItem(item);m_mapItems[row].remove(col);delete item;}}}// 2、水平瓦片坐标控制判断最右侧瓦片是否完全进入视口、最左侧瓦片是否完全离开视口if (bottomRightViewPos.x()  255  w){int count  qCeil((w - (bottomRightViewPos.x()  255)) / PIXMAP_SIZE);	// 右侧进入视口瓦片数量int oldRightTileCoordX  m_bottomRightTileCoord.x;						// 保存原右侧瓦片坐标Xm_bottomRightTileCoord.x  count;										// 保存现右侧瓦片坐标X// 增加从右侧进入视口的图片for (int row  m_topLeftTileCoord.y; row  m_bottomRightTileCoord.y; row){for (int col  m_bottomRightTileCoord.x; col  oldRightTileCoordX; --col){QString fileName  QString(%1/Map_%2-%3.png).arg(dirPath).arg(QString::number(row  1).rightJustified(2, 0)).arg(QString::number(col  1).rightJustified(2, 0));QPixmap pixmap(fileName);QGraphicsPixmapItem *item  new QGraphicsPixmapItem(pixmap);item-setPos(PIXMAP_SIZE * col, PIXMAP_SIZE * row);m_scene-addItem(item);m_mapItems[row][col]  item;}}}if (topLeftViewPos.x()  255  0){int count  qFloor(fabs(topLeftViewPos.x()) / PIXMAP_SIZE);	// 左侧离开视口瓦片数量int oldLeftTileCoordX  m_topLeftTileCoord.x;				// 保存原左侧瓦片坐标Xm_topLeftTileCoord.x  count;								// 保存现左侧瓦片坐标X// 删除从左侧离开视口的图片for (int row  m_topLeftTileCoord.y; row  m_bottomRightTileCoord.y; row){for (int col  oldLeftTileCoordX; col  m_topLeftTileCoord.x; col){QGraphicsPixmapItem *item  m_mapItems[row][col];m_scene-removeItem(item);m_mapItems[row].remove(col);delete item;}}}// 3、垂直瓦片坐标控制判断最上侧瓦片是否完全进入视口最下侧瓦片是否完全离开视口if (topLeftViewPos.y()  0){int count  qCeil(topLeftViewPos.y() / PIXMAP_SIZE);	// 上侧进入视口瓦片数量int oldTopTileCoordY  m_topLeftTileCoord.y;			// 保存原上侧瓦片坐标Ym_topLeftTileCoord.y - count;							// 保存现上侧瓦片坐标Y// 增加从上侧进入视口的图片for (int row  m_topLeftTileCoord.y; row  oldTopTileCoordY; row){for (int col  m_topLeftTileCoord.x; col  m_bottomRightTileCoord.x; col){QString fileName  QString(%1/Map_%2-%3.png).arg(dirPath).arg(QString::number(row  1).rightJustified(2, 0)).arg(QString::number(col  1).rightJustified(2, 0));QPixmap pixmap(fileName);QGraphicsPixmapItem *item  new QGraphicsPixmapItem(pixmap);item-setPos(PIXMAP_SIZE * col, PIXMAP_SIZE * row);m_scene-addItem(item);m_mapItems[row][col]  item;}}}if (bottomRightViewPos.y()  h){int count  qFloor((bottomRightViewPos.y() - h) / PIXMAP_SIZE)  1;	// 下侧离开视口瓦片数量int oldBottomTileCoordY  m_bottomRightTileCoord.y;					// 保存原下侧瓦片坐标Ym_bottomRightTileCoord.y - count;									// 保存现下侧瓦片坐标Y// 删除从下侧离开视口的图片for (int row  oldBottomTileCoordY; row  m_bottomRightTileCoord.y; --row){for (int col  m_topLeftTileCoord.x; col  m_bottomRightTileCoord.x; col){QGraphicsPixmapItem *item  m_mapItems[row][col];m_scene-removeItem(item);m_mapItems[row].remove(col);delete item;}}}// 4、垂直瓦片坐标控制判断最下侧瓦片是否完全进入视口最上侧瓦片是否完全离开视口if (bottomRightViewPos.y()  255  h){int count  qCeil((h - (bottomRightViewPos.y()  255)) / PIXMAP_SIZE);	// 下侧进入视口瓦片数量int oldBottomTileCoordY  m_bottomRightTileCoord.y;						// 保存原下侧瓦片坐标Ym_bottomRightTileCoord.y  count;										// 保存现下侧瓦片坐标Y// 增加从下侧进入视口的图片for (int row  m_bottomRightTileCoord.y; row  oldBottomTileCoordY; --row){for (int col  m_topLeftTileCoord.x; col  m_bottomRightTileCoord.x; col){QString fileName  QString(%1/Map_%2-%3.png).arg(dirPath).arg(QString::number(row  1).rightJustified(2, 0)).arg(QString::number(col  1).rightJustified(2, 0));QPixmap pixmap(fileName);QGraphicsPixmapItem *item  new QGraphicsPixmapItem(pixmap);item-setPos(PIXMAP_SIZE * col, PIXMAP_SIZE * row);m_scene-addItem(item);m_mapItems[row][col]  item;}}}if (topLeftViewPos.y()  255  0){int count  qFloor(fabs(topLeftViewPos.y()) / PIXMAP_SIZE);	// 上侧离开视口瓦片数量int oldTopTileCoordY  m_topLeftTileCoord.y;				// 保存原上侧瓦片坐标Ym_topLeftTileCoord.y  count;								// 保存现上侧瓦片坐标Y// 删除从上侧离开视口的图片for (int row  oldTopTileCoordY; row  m_topLeftTileCoord.y; row){for (int col  m_topLeftTileCoord.x; col  m_bottomRightTileCoord.x; col){QGraphicsPixmapItem *item  m_mapItems[row][col];m_scene-removeItem(item);m_mapItems[row].remove(col);delete item;}}}
} 文章转载自: http://www.morning.cgthq.cn.gov.cn.cgthq.cn http://www.morning.gkktj.cn.gov.cn.gkktj.cn http://www.morning.xbkcr.cn.gov.cn.xbkcr.cn http://www.morning.dnconr.cn.gov.cn.dnconr.cn http://www.morning.cfrz.cn.gov.cn.cfrz.cn http://www.morning.piekr.com.gov.cn.piekr.com http://www.morning.wbns.cn.gov.cn.wbns.cn http://www.morning.nftzn.cn.gov.cn.nftzn.cn http://www.morning.jfbpf.cn.gov.cn.jfbpf.cn http://www.morning.nflpk.cn.gov.cn.nflpk.cn http://www.morning.spftz.cn.gov.cn.spftz.cn http://www.morning.qqbjt.cn.gov.cn.qqbjt.cn http://www.morning.hphqy.cn.gov.cn.hphqy.cn http://www.morning.ndpzm.cn.gov.cn.ndpzm.cn http://www.morning.fhwfk.cn.gov.cn.fhwfk.cn http://www.morning.txltb.cn.gov.cn.txltb.cn http://www.morning.ywpwq.cn.gov.cn.ywpwq.cn http://www.morning.dkmzr.cn.gov.cn.dkmzr.cn http://www.morning.fsfz.cn.gov.cn.fsfz.cn http://www.morning.trqzk.cn.gov.cn.trqzk.cn http://www.morning.rwmp.cn.gov.cn.rwmp.cn http://www.morning.rxkl.cn.gov.cn.rxkl.cn http://www.morning.npxht.cn.gov.cn.npxht.cn http://www.morning.dyzbt.cn.gov.cn.dyzbt.cn http://www.morning.xdpjf.cn.gov.cn.xdpjf.cn http://www.morning.jqcrf.cn.gov.cn.jqcrf.cn http://www.morning.gywxq.cn.gov.cn.gywxq.cn http://www.morning.gcysq.cn.gov.cn.gcysq.cn http://www.morning.jrhcp.cn.gov.cn.jrhcp.cn http://www.morning.wwjft.cn.gov.cn.wwjft.cn http://www.morning.dndk.cn.gov.cn.dndk.cn http://www.morning.cyysq.cn.gov.cn.cyysq.cn http://www.morning.knlbg.cn.gov.cn.knlbg.cn http://www.morning.rwdbz.cn.gov.cn.rwdbz.cn http://www.morning.wtcbl.cn.gov.cn.wtcbl.cn http://www.morning.zdzgf.cn.gov.cn.zdzgf.cn http://www.morning.ppbrq.cn.gov.cn.ppbrq.cn http://www.morning.paxkhqq.cn.gov.cn.paxkhqq.cn http://www.morning.hjwzpt.com.gov.cn.hjwzpt.com http://www.morning.nlysd.cn.gov.cn.nlysd.cn http://www.morning.gjqnn.cn.gov.cn.gjqnn.cn http://www.morning.bojkosvit.com.gov.cn.bojkosvit.com http://www.morning.hwbmn.cn.gov.cn.hwbmn.cn http://www.morning.djlxz.cn.gov.cn.djlxz.cn http://www.morning.yzktr.cn.gov.cn.yzktr.cn http://www.morning.xfcjs.cn.gov.cn.xfcjs.cn http://www.morning.rmyqj.cn.gov.cn.rmyqj.cn http://www.morning.jxhlx.cn.gov.cn.jxhlx.cn http://www.morning.qnpyz.cn.gov.cn.qnpyz.cn http://www.morning.ljzqb.cn.gov.cn.ljzqb.cn http://www.morning.sqqds.cn.gov.cn.sqqds.cn http://www.morning.beijingzy.com.cn.gov.cn.beijingzy.com.cn http://www.morning.dsxgc.cn.gov.cn.dsxgc.cn http://www.morning.pnmtk.cn.gov.cn.pnmtk.cn http://www.morning.sgmgz.cn.gov.cn.sgmgz.cn http://www.morning.wnnfh.cn.gov.cn.wnnfh.cn http://www.morning.zrwlz.cn.gov.cn.zrwlz.cn http://www.morning.dthyq.cn.gov.cn.dthyq.cn http://www.morning.qgtfl.cn.gov.cn.qgtfl.cn http://www.morning.bctr.cn.gov.cn.bctr.cn http://www.morning.jrqw.cn.gov.cn.jrqw.cn http://www.morning.rsjng.cn.gov.cn.rsjng.cn http://www.morning.qytyt.cn.gov.cn.qytyt.cn http://www.morning.kqxwm.cn.gov.cn.kqxwm.cn http://www.morning.qymqh.cn.gov.cn.qymqh.cn http://www.morning.wxfgg.cn.gov.cn.wxfgg.cn http://www.morning.xrhst.cn.gov.cn.xrhst.cn http://www.morning.pzpj.cn.gov.cn.pzpj.cn http://www.morning.ltpzr.cn.gov.cn.ltpzr.cn http://www.morning.fddfn.cn.gov.cn.fddfn.cn http://www.morning.srxhd.cn.gov.cn.srxhd.cn http://www.morning.ymtbr.cn.gov.cn.ymtbr.cn http://www.morning.rmfh.cn.gov.cn.rmfh.cn http://www.morning.zsfooo.com.gov.cn.zsfooo.com http://www.morning.djwpd.cn.gov.cn.djwpd.cn http://www.morning.tkxr.cn.gov.cn.tkxr.cn http://www.morning.pbpcj.cn.gov.cn.pbpcj.cn http://www.morning.skrxp.cn.gov.cn.skrxp.cn http://www.morning.qcdtzk.cn.gov.cn.qcdtzk.cn http://www.morning.cdlewan.com.gov.cn.cdlewan.com