# /usr/bin/python3
# Test program for module {paper_figures_B}
# Last edited on 2021-10-01 23:41:42 by stolfi

import paper_figures_B
import move
import move_parms
import path
import path_hp
import contact
import contact_hp
import txt_write
import job_parms
import hacks
import pyx
import rn
import sys
from math import sqrt, sin, cos, floor, ceil, inf, nan, pi

parms = job_parms.typical_js()
parms['solid_raster_width'] = 1.00
parms['contour_trace_width'] = 0.75

mp_jump = move_parms.make_for_jumps(parms)
mp_cont = move_parms.make_for_contours(parms)
mp_fill = move_parms.make_for_fillings(parms)

wd_fill = move_parms.width(mp_fill)
wd_cont = move_parms.width(mp_cont)

# Figures and number of sub-figures:

fignums = (
#   ( "input", 3),
  ( "zigzig", 1),
  ( "zigzag", 1),
#   ( "cold", 1),
#   ( "rivers", 2),
#   ( "canon", 1),
#   ( "blocks", 2),
)

def test_plot_figure(fig, SUBS):
  sys.stderr.write("--- testing {make_figure} fig = '%s'---\n" % fig)
  PCS,PFS,PLS,CCS,VGS,EGS = paper_figures_B.make_figure(fig, mp_cont, mp_fill, mp_jump) 
  for subfig in SUBS:
    sys.stderr.write("--- testing {plot_figure} fig = '%s' = subfig %d---\n" % (fig,subfig))
    name = "tests/out/paper_figures_B_TST_p_" + fig + ("_%d" % subfig)
    paper_figures_B.plot_figure(name, fig, subfig, wd_cont,wd_fill, PCS,PFS,PLS,CCS,VGS,EGS)
  return
  # ----------------------------------------------------------------------

def test_write_txt():
  sys.stderr.write("--- testing txt output ---\n")
  fname = "tests/out/paper_figures_B_TST.txt"
  PCS,PFS,PLS,CCS,VGS,EGS = paper_figures_B.make_figure("input", mp_cont, mp_fill, mp_jump) 
  wr = open(fname, "w")
  Z = 10.0
  angle = 0
  for oph in PFS: path_hp.set_group(oph,0)
  txt_write.write(wr, PCS, PFS, CCS, Z, angle)
  wr.close()
  return
  # ----------------------------------------------------------------------

test_write_txt()

for fig, nsub in fignums:
  test_plot_figure(fig, list(range(nsub)))
