home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_progs / libs / plotlib.lha / Plot_1.lzh / Source / OpClL2.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-02-09  |  7.8 KB  |  211 lines

  1. /****************************************************************
  2. *                                                                                                                                *
  3. *     Filename : OpClL2.c                                                                                    *
  4. *                                                                                                                                *
  5. *****************************************************************
  6. *                                                                                                                                *
  7. *        Comment : Level 2 Funktionen von der Plotlibrary.                        *
  8. *                            Unterstützt das öffnen und das schliessen der            *
  9. *                            der Library.                                                                            *
  10. *                                                                                                                                *
  11. *                                Funktionen                                                        *
  12. *                            ==========                                                        *
  13. *                                                                                                                                *
  14. *                createplot()            alloziert Speicher für Plotstruktur        *
  15. *                initplot()                setzt die Plotstrukur auf default            *
  16. *                closeplot()                gibt alle Resourcen frei                            *
  17. *                datainit()                setzte default Grenzwerte                            *
  18. *                                                                                                                                *
  19. *                             globale Variablen                                                *
  20. *                         =================                                                *
  21. *                                                                                                                                *
  22. *                            plot                Plotstrukturpointer                                        *
  23. *                                                                                                                                *
  24. *                Rev : V1.0                                                                                            *
  25. *                                                                                                                                *
  26. *        History : V1.0 erstellen dieses Files                            15/11/89    *
  27. *                                                                                                                                *
  28. *                Doc : Plotlibrary User's Guide                                                    *
  29. *                                                                                                                                *
  30. *             Bugs : keine bekannten                                                                        *
  31. *                                                                                                                                *
  32. *            Autor : Oesch Silvano                                                                            *
  33. *                                                                                                                                *
  34. *            Datum : 15/11/89                                                                                    *
  35. *                                                                                                                                *
  36. ****************************************************************/
  37.  
  38. /****************************************************************
  39. *                                                                                                                                *
  40. *    Plotlibrary Includedateien                                                                        *
  41. *                                                                                                                                *
  42. ****************************************************************/
  43.  
  44. #include "Plot.h"
  45. #include "PlotL2.h"
  46. #include "DispL2.h"
  47. #include "OpClL2.h"
  48.  
  49. /****************************************************************
  50. *                                                                                                                                *
  51. *    globale Variablen                                                                                            *
  52. *                                                                                                                                *
  53. ****************************************************************/
  54.  
  55. struct Plot *plot = NULL;
  56.  
  57. /****************************************************************
  58. *                                                                                                                                *
  59. *    externe Variablen                                                                                            *
  60. *                                                                                                                                *
  61. ****************************************************************/
  62.  
  63. extern int plerr;
  64.  
  65. /****************************************************************
  66. *                                                                                                                                *
  67. *    Function : createplot()                                                                                *
  68. *                                                                                                                                *
  69. *****************************************************************
  70. *                                                                                                                                *
  71. *         Input : void                                                                                                *
  72. *                                                                                                                                *
  73. *        Output : int returnset                                                                            *
  74. *                            != FALSE                Speicher bekommen                                    *
  75. *                            == FALSE                Fehler bei Speicherallozierung        *
  76. *                                                                                                                                *
  77. *****************************************************************
  78. *                                                                                                                                *
  79. *     Comment : alloziert Speicher für die Plotstruktur. Durch            *
  80. *                         das löschen des Speichers sind die folgenden                *
  81. *                         Standardwerte eingestellt:                                                    *
  82. *                                                                                                                                *
  83. *                            Dimension : D2                                                                        *
  84. *                                         Typ :    RID                                                                        *
  85. *                                Masstab : LIN                                                                        *
  86. *                         Grenzwerte    :    AUTOON                                                                *
  87. *                                                                                                                                *
  88. ****************************************************************/
  89.  
  90. int createplot()
  91. {
  92.     int plotsize,                                            /* Grösse der Plotstruktur    */
  93.             returnset;                                        /* Globaler Rückgabewert        */
  94.  
  95.     plotsize = sizeof(struct Plot);        /* Grösse bestimmen                    */
  96.     plot = (struct Plot *)calloc(1,plotsize);
  97.                                                                         /* hole Speicher                        */
  98.     if (plot == NULL)                                    /* Fehler ?                                    */
  99.     {
  100.         seterror(MEMOPPLOT);                        /* Ja                                                */
  101.         setreturn(FALSE);
  102.     }
  103.     else
  104.     {
  105.         initplot();                                            /* initialisiere plot                */
  106.         setreturn(TRUE);
  107.     }
  108.     return (returnset);                                /* und zurück                                */
  109. }
  110.  
  111. /****************************************************************
  112. *                                                                                                                                *
  113. *    Function : initplot()                                                                                    *
  114. *                                                                                                                                *
  115. *****************************************************************
  116. *                                                                                                                                *
  117. *         Input : void                                                                                                *
  118. *                                                                                                                                *
  119. *        Output : void                                                                                                *
  120. *                                                                                                                                *
  121. *****************************************************************
  122. *                                                                                                                                *
  123. *     Comment : Defaultwerte setzten der Plotstruktur soweit sie        *
  124. *                         notwendig sind                                                                            *
  125. *                                                                                                                                *
  126. *                                                                                                                                *
  127. ****************************************************************/
  128.  
  129. void initplot()
  130. {
  131.     plot->typ            = D2;                                /* Darstellungstyp                    */
  132.     plot->grid        = GRID;                            /* Gitterdarstellung                */
  133.     plot->clipp        = NOCLIPP;                    /* kein Clipping                        */
  134.     plot->autoval    = AUTOON;                        /* automatisches minmax            */
  135.     plot->xmes        = LIN;                            /* alle Achsen linear                */
  136.     plot->ymes        = LIN;
  137.     plot->zmes        = LIN;
  138.     plot->count        = NULL;                            /* Kurvencount auf NULL            */
  139.     plot->currid    = NULL;                            /* und neue ID verteilen        */
  140.     plot->d3opt        = HIDDEN|CROSH;            /* Hiddenline, Crosshatch.    */
  141.                                                                         /* einschalten                            */
  142.     datainit();
  143. }
  144.  
  145. /****************************************************************
  146. *                                                                                                                                *
  147. *    Function : datainit()                                                                                    *
  148. *                                                                                                                                *
  149. *****************************************************************
  150. *                                                                                                                                *
  151. *         Input : void                                                                                                *
  152. *                                                                                                                                *
  153. *        Output : void                                                                                                *
  154. *                                                                                                                                *
  155. *****************************************************************
  156. *                                                                                                                                *
  157. *     Comment : Alle minimalen und maximalen Grenzwerte der Plot-    *
  158. *                         struktur auf +-5 setzten. Wenn AUTOVAL vor laden        *
  159. *                         der ersten Kurve auseschaltet wird, dann gelten        *
  160. *                         doiese Grenzen.                                                                        *
  161. *                                                                                                                                *
  162. ****************************************************************/
  163.  
  164. static void datainit()
  165. {
  166.     plot->xmin        = (DATA)-5.0;                /* alle Werte löschen                */
  167.     plot->xmax        = (DATA)5.0;
  168.     plot->ymin        = (DATA)-5.0;
  169.     plot->ymax        = (DATA)5.0;
  170.     plot->zmin        = (DATA)-5.0;
  171.     plot->zmax        = (DATA)5.0;
  172. }
  173.  
  174. /****************************************************************
  175. *                                                                                                                                *
  176. *    Function : closeplot()                                                                                *
  177. *                                                                                                                                *
  178. *****************************************************************
  179. *                                                                                                                                *
  180. *         Input : void                                                                                                *
  181. *                                                                                                                                *
  182. *        Output : void                                                                                                *
  183. *                                                                                                                                *
  184. *****************************************************************
  185. *                                                                                                                                *
  186. *     Comment : Der Graphikbildschirm wird geschlossen, wenn er        *
  187. *                         geöffnet ist. Alle Kurvenstrukturen und die                *
  188. *                         Plotstruktur werden an das System zurückgegeben.        *
  189. *                                                                                                                                *
  190. ****************************************************************/
  191.  
  192. void closeplot()
  193. {
  194.     char **name;                                            /* Zeiger auf Charpointer        */
  195.     int i;                                                        /* Schleifenzähler                    */
  196.  
  197.     (void)deldata(DELALL,NULL);                /* alle Kurven freigeben        */
  198.  
  199.     name = &plot->titel;                            /* startend ab Titel                */
  200.     for (i=0;i<MAXNAMES;i++)                    /* alle freigeben                        */
  201.     {
  202.         if (*name)                                            /* aber nur wenn vorhanden    */
  203.             free(*name);                                    /* Name löschen                            */
  204.         name++;                                                    /* nächster Name                        */
  205.     }
  206.  
  207.     free(plot);                                                /* plotstruktur freigeben        */
  208.     plot = NULL;                                            /* setzte zurück auf NULL        */
  209. }
  210.  
  211.