Скачиваний:
5
Добавлен:
01.05.2014
Размер:
9 Кб
Скачать
☆
unit Visual;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls, Buttons, Grids, Tabs, ImgList, Sistol, Main;

type
  TForm2 = class(TForm)
    Panel2: TPanel;
    BitBtn1: TBitBtn;
    Bevel2: TBevel;
    Panel3: TPanel;
    ProcessGrid: TStringGrid;
    ElGrid1: TStringGrid;
    ElGrid2: TStringGrid;
    ElGrid3: TStringGrid;
    ElGrid4: TStringGrid;
    ElGrid5: TStringGrid;
    ElGrid6: TStringGrid;
    ElGrid7: TStringGrid;
    ElGrid8: TStringGrid;
    ElGrid9: TStringGrid;
    StrelkaX12: TImage;
    StrelkaX23: TImage;
    StrelkaX34: TImage;
    StrelkaX45: TImage;
    StrelkaX56: TImage;
    StrelkaX67: TImage;
    StrelkaX78: TImage;
    StrelkaX89: TImage;
    //StrelkaX1: TImage;
    //StrelkaX9: TImage;
    StrelkaY12: TImage;
    StrelkaY23: TImage;
    StrelkaY34: TImage;
    StrelkaY45: TImage;
    StrelkaY56: TImage;
    StrelkaY67: TImage;
    StrelkaY78: TImage;
    StrelkaY89: TImage;
    StrelkaA1: TImage;
    StrelkaA2: TImage;
    StrelkaA3: TImage;
    StrelkaA4: TImage;
    StrelkaA5: TImage;
    StrelkaA6: TImage;
    StrelkaA7: TImage;
    StrelkaA8: TImage;
    StrelkaA9: TImage;
    GridA: TStringGrid;
    GridX: TStringGrid;
    GridY: TStringGrid;
    Button2: TButton;
    CheckBox1: TCheckBox;
    Button3: TButton;
    Button4: TButton;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    procedure BitBtn1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure ProcessGridDrawCell(Sender: TObject; ACol, ARow: Integer;
      Rect: TRect; State: TGridDrawState);
    procedure ElGridDrawCell(Sender: TObject; ACol, ARow: Integer;
      Rect: TRect; State: TGridDrawState);
    procedure GridsAXYDrawCel(Sender: TObject; ACol, ARow: Integer;
      Rect: TRect; State: TGridDrawState);
    procedure FormShow(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure CheckBox1Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure ShowAXY(FlagCh:boolean);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;
  ElGridArray :  array[1..9] of TStringgrid;
  StrelkaAArray: array[1..9] of TImage;
  StrelkaXArray: array[1..8] of TImage;
  StrelkaYArray: array[1..8] of TImage;
  SistolSystem: TSistolSystem;
implementation

{$R *.dfm}

const X1 = 22; X2 = 50;
      Y1 = 18; Y2 = 34;

procedure TForm2.ShowAXY(FlagCh:boolean);
var i,j,k,l:integer;
begin 
 if FlagCh then
  for i := 1 to MATRIX_SIZE do begin
    GridX.Cells[0,i-1] := SistolSystem.VectorXCh[i];
    GridY.Cells[0,i-1] := SistolSystem.VectorYCh[i];
    for j := 1 to MATRIX_SIZE do 
      GridA.Cells[j-1,i-1] := SistolSystem.MatrixACh[i,j];
  end
 else
  for i := 1 to MATRIX_SIZE do begin
    GridX.Cells[0,i-1] := inttostr(SistolSystem.VectorX[i]);
    GridY.Cells[0,i-1] := inttostr(SistolSystem.VectorYCur[i]);
    for j := 1 to MATRIX_SIZE do 
      GridA.Cells[j-1,i-1] := inttostr(SistolSystem.MatrixA[i,j]);
  end
end;

procedure TForm2.BitBtn1Click(Sender: TObject);
begin
  Close;
end;

procedure TForm2.FormCreate(Sender: TObject);
var i,j,k,l:integer;
begin
 for j:= 0 to 7 do begin
   ProcessGrid.ColWidths[2*j]    := X1;
   ProcessGrid.ColWidths[2*j+1]  := X2;
   ProcessGrid.RowHeights[2*j]   := Y1;
   ProcessGrid.RowHeights[2*j+1] := Y2;
 end;
 ProcessGrid.ColWidths[16]    := X1;
 ProcessGrid.RowHeights[16]   := Y1;
 ProcessGrid.FixedCols := 0;
 ProcessGrid.FixedRows := 0;

 ElGridArray[1] := ElGrid1; ElGridArray[2] := ElGrid2;
 ElGridArray[3] := ElGrid3; ElGridArray[4] := ElGrid4;
 ElGridArray[5] := ElGrid5; ElGridArray[6] := ElGrid6;
 ElGridArray[7] := ElGrid7; ElGridArray[8] := ElGrid8;
 ElGridArray[9] := ElGrid9;
 ElGridArray[1].Left := ProcessGrid.Left;
 for i := 2 to 9 do
   ElGridArray[i].Left := ElGridArray[i-1].Left + X1 + X2;
 for i := 1 to 9 do begin
   ElGridArray[i].ColWidths[0] := X1;
   ElGridArray[i].ColWidths[1] := X1-8;
   ElGridArray[i].OnDrawCell := ElGridDrawCell;
 end;
 SistolSystem := TSistolSystem.Create;
 with SistolSystem do begin
   SistolSystem.TableGrid := ProcessGrid;
   for j:= 1 to NUM_STUP do begin 
     ProcessElemSGrid[j] := ElGridArray[j];
   end;
 end;


// Рисуем стрелки
 StrelkaAArray[1] := StrelkaA1; StrelkaAArray[2] := StrelkaA2;
 StrelkaAArray[3] := StrelkaA3; StrelkaAArray[4] := StrelkaA4;
 StrelkaAArray[5] := StrelkaA5; StrelkaAArray[6] := StrelkaA6;
 StrelkaAArray[7] := StrelkaA7; StrelkaAArray[8] := StrelkaA8;
 StrelkaAArray[9] := StrelkaA9;
 StrelkaAArray[1].Left := ProcessGrid.Left + 6;
 for i := 2 to 9 do
   StrelkaAArray[i].Left := StrelkaAArray[i-1].Left + X1 + X2;

 StrelkaXArray[1] := StrelkaX12; StrelkaXArray[2] := StrelkaX23;
 StrelkaXArray[3] := StrelkaX34; StrelkaXArray[4] := StrelkaX45;
 StrelkaXArray[5] := StrelkaX56; StrelkaXArray[6] := StrelkaX67;
 StrelkaXArray[7] := StrelkaX78; StrelkaXArray[8] := StrelkaX89;
 StrelkaXArray[1].Left := ProcessGrid.Left + 38;
 for i := 2 to 8 do
   StrelkaXArray[i].Left := StrelkaXArray[i-1].Left + X1 + X2;

 StrelkaYArray[1] := StrelkaY12; StrelkaYArray[2] := StrelkaY23;
 StrelkaYArray[3] := StrelkaY34; StrelkaYArray[4] := StrelkaY45;
 StrelkaYArray[5] := StrelkaY56; StrelkaYArray[6] := StrelkaY67;
 StrelkaYArray[7] := StrelkaY78; StrelkaYArray[8] := StrelkaY89;
 StrelkaYArray[1].Left := ProcessGrid.Left + 40;
 for i := 2 to 8 do
   StrelkaYArray[i].Left := StrelkaYArray[i-1].Left + X1 + X2;

 Button3.Enabled := false;
 Button4.Enabled := false;
end;

procedure TForm2.ProcessGridDrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
var grid:TStringGrid;
begin
 grid:=TStringGrid(Sender);
 with Grid, Grid.Canvas do begin
  if NOT(Odd(ARow) OR Odd(ACol)) then begin
    if (ARow+ACol>6)AND(ACol-ARow<10)
      then Brush.Color:=RGB(200,220,240)
      else Brush.Color:=clBtnFace
  end else begin
    Brush.Color:=clBtnFace;
  end;
  FillRect(Rect);
  Font.Color:=clBlack;
  Font.Style := [fsBold];
  textout(Rect.Left,Rect.Top+2,Cells[ACol,ARow]);
 end;
end;

procedure TForm2.ElGridDrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
var grid:TStringGrid;
begin
 grid:=TStringGrid(Sender);
 with Grid, Grid.Canvas do begin
  if (ACol=0) AND (ARow=0) then Brush.Color:=RGB(200,220,240);//clGray;
  if (ACol=1) AND (ARow=0) then Brush.Color:=RGB(255,255,128);
  if (ACol=0) AND (ARow=1) then Brush.Color:=RGB(255,128,64);
  if (ACol=1) AND (ARow=1) then Brush.Color:=RGB(255,128,64);
  FillRect(Rect);
  Font.Color:=clBlack;
  Font.Style := [fsBold];
  textout(Rect.Left,Rect.Top+2,Cells[ACol,ARow]);
 end;
end;

procedure TForm2.GridsAXYDrawCel(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
var grid:TStringGrid;
begin
 grid:=TStringGrid(Sender);
 with Grid, Grid.Canvas do begin
  Brush.Color:=clBtnFace;
  //Brush.Color:=clBtnFace;
  FillRect(Rect);
  Font.Color:=clBlack;
  Font.Style := [fsBold];
  textout(Rect.Left,Rect.Top+2,Cells[ACol,ARow]);
  with Pen do begin
    Color:=clBlack;
    Style:=psSolid;
    Width:=1;
  end;
  with Rect do begin
    MoveTo(Left, Bottom);
    LineTo(Right, Bottom);
    MoveTo(Right, Top);
    LineTo(Right, Bottom);
  end;
 end;


end;



procedure TForm2.FormShow(Sender: TObject);
var i,j,k,l: integer;
begin
  Button2Click(self);
end;

procedure TForm2.Button2Click(Sender: TObject);
begin
  SistolSystem.GoStart;
  ShowAXY(CheckBox1.Checked);
  SistolSystem.ShowSystem(CheckBox1.Checked);
  Button3.Enabled := true;
  Button4.Enabled := false;
end;

procedure TForm2.CheckBox1Click(Sender: TObject);
begin
 ShowAXY(CheckBox1.Checked);
 SistolSystem.ShowSystem(CheckBox1.Checked);
end;

procedure TForm2.Button3Click(Sender: TObject);
begin
  if SistolSystem.Step = 0 then Button4.Enabled := true;
  SistolSystem.GoNext;
  ShowAXY(CheckBox1.Checked);
  SistolSystem.ShowSystem(CheckBox1.Checked);
  if SistolSystem.Step = 14 then Button3.Enabled := false
end;

procedure TForm2.Button4Click(Sender: TObject);
begin
  if SistolSystem.Step = 14 then Button3.Enabled := true;
  SistolSystem.GoPred;
  ShowAXY(CheckBox1.Checked);
  SistolSystem.ShowSystem(CheckBox1.Checked);
  if SistolSystem.Step = 0 then Button4.Enabled := false;
end;

end.
Соседние файлы в папке Лабораторная работа