home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format 58 / af058b.adf / PV21.lha / REXX / MovePts.pvrx < prev    next >
Text File  |  1991-10-21  |  3KB  |  144 lines

  1. /* MovePts.pvrx---move selected points by precise increments
  2.     in the X or Y axis.
  3.    Author:  Jeff Blume - August 28, 1991
  4.    Copyright © 1991 by Stylus, Inc.
  5.    Suggested "ProVector.pvrx" entries:
  6.  
  7.     'Define "MovePts    Ctrl-E" "MovePts MENU"'
  8.     'DefineKey E "MovePts MENU"'
  9.  
  10.     (Control-E for "Edit" ???)
  11. */
  12.  
  13. address "ProVector"
  14.  
  15. /* Get the argument list to see whether this is a MENU, or an OK */
  16. arg arglist
  17. Cmd = word(arglist,1)
  18.  
  19. options results
  20.  
  21. /* Try to get exclusive lock on project window.
  22.     If can't get lock, not polite to interrupt. */
  23. 'Lock'
  24. if RC ~= 0 then exit
  25.  
  26. /* This loop is called from the menu */
  27. if Cmd = 'MENU' then
  28. DO
  29.     /* Test Selected list for magnetized? */
  30.     /* Magnetize Sel Objs for better coord identification.*/
  31.     'SelectList' Sel; SelN = Result
  32.     if SelN = 0 then do
  33.         RC = 100
  34.         call Error "NO OBJECT SELECTED!"
  35.     end
  36.     else do
  37.         'Magnetize' SelN Sel
  38.         do i = 0 to SelN-1
  39.             'SelectObj'  Sel.i /* restore selection state */
  40.         end
  41.     end
  42.     'Prompt "Click points; Double Last"'
  43.     'GetUserData 0 1 100 "MovePts OK" ""'
  44. END
  45. /* end "MENU" loop */
  46.  
  47. /* This was called from GetUserData */
  48. if Cmd = 'OK' then
  49. DO
  50.     'EndPrompt'
  51.     'GetInputPoints Pts'; NumIn=Result
  52.     'SelectList' Sel; SelN = Result
  53.     'PushUndo'
  54.  
  55.     /* Get X and Y shifts */
  56.     'GetStr "Move X - Move Y (N1 N2)" "OK" "CANCEL"' /* longest prompt */
  57.     MCoords = result
  58.     if rc ~= 0 | words(MCoords) ~= 2 then do
  59.         RC = 100
  60.         call Error "MACRO CANCELED OR BAD COORDS GIVEN"
  61.         end
  62.     /* extract the X and Y values */
  63.     MX = subword(MCoords,1,1)
  64.     MY = subword(MCoords,2,1)
  65.  
  66.     'Prompt "Looking for points."'
  67.     NumModObjs = 0 /* counter for Objects to be modified */
  68.     ModObj.0 = 0        /* index for Objects to be modified */
  69.     do i=0 to SelN-1
  70.         /* Identify points to be moved */
  71.         'GetPoints' Sel.i ObjPts.i; NumPts.i=Result
  72.         if RC = 18 then
  73.             do
  74.                 'GetBool "CAN NOT MOVEPT TEXT OR GROUP" "Cancel" "Cancel"'
  75.                 iterate
  76.             end
  77.         do p=0 to NumIn-1
  78.             call MatchPoint
  79.         end
  80.     end
  81.     'EndPrompt'
  82.  
  83.     if NumModObjs = 0 then do
  84.         RC = 100
  85.         call Error "NO LEGAL OBJECTS SELECTED!"
  86.         end
  87.  
  88.     'Prompt "Moving points!"'
  89.     do m=1 to NumModObjs
  90.         'SaveUndo' ModObj.m
  91.         'ChangePoints' ModObj.m ModNum.m ModPts.m
  92.     end
  93.     'EndPrompt'
  94.  
  95.     /* De-Magnetize, general cleanup */
  96.     'Magnetize' 0 Sel
  97.     'Repair'
  98. END
  99. /* end "OK" loop */
  100.  
  101. 'UnLock'
  102. EXIT
  103.  
  104. ERROR:
  105.     arg ErrTxt
  106.     if RC ~= 0 & ErrTxt ~= "" then 'GetBool ErrTxt "Cancel" "Cancel"'
  107.     'Magnetize' 0 Sel
  108.     'EndPrompt'
  109.     /*'Repair'*/
  110.     'UnLock'
  111.     exit
  112.  
  113. MATCHPOINT:
  114.     do j = 0 to NumPts.i-1
  115.         select
  116.             when ObjPts.i.j.X = Pts.p.X & ObjPts.i.j.Y = Pts.p.Y then
  117.                 do
  118.                     ObjPts.i.j.X = ObjPts.i.j.X + MX
  119.                     ObjPts.i.j.Y = ObjPts.i.j.Y + MY
  120.                     call CmpModObj
  121.                 end
  122.             when j = NumPts.i-1 then return    /* Test next obj */
  123.             otherwise iterate
  124.         end
  125.     end
  126.     return
  127.  
  128. CMPMODOBJ:
  129.     /* Compare current obj to list of objs to be modified */
  130.     do c=0 to NumModObjs
  131.         select
  132.             when Sel.i = ModObj.c then leave c    /* same as last ModObj */
  133.             when Sel.i ~= ModObj.c & c = NumModObjs then    /* not on list */
  134.                 do
  135.                     NumModObjs = NumModObjs + 1    /* increment number */
  136.                     ModObj.NumModObjs = Sel.i        /* add to list */
  137.                     ModPts.NumModObjs = ObjPts.i
  138.                     ModNum.NumModObjs = NumPts.i
  139.                 end
  140.             otherwise iterate
  141.         end
  142.     end
  143.     return
  144.