!-------------------------------------------------
!  UEpack Module
!-------------------------------------------------
module uepack
  use dcl_common

  interface DclSetHatchLevel
     module procedure DclSetHatchA, DclSetHatchB, DclSetHatchV, DclSetHatchN
  end interface

  private :: DclSetHatchA, DclSetHatchB, DclSetHatchV, DclSetHatchN

  contains
!------------------------------2次元等値線図のぬりわけをおこなう．
    subroutine DclDrawHatch(z)
      real,      intent(in), dimension(:,:) :: z

      nx = size(z,1)
      ny = size(z,2)
      call uetone(z,nx,nx,ny)   
    end subroutine
!------------------------------2次元等値線図のぬりわけをおこなう．
    subroutine DclDrawHatchEx(z)
      real,      intent(in), dimension(:,:) :: z

      nx = size(z,1)
      ny = size(z,2)
      call uetonf(z,nx,nx,ny)  
    end subroutine
!------------------------------トーンレベル値を最小値・最大値,きざみ値で設定する．
    subroutine   DclSetHatchA(xmin,xmax,dx)
      real,      intent(in) :: xmin,xmax    !トーンレベルの最小・最大値
      real,      intent(in) :: dx           !dx > 0 のときdxをきざみ幅
      call uegtla(xmin,xmax,dx) 
    end subroutine
!------------------------------トーンレベル値を配列,きざみ値で設定する．
    subroutine DclSetHatchB(z,mx,nx,ny,dx)
      real,      intent(in), dimension(:,:) :: z
      real,      intent(in) :: dx            !dx > 0 のときdxをきざみ幅

      nx = size(z,1)
      ny = size(z,2)
      call uegtlb(z,nx,nx,ny,dx) 
     end subroutine
!------------------------------ ぬりわけるレベルとパターンを1レベルごと指定する．
    subroutine DclSetHatchV(level1,level2,pattern)
      real,      intent(in) :: level1,level2  !ぬりわけるレベルの下限上限値
      integer,   intent(in) :: pattern        !トーンパターン番号
      call uestlv(level1,level2,pattern)
    end subroutine
!----------------------------- ぬりわけるレベルとパターンを配列で複数レベル指定する．
    subroutine DclSetHatchN(level,pattern)
      integer, intent(in), dimension(:) :: pattern 
      real,    intent(in), dimension(size(pattern)) :: level 
      call uestln(level,pattern,size(pattern)) 
    end subroutine
!-------------------------------第iton番目のトーンレベルの属性
    subroutine DclGetHatchLevel(number, level1, level2, pattern) 
      integer,   intent(in) :: number
      real,      intent(out) :: level1, level2
      integer,   intent(out) :: pattern
      call ueqtlv(level1,level2,pattern,number) 
    end subroutine
!------------------------------現在設定されているトーンレベルの数
    function DclGetHatchLevelNumber()
      integer :: DclGetHatchLevelNumber
      call ueqntl(DclGetHatchLevelNumber)  
    end function
!-----------------------------トーンレベルを無効にする．
    subroutine DclClearHatchLevel()
      call ueitlv() 
    end subroutine
      
end module
