From mcvax!prlb2!bernard@uunet.uu.net Sat Jan 28 23:40:02 1989 Date: 27 Jan 89 13:17:45 GMT From: mcvax!prlb2!bernard@uunet.uu.net (Bernard Yves) Subject: NeWSillustrator version 1.0 (part 1 of 5) To: news-makers@brillig.umd.edu Although I do not want to start a software maintenance activity, but due to the many encouraging mails I received and to the very buggy state of the previoulsy posted version, I finally decided to send a new version of NeWSillustrator I finished some times ago. Most of the known bugs have been corrected and the interface has been completely redesigned : it uses the 3 buttons of the mouse and an iconic tool palette. More sophisticated functions have been added for lines and curves edition. Some NeWS bugs (e.g. pointinpath --> unexpected SIGSEV signal) which used to crash the news server have been carefully bypassed. This posting includes a new manual. ----------------------------------------------------------------------------- NeWSillustrator --------------- NeWSillustrator is an object-oriented drawing program completely written in NeWS. It includes various object types with full control on line width, line type, line color, font, font size, color filling... Objects can be moved, scaled, rotated, grouped, copied, edited, clipped, aligned, centered,... Postscript files can be imported (with the limitation of the NeWS postscript interpreter) and generated for printing. Full scrolling and zooming capabilities are available at any time. Graphical input items (e.g. point, angle, ...) can be defined indifferently with the mouse or alphanumerically. Due to the interpreted feature of NeWS Postscript, many functions of NeWSillustrator can be redefined to your convenience and loaded at any time. However, this requires some programming experience with Postscript and NeWS. NeWSillustrator is written in NeWS, a superset of PostScript: NeWS = PostScript (a forth-like language with powerful graphics primitives) + Window Management concepts (events, processes,canvas) + object-oriented extensions (classes, inheritance,...) For those interested, look at the code and expand it as you want. NeWSillustrator runs with Sun NeWS window management system, release 1.1. It requires the existence of two shell variables : HOME and PWD (current directory of the news_server process). Starting. --------- After loading, NeWSillustrator will ask you to shape 3 windows : the Control Panel, the Drawing Area and the Tool Palette. Make them big enough. Place them at your convenience. Mouse Usage. ------------ Most of the input is made with mouse clicks except for text objects. The general functions of the 3 mouse buttons are the following: - Left button (LB) : to make an action such as inputting a point, selecting an object, selecting a control panel item, confirming, selecting a command icon. - Right button (RB) : The right button gives access to the menu associated to the window except for the Drawing Area where it can have various meanings: - in a started command needing an undefined number of clicks, the right button is used to end the click sequence. For instance, during the definition of a polygon the sequence of clicked points is stopped in clicking on the right button. - in a started command with a known number of clicks, the right button is used to abort it. - in some commands (e.g. Select), the right button gives access to the window menu. - Middle button (MB) : used in complex edition operations (e.g. to delete a point) in the Drawing Area. Other baroque usage in the other windows. Tool Selection. ------------------ A tool is selected by clicking with the LB on its icon in the tool palette. The tool layout in the palette is the following: Select Move Align Left Rectangle Rotate Align Down Polyline Scale Align ... Polygon Copy Align ... Curve Move Up Center Vertical RoundedRect Move Down Center ... Oval Delete/Ungroup Repeat Text Destroy Undo Group Edit Import PS Clip A tool is always applied on the current object. The Select tool is used to change the current object. A newly created object always become the current one. The Undo tool is implemented for Delete and Destroy. The Repeat tool repeats the last tool executed. It only works for Copy. This allows to place objects at a regular distance. There is a default tool which is by default Select : any time a command is terminated, the default tool is started. The default tool is changed by selecting a tool with the Middle button. Not all tools can be the default one : only object creation tools and Select. Usually, once a tool is selected, messages are printed in the control panel to explain you what to do and what happened. The message panel item is at the bottom of the control panel. If you don't see it, move or reshape the control panel window. Error messages come in the item item. For all tools and commands requiring file names (e.g. ImportPS,...), enter the name in the corresponding control panel item (e.g. PS file name) BEFORE selecting the command. For file savings, if the file already exists, you will have to confirm: a explanation appears in the message panel. Confirmation is made by clicking anywhere with LB. Commands Menu. ------------- Pressing the RB button in the Tool Palette or the Drawing Area (when the select tool is activated) gives access to the menu of commands associated to the window. The upper part of these menus are filled with the same commands. You can use the Scroll bar to scroll and the Zoom commands in the menu at any time: Zoom In enlarges by a factor 2, Zoom Out by 1/2. The Drawing Area ---------------- This is where the drawing is made. The dashed lines are the sides of the visible area of an A4 sheet on a laser printer. Tools and Commands Descriptions. -------------------------------- Object Creation Tools. ---------------------- These are : Rect, Polyline, Polygon, Curve, RoundedRect, Oval, Text, Group, ImportPS. Rect, RoundedRect, Oval : should be obvious; input points with LB; abort with RB. Line, Polygon: points are input with the Left mouse button. End with the Right mouse button. Use the Middle button to cancel the last input point. Curve : curves are made of Postscript elementary curves which are defined by 4 points. You will be asked to enter a sequence of points, and every time you input 3 points, a elementary curve is drawn connecting the 3 points with the last point of the previous curve. The curve is ended in clicking on the Right button. The middle button deletes the last entered point. With some practice, it is easy to make complex curves with straight segments (input the same control points). Text : The current text in control panel item labelled 'Text String' will follow the cursor in the Drawing Area. Click with the LB to place it, with the RB to abort the command. The text can be edited before placing it in going in the corresponding the item in the Control Panel: just click in the Text String item with the left mouse button and insert text. Text editing is allowed with the DEL, ctrl-f, ctrl-b and ctrl-d keys with the usual emacs meaning. Group : A group is a collection of any objects. A group is defined in two ways: by a box (the default) or by enumeration. The definition mode is changed in clicking in the 'Group Defined by' item of the control panel. by box: just enter a box enclosing completely the objects to group. by enumeration : select each object by clicking on it. End in clicking with the Right button. Cancel the last selected object with the middle button. Objects in a group are not accessible individually : to select an object in a group, you have to delete the group. A group is depicted on the screen by drawing its components and small squares on its enclosing box. A group is selected by clicking in that box. ImportPS : This object type correspond to imported Postscript files. The range of importable files is limited by the NeWS Postscript omissions (fonts, pattern filling,...). PS files produced by Fig seem to work. Of course, PS files generated by NeWSillustrator can be imported. Files which NeWS can not display will cause errors -- see the message in the control panel -- and will be (or should be) refused. Again, before selecting ImportPS, define the PS file to import in the corresponding item in the Control Panel. If the file can be successfully loaded, it will be displayed on the screen and you will be asked to give its bounding box. If nothing has appeared in the Drawing Area, then maybe the drawing is not in the displayed part of the sheet space: use the scroll bars or the zoom out command (by accessing the command menu in pressing RB in the Tool Palette). An imported file is considered as an usual object : it can be moved, copied, rotated, scaled, grouped,... Importation of Postscript file is made by generating an intermediate file in your home directory with the same name as the imported file and ".wps" as extension. These files are not deleted. Edition Tools. -------------- These operations always work on the current selection. To set an object as the current selection use the select command. Select : click in the inside of the object with the LB or MB. NeWSillustrator will select the 'smallest' object found under the clicked point. If it is not the one you want (because of many overlapping objects), move other objects or create a group that you will define by a box enclosing the object you want. Groups are selected by clicking in their enclosing box. Move, Rotate, Scale : obvious; use the RB to abort the operation. Rotation and scaling use the origin point of the object as reference point. The origin point is usually the first point input when defining the object or a corner of the enclosing box. Scale factors and Rotation angles are displayed in the Control Panel. Rotation and scaling of Text is not perfect with some fonts and sizes: this a bug in NeWS 1.1. Copy : makes a copy of the current object. The copy becomes the current object and you have to move it where you want. Move Up, Move Down : the display order defines how objects overlap each other. Move Up and Down change the display order and give full control on overlapping. Move Up (Down) will swap the current object with the next encountered object in the display list which is drawn after (before) it. If you continuously apply Move Up (Down) on an object, it should then become the last (first) displayed object (see the message in the control panel). Delete : delete the current selection. Delete a group but not its components (i.e. ungroup). Destroy : deletes a group AND all its components. Edit : only works for Lines, Polygons, Curves (and Text); allows to move, delete and insert points defining the selected objects. First, select a point by clicking on it with the Left button, move it and click with LB to accept the move or with the RB to cancel it. Delete it with MB. Insert a point in clicking on the line segment where you want to insert it. To stop edition click with the RB. Note that the first point of an item is not editable. For Text, simply correct the text in the 'Text String' Control Panel item. Clip : clip the current selection object with another object which will have to be selected by the user. The clipping object should not be a group, a text or an ImportPS object. The inside of the clipping path is determined by the normal PostScript non-zero winding number rule. A clipped object is implemented as a special kind of group: many operations available on group can be used on clipped object (e.g. delete, destroy). Align Left, Right,..., Center : works for items in a selected group; Drawing Area Menu Commands -------------------------- Redisplay : objects overlapping moved objects are not redrawn when these are moved. Use Redisplay to redraw all the objects and redraw them in the current order. Zoom Operations : Zoom In and Out by a factor 2 ; use the scroll bar to scroll your drawing. Font => Choose the font in the font menu. It will be the default font of newly created text object and the font of the current selection. All the fonts listed are not available on the laser. Also, there are problems with some fonts in NeWS. Font Size => : obvious. Files Operations. The 'Files IO =>' leads to a submenu with files operations. They require the corresponding file name to be defined in the control panel before selecting them. save PS file : generates a Postscript file printable on a laser and importable as an object in NeWSillustrator; save Objects file: save all the objects of the current drawing; load Object file: add all the objects in the file to the current drawing; (Object files can be used as a library) There are two other entries in the file menu: Window Pos. : gives the positions and dimensions of the three windows. See the Customization section. Info : displays a short copyright notice in the Control Panel message item. The generated PostScript files are prefixed with a header string. By default, this header is the standard Adobe starting line. However, for including PS files in other applications (e.g. LaTeX), it is generally useful to have a starting line containing the dimensions of the drawing. There is a switch called '/LatexFile?' that when set to true will generate as first line: % Rotation=0,Width=...,Height=...,Xoff=...,Yoff=... where the dots will be replaced by the adequate values. See the Customization section for setting this switch. Change the format according to your PostScript inclusion facilities of your Latex system in modifying the format string in the source code. Control Panel ------------- There are three main types of Control panel items : text and file name items, drawing parameters items and control items. Drawing parameters Items: -------------------------- They are : line width, style, join, cap, color, fill color, Rounded Corner Radius, line arrow, arrow size. Values of the drawing parameters are those of the current selection. Change of a drawing parameter always affect the current selection. If it is a group, its components will be affected. Use of Sliding items (e.g line color): just click anywhere on the line or drag the cursor to the required value. line color : the gray level from 0 (black) to 100 (white). fill color : idem ; the -1 is used for no fill. Color of text is changed by the line color slide, but in NeWS text is always displayed as black on a monochrome screen. In the Menu associated with the Control Panel, there is the "Set as Default" command which will set the current display parameters as the default ones for newly created objects. Control Items : ---------------- These are: grid size, grid on, snap to grid, group defined by, line quality, click to move, and Message, Values and Error items. Message Item : where message appear. Look at it. Just below it is the Values item, which display mouse coordinates, rotation angle, scaling factor,... Note that coordinates values are labelled according to the fact that they are relative (e.g. the second point of a rectangle is given relatively to the first one) or absolute coordinates. Just below the 'Values' item is the error message item. The line quality controls the rendering quality of NeWS : 0 = low quality but faster, 10 = best quality but slower. Grid Size : the current unit is screen point. Snap To Grid : clicked points will be snapped to the grid. 'Snap To Grid' is independent of the 'Grid On' item, except for the animation mode in interaction which changes whether the grid is on or not. Click To Move : the default mode when you select the Move tool on the current selection is that the object follows the cursor and you click with LB to place it. In Click To Move, you will first have to click an anchor point and then move the object. This is sometimes needed to place objects partly outside the window. File Items: obvious ------------------- For writing operations, if the file already exists, you will have to confirm by clicking on LB. Alphanumeric Input. ------------------- Alphanumeric input is to be used when you want to define accurate geometric informations or when it is physically impossible to define what you want with the mouse (e.g. scaling a big object by 200...) In the lower part of the Control Panel, there is an item labelled 'Data'. At any time where the program is waiting for a mouse click defining a point, an angle or a scaling, you can instead of clicking the mouse, click with LB in this item and type the values you want. The data will be sent after you have pressed the big button labelled 'SendIt'. For instance, if you want to make a circle with a diameter of 100 units, you can type '100 100' in the 'Data' item and 'SendIts' instead of clicking the second point of the oval in the drawing area. If you make an error (e.g. typing error, bad number of arguments), you will be warned by a message. Be careful to send coordinates matching the kind of coordinates the program is awaiting for : relative or absolute. (In general, the first point defining an object is absolute and the other ones are relative to it). User Customization. ------------------- At the end of its loading, before opening all windows, NeWSillustrator will load a file ~/.NeWSillustrator if it exists. In this file, you can write postscript code to change the behavior of NeWSillustrator. This requires some knowledge of NeWS postscript and of the NeWSillustrator code, but many useful customizations can be done by just recopying and modifying to your needs the existing procedures (the complete code of NeWSillustrator is the executable file itself). Here is an example where the following changes and settings are made: the drawing of arrows is changed to filled arrows, the default font to Courrier, the default font size and the crosshair cursor are redefined, the 'dash2' line style is changed, the 'Click To Move' switch is set on, the Move command is redefined, starting positions and dimensions are given for the 3 windows (the 'Window Pos.' options in the file menu will display in the message item the positions and dimensions of all windows), and finally the /LatexFile? switch is set to true console (arrow\n) [] fprintf %useful for debugging %arrow change /drarrow { % size x0 y0 x1 y1 => - ; draws an arrow % at end of seg %this code will be copied in saved postscript files. gsave [] 0 setdash %plain line dup 3 index sub %s x0 y0 x1 y1 yr 2 index 5 index sub atan %s x0 y0 x1 y1 a 3 1 roll %s x0 y0 a x1 y1 translate rotate pop pop %s dup neg dup neg %s -s s moveto 0 0 lineto %s neg dup lineto % stroke fill grestore } def %font and pointsize /FontName /Courier def /pointsize 10 def %crosshair /crosshair { crosshair? {x y 20 sub moveto 0 5 rlineto x y 20 add moveto 0 -5 rlineto x 20 sub y moveto 5 0 rlineto x 20 add y moveto -5 0 rlineto} if } def % plain - dash1 - dash2 /dasharray [ [ [] 0 ] [ [3] 0 ] [ [6 3] 0 ] ] def console (ClickToMove?\n) [] fprintf /ClickToMove? true def %update control panel item value; as CP items are not yet defined, fork %a little process which will do the update after the Control Panel items %will be created { { pause NeWSillustratorDict /Started known {items begin ClickToMove? /ItemValue 1 put /paint ClickToMove? send end exit} if pause pause %let other processes run } loop } fork pop console (Move redefinition\n) [] fprintf %redefines the tool Move to erase the object before moving it. CommandDict /Move get %the Move Tool begin /execproc { /crosshair? true def /erase fapply_on_sel /drag_and_trans fapply_on_sel Abort? {/display fapply_on_sel} if /crosshair? false def /commandswitch [/ClickToMove? ClickToMove?] store } def end console (Window Positions\n) [] fprintf /ControlPanelPosition [600 2 550 476] store /DrawingAreaPosition [15 147 586 671] store /ToolPalettePosition [847 253 302 619] store /LatexFile? true store Making New Tools. ----------------- The menu associated to the Tool Palette contains a 'Make Tool' option. In this distributed version, this is the only interactive extension mechanism. It allows to create a tool template with its icon for which you have to write the adequate NeWS code. A tool is just an icon with some associated code. The icon is in fact a group of objects made with NeWSillustrator. For the code, it is a bit more complicated. The procedure to make a tool is the following: 1. draw its icon (it should be a group) or select an existing group; 2. type in the 'Text String' item of the Control Panel the code of your tool. For instance: { mytoolproc } where my 'mytoolproc' is a Postscript procedure to write. 4. select the 'Make Tool' option in the tool palette menu. 5. Confirm for the code text 6. Position the icon in the tool palette. 7. save the tool in a file 8. edit this file and write the code for /mytoolproc. Example : make a tool with the following code { (CouCou!!) prvalue pause pause} select its icon: 'CouCou!!' will be displayed for a short time in the 'Value' control panel item. Tools can be saved in and loaded from files. Look at the corresponding options in the file menu. Frequently used tools files can be included in your ~/.NeWSillustrator file. Bugs. ---- There are surely many bugs. For instance, there is a bug in saving text objects: if the text contains a '(' opening parenthesis and not the closing one, the saved file (PS or Object) will not be usable. In that case, use you editor and replace the '(' with '\('. Performance. ----------- On my old Sun3/60 -- with its own disk --, performance is quite good. However, on Sun3/50 or others connected to a heavily loaded server, you may have problems, the most irritating one being the lost of mouse clicks due to the slowness of the system. On a Sun3/260, it's a real pleasure. Author ------ Yves Bernard Philips Research Lab, Brussels 2 avenue Van Becelare, 1170 Brussels e-mail: bernard@prlb2.uucp Copyright and Warranty : read the notice in the source file. ---------------------- Date: Thu, 12 Jan 89 11:17:06 EST To: NeWS-makers@brillig.umd.edu Subject: Printing NeWSIllustrator PostScript Files From: sgi!ciemo%bananapc.SGI.COM@ucbvax.Berkeley.EDU (Dave Ciemiewicz) Silicon Graphics (and I believe Sun) uses Adobe's TranScript software for printing text on PostScript printers like the Apple LaserWriter. To print the files generated by Bernard Yves NeWSIllustrator, I've had to add '%!' PostScript magic number to the files by hand. To quote the Red Book (PostScript Language Reference Manual, p. 265, Comment Conventions), The very first line of every PostScript program (whether it is conforming or nonconforming) should be a comment that begins with the characters `%!'. By adding the line in the contextual illustrated in the contextual diff below, NeWSIllustrator will now generate PostScript files with the '%!' magic number allowing users to do things (on SGI boxes) like "lp ps0". *** Old stuff --- New lines with magic number code (don't forget to remove the '+' character) *************** *** 302,307 /PrintPS_header{ %postscript utilities PSfile (/rect {dup 0 exch rlineto exch 0 rlineto neg 0 exch rlineto closepath } def /ovalpath { matrix currentmatrix 5 1 roll --- 302,308 ----- /PrintPS_header{ %postscript utilities + PSfile (%!\n) writestring % PostScript header magic number PSfile (/rect {dup 0 exch rlineto exch 0 rlineto neg 0 exch rlineto closepath } def /ovalpath { matrix currentmatrix 5 1 roll *************** -- ciemo (pronounced SEE-MO) "Language is a virus" Ciemiewicz (pronounced SI-MI-WITZ) --- Laurie Anderson Dave (pronounced DAYV)