home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format 58
/
af058b.adf
/
PV21.lha
/
REXX
/
Dimension.pvrx
< prev
next >
Wrap
Text File
|
1991-07-18
|
3KB
|
109 lines
/* Dimension.pvrx
Copyright © 1990 by Taliesin, Inc.
Author - Ross Cunniff
*/
/* Get the argument list to see whether this is a MENU, an OK, or a SIZE */
address 'ProVector'
arg arglist
Cmd = word(arglist,1)
/* Get the rexxmathlib.library */
if ~exists("LIBS:rexxmathlib.library") then do
'GetBool "Can not find REXXMATHLIB.LIBRARY" "Cancel" "Cancel"'
exit
end
else call addlib "rexxmathlib.library",0,-30,0
/* Always do this for a ProVector AREXX function */
Options Results
'Lock Wait'
if Cmd = 'MENU' then do
/* This was called directly from the menu */
/* Call setdimension after getting a line segment */
'Prompt "Drag dimension line:"'
'GetUserData 1 2 2 "Dimension OK" ""'
end
else if Cmd = 'OK' then do
/* This was called from GetUseData */
'EndPrompt'
'GetInputPoints Pts'
/* First, create the line segment */
'PolyLine 2 Pts'; Obj = Result
X0 = Pts.0.X; Y0 = Pts.0.Y
X1 = Pts.1.X; Y1 = Pts.1.Y
/* Next, calculate the parameters for the text string */
DX = X1 - X0; DY = Y1 - Y0
Dist = sqrt( DX*DX + DY*DY )
DStr = trunc(Dist,2)
NChars = Length(DStr)
ChWidth = (Dist/3)/NChars
ChHeight = 2*ChWidth
ChXPos = 0.66666666 * X0 + 0.33333333 * X1
ChYPos = 0.66666666 * Y0 + 0.33333333 * Y1
ChAngle = 180 * atan2(Y1 - Y0, X1 - X0) / 3.141592653589
/* Make a new undo level */
'PushUndo'
/* Now, create the text string */
'Text DStr ChXPos ChYPos ChWidth ChHeight ChAngle'; TObj = Result
/* Group the line and the text string together */
GList.0 = Obj; GList.1 = TObj
'Group 2 GList'; GObj = Result
/* Attach the redimension call to the object */
'Rexx GObj Dimension SIZE'; RObj = Result
/* Select it */
'SelectObj RObj'
end
else if Cmd = 'SIZE' then do
RObj = word(arglist,2)
CX = word(arglist,3); CY = word(arglist,4)
SX = word(arglist,5); SY = word(arglist,6)
'GroupObj RObj'; GObj = Result
'GroupObj GObj'; Obj = Result
'NextObj Obj'; TObj = Result
'Size RObj CX CY SX SY'
'GetText TObj'; SStr=Result
'GetPoints Obj Points'; NumPoints = Result - 1
X0 = Points.0.X; Y0 = Points.0.Y
XN = Points.NumPoints.X; YN = Points.NumPoints.Y
Drop Points
DX = XN - X0; DY = YN - Y0
Dist = sqrt( DX*DX + DY*DY ); DStr = trunc(Dist,2)
NChars = Length(DStr)
'ChangeText TObj DStr'
Angle = 180.0*atan2( YN - Y0, XN - X0 )/3.141592653589
'Rotate TObj CX CY Angle'
'ObjExtent TObj Ext'
X = 0.5*Ext.X1 + 0.5*Ext.X2; Y = 0.25*Ext.Y1 + 0.75*Ext.Y2
NW = (Ext.X2 - Ext.X1) / NChars; NH = Ext.Y2 - Ext.Y1
XScale = Length(SStr)/NChars
YScale = (2 * NW * XScale) / NH /* YScale = XScale * SY / SX */
'Size TObj X Y XScale YScale'
Angle = 0 - Angle; 'Rotate TObj CX CY Angle'
'Rotate RObj 0 0 0'
'Repair'
end
/* All done! Unlock ProVector */
'UnLock'