unit Unit5;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, RTTICtrls, RTTIGrids, Forms, Controls, Graphics,
  Dialogs, Grids, CheckLst, ValEdit, ComCtrls, StdCtrls, ExtCtrls, types, AccPampa,Refinar,Unit6;

type

  { TForm5 }      {PARAMETROS CAPA 1}

  TForm5 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    CheckBox1: TCheckBox;
    CheckGroup1: TCheckGroup;
    CheckGroup2: TCheckGroup;
    Edit1: TEdit;
    GroupBox1: TGroupBox;
    GroupBox2: TGroupBox;
    GroupBox3: TGroupBox;
    GroupBox4: TGroupBox;
    GroupBox5: TGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    PageControl1: TPageControl;
    PageControl2: TPageControl;
    TabSheet1: TTabSheet;
    TabSheet2: TTabSheet;
    TabSheet3: TTabSheet;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Form5new();
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form5: TForm5;

implementation

{$R *.lfm}

{ TForm5 }



procedure TForm5.FormCreate(Sender: TObject);
   Var i,j:Integer;
begin

     For i:=0 To 30 Do Begin
     Cd1[i]:=TEdit.Create(Self);
     Cd1[i].parent:=Groupbox1;
     Cd1[i].Visible:=False;
     ChCd1[i]:=TCheckbox.Create(Self);
     ChCd1[i].Parent:=Groupbox1;
     ChCd1[i].Visible:=False;
     ChCd1[i].Autosize:=True;
     Cnd1[i]:=TEdit.Create(Self);
     Cnd1[i].parent:=Groupbox2;
     Cnd1[i].Visible:=False;
     ChCnd1[i]:=TCheckbox.Create(Self);
     ChCnd1[i].Parent:=Groupbox2;
     ChCnd1[i].Visible:=False;

     Eld1[i]:=TLabel.Create(Self);
     Eld1[i].parent:=Groupbox1;
     Eld1[i].Visible:=False;
     Elnd1[i]:=TLabel.Create(Self);
     Elnd1[i].parent:=Groupbox2;
     Elnd1[i].Visible:=False;

     NL1[i]:=TEdit.Create(Self);
     NL1[i].parent:=Groupbox3;
     NL1[i].Visible:=False;

     Elem1[i]:=TLabel.Create(Self);
     Elem1[i].parent:=Groupbox3;
     Elem1[i].Visible:=False;

     PEl1[i]:=TTabsheet.Create(Self);
     PEl1[i].Parent:=PageControl2;
     PEl1[i].Visible:=False;

     CLineas1[i]:=TGroupbox.Create(Self);
     CLineas1[i].Parent:=PEl1[i];
     CLineas1[i].Visible:=False;
     CLineas1[i].Autosize:=True;

     CBordes1[i]:=TGroupbox.Create(Self);
     CBordes1[i].Parent:=PEl1[i];
     CBordes1[i].Visible:=False;
     CBordes1[i].Autosize:=True;

     CEnergy1[i]:=TGroupBox.Create(Self);
     CEnergy1[i].Parent:=PEl1[i];
     CEnergy1[i].Visible:=False;
     CEnergy1[i].Autosize:=True;

     Crtps1[i]:=TGroupBox.Create(Self);
     Crtps1[i].Parent:=PEl1[i];
     Crtps1[i].Visible:=False;
     Crtps1[i].Autosize:=True;

     CTail1[i]:=TGroupBox.Create(Self);
     CTail1[i].Parent:=PEl1[i];
     CTail1[i].Visible:=False;
     CTail1[i].Autosize:=True;

     CBeta1[i]:=TGroupBox.Create(Self);
     CBeta1[i].Parent:=PEl1[i];
     CBeta1[i].Visible:=False;
     CBeta1[i].Autosize:=True;

     CPerfil1[i]:=TGroupBox.Create(Self);
     CPerfil1[i].Parent:=PEl1[i];
     CPerfil1[i].Visible:=False;
     CPerfil1[i].Autosize:=True;

     G[i]:=TEdit.Create(Self);
     G[i].parent:=Groupbox4;
     G[i].Visible:=False;
     ChG[i]:=TCheckbox.Create(Self);
     ChG[i].parent:=Groupbox4;
     ChG[i].Visible:=False;
     FE[i]:=TEdit.Create(Self);
     FE[i].parent:=Groupbox5;
     FE[i].Visible:=False;
   end;

   For i:=0 To 30 Do Begin
     For j:=0 To 20 Do Begin
       Lineas1[i,j]:=TEdit.Create(Self);
       Lineas1[i,j].Parent:=CLineas1[i];
       Lineas1[i,j].Visible:=False;

       Bordes1[i,j]:=TEdit.Create(Self);
       Bordes1[i,j].Parent:=CBordes1[i];
       Bordes1[i,j].Visible:=False;

       Energias1[i,j]:=TEdit.Create(Self);
       Energias1[i,j].Parent:=CEnergy1[i];
       Energias1[i,j].Visible:=False;
       ChEnergias1[i,j]:=TCheckBox.Create(Self);
       ChEnergias1[i,j].Parent:=CEnergy1[i];
       ChEnergias1[i,j].Visible:=False;

       Rtps1[i,j]:=TEdit.Create(Self);
       Rtps1[i,j].Parent:=CRtps1[i];
       Rtps1[i,j].Visible:=False;
       ChRtps1[i,j]:=TCheckbox.Create(Self);
       ChRtps1[i,j].Parent:=CRtps1[i];
       ChRtps1[i,j].Visible:=False;

       Tail1[i,j]:=TEdit.Create(Self);
       Tail1[i,j].Parent:=CTail1[i];
       Tail1[i,j].Visible:=False;
       ChTail1[i,j]:=TCheckbox.Create(Self);
       ChTail1[i,j].Parent:=CTail1[i];
       ChTail1[i,j].Visible:=False;

       Beta1[i,j]:=TEdit.Create(Self);
       Beta1[i,j].Parent:=CBeta1[i];
       Beta1[i,j].Visible:=False;
       ChBeta1[i,j]:=TCheckbox.Create(Self);
       ChBeta1[i,j].Parent:=CBeta1[i];
       ChBeta1[i,j].Visible:=False;

       Perfil1[i,j]:=TEdit.Create(Self);
       Perfil1[i,j].Parent:=CPerfil1[i];
       Perfil1[i,j].Visible:=False;
     end;
   end;
   For i:=0 To 30 Do Begin
     Cd1[i].Visible:=False;
     ChCd1[i].Visible:=False;
     Eld1[i].Visible:=False;
     Cnd1[i].Visible:=False;
     ChCnd1[i].Visible:=False;
     Elnd1[i].Visible:=False;
     NL1[i].Visible:=False;
     Elem1[i].Visible:=False;
     PEl1[i].Visible:=False;
     PEl1[i].Caption:='';
     CLineas1[i].Visible:=False;
     CBordes1[i].Visible:=False;
     CEnergy1[i].Visible:=False;
     Crtps1[i].Visible:=False;
     CTail1[i].Visible:=False;
     CBeta1[i].Visible:=False;
     CPerfil1[i].Visible:=False;
     G[i].Visible:=False;
     ChG[i].Visible:=False;
     FE[i].Visible:=False;
   end;

