4 * @author Olavi Pulkkinen <olavi.pulkkinen@fudeco.com>
5 * @copyright (c) 2010 Speed Freak team
6 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
9 #include "routedialog.h"
10 #include "ui_routedialog.h"
15 int left = 50, top = 50, right = 350, bottom = 200; // Limits in screen coordinates
16 qreal xmax, xmin, ymin, ymax; // Limits in world coordinates
18 QList<QVector3D> vertexList; // Vertecies of route
20 RouteDialog::RouteDialog(QWidget *parent) :
22 ui(new Ui::RouteDialog)
25 xmin =0.0; xmax=100.0; ymin = 0.0; ymax = 20.0;
27 vertexList.append(QVector3D(40.02, 10.02, 10.02));
28 vertexList.append(QVector3D(50.01, 5.01, 10));
29 vertexList.append(QVector3D(69.98, 4.98, 10));
30 vertexList.append(QVector3D(80.02, 9.98, 10));
31 vertexList.append(QVector3D(70.01, 15.01, 10));
32 vertexList.append(QVector3D(49.99, 14.97, 10));
33 vertexList.append(QVector3D(40.01, 10.01, 10.02));
36 RouteDialog::~RouteDialog()
41 void RouteDialog::changeEvent(QEvent *e)
43 QDialog::changeEvent(e);
45 case QEvent::LanguageChange:
46 ui->retranslateUi(this);
54 * Draws route to the route dialog
57 void RouteDialog::paintEvent(QPaintEvent *)
61 int scx1, scy1, scx2, scy2;
63 QPainter painter(this);
65 painter.setRenderHint(QPainter::Antialiasing, true);
66 painter.setPen(QPen((Qt::black),2));
67 painter.setBrush(QBrush((Qt::yellow), Qt::SolidPattern));
69 // Draw route window frsme
70 painter.drawLine(left,top,right,top);
71 painter.drawLine(right,top,right,bottom);
72 painter.drawLine(left,top,left,bottom);
73 painter.drawLine(left,bottom,right,bottom);
75 maxi = vertexList.size();
76 for (i=0; i<maxi-1; i++)
78 x1 = vertexList.at(i).x();
79 y1 = vertexList.at(i).y();
80 x2 = vertexList.at(i+1).x();
81 y2 = vertexList.at(i+1).y();
83 scx1 = left + (x1-xmin)/(xmax-xmin)*(right-left);
84 scy1 = top + (ymax-y1)/(ymax-ymin)*(bottom-top);
85 scx2 = left + (x2-xmin)/(xmax-xmin)*(right-left);
86 scy2 = top + (ymax-y2)/(ymax-ymin)*(bottom-top);
88 painter.drawLine( scx1, scy1, scx2, scy2);
92 void RouteDialog::on_closePushButton_clicked()