      SUBROUTINE HELP(X0,X1,Y0,Y1,IREFRE,ITYP,IOPT,IBOUT)
C
      INCLUDE 'com_boutons.f'
      INCLUDE 'com_coor.f'
      INCLUDE 'com_options.f'
C
      CHARACTER*32 CSEC
      DIMENSION DDX(8),DDY(8)
      LOGICAL*4 REDRAW
C
      IF (IBOUT.EQ.-9999) THEN
        IBOUT = 0
        RETURN
      ENDIF
      IF (IFONT2.EQ.2) THEN
        ITOUR2 = 2
      ELSEIF(IFONT2.EQ.3) THEN
        ITOUR2 = 2
      ELSE
        ITOUR2 = 1
      ENDIF
      CALL VRAIECOORD(XDMIN,YDMAX,IX0,IY0)
      CALL VRAIECOORD(XHELP,YDMI2,IX1,IY1)
      PIPI = (XHELP-XDMIN)/REAL(IX1-IX0)
cc      DX = .02*(X1-X0)
      DX = REAL(ITOUR2)*PIPI
cc      DY2 = (Y1-Y0)*.0042
      DY2 = PIPI
      DX3 = 2.5*DX
      DY3 = DX3
      IF (ITYP.EQ.-13) THEN
        CALL ECRANG(ANGX,ANGY,ANGZ,IFONT1,XBOUT(2,IBROT),YBOUT(1,IBROT)
     &             ,DX3,DY3)
        IF (IOPT.NE.-3) RETURN
      ENDIF
      IF (IREFRE.EQ.1) THEN
cc        DY  = (Y1-Y0)*.024
        DY  = (Y1-Y0)*.025
        DX2 = PIPI
        DDX(1) = (X1-X0-2.*DX-DX2)*.5
        DDX(2) = (X1-X0-2.*(DX+DX2))/3.
        DDX(3) = (X1-X0-2.*DX-3.*DX2)*.25
        DDX(4) = X1-X0-2.*DX
        DDX(5) = DDX(1)
        DDX(6) = DDX(4)
        DDX(7) = DDX(1)
        DDX(8) = 2.*(X1-X0-2.*DX-DX2)/3.
        DDY(1) = 1.5*DY
        DDY(2) = DDY(1)
        DDY(3) = DDY(1)
        DDY(4) = 1.3*DY