end;

procedure TForm5.Form5new();
  Var i,j:Integer;
begin
  For i:=1 To 30 Do Nlin[i]:=0;
  NG:=0;
  For i:=1 To 100 Do Grupo[i]:='';
  For i:=1 To 300 Do Desc[i]:='';
  For i:=1 To 9 Do Fesc[i]:=0.0;
  For i:=1 To Np Do Begin
      P0[i]:=0.0;
      Cod[i]:=0;
  end;
  For i:=1 To 30 Do For j:=1 To 20 Do Begin
      Perf[i,j]:=' ';
  end;
  For i:=0 To 30 Do For j:=0 To 20 Do Begin
    Lineas1[i,j].Visible:=False;
    Bordes1[i,j].Visible:=False;
    Energias1[i,j].Visible:=False;
    ChEnergias1[i,j].Visible:=False;
    ChEnergias1[i,j].Checked:=False;
    Rtps1[i,j].Visible:=False;
    ChRtps1[i,j].Visible:=False;
    ChRtps1[i,j].Checked:=False;
    Tail1[i,j].Visible:=False;
    ChTail1[i,j].Visible:=False;
    ChTail1[i,j].Checked:=False;
    Beta1[i,j].Visible:=False;
    ChBeta1[i,j].Visible:=False;
    ChBeta1[i,j].Checked:=False;
    Perfil1[i,j].Visible:=False;
  end;
  For i:=0 To 30 Do Begin
    Cd1[i].Visible:=False;
    Cd1[i].Caption:='0';
    ChCd1[i].Visible:=False;
    Eld1[i].Visible:=False;
    Eld1[i].Caption:='';
    Cnd1[i].Visible:=False;
    ChCnd1[i].Visible:=False;
    Elnd1[i].Visible:=False;
    NL1[i].Visible:=False;
    Elem1[i].Visible:=False;
    PEl1[i].Visible:=False;
    PEl1[i].Caption:='';
    CLineas1[i].Visible:=False;
    CBordes1[i].Visible:=False;
    CEnergy1[i].Visible:=False;
    Crtps1[i].Visible:=False;
    CTail1[i].Visible:=False;
    CBeta1[i].Visible:=False;
    CPerfil1[i].Visible:=False;
    G[i].Visible:=False;
    ChG[i].Visible:=False;
    FE[i].Visible:=False;
  end;
