<> <> <> <> <<>> <> DIRECTORY Atom USING [PutPropOnList], CD USING [Design, Number, Rect], CDCommandOps USING [BoundingBox, CallWithResource], CDPanel USING [DefineButton, DefineNewLine], CDPanelExtras USING [DefineTextEntry, FromDisplayRope], CDProperties USING [PutDesignProp, RegisterProperty], CDSequencer USING [Command, ImplementCommand], CDValue USING [RegisterKey, Store], CDViewer USING [ViewerList, ViewersOf, VisibleRect], Commander USING [CommandProc, Handle, Register], CommandTool USING [NextArgument], CStitching USING [NewTesselation, Tesselation, FindTile], Imager USING [metersPerPoint, Rectangle], IO USING [int, PutF, PutFR, real, rope], MessageWindow USING [Append, Blink, Clear], Nectarine USING [DoInterpress, invalidPrinter, Print], Rope USING [ActionType, Cat, Equal, Fetch, IsEmpty, Length, Map, ROPE, SkipTo, Substr], RopeFile USING [Create], SafeStorage USING [GetCanonicalReferentType, Type], SweepCollectableStorage USING [EnumerateCollectableStorage, InfoProc], TEditDocument USING [Selection], TEditInputOps USING [Break, CallWithLocks], TerminalIO USING [WriteRope], TextNode USING [Ref], TiogaAccess USING [Create, GetInternalProp, Put, TiogaChar, Writer, WriteSelection, WriteViewer], UserProfile USING [Token], ViewerClasses USING [Viewer], ViewerOps USING [BlinkIcon, CreateViewer]; NectarineCommand: CEDAR PROGRAM IMPORTS Atom, CDCommandOps, CDPanel, CDPanelExtras, CDProperties, CDSequencer, CDValue, CDViewer, Commander, CommandTool, CStitching, IO, MessageWindow, Nectarine, Rope, RopeFile, SafeStorage, SweepCollectableStorage, TEditInputOps, TerminalIO, TiogaAccess, UserProfile, ViewerOps ~ BEGIN masterKey: ATOM = $Nectarine; whatKey: ATOM = $NectarineWhat; whereKey: ATOM = $NectarineWhere; copiesKey: ATOM = $NectarineCopies; CSTile: SafeStorage.Type; ROPE: TYPE ~ Rope.ROPE; lastPrint: RECORD [ip: ROPE, key: ATOM, q: INT, w: Imager.Rectangle]; <> NectarineCommand: PROC [comm: CDSequencer.Command] ~ BEGIN <> abort: REF BOOL _ NEW [BOOL _ FALSE]; DoIt: PROC [comm: CDSequencer.Command] ~ BEGIN <> what: ROPE ~ CDPanelExtras.FromDisplayRope [comm.design, whatKey]; where: ROPE ~ CDPanelExtras.FromDisplayRope [comm.design, whereKey]; howMany: INT _ 0; cropKey, printKey: ATOM; masterName: ROPE _ NIL; usedField: Imager.Rectangle; rollPaperDeviceHint: REF Imager.Rectangle _ NIL; <> IF where.Equal ["Explain", FALSE] THEN {ExplainGoals []; RETURN}; <> SELECT TRUE FROM what.Equal ["Design", FALSE] => cropKey _ $NectarineAll; what.Equal ["Wysiwyg", FALSE] => cropKey _ $NectarineWysiwyg; what.Equal ["Selection", FALSE] => cropKey _ $NectarineSel; ENDCASE => BEGIN TerminalIO.WriteRope ["Unknown cropping option.\n"]; ERROR ABORTED END; <> SELECT TRUE FROM where.Equal ["ColorVersatec", FALSE] => BEGIN ImportantMessage ["Are you sure you did not want to use the printer server 'PeachExpand' (see doc)?"]; printKey _ $NColorVersatec END; where.Equal ["Color400", FALSE] => printKey _ $NColor400; where.Equal ["Raven300", FALSE] => printKey _ $NRaven300; where.Equal ["Bw400", FALSE] => printKey _ $NBw400; where.Equal ["Versatec", FALSE] => printKey _ $NVersatec; where.Equal ["PlateMaker", FALSE] => printKey _ $NPlateMaker; where.Equal ["Tioga doc", FALSE] => printKey _ $NPasteInTioga; where.Equal ["IP only", FALSE] => printKey _ $NmasterOnly; where.Equal ["PeachExpand", FALSE] => BEGIN TerminalIO.WriteRope ["I will create an Interpress master, which I will use to produce a PD file. I will then send it to the expansion server to create a bitmap, and from there I will send it to the color Versatec. You will have to delete the temporary files manually.\n"]; printKey _ $NPeachExpand END; ENDCASE => {TerminalIO.WriteRope ["Unknown printer.\n"]; ERROR ABORTED}; <> BEGIN nrRopeRaw: ROPE ~ CDPanelExtras.FromDisplayRope [comm.design, copiesKey]; nrPos: INTEGER ~ nrRopeRaw.SkipTo [0, "0123456789"]; nrRope: ROPE ~ nrRopeRaw.Substr [nrPos, nrRopeRaw.Length[]-nrPos]; IF (NOT nrRope.IsEmpty []) THEN BEGIN -- default: 0 howMany _ (ORD [nrRope.Fetch[0]] - ORD ['0]); FOR i: INT IN [1 .. nrRopeRaw.Length[]) DO howMany _ howMany * 10 + (ORD [nrRopeRaw.Fetch[i]] - ORD ['0]) ENDLOOP END END; -- Interpret how many <> IF (masterName.IsEmpty []) THEN BEGIN cW: CD.Rect; -- ChipNDale window l: CD.Number ~ comm.design.technology.lambda; SELECT cropKey FROM $NectarineAll => cW _ CDCommandOps.BoundingBox [comm.design]; $NectarineSel => cW _ CDCommandOps.BoundingBox [comm.design, TRUE]; $NectarineWysiwyg => BEGIN viewers: CDViewer.ViewerList = CDViewer.ViewersOf [comm.design]; goodViewer: ViewerClasses.Viewer; good: INT _ 0; IF (viewers = NIL) THEN BEGIN TerminalIO.WriteRope ["You do not see anything of this design !\n"]; ERROR ABORTED END; FOR v: CDViewer.ViewerList _ viewers, v.rest WHILE v # NIL DO IF NOT v.first.iconic THEN {goodViewer _ v.first; good _ good.SUCC} ENDLOOP; SELECT good FROM 0 => {TerminalIO.WriteRope ["You do not see anything !\n"]; ERROR ABORTED}; > 1 => TerminalIO.WriteRope ["WARNING: you see more than one viewer. I pick one at random\n"]; ENDCASE => NULL; cW _ CDViewer.VisibleRect [goodViewer] END; ENDCASE => ERROR; <> cW _ [x1: cW.x1 - l, x2: cW.x2 + l, y1: cW.y1 - l, y2: cW.y2 + l]; [masterName, usedField] _ Nectarine.DoInterpress [design: comm.design, chipNDaleWindow: cW, clip: (cropKey = $NectarineWysiwyg) OR (cropKey = $NectarineSel), onlySel: (cropKey = $NectarineSel), abortFlag: abort]; CDProperties.PutDesignProp [comm.design, masterKey, masterName] END; -- create Interpress master <> lastPrint _ [ip: masterName, key: printKey, q: howMany, w: usedField]; -- for Redo SELECT printKey FROM $NmasterOnly => NULL; $NPasteInTioga => Paste [masterName, usedField]; ENDCASE => BEGIN IF (usedField.h > usedField.w) THEN rollPaperDeviceHint _ NEW [Imager.Rectangle _ usedField]; [] _ Nectarine.Print [masterName, printKey, howMany, rollPaperDeviceHint ! Nectarine.invalidPrinter => ERROR] END; TerminalIO.WriteRope ["Design unlocked by Nectarine.\n"] END; -- DoIt [] _ CDCommandOps.CallWithResource [DoIt, comm, $Nectarine, abort] <> END; -- NectarineCommand Paste: PROC [name: ROPE, bb: Imager.Rectangle, newViewer: BOOL _ FALSE] ~ BEGIN <> <> master: ROPE ~ RopeFile.Create [name]; -- the Interpress master desguised as a rope document: TiogaAccess.Writer _ TiogaAccess.Create []; -- a working area Tioga doc vanillaChar: TiogaAccess.TiogaChar = [0, 0C, ALL [FALSE], NIL, TRUE, FALSE, 0, NIL]; dummy, ip, caption: TiogaAccess.TiogaChar _ vanillaChar; space: REAL ~ 8.0 * Imager.metersPerPoint * 1000.0; -- in mm topCalcRope: ROPE; -- for postfix property calculating top leading and ident WriteRope: PROC [r: ROPE, attr: TiogaAccess.TiogaChar] ~ BEGIN <> PutChar: Rope.ActionType ~ {attr.char _ c; document.Put [attr]}; [] _ Rope.Map [base: r, action: PutChar] END; -- WriteRope PutProp: PROC [char: TiogaAccess.TiogaChar, prop: ATOM, val: ROPE] RETURNS [TiogaAccess.TiogaChar] ~ BEGIN <> char.propList _ Atom.PutPropOnList [propList: char.propList, prop: prop, val: TiogaAccess.GetInternalProp [prop, val]]; RETURN [char] END; -- PutProp Stuff: PROC [root: TextNode.Ref, tSel:TEditDocument.Selection] ~ BEGIN <> IF newViewer THEN BEGIN repository: ViewerClasses.Viewer _ ViewerOps.CreateViewer [$Text]; document.WriteViewer [repository]; ViewerOps.BlinkIcon [repository, 0] END ELSE {TEditInputOps.Break []; TiogaAccess.WriteSelection [document]} END; -- Stuff <> dummy.endOfNode _ TRUE; WriteRope ["\n", dummy]; <> dummy.endOfNode _ FALSE; dummy.looks['n] _ TRUE; WriteRope ["[Artwork node; type 'ArtworkInterpress on' to command tool]", dummy]; ip.char _ '\n; ip.endOfNode _ TRUE; ip.deltaLevel _ 1; ip.format _ $artworkFigure; -- it is an artwork node <> topCalcRope _ IO.PutFR ["%g the lineLength .mul %g .add", IO.real [bb.h/bb.w], IO.real [space]]; ip _ PutProp [ip, $Postfix, IO.PutFR ["%g topLeading %g topIndent %g mm bottomLeading", IO.rope [topCalcRope], IO.rope [topCalcRope], IO.real [space/2.0]]]; -- margin in the document ip _ PutProp [ip, $Bounds, IO.PutFR ["%g mm xmin %g mm ymin %g mm xmax %g mm ymax", IO.real [bb.x], IO.real [bb.y], IO.real [bb.x+bb.w], IO.real [bb.y+bb.h]]]; -- set the bounding box ip _ PutProp [ip, $Artwork, "Interpress"]; -- the artwork type is "Interpress" ip _ PutProp [ip, $Interpress, master]; -- the Interpress master desguised as a rope ip _ PutProp [ip, $Fit, "TRUE"]; -- fit the figure to the margins of the sibling node document.Put [ip]; <> caption.looks['i] _ TRUE; caption.looks['o] _ TRUE; -- should be in the style WriteRope ["Insert caption here", caption]; caption.char _ 0C; caption.format _ $artworkCaption; caption.endOfNode _ TRUE; document.Put [caption]; <> TEditInputOps.CallWithLocks [Stuff] END; -- Paste Registations: PROC [] ~ BEGIN defaultCrops: LIST OF ROPE ~ LIST ["Design", "Selection", "Wysiwyg"]; defaultPrinters: LIST OF ROPE ~ LIST ["Explain", "PeachExpand", "Tioga doc", "Raven300", "Bw400", "Versatec", "ColorVersatec", "Color400", "PlateMaker", "IP only"]; [] _ CDProperties.RegisterProperty [masterKey, masterKey]; CDValue.RegisterKey [key: whatKey, registrationKey: masterKey]; CDValue.RegisterKey [key: whereKey, registrationKey: masterKey]; CDValue.RegisterKey [key: copiesKey, registrationKey: masterKey]; CDValue.Store [key: whatKey, value: defaultCrops]; CDValue.Store [key: whereKey, value: defaultPrinters]; CDValue.Store [key: copiesKey, value: "1"]; CDPanel.DefineButton [name: "Nectarine", border: TRUE, command: $NectarineCmd]; CDPanelExtras.DefineTextEntry [cdValueKey: whatKey, button: "What:", width: 60, editable: FALSE]; CDPanelExtras.DefineTextEntry [cdValueKey: whereKey, button: "Where:", width: 90, editable: FALSE]; CDPanelExtras.DefineTextEntry [cdValueKey: copiesKey, button: "Copies:", width: 30]; CDPanel.DefineNewLine []; CDSequencer.ImplementCommand [key: $NectarineCmd, proc: NectarineCommand, queue: doQueue]; Commander.Register [key: "NCount", proc: Count, doc: "Counts corner stitching tiles"]; Commander.Register [key: "NRedo", proc: Redo, doc: "Syntax: NRedo . Redoes the last Nectarine Print command on the same Interpress master but with the newly specified goal. The goal must be one of those specified in the field of the Nectarine line in the ChipNDale control panel. Default: the same as the last time around."] END; -- Registrations Count: Commander.CommandProc ~ BEGIN <<[cmd: Commander.Handle] RETURNS [result: REF ANY _ NIL, msg: ROPE _ NIL]>> PerObject: SweepCollectableStorage.InfoProc ~ BEGIN <<[type: SafeStorage.Type, size: INT, object: LONG CARDINAL] RETURNS [continue: BOOLEAN] >> IF type = CODE [CStitching.Tesselation] THEN tessCount _ tessCount + 1 ELSE IF type = CSTile THEN tileCount _ tileCount + 1; RETURN [TRUE] END; -- PerObject tessCount: INT _ 0; tileCount: INT _ 0; TRUSTED { SweepCollectableStorage.EnumerateCollectableStorage [PerObject] }; cmd.out.PutF ["tesselations = %g\n", IO.int [tessCount]]; cmd.out.PutF ["tiles = %g\n", IO.int [tileCount]] END; -- Count Redo: Commander.CommandProc ~ BEGIN <<[cmd: Commander.Handle] RETURNS [result: REF ANY _ NIL, msg: ROPE _ NIL]>> <. Redoes the last Print command on the same Interpress master but on the newly specified goal. The goal must be one of those specified in the field of the Nectarine line in the ChipNDale control panel. Default: the same as the last time around.>> where: ROPE ~ CommandTool.NextArgument [cmd]; savedKey: ATOM ~ lastPrint.key; IF NOT where.IsEmpty [] THEN lastPrint.key _ SELECT TRUE FROM where.Equal ["ColorVersatec", FALSE] => $NColorVersatec, where.Equal ["Color400", FALSE] => $NColor400, where.Equal ["Raven300", FALSE] => $NRaven300, where.Equal ["Bw400", FALSE] => $NBw400, where.Equal ["Versatec", FALSE] => $NVersatec, where.Equal ["PlateMaker", FALSE] => $NPlateMaker, where.Equal ["Tioga", FALSE] => $NPasteInTioga, where.Equal ["Tioga doc", FALSE] => $NPasteInTioga, where.Equal ["Paste", FALSE] => $NPasteInTioga, where.Equal ["Stuff", FALSE] => $NPasteInTioga, where.Equal ["IP only", FALSE] => $NmasterOnly, where.Equal ["IP", FALSE] => $NmasterOnly, where.Equal ["PeachExpand", FALSE] => $NPeachExpand, ENDCASE => $cacca; SELECT lastPrint.key FROM $NmasterOnly => msg _ lastPrint.ip; $NPasteInTioga => BEGIN <> Paste [lastPrint.ip, lastPrint.w, TRUE]; msg _ "Image deposed in temporary blinking iconic Tioga viewer." END; $cacca => BEGIN lastPrint.key _ savedKey; result _ $Failure; msg _ cmd.procData.doc END; ENDCASE => BEGIN rollPaperDeviceHint: REF Imager.Rectangle _ NIL; IF (lastPrint.w.h > lastPrint.w.w) THEN rollPaperDeviceHint _ NEW [Imager.Rectangle _ lastPrint.w]; [] _ Nectarine.Print [lastPrint.ip, lastPrint.key, lastPrint.q, rollPaperDeviceHint ! Nectarine.invalidPrinter => {result _ $Failure; msg _ cmd.procData.doc}] END END; -- Redo ExplainGoals: PROC [] ~ BEGIN <> Plop: PROC [plup, plip, plap: ROPE] ~ BEGIN <> TerminalIO.WriteRope [plup.Cat [": print on ", UserProfile.Token [Rope.Cat ["Nectarine.", plup], plip]]]; TerminalIO.WriteRope [Rope.Cat [", a ", plap, " printer.\n"]] END; -- Plop TerminalIO.WriteRope ["The following goals are available for the output:\n"]; TerminalIO.WriteRope ["PeachExpand: expand the PD file on "]; TerminalIO.WriteRope [UserProfile.Token ["Nectarine.PeachExpand", "Kearsarge"]]; TerminalIO.WriteRope [" and send it to "]; TerminalIO.WriteRope [UserProfile.Token ["Nectarine.ColorVersatec", "Sleepy"]]; TerminalIO.WriteRope [".\n"]; TerminalIO.WriteRope ["Tioga doc: copy in the Tioga document at the caret.\n"]; Plop ["Raven300", "Quoth", "black & white Interpress"]; Plop ["Bw400", "MtFuji", "black & white thermal"]; Plop ["Versatec", "Sleepy", "black & white Versatec"]; Plop ["ColorVersatec", "Sleepy", "colour Versatec"]; Plop ["Color400", "MtFuji", "colour thermal"]; Plop ["PlateMaker", "PlateMaker", "special"]; TerminalIO.WriteRope ["Explain: jot down this explanation.\n\n"] END; -- ExplainGoals ImportantMessage: PROC [msg: Rope.ROPE] ~ BEGIN <> TerminalIO.WriteRope [msg]; TerminalIO.WriteRope ["\n"]; MessageWindow.Clear []; MessageWindow.Append [msg]; MessageWindow.Blink [] END; -- ImportantMessage CSTile _ SafeStorage.GetCanonicalReferentType [CStitching.NewTesselation[].FindTile[[0,0]]]; Registations []; TerminalIO.WriteRope ["Nectarine package loaded.\n"]; ExplainGoals [] END. <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <<>> <<>>