#!/usr/bin/ruby
# coding: utf-8

include Math
require "numru/dcl"
include NumRu


def draw_preparation( iws = 1, figfn = 'dcl' )

  if iws == 2 then
    DCL.swcset( 'FNAME', figfn )
    DCL.sgiset( 'IFONT', 2 )
#    DCL.uziset( 'INDEXT0', 10 )
    DCL.uziset( 'INDEXT1', 19 )
    DCL.uziset( 'INDEXT2', 19 )
  end
  # draw a figure
  #   "display number" : 1 for monitor
  #                    : 2 for pdf file
  DCL.gropn( iws )                                   # open a device
end


def draw_finish
  DCL.grcls
end


def draw_orbit( title, sFigSize, a_X, a_Y, a_PlanetName )

  DCL.sgpset('lclip', true)
  DCL.grfrm                             # set a frame
#  DCL.ussttl( 'Latitude', 'degrees', 'Tendency', 'K s-1' )  # name and unit of axes
  DCL.grswnd(-sFigSize, sFigSize, -sFigSize, sFigSize) # set range of axes
  DCL.grsvpt(0.2,0.8,0.2,0.8)           # set viewport
  itr = 1
  DCL.grstrn(itr)                       # select kind of axis, 
                                        #   1 : lin.-lin. plot
                                        #   2 : lin.-log. plot
                                        #   3 : log.-lin. plot
                                        #   4 : log.-log. plot
  DCL.grstrf                            # determine axes, 
  DCL.usdaxs                            # draw axes
  DCL.uuslnt(1)                         # set line type
  #  DCL.uuslni(1)                         # set line index
  DCL.uuslnt(1)                     # set line type

  DCL.uuslni(19)                    # set line index
  for iPlanet in 0..(a_X[0,true].size-1)
    DCL.uulin( a_X[true,iPlanet], a_Y[true,iPlanet] )            # draw a line
  end
  DCL::sgstxs(0.03)
  for iPlanet in 0..(a_X[0,true].size-1)
    DCL.sgtxu( a_X[0,iPlanet], a_Y[0,iPlanet], a_PlanetName[iPlanet] )
  end

  DCL.sgspms(0.05)
  DCL.sgspmi(29)
  DCL.sgpmu( [0.0], [0.0] )            # draw a line
#  DCL.sgtxu( 0.0, 0.0, 'S' )

  DCL.sgstxs(0.025)
  DCL.sgtxv(0.5,0.85, title)

end
