File: form.cpp

package info (click to toggle)
dlt-viewer 2.23.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 7,432 kB
  • sloc: cpp: 27,832; ansic: 4,454; xml: 491; sh: 154; makefile: 75
file content (94 lines) | stat: -rw-r--r-- 2,243 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/**
 * @licence app begin@
 * Copyright (C) 2011-2012  BMW AG
 *
 * This file is part of COVESA Project Dlt Viewer.
 *
 * Contributions are licensed to the COVESA Alliance under one or more
 * Contribution License Agreements.
 *
 * \copyright
 * This Source Code Form is subject to the terms of the
 * Mozilla Public License, v. 2.0. If a  copy of the MPL was not distributed with
 * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * \file form.cpp
 * For further information see http://www.covesa.global/.
 * @licence end@
 */

#include "form.h"
#include "ui_form.h"


//using namespace DltSpeedPlugin;

Form::Form(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Form)
{
    ui->setupUi(this);

    dataArray = new QwtPointArrayData(timeY,speedX);

    ui->qwtPlot->setTitle("MySpeedPlugin");

    ui->qwtPlot->setAxisScale(0,0,100);

    //ui->thermo->setMaximumHeight(100);
    //ui->thermo->setMinimumHeight(0);

    curve1 = new QwtPlotCurve("Curve 1");
    curve1->attach(ui->qwtPlot);

    QwtLinearColorMap * colorMap = new QwtLinearColorMap(Qt::green, Qt::red);
    colorMap->addColorStop(0, Qt::green);
    colorMap->addColorStop(80, Qt::red);
    ui->thermo->setColorMap(colorMap);
}

Form::~Form()
{
    delete ui;
}


void Form::setSpeedGraph(QDltArgument currentSpeed,unsigned int time)
{
    // Push data for speed and time to container
    speedX.push_back(currentSpeed.toString().toDouble());
    timeY.push_back((double)time);

    // Set currentSpeed to lcdNumber
    //ui->lcdNumber->display(currentSpeed.toString());

    // Copy the data into the curves
    dataArray = new QwtPointArrayData(timeY,speedX);
    curve1->setData(dataArray);

    // Change color if value is bigger than 80
    if(currentSpeed.toString().toDouble()<80)
    {
        curve1->setPen(QPen(Qt::green, 1));
    }
    else
    {
        curve1->setPen(QPen(Qt::red, 1));
    }


    //ui->thermo->setValue(currentSpeed.toString().toDouble());

    // Replot curve
    ui->qwtPlot->replot();

}

void Form::setSpeedLCD(QDltArgument currentSpeed,unsigned int time)
{
    // Set currentSpeed to lcdNumber
    ui->lcdNumber->display(currentSpeed.toString());

    ui->thermo->setValue(currentSpeed.toString().toDouble());
}