#!/bin/sh
# Every figure of the command-line figure tutorial, from one script.
#
#   python make_inputs.py          # writes the illustrative input archives
#   sh figures.sh                  # writes the figures into figures/
#
# Set VV to run another vibe-viewer, for example a source checkout:
#   VV="python -m vibeviewer" sh figures.sh
set -e
VV="${VV:-vibe-viewer}"
OUT="${OUT:-figures}"
mkdir -p "$OUT"

# 1. Four structures with one camera convention, as a two-column PDF.
#    A slab has no 3D cell, so the shared view is a Cartesian direction.
CAMERA="--view 1,0.35,0.2 --orthographic --background white --publication --dpi 600 --width-mm 88 --size 4x3"
for name in diamond rocksalt zincblende slab; do
  $VV capture "$name.qvf" $CAMERA -o "$OUT/$name.png"
done
$VV figure "$OUT/diamond.png" "$OUT/rocksalt.png" "$OUT/zincblende.png" "$OUT/slab.png" \
  --width-mm 178 -o "$OUT/structures.pdf"

# 2. The same zincblende cell as vector line art, looking down [110].
$VV capture zincblende.qvf --uvw 1,1,0 --background white --width-mm 85 -o "$OUT/zincblende-110.svg"

# 3. Band structure beside its DOS, and the DOS alone, as journal charts.
$VV capture model-bands.qvf -s bands --dos dos --width-mm 85 --size 3x2 -o "$OUT/bands-dos.pdf"
$VV capture model-bands.qvf -s dos --font serif --font-size 9 --width-mm 60 -o "$OUT/dos.svg"

# 4. The 54-atom (3,3,3) cyclic cluster of MgO about one Mg atom, with its
#    boundary weights, ghosted images and translation vectors.
$VV capture mgo-primitive.qvf --wigner-seitz 3,3,3 --ws-center "element Mg" \
  --ws-weights colour --ws-cluster --background white --no-cell \
  --view 1,0.35,0.2 --orthographic --dpi 600 --width-mm 85 -o "$OUT/mgo-cluster.png"

# 5. Labelled boundary sites of a smaller (2,2,2) supercell, to read images off.
$VV capture mgo-primitive.qvf --wigner-seitz 2,2,2 --ws-center "element Mg" \
  --ws-weights colour --ws-labels image --background white --no-cell \
  --view 1,0.35,0.2 --orthographic --size 1400x1000 -o "$OUT/mgo-labels.png"

# 6. A periodic pore channel with its numbers written beside the image.
$VV capture rods.qvf --pores --pore-probe 1.8 --pore-convergence \
  --pore-report "$OUT/rods-pores.json" --background white \
  --view 0.3,-1,0.6 --size 900x700 -o "$OUT/rods-pores.png"

echo "Figures in $OUT/"
