DIRECTORY CCTTool, Atom USING [GetPropFromList, PutPropOnList], Buttons USING [Button, ButtonProc, Create, SetDisplayStyle], ColorTransforms USING [Transform, TRC], ColorTransformTRC USING [ReadTRCFromAltoFile], Commander USING [CommandProc, Register], CommandTool USING [ArgumentVector, Parse], Containers USING [Container, Create], Convert USING [Error, RealFromRope, RopeFromReal], FS USING [Error, FileInfo], Icons USING [IconFlavor, NewIconFromFile], Imager USING [black], ImagerFont USING [Find, Font], Labels USING [Create, Label], MessageWindow USING [Append, Blink], Rope USING [Cat, Length, ROPE], Rules USING [Create], VFonts USING [StringWidth], ViewerClasses USING [Viewer], ViewerEvents USING [EventProc, RegisterEventProc], ViewerOps USING [OpenIcon, SetOpenHeight], ViewerTools USING [GetContents, MakeNewTextViewer, SetContents]; CCTToolImpl: CEDAR MONITOR IMPORTS Atom, Buttons, ColorTransformTRC, Commander, CommandTool, Containers, Convert, FS, Icons, Imager, ImagerFont, Labels, MessageWindow, Rope, Rules, VFonts, ViewerEvents, ViewerOps, ViewerTools EXPORTS CCTTool ~ { OPEN CCTTool; ROPE: TYPE ~ Rope.ROPE; Viewer: TYPE ~ ViewerClasses.Viewer; TransformCoords: TYPE ~ RECORD [from, to: NAT]; entryVSpace: CARDINAL = 8; entryHSpace: CARDINAL = 2; hMargin: CARDINAL = 5; --Spacing between buttons on a line vMargin: CARDINAL = 5; --Spacing between rows of buttons graphInset: CARDINAL = 110; buttonHeight: CARDINAL _ 20; buttonWidth: CARDINAL _ 0; trcWidth: CARDINAL _ 250; trcHeight: CARDINAL _ trcWidth; typicalWidth: CARDINAL ~ entryVSpace+graphInset+trcWidth; viewer: Containers.Container _ NIL; --The actual CCT Tool viewer printTrcFile: ROPE _ NIL; printTrcNames: ARRAY [0..3) OF ROPE _ ALL[NIL]; printTrcs: PUBLIC ARRAY [0..3) OF ColorTransforms.TRC; transform: PUBLIC ColorTransforms.Transform _ [[1,0,0],[0,1,0],[0,0,1],[0,0,0]]; toggleButton: PUBLIC PACKED ARRAY ToggleButton OF BOOLEAN _ ALL[FALSE]; ucrGamma, ucrThreshold, ucrFraction: PUBLIC REAL _ 0; cctToolIcon: Icons.IconFlavor ~ Icons.NewIconFromFile["CCTTool.icons", 0]; NoCCTTool: PROC RETURNS [BOOLEAN] ~ INLINE { RETURN [viewer=NIL OR viewer.destroyed] }; MakeCCTToolCommand: Commander.CommandProc = BEGIN RETURN [msg: MakeCCTTool[]] END; MakeCCTTool: ENTRY PROC RETURNS [msg: ROPE] ~ { ENABLE UNWIND => NULL; height: CARDINAL; IF viewer#NIL AND ~viewer.destroyed THEN { ViewerOps.OpenIcon[viewer]; RETURN [msg: "Opened existing CCT Tool.\n"] }; viewer _ Containers.Create[[ name: "Coronado CCT Tool", column: right, iconic: TRUE, icon: cctToolIcon, scrollable: TRUE ]]; height _ MakeCCTViewer[]; ViewerOps.SetOpenHeight[viewer, height]; }; CCTTextLosingInputFocus: ENTRY ViewerEvents.EventProc = { GetValue: PROC RETURNS [value: REAL] ~ { value _ Convert.RealFromRope[r: contents ! Convert.Error => { MessageWindow.Append[message: Rope.Cat[contents, "not a legal value."], clearFirst: TRUE]; MessageWindow.Blink[]; value _ 0; ViewerTools.SetContents[viewer: viewer, contents: "0"]; CONTINUE; }]; }; EvaluateTRCs: PROC ~ { IF printTrcFile=NIL THEN RETURN; FOR from: NAT IN [0..3) DO IF Rope.Length[printTrcNames[from]]=0 THEN printTrcs[from] _ NIL ELSE printTrcs[from] _ ColorTransformTRC.ReadTRCFromAltoFile[fileName: printTrcFile, trcName: printTrcNames[from] ! ANY => { MessageWindow.Append[message: Rope.Cat["Could not find trc: ", printTrcNames[from]], clearFirst: TRUE]; MessageWindow.Blink[]; printTrcs[from] _ NIL; CONTINUE }]; ENDLOOP; }; SetTRC: PROC [from: NAT] ~ { printTrcNames[from] _ contents; EvaluateTRCs[]; }; id: REF ~ Atom.GetPropFromList[propList: viewer.props, prop: $CCTTool]; contents: ROPE ~ ViewerTools.GetContents[viewer: viewer]; WITH id SELECT FROM atom: ATOM => { SELECT atom FROM $File => { printTrcFile _ FS.FileInfo[name: contents ! FS.Error => { printTrcFile _ NIL; MessageWindow.Append[message: Rope.Cat[r1: "TRC file (", r2: contents, r3: ") not found."], clearFirst: TRUE]; MessageWindow.Blink[]; CONTINUE }].fullFName; EvaluateTRCs[]; }; $Red => SetTRC[from: 0]; $Green => SetTRC[from: 1]; $Blue => SetTRC[from: 2]; $Gamma => ucrGamma _ GetValue[]; $Threshold => ucrThreshold _ GetValue[]; $Fraction => ucrFraction _ GetValue[]; ENDCASE => ERROR; }; tCoord: REF TransformCoords => transform[tCoord.from][tCoord.to] _ GetValue[]; ENDCASE => ERROR; }; ToggleButtonProc: Buttons.ButtonProc = { v: Viewer ~ NARROW[parent]; button: ToggleButton ~ NARROW[clientData, REF ToggleButton]^; Buttons.SetDisplayStyle[button: v, style: IF toggleButton[button] _ ~toggleButton[button] THEN $WhiteOnBlack ELSE $BlackOnWhite]; }; MakeCCTViewer: INTERNAL PROC [] RETURNS [height: CARDINAL] ~ { MakeRule: PROC ~ { [] _ Rules.Create[info: [wx: entryHSpace, wy: thisY, wh: 2, ww: typicalWidth, parent: viewer], color: Imager.black]; thisY _ thisY + entryVSpace; }; MakeTitle: PROC [title: ROPE] ~ { font: ImagerFont.Font ~ ImagerFont.Find["Xerox/TiogaFonts/TimesRoman14B"]; tempWidth: CARDINAL _ VFonts.StringWidth[string: title, font: font]; prev _ Labels.Create[info: [name: title, wx: (typicalWidth - tempWidth)/2, wy: thisY, parent: viewer, border: FALSE], font: font]; thisY _ thisY + 14 + entryVSpace; --The 14 comes from TimesRoman14 }; MakeTextInputViewer: PROC [id: REF ANY, title, initialContents: ROPE _ NIL, ww: INTEGER _ trcWidth, deltaThisY: INTEGER _ entryVSpace, newLine: BOOL _ TRUE] ~ { IF title#NIL THEN { tempWidth: CARDINAL _ VFonts.StringWidth[string: title]; label: Labels.Label _ Labels.Create[ info: [name: title, wx: thisX - tempWidth - 2*hMargin, wy: thisY, parent: viewer, border: FALSE]]; }; prev _ ViewerTools.MakeNewTextViewer[info: [props: Atom.PutPropOnList[propList: NIL, prop: $CCTTool, val: id], wx: thisX, wy: thisY, ww: ww, wh: buttonHeight, parent: viewer, scrollable: FALSE, data: initialContents]]; IF newLine THEN {thisX _ entryHSpace + graphInset; thisY _ thisY + prev.wh + deltaThisY} ELSE thisX _ thisX + hMargin + prev.ww; [] _ ViewerEvents.RegisterEventProc[proc: CCTTextLosingInputFocus, event: killInputFocus, filter: prev, before: FALSE]; }; MakeToggleButton: PROC [label: ROPE, button: ToggleButton, initialState: BOOLEAN] ~ { prev _ Buttons.Create[info: [name: label, wx: thisX, wy: thisY, parent: viewer], proc: ToggleButtonProc, clientData: NEW[ToggleButton _ button]]; Buttons.SetDisplayStyle[button: prev, style: IF toggleButton[button] _ initialState THEN $WhiteOnBlack ELSE $BlackOnWhite]; thisX _ thisX + prev.ww + hMargin; }; prev: ViewerClasses.Viewer; thisX: INT _ entryHSpace+graphInset; thisY: INT _ entryVSpace; MakeTitle["Input TRC"]; MakeTextInputViewer[$File, "TRC File Name"]; MakeTextInputViewer[$Red, "Red TRC"]; MakeTextInputViewer[$Green, "Green TRC"]; MakeTextInputViewer[$Blue, "Blue TRC"]; MakeRule[]; MakeTitle["Color Correction Transform"]; FOR each: LIST OF ROPE _ LIST["Red", "Green", "Blue", "Constant offset"], each.rest UNTIL each=NIL DO prev _ Labels.Create[info: [name: each.first, wx: thisX, wy: thisY, parent: viewer, border: FALSE]]; thisX _ thisX + trcWidth/4-hMargin + hMargin; ENDLOOP; thisX _ entryHSpace + graphInset; thisY _ thisY + prev.wh + 2; FOR to: NAT IN [0..3) DO FOR from: NAT IN [0..4) DO id: REF TransformCoords ~ NEW[TransformCoords _ [from: from, to: to]]; MakeTextInputViewer[id: id, title: IF from=0 THEN SELECT to FROM 0 => "Cyan", 1 => "Magenta", 2 => "Yellow", ENDCASE => "Error" ELSE NIL, initialContents: Convert.RopeFromReal[from: transform[from][to]], ww: trcWidth/4-hMargin, newLine: from=3, deltaThisY: IF to=2 THEN entryVSpace ELSE 2]; ENDLOOP; ENDLOOP; MakeToggleButton["Log Data", alreadyLog, TRUE]; MakeToggleButton["Invert in", invertIn, TRUE]; MakeToggleButton["out", invertOut, FALSE]; MakeRule[]; MakeTitle["Under Color Removal"]; thisX _ entryHSpace + graphInset; thisY _ thisY + prev.wh + entryVSpace; MakeTextInputViewer[id: $Gamma, title: "Gamma", initialContents: "0", ww: trcWidth/4, deltaThisY: 2]; MakeTextInputViewer[id: $Threshold, title: "Threshold", initialContents: "0", ww: trcWidth/4, deltaThisY: 2]; MakeTextInputViewer[id: $Fraction, title: "Fraction Removed", initialContents: "0", ww: trcWidth/4]; height _ thisY _ thisY + entryVSpace; }; SetGamma: Commander.CommandProc = { arg: CommandTool.ArgumentVector ~ CommandTool.Parse[cmd: cmd]; IF arg.argc#2 THEN GOTO Failure; EXITS Failure => RETURN [msg: "Usage: Gamma ", result: $Failure]; }; Init: PROC ~ { Commander.Register[key: "MakeCCTTool", proc: MakeCCTToolCommand, doc: "Create a CCT Tool" ]; [] _ MakeCCTTool[]; }; Init[]; }. fCCTToolImpl.mesa Copyright c 1984, 1985 by Xerox Corporation. All rights reserved. Implements tool to allow user to set parameters for CCT and UCR for printing Eric Nickell January 19, 1986 11:50:43 pm PST Types and Constants Global Data CCTTool Implementation [viewer: ViewerClasses.Viewer, event: ViewerEvents.ViewerEvent, before: BOOL] RETURNS [abort: BOOL _ FALSE] [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] Color correct and under-color removal [cmd: Commander.Handle] RETURNS [result: REF ANY _ NIL, msg: ROPE _ NIL] ΚΣ˜default™Icodešœ Οmœ7™BJ™LL™-J˜—šΟk ˜ L˜Lšœžœ"˜,Jšœžœ/˜š œžœ˜L–][info: ViewerClasses.ViewerRec, color: ImagerColorDefs.Color _ NIL, paint: BOOL _ TRUE]šœt˜tL˜L˜—š  œžœ žœ˜!N–[name: ROPE]šœJ˜JN–/[string: ROPE, font: ImagerFont.Font _ NIL]šœ žœ1˜DN–Έ[info: ViewerClasses.ViewerRec _ [class: NIL, wx: 0, wy: 0, ww: 0, wh: 0, cx: 0, cy: 0, cw: 0, ch: 0, lock: [process: PROCESS#0B, count: 0B (0)], tipTable: NIL, name: NIL, file: NIL, label: NIL, menu: NIL, icon: 177777B?, column: left, caption: FALSE, scrollable: TRUE, hscrollable: FALSE, iconic: TRUE, border: TRUE, newVersion: FALSE, newFile: FALSE, visible: TRUE, offDeskTop: FALSE, destroyed: FALSE, init: FALSE, saveInProgress: FALSE, inhibitDestroy: FALSE, guardDestroy: FALSE, paintingWedged: FALSE, ...], font: ImagerFont.Font _ NIL, paint: BOOL _ TRUE]šœnžœ˜‚Nšœ"ŸΠbc˜BL˜—š œžœžœžœžœžœžœžœžœžœ˜ šžœžœžœ˜Lšœ žœ%˜8Lšœžœ˜‡Lšœ˜—L–<[propList: Atom.PropList, prop: REF ANY, val: REF ANY]šœPžœhžœ˜ΪLšžœ žœJžœ#˜€L–s[proc: ViewerEvents.EventProc, event: ViewerEvents.ViewerEvent, filter: REF ANY _ NIL, before: BOOL _ TRUE]šœpžœ˜wL˜—š œžœ žœ&žœ˜UL–Ώ[info: ViewerClasses.ViewerRec _ [class: NIL, wx: 0, wy: 0, ww: 0, wh: 0, cx: 0, cy: 0, cw: 0, ch: 0, lock: [process: PROCESS#0B, count: 0B (0)], tipTable: NIL, name: NIL, file: NIL, label: NIL, menu: NIL, icon: 177777B?, column: left, caption: FALSE, scrollable: TRUE, hscrollable: FALSE, iconic: TRUE, border: TRUE, newVersion: FALSE, newFile: FALSE, visible: TRUE, offDeskTop: FALSE, destroyed: FALSE, init: FALSE, saveInProgress: FALSE, inhibitDestroy: FALSE, guardDestroy: FALSE, paintingWedged: FALSE, ...], proc: Buttons.ButtonProc, clientData: REF ANY _ NIL, fork: BOOL _ TRUE, font: ImagerFont.Font _ NIL, documentation: REF ANY _ NIL, guarded: BOOL _ FALSE, paint: BOOL _ TRUE]šœužœ˜‘L–?[button: Buttons.Button, style: ATOM, paint: BOOL _ TRUE]šœ-žœ%žœžœ˜{L˜"L˜—J˜Jšœžœ˜$Jšœžœ˜J˜™%L˜L˜,L˜%L˜)L˜'L˜L˜ L˜L–Έ[info: ViewerClasses.ViewerRec _ [class: NIL, wx: 0, wy: 0, ww: 0, wh: 0, cx: 0, cy: 0, cw: 0, ch: 0, lock: [process: PROCESS#0B, count: 0B (0)], tipTable: NIL, name: NIL, file: NIL, label: NIL, menu: NIL, icon: 177777B?, column: left, caption: FALSE, scrollable: TRUE, hscrollable: FALSE, iconic: TRUE, border: TRUE, newVersion: FALSE, newFile: FALSE, visible: TRUE, offDeskTop: FALSE, destroyed: FALSE, init: FALSE, saveInProgress: FALSE, inhibitDestroy: FALSE, guardDestroy: FALSE, paintingWedged: FALSE, ...], font: ImagerFont.Font _ NIL, paint: BOOL _ TRUE]˜(šžœžœžœžœžœ7žœžœž˜eL–Έ[info: ViewerClasses.ViewerRec _ [class: NIL, wx: 0, wy: 0, ww: 0, wh: 0, cx: 0, cy: 0, cw: 0, ch: 0, lock: [process: PROCESS#0B, count: 0B (0)], tipTable: NIL, name: NIL, file: NIL, label: NIL, menu: NIL, icon: 177777B?, column: left, caption: FALSE, scrollable: TRUE, hscrollable: FALSE, iconic: TRUE, border: TRUE, newVersion: FALSE, newFile: FALSE, visible: TRUE, offDeskTop: FALSE, destroyed: FALSE, init: FALSE, saveInProgress: FALSE, inhibitDestroy: FALSE, guardDestroy: FALSE, paintingWedged: FALSE, ...], font: ImagerFont.Font _ NIL, paint: BOOL _ TRUE]šœ\žœ˜dLšœ-˜-Lšžœ˜—L˜!L˜L˜šžœžœžœž˜šžœžœžœž˜Lšœžœžœ)˜FL–L[from: REAL, precision: Convert.RealPrecision _ 7, useE: BOOL _ FALSE]šœ#žœžœžœžœ-žœ žœžœyžœžœ žœ˜’Lšžœ˜—Lšžœ˜—L–Ώ[info: ViewerClasses.ViewerRec _ [class: NIL, wx: 0, wy: 0, ww: 0, wh: 0, cx: 0, cy: 0, cw: 0, ch: 0, lock: [process: PROCESS#0B, count: 0B (0)], tipTable: NIL, name: NIL, file: NIL, label: NIL, menu: NIL, icon: 177777B?, column: left, caption: FALSE, scrollable: TRUE, hscrollable: FALSE, iconic: TRUE, border: TRUE, newVersion: FALSE, newFile: FALSE, visible: TRUE, offDeskTop: FALSE, destroyed: FALSE, init: FALSE, saveInProgress: FALSE, inhibitDestroy: FALSE, guardDestroy: FALSE, paintingWedged: FALSE, ...], proc: Buttons.ButtonProc, clientData: REF ANY _ NIL, fork: BOOL _ TRUE, font: ImagerFont.Font _ NIL, documentation: REF ANY _ NIL, guarded: BOOL _ FALSE, paint: BOOL _ TRUE]šœ)žœ˜/L–Ώ[info: ViewerClasses.ViewerRec _ [class: NIL, wx: 0, wy: 0, ww: 0, wh: 0, cx: 0, cy: 0, cw: 0, ch: 0, lock: [process: PROCESS#0B, count: 0B (0)], tipTable: NIL, name: NIL, file: NIL, label: NIL, menu: NIL, icon: 177777B?, column: left, caption: FALSE, scrollable: TRUE, hscrollable: FALSE, iconic: TRUE, border: TRUE, newVersion: FALSE, newFile: FALSE, visible: TRUE, offDeskTop: FALSE, destroyed: FALSE, init: FALSE, saveInProgress: FALSE, inhibitDestroy: FALSE, guardDestroy: FALSE, paintingWedged: FALSE, ...], proc: Buttons.ButtonProc, clientData: REF ANY _ NIL, fork: BOOL _ TRUE, font: ImagerFont.Font _ NIL, documentation: REF ANY _ NIL, guarded: BOOL _ FALSE, paint: BOOL _ TRUE]šœ(žœ˜.Lšœ#žœ˜*L˜L˜ L˜!L˜!L˜&L˜L˜eL˜mL˜dL˜J˜J˜%L˜—Jšœ˜J˜—J˜–L -- [cmd: Commander.Handle] RETURNS [result: REF ANY _ NIL, msg: ROPE _ NIL]š‘œ˜#Lš’H™HL–I[cmd: Commander.Handle, starExpand: BOOL _ FALSE, switchChar: CHAR]˜>Lšžœ žœžœ ˜ Lšžœ žœ5˜LL˜—š œžœ˜L˜\L˜J˜J˜—˜L˜—Jšœ˜——…—!@W