可以根据要求定制对象的显示(颜色和厚度)。按以下要求:
下面是一个实现 onUpdateObject 的例子,通过这个例子,管道的颜色会根据压力而改变,管道的厚度会根据质量流量而改变:
procedure onUpdateObject(obj:ebsobject);
var
pipe:ebspipe;
mass:real;
pressure:real;
width:integer;
color:integer;
begin
pipe := ebspipe(obj);if isKindOf( pipe, "ebspipewater" ) or isKindOf( pipe, "ebspipesteam" ) then
beginpressure:=pipe.p;if isKindOf( pipe, "ebspipewater" ) then
beginif pressure < 1 then color := $ffa0a0 elseif pressure < 5 then color := $ff8080 elseif pressure < 10 then color := $ff4040 elseif pressure < 40 then color := $ff0000 elseif pressure < 100 then color := $d00000 elsecolor := $a00000;end else
beginif pressure < 1 then color := $a0a0ff elseif pressure < 5 then color := $8080ff elseif pressure < 10 then color := $4040ff elseif pressure < 40 then color := $0000ff elseif pressure < 100 then color := $0000d0 elsecolor := $0000a0;end;pipe.color:=color;
mass:=pipe.m;if mass < 10 then width := 1 elseif mass < 30 then width := 2 elseif mass < 60 then width := 3 elseif mass < 100 then width := 4 elseif mass < 150 then width := 5 elseif mass < 200 then width := 6 elseif mass < 300 then width := 7 elseif mass < 400 then width := 8 elseif mass < 500 then width := 9 elsewidth := 10;pipe.width:=width;end;
end;