home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 October / Chip_2001-10_cd1.bin / zkuste / delphi / kompon / d123456 / CHEMPLOT.ZIP / TPlot / Axisedit.pas < prev    next >
Pascal/Delphi Source File  |  2001-07-24  |  25KB  |  750 lines

  1. unit Axisedit;
  2.  
  3. {$I Plot.inc}
  4.  
  5. {-----------------------------------------------------------------------------
  6. The contents of this file are subject to the Q Public License
  7. ("QPL"); you may not use this file except in compliance
  8. with the QPL. You may obtain a copy of the QPL from 
  9. the file QPL.html in this distribution, derived from:
  10.  
  11. http://www.trolltech.com/products/download/freelicense/license.html
  12.  
  13. The QPL prohibits development of proprietary software. 
  14. There is a Professional Version of this software available for this. 
  15. Contact sales@chemware.hypermart.net for more information.
  16.  
  17. Software distributed under the QPL is distributed on an "AS IS" basis,
  18. WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the QPL for
  19. the specific language governing rights and limitations under the QPL.
  20.  
  21. The Original Code is: AxisEdit.pas, released 12 September 2000.
  22.  
  23. The Initial Developer of the Original Code is Mat Ballard.
  24. Portions created by Mat Ballard are Copyright (C) 1999 Mat Ballard.
  25. Portions created by Microsoft are Copyright (C) 1998, 1999 Microsoft Corp.
  26. All Rights Reserved.
  27.  
  28. Contributor(s): Mat Ballard                 e-mail: mat.ballard@chemware.hypermart.net.
  29.  
  30. Last Modified: 03/11/2001
  31. Current Version: 2.00
  32.  
  33. You may retrieve the latest version of this file from:
  34.  
  35.         http://Chemware.hypermart.net/
  36.  
  37. This work was created with the Project JEDI VCL guidelines:
  38.  
  39.         http://www.delphi-jedi.org/Jedi:VCLVCL
  40.  
  41. in mind. 
  42.  
  43. Purpose:
  44. To facilitate user manipluation of Axis properties.
  45.  
  46. Known Issues:
  47. -----------------------------------------------------------------------------}
  48.  
  49. interface
  50.  
  51. uses
  52.   Classes, SysUtils, TypInfo,
  53. {$IFDEF WINDOWS}
  54.   WinTypes, WinProcs,
  55.   Buttons, Controls, Forms, Graphics, StdCtrls,
  56. {$ENDIF}
  57. {$IFDEF WIN32}
  58.   Windows,
  59.   Buttons, Controls, Forms, Graphics, StdCtrls,
  60. {$ENDIF}
  61. {$IFDEF LINUX}
  62.   QButtons, QControls, QForms, QGraphics, QStdCtrls,
  63. {$ENDIF}
  64.  
  65.   Axis, Coloredt, Misc, Nedit, Plotdefs, Titles;
  66.  
  67. type
  68.   TAxisProperty = record
  69.     Visible: Boolean;
  70.     LabelFormat: TLabelFormat;
  71.     LabelDigits: Byte;
  72.     LabelPrecision: Byte;
  73.     LabelDirection: TDirection;
  74.     PenColor: TColor;
  75.     PenWidthIndex: Integer;
  76.     PenStyleIndex: Integer;
  77.     TickSize: Byte;
  78.     TickDirection: TOrientation;
  79.     TickStepSize: Single;
  80.     TickMinors: Byte;
  81.     ScaleMin: Single;
  82.     ScaleMax: Single;
  83.     ScaleIntercept: Single;
  84.     ScaleAuto: Boolean;
  85.     ScaleLog: Boolean;
  86.     ArrowSize: Byte;
  87.     ArrowDirection: TAlignment;
  88.     LimitLower: Single;
  89.     LimitUpper: Single;
  90.     LimitsVisible: Boolean;
  91.     ZAngle: Word;
  92.     ZInterceptY: Single;
  93.     ZLength: Word;
  94.   end;
  95.  
  96.   TAxisEditorForm = class(TForm)
  97.     HelpBitBtn: TBitBtn;
  98.     CancelBitBtn: TBitBtn;
  99.     OKBitBtn: TBitBtn;
  100.     VisibleCheckBox: TCheckBox;
  101.     PenGroupBox: TGroupBox;
  102.     PenColorLabel: TLabel;
  103.     PenWidthLabel: TLabel;
  104.     PenWidthComboBox: TComboBox;
  105.     PenStyleComboBox: TComboBox;
  106.     PenStyleLabel: TLabel;
  107.     LabelsGroupBox: TGroupBox;
  108.     DigitsLabel: TLabel;
  109.     PrecisionLabel: TLabel;
  110.     FormatLabel: TLabel;
  111.     DigitsComboBox: TComboBox;
  112.     PrecisionComboBox: TComboBox;
  113.     FormatComboBox: TComboBox;
  114.     TickGroupBox: TGroupBox;
  115.     TickSizeLabel: TLabel;
  116.     TickDirectionLabel: TLabel;
  117.     TickDirectionComboBox: TComboBox;
  118.     StepSizeLabel: TLabel;
  119.     ScaleGroupBox: TGroupBox;
  120.     InterceptLabel: TLabel;
  121.     LogScaleCheckBox: TCheckBox;
  122.     MinLabel: TLabel;
  123.     MaxLabel: TLabel;
  124.     ArrowsGroupBox: TGroupBox;
  125.     ArrowSizeLabel: TLabel;
  126.     ArrowDirectionLabel: TLabel;
  127.     ArrowDirectionComboBox: TComboBox;
  128.     TitleEdit: TEdit;
  129.     TickMinorsLabel: TLabel;
  130.     MinorsComboBox: TComboBox;
  131.     NoComboBox: TComboBox;
  132.     AxisNumberLabel: TLabel;
  133.     AutoScaleCheckBox: TCheckBox;
  134.     TickSizeNEdit: TNEdit;
  135.     StepSizeNEdit: TNEdit;
  136.     MinNEdit: TNEdit;
  137.     MaxNEdit: TNEdit;
  138.     InterceptNEdit: TNEdit;
  139.     ArrowSizeNEdit: TNEdit;
  140.     PenColorEdit: TColorEdit;
  141.     ApplyBitBtn: TBitBtn;
  142.     LabelDirectionLabel: TLabel;
  143.     LabelDirectionComboBox: TComboBox;
  144.     ZAxisGroupBox: TGroupBox;
  145.     ZAngleLabel: TLabel;
  146.     ZLengthLabel: TLabel;
  147.     ZAngleNEdit: TNEdit;
  148.     ZLengthNEdit: TNEdit;
  149.     ZInterceptLabel: TLabel;
  150.     ZInterceptNEdit: TNEdit;
  151.     LimitsGroupBox: TGroupBox;
  152.     LowerLimitLabel: TLabel;
  153.     UpperLimitLabel: TLabel;
  154.     LowerLimitNEdit: TNEdit;
  155.     UpperLimitNEdit: TNEdit;
  156.     LimitsVisibleCheckBox: TCheckBox;
  157.     procedure FormCreate(Sender: TObject);
  158.     procedure FormatComboBoxClick(Sender: TObject);
  159.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  160.     procedure PenStyleComboBoxClick(Sender: TObject);
  161.     procedure FormActivate(Sender: TObject);
  162.     procedure FormDestroy(Sender: TObject);
  163.     procedure NoComboBoxClick(Sender: TObject);
  164.     procedure TitleEditChange(Sender: TObject);
  165.     procedure DigitsComboBoxClick(Sender: TObject);
  166.     procedure PrecisionComboBoxClick(Sender: TObject);
  167.     procedure TickDirectionComboBoxClick(Sender: TObject);
  168.     procedure TickSizeNEditChange(Sender: TObject);
  169.     procedure StepSizeNEditChange(Sender: TObject);
  170.     procedure MinNEditChange(Sender: TObject);
  171.     procedure MaxNEditChange(Sender: TObject);
  172.     procedure InterceptNEditChange(Sender: TObject);
  173.     procedure MinorsComboBoxClick(Sender: TObject);
  174.     procedure ArrowDirectionComboBoxClick(Sender: TObject);
  175.     procedure ArrowSizeNEditChange(Sender: TObject);
  176.     procedure VisibleCheckBoxClick(Sender: TObject);
  177.     procedure AutoScaleCheckBoxClick(Sender: TObject);
  178.     procedure LogScaleCheckBoxClick(Sender: TObject);
  179.     procedure PenWidthComboBoxClick(Sender: TObject);
  180.     procedure PenColorEditChange(Sender: TObject);
  181.     procedure ApplyBitBtnClick(Sender: TObject);
  182.     procedure LabelDirectionComboBoxClick(Sender: TObject);
  183.     procedure ZAngleNEditChange(Sender: TObject);
  184.     procedure ZLengthNEditChange(Sender: TObject);
  185.     procedure ZInterceptNEditChange(Sender: TObject);
  186.     procedure LowerLimitNEditChange(Sender: TObject);
  187.     procedure UpperLimitNEditChange(Sender: TObject);
  188.     procedure LimitsVisibleCheckBoxClick(Sender: TObject);
  189.   private
  190.     pAXP: ^TAxisProperty;
  191.     CurrentIndex: Integer;
  192.  
  193.   public
  194.     AxisPropertyList: TList;
  195.     AxisNames: TStringList;
  196.     HistoryMode: Boolean;
  197.     ThePlot: TObject;
  198.  
  199.     function AddAxis(AName: String; AnAxisProperty: TAxisProperty): Integer;
  200.     procedure SelectAxis(Index: Integer);
  201. {$IFNDEF LANG_ENGLISH}
  202.     procedure DoCaptionsFromResource;
  203. {$ENDIF}    
  204.     procedure DoHintsFromResource;
  205.   end;
  206.  
  207. var
  208.   AxisEditorForm: TAxisEditorForm;
  209.  
  210. implementation
  211.  
  212. {$R *.dfm}
  213.  
  214. uses
  215.   Plot;
  216.  
  217. {------------------------------------------------------------------------------
  218.     Procedure: TAxisEditorForm.FormCreate
  219.   Description: standard FormCreate procedure
  220.        Author: Mat Ballard
  221.  Date created: 04/25/2000
  222. Date modified: 04/25/2000 by Mat Ballard
  223.       Purpose: sets the position and populates the Color combo
  224.  Known Issues:
  225.  ------------------------------------------------------------------------------}
  226. procedure TAxisEditorForm.FormCreate(Sender: TObject);
  227. var
  228.   i: Integer;
  229. begin
  230. {$IFNDEF LANG_ENGLISH}
  231.   DoCaptionsFromResource;
  232. {$ENDIF}
  233.   DoHintsFromResource;
  234.  
  235.   SetDialogGeometry(Self, ApplyBitBtn, HelpBitBtn.Left);
  236.  
  237. {set combo and edit box widths:}
  238.   for i := 0 to Self.ComponentCount - 1 do
  239.     if ((Self.Components[i] is TNEdit) or
  240.         (Self.Components[i] is TColorEdit) or
  241.         (Self.Components[i] is TComboBox)) then
  242.       TControl(Self.Components[i]).Width := 88
  243.     else if (Self.Components[i] is TBitBtn) then
  244.       TControl(Self.Components[i]).Width := 97;
  245. {the exception:}
  246.   NoComboBox.Width := 57;
  247.  
  248. {Populate the combo boxes:}
  249.   for i := 0 to 18 do
  250.     DigitsComboBox.Items.Add(IntToStr(i));
  251.   for i := 0 to Ord(High(TLabelFormat)) do
  252.     FormatComboBox.Items.Add(Copy(GetEnumName(TypeInfo(TLabelFormat), i), 3, 99));
  253.   for i := 0 to 9 do
  254.     MinorsComboBox.Items.Add(IntToStr(i));
  255.   for i := 0 to 20 do
  256.     PenWidthComboBox.Items.Add(IntToStr(i));
  257.   for i := 0 to Ord(High(TPenStyle)) do
  258.     PenStyleComboBox.Items.Add(Copy(GetEnumName(TypeInfo(TPenStyle), i), 3, 99));
  259.   for i := 0 to 7 do
  260.     PrecisionComboBox.Items.Add(IntToStr(i));
  261.   for i := 0 to Ord(High(TDirection)) do
  262.     LabelDirectionComboBox.Items.Add(Copy(GetEnumName(TypeInfo(TDirection), i), 3, 99));
  263.  
  264.   AxisPropertyList := TList.Create;
  265.   AxisNames := TStringList.Create;
  266. end;
  267.  
  268. {------------------------------------------------------------------------------
  269.     Procedure: TAxisEditorForm.DoCaptionsFromResource
  270.   Description: standard loading of labels from resources
  271.        Author: Mat Ballard
  272.  Date created: 06/25/2001
  273. Date modified: 06/25/2001 by Mat Ballard
  274.       Purpose: display in different languages
  275.  Known Issues:
  276.  ------------------------------------------------------------------------------}
  277. {$IFNDEF LANG_ENGLISH}
  278. procedure TAxisEditorForm.DoCaptionsFromResource;
  279. begin
  280.   Self.Caption := sAxis + ' ' + sEditor;
  281.   AxisNumberLabel.Caption := sAxis + ' ' + sNumber;
  282.   AutoScaleCheckBox.Caption := sAutoScalingTicking;
  283.   VisibleCheckBox.Caption := sAxis + ' ' + sVisible;
  284.   ScaleGroupBox.Caption := sScale;
  285.     MinLabel.Caption := sMin;
  286.     MaxLabel.Caption := sMax;
  287.     InterceptLabel.Caption := sIntercept;
  288.     LogScaleCheckBox.Caption := sLogarithmic;
  289.   TickGroupBox.Caption := sTicks;
  290.     TickDirectionLabel.Caption := sDirection;
  291.     TickMinorsLabel.Caption := sMinors;
  292.     TickSizeLabel.Caption := sSize;
  293.     StepSizeLabel.Caption := sStepSize;
  294.   LabelsGroupBox.Caption := sLabels;
  295.     FormatLabel.Caption := sFormat;
  296.     DigitsLabel.Caption := sDigits;
  297.     PrecisionLabel.Caption := sPrecision;
  298.     LabelDirectionLabel.Caption := sDirection;
  299.   PenGroupBox.Caption := sPen;
  300.     PenColorLabel.Caption := sColor;
  301.     PenWidthLabel.Caption := sWidth;
  302.     PenStyleLabel.Caption := sStyle;
  303.   ArrowsGroupBox.Caption := sArrows;
  304.     ArrowSizeLabel.Caption := sSize;
  305.     ArrowDirectionLabel.Caption := sDirection;
  306.   LimitsGroupBox.Caption := sLimits;
  307.     LowerLimitLabel.Caption := sLower;
  308.     UpperLimitLabel.Caption := sUpper;
  309.     LimitsVisibleCheckBox.Caption := sVisible;
  310.   ZAxisGroupBox.Caption := 'Z ' + sAxis;
  311.     ZAngleLabel.Caption := sAngle;
  312.     ZLengthLabel.Caption := sLength;
  313.     ZInterceptLabel.Caption := sIntercept;
  314.   HelpBitBtn.Caption := sHelp;
  315.   OKBitBtn.Caption := sOK;
  316.   CancelBitBtn.Caption := sCancel;
  317.   ApplyBitBtn.Caption := sApply;
  318. end;
  319. {$ENDIF}
  320.  
  321. {------------------------------------------------------------------------------
  322.     Procedure: TAxisEditorForm.DoHintsFromResource
  323.   Description: standard loading of labels from resources
  324.        Author: Mat Ballard
  325.  Date created: 06/25/2001
  326. Date modified: 06/25/2001 by Mat Ballard
  327.       Purpose: display in different languages
  328.  Known Issues:
  329.  ------------------------------------------------------------------------------}
  330. procedure TAxisEditorForm.DoHintsFromResource;
  331. begin
  332.   TitleEdit.Hint := sTitleEditHint;
  333.   NoComboBox.Hint := sAxisNumberHint;
  334.   AutoScaleCheckBox.Hint := sAutoScalingTickingHint;
  335.   VisibleCheckBox.Hint := sAxisVisibleHint;
  336.   MinNEdit.Hint := sMinHint;
  337.   MaxNEdit.Hint := sMaxHint;
  338.   InterceptNEdit.Hint := sInterceptHint;
  339.   LogScaleCheckBox.Hint := sLogarithmicHint;
  340.   TickDirectionComboBox.Hint := sTickDirectionHint;
  341.   MinorsComboBox.Hint := sMinorsHint;
  342.   TickSizeNEdit.Hint := sSizeHint;
  343.   StepSizeNEdit.Hint := sStepSizeHint;
  344.   FormatComboBox.Hint := sFormatHint;
  345.   DigitsComboBox.Hint := sDigitsHint;
  346.   PrecisionComboBox.Hint := sPrecisionHint;
  347.   LabelDirectionComboBox.Hint := sLabelDirectionHint;
  348.   ArrowSizeNEdit.Hint := sArrowSizeHint;
  349.   ArrowDirectionComboBox.Hint := sArrowDirectionHint;
  350.   LimitsGroupBox.Hint := sLimitsGroupBoxHint;
  351.   LowerLimitNEdit.Hint := sLowerLimitHint;
  352.   UpperLimitNEdit.Hint := sLowerLimitHint;
  353.   LimitsVisibleCheckBox.Hint := sLimitsVisibleHint;
  354.   ZAngleNEdit.Hint := sAngleHint;
  355.   ZLengthNEdit.Hint := sLengthHint;
  356.   ZInterceptNEdit.Hint := sZInterceptHint;
  357.   ApplyBitBtn.Hint := sApplyHint;
  358. end;
  359.  
  360. {------------------------------------------------------------------------------
  361.     Procedure: TAxisEditorForm.FormClose
  362.   Description: standard FormClose procedure
  363.        Author: Mat Ballard
  364.  Date created: 04/25/2000
  365. Date modified: 04/25/2000 by Mat Ballard
  366.       Purpose: checks for valid user input
  367.  Known Issues:
  368.  ------------------------------------------------------------------------------}
  369. procedure TAxisEditorForm.FormClose(Sender: TObject;
  370.   var Action: TCloseAction);
  371. begin
  372. {Check that floating point values are valid:
  373.   Action := caHide;
  374.   try
  375.     if (not AutoScaleCheckBox.Checked) then
  376.     begin
  377.       MinEdit.SetFocus;
  378.       Test := StrToFloat(MinEdit.Text)
  379.       MaxEdit.SetFocus;
  380.       TestMax := StrToFloat(MaxEdit.Text)
  381.       if (TestMax < Test) then
  382.         ERangeError.CreateFmt('The Min (%g) MUST be less than the Max (%g)',
  383.           [Test, TestMax]);
  384.       InterceptEdit.SetFocus;
  385.       Test := StrToFloat(InterceptEdit.Text)
  386.       StepSizeEdit.SetFocus;
  387.       Test := Test + StrToFloat(StepSizeEdit.Text);
  388.   {We do the above and below the squelch the warning messages.
  389.       Tag := Trunc(Test);
  390.     end;
  391.   except
  392. {Prevent closure:
  393.     Action := caNone;
  394.   end;}
  395. end;
  396.  
  397. {------------------------------------------------------------------------------
  398.     Procedure: TAxisEditorForm.FormatComboBoxClick
  399.   Description: responds to NumberFormat selection
  400.        Author: Mat Ballard
  401.  Date created: 04/25/2000
  402. Date modified: 04/25/2000 by Mat Ballard
  403.       Purpose: loads the Digits combo depending on selection
  404.  Known Issues:
  405.  ------------------------------------------------------------------------------}
  406. procedure TAxisEditorForm.FormatComboBoxClick(Sender: TObject);
  407. var
  408.   i, iMax, OldIndex: Integer;
  409. begin
  410.   pAXP^.LabelFormat := TLabelFormat(FormatComboBox.ItemIndex);
  411.   OldIndex := DigitsComboBox.ItemIndex;
  412.   DigitsComboBox.Clear;
  413.   iMax := 18;
  414.   if ((FormatComboBox.ItemIndex = Ord(ffGeneral)) or
  415.       (FormatComboBox.ItemIndex = Ord(ffExponent))) then
  416.     iMax := 4;
  417.   for i := 0 to iMax do
  418.   begin
  419.     DigitsComboBox.Items.Add(IntToStr(i));
  420.   end;
  421.   if (OldIndex > iMax) then OldIndex := iMax;
  422.   DigitsComboBox.ItemIndex := OldIndex;
  423. end;
  424.  
  425. {------------------------------------------------------------------------------
  426.     Procedure: TAxisEditorForm.PenStyleComboBoxClick
  427.   Description: responds to user selection
  428.        Author: Mat Ballard
  429.  Date created: 04/25/2000
  430. Date modified: 04/25/2000 by Mat Ballard
  431.       Purpose: sets the Width to 1 if neccessary
  432.  Known Issues:
  433.  ------------------------------------------------------------------------------}
  434. procedure TAxisEditorForm.PenStyleComboBoxClick(Sender: TObject);
  435. begin
  436.   pAXP^.PenStyleIndex := PenStyleComboBox.ItemIndex;
  437.   if (PenStyleComboBox.ItemIndex > Ord(psSolid)) then
  438.     PenWidthComboBox.ItemIndex := 1;
  439. end;
  440.  
  441. {------------------------------------------------------------------------------
  442.     Procedure: TAxisEditorForm.FormActivate
  443.   Description: standard FormActivate procedure
  444.        Author: Mat Ballard
  445.  Date created: 04/25/2000
  446. Date modified: 04/25/2000 by Mat Ballard
  447.       Purpose: sets the Visibility of the Max Label
  448.  Known Issues:
  449.  ------------------------------------------------------------------------------}
  450. procedure TAxisEditorForm.FormActivate(Sender: TObject);
  451. begin
  452.   if (MaxNEdit.Enabled = FALSE) then
  453.     MaxLabel.Enabled := FALSE;
  454.   FormatComboBoxClick(Self);
  455. {$IFDEF LINUX}
  456.   HelpBitBtn.Kind := bkCustom;
  457. {$ENDIF}
  458. end;
  459.  
  460. procedure TAxisEditorForm.FormDestroy(Sender: TObject);
  461. var
  462.   i: Integer;
  463. begin
  464.   for i := 0 to AxisPropertyList.Count-1 do
  465.     FreeMem(AxisPropertyList.Items[i], SizeOf(TAxisProperty));
  466.  
  467.   AxisPropertyList.Free;
  468.   AxisNames.Free;
  469. end;
  470.  
  471. {------------------------------------------------------------------------------
  472.     Procedure: TAxisEditorForm.SelectAxis
  473.   Description: responds to selection of a new Axis
  474.        Author: Mat Ballard
  475.  Date created: 04/25/2000
  476. Date modified: 04/25/2000 by Mat Ballard
  477.       Purpose: manage user input
  478.  Known Issues:
  479.  ------------------------------------------------------------------------------}
  480. procedure TAxisEditorForm.SelectAxis(Index: Integer);
  481. begin
  482.   pAXP := AxisPropertyList.Items[Index];
  483.   CurrentIndex := Index;
  484.  
  485. {Load the combo box:}
  486.   ArrowDirectionComboBox.Clear;
  487.   TickDirectionComboBox.Clear;
  488.   if (Index = 0) then {X Axis:}
  489.   begin
  490.     if (HistoryMode) then
  491.       MaxNEdit.Enabled := FALSE;
  492.     ArrowDirectionComboBox.Items.Add(sLeft);
  493.     ArrowDirectionComboBox.Items.Add(sRight);
  494.     ArrowDirectionComboBox.Items.Add(sNone);
  495.     TickDirectionComboBox.Items.Add(sDown);
  496.     TickDirectionComboBox.Items.Add(sUp);
  497.   end
  498.   else
  499.   begin
  500.     MaxNEdit.Enabled := TRUE;
  501.     ArrowDirectionComboBox.Items.Add(sDown);
  502.     ArrowDirectionComboBox.Items.Add(sUp);
  503.     ArrowDirectionComboBox.Items.Add(sNone);
  504.     TickDirectionComboBox.Items.Add(sRight);
  505.     TickDirectionComboBox.Items.Add(sLeft);
  506.   end;                  
  507.  
  508.   TitleEdit.Text := AxisNames.Strings[Index];
  509.   FormatComboBox.ItemIndex := Ord(pAXP^.LabelFormat);
  510.   DigitsComboBox.ItemIndex := pAXP^.LabelDigits;
  511.   PrecisionComboBox.ItemIndex := pAXP^.LabelPrecision;
  512.   LabelDirectionComboBox.ItemIndex := Ord(pAXP^.LabelDirection);
  513.   PenColorEdit.SetColour(pAXP^.PenColor);
  514.   PenWidthComboBox.ItemIndex := pAXP^.PenWidthIndex;
  515.   PenStyleComboBox.ItemIndex := pAXP^.PenStyleIndex;
  516.   TickSizeNEdit.AsInteger := pAXP^.TickSize;
  517.   TickDirectionComboBox.ItemIndex := Ord(pAXP^.TickDirection);
  518.   StepSizeNEdit.AsReal := pAXP^.TickStepSize;
  519.   MinorsComboBox.ItemIndex := pAXP^.TickMinors;
  520.   MinNEdit.AsReal := pAXP^.ScaleMin;
  521.   MaxNEdit.AsReal :=  pAXP^.ScaleMax;
  522.   InterceptNEdit.AsReal := pAXP^.ScaleIntercept;
  523.   ZInterceptNEdit.AsReal := pAXP^.ZInterceptY;
  524.   AutoScaleCheckBox.Checked :=  pAXP^.ScaleAuto;
  525.   LogScaleCheckBox.Checked :=  pAXP^.ScaleLog;
  526.   ArrowSizeNEdit.AsInteger := pAXP^.ArrowSize;
  527.   ArrowDirectionComboBox.ItemIndex := Ord(pAXP^.ArrowDirection);
  528.   LowerLimitNEdit.AsReal := pAXP^.LimitLower;
  529.   UpperLimitNEdit.AsReal := pAXP^.LimitUpper;
  530.   LimitsVisibleCheckBox.Checked := pAXP^.LimitsVisible;
  531.   if (pAXP^.ZLength > 0) then
  532.   begin
  533.     ZAngleNEdit.AsInteger := pAXP^.ZAngle;
  534.     ZInterceptNEdit.AsReal := pAXP^.ZInterceptY;
  535.     ZLengthNEdit.AsInteger := pAXP^.ZLength;
  536.     ZAxisGroupBox.Enabled := TRUE;
  537.   end
  538.   else
  539.   begin
  540.     ZAxisGroupBox.Enabled := FALSE;
  541.   end;
  542.   ZAngleLabel.Enabled := ZAxisGroupBox.Enabled;
  543.   ZLengthLabel.Enabled := ZAxisGroupBox.Enabled;
  544.   ZInterceptLabel.Enabled := ZAxisGroupBox.Enabled;
  545.  
  546.   AutoScaleCheckBoxClick(Self);
  547.  
  548.   VisibleCheckBox.Checked := pAXP^.Visible;
  549. end;
  550.  
  551. procedure TAxisEditorForm.NoComboBoxClick(Sender: TObject);
  552. var
  553.   Test,
  554.   TestMax: Single;
  555. begin
  556.   try
  557.     if (not AutoScaleCheckBox.Checked) then
  558.     begin
  559.       MinNEdit.SetFocus;
  560.       Test := MinNEdit.AsReal;
  561.       MaxNEdit.SetFocus;
  562.       TestMax := MaxNEdit.AsReal;
  563.       if (TestMax < Test) then
  564.         ERangeError.CreateFmt(sNoComboBoxClick1, [Test, TestMax]);
  565.       InterceptNEdit.SetFocus;
  566.       Test := InterceptNEdit.AsReal;
  567.       StepSizeNEdit.SetFocus;
  568.       Test := Test + StepSizeNEdit.AsReal;
  569. {We do the above and below the squelch the warning messages.}
  570.       Tag := Trunc(Test);
  571.     end;
  572.     SelectAxis(NoComboBox.ItemIndex);
  573.   except
  574.   end;
  575. end;
  576.  
  577. {------------------------------------------------------------------------------
  578.      Function: TAxisEditorForm.AddAxis
  579.   Description: adds a new Axis to the list
  580.        Author: Mat Ballard
  581.  Date created: 04/25/2000
  582. Date modified: 04/25/2000 by Mat Ballard
  583.       Purpose: stores the Axis properties
  584.  Known Issues:
  585.  ------------------------------------------------------------------------------}
  586. function TAxisEditorForm.AddAxis(AName: String; AnAxisProperty: TAxisProperty): Integer;
  587. var
  588.   pDestination: Pointer;
  589.   pDest, pSource: PChar;
  590.   i: Integer;
  591. begin
  592.   NoComboBox.Items.Add(IntToStr(AxisNames.Count));
  593.  
  594.   AxisNames.Add(AName);
  595.  
  596.   GetMem(pDestination, SizeOf(AnAxisProperty));
  597.   pSource := @AnAxisProperty;
  598. {NB: this causes terminal access violations:
  599.   System.Move(pSource, pDestination, SizeOf(AnAxisProperty));}
  600.  
  601.   pDest := pDestination;
  602.   for i := 1 to SizeOf(AnAxisProperty) do
  603.   begin
  604.     pDest^ := pSource^;
  605.     Inc(pSource);
  606.     Inc(pDest);
  607.   end;
  608.  
  609.   AxisPropertyList.Add(pDestination);
  610.   AddAxis := AxisPropertyList.Count;
  611. end;
  612.  
  613. procedure TAxisEditorForm.TitleEditChange(Sender: TObject);
  614. begin
  615.   AxisNames.Strings[CurrentIndex] := TitleEdit.Text;
  616. end;
  617.  
  618. procedure TAxisEditorForm.DigitsComboBoxClick(Sender: TObject);
  619. begin
  620.   pAXP^.LabelDigits := DigitsComboBox.ItemIndex;
  621. end;
  622.  
  623. procedure TAxisEditorForm.PrecisionComboBoxClick(Sender: TObject);
  624. begin
  625.   pAXP^.LabelPrecision := PrecisionComboBox.ItemIndex;
  626. end;
  627.  
  628. procedure TAxisEditorForm.TickDirectionComboBoxClick(Sender: TObject);
  629. begin
  630.   pAXP^.TickDirection := TOrientation(TickDirectionComboBox.ItemIndex);
  631. end;
  632.  
  633. procedure TAxisEditorForm.TickSizeNEditChange(Sender: TObject);
  634. begin
  635.   pAXP^.TickSize := TickSizeNEdit.AsInteger;
  636. end;
  637.  
  638. procedure TAxisEditorForm.StepSizeNEditChange(Sender: TObject);
  639. begin
  640.   pAXP^.TickStepSize := StepSizeNEdit.AsReal;
  641. end;
  642.  
  643. procedure TAxisEditorForm.MinNEditChange(Sender: TObject);
  644. begin
  645.   pAXP^.ScaleMin := MinNEdit.AsReal;
  646. end;
  647.  
  648. procedure TAxisEditorForm.MaxNEditChange(Sender: TObject);
  649. begin
  650.   pAXP^.ScaleMax := MaxNEdit.AsReal;
  651. end;
  652.  
  653. procedure TAxisEditorForm.InterceptNEditChange(Sender: TObject);
  654. begin
  655.   pAXP^.ScaleIntercept := InterceptNEdit.AsReal;
  656. end;
  657.  
  658. procedure TAxisEditorForm.MinorsComboBoxClick(Sender: TObject);
  659. begin
  660.   pAXP^.TickMinors := MinorsComboBox.ItemIndex;
  661. end;
  662.  
  663. procedure TAxisEditorForm.ArrowDirectionComboBoxClick(Sender: TObject);
  664. begin
  665.   pAXP^.ArrowDirection := TAlignment(ArrowDirectionComboBox.ItemIndex);
  666. end;
  667.  
  668. procedure TAxisEditorForm.ArrowSizeNEditChange(Sender: TObject);
  669. begin
  670.   pAXP^.ArrowSize := ArrowSizeNEdit.AsInteger;
  671. end;
  672.  
  673. procedure TAxisEditorForm.VisibleCheckBoxClick(Sender: TObject);
  674. begin
  675.   pAXP^.Visible := VisibleCheckBox.Checked;
  676. end;
  677.  
  678. procedure TAxisEditorForm.AutoScaleCheckBoxClick(Sender: TObject);
  679. begin
  680.   pAXP^.ScaleAuto := AutoScaleCheckBox.Checked;
  681.  
  682.   StepSizeNEdit.Enabled := not AutoScaleCheckBox.Checked;
  683.   MinNEdit.Enabled := not AutoScaleCheckBox.Checked;
  684.   MaxNEdit.Enabled := not AutoScaleCheckBox.Checked;
  685.   InterceptNEdit.Enabled := not AutoScaleCheckBox.Checked;
  686.  
  687.   StepSizeLabel.Enabled := not AutoScaleCheckBox.Checked;
  688.   MinLabel.Enabled := not AutoScaleCheckBox.Checked;
  689.   MaxLabel.Enabled := not AutoScaleCheckBox.Checked;
  690.   InterceptLabel.Enabled := not AutoScaleCheckBox.Checked;
  691. end;
  692.  
  693. procedure TAxisEditorForm.LogScaleCheckBoxClick(Sender: TObject);
  694. begin
  695.   pAXP^.ScaleLog := LogScaleCheckBox.Checked;
  696. end;
  697.  
  698. procedure TAxisEditorForm.PenWidthComboBoxClick(Sender: TObject);
  699. begin
  700.   pAXP^.PenWidthIndex := PenWidthComboBox.ItemIndex;
  701. end;
  702.  
  703. procedure TAxisEditorForm.PenColorEditChange(Sender: TObject);
  704. begin
  705.   pAXP^.PenColor := PenColorEdit.Color;
  706. end;
  707.  
  708. procedure TAxisEditorForm.ApplyBitBtnClick(Sender: TObject);
  709. begin
  710.   TPlot(ThePlot).ApplyAxisChange(Self);
  711. end;
  712.  
  713. procedure TAxisEditorForm.LabelDirectionComboBoxClick(Sender: TObject);
  714. begin
  715.   pAXP^.LabelDirection := TDirection(LabelDirectionComboBox.ItemIndex);
  716. end;
  717.  
  718.  
  719. procedure TAxisEditorForm.ZAngleNEditChange(Sender: TObject);
  720. begin
  721.   pAXP^.ZAngle := ZAngleNEdit.AsInteger;
  722. end;
  723.  
  724. procedure TAxisEditorForm.ZLengthNEditChange(Sender: TObject);
  725. begin
  726.   pAXP^.ZLength := ZLengthNEdit.AsInteger;
  727. end;
  728.  
  729. procedure TAxisEditorForm.ZInterceptNEditChange(Sender: TObject);
  730. begin
  731.   pAXP^.ZInterceptY := ZInterceptNEdit.AsReal;
  732. end;
  733.  
  734. procedure TAxisEditorForm.LowerLimitNEditChange(Sender: TObject);
  735. begin
  736.   pAXP^.LimitLower := LowerLimitNEdit.AsReal;
  737. end;
  738.  
  739. procedure TAxisEditorForm.UpperLimitNEditChange(Sender: TObject);
  740. begin
  741.   pAXP^.LimitUpper := UpperLimitNEdit.AsReal;
  742. end;
  743.  
  744. procedure TAxisEditorForm.LimitsVisibleCheckBoxClick(Sender: TObject);
  745. begin
  746.   pAXP^.LimitsVisible := LimitsVisibleCheckBox.Checked;
  747. end;
  748.  
  749. end.
  750.