home *** CD-ROM | disk | FTP | other *** search
- unit Plotdefs;
-
- {$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: Menus.pas, released 16 october 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: 04/16/2001
-
- 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.
-
- Known Issues:
- -----------------------------------------------------------------------------}
-
- {
- HOWTO add menu items:
-
- Warning: this is a complex multistep process!
-
- 1. Edit TPlot.wb1 and add the menu item(s) you want.
- It is best to add them in their correct position near rows 209-269.
- Add its hint similarly, in the rows below.
- Make sure you update the indices correctly.
-
- 2. Open Images32.res in the Image Editor.
-
- 3. for i := MaxImageNo downto NewIndex do
- ImageIndex := ImageIndex + NoNewMenuItems;
-
- 4. create your new 16x16x256 bitmap(s), and rename them to NewIndex, ....
-
- 5. Save Images32.Res.
-
- 6. Open Plotxxx_xx.bpg, open Plotxxx_Rxx.dpk, and ...
-
- 7. In Plotdefs.pas, insert your new mnuMyNewMenuItem(s).
-
- 8. In PlotImageList.pas, redefine NO_IMAGES to the new value.
-
- 9. In Plot.pas, create your new MyNewMenuClick method(s).
-
- 10. In Plot.pas, go to the CreateOnClicks procedure of TCustomPlot.CreateMenus, and add:
- FPlotPopUpMenu.Items[Ord(mnuXXX)].Items[Ord(mnuMyNewMenuItem)].OnClick := MyNewMenuClick;
-
- 11. Similarly add the Caption and Hint.
-
- 20. Change
- TPlot.DetermineMenuVisibility,
- TPlot.SetSeriesVisibility and
- TPlot.SetSeriesEnabledness
- TPopupOptions.Create
- as required.
-
- 21. If you are support languages than English, try to translate your new menu caption and hint.
-
- 22. Export the neccessary resourcestrings from the spreadsheet to the TPlot/lang/eng.txt (and other) files.
- }
-
- interface
-
- uses
- Classes, {SysUtils,}
- {$IFDEF WINDOWS}
- Menus, Graphics, Wintypes
- {$ENDIF}
- {$IFDEF WIN32}
- Menus, Graphics, Windows
- {$ENDIF}
- {$IFDEF LINUX}
- Types,
- QGraphics, QMenus
- {$ENDIF}
- ;
-
- {Misc and TPlot now only work for Compiler 3 up !}
- {$IFDEF COMPILER3_UP}
- {$IFDEF WIN32}
- {http://www.freetranslation.com/:}
- {$IFDEF LANG_ENGLISH}{$I lang\eng.txt}{$ENDIF}
- {$IFDEF LANG_FRENCH}{$I lang\fre.txt}{$ENDIF}
- {$IFDEF LANG_GERMAN}{$I lang\ger.txt}{$ENDIF}
- {$IFDEF LANG_ITALIAN}{$I lang\ita.txt}{$ENDIF}
- {$IFDEF LANG_NORWEGIAN}{$I lang\nor.txt}{$ENDIF}
- {$IFDEF LANG_PORTUGUESE}{$I lang\por.txt}{$ENDIF}
- {$IFDEF LANG_SPANISH}{$I lang\spa.txt}{$ENDIF}
- {Universal Translator by LanguageForce:}
- {$IFDEF LANG_CZECH}{$I lang\cze.txt}{$ENDIF}
- {$IFDEF LANG_DUTCH}{$I lang\dut.txt}{$ENDIF}
- {$IFDEF LANG_DANISH}{$I lang\dan.txt}{$ENDIF}
- {$IFDEF LANG_GREEK}{$I lang\gre.txt}{$ENDIF}
- {$IFDEF LANG_HUNGARIAN}{$I lang\hun.txt}{$ENDIF}
- {$IFDEF LANG_INDONESIAN}{$I lang\ind.txt}{$ENDIF}
- {$IFDEF LANG_ROMANIAN}{$I lang\rom.txt}{$ENDIF}
- {$IFDEF LANG_RUSSIAN}{$I lang\rus.txt}{$ENDIF}
- {$IFDEF LANG_SLOVAK}{$I lang\slo.txt}{$ENDIF}
- {$IFDEF LANG_SWEDISH}{$I lang\swe.txt}{$ENDIF}
- {$IFDEF LANG_THAI}{$I lang\tha.txt}{$ENDIF}
- {$IFDEF LANG_TURKISH}{$I lang\tur.txt}{$ENDIF}
- {$IFDEF LANG_UKRAINIAN}{$I lang\ukr.txt}{$ENDIF}
- {$ENDIF}
- {$IFDEF LINUX}
- {http://www.freetranslation.com/:}
- {$IFDEF LANG_ENGLISH}{$I lang/eng.txt}{$ENDIF}
- {$IFDEF LANG_FRENCH}{$I lang/fre.txt}{$ENDIF}
- {$IFDEF LANG_GERMAN}{$I lang/ger.txt}{$ENDIF}
- {$IFDEF LANG_ITALIAN}{$I lang/ita.txt}{$ENDIF}
- {$IFDEF LANG_NORWEGIAN}{$I lang/nor.txt}{$ENDIF}
- {$IFDEF LANG_PORTUGUESE}{$I lang/por.txt}{$ENDIF}
- {$IFDEF LANG_SPANISH}{$I lang/spa.txt}{$ENDIF}
- {Universal Translator by LanguageForce:}
- {$IFDEF LANG_CZECH}{$I lang/cze.txt}{$ENDIF}
- {$IFDEF LANG_DUTCH}{$I lang/dut.txt}{$ENDIF}
- {$IFDEF LANG_DANISH}{$I lang/dan.txt}{$ENDIF}
- {$IFDEF LANG_GREEK}{$I lang/gre.txt}{$ENDIF}
- {$IFDEF LANG_HUNGARIAN}{$I lang/hun.txt}{$ENDIF}
- {$IFDEF LANG_INDONESIAN}{$I lang/ind.txt}{$ENDIF}
- {$IFDEF LANG_ROMANIAN}{$I lang/rom.txt}{$ENDIF}
- {$IFDEF LANG_RUSSIAN}{$I lang/rus.txt}{$ENDIF}
- {$IFDEF LANG_SLOVAK}{$I lang/slo.txt}{$ENDIF}
- {$IFDEF LANG_SWEDISH}{$I lang/swe.txt}{$ENDIF}
- {$IFDEF LANG_THAI}{$I lang/tha.txt}{$ENDIF}
- {$IFDEF LANG_TURKISH}{$I lang/tur.txt}{$ENDIF}
- {$IFDEF LANG_UKRAINIAN}{$I lang/ukr.txt}{$ENDIF}
- {$ENDIF}
- {$ELSE}
- Misc and TPlot now only work for Compiler 3 up !
- {$ENDIF}
-
- const
- TPLOT_VERSION = 232;
-
- FILE_FORMAT_VERSION = 200;
- MAX_FILE_VERSION = 200;
-
- TAG_BASE = 1000;
- CAPTION_BASE = 3000;
- HINT_BASE = 4000;
-
- TWO_PI = 2*PI;
- PI_ON_TWO = PI/2;
- THREE_PI_ON_TWO = 3*PI/2;
-
- {$IFDEF MSWINDOWS}
- SMALL_FONT_SIZE = 8;
- MEDIUM_FONT_SIZE = 9;
- LARGE_FONT_SIZE = 14;
- {$ENDIF}
- {$IFDEF LINUX}
- SMALL_FONT_SIZE = 10;
- MEDIUM_FONT_SIZE = 12;
- LARGE_FONT_SIZE = 18;
- {$ENDIF}
-
- {This roughly controls the number of unique colors in contour plots:}
- COLOUR_GRANULARITY = 256;
- {Default: 256;
- - larger values may give a slightly improved image;
- - smaller values lead to false banding.}
-
- resourcestring
- {constructor:}
- sArial = 'Arial';
-
- type
- {type definitions for dynamic menu arrays:}
- TMenuArray = array[0..127] of TMenuItem;
- pMenuArray = ^TMenuArray;
-
- TDegrees = 0..359;
-
- TDirection = (drHorizontal, drVertical);
- {Screen objects are often Horizontal or Vertical.}
-
- TOrientation = (orRight, orLeft);
- {Other screen objects can be Left or Right aligned.}
-
- {Different possible plot types: these determine how the series are interpreted,
- and so how data are displayed on screen}
- TPlotType = (
- ptXY,
- ptError,
- ptMultiple,
- ptBubble,
- ptColumn,
- ptStack,
- ptNormStack,
- ptPie,
- ptPolar,
- ptLineContour,
- ptContour,
- pt3DContour,
- pt3DWire,
- pt3DColumn);
- {ptXY - a normal XY plot that everyone does in sigh school
-
- ptError - every second (odd indexed) series is interpreted as the "error bar" of the
- previous (even indexed) series.
-
- ptMultiple - each "point" is composed of a multiple of points from
- the different series. This is a generalised extension of the previous
- ptError type. It is used for High-Low-Close, High-Low-Open-Close, etc
- plots. Eg:
- high, low high, average, low high, low, open, close;
- X X H
- | | |
- | | O
- | O |
- | | |
- | | |
- | | |
- | | C
- | | |
- X X L
- See the Multiplicity property !
-
- ptColumn - columns of data: the last X value is taken as Xn + (Xn - Xn-1),
- so the appearance is:
- (X1, Y1)----(X2, Y1)
- | |
- | (Xn, Yn)----(Xn+dX, Yn)
- (X0, Y0)----(X1, Y0) | |
- | | | |
- | | | |
- | | | |
- | | | |
- (X0, 0)---------(X1, 0)------------(X2, 0)---------(Xn+dX, 0)
- - when there are N (> 1) series, each gap is divided by (N+1):
- -------
- | |
- | |
- ------- | |
- | |------ | |
- | | | | |------
- | | | | | |
- | | | | | |
- (X0, 0)---------(X1, 0)------------(X2, 0)
-
- ptStack - a stacked column, with each series on to of each other
-
- ptNormStack - like a stack, but normalized to 100%
-
- ptPie - very boring pie graphs
-
- ptPolar - (x, y) = (r*cos(theta), r*sin(theta))
-
- ptContour - a two-dimensional plot where the color represents the Y value.
-
- pt3DContour - a three-dimensional plot where the color represents the Y value.
-
- pt3DWire - a three-dimensional plot in which each series in order as succesive slices through the surface
- }
-
- TScreenJob = (sjNone,
- sjDrag,
- sjRightDrag,
- sjHide,
- sjZoomIn,
- sjEditAxis,
- sjTouchNotePointer,
- sjMoveNotePointer,
- sjEditFont,
- sjEditPoint,
- sjEditSeries,
- sjFlashEdit,
- sjCopySeries,
- sjDisplace,
- sjCloneSeries,
- sjDeleteSeries,
- sjLinearize,
- sjZero,
- sjPosition,
- sjNearestPoint,
- sjAverage,
- sjContractSeries,
- sjContractAllSeries,
- sjSplineSeries,
- sjHighs,
- sjLows,
- sjMovingAverage,
- sjSmoothSeries,
- sjSortSeries,
- sjDifferentiate,
- sjIntegrate,
- sjIntegral,
- sjLineOfBestFit,
- sjDualLineBestFit1, sjDualLineBestFit2,
- sjSelection,
- sjDualSelection1, sjDualSelection2);
- {What particular operation is to be carried out ?}
- {}
- {Note that a 2-region line of best fit is a 2 stage operation.}
-
- TObjectType = (soNone,
- soTitle,
- soLegend,
- soResult,
- soXAxis, soXAxisTitle, soXAxisLabel,
- soYAxis, soYAxisTitle,soYAxisLabel,
- soZAxis, soZAxisTitle,soZAxisLabel,
- soLeftBorder, soTopBorder, soRightBorder, soBottomBorder,
- soSeries,
- soNote);
- {What object on the screen got clicked on ?}
- {}
- {Note that the soYAxis, soYAxisTitle, and soYAxisLabel are generic: several
- sub-components can share this type.}
-
- TDisplayMode = (dmNormal, dmNone, dmRun, dmHistory);
- {What do we do when new data is added ?}
- {}
- { dmNormal: Check (and adjust DisplayMode if neccessary) with the addition of every point.}
- { dmNone: Nothing;}
- { dmRun: Increase the Span of the X Axis by 100% to accomodate the new data,
- and alter (increase) the scale of the Y Axis if needed.}
- { dmHistory: Similar to dmRun, except that the X-Axis runs from (Min-Max)
- through (x-Max) to 0.}
- {}
- {Note that with dmRun we can expect more data with increasing X values.
- Rather than force a complete screen re-draw every time a data point is
- added, we extend the X Axis by 100%.}
- {}
- {History mode, dmHistory, deserves a few more words. In this mode TCustomPlot
- displays the data over the last History 's worth of points - older data is not
- displayed. The result is a graph that shows the last few seconds or minutes of
- data in great detail.}
-
- TContourDetail = (cdLow, cdMedium, cdHigh);
-
- TGridType = (gtNone, gtHorizontal, gtVertical, gtBoth);
-
- TSymbol = (syNone,
- syCircle, sySquare,
- syUpTriangle, syDownTriangle,
- syPlus, syCross, syStar,
- syDash, syVertDash, syLeftDash, syRightDash);
- {These are the different symbols that are used to represent the data points.}
-
- {the actual menus:}
- TMainMenus = (
- mnuFile,
- mnuEdit,
- mnuView,
- mnuCalc
- {$IFDEF FINANCE}
- , mnuFinance
- {$ENDIF}
- );
- TMainOptions = set of TMainMenus;
-
- TFileMenus = (
- mnuNew,
- mnuOpen,
- mnuOverlayDiv, {convention: Name the Divs after the following menuitem}
- mnuOverlay,
- mnuClearOverlays,
- mnuSaveDiv,
- mnuSave,
- mnuSaveAs,
- mnuSaveImage,
- mnuPrintDiv,
- mnuPrint);
- TFileOptions = set of TFileMenus;
-
- TEditMenus = (
- mnuCopy,
- mnuCopyHTML,
- mnuCopySeries,
- mnuPaste,
- mnuDisplaceDiv,
- mnuDisplace,
- mnuResetDisplacement,
- mnuEditSeriesDiv,
- mnuNewSeries,
- mnuCloneSeries,
- mnuEditPoint,
- mnuEditData,
- mnuEditSeries,
- mnuDeleteSeries,
- mnuLinearize,
- mnuZero,
- mnuAxisDiv,
- mnuNewYAxis,
- mnuEditAxis,
- mnuDeleteY2Axis,
- mnuEditFontDiv,
- mnuNewNote,
- mnuMoveNotePointer,
- mnuDeleteNote,
- mnuEditFont,
- mnuPropertiesDiv,
- mnuProperties); {19}
- TEditOptions = set of TEditMenus;
-
- TViewMenus = (
- mnuHide,
- mnuShowAll,
- mnuDisplayModeDiv,
- mnuDisplayMode,
- mnuLegend,
- mnuZoomDiv,
- mnuSetAsNormal,
- mnuNormal,
- mnuManualZoom,
- mnuZoomIn,
- mnuZoomOut);
- TViewOptions = set of TViewMenus;
-
- TCalcMenus = (
- mnuPosition,
- mnuNearestPoint,
- mnuCalcAverageDiv,
- mnuCalcAverage,
- mnuCompressSeries,
- mnuCompressAllSeries,
- mnuContractSeries,
- mnuContractAllSeries,
- mnuCubicSpline,
- mnuHighs,
- mnuMovingAverage,
- mnuSmoothSeries,
- mnuSortSeries,
- mnuCalculusDiv,
- mnuDifferentiate,
- mnuIntegrate,
- mnuIntegral,
- mnuLineOfBestFitDiv,
- mnuLineOfBestFit,
- mnuTwoRegionLineOfBestFit
- {$IFDEF FUNCTIONS}
- , mnuFunctionDiv,
- mnuFunction
- {$ENDIF}
- );
- TCalcOptions = set of TCalcMenus;
-
- {$IFDEF FINANCE}
- {These have been taken from:
- http://www.stockcharts.com/education/What/IndicatorAnalysis/
- }
- TFinanceMenus = (
- mnuADL,
- mnuAroon,
- mnuADX,
- mnuATR,
- mnuBB,
- mnuCCI,
- mnuCMF,
- mnuMACD,
- mnuMA,
- mnuPVO,
- mnuPO,
- mnuPR,
- mnuPVB,
- mnuRSI,
- mnuStochOsc,
- mnuStochRSI,
- mnuTRIN,
- mnuWilliams);
- TFinanceOptions = set of TFinanceMenus;
- {$ENDIF}
-
- TSaveOption = (soAsText, soProperties);
- TSaveOptions = set of TSaveOption;
-
- T3DPoint = Record
- x: Integer;
- y: Integer;
- z: Integer;
- end;
- p3DPoint = ^T3DPoint;
-
- T3DZPoint = Record
- x: Integer;
- y: Integer;
- Z: Single;
- end;
- p3DZPoint = ^T3DZPoint;
-
- T3DRealPoint = Record
- X: Single;
- Y: Single;
- Z: Single;
- end;
- p3DRealPoint = ^T3DRealPoint;
-
- TPoints = array [0..600] of TPoint;
- pTPoints = ^TPoints;
-
- TLimits = class(TPersistent)
- private
- FAxisIndex: Byte;
- FPen: TPen;
- FLower: Single;
- FUpper: Single;
- FVisible: Boolean;
- FOnChange: TNotifyEvent;
- procedure SetAxisIndex(Value: Byte);
- procedure SetPen(Value: TPen);
- procedure SetLower(Value: Single);
- procedure SetUpper(Value: Single);
- procedure SetVisible(Value: Boolean);
- protected
- procedure AssignTo(Dest: TPersistent); override;
- public
- Constructor Create; {$IFDEF DELPHI4_UP}reintroduce;{$ENDIF}
- Destructor Destroy; override;
- published
- property AxisIndex: Byte read FAxisIndex write SetAxisIndex;
- property Pen: TPen read FPen write SetPen;
- property Lower: Single read FLower write SetLower;
- property Upper: Single read FUpper write SetUpper;
- property Visible: Boolean read FVisible write SetVisible;
- property OnChange: TNotifyEvent read FOnChange write FOnChange;
- end;
-
-
- TPopupOptions = class(TPersistent)
- private
- FMenu: TMainOptions;
- FFile: TFileOptions;
- FEdit: TEditOptions;
- FView: TViewOptions;
- FCalc: TCalcOptions;
- {$IFDEF FINANCE}
- FFinance: TFinanceOptions;
- {$ENDIF}
- protected
- procedure AssignTo(Dest: TPersistent); override;
- {TPopupOptions's implementation of the standard Assign(To) method.}
- public
- Constructor Create; {$IFDEF DELPHI4_UP}reintroduce;{$ENDIF}
- {D1 cannot publish sets with more than 16 members}
- {$IFNDEF DELPHI1}
- published
- {$ENDIF}
- property Menu: TMainOptions read FMenu write FMenu;
- property File_: TFileOptions read FFile write FFile;
- property Edit: TEditOptions read FEdit write FEdit;
- property View: TViewOptions read FView write FView;
- property Calc: TCalcOptions read FCalc write FCalc;
- {$IFDEF FINANCE}
- property Finance: TFinanceOptions read FFinance write FFinance;
- {$ENDIF}
- end;
-
- implementation
-
-
- {------------------------------------------------------------------------------
- Constructor: TPopupOptions.Create;
- Description: standard constructor
- Author: Mat Ballard
- Date created: 10/15/1999
- Date modified: 10/15/2000 by Mat Ballard
- Purpose: enables all menu options
- Known Issues:
- ------------------------------------------------------------------------------}
- Constructor TPopupOptions.Create;
- var
- i: Integer;
- begin
- FMenu := [];
- FFile := [];
- FEdit := [];
- FView := [];
- FCalc := [];
- {$IFDEF FINANCE}
- FFinance := [];
- {$ENDIF}
-
- for i := 0 to Ord(High(TMainMenus)) do
- Include(FMenu, TMainMenus(i));
- for i := 0 to Ord(High(TFileMenus)) do
- Include(FFile, TFileMenus(i));
- for i := 0 to Ord(High(TEditMenus)) do
- Include(FEdit, TEditMenus(i));
- for i := 0 to Ord(High(TViewMenus)) do
- Include(FView, TViewMenus(i));
- for i := 0 to Ord(High(TCalcMenus)) do
- Include(FCalc, TCalcMenus(i));
- {$IFDEF FINANCE}
- for i := 0 to Ord(High(TFinanceMenus)) do
- Include(FFinance, TFinanceMenus(i));
- {$ENDIF}
- end;
-
- {------------------------------------------------------------------------------
- Procedure: TPopupOptions.AssignTo;
- Description: standard copier
- Author: Mat Ballard
- Date created: 04/20/2001
- Date modified: 04/20/2001 by Mat Ballard
- Purpose: copies values from a source
- Known Issues:
- ------------------------------------------------------------------------------}
- procedure TPopupOptions.AssignTo(Dest: TPersistent);
- begin
- TPopupOptions(Dest).Menu := FMenu;
- TPopupOptions(Dest).File_ := FFile;
- TPopupOptions(Dest).Edit := FEdit;
- TPopupOptions(Dest).View := FView;
- TPopupOptions(Dest).Calc := FCalc;
- {$IFDEF FINANCE}
- TPopupOptions(Dest).Finance := FFinance;
- {$ENDIF}
- end;
-
- {******************************************************************************}
- {------------------------------------------------------------------------------
- Constructor: TLimits.Create;
- Description: standard constructor
- Author: Mat Ballard
- Date created: 07/20/2001
- Date modified: 07/20/2001 by Mat Ballard
- Purpose: sets default values
- Known Issues:
- ------------------------------------------------------------------------------}
- Constructor TLimits.Create;
- begin
- FAxisIndex := 1;
- FUpper := 7;
- FLower := 3;
- FPen := TPen.Create;
- FPen.Color := clRed;
- FPen.Style := psDot;
- FOnChange := nil;
- end;
-
- Destructor TLimits.Destroy;
- begin
- FOnChange := nil;
- FPen.Free;
- inherited Destroy;
- end;
-
- {------------------------------------------------------------------------------
- Procedure: TLimits.AssignTo;
- Description: standard copier
- Author: Mat Ballard
- Date created: 04/20/2001
- Date modified: 04/20/2001 by Mat Ballard
- Purpose: copies values from a source
- Known Issues:
- ------------------------------------------------------------------------------}
- procedure TLimits.AssignTo(Dest: TPersistent);
- begin
- TLimits(Dest).Upper := FUpper;
- TLimits(Dest).Lower := FLower;
- TLimits(Dest).Visible := FVisible;
- end;
-
- procedure TLimits.SetUpper(Value: Single);
- begin
- FUpper := Value;
- if (FUpper < FLower) then
- FLower := Value;
- if Assigned(FOnChange) then OnChange(Self);
- end;
-
- procedure TLimits.SetAxisIndex(Value: Byte);
- begin
- FAxisIndex := Value;
- if Assigned(FOnChange) then OnChange(Self);
- end;
-
- procedure TLimits.SetPen(Value: TPen);
- begin
- FPen := Value;
- if Assigned(FOnChange) then OnChange(Self);
- end;
-
- procedure TLimits.SetLower(Value: Single);
- begin
- FLower := Value;
- if (FLower > FUpper) then
- FLower := Value;
- if Assigned(FOnChange) then OnChange(Self);
- end;
-
- procedure TLimits.SetVisible(Value: Boolean);
- begin
- FVisible := Value;
- if Assigned(FOnChange) then OnChange(Self);
- end;
-
- end.
-