home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 3 / CDPDIII.bin / pd / graphics / 3d / icoons / source / commands.c < prev    next >
C/C++ Source or Header  |  1992-10-11  |  34KB  |  1,035 lines

  1.  
  2. /************************************************************************/
  3. /*                                                                      */
  4. /* This file contains code for most of the commands.            */
  5. /*                                                                      */
  6. /************************************************************************/
  7.  
  8. #include <stdio.h>
  9. #include <string.h>
  10. #include <ctype.h>
  11. #include <math.h>
  12.  
  13. #include "general.h"
  14. #include "globals.h"
  15. #include "intui.h"
  16. #include "spl_math.h"
  17. #include "spl_util.h"
  18. #include "spl_gfx.h"
  19. #include "file.h"
  20. #include "add.h"
  21. #include "move.h"
  22. #include "scale_g.h"
  23. #include "rotate_g.h"
  24. #include "knotinfo.h"
  25. #include "ttddd.h"
  26. #include "commands.h"
  27.  
  28.  
  29. static char Current_Object_FileName[File_Name_Length+1] = { '\0' };
  30. static char Current_Object_DirName[Path_Name_Length+1] = { '\0' };
  31.  
  32. static char Current_TTDDD_FileName[File_Name_Length+1] = { '\0' };
  33. static char Current_TTDDD_DirName[Path_Name_Length+1] = { '\0' };
  34.  
  35. static char Current_Config_FileName[File_Name_Length+1] = { '\0' };
  36. static char Current_Config_DirName[Path_Name_Length+1] = { '-' };
  37.  
  38. void Command_Pan_Up()
  39. /************************************************************************/
  40. /*                                                                      */
  41. /* Pan upwards in the current view.                    */
  42. /*                                                                      */
  43. /************************************************************************/
  44. {
  45.     Move_Offset(0, Select_View_Id);
  46.     Compute_Splines();
  47.     Redraw_Mask |= What_All;
  48.  
  49. } /* Command_Pan_Up */
  50.  
  51. void Command_Pan_Down()
  52. /************************************************************************/
  53. /*                                                                      */
  54. /* Pan downwards in the current view.                    */
  55. /*                                                                      */
  56. /************************************************************************/
  57. {
  58.     Move_Offset(1, Select_View_Id);
  59.     Compute_Splines();
  60.     Redraw_Mask |= What_All;
  61.  
  62. } /* Command_Pan_Down */
  63.  
  64. void Command_Pan_Right()
  65. /************************************************************************/
  66. /*                                                                      */
  67. /* Pan to the right in the current view.                */
  68. /*                                                                      */
  69. /************************************************************************/
  70. {
  71.     Move_Offset(2, Select_View_Id);
  72.     Compute_Splines();
  73.     Redraw_Mask |= What_All;
  74.  
  75. } /* Command_Pan_Right */
  76.  
  77. void Command_Pan_Left()
  78. /************************************************************************/
  79. /*                                                                      */
  80. /* Pan to the left in the current view.                    */        
  81. /*                                                                      */
  82. /************************************************************************/
  83. {
  84.     Move_Offset(3, Select_View_Id);
  85.     Compute_Splines();
  86.     Redraw_Mask |= What_All;
  87.  
  88. } /* Command_Pan_Left */
  89.  
  90. void Command_Add()
  91. /************************************************************************/
  92. /*                                                                      */
  93. /* Enter add mode.                            */
  94. /*                                                                      */
  95. /************************************************************************/
  96. {
  97.     Set_Mode_Add();
  98.  
  99. } /* Command_Add */
  100.  
  101. void Command_Scale_Group()
  102. /************************************************************************/
  103. /*                                                                      */
  104. /* Show scale group window.                        */
  105. /*                                                                      */
  106. /************************************************************************/
  107. {
  108.     if (Windows[(int)W_Scale_Group].Window == NULL) 
  109.                     Window_Open(W_Scale_Group);
  110.     WindowToFront(Windows[W_Scale_Group].Window);
  111.  
  112. } /* Command_Scale_Group */
  113.  
  114. void Command_Rotate_Group()
  115. /************************************************************************/
  116. /*                                                                      */
  117. /* Show rotate group window.                        */
  118. /*                                                                      */
  119. /************************************************************************/
  120. {
  121.     if (Windows[(int)W_Rotate_Group].Window == NULL) 
  122.                     Window_Open(W_Rotate_Group);
  123.     WindowToFront(Windows[W_Rotate_Group].Window);
  124.  
  125. } /* Command_Rotate_Group */
  126.  
  127. void Command_Move_Group()
  128. /************************************************************************/
  129. /*                                                                      */
  130. /* Show move group window.                        */
  131. /*                                                                      */
  132. /************************************************************************/
  133. {
  134.     if (Windows[(int)W_Move_Group].Window == NULL) 
  135.                     Window_Open(W_Move_Group);
  136.     WindowToFront(Windows[W_Move_Group].Window);
  137.  
  138.     if (Select_Point_Id >= 0) 
  139.     Set_Move_Group_Position(Points[Select_Point_Id].Pos);
  140.  
  141. } /* Command_Move_Group */
  142.  
  143. void Command_Connect()
  144. /************************************************************************/
  145. /*                                                                      */
  146. /* Try to connect the selected spline to another spline near it.    */
  147. /* If ok, then enable menu, and return to normal mode.            */
  148. /*                                                                      */
  149. /************************************************************************/
  150. {
  151.     if (Select_View_Id < 0 || 
  152.     Select_Spline == NULL || Select_Knot == NULL) return;
  153.  
  154.     if (Splines_Connect(Select_View_Id, Select_Spline, Select_Knot)) {
  155.  
  156.         Mark_Connected_Segments(Select_Point_Id);
  157.         Draw_Marked_Segments(DM_Erase, What_All); 
  158.         Compute_Marked_Segments();
  159.         Draw_Marked_Segments(DM_Normal, What_All); 
  160.  
  161.     Set_RMBTrap(FALSE);    /* Enable menu again */
  162.  
  163.         Set_Mode_Normal();
  164.         Set_Window_Title(NULL);
  165.  
  166.     } /* if */
  167.  
  168. } /* Command_Connect */
  169.  
  170. void Command_Combine()
  171. /************************************************************************/
  172. /*                                                                      */
  173. /* Try to combine the selected spline with another spline near it.    */
  174. /*                                                                      */
  175. /************************************************************************/
  176. {
  177.     if (Select_View_Id < 0 || 
  178.     Select_Spline == NULL || Select_Knot == NULL) return;
  179.  
  180.     if (Splines_Combine(Select_View_Id, Select_Spline, Select_Knot)) {
  181.  
  182.         Mark_Connected_Segments(Select_Point_Id);
  183.         Draw_Marked_Segments(DM_Erase, What_All); 
  184.         Compute_Marked_Segments();
  185.         Deselect_All();
  186.  
  187.         Set_Window_Title(NULL);
  188.         Draw_Marked_Segments(DM_Normal, What_All); 
  189.  
  190.     } /* if */
  191.  
  192. } /* Command_Combine */
  193.  
  194. void Command_Delete_Point()
  195. /************************************************************************/
  196. /*                                                                      */
  197. /* Delete all knots which references the selected point            */
  198. /*                                                                      */
  199. /************************************************************************/
  200. {
  201.     Spline_T     *Spline, *Next_Spline;
  202.     Knot_T    *Knot;
  203.     short    Point_Id;
  204.     int        i;
  205.  
  206.     if (Select_Point_Id < 0) return;
  207.  
  208.     Point_Id = Select_Point_Id;
  209.  
  210.     if (!Group_Mode) Deselect_All();
  211.  
  212.     for (Spline = Splines; Spline != NULL; Spline = Next_Spline) {
  213.  
  214.     /* Get next spline now as 'Spline' may be deleted below.    */
  215.     Next_Spline = Spline->Next;
  216.  
  217.     for (i = 0, Knot = Spline->First; i < Spline->Nbr_Knots;
  218.                         i++, Knot = Knot->Next) {
  219.  
  220.         if (Knot->Point_Id != Point_Id) continue;
  221.  
  222.         /* We've found a knot which references the point to be    */
  223.         /* deleted.                        */
  224.  
  225.         i = Spline->Nbr_Knots; /* Stop inner loop */
  226.  
  227.         /* Undraw the spline, it will be modified */
  228.             if (!Group_Mode) Draw_Spline(Spline, DM_Erase, What_All);
  229.  
  230.             if (Spline->Nbr_Knots < 3) Spline_Free(Spline);
  231.             else {
  232.  
  233.         Knot_Delete(Spline, Knot);
  234.  
  235.         /* Recompute, and draw the modified spline again */
  236.             if (!Group_Mode) {
  237.             Compute_Spline(Spline);
  238.                 Draw_Spline(Spline, DM_Normal, What_All);
  239.          } /* if */
  240.  
  241.             } /* if .. else .. */
  242.  
  243.  
  244.     } /* for */
  245.  
  246.     } /* for */
  247.  
  248.     if (!Group_Mode) {
  249.  
  250.         Set_Move_Group_Position(Current_Pos);
  251.         KnotInfo_Show_Info(Select_Spline, Select_Knot);
  252.         Set_Window_Title(NULL);
  253.  
  254.     } /* if */
  255.     
  256. } /* Command_Delete_Point */
  257.  
  258. void Command_Delete()
  259. /************************************************************************/
  260. /*                                                                      */
  261. /* Delete all knots which references the selected point, or if in group    */
  262. /* mode: Delete all selected points                    */
  263. /*                                                                      */
  264. /************************************************************************/
  265. {
  266.     short    Point_Id;
  267.  
  268.     if (!Group_Mode) {
  269.     Command_Delete_Point();
  270.     return;
  271.     }
  272.  
  273.     Set_Window_Title("Deleting points");
  274.  
  275.     for (Point_Id = 0; Point_Id < Max_Nbr_Points; Point_Id++) {
  276.  
  277.     if (Is_Selected(Points[Point_Id])) {
  278.  
  279.         Select_Point_Id = Point_Id;
  280.         Command_Delete_Point();
  281.  
  282.         } /* if */
  283.  
  284.     } /* for */
  285.  
  286.     Deselect_All();
  287.     Compute_Splines();
  288.  
  289.     Set_Move_Group_Position(Current_Pos);
  290.     KnotInfo_Show_Info(Select_Spline, Select_Knot);
  291.     Set_Window_Title(NULL);
  292.  
  293.     Redraw_Mask = What_All;
  294.  
  295. } /* Command_Delete */
  296.  
  297. void Command_Cut()
  298. /************************************************************************/
  299. /*                                                                      */
  300. /* Cut the selected spline at the selected knot.            */
  301. /*                                                                      */
  302. /************************************************************************/
  303. {
  304.     Spline_T *Spline;
  305.     Spline_T *New_Spline;
  306.     Knot_T   *Knot;
  307.  
  308.     if (Select_Spline == NULL || Select_Knot == NULL) return;
  309.  
  310.     Spline = Select_Spline;
  311.     Knot   = Select_Knot;
  312.     Deselect_All();
  313.  
  314.     /* Undraw the spline, it will be modified */
  315.     Draw_Spline(Spline, DM_Erase, What_All);
  316.  
  317.     New_Spline = Spline_Cut(Spline, Knot);
  318.  
  319.     Compute_Spline(Spline);
  320.     Draw_Spline(Spline, DM_Normal, What_All);
  321.  
  322.     if (New_Spline != NULL && New_Spline != Spline) {
  323.         Compute_Spline(New_Spline);
  324.         Draw_Spline(New_Spline, DM_Normal, What_All);
  325.     }
  326.  
  327.     Set_Move_Group_Position(Current_Pos);
  328.     KnotInfo_Show_Info(Select_Spline, Select_Knot);
  329.     Set_Window_Title(NULL);
  330.     
  331. } /* Command_Cut */
  332.  
  333. void Command_Disconnect()
  334. /************************************************************************/
  335. /*                                                                      */
  336. /* Disconnect two splines.                        */
  337. /*                                                                      */
  338. /************************************************************************/
  339. {
  340.     if (Select_Point_Id < 0) return;
  341.  
  342.     Splines_Disconnect(Select_Point_Id);
  343.     Set_Window_Title(NULL);
  344.     Redraw_Mask |= What_All;
  345.  
  346. } /* Command_Disconnect */
  347.  
  348. void Command_Hide()
  349. /************************************************************************/
  350. /*                                                                      */
  351. /* If points are hidden, then show all points and select the previously    */
  352. /* visible points.                            */
  353. /* If none were hidden, then hide unselected points and deselect all.    */
  354. /*                                                                      */
  355. /************************************************************************/
  356. {
  357.     if (Points_Hidden) {
  358.     Show_All_Points();
  359.         Compute_Splines();
  360.     } else Hide_Unselected_Points();
  361.     Set_Window_Title(NULL);
  362.     Redraw_Mask |= What_All;
  363.  
  364. } /* Command_Hide */
  365.  
  366. void Command_Show()
  367. /************************************************************************/
  368. /*                                                                      */
  369. /* Show all hidden points again.                    */
  370. /*                                                                      */
  371. /************************************************************************/
  372. {
  373.     Show_All_Points();
  374.     Compute_Splines();
  375.     Set_Window_Title(NULL);
  376.     Redraw_Mask |= What_All;
  377.  
  378. } /* Command_Show */
  379.  
  380. void Command_Loop()
  381. /************************************************************************/
  382. /*                                                                      */
  383. /* 'Loop' or 'unloop'the current spline.                */
  384. /*                                                                      */
  385. /************************************************************************/
  386. {
  387.     if (Select_Spline == NULL) return;
  388.  
  389.     /* Erase the spline, it will be modified    */
  390.     Draw_Spline(Select_Spline, DM_Erase, What_All);
  391.  
  392.     Spline_Loop(Select_Spline, !Select_Spline->Loop);
  393.     
  394.     /* Compute the loop segment if necessary    */
  395.     if (Select_Spline->Loop)
  396.         Compute_Segment(Select_Spline, Select_Spline->Last);
  397.  
  398.     /* Draw the modified spline    */
  399.     Draw_Spline(Select_Spline, DM_Normal, What_All);
  400.  
  401. } /* Command_Loop */
  402.  
  403.  
  404. void Command_Select_Next()
  405. /************************************************************************/
  406. /*                                                                      */
  407. /* Select next knot on this point.                    */
  408. /*                                                                      */
  409. /************************************************************************/
  410. {
  411.     Select_Next_Knot();    /* Select next knot at current point */
  412.  
  413.         /* Draw marked segments in normal color */
  414.     Draw_Marked_Segments(DM_Normal, What_All); 
  415.  
  416.         /* Mark new selection, and draw it    */
  417.     Mark_Selected_Segments();
  418.     Draw_Marked_Segments(DM_Normal, What_All);
  419.  
  420.     KnotInfo_Show_Info(Select_Spline, Select_Knot);
  421.     Set_Window_Title(NULL);
  422.  
  423. } /* Command_Select_Next */
  424.  
  425. void Command_Toggle_Select_All()
  426. /************************************************************************/
  427. /*                                                                      */
  428. /* Toggle selection of all visible points.                */
  429. /*                                                                      */
  430. /************************************************************************/
  431. {
  432.     Toggle_Select_All();
  433.  
  434.     Draw_All(What_K); 
  435.  
  436.     KnotInfo_Show_Info(Select_Spline, Select_Knot);
  437.     Set_Window_Title(NULL);
  438.  
  439. } /* Command_Toggle_Select_All */
  440.  
  441. void Command_Toggle_Select_Spline()
  442. /************************************************************************/
  443. /*                                                                      */
  444. /* Toggle selection of all visible points.                */
  445. /*                                                                      */
  446. /************************************************************************/
  447. {
  448.     if (Select_Spline == NULL) return;
  449.  
  450.     Toggle_Select_Spline(Select_Spline);
  451.  
  452.     Draw_Spline(Select_Spline, DM_Normal, What_K); 
  453.  
  454.     KnotInfo_Show_Info(Select_Spline, Select_Knot);
  455.     Set_Window_Title(NULL);
  456.  
  457. } /* Command_Toggle_Select_Spline */
  458.  
  459. void Command_Resolution_Down()
  460. /************************************************************************/
  461. /*                                                                      */
  462. /* Change to lower resolution.                        */
  463. /*                                                                      */
  464. /************************************************************************/
  465. {
  466.     if (Spline_Resolution <= 1) return;
  467.  
  468.     Spline_Resolution--;
  469.     sprintf(Error_Msg, "New resolution: %d", Spline_Resolution);
  470.     Display_Status(Error_Msg);
  471.     Compute_Splines();
  472.     Redraw_Mask |= What_All;
  473.  
  474. } /* Command_Resolution_Down */
  475.  
  476. void Command_Resolution_Up()
  477. /************************************************************************/
  478. /*                                                                      */
  479. /* Change to higher resolution.                        */
  480. /*                                                                      */
  481. /************************************************************************/
  482. {
  483.     if (Spline_Resolution >= Max_Spline_Resolution) return;
  484.  
  485.     Spline_Resolution++;
  486.     sprintf(Error_Msg, "New resolution: %d", Spline_Resolution);
  487.     Display_Status(Error_Msg);
  488.  
  489.     Compute_Splines();
  490.     Redraw_Mask |= What_All;
  491.  
  492. } /* Command_Resolution_Up */
  493.  
  494. void Command_Deselect_All()
  495. /************************************************************************/
  496. /*                                                                      */
  497. /* Deselect all.                            */
  498. /*                                                                      */
  499. /************************************************************************/
  500. {
  501.     Deselect_All();
  502.     Draw_Marked_Segments(DM_Normal, What_All); 
  503.     Set_Window_Title(NULL);
  504.     Redraw_Mask |= What_K;
  505.  
  506. } /* Command_Deselect_All */
  507.  
  508. void Command_Redraw()
  509. /************************************************************************/
  510. /*                                                                      */
  511. /* Redraw all.                                */
  512. /*                                                                      */
  513. /************************************************************************/
  514. {
  515.     Redraw_Mask |= What_All;
  516.  
  517. } /* Command_Redraw */
  518.  
  519.  
  520. void Command_Unexpand()
  521. /************************************************************************/
  522. /*                                                                      */
  523. /* Close big (expanded view) window.                    */
  524. /*                                                                      */
  525. /************************************************************************/
  526. {
  527.     if (Windows[(int)W_ExpandedView].Window == NULL) return;
  528.  
  529.     Window_Close(W_ExpandedView);
  530.  
  531.     Id_Active_Window = W_Main;
  532.     Views            = Views_Small;
  533.     What_Mask        = What_All;
  534.  
  535.     Set_Window_Title(NULL);    /* Reset title */
  536.  
  537.     Compute_Splines();
  538.     Redraw_Mask |= What_All;
  539.  
  540. } /* Command_Unexpand */
  541.  
  542. void Command_X_Expand()
  543. /************************************************************************/
  544. /*                                                                      */
  545. /* Open expanded X window.                        */
  546. /*                                                                      */
  547. /************************************************************************/
  548. {
  549.     if (Windows[W_ExpandedView].Window == NULL) Window_Open(W_ExpandedView);
  550.     else WindowToFront(Windows[W_ExpandedView].Window);
  551.  
  552.     Id_Active_Window = W_ExpandedView;
  553.     Views            = Views_Big;
  554.     What_Mask        = What_X;
  555.  
  556.     Set_Window_Title("ICoons    Expanded view: X");
  557.  
  558.     Compute_Splines();
  559.     Redraw_Mask |= What_All;
  560.  
  561. } /* Command_X_Expand */
  562.  
  563. void Command_Y_Expand()
  564. /************************************************************************/
  565. /*                                                                      */
  566. /* Open expanded Y window.                        */
  567. /*                                                                      */
  568. /************************************************************************/
  569. {
  570.     if (Windows[W_ExpandedView].Window == NULL) Window_Open(W_ExpandedView);
  571.     else WindowToFront(Windows[W_ExpandedView].Window);
  572.  
  573.     Id_Active_Window = W_ExpandedView;
  574.     Views              = Views_Big;
  575.     What_Mask          = What_Y;
  576.  
  577.     Set_Window_Title("ICoons    Expanded view: Y");
  578.  
  579.     Compute_Splines();
  580.     Redraw_Mask |= What_All;
  581.  
  582. } /* Command_Y_Expand */
  583.  
  584. void Command_Z_Expand()
  585. /************************************************************************/
  586. /*                                                                      */
  587. /* Open expanded Z window.                        */
  588. /*                                                                      */
  589. /************************************************************************/
  590. {
  591.     if (Windows[W_ExpandedView].Window == NULL) Window_Open(W_ExpandedView);
  592.     else WindowToFront(Windows[W_ExpandedView].Window);
  593.  
  594.     Id_Active_Window = W_ExpandedView;
  595.     Views            = Views_Big;
  596.     What_Mask        = What_Z;
  597.  
  598.     Set_Window_Title("ICoons    Expanded view: Z");
  599.  
  600.     Compute_Splines();
  601.     Redraw_Mask |= What_All;
  602.  
  603. } /* Command_Z_Expand */
  604.  
  605. void Command_Persp_Expand()
  606. /************************************************************************/
  607. /*                                                                      */
  608. /* Open expanded perspective window.                    */
  609. /*                                                                      */
  610. /************************************************************************/
  611. {
  612.     if (Windows[W_ExpandedView].Window == NULL) Window_Open(W_ExpandedView);
  613.     else WindowToFront(Windows[W_ExpandedView].Window);
  614.  
  615.     Id_Active_Window = W_ExpandedView;
  616.     Views              = Views_Big;
  617.     What_Mask        = What_P;
  618.  
  619.     Set_Window_Title("ICoons    Expanded view: Perspective");
  620.  
  621.     Compute_Splines();
  622.     Redraw_Mask |= What_All;
  623.  
  624. } /* Command_Persp_Expand */
  625.  
  626.  
  627. void Command_About()
  628. /************************************************************************/
  629. /*                                                                      */
  630. /* Show 'about' requester.                        */
  631. /*                                                                      */
  632. /************************************************************************/
  633. {
  634.     char     Buffer[1000];
  635.     Spline_T    *Spline;
  636.     int        i, Nbr_Points, Nbr_Splines, Nbr_Knots;
  637.     int        Total_Nbr_Knots;
  638.  
  639.     Nbr_Points = Nbr_Splines = Nbr_Knots = Total_Nbr_Knots = 0;
  640.  
  641.     for (i = 0; i < Max_Nbr_Points; i++) 
  642.     if (Points[i].Reference_Count > 0) Nbr_Points++;
  643.   
  644.     Spline = Splines;
  645.     while (Spline != NULL) {
  646.     Nbr_Splines++;
  647.     Total_Nbr_Knots += Spline->Nbr_Knots;
  648.     if (Nbr_Knots < Spline->Nbr_Knots) Nbr_Knots = Spline->Nbr_Knots;
  649.     Spline = Spline->Next;
  650.     }
  651.  
  652.     sprintf(Buffer, 
  653.         "\n"
  654.         "            ICoons v. 1.0            \n"
  655.         "\n"
  656.         "        by Helge E. Rasmussen\n"
  657.         "           her@compel.dk\n"
  658.     "\n"
  659.         "           Statistics:\n"
  660.     "        Points   : %d of %d\n"
  661.     "        Splines  : %d\n"
  662.     "        Knots    : %d\n"
  663.     "        Longest K: %d",
  664.     Nbr_Points, Max_Nbr_Points,
  665.     Nbr_Splines,
  666.     Total_Nbr_Knots,
  667.     Nbr_Knots);
  668.  
  669.     Display_Message(Buffer);
  670.  
  671. } /* Command_About */
  672.  
  673. void Command_New()
  674. /************************************************************************/
  675. /*                                                                      */
  676. /* Delete current object and start a new one.                */
  677. /*                                                                      */
  678. /************************************************************************/
  679. {
  680.     int Answer;
  681.  
  682.     Answer = Ask_Question("Start on new object?", "Yes|No");
  683.  
  684.     if (Answer == 1) {
  685.  
  686.         Splines_Init();
  687.         Compute_Splines();
  688.         Set_Window_Title(NULL);
  689.         Redraw_Mask |= What_All;
  690.  
  691.     } /* if */
  692.  
  693. } /* Command_New */
  694.  
  695. void Command_Load_Object()
  696. /************************************************************************/
  697. /*                                                                      */
  698. /* Load an object from disk.                        */
  699. /*                                                                      */
  700. /************************************************************************/
  701. {
  702.     struct FileRequester *Requester;
  703.     char   Path[Buffer_Length+1];
  704.  
  705.  
  706.     Requester = AllocAslRequestTags(ASL_FileRequest,
  707.     ASL_Hail,    (ULONG) "Load object",
  708.     ASL_Dir,    (ULONG) Current_Object_DirName,
  709.     ASL_File,    (ULONG) Current_Object_FileName,
  710.     ASL_Pattern,    (ULONG) "#?.ic",
  711.     ASL_FuncFlags,    FILF_PATGAD,
  712.     ASL_Window,    Windows[Id_Active_Window].Window,
  713.     TAG_DONE);
  714.  
  715.     if (Requester == NULL) return;
  716.  
  717.     if (AslRequest(Requester, NULL)) {
  718.  
  719.     strncpy(Current_Object_FileName, Requester->rf_File, File_Name_Length);
  720.     Current_Object_FileName[File_Name_Length] = '\0';
  721.  
  722.     strncpy(Current_Object_DirName, Requester->rf_Dir, Path_Name_Length);
  723.     Current_Object_DirName[Path_Name_Length] = '\0';
  724.  
  725.     strncpy(Path, Requester->rf_Dir, Buffer_Length);
  726.  
  727.     if (AddPart(Path, Requester->rf_File, Buffer_Length) != 0) {
  728.  
  729.             Object_File_Read(Path);
  730.             Compute_Splines();
  731.             Set_Window_Title(NULL);
  732.             Redraw_Mask |= What_All;
  733.  
  734.     } /* if */
  735.  
  736.     } /* if */
  737.  
  738.     FreeAslRequest(Requester); 
  739.  
  740. } /* Command_Load_Object */
  741.  
  742. void Command_Save_Object()
  743. /************************************************************************/
  744. /*                                                                      */
  745. /* Save the object to disk.                        */
  746. /*                                                                      */
  747. /************************************************************************/
  748. {
  749.     struct FileRequester *Requester;
  750.     char   Path[Buffer_Length+1];
  751.  
  752.  
  753.     Requester = AllocAslRequestTags(ASL_FileRequest,
  754.     ASL_Hail,    (ULONG) "Save object",
  755.     ASL_Dir,    (ULONG) Current_Object_DirName,
  756.     ASL_File,    (ULONG) Current_Object_FileName,
  757.     ASL_Pattern,    (ULONG) "#?.ic",
  758.     ASL_FuncFlags,    FILF_SAVE | FILF_PATGAD,
  759.     ASL_Window,    Windows[Id_Active_Window].Window,
  760.     TAG_DONE);
  761.  
  762.     if (Requester == NULL) return;
  763.  
  764.     if (AslRequest(Requester, NULL)) {
  765.  
  766.     strncpy(Current_Object_FileName, Requester->rf_File, File_Name_Length);
  767.     Current_Object_FileName[File_Name_Length] = '\0';
  768.  
  769.     strncpy(Current_Object_DirName, Requester->rf_Dir, Path_Name_Length);
  770.     Current_Object_DirName[Path_Name_Length] = '\0';
  771.  
  772.     strncpy(Path, Requester->rf_Dir, Buffer_Length);
  773.  
  774.     if (AddPart(Path, Requester->rf_File, Buffer_Length) != 0) {
  775.  
  776.             Object_File_Write(Path);
  777.  
  778.     } /* if */
  779.  
  780.     } /* if */
  781.  
  782.     FreeAslRequest(Requester); 
  783.  
  784. } /* Command_Save_Object */
  785.  
  786. void Command_Load_JMan_Object()
  787. /************************************************************************/
  788. /*                                                                      */
  789. /* Load an Journeyman object from disk.                    */
  790. /*                                                                      */
  791. /************************************************************************/
  792. {
  793.     struct FileRequester *Requester;
  794.     char   Path[Buffer_Length+1];
  795.  
  796.  
  797.     Requester = AllocAslRequestTags(ASL_FileRequest,
  798.     ASL_Hail,    (ULONG) "Load Journeyman object",
  799.     ASL_Dir,    (ULONG) Current_Object_DirName,
  800.     /* ASL_File,    (ULONG) Current_Object_FileName, */
  801.     ASL_Pattern,    (ULONG) "#?.seg",
  802.     ASL_FuncFlags,    FILF_PATGAD,
  803.     ASL_Window,    Windows[Id_Active_Window].Window,
  804.     TAG_DONE);
  805.  
  806.     if (Requester == NULL) return;
  807.  
  808.     if (AslRequest(Requester, NULL)) {
  809.  
  810. #if 0
  811.     strncpy(Current_Object_FileName, Requester->rf_File, File_Name_Length);
  812.     Current_Object_FileName[File_Name_Length] = '\0';
  813. #endif
  814.  
  815.     strncpy(Current_Object_DirName, Requester->rf_Dir, Path_Name_Length);
  816.     Current_Object_DirName[Path_Name_Length] = '\0';
  817.     strncpy(Path, Requester->rf_Dir, Buffer_Length);
  818.  
  819.     if (AddPart(Path, Requester->rf_File, Buffer_Length) != 0) {
  820.  
  821.         JMan_File_Read(Path);
  822.             Compute_Splines();
  823.             Set_Window_Title(NULL);
  824.             Redraw_Mask |= What_All;
  825.  
  826.     } /* if */
  827.  
  828.     } /* if */
  829.  
  830.     FreeAslRequest(Requester); 
  831.  
  832. } /* Command_Load_JMan_Object */
  833.  
  834. void Command_Generate_TTDDD_File()
  835. /************************************************************************/
  836. /*                                                                      */
  837. /* Generate a TTDDD description of the current object.            */
  838. /*                                                                      */
  839. /************************************************************************/
  840. {
  841.     struct FileRequester *Requester;
  842.     char   Path[Buffer_Length+1];
  843.  
  844.  
  845.     Requester = AllocAslRequestTags(ASL_FileRequest,
  846.     ASL_Hail,    (ULONG) "Save TTDDD object",
  847.     ASL_Dir,    (ULONG) Current_TTDDD_DirName,
  848.     ASL_File,    (ULONG) Current_TTDDD_FileName,
  849.     ASL_Pattern,    (ULONG) "#?.ttddd",
  850.     ASL_FuncFlags,    FILF_SAVE | FILF_PATGAD,
  851.     ASL_Window,    Windows[Id_Active_Window].Window,
  852.     TAG_DONE);
  853.  
  854.     if (Requester == NULL) return;
  855.  
  856.     if (AslRequest(Requester, NULL)) {
  857.  
  858.     strncpy(Current_TTDDD_FileName, Requester->rf_File, File_Name_Length);
  859.     Current_TTDDD_FileName[File_Name_Length] = '\0';
  860.  
  861.     strncpy(Current_TTDDD_DirName, Requester->rf_Dir, Path_Name_Length);
  862.     Current_TTDDD_DirName[Path_Name_Length] = '\0';
  863.  
  864.     strncpy(Path, Requester->rf_Dir, Buffer_Length);
  865.  
  866.     if (AddPart(Path, Requester->rf_File, Buffer_Length) != 0) {
  867.  
  868.         Display_Status("Generating TTDDD file...");
  869.  
  870.             (void) Generate_TTDDD_File(Path);
  871.  
  872.         Display_Status(NULL);
  873.  
  874.     } /* if */
  875.  
  876.     } /* if */
  877.  
  878.     FreeAslRequest(Requester); 
  879.  
  880. } /* Command_Generate_TTDDD_File */
  881.  
  882. void Command_Load_Config()
  883. /************************************************************************/
  884. /*                                                                      */
  885. /* Load configuration from disk.                        */
  886. /*                                                                      */
  887. /************************************************************************/
  888. {
  889.     struct FileRequester *Requester;
  890.     char   Path[Buffer_Length+1];
  891.  
  892.     if (*Current_Config_DirName == '-') 
  893.     strcpy(Current_Config_DirName, "s:");
  894.     if (*Current_Config_FileName == '\0') 
  895.     strcpy(Current_Config_FileName, Default_Config_File_Name);
  896.  
  897.     Requester = AllocAslRequestTags(ASL_FileRequest,
  898.     ASL_Hail,    (ULONG) "Load configuration",
  899.     ASL_Dir,    (ULONG) Current_Config_DirName,
  900.     ASL_File,    (ULONG) Current_Config_FileName,
  901.     ASL_Pattern,    (ULONG) "#?.cfg",
  902.     ASL_FuncFlags,    FILF_PATGAD,
  903.     ASL_Window,    Windows[Id_Active_Window].Window,
  904.     TAG_DONE);
  905.  
  906.     if (Requester == NULL) return;
  907.  
  908.     if (AslRequest(Requester, NULL)) {
  909.  
  910.     strncpy(Current_Config_FileName, Requester->rf_File, File_Name_Length);
  911.     Current_Config_FileName[File_Name_Length] = '\0';
  912.  
  913.     strncpy(Current_Config_DirName, Requester->rf_Dir, Path_Name_Length);
  914.     Current_Config_DirName[Path_Name_Length] = '\0';
  915.  
  916.     strncpy(Path, Requester->rf_Dir, Buffer_Length);
  917.  
  918.     if (AddPart(Path, Requester->rf_File, Buffer_Length) != 0) {
  919.  
  920.             Config_File_Read(Path);
  921.             Compute_Splines();
  922.             Set_Window_Title(NULL);
  923.             Redraw_Mask |= What_All;
  924.  
  925.     } /* if */
  926.  
  927.     } /* if */
  928.  
  929.     FreeAslRequest(Requester); 
  930.  
  931. } /* Command_Load_Config */
  932.  
  933. void Command_Save_Config()
  934. /************************************************************************/
  935. /*                                                                      */
  936. /* Save the configuration to disk.                    */
  937. /*                                                                      */
  938. /************************************************************************/
  939. {
  940.     struct FileRequester *Requester;
  941.     char   Path[Buffer_Length+1];
  942.  
  943.     if (*Current_Config_DirName == '-') 
  944.     strcpy(Current_Config_DirName, "S:");
  945.     if (*Current_Config_FileName == '\0') 
  946.     strcpy(Current_Config_FileName, Default_Config_File_Name);
  947.  
  948.     Requester = AllocAslRequestTags(ASL_FileRequest,
  949.     ASL_Hail,    (ULONG) "Save configuration",
  950.     ASL_Dir,    (ULONG) Current_Config_DirName,
  951.     ASL_File,    (ULONG) Current_Config_FileName,
  952.     ASL_Pattern,    (ULONG) "#?.cfg",
  953.     ASL_FuncFlags,    FILF_SAVE | FILF_PATGAD,
  954.     ASL_Window,    Windows[Id_Active_Window].Window,
  955.     TAG_DONE);
  956.  
  957.     if (Requester == NULL) return;
  958.  
  959.     if (AslRequest(Requester, NULL)) {
  960.  
  961.     strncpy(Current_Config_FileName, Requester->rf_File, File_Name_Length);
  962.     Current_Config_FileName[File_Name_Length] = '\0';
  963.  
  964.     strncpy(Current_Config_DirName, Requester->rf_Dir, Path_Name_Length);
  965.     Current_Config_DirName[Path_Name_Length] = '\0';
  966.  
  967.     strncpy(Path, Requester->rf_Dir, Buffer_Length);
  968.  
  969.     if (AddPart(Path, Requester->rf_File, Buffer_Length) != 0) {
  970.  
  971.             Config_File_Write(Path);
  972.  
  973.     } /* if */
  974.  
  975.     } /* if */
  976.  
  977.     FreeAslRequest(Requester); 
  978.  
  979. } /* Command_Save_Config */
  980.  
  981. void Command_Quit()
  982. /************************************************************************/
  983. /*                                                                      */
  984. /* Quit the program.                            */
  985. /*                                                                      */
  986. /************************************************************************/
  987. {
  988.     int Answer;
  989.  
  990.     Answer = Ask_Question("Do you really want to quit?", "Yes|No");
  991.  
  992.     if (Answer == 1) Quit_Flag = TRUE;
  993.  
  994. } /* Command_Quit */
  995.  
  996. void Command_ZoomIn()
  997. /************************************************************************/
  998. /*                                                                      */
  999. /* Zoom in.                                */
  1000. /*                                                                      */
  1001. /************************************************************************/
  1002. {
  1003.     Modify_Scale(1.5);
  1004.     Compute_Splines();
  1005.     Redraw_Mask |= What_All;
  1006.  
  1007. } /* Command_ZoomIn */
  1008.  
  1009. void Command_ZoomOut()
  1010. /************************************************************************/
  1011. /*                                                                      */
  1012. /* Zoom out.                                */
  1013. /*                                                                      */
  1014. /************************************************************************/
  1015. {
  1016.     Modify_Scale(0.6666666);
  1017.     Compute_Splines();
  1018.     Redraw_Mask |= What_All;
  1019.  
  1020. } /* Command_ZoomOut */
  1021.  
  1022. void Command_Show_KnotInfo()
  1023. /************************************************************************/
  1024. /*                                                                      */
  1025. /* Show the knot information window.                    */
  1026. /*                                                                      */
  1027. /************************************************************************/
  1028. {
  1029.     if (Windows[(int)W_KnotInfo].Window == NULL) Window_Open(W_KnotInfo);
  1030.     WindowToFront(Windows[W_KnotInfo].Window);
  1031.  
  1032.     KnotInfo_Show_Info(Select_Spline, Select_Knot);
  1033.  
  1034. } /* Command_Show_KnotInfo */
  1035.