Path: utzoo!attcan!uunet!mcvax!prlb2!bernard From: bernard@prlb2.UUCP (Bernard Yves) Newsgroups: comp.windows.news Subject: NeWSillustrator Keywords: graphics, object-oriented, NeWS/DP Message-ID: <518@prlb2.UUCP> Date: 5 Jan 89 14:32:16 GMT Organization: Philips Research Laboratory, Brussels Lines: 273 I am about to post 2 following articles with the complete source code of NeWSillustrator for NeWS 1.1. NeWSillustrator is an object-oriented drawing program (similar to fig or NewsDraw). It includes various object types (lines, polygons, curves, text,...) 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,... Objects can be saved and loaded, Postscript files can be imported (with the limitation of the NeWS postscript interpreter)to be manipulated as objects, and generated for laser printing. Full scrolling and zooming capabilities are available. Contrarly to NewsDraw, NeWSillustrator is entirely written in NeWS: there is no client program written in C or some other traditional language. One will note the equal code size of NeWSillustrator (i.e. 2600 lines of NeWS postscript) and NewsDraw (i.e. 500 lines of NeWS PS and 2000 lines of C) for much greater functionalities in NeWSillustrator. This is partly due to the object-oriented extension of NeWS. And that for the same performance... and with probably a much better readability and flexibility. For me, this raises the following remark : for this kind of application, it is easier to program in NeWS than in C. If I had to write some client program, I will not do it in C, but in higher level languages such as Objective-C or Prolog. Many improvments should be made to NeWSillustrator. The main one would be to replace the very long command menu with an iconic tool window. Try to do it or wait for the next version... I am waiting now for a better NeWS implementation (full Postscript compatible), good NeWS documentation, ...and an equivalent Display Postscript of NeWSillustrator. Manual (draft). -------------- After loading, NeWSillustrator will ask you to shape two windows. Make them big enough. The first one is the Control Panel, the second one is the Drawing Area. 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. The command menu is activated in pressing the right mouse button. In this menu, the available operations are divided in 3 parts : edition operations, object creation operations and finally zoom, font and files operations Usually, once a command 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. For all commands requiring text input or file name (e.g. Text, ImportPS,...), enter the text or name in the corresponding control panel item (e.g. Text String, PS file name) BEFORE selecting the command. Object Creation Operations. --------------------------- These are : Rect, Line, Polygon, Curve, RoundedRect, Oval, Text, Group, ImportPS. For all these operations, you will be asked to input points with the mouse: a point is entered in clicking on any button. When asked for a sequence of points (e.g. line and curve), end the sequence by clicking twice (or double-clicking) on the last point. Once an object is successfuly created, it becomes the current object. Rect, Line, Polygon, RoundedRect, Oval : should be obvious. 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. Text : before selecting this command, first enter the text to draw in the 'Text String' item of 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. Once the text is input, select the text command in the drawing area window menu and position the text at the right place. 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 completly the objects to group. by enumeration : enter the origin point of the group, and then select each object by clicking on it. End in double-clicking on any point. 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 (Sometime, after rotation and scaling the box is not correct). A group is selected by clicking a point 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. 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. Edition Operations. ------------------- 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. NeWSillustrator will select the first 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. 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. Copy : makes a copy of the current object. The copy becomes the new selection and you have to move it where you want. Redisplay : objects overlapping moved objects are not redrawn. Use Redisplay to redraw all the objects and redraw them in the current order. 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. Other => : a submenu of other editing operations: --------- Edit : only works for Lines, Polygons and Curves; allows to move points defining the selected objects. First, select a point by clicking on it and then move it. To stop edition double-click anywhere. Note that the first point of an item is not editable. 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; Zoom Operations : easy ; 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, change 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) Control Panel ------------- There are three 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. Values of the drawing parameters are those of the curent 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. Control Items : grid size, grid on, group defined by, message item, line quality. 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. The grid will be displayed at the next repaint of the Drawing Area Window. File Items : obvious. ---------------------------------------------------------------------------- Yves Bernard Philips Research Lab Brussels, 2 av. Van Becelaere 1170 Brussels, Belgium bernard@prlb2.uucp