-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunits.cpp
133 lines (129 loc) · 4.62 KB
/
units.cpp
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#define STRICT
#include <windows.h>
#include "dxw.h"
#include "gauge.h"
#define NOMATCH (0xFFFF)
static WPARAM
FindString(HWND hDlg, char* str) {
WPARAM Index;
long res = SendDlgItemMessage(hDlg, IDC_UN_LIST, LB_GETCOUNT, 0, 0);
if (res == LB_ERR) return NOMATCH;
for (Index = 0; Index < (WPARAM) res; ++Index) {
SendDlgItemMessage(hDlg, IDC_UN_LIST, LB_GETTEXT, Index, (LPARAM) (LPSTR) buf);
if (!strcmp(buf, str)) return Index;
}
return NOMATCH;
}
//ARGSUSED
DLG_PROC(UnitProc) {
//static Gauge*G=nullptr;
WPARAM Index;
switch (msg) {
case WM_INITDIALOG:
SendDlgItemMessage(hDlg, IDC_UN_N_UN, CB_ADDSTRING, 0, (LPARAM) (LPSTR) "atm");
SendDlgItemMessage(hDlg, IDC_UN_N_UN, CB_ADDSTRING, 0, (LPARAM) (LPSTR) "bar");
SendDlgItemMessage(hDlg, IDC_UN_N_UN, CB_ADDSTRING, 0, (LPARAM) (LPSTR) "Pa");
SendDlgItemMessage(hDlg, IDC_UN_N_UN, CB_ADDSTRING, 0, (LPARAM) (LPSTR) "V");
SetDlgItemText(hDlg, IDC_UN_O_UN, ((Gauge*) lParam)->unit);
SetDlgItemText(hDlg, IDC_UN_N_UN, ((Gauge*) lParam)->unit);
SetDlgItemText(hDlg, IDC_UN_O_RT, "1");
SetDlgItemText(hDlg, IDC_UN_N_RT, "1");
SetDlgItemText(hDlg, IDC_UN_O_SH, "0");
SetDlgItemText(hDlg, IDC_UN_N_SH, "0");
{
for (auto G : GaugeIterator()) {
if (!lstrcmp(G->unit, ((Gauge*) lParam)->unit)) SendDlgItemMessage(hDlg, IDC_UN_LIST, LB_ADDSTRING, 0, (LPARAM) (LPSTR) (G->ChNum));
}
}
Index = FindString(hDlg, ((Gauge*) lParam)->ChNum);
if (Index != NOMATCH)
SendDlgItemMessage(hDlg, IDC_UN_LIST, LB_SETSEL, TRUE, MAKELPARAM(Index, 0));
return TRUE;
case WM_COMMAND:
switch (wParam) {
case IDC_UN_ALL: {
SendDlgItemMessage(hDlg, IDC_UN_LIST, LB_SELITEMRANGE, TRUE, MAKELPARAM(0, Gauge::nGauges - 1));
} break;
case IDOK: {
double nr = 1, or_ = 1, ns = 0, os = 0;
GetDlgItemDouble(hDlg, IDC_UN_N_RT, nr);
GetDlgItemDouble(hDlg, IDC_UN_O_RT, or_);
GetDlgItemDouble(hDlg, IDC_UN_N_SH, ns);
GetDlgItemDouble(hDlg, IDC_UN_O_SH, os);
{
for (auto G : GaugeIterator()) {
Index = FindString(hDlg, G->ChNum);
if (Index == NOMATCH) continue;
if (SendDlgItemMessage(hDlg, IDC_UN_LIST, LB_GETSEL, Index, 0) > 0) {
G->V0 -= G->Zero_corr;
G->Zero_corr = 0;
G->dV = G->dV * nr / or_;
G->V0 = (G->V0 - os) * nr / or_ + ns;
if (G->m_Upper != G->m_Lower) {
G->m_Lower = (G->m_Lower - os) * nr / or_ + ns;
G->m_Upper = (G->m_Upper - os) * nr / or_ + ns;
if (G->m_Lower > G->m_Upper) {
double tmp = G->m_Lower;
G->m_Lower = G->m_Upper;
G->m_Upper = tmp;
}
}
GetDlgItemText(hDlg, IDC_UN_N_UN, G->unit, 4);
G->FreeI();
G->Redraw();
Changed = 1;
}
}
} //endfor
}
case IDCANCEL:
EndDialog(hDlg, wParam);
break;
}
return TRUE;
}
return FALSE;
}
//ARGSUSED
DLG_PROC(TShiftProc) {
WPARAM Index;
switch (msg) {
case WM_INITDIALOG:
SetDlgItemText(hDlg, IDC_TS_VAL, "0");
{
for (auto G : GaugeIterator()) {
SendDlgItemMessage(hDlg, IDC_TS_LIST, LB_ADDSTRING, 0, (LPARAM) (LPSTR) (G->ChNum));
}
}
Index = (WPARAM) SendDlgItemMessage(hDlg, IDC_TS_LIST, LB_FINDSTRING, 0, (LPARAM) (LPSTR) (((Gauge*) lParam)->ChNum));
SendDlgItemMessage(hDlg, IDC_TS_LIST, LB_SETSEL, TRUE, MAKELPARAM(Index, 0));
return TRUE;
case WM_COMMAND:
switch (wParam) {
case IDC_TS_ALL: {
SendDlgItemMessage(hDlg, IDC_TS_LIST, LB_SELITEMRANGE, TRUE, MAKELPARAM(0, Gauge::nGauges - 1));
} break;
case IDOK: {
double shift = 0;
GetDlgItemDouble(hDlg, IDC_TS_VAL, shift);
{
for (auto G : GaugeIterator()) {
long res = SendDlgItemMessage(hDlg, IDC_TS_LIST, LB_FINDSTRING, 0, (LPARAM) (LPSTR) (G->ChNum));
if (res == LB_ERR) continue;
Index = (WPARAM) res;
if (SendDlgItemMessage(hDlg, IDC_TS_LIST, LB_GETSEL, Index, 0) > 0) {
for (auto& P : G->Rates) P.Tstart += shift;
G->Redraw();
Changed = 1;
}
}
} //endfor
}
case IDCANCEL:
EndDialog(hDlg, wParam);
break;
}
return TRUE;
}
return FALSE;
}