home *** CD-ROM | disk | FTP | other *** search
/ DTP Toolbox / DTPToolbox.iso / propage4.0 / arexx / editpoints.pdrx < prev    next >
Encoding:
Text File  |  1994-04-11  |  3.5 KB  |  91 lines

  1. /*
  2. This genie edits the positions & curvature of points. Click on the points you want to convert, then on a blank place to stop.
  3.  
  4. Written by Don Cox, Apr. '94. Copyright. Not Public Domain.
  5. */
  6. /* $VER: EditPoints Apr 94 */
  7.  
  8. trace r
  9.  
  10. if ~show("l", "gdarexxsupport.library") then
  11.     if ~addlib("gdarexxsupport.library", 0, -30,0) then do
  12.         call ppm_Inform(1,"Please install the gdarexxsupport.library in your libs: directory before running this Genie.")
  13.     end
  14. call pdm_AutoUpdate(0)
  15. numeric digits 10
  16. cr = "0a"x
  17.  
  18. do i = 1 to 50  /* safety limit */
  19.     clickpos = pdm_ClickOnPoint("  Click on the Points to be changed...")
  20.     if clickpos = "0 0" then exit_msg()
  21.  
  22.     object  = word(clickpos, 1)
  23.     point  = word(clickpos, 2)
  24.     pointinfo = pdm_GetPoint(object,point)
  25.     parse var pointinfo Xpos Ypos tangent1X tangent1Y tangent2X tangent2Y
  26.     radius1 = trunc(squareroot((tangent1X**2)+(tangent1Y**2)),4)
  27.     radius2 = trunc(squareroot((tangent2X**2)+(tangent2Y**2)),4)
  28.     sharpness = (radius1+radius2)/2
  29.     if sharpness = 0 then sharpness = "C"
  30.     else sharpness = "S"
  31.     form = "Position X:"Xpos ||cr|| "Position Y:"Ypos ||cr|| "Tangent A length:"radius1 ||cr|| "Tangent B length:"radius2 ||cr|| "Rotate (degrees):0" ||cr|| "Delete/Cut/Leave:L" ||cr|| "Smooth/Corner (S/C):"sharpness
  32.     form = pdm_GetForm("Edit point "point" on object "object, 18,form)
  33.     if form = "" then exit_msg("Cancelled")
  34.     parse var form newXpos "0a"x newYpos "0a"x newradius1 "0a"x newradius2 "0a"x rotation "0a"x butcher "0a"x newsharpness
  35.     if ~(datatype(newXpos,n) & datatype(newYpos,n) & datatype(newradius1,n) & datatype(newradius2,n) & datatype(rotation,n)) then exit_msg("Invalid entry")
  36.     newsharpness = upper(strip(newsharpness))
  37.     if newsharpness~="C" then newsharpness = "S"
  38.     sharpset = 1.0
  39.     if newsharpness = "C" then sharpset = 0
  40.  
  41.     if (newXpos~=Xpos | newYpos~=Ypos) then call pdm_SetPoint(object, point, newXpos newYpos )
  42.     if newsharpness~=sharpness then call pdm_SmoothPoint(object, point, sharpset)
  43.     if (newradius1~=radius1 | newradius2~=radius2) then call pdm_SetPointRadius(object, point, newradius1,newradius2)
  44.     if rotation~=0 then call pdm_RotatePoint(object,point,rotation)
  45.  
  46.     if upper(strip(butcher))="D" then call pdm_RemovePoint(object,point)
  47.     if upper(strip(butcher))="C" then call pdm_CutAtPoint(object,point)
  48.     
  49.     call pdm_UpdateScreen(1)
  50.  
  51.     end
  52.  
  53. exit_msg()
  54.  
  55.  
  56. /* +++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++ */
  57.  
  58. squareroot: /* to avoid bug in gdarexxsupport.library sqrt function */
  59. parse arg number
  60.  
  61. removed = remlib("gdarexxsupport.library")
  62. if removed~=1 then call ppm_Inform(1,"Could not remove gdarexxsupport.library calculations may be faulty","Resume")
  63.  
  64. /* rexxmathlib.library is needed instead  */
  65. if ~show("l", "rexxmathlib.library") then
  66.     if ~addlib("rexxmathlib.library", 0, -30,0) then do
  67.         call ppm_Inform(1,"Please install the rexxmathlib.library in your libs: directory before running this Genie.")
  68.     end
  69.  
  70. number = sqrt(number)
  71.  
  72. if ~show("l", "gdarexxsupport.library") then
  73.     if ~addlib("gdarexxsupport.library", 0, -30,0) then do
  74.         call ppm_Inform(1,"Please install the gdarexxsupport.library in your libs: directory before running this Genie.")
  75.     end
  76.  
  77.  
  78. return number
  79.  
  80. /* +++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++ */
  81. /* +++++++++++++++++++++++++++++++++  +++++++++++++++++++++++++++++++ */
  82.  
  83. exit_msg: procedure expose units
  84. do
  85.  parse arg message
  86.  
  87.  if message ~= '' then call pdm_Inform(1,message,)
  88.  call pdm_AutoUpdate(1)
  89.  exit
  90. end
  91.