unit PwrCurveGr;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  GraphBaseSt, Placemnt, ExtCtrls, TeeProcs, TeEngine, Chart, ComCtrls,
  ToolWin, Series,data, ActnList, GraphBase;

type
  TfmPwrCurveGr = class(TfmGraphBaseSt)
    Series1: TFastLineSeries;
    actChgWG: TAction;
    procedure actChgWGExecute(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
    FPwrCurve : TWindPwrCurve;
  public
    { Public declarations }
    procedure LoadPwrCurve(const FileNm : string);
    procedure NewPwrCurve(WGr : TWindPwrCurve);
    //constructor Create(const FileNm : string); reintroduce; overload;
    //constructor Create(AWG : TWindPwrCurve); reintroduce; overload;
  end;

var
  fmPwrCurveGr: TfmPwrCurveGr;

implementation


{$R *.DFM}

{ TfmPwrCurveGr }

{
constructor TfmPwrCurveGr.Create(const FileNm: string);

begin
  inherited create(Application);
  LoadPwrCurve(FileNm);
end;
}

procedure TfmPwrCurveGr.LoadPwrCurve(const FileNm: string);
begin
  if Assigned(FPwrCurve) then
     FPwrCurve.Free;
  FPwrCurve := TWindPwrCurve.Create;
  FPwrCurve.LoadFromWaspPow(FileNm);
  NewPwrCurve(FPwrCurve);
end;

procedure TfmPwrCurveGr.actChgWGExecute(Sender: TObject);
var
 WG : TWindPwrCurve;
begin
  WG:=DM.SelectPwrCurve;
  if WG<>nil then
     NewPwrCurve(WG);
end;
{
constructor TfmPwrCurveGr.Create(AWG: TWindPwrCurve);
begin
  inherited Create(Application);
  NewPwrCurve(AWG);
end;
}

procedure TfmPwrCurveGr.NewPwrCurve(WGr: TWindPwrCurve);
var
 i  : integer;
 nm : float;
begin
  if WGr<>nil then
  begin
    with WGr do
    begin
      Chart1.Title.Text.Text := ModelName;
      Series1.Clear;
      for i:=0 to Count-1 do
         Series1.AddXY(Points[i].x,Points[i].y);

      nm := 1.1 * Series1.MaxYValue;
      Chart1.LeftAxis.AutomaticMaximum := False;
      Chart1.LeftAxis.Maximum := nm;
      nm := 1.1 * Series1.MaxXValue;
      Chart1.BottomAxis.AutomaticMaximum := False;
      Chart1.BottomAxis.Maximum := nm;
    end;
  end
end;

procedure TfmPwrCurveGr.FormCreate(Sender: TObject);
begin
  inherited;
  NewPwrCurve(wg);
end;

end.
