1
/*===========================================================================
2
Copyright (C) 1993-2009 European Southern Observatory (ESO)
4
This program is free software; you can redistribute it and/or
5
modify it under the terms of the GNU General Public License as
6
published by the Free Software Foundation; either version 2 of
7
the License, or (at your option) any later version.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public
15
License along with this program; if not, write to the Free
16
Software Foundation, Inc., 675 Massachusetts Ave, Cambridge,
19
Correspondence concerning ESO-MIDAS should be addressed as follows:
20
Internet e-mail: midas@eso.org
21
Postal address: European Southern Observatory
22
Data Management Division
23
Karl-Schwarzschild-Strasse 2
24
D 85748 Garching bei Muenchen
26
===========================================================================*/
28
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
30
.PURPOSE Takes care of opening and closing graphics devices
31
.AUTHOR R.M. van Hees IPG-ESO Garching
32
.KEYWORDS High level plot interface
34
.COMMENTS holds PCOPEN and PCCLOS
35
.ENVIRONment MIDAS and AGL
36
#include <agl.h> Prototypes for AGL application programs
37
#include <osparms.h> Symbols used by the OS interfaces
38
#include <plot_def.h> Symbols used by the PLT interfaces
39
#include <midas_def.h> Prototypes for MIDAS interfaces
41
.VERSION 1.0 23-Sep-1993 FORTRAN --> C RvH
44
------------------------------------------------------------*/
46
* Define _POSIX_SOURCE to indicate
47
* that this is a POSIX program
49
#define _POSIX_SOURCE 1
52
* definition of the used functions in this module
59
#include <midas_def.h>
62
* define some macros and constants
68
#define FATAL 1 /* error status FATAL */
70
#define MAXDEV 10 /* maximum number of different devices */
71
#define MAXLEN 80 /* maximum length of device name */
73
/* The routine PCOPEN makes use of several static functions.
74
* They are used according to the following scheme:
76
* graphic display PCOPEN image display
80
* <-------- ---------->
94
* definition of struct dev, containing device name and AGL ID-number
106
/*++++++++++++++++++++++++++++
108
.PURPOSE get logical device name for current graphics window
109
on both workstations and terminals
110
input: char *kname: type of device
111
output: char *lname: logical name of device
113
.COMMENTS The length of the file AGL3CONFIG:agldevs.dat, also
114
defines the number of supported graphics devices.
115
This number should consist with the number of devices
116
declared in the file PLTDEV.INC
117
static function also defined in low level routine GETDEV
118
------------------------------*/
120
static int PCDEV( char *kname, char *lname )
122
static int PCDEV( kname, lname )
128
char devnam[84], *strtest;
130
char *pldev = "AGL3CONFIG:agldevs.dat",
131
*err_opn = "*** FATAL: PCDEV, Cannot open file with device definitions";
134
/* get rid of trailing blanks */
136
(void) strtok( kname, " " );
140
/* read from AGLDEVS.dat */
142
if ( (fid = CGN_OPEN( pldev, READ )) == -1 ) SCETER( 1, err_opn );
145
/* keyword conversion or user input conversion */
147
if ( strncmp( kname+1, "_", 1 ) == 0 )
148
strtest = kname+2; /*full device name*/
150
strtest = kname; /*normal device name*/
153
while ( ! found && ( osaread( fid, devnam, MAXLEN )) >= 0 )
154
{ if ( ! (*devnam == '#') )
155
{ if ( ! strncmp( devnam, "unknown", 7 ) )
156
{ (void) strcpy( lname, "unknown" );
160
{ (void) strtok( devnam, ":");
161
if ( strcmp( strtest, devnam ) == 0 )
162
{ (void) strcpy( lname, strtest );
169
(void) osaclose(fid);
171
if ( found == FALSE )
173
SCTPUT( "*** FATAL: PCDEV, Cannot find device definition" );
184
/*+++++++++++++++++++++++++++++++
186
.PURPOSE find and write viewport CLIP values, on graphics display
187
input: int plmode : plot mode
188
char *device: name of plotting device
189
output: float *clpl : clip limits
190
.COMMENTS static function
191
-------------------------------*/
193
static void GRPCLP( int plmode, char *device, float *clpl )
195
static void GRPCLP( plmode, device, clpl )
201
int actvals, xy, qdszy[2], knul, unit ;
203
float aspect, xmxcl, maxcl[PLDIM2], devmm[PLDIM2], dval[PLDIM2],
204
frmwc[PLDIM2], frmcl[PLDIM2], frmmm[PLDIM2],
205
offset[PLDIM2], offusr[PLDIM2], scale[PLDIM3],
206
scusr[PLDIM2], wndl[4];
208
char frame[5], cmnd[21], text[81], *offcoo[2], *scacoo[2],
209
*errmmoff[PLDIM2], *errscoff[PLDIM2], *errnooff[PLDIM2],
210
*errmmsca[PLDIM2], *errscsca[PLDIM2], *errnosca[PLDIM2],
213
char *errtrm = "*** FATAL: (GRPCLP) terminal unknown to system",
214
*errmin = " smallest possible scale:%13.6g units/mm",
215
*errlarge = " largest possible size: %6.1f mm";
217
errmmoff[0] = "*** FATAL: maximum offset in x: %6.1f mm";
218
errmmoff[1] = "*** FATAL: maximum offset in y: %6.1f mm";
219
errscoff[0] = "*** FATAL: maximum offset in x: %6d screen pixels";
220
errscoff[1] = "*** FATAL: maximum offset in y: %6d screen pixels";
221
errnooff[0] = "*** FATAL: norm. offset in x must be between 0 and 1";
222
errnooff[1] = "*** FATAL: norm. offset in y must be between 0 and 1";
224
errmmsca[0] = "*** FATAL: maximum axis size in x: %6.1f mm";
225
errmmsca[1] = "*** FATAL: maximum axis size in y: %6.1f mm";
226
errscsca[0] = "*** FATAL: maximum axis size in x: %6d screen pixels";
227
errscsca[1] = "*** FATAL: maximum axis size in y: %6d screen pixels";
228
errnosca[0] = "*** FATAL: norm.axis size in x must be between 0 and 1";
229
errnosca[1] = "*** FATAL: norm.axis size in y must be between 0 and 1";
231
errsiz[0] = "*** FATAL: plot too large in x direction";
232
errsiz[1] = "*** FATAL: plot too large in y direction";
234
PCKRDR( "XWNDL", 4, &actvals, wndl );
235
frmwc[0] = (float) fabs( *(wndl+1) - *wndl );
236
PCKRDR( "YWNDL", 4, &actvals, wndl );
237
frmwc[1] = (float) fabs( *(wndl+1) - *wndl );
239
for ( xy = 0; xy < PLDIM2; xy++ ) offcoo[xy] = osmmget(5);
240
for ( xy = 0; xy < PLDIM2; xy++ ) scacoo[xy] = osmmget(5);
243
* get terminal characteristics, if failed exit
245
if ( ( AG_RGET( "ASPE", &aspect ) != 1 ) || ( AG_RGET( "DEVD", dval ) != 2 ) )
247
for ( xy = 0; xy < PLDIM2; xy++ ) devmm[xy] = 10 * dval[xy];
250
* determine scaling parameters
252
(void) SCKGETC( "MID$CMND", 1, 20, &actvals, cmnd );
253
if ( plmode != 2 || strncmp( QUAL, "AXES", 4 ) == 0 )
259
else /* plot mode equals 2 */
267
* read the x and Y coordinate unit for x and y offset
269
PCKRDR( "XOFF", 1, &actvals, offusr );
270
PCKRDR( "YOFF", 1, &actvals, offusr+1 );
271
PCKRDC( "CXOF", 4, &actvals, offcoo[0] );
272
PCKRDC( "CYOF", 4, &actvals, offcoo[1] );
273
PCKRDR( "OFFS", 2, &actvals, offset );
275
for ( xy = 0; xy < PLDIM2; xy++ )
279
if ( strncmp( offcoo[xy], "MM", 2 ) == 0 )
280
{ offset[xy] = MYMAX( offusr[xy], offset[xy] );
281
if ( offset[xy] + 999 > PLT_EPS )
282
{ if ( offset[xy] > devmm[xy] )
283
{ (void) sprintf( text, errmmoff[xy], devmm[xy] );
288
clpl[0] = offset[0] / devmm[0];
290
clpl[2] = offset[1] / devmm[1];
295
* set offset in screen coordinates
297
else if ( strncmp( offcoo[xy], "SC", 2 ) == 0 )
298
{ (void) SCKRDI( "IDIDEV", 32, 2, &actvals, qdszy, &unit, &knul);
299
if ( offset[xy] > qdszy[xy] )
300
{ (void) sprintf( text, errscoff[xy], qdszy[xy] );
306
clpl[0] = offset[0]/qdszy[0];
308
clpl[2] = offset[1]/qdszy[1];
312
* set offset in normlized coordinates
314
else if ( strncmp( offcoo[xy], "NO", 2 ) == 0 )
315
{ if ( offset[xy] < 0.0 || offset[xy] > 1.0 )
316
{ (void) strcpy(text, errnooff[xy]);
328
* else we assume mm offset
332
{ offset[xy] = MYMAX( offusr[xy], offset[xy] );
333
if ( offset[xy] + 999 > PLT_EPS )
334
{ if ( offset[xy] > devmm[xy] )
335
{ (void) sprintf( text, errmmoff[xy], devmm[xy] );
340
clpl[0] = offset[0] / devmm[0];
342
clpl[2] = offset[1] / devmm[1];
348
* X and Y scaling and position:
350
PCKRDC( "FRAME", 4, &actvals, frame );
351
PCKRDR( "XSCA", 1, &actvals, scusr );
352
PCKRDR( "YSCA", 1, &actvals, scusr+1 );
353
PCKRDC( "CXSC", 4, &actvals, scacoo[0] );
354
PCKRDC( "CYSC", 4, &actvals, scacoo[1] );
355
PCKRDR( "SCAL", 3, &actvals, scale );
357
for ( xy = 0; xy < PLDIM2; xy++ )
359
* scale via command line or preset
361
{if ( fabs( scale[xy] ) > PLT_EPS )
362
{ if ( ( strncmp( scacoo[xy], "MM", 2 ) == 0 )
363
|| ( scale[xy] < 0.0 ) ) /* scale in mm. or in neg. numbers*/
364
{ if ( fabs(scale[xy]) > devmm[xy] )
365
{ (void) sprintf( text, errmmsca[xy], devmm[xy] );
369
frmmm[xy] = (float) fabs( scale[xy]); /*viewport size*/
372
else if ( strncmp( scacoo[xy], "SC", 2 ) == 0 ) /*screen. coord.*/
373
{ (void) SCKRDI( "IDIDEV", 32, 2, &actvals, qdszy, &unit, &knul);
374
if ( scale[xy] > qdszy[xy] )
375
{ (void) sprintf( text, errscsca[xy], qdszy[xy] );
379
frmmm[xy] = scale[xy]/qdszy[xy]*devmm[xy]; /*viewport size*/
383
else if ( strncmp( scacoo[xy], "NO", 2 ) == 0 ) /*norm.coord*/
384
{ if ( scale[xy] < 0.0 || scale[xy] > 1.0 )
385
{ (void) strcpy(text, errnosca[xy]);
389
frmmm[xy] = scale[xy]*devmm[xy];
393
else /*scale in wo per mm*/
394
frmmm[xy] = fabs( frmwc[xy]/scale[xy] );
397
frmcl[xy] = (float) fabs(frmmm[xy]/devmm[xy]);
403
else if ( fabs( scusr[xy]) > PLT_EPS )
404
{ if ( scusr[xy] < 0.0 ) /*scale in mm*/
405
frmmm[xy] = (float) fabs( scusr[xy] ); /*viewport size*/
407
frmmm[xy] = frmwc[xy] / scusr[xy]; /*scale in wo/mm*/
408
frmcl[xy] = (float) fabs( frmmm[xy] / devmm[xy]); /*norm.view size*/
411
else /*no scale given; use default*/
413
{ if ( strncmp( frame, "SQ", 2 ) == 0 )
415
clpl[1] = clpl[0] + aspect* (clpl[3] - clpl[2]);
416
if ( clpl[1] > xmxcl )
418
clpl[2] = clpl[3]-(clpl[1]-clpl[0])/aspect;
421
frmcl[xy] = clpl[1] - clpl[0];
422
frmmm[xy] = devmm[xy] * frmcl[xy];
425
{ frmcl[xy] = clpl[3] - clpl[2];
426
frmmm[xy] = devmm[xy] * frmcl[xy];
431
maxcl[xy] = clpl[1] - clpl[0];
433
maxcl[xy] = clpl[3] - clpl[2];
438
if ( frmcl[xy] > maxcl[xy]+0.01 &&
439
strncmp( device, "VERSATEC", 8 ) != 0 )
440
{ if ( scale[xy] < 0.0 )
441
(void) sprintf( text, errlarge, maxcl[xy] * devmm[xy] );
443
(void) sprintf( text, errmin, frmwc[xy]/( maxcl[xy] * devmm[xy]));
444
SCTPUT( errsiz[xy] );
447
else /* size is ok */
449
clpl[1] = clpl[0] + frmcl[xy];
451
{ if ( fabs( offset[1] + 999 ) > PLT_EPS )
452
clpl[3] = clpl[2] + frmcl[xy];
454
clpl[2] = clpl[3] - frmcl[xy];
459
for ( xy = 0; xy < PLDIM2; xy++ )
460
scale[xy] = (float) fabs( frmwc[xy]/frmmm[xy]);
462
PCKWRR( "SCAL", 2, scale ); /*store scale*/
463
PCKWRR( "CLPL", 4, clpl ); /*store clip values*/
465
for ( xy = 0; xy < PLDIM2; xy++ ) osmmfree(offcoo[xy]);
466
for ( xy = 0; xy < PLDIM2; xy++ ) osmmfree(scacoo[xy]);
475
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
477
.PURPOSE Get name of frame displayed on current active display channel
479
.RETURNS 0 = o.k., else nothing loaded into channel
480
.COMMENTS static function, also defined in PLOTAXES
481
------------------------------------------------------------*/
483
static int GETFRAME( char *frame )
485
static int GETFRAME( frame )
493
/* get the name of the frame loaded in the current image display */
495
(void) SCKGETC("IDIMEMC",1,80,&iav,frame);
497
if (truelen(frame) == 0)
507
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
509
.PURPOSE converts world coordinates to screen pixels
510
input: float *wcpix: pixel in world coordimates
511
output: float *scpix: pixel in screen coordinates
512
.COMMENTS static function
513
------------------------------------------------------------*/
515
static void WC2PIX( float *wcpix, float *scpix )
517
static void WC2PIX( wcpix, scpix )
518
float *wcpix, *scpix;
521
int iac, imf, knul, qdszy, dzmemi[13], unit;
522
float cx, cy, imgpix[2];
523
double start[2], step[2];
526
char *err_fram = "*** FATAL: no frame loaded in the display channel";
529
* get the name of the loaded frame and it's characteristics
531
if ( GETFRAME( frame ) != 0 ) SCETER( 1, err_fram );
532
(void) SCFOPN( frame, D_R4_FORMAT, 0, F_IMA_TYPE, &imf );
533
(void) SCDRDD( imf, "START", 1, PLDIM2, &iac, start, &unit, &knul );
534
(void) SCDRDD( imf, "STEP" , 1, PLDIM2, &iac, step , &unit, &knul );
535
(void) SCFCLO( imf );
538
* get display parameters
540
(void) SCKRDI( "IDIMEMI", 1, 13, &iac, dzmemi, &unit, &knul);
541
(void) SCKRDI( "IDIDEV", 3, 1, &iac, &qdszy, &unit, &knul);
544
* calculate image pixel
546
imgpix[0] = (float) ((wcpix[0] - start[0])/step[0] + 1);
547
imgpix[1] = (float) ((wcpix[1] - start[1])/step[1] + 1);
550
* take care of one real pixel + scaling
553
cx = - (imgpix[0] - (float) SFPX ) * (float) SCALX;
555
cx = (imgpix[0] - (float) SFPX ) / (float) SCALX;
559
cy = - (imgpix[1] - (float) SFPY ) * (float) SCALY;
561
cy = (imgpix[1] - (float) SFPY ) / (float) SCALY;
564
scpix[0] = ( cx - SCROLX ) * ZOOMX;
565
scpix[1] = ( cy - SCROLY ) * ZOOMY + qdszy - 1;
574
/*++++++++++++++++++++++++++++++
576
.PURPOSE find and write viewport CLIP values, on image display
577
output: float *clpl : clip limits
578
.COMMENTS static function
579
--------------------------------*/
581
static void DISCLP( float *clpl )
583
static void DISCLP( clpl )
587
int actvals, imf, knul, unit, xy, scale[PLDIM2], scrpx[PLDIM2];
589
float frmmm[PLDIM2], frmpx[PLDIM2], offmm[PLDIM2], wcpix1[PLDIM2],
590
wndl[8], scpix1[PLDIM2], scpix2[PLDIM2], wcpix2[PLDIM2];
594
char *err_fram = "*** FATAL: no frame loaded in the display channel";
597
* get the name of the loaded frame and it's characteristics
599
if ( GETFRAME( frame ) != 0 ) SCETER( 1, err_fram );
600
(void) SCFOPN( frame, D_R4_FORMAT, 0, F_IMA_TYPE, &imf );
601
(void) SCDRDD( imf, "STEP" , 1, PLDIM2, &actvals, step , &unit, &knul );
602
(void) SCFCLO( imf );
605
* get display parameters
607
(void) SCKRDI( "IDIDEV", 2, 2, &actvals, scrpx, &unit, &knul);
608
(void) SCKRDI( "IDIMEMI", 8, 2, &actvals, scale, &unit, &knul);
611
* do pixel convertion
613
PCKRDR( "XWNDL", 2, &actvals, wndl );
614
PCKRDR( "YWNDL", 2, &actvals, wndl+2 );
616
wcpix1[0] = (float) (wndl[0] + step[0]/2.0);
617
wcpix1[1] = (float) (wndl[2] + step[1]/2.0);
618
wcpix2[0] = (float) (wndl[1] + step[0]/2.0);
619
wcpix2[1] = (float) (wndl[3] + step[1]/2.0);
622
wcpix1[0] = (float) (wndl[0]);
623
wcpix1[1] = (float) (wndl[2]);
624
wcpix2[0] = (float) (wndl[1]);
625
wcpix2[1] = (float) (wndl[3]);
627
WC2PIX( wcpix1, scpix1 );
628
WC2PIX( wcpix2, scpix2 );
631
* make the box 1/2 pixel larger
635
scpix1[0] -= 0.5 * scale[0];
636
scpix2[0] -= 0.5 * scale[0];
640
scpix1[1] -= 0.5 * scale[1];
641
scpix2[1] -= 0.5 * scale[1];
645
* get terminal characteristics
647
for ( xy = 0; xy < PLDIM2; xy++ )
648
{ frmpx[xy] = (float) fabs((double) scpix2[xy] - scpix1[xy] ) + 1;
649
frmmm[xy] = frmpx[xy] / scrpx[xy];
650
offmm[xy] = scpix1[xy] / scrpx[xy];
653
* set the clip coordinates
655
clpl[0] = MYMAX( offmm[0], 0.0 );
656
clpl[1] = MYMIN( offmm[0] + (float) fabs((double) frmmm[0] ), 1.0 );
657
clpl[2] = MYMAX( offmm[1], 0.0 );
658
clpl[3] = MYMIN( offmm[1] + (float) fabs((double) frmmm[1] ), 1.0 );
660
PCKWRR( "CLPL", 4, clpl ); /*store clip values*/
667
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
669
.PURPOSE Set the plot window in world coordinates
670
input: float *wcfram plot window limits in world coordinated
672
.COMMENTS static function, also defined as low level plot interface
673
------------------------------------------------------------*/
675
static void PCWND( float *wcfram )
677
static void PCWND( wcfram )
684
* copy input array because we are going to change it
694
if ( wcfram[3] <= -2.0 ) /* logarithmic x-axis*/
695
{ wndl[0] = exp( wcfram[0] );
696
wndl[1] = exp( wcfram[1] );
698
else if ( wcfram[3] < 0.0 )
699
{ wndl[0] = pow( 10.0, wcfram[0] );
700
wndl[1] = pow( 10.0, wcfram[1] );
703
if ( wcfram[7] <= -2.0 ) /* logarithmic y-axis*/
704
{ wndl[2] = exp( wcfram[4] );
705
wndl[3] = exp( wcfram[5] );
707
else if ( wcfram[7] < 0.0 )
708
{ wndl[2] = pow( 10.0, wcfram[4] );
709
wndl[3] = pow( 10.0, wcfram[5] );
714
AG_WDEF( wndl[0], wndl[1], wndl[2], wndl[3] );
717
if ( wcfram[3] < 0 ) AG_SSET( "logx" );
718
if ( wcfram[7] < 0 ) AG_SSET( "logy" );
727
/*++++++++++++++++++++++++++++++
729
.PURPOSE does a complete setup of the plot parameters and AGL
730
.COMMENTS static function
731
-------------------------------*/
733
static void PCSET( void )
738
int actvals, color, font, ltype, lwidth, twidth, ncol;
740
char clmod[5], text[81];
745
PCKRDI( "FONT", 1, &actvals, &font );
746
(void) sprintf( text, "font=%1d", font );
752
PCKRDI( "LTYPE", 1, &actvals, <ype );
754
{ (void) sprintf( text, "lstyl=%1d", ltype - 1 );
760
PCKRDI( "LWIDTH", 1, &actvals, &lwidth );
761
(void) sprintf( text, "lwidt=%1d", lwidth - 1 );
765
* set line width for text
767
PCKRDI( "TWIDTH", 1, &actvals, &twidth );
768
(void) sprintf( text, "twidt=%1d", twidth );
772
* determine character and symbol sizes for the MIDAS layout
779
(void) AG_IGET( "ncol", &ncol);
780
PCKRDI( "COLOR", 1, &actvals, &color );
781
if ( ncol == 1 && color > 1 ) color = 1;
782
(void) sprintf( text, "color=%1d", color );
788
PCKRDC( "COLMODE", 4, &actvals, clmod );
789
if ( strncmp( clmod, "X", 1 ) == 0 )
790
AG_SSET( "mode=Xor" );
792
AG_SSET( "mode=Sub" );
794
* do a complete "manual" setting, which gives a default frame!!
796
PCKRDR( "XWNDL", 4, &actvals, wcfram );
797
PCKRDR( "YWNDL", 4, &actvals, wcfram+FOR_Y );
807
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
809
.PURPOSE Sets up the graphic device according to plot mode
810
input: char *devnam: name of device to be activated
811
char *plname: name of meta file
812
int access : access mode: -1 = cursor,
815
in/output: int *plmode: plot mode: 0 = no axis & no info,
816
1 = draw axes & some info,
817
2 = draw axes & full info,
818
-1 take value from keyword PMODE
820
.COMMENTS PCOPEN activates a given device, or the current (by MIDAS)
821
defined device if no device name is given. A given device has
822
to be present in the AGLDEVS.dat file.
824
PCOPEN does not open or append to a meta file if PLNAME
825
equals "NO"ne. If no name or a file name (without ".plt"
826
extention) is given PCOPEN will open or append to a meta file
827
(see access mode). Default for the name of the meta file is
828
the name of the activated device extended with MIDAS session
829
number with extention ".plt".
831
PCOPEN reads the MIDAS graphics keywords, opens this device
832
(on graphics or image display) according to the MIDAS settings.
833
The coordinate box have to be defined BEFORE PCOPEN !!!
834
Use the MIDAS routine PCKWRR, with parameters: XWNDL and YWNDL.
835
------------------------------------------------------------*/
836
void PCOPEN( devnam, plname, access, plmode )
837
char *devnam, *plname;
841
int actvals, amode, bcolor, iac, idev, meta, newdev, pmode;
842
float ocount, rdef, clpl[4];
843
char *pntr, session[3], debug[5], erase[5], action[9], cmnd[21],
844
device[21], dname[21], plmeta[81], text[81];
846
static int nrdev = 0;
847
static struct dev devtbl[MAXDEV];
849
char *errpmode = "*** FATAL: PCOPEN, unknown plot mode ...",
850
*errdev = "*** FATAL: PCOPEN, unknown or unavailable device",
851
*errhlp = " use HELP [printers]",
852
*errmxdev = "*** FATAL: PCOPEN, too many different devices opened (> 4)",
853
*errplt = "*** FATAL: PCOPEN, no graphics device ==> No CURSOR",
854
*errnopl = "*** FATAL: PCOPEN, no existing plot file to append",
855
*errnoex = "*** FATAL: PCOPEN, no existing plot for graphics cursor";
857
* initialize device and meta-file name
859
*device = *plmeta = '\0';
860
(void) strncat( device, devnam, 20 );
861
(void) strncat( plmeta, plname, 80 );
862
(void) SCKGETC( "MID$SESS", 11, 2, &iac, session );
863
PCKRDR( "OCOUNT", 1, &actvals, &ocount );
868
if ( *plmode == -1 ) /* plmode = -1 => use PMODE */
869
{ PCKRDI( "PMODE", 1, &actvals, &pmode );
873
* and check its value
875
if ( *plmode < 0 && *plmode > 2 ) SCETER( 2, errpmode );
880
PCKRDC( "DEBUG", 4, &actvals, debug );
881
if ( strncmp( debug, "ON", 2 ) == 0 )
882
AG_SSET( "msgw;debu=1;errf=aglerr.log" );
884
AG_SSET( "msgn;debu=0" );
889
if ( truelen( device ) == 0 ) /* a device name given? */
890
(void) SCKGETC( "MID$PLOT", 1, 20, &iac, device );
892
if ( PCDEV( device, dname ) != ERR_NORMAL ||
893
strncmp( dname, "unknown", 7 ) == 0 )
899
if ( nrdev == 0 ) /* are there devices opened? */
902
(void) strcpy( devtbl[idev].name, dname );
905
{ for ( idev = 0; idev < nrdev; idev++ )
906
if ( strcmp( dname, devtbl[idev].name ) == 0 ) break;
908
if ( idev == nrdev ) /*new device*/
909
{ if ( ++nrdev > MAXDEV ) SCETER( 4, errmxdev );
910
(void) strcpy( devtbl[idev].name, dname );
916
* set the access mode according to plot, overplot and cursor command
918
(void) SCKGETC( "MID$CMND", 1, 20, &iac, cmnd );
919
if ( access == -1 ) /*reserved for cursor*/
920
{ if ( strncmp( dname,"graph",5 ) != 0 && strncmp( dname,"image",5 ) != 0 )
924
else if ( access == 1 ) /*overplot command*/
925
{ if ( strncmp( QUAL, "AX", 2 ) == 0 ) /*axes*/
927
else if ( strncmp( COMM, "LAB", 3 ) == 0 ) /*label graphics*/
932
else /*plot command*/
933
{ PCKRDC( "CLEAR", 4, &actvals, erase );
934
if ( strncmp( QUAL, "AX", 2 ) == 0 ) /*axes*/
935
{ if ( strncmp( erase, "ON", 2 ) == 0 || ocount < 1)
938
amode = 2; /*no erase*/
940
else /*data plotting*/
941
{ if ( strncmp( erase, "ON", 2 ) == 0 || ocount < 1)
944
amode = 6; /*no erase*/
950
meta = FALSE; /* default: no meta file*/
952
{ if ( strncmp( plmeta, "no", 2 ) != 0 )
954
if ( amode == 1 || amode == 5 ) /*new plotfile*/
955
{ if ( truelen( plmeta ) == 0 ) /*called with no name*/
956
{ (void) strcpy( plmeta, dname );
957
if ( (pntr = strchr( plmeta, '.' )) == NULL )
958
(void) strcat( plmeta, session );
960
(void) strcpy( pntr, session );
962
if ( (pntr = strchr( plmeta, '.' )) == NULL )
963
(void) strcat( plmeta, ".plt" );
965
(void) strcpy( pntr, ".plt" );
966
PCKWRC( "PLNAM", plmeta );
969
else /*overplot mode*/
970
{ PCKRDC( "PLNAM", 80, &actvals, plmeta );
971
if ( ocount == 0.0 ) SCETER( 5, errnopl );
976
* define default viewport setting
978
clpl[0] = clpl[2] = 0.0;
979
clpl[1] = clpl[3] = 1.0;
981
* open viewport for device
984
{ case 1: /*PLOT AXES*/
985
case 5: /*PLOT DATA erase*/
986
(void) strcat( dname, ":" );
988
case -1: /*GET GCURSOR*/
989
if ( ocount == 0.0 ) SCETER( 6, errnoex ); /*none existing*/
990
PCKRDR( "CLPL", 4, &actvals, clpl );
991
case 3: /*LABEL GRAPH*/
992
if ( ocount == 0.0 ) break;
993
case 2: /*OVER AXES*/
994
case 4: /*OVER DATA*/
995
case 6: /*PLOT DATA no-erase*/
996
(void) strcat( dname, "/n:" );
997
(void) strcat( plmeta, "/a" );
1001
devtbl[idev].id = AG_VDEF( dname,
1002
clpl[0], clpl[1], clpl[2], clpl[3], 0., 0. );
1004
AG_VSEL( devtbl[idev].id );
1007
{ AG_MCLS(); /* close the still open meta file */
1008
AG_MOPN( plmeta ); /* and open a new */
1012
{ if ( amode == 3 || amode == 4 )
1013
PCKRDR( "CLPL", 4, &actvals, clpl );
1016
{ PCKWRR( "SCALES", 0, &rdef );
1017
PCKWRR( "OFFSET", 0, &rdef );
1019
(void) SCKGETC( "ACTION", 1, 4, &iac, action );
1020
if ( strncmp( action, "DISP", 4 ) == 0 )
1023
GRPCLP( *plmode, device, clpl );
1026
PCKWRR( "OCOUNT", 1, &ocount );
1029
PCKRDR( "CLPL", 4, &actvals, clpl );
1031
AG_CDEF( clpl[0], clpl[1], clpl[2], clpl[3] );
1033
if ( amode == 1 || amode == 5 )
1034
{ PCKRDI( "BCOLOR", 1, &actvals, &bcolor );
1035
(void) sprintf( text, "back=%1d", bcolor );
1047
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1049
.PURPOSE Close plot file, and terminate graphic operations
1050
------------------------------------------------------------*/
1054
* terminate orderly the AGL operations