-
Notifications
You must be signed in to change notification settings - Fork 0
/
ULine.pas
executable file
·231 lines (194 loc) · 5.43 KB
/
ULine.pas
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
unit ULine;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
UEmbedForm, StdCtrls, ExtCtrls,
tc, Grids;
type
TFLine = class(TEmbedForm)
Panel4: TPanel;
Label1: TLabel;
Panel1: TPanel;
Label5: TLabel;
MaterialBox: TComboBox;
Panel3: TPanel;
grid: TStringGrid;
Label2: TLabel;
Panel2: TPanel;
Bevel1: TBevel;
Label3: TLabel;
Panel5: TPanel;
procedure FormCreate(Sender: TObject);
procedure gridKeyPress(Sender: TObject; var Key: Char);
public
procedure RefreshMaterialBox;
procedure Load(Line : TAssembleLine);
procedure Save(Line : TAssembleLine);
procedure SetPartCapacity(value : massa);
function GetPartCapacity : massa;
procedure SetMinPart(value : massa);
function GetMinPart : massa;
procedure SetMaterialType(value : integer);
function GetMaterialType : integer;
property PartCapacity : massa read GetPartCapacity write SetPartCapacity;
property MinPart : massa read GetMinPart write SetMinPart;
property MaterialType : integer read GetMaterialType write SetMaterialType;
end;
var
FLine: TFLine;
implementation
Uses Umassa, UModel;
var
FPartCapacity : TFMassa;
FMinPart : TFMassa;
NoMaterials : TLabel;
{$R *.DFM}
procedure TFLine.FormCreate(Sender: TObject);
begin
inherited;
Panel1.BorderStyle := bsNone;
Panel5.BorderStyle := bsNone;
NoMaterials := TLabel.Create(self);
FPartCapacity := TFMassa.CreateEmbedded(self, Panel1);
FPartCapacity.show;
FMinPart := TFMassa.CreateEmbedded(self, Panel5);
FMinPart.show;
end;
function TFLine.GetMaterialType: integer;
begin
with MaterialBox do
if ItemIndex = -1 then result := -1
else
result := (Items.Objects[ItemIndex] as TMaterial).Number;
end;
function TFLine.GetPartCapacity: massa;
begin
result := FPartCapacity.Number;
end;
procedure TFLine.Load(Line: TAssembleLine);
var
list : TObjectArray;
row, col : integer;
t : time;
begin
list := FModel.Model.Materials.List;
if Length(List) = 0 then
begin
NoMaterials := TLabel.Create(self);
with NoMaterials do
begin
Visible := false;
Parent := Panel3;
Caption := mNoMaterials;
Font.Color := clWhite;
Font.Style := [fsBold];
AutoSize := false;
Align := alClient;
Alignment := taCenter;
Layout := tlCenter;
Show;
end;
grid.hide;
exit;
end
else
begin
NoMaterials.Hide;
grid.show;
end;
// óñòàíàâëèâàåì ðàçìåðíîñòü ñåòêè
grid.cells[0,0] := '(Òèïû ñûðüÿ)';
grid.ColCount := Length(list) + 1;
grid.RowCount := Length(list) + 1;
grid.FixedCols := 1;
grid.FixedRows := 1;
grid.ColWidths[0] := 150;
// çàïîëíÿåì çàãîëîâêè
for row := Low(list) to high(List) do
begin
grid.Cells[0,row + 1] := (List[row] as TMaterial).Name;
grid.Cells[row + 1,0] := (List[row] as TMaterial).Name;
end;
// çàãðóæàåì çíà÷åíèÿ
PartCapacity := Line.PartCapacity;
MinPart := Line.MinPart;
MaterialType := Line.CurMaterialType;
for row := Low(list) to high(list) do
for col := Low(list) to high(list) do
begin
t := Line.FReconfigure.GetReconfTime(
(List[row] as TMaterial).number,
(List[col] as TMaterial).number);
if (abs(t + 1) > eps) then t := t / 3600;
grid.Cells[row + 1, col + 1] := FloatToStr(t);
end;
end;
procedure TFLine.Save(Line: TAssembleLine);
var
list : TObjectArray;
row, col : integer;
t : time;
begin
Line.PartCapacity := PartCapacity;
Line.MinPart := MInPart;
Line.CurMaterialType := MaterialType;
list := FModel.Model.Materials.List;
for row := Low(list) to high(list) do
for col := Low(list) to high(list) do
begin
t := StrToFloat(grid.cells[row + 1, col + 1]);
if abs(t + 1) > eps then t := t * 3600;
Line.FReconfigure.SetReconfTime(
(List[row] as TMaterial).number,
(List[col] as TMaterial).number, t);
end;
end;
procedure TFLine.SetPartCapacity(value: massa);
begin
FPartCapacity.Number := value;
end;
procedure TFLine.SetMaterialType(value: integer);
begin
RefreshMaterialBox;
MaterialBox.ItemIndex := FModel.Model.Materials.FindByNumber(value);
end;
procedure TFLine.RefreshMaterialBox;
var
i : integer;
begin
MaterialBox.Clear;
with FModel.Model.Materials do
for i := Low(List) to high(List) do
MaterialBox.Items.AddObject(List[i].Name, List[i]);
end;
procedure TFLine.gridKeyPress(Sender: TObject; var Key: Char);
var
t : real;
e : ENotFloat;
begin
inherited;
if (grid.row = grid.col) or
not (
(key in ['0'..'9']) or
(key = #8) or
(key = '-') or
(key = ',')
)
then key := #27;
// try
// t := StrToFloat(grid.cells[grid.row, grid.col]);
// if (t < 0) and not(abs(t + 1) > eps) then
// raise e.Create;
// except
// MessageDlg(e.Message , mtError, [mbOk], 0);
// end;
end;
function TFLine.GetMinPart: massa;
begin
result := FMinPart.Number;
end;
procedure TFLine.SetMinPart(value: massa);
begin
FMinPart.Number := value;
end;
end.