-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcolorChanged.cpp
More file actions
43 lines (40 loc) · 1.47 KB
/
colorChanged.cpp
File metadata and controls
43 lines (40 loc) · 1.47 KB
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
#include "mainwindow.h"
#include "resval.h"
#include "ui_ResCalc.h"
void MainWindow::colorChanged(int band)
{
float res = resVal.resGet(); //Holds the resistance value
int nBands = ui->NBand_slider->value(); //Holds the number of bands currently in use
if (band < 4 || (band == 4 && nBands > 4))
{
//Updates the resistance values in the screen
if (res >= 1000000000)
{
ui->resValDisp->setValue(res /= 1000000000); //Sets the value of the resistor
ui->resValDispMult->setText("GOhm"); //Sets the multiple in Ohms
}
else if (res >= 1000000)
{
ui->resValDisp->setValue(res /= 1000000); //Sets the value of the resistor
ui->resValDispMult->setText("MOhm"); //Sets the multiple in Ohms
}
else if (res >= 1000)
{
ui->resValDisp->setValue(res /= 1000); //Sets the value of the resistor
ui->resValDispMult->setText("kOhm"); //Sets the multiple in Ohms
}
else
{
ui->resValDisp->setValue(res); //Sets the value of the resistor
ui->resValDispMult->setText("Ohm"); //Sets the multiple in Ohms
}
}
else if ((band == 4 && nBands < 5) || (band == 5 && nBands > 4))
{
ui->tolValDisp->setValue(resVal.tolGet()); //Updates the tolerance value
}
else if (band == 6)
{
ui->tCoefValDisp->setValue(resVal.tempCoefGet()); //Updates the temperature coeficient value
}
}