Bugfix in AliPoints2Memory
[u/mrichter/AliRoot.git] / GEANT321 / gdraw / gdopen.F
1 *
2 * $Id$
3 *
4 * $Log$
5 * Revision 1.2  1997/01/24 14:16:06  mclareni
6 * NZLEFT 2nd argument 0 instead of blank for Msoft
7 *
8 * Revision 1.1.1.1.2.1  1997/01/21 11:24:20  mclareni
9 * All mods for Winnt 96a on winnt branch
10 *
11 * Revision 1.1.1.1  1995/10/24 10:20:23  cernlib
12 * Geant
13 *
14 *
15 #include "geant321/pilot.h"
16 *CMZ :  3.21/02 29/03/94  15.41.26  by  S.Giani
17 *-- Author :
18       SUBROUTINE GDOPEN(IVIEW)
19 C.
20 C.    ******************************************************************
21 C.    *                                                                *
22 C.    *       Open view bank IVIEW for storing; if IVIEW=0 then        *
23 C.    *       none view bank is opened and drawing is done             *
24 C.    *       on the screen.                                           *
25 C.    *                                                                *
26 C.    *       Q(JDRAW+IVIEW) contains a control word that is :         *
27 C.    *                                                                *
28 C.    *       1 for empty banks (created just to avoid gaps)           *
29 C.    *         or for deleted banks                                   *
30 C.    *                                                                *
31 C.    *       2 for opened banks (all banks that have been opened)     *
32 C.    *                                                                *
33 C.    *       3 for protected banks (all banks that can't be deleted   *
34 C.    *         by the user)                                           *
35 C.    *                                                                *
36 C.    *    ==>Called by : <USER>, <GXINT>                              *
37 C.    *       Authors : R.Brun, P.Zanarini   *********                 *
38 C.    *                                                                *
39 C.    ******************************************************************
40 C.
41 #include "geant321/gcbank.inc"
42 #include "geant321/gcflag.inc"
43 #include "geant321/gcdraw.inc"
44 #include "geant321/gcunit.inc"
45       COMMON/GCLOCA/NLOCAL(2),JLOCA(19),JV
46 C.
47 C.    ------------------------------------------------------------------
48 C.
49 C
50 C             Book JDRAW structure for view banks if not there
51 C
52       IF (JDRAW.LE.0) CALL MZBOOK(IXCONS,JDRAW,JDRAW,1,'DRAW',0,0,0,3,0)
53 C
54 C             Previous view number must be 0 (screen)
55 C
56       IF (IDVIEW.NE.0) GO TO 60
57 C
58 C             If want open a view bigger than current number of views
59 C             then do a pushing of view banks
60 C
61       IF(IVIEW.LE.0)GO TO 999
62       IF (IVIEW.GT.NKVIEW) GO TO 20
63 C
64 C             Cannot open a view already used
65 C
66       IF (LQ(JDRAW-IVIEW).NE.0) GO TO 40
67       IDVIEW=IVIEW
68       IF (IDVIEW.EQ.0) GO TO 999
69 C
70 C             Open view number IDVIEW
71 C
72    10 Q(JDRAW+IDVIEW)=2.
73       CALL MZBOOK(IXCONS,JV,JDRAW,-IDVIEW,'DRAW',6,6,22,3,0)
74 C
75 C             Set number of words for creation and for pushing of banks
76 C             graphic unit, graphic segment, text unit, text segment
77 C
78 C
79       NLEFT=NZLEFT(IXCONS,0)
80       NL=NLEFT/10
81       MAXGS=MIN(NL,10000)
82       MAXGU=MAXGS/10
83       MORGS=MAXGS/2
84       MORGU=MAXGU/2
85       MAXTU=10
86       MORTU=MAXTU
87       MAXTS=100
88       MORTS=MAXTS
89 C
90       Q(JV+2)=MAXGU
91       Q(JV+3)=MORGU
92       Q(JV+5)=MAXGS
93       Q(JV+6)=MORGS
94       Q(JV+8)=MAXTU
95       Q(JV+9)=MORTU
96       Q(JV+11)=MAXTS
97       Q(JV+12)=MORTS
98 C
99       Q(JV+16)=PLTRNX/2.
100       Q(JV+17)=PLTRNY/2.
101 C
102 C           Set ICUT of the view bank to 0
103 C
104       Q(JV+22)=0.
105 C
106 C             Graphic unit, graphic segment, text unit, text segment
107 C             pointers are reset to zero
108 C
109       IGU=0
110       IGS=0
111       ITU=0
112       ITS=0
113 C
114 C             Create view banks
115 C
116       ND1=Q(JV+2)
117       ND2=ND1
118       ND3=Q(JV+8)
119       ND4=Q(JV+5)
120       ND5=ND4
121       ND6=Q(JV+11)
122       CALL MZBOOK(IXCONS,LBANK,JV,-1,'DRAW',0,0,ND1,3,0)
123       CALL MZBOOK(IXCONS,LBANK,JV,-2,'DRAW',0,0,ND2,3,0)
124       CALL MZBOOK(IXCONS,LBANK,JV,-3,'DRAW',0,0,ND3,3,0)
125       CALL MZBOOK(IXCONS,LBANK,JV,-4,'DRAW',0,0,ND4,3,0)
126       CALL MZBOOK(IXCONS,LBANK,JV,-5,'DRAW',0,0,ND5,3,0)
127       CALL MZBOOK(IXCONS,LBANK,JV,-6,'DRAW',0,0,ND6,3,0)
128       GO TO 999
129 C
130 C             Push view banks
131 C
132    20 IDVIEW=IVIEW
133       NDL=IDVIEW-NKVIEW
134       CALL MZPUSH(IXCONS,JDRAW,NDL,NDL,'I')
135       IF(IEOTRI.NE.0)GO TO 50
136       DO 30 I=NKVIEW+1,IDVIEW-1
137          Q(JDRAW+I)=1.
138    30 CONTINUE
139       NKVIEW=IDVIEW
140       GO TO 10
141 C
142    40 WRITE (CHMAIL,1000)
143       CALL GMAIL(0,0)
144       GO TO 999
145 C
146    50 WRITE (CHMAIL,1100)
147       CALL GMAIL(0,0)
148       GO TO 999
149 C
150    60 WRITE (CHMAIL,1200)
151       CALL GMAIL(0,0)
152 C
153  1000 FORMAT (' ERROR IN GDOPEN: VIEW ALREADY EXISTING')
154  1100 FORMAT (' ERROR IN GDOPEN: MEMORY OVERFLOW IN PUSHING A BANK')
155  1200 FORMAT (' ERROR IN GDOPEN: ANOTHER VIEW IS ALREADY OPENED')
156   999 RETURN
157       END