531 lines
19 KiB
ObjectPascal
Raw Permalink Blame History

unit Uedit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, ExtCtrls,
UDessin, UDessinComposant,UFonctions, UInit;
procedure AjouteComposant(S:string; x,y:integer);
procedure AjouteSegment;
procedure SupprimeComposant;
procedure SelectionComposants;
procedure Resegmentation;
procedure RazEnCours;
procedure RAZSelection;
procedure PanneauEdition(x,y:integer);
procedure RAZPanneauEdition;
procedure ListeNom;
function CompteurComposant(S:string):integer;
implementation
uses Unit1,UnitRelais, UTest;
procedure AjouteComposant(S:string; x,y:integer);
begin
if pos('Im_rl',s)>0 then begin
SetLength(L_Relais,Nb_Relais +1);
L_Relais[Nb_Relais].P.X:=cordox(x);
L_Relais[Nb_Relais].P.Y:=cordoy(y);
L_Relais[Nb_Relais].modele:=copy(s,6,3);
L_Relais[Nb_Relais].Visible:=true;
L_Relais[Nb_Relais].nom:='';
CompoEnCours:='R';
NumeroEnCours:=Nb_Relais;
L_Relais[Nb_Relais].Pd.X:=0;
L_Relais[Nb_Relais].Pd.Y:=-4;
if L_Relais[Nb_Relais].modele='1' then L_Relais[Nb_Relais].Pd.Y:=-5;
if L_Relais[Nb_Relais].modele='4' then L_Relais[Nb_Relais].Pd.Y:=-5;
if L_Relais[Nb_Relais].modele='7' then L_Relais[Nb_Relais].Pd.Y:=-5;
if L_Relais[Nb_Relais].modele='11' then L_Relais[Nb_Relais].Pd.Y:=-7;
if L_Relais[Nb_Relais].modele='12' then L_Relais[Nb_Relais].Pd.Y:=-7;
inc(Nb_Relais);
end;
if pos('Im_cx',s)>0 then begin
SetLength(L_Connect,Nb_Connect +1);
L_Connect[Nb_Connect].P.X:=cordox(x);
L_Connect[Nb_Connect].P.Y:=cordoy(y);
CompoEnCours:='X';
NumeroEnCours:=Nb_Connect;
inc(Nb_Connect);
end;
if pos('Im_ct',s)>0 then begin
SetLength(L_Contact,Nb_Contact +1);
L_Contact[Nb_Contact].P.X:=cordox(x);
L_Contact[Nb_Contact].P.Y:=cordoy(y);
L_Contact[Nb_Contact].modele:=copy(s,6,3);
L_Contact[Nb_Contact].nom:='';
CompoEnCours:='C';
NumeroEnCours:=Nb_Contact;
if (L_Contact[Nb_Contact].modele='10') or (L_Contact[Nb_Contact].modele='15') then L_Contact[Nb_Contact].Manuel:=true;
if (L_Contact[Nb_Contact].modele='11') or (L_Contact[Nb_Contact].modele='12') or
(L_Contact[Nb_Contact].modele='13') or (L_Contact[Nb_Contact].modele='14') or
(L_Contact[Nb_Contact].modele='16') or (L_Contact[Nb_Contact].modele='17') then begin
L_Contact[Nb_Contact].EtatI:=true;
L_Contact[Nb_Contact].Manuel:=true;
end;
inc(Nb_Contact);
end;
if pos('Im_cp',s)>0 then begin
SetLength(L_Compo,Nb_Compo +1);
L_Compo[Nb_Compo].P.X:=cordox(x);
L_Compo[Nb_Compo].P.Y:=cordoy(y);
L_Compo[Nb_Compo].modele:=copy(s,6,3);
CompoEnCours:='P';
NumeroEnCours:=Nb_Compo;
inc(Nb_Compo);
end;
if pos('Im_al',s)>0 then begin
SetLength(L_Alim,Nb_Alim +1);
L_Alim[Nb_Alim].P.X:=cordox(x);
L_Alim[Nb_Alim].P.Y:=cordoy(y);
L_Alim[Nb_Alim].modele:=copy(s,6,3);
CompoEnCours:='A';
NumeroEnCours:=Nb_Alim;
inc(Nb_Alim);
end;
if pos('Im_la',s)>0 then begin
SetLength(L_Lampe,Nb_Lampe +1);
L_Lampe[Nb_Lampe].P.X:=cordox(x);
L_Lampe[Nb_Lampe].P.Y:=cordoy(y);
L_Lampe[Nb_Lampe].modele:=copy(s,6,3);
L_Lampe[Nb_Lampe].Clr0:=clBlack;
L_Lampe[Nb_Lampe].Clr1:=clRed;
L_Lampe[Nb_Lampe].nom:='';
L_Lampe[Nb_Lampe].Pd.X:=0;
L_Lampe[Nb_Lampe].Pd.Y:=0;
if L_Lampe[Nb_Lampe].modele='1' then L_Lampe[Nb_Lampe].Pd.Y:=-5;
if L_Lampe[Nb_Lampe].modele='2' then L_Lampe[Nb_Lampe].Pd.X:=5;
CompoEnCours:='L';
NumeroEnCours:=Nb_Lampe;
inc(Nb_Lampe);
end;
Affichage;
end;
procedure AjouteSegment;
begin
SetLength(L_Segment,Nb_Segment +1);
L_Segment[Nb_Segment].P1.X:=round(dx);
L_Segment[Nb_Segment].P1.Y:=round(dy);
L_Segment[Nb_Segment].P2.X:=round(fx);
L_Segment[Nb_Segment].P2.Y:=round(fy);
CompoEnCours:='S';
NumeroEnCours:=Nb_Segment;
inc(Nb_Segment);
Affichage;
end;
procedure RazEnCours;
var i:integer;
begin
CompoEnCours:='';
NumeroEnCours:=-1;
EnCours:=false;
for i:=0 to Nb_Contact - 1 do L_Contact[i].Select := false;
end;
procedure RAZSelection;
var i:integer;
begin
for i:=0 to Nb_Relais - 1 do L_Relais[i].Select:=false;
for i:=0 to Nb_Lampe - 1 do L_Lampe[i].Select:=false;
for i:=0 to Nb_Connect - 1 do L_Connect[i].Select:=false;
for i:=0 to Nb_Contact - 1 do L_Contact[i].Select:=false;
for i:=0 to Nb_Compo - 1 do L_Compo[i].Select:=false;
for i:=0 to Nb_Segment - 1 do begin
L_Segment[i].Select1:=false;
L_Segment[i].Select2:=false;
end;
for i:=0 to Nb_Alim - 1 do L_Alim[i].Select:=false;
Affichage;
end;
procedure SupprimeComposant;
var i:integer;
begin
i:=0;
while i<= Nb_Relais - 1 do begin
RAZPanneauEdition;
if L_Relais[i].Select then begin
L_Relais[i]:=L_Relais[nb_Relais-1];
dec(Nb_Relais);
dec(i);
end;
inc(i);
end;
i:=0;
while i<= Nb_Lampe - 1 do begin
RAZPanneauEdition;
if L_Lampe[i].Select then begin
L_Lampe[i]:=L_Lampe[nb_Lampe-1];
dec(Nb_Lampe);
dec(i);
end;
inc(i);
end;
i:=0;
while i<= Nb_Connect - 1 do begin
if L_Connect[i].Select then begin
L_Connect[i]:=L_Connect[nb_Connect-1];
dec(Nb_Connect);
dec(i);
end;
inc(i);
end;
i:=0;
while i<= Nb_Contact - 1 do begin
RAZPanneauEdition;
if L_Contact[i].Select then begin
L_Contact[i]:=L_Contact[nb_Contact-1];
dec(Nb_Contact);
dec(i);
end;
inc(i);
end;
i:=0;
while i<= Nb_Compo - 1 do begin
if L_Compo[i].Select then begin
L_Compo[i]:=L_Compo[nb_Compo-1];
dec(Nb_Compo);
dec(i);
end;
inc(i);
end;
i:=0;
while i<= Nb_Alim - 1 do begin
if L_Alim[i].Select then begin
L_Alim[i]:=L_Alim[nb_Alim-1];
dec(Nb_Alim);
dec(i);
end;
inc(i);
end;
i:=0;
while i<= Nb_Segment - 1 do begin
if (L_Segment[i].Select1 and L_Segment[i].Select2) then begin
L_Segment[i]:=L_Segment[nb_Segment-1];
dec(Nb_Segment);
dec(i);
end;
inc(i);
end;
Affichage;
end;
procedure SelectionComposants;
var i,ic:integer;
d,d1,d2,d01,d02:real;
sc:string;
b:boolean;
procedure swap(s:string);
begin
d:=d1;
sc:=s;
ic:=i;
end;
begin
// Test('D Selection Composant');
// Form1.memo1.Lines.Add('Recherche entre '+IntToStr(dx)+','+IntToStr(dy)+' et '+IntToStr(fx)+','+IntToStr(fy));
RazEnCours;
if (dx=fx) and (dy=fy) then begin
d:=10000;
ic:=-1; sc:='';
for i:=0 to Nb_Relais - 1 do begin
d1:=sqrt(sqr(L_Relais[i].P.X-dx)+sqr(L_Relais[i].P.Y-dy));
if d1<d then swap('R');
end;
for i:=0 to Nb_Lampe - 1 do begin
d1:=sqrt(sqr(L_Lampe[i].P.X-dx)+sqr(L_Lampe[i].P.Y-dy));
if d1<d then swap('L');
end;
for i:=0 to Nb_Connect - 1 do begin
d1:=sqrt(sqr(L_Connect[i].P.X-dx)+sqr(L_Connect[i].P.Y-dy));
if d1<d then swap('X');
end;
for i:=0 to Nb_Contact - 1 do begin
d1:=sqrt(sqr(L_Contact[i].P.X-dx)+sqr(L_Contact[i].P.Y-dy));
if d1<d then swap('C');
end;
for i:=0 to Nb_Compo - 1 do begin
d1:=sqrt(sqr(L_Compo[i].P.X-dx)+sqr(L_Compo[i].P.Y-dy));
if d1<d then swap('P');
end;
for i:=0 to Nb_Segment - 1 do begin
d01:= distance(L_Segment[i].P1.X,L_Segment[i].P1.Y,dx,dy);
d02:= distance(dx,dy,L_Segment[i].P2.X,L_Segment[i].P2.Y);;
d2:= distance(L_Segment[i].P1.X,L_Segment[i].P1.Y,L_Segment[i].P2.X,L_Segment[i].P2.Y);
d1:= dist_proj_ortho(L_Segment[i].P1.X,L_Segment[i].P1.Y,L_Segment[i].P2.X,L_Segment[i].P2.Y,dx,dy);
if (d1<d) and (d2>d01) and (d2>d02) then swap('S');
end;
for i:=0 to Nb_Alim - 1 do begin
d1:=sqrt(sqr(L_Alim[i].P.X-dx)+sqr(L_Alim[i].P.Y-dy));
if d1<d then swap('A');
end;
for i:=0 to Nb_Relais - 1 do L_Relais[i].Select := (sc='R') and (i=ic);
for i:=0 to Nb_Lampe - 1 do L_Lampe[i].Select := (sc='L') and (i=ic);
for i:=0 to Nb_Connect - 1 do L_Connect[i].Select := (sc='X') and (i=ic);
for i:=0 to Nb_Contact - 1 do L_Contact[i].Select := (sc='C') and (i=ic);
for i:=0 to Nb_Compo - 1 do L_Compo[i].Select := (sc='P') and (i=ic);
for i:=0 to Nb_Segment - 1 do begin
L_Segment[i].Select1 := (sc='S') and (i=ic);
L_Segment[i].Select2 := (sc='S') and (i=ic);
end;
for i:=0 to Nb_Alim - 1 do L_Alim[i].Select := (sc='A') and (i=ic);
end else begin
for i:=0 to Nb_Relais - 1 do L_Relais[i].Select := entre(L_Relais[i].P.X,dx,fx) and entre(L_Relais[i].P.Y,dy,fy);
for i:=0 to Nb_Lampe - 1 do L_Lampe[i].Select := entre(L_Lampe[i].P.X,dx,fx) and entre(L_Lampe[i].P.Y,dy,fy);
for i:=0 to Nb_Connect - 1 do L_Connect[i].Select := entre(L_Connect[i].P.X,dx,fx) and entre(L_Connect[i].P.Y,dy,fy);
for i:=0 to Nb_Contact - 1 do L_Contact[i].Select := entre(L_Contact[i].P.X,dx,fx) and entre(L_Contact[i].P.Y,dy,fy);
for i:=0 to Nb_Compo - 1 do L_Compo[i].Select := entre(L_Compo[i].P.X,dx,fx) and entre(L_Compo[i].P.Y,dy,fy);
for i:=0 to Nb_Segment - 1 do begin
L_Segment[i].Select1 := entre(L_Segment[i].P1.X,dx,fx) and entre(L_Segment[i].P1.Y,dy,fy);
L_Segment[i].Select2 := entre(L_Segment[i].P2.X,dx,fx) and entre(L_Segment[i].P2.Y,dy,fy);
end;
for i:=0 to Nb_Alim - 1 do L_Alim[i].Select := entre(L_Alim[i].P.X,dx,fx) and entre(L_Alim[i].P.Y,dy,fy);
end;
b:=false;
for i:=0 to Nb_Relais - 1 do b:=b or L_Relais[i].Select;
for i:=0 to Nb_Lampe - 1 do b:=b or L_Lampe[i].Select;
for i:=0 to Nb_Connect - 1 do b:=b or L_Connect[i].Select;
for i:=0 to Nb_Contact - 1 do b:=b or L_Contact[i].Select;
for i:=0 to Nb_Compo - 1 do b:=b or L_Compo[i].Select;
for i:=0 to Nb_Segment - 1 do b:=b or L_Segment[i].Select1 or L_Segment[i].Select2;
for i:=0 to Nb_Alim - 1 do b:=b or L_Alim[i].Select;
Form1.BBtn_Gauche.Enabled:=b;
Form1.BBtn_Droite.Enabled:=b;
Form1.BBtn_Haut.Enabled:=b;
Form1.BBtn_Bas.Enabled:=b;
Form1.BBtn_Supprime.Enabled:=b;
Affichage;
end;
procedure Resegmentation;
var i,j,cc:integer;
cdi,cdj,cbi,cbj:double;
b,bc:boolean;
x1,y1,x2,y2 : integer;
Seg:T_Segment;
begin
// segment nuls mis <20> z<>ro et supprim<69>s plus tard
for i:=0 to Nb_Segment - 1 do begin
if (L_Segment[i].P1.X=L_Segment[i].P2.X) and (L_Segment[i].P1.Y=L_Segment[i].P2.Y) then begin
L_Segment[i].P1.X:=0; L_Segment[i].P1.Y:=0;
L_Segment[i].P2.X:=0; L_Segment[i].P2.Y:=0;
end;
end;
// Fait les lignes enti<74>res
repeat;
bc:=false;
for i:=0 to Nb_Segment - 2 do for j:=i+1 to Nb_Segment - 1 do begin
// non verticaux
if (L_Segment[i].P2.X-L_Segment[i].P1.X <> 0) and (L_Segment[j].P2.X-L_Segment[j].P1.X <> 0) then begin // non vertical
cdi:=(L_Segment[i].P2.Y-L_Segment[i].P1.Y)/(L_Segment[i].P2.X-L_Segment[i].P1.X); // cd coef directeur
cdj:=(L_Segment[j].P2.Y-L_Segment[j].P1.Y)/(L_Segment[j].P2.X-L_Segment[j].P1.X);
if cdi=cdj then begin // si colin<69>aire
cbi:=L_Segment[i].P1.Y-cdi*L_Segment[i].P1.X; // b (y=ax+b)
cbj:=L_Segment[j].P1.Y-cdj*L_Segment[j].P1.X;
if cbi=cbj then begin // si m<>me droite
b:=entre(L_Segment[i].P1.X,L_Segment[j].P1.X,L_Segment[j].P2.X) or entre(L_Segment[i].P2.X,L_Segment[j].P1.X,L_Segment[j].P2.X)
or entre(L_Segment[j].P1.X,L_Segment[i].P1.X,L_Segment[i].P2.X) or entre(L_Segment[j].P2.X,L_Segment[i].P1.X,L_Segment[i].P2.X);
if b then begin // si contig<69>e ou superpos<6F>
bc:=true;
x1:=L_Segment[i].P1.X;y1:=L_Segment[i].P1.Y;
if x1>L_Segment[i].P2.X then begin x1:=L_Segment[i].P2.X;y1:=L_Segment[i].P2.Y; end;
if x1>L_Segment[j].P1.X then begin x1:=L_Segment[j].P1.X;y1:=L_Segment[j].P1.Y; end;
if x1>L_Segment[j].P2.X then begin x1:=L_Segment[j].P2.X;y1:=L_Segment[j].P2.Y; end;
x2:=L_Segment[i].P1.X;y2:=L_Segment[i].P1.Y;
if x2<L_Segment[i].P2.X then begin x2:=L_Segment[i].P2.X;y2:=L_Segment[i].P2.Y; end;
if x2<L_Segment[j].P1.X then begin x2:=L_Segment[j].P1.X;y2:=L_Segment[j].P1.Y; end;
if x2<L_Segment[j].P2.X then begin x2:=L_Segment[j].P2.X;y2:=L_Segment[j].P2.Y; end;
L_Segment[i].P1.X:=x1; L_Segment[i].P1.Y:=y1;
L_Segment[i].P2.X:=x2; L_Segment[i].P2.Y:=y2;
L_Segment[j].P1.X:=0; L_Segment[j].P1.Y:=0; // mis <20> z<>ro sera supprimm<6D> plus tard
L_Segment[j].P2.X:=0; L_Segment[j].P2.Y:=0;
end;
end;
end;
end;
// verticaux
if (L_Segment[i].P2.X-L_Segment[i].P1.X = 0) and (L_Segment[j].P2.X-L_Segment[j].P1.X = 0) and (L_Segment[i].P2.Y-L_Segment[i].P1.Y <> 0) and (L_Segment[j].P2.Y-L_Segment[j].P1.Y <> 0) then begin
cdi:=(L_Segment[i].P2.X-L_Segment[i].P1.X)/(L_Segment[i].P2.Y-L_Segment[i].P1.Y);
cdj:=(L_Segment[j].P2.X-L_Segment[j].P1.X)/(L_Segment[j].P2.Y-L_Segment[j].P1.Y);
if cdi=cdj then begin
cbi:=L_Segment[i].P1.X-cdi*L_Segment[i].P1.Y;
cbj:=L_Segment[j].P1.X-cdj*L_Segment[j].P1.Y;
if cbi=cbj then begin
b:=entre(L_Segment[i].P1.Y,L_Segment[j].P1.Y,L_Segment[j].P2.Y) or entre(L_Segment[i].P2.Y,L_Segment[j].P1.Y,L_Segment[j].P2.Y)
or entre(L_Segment[j].P1.Y,L_Segment[i].P1.Y,L_Segment[i].P2.Y) or entre(L_Segment[j].P2.Y,L_Segment[i].P1.Y,L_Segment[i].P2.Y);
if b then begin
bc:=true;
x1:=L_Segment[i].P1.X;y1:=L_Segment[i].P1.Y;
if y1>L_Segment[i].P2.Y then begin y1:=L_Segment[i].P2.Y;x1:=L_Segment[i].P2.X; end;
if y1>L_Segment[j].P1.Y then begin y1:=L_Segment[j].P1.Y;x1:=L_Segment[j].P1.X; end;
if y1>L_Segment[j].P2.Y then begin y1:=L_Segment[j].P2.Y;x1:=L_Segment[j].P2.X; end;
x2:=L_Segment[i].P1.X;y2:=L_Segment[i].P1.Y;
if y2<L_Segment[i].P2.Y then begin y2:=L_Segment[i].P2.Y;x2:=L_Segment[i].P2.X; end;
if y2<L_Segment[j].P1.Y then begin y2:=L_Segment[j].P1.Y;x2:=L_Segment[j].P1.X; end;
if y2<L_Segment[j].P2.Y then begin y2:=L_Segment[j].P2.Y;x2:=L_Segment[j].P2.X; end;
L_Segment[i].P1.X:=x1; L_Segment[i].P1.Y:=y1;
L_Segment[i].P2.X:=x2; L_Segment[i].P2.Y:=y2;
L_Segment[j].P1.X:=0; L_Segment[j].P1.Y:=0;
L_Segment[j].P2.X:=0; L_Segment[j].P2.Y:=0;
end; // if b
end; // if cbi=cbj
end; // if cdi=cdj
end; // if
end; // for i,j
// place les 0 <20> la fin
for i:=0 to Nb_Segment - 2 do for j:=i+1 to Nb_Segment - 1 do begin
if (L_Segment[i].P1.X=0) and (L_Segment[i].P1.Y=0) and (L_Segment[i].P2.X=0) and (L_Segment[i].P2.Y=0) then begin
Seg:=L_Segment[i];
L_Segment[i]:=L_Segment[j];
L_Segment[j]:=Seg;
end; //if
end; // for i,j
cc:=0; // compte les 0 et les supprime
for i:=0 to Nb_Segment - 1 do if (L_Segment[i].P1.X=0) and (L_Segment[i].P1.Y=0) and (L_Segment[i].P2.X=0) and (L_Segment[i].P2.Y=0) then inc(cc);
Nb_Segment:=Nb_Segment-cc;
Setlength(L_Segment,Nb_Segment);
until not bc; // tant qu'on fusionne on rev<65>rifie
//Scinde les segments sur les connexions
repeat;
bc:=false;
// non verticaux
for i:=0 to Nb_Segment - 1 do for j:=0 to Nb_Connect - 1 do begin
if (L_Segment[i].P2.X-L_Segment[i].P1.X <> 0) then begin
cdi:=(L_Segment[i].P2.Y-L_Segment[i].P1.Y)/(L_Segment[i].P2.X-L_Segment[i].P1.X);
cbi:=L_Segment[i].P1.Y-cdi*L_Segment[i].P1.X;
b:=(L_Connect[j].P.Y=cdi*L_Connect[j].P.X+cbi) and entre(L_Connect[j].P.X,L_Segment[i].P1.X,L_Segment[i].P2.X) and (L_Connect[j].P.X<>L_Segment[i].P1.X) and (L_Connect[j].P.X<>L_Segment[i].P2.X);
if b then begin
bc:=true;
SetLength(L_Segment,Nb_Segment +1);
L_Segment[Nb_Segment].P1.X:=L_Connect[j].P.X;
L_Segment[Nb_Segment].P1.Y:=L_Connect[j].P.Y;
L_Segment[Nb_Segment].P2.X:=L_Segment[i].P2.X;
L_Segment[Nb_Segment].P2.Y:=L_Segment[i].P2.Y;
L_Segment[i].P2.X:=L_Connect[j].P.X;
L_Segment[i].P2.Y:=L_Connect[j].P.Y;
Inc(Nb_Segment);
end;
end;
// verticaux
if (L_Segment[i].P2.X-L_Segment[i].P1.X = 0) and (L_Segment[i].P2.Y-L_Segment[i].P1.Y <> 0) then begin
cdi:=(L_Segment[i].P2.X-L_Segment[i].P1.X)/(L_Segment[i].P2.Y-L_Segment[i].P1.Y);
cbi:=L_Segment[i].P1.X-cdi*L_Segment[i].P1.Y;
b:=(L_Connect[j].P.X=cdi*L_Connect[j].P.Y+cbi) and entre(L_Connect[j].P.Y,L_Segment[i].P1.Y,L_Segment[i].P2.Y) and (L_Connect[j].P.Y<>L_Segment[i].P1.Y) and (L_Connect[j].P.Y<>L_Segment[i].P2.Y);
if b then begin
bc:=true;
SetLength(L_Segment,Nb_Segment +1);
L_Segment[Nb_Segment].P1.X:=L_Connect[j].P.X;
L_Segment[Nb_Segment].P1.Y:=L_Connect[j].P.Y;
L_Segment[Nb_Segment].P2.X:=L_Segment[i].P2.X;
L_Segment[Nb_Segment].P2.Y:=L_Segment[i].P2.Y;
L_Segment[i].P2.X:=L_Connect[j].P.X;
L_Segment[i].P2.Y:=L_Connect[j].P.Y;
Inc(Nb_Segment);
end;
end;
end;
until not bc; // tant qu'on scinde on rev<65>rifie
end;
function CompteurComposant(S:string):integer;
var i,c:integer;
begin
c:=0;
if S='C' then for i:=0 to Nb_Contact-1 do if L_Contact[i].Select then inc(c);
if S='R' then for i:=0 to Nb_Relais-1 do if L_Relais[i].Select then inc(c);
if S='L' then for i:=0 to Nb_Lampe-1 do if L_Lampe[i].Select then inc(c);
Result:=c;
end;
procedure RAZPanneauEdition;
begin
With Form1 do begin
Pnl_Contact.Visible:=false;
Pnl_Relais.Visible:=false;
Pnl_Lampe.Visible:=false;
end;
end;
procedure ListeNom;
var i:integer;
begin
With Form1 do begin
CO_C_Nom.Clear;
for i:=0 to Nb_Relais-1 do if L_Relais[i].nom<>'' then CO_C_Nom.Items.Add(L_Relais[i].nom);
for i:=0 to Nb_Contact-1 do if L_Contact[i].Manuel and (L_Contact[i].nom<>'') then CO_C_Nom.Items.Add(L_Contact[i].nom);
end; // With Form1
end;
// Affiche les panneaux d'<27>dition des composants
procedure PanneauEdition(x,y:integer);
var i:integer;
begin
RAZPanneauEdition;
With Form1 do begin
// Contact
if CompteurComposant('C')=1 then begin
Pnl_Contact.Visible:=true;
for i:=0 to Nb_Contact-1 do if L_Contact[i].Select then begin
CB_C_EtatI.Checked:=L_Contact[i].EtatI;
CB_C_Manuel.Checked:=L_Contact[i].Manuel;
CB_C_Visible.Checked:=L_Contact[i].Visible;
CO_C_Nom.Text:=L_Contact[i].nom;
SP_C_dx.Value:=L_Contact[i].Pd.X;
SP_C_dy.Value:=L_Contact[i].Pd.Y;
end; // for i
end; // if CompteurComposant('C')
// Relais
if CompteurComposant('R')=1 then begin
Pnl_Relais.Visible:=true;
for i:=0 to Nb_Relais-1 do if L_Relais[i].Select then begin
CB_R_Visible.Checked:=L_Relais[i].Visible;
Ed_R_Nom.Text:=L_Relais[i].nom;
SP_R_dx.Value:=L_Relais[i].Pd.X;
SP_R_dy.Value:=L_Relais[i].Pd.Y;
Ed_R_Tempo.Text:=IntToStr(L_Relais[i].tpr);
end; // for i
end; // if CompteurComposant('R')
// Lampe
if CompteurComposant('L')=1 then begin
Pnl_Lampe.Visible:=true;
for i:=0 to Nb_Lampe-1 do if L_Lampe[i].Select then begin
CB_L_Visible.Checked:=L_Lampe[i].Visible;
Ed_L_Nom.Text:=L_Lampe[i].nom;
SP_L_dx.Value:=L_Lampe[i].Pd.X;
SP_L_dy.Value:=L_Lampe[i].Pd.Y;
PNL_L0.Color:=L_Lampe[i].Clr0;
PNL_L1.Color:=L_Lampe[i].Clr1;
end; // for i
end; // if CompteurComposant('L')
end; // with Form1
end; // PanneauEdition(x,y:integer);
end.