DIRECTORY CD, CDApplications, CDSequencer, CDCallSpecific, CDInline, CDObjectProcs, CDOps, CDOrient, TerminalIO; StretchCommands: CEDAR PROGRAM IMPORTS CDApplications, CDInline, CDObjectProcs, CDOps, CDOrient, CDSequencer, TerminalIO = BEGIN StretchApplication: PROC [design: CD.Design, aptr: CD.ApplicationPtr, orientInPlane: CD.Orientation, amount: CD.DesignNumber] RETURNS [include: CD.ApplicationList_NIL, removeMe: BOOL_FALSE] = BEGIN CallSpecific: PROC [design: CD.Design, aptr: CD.ApplicationPtr, x: REF, objectSpecific: REF] RETURNS [done: BOOL_FALSE, removeMe: BOOL_FALSE, include: CD.ApplicationList_NIL, repaintMe: BOOL_FALSE, repaintInclude: BOOL_FALSE] = BEGIN IF objectSpecific#NIL THEN BEGIN p: REF = CDObjectProcs.FetchFurther [aptr.ob.p, objectSpecific]; IF p#NIL AND ISTYPE[p, REF CDCallSpecific.CallProc] THEN BEGIN [done: done, removeMe: removeMe, include: include, repaintMe: repaintMe, repaintInclude: repaintInclude] _ NARROW[p, REF CDCallSpecific.CallProc]^[design, aptr, x] END; END; END; appOrient, orientInObject: CD.Orientation; done, repaintMe, repaintInclude: BOOL; offset: REF CD.DesignPosition _ NEW[CD.DesignPosition_[0, 0]]; orientInPlane _ CDOrient.ConcentrateOnRotate90[orientInPlane]; appOrient _ CDOrient.ConcentrateOnRotate90[aptr.orientation]; orientInObject _ CDOrient.DecomposeOrient[ itemOrientInWorld: orientInPlane, cellOrientInWorld: appOrient ]; IF CDOrient.IncludesOddRot90[orientInObject] THEN offset.x_amount ELSE offset.y_amount; CDOps.DelayedRedraw[design, CDApplications.ApplicationRect[aptr]]; [done, removeMe, include, repaintMe, repaintInclude] _ CallSpecific[design, aptr, offset , $Lengthen]; IF done THEN { SELECT CDOrient.ConcentrateOnRotate90[orientInPlane] FROM CDOrient.original => { aptr.location.y _ aptr.location.y-amount; IF include#NIL THEN MoveAppList[include, [0, -amount]] }; CDOrient.rotate90 => NULL; CDOrient.rotate180 => NULL; CDOrient.rotate270 => { aptr.location.x _ aptr.location.x-amount; IF include#NIL THEN MoveAppList[include, [-amount, 0]] }; ENDCASE => ERROR; CDOps.DelayedRedraw[design, CDApplications.ApplicationRect[aptr]]; }; END; DoAStretch: PROC [design: CD.Design, from, to: CD.DesignPosition] = BEGIN r: CD.DesignRect; multipleSelection: BOOL; pointedAp, selAp: CD.ApplicationPtr; orientInPlane: CD.Orientation; amount: CD.DesignNumber; include: CD.ApplicationList; removeMe: BOOL; removeList, includeList: CD.ApplicationList_NIL; count: NAT _ 0; IF from=to THEN { TerminalIO.WriteRope[" null stretch\n"]; RETURN }; [selAp, multipleSelection] _ CDOps.SelectedApplication[design]; pointedAp _ CDApplications.AplicationAt[CDOps.AppList[design], from]; IF pointedAp=NIL THEN { TerminalIO.WriteRope[" no object pointed\n"]; RETURN }; r _ CDApplications.ApplicationRect[pointedAp]; IF ABS[to.x-from.x]>ABS[to.y-from.y] THEN { --horizontal IF ABS[r.x1-from.x] < ABS[r.x2-from.x] THEN {--left-- amount _ from.x-to.x; orientInPlane _ CDOrient.rotate270 } ELSE { --right-- amount _ to.x-from.x; orientInPlane _ CDOrient.rotate90 } } ELSE { --vertical IF ABS[r.y1-from.y] < ABS[r.y2-from.y] THEN {--near to origin-- amount _ from.y-to.y; orientInPlane _ CDOrient.original } ELSE { --far from origin-- amount _ to.y-from.y; orientInPlane _ CDOrient.rotate180 } }; IF selAp=NIL THEN { -- use pointed count _ 1; [includeList, removeMe] _ StretchApplication[design, pointedAp, orientInPlane, amount]; IF removeMe THEN removeList _ LIST[pointedAp]; } ELSE { -- use selected FOR list: CD.ApplicationList _ CDOps.AppList[design], list.rest WHILE list#NIL DO IF list.first.selected THEN { count _ count+1; [include, removeMe] _ StretchApplication[design, list.first, orientInPlane, amount]; IF removeMe THEN removeList _ CONS[list.first, removeList]; IF include#NIL THEN includeList _ CDApplications.AppendToList[include, includeList]; } ENDLOOP; }; RemoveAppList[design, removeList]; IncludeAppList[design, includeList]; TerminalIO.WriteInt[count]; TerminalIO.WriteRope[" objects tried to stretch\n"]; END; RemoveAppList: PROC [design: CD.Design, appList: CD.ApplicationList, draw: BOOL_TRUE] = BEGIN FOR list: CD.ApplicationList _ appList, list.rest WHILE list#NIL DO CDOps.RemoveApplication[design, list.first, draw]; ENDLOOP; END; IncludeAppList: PROC [design: CD.Design, appList: CD.ApplicationList, draw: BOOL_TRUE] = BEGIN FOR list: CD.ApplicationList _ appList, list.rest WHILE list#NIL DO CDOps.IncludeApplication[design, list.first, draw]; ENDLOOP; END; MoveAppList: PROC [appList: CD.ApplicationList, offset: CD.DesignPosition] = BEGIN FOR list: CD.ApplicationList _ appList, list.rest WHILE list#NIL DO list.first.location _ CDInline.AddPoints[list.first.location, offset]; ENDLOOP; END; StretchPSCommand: PROC [comm: CDSequencer.Command] = BEGIN TerminalIO.WriteRope["Stretch"]; TerminalIO.WriteRope[" --Debug output: "]; TerminalIO.WriteInt[comm.sPos.y]; TerminalIO.WriteInt[comm.pos.y]; TerminalIO.WriteRope[" -- "]; DoAStretch[design: comm.design, from: comm.sPos, to: comm.pos] END; Impl: PROC [] = BEGIN CDSequencer.ImplementCommand[$StretchPS, StretchPSCommand]; END; Impl[]; END. ŒStretchCommands.mesa (part of Chipndale) by Christian Jacobi July 11, 1983 3:42 pm last edited Christian Jacobi February 14, 1984 4:05 pm -- orientInPlane: -- at position "original" the bottom edge [(0, 0), (1, 0)] is streched -- mirroring is ignored -- amount>0 ==> grow in direction orientInPlane -- amount<0 ==> shrink on edge orientInPlane --ignore mirroring and 45 degrees ÊƘJšœ*™*Jšœ,™,Jšœ8™8J˜šÏk ˜ Jšœ˜J˜J˜ J˜Jšœ ˜ Jšœ˜Jšœ˜J˜ J˜ J˜—šÏbœœ˜JšœV˜]—Jš˜J˜J˜šÏnœœ œœ œœœ œœ œœ˜¿Jšœ™JšœH™HJšœ™Jšœ/™/Jšœ,™,Jš˜J˜š Ÿ œœ œœœœ˜]šœœœ œœ œœ˜QJš œ œœœœ˜4—Jš˜šœœ˜Jš˜Jšœœ:˜@š œœœœœ˜8Jš˜J˜ J˜J˜J˜Jšœ"œœ+˜ZJšœ˜—Jšœ˜—Jšœ˜J˜—Jšœœ ˜*Jšœ!œ˜&Jš œœœœœ˜>Jšœ!™!Jšœ>˜>Jšœ=˜=šœ*˜*Jšœ"˜"Jšœ˜Jšœ˜—Jšœ+œœ˜WJšœB˜BJšœf˜fšœœ˜šœ/˜9šœ˜Jšœ)˜)Jšœ œœ#˜6J˜—Jšœœ˜Jšœœ˜šœ˜Jšœ)˜)Jšœ œœ#˜6J˜—Jšœœ˜—JšœB˜BJšœ˜—Jšœ˜—J˜šŸ œœ œœ˜CJš˜Jšœœ ˜Jšœœ˜Jšœœ˜$Jšœœ ˜Jšœœ˜Jšœ œ˜Jšœ œ˜Jšœœœ˜0Jšœœ˜šœ œ˜J˜)Jš˜Jšœ˜—Jšœ?˜?JšœE˜Ešœ œœ˜J˜.Jš˜Jšœ˜—Jšœ.˜.š œœœœÏc ˜8š œœœœ ˜5Jšœ˜Jšœ"˜"J˜—šœ  ˜Jšœ˜Jšœ!˜!J˜—J˜—šœ  ˜š œœœœ ˜?Jšœ˜Jšœ!˜!J˜—šœ ˜Jšœ˜Jšœ"˜"J˜—J˜—šœœœ ˜"Jšœ ˜ JšœW˜WJšœ œœ ˜.J˜—šœ ˜š œœ4œœ˜Qšœœ˜Jšœ˜JšœT˜TJšœ œœ˜;Jšœ œœA˜TJ˜—Jšœ˜—J˜—Jšœ"˜"Jšœ$˜$Jšœ˜J˜4Jšœ˜—J˜š Ÿ œœ œœœœ˜WJš˜š œœ&œœ˜CJšœ2˜2Jšœ˜—Jšœ˜—Jšœ˜š Ÿœœ œœœœ˜XJš˜š œœ&œœ˜CJšœ3˜3Jšœ˜—Jšœ˜—J˜šŸ œœ œœ˜LJš˜š œœ&œœ˜CJšœF˜FJšœ˜—Jšœ˜—J˜šŸœœ˜4Jš˜J˜ J˜J˜*JšœB˜BJ˜J˜Jšœ>˜>Jšœ˜J˜—šŸœœ˜Jš˜Jšœ;˜;Jšœ˜J˜—J˜Jšœ˜J˜—…—ðB