end;


procedure TForm5.Button1Click(Sender: TObject);  {Aceptar}
   Var i,j,l:Integer;
begin
    For i:=0 To Ndet-1 Do Zdet[i+1]:=StrToInt(Zd1[i].Text);
    For i:=0 To Nnodet-1 Do Znodet[i+1]:=StrToInt(Znd1[i].Text);
    NG:=StrToInt(Edit1.Text);
    NL:=0;
    For i:=1 To Ndet Do NL:=NL+StrToInt(NL1[i-1].Text);
    For i:=NPG+NG+4*NL+1 to NPG+NG+4*NL+Ndet Do Begin
        P0[i]:=StrToFloat(Cd1[i-NPG-1-NG-4*NL].Text);
        if ChCd1[i-NPG-1-NG-4*NL].Checked=True then Cod[i]:=1
        else  Cod[i]:=0;
    end;
    For i:=NPG+NG+4*NL+Ndet+1 to NPG+NG+4*NL+Nel Do Begin
        P0[i]:=StrToFloat(Cnd1[i-NPG-1-NG-4*NL-Ndet].Text);
        if ChCnd1[i-NPG-1-NG-4*NL-Ndet].Checked=True then  Cod[i]:=1
        else  Cod[i]:=0;
     end;
     For i:=0 To Ndet Do Nlin[i+1]:=StrToInt(NL1[i].Text);
     l:=0;
     For i:=0 To Ndet-1 Do For j:=0 To Nlin[i+1]-1 do Begin
             Inc(l);
             Desc[l]:=Lineas1[i,j].Text;
             Borde[i+1,j+1]:=Bordes1[i,j].Text;
             P0[l+NPG]:=StrToFloat(Energias1[i,j].Text);
             if ChEnergias1[i,j].Checked=True then  Cod[l+NPG]:=1
             else  Cod[l+NPG]:=0;
             P0[NL+l+NPG]:=StrToFloat(Rtps1[i,j].Text);
             if ChRtps1[i,j].Checked=True then  Cod[NL+l+NPG]:=1
             else   Cod[NL+l+NPG]:=0;
             P0[2*NL+l+NPG]:=StrToFloat(Tail1[i,j].Text);
             if ChTail1[i,j].Checked=True then  Cod[2*NL+l+NPG]:=1
             else   Cod[2*NL+l+NPG]:=0;
             P0[3*NL+l+NPG]:=StrToFloat(Beta1[i,j].Text);
             if ChBeta1[i,j].Checked=True then  Cod[3*NL+l+NPG]:=1
             else   Cod[3*NL+l+NPG]:=0;
             Perf[i+1,j+1]:=Perfil1[i,j].Text[1];
     end;
     For i:=0 To NG-1 Do Begin
         Grupo[i+1]:=G[i].Text;
         P0[NPG+4*NL+i+1]:=StrToFloat(FE[i].Text);
         if ChG[i].Checked=True then Cod[NPG+4*NL+i+1]:=1
         else  Cod[NPG+4*NL+i+1]:=0;
     end;
     If(CheckBox1.Checked=True) then ff:=True
     Else If(CheckBox1.Checked=False) then ff:=False;
    ContNPR;
    Form5.Close;
end;

procedure TForm5.Button2Click(Sender: TObject); {Nro de Lineas:Aplicar}
  Var i,j,NLmayor:Integer;
