home *** CD-ROM | disk | FTP | other *** search
- unit Seredit;
-
- {$I Plot.inc}
-
- {-----------------------------------------------------------------------------
- The contents of this file are subject to the Q Public License
- ("QPL"); you may not use this file except in compliance
- with the QPL. You may obtain a copy of the QPL from
- the file QPL.html in this distribution, derived from:
-
- http://www.trolltech.com/products/download/freelicense/license.html
-
- The QPL prohibits development of proprietary software.
- There is a Professional Version of this software available for this.
- Contact sales@chemware.hypermart.net for more information.
-
- Software distributed under the QPL is distributed on an "AS IS" basis,
- WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the QPL for
- the specific language governing rights and limitations under the QPL.
-
- The Original Code is: SerEdit.pas, released 12 September 2000.
-
- The Initial Developer of the Original Code is Mat Ballard.
- Portions created by Mat Ballard are Copyright (C) 1999 Mat Ballard.
- Portions created by Microsoft are Copyright (C) 1998, 1999 Microsoft Corp.
- All Rights Reserved.
-
- Contributor(s): Mat Ballard e-mail: mat.ballard@chemware.hypermart.net.
-
- Last Modified: 02/25/2000
- Current Version: 2.00
-
- You may retrieve the latest version of this file from:
-
- http://Chemware.hypermart.net/
-
- This work was created with the Project JEDI VCL guidelines:
-
- http://www.delphi-jedi.org/Jedi:VCLVCL
-
- in mind.
-
- Purpose:
- To facilitate user manipluation of Series properties
-
- Known Issues:
- -----------------------------------------------------------------------------}
-
- interface
-
- uses
- Classes, SysUtils, TypInfo,
- {$IFDEF WINDOWS}
- WinTypes, WinProcs,
- Buttons, Controls, {Dialogs,} Forms, Graphics, StdCtrls,
- {$ENDIF}
- {$IFDEF WIN32}
- Windows,
- Buttons, Controls, {Dialogs,} Forms, Graphics, StdCtrls,
- {$ENDIF}
- {$IFDEF LINUX}
- QButtons, QControls, QDialogs, QExtCtrls, QForms, QGraphics, QStdCtrls,
- {$ENDIF}
-
- Misc, NEdit, Plotdefs, Coloredt;
-
- type
- TSeriesProperty = record
- PenColor: TColor;
- PenWidthIndex: Integer;
- PenStyleIndex: Integer;
- BrushColor: TColor;
- BrushStyleIndex: Integer;
- SymbolIndex: Integer;
- SymbolSize: Integer;
- YAxisIndex: Byte;
- DeltaX: Integer;
- DeltaY: Integer;
- XDataIndependent: Boolean;
- ExternalXSeries: Boolean;
- Visible: Boolean;
- ShadeLimits: Boolean;
- end;
-
- TSeriesEditorForm = class(TForm)
- HelpBitBtn: TBitBtn;
- CancelBitBtn: TBitBtn;
- OKBitBtn: TBitBtn;
- VisibleCheckBox: TCheckBox;
- PenGroupBox: TGroupBox;
- PenColorLabel: TLabel;
- PenWidthLabel: TLabel;
- PenWidthComboBox: TComboBox;
- PenStyleComboBox: TComboBox;
- PenStyleLabel: TLabel;
- NoComboBox: TComboBox;
- DisplacementGroupBox: TGroupBox;
- DeltaXLabel: TLabel;
- DeltaYLabel: TLabel;
- SeriesNumberLabel: TLabel;
- NameEdit: TEdit;
- YAxisLabel: TLabel;
- YAxisComboBox: TComboBox;
- XDataIndependentCheckBox: TCheckBox;
- BrushGroupBox: TGroupBox;
- BrushColorLabel: TLabel;
- BrushStyleLabel: TLabel;
- BrushStyleComboBox: TComboBox;
- DeltaXNEdit: TNEdit;
- DeltaYNEdit: TNEdit;
- PenColorEdit: TColorEdit;
- BrushColorEdit: TColorEdit;
- ApplyBitBtn: TBitBtn;
- SymbolGroupBox: TGroupBox;
- SymbolSizeLabel: TLabel;
- SymbolComboBox: TComboBox;
- SymbolSizeNEdit: TNEdit;
- SymbolTypeLabel: TLabel;
- ShadedCheckBox: TCheckBox;
- procedure FormCreate(Sender: TObject);
- procedure FormDestroy(Sender: TObject);
- procedure NoComboBoxClick(Sender: TObject);
- procedure PenWidthComboBoxClick(Sender: TObject);
- procedure PenStyleComboBoxClick(Sender: TObject);
- procedure SymbolComboBoxClick(Sender: TObject);
- procedure VisibleCheckBoxClick(Sender: TObject);
- procedure YAxisComboBoxClick(Sender: TObject);
- procedure DeltaXNEditChange(Sender: TObject);
- procedure DeltaYNEditChange(Sender: TObject);
- procedure SymbolSizeNEditChange(Sender: TObject);
- procedure NameEditChange(Sender: TObject);
- procedure XDataIndependentCheckBoxClick(Sender: TObject);
- procedure PenColorEditChange(Sender: TObject);
- procedure BrushColorEditChange(Sender: TObject);
- procedure ApplyBitBtnClick(Sender: TObject);
- procedure ShadedCheckBoxClick(Sender: TObject);
- private
- pASP: ^TSeriesProperty;
- CurrentIndex: Integer;
-
- public
- SeriesPropertyList: TList;
- SeriesNames: TStringList;
- ThePlot: TObject;
-
- function AddSeries(AName: String; ASeriesProperty: TSeriesProperty): Integer;
- procedure SelectSeries(Index: Integer);
- {$IFNDEF LANG_ENGLISH}
- procedure DoCaptionsFromResource;
- {$ENDIF}
- procedure DoHintsFromResource;
- end;
-
- var
- SeriesEditorForm: TSeriesEditorForm;
-
- implementation
-
- {$R *.dfm}
-
- uses
- Plot;
-
- {------------------------------------------------------------------------------
- Procedure: TSeriesEditorForm.FormCreate
- Description: standard FormCreate procedure
- Author: Mat Ballard
- Date created: 04/25/2000
- Date modified: 04/25/2000 by Mat Ballard
- Purpose: sets the position, populates the PenColor combo, and initializes SeriesNames and SeriesPropertyList
- Known Issues:
- ------------------------------------------------------------------------------}
- procedure TSeriesEditorForm.FormCreate(Sender: TObject);
- var
- i: Integer;
- begin
- {$IFNDEF LANG_ENGLISH}
- DoCaptionsFromResource;
- {$ENDIF}
- DoHintsFromResource;
-
- SetDialogGeometry(Self, ApplyBitBtn, HelpBitBtn.Left);
-
- {Populate the combo boxes:}
- for i := 0 to Ord(High(TBrushStyle)) do
- BrushStyleComboBox.Items.Add(Copy(GetEnumName(TypeInfo(TBrushStyle), i), 3, 99));
- for i := 0 to 20 do
- PenWidthComboBox.Items.Add(IntToStr(i));
- for i := 0 to Ord(High(TPenStyle)) do
- PenStyleComboBox.Items.Add(Copy(GetEnumName(TypeInfo(TPenStyle), i), 3, 99));
- for i := 0 to Ord(High(TSymbol)) do
- SymbolComboBox.Items.Add(Copy(GetEnumName(TypeInfo(TSymbol), i), 3, 99));
-
- {set combo and edit box widths:}
- for i := 0 to Self.ComponentCount - 1 do
- if ((Self.Components[i] is TEdit) or
- (Self.Components[i] is TNEdit) or
- (Self.Components[i] is TColorEdit) or
- (Self.Components[i] is TComboBox)) then
- TControl(Self.Components[i]).Width := 88
- else if (Self.Components[i] is TBitBtn) then
- TControl(Self.Components[i]).Width := 97;
- {the exceptions:}
- NoComboBox.Width := 48;
- //SymbolSizeNEdit.Width := 48;
- YAxisComboBox.Width := 121;
- SymbolComboBox.Width := 105;
- NameEdit.Width := 193;
-
- SymbolComboBox.ItemIndex := 0;
- SeriesPropertyList := TList.Create;
- SeriesNames := TStringList.Create;
- end;
-
- {------------------------------------------------------------------------------
- Procedure: TSeriesEditorForm.DoCaptionsFromResource
- Description: standard loading of labels from resources
- Author: Mat Ballard
- Date created: 06/25/2001
- Date modified: 06/25/2001 by Mat Ballard
- Purpose: display in different languages
- Known Issues:
- ------------------------------------------------------------------------------}
- {$IFNDEF LANG_ENGLISH}
- procedure TSeriesEditorForm.DoCaptionsFromResource;
- begin
- Self.Caption := sSeries + ' ' + sEditor;
- SeriesNumberLabel.Caption := sSeries + ' ' + sNumber;
- DisplacementGroupBox.Caption := sDisplacement;
- DeltaXLabel.Caption := sMoveThe + 'X';
- DeltaYLabel.Caption := sMoveThe + 'Y';
- BrushGroupBox.Caption := sBrush;
- BrushColorLabel.Caption := sColor;
- BrushStyleLabel.Caption := sStyle;
- SymbolGroupBox.Caption := sSymbol;
- SymbolTypeLabel.Caption := sType;
- SymbolSizeLabel.Caption := sSize;
- PenGroupBox.Caption := sPen;
- PenColorLabel.Caption := sColor;
- PenWidthLabel.Caption := sWidth;
- PenStyleLabel.Caption := sStyle;
- XDataIndependentCheckBox.Caption := 'X ' + sData + sIndependent;
- VisibleCheckBox.Caption := sVisible;
- YAxisLabel.Caption := 'Y ' + sAxis;
- ShadedCheckBox.Caption := sShaded;
-
- HelpBitBtn.Caption := sHelp;
- OKBitBtn.Caption := sOK;
- CancelBitBtn.Caption := sCancel;
- ApplyBitBtn.Caption := sApply;
- end;
- {$ENDIF}
-
- {------------------------------------------------------------------------------
- Procedure: TSeriesEditorForm.DoHintsFromResource
- Description: standard loading of hints from resources
- Author: Mat Ballard
- Date created: 06/25/2001
- Date modified: 06/25/2001 by Mat Ballard
- Purpose: display Hints in different languages
- Known Issues:
- ------------------------------------------------------------------------------}
- procedure TSeriesEditorForm.DoHintsFromResource;
- begin
- NoComboBox.Hint := sNoComboBoxHint;
- NameEdit.Hint := sNameEditHint;
- DisplacementGroupBox.Hint := sDisplacementGroupBoxHint;
- BrushGroupBox.Hint := sBrushGroupBoxHint;
- SymbolGroupBox.Hint := sSymbolGroupBoxHint;
- PenGroupBox.Hint := sPenGroupBoxHint;
- YAxisComboBox.Hint := sYAxisComboBoxHint;
- XDataIndependentCheckBox.Hint := sXDataIndependentCheckBoxHint;
- VisibleCheckBox.Hint := sVisibleCheckBoxHint;
- ShadedCheckBox.Hint := sShadedHint;
- ApplyBitBtn.Hint := sApplyHint;
- end;
-
- {------------------------------------------------------------------------------
- Procedure: TSeriesEditorForm.FormDestroy
- Description: standard FormDestroy procedure
- Author: Mat Ballard
- Date created: 04/25/2000
- Date modified: 04/25/2000 by Mat Ballard
- Purpose: frees the SeriesNames and SeriesPropertyList
- Known Issues:
- ------------------------------------------------------------------------------}
- procedure TSeriesEditorForm.FormDestroy(Sender: TObject);
- var
- i: Integer;
- begin
- for i := 0 to SeriesPropertyList.Count-1 do
- FreeMem(SeriesPropertyList.Items[i], SizeOf(TSeriesProperty));
-
- SeriesPropertyList.Free;
- SeriesNames.Free;
- end;
-
- {------------------------------------------------------------------------------
- Function: TSeriesEditorForm.AddSeries
- Description: adds a new series to the list
- Author: Mat Ballard
- Date created: 04/25/2000
- Date modified: 04/25/2000 by Mat Ballard
- Purpose: stores the Series properties
- Known Issues:
- ------------------------------------------------------------------------------}
- function TSeriesEditorForm.AddSeries(AName: String; ASeriesProperty: TSeriesProperty): Integer;
- var
- i: Integer;
- pDestination: Pointer;
- pSource,
- pDest: PChar;
- begin
- NoComboBox.Items.Add(IntToStr(SeriesNames.Count));
-
- SeriesNames.Add(AName);
-
- GetMem(pDestination, SizeOf(ASeriesProperty));
- pSource := @ASeriesProperty;
- {NB: this causes terminal access violations:
- System.Move(pSource, pDestination, SizeOf(TSeriesProperty));}
- pDest := pDestination;
- for i := 1 to SizeOf(ASeriesProperty) do
- begin
- pDest^ := pSource^;
- Inc(pSource);
- Inc(pDest);
- end;
-
- SeriesPropertyList.Add(pDestination);
- AddSeries := SeriesPropertyList.Count;
- end;
-
- {------------------------------------------------------------------------------
- Procedure: TSeriesEditorForm.SelectSeries
- Description: responds to selection of a new Series
- Author: Mat Ballard
- Date created: 04/25/2000
- Date modified: 04/25/2000 by Mat Ballard
- Purpose: manage user input
- Known Issues:
- ------------------------------------------------------------------------------}
- procedure TSeriesEditorForm.SelectSeries(Index: Integer);
- begin
- pASP := SeriesPropertyList.Items[Index];
- CurrentIndex := Index;
-
- NameEdit.Text := SeriesNames.Strings[Index];
-
- PenColorEdit.Color := pASP^.PenColor;
- PenColorEdit.Text := ColorToString(pASP^.PenColor)+ ' ...';
- PenWidthComboBox.ItemIndex := pASP^.PenWidthIndex;
- PenStyleComboBox.ItemIndex := pASP^.PenStyleIndex;
-
- BrushColorEdit.Color := pASP^.BrushColor;
- BrushColorEdit.Text := ColorToString(pASP^.BrushColor)+ ' ...';
- BrushStyleComboBox.ItemIndex := pASP^.BrushStyleIndex;
- SymbolComboBox.ItemIndex := pASP^.SymbolIndex;
- SymbolSizeNEdit.AsInteger := pASP^.SymbolSize;
- {We define YAxisIndex to run from 1 to FAxisList.Count-1}
- YAxisComboBox.ItemIndex := pASP^.YAxisIndex-1;
- DeltaXNEdit.AsInteger := pASP^.DeltaX;
- DeltaYNEdit.AsInteger := pASP^.DeltaY;
- VisibleCheckBox.Checked := pASP^.Visible;
- XDataIndependentCheckBox.Checked := pASP^.XDataIndependent;
- XDataIndependentCheckBox.Visible := pASP^.ExternalXSeries;
- ShadedCheckBox.Checked := pASP^.ShadeLimits;
- end;
-
- {------------------------------------------------------------------------------
- Procedure: TSeriesEditorForm.NoComboBoxClick
- Description: responds to user selection of a new Series
- Author: Mat Ballard
- Date created: 04/25/2000
- Date modified: 04/25/2000 by Mat Ballard
- Purpose: manage user input
- Known Issues: see SelectSeries above
- ------------------------------------------------------------------------------}
- procedure TSeriesEditorForm.NoComboBoxClick(Sender: TObject);
- begin
- SelectSeries(NoComboBox.ItemIndex);
- end;
-
- {------------------------------------------------------------------------------
- Procedure: TSeriesEditorForm.PenWidthComboBoxClick
- Description: responds to selection of a new Pen Width for the Series
- Author: Mat Ballard
- Date created: 04/25/2000
- Date modified: 04/25/2000 by Mat Ballard
- Purpose: manage user input
- Known Issues:
- ------------------------------------------------------------------------------}
- procedure TSeriesEditorForm.PenWidthComboBoxClick(Sender: TObject);
- begin
- pASP^.PenWidthIndex := PenWidthComboBox.ItemIndex;
- end;
-
- {------------------------------------------------------------------------------
- Procedure: TSeriesEditorForm.PenStyleComboBoxClick
- Description: responds to selection of a new Pen Style for the Series
- Author: Mat Ballard
- Date created: 04/25/2000
- Date modified: 04/25/2000 by Mat Ballard
- Purpose: manage user input
- Known Issues:
- ------------------------------------------------------------------------------}
- procedure TSeriesEditorForm.PenStyleComboBoxClick(Sender: TObject);
- begin
- pASP^.PenStyleIndex := PenStyleComboBox.ItemIndex;
- if (PenStyleComboBox.ItemIndex > Ord(psSolid)) then
- PenWidthComboBox.ItemIndex := 1;
- end;
-
- {------------------------------------------------------------------------------
- Procedure: TSeriesEditorForm.SymbolComboBoxClick
- Description: responds to selection of a new Symbol for the Series
- Author: Mat Ballard
- Date created: 04/25/2000
- Date modified: 04/25/2000 by Mat Ballard
- Purpose: manage user input
- Known Issues:
- ------------------------------------------------------------------------------}
- procedure TSeriesEditorForm.SymbolComboBoxClick(Sender: TObject);
- begin
- pASP^.SymbolIndex := SymbolComboBox.ItemIndex;
- end;
-
- {------------------------------------------------------------------------------
- Procedure: TSeriesEditorForm.VisibleCheckBoxClick
- Description: responds to changes to the Visibility of the Series
- Author: Mat Ballard
- Date created: 04/25/2000
- Date modified: 04/25/2000 by Mat Ballard
- Purpose: manage user input
- Known Issues:
- ------------------------------------------------------------------------------}
- procedure TSeriesEditorForm.VisibleCheckBoxClick(Sender: TObject);
- begin
- pASP^.Visible := VisibleCheckBox.Checked;
- end;
-
- {------------------------------------------------------------------------------
- Procedure: TSeriesEditorForm.YAxisComboBoxClick
- Description: responds to changes in the selected Y Axis (primary or 2nd)
- Author: Mat Ballard
- Date created: 04/25/2000
- Date modified: 04/25/2000 by Mat Ballard
- Purpose: manage user input
- Known Issues:
- ------------------------------------------------------------------------------}
- procedure TSeriesEditorForm.YAxisComboBoxClick(Sender: TObject);
- begin
- {We define YAxisIndex to run from 1 to FAxisList.Count-1}
- pASP^.YAxisIndex := YAxisComboBox.ItemIndex+1;
- end;
-
- {------------------------------------------------------------------------------
- Procedure: TSeriesEditorForm.DeltaXNEditChange
- Description: responds to changes in DeltaX
- Author: Mat Ballard
- Date created: 04/25/2000
- Date modified: 04/25/2000 by Mat Ballard
- Purpose: manage user input
- Known Issues:
- ------------------------------------------------------------------------------}
- procedure TSeriesEditorForm.DeltaXNEditChange(Sender: TObject);
- begin
- pASP^.DeltaX := DeltaXNEdit.AsInteger;
- end;
-
- {------------------------------------------------------------------------------
- Procedure: TSeriesEditorForm.DeltaYNEditChange
- Description: repsonds to changes in DeltaY
- Author: Mat Ballard
- Date created: 04/25/2000
- Date modified: 04/25/2000 by Mat Ballard
- Purpose: manage user input
- Known Issues:
- ------------------------------------------------------------------------------}
- procedure TSeriesEditorForm.DeltaYNEditChange(Sender: TObject);
- begin
- pASP^.DeltaY := DeltaYNEdit.AsInteger;
- end;
-
- {------------------------------------------------------------------------------
- Procedure: TSeriesEditorForm.SymbolSizeNEditChange
- Description: repsonds to changes in SymbolSize
- Author: Mat Ballard
- Date created: 04/25/2000
- Date modified: 04/25/2000 by Mat Ballard
- Purpose: manage user input
- Known Issues:
- ------------------------------------------------------------------------------}
- procedure TSeriesEditorForm.SymbolSizeNEditChange(Sender: TObject);
- begin
- pASP^.SymbolSize := SymbolSizeNEdit.AsInteger;
- end;
-
- {------------------------------------------------------------------------------
- Procedure: TSeriesEditorForm.NameEditChange
- Description: repsonds to changes in the Series Name
- Author: Mat Ballard
- Date created: 04/25/2000
- Date modified: 04/25/2000 by Mat Ballard
- Purpose: manage user input
- Known Issues:
- ------------------------------------------------------------------------------}
- procedure TSeriesEditorForm.NameEditChange(Sender: TObject);
- begin
- SeriesNames.Strings[CurrentIndex] := NameEdit.Text;
- end;
-
- procedure TSeriesEditorForm.XDataIndependentCheckBoxClick(Sender: TObject);
- begin
- pASP^.XDataIndependent := XDataIndependentCheckBox.Checked;
- end;
-
- procedure TSeriesEditorForm.PenColorEditChange(Sender: TObject);
- begin
- pASP^.PenColor := PenColorEdit.Color;
- pASP^.BrushColor := Misc.GetPalerColor(pASP.PenColor, 70);
- end;
-
- procedure TSeriesEditorForm.BrushColorEditChange(Sender: TObject);
- begin
- pASP^.BrushColor := BrushColorEdit.Color;
- end;
-
- procedure TSeriesEditorForm.ApplyBitBtnClick(Sender: TObject);
- begin
- TPlot(ThePlot).ApplySeriesChange(Self);
- end;
-
-
- procedure TSeriesEditorForm.ShadedCheckBoxClick(Sender: TObject);
- begin
- pASP^.ShadeLimits := ShadedCheckBox.Checked;
- end;
-
- end.
-