From 3b1d2fd5c6582960e6ef09038fa35116689266ce Mon Sep 17 00:00:00 2001 From: Olavi Pulkkinen Date: Wed, 17 Mar 2010 13:04:34 +0200 Subject: [PATCH] Added route drawing to route dialog --- Client/routedialog.cpp | 64 ++++++++++++++++++++++++++++++++++++++++++++++++ Client/routedialog.h | 1 + 2 files changed, 65 insertions(+) diff --git a/Client/routedialog.cpp b/Client/routedialog.cpp index 6290174..db05402 100644 --- a/Client/routedialog.cpp +++ b/Client/routedialog.cpp @@ -1,11 +1,36 @@ +/* + * RouteDialog class + * + * @author Olavi Pulkkinen + * @copyright (c) 2010 Speed Freak team + * @license http://opensource.org/licenses/gpl-license.php GNU Public License + */ + #include "routedialog.h" #include "ui_routedialog.h" +#include +#include +#include + +int left = 50, top = 50, right = 350, bottom = 200; // Limits in screen coordinates +qreal xmax, xmin, ymin, ymax; // Limits in world coordinates + +QList vertexList; // Vertecies of route RouteDialog::RouteDialog(QWidget *parent) : QDialog(parent), ui(new Ui::RouteDialog) { ui->setupUi(this); + xmin =0.0; xmax=100.0; ymin = 0.0; ymax = 20.0; + + vertexList.append(QVector3D(40.02, 10.02, 10.02)); + vertexList.append(QVector3D(50.01, 5.01, 10)); + vertexList.append(QVector3D(69.98, 4.98, 10)); + vertexList.append(QVector3D(80.02, 9.98, 10)); + vertexList.append(QVector3D(70.01, 15.01, 10)); + vertexList.append(QVector3D(49.99, 14.97, 10)); + vertexList.append(QVector3D(40.01, 10.01, 10.02)); } RouteDialog::~RouteDialog() @@ -25,6 +50,45 @@ void RouteDialog::changeEvent(QEvent *e) } } +/** + * Draws route to the route dialog + * @param QPaintEvent + */ +void RouteDialog::paintEvent(QPaintEvent *) +{ + int i, maxi; + qreal x1, y1, x2, y2; + int scx1, scy1, scx2, scy2; + + QPainter painter(this); + + painter.setRenderHint(QPainter::Antialiasing, true); + painter.setPen(QPen((Qt::black),2)); + painter.setBrush(QBrush((Qt::yellow), Qt::SolidPattern)); + + // Draw route window frsme + painter.drawLine(left,top,right,top); + painter.drawLine(right,top,right,bottom); + painter.drawLine(left,top,left,bottom); + painter.drawLine(left,bottom,right,bottom); + + maxi = vertexList.size(); + for (i=0; i