home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 7 / FreshFishVol7.bin / new / misc / sci / splines / spline.c < prev    next >
C/C++ Source or Header  |  1994-09-16  |  3KB  |  118 lines

  1. /* The routines in this file are copyright (c) 1987 by Helene (Lee) Taran.
  2.  * Permission is granted for use and free distribution as long as the
  3.  * original author's name is included with the code.
  4.  */
  5.  
  6. /*
  7.  * Reformatted, and modified to compile without warnings and errors
  8.  * under SAS/C -6.5x by gduncan@philips.oz.au (GMD). This included
  9.  * proto generation, renaming of some literals to avoid name collisions,
  10.  * and Amiga Version string (also displayed in Title bar).
  11.  * No original version number, this version arbitrarily named 1.1. 
  12.  * - otherwise no functional changes.
  13.  * GMD - Sep 94
  14.  */
  15.  
  16. #include "all.h"
  17.  
  18. #define VERSION "1.1 "__AMIGADATE__
  19.  
  20. /*
  21.  * Version string (GMD)
  22.  */
  23. static char A_vers[] = "\0$VER: spline\t" VERSION;
  24.  
  25. DLIST_ELEMENT Control_Points;
  26.  
  27. main ()
  28. {
  29.  
  30.   /*
  31.    * append Version string to TitleBar (GMD)
  32.    */
  33.  
  34.   strcat (TitleBar, VERSION);
  35.   OpenLibraries ();
  36.   SetupEnvironment ();
  37.   Init_List (&Control_Points);
  38.   Create_ControlPoints ();
  39.   Init_GValues ();        /* sets up the Gvalues for interpolating splines */
  40.  
  41.  
  42.  
  43.   while (1)            /* Main Loop */
  44.     {
  45.       INTUIMESSAGE *message;
  46.       INTUIMESSAGE mcopy;
  47.  
  48.       /* Wait until something happens and then respond to it */
  49.  
  50.       Wait (1 << Window->UserPort->mp_SigBit);
  51.  
  52.       /* Now, one or more input events have arrived. Respond to ALL */
  53.       while (message = (INTUIMESSAGE *) GetMsg (Window->UserPort))
  54.     {
  55.       mcopy = *message;    /* make a copy of the message */
  56.       ReplyMsg ((MESSAGE *) message);    /* reply to it immediately */
  57.       ProcessMessage (&mcopy);    /* react to the message */
  58.     }
  59.     }
  60. }
  61.  
  62.  
  63. /* ProcessMessage processes an input event given */
  64.  
  65. void
  66. ProcessMessage (msg)
  67.      INTUIMESSAGE *msg;
  68. {
  69.   switch (msg->Class)
  70.     {
  71.     case CLOSEWINDOW:
  72.       close_things ();
  73.       exit (0);
  74.     case MOUSEBUTTONS:
  75.       if (msg->Code == SELECTDOWN)
  76.     {
  77.       DLISTPTR p, Select_ControlPoint ();
  78.       if (p = Select_ControlPoint (msg->MouseX, msg->MouseY))
  79.         Edit_ControlPoint (Window, p);
  80.       else
  81.         Edit_CurveStyle (Window);
  82.     }
  83.       break;
  84.     }
  85. }
  86.  
  87. void
  88. Create_ControlPoints ()
  89. {
  90.   DLISTPTR p;
  91.   REAL_POINT *c;
  92.  
  93.   p = (DLISTPTR) calloc (1, sizeof (DLIST_ELEMENT));
  94.   c = (REAL_POINT *) calloc (1, sizeof (REAL_POINT));
  95.   c->x = 300;
  96.   c->y = 200;
  97.   p->contents = c;
  98.   INSERT_FIRST (p, &Control_Points);
  99.  
  100.   p = (DLISTPTR) calloc (1, sizeof (DLIST_ELEMENT));
  101.   c = (REAL_POINT *) calloc (1, sizeof (REAL_POINT));
  102.   c->x = 155;
  103.   c->y = 30;
  104.   p->contents = c;
  105.   INSERT_FIRST (p, &Control_Points);
  106.  
  107.   p = (DLISTPTR) calloc (1, sizeof (DLIST_ELEMENT));
  108.   c = (REAL_POINT *) calloc (1, sizeof (REAL_POINT));
  109.   c->x = 20;
  110.   c->y = 175;
  111.   p->contents = c;
  112.   INSERT_FIRST (p, &Control_Points);
  113.  
  114.   Draw_ControlPoints (Window);
  115.   Draw_Natural_Bspline (Window, &Control_Points);
  116. }
  117. /*--*/
  118.