home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume6 / yahp2ps / part02 / global.c < prev    next >
C/C++ Source or Header  |  1989-02-03  |  4KB  |  205 lines

  1. /*
  2.         HPGL to PostScript converter
  3.    Copyright (C) 1988 (and following) Federico Heinz
  4.  
  5. yahp2ps is distributed in the hope that it will be useful, but WITHOUT ANY
  6. WARRANTY.  No author or distributor accepts responsibility to anyone
  7. for the consequences of using it or for whether it serves any
  8. particular purpose or works at all, unless he says so in writing.
  9. Refer to the Free Software Foundation's General Public License for full details.
  10.  
  11. Everyone is granted permission to copy, modify and redistribute yahp2ps,
  12. but only under the conditions described in the GNU General Public
  13. License.  A copy of this license is supposed to have been given to you
  14. along with yahp2ps so you can know your rights and responsibilities.  It
  15. should be in a file named COPYING.  Among other things, the copyright
  16. notice and this notice must be preserved on all copies.
  17.  
  18. In other words, go ahead and share yahp2ps, but don't try to stop
  19. anyone else from sharing it farther.  Help stamp out software hoarding!
  20.  
  21. yahp2ps is TOTALLY unrelated to GNU or the Free Software Foundation,
  22. it is only released under the same conditions.
  23.  
  24.     For bug reports, wishes, etc. send e-mail to
  25.  
  26.     ...!mcvax!unido!tub!actisb!federico  (from Europe)
  27.     ...!uunet!pyramid!actisb!federico    (from anywhere else)
  28.  
  29.     For Physical mail:
  30.  
  31.     Federico Heinz
  32.     Beusselstr. 21
  33.     1000 Berlin 21
  34.  
  35.     Tel. (+49 30) 396 77 92
  36.  
  37. */
  38. /************************************************************************
  39.  
  40.    Commands affecting the virtual plotter's global state.
  41.  
  42. ************************************************************************/
  43.  
  44. #include "defs.h"
  45. #include "dispatch.h"
  46. #include "io.h"
  47. #include "mchinery.h"
  48. #include "penctrl.h"
  49. #include "circle.h"
  50. #include "shade.h"
  51. #include "tick.h"
  52. #include "global.h"
  53. #include "char.h"
  54.  
  55.  
  56. /*
  57.  
  58.   Set the default values for the parameters controlled by this module.
  59.  
  60. */
  61.  
  62. void globalInit()
  63.  
  64. { resetWindow();
  65.   turnScalingOff();
  66. }
  67.  
  68.  
  69. /*
  70.  
  71.   Restore default values of all modules.
  72.  
  73. */
  74.  
  75. void restoreDefaults()
  76.  
  77. { globalInit();
  78.   basicInit();
  79.   shadeInit();
  80.   tickInit();
  81.   charInit();
  82. }
  83.  
  84.  
  85. /*
  86.  
  87.   Reset default values for plotter opeartion.
  88.  
  89. */
  90.  
  91. CommandImplementation setDefaults()
  92.  
  93. { restoreDefaults();
  94.   endCommand();
  95. }
  96.  
  97.  
  98. /*
  99.  
  100.   Restart plotter.
  101.  
  102. */
  103.  
  104. CommandImplementation initialize()
  105.  
  106. { penctrlInit();
  107.   restoreDefaults();
  108.   endCommand();
  109. }
  110.  
  111.  
  112. CommandImplementation inputP1P2()
  113.  
  114. { CoordinatePair newPlotterP1, newPlotterP2;
  115.  
  116.   if (isTerminator(LookAhead))
  117.     resetP1P2();
  118.   else if (getCoordinatePair(newPlotterP1))
  119.   { if (isTerminator(LookAhead) || !getCoordinatePair(newPlotterP2))
  120.     { newPlotterP2[X] += newPlotterP1[X] - PlotterP1[X];
  121.       newPlotterP2[Y] += newPlotterP1[Y] - PlotterP1[Y];
  122.     }
  123.     changeP1P2(newPlotterP1, newPlotterP2);
  124.   }
  125.   endCommand();
  126. }
  127.  
  128.  
  129.  
  130. /*
  131.  
  132.   Set the clipping rectangle.
  133.  
  134. */
  135.  
  136. CommandImplementation inputWindow()
  137.  
  138. { CoordinatePair corner1, corner2;
  139.  
  140.   if (isTerminator(LookAhead) || !getCoordinatePair(corner1) ||
  141.       !getCoordinatePair(corner2))
  142.     resetWindow();
  143.   else 
  144.   { corner1[X] = trunc(corner1[X]);
  145.     corner1[Y] = trunc(corner1[Y]);
  146.     corner2[X] = trunc(corner2[X]);
  147.     corner2[Y] = trunc(corner2[Y]);
  148.     setWindow(corner1,corner2);
  149.   }
  150.   endCommand();
  151. }
  152.  
  153.  
  154.  
  155. CommandImplementation setPaperSize()
  156.  
  157. { Number temp;
  158.  
  159.   if (getInteger(&temp))
  160.     if (temp < PaperSizeLimit)
  161.       warning("Sorry, only DIN A4 paper currently supported.");
  162. }
  163.  
  164.  
  165.  
  166. /*
  167.  
  168.   Rotate the coordinate system.
  169.  
  170. */
  171.  
  172. CommandImplementation rotateCoordSys()
  173.  
  174. { Number angle;
  175.  
  176.   if (isTerminator(LookAhead))
  177.     unRotate();
  178.   else if (getNumber(&angle))
  179.     if (angle == Zero)
  180.       unRotate();
  181.     else if (angle == OneSquare)
  182.       rotate();
  183.     else
  184.       warning("Erroneous rotation angle.");
  185.   endCommand();
  186. }
  187.  
  188.  
  189.  
  190. CommandImplementation setScale()
  191.  
  192. { CoordinatePair newUserP1, newUserP2;
  193.  
  194.   if (isTerminator(LookAhead))
  195.     turnScalingOff();
  196.   else if (getNumber(&newUserP1[X]) && getNumber(&newUserP2[X]) &&
  197.            getNumber(&newUserP1[Y]) && getNumber(&newUserP2[Y]))
  198.     turnScalingOn(newUserP1, newUserP2);
  199.   endCommand();
  200. }
  201.  
  202.  
  203.  
  204.  
  205.