5 * Revision 1.1.1.1 1995/10/24 10:21:50 cernlib
9 #include "geant321/pilot.h"
10 *CMZ : 3.21/02 29/03/94 15.41.33 by S.Giani
14 C. ******************************************************************
16 C. * Geometry commands *
18 C. * Point to volume just drawn to pick up medium name, volume name *
19 C. * etc. The first point points to the volume, the second point *
20 C. * gives the position of the character string which contains this *
23 C. * Authors: S.Egli ********** *
25 C. ******************************************************************
27 #include "geant321/gconsp.inc"
28 #include "geant321/gcvolu.inc"
29 #include "geant321/gcdraw.inc"
30 #include "geant321/gcbank.inc"
31 #include "geant321/gcsets.inc"
32 #include "geant321/gctmed.inc"
33 #include "geant321/gcmate.inc"
34 #include "geant321/gcunit.inc"
36 * this COMMON filled in routine GDRAW !
40 DIMENSION XC(3),XYZ(3),XINVMA(3,3),VL(3),VM(3),VN(3)
41 DIMENSION XX(10),YY(10),RHELP(3)
43 CHARACTER*4 NAMV,CHIDTY
47 * determine inverse matrix xinvma for current view parameters
49 PH = ABS(MOD(GPHI,360.))
50 THET = ABS(MOD(GTHETA,360.))
51 IF(THET.LE.180.)GO TO 10
55 10 ST = SIN(THET * DEGRAD)
56 CT = COS(THET * DEGRAD)
66 IF(ABS(VN(2)).GT.0.99999) THEN
68 * Special case when observer line of sight is along mu:
69 * in this case one chooses arbitrarily the vertical axis of
70 * plane of projection as the lambda axis and the horizontal
85 * Define new lambda axis
95 * now invert matrix defined by VL,VM,VN -> XINVMA
103 CALL RINV(3,XINVMA,3,RHELP,IFAIL)
105 WRITE(CHMAIL,10100) IFAIL
110 * perspective projection ?
112 CALL UCTOH('PERS',IPERS,4,4)
113 IF(IPRJ.EQ.IPERS)THEN
119 * pick up two points in user coordinates:
121 30 CALL IRQLC(1,1,ISTAT,NT,U0,V0)
122 IF(ISTAT.EQ.0)GOTO 999
123 CALL IRQLC(1,1,ISTAT,NT,U1,V1)
124 IF(ISTAT.EQ.0)GOTO 999
126 * transform (u0,v0) to coordinates in MARS system:
127 * (inverse operation of what is done in routine GDFR3D)
129 * take zoom parameters into account:
131 U01=(U0-GZUB-GZUC)/GZUA
132 V01=(V0-GZVB-GZVC)/GZVA
134 * rotate and shift back
136 UU=+COSPSI*(U01-GU0)+SINPSI*(V01-GV0)
137 VV=-SINPSI*(U01-GU0)+COSPSI*(V01-GV0)
144 XC(1)=XINVMA(1,1)*XYZ(1)+XINVMA(1,2)*XYZ(2)+XINVMA(1,3)*XYZ(3)
145 XC(2)=XINVMA(2,1)*XYZ(1)+XINVMA(2,2)*XYZ(2)+XINVMA(2,3)*XYZ(3)
146 XC(3)=XINVMA(3,1)*XYZ(1)+XINVMA(3,2)*XYZ(2)+XINVMA(3,3)*XYZ(3)
148 * build up GCVOLU structure with last drawn volume as
153 CALL GLVOLU(NLEV,NVLAST,LNUM,IER)
158 CALL GMEDIA(XC,NUMED)
165 JTM = LQ(JTMED- NUMED)
167 40 NATMED(I)=IQ(JTM+I)
177 CALL UHTOC(NAMES(NLEVEL),4,NAMV,4)
178 CALL UHTOC(NATMED,4,NAMM,20)
180 IF(NAMM(I:I).EQ.'$')NAMM(I:I)=' '
183 IF(NAMM(I:I).NE.' ')GOTO 70
187 * determine detector idtype
189 IF(JSET.GT.0)CALL GFINDS
191 * draw pointer and write volume name,medium
199 * determine text alignment
201 PHI=ATAN2(V1-V0,U1-U0)*RADDEG
202 IF(ABS(PHI).LT.90.)THEN
212 CALL ISTXAL(IHOR,IVER)
214 IF(.NOT.BTEST(IQ(LQ(JVOLUM-LVOLUM(1))),4))THEN
215 CALL ITX(U1,V1,NAMV//'"j# '//NAMM(1:NJLAST))
217 WRITE(CHIDTY,10000)IDTYPE
218 CALL ITX(U1,V1,NAMV//'"j# '//NAMM(1:NJLAST)//','//CHIDTY)
222 10100 FORMAT(' GXPICK: Matrix inversion failed with ',I3,
224 10200 FORMAT(' GXPICK: perspective projection can not be handled')
225 10300 FORMAT(' GXPICK: point is outside volume')