#!/usr/bin/env ruby

require "numru/ggraph"
require "getoptlong"
include NumRu

###
###引数処理
###
parser = GetoptLong.new
parser.set_options(
                   ###    global option   ###
                   ['--num',         GetoptLong::REQUIRED_ARGUMENT],
                   ['--delt',        GetoptLong::REQUIRED_ARGUMENT],
                   ['--range',       GetoptLong::REQUIRED_ARGUMENT],
                   ['--aspect',      GetoptLong::REQUIRED_ARGUMENT],
                   ['--int',         GetoptLong::REQUIRED_ARGUMENT],
                   ['--MaxTone',     GetoptLong::REQUIRED_ARGUMENT],
                   ['--MaxLine',     GetoptLong::REQUIRED_ARGUMENT],
                   ['--X',           GetoptLong::REQUIRED_ARGUMENT],
                   ['--T',           GetoptLong::REQUIRED_ARGUMENT],
                   ['--dump',         GetoptLong::NO_ARGUMENT],
                   ['--nocont',      GetoptLong::NO_ARGUMENT]
                   )
begin
  parser.each_option do |name, arg|
    eval "$OPT_#{name.sub(/^--/, '').gsub(/-/, '_')} = '#{arg}'" 
  end
rescue
  exit(1)
end

###
### 値の取得
###

var   = "MoistBuoy"
gphys1 = GPhys::IO.open( ARGV[0], var )

var   = "Buoy"
gphys2 = GPhys::IO.open( ARGV[0], var )

var   = "BuoyAll"
gphys12 = GPhys::IO.open( ARGV[0], var )


DCL::swpset('IHEIGHT', 500 )
DCL::swpset('IWIDTH',  500 )


DCL.gropn( 2 )
DCL.sgpset('lfull',true) 
DCL.sgpset('lfprop',true) 
#DCL.sglset('lclip',true)
DCL.sgpset('lcntl', false) 

DCL.uzfact(0.75)

GGraph.line( gphys2.cut('x'=> 75000).cut('t'=>$OPT_T.to_f), 
             true,  
             'exchange'=>true,
             'title'=>'Buoyancy',
	     'index'=>43,
	     'type'=>1, 
             'max'=>($OPT_MaxLine == nil) ? nil :   $OPT_MaxLine.to_f,
             'min'=>($OPT_MaxLine == nil) ? nil : - $OPT_MaxLine.to_f
            )

GGraph.line( gphys1.cut('x'=> 75000).cut('t'=>$OPT_T.to_f), 
             false, 
             'exchange'=>true,
	     'annotate'=>true,
	     'index'=>23,
	     'type'=>1
            )

GGraph.line( gphys12.cut('x'=> 75000).cut('t'=>$OPT_T.to_f), 
             false, 
             'exchange'=>true,
	     'annotate'=>true,
             'index'=>11, 
	     'type'=>3
            )

DCL.grcls


