Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

open-axiom repository from github

24005 views
1
/*
2
Copyright (C) 1991-2002, The Numerical Algorithms Group Ltd.
3
All rights reserved.
4
Copyright (C) 2007-2010, Gabriel Dos Reis.
5
All rights reserved.
6
7
Redistribution and use in source and binary forms, with or without
8
modification, are permitted provided that the following conditions are
9
met:
10
11
- Redistributions of source code must retain the above copyright
12
notice, this list of conditions and the following disclaimer.
13
14
- Redistributions in binary form must reproduce the above copyright
15
notice, this list of conditions and the following disclaimer in
16
the documentation and/or other materials provided with the
17
distribution.
18
19
- Neither the name of The Numerical Algorithms Group Ltd. nor the
20
names of its contributors may be used to endorse or promote products
21
derived from this software without specific prior written permission.
22
23
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
24
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
26
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
27
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
*/
35
36
#define _VIEWPORT2D_C
37
38
#include <stdio.h>
39
#include <stdlib.h>
40
#include <string.h>
41
#include <unistd.h>
42
#include <math.h>
43
#include <X11/X.h>
44
#include <X11/Xlib.h>
45
#include <X11/Xutil.h>
46
#include <limits.h>
47
48
#include "open-axiom.h"
49
50
#define NotPoint (SHRT_MAX)
51
#define eqNANQ(x) (x == NotPoint)
52
53
#include "header2.h"
54
55
#include "all_2d.H1"
56
#include "Gfun.H1"
57
#include "util.H1"
58
#include "XSpadFill.h"
59
60
#include "spadBitmap.bitmap"
61
#include "spadMask.mask"
62
63
using namespace OpenAxiom;
64
65
#define rint(z) ((int)(z))
66
67
Atom wm_delete_window;
68
69
70
/***************************
71
*** void writeTitle() ***
72
***************************/
73
74
void
75
writeTitle(void)
76
{
77
78
int strlength;
79
XWindowAttributes attribInfo;
80
81
XGetWindowAttributes(dsply,viewport->titleWindow,&attribInfo);
82
if (mono) GSetForeground(anotherGC,(float)foregroundColor,Xoption);
83
else GSetForeground(anotherGC,(float)titleColor,Xoption);
84
XClearWindow(dsply,viewport->titleWindow); /* it's behind the viewWindow */
85
strlength = strlen(viewport->title);
86
GDrawImageString(anotherGC,viewport->titleWindow,
87
centerX(anotherGC,viewport->title,strlength,attribInfo.width),
88
15,viewport->title,strlength,Xoption);
89
90
}
91
92
93
/********************************/
94
/*** void drawTheViewport() ***/
95
/********************************/
96
97
void
98
drawTheViewport(int dFlag)
99
{
100
101
Window vw;
102
XWindowAttributes vwInfo;
103
pointListStruct *aList;
104
pointStruct *aPoint;
105
XPoint *anXPoint,*tempXpt;
106
XArc *anXarc;
107
Vertex *anX10Point;
108
float jj,diffX, diffY, tickStart,oneTickUnit;
109
int i,j,k,ii,halfSize;
110
int charlength,strlength,halflength;
111
int ptX,ptY,ptX1,ptY1,clipped, clipped1;
112
int xAxis,yAxis,dummyInt, ascent, descent;
113
int unitWidth,boxX,boxY,boxW,boxH;
114
char aunit[20];
115
XCharStruct overall;
116
117
drawMore = yes;
118
vw = viewport->viewWindow;
119
XGetWindowAttributes(dsply,vw,&vwInfo);
120
aspectR = (float)vwInfo.width/(float)vwInfo.height;
121
122
XTextExtents(unitFont,"o",1,&dummyInt,&ascent,&descent,&overall);
123
124
/* Calculate various factors for use in projection. */
125
/* Scale the plot, so that the scaling between the axes remains
126
constant and fits within the smaller of the two dimensions. */
127
128
charlength = overall.width;
129
130
if (dFlag==Xoption) XClearWindow(dsply,vw);
131
132
for (i=0; i<maxGraphs; i++) {
133
134
if ((graphArray[i].key) && (graphStateArray[i].showing)) {
135
136
/* Scale y coordinate dimensions relative to viewport aspect ratio. */
137
138
graphArray[i].yNorm = 1.0/((graphArray[i].ymax-graphArray[i].ymin) *
139
aspectR);
140
graphArray[i].originY = -graphArray[i].ymin*graphArray[i].yNorm
141
- 0.5/aspectR;
142
graphArray[i].unitY = graphArray[i].spadUnitY*graphArray[i].yNorm;
143
144
xAxis = rint(vwInfo.width *
145
((graphArray[0].originX - graphStateArray[0].centerX) *
146
graphStateArray[0].scaleX + 0.5));
147
yAxis= rint(vwInfo.height * aspectR *
148
(1 - ((graphArray[0].originY*aspectR -
149
graphStateArray[0].centerY) *
150
graphStateArray[0].scaleY + 0.5*aspectR )));
151
152
if (graphStateArray[i].axesOn) {
153
if (dFlag==Xoption) /* do only for X, ps uses default of black */
154
GSetForeground(globalGC1,
155
(float)monoColor(graphStateArray[i].axesColor),
156
dFlag);
157
158
if ((yAxis >=0) && (yAxis <= vwInfo.height))
159
GDrawLine(globalGC1,vw,
160
0,yAxis,
161
vwInfo.width,yAxis,
162
dFlag);
163
if ((xAxis >=0) && (xAxis <= vwInfo.width))
164
GDrawLine(globalGC1,vw,
165
xAxis,0,
166
xAxis,vwInfo.height,
167
dFlag);
168
}
169
170
171
tempXpt = anXPoint = xPointsArray[i].xPoint;
172
anX10Point = xPointsArray[i].x10Point;
173
anXarc = xPointsArray[i].arc;
174
175
for (j=0,aList=graphArray[i].listOfListsOfPoints;
176
(j<graphArray[i].numberOfLists);
177
j++, aList++) {
178
179
for (k=0,aPoint=aList->listOfPoints;
180
(k<aList->numberOfPoints);
181
k++,aPoint++) {
182
183
if (graphStateArray[i].scaleX > 99.0)
184
graphStateArray[i].scaleX = 99.0;
185
if (graphStateArray[i].scaleY > 99.0)
186
graphStateArray[0].scaleY = 99.0;
187
if (i > 0) {
188
if (isNaN(aPoint->x)) {
189
anXPoint->x = anX10Point->x = NotPoint;
190
}
191
else {
192
diffX = graphArray[i].xmax-graphArray[i].xmin;
193
anXPoint->x = anX10Point->x = vwInfo.width *
194
((aPoint->x * diffX/(graphArray[0].xmax-graphArray[0].xmin)
195
+ (graphArray[0].originX - graphArray[i].originX*diffX /
196
(graphArray[0].xmax-graphArray[0].xmin))
197
- graphStateArray[0].centerX)*graphStateArray[i].scaleX+0.5);
198
}
199
if (isNaN(aPoint->y)) {
200
anXPoint->y = anX10Point->y = NotPoint;
201
}
202
else {
203
diffY = graphArray[i].ymax-graphArray[i].ymin;
204
anXPoint->y = anX10Point->y = vwInfo.height * aspectR *
205
(1 - ((aPoint->y * diffY/(graphArray[0].ymax-graphArray[0].ymin)
206
+ (graphArray[0].originY - graphArray[i].originY* diffY/
207
(graphArray[0].ymax-graphArray[0].ymin))*aspectR
208
- graphStateArray[0].centerY) *
209
graphStateArray[i].scaleY + 0.5*aspectR));
210
}
211
} else {
212
if (isNaN(aPoint->x)) {
213
anXPoint->x = anX10Point->x = NotPoint;
214
}
215
else {
216
anXPoint->x = anX10Point->x = vwInfo.width *
217
((aPoint->x - graphStateArray[i].centerX) *
218
graphStateArray[i].scaleX + 0.5);
219
}
220
if (isNaN(aPoint->y)) {
221
anXPoint->y = anX10Point->y = NotPoint;
222
}
223
else {
224
anXPoint->y = anX10Point->y = vwInfo.height * aspectR *
225
(1 - ((aPoint->y - graphStateArray[i].centerY) *
226
graphStateArray[i].scaleY + 0.5*aspectR));
227
}
228
}
229
230
/* first or last point */
231
if (k == 0 || k == (aList->numberOfPoints - 1)) {
232
anX10Point->flags = 0;
233
} else {
234
anX10Point->flags = VertexCurved;
235
}
236
237
anXPoint++;
238
anX10Point++;
239
anXarc++;
240
} /* for aPoint in pointList */
241
242
aPoint--; /* make it legal, the last one*/
243
if (graphStateArray[i].connectOn || graphStateArray[i].pointsOn) {
244
halfSize = aList->pointSize/2;
245
ptX = tempXpt->x;
246
ptY = tempXpt->y;
247
clipped = ptX > vwInfo.x && ptX < vwInfo.width &&
248
ptY > 0 && ptY < vwInfo.height;
249
if (graphStateArray[i].pointsOn) {
250
if (dFlag==Xoption) {
251
if (mono) {
252
GSetForeground(globalGC1,
253
(float)monoColor((int)(aPoint->hue)),
254
dFlag);
255
} else {
256
GSetForeground(globalGC1,
257
(float)XSolidColor((int)(aPoint->hue),
258
(int)(aPoint->shade)),
259
dFlag);
260
}
261
}
262
if (clipped && !eqNANQ(ptX) && !eqNANQ(ptY))
263
GFillArc(globalGC1,vw,ptX-halfSize,
264
ptY-halfSize,aList->pointSize,aList->pointSize,
265
0,360*64, dFlag);
266
267
} /* if points on */
268
for (ii=0, aPoint=aList->listOfPoints;
269
ii<aList->numberOfPoints;
270
++ii, ++tempXpt, ++aPoint) {
271
ptX1 = tempXpt->x;
272
ptY1 = tempXpt->y;
273
clipped1 = ptX1 > vwInfo.x && ptX1 < vwInfo.width &&
274
ptY1 > 0 && ptY1 < vwInfo.height;
275
if (graphStateArray[i].connectOn) {
276
if (dFlag==Xoption) {
277
if (mono) {
278
GSetForeground(globalGC1,
279
(float)monoColor((int)(aList->lineColor-1)/5),
280
dFlag);
281
} else {
282
GSetForeground(globalGC1,
283
(float)XSolidColor((int)(aList->lineColor-1)/5,
284
(int)((aList->lineColor-1)%5)/2),
285
dFlag);
286
}
287
} /* if X */
288
if ((clipped || clipped1) && !eqNANQ(ptX) && !eqNANQ(ptY) &&
289
!eqNANQ(ptX1) && !eqNANQ(ptY1))
290
GDrawLine(globalGC1,vw,
291
ptX,ptY,ptX1,ptY1,
292
dFlag);
293
} /* if lines on */
294
if (graphStateArray[i].pointsOn) {
295
if (dFlag==Xoption) {
296
if (mono) {
297
GSetForeground(globalGC1,
298
(float)monoColor((int)(aPoint->hue)),
299
dFlag);
300
} else {
301
GSetForeground(globalGC1,
302
(float)XSolidColor((int)(aPoint->hue),
303
(int)(aPoint->shade)),
304
dFlag);
305
}
306
}
307
if (clipped1 && !eqNANQ(ptX1) && !eqNANQ(ptY1))
308
GFillArc(globalGC1,vw,ptX1-halfSize,
309
ptY1-halfSize,aList->pointSize,aList->pointSize,
310
0,360*64, dFlag);
311
} /* if points on */
312
ptX = ptX1; ptY = ptY1; clipped = clipped1;
313
} /* for all points */
314
} /* if points or lines on */
315
316
if (graphStateArray[i].splineOn) { /* need spline color as well */
317
if (dFlag==Xoption) /* do only for X, ps uses default of black */
318
GSetForeground(globalGC1,
319
(float)monoColor(148),
320
dFlag);
321
boxX = vwInfo.width *
322
((-0.5 - graphStateArray[i].centerX)*
323
graphStateArray[i].scaleX + 0.5);
324
boxY = vwInfo.height * aspectR *
325
(1 - ((0.5 - graphStateArray[i].centerY)*
326
graphStateArray[i].scaleY + 0.5*aspectR));
327
328
boxW = graphStateArray[i].scaleX * vwInfo.width + 1;
329
boxH = graphStateArray[i].scaleY * vwInfo.height * aspectR + 1;
330
331
GDrawRectangle(globalGC1,vw,
332
boxX,boxY,boxW,boxH,
333
dFlag);
334
}
335
336
tempXpt = anXPoint;
337
} /* for a aList in listofListsOfPoints */
338
if (graphStateArray[i].unitsOn) {
339
/* do only for X, ps uses default of black */
340
if (dFlag==Xoption)
341
GSetForeground(unitGC,
342
(float)monoColor(graphStateArray[i].unitsColor),
343
dFlag);
344
345
346
tickStart = calcUnitX(0);
347
oneTickUnit = calcUnitX(1) - tickStart;
348
349
/* ticks along the positive X axis */
350
351
unitWidth = 5*overall.width; /* limit on acceptable separation : 5 chars */
352
k = floor(unitWidth/oneTickUnit) +1; /* get skipping integer */
353
for (ii=0, jj = tickStart;
354
jj < vwInfo.width;
355
ii=ii+k,jj =jj+k* oneTickUnit) {
356
if (jj >= 0) {
357
358
/* ticks stuck to viewport*/
359
GDrawLine(unitGC,vw,
360
(int)rint(jj),vwInfo.height-8,(int)rint(jj),vwInfo.height-4,
361
dFlag);
362
363
sprintf(aunit,"%0.3g",ii*graphArray[0].spadUnitX);
364
strlength=strlen(aunit);
365
halflength=XTextWidth(unitFont,aunit,strlength)/2;
366
367
if (dFlag == Xoption) GDrawImageString(unitGC,
368
vw,
369
(int)rint(jj) - halflength,
370
vwInfo.height -8 -descent,
371
aunit,
372
strlength,
373
dFlag);
374
if (dFlag == PSoption) GDrawImageString(unitGC,
375
vw,
376
(int)rint(jj) -(strlength*3) ,
377
vwInfo.height -14,
378
aunit,
379
strlength,
380
dFlag);
381
/* these are "eyeball" parameters for the given PS font */
382
383
}
384
385
}
386
/* ticks along the negative X axis */
387
for (ii=-k,jj=tickStart - k*oneTickUnit;
388
jj > 0;
389
ii=ii-k,jj = jj-k*oneTickUnit) {
390
if (jj <= vwInfo.width) {
391
392
/* ticks stuck to viewport*/
393
GDrawLine(unitGC,vw,
394
(int)rint(jj),vwInfo.height-8,(int)rint(jj),vwInfo.height-4,
395
dFlag);
396
397
sprintf(aunit,"%0.3g",ii*graphArray[0].spadUnitX);
398
strlength=strlen(aunit);
399
halflength=XTextWidth(unitFont,aunit,strlength)/2;
400
401
if (dFlag == Xoption) GDrawImageString(unitGC,
402
vw,
403
(int)rint(jj) - halflength,
404
vwInfo.height -8 -descent,
405
aunit,
406
strlength,
407
dFlag);
408
if (dFlag == PSoption) GDrawImageString(unitGC,
409
vw,
410
(int)rint(jj) -(strlength*3) ,
411
vwInfo.height -14,
412
aunit,
413
strlength,
414
dFlag);
415
/* these are "eyeball" parameters for the given PS font */
416
}
417
}
418
419
tickStart = calcUnitY(0);
420
oneTickUnit = calcUnitY(1) - tickStart;
421
422
/* ticks along the positive Y axis */
423
unitWidth = 2*(ascent+descent); /* limit of acceptable separation */
424
k = floor(unitWidth/fabs(oneTickUnit)) +1; /* get skipping integer */
425
for (ii=0,jj = tickStart;
426
jj > 0;
427
ii=ii+k,jj =jj+k*oneTickUnit ) {
428
if (jj < vwInfo.height) {
429
430
/* ticks stuck to viewport*/
431
/* on the right */
432
/*
433
GDrawLine(unitGC,vw,
434
vwInfo.width-6,(int)rint(jj),
435
vwInfo.width-2,(int)rint(jj),dFlag);
436
*/
437
/* on the left */
438
GDrawLine(unitGC,vw,
439
2,(int)rint(jj),
440
6,(int)rint(jj),
441
dFlag);
442
sprintf(aunit,"%0.3g",ii*graphArray[0].spadUnitY);
443
strlength=strlen(aunit);
444
XTextExtents(unitFont,aunit,strlength,&dummyInt,
445
&ascent,&descent,&overall);
446
halflength=overall.width; /* let's reuse that variable */
447
448
if(dFlag == Xoption){
449
/* on the right */
450
/*
451
GDrawImageString(unitGC, vw,
452
vwInfo.width-halflength -6-descent,
453
(int)rint(jj)+ascent/2 ,
454
aunit, strlength, dFlag);
455
*/
456
/* on the left */
457
GDrawImageString(unitGC, vw,
458
8 + charlength/2,
459
(int)rint(jj)+ascent/2 ,
460
aunit, strlength, dFlag);
461
}
462
if(dFlag == PSoption){
463
/* on the right */
464
/*
465
GDrawImageString(unitGC, vw,
466
vwInfo.width - 6 - (strlength*6),
467
(int)rint(jj)+4,
468
aunit, strlength, dFlag);
469
*/
470
/* on the left */
471
GDrawImageString(unitGC, vw,
472
8,(int)rint(jj)+4,
473
aunit, strlength, dFlag);
474
/* these are "eyeball" parameters for the given PS font */
475
}
476
}
477
}
478
479
/* ticks along the negative Y axis */
480
481
for (ii=(-k),jj = tickStart - k*oneTickUnit;
482
jj < vwInfo.height;
483
ii=ii-k,jj =jj-k*oneTickUnit) {
484
if (jj > 0) {
485
486
/* ticks stuck to viewport*/
487
/* on the right */
488
/*
489
GDrawLine(unitGC,vw,
490
vwInfo.width-6,(int)rint(jj),
491
vwInfo.width-2,(int)rint(jj),
492
dFlag);
493
*/
494
/* on the left */
495
GDrawLine(unitGC,vw,
496
2,(int)rint(jj),
497
6,(int)rint(jj),
498
dFlag);
499
500
sprintf(aunit,"%0.3g",ii*graphArray[0].spadUnitY);
501
strlength=strlen(aunit);
502
XTextExtents(unitFont,aunit,strlength,&dummyInt,
503
&ascent,&descent,&overall);
504
halflength=overall.width; /* let's reuse that variable */
505
506
if(dFlag == Xoption){
507
/* on the right */
508
/*
509
GDrawImageString(unitGC, vw,
510
vwInfo.width-halflength -6-descent,
511
(int)rint(jj)+ascent/2 ,
512
aunit, strlength, dFlag);
513
*/
514
/* on the left */
515
GDrawImageString(unitGC, vw,
516
8 + charlength/2,
517
(int)rint(jj)+ascent/2 ,
518
aunit, strlength, dFlag);
519
}
520
if(dFlag == PSoption){
521
/* on the right */
522
/*
523
GDrawImageString(unitGC, vw,
524
vwInfo.width -6 -(strlength*6),
525
(int)rint(jj)+4 ,
526
aunit, strlength, dFlag);
527
*/
528
/* on the left */
529
GDrawImageString(unitGC, vw,
530
8,
531
(int)rint(jj)+4 ,
532
aunit, strlength, dFlag);
533
/* these are "eyeball" parameters for the given PS font */
534
}
535
}
536
}
537
538
} /* if unitsOn */
539
} /* if graph i exists and is showing */
540
} /* for i in graphs */
541
542
543
if (dFlag==Xoption) {
544
if (!followMouse) {
545
/* no need to do this while autorepeating */
546
makeMessageFromData(queriedGraph);
547
writeControlMessage();
548
}
549
XFlush(dsply);
550
}
551
552
} /* drawViewport() */
553
554
555
556
/************************************
557
*** viewPoints *makeViewport() ***
558
************************************/
559
560
viewPoints *
561
makeViewport(const char* title,int vX,int vY,int vW,int vH,int showCP)
562
{
563
Pixmap spadbits,spadmask;
564
XSetWindowAttributes viewAttrib;
565
XSizeHints titleSizeHints,viewSizeHints;
566
Window viewTitleWindow,viewGraphWindow;
567
XColor foreColor, backColor;
568
569
#ifdef DEBUG
570
fprintf(stderr,"view2D: About to make a viewport\n");
571
#endif
572
573
/* Create a viewport */
574
if (!(viewport = (viewPoints *)malloc(sizeof(viewPoints)))) {
575
fprintf(stderr,"Ran out of memory (malloc) trying to create a viewport.\n");
576
openaxiom_sleep(5);
577
exitWithAck(RootWindow(dsply,scrn),Window,-1);
578
}
579
580
#ifdef DEBUG
581
fprintf(stderr,"view2D: Made a viewport\n");
582
#endif
583
584
strcpy(viewport->title,title);
585
586
viewport->closing = no;
587
viewport->allowDraw = yes; /* just draw axes the first time around */
588
viewport->axesOn = axesON;
589
viewport->unitsOn = unitsON;
590
viewport->pointsOn = pointsON;
591
viewport->linesOn = connectON;
592
viewport->splineOn = splineON;
593
594
/**** Make the windows for the viewport ****/
595
spadbits = XCreateBitmapFromData(dsply,rtWindow,
596
(const char*) spadBitmap_bits,
597
spadBitmap_width,spadBitmap_height);
598
spadmask = XCreateBitmapFromData(dsply,rtWindow,
599
(const char*) spadMask_bits,
600
spadMask_width,spadMask_height);
601
viewAttrib.background_pixel = backgroundColor;
602
viewAttrib.border_pixel = foregroundColor;
603
viewAttrib.override_redirect = overrideManager;
604
viewAttrib.colormap = colorMap;
605
606
foreColor.pixel = foregroundColor;
607
backColor.pixel = backgroundColor;
608
XQueryColor(dsply,colorMap,&foreColor);
609
XQueryColor(dsply,colorMap,&backColor);
610
viewAttrib.cursor = XCreatePixmapCursor(dsply,spadbits,spadmask,
611
&foreColor,&backColor,spadBitmap_x_hot,spadBitmap_y_hot);
612
613
viewAttrib.event_mask = titleMASK;
614
if (vW) {
615
titleSizeHints.flags = PPosition | PSize;
616
titleSizeHints.x = vX;
617
titleSizeHints.y = vY;
618
titleSizeHints.width = vW;
619
titleSizeHints.height = vH;
620
} else {
621
titleSizeHints.flags = PSize;
622
titleSizeHints.width = viewWidth;
623
titleSizeHints.height = viewHeight;
624
}
625
626
viewTitleWindow = XCreateWindow(dsply,rtWindow,vX,vY,vW,vH,
627
viewBorderWidth,
628
CopyFromParent,InputOutput,CopyFromParent,
629
viewportTitleCreateMASK,&viewAttrib);
630
631
wm_delete_window = XInternAtom(dsply, "WM_DELETE_WINDOW", False);
632
(void) XSetWMProtocols(dsply, viewTitleWindow, &wm_delete_window, 1);
633
634
XSetNormalHints(dsply,viewTitleWindow,&titleSizeHints);
635
XSetStandardProperties(dsply,viewTitleWindow,"OpenAxiom 2D",viewport->title,
636
None,NULL,0,&titleSizeHints);
637
638
viewport->titleWindow = viewTitleWindow;
639
viewAttrib.event_mask = viewportMASK;
640
viewSizeHints.flags = PPosition | PSize;
641
viewSizeHints.x = -viewBorderWidth;
642
viewSizeHints.y = titleHeight;
643
viewSizeHints.width = titleSizeHints.width;
644
viewSizeHints.height = titleSizeHints.height -
645
(titleHeight + appendixHeight);
646
viewGraphWindow = XCreateWindow(dsply,viewTitleWindow,
647
viewSizeHints.x,viewSizeHints.y,
648
viewSizeHints.width,viewSizeHints.height,
649
viewBorderWidth,
650
CopyFromParent,InputOutput,CopyFromParent,
651
viewportCreateMASK,&viewAttrib);
652
XSetNormalHints(dsply,viewGraphWindow,&viewSizeHints);
653
XSetStandardProperties(dsply,viewGraphWindow,"2D Viewport","2D Viewport",
654
None,NULL,0,&viewSizeHints);
655
656
viewport->viewWindow = viewGraphWindow;
657
658
/*Make the control panel for the viewport. */
659
viewport->controlPanel = makeControlPanel();
660
if ((viewport->haveControl = showCP)) putControlPanelSomewhere(anywhere);
661
662
XSync(dsply,False);
663
return(viewport);
664
665
}
666
667
668
/*********************************************
669
***** viewPoints *makeView2D(viewdata) ****
670
*********************************************/
671
672
673
viewPoints *
674
makeView2D(view2DStruct *viewdata)
675
{
676
viewPoints *vPoints;
677
678
vPoints = makeViewport(viewdata->title, viewdata->vX,viewdata->vY,
679
viewdata->vW,viewdata->vH,viewdata->showCP);
680
681
vPoints->allowDraw = yes; /* draw everything from now on */
682
683
if (viewdata->showCP) clearControlMessage();
684
685
writeTitle();
686
687
XMapWindow(dsply,vPoints->viewWindow);
688
XMapWindow(dsply,vPoints->titleWindow);
689
XSync(dsply,0);
690
691
drawViewport(Xoption); /* draw viewport with X routines (as opposed to PS) */
692
return(vPoints);
693
694
} /* makeView2D */
695
696
697