#include "mainwindow.h"
#include "graph.h"
#include "ui_mainwindow.h"
#include <QPainter>
#include <QMessageBox>
#define WIN_WIGHT 1500
#define WIN_HEIGHT 800
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
setFixedSize(WIN_WIGHT,WIN_HEIGHT);
pix=QPixmap(WIN_WIGHT,WIN_HEIGHT);
pix.fill(Qt::white);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::drawline(int x1,int y1,int x2,int y2, QColor const c)
{
QPainter painter(&pix);
painter.setPen(QPen(c));
QLineF line(x1,y1,x2,y2);
painter.drawLine(line);
update();
}
void MainWindow::paintEvent(QPaintEvent* event)
{
QPainter painter(this);
painter.drawPixmap(0,0,WIN_WIGHT,WIN_HEIGHT,pix);
}
void MainWindow::on_recommendpath_clicked()
{ Graph graph;
graph.Init();
Graph::Vex vexs[SIZE];
Graph::Edge edges[SIZE*SIZE];
memset(vexs,0,sizeof (vexs));
memset(edges,0,sizeof (edges));
graph.createScenicSpot(vexs,edges);
for(int i = 0;i < 7;i++)
graph.InsertVex(vexs[i]);
for(int i = 0;i < 11;i++)
graph.InsertEdge(edges[i]);
Graph::Edge temp[11];
graph.MST(temp);//最小生成树,推荐游览路径
pix.fill(Qt::white);
int B1X,B1Y,B2X,B2Y;
QPoint p1,p2;
for(int i = 0;i < 11;i++){
switch (temp[i].vex1) {
case 0:
p1=ui->spot1_3->mapToGlobal(QPoint(0,0));
B1X=p1.x(),B1Y=p1.y();
switch(temp[i].vex2){
case 0:
p2=ui->spot1_3->mapToGlobal(QPoint(0,0));
break;
case 1:
p2=ui->spot2_3->mapToGlobal(QPoint(0,0));
break;
case 2:
p2=ui->spot3_3->mapToGlobal(QPoint(0,0));
break;
case 3:
p2=ui->spot4_3->mapToGlobal(QPoint(0,0));
break;
case 4:
p2=ui->spot5_3->mapToGlobal(QPoint(0,0));
break;
case 5:
p2=ui->spot6_3->mapToGlobal(QPoint(0,0));
break;
case 6:
p2=ui->spot7_3->mapToGlobal(QPoint(0,0));
break;
}
B2X=p2.x(),B2Y=p2.y();
drawline(B1X,B1Y,B2X,B2Y,QColor(255,0,0));
break;
case 1:
p1=ui->spot2_3->mapToGlobal(QPoint(0,0));
B1X=p1.x(),B1Y=p1.y();
switch(temp[i].vex2){
case 0:
p2=ui->spot1_3->mapToGlobal(QPoint(0,0));
break;
case 1:
p2=ui->spot2_3->mapToGlobal(QPoint(0,0));
break;
case 2:
p2=ui->spot3_3->mapToGlobal(QPoint(0,0));
//printf("x1:%d y1:%d x2:%d y2:%d \n",B1X,B1Y,B2X,B2Y);
break;
case 3:
p2=ui->spot4_3->mapToGlobal(QPoint(0,0));
break;
case 4:
p2=ui->spot5_3->mapToGlobal(QPoint(0,0));
break;
case 5:
p2=ui->spot6_3->mapToGlobal(QPoint(0,0));
break;
case 6:
p2=ui->spot7_3->mapToGlobal(QPoint(0,0));
break;
}
B2X=p2.x(),B2Y=p2.y();
drawline(B1X,B1Y,B2X,B2Y,QColor(255,0,0));
break;
case 2:
p1=ui->spot3_3->mapToGlobal(QPoint(0,0));
B1X=p1.x(),B1Y=p1.y();
switch(temp[i].vex2){
case 0:
p2=ui->spot1_3->mapToGlobal(QPoint(0,0));
break;
case 1:
p2=ui->spot2_3->mapToGlobal(QPoint(0,0));
break;
case 2:
p2=ui->spot3_3->mapToGlobal(QPoint(0,0));
break;
case 3:
p2=ui->spot4_3->mapToGlobal(QPoint(0,0));
break;
case 4:
p2=ui->spot5_3->mapToGlobal(QPoint(0,0));
break;
case 5:
p2=ui->spot6_3->mapToGlobal(QPoint(0,0));
break;
case 6:
p2=ui->spot7_3->mapToGlobal(QPoint(0,0));
break;
}
B2X=p2.x(),B2Y=p2.y();
drawline(B1X,B1Y,B2X,B2Y,QColor(255,0,0));
break;
case 3:
p1=ui->spot4_3->mapToGlobal(QPoint(0,0));
B1X=p1.x(),B1Y=p1.y();
switch(temp[i].vex2){
case 0:
p2=ui->spot1_3->mapToGlobal(QPoint(0,0));
break;
case 1:
p2=ui->spot2_3->mapToGlobal(QPoint(0,0));
break;
case 2:
p2=ui->spot3_3->mapToGlobal(QPoint(0,0));
break;
case 3:
p2=ui->spot4_3->mapToGlobal(QPoint(0,0));
break;
case 4:
p2=ui->spot5_3->mapToGlobal(QPoint(0,0));
break;
case 5:
p2=ui->spot6_3->mapToGlobal(QPoint(0,0));
break;
case 6:
p2=ui->spot7_3->mapToGlobal(QPoint(0,0));
break;
}
B2X=p2.x(),B2Y=p2.y();
drawline(B1X,B1Y,B2X,B2Y,QColor(255,0,0));
break;
case 4:
p1=ui->spot5_3->mapToGlobal(QPoint(0,0));
B1X=p1.x(),B1Y=p1.y();
switch(temp[i].vex2){
case 0:
p2=ui->spot1_3->mapToGlobal(QPoint(0,0));
break;
case 1:
p2=ui->spot2_3->mapToGlobal(QPoint(0,0));
break;
case 2:
p2=ui->spot3_3->mapToGlobal(QPoint(0,0));
break;
case 3:
p2=ui->spot4_3->mapToGlobal(QPoint(0,0));
break;
case 4:
p2=ui->spot5_3->mapToGlobal(QPoint(0,0));
break;
case 5:
p2=ui->spot6_3->mapToGlobal(QPoint(0,0));
break;
case 6:
p2=ui->spot7_3->mapToGlobal(QPoint(0,0));
break;
}
B2X=p2.x(),B2Y=p2.y();
drawline(B1X,B1Y,B2X,B2Y,QColor(255,0,0));
break;
case 5:
p1=ui->spot6_3->mapToGlobal(QPoint(0,0));
B1X=p1.x(),B1Y=p1.y();
switch(temp[i].vex2){
case 0:
p2=ui->spot1_3->mapToGlobal(QPoint(0,0));
break;
case 1:
p2=ui->spot2_3->mapToGlobal(QPoint(0,0));
break;
case 2:
p2=ui->spot3_3->mapToGlobal(QPoint(0,0));
break;
case 3:
p2=ui->spot4_3->mapToGlobal(QPoint(0,0));
break;
case 4:
p2=ui->spot5_3->mapToGlobal(QPoint(0,0));
break;
case 5:
p2=ui->spot6_3->mapToGlobal(QPoint(0,0));
break;
case 6:
p2=ui->spot7_3->mapToGlobal(QPoint(0,0));
break;
}
B2X=p2.x(),B2Y=p2.y();
drawline(B1X,B1Y,B2X,B2Y,QColor(255,0,0));
break;
case 6:
p1=ui->spot7_3->mapToGlobal(QPoint(0,0));
B1X=p1.x(),B1Y=p1.y();
switch(temp[i].vex2){
case 0:
p2=ui->spot1_3->mapToGlobal(QPoint(0,0));
break;
case 1:
p2=ui->spot2_3->mapToGlobal(QPoint(0,0));
break;
case 2:
p2=ui->spot3_3->mapToGlobal(QPoint(0,0));
break;
case 3:
p2=
onnx
- 粉丝: 9973
- 资源: 5626
最新资源
- 基于Go和React的高质量企业微信私域流量管理系统 。遵守Apache2.0协议,全网唯一免费商用。企业微信、私域流量、SCRM。详细文档+优秀项目+全部资料.zip
- 基于Go和React的企业微信的开源 SCRM 系统。企微,个微,微信,聚合聊天,自动回复,加好友。详细文档+优秀项目+全部资料.zip
- 基于go语言的搜索引擎,信息检索系统详细文档+优秀项目+全部资料.zip
- 基于Go语言,Beego框架开发的简单的文章发布管理系统。详细文档+优秀项目+全部资料.zip
- 基于Go语言的轻量级高性能的分布式日志系统详细文档+优秀项目+全部资料.zip
- 基于go语言简单的用户管理系统详细文档+优秀项目+全部资料.zip
- 基于Go语言的一个秒杀系统详细文档+优秀项目+全部资料.zip
- 基于Go语言的一个简易blog系统详细文档+优秀项目+全部资料.zip
- 基于Go语言开发,具备高安全性、高性能和易扩展性的企业级内容管理系统,详细文档+优秀项目+全部资料.zip
- 基于Go语言实现的单点登录系统详细文档+优秀项目+全部资料.zip
- 基于Go语言实现的微服务电商系统详细文档+优秀项目+全部资料.zip
- 基于python和sql server2014做的商品学生信息管理系统,有界面,利用的sql server数据库详细文档+优秀项目+全部资料.zip
- 基于OWTP协议库,封装所有与openw-server钱包服务API交互方法。用于集成到go语言开发下的应用方系统。详细文档+优秀项目+全部资料.zip
- 基于Quasar和Go语言的功能全面的管理系统详细文档+优秀项目+全部资料.zip
- 基于SpringBoot 开发的员工的季度绩效考核系统详细文档+优秀项目+全部资料.zip
- 四足机器人技术发展及其应用场景概述
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