标尺添加
This commit is contained in:
@@ -129,8 +129,10 @@ OPMapWidget::OPMapWidget(QWidget *parent, Configuration *config) : QGraphicsView
|
||||
connect(waypointsetting,SIGNAL(WPLoad(QString)),
|
||||
this,SLOT(WPLoad(QString)));
|
||||
|
||||
/*
|
||||
connect(this,SIGNAL(allPoint(QMap<int,int>)),
|
||||
waypointsetting,SLOT(setallPoint(QMap<int,int>)));
|
||||
*/
|
||||
|
||||
connect(waypointsetting,SIGNAL(searchall()),
|
||||
this,SLOT(WPsearchall()));
|
||||
@@ -148,6 +150,9 @@ OPMapWidget::OPMapWidget(QWidget *parent, Configuration *config) : QGraphicsView
|
||||
missiontable->hide();
|
||||
|
||||
|
||||
measureline = new MeasureLine(point_begin, point_end, map, QColor("#FFFF00"));
|
||||
mscene.addItem(measureline);
|
||||
measureline->hide();
|
||||
|
||||
//ruler = new RuleDialog();
|
||||
|
||||
@@ -199,7 +204,15 @@ void OPMapWidget::ruler_clicked(void)
|
||||
else
|
||||
{
|
||||
isMeasure = true;
|
||||
this->setCursor(QCursor(QPixmap(":/markers/images/ruler.png")));
|
||||
measurenumber = 1;//开始记录
|
||||
|
||||
if(measureline)
|
||||
{
|
||||
measureline->show();
|
||||
}
|
||||
|
||||
QPixmap pix(":/markers/images/ruler.png");
|
||||
this->setCursor(QCursor(pix.scaled(QSize(50,50), Qt::KeepAspectRatio)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -561,6 +574,27 @@ internals::PointLatLng OPMapWidget::currentMousePosition()
|
||||
void OPMapWidget::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
QGraphicsView::mouseMoveEvent(event);
|
||||
|
||||
if(altitudeitem)
|
||||
{
|
||||
if((event->pos().x() > altitudeitem->x())&&(event->pos().x() < (altitudeitem->boundingRect().width() + altitudeitem->x())) &&
|
||||
(event->pos().y() > altitudeitem->y())&&(event->pos().y() < (altitudeitem->boundingRect().height() + altitudeitem->y())))//在高度区域禁止生成航点
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//一个区域内禁止生成
|
||||
if(waypointsetting)
|
||||
{
|
||||
if((event->pos().x() > waypointsetting->x())&&(event->pos().x() < (waypointsetting->boundingRect().width() + waypointsetting->x())) &&
|
||||
(event->pos().y() > waypointsetting->y())&&(event->pos().y() < (waypointsetting->boundingRect().height() + waypointsetting->y())))//在按键区域禁止生成航点
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QPointF p = event->pos();
|
||||
|
||||
//qDebug() << "mouseMoveEvent";
|
||||
@@ -571,6 +605,23 @@ void OPMapWidget::mouseMoveEvent(QMouseEvent *event)
|
||||
|
||||
isLNOP = false;
|
||||
|
||||
|
||||
if(isMeasure)
|
||||
{
|
||||
QPointF p = event->pos();
|
||||
p = map->mapFromParent(p);
|
||||
point_end = map->FromLocalToLatLng(p.x(), p.y());
|
||||
//measurenumber = 1;
|
||||
|
||||
if(measureline)
|
||||
{
|
||||
if(measurenumber == 2)//取了第一个点后
|
||||
{
|
||||
measureline->setTo(point_end);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
emit EmitCurrentMousePosition(currentmouseposition);
|
||||
}
|
||||
|
||||
@@ -579,7 +630,62 @@ void OPMapWidget::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
QGraphicsView::mousePressEvent(event);
|
||||
|
||||
//qDebug() << "mousePressEvent";
|
||||
if(altitudeitem)
|
||||
{
|
||||
if((event->pos().x() > altitudeitem->x())&&(event->pos().x() < (altitudeitem->boundingRect().width() + altitudeitem->x())) &&
|
||||
(event->pos().y() > altitudeitem->y())&&(event->pos().y() < (altitudeitem->boundingRect().height() + altitudeitem->y())))//在高度区域禁止生成航点
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//一个区域内禁止生成
|
||||
if(waypointsetting)
|
||||
{
|
||||
if((event->pos().x() > waypointsetting->x())&&(event->pos().x() < (waypointsetting->boundingRect().width() + waypointsetting->x())) &&
|
||||
(event->pos().y() > waypointsetting->y())&&(event->pos().y() < (waypointsetting->boundingRect().height() + waypointsetting->y())))//在按键区域禁止生成航点
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(event->button() == Qt::LeftButton)
|
||||
{
|
||||
|
||||
if(isMeasure)
|
||||
{
|
||||
if(measurenumber == 1)
|
||||
{
|
||||
QPointF p = event->pos();
|
||||
p = map->mapFromParent(p);
|
||||
point_begin = map->FromLocalToLatLng(p.x(), p.y());
|
||||
measurenumber ++;
|
||||
|
||||
if(measureline)
|
||||
{
|
||||
measureline->setFrom(point_begin);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
QPointF p = event->pos();
|
||||
p = map->mapFromParent(p);
|
||||
point_end = map->FromLocalToLatLng(p.x(), p.y());
|
||||
measurenumber = 1;
|
||||
|
||||
if(measureline)
|
||||
{
|
||||
measureline->setTo(point_end);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
isLNOP = false;
|
||||
|
||||
@@ -599,6 +705,12 @@ void OPMapWidget::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
QGraphicsView::mouseDoubleClickEvent(event);
|
||||
|
||||
|
||||
if(isMeasure)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(altitudeitem)
|
||||
{
|
||||
if((event->pos().x() > altitudeitem->x())&&(event->pos().x() < (altitudeitem->boundingRect().width() + altitudeitem->x())) &&
|
||||
|
||||
Reference in New Issue
Block a user