ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/JDesigner/ufEdgeProp.pas
Revision: 1.1.1.1 (vendor branch)
Committed: Mon Dec 10 19:29:12 2001 UTC (14 years, 11 months ago) by hsauro
Branch: MAIN, hsauro
CVS Tags: V10, HEAD_NEW, HEAD
Changes since 1.1: +0 -0 lines
Log Message:
no message

Line File contents
1 unit ufEdgeProp;
2
3 interface
4
5 uses
6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7 uEdgeList, uNetwork, ExtCtrls, StdCtrls, Grids, Fssexpr, ComCtrls, Aligrid,
8 ColCombo, Spin;
9
10 type
11 TfrmEdgeProp = class(TForm)
12 pnlBottom: TPanel;
13 BtnOK: TButton;
14 BtnCancel: TButton;
15 expr: TAlgExpression;
16 PageControl: TPageControl;
17 tsStoichiometry: TTabSheet;
18 Label1: TLabel;
19 EdtName: TEdit;
20 chkReversible: TCheckBox;
21 ReactantGrid: TStringGrid;
22 Label2: TLabel;
23 Label4: TLabel;
24 ProductGrid: TStringGrid;
25 Label3: TLabel;
26 Label5: TLabel;
27 tsRateLaw: TTabSheet;
28 EdtRatelaw: TEdit;
29 Label6: TLabel;
30 Label7: TLabel;
31 Label8: TLabel;
32 StringGrid: TStringAlignGrid;
33 tbsDisplay: TTabSheet;
34 Label9: TLabel;
35 cbEdgeColour: TColorCombo;
36 Label10: TLabel;
37 cbFillColour: TColorCombo;
38 Label11: TLabel;
39 spArcThickness: TSpinEdit;
40 lblFlux: TLabel;
41 procedure FormShow(Sender: TObject);
42 procedure EdtRatelawExit(Sender: TObject);
43 procedure FormCreate(Sender: TObject);
44 procedure StringGridAfterEdit(Sender: TObject; col, row: Integer);
45 procedure tsRateLawShow(Sender: TObject);
46 procedure chkReversibleClick(Sender: TObject);
47 private
48 { Private declarations }
49 public
50 { Public declarations }
51 Edge : TEdge;
52 Network : TNetwork;
53 procedure BuildParameterTable();
54 end;
55
56 var
57 frmEdgeProp: TfrmEdgeProp;
58
59 implementation
60
61 {$R *.DFM}
62
63 procedure TfrmEdgeProp.FormShow(Sender: TObject);
64 var i, nReactants, nProducts : integer;
65 begin
66 EdtName.Text := Edge.Name;
67 EdtRateLaw.Text := Edge.RateLaw;
68 nReactants := Edge.srcConnectedNodeList.Count;
69 nProducts := Edge.destConnectedNodeList.Count;
70 chkReversible.Checked := Edge.Reversible;
71
72 ReactantGrid.RowCount := nReactants;
73 ProductGrid.RowCount := nProducts;
74
75 for i := 0 to nReactants - 1 do
76 begin
77 ReactantGrid.Cells[1, i] := IntToStr (Edge.srcConnectedNodeList[i].Stoich);
78 ReactantGrid.Cells[0, i] := Edge.srcConnectedNodeList[i].SubNode.ParentNode.Name;
79 end;
80
81 for i := 0 to nProducts - 1 do
82 begin
83 ProductGrid.Cells[1, i] := IntToStr (Edge.destConnectedNodeList[i].Stoich);
84 ProductGrid.Cells[0, i] := Edge.destConnectedNodeList[i].SubNode.ParentNode.Name;
85 end;
86 end;
87
88
89 procedure TfrmEdgeProp.BuildParameterTable();
90 var i, n, nodeId : integer;
91 begin
92 n := expr.getnSymbols();
93 for i := 1 to n do
94 begin
95 StringGrid.Cells[0,i] := expr.GetnthSymbol (i);
96 nodeId := Network.FindNode (expr.GetnthSymbol (i));
97 if nodeId = -1 then
98 StringGrid.Cells[1,i] := floattostr (expr.getVar (expr.GetnthSymbol (i)))
99 else
100 begin
101 expr.SetVar (expr.GetnthSymbol (i), Network.NodeList[nodeId].value);
102 StringGrid.Cells[1,i] := floattostr (Network.NodeList[nodeId].value);
103 end;
104 end;
105 StringGrid.Row := 1;
106 StringGrid.Col := 1;
107 end;
108
109
110 procedure TfrmEdgeProp.EdtRatelawExit(Sender: TObject);
111 begin
112 expr.Clear;
113 if expr.Check (EdtRateLaw.Text) = eAlgOK then
114 BuildParameterTable();
115 end;
116
117
118 procedure TfrmEdgeProp.FormCreate(Sender: TObject);
119 begin
120 StringGrid.Cells[0,0] := 'Symbol Name';
121 StringGrid.Cells[1,0] := 'Value';
122 StringGrid.Ctl3D := False;
123 end;
124
125 procedure TfrmEdgeProp.StringGridAfterEdit(Sender: TObject; col,
126 row: Integer);
127 begin
128 expr.SetVar (StringGrid.Cells[0,row], strtofloat (StringGrid.Cells[col,row]));
129 end;
130
131 procedure TfrmEdgeProp.tsRateLawShow(Sender: TObject);
132 var i : integer; str : string;
133 begin
134 lblFlux.caption := Edge.Name;
135
136 if (Edge.RateLaw = 'v') then
137 begin
138 // Pretty basic equation constructor, needs MORE WORK!
139 str := 'k*';
140 for i := 0 to Edge.srcConnectedNodeList.Count - 1 do
141 begin
142 str := str + Edge.srcConnectedNodeList[i].SubNode.ParentNode.Name;
143 if i < Edge.srcConnectedNodeList.Count - 1 then
144 str := str + '*';
145 end;
146 if Edge.Reversible then
147 begin
148 str := str + ' - k*';
149 for i := 0 to Edge.destConnectedNodeList.Count - 1 do
150 begin
151 str := str + Edge.destConnectedNodeList[i].SubNode.ParentNode.Name;
152 if i < Edge.destConnectedNodeList.Count - 1 then
153 str := str + '*';
154 end;
155 end;
156 Edge.RateLaw := str;
157 EdtRateLaw.Text := Edge.RateLaw;
158 end;
159 end;
160
161 procedure TfrmEdgeProp.chkReversibleClick(Sender: TObject);
162 begin
163 Edge.Reversible := chkReversible.Checked;
164 end;
165
166 end.