home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 September / Chip_2001-09_cd1.bin / zkuste / delphi / kolekce / d12345 / CHEMPLOT.ZIP / TPlot / Plotdefs.pas < prev    next >
Pascal/Delphi Source File  |  2001-05-30  |  15KB  |  524 lines

  1. unit Plotdefs;
  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: Menus.pas, released 16 october 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: 04/16/2001
  31.  
  32. You may retrieve the latest version of this file from:
  33.  
  34.         http://Chemware.hypermart.net/
  35.  
  36. This work was created with the Project JEDI VCL guidelines:
  37.  
  38.         http://www.delphi-jedi.org/Jedi:VCLVCL
  39.  
  40. in mind.
  41.  
  42. Known Issues:
  43. -----------------------------------------------------------------------------}
  44.  
  45. {
  46. HOWTO add menu items:
  47.  
  48. Warning: this is a complex multistep process!
  49.  
  50. 1. Edit TPlot.wb1 and add the menu item(s) you want, where you want.
  51.    Make sure you update the indices correctly.
  52.  
  53. 2. Copy the 3000 series indices and captions to your favourite editor.
  54.  
  55. 3. Ditto the 4000 ditto to ditto, add to the end of the 3000 ditto.
  56.  
  57. 4. Remove the blank lines.
  58.  
  59. 5. Change every 'CRLF' to '"CRLF '.
  60.  
  61. 6. Change every tab to ', "'.
  62.  
  63. 7. Open Strlist.res or Strlist32.res in your favourite String Resource editor.
  64.  
  65. 8. Delete the existing 3000-4999 stringlist data.
  66.  
  67. 9. Paste in the new stringlists from your editor.
  68.  
  69. 10. Save the new stringlist resource.
  70.  
  71. 11. Open Images32.res in the Image Editor.
  72.  
  73. 12. for i := MaxImageNo downto NewIndex do
  74.       ImageIndex := ImageIndex + NoNewMenuItems;
  75.  
  76. 13. create your new 16x16x256 bitmap(s), and rename them to NewIndex, ....
  77.  
  78. 14. Save Images32.Res.
  79.  
  80. 15. Open Plotxxx_xx.bpg, open Plotxxx_Rxx.dpk, and ...
  81.  
  82. 16. In Plotdefs.pas, insert your new mnuMyNewMenuItem(s).
  83.  
  84. 17. In PlotImageList.pas, redefine NO_IMAGES to the new value.
  85.  
  86. 18. In Plot.pas, create your new MyNewMenuClick method(s).
  87.  
  88. 19. In Plot.pas, go to TCustomPlot.CreateMenus, and add:
  89.   FPlotPopUpMenu.Items[Ord(mnuXXX)].Items[Ord(mnuMyNewMenuItem)].OnClick := MyNewMenuClick;
  90.  
  91. 20. Change
  92.           TPlot.DetermineMenuVisibility,
  93.           TPlot.SetSeriesVisibility and
  94.           TPlot.SetSeriesEnabledness
  95.           TPopupOptions.Create
  96.   as required.
  97. }
  98.  
  99. interface
  100.  
  101. uses
  102.   Classes, {SysUtils,}
  103. {$IFDEF WINDOWS}
  104.   Menus, Wintypes
  105. {$ENDIF}
  106. {$IFDEF WIN32}
  107.   Menus, Windows
  108. {$ENDIF}
  109. {$IFDEF LINUX}
  110.   Types,
  111.   QMenus
  112. {$ENDIF}
  113.   ;
  114.  
  115. const
  116.   TPLOT_VERSION = 200;
  117.  
  118.   FILE_FORMAT_VERSION = 200;
  119.   MAX_FILE_VERSION = 200;
  120.  
  121.   TAG_BASE = 1000;
  122.   CAPTION_BASE = 3000;
  123.   HINT_BASE = 4000;
  124.  
  125.   TWO_PI = 2*PI;
  126.   PI_ON_TWO = PI/2;
  127.   THREE_PI_ON_TWO = 3*PI/2;
  128.  
  129. {$IFDEF MSWINDOWS}
  130.   SMALL_FONT_SIZE = 8;
  131.   MEDIUM_FONT_SIZE = 9;
  132.   LARGE_FONT_SIZE = 14;
  133. {$ENDIF}
  134. {$IFDEF LINUX}
  135.   SMALL_FONT_SIZE = 10;
  136.   MEDIUM_FONT_SIZE = 12;
  137.   LARGE_FONT_SIZE = 18;
  138. {$ENDIF}
  139.  
  140.  
  141. resourcestring
  142. {constructor:}
  143.   sArial = 'Arial';
  144.   
  145. type
  146. {type definitions for dynamic menu arrays:}
  147.   TMenuArray = array[0..127] of TMenuItem;
  148.   pMenuArray = ^TMenuArray;
  149.  
  150. {Different possible plot types: these determine how the series are interpreted,
  151.  and so how data are displayed on screen}
  152.   TPlotType = (
  153.     ptXY,
  154.     ptError,
  155.     ptMultiple,
  156.     ptBubble,
  157.     ptColumn,
  158.     ptStack,
  159.     ptNormStack,
  160.     ptPie,
  161.     ptPolar,
  162.     ptContour,
  163.     pt3DContour,
  164.     pt3DWire{pt3DSurface, ptPipeLine, pt3DContour});
  165. {ptXY          - a normal XY plot that everyone does in sigh school
  166.  
  167.  ptError       - every second (odd indexed) series is interpreted as the "error bar" of the
  168.                  previous (even indexed) series.
  169.                   
  170.  ptMultiple    - each "point" is composed of a multiple of points from
  171.                  the different series. This is a generalised extension of the previous
  172.                  ptError type. It is used for High-Low-Close, High-Low-Open-Close, etc
  173.                  plots. Eg:
  174.   high, low        high, average, low        high, low, open, close;
  175.      X                     X                           H
  176.      |                     |                           |
  177.      |                     |                           O
  178.      |                     O                           |
  179.      |                     |                           |
  180.      |                     |                           |
  181.      |                     |                           |
  182.      |                     |                           C
  183.      |                     |                           |
  184.      X                     X                           L
  185.                  See the Multiplicity property !
  186.  
  187.  ptColumn      - columns of data: the last X value is taken as Xn + (Xn - Xn-1),
  188.                  so the appearance is:
  189.                               (X1, Y1)----(X2, Y1)
  190.                               |                  |
  191.                               |                  (Xn, Yn)----(Xn+dX, Yn)
  192.            (X0, Y0)----(X1, Y0)                  |                     |
  193.            |                  |                  |                     |
  194.            |                  |                  |                     |
  195.            |                  |                  |                     |
  196.            |                  |                  |                     |
  197.            (X0, 0)---------(X1, 0)------------(X2, 0)---------(Xn+dX, 0)
  198.                 - when there are N (> 1) series, each gap is divided by (N+1):
  199.                               -------
  200.                               |     |
  201.                               |     |
  202.            -------            |     |
  203.            |     |------      |     |
  204.            |     |     |      |     |------
  205.            |     |     |      |     |     |
  206.            |     |     |      |     |     |
  207.            (X0, 0)---------(X1, 0)------------(X2, 0)
  208.  
  209.  ptStack       - a stacked column, with each series on to of each other
  210.  
  211.  ptNormStack   - like a stack, but normalized to 100%
  212.  
  213.  ptPie         - very boring pie graphs
  214.  
  215.  ptPolar       - (x, y) = (r*cos(theta), r*sin(theta))
  216.  
  217.  ptContour     - a two-dimensional plot where the color represents the Y value.
  218.  
  219.  pt3DContour   - a three-dimensional plot where the color represents the Y value.
  220.  
  221.  pt3DWire      - a three-dimensional plot in which each series in order as succesive slices through the surface
  222. }
  223.  
  224.   TScreenJob = (sjNone,
  225.                 sjDrag,
  226.                 sjRightDrag,
  227.                 sjHide,
  228.                 sjZoomIn,
  229.                 sjEditAxis,
  230.                 sjTouchNotePointer,
  231.                 sjMoveNotePointer,
  232.                 sjEditFont,
  233.                 sjEditPoint,
  234.                 sjEditSeries,
  235.                 sjFlashEdit,
  236.                 sjCopySeries,
  237.                 sjDisplace,
  238.                 sjCloneSeries,
  239.                 sjDeleteSeries,
  240.                 sjLinearize,
  241.                 sjZero,
  242.                 sjPosition,
  243.                 sjNearestPoint,
  244.                 sjAverage,
  245.                 sjContractSeries,
  246.                 sjContractAllSeries,
  247.                 sjSplineSeries,
  248.                 sjHighs,
  249.                 sjLows,
  250.                 sjMovingAverage,
  251.                 sjSmoothSeries,
  252.                 sjSortSeries,
  253.                 sjDifferentiate,
  254.                 sjIntegrate,
  255.                 sjIntegral,
  256.                 sjLineOfBestFit,
  257.                 sjDualLineBestFit1, sjDualLineBestFit2,
  258.                 sjSelection,
  259.                 sjDualSelection1, sjDualSelection2);
  260. {What particular operation is to be carried out ?}
  261. {}
  262. {Note that a 2-region line of best fit is a 2 stage operation.}
  263.  
  264.   TObjectType = (soNone,
  265.                  soTitle,
  266.                  soLegend,
  267.                  soResult,
  268.                  soNote,
  269.                  soXAxis, soXAxisTitle, soXAxisLabel,
  270.                  soYAxis, soYAxisTitle,soYAxisLabel,
  271.                  soLeftBorder, soTopBorder, soRightBorder, soBottomBorder,
  272.                  soSeries);
  273. {What object on the screen got clicked on ?}
  274. {}
  275. {Note that the soYAxis, soYAxisTitle, and soYAxisLabel are generic: several
  276.  sub-components can share this type.}
  277.  
  278.   TDisplayMode = (dmNormal, dmNone, dmRun, dmHistory);
  279. {What do we do when new data is added ?}
  280. {}
  281. {    dmNormal: Check (and adjust DisplayMode if neccessary) with the addition of every point.}
  282. {    dmNone: Nothing;}
  283. {    dmRun: Increase the Span of the X Axis by 100% to accomodate the new data,
  284.  and alter (increase) the scale of the Y Axis if needed.}
  285. {    dmHistory: Similar to dmRun, except that the X-Axis runs from (Min-Max)
  286.  through (x-Max) to 0.}
  287. {}
  288. {Note that with dmRun we can expect more data with increasing X values.
  289.  Rather than force a complete screen re-draw every time a data point is
  290.  added, we extend the X Axis by 100%.}
  291. {}
  292. {History mode, dmHistory, deserves a few more words. In this mode TCustomPlot
  293.  displays the data over the last History 's worth of points - older data is not
  294.  displayed. The result is a graph that shows the last few seconds or minutes of
  295.  data in great detail.}
  296.  
  297.   TContourDetail = (cdLow, cdMedium, cdHigh, cdVHigh);
  298.  
  299.   TGridType = (gtNone, gtHorizontal, gtVertical, gtBoth);
  300.  
  301.   TSymbol = (syNone,
  302.     syCircle, sySquare,
  303.     syUpTriangle, syDownTriangle,
  304.     syPlus, syCross, syStar,
  305.     syDash, syVertDash, syLeftDash, syRightDash);
  306. {These are the different symbols that are used to represent the data points.}
  307.  
  308. {the actual menus:}
  309.   TMainMenus = (
  310.     mnuFile,
  311.     mnuEdit,
  312.     mnuView,
  313.     mnuCalc
  314. {$IFDEF FINANCIAL}
  315.     , mnuFinance
  316. {$ENDIF}
  317.     );
  318.   TMainOptions = set of TMainMenus;
  319.  
  320.   TFileMenus = (
  321.     mnuNew,
  322.     mnuOpen,
  323.     mnuOverlayDiv, {convention: Name the Divs after the following menuitem}
  324.     mnuOverlay,
  325.     mnuClearOverlays,
  326.     mnuSaveDiv,
  327.     mnuSave,
  328.     mnuSaveAs,
  329.     mnuSaveImage,
  330.     mnuPrintDiv,
  331.     mnuPrint);
  332.   TFileOptions = set of TFileMenus;
  333.  
  334.   TEditMenus = (
  335.     mnuCopy,
  336.     mnuCopyHTML,
  337.     mnuCopySeries,
  338.     mnuPaste,
  339.     mnuDisplaceDiv,
  340.     mnuDisplace,
  341.     mnuResetDisplacement,
  342.     mnuEditSeriesDiv,
  343.     mnuNewSeries,
  344.     mnuCloneSeries,
  345.     mnuEditPoint,
  346.     mnuEditData,
  347.     mnuEditSeries,
  348.     mnuDeleteSeries,
  349.     mnuLinearize,
  350.     mnuZero,
  351.     mnuAxisDiv,
  352.     mnuNewY2Axis,
  353.     mnuEditAxis,
  354.     mnuDeleteY2Axis,
  355.     mnuEditFontDiv,
  356.     mnuNewNote,
  357.     mnuMoveNotePointer,
  358.     mnuDeleteNote,
  359.     mnuEditFont,
  360.     mnuEditPropertiesDiv,
  361.     mnuEditProperties); {19}
  362.   TEditOptions = set of TEditMenus;
  363.  
  364.   TViewMenus = (
  365.     mnuHide,
  366.     mnuShowAll,
  367.     mnuDisplayModeDiv,
  368.     mnuDisplayMode,
  369.     mnuLegend,
  370.     mnuZoomDiv,
  371.     mnuSetAsNormal,
  372.     mnuNormalView,
  373.     mnuManualZoom,
  374.     mnuZoomIn,
  375.     mnuZoomOut);
  376.   TViewOptions = set of TViewMenus;
  377.  
  378.   TCalcMenus = (
  379.     mnuPosition,
  380.     mnuNearestPoint,
  381.     mnuCalcAverageDiv,
  382.     mnuCalcAverage,
  383.     mnuCompressSeries,
  384.     mnuCompressAllSeries,
  385.     mnuContractSeries,
  386.     mnuContractAllSeries,
  387.     mnuCubicSplineSeries,
  388.     mnuHighs,
  389.     mnuMovingAverage,
  390.     mnuSmoothSeries,
  391.     mnuSortSeries,
  392.     mnuCalculusDiv,
  393.     mnuDifferentiate,
  394.     mnuIntegrate,
  395.     mnuIntegral,
  396.     mnuLineOfBestFitDiv,
  397.     mnuLineOfBestFit,
  398.     mnuTwoRegionLineOfBestFit
  399. {$IFDEF FUNCTIONS}
  400.     , mnuFunctionDiv,
  401.     mnuFunction);
  402. {$ENDIF}
  403.     );
  404.   TCalcOptions = set of TCalcMenus;
  405.  
  406. {$IFDEF FINANCE}
  407.   TFinanceMenus = (
  408.     mnuRSI
  409.     );
  410.   TFinanceOptions = set of TFinanceMenus;
  411. {$ENDIF}
  412.  
  413.   TModeMenus = (
  414.     mnuNormal,
  415.     mnuNone,
  416.     mnuRun,
  417.     mnuHistory);
  418.  
  419.   TSaveOption = (soAsText, soProperties);
  420.   TSaveOptions = set of TSaveOption;
  421.  
  422.   T3DPoint = Record
  423.     x: Integer;
  424.     y: Integer;
  425.     Z: Single;
  426.     ZShift: TPoint;
  427.   end;
  428.  
  429.   TPoints = array [0..600] of TPoint;
  430.   pTPoints = ^TPoints;
  431.  
  432.   TPopupOptions = class(TPersistent)
  433.   private
  434.     FMenu: TMainOptions;
  435.     FFile: TFileOptions;
  436.     FEdit: TEditOptions;
  437.     FView: TViewOptions;
  438.     FCalc: TCalcOptions;
  439. {$IFDEF FINANCE}
  440.     FFinance: TFinanceOptions;
  441. {$ENDIF}
  442.   protected
  443.     procedure AssignTo(Dest: TPersistent); override;
  444. {TRectangle's implementation of the standard Assign(To) method.}
  445.   public
  446.     Constructor Create; {$IFDEF DELPHI4_UP}reintroduce;{$ENDIF}
  447. {D1 cannot publish sets with more than 16 members}
  448. {$IFNDEF DELPHI1}
  449.   published
  450. {$ENDIF}
  451.     property Menu: TMainOptions read FMenu write FMenu;
  452.     property File_: TFileOptions read FFile write FFile;
  453.     property Edit: TEditOptions read FEdit write FEdit;
  454.     property View: TViewOptions read FView write FView;
  455.     property Calc: TCalcOptions read FCalc write FCalc;
  456. {$IFDEF FINANCE}
  457.     property Finance: TFinanceOptions read FFinance write FFinance;
  458. {$ENDIF}
  459.   end;
  460.  
  461. implementation
  462.  
  463. {------------------------------------------------------------------------------
  464.   Constructor: TPopupOptions.Create;
  465.   Description: standard constructor
  466.        Author: Mat Ballard
  467.  Date created: 10/15/1999
  468. Date modified: 10/15/2000 by Mat Ballard
  469.       Purpose: enables all menu options
  470.  Known Issues:
  471.  ------------------------------------------------------------------------------}
  472. Constructor TPopupOptions.Create;
  473. var
  474.   i: Integer;
  475. begin
  476.   FMenu := [];
  477.   FFile := [];
  478.   FEdit := [];
  479.   FView := [];
  480.   FCalc := [];
  481. {$IFDEF FINANCE}
  482.   FFinance := [];
  483. {$ENDIF}
  484.  
  485.   for i := 0 to Ord(High(TMainMenus)) do
  486.     Include(FMenu, TMainMenus(i));
  487.   for i := 0 to Ord(High(TFileMenus)) do
  488.     Include(FFile, TFileMenus(i));
  489.   for i := 0 to Ord(High(TEditMenus)) do
  490.     Include(FEdit, TEditMenus(i));
  491.   for i := 0 to Ord(High(TViewMenus)) do
  492.     Include(FView, TViewMenus(i));
  493.   for i := 0 to Ord(High(TCalcMenus)) do
  494.     Include(FCalc, TCalcMenus(i));
  495. {$IFDEF FINANCE}
  496.   for i := 0 to Ord(High(TFinanceMenus)) do
  497.     Include(FFinance, TFinanceMenus(i));
  498. {$ENDIF}
  499. end;
  500.  
  501. {------------------------------------------------------------------------------
  502.     Procedure: TPopupOptions.AssignTo;
  503.   Description: standard copier
  504.        Author: Mat Ballard
  505.  Date created: 04/20/2001
  506. Date modified: 04/20/2001 by Mat Ballard
  507.       Purpose: copies values from a source
  508.  Known Issues:
  509.  ------------------------------------------------------------------------------}
  510. procedure TPopupOptions.AssignTo(Dest: TPersistent);
  511. begin
  512.   TPopupOptions(Dest).Menu := FMenu;
  513.   TPopupOptions(Dest).File_ := FFile;
  514.   TPopupOptions(Dest).Edit := FEdit;
  515.   TPopupOptions(Dest).View := FView;
  516.   TPopupOptions(Dest).Calc := FCalc;
  517. {$IFDEF FINANCE}
  518.   TPopupOptions(Dest).Finance := FFinance;
  519. {$ENDIF}
  520. end;
  521.  
  522.  
  523. end.
  524.