c        DDY(5) = 3.5*DY
        DDY(5) = 3.9*DY+2.*DY2
        DDY(6) = 1.1*DY
        DDY(7) = DDY(4)
        DDY(8) = DDY(1)
        II = IABS(ITB(1))
        XBOUT(1,1) = X0+DX
        XBOUT(2,1) = XBOUT(1,1) + DDX(II)
        YBOUT(2,1) = Y1 - DY2
        YBOUT(1,1) = YBOUT(2,1) - DDY(II)
        XCOUR = XBOUT(2,1) + DX2
        YCOUR = YBOUT(1,1)
        YMIN  = YCOUR
        DO I=2,NBOUT-1
          IF (LBOUT(I).GT.0) THEN
            IF (ITB(I).LT.0) THEN
              FACY = .7
              II = -ITB(I)
            ELSE
              FACY = 1.
              II = ITB(I)
            ENDIF
            IF (XCOUR+DDX(II).LT.X1) THEN
              XBOUT(1,I) = XCOUR + DX2
              XBOUT(2,I) = XBOUT(1,I) + DDX(II)
              YBOUT(1,I) = .5*(YBOUT(1,I-1)+YBOUT(2,I-1)-DDY(II)*FACY)
              YBOUT(2,I) = YBOUT(1,I) + DDY(II)*FACY
              XCOUR = XBOUT(2,I)
              YCOUR = YBOUT(1,I)
              IF (II.EQ.5) THEN
                XBOUT(2,I-1) = XBOUT(1,I) - DX2
                XBOUT(1,I-1) = XBOUT(2,I-1) - DDX(IABS(ITB(I-1)))
                XBOUT(1,I-2) = XBOUT(1,I-1)
                XBOUT(2,I-2) = XBOUT(2,I-1)
                XBOUT(1,I-3) = XBOUT(1,I-1)
                XBOUT(2,I-3) = XBOUT(2,I-1)
                YBOUT(1,I-1) = YBOUT(1,I)
                YBOUT(2,I-1) = YBOUT(1,I-1) + DDY(IABS(ITB(I-1)))*FACY
                YBOUT(2,I-3) = YBOUT(2,I)
                YBOUT(1,I-3) = YBOUT(2,I-3) - DDY(IABS(ITB(I-3)))*FACY
                YYYM = .5*(YBOUT(2,I-1)+YBOUT(1,I-3))
                YBOUT(2,I-2) = YYYM + .5*DDY(IABS(ITB(I-2)))*FACY
                YBOUT(1,I-2) = YYYM - .5*DDY(IABS(ITB(I-2)))*FACY
                YMIN = YBOUT(1,I)
              ENDIF
            ELSE
              IF (II.EQ.5) THEN
                XBOUT(2,I) = X1 - DX
                XBOUT(1,I) = XBOUT(2,I) - DDX(II)
                YBOUT(2,I) = YBOUT(2,I-1)
                YBOUT(1,I) = YBOUT(2,I) - DDY(II)*FACY
                XBOUT(1,I-1) = X0 + DX
                XBOUT(2,I-1) = XBOUT(1,I-1) + DDX(IABS(ITB(I-1)))
                YBOUT(1,I-1) = YBOUT(1,I)
                YBOUT(2,I-1) = YBOUT(1,I-1) + DDY(IABS(ITB(I-1)))*FACY
              ELSE
                XBOUT(1,I) = X0 + DX
                XBOUT(2,I) = XBOUT(1,I) + DDX(II)
                YBOUT(2,I) = YMIN - DY2
                YBOUT(1,I) = YBOUT(2,I) - DDY(II)*FACY
                IF (LBOUT(I-1).EQ.0) THEN
                  XBOUT(2,I-2) = X1 - DX
                  XBOUT(1,I-2) = XBOUT(2,I-2)-DDX(IABS(ITB(I-2)))
                  XBOUT(1,I-1) = XBOUT(1,I-2)
                  XBOUT(2,I-1) = XBOUT(2,I-2)
                ELSE
                  XBOUT(2,I-1) = X1 - DX
                  XBOUT(1,I-1) = XBOUT(2,I-1)-DDX(IABS(ITB(I-1)))
                ENDIF
              ENDIF
              XCOUR = XBOUT(2,I)
              YCOUR = YBOUT(1,I)
              YMIN = MIN(YMIN,YCOUR)
            ENDIF
          ELSE
            XBOUT(1,I) = XBOUT(1,I-1)
            XBOUT(2,I) = XBOUT(2,I-1)
            YBOUT(1,I) = YBOUT(1,I-1)
            YBOUT(2,I) = YBOUT(2,I-1)
          ENDIF
        ENDDO
C
        XBOUT(1,NBOUT) = XBOUT(1,3)
        XBOUT(2,NBOUT) = XBOUT(1,NBOUT)+DDX(1)/4.
        YBOUT(1,NBOUT) = YBOUT(1,3)+(YBOUT(2,3)-YBOUT(1,3))*.1
        YBOUT(2,NBOUT) = YBOUT(2,3)-(YBOUT(2,3)-YBOUT(1,3))*.1
C
        XMAMA = X1-4.*DX
        DO I=1,NBOUT
          IF (XBOUT(2,I).GE.XMAMA) XBOUT(2,I) = X1-DX
          IF (ITB(I).EQ.6) THEN
            YBOUT(1,I) = YBOUT(1,I) + DX
            YBOUT(2,I) = YBOUT(2,I) - DX
          ENDIF
        ENDDO
        IF (IOPT.EQ.-2.OR.IOPT.EQ.-5) THEN
          CALL ECRANG(ANGX,ANGY,ANGZ,IFONT1
     &               ,XBOUT(2,IBROT),YBOUT(1,IBROT),DX3,DY3)
          RETURN
        ELSEIF(IOPT.EQ.-4) THEN
          RETURN
        ENDIF
        REDRAW = .TRUE.
      ELSE
        IF (IOPT.EQ.-2.OR.IOPT.EQ.-5) THEN
          CALL ECRANG(ANGX,ANGY,ANGZ,IFONT1
     &               ,XBOUT(2,IBROT),YBOUT(1,IBROT),DX3,DY3)
          RETURN
        ELSEIF(IOPT.EQ.-4) THEN
          RETURN
        ENDIF
        REDRAW = .FALSE.
      ENDIF
      CALL GSBND(X0,X1,Y0,Y1)
      CALL GSPAT(8)
      IF (IBOUT.EQ.0.OR.REDRAW) THEN
        CALL GSPROGRE(1)
        ILARG = IX1-IX0
        IHAUT = IY1-IY0