begin

  For i:=0 To 30 Do For j:=0 To 20 Do Lineas1[i,j].Visible:=False;
  For i:=0 To 30 Do For j:=0 To 20 Do Bordes1[i,j].Visible:=False;
  For i:=0 To 30 Do For j:=0 To 20 Do Energias1[i,j].Visible:=False;
  For i:=0 To 30 Do For j:=0 To 20 Do ChEnergias1[i,j].Visible:=False;
  For i:=0 To 30 Do For j:=0 To 20 Do Rtps1[i,j].Visible:=False;
  For i:=0 To 30 Do For j:=0 To 20 Do ChRtps1[i,j].Visible:=False;
  For i:=0 To 30 Do For j:=0 To 20 Do Tail1[i,j].Visible:=False;
  For i:=0 To 30 Do For j:=0 To 20 Do ChTail1[i,j].Visible:=False;
  For i:=0 To 30 Do For j:=0 To 20 Do Beta1[i,j].Visible:=False;
  For i:=0 To 30 Do For j:=0 To 20 Do ChBeta1[i,j].Visible:=False;
  For i:=0 To 30 Do For j:=0 To 20 Do Perfil1[i,j].Visible:=False;
  For i:=0 To Ndet-1 Do Begin
     For j:=0 To StrToInt(NL1[i].Caption)-1 Do Begin
       Lineas1[i,j].Visible:=True;
       Lineas1[i,j].Left:=2;
       Lineas1[i,j].Top:=2+30*j;
       Lineas1[i,j].height:=27;
       Lineas1[i,j].width:=80;

       Bordes1[i,j].Visible:=True;
       Bordes1[i,j].Left:=2;
       Bordes1[i,j].Top:=2+30*j;
       Bordes1[i,j].height:=27;
       Bordes1[i,j].width:=80;

       ChEnergias1[i,j].Visible:=True;
       ChEnergias1[i,j].Left:=2;
       ChEnergias1[i,j].Top:=2+30*j;
       Energias1[i,j].Visible:=True;
       Energias1[i,j].Left:=2+30;
       Energias1[i,j].Top:=2+30*j;
       Energias1[i,j].height:=27;
       Energias1[i,j].width:=80;

       ChRtps1[i,j].Visible:=True;
       ChRtps1[i,j].Left:=2;
       ChRtps1[i,j].Top:=2+30*j;
       Rtps1[i,j].Visible:=True;
       Rtps1[i,j].Left:=2+30;
       Rtps1[i,j].Top:=2+30*j;
       Rtps1[i,j].height:=27;
       Rtps1[i,j].width:=80;

       ChTail1[i,j].Visible:=True;
       ChTail1[i,j].Left:=2;
       ChTail1[i,j].Top:=2+30*j;
       Tail1[i,j].Visible:=True;
       Tail1[i,j].Left:=2+30;
       Tail1[i,j].Top:=2+30*j;
       Tail1[i,j].height:=27;
       Tail1[i,j].width:=80;

       ChBeta1[i,j].Visible:=True;
       ChBeta1[i,j].Left:=2;
       ChBeta1[i,j].Top:=2+30*j;
       Beta1[i,j].Visible:=True;
       Beta1[i,j].Left:=2+30;
       Beta1[i,j].Top:=2+30*j;
       Beta1[i,j].height:=27;
       Beta1[i,j].width:=80;

       Perfil1[i,j].Visible:=True;
       Perfil1[i,j].Left:=2;
       Perfil1[i,j].Top:=2+30*j;
       Perfil1[i,j].height:=27;
       Perfil1[i,j].width:=45;
     end;
  end;
  NLmayor:=StrToInt(NL1[0].Caption);
  For i:=1 To Ndet-1 Do Begin
     if(StrToInt(NL1[i].Caption)>NLmayor) Then
     NLmayor:=StrToInt(NL1[i].Caption);
  end;
  If(NLMayor>=7) Then Begin
     PageControl1.Height:= 312+(29*(NLmayor-7));
     PageControl2.Height:= 272+(29*(NLmayor-7));
  end;
  If (NLmayor<7)Then Begin
     PageControl1.Height:=312;
     PageControl2.Height:=272;
  end;
  Button1.Top:=PageControl1.Height+12;
end;

procedure TForm5.Button3Click(Sender: TObject);    {Grupos: Aplicar}
  Var i:Integer;
begin
  NG:=StrToInt(Edit1.Text);
  For i:=0 To 30 Do  G[i].Visible:=False;
  For i:=0 To 30 Do  ChG[i].Visible:=False;
  For i:=0 To 30 Do  FE[i].Visible:=False;
  For i:=0 To StrToInt(Edit1.Text)-1 Do Begin
       ChG[i].Visible:=True;
       ChG[i].Left:=2;
       ChG[i].Top:=20+30*i;
       G[i].Visible:=True;
       G[i].Left:=25;
       G[i].Top:=20+30*i;
       G[i].height:=27;
       G[i].width:=80;

       FE[i].Visible:=True;
       FE[i].Left:=2;
       FE[i].Top:=20+30*i;
       FE[i].height:=27;
       FE[i].width:=120;
  end;
