home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / wps / progs / chaos / sources / graph.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-12  |  1.8 KB  |  53 lines

  1. /*  PMChaos.   (C) Copyright Matthew Austern, 1993.
  2.  
  3.     Permission granted to use, distribute, and modify, provided that this
  4.     notice remains intact.  If you distribute a modified version, you must
  5.     identify your modifications as such.
  6. */
  7.  
  8. /* Prototypes for functions in graph.c */
  9.  
  10. /* Must #include os2.h before including this file. */
  11.  
  12. #define MaxGraphLabelLength 100
  13.  
  14. struct GraphInfo {
  15.   long WindowWidth, WindowHeight; /* Full size of the window. */
  16.   double xMin, xMax, yMin, yMax; /* Limits of the graph. */
  17.   long xLeftMargin, yBotMargin;     /* Blank space by the side of graph. */
  18.   long xRightMargin, yTopMargin; /*  Not symmetric, because of axis labels. */
  19.   double xConvFactor, yConvFactor; /* Convert from graph to window coords. */
  20.   double xFirstTick, yFirstTick, xTickInc, yTickInc; /* Where to put ticks. */
  21.   long MajorTickSize, HalfTickSize, MinorTickSize; /* Size of ticks. */
  22.   char xLabel[MaxGraphLabelLength], yLabel[MaxGraphLabelLength];
  23.   long xLabelWidth, yLabelWidth;
  24.   unsigned short FontPointSize;
  25.   long FontHeight;
  26.   long FontWidth;
  27. };
  28.  
  29. void DrawAxes(HPS hps, struct GraphInfo *G);
  30. void ClipToGraph (HPS PS, struct GraphInfo *G);
  31. void UndoClipping(HPS);
  32. void SizeAxes(HPS hps,
  33.           long Width, long Height,
  34.           double xMin, double xMax, double yMin, double yMax,
  35.           char *xLabel, char *yLabel,
  36.           struct GraphInfo *G);
  37.  
  38. #include "inline.h"
  39.  
  40. INLINE POINTL toPoint (double x, double y, struct GraphInfo *G)
  41. {
  42.   POINTL result;
  43.   result.x = (long) (G->xLeftMargin + (x - G->xMin) * G->xConvFactor);
  44.   result.y = (long) (G->yBotMargin + (y - G->yMin) * G->yConvFactor);
  45.   return result;
  46. }
  47.  
  48. INLINE void toXY (POINTL P, double *x, double *y, struct GraphInfo *G)
  49. {
  50.   *x = G->xMin + (P.x - G->xLeftMargin) / G->xConvFactor;
  51.   *y = G->yMin + (P.y - G->yBotMargin) / G->yConvFactor;
  52. }
  53.