cc        IF (IBOUT.EQ.0) THEN
cc          KK = 0
cc        ELSE
cc          KK = KBOUT(IABS(IBOUT))
cc        ENDIF
cc        IF (IBOUT.EQ.0.OR.KK.EQ.14.OR.KK.EQ.34.OR.KK.EQ.35.OR.KK.EQ.37
cc     &  .OR.IOPT.EQ.-3) CALL MY_GSAREA2B(X0,X1,Y0,Y1)
        CALL MY_GSAREA2B(X0,X1,Y0,Y1)
        I0 = 1
        I1 = NBOUT
        ICOL1 = 7
        ICOL2 = 15
      ELSEIF(IBOUT.NE.0) THEN
        I0 = IABS(IBOUT)
        I1 = I0
cc        IF (IBOUT.EQ.IBROT.OR.IBOUT.EQ.IBREL) THEN
        IF (IBOUT.EQ.IBROT) THEN
          ICOL1 = 7
          ICOL2 = 15
        ELSE
          ICOL1 = 15
          ICOL2 = 7
        ENDIF
      ELSE
        PRINT*,'bizarre'
      ENDIF
      DO I=I0,I1
        IF (LBOUT(I).GT.0) THEN
          J = KBOUT(I)
          IF ((J.EQ.1.AND.IDEMI.EQ.3)
     &  .OR.(J.EQ.23.AND.IEXAG.EQ.0)
     &  .OR.(IFISO.EQ.0.AND.(J.EQ.-9.OR.J.EQ.17.OR.J.EQ.19.OR.J.EQ.21))
     &  .OR.(IFVIT.EQ.0.AND.(J.EQ.-5.OR.J.EQ.-6.OR.J.EQ.39))
c     &  .OR.(ICOURB.LT.-3.AND.J.EQ.-7)
     &  .OR.(IFREEZE.NE.0.AND.
     &          (J.EQ.14.OR.(J.EQ.-1.AND.ICOURB.GE.0)
     &       .OR.J.EQ.34.OR.J.EQ.2.OR.J.EQ.37.OR.J.EQ.24))) THEN
            IFONT = IFONT8
            ICOL0 = 15
            IACTIF(I) = 0
          ELSEIF(IABS(ITB(I)).EQ.6) THEN
            IFONT = IFONT8
            ICOL0 = 3
          ELSE
            IFONT = IFONT7
            ICOL0 = 0
            IACTIF(I) = 1
          ENDIF
          IF (KBOUT(I).EQ.-21) THEN
            CALL AREFRESH(IRELIM,IRELIVA,IRELIVI)
            IF (IRELIM.NE.0.OR.IRELIVA.NE.0.OR.IRELIVI.NE.0) THEN
              IBRELON = 1
              ICOL0 = 1
              IACTIF(I) = 1
