PreViewDoc.tioga
Copyright Ó 1988, 1989, 1990, 1992 by Xerox Corporation. All rights reserved.
Written by: Ken Pier, September 4, 1985
Last Edited By: Ken Pier, July 17, 1992 6:07 pm PDT
PreView
PCEDAR 2.0 — FOR INTERNAL XEROX USE ONLY
PreView Tool
Ken Pier
© Copyright 1985, 1987, 1988, 1989, 1990, 1991, 1992 Xerox Corporation. All rights reserved.
Abstract: PreView is a Cedar tool which allows users to open a viewer on any one of several file types: Interpress, RES, and AIS. There is also an option to use three color separation AIS files to get a full color picture. The user may scroll horizontally and vertically on any file page, and may flip through pages of a multi-page file. The user interface is the same for all the file types. PreView also provides interactive scaling, rotation, and cropping of file pages on display, with the option to either write a new Interpress file with the selected contents or to stuff the selected contents directly into a Tioga document in the form of a TiogaArtwork node.
Created by: Ken Pier
Maintained by: Ken Pier <Pier.PARC, Pier:PARC:Xerox>
Keywords: AIS format, artwork, color display, illustration, Imager, Interpress, preview, Raster Encoding Standard, RES format, Tioga documents, Versatec color plotter, viewer
XEROX  Xerox Corporation
   Palo Alto Research Center
   3333 Coyote Hill Road
   Palo Alto, California 94304

