merge proj and change encode to utf8

This commit is contained in:
wmj committed 2017-12-16 22:19:15 +08:00
commit 723c6760f5
9 files changed
+76 -41

No files matched your search

+13 -22
View File
@@ -4,7 +4,7 @@
#
#-------------------------------------------------
QT += core gui
QT += core gui
QT += xml
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
@@ -27,30 +27,21 @@ DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += \
main.cpp \
mainwindow.cpp \
monitor.cpp \
cars.cpp \
parkinglot.cpp \
cars.cpp \
main.cpp \
mainwindow.cpp \
monitor.cpp \
parkinglot.cpp \
ParkingLotWidget.cpp \
ParkingSpaceWidget.cpp \
Road.cpp
monitor.cpp \
cars.cpp \
parkinglot.cpp \
ParkingLotWidget.cpp \
Road.cpp \
ParkingSpaceWidget.cpp
HEADERS += \
mainwindow.h \
monitor.h \
cars.h \
parkinglot.h \
cars.h \
mainwindow.h \
monitor.h \
parkinglot.h \
ParkingLotWidget.h \
ParkingSpaceWidget.h \
Road.h
monitor.h \
cars.h \
parkinglot.h \
ParkingLotWidget.h \
Road.h \
ParkingSpaceWidget.h
FORMS += \
mainwindow.ui
+4 -4
View File
@@ -1,4 +1,4 @@
#include "ParkingLotWidget.h"
#include "ParkingLotWidget.h"
#include "ParkingSpaceWidget.h"
#include <QFile>
#include <QMessageBox>
@@ -55,7 +55,7 @@ void ParkingLotWidget::parse_xml(const QString & xml)
layout = parseLayout(element);
} else
{
qDebug() << this -> objectName() << "布局文件错误";
qDebug() << this -> objectName() << "布局文件错误";
}
}
@@ -88,10 +88,10 @@ QBoxLayout * ParkingLotWidget::parseLayout(const QDomElement & element)
else if ((name.at(0) == 'v' || name.at(0) == 'h' )&& name.contains("Layout"))
layout->addLayout(parseLayout(child));
else
qDebug() << this->objectName() << "错误的xml标签";
qDebug() << this->objectName() << "错误的xml标签";
child = child.nextSiblingElement();
}
layout->addStretch(); // 添加伸缩,实现居上或居左对齐
layout->addStretch(); // 添加伸缩,实现居上或居左对齐
layout->setMargin(0);
layout->setSpacing(0);
return layout;
+3 -3
View File
@@ -1,4 +1,4 @@
#include "ParkingSpaceWidget.h"
#include "ParkingSpaceWidget.h"
#include <QPainter>
#include <QDebug>
#include "ParkingLotWidget.h"
@@ -13,7 +13,7 @@ ParkingSpaceWidget::ParkingSpaceWidget(ParkingLotWidget* parent, const QString &
case 'E':d = E; break;
case 'W':d = W; break;
case 'S':d = S; break;
default: qDebug() << this->objectName() << "错误的方向";
default: qDebug() << this->objectName() << "错误的方向";
}
this->dir = d;
switch (this->dir)
@@ -46,7 +46,7 @@ QBoxLayout *ParkingSpaceWidget::makeParkingSapceGroup(ParkingLotWidget* parent,
ParkingSpaceWidget *pk = new ParkingSpaceWidget(parent, dir);
layout->addWidget(pk);
}
layout->addStretch(); // 居上或居左对齐
layout->addStretch(); // 居上或居左对齐
layout->setMargin(0);
layout->setSpacing(0);
return layout;
+40 -7
View File
@@ -1,17 +1,50 @@
#include "cars.h"
#include <QtGlobal>
#include <QPainter>
Cars::Cars(QWidget *parent) : QWidget(parent)
Cars::Cars(QWidget *parent, int dir, Cars::Color color) : QWidget(parent)
{
m_color = Color(rand() % 3);
resize(200, 130);
if(color==RANDOM)
color = Cars::Color(rand()%3); //车身颜色一定是确定的
m_color = color;
m_dir = dir;
m_pos = this->pos();
resize(M_WID, M_LEN);
switch (m_color) {
case Pink:
m_pixmap = QPixmap(":/cars/pink");
break;
case Red:
m_pixmap = QPixmap(":/cars/red");
break;
case Yellow:
m_pixmap = QPixmap(":/cars/yellow");
break;
default:
m_pixmap = QPixmap(":/cars/red");
break;
}
}
void Cars::paintEvent(QPaintEvent *event) {
QPainter painter(this);
QPixmap pix(":/cars/yellow");
painter.drawPixmap(0, 0, 200, 130, pix);
m_pos = this->pos();
painter.translate(M_WID/2, M_LEN/2); //转移远点,设置旋转中心
painter.rotate(m_dir); //旋转
painter.translate(-M_WID/2, -M_LEN/2); //移回远点
painter.drawPixmap(0, 0, M_WID, M_LEN, m_pixmap); //绘制小车
painter.setPen(QPen(Qt::red, 5));
painter.drawRect(0, 0, 200, 130);
painter.drawRect(0, 0, M_WID, M_LEN);
event->ignore();
}
void Cars::Forward(int vel)
{
float ang = m_dir*PI/180;
this->move(m_pos.x()+vel*sin(ang), m_pos.y()-vel*cos(ang));
}
void Cars::Backward(int vel)
{
float ang = m_dir*PI/180;
this->move(m_pos.x()-vel*sin(ang), m_pos.y()+vel*cos(ang));
}
+15 -4
View File
@@ -4,19 +4,30 @@
#include <QWidget>
#include <QPixmap>
#include <QString>
#include <QPaintEvent>
#include <QPoint>
//车身长宽
#define M_LEN (200)
#define M_WID (130)
#define PI (3.1415926f)
class Cars : public QWidget
{
Q_OBJECT
public:
enum Color { Pink, Red, Yellow };
explicit Cars(QWidget *parent = nullptr);
explicit Cars(Color color, QWidget *parenet = nullptr) {}
enum Color { Pink, Red, Yellow, RANDOM };
explicit Cars(QWidget *parent = nullptr, int dir = 0, Cars::Color color = RANDOM);
void paintEvent(QPaintEvent *event);
void Forward(int vel);
void Backward(int vel);
private:
Color m_color;
Color m_color; //车身颜色
int m_dir; //车头朝向 方向角 N为0, 顺时针递增
QPixmap m_pixmap;
QString m_number;
QPoint m_pos;
signals:
public slots:
+1 -1
View File
@@ -19,7 +19,7 @@ MainWindow::MainWindow(QWidget *parent) :
// scrollArea->resize(1800, 800);
// monitor = new Monitor(this);
// Cars *car = new Cars(this);
ParkingLotWidget *pk = new ParkingLotWidget(this, "D:\\wming\\Documents\\DataStructureProject\\parkinglot_f1.xml");
ParkingLotWidget *pk = new ParkingLotWidget(this, "parkinglot_f1.xml");
// pk->show();
// pk->creatMap();
/*QLabel *label = new QLabel(this);
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 49 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 45 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 47 KiB