{--------------------------------------------------------------------------- The control program for mass-spectrometer MI1201-AGM (c) Copyright Aleksandrov O.E., 2001 Molecular Physics department, USTU, Ekaterinsburg, K-2, 620002, RUSSIA phone 75-47-15 E-mail: aleks@dpt.ustu.ru Программа управления масс-спектрометром МИ1201-АГМ (c) Собственность Александрова О.Е., 2001 620002, Екатеринбург, К-2, УГТУ, Кафедра молекулярной физики тел. 75-47-15 E-mail: aleks@dpt.ustu.ru ----------------------------------------------------------------------------} unit MCAD_MI1201_SeriesEditor; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, MCAD_MI1201_Thread, MCAD_MI1201_Thread_Types, MCAD_MI1201_TChartSeries, MCAD_MI1201_FormSpectrum; type TFormSeriesEditor = class(TForm) ListBoxSeries: TListBox; ButtonColor: TButton; RadioGroupLineType: TRadioGroup; EditThickness: TEdit; LabelThickness: TLabel; ColorDialog: TColorDialog; PanelColor: TPanel; procedure ListBoxSeriesClick(Sender: TObject); procedure RadioGroupLineTypeClick(Sender: TObject); procedure EditThicknessDblClick(Sender: TObject); procedure EditThicknessExit(Sender: TObject); procedure ButtonColorClick(Sender: TObject); procedure FormHide(Sender: TObject); procedure FormShow(Sender: TObject); procedure EditThicknessKeyPress(Sender: TObject; var Key: Char); procedure FormDestroy(Sender: TObject); private { Private declarations } SeriesSet:tSeriesSet; Series:tSeries; SerValid:boolean; procedure Apply; procedure ApplyColor; procedure ApplyLineType; procedure ApplyLineWidth; public { Public declarations } AFormSpectrum:tFormSpectrum; end; var FormSeriesEditor: TFormSeriesEditor; implementation USES Series; {$R *.DFM} procedure TFormSeriesEditor.Apply; begin ApplyColor; ApplyLineType; ApplyLineWidth; end; procedure TFormSeriesEditor.ApplyColor; var ms:tCustomSeries; begin if SerValid then begin if not Assigned(AFormSpectrum) then Exit; ms:=AFormSpectrum.MassSpectrometer.DataSeries[Series]; if Assigned(ms) then begin ms.SeriesColor:=ColorDialog.Color; end; ms:=AFormSpectrum.Signals[Series]; if Assigned(ms) then begin ms.SeriesColor:=ColorDialog.Color; end; PanelColor.Color:=ColorDialog.Color; end; end; procedure TFormSeriesEditor.ApplyLineType; var ms:tMSSeries; begin if SerValid then begin if not Assigned(AFormSpectrum) then Exit; ms:=AFormSpectrum.MassSpectrometer.DataSeries[Series]; if Assigned(ms) then begin ms.LinePen.Style:=tPenStyle(RadioGroupLineType.ItemIndex); end; end; end; procedure TFormSeriesEditor.ApplyLineWidth; var ms:tCustomSeries; begin if SerValid then begin if not Assigned(AFormSpectrum) then Exit; ms:=AFormSpectrum.MassSpectrometer.DataSeries[Series]; if Assigned(ms) then begin try ms.LinePen.Width:=StrToInt(EditThickness.Text); except EditThickness.Text:=IntToStr(ms.LinePen.Width); end; end; end; end; procedure TFormSeriesEditor.ListBoxSeriesClick(Sender: TObject); var s:tSeries; i:integer; ms:tCustomSeries; begin Apply; SerValid:=FALSE; PanelColor.Visible:=FALSE; if not Assigned(AFormSpectrum) then Exit; i:=-1; for s:=Low(s) to High(s) do begin if s in SeriesSet then begin Inc(i); if i=ListBoxSeries.ItemIndex then begin Series:=s; Break; end; end; end; if (Series in SeriesSet) and (i=ListBoxSeries.ItemIndex) then begin ms:=AFormSpectrum.MassSpectrometer.DataSeries[Series]; if Assigned(ms) then begin SerValid:=TRUE; RadioGroupLineType.ItemIndex:=Ord(ms.LinePen.Style); EditThickness.Text:=IntToStr(ms.LinePen.Width); ColorDialog.Color:=ms.SeriesColor; PanelColor.Color:=ColorDialog.Color; RadioGroupLineType.Enabled:=TRUE; LabelThickness.Enabled:=TRUE; EditThickness.Enabled:=TRUE; ButtonColor.Enabled:=TRUE; PanelColor.Visible:=TRUE; end; end; end; procedure TFormSeriesEditor.RadioGroupLineTypeClick(Sender: TObject); begin ApplyLineType; end; procedure TFormSeriesEditor.EditThicknessDblClick(Sender: TObject); begin ApplyLineWidth; end; procedure TFormSeriesEditor.EditThicknessExit(Sender: TObject); begin ApplyLineWidth; end; procedure TFormSeriesEditor.ButtonColorClick(Sender: TObject); var fs:tFormStyle; begin fs:=FormStyle; FormStyle:=fsNormal; If ColorDialog.Execute then begin ApplyColor; end; FormStyle:=fs; end; procedure TFormSeriesEditor.FormHide(Sender: TObject); begin AFormSpectrum:=NIL; SerValid:=FALSE; end; procedure TFormSeriesEditor.FormShow(Sender: TObject); var s:tSeries; i:integer; begin if Assigned(AFormSpectrum) then begin i:=0; for s:=Low(s) to High(s) do begin if Assigned(AFormSpectrum.MassSpectrometer.DataSeries[s]) then begin Inc(i); end; end; if ListBoxSeries.Items.Count<>i then begin ListBoxSeries.Clear; SeriesSet:=[]; SerValid:=FALSE; for s:=Low(s) to High(s) do begin if Assigned(AFormSpectrum.MassSpectrometer.DataSeries[s]) then begin ListBoxSeries.Items.Add(AFormSpectrum.MassSpectrometer.DataSeries[s].Title); Include(SeriesSet,s); end; end; end; ListBoxSeries.Enabled:=ListBoxSeries.Items.Count>0; end else begin ListBoxSeries.Clear; ListBoxSeries.Enabled:=False; RadioGroupLineType.Enabled:=False; LabelThickness.Enabled:=False; EditThickness.Enabled:=False; ButtonColor.Enabled:=False; ListBoxSeries.Enabled:=FALSE; end; end; procedure TFormSeriesEditor.EditThicknessKeyPress(Sender: TObject; var Key: Char); var s:tCustomSeries; begin if not SerValid then Exit; case Key of #13: begin ApplyLineWidth; end; #27: begin if Assigned(AFormSpectrum) then begin s:=AFormSpectrum.MassSpectrometer.DataSeries[Series]; if Assigned(s) then begin EditThickness.Text:=IntToStr(s.LinePen.Width); end; end; end; end; end; procedure TFormSeriesEditor.FormDestroy(Sender: TObject); begin if Self=FormSeriesEditor then FormSeriesEditor:=NIL; end; end.