Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it

611072 views
1
% This file was created automatically from gobject.msk.
2
% DO NOT EDIT!
3
\Chapter{Graphic Sheets - Basic graphic operations}
4
5
This chapter describes how graphics are accessed in {\XGAP} via the lowest
6
library functions for graphic sheets. These functions are used in all other
7
parts of {\XGAP} and you normally only need to know them if you want to
8
display other things than graphic posets and subgroup lattices.
9
10
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11
\Section{Graphic Sheet Objects}
12
13
To access any graphics in {\XGAP} you first have to create a *graphic*
14
*sheet* object. Such objects are linked internally to windows on the
15
screen. You do *not* have to think about redrawing, resizing and other
16
organizing stuff. The graphic sheet object is a {\GAP} object
17
in the category `IsGraphicSheet' and should be saved because it is needed
18
later on for all graphic operations.
19
20
21
\>GraphicSheet( <title>, <width>, <height> ) O
22
23
creates a graphic sheet with title <title> and dimension <width> by
24
<height>. A graphic sheet is the basic tool to draw something, it is
25
like a piece of paper on which you can put your graphic objects, and to
26
which you can attach your menus. The coordinate $(0,0)$ is the upper
27
left corner, $(<width>-1,<height>-1)$ the lower right.
28
29
It is possible to change the default behaviour of a graphic sheet by
30
installing methods (or sometimes called callbacks) for the following
31
events. In order to avoid confusion with the {\GAP} term ``method'' the
32
term ``callback'' will be used in the following. For example, to install
33
the function `MyLeftPBDownCallback' as callback for the left mouse button
34
down event of a graphic sheet <sheet>, you have to call
35
`InstallCallback' as follows.
36
37
\begintt
38
gap> InstallCallback( sheet, "LeftPBDown", MyLeftPBDownCallback );
39
\endtt
40
41
{\XGAP} stores for each graphic sheet a list of callback keys and a list
42
of callback functions for each key. That means that when a certain
43
callback key is triggered for a graphic sheet then the corresponding
44
list of callback functions is called one function after the other. The
45
following keys have predefined meanings which are explained below:
46
`Close', `LeftPBDown', `RightPBDown', `ShiftLeftPBDown',
47
`ShiftRightPBDown', `CtrlLeftPBDown', `CtrlRightPBDown'.
48
All of these keys are strings. You can install your own callback
49
functions for new keys, however they will not be triggered automatically.
50
51
\>Close( <sheet> )!{Callback}
52
53
the function will be called as soon as the user selects ``close graphic
54
sheet'', the installed function gets the graphic sheet <sheet> to
55
close as argument.
56
57
\>LeftPBDown( <sheet>, <x>, <y> )
58
59
the function will be called as soon as the user presses the left mouse
60
button inside the graphic sheet, the installed function gets the
61
graphic sheet <sheet>, the <x> coordinate and <y> coordinate of the
62
pointer as arguments.
63
64
\>RightPBDown( <sheet>, <x>, <y> )
65
66
same as `LeftPBDown' except that the user has pressed the right mouse
67
button.
68
69
\>ShiftLeftPBDown( <sheet>, <x>, <y> )
70
71
same as `LeftPBDown' except that the user has pressed the left mouse
72
button together with the $SHIFT$ key on the keyboard.
73
74
\>ShiftRightPBDown( <sheet>, <x>, <y> )
75
76
same as `LeftPBDown' except that the user has pressed the right mouse
77
button together with the $SHIFT$ key on the keyboard.
78
79
\>CtrlLeftPBDown( <sheet>, <x>, <y> )
80
81
same as `LeftPBDown' except that the user has pressed the left mouse
82
button together with the $CTRL$ key on the keyboard.
83
84
\>CtrlRightPBDown( <sheet>, <x>, <y> )
85
86
same as `LeftPBDown' except that the user has pressed the right mouse
87
button together with the $CTRL$ key on the keyboard.
88
89
90
91
Here is the documentation for the operations to control the callback
92
functions:
93
94
\>InstallCallback( <sheet>, <key>, <func> ) O
95
96
Installs a new callback function for the sheet <sheet> for the key <key>.
97
Note that the old functions for this key are *not* deleted.
98
99
100
\>RemoveCallback( <sheet>, <func>, <call> ) O
101
102
Removes an old callback. Note that you have to specify not only the
103
<key> but also explicitly the <func> which should be removed from the
104
list!
105
106
107
\>Callback( <sheet>, <key>, <args> ) O
108
109
Executes all callback functions of the sheet <sheet> that are stored under
110
the key <func> with the argument list <args>.
111
112
113
114
Every graphic object in {\XGAP} can be <alive> or not. This is controlled
115
by the filter `IsAlive'. Being <alive> means that the object can be used
116
for further operations. If for example the user closes a window by a
117
mouse operation the corresponding graphic sheet object is no longer
118
<alive>.
119
120
121
\>IsAlive( <gobj> ) F
122
123
This filter controls if a graphic object is <alive>, meaning that it can
124
be used for further graphic operations.
125
126
127
128
The following operations apply to graphic sheets:
129
130
\>Close( <sheet> ) O
131
132
The graphic sheet <sheet> is closed which means that the corresponding
133
window is closed and the sheet becomes <not alive>.
134
135
136
\>Resize( <sheet>, <width>, <height> ) O
137
138
The <width> and <height> of the sheet <sheet> are changed. That does *not*
139
automatically mean that the window size is changed. It may also happen
140
that only the scrollbars are changed.
141
142
143
\>WindowId( <sheet> ) A
144
145
Every graphic sheet has a unique number, its <window id>. This is mainly
146
used internally.
147
148
149
\>SetTitle( <sheet>, <title> ) O
150
151
Every graphic sheet has a title which appears somewhere on the window.
152
It is initially set via the call to the constructor `GraphicSheet' and
153
can be changed later with this operation.
154
155
156
\>SaveAsPS( <sheet>, <filename> ) O
157
158
Saves the graphics in the sheet <sheet> as postscript into the file
159
<filename>, which is overwritten, if it exists.
160
161
162
\>FastUpdate( <sheet>, <flag> ) O
163
164
Switches the `UseFastUpdate' filter for the sheet <sheet> to the
165
boolean value of <flag>. If this filter is set for a sheet, the screen
166
is no longer updated completely if a graphic object is moved or
167
deleted. You should call `FastUpdate( <sheet>, true )' before you
168
start large rearrangements of the graphic objects and
169
`FastUpdate( <sheet>, false )' at the end.
170
171
172
173
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
174
\Section{Graphic Objects in Sheets}
175
176
All graphics within graphic sheets are so called graphic objects. They
177
are {\GAP} objects in the category `IsGraphicObject'. These objects are
178
linked internally to the actual graphics within the window. You can
179
modify these objects via certain operations which leads to the
180
corresponding change of the real graphics on the screen. The types of
181
graphic objects supported in {\XGAP} are: boxes, circles, discs, diamonds,
182
rectangles, lines, texts, vertices and connections. Vertices are compound
183
objects consisting of a circle, rectangle oder diamond with a short text
184
inside. They remember their connections to other vertices. That means
185
that if for example the position of a vertex is changed, the line which
186
makes the connection to some other vertex is also changed automatically.
187
For every graphic object there is a constructor which has the same name
188
as the graphic object (e.g. `Box' is the constructor for boxes).
189
190
191
192
\>IsGraphicObject( <gobj> ) C
193
194
This is the category in which all graphic objects are.
195
196
197
198
\bigskip%
199
200
*Constructors:*
201
202
\>Box( <sheet>, <x>, <y>, <w>, <h> ) O
203
\>Box( <sheet>, <x>, <y>, <w>, <h>, <defaults> ) O
204
205
creates a new graphic object, namely a filled black box, in the graphic
206
sheet <sheet> and returns a {\GAP} record describing this object. The
207
four corners of the box are $(<x>,<y>)$, $(<x>+<w>,<y>)$,
208
$(<x>+<w>,<y>+<h>)$, and $(<x>,<y>+<h>)$.
209
210
Note that the box is $<w>+1$ pixel wide and $<h>+1$ pixels high.
211
212
If a record <defaults> is given and contains a component `color' of value
213
<color>, the function works like the first version of `Box', except
214
that the color of the box will be <color>. See "Color Models" for how
215
to select a <color>.
216
217
See "operations for graphic objects" for a list of operations
218
that apply to boxes.
219
220
Note that `Reshape' for boxes takes three parameters, namely the box
221
object, the new width, and the new height of the box.
222
223
224
\>Circle( <sheet>, <x>, <y>, <r> ) O
225
\>Circle( <sheet>, <x>, <y>, <r>, <defaults> ) O
226
227
creates a new graphic object, namely a black circle, in the graphic sheet
228
<sheet> and returns a {\GAP} record describing this object. The center
229
of the circle is $(<x>,<y>)$ and the radius is $<r>$.
230
231
If a record <defaults> is given and contains a component `color' of value
232
<color>, the function works like the first version of `Circle', except
233
that the color of the circle will be <color>. See "Color Models" for how
234
to select a <color>. If the record contains a component `width' of value
235
<width>, the line width of the circle is set accordingly.
236
237
See "operations for graphic objects" for a list of operations
238
that apply to circles.
239
240
Note that `Reshape' for circles takes two parameters, namely the circle
241
object, and the new radius of the circle.
242
243
244
\>Disc( <sheet>, <x>, <y>, <r> ) O
245
\>Disc( <sheet>, <x>, <y>, <r>, <defaults> ) O
246
247
creates a new graphic object, namely a disc (a black filled circle),
248
in the graphic sheet
249
<sheet> and returns a {\GAP} record describing this object. The center
250
of the disc is $(<x>,<y>)$ and the radius is $<r>$.
251
252
If a record <defaults> is given and contains a component `color' of value
253
<color>, the function works like the first version of `Disc', except
254
that the color of the disc will be <color>. See "Color Models" for how
255
to select a <color>.
256
257
See "operations for graphic objects" for a list of operations
258
that apply to discs.
259
260
Note that `Reshape' for discs takes two parameters, namely the disc
261
object, and the new radius.
262
263
264
\>Diamond( <sheet>, <x>, <y>, <w>, <h> ) O
265
\>Diamond( <sheet>, <x>, <y>, <w>, <h>, <defaults> ) O
266
267
creates a new graphic object, namely a black diamond, in the graphic sheet
268
<sheet> and returns a {\GAP} record describing this object. The left
269
corner of the diamond is $(<x>,<y>)$, the others are $(<x>+<w>,<y>-<h>)$,
270
$(<x>+<w>,<y>+<h>)$, and $(<x>+2<w>,<y>)$.
271
272
If a record <defaults> is given and contains a component `color' of value
273
<color>, the function works like the first version of `Diamond', except
274
that the color of the diamond will be <color>. See "Color Models" for how
275
to select a <color>. If the record contains a component `width' with
276
integer value <width>, the line width is set accordingly.
277
278
See "operations for graphic objects" for a list of operations
279
that apply to diamonds.
280
281
Note that `Reshape' for diamonds takes three parameters, namely the diamond
282
object, and the new <width> and <height> values.
283
284
285
\>Rectangle( <sheet>, <x>, <y>, <w>, <h> ) O
286
\>Rectangle( <sheet>, <x>, <y>, <w>, <h>, <defaults> ) O
287
288
creates a new graphic object, namely a black rectangle, in the graphic
289
sheet <sheet> and returns a {\GAP} record describing this object. The
290
four corners of the box are $(<x>,<y>)$, $(<x>+<w>,<y>)$,
291
$(<x>+<w>,<y>+<h>)$, and $(<x>,<y>+<h>)$.
292
293
Note that the rectangle is $<w>+1$ pixel wide and $<h>+1$ pixels high.
294
295
If a record <defaults> is given and contains a component `color' of value
296
<color>, the function works like the first version of `Rectangle',
297
except
298
that the color of the rectangle will be <color>. See "Color Models" for
299
how
300
to select a <color>. If the record contains a component `width' with
301
integer value <width>, the line width is set accordingly.
302
303
See "operations for graphic objects" for a list of operations
304
that apply to rectangles.
305
306
Note that `Reshape' for rectangles takes three parameters, namely the
307
rectangle object, and the new <width> and <height> values.
308
309
310
\>Line( <sheet>, <x>, <y>, <w>, <h> ) O
311
\>Line( <sheet>, <x>, <y>, <w>, <h>, <defaults> ) O
312
313
creates a new graphic object, namely a black line, in the graphic
314
sheet <sheet> and returns a {\GAP} record describing this object. The
315
line has the end points $(<x>,<y>)$ and $(<x>+<w>,<y>+<h>)$.
316
317
If a record <defaults> is given and contains a component `color' of value
318
<color>, the function works like the first version of `Line', except
319
that the color of the line will be <color>. See "Color Models" for how
320
to select a <color>. If the record contains a component `width' with
321
integer value <width>, the line width is set accordingly. If the record
322
contains a component `label' with a string value <label>, a text object
323
is attached as a label to the line.
324
325
See "operations for graphic objects" for a list of operations
326
that apply to lines.
327
328
Note that `Reshape' for lines takes three parameters, namely the
329
line object, and the new <w> and <h> value. `Change' for
330
lines in contrast takes five parameters, namely the line object and all
331
four coordinates like in the original call.
332
333
334
\>Text( <sheet>, <font>, <x>, <y>, <str> ) O
335
\>Text( <sheet>, <font>, <x>, <y>, <str>, <defaults> ) O
336
337
creates a new graphic object, namely the string <str> as a black text,
338
in the graphic sheet <sheet> and returns a {\GAP} record describing
339
this object. The text has the baseline of the first character at
340
$(x,y)$.
341
342
If a record <defaults> is given and contains a component `color' of value
343
<color>, the function works like the first version of `Text', except
344
that the color of the text will be <color>. See "Color Models" for how
345
to select a <color>.
346
347
See "operations for graphic objects" for a list of operations
348
that apply to texts.
349
350
Note that `Reshape' for texts takes two parameters, namely the
351
text object, and the new font. Use `Relabel' to change the string of the
352
text.
353
354
355
356
357
\bigskip%
358
359
*Operations for graphic objects:*
360
361
\>Connection( <vertex>, <vertex> ) O
362
\>Connection( <vertex>, <vertex>, <defaults> ) O
363
364
Connects two vertices with a line.
365
The second variation can get a <defaults> record for the actual line. The
366
same entries as in the <defaults> record for lines are allowed.
367
368
369
\>Disconnect( <vertex>, <vertex> ) O
370
371
Deletes connection between two vertices.
372
373
374
375
\>Draw( <object> ) O
376
377
This operation (re-)draws a graphic object on the screen. You normally
378
do not need to call this yourself. But in some rare cases of object
379
overlaps you could find it useful.
380
381
382
\>`Delete( <sheet>, <object> )'{Delete![gobject]}@{`Delete'!`[gobject]'} O
383
\>`Delete( <object> )'{Delete![gobject]}@{`Delete'!`[gobject]'} O
384
385
Deletes a graphic object. Calls `Destroy' first, so the graphic object
386
is no more <alive> afterwards. The object is deleted from the list of
387
objects in its graphic sheet. There is no way to reactivate such an
388
object afterwards.
389
390
391
\>Destroy( <object> ) O
392
393
Destroys a graphic object. It disappears from the screen and will not be
394
<alive> any more after this call.
395
Note that <object> is *not* deleted from the list of objects in its
396
graphic sheet <sheet>.
397
This makes it possible to `Revive' it again.
398
In order to delete <object> from <sheet>,
399
use `Delete( <sheet>, <obj> )', which calls `Destroy' for <obj>.
400
401
402
\>Revive( <object> ) O
403
404
Note that <object> must be in the list of objects in its graphic sheet!
405
So this is only possible for `Destroyed', not
406
for `Deleted' graphic objects.
407
408
409
\>`Move( <object>, <x>, <y> )'{Move![gobject]}@{`Move'!`[gobject]'} O
410
411
Changes the position of a graphic object absolutely. It must be <alive>
412
and will be moved at once on the screen.
413
414
415
\>MoveDelta( <object>, <dx>, <dy> ) O
416
417
Changes the position of a graphic object relatively. It must be <alive>
418
and will be moved at once on the screen.
419
420
421
\>PSString( <object> ) O
422
423
Creates a postscript string which describes the graphic object. Normally
424
you do not need to call this because it is only used internally if the
425
user exports the whole graphic sheet to encapsulated postscript.
426
427
428
\>PrintInfo( <object> ) O
429
430
This operation prints debugging info about a graphic object.
431
432
433
\>`Recolor( <object>, <col> )'{Recolor![gobject]}@{`Recolor'!`[gobject]'} O
434
435
Changes the color of a graphic object. See "Color Models" for how
436
to select a <color>.
437
438
439
\>`Reshape( <object>, ... )'{Reshape![gobject]}@{`Reshape'!`[gobject]'} O
440
441
Changes the shape of a graphic object. The parameters depend on the type
442
of the object. See the descriptions of the constructors for the actual
443
usage.
444
445
446
\>`\\in'{in!for graphic objects}@{`in'!for graphic objects}
447
448
This infix operation needs a vector of two integers to its left and a graphic
449
object to its right (``vector of two integers'' means a list of two
450
integers e.g. `[15,9]'). It determines, if the position given by the two
451
integer coordinates is inside (e.g. for boxes) or on (e.g. for lines) the
452
graphic objects. Returns a boolean value.
453
\>Change( <object>, ... ) O
454
455
Changes the shape of a graphic object. The parameters depend on the type
456
of the object. See the descriptions of the constructors for the actual
457
usage.
458
459
460
\>`Relabel( <object>, <str> )'{Relabel![gobject]}@{`Relabel'!`[gobject]'} O
461
462
Changes the label of a graphic object. The second argument must always
463
be a string.
464
465
466
\>`SetWidth( <object>, <w> )'{SetWidth![gobject]}@{`SetWidth'!`[gobject]'} O
467
468
Changes the line width of the graphic object. The line width <w> must be
469
a relatively small integer.
470
471
472
\>`Highlight( <vertex> )'{Highlight![gobject]}@{`Highlight'!`[gobject]'} O
473
\>`Highlight( <vertex>, <flag> )'{Highlight![gobject]}@{`Highlight'!`[gobject]'} O
474
475
In the first form this operation switches the highlighting status of a
476
vertex to ON. In the second form the <flag> decides about ON or OFF.
477
Highlighting normally means a thicker line width and a change in color.
478
479
480
481
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
482
\Section{Colors in XGAP}
483
484
\label{Color Models}
485
486
Depending on the type of display you are using, there may be more or
487
fewer colors available. You should write your programs always such that
488
they work even on monochrome displays. In {\XGAP} these differences can
489
be read off from the so called ``color model''. The global variable
490
`COLORS' contains all available information.
491
492
493
\>`COLORS' V
494
495
The variable `COLORS' contains a list of available colors. If an entry
496
is `false' this color is not available on your screen. Possible colors
497
are: `"black"', `"white"', `"lightGrey"', `"dimGrey"', `"red"', `"blue"',
498
and `"green"'.
499
500
The following example opens a new graphic sheet (see "GraphicSheet"),
501
puts a black box (see "Box") onto it and changes its color. Obviously
502
you need a color display for this example.
503
504
\begintt
505
gap> sheet := GraphicSheet( "Nice Sheet", 300, 300 );
506
<graphic sheet "Nice Sheet">
507
gap> box := Box( sheet, 10, 10, 290, 290 );
508
<box>
509
gap> Recolor( box, COLORS.green );
510
gap> Recolor( box, COLORS.blue );
511
gap> Recolor( box, COLORS.red );
512
gap> Recolor( box, COLORS.lightGrey );
513
gap> Recolor( box, COLORS.dimGrey );
514
gap> Close(sheet);
515
\endtt
516
517
The component `model' is always a string. It is `monochrome', if the
518
display does not support colors. It is `gray' if we only have gray shades
519
and `colorX' if we have colors. The ``X'' can be either 3 or 5, depending
520
on how many colors are available.
521
522
523
524
525
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
526
\Section{Operations for Graphic Objects}
527
528
The following table gives an overview over the supported graphic objects and
529
the functions which are applicable respectively:
530
531
Here are the supported graphic object types: `Box', `Circle', `Disc',
532
`Diamond', `Rectangle', `Line', `Text', `Vertex'.
533
534
These functions apply to all graphic object types:
535
`Draw', `Delete', `Destroy', `Revive', `Move', `MoveDelta', `PSString',
536
`PrintInfo', `ViewObj', `Recolor', `Reshape', `\\in', `WindowId'
537
538
In addition, the operation `Relabel' applies to objects of types `Line',
539
`Text', and `Vertex'; the operation `SetWidth' applies to objects of types
540
`Diamond', `Rectangle', `Circle', and `Line'. There is also `Change' for a
541
`Line' and `Highlight' for a `Vertex'.
542
543
544
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
545
\Section{Global Information}
546
547
There are some global data structures which can and should be consulted if
548
certain information is needed. The first (about color handling) was already
549
described in section "Color Models". The second is for vertices:
550
551
\>`VERTEX'{VERTEX!record}@{`VERTEX'!record} V
552
553
This globally bound record contains the following components:
554
555
\beginitems
556
`circle' & integer value for the vertex type ``circle''
557
558
`diamond' & integer value for the vertex type ``diamond''
559
560
`rectangle' & integer value for the vertex type ``rectangle''
561
562
`radius' & radius in pixels of a vertex on the screen
563
564
`diameter' & diameter in pixels of a vertex on the screen
565
\enditems
566
567
\bigskip%
568
569
The third structure is about the available fonts.
570
571
\>`FONTS' V
572
573
This globally bound record has the following components: `tiny', `small',
574
`normal', `large', `huge' and `fonts'. The first 5 are itself records each
575
for one available font. They have components `name' for the name of the font
576
and `fontInfo', which is a list of 3 integers. The first is the maximal size
577
of a character above the baseline in pixels, the second is the maximal size
578
of a character below the baseline in pixels, and the third is the width
579
in pixels of *all* characters, because it is always assumed, that the
580
fonts are non-proportional.
581
582
\>FontInfo( <font> ) O
583
584
Returns the information about the font <font>. The result is a triple
585
of integers. The first number is the maximal size
586
of a character above the baseline in pixels, the second is the maximal size
587
of a character below the baseline in pixels, and the third is the width
588
in pixels of *all* characters, because it is always assumed, that the
589
fonts are non-proportional. Use this function rather than accessing
590
the component `fontInfo' of a font object directly!
591
592
593
594
\bigskip%
595
596
There is another global structure:
597
598
\>`BUTTONS' V
599
600
This record contains the following components: `left' and `right' contain a
601
number for the left resp. right mouse button. `shift' and `ctrl' contain
602
codes for the respective keys on the keyboard.
603
604
\bigskip%
605
606
You should always use these global data instead of hardwiring any integers into
607
your code.
608
609