cc              IFONT = IFONT7
              IFONT = IFONT8
            ELSE
              IBRELON = 0
              ICOL0 = 15
              IACTIF(I) = 0
              IFONT = IFONT8
            ENDIF
            ICOL3 = 3
            CSEC = ' '
            LSEC = 0
          ELSEIF(KBOUT(I).EQ.-11) THEN
            IF (ILANG.EQ.0) THEN
              IF (IPERSP.EQ.1) THEN
                CSEC = '  isométr. '
              ELSEIF(IPERSP.EQ.-1) THEN
                CSEC = ' lointaine '
              ELSEIF(IPERSP.EQ.-2) THEN
                CSEC = '   moyenne '
              ELSEIF(IPERSP.EQ.-3) THEN
                CSEC = '    proche '
              ENDIF
            ELSE
              IF (IPERSP.EQ.1) THEN
                CSEC = '  isometr. '
              ELSEIF(IPERSP.EQ.-1) THEN
                CSEC = '   faraway '
              ELSEIF(IPERSP.EQ.-2) THEN
                CSEC = '    medium '
              ELSEIF(IPERSP.EQ.-3) THEN
                CSEC = '     close '
              ENDIF
            ENDIF
            LSEC = 11
            ICOL3 = 3
          ELSEIF(KBOUT(I).EQ.-10) THEN
            IF (ICTFAC.GT.15) THEN
              WRITE(CSEC(1:2),'(I1," ")') IDIRL
            ELSE
              CSEC(1:2) = '* '
            ENDIF
            LSEC = 2
            ICOL3 = 3
          ELSEIF(KBOUT(I).EQ.-5) THEN
            IF (IVIT.GT.0) THEN
              CSEC(1:2) = ' *'
              ICOL3 = 15
            ELSE
              WRITE(CSEC,'(I2)') ICTFLE
              IF (ICTFLE.EQ.8.OR.ICTFLE.GT.15) THEN
                ICOL3 = 0
              ELSE
                ICOL3 = ICTFLE
              ENDIF
            ENDIF
            LSEC = 2
          ELSEIF(KBOUT(I).EQ.-2) THEN
            LCMAX = 7
            ITOUS = 0
            DO K=1,NUMSD
              IF (ISDVU(K).EQ.0) ITOUS = ITOUS+1
            ENDDO
            IF (ITOUS.EQ.0) THEN
              IF (ILANG.EQ.0) THEN
                CSEC = '   Tous  '
              ELSE
                CSEC = '   All   '
              ENDIF
            ELSEIF(ITOUS.EQ.NUMSD) THEN
              IF (ILANG.EQ.0) THEN
                CSEC = '  Aucun  '
              ELSE
                CSEC = '  None   '
              ENDIF
            ELSEIF(ITOUS.LT.NUMSD-4) THEN
              CSEC = '    *   '
            ELSE
              LC = 0
              DO K=1,NUMSD
                IF (ISDVU(K).GT.0) THEN
                  IF (LC.GT.0) THEN
                    LC = LC+1
                    WRITE(CSEC(LC:LC),'(",")')
                  ENDIF
                  IF (K.LT.10) THEN
                    WRITE(CSEC(LC+1:LC+1),'(I1)') K
                    LC = LC+1
                  ELSEIF(K.LT.100) THEN
                    WRITE(CSEC(LC+1:LC+2),'(I2)') K
                    LC = LC+2
                  ELSE
                    WRITE(CSEC(LC+1:LC+3),'(I3)') K
                    LC = LC+3
                  ENDIF
                ENDIF
              ENDDO
              IF (LC.GT.LCMAX) THEN
                CSEC = '   *  '
              ELSEIF(LC.LT.LCMAX) THEN
                CSEC(LCMAX+1-LC:LCMAX) = CSEC(1:LC)
                DO K=1,LCMAX-LC
                  CSEC(K:K) = ' '
                ENDDO
              ENDIF
            ENDIF
            LSEC = LCMAX
            ICOL3 = 3
          ELSEIF(KBOUT(I).EQ.3) THEN
            WRITE(CSEC,'(I2)') ICTFON
            LSEC = 2
            IF (ICTFON.EQ.8) THEN
              ICOL3 = 0
            ELSE
              ICOL3 = ICTFON
            ENDIF
          ELSEIF(KBOUT(I).EQ.11) THEN
            WRITE(CSEC(1:4),'(SP,I4,SP)') IANG(IANGLE)
            LSEC = 4
            ICOL3 = 3
          ELSEIF(KBOUT(I).EQ.17) THEN
            IF (ISO.EQ.1) THEN
              IF (ISOFRO.EQ.0) THEN
                  CSEC(1:2) = ' 1'
              ELSE
                IF (IVALMAR.EQ.0) THEN
                  CSEC(1:2) = '1b'
                ELSE
                  CSEC(1:2) = '1c'
                ENDIF
              ENDIF
            ELSEIF(ISO.EQ.2) THEN
              IF (IVALMAR.EQ.0) THEN
                CSEC(1:2) = ' 2'
              ELSE
                CSEC(1:2) = '2b'
              ENDIF
            ELSE
              WRITE(CSEC,'(I2)') ISO
            ENDIF
            LSEC = 2
            ICOL3 = 3
          ELSEIF(KBOUT(I).EQ.18) THEN
            WRITE(CSEC(1:2),'(I2)') ICT-1
            CSEC(3:3) = ' '
            LSEC = 3
            IF (ICT.EQ.9) THEN
              ICOL3 = 0
            ELSE
              ICOL3 = ICT-1
            ENDIF
          ELSEIF(KBOUT(I).EQ.20) THEN
            WRITE(CSEC,'(I2)') ITABLE
            LSEC = 2
            ICOL3 = 3
          ELSEIF(KBOUT(I).EQ.25) THEN
            WRITE(CSEC,'(I2)') ICTFAC
            CSEC(3:3) = ' '
            LSEC = 3
            IF (ICTFAC.EQ.8.OR.ICTFAC.GT.16) THEN
              ICOL3 = 0
            ELSE
              ICOL3 = ICTFAC
            ENDIF
          ELSEIF(KBOUT(I).EQ.28) THEN
            CSEC = HELPPS
            LSEC = 14
            ICOL3 = 3
          ELSEIF(KBOUT(I).EQ.32) THEN
            CALL ECRANG(ANGX,ANGY,ANGZ,IFONT1
     &                 ,XBOUT(2,IBROT),YBOUT(1,IBROT),DX3,DY3)
          ELSEIF(KBOUT(I).EQ.34) THEN
            WRITE(CSEC,'(F4.1)') HYA4
            LSEC = 4
            ICOL3 = 3
          ELSEIF(KBOUT(I).EQ.36) THEN
            CALL ECRANG(ANGX,ANGY,ANGZ,IFONT1
     &                 ,XBOUT(2,IBROT),YBOUT(1,IBROT),DX3,DY3)
            ICOL3 = 3
            CSEC = ' '
            LSEC = 0
          ELSE
            ICOL3 = 3
            CSEC = ' '
            LSEC = 0
          ENDIF
          IF (KBOUT(I).EQ.-3333.AND.IFREEZE.NE.0) THEN
            CALL DESBOUT(IFONT,IFONT1,ITB(I),ICB(I),CBOUT(I),LBOUT(I)
     &                  ,XBOUT(1,I),YBOUT(1,I),XHELP,IMENU(I),CSEC,LSEC
     &                  ,DX3,DY3,ITOUR2,5,15,7,1,ILANG)
          ELSEIF( (KBOUT(I).EQ.-20.AND.IPROGRE.LT.0)
     &        .OR.(KBOUT(I).EQ.-17.AND.ITITAV.LT.0)
     &        .OR.(KBOUT(I).EQ.  4.AND.ISHRINK.LT.0)
     &        .OR.(KBOUT(I).EQ.  6.AND.IFC.LT.0)
     &        .OR.(KBOUT(I).EQ. 14.AND.ICARRE.LT.0)
     &        .OR.(KBOUT(I).EQ. 31.AND.ISENS.LT.0)) THEN