end;

procedure TForm5.FormActivate(Sender: TObject);
  Var i,j,l:Integer;
begin
  Button2.Top:=40+30*Ndet;
  For i:=0 To Ndet-1 Do Zd1[i].Text:=FloatToStr(Zdet[i+1]);
  For i:=0 To Nnodet-1 Do Znd1[i].Text:=FloatToStr(Znodet[i+1]);
  {Para que se muestren los cuadros con las concentraciones, el numero de lineas, etc, de Form5 y Form7  }
  For i:=0 To Ndet-1 Do Begin
    Cd1[i].Visible:=True;
    Cd1[i].Left:=74;
    Cd1[i].Top:=30+28*i;
    Cd1[i].height:=27;
    Cd1[i].width:=100;

    ChCd1[i].Visible:=True;
    ChCd1[i].Left:=2;
    ChCd1[i].Top:=30+28*i;
    Groupbox1.Autosize:=True;

    Eld1[i].Visible:=True;
    Eld1[i].Caption:=Sim[StrToInt(Zd1[i].Text)]+':';
    Eld1[i].Left:=25;
    Eld1[i].Top:=35+28*i;
    Eld1[i].height:=18;
    Eld1[i].width:=46;
  {Numero de lineas y simbolo para cada elemento de la capa 1}
    NL1[i].Visible:=True;
    NL1[i].Left:=50;
    NL1[i].Top:=40+30*i;
    NL1[i].height:=27;
    NL1[i].width:=80;

    Elem1[i].Visible:=True;
    Elem1[i].Caption:=Sim[StrToInt(Zd1[i].Text)]+':';
    Elem1[i].Left:=6;
    Elem1[i].Top:=45+30*i;
    Elem1[i].height:=18;
    Elem1[i].width:=46;
   {Pestaña con la informacion de cada elemento para la capa 1}
    PEl1[i].Visible:=True;
    PEl1[i].Caption:=Sim[StrToInt(Zd1[i].Text)];
   {cuadros con informacion de los elementos (nombre de la linea, borde, energia,
   RTP, ancho) para la capa 1}
    CLineas1[i].Visible:=True;
    CLineas1[i].Caption:='Lines';
    CLineas1[i].Height:=268;
    CLineas1[i].Width:=90;
    CLineas1[i].Top:=2;
    CLineas1[i].Left:=2;

    CBordes1[i].Visible:=True;
    CBordes1[i].Caption:='Edges';
    CBordes1[i].Height:=268;
    CBordes1[i].Width:=90;
    CBordes1[i].Top:=2;
    CBordes1[i].Left:=94;

    CEnergy1[i].Visible:=True;
    CEnergy1[i].Caption:='Energy';
    CEnergy1[i].Height:=268;
    CEnergy1[i].Width:=90;
    CEnergy1[i].Top:=2;
    CEnergy1[i].Left:=186;

    Crtps1[i].Visible:=True;
    Crtps1[i].Caption:='RTP';
    Crtps1[i].Height:=268;
    Crtps1[i].Width:=90;
    Crtps1[i].Top:=2;
    Crtps1[i].Left:=308;

    CTail1[i].Visible:=True;
    CTail1[i].Caption:='Tail';
    CTail1[i].Height:=268;
    CTail1[i].Width:=90;
    CTail1[i].Top:=2;
    CTail1[i].Left:=430;

    CBeta1[i].Visible:=True;
    CBeta1[i].Caption:='Beta';
    CBeta1[i].Height:=268;
    CBeta1[i].Width:=90;
    CBeta1[i].Top:=2;
    CBeta1[i].Left:=552;

    CPerfil1[i].Visible:=True;
    CPerfil1[i].Caption:='Profile';
    CPerfil1[i].Height:=20;
    CPerfil1[i].Width:=100;
    CPerfil1[i].Top:=2;
    CPerfil1[i].Left:=674;
  end;
  For i:=0 To Nnodet-1 Do Begin
    Cnd1[i].Visible:=True;
    Cnd1[i].Left:=70;
    Cnd1[i].Top:=30+28*i;
    Cnd1[i].height:=27;
    Cnd1[i].width:=100;

    ChCnd1[i].Visible:=True;
    ChCnd1[i].Left:=2;
    ChCnd1[i].Top:=30+28*i;

    Elnd1[i].Visible:=True;
    Elnd1[i].Caption:=Sim[StrToInt(Znd1[i].Text)]+':';
    Elnd1[i].Left:=25;
    Elnd1[i].Top:=35+28*i;
    Elnd1[i].height:=18;
    Elnd1[i].width:=46;
  end;
  Edit1.text:=IntToStr(NG);
  For i:=0 To NG-1 Do Begin
      ChG[i].Visible:=True;
      ChG[i].Left:=2;
      ChG[i].Top:=20+30*i;
      G[i].Visible:=True;
      G[i].Left:=25;
      G[i].Top:=20+30*i;
      G[i].height:=27;
      G[i].width:=80;

      FE[i].Visible:=True;
      FE[i].Left:=25;
      FE[i].Top:=20+30*i;
      FE[i].height:=27;
      FE[i].width:=120;
  end;
  For i:=NPG+NG+4*NL+1 to NPG+NG+4*NL+Ndet Do Begin
     Cd1[i-NPG-1-NG-4*NL].Text:=FloatToStr(P0[i]);
     if Cod[i]=1 then  ChCd1[i-NPG-1-NG-4*NL].Checked:=True
     else  ChCd1[i-NPG-1-NG-4*NL].Checked:=False;
  end;
  For i:=NPG+NG+4*NL+Ndet+1 to NPG+NG+4*NL+Nel Do Begin
     Cnd1[i-NPG-1-NG-4*NL-Ndet].Text:=FloatToStr(P0[i]);
     if Cod[i]=1 then  ChCnd1[i-NPG-1-NG-4*NL-Ndet].Checked:=True
     else  ChCnd1[i-NPG-1-NG-4*NL-Ndet].Checked:=False;
  end;
  For i:=0 To Ndet Do NL1[i].Text:=FloatToStr(Nlin[i+1]);
  Form5.Button2Click(Form5);
  l:=0;
  For i:=0 To 30 Do For j:=0 To 20 Do Begin
      Lineas1[i,j].Text:='';
      Bordes1[i,j].Text:='';
      Energias1[i,j].Text:='';
      ChEnergias1[i,j].Checked:= False;
      Rtps1[i,j].Text:='';
      ChRtps1[i,j].Checked:= False;
      Tail1[i,j].Text:='';
      ChTail1[i,j].Checked:= False;
      Beta1[i,j].Text:='';
      ChBeta1[i,j].Checked:= False;
      Perfil1[i,j].Text:='';
  end;
  For i:=0 To Ndet-1 Do For j:=0 To Nlin[i+1]-1 do Begin
          Inc(l);
          Lineas1[i,j].Text:=Desc[l];
          Bordes1[i,j].Text:=Borde[i+1,j+1];
          Energias1[i,j].Text:=FloatToStr(E[i+1,j+1]);{P0[l+NPG]);}
          if Cod[l+NPG]=1 then  ChEnergias1[i,j].Checked:=True
          else  ChEnergias1[i,j].Checked:= False;
          Rtps1[i,j].Text:=FloatToStr(Fr[i+1,j+1]);{P0[NL+l+NPG]);}
          if Cod[NL+l+NPG]=1 then  ChRtps1[i,j].Checked:=True
          else  ChRtps1[i,j].Checked:= False;
          Tail1[i,j].Text:=FloatToStr(Tail[i+1,j+1]);{P0[NL+l+NPG]);}
          if Cod[2*NL+l+NPG]=1 then  ChTail1[i,j].Checked:=True
          else  ChTail1[i,j].Checked:= False;
          Beta1[i,j].Text:=FloatToStr(Beta[i+1,j+1]);{P0[NL+l+NPG]);}
          if Cod[3*NL+l+NPG]=1 then  ChBeta1[i,j].Checked:=True
          else  ChBeta1[i,j].Checked:= False;
          Perfil1[i,j].Text:=Perf[i+1,j+1];
  end;
  For i:=0 To 30 Do Begin
      G[i].Text:='';
      FE[i].Text:='';
      ChG[i].Checked:= False;
  end;
  For i:=0 To NG-1 Do Begin
      G[i].Text:=Grupo[i+1];
      FE[i].Text:=FloatToStr(P0[NPG+4*NL+i+1]);
      if Cod[NPG+4*NL+i+1]=1 then  ChG[i].Checked:=True
      else  ChG[i].Checked:= False;
  end;

   if(GroupBox3.Height>PageControl1.Height) Then Begin
      PageControl1.Height:=GroupBox3.Height+60;
      Button1.Top:=PageControl1.Height+30
   end;
end;
end.

