当前位置: 首页 > news >正文

织梦网站图标路径自媒体135网站免费下载安装

织梦网站图标路径,自媒体135网站免费下载安装,唐山房产网站建设,大型门户网站 要求前文链接:QGraphicsView实现简易地图3『局部加载-地图缩放』 当鼠标拖动地图移动时,需要实时增补和删减瓦片地图,大致思路是计算地图从各方向移动时进出视口的瓦片坐标值,根据变化后的瓦片坐标值来增减地图瓦片,以下将…

前文链接: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.qdjiajiao.com/news/12296.html

相关文章:

  • 京网站建设公司免费的网站域名查询app
  • 东莞如何建设网站制作平台今日重大新闻
  • 化工企业网站jsp可以免费发布广告的平台有哪些
  • 做网站备案需要什么特殊材料网络链接推广
  • 做电商网站需要注册什么公司名称代写文案的软件
  • 制作收款网站网站seo课程
  • 做公众号的必备参考网站重庆seo海洋qq
  • 网站建设自己在家接单怎么用模板做网站
  • 商贸公司寮步网站建设今日热点新闻事件摘抄2022
  • 网站管理怎么做第一推广网
  • 黑马网站建设营销策略的概念
  • 怎么建立网站的流程市场调研报告800字
  • 网站联动是什么意思沈阳网站制作推广
  • 政府网站报价什么是网络软文营销
  • 无锡阿里巴巴做网站百度一下的网址
  • 网站按天扣费优化推广近一周的新闻大事热点
  • 在别的公司做的网站可以转走吗百度热线电话
  • 互动案例的网站百度网站站长工具
  • 怎样买网站建设网络平台营销
  • 莱芜网站优化是什么seo权重优化
  • 佛山搭建建网站哪家好swot分析
  • 网站重新设计需要多久新手小白怎么做跨境电商
  • 一元云淘网站开发教程推广优化网站排名
  • 17网一起做网店网站公司网页设计
  • 网站的切图是谁来做西安优化外
  • 手机英文网站关键词优化到首页怎么做到的
  • 网站用的横幅广告怎么做seo入门培训班
  • 成品网站建设流程上海关键词优化公司哪家好
  • 建设企业网站找谁网站建设与管理是干什么的
  • 做网站 能挣钱吗江苏seo