cc     &        .OR.(KBOUT(I).EQ. -5.AND.IVIT.LT.0)
            CALL DESBOUT(IFONT,IFONT1,ITB(I),ICB(I),CBOUT(I),LBOUT(I)
     &                  ,XBOUT(1,I),YBOUT(1,I),XHELP,IMENU(I),CSEC,LSEC
     &                  ,DX3,DY3,ITOUR2,ICOL0,15,7,ICOL3,ILANG)
          ELSE
            CALL DESBOUT(IFONT,IFONT1,ITB(I),ICB(I),CBOUT(I),LBOUT(I)
     &                  ,XBOUT(1,I),YBOUT(1,I),XHELP,IMENU(I),CSEC,LSEC
     &                  ,DX3,DY3,ITOUR2,ICOL0,ICOL1,ICOL2,ICOL3,ILANG)
          ENDIF
        ELSE
          IACTIF(I) = 0
        ENDIF
      ENDDO
      IF (IBOUT.EQ.0.OR.REDRAW) THEN
        CALL GSPROGRE(0)
        CALL x11metrect2(IX0,IY0,ILARG,IHAUT,IX0,IY0)
      ENDIF
      CALL ASFCOL(7)
      CALL GSCOL(7)
      END
C-----------------------------------------------------------------------
      SUBROUTINE QBOUT(XCUCU,YCUCU,IBOUT)
      INCLUDE 'com_boutons.f'
      DO I=1,NBOUT
        IF (XCUCU.GE.XBOUT(1,I).AND.XCUCU.LE.XBOUT(2,I)
     & .AND.YCUCU.GE.YBOUT(1,I).AND.YCUCU.LE.YBOUT(2,I)
     & .AND.IACTIF(I).NE.0.AND.ITB(I).NE.6) THEN
          IBOUT = I
          RETURN
        ENDIF
      ENDDO
      IBOUT = 0
      END