For Internal Xerox Use Only
1. Introduction
PreView is a Cedar tool which allows users to open a viewer on any one of several file types: Interpress, RES, and AIS. There is also an option to use three color separation AIS files to get a full color picture. The user may scroll horizontally and vertically on any file page, and may flip through pages of a multi-page file. The user interface is the same for all the file types. PreView also provides interactive scaling, rotation, and cropping of file pages on display, with the option to either write a new Interpress file with the selected contents or to stuff the selected contents directly into a Tioga document in the form of a TiogaArtwork node.
2. Getting Started
Getting a new PreView Tool
Type "PreView [switches] FileList" to the appropriate Commander, where [switches] is an optional set of switches and FileList is a series of file names. Star expansion is no longer provided by the Commander. PreView.command will be executed if this is the first use of PreView in the current session. Long file names with extension (e.g. /User/UserName/SubD/Foo.ip) or short file names with or without extension (e.g. Bar, or Bar.res) may be in the FileList. If the short file name exists in the local context, it will be used. If it does not exist, and has no extension, PreView will attempt to find a local file by attempting the following default file extensions:
ip, Interpress, ais, res, IP
(The user may modify this list of file extensions via a UserProfile option).
PreView uses the text of the file extension only as a hint to determine what file type is in the file; it looks within the file to determine its type. If the file exists and has a compatible type, a new PreView Tool will be opened (left column, iconic) on the file.
UserProfile Options and Switches
Profile Options
The user may modify the list of file extensions via the UserProfile option "PreView.Extensions". For example:
PreView.Extensions: "MyExtension YourExtension InterP PP".
Defaults are PreView.Extensions: "ip ais res interpress IP Interpress".
Switches
Switches are set in the usual way; for example:
Preview -s 11 14 Color400Image.ip -- thermal transfer printer accepts 11 X 14 images
-c => Full Color. Applies only to AIS files, and specifies that the following three file names are to be treated as a triple of color separations in Red, Green, Blue order. Tokens after the three file names will be ignored. Size will be ignored because it is specified in the AIS file. The file names may be short or complete. For example:
PreView -c /Server/User/AIS/My-red.ais /Server/User/AIS/My-green.ais /Server/User/AIS/My-blue.ais
PreView -c /Server/User/AIS/My-red.ais!33 /Server/User/AIS/My-green.ais!33 /Server/User/AIS/My-blue.ais!33
PreView -c /Server/User/AIS/Old-red.ais!L /Server/User/AIS/Old-green.ais!L /Server/User/AIS/Old-blue.ais!L.
The name displayed at the top of the PreViewer will be "/Server/User/AIS/My-*.ais".
-p => Multiple pages. Applies only to AIS and RES files (but not mixed together; only the same file type for every page), and specifies that the FileList is to be treated as a set of pages in a single document. The file names may be short or complete. For example, to view color separations:
PreView -p /Server/User/AIS/My-red.ais /Server/User/AIS/My-green.ais /Server/User/AIS/My-blue.ais
PreView -p /Server/User/AIS/My-red.ais!33 /Server/User/AIS/My-green.ais!33 /Server/User/AIS/My-blue.ais!33
PreView -p /Server/User/AIS/Old-red.ais!L /Server/User/AIS/Old-green.ais!L /Server/User/AIS/Old-blue.ais!L.
The name displayed at the top of the PreViewer will change to the appropriate file name when the file is displayed.
-m => No ImagerMemory. Preview uses a package called ImagerMemory to memorize Imager calls for fast repainting. ImagerMemory is used for Interpress files only. If -m is given, painting will not use ImagerMemory but will be done from scratch each time. For example:
PreView -m /Server/User/Wherever/Weird.ip.
PreView -m -s 10.0 20.0/Server/User/Wherever/FunnySizeWeird.ip.
-s => Size. PreView interprets the next two tokens as (positive) real numbers; the first number is the page size in inches in the X (fast) direction; the second number is the page size in inches in the Y (slow) direction. For example, an 11" by 17" file might do:
PreView -s 11.0 17.0 /Server/User/Me/Color400Image.ip.
The default size is 8.5" x 11".
-v => Versatec. Only should be used for files which were destined for the large Versatec color plotter. PreView will assume a page size of 40" square, instead of the default size of 8.5" x 11". For example:
PreView -v /Server/User/IP/BigColorFile.IP.
3. User Interface
The user interface consists of scrolling, transformation, paging, and output control functions. Scrolling and transformation are provided by the BiScrollers package, while paging and output control are implemented in the tool itself. All functions are nearly self-documenting if you experiment a bit with a PreView Tool.
Scrolling and Transformation Controls
Scrolling and image transformation are provided by the BiScrollers package, which displays two scroll bars in the image viewer and transformation buttons at the top of a PreView Tool.
Scrolling Controls
The BiScrollers vertical scroll bar is at the left of the viewer, and the horizontal scroll bar is at the bottom. They work in a manner analogous to a Tioga scroll bar. Move the cursor into the left edge of the viewer and the vertical scroll bar will appear. Scroll Up, Thumb, and Scroll Down are invoked as usual with left, middle and right mouse buttons respectively, and the scroll bar pattern indicates the percentage of the page that is actually displayed in the viewer. Similarly, move the cursor to the bottom of the viewer to invoke the horizontal scroll bar, which provides Scroll Left, Thumb, and Scroll Right.
Transformation Controls
The transformation buttons at the top of the viewer are:
Scale Rotate Fit Reset Edge Prev
The transformation buttons are PopUpButtons which change the display when invoked. See BiScrollersDoc and PopUpButtonsDoc for information on PopUpButtons. In addition, some of the buttons use the Tioga current selection as argument.
There is no need to memorize click/Shift/CTRL combinations for PopUpButtons. The buttons are self-documenting. Hold down any mouse button with the cursor over a pop-up button and a menu of options will pop up. Then move the cursor over the desired function and release the mouse button. The click/Shift/CTRL combinations are accelerators only.
Scale:
Magnify- scale image by (current selection); defaults to 2.0 if current selection is not a number.
Reset- reset scale to 1.0;
Shrink- scale image by 1.0/(current selection); defaults to 1.0/2.0 if current selection is not a number..
If current selection is not a number, the value 2.0 is used and a message may be flashed in the MessageWindow.
Rotate:
Left- rotate image ccw by (current selection) degrees; defaults to 90.0 if current selection is not a number.
Reset- reset rotation to 0 degrees;
Right- rotate image cw by (current selection) degrees; defaults to 90.0 if current selection is not a number.
Half- rotate image cw by 180
If (current selection) is not a number, the value 90.0 is used and a message may be flashed in the MessageWindow..
Fit:
FitUniformly- scale and translate the image so as to maximize magnification while fitting the entire image in the viewer. Aspect ratio is preserved.
FitXY- scale and translate the image so as to maximize magnification while fitting the entire image in the viewer. Aspect ratio is not preserved.
Reset:
Vanilla- resets all scrolling transformations to their nominal values and moves the image so the upper left corner is in the upper left corner of the viewer. Handy for images containing text.
VanillaAndCenter- reset all scrolling transformations to their nominal values and center the image in the viewer.
Center- center the image in the center of the viewer, preserving transformations.
Edge:
options- see the pop up menu for edge options. Moves the image to align with the chosen edge option.
Prev:
Prev- restores previous tool-to-viewer transformation.
Output, Selection and Paging Controls
Beneath the transformation buttons is another line of PopUpButtons:
Stuff ToIP Selection Page
These PopUpButtons control paging through a multi-page file and creating output from PreView.
There is no need to memorize click/Shift/CTRL combinations. The buttons are PopUpButtons and are self documenting. Hold down any key over the button and a menu of all options will pop up. The click/Shift/CTRL combinations are accelerators only.
Output Controls
Making and Querying a PreView Selection:
Output is controlled by the Stuff and the ToIP buttons, and by the selection rectangle. The user sweeps out a selection by moving the cursor over the viewer (note the crosshairs cursor pattern). When the left mouse button is depressed, PreView will fix one corner of the selection rectangle at the mouse point. A rectangle is then swept out by holding down the left button continuously; note the rubberbanding rectangle as feedback. Once the button is released, the user may change the selection rectangle in the following ways. If the left mouse button is depressed near a corner, then that corner will follow the mouse. If the button is depressed near the center of an edge of the rectangle, then that edge will follow the mouse. If the button is depressed near the center of the rectangle, then the entire rectangle will follow the mouse. The user may at any time cancel the selection by a middle button click in the viewer, or have the selection rectangle printed in the message window by a right button click in the viewer.
The size of the current selection x y w h is shown in the message window and the scaled width and scaled height are shown above the page slider. The units are inches. When the image has been scaled, the x y w h remains unscaled; scaled width and scaled height give the scaled dimensions of the selection.
If the user wishes to determine the size of an area of the original document, he or she should refer to the x y w h values; even if the document is scaled (to permit, for example, closer inspection of the selected area), the x y w h will reflect the size of the selected area of the original document.
The scale factor does, however, apply to the selected area if that area is inserted into a Tioga document (via the Stuff button) or saved to an Interpress file (via the ToIP button); in this case, the size of the selection, as it would appear if printed from the new Interpress or Tioga document, is given by scaled width and scaled height.
After selection, any transformations (e.g. Scale, Rotate, ...) invoked will also be reflected in the selection. It is possible but somewhat counterintuitive to modify the selection after invoking transformations. After setting the desired selection, the output control menu buttons may be invoked.
Stuff:
Stuff causes the image in the (possibly transformed) selection to be converted to a Tioga Artwork node (of type Interpress) and then "stuffed" at the current Tioga caret. To see the image in the Artwork node, execute "ArtworkInterpress on" in a Commander. Stuffing may be done with either the current selection or the whole image, may be done with or without a border, and may be fit to the margins of the Tioga document. Pop up the Stuff button to see the options and accelerators. To perform a stuff, AFTER SELECTING move the input focus (caret) to the Tioga document at the place you want the new stuffed node to go, THEN use the Stuff button.
ToIP:
ToIP causes the image in the (possibly transformed) selection to be written to an Interpress master whose file name is determined as follows:
Suppose that the PreView command was given in a Commander with working directory /tilde/YourName/pics/. Then,
a. If a file with root name Foo has been PreViewed and the Tioga selection is empty when ToIP is invoked, then /tilde/YourName/pics/Foo.ip will be written.
b. If the Tioga selection has the short name "Bar" in it when ToIP is invoked, then /tilde/YourName/pics/Bar.ip will be written.
c. If the Tioga selection has a longer file name like "FooBar.interpress" in it when ToIP is invoked, then /tilde/YourName/pics/FooBar.interpress will be written.
d. If the Tioga selection has a full file name like "/net/server/myspace/pics/Gorp.ip" in it when ToIP is invoked, then /net/server/myspace/pics/Gorp.ip will be written.
In short, the working directory of the Commander when PreView was invoked will be prepended to the file name unless a full file name is selected. ToIP may be done with either the current PreView selection or the whole image. Pop up the ToIP button to see the options and accelerators.
AISPreView and RESPreView are willing to output (Stuff or ToIP) only those pixels within the selection (clipping) rectangle instead of the entire array regardless of clipping. Now, small selections will produce small pixelMaps in the Tioga or IP output file. This can only be done, in general, for pixelMaps. If you have images in other formats which you know in your heart are just pixelMaps, convert them to AIS or RES using InterpressConverters, then clip them using PreView.
Selection:
Center- moves the image so the center of the PreView selection rectangle is in the center of the viewer. Requires a valid PreView selection. See "Making a PreView Selection".
CenterAndFit- moves the image so the center of the PreView selection rectangle is in the center of the viewer, then fits the image so as to maximize magnification while fitting the entire selection in the viewer. Aspect ratio is preserved. Requires a valid PreView selection. See "Making a PreView Selection".
CenterAndScale- moves the image so the center of the PreView selection rectangle is in the center of the viewer, then scales the image so as to maximize magnification without first fitting the entire selection in the viewer. Aspect ratio is preserved. Requires a valid PreView selection. See "Making a PreView Selection".
SelectPage- cancels the current selection and selects the entire page. Useful for finding page boundaries before a ToIP command.
SetSelection- takes the current Tioga selection and tries to parse it into the four numbers to set the selection rectangle to. The numbers should be x y w h, in that order, with no commas between them. The units are inches.
ShowSelection- shows the current selection x y w h in the message window and the scaled width and scaled height above the page slider. The units are inches. When the image has been scaled, the x y w h remains unscaled; scaled width and scaled height give the scaled dimensions of the selection.
N.B. The current implementations of clipping in the imaging contexts used by Stuff and ToIP for Interpress masters do no culling or filtering. That means that even though a small selection is made to be copied, the entire page plus the clipping commands will appear in the output node or IP Master. This will be remedied as soon as culling or filtering contexts are implemented by the Imager.
Paging Controls
To the right of the Page button is a small Tioga viewer labeled AtPage: in which the current page number is displayed. To the right of the current page number viewer is a slider; put the cursor in the slider and hold the left mouse button down to "thumb" through the pages of the document. The current page number viewer will change dynamically to indicate the page number that will become the currently displayed page if you release the left button.
The Page PopUpButton changes the display when invoked by the mouse buttons outlined below.
Page:
TurnForward- causes the next page of the document to become the currently displayed page;
TurnBackward- causes the previous page of the document to become the currently displayed page.
FirstPage- causes the first page of the document to become the currently displayed page.
LastPage- causes the last page of the document to become the currently displayed page.
FromTiogaSelection- causes the page number in the Tioga selection to become the currently displayed page.
4. Programmer's Interface
PPreViewClient.Mesa has some public procedures:
WhichFileType: PROC [fileName: Rope.ROPE, mustBe: PPreView.FileType]
RETURNS [PPreView.FileInfo];
Return information regarding the named file.
CreatePreViewer: PROC [
fileNames: NameList,
switches: Switches,
xSize, ySize: REAL,
mustBe: PPreView.FileType ← ip]
RETURNS [preViewer: ViewerClasses.Viewer];
Return a container that includes all Viewers and BiScrollers necessary for PreView operation.
CreatePreViewerFromData: PROC [data: PPreView.Data, versionSpecified: BOOL]
RETURNS [ViewerClasses.Viewer];
Return a container that includes all Viewers and BiScrollers necessary for PreView operation.
GetTransformation: PROC [v: ViewerClasses.Viewer] RETURNS [Imager.Transformation];
Return the transformation associated with the viewer.
GetTransformedRect: PROC [data: PPreView.Data, v: ViewerClasses.Viewer]
RETURNS [Imager.Rectangle];
Returned the transformed BiScroller rectangle.
ShowSelection: PROC [data: PPreView.Data, v: ViewerClasses.Viewer];
Show the current selection in the message window and the Preview control area.
PPreView.mesa should be considered private to the implementation.
5. Helpful hints
Scrolling transformations are not affected by page turning; if you turn a page and it doesn't display to your liking, try the Vanilla option in the Reset button and go from there.
Once you have invoked a time consuming operation, don't pass the mouse through a BiScrollers scroll bar. Since those bars are themselves implemented as viewers, that will result in locking the cursor and the viewer columns for the duration of the painting of that PreViewer.
The first time a PreViewer is painted may go slowly due to remote file access, setting up internal data structures, building pixel maps, font cache filling, and image memorizing. Scaling and rotating will also cause font caching activity the first time they are invoked. Subsequent paintings will be faster.
Patience is a virtue.