1 Star 0 Fork 42

jinzhiyuan/easygis

forked from qizr/easygis 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
mapautoplane.cpp 1.09 KB
一键复制 编辑 原始数据 按行查看 历史
qizr 提交于 2021-12-26 17:58 . add plane func
#include "mapautoplane.h"
#include "maplayer.h"
#include <QRandomGenerator>
#include <QDebug>
EasyGIS::MapAutoplane::MapAutoplane(const MapLayer *layer,QPointF pos,QGraphicsItem *parent):mLayer(layer), current_mktpoint(pos),QGraphicsPixmapItem(parent)
{
QPixmap pix(":/plane-red.png");
this->setPixmap(pix);
QPointF scene_point=this->current_mktpoint/this->mLayer->resolution();
this->setOffset(scene_point);
}
void EasyGIS::MapAutoplane::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
QPointF scene_point=this->current_mktpoint/this->mLayer->resolution();
this->setOffset(scene_point);
QGraphicsPixmapItem::paint(painter,option,widget);
}
QRectF EasyGIS::MapAutoplane::boundingRect() const
{
QPointF scene_point=this->current_mktpoint/this->mLayer->resolution();
return QRectF(scene_point.x(),scene_point.y(),16,16);
}
void EasyGIS::MapAutoplane::updatePos()
{
qreal x=QRandomGenerator::global()->bounded(-1000, 1000);
qreal y=QRandomGenerator::global()->bounded(-1000, 1000);
this->current_mktpoint+=QPointF(x,y);
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/talkmeclub/easygis.git
git@gitee.com:talkmeclub/easygis.git
talkmeclub
easygis
easygis
master

搜索帮助