GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
% This file was created automatically from gobject.msk.1% DO NOT EDIT!2\Chapter{Graphic Sheets - Basic graphic operations}34This chapter describes how graphics are accessed in {\XGAP} via the lowest5library functions for graphic sheets. These functions are used in all other6parts of {\XGAP} and you normally only need to know them if you want to7display other things than graphic posets and subgroup lattices.89%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%10\Section{Graphic Sheet Objects}1112To access any graphics in {\XGAP} you first have to create a *graphic*13*sheet* object. Such objects are linked internally to windows on the14screen. You do *not* have to think about redrawing, resizing and other15organizing stuff. The graphic sheet object is a {\GAP} object16in the category `IsGraphicSheet' and should be saved because it is needed17later on for all graphic operations.181920\>GraphicSheet( <title>, <width>, <height> ) O2122creates a graphic sheet with title <title> and dimension <width> by23<height>. A graphic sheet is the basic tool to draw something, it is24like a piece of paper on which you can put your graphic objects, and to25which you can attach your menus. The coordinate $(0,0)$ is the upper26left corner, $(<width>-1,<height>-1)$ the lower right.2728It is possible to change the default behaviour of a graphic sheet by29installing methods (or sometimes called callbacks) for the following30events. In order to avoid confusion with the {\GAP} term ``method'' the31term ``callback'' will be used in the following. For example, to install32the function `MyLeftPBDownCallback' as callback for the left mouse button33down event of a graphic sheet <sheet>, you have to call34`InstallCallback' as follows.3536\begintt37gap> InstallCallback( sheet, "LeftPBDown", MyLeftPBDownCallback );38\endtt3940{\XGAP} stores for each graphic sheet a list of callback keys and a list41of callback functions for each key. That means that when a certain42callback key is triggered for a graphic sheet then the corresponding43list of callback functions is called one function after the other. The44following keys have predefined meanings which are explained below:45`Close', `LeftPBDown', `RightPBDown', `ShiftLeftPBDown',46`ShiftRightPBDown', `CtrlLeftPBDown', `CtrlRightPBDown'.47All of these keys are strings. You can install your own callback48functions for new keys, however they will not be triggered automatically.4950\>Close( <sheet> )!{Callback}5152the function will be called as soon as the user selects ``close graphic53sheet'', the installed function gets the graphic sheet <sheet> to54close as argument.5556\>LeftPBDown( <sheet>, <x>, <y> )5758the function will be called as soon as the user presses the left mouse59button inside the graphic sheet, the installed function gets the60graphic sheet <sheet>, the <x> coordinate and <y> coordinate of the61pointer as arguments.6263\>RightPBDown( <sheet>, <x>, <y> )6465same as `LeftPBDown' except that the user has pressed the right mouse66button.6768\>ShiftLeftPBDown( <sheet>, <x>, <y> )6970same as `LeftPBDown' except that the user has pressed the left mouse71button together with the $SHIFT$ key on the keyboard.7273\>ShiftRightPBDown( <sheet>, <x>, <y> )7475same as `LeftPBDown' except that the user has pressed the right mouse76button together with the $SHIFT$ key on the keyboard.7778\>CtrlLeftPBDown( <sheet>, <x>, <y> )7980same as `LeftPBDown' except that the user has pressed the left mouse81button together with the $CTRL$ key on the keyboard.8283\>CtrlRightPBDown( <sheet>, <x>, <y> )8485same as `LeftPBDown' except that the user has pressed the right mouse86button together with the $CTRL$ key on the keyboard.87888990Here is the documentation for the operations to control the callback91functions:9293\>InstallCallback( <sheet>, <key>, <func> ) O9495Installs a new callback function for the sheet <sheet> for the key <key>.96Note that the old functions for this key are *not* deleted.979899\>RemoveCallback( <sheet>, <func>, <call> ) O100101Removes an old callback. Note that you have to specify not only the102<key> but also explicitly the <func> which should be removed from the103list!104105106\>Callback( <sheet>, <key>, <args> ) O107108Executes all callback functions of the sheet <sheet> that are stored under109the key <func> with the argument list <args>.110111112113Every graphic object in {\XGAP} can be <alive> or not. This is controlled114by the filter `IsAlive'. Being <alive> means that the object can be used115for further operations. If for example the user closes a window by a116mouse operation the corresponding graphic sheet object is no longer117<alive>.118119120\>IsAlive( <gobj> ) F121122This filter controls if a graphic object is <alive>, meaning that it can123be used for further graphic operations.124125126127The following operations apply to graphic sheets:128129\>Close( <sheet> ) O130131The graphic sheet <sheet> is closed which means that the corresponding132window is closed and the sheet becomes <not alive>.133134135\>Resize( <sheet>, <width>, <height> ) O136137The <width> and <height> of the sheet <sheet> are changed. That does *not*138automatically mean that the window size is changed. It may also happen139that only the scrollbars are changed.140141142\>WindowId( <sheet> ) A143144Every graphic sheet has a unique number, its <window id>. This is mainly145used internally.146147148\>SetTitle( <sheet>, <title> ) O149150Every graphic sheet has a title which appears somewhere on the window.151It is initially set via the call to the constructor `GraphicSheet' and152can be changed later with this operation.153154155\>SaveAsPS( <sheet>, <filename> ) O156157Saves the graphics in the sheet <sheet> as postscript into the file158<filename>, which is overwritten, if it exists.159160161\>FastUpdate( <sheet>, <flag> ) O162163Switches the `UseFastUpdate' filter for the sheet <sheet> to the164boolean value of <flag>. If this filter is set for a sheet, the screen165is no longer updated completely if a graphic object is moved or166deleted. You should call `FastUpdate( <sheet>, true )' before you167start large rearrangements of the graphic objects and168`FastUpdate( <sheet>, false )' at the end.169170171172%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%173\Section{Graphic Objects in Sheets}174175All graphics within graphic sheets are so called graphic objects. They176are {\GAP} objects in the category `IsGraphicObject'. These objects are177linked internally to the actual graphics within the window. You can178modify these objects via certain operations which leads to the179corresponding change of the real graphics on the screen. The types of180graphic objects supported in {\XGAP} are: boxes, circles, discs, diamonds,181rectangles, lines, texts, vertices and connections. Vertices are compound182objects consisting of a circle, rectangle oder diamond with a short text183inside. They remember their connections to other vertices. That means184that if for example the position of a vertex is changed, the line which185makes the connection to some other vertex is also changed automatically.186For every graphic object there is a constructor which has the same name187as the graphic object (e.g. `Box' is the constructor for boxes).188189190191\>IsGraphicObject( <gobj> ) C192193This is the category in which all graphic objects are.194195196197\bigskip%198199*Constructors:*200201\>Box( <sheet>, <x>, <y>, <w>, <h> ) O202\>Box( <sheet>, <x>, <y>, <w>, <h>, <defaults> ) O203204creates a new graphic object, namely a filled black box, in the graphic205sheet <sheet> and returns a {\GAP} record describing this object. The206four corners of the box are $(<x>,<y>)$, $(<x>+<w>,<y>)$,207$(<x>+<w>,<y>+<h>)$, and $(<x>,<y>+<h>)$.208209Note that the box is $<w>+1$ pixel wide and $<h>+1$ pixels high.210211If a record <defaults> is given and contains a component `color' of value212<color>, the function works like the first version of `Box', except213that the color of the box will be <color>. See "Color Models" for how214to select a <color>.215216See "operations for graphic objects" for a list of operations217that apply to boxes.218219Note that `Reshape' for boxes takes three parameters, namely the box220object, the new width, and the new height of the box.221222223\>Circle( <sheet>, <x>, <y>, <r> ) O224\>Circle( <sheet>, <x>, <y>, <r>, <defaults> ) O225226creates a new graphic object, namely a black circle, in the graphic sheet227<sheet> and returns a {\GAP} record describing this object. The center228of the circle is $(<x>,<y>)$ and the radius is $<r>$.229230If a record <defaults> is given and contains a component `color' of value231<color>, the function works like the first version of `Circle', except232that the color of the circle will be <color>. See "Color Models" for how233to select a <color>. If the record contains a component `width' of value234<width>, the line width of the circle is set accordingly.235236See "operations for graphic objects" for a list of operations237that apply to circles.238239Note that `Reshape' for circles takes two parameters, namely the circle240object, and the new radius of the circle.241242243\>Disc( <sheet>, <x>, <y>, <r> ) O244\>Disc( <sheet>, <x>, <y>, <r>, <defaults> ) O245246creates a new graphic object, namely a disc (a black filled circle),247in the graphic sheet248<sheet> and returns a {\GAP} record describing this object. The center249of the disc is $(<x>,<y>)$ and the radius is $<r>$.250251If a record <defaults> is given and contains a component `color' of value252<color>, the function works like the first version of `Disc', except253that the color of the disc will be <color>. See "Color Models" for how254to select a <color>.255256See "operations for graphic objects" for a list of operations257that apply to discs.258259Note that `Reshape' for discs takes two parameters, namely the disc260object, and the new radius.261262263\>Diamond( <sheet>, <x>, <y>, <w>, <h> ) O264\>Diamond( <sheet>, <x>, <y>, <w>, <h>, <defaults> ) O265266creates a new graphic object, namely a black diamond, in the graphic sheet267<sheet> and returns a {\GAP} record describing this object. The left268corner of the diamond is $(<x>,<y>)$, the others are $(<x>+<w>,<y>-<h>)$,269$(<x>+<w>,<y>+<h>)$, and $(<x>+2<w>,<y>)$.270271If a record <defaults> is given and contains a component `color' of value272<color>, the function works like the first version of `Diamond', except273that the color of the diamond will be <color>. See "Color Models" for how274to select a <color>. If the record contains a component `width' with275integer value <width>, the line width is set accordingly.276277See "operations for graphic objects" for a list of operations278that apply to diamonds.279280Note that `Reshape' for diamonds takes three parameters, namely the diamond281object, and the new <width> and <height> values.282283284\>Rectangle( <sheet>, <x>, <y>, <w>, <h> ) O285\>Rectangle( <sheet>, <x>, <y>, <w>, <h>, <defaults> ) O286287creates a new graphic object, namely a black rectangle, in the graphic288sheet <sheet> and returns a {\GAP} record describing this object. The289four corners of the box are $(<x>,<y>)$, $(<x>+<w>,<y>)$,290$(<x>+<w>,<y>+<h>)$, and $(<x>,<y>+<h>)$.291292Note that the rectangle is $<w>+1$ pixel wide and $<h>+1$ pixels high.293294If a record <defaults> is given and contains a component `color' of value295<color>, the function works like the first version of `Rectangle',296except297that the color of the rectangle will be <color>. See "Color Models" for298how299to select a <color>. If the record contains a component `width' with300integer value <width>, the line width is set accordingly.301302See "operations for graphic objects" for a list of operations303that apply to rectangles.304305Note that `Reshape' for rectangles takes three parameters, namely the306rectangle object, and the new <width> and <height> values.307308309\>Line( <sheet>, <x>, <y>, <w>, <h> ) O310\>Line( <sheet>, <x>, <y>, <w>, <h>, <defaults> ) O311312creates a new graphic object, namely a black line, in the graphic313sheet <sheet> and returns a {\GAP} record describing this object. The314line has the end points $(<x>,<y>)$ and $(<x>+<w>,<y>+<h>)$.315316If a record <defaults> is given and contains a component `color' of value317<color>, the function works like the first version of `Line', except318that the color of the line will be <color>. See "Color Models" for how319to select a <color>. If the record contains a component `width' with320integer value <width>, the line width is set accordingly. If the record321contains a component `label' with a string value <label>, a text object322is attached as a label to the line.323324See "operations for graphic objects" for a list of operations325that apply to lines.326327Note that `Reshape' for lines takes three parameters, namely the328line object, and the new <w> and <h> value. `Change' for329lines in contrast takes five parameters, namely the line object and all330four coordinates like in the original call.331332333\>Text( <sheet>, <font>, <x>, <y>, <str> ) O334\>Text( <sheet>, <font>, <x>, <y>, <str>, <defaults> ) O335336creates a new graphic object, namely the string <str> as a black text,337in the graphic sheet <sheet> and returns a {\GAP} record describing338this object. The text has the baseline of the first character at339$(x,y)$.340341If a record <defaults> is given and contains a component `color' of value342<color>, the function works like the first version of `Text', except343that the color of the text will be <color>. See "Color Models" for how344to select a <color>.345346See "operations for graphic objects" for a list of operations347that apply to texts.348349Note that `Reshape' for texts takes two parameters, namely the350text object, and the new font. Use `Relabel' to change the string of the351text.352353354355356\bigskip%357358*Operations for graphic objects:*359360\>Connection( <vertex>, <vertex> ) O361\>Connection( <vertex>, <vertex>, <defaults> ) O362363Connects two vertices with a line.364The second variation can get a <defaults> record for the actual line. The365same entries as in the <defaults> record for lines are allowed.366367368\>Disconnect( <vertex>, <vertex> ) O369370Deletes connection between two vertices.371372373374\>Draw( <object> ) O375376This operation (re-)draws a graphic object on the screen. You normally377do not need to call this yourself. But in some rare cases of object378overlaps you could find it useful.379380381\>`Delete( <sheet>, <object> )'{Delete![gobject]}@{`Delete'!`[gobject]'} O382\>`Delete( <object> )'{Delete![gobject]}@{`Delete'!`[gobject]'} O383384Deletes a graphic object. Calls `Destroy' first, so the graphic object385is no more <alive> afterwards. The object is deleted from the list of386objects in its graphic sheet. There is no way to reactivate such an387object afterwards.388389390\>Destroy( <object> ) O391392Destroys a graphic object. It disappears from the screen and will not be393<alive> any more after this call.394Note that <object> is *not* deleted from the list of objects in its395graphic sheet <sheet>.396This makes it possible to `Revive' it again.397In order to delete <object> from <sheet>,398use `Delete( <sheet>, <obj> )', which calls `Destroy' for <obj>.399400401\>Revive( <object> ) O402403Note that <object> must be in the list of objects in its graphic sheet!404So this is only possible for `Destroyed', not405for `Deleted' graphic objects.406407408\>`Move( <object>, <x>, <y> )'{Move![gobject]}@{`Move'!`[gobject]'} O409410Changes the position of a graphic object absolutely. It must be <alive>411and will be moved at once on the screen.412413414\>MoveDelta( <object>, <dx>, <dy> ) O415416Changes the position of a graphic object relatively. It must be <alive>417and will be moved at once on the screen.418419420\>PSString( <object> ) O421422Creates a postscript string which describes the graphic object. Normally423you do not need to call this because it is only used internally if the424user exports the whole graphic sheet to encapsulated postscript.425426427\>PrintInfo( <object> ) O428429This operation prints debugging info about a graphic object.430431432\>`Recolor( <object>, <col> )'{Recolor![gobject]}@{`Recolor'!`[gobject]'} O433434Changes the color of a graphic object. See "Color Models" for how435to select a <color>.436437438\>`Reshape( <object>, ... )'{Reshape![gobject]}@{`Reshape'!`[gobject]'} O439440Changes the shape of a graphic object. The parameters depend on the type441of the object. See the descriptions of the constructors for the actual442usage.443444445\>`\\in'{in!for graphic objects}@{`in'!for graphic objects}446447This infix operation needs a vector of two integers to its left and a graphic448object to its right (``vector of two integers'' means a list of two449integers e.g. `[15,9]'). It determines, if the position given by the two450integer coordinates is inside (e.g. for boxes) or on (e.g. for lines) the451graphic objects. Returns a boolean value.452\>Change( <object>, ... ) O453454Changes the shape of a graphic object. The parameters depend on the type455of the object. See the descriptions of the constructors for the actual456usage.457458459\>`Relabel( <object>, <str> )'{Relabel![gobject]}@{`Relabel'!`[gobject]'} O460461Changes the label of a graphic object. The second argument must always462be a string.463464465\>`SetWidth( <object>, <w> )'{SetWidth![gobject]}@{`SetWidth'!`[gobject]'} O466467Changes the line width of the graphic object. The line width <w> must be468a relatively small integer.469470471\>`Highlight( <vertex> )'{Highlight![gobject]}@{`Highlight'!`[gobject]'} O472\>`Highlight( <vertex>, <flag> )'{Highlight![gobject]}@{`Highlight'!`[gobject]'} O473474In the first form this operation switches the highlighting status of a475vertex to ON. In the second form the <flag> decides about ON or OFF.476Highlighting normally means a thicker line width and a change in color.477478479480%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%481\Section{Colors in XGAP}482483\label{Color Models}484485Depending on the type of display you are using, there may be more or486fewer colors available. You should write your programs always such that487they work even on monochrome displays. In {\XGAP} these differences can488be read off from the so called ``color model''. The global variable489`COLORS' contains all available information.490491492\>`COLORS' V493494The variable `COLORS' contains a list of available colors. If an entry495is `false' this color is not available on your screen. Possible colors496are: `"black"', `"white"', `"lightGrey"', `"dimGrey"', `"red"', `"blue"',497and `"green"'.498499The following example opens a new graphic sheet (see "GraphicSheet"),500puts a black box (see "Box") onto it and changes its color. Obviously501you need a color display for this example.502503\begintt504gap> sheet := GraphicSheet( "Nice Sheet", 300, 300 );505<graphic sheet "Nice Sheet">506gap> box := Box( sheet, 10, 10, 290, 290 );507<box>508gap> Recolor( box, COLORS.green );509gap> Recolor( box, COLORS.blue );510gap> Recolor( box, COLORS.red );511gap> Recolor( box, COLORS.lightGrey );512gap> Recolor( box, COLORS.dimGrey );513gap> Close(sheet);514\endtt515516The component `model' is always a string. It is `monochrome', if the517display does not support colors. It is `gray' if we only have gray shades518and `colorX' if we have colors. The ``X'' can be either 3 or 5, depending519on how many colors are available.520521522523524%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%525\Section{Operations for Graphic Objects}526527The following table gives an overview over the supported graphic objects and528the functions which are applicable respectively:529530Here are the supported graphic object types: `Box', `Circle', `Disc',531`Diamond', `Rectangle', `Line', `Text', `Vertex'.532533These functions apply to all graphic object types:534`Draw', `Delete', `Destroy', `Revive', `Move', `MoveDelta', `PSString',535`PrintInfo', `ViewObj', `Recolor', `Reshape', `\\in', `WindowId'536537In addition, the operation `Relabel' applies to objects of types `Line',538`Text', and `Vertex'; the operation `SetWidth' applies to objects of types539`Diamond', `Rectangle', `Circle', and `Line'. There is also `Change' for a540`Line' and `Highlight' for a `Vertex'.541542543%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%544\Section{Global Information}545546There are some global data structures which can and should be consulted if547certain information is needed. The first (about color handling) was already548described in section "Color Models". The second is for vertices:549550\>`VERTEX'{VERTEX!record}@{`VERTEX'!record} V551552This globally bound record contains the following components:553554\beginitems555`circle' & integer value for the vertex type ``circle''556557`diamond' & integer value for the vertex type ``diamond''558559`rectangle' & integer value for the vertex type ``rectangle''560561`radius' & radius in pixels of a vertex on the screen562563`diameter' & diameter in pixels of a vertex on the screen564\enditems565566\bigskip%567568The third structure is about the available fonts.569570\>`FONTS' V571572This globally bound record has the following components: `tiny', `small',573`normal', `large', `huge' and `fonts'. The first 5 are itself records each574for one available font. They have components `name' for the name of the font575and `fontInfo', which is a list of 3 integers. The first is the maximal size576of a character above the baseline in pixels, the second is the maximal size577of a character below the baseline in pixels, and the third is the width578in pixels of *all* characters, because it is always assumed, that the579fonts are non-proportional.580581\>FontInfo( <font> ) O582583Returns the information about the font <font>. The result is a triple584of integers. The first number is the maximal size585of a character above the baseline in pixels, the second is the maximal size586of a character below the baseline in pixels, and the third is the width587in pixels of *all* characters, because it is always assumed, that the588fonts are non-proportional. Use this function rather than accessing589the component `fontInfo' of a font object directly!590591592593\bigskip%594595There is another global structure:596597\>`BUTTONS' V598599This record contains the following components: `left' and `right' contain a600number for the left resp. right mouse button. `shift' and `ctrl' contain601codes for the respective keys on the keyboard.602603\bigskip%604605You should always use these global data instead of hardwiring any integers into606your code.607608609