home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 December / Chip_2001-12_cd1.bin / zkuste / delphi / kolekce / d56 / DM2KVCL.ZIP / PLOTDEMO / PLOTDMOU.PAS < prev   
Pascal/Delphi Source File  |  2000-11-26  |  5KB  |  165 lines

  1. {****************************************************************************}
  2. {                            Data Master 2000                                }
  3. {****************************************************************************}
  4. unit PlotDmoU;
  5.  
  6. interface
  7.  
  8. uses
  9.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  10.   ExtCtrls, Plot, StdCtrls, Data, Spin, ColorGrd, ComCtrls;
  11.  
  12. type
  13.   TPlotDemoForm = class(TForm)
  14.     Plot: TPlot;
  15.     Container: TContainer;
  16.     Panel: TPanel;
  17.     PlotHintLabel: TLabel;
  18.     PlotClickLabel: TLabel;
  19.     YAxisButton: TButton;
  20.     SerieLabel: TLabel;
  21.     SerieSpinEdit: TSpinEdit;
  22.     SerieButton: TButton;
  23.     SaveButton: TButton;
  24.     SelectionCheckBox: TCheckBox;
  25.     ColorGrid1: TColorGrid;
  26.     CopyRadioGroup: TRadioGroup;
  27.     CopyButton: TButton;
  28.     DeleteButton: TButton;
  29.     ModeComboBox: TComboBox;
  30.     ModifiedCheckBox: TCheckBox;
  31.     FillButton: TButton;
  32.     ProgressBar: TProgressBar;
  33.     Label1: TLabel;
  34.     procedure PlotHint(Sender: TObject; H: String);
  35.     procedure PlotPaint(Sender: TObject);
  36.     procedure PlotPointClick(Sender: TObject; Point, Serie: Integer);
  37.     procedure PlotSelectionChange(Sender: TObject);
  38.     procedure YAxisButtonClick(Sender: TObject);
  39.     procedure SerieButtonClick(Sender: TObject);
  40.     procedure SaveButtonClick(Sender: TObject);
  41.     procedure SelectionCheckBoxClick(Sender: TObject);
  42.     procedure ColorGrid1Change(Sender: TObject);
  43.     procedure CopyButtonClick(Sender: TObject);
  44.     procedure SerieSpinEditChange(Sender: TObject);
  45.     procedure DeleteButtonClick(Sender: TObject);
  46.     procedure ModeComboBoxChange(Sender: TObject);
  47.     procedure PlotError(Sender: TObject; H: String);
  48.     procedure ContainerChanged(Sender: TObject);
  49.     procedure FillButtonClick(Sender: TObject);
  50.     procedure ContainerProgress(Sender: TObject; P: Integer);
  51.   private
  52.     { Private declarations }
  53.   public
  54.     { Public declarations }
  55.   end;
  56.  
  57. var
  58.   PlotDemoForm: TPlotDemoForm;
  59.  
  60. implementation
  61.  
  62. uses AxisDlg, SerieDlg, Common;
  63.  
  64. {$R *.DFM}
  65.  
  66. procedure TPlotDemoForm.PlotHint(Sender: TObject; H: String);
  67. begin
  68.   PlotHintLabel.Caption:=H; PlotHintLabel.Refresh;
  69. end;
  70.  
  71. procedure TPlotDemoForm.PlotPaint(Sender: TObject);
  72. begin
  73.   Plot.DrawPoint(5,100,ptCircle,20);
  74. end;
  75.  
  76. procedure TPlotDemoForm.PlotPointClick(Sender: TObject; Point,Serie: Integer);
  77. begin
  78.   MessageBeep($ffffffff);
  79.   PlotClickLabel.Caption:=Format('Point: %d, serie: %d',[Point,Serie]);
  80. end;
  81.  
  82. procedure TPlotDemoForm.PlotSelectionChange(Sender: TObject);
  83. begin
  84.   PlotClickLabel.Caption:=Format('X1:%g, X2:%g, Y1:%g, Y2:%g',
  85.   [Plot.SelectionLeft,Plot.SelectionRight,
  86.   Plot.SelectionBottom,Plot.SelectionTop]);
  87. end;
  88.  
  89. procedure TPlotDemoForm.YAxisButtonClick(Sender: TObject);
  90. begin
  91.   AxisPropsForm.Execute(Plot.YAxis);
  92. end;
  93.  
  94. procedure TPlotDemoForm.SerieButtonClick(Sender: TObject);
  95. begin
  96.   with SeriePropsForm do
  97.   begin
  98.     WorksheetComboBox.Clear;
  99.     WorksheetComboBox.Items.AddObject(Container.FileName,Container);
  100.     if Assigned(Plot.ThisSerie.Container)
  101.     then WorksheetComboBox.ItemIndex:=0 else WorksheetComboBox.ItemIndex:=-1;
  102.     XColumnComboBox.Items.Text:='Value'+CRLF+'Square';
  103.     YColumnComboBox.Items.Assign(XColumnComboBox.Items); // copy column labels
  104.     // here - set XExpressionComboBox.Items!
  105.     YExpressionComboBox.Items.Assign(XExpressionComboBox.Items); // copy hist.
  106.     Execute(Plot.ThisSerie);
  107.     YExpressionComboBox.Items.Assign(XExpressionComboBox.Items); // save hist.
  108.   end;
  109. end;
  110.  
  111. procedure TPlotDemoForm.SaveButtonClick(Sender: TObject);
  112. begin
  113.   Plot.SaveToFile(ChangeFileExt(Container.FileName,'.wmf'));
  114. end;
  115.  
  116. procedure TPlotDemoForm.SelectionCheckBoxClick(Sender: TObject);
  117. begin
  118.   Plot.SelectionVisible:=SelectionCheckBox.Checked;
  119. end;
  120.  
  121. procedure TPlotDemoForm.ColorGrid1Change(Sender: TObject);
  122. begin
  123.   {Plot.transparent!}Color:=ColorGrid1.ForeGroundColor;
  124. end;
  125.  
  126. procedure TPlotDemoForm.CopyButtonClick(Sender: TObject);
  127. begin Plot.CopyToClipboard(TPlotCopyMode(CopyRadioGroup.ItemIndex),true); end;
  128.  
  129. procedure TPlotDemoForm.SerieSpinEditChange(Sender: TObject);
  130. begin Plot.SerieIndex:=SerieSpinEdit.Value; end;
  131.  
  132. procedure TPlotDemoForm.DeleteButtonClick(Sender: TObject);
  133. begin Plot.Delete; end;
  134.  
  135. procedure TPlotDemoForm.ModeComboBoxChange(Sender: TObject);
  136. begin Plot.MouseMode:=TPlotMouseMode(ModeComboBox.ItemIndex); end;
  137.  
  138. procedure TPlotDemoForm.PlotError(Sender: TObject; H: String);
  139. begin PlotClickLabel.Caption:=H; end;
  140.  
  141. procedure TPlotDemoForm.ContainerChanged(Sender: TObject);
  142. begin ModifiedCheckBox.Checked:=Container.Modified; Plot.Refresh; end;
  143.  
  144. procedure TPlotDemoForm.FillButtonClick(Sender: TObject);
  145. var i: integer; d: trealdata;
  146. begin
  147.   for i:=0 to plot.series.count-1 do plot.series[i].clearblock;
  148.   container.clear;
  149.   for i:=0 to 10000 do
  150.   begin
  151.     d:=trealdata.create; d.insitem(i); d.insitem(i*i/1.5);
  152.     container.items.add(d);
  153.   end;
  154.   plot.series[0].firstline:=0; plot.series[0].lastline:=10000;
  155.   plot.series[0].xcolumn:=1; plot.series[0].ycolumn:=2;
  156.   plot.xaxis.autoscale:=true; plot.yaxis.autoscale:=true;
  157. end;
  158.  
  159. procedure TPlotDemoForm.ContainerProgress(Sender: TObject; P: Integer);
  160. begin
  161.   if p<99 then Progressbar.position:=p else Progressbar.position:=0;
  162. end;
  163.  
  164. end.
  165.