This commit is contained in:
f1iwq2
2023-07-22 21:07:52 +02:00
parent 9957edb6c9
commit de401c95d7
13 changed files with 1618 additions and 270 deletions

View File

@@ -450,6 +450,7 @@ procedure grise_ligne_tco;
frXGlob,frYGlob : real;
procedure calcul_reduction(Var frx,fry : real;DimDestX,DimDestY,DimOrgX,DimOrgY : integer);
procedure calcul_cellules;
procedure sauve_fichier_tco;
procedure zone_TCO(det1,det2,mode: integer);
procedure efface_entoure;
@@ -478,6 +479,7 @@ var fichier : textfile;
procedure lire_fichier_tco;
var fichier : textfile;
s,sa : string;
nv,x,y,i,j,m,adresse,valeur,erreur,FeuOriente,PiedFeu,tailleFont,e,NPar : integer;
trouve_CoulFond,trouve_clVoies,trouve_clAllume,trouve_clGrille,trouve_clCanton,
trouve_clTexte,trouve_clQuai,trouve_matrice,trouve_ratio,trouve_ModeCanton,
@@ -4309,7 +4311,7 @@ end;
end;
if trajet=4 then
begin
moveto(xc,y0);LineTo(xc,yc);lineTo(xf,yf); // -\
moveto(xc,y0);LineTo(xc,yc);lineTo(xf,yf); // -\
end;
end;
@@ -4323,9 +4325,17 @@ begin
begin
frX:=DimDestX/DimOrgX;
frY:=DimDestY/DimOrgY;
//Affiche(formatfloat('0.000000',frY),clyellow);
end;
//Affiche(formatfloat('0.000000',frY),clyellow);
end;
// Affiche dans le TCO en x,y un signal à 90° d'après l'image transmise
// x y en coordonnées pixels
procedure Feu_90G(ImageSource : TImage;x,y : integer;FrX,FrY : real;inverse : boolean);
var p : array[0..2] of TPoint;
TailleY,TailleX : integer;
begin
TailleY:=ImageSource.Picture.Height;
TailleX:=ImageSource.Picture.Width;
// copie à 90°G sans mise à l'échelle dans l'image provisoire
p[0].X:=TailleY; //90;
@@ -4333,7 +4343,7 @@ begin
p[1].X:=TailleY; //90;
p[1].Y:=TailleX; //49;
p[2].X:=0; //0;
TailleX:=ImageSource.Picture.Width;
p[2].Y:=0; //0;
if inverse then
begin
@@ -4347,8 +4357,15 @@ begin
//PimageTemp.Visible:=true;
// copie l'image du signal retournée depuis image temporaire vers tco avec une réduction en mode transparennt
TransparentBlt(PcanvasTCO.Handle,x,y,round(TailleY*FrY),round(TailleX*FrX), // destination
PImageTemp.Canvas.Handle,0,0,TailleY,TailleX,clBlue); // source - clblue est la couleur de transparence
PImageTCO.Picture.Bitmap.Modified:=True; // rafraichit l'affichage sinon le stretchblt n'apparaît pas.
PImageTemp.Canvas.Handle,0,0,TailleY,TailleX,clBlue); // source - clblue est la couleur de transparence
PImageTCO.Picture.Bitmap.Modified:=True; // rafraichit l'affichage sinon le stretchblt n'apparaît pas.
end;
// copie de l'image du signal à 90° dans le canvas source et le tourne de 90° et le met dans l'image temporaire
procedure Feu_90D(ImageSource : TImage;x,y : integer ; FrX,FrY : real;inverse : boolean);
var p : array[0..2] of TPoint;
TailleY,TailleX : integer;
begin
TailleY:=ImageSource.Picture.Height;
TailleX:=ImageSource.Picture.Width;
@@ -4682,6 +4699,7 @@ begin
if pied=1 then LineTo( x+round((x1+60)*frX),y+round((y1+7)*frY) ) else
LineTo( x+round((x1-40)*frX),y+round((y1+7)*frY) ) ;
end;
end;
procedure Efface_Cellule(Canvas : Tcanvas;x,y : integer;Mode : TPenMode);
var x0,y0 : integer;
@@ -4700,12 +4718,13 @@ begin
// if (tco[x-1,y].BImage=12) and (tco[x-1,y].FeuOriente=3) then exit;
end;
}
}
if (x>NbreCellX) or (y>NbreCellY) or (x<1) or (y<1) then exit;
x0:=(x-1)*LargeurCell;
y0:=(y-1)*HauteurCell;
r:=Rect(x0,y0,x0+LargeurCell,y0+HauteurCell);
c:=TCO[x,y].CouleurFond;
with canvas do
begin
Pen.Mode:=mode;
@@ -4714,7 +4733,8 @@ begin
Brush.Color:=c;
Brush.style:=bsSolid;
fillRect(r);
fillRect(r);
end;
end;
// Dessine un signal dans le canvasDest en x,y , dont l'adresse se trouve à la cellule x,y
procedure dessin_Signal(CanvasDest : Tcanvas;x,y : integer );
@@ -4731,6 +4751,7 @@ begin
Orientation:=TCO[x,y].FeuOriente;
if Orientation=0 then Orientation:=1; // cas d'un signal non encore renseigné
index:=index_feu(adresse);
aspect:=feux[index].aspect;
if aspect=0 then aspect:=9;
@@ -4745,6 +4766,7 @@ begin
7 : ImageFeu:=Formprinc.Image7feux;
9 : ImageFeu:=Formprinc.Image9feux;
12 : ImageFeu:=Formprinc.Image2Dir;
13 : ImageFeu:=Formprinc.Image3Dir;
14 : ImageFeu:=Formprinc.Image4Dir;
15 : ImageFeu:=Formprinc.Image5Dir;
16 : ImageFeu:=Formprinc.Image6Dir;
@@ -4756,6 +4778,7 @@ begin
TailleX:=ImageFeu.picture.BitMap.Width;
TailleY:=ImageFeu.picture.BitMap.Height; // taille du feu d'origine (verticale)
PiedFeu:=TCO[x,y].PiedFeu; // gauche ou droite de la voie
// réduction variable en fonction de la taille des cellules. 50 est le Zoom Maxi
calcul_reduction(frx,fry,round(TailleX*LargeurCell/ZoomMax),round(tailleY*HauteurCell/ZoomMax),TailleX,TailleY);
@@ -4767,6 +4790,7 @@ begin
if aspect=7 then begin x0:=round(10*frX); y0:=HauteurCell-round(tailleX*frY);end;
if aspect=5 then begin x0:=0; y0:=round((tailleX/2)*frY);end;
if aspect=4 then begin x0:=0; y0:=round((tailleX/2)*frY);end;
if aspect=3 then begin x0:=0; y0:=round((tailleX/2)*frY);end;
if aspect=2 then begin x0:=0; y0:=round((tailleX/2)*frY);end;
end;
@@ -4782,11 +4806,22 @@ begin
if aspect=2 then begin x0:=round(10*frX); y0:=round((tailleX/2)*frY);end;
end;
// décalage en X pour rapprocher le signal du le bord droit de la cellule pour les feux verticaux
// décalage en X pour rapprocher le signal du le bord droit de la cellule pour les feux verticaux
if orientation=1 then
begin
if aspect=20 then begin x0:=0; y0:=0; end;
if aspect=9 then begin x0:=0; y0:=0; end;
if aspect=7 then begin x0:=0; y0:=0; end;
if aspect=5 then begin x0:=round(13*frx); y0:=0;end;
if aspect=4 then begin x0:=round(13*frx); y0:=0;end;
if aspect=3 then begin x0:=round(13*frx); y0:=0;end;
if aspect=2 then begin x0:=round(13*frx); y0:=0;end;
end;
x0:=x0+xp;y0:=y0+yp;
tco[x,y].x:=x0;
tco[x,y].y:=y0;
// affichage du signal et du pied - orientation verticale
if (Orientation=1) then
begin
@@ -4799,9 +4834,10 @@ begin
FormTCO.ImageTemp.Canvas.Handle,0,0,TailleX,TailleY,clBlue);
end
else
if (Orientation=1) then
// copie avec mise à l'échelle de l'image du signal
TransparentBlt(canvasDest.Handle,x0,y0,round(TailleX*frX),round(TailleY*frY),
ImageFeu.Canvas.Handle,0,0,TailleX,TailleY,clBlue);
PImageTCO.Picture.Bitmap.Modified:=True; // rafraichit l'affichage sinon le stretchblt n'apparaît pas.
case aspect of
20 : affiche_pied_Vertical5G(x0+round(10*frx),y0+hauteurCell-round(10*fry),frX,frY,piedFeu);
@@ -4814,9 +4850,10 @@ begin
end;
end;
// affichage du feu et du pieds - orientation 90°G
if Orientation=2 then
begin
Feu_90G(ImageFeu,x0,y0,frX,frY,feux[index].contrevoie); // ici on passe l'origine du signal
// dessiner le pied
case aspect of
20 : affiche_pied5G_90G(x0+2,y0+round(fry*5),frX,frY,piedFeu);
@@ -4845,7 +4882,8 @@ end;
end;
end;
// allumage des feux du signal -----------------
// allumage des feux du signal -----------------
dessine_feu_mx(canvasDest,x0,y0,frX,frY,adresse,orientation);
end;
@@ -4891,7 +4929,7 @@ begin
4 : dessin_4(PCanvasTCO,X,Y,Mode);
5 : dessin_5(PCanvasTCO,X,Y,Mode);
6 : dessin_6(PCanvasTCO,X,Y,Mode);
7 : dessin_7(PCanvasTCO,X,Y,Mode);
7 : dessin_7(PCanvasTCO,X,Y,Mode);
8 : dessin_8(PCanvasTCO,X,Y,Mode);
9 : dessin_9(PCanvasTCO,X,Y,mode);
10 : dessin_10(PCanvasTCO,X,Y,mode);
@@ -5004,10 +5042,29 @@ begin
Font.Color:=tco[x,y].coulFonte;
TextOut(xOrg+round(20*frXGlob),yOrg+HauteurCell-round(14*frYGlob),s);
end;
end;
end;
// autres détecteurs
if ((Bimage=6) or (Bimage=11) or (Bimage=16)) and (adresse<>0) then
begin // Adresse de l'élément
with PCanvasTCO do
begin
Brush.Color:=tco[x,y].CouleurFond;
Font.Color:=tco[x,y].coulFonte;;
Font.Style:=style(tco[x,y].FontStyle);
Font.Name:='Arial';
TextOut(xOrg+round(28*frXGlob),yOrg+round(2*fryGlob),s);
//exit;
end;
end;
// adresse des signaux
if (BImage=30) and (adresse<>0) then
begin
index:=index_feu(adresse);
aspect:=feux[index].Aspect;
oriente:=TCO[x,y].FeuOriente;
pied:=TCO[x,y].PiedFeu;
inverse:=feux[index].contrevoie;
xt:=0;yt:=0;
if (aspect=20) and (Oriente=1) then
@@ -5028,9 +5085,9 @@ begin
else begin xt:=largeurCell+round(10*frxGlob);yt:=round(1*fryGlob);end;
end;
if (aspect=9) and (Oriente=1) then begin xt:=LargeurCell-round(25*frXGlob);yt:=2*HauteurCell-round(25*fryGlob);end;
if (aspect=9) and (Oriente=2) then begin xt:=round(10*frXGlob);yt:=HauteurCell-round(17*frYGlob);end; // orientation G
if (aspect=9) and (Oriente=3) then begin xt:=LargeurCell+round(25*frXglob);yt:=1;end;
if (aspect=7) and (Oriente=1) then begin xt:=LargeurCell-round(25*frXGlob);yt:=HauteurCell;end;
if (aspect=9) and (Oriente=2) then begin xt:=round(10*frXGlob);yt:=HauteurCell-round(17*frYGlob);end; // orientation G
if (aspect=9) and (Oriente=3) then begin xt:=LargeurCell+round(25*frXglob);yt:=1;end;
if (aspect=7) and (Oriente=1) then begin xt:=LargeurCell-round(25*frXGlob);yt:=HauteurCell;end;
if (aspect=7) and (Oriente=2) then begin xt:=round(10*frXGlob);yt:=HauteurCell-round(15*frYGlob);end;
if (aspect=7) and (Oriente=3) then begin xt:=LargeurCell+2;yt:=1;end;
if (aspect=5) and (Oriente=1) then begin xt:=round(10*frXGlob);yt:=HauteurCell+round(25*fryGlob);end;
@@ -6104,7 +6161,6 @@ begin
ImageTCO.Picture.BitMap.Width:=LargeurCell*NbreCellX;
PCanvasTCO:=FormTCO.ImageTCO.Picture.Bitmap.Canvas;
PBitMapTCO:=FormTCO.ImageTCO.Picture.Bitmap;
PBitMapTCO:=FormTCO.ImageTCO.Picture.Bitmap;
PImageTCO:=FormTCO.ImageTCO;
@@ -8032,7 +8088,7 @@ begin
if (Target as TImage).Name<>'ImageTCO' then exit;
if (x=0) and (y=0) then exit;
BitBlt(imageTCO.canvas.handle,oldx,oldy,LargeurCell,HauteurCell,oldbmp.canvas.handle,0,0,SRCCOPY);
efface_entoure;
efface_entoure;
TCO_modifie:=true;
Xclic:=X;YClic:=Y;
XclicCell:=Xclic div largeurCell +1;
@@ -8136,7 +8192,6 @@ begin
// ancien signal orienté orienté 90D
if tco[XClicCell,YClicCell].FeuOriente=3 then
begin
Efface_Cellule(PCanvasTCO,xClicCell,yClicCell,PmCopy);
Efface_Cellule(PCanvasTCO,xClicCell,yClicCell,PmCopy);
if aspect>=4 then Efface_Cellule(PCanvasTCO,xClicCell+1,yClicCell,PmCopy);
end;
@@ -8185,7 +8240,6 @@ begin
begin
Efface_Cellule(PCanvasTCO,xClicCell,yClicCell,PmCopy);
// si le signal occupe 2 cellules
if aspect>=4 then Efface_Cellule(PCanvasTCO,xClicCell+1,yClicCell,PmCopy);
if aspect>=4 then Efface_Cellule(PCanvasTCO,xClicCell+1,yClicCell,PmCopy);
end;
@@ -8368,7 +8422,7 @@ begin
if i=0 then exit;
TFormPilote.Create(Self);
with formPilote do
begin
begin
show;
ImagePilote.top:=40;ImagePilote.left:=220;
ImagePilote.Parent:=FormPilote;
@@ -8381,7 +8435,7 @@ begin
feux[0].EtatSignal:=feux[i].EtatSignal;
LabelNbFeux.Visible:=False;
EditNbreFeux.Visible:=false;
EditNbreFeux.Visible:=false;
GroupBox1.Visible:=true;
GroupBox2.Visible:=true;
efface_entoure;