-
Notifications
You must be signed in to change notification settings - Fork 0
/
UMain.pas
executable file
·289 lines (258 loc) · 7.25 KB
/
UMain.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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
unit UMain;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Menus, ActnList,
tc, ToolWin, ComCtrls, ExtCtrls, StdCtrls, shellapi;
type
TMain = class(TForm)
MainMenu1: TMainMenu;
NFile: TMenuItem;
Nexit: TMenuItem;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
ActionList1: TActionList;
AExit: TAction;
NParams: TMenuItem;
NLines: TMenuItem;
AModel: TAction;
N4: TMenuItem;
N5: TMenuItem;
N6: TMenuItem;
N7: TMenuItem;
AAbout: TAction;
AHelp: TAction;
ControlBar1: TControlBar;
N8: TMenuItem;
N9: TMenuItem;
N10: TMenuItem;
ALinesReport: TAction;
AModelReport: TAction;
ToolBar1: TToolBar;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
ToolButton3: TToolButton;
ToolButton4: TToolButton;
ToolButton5: TToolButton;
ToolButton6: TToolButton;
ToolButton7: TToolButton;
ASolve: TAction;
N11: TMenuItem;
N12: TMenuItem;
ToolButton8: TToolButton;
ToolButton9: TToolButton;
N13: TMenuItem;
StatusBar1: TStatusBar;
N14: TMenuItem;
N15: TMenuItem;
AReconfReport: TAction;
AMaterialsReport: TAction;
N16: TMenuItem;
ALoad: TAction;
ASave: TAction;
ABunkersReport: TAction;
N17: TMenuItem;
ToolButton10: TToolButton;
AWorkGraphs: TAction;
N18: TMenuItem;
Areconflist: TAction;
N19: TMenuItem;
AOptimize: TAction;
N20: TMenuItem;
AOptParams: TAction;
N21: TMenuItem;
N22: TMenuItem;
procedure AExitExecute(Sender: TObject);
procedure AModelExecute(Sender: TObject);
procedure ALinesReportExecute(Sender: TObject);
procedure AModelReportExecute(Sender: TObject);
procedure ASolveExecute(Sender: TObject);
procedure ABunkersReportExecute(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormPaint(Sender: TObject);
procedure ALoadExecute(Sender: TObject);
procedure ASaveExecute(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure AMaterialsReportExecute(Sender: TObject);
procedure AAboutExecute(Sender: TObject);
procedure AWorkGraphsExecute(Sender: TObject);
procedure AreconflistExecute(Sender: TObject);
procedure AHelpExecute(Sender: TObject);
procedure AOptimizeExecute(Sender: TObject);
procedure AOptParamsExecute(Sender: TObject);
private
procedure SHint(Sender : TObject);
public
procedure RefreshCapt;
end;
var
Main: TMain;
implementation
uses UModel, UResultReport, UModelReport, UBunkersReport, UMaterialReport,
UAbout, UWorkGraphs, UReconfList, UOpt, UOptParams;
{$R *.DFM}
procedure TMain.AExitExecute(Sender: TObject);
begin
close;
end;
procedure TMain.AModelExecute(Sender: TObject);
begin
FModel.ShowModal;
end;
procedure TMain.ALinesReportExecute(Sender: TObject);
begin
if assigned(ResultReport) then ResultReport.free;
ResultReport := TResultReport.Create(nil);
ResultReport.Model := FModel.ModelCopy;
ResultReport.loadFromModel;
ResultReport.Update;
ResultReport.Preview;
end;
procedure TMain.AModelReportExecute(Sender: TObject);
begin
FModel.APrintExecute(nil);
end;
procedure TMain.ASolveExecute(Sender: TObject);
var
p : TProgressBar;
begin
try
Screen.Cursor := crHourGlass;
p := TProgressBar.Create(nil);
p.Smooth := true;
p.Parent := StatusBar1;
p.top := 4;
p.left := 254;
p.height := 15;
p.visible := true;
StatusBar1.Update;
with FModel do
begin
ModelCopy.LoadFromModel(Model);
ModelCopy.Solve(p);
end;
finally
Screen.Cursor := crDefault;
if assigned(p) then p.free;
end;
end;
procedure TMain.ABunkersReportExecute(Sender: TObject);
begin
if assigned(BunkersReport) then BunkersReport.free;
BunkersReport := TBunkersReport.Create(nil);
BunkersReport.Model := FModel.ModelCopy;
BunkersReport.loadFromModel;
BunkersReport.Update;
BunkersReport.Preview;
end;
procedure TMain.FormActivate(Sender: TObject);
begin
// ToolBar1.ButtonHeight := MenuBar1.Height;
end;
procedure TMain.FormCreate(Sender: TObject);
begin
Application.OnHint := SHint;
end;
procedure TMain.SHint;
begin
StatusBar1.Panels[0].Text := Application.Hint;
FModel.Status.Panels[0].Text := Application.Hint;
end;
procedure TMain.FormPaint(Sender: TObject);
begin
RefreshCapt;
end;
procedure TMain.RefreshCapt;
begin
Caption := CAPT + ' - ' + FModel.ModelName;
end;
procedure TMain.ALoadExecute(Sender: TObject);
begin
FModel.ALoadExecute(Sender);
RefreshCapt;
end;
procedure TMain.ASaveExecute(Sender: TObject);
begin
FModel.ASaveExecute(Sender);
RefreshCapt;
end;
procedure TMain.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if FModel.Modified then
if MessageDlg('Ñîõðàíèòü ìîäåëü?', mtConfirmation, [mbYes, mbNo], 0) = mrYes then
ASaveExecute(self);
end;
procedure TMain.AMaterialsReportExecute(Sender: TObject);
begin
if assigned(MaterialsReport) then MaterialsReport.free;
MaterialsReport := TMaterialsReport.Create(nil);
with MaterialsReport do
begin
Model := FModel.ModelCopy;
LoadFromModel;
Update;
Preview;
end;
end;
procedure TMain.AAboutExecute(Sender: TObject);
begin
FAbout.ShowModal;
end;
procedure TMain.AWorkGraphsExecute(Sender: TObject);
begin
FWorkGraphs.Model := FModel.ModelCopy;
FWorkGraphs.ShowModal;
end;
procedure TMain.AreconflistExecute(Sender: TObject);
begin
FReconfList.Model := FModel.Model;
FReconflist.ShowModal;
end;
procedure TMain.AHelpExecute(Sender: TObject);
begin
ShellExecute(Handle, PChar('open'), 'Ðóêîâîäñòâî ïîëüçîâàòåëÿ.doc', '', '', SW_SHOWMAXIMIZED);
end;
procedure TMain.AOptimizeExecute(Sender: TObject);
var
m : TMemoryStream;
begin
// Îïòèìèçàöèÿ ãðàôèêà ïåðåíàñòðîåê ëèíèé îáðàáîòêè çåðíà
if (MessageDlg('Ïîñëå îïòèìèçàöèè ãðàôèê ïåðåíàñòðîåê áóäåò èçìåíåí. Ïðîäîëæèòü?', mtConfirmation, [mbYes, mbNo], 0) = mrYes) then
begin
try
Screen.Cursor := crHourGlass;
FOpt.Show;
// p := TProgressBar.Create(nil);
// p.Smooth := true;
// p.Parent := StatusBar1;
// p.top := 4;
// p.left := 254;
// p.height := 15;
// p.visible := true;
// StatusBar1.Update;
with FModel do
begin
ModelCopy.LoadFromModel(Model);
ModelCopy.Optimize(FOpt);
m := TMemoryStream.Create;
ModelCopy.ReconfList.Save(m);
Model.ReconfList.Clear;
m.Seek(0, soFromBeginning);
Model.ReconfList.Load(m);
end;
finally
Screen.Cursor := crDefault;
FOpt.Close;
m.free;
// if assigned(p) then p.free;
end;
end;
end;
procedure TMain.AOptParamsExecute(Sender: TObject);
begin
FOptParams.M := FModel.Model;
FOptParams.ShowModal;
end;
end.