#include <QPainter>
#include <QPicture>
#include <QDebug>
-#include <QDesktopServices>
-#include <QUrl>
const int DIAGRAM_WIDTH = 400;
const int DIAGRAM_HEIGHT = 300;
/**
* Constructor of this class.
+ *
* @param QWidget pointer to parent object. By default the value is NULL.
*/
ResultDialog::ResultDialog(QWidget *parent) :
delete ui;
}
+/**
+ *
+ */
void ResultDialog::changeEvent(QEvent *e)
{
QDialog::changeEvent(e);
/**
* Draws speed diagram to the UI
+ *
* @param QPaintEvent
*/
void ResultDialog::paintEvent(QPaintEvent *)
{
setHeaders();
- //Create Pixmap, where image will be draw
- QPixmap image(ui->scrollArea->width(), ui->scrollArea->height()/*DIAGRAM_WIDTH+100, DIAGRAM_HEIGHT+70*/);
-
- //Create painter and give paramemeter where image will be draw
- QPainter painter(&image);
- painter.setPen(Qt::white);
- painter.setBrush(Qt::white);
- painter.drawRect(QRect(0, 0, ui->scrollArea->width(), ui->scrollArea->height()/*DIAGRAM_WIDTH+100, DIAGRAM_HEIGHT+70*/));
-
+ QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setPen(QPen((Qt::gray),2));
fontForResult.setPixelSize(50);
painter.setFont(fontForResult);
- painter.drawText(diagramStemStart.x() + 30, diagramStemStart.y() - 150, resultString);
+ painter.drawText(diagramStemStart.x() + 50, diagramStemStart.y() - 150, resultString);
painter.setFont(font);
painter.setPen(QPen((Qt::darkCyan),2));
{
painter.drawPolyline(points, pointsToShow);
}
- //Save image in file acceleration.png
- image.save("acceleration.png", 0, -1);
-
- //Create label
- QLabel *imageLabel = new QLabel(this);
-
- //Set image pixmap to label
- imageLabel->setPixmap(image);
-
- //Set image label to scrollArea
- ui->scrollArea->setWidget(imageLabel);
-
}
/**
* Change the given speed and time to the point for the diagram.
+ *
* @param aSpeed is speed which need to change, aTime is time in seconds which need to change.
* @return point is calculated from aSpeed and aTime.
*/
void ResultDialog::setTimesIntoLabels()
{
QString time, timeInteger;
- timeInteger.setNum(timeArray[4]);
+ timeInteger.sprintf("%.2f", timeArray[4]);
time = "0 - 40 km/h: ";
time.append(timeInteger);
ui->labelResult40kmh->setText(time);
- timeInteger.setNum(timeArray[3]);
+ timeInteger.sprintf("%.2f", timeArray[3]);
time = "0 - 30 km/h: ";
time.append(timeInteger);
ui->labelResult30kmh->setText(time);
- timeInteger.setNum(timeArray[2]);
+ timeInteger.sprintf("%.2f", timeArray[2]);
time = "0 - 20 km/h: ";
time.append(timeInteger);
ui->labelResult20kmh->setText(time);
- timeInteger.setNum(timeArray[1]);
+ timeInteger.sprintf("%.2f", timeArray[1]);
time = "0 - 10 km/h: ";
time.append(timeInteger);
ui->labelResult10kmh->setText(time);
- timeInteger.setNum(timeArray[6]);
+ timeInteger.sprintf("%.2f", timeArray[6]);
time = "0 - 60 km/h: ";
time.append(timeInteger);
ui->labelResult60kmh->setText(time);
- timeInteger.setNum(timeArray[5]);
+ timeInteger.sprintf("%.2f", timeArray[5]);
time = "0 - 50 km/h: ";
time.append(timeInteger);
ui->labelResult50kmh->setText(time);
- timeInteger.setNum(timeArray[7]);
+ timeInteger.sprintf("%.2f", timeArray[7]);
time = "0 - 70 km/h: ";
time.append(timeInteger);
ui->labelResult70kmh->setText(time);
- timeInteger.setNum(timeArray[8]);
+ timeInteger.sprintf("%.2f", timeArray[8]);
time = "0 - 80 km/h: ";
time.append(timeInteger);
ui->labelResult80kmh->setText(time);
- timeInteger.setNum(timeArray[9]);
+ timeInteger.sprintf("%.2f", timeArray[9]);
time = "0 - 90 km/h: ";
time.append(timeInteger);
ui->labelResult90kmh->setText(time);
- timeInteger.setNum(timeArray[10]);
+ timeInteger.sprintf("%.2f", timeArray[10]);
time = "0 - 100 km/h: ";
time.append(timeInteger);
ui->labelResult100kmh->setText(time);
/**
* Sets right timeAxelLength value depending the time which
* has spent to reach target speed.
+ *
+ * @param int choice
*/
void ResultDialog::setTimeAxelLength(int pChoice)
{
emit sendresult(timeArray[this->getTargetChoice()]);
}
+/**
+ * Get result.
+ *
+ * @return double result.
+ */
double ResultDialog::getResult()
{
return timeArray[this->getTargetChoice()];
/**
* This public function sets diagram's stem gap
+ *
* @param pValue is the speed value which determines diagram gap's value
*/
void ResultDialog::setEnd(int pValue)
/**
* This public function stores time in timeArray
+ *
* @param pSpeed is the speed value at the time so we know where store time
* @param pTime is the result which needs to be store in timeArray
*/
/**
* Checks which target speed has been choosed
+ *
* @return targetChoice which tells to caller integer value about the target speed
- * e.g. 20 km/h is value 2 and 60 km/h is value 6
+ * e.g. 20 km/h is value 2 and 60 km/h is value 6
*/
int ResultDialog::getTargetChoice()
{
}
return targetChoice;
}
-
+/**
+ * Set label info to user.
+ *
+ * @param QString info text
+ */
void ResultDialog::setLabelInfoToUser(QString infoText)
{
this->ui->labelInfoToUser->setText(infoText);
helpAccelerationDialog = NULL;
}
}
-/**
- * This slot function opens E-mail application with attachment file
- * (acceleration.png). Image of resultdialog
- */
-
-void ResultDialog::on_pushButtonEMail_clicked()
-{
- QDesktopServices::openUrl(QUrl("mailto:name@domain.com?Subject=Acceleration Result&Body=Hi, Here are my acceleration result!&Attachment=acceleration.png"));
-}