Files
gcs-nf/opmap/mapwidget/waypointsetting.cpp
T
2022-04-01 21:37:32 +08:00

193 lines
4.1 KiB
C++

#include "waypointsetting.h"
namespace mapcontrol {
WayPointSetting::WayPointSetting(MapGraphicItem *map, QColor background) : myMap(map), myColor(background)
{
this->setAcceptHoverEvents(true);
this->setFlag(QGraphicsItem::ItemIsMovable, true);
this->setFlag(QGraphicsItem::ItemIgnoresTransformations, true);
this->setFlag(QGraphicsItem::ItemIsSelectable, false);
this->setFlag(QGraphicsItem::ItemIsFocusable,false);
connect(map, SIGNAL(childRefreshPosition()), this, SLOT(RefreshPos()));
connect(map, SIGNAL(childSetOpacity(qreal)), this, SLOT(setOpacitySlot(qreal)));
this->setZValue(7);
btn_load = new WayPointButton(map);
btn_load->setParentItem(this);
btn_load->setGeometry(10,10,80,80);
btn_load->setText(tr("Load"));
btn_save = new WayPointButton(map);
btn_save->setParentItem(this);
btn_save->setGeometry(110,10,80,80);
btn_save->setText(tr("Save"));
btn_upload = new WayPointButton(map);
btn_upload->setParentItem(this);
btn_upload->setGeometry(10,100,80,80);
btn_upload->setText(tr("Upload"));
btn_download = new WayPointButton(map);
btn_download->setParentItem(this);
btn_download->setGeometry(110,100,80,80);
btn_download->setText(tr("Download"));
btn_insert = new WayPointButton(map);
btn_insert->setParentItem(this);
btn_insert->setGeometry(10,190,80,80);
btn_insert->setText(tr("insert"));
btn_delete = new WayPointButton(map);
btn_delete->setParentItem(this);
btn_delete->setGeometry(110,190,80,80);
btn_delete->setText(tr("delete"));
btn_last = new WayPointButton(map);
btn_last->setParentItem(this);
btn_last->setGeometry(10,280,80,80);
btn_last->setText(tr("last"));
btn_next = new WayPointButton(map);
btn_next->setParentItem(this);
btn_next->setGeometry(110,280,80,80);
btn_next->setText(tr("next"));
btn_ruler = new WayPointButton(map);
btn_ruler->setParentItem(this);
btn_ruler->setGeometry(10,370,80,80);
btn_ruler->setText(tr("ruler"));
btn_table = new WayPointButton(map);
btn_table->setParentItem(this);
btn_table->setGeometry(110,370,80,80);
btn_table->setText(tr("table"));
}
QRectF WayPointSetting::boundingRect() const //鼠标可以操作的大小
{
return QRectF(0,0,200,460);
}
void WayPointSetting::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(option);
Q_UNUSED(widget);
painter->setRenderHint(QPainter::Antialiasing, true);
QPen ePen;
ePen.setWidth(1);
QFont font;
font.setPixelSize(15);//不随着屏幕分辨率改变而改变
font.setFamily("Arial");//非衬线
painter->setFont(font);
//画底部
painter->save();
ePen.setColor(myColor);
painter->setPen(ePen);
painter->setBrush(myColor);//QColor("#a39d9c"));
painter->setOpacity(opacity);
painter->drawRect(0,0,this->boundingRect().width(),this->boundingRect().height());
painter->restore();
}
void WayPointSetting::RefreshPos()
{
this->setPos(0,
0);
}
void WayPointSetting::setOpacitySlot(qreal opacity)
{
setOpacity(opacity);
}
void WayPointSetting::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
event->accept();
if (event->button() == Qt::LeftButton) {
isDragging = true;
}
}
void WayPointSetting::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
event->accept();
if (event->button() == Qt::LeftButton) {
isDragging = false;
}
}
void WayPointSetting::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
{
event->accept();
if (event->button() == Qt::LeftButton) {
}
}
void WayPointSetting::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
event->accept();
if (isDragging) {
}
}
void WayPointSetting::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
event->accept();
opacity = 0.6;
update();
}
void WayPointSetting::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
event->accept();
opacity = 0.2;
update();
}
void WayPointSetting::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
event->accept();
}
}