lecture_fichier_JMW/code_JMW/UDessinComposant.pas

1010 lines
30 KiB
ObjectPascal

unit UDessinComposant;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, ExtCtrls,UInit,math;
function cordo(i:integer):double;
function cordox(i:integer):integer;
function cordoy(i:integer):integer;
function ecranx(r:real):integer;
function ecrany(r:real):integer;
procedure Trait(x1,y1,x2,y2:real);
procedure DessineRelais(Rl:T_Relais);
procedure DessineConnect(Cx:T_Connect);
procedure DessineContact(Ct:T_Contact);
procedure DessineSegment(Sg:T_Segment);
procedure DessineAlim(Al:T_Alim);
procedure DessineCompo(Cp:T_Compo);
procedure DessineLampe(La:T_Lampe);
implementation
uses Unit1, UDessin,UTest,UPage;
function cordo(i:integer):double;
begin
result:=(i/Facteur*zoom);
end;
function cordox(i:integer):integer;
begin
result:=round(i/Facteur*zoom)+Form1.SB_Hor.Position*sbx;
end;
function cordoy(i:integer):integer;
begin
result:=round(i/Facteur*zoom)+Form1.SB_Ver.Position*sby;
end;
function ecran(rx,ry:double):TPoint;
begin
result.X:=round((rx-Form1.SB_Hor.Position*sbx)*Facteur/zoom);
result.Y:=round((ry-Form1.SB_Ver.Position*sby)*Facteur/zoom);
end;
function ecranx(r:real):integer;
begin
result:=round((r-Form1.SB_Hor.Position*sbx)*Facteur/zoom);
end;
function ecrany(r:real):integer;
begin
result:=round((r-Form1.SB_Ver.Position*sby)*Facteur/zoom);
end;
procedure Trait(x1,y1,x2,y2:real);
begin
// Form1.Image.Canvas.Pen.Color:=clyellow;
Form1.Image.Canvas.Pen.Width:=1+round(1/zoom);
Form1.Image.Canvas.MoveTo(ecranx(x1),ecrany(y1));
Form1.Image.Canvas.LineTo(ecranx(x2),ecrany(y2));
end;
procedure TraitFort(x1,x2,y:real); // horizontal
begin
Form1.Image.Canvas.FillRect(Rect(ecranx(x1),ecrany(y-0.1),ecranx(x2),ecrany(y+0.1)));
end;
procedure TraitFin(x,y1,y2:real); // vertical
begin
Form1.Image.Canvas.FillRect(Rect(ecranx(x-0.05),ecrany(y1),ecranx(x+0.05),ecrany(y2)));
end;
procedure Rond(x,y:real);
begin
Form1.Image.Canvas.Brush.Style:=bsSolid;
Form1.Image.Canvas.Ellipse(ecranx(x-0.3),ecrany(y-0.3),1+ecranx(x+0.3),1+ecrany(y+0.3));
end;
procedure fleche(x,y:real;b:boolean);
begin
Form1.Image.Canvas.Pen.Color:=RGB(160,160,160);
Form1.Image.Canvas.Pen.Width:=1+round(1/zoom);
Form1.Image.Canvas.MoveTo(ecranx(x),ecrany(y+0.5));
Form1.Image.Canvas.LineTo(ecranx(x),ecrany(y-0.5));
if b then begin
Form1.Image.Canvas.MoveTo(ecranx(x-0.25),ecrany(y-0.25));
Form1.Image.Canvas.LineTo(ecranx(x),ecrany(y-0.5));
Form1.Image.Canvas.LineTo(ecranx(x+0.25),ecrany(y-0.25));
end else begin
Form1.Image.Canvas.MoveTo(ecranx(x-0.25),ecrany(y+0.25));
Form1.Image.Canvas.LineTo(ecranx(x),ecrany(y+0.5));
Form1.Image.Canvas.LineTo(ecranx(x+0.25),ecrany(y+0.25));
end;
end;
procedure Pivot1(x,y:real;b:boolean);
begin
Form1.Image.Canvas.Pen.Width:=1;//+round(1/zoom);
if not b then
Form1.Image.Canvas.Polygon([ecran(x-1,y-0.08), ecran(x-1,y+0.08), ecran(x+1,y+0.75+0.08), ecran(x+1,y+0.75-0.08)])
else
Form1.Image.Canvas.Polygon([ecran(x-1,y-0.08), ecran(x-1,y+0.08), ecran(x+1,y+0.25+0.08), ecran(x+1,y+0.25-0.08)]);
end;
procedure Pivot2(x,y:real;b:boolean);
begin
Form1.Image.Canvas.Pen.Width:=1;//+round(1/zoom);
if not b then
Form1.Image.Canvas.Polygon([ecran(x+1,y-0.08), ecran(x+1,y+0.08), ecran(x-1,y+0.75+0.08), ecran(x-1,y+0.75-0.08)])
else
Form1.Image.Canvas.Polygon([ecran(x+1,y-0.08), ecran(x+1,y+0.08), ecran(x-1,y+0.25+0.08), ecran(x-1,y+0.25-0.08)]);
end;
procedure Pivot3(x,y:real;b:boolean);
begin
Form1.Image.Canvas.Pen.Width:=1;//+round(1/zoom);
if not b then
Form1.Image.Canvas.Polygon([ecran(x-0.08,y+1), ecran(x+0.08,y+1), ecran(x-0.75+0.08,y-1), ecran(x-0.75-0.08,y-1)])
else
Form1.Image.Canvas.Polygon([ecran(x-0.08,y+1), ecran(x+0.08,y+1), ecran(x+0.75+0.08,y-1), ecran(x+0.75-0.08,y-1)]);
end;
procedure Texte(x,y:real;s:string);
begin
Form1.Image.Canvas.TextOut(ecranx(x)-round(Form1.Image.Canvas.TextWidth(s)/2),ecrany(y),s);
end;
procedure ix(x,y:real);
begin
Form1.Image.Canvas.MoveTo(ecranx(x-1),ecrany(y-1));
Form1.Image.Canvas.LineTo(ecranx(x+1),ecrany(y+1));
Form1.Image.Canvas.MoveTo(ecranx(x+1),ecrany(y-1));
Form1.Image.Canvas.LineTo(ecranx(x-1),ecrany(y+1));
end;
// Dessins
procedure DessineRelais(Rl:T_Relais);
var x,y:integer;
cl:TColor;
b:boolean;
begin
x:=Rl.P.X; y:=Rl.P.Y;
b:=false;
if (Rl.Fonction>=0) and (length(L_Fonction)>0) then b:=bExec and L_Fonction[Rl.Fonction].EtatP; //}
cl:=clBlack;
if (EnCours or Rl.Select) and not bExec then cl:=clBlue;
Form1.Image.Canvas.Pen.Color:=cl;
Form1.Image.Canvas.Brush.Color:=cl;
// test(format('',[Rl.AppPot]));
if Rl.modele='1' then begin
TraitFort(x-1.3,x+1.3,y-1);
TraitFort(x-1.3,x+1.3,y+1);
TraitFin(x-1,y-1,y+1);
TraitFin(x+1,y-1,y+1);
Rond(x+1,y); Rond(x-1,y);
if Form1.VisuelRelais.Checked then fleche(x,y,b);
end;
if Rl.modele='2' then begin
TraitFort(x-1.3,x+1.3,y-0.5);
TraitFort(x-1.3,x+1.3,y+1.5);
TraitFin(x-1,y-0.5,y+1.5);
TraitFin(x+1,y-0.5,y+1.5);
Rond(x-1,y); Rond(x-1,y+1);
if Form1.VisuelRelais.Checked then fleche(x,y+0.5,b);
end;
if Rl.modele='3' then begin
TraitFort(x-1.3,x+1.3,y-0.5);
TraitFort(x-1.3,x+1.3,y+1.5);
TraitFin(x-1,y-0.5,y+1.5);
TraitFin(x+1,y-0.5,y+1.5);
Rond(x+1,y); Rond(x+1,y+1);
if Form1.VisuelRelais.Checked then fleche(x,y+0.5,b);
end;
if Rl.modele='4' then begin
TraitFort(x-1.3,x+1.3,y-1);
TraitFort(x-1.3,x+1.3,y+1);
TraitFin(x-1,y-1,y+1);
TraitFin(x+1,y-1,y+1);
Rond(x+1,y); Rond(x-1,y);
Form1.Image.Canvas.FillRect(Rect(ecranx(x-1),ecrany(y-1),ecranx(x+1),ecrany(y-0.5)));
if Form1.VisuelRelais.Checked then fleche(x,y,b);
end;
if Rl.modele='5' then begin
TraitFort(x-1.3,x+1.3,y-0.5);
TraitFort(x-1.3,x+1.3,y+1.5);
TraitFin(x-1,y-0.5,y+1.5);
TraitFin(x+1,y-0.5,y+1.5);
Rond(x-1,y); Rond(x-1,y+1);
Form1.Image.Canvas.FillRect(Rect(ecranx(x-1),ecrany(y-0.5),ecranx(x+1),ecrany(y)));
if Form1.VisuelRelais.Checked then fleche(x,y+0.5,b);
end;
if Rl.modele='6' then begin
TraitFort(x-1.3,x+1.3,y-0.5);
TraitFort(x-1.3,x+1.3,y+1.5);
TraitFin(x-1,y-0.5,y+1.5);
TraitFin(x+1,y-0.5,y+1.5);
Rond(x+1,y); Rond(x+1,y+1);
Form1.Image.Canvas.FillRect(Rect(ecranx(x-1),ecrany(y-0.5),ecranx(x+1),ecrany(y)));
if Form1.VisuelRelais.Checked then fleche(x,y+0.5,b);
end;
if Rl.modele='7' then begin
TraitFort(x-1.3,x+1.3,y-1);
TraitFort(x-1.3,x+1.3,y+1);
TraitFin(x-1,y-1,y+1);
TraitFin(x+1,y-1,y+1);
Rond(x+1,y); Rond(x-1,y);
Form1.Image.Canvas.FillRect(Rect(ecranx(x-1),ecrany(y+0.5),ecranx(x+1),ecrany(y+1)));
if Form1.VisuelRelais.Checked then fleche(x,y,b);
end;
if Rl.modele='8' then begin
TraitFort(x-1.3,x+1.3,y-0.5);
TraitFort(x-1.3,x+1.3,y+1.5);
TraitFin(x-1,y-0.5,y+1.5);
TraitFin(x+1,y-0.5,y+1.5);
Rond(x-1,y); Rond(x-1,y+1);
Form1.Image.Canvas.FillRect(Rect(ecranx(x-1),ecrany(y+1),ecranx(x+1),ecrany(y+1.5)));
if Form1.VisuelRelais.Checked then fleche(x,y+0.5,b);
end;
if Rl.modele='9' then begin
TraitFort(x-1.3,x+1.3,y-0.5);
TraitFort(x-1.3,x+1.3,y+1.5);
TraitFin(x-1,y-0.5,y+1.5);
TraitFin(x+1,y-0.5,y+1.5);
Rond(x+1,y); Rond(x+1,y+1);
Form1.Image.Canvas.FillRect(Rect(ecranx(x-1),ecrany(y+1),ecranx(x+1),ecrany(y+1.5)));
if Form1.VisuelRelais.Checked then fleche(x,y+0.5,b);
end;
if Rl.modele='10' then begin
TraitFort(x-2.3,x+2.3,y-0.5);
TraitFort(x-2.3,x+2.3,y+1.5);
TraitFin(x-2,y-0.5,y+1.5);
TraitFin(x+2,y-0.5,y+1.5);
TraitFin(x-0.4,y-0.5,y+1.5);
TraitFin(x+0.4,y-0.5,y+1.5);
Rond(x+2,y); Rond(x+2,y+1);
Rond(x-2,y); Rond(x-2,y+1);
end;
if Rl.modele='11' then begin
TraitFort(x-1.3,x+1.3,y-2);
TraitFort(x-1.3,x+1.3,y);
TraitFort(x-1.3,x+1.3,y+2);
TraitFin(x-1,y-2,y+2);
TraitFin(x+1,y-2,y+2);
Rond(x+1,y-1); Rond(x-1,y-1);
Rond(x+1,y+1); Rond(x-1,y+1);
Form1.Image.Canvas.Font.Color:=cl;
Form1.Image.Canvas.Brush.Color:=ClrFd;
Form1.Image.Canvas.Brush.Style:=BsClear;
Form1.Image.Canvas.TextOut(ecranx(x-0.4),ecrany(y-1.5),'A');
Form1.Image.Canvas.TextOut(ecranx(x-0.4),ecrany(y+0.5),'M');
if Form1.VisuelRelais.Checked then fleche(x,y,b);
end;
if Rl.modele='12' then begin
TraitFort(x-1.3,x+1.3,y-2);
TraitFort(x-1.3,x+1.3,y);
TraitFort(x-1.3,x+1.3,y+2);
TraitFin(x-1,y-2,y+2);
TraitFin(x+1,y-2,y+2);
Rond(x+1,y-1); Rond(x-1,y-1);
Rond(x+1,y+1); Rond(x-1,y+1);
Form1.Image.Canvas.Font.Color:=cl;
Form1.Image.Canvas.Brush.Color:=ClrFd;
Form1.Image.Canvas.Brush.Style:=BsClear;
Form1.Image.Canvas.TextOut(ecranx(x-0.6),ecrany(y-1.5),'+ -');
Form1.Image.Canvas.TextOut(ecranx(x-0.6),ecrany(y+0.5),'+ -');
if Form1.VisuelRelais.Checked then fleche(x,y,b);
end;
if Rl.Visible then begin
Form1.Image.Canvas.Font.Color:=cl;
Form1.Image.Canvas.Brush.Color:=ClrFd;
Form1.Image.Canvas.Brush.Style:=BsClear;
Texte(x+Rl.Pd.X/2,y+Rl.Pd.Y/2,Rl.nom);
end;
end;
procedure DessineConnect(Cx:T_Connect);
var cl:TColor;
begin
cl:=clBlack;
if (EnCours or Cx.Select) and not bExec then cl:=clBlue;
if bexec and (form1.Potentiels1.Checked) then cl:=ClrPotentiel(L_Potentiel[Cx.AppaPotentiel].Rp,L_Potentiel[Cx.AppaPotentiel].Rm);
if bexec and (form1.Courants1.Checked) then begin
if Cx.Parcouru=1 then cl:=clRed;
end;
Form1.Image.Canvas.Pen.Color:=cl;
Form1.Image.Canvas.Brush.Color:=cl;
Rond(Cx.P.X,Cx.P.Y);
end;
procedure DessineAlim(Al:T_Alim);
var cl:TColor;
s:string;
begin
cl:=clBlack;
if (EnCours or Al.Select) and not bExec then cl:=clBlue;
if bexec and (form1.Potentiels1.Checked) then begin
if Al.modele='1' then cl:=clRed;
if Al.modele='2' then cl:=clBlue;
if (Al.modele='3') and pulse then cl:=clRed;
end;
if bexec and (form1.Courants1.Checked) then begin
if Al.Parcouru=1 then cl:=clRed;
end;
//test(format('',[Al.]));
Form1.Image.Canvas.Pen.Color:=cl;
Form1.Image.Canvas.Brush.Color:=cl;
Rond(Al.P.X,Al.P.Y);
Form1.Image.Canvas.Font.Color:=cl;
Form1.Image.Canvas.Brush.Color:=ClrFd;
Form1.Image.Canvas.Brush.Style:=BsClear;
s:='+';
if Al.modele='2' then s:='-';
if Al.modele='3' then s:='p';
Form1.Image.Canvas.TextOut(ecranx(Al.P.X-0.8),ecrany(Al.P.Y-1),s);
end;
procedure DessineSegment(Sg:T_Segment);
var cl:TColor;
s:string;
begin
cl:=clBlack;
if (EnCours or Sg.Select1 or Sg.Select2) and not bExec then cl:=clBlue;
if bexec and (form1.Potentiels1.Checked) then cl:=ClrPotentiel(L_Potentiel[L_Branche[Sg.AppaBranche].AppaPotentiel].Rp,L_Potentiel[L_Branche[Sg.AppaBranche].AppaPotentiel].Rm);
// test(format('',[Sg.]));
if bexec and (form1.Courants1.Checked) then begin
if L_Branche[Sg.AppaBranche].Courant=-1 then cl:=clBlack;
if L_Branche[Sg.AppaBranche].Courant=0 then cl:=clBlack;
if L_Branche[Sg.AppaBranche].Courant=1 then cl:=clRed;
end;
Form1.Image.Canvas.Pen.Color:=cl;
Form1.Image.Canvas.Brush.Color:=cl;
Trait(Sg.P1.X,Sg.P1.Y,Sg.P2.X,Sg.P2.Y);
// affichage branche
{ Form1.Image.Canvas.Font.Color:=clGreen;
Form1.Image.Canvas.Brush.Color:=ClrFd;
Form1.Image.Canvas.Brush.Style:=BsClear;
s:=IntToStr(Sg.AppaBranche);
if Sg.AppaBranche<Length(L_Branche) then s:=s+','+IntToStr(L_Branche[Sg.AppaBranche].AppaPotentiel);
Texte(round((Sg.P1.X+Sg.P2.X)/2),round((Sg.P1.Y+Sg.P2.Y)/2),s); //}
end;
procedure DessineContact(Ct:T_Contact);
var x,y:integer;
cl,cl1,cl2,cl3:TColor;
b:boolean;
begin
cl:=clBlack;
if (EnCours or Ct.Select) and not bExec then cl:=clBlue;
x:=Ct.P.X; y:=Ct.P.Y;
if form1.Visuelinteractif.Checked and bExec and Ct.Manuel then begin
Form1.Image.Canvas.Pen.Color:=RGB(220,230,250);
Form1.Image.Canvas.Brush.Color:=RGB(220,230,250);
Form1.Image.Canvas.Brush.Style:=bsSolid;
Form1.Image.Canvas.Ellipse(ecranx(x-0.95),ecrany(y-0.95),1+ecranx(x+0.95),1+ecrany(y+0.95));
end;
// test(format('',[Ct.]));
Form1.Image.Canvas.Pen.Color:=cl;
Form1.Image.Canvas.Brush.Color:=cl;
b:=(ct.EtatI and not bExec) or (bExec and ct.EtatP);
if Ct.modele='1' then begin
if bexec and form1.Courants1.Checked and (Ct.Parcouru=1) and b then begin
Form1.Image.Canvas.Pen.Color:=clRed;
Form1.Image.Canvas.Brush.Color:=clRed;
end;
if bexec and form1.Potentiels1.Checked then begin
Form1.Image.Canvas.Pen.Color:=Ct.cl1;
Form1.Image.Canvas.Brush.Color:=Ct.cl1;
end; //}
Rond(x+1,y);
if bexec and form1.Potentiels1.Checked then begin
Form1.Image.Canvas.Pen.Color:=Ct.cl0;
Form1.Image.Canvas.Brush.Color:=Ct.cl0;
end; //}
Rond(x-1,y);
Pivot1(x,y,b);
end;
if Ct.modele='2' then begin
if bexec and form1.Courants1.Checked and (Ct.Parcouru=1) and b then begin
Form1.Image.Canvas.Pen.Color:=clRed;
Form1.Image.Canvas.Brush.Color:=clRed;
end;
if bexec and form1.Potentiels1.Checked then begin
Form1.Image.Canvas.Pen.Color:=Ct.cl0;
Form1.Image.Canvas.Brush.Color:=Ct.cl0;
end; //}
Rond(x-1,y);
if bexec and form1.Potentiels1.Checked then begin
Form1.Image.Canvas.Pen.Color:=Ct.cl1;
Form1.Image.Canvas.Brush.Color:=Ct.cl1;
end;//}
Rond(x+1,y);
Pivot2(x,y,b);
end;
if Ct.modele='3' then begin
if bexec and form1.Courants1.Checked and (Ct.Parcouru=1) and (not b) then begin
Form1.Image.Canvas.Pen.Color:=clRed;
Form1.Image.Canvas.Brush.Color:=clRed;
end;
if bexec and form1.Potentiels1.Checked then begin
Form1.Image.Canvas.Pen.Color:=Ct.cl1;
Form1.Image.Canvas.Brush.Color:=Ct.cl1;
end;
Rond(x+1,y+1);
if bexec and form1.Potentiels1.Checked then begin
Form1.Image.Canvas.Pen.Color:=Ct.cl0;
Form1.Image.Canvas.Brush.Color:=Ct.cl0;
end;
Rond(x-1,y);
Trait(x-1,y,x-1,y+1);
Pivot1(x,y,b);
end;
if Ct.modele='4' then begin
if bexec and form1.Courants1.Checked and (Ct.Parcouru=1) and (not b) then begin
Form1.Image.Canvas.Pen.Color:=clRed;
Form1.Image.Canvas.Brush.Color:=clRed;
end;
if bexec and form1.Potentiels1.Checked then begin
Form1.Image.Canvas.Pen.Color:=Ct.cl0;
Form1.Image.Canvas.Brush.Color:=Ct.cl0;
end;
Rond(x-1,y+1);
if bexec and form1.Potentiels1.Checked then begin
Form1.Image.Canvas.Pen.Color:=Ct.cl1;
Form1.Image.Canvas.Brush.Color:=Ct.cl1;
end;
Rond(x+1,y);
Trait(x+1,y,x+1,y+1);
Pivot2(x,y,b);
end;
if Ct.modele='5' then begin
cl1:=cl; cl2:=cl;cl3:=cl;
if bexec and form1.Courants1.Checked and (Ct.Parcouru=1) and b then begin
cl1:=clRed;
cl3:=clRed;
end;
if bexec and form1.Courants1.Checked and (Ct.Parcouru=1) and (not b) then begin
cl1:=clRed;
cl2:=clRed;
end;
if bexec and form1.Potentiels1.Checked then cl2:=Ct.cl2;
Form1.Image.Canvas.Pen.Color:=cl2;
Form1.Image.Canvas.Brush.Color:=cl2;
Rond(x+1,y+1);
if bexec and form1.Potentiels1.Checked then cl3:=Ct.cl1;
Form1.Image.Canvas.Pen.Color:=cl3;
Form1.Image.Canvas.Brush.Color:=cl3;
Rond(x+1,y);
if bexec and form1.Potentiels1.Checked then cl1:=Ct.cl0;
Form1.Image.Canvas.Pen.Color:=cl1;
Form1.Image.Canvas.Brush.Color:=cl1;
Rond(x-1,y);
Trait(x-1,y,x-1,y+1);
Pivot1(x,y,b);
end;
if Ct.modele='6' then begin
cl1:=cl; cl2:=cl;cl3:=cl;
if bexec and form1.Courants1.Checked and (Ct.Parcouru=1) and b then begin
cl1:=clRed;
cl3:=clRed;
end;
if bexec and form1.Courants1.Checked and (Ct.Parcouru=1) and (not b) then begin
cl1:=clRed;
cl2:=clRed;
end;
if bexec and form1.Potentiels1.Checked then cl2:=Ct.cl2;
Form1.Image.Canvas.Pen.Color:=cl2;
Form1.Image.Canvas.Brush.Color:=cl2;
Rond(x-1,y+1);
if bexec and form1.Potentiels1.Checked then cl3:=Ct.cl1;
Form1.Image.Canvas.Pen.Color:=cl3;
Form1.Image.Canvas.Brush.Color:=cl3;
Rond(x-1,y);
if bexec and form1.Potentiels1.Checked then cl1:=Ct.cl0;
Form1.Image.Canvas.Pen.Color:=cl1;
Form1.Image.Canvas.Brush.Color:=cl1;
Rond(x+1,y);
Trait(x+1,y,x+1,y+1);
Pivot2(x,y,b);
end;
if Ct.modele='7' then begin
if bexec and form1.Courants1.Checked and (Ct.Parcouru=1) and b then begin
Form1.Image.Canvas.Pen.Color:=clRed;
Form1.Image.Canvas.Brush.Color:=clRed;
end;
if bexec and form1.Potentiels1.Checked then begin
Form1.Image.Canvas.Pen.Color:=Ct.cl0;
Form1.Image.Canvas.Brush.Color:=Ct.cl0;
end;
Rond(x+1,y-1);
if bexec and form1.Potentiels1.Checked then begin
Form1.Image.Canvas.Pen.Color:=Ct.cl1;
Form1.Image.Canvas.Brush.Color:=Ct.cl1;
end;
Rond(x,y+1);
Pivot3(x,y,b);
end;
if Ct.modele='8' then begin
if bexec and form1.Courants1.Checked and (Ct.Parcouru=1) and (not b) then begin
Form1.Image.Canvas.Pen.Color:=clRed;
Form1.Image.Canvas.Brush.Color:=clRed;
end;
if bexec and form1.Potentiels1.Checked then begin
Form1.Image.Canvas.Pen.Color:=Ct.cl0;
Form1.Image.Canvas.Brush.Color:=Ct.cl0;
end;
Rond(x-1,y-1);
if bexec and form1.Potentiels1.Checked then begin
Form1.Image.Canvas.Pen.Color:=Ct.cl1;
Form1.Image.Canvas.Brush.Color:=Ct.cl1;
end;
Rond(x,y+1);
Pivot3(x,y,b);
end;
if Ct.modele='9' then begin
cl1:=cl; cl2:=cl;cl3:=cl;
if bexec and form1.Courants1.Checked and (Ct.Parcouru=1) and b then begin
cl1:=clRed;
cl2:=clRed;
end;
if bexec and form1.Courants1.Checked and (Ct.Parcouru=1) and (not b) then begin
cl1:=clRed;
cl3:=clRed;
end;
if bexec and form1.Potentiels1.Checked then cl2:=Ct.cl1;
Form1.Image.Canvas.Pen.Color:=cl2;
Form1.Image.Canvas.Brush.Color:=cl2;
Rond(x+1,y-1);
if bexec and form1.Potentiels1.Checked then cl3:=Ct.cl2;
Form1.Image.Canvas.Pen.Color:=cl3;
Form1.Image.Canvas.Brush.Color:=cl3;
Rond(x-1,y-1);
if bexec and form1.Potentiels1.Checked then cl1:=Ct.cl0;
Form1.Image.Canvas.Pen.Color:=cl1;
Form1.Image.Canvas.Brush.Color:=cl1;
Rond(x,y+1);
Pivot3(x,y,b);
end;
if Ct.modele='10' then begin
if bexec and form1.Potentiels1.Checked then begin
Form1.Image.Canvas.Pen.Color:=Ct.cl0;
Form1.Image.Canvas.Brush.Color:=Ct.cl0;
end;
Trait(x-1,y,x,y);
if bexec and form1.Potentiels1.Checked then begin
Form1.Image.Canvas.Pen.Color:=Ct.cl1;
Form1.Image.Canvas.Brush.Color:=Ct.cl1;
end;
Trait(x,y,x+1,y);
Form1.Image.Canvas.Pen.Width:=1+round(1/zoom);
Form1.Image.Canvas.Brush.Color:=ClrFd;
Form1.Image.Canvas.Ellipse(ecranx(x-0.7),ecrany(y-0.7),ecranx(x+0.75),ecrany(y+0.75));
Form1.Image.Canvas.Brush.Color:=Cl;
if bexec and form1.Potentiels1.Checked then Form1.Image.Canvas.Brush.Color:=Ct.Cl1;
if not b then Form1.Image.Canvas.Chord(ecranx(x-0.7),ecrany(y-0.7),ecranx(x+0.75),ecrany(y+0.75),ecranx(x),ecrany(y+1),ecranx(x),ecrany(y-1));
if b then Form1.Image.Canvas.Chord(ecranx(x-0.7),ecrany(y-0.7),ecranx(x+0.75),ecrany(y+0.75),ecranx(x-1),ecrany(y),ecranx(x+1),ecrany(y));
if bexec and form1.Courants1.Checked and (Ct.Parcouru=1) and b then begin
Form1.Image.Canvas.Pen.Color:=clRed;
Form1.Image.Canvas.Brush.Color:=clRed;
Trait(x-1,y,x+1,y);
end;
end;
if Ct.modele='15' then begin
if bexec and form1.Potentiels1.Checked then begin
Form1.Image.Canvas.Pen.Color:=Ct.cl0;
Form1.Image.Canvas.Brush.Color:=Ct.cl0;
end;
Trait(x-1,y,x,y);
if bexec and form1.Potentiels1.Checked then begin
Form1.Image.Canvas.Pen.Color:=Ct.cl1;
Form1.Image.Canvas.Brush.Color:=Ct.cl1;
end;
Trait(x,y,x+1,y);
Form1.Image.Canvas.Pen.Width:=1+round(1/zoom);
Form1.Image.Canvas.Brush.Color:=ClrFd;
Form1.Image.Canvas.Ellipse(ecranx(x-0.7),ecrany(y-0.7),ecranx(x+0.75),ecrany(y+0.75));
Form1.Image.Canvas.Brush.Color:=Cl;
if bexec and form1.Potentiels1.Checked then Form1.Image.Canvas.Brush.Color:=Ct.Cl1;
if b then Form1.Image.Canvas.Chord(ecranx(x-0.7),ecrany(y-0.7),ecranx(x+0.75),ecrany(y+0.75),ecranx(x),ecrany(y+1),ecranx(x),ecrany(y-1));
if not b then Form1.Image.Canvas.Chord(ecranx(x-0.7),ecrany(y-0.7),ecranx(x+0.75),ecrany(y+0.75),ecranx(x-1),ecrany(y),ecranx(x+1),ecrany(y));
if bexec and form1.Courants1.Checked and (Ct.Parcouru=1) and (not b) then begin
Form1.Image.Canvas.Pen.Color:=clRed;
Form1.Image.Canvas.Brush.Color:=clRed;
Trait(x-1,y,x+1,y);
end;
end;
if Ct.modele='11' then begin
if bexec and form1.Courants1.Checked and (Ct.Parcouru=1) and not(b) then begin
Form1.Image.Canvas.Pen.Color:=clRed;
Form1.Image.Canvas.Brush.Color:=clRed;
end;
if bexec and form1.Potentiels1.Checked then begin
Form1.Image.Canvas.Pen.Color:=Ct.cl1;
Form1.Image.Canvas.Brush.Color:=Ct.cl1;
end;
Rond(x+1,y+1);
if bexec and form1.Potentiels1.Checked then begin
Form1.Image.Canvas.Pen.Color:=Ct.cl0;
Form1.Image.Canvas.Brush.Color:=Ct.cl0;
end;
Rond(x-1,y);
Trait(x-1,y,x-1,y+1);
Pivot1(x,y,b);
Form1.Image.Canvas.Pen.Color:=cl;
Form1.Image.Canvas.Brush.Color:=cl;
if b then begin
Trait(x+0.3,y+1.05,x-0.3,y+0.85);
Trait(x+0.3,y+0.65,x-0.3,y+0.85);
Trait(x+0.3,y+0.65,x-0.3,y+0.45);
Trait(x+0.3,y+0.25,x-0.3,y+0.45);
Trait(x+0.1,y,x+0.1,y-0.3);
Trait(x+0.1,y-0.3,x+0.4,y-0.3);
Trait(x+0.4,y-0.3,x+0.4,y-0.5);
Trait(x+0.4,y-0.5,x-0.4,y-0.5);
Trait(x-0.1,y,x-0.1,y-0.3);
Trait(x-0.1,y-0.3,x-0.4,y-0.3);
Trait(x-0.4,y-0.3,x-0.4,y-0.5);
end else begin
Trait(x+0.3,y+1.1,x-0.3,y+0.95);
Trait(x+0.3,y+0.8,x-0.3,y+0.95);
Trait(x+0.3,y+0.8,x-0.3,y+0.65);
Trait(x+0.3,y+0.5,x-0.3,y+0.65);
Trait(x+0.1,y+0.25,x+0.1,y-0.05);
Trait(x+0.1,y-0.05,x+0.4,y-0.05);
Trait(x+0.4,y-0.05,x+0.4,y-0.25);
Trait(x+0.4,y-0.25,x-0.4,y-0.25);
Trait(x-0.1,y+0.25,x-0.1,y-0.05);
Trait(x-0.1,y-0.05,x-0.4,y-0.05);
Trait(x-0.4,y-0.05,x-0.4,y-0.25);
end;
end;
if Ct.modele='12' then begin
if bexec and form1.Courants1.Checked and (Ct.Parcouru=1) and not(b) then begin
Form1.Image.Canvas.Pen.Color:=clRed;
Form1.Image.Canvas.Brush.Color:=clRed;
end;
if bexec and form1.Potentiels1.Checked then begin
Form1.Image.Canvas.Pen.Color:=Ct.cl0;
Form1.Image.Canvas.Brush.Color:=Ct.cl0;
end;
Rond(x-1,y+1);
if bexec and form1.Potentiels1.Checked then begin
Form1.Image.Canvas.Pen.Color:=Ct.cl1;
Form1.Image.Canvas.Brush.Color:=Ct.cl1;
end;
Rond(x+1,y);
Trait(x+1,y,x+1,y+1);
Pivot2(x,y,b);
Form1.Image.Canvas.Pen.Color:=cl;
Form1.Image.Canvas.Brush.Color:=cl;
if b then begin
Trait(x-0.3,y+1.05,x+0.3,y+0.85);
Trait(x-0.3,y+0.65,x+0.3,y+0.85);
Trait(x-0.3,y+0.65,x+0.3,y+0.45);
Trait(x-0.3,y+0.25,x+0.3,y+0.45);
Trait(x+0.1,y,x+0.1,y-0.3);
Trait(x+0.1,y-0.3,x+0.4,y-0.3);
Trait(x+0.4,y-0.3,x+0.4,y-0.5);
Trait(x+0.4,y-0.5,x-0.4,y-0.5);
Trait(x-0.1,y,x-0.1,y-0.3);
Trait(x-0.1,y-0.3,x-0.4,y-0.3);
Trait(x-0.4,y-0.3,x-0.4,y-0.5);
end else begin
Trait(x-0.3,y+1.1,x+0.3,y+0.95);
Trait(x-0.3,y+0.8,x+0.3,y+0.95);
Trait(x-0.3,y+0.8,x+0.3,y+0.65);
Trait(x-0.3,y+0.5,x+0.3,y+0.65);
Trait(x+0.1,y+0.25,x+0.1,y-0.05);
Trait(x+0.1,y-0.05,x+0.4,y-0.05);
Trait(x+0.4,y-0.05,x+0.4,y-0.25);
Trait(x+0.4,y-0.25,x-0.4,y-0.25);
Trait(x-0.1,y+0.25,x-0.1,y-0.05);
Trait(x-0.1,y-0.05,x-0.4,y-0.05);
Trait(x-0.4,y-0.05,x-0.4,y-0.25);
end;
end;
if Ct.modele='13' then begin
if bexec and form1.Courants1.Checked and (Ct.Parcouru=1) and b then begin
Form1.Image.Canvas.Pen.Color:=clRed;
Form1.Image.Canvas.Brush.Color:=clRed;
end;
if bexec and form1.Potentiels1.Checked then begin
Form1.Image.Canvas.Pen.Color:=Ct.cl1;
Form1.Image.Canvas.Brush.Color:=Ct.cl1;
end;
Rond(x+1,y);
if bexec and form1.Potentiels1.Checked then begin
Form1.Image.Canvas.Pen.Color:=Ct.cl0;
Form1.Image.Canvas.Brush.Color:=Ct.cl0;
end;
Rond(x-1,y);
Pivot1(x,y,b);
Form1.Image.Canvas.Pen.Color:=cl;
Form1.Image.Canvas.Brush.Color:=cl;
if b then begin
Trait(x+0.3,y+1.05,x-0.3,y+0.85);
Trait(x+0.3,y+0.65,x-0.3,y+0.85);
Trait(x+0.3,y+0.65,x-0.3,y+0.45);
Trait(x+0.3,y+0.25,x-0.3,y+0.45);
Trait(x+0.1,y,x+0.1,y-0.3);
Trait(x+0.1,y-0.3,x+0.4,y-0.3);
Trait(x+0.4,y-0.3,x+0.4,y-0.5);
Trait(x+0.4,y-0.5,x-0.4,y-0.5);
Trait(x-0.1,y,x-0.1,y-0.3);
Trait(x-0.1,y-0.3,x-0.4,y-0.3);
Trait(x-0.4,y-0.3,x-0.4,y-0.5);
end else begin
Trait(x+0.3,y+1.1,x-0.3,y+0.95);
Trait(x+0.3,y+0.8,x-0.3,y+0.95);
Trait(x+0.3,y+0.8,x-0.3,y+0.65);
Trait(x+0.3,y+0.5,x-0.3,y+0.65);
Trait(x+0.1,y+0.25,x+0.1,y-0.05);
Trait(x+0.1,y-0.05,x+0.4,y-0.05);
Trait(x+0.4,y-0.05,x+0.4,y-0.25);
Trait(x+0.4,y-0.25,x-0.4,y-0.25);
Trait(x-0.1,y+0.25,x-0.1,y-0.05);
Trait(x-0.1,y-0.05,x-0.4,y-0.05);
Trait(x-0.4,y-0.05,x-0.4,y-0.25);
end;
end;
if Ct.modele='14' then begin
if bexec and form1.Courants1.Checked and (Ct.Parcouru=1) and b then begin
Form1.Image.Canvas.Pen.Color:=clRed;
Form1.Image.Canvas.Brush.Color:=clRed;
end;
if bexec and form1.Potentiels1.Checked then begin
Form1.Image.Canvas.Pen.Color:=Ct.cl0;
Form1.Image.Canvas.Brush.Color:=Ct.cl0;
end;
Rond(x-1,y);
if bexec and form1.Potentiels1.Checked then begin
Form1.Image.Canvas.Pen.Color:=Ct.cl1;
Form1.Image.Canvas.Brush.Color:=Ct.cl1;
end;
Rond(x+1,y);
Pivot2(x,y,b);
Form1.Image.Canvas.Pen.Color:=cl;
Form1.Image.Canvas.Brush.Color:=cl;
if b then begin
Trait(x-0.3,y+1.05,x+0.3,y+0.85);
Trait(x-0.3,y+0.65,x+0.3,y+0.85);
Trait(x-0.3,y+0.65,x+0.3,y+0.45);
Trait(x-0.3,y+0.25,x+0.3,y+0.45);
Trait(x+0.1,y,x+0.1,y-0.3);
Trait(x+0.1,y-0.3,x+0.4,y-0.3);
Trait(x+0.4,y-0.3,x+0.4,y-0.5);
Trait(x+0.4,y-0.5,x-0.4,y-0.5);
Trait(x-0.1,y,x-0.1,y-0.3);
Trait(x-0.1,y-0.3,x-0.4,y-0.3);
Trait(x-0.4,y-0.3,x-0.4,y-0.5);
end else begin
Trait(x-0.3,y+1.1,x+0.3,y+0.95);
Trait(x-0.3,y+0.8,x+0.3,y+0.95);
Trait(x-0.3,y+0.8,x+0.3,y+0.65);
Trait(x-0.3,y+0.5,x+0.3,y+0.65);
Trait(x+0.1,y+0.25,x+0.1,y-0.05);
Trait(x+0.1,y-0.05,x+0.4,y-0.05);
Trait(x+0.4,y-0.05,x+0.4,y-0.25);
Trait(x+0.4,y-0.25,x-0.4,y-0.25);
Trait(x-0.1,y+0.25,x-0.1,y-0.05);
Trait(x-0.1,y-0.05,x-0.4,y-0.05);
Trait(x-0.4,y-0.05,x-0.4,y-0.25);
end;
end;
if Ct.modele='16' then begin // barette
if bexec and form1.Courants1.Checked and (Ct.Parcouru=1) and b then begin
Form1.Image.Canvas.Pen.Color:=clRed;
Form1.Image.Canvas.Brush.Color:=clRed;
end;
if bexec and form1.Potentiels1.Checked then begin
Form1.Image.Canvas.Pen.Color:=Ct.cl0;
Form1.Image.Canvas.Brush.Color:=Ct.cl0;
end;
Rond(x-1,y);
if bexec and form1.Potentiels1.Checked then begin
Form1.Image.Canvas.Pen.Color:=Ct.cl1;
Form1.Image.Canvas.Brush.Color:=Ct.cl1;
end;
Rond(x+1,y);
if b then begin
Trait(x-1,y+0.3,x+1,y+0.3);
Trait(x-1,y-0.3,x+1,y-0.3);
end;
end;
if Ct.modele='17' then begin // fusible
if bexec and form1.Courants1.Checked and (Ct.Parcouru=1) and b then begin
Form1.Image.Canvas.Pen.Color:=clRed;
Form1.Image.Canvas.Brush.Color:=clRed;
end;
if bexec and form1.Potentiels1.Checked then begin
Form1.Image.Canvas.Pen.Color:=Ct.cl0;
Form1.Image.Canvas.Brush.Color:=Ct.cl0;
end;
Rond(x-1,y);
if bexec and form1.Potentiels1.Checked then begin
Form1.Image.Canvas.Pen.Color:=Ct.cl1;
Form1.Image.Canvas.Brush.Color:=Ct.cl1;
end;
Rond(x+1,y);
if b then begin
Trait(x-1,y,x-0.9,y-0.4);
Trait(x-0.9,y-0.4,x-0.7,y-0.7);
Trait(x-0.7,y-0.7,x-0.5,y-0.9);
Trait(x-0.5,y-0.9,x-0.3,y-0.8);
Trait(x-0.3,y-0.8,x-0.1,y-0.4);
Trait(x-0.1,y-0.4,x+0.1,y+0.4);
Trait(x+0.1,y+0.4,x+0.3,y+0.8);
Trait(x+0.3,y+0.8,x+0.5,y+0.9);
Trait(x+0.5,y+0.9,x+0.7,y+0.7);
Trait(x+0.7,y+0.7,x+0.9,y+0.4);
Trait(x+0.9,y+0.4,x+1,y);
end;
end;
if Ct.Visible then begin
Form1.Image.Canvas.Font.Color:=cl;
Form1.Image.Canvas.Brush.Color:=ClrFd;
Form1.Image.Canvas.Brush.Style:=BsClear;
Texte(x+Ct.Pd.X/2,y+Ct.Pd.Y/2,Ct.nom);
end;
end;
procedure DessineCompo(Cp:T_Compo);
var x,y:integer;
cl:TColor;
begin
cl:=clBlack;
if (EnCours or Cp.Select) and not bExec then cl:=clBlue;
Form1.Image.Canvas.Pen.Color:=cl;
Form1.Image.Canvas.Brush.Color:=cl;
x:=Cp.P.X;
y:=Cp.P.Y;
if Cp.modele='1' then begin //resistance
Trait(x-1,y,x-1,y-0.5);
Trait(x+1,y,x+1,y-0.5);
Trait(x-0.33,y-0.5,x-0.33,y+0.5);
Trait(x+0.33,y-0.5,x+0.33,y+0.5);
Trait(x-1,y-0.5,x-0.33,y-0.5);
Trait(x-0.33,y+0.5,x+0.33,y+0.5);
Trait(x+1,y-0.5,x+0.33,y-0.5);
end;
end;
procedure DessineLampe(La:T_Lampe);
var x,y:integer;
cl:TColor;
begin
cl:=clBlack;
if (EnCours or La.Select) and not bExec then cl:=clBlue;
Form1.Image.Canvas.Pen.Color:=cl;
Form1.Image.Canvas.Brush.Color:=cl;
x:=La.P.X; y:=La.P.Y;
if not bexec then begin
Form1.Image.Canvas.Brush.Style:=bsClear;
Form1.Image.Canvas.Ellipse(ecranx(x-1),ecrany(y-1),ecranx(x+1),ecrany(y+1));
end else begin
Form1.Image.Canvas.Brush.Style:=bsSolid;
if La.EtatB then Form1.Image.Canvas.Brush.Color:=La.Clr1 else Form1.Image.Canvas.Brush.Color:=La.Clr0;
Form1.Image.Canvas.Ellipse(ecranx(x-1),ecrany(y-1),ecranx(x+1),ecrany(y+1));
end;
Form1.Image.Canvas.Brush.Style:=bsSolid;
Form1.Image.Canvas.Brush.Color:=cl;
// if La.EtatB and bexec and (form1.Courants1.Checked) then begin
// Form1.Image.Canvas.Pen.Color:=clRed;
// Form1.Image.Canvas.Brush.Color:=clRed;
// end;
if La.modele='1' then begin
Rond(x-1,y); Rond(x+1,y);
end;
if La.modele='2' then begin
Rond(x,y-1); Rond(x,y+1);
end;
if La.Visible then begin
Form1.Image.Canvas.Pen.Color:=cl;
Form1.Image.Canvas.Font.Color:=cl;
Form1.Image.Canvas.Brush.Color:=ClrFd;
Form1.Image.Canvas.Brush.Style:=BsClear;
Texte(x+La.Pd.X/2,y+La.Pd.Y/2,La.nom);
end;
end;
end.