# Last edited on 2008-02-04 12:48:51 by stolfi

TEST_FIGS := \
  sunview-03-orig-S22-75-12-000-22 \
  sunview-03-orig-S22-50-12-000-22 \
  sunview-03-orig-S22-25-12-000-22

SUNMETRIC_FIGS := \
  sunmetric-03-orig-S22-25-08-000-22 \
  sunmetric-03-orig-S22-25-09-000-22 \
  sunmetric-03-orig-S22-25-10-000-22 \
  sunmetric-03-orig-S22-25-11-000-22 \
  sunmetric-03-orig-S22-25-12-000-22 \
  \
  sunmetric-03-orig-S22-50-08-000-22 \
  sunmetric-03-orig-S22-50-09-000-22 \
  sunmetric-03-orig-S22-50-10-000-22 \
  sunmetric-03-orig-S22-50-11-000-22 \
  sunmetric-03-orig-S22-50-12-000-22 \
  \
  sunmetric-03-orig-S22-75-08-000-22 \
  sunmetric-03-orig-S22-75-09-000-22 \
  sunmetric-03-orig-S22-75-10-000-22 \
  sunmetric-03-orig-S22-75-11-000-22 \
  sunmetric-03-orig-S22-75-12-000-22

SUNVIEW_SAMPLE_FIGS := \
  sunview-01-orig-S22-75-12-000-22 \
  sunview-01-orig-S22-25-12-000-22 \
  sunview-01-orig-S22-50-12-000-22 \
  \
  sunview-02-orig-S22-75-09-000-22 \
  sunview-02-orig-S22-25-09-000-22 \
  sunview-02-orig-S22-50-09-000-22 \
  \
  sunview-02-orig-S22-75-12-000-22 \
  sunview-02-orig-S22-50-12-000-22 \
  sunview-02-orig-S22-25-12-000-22 \
  \
  sunview-03-orig-S22-75-12-000-22 \
  sunview-03-orig-S22-50-12-000-22 \
  sunview-03-orig-S22-25-12-000-22
  
CUTAWAY_FIGS := \
  cutaway-01-orig \
  cutaway-02-orig \
  cutaway-03-orig
  
SUNPATH_FIGS := \
  sunpath-S22

ALL_FIGS := \
  ${SUNMETRIC_FIGS} \
  ${SUNVIEW_SAMPLE_FIGS} \
  ${CUTAWAY_FIGS} \
  ${SUNPATH_FIGS } \

DO_FIGS := \
  ${SUNMETRIC_FIGS}
  
DONT_DO_FIGS :=
  
INCLUDES := \
  lights-detail.inc \
  camera.inc \
  coord-axes.inc \
  grid.inc \
  heater.inc \
  surrounds.inc \
  astronomy.inc \
  roof-mount.inc \
  heater-profile-01.inc \
  heater-profile-02.inc \
  heater-profile-03.inc \
  collector-orig.inc \
  collector-horiz.inc \
  scene-sunview.inc

.PHONY: \
  all single cleanup \
  make-params image showimage export
  
all: 
	for fig in ${DO_FIGS} ; do \
          ${MAKE} FIG=$$fig single ; \
        done
        
######################################################################
# Sub-makefile - caller must define ${FIG}

FIG := FIG.IS.UNDEFINED

ifneq "/${FIG}" "/FIG.IS.UNDEFINED"

FIELDS  := ${subst -, ,${FIG}}
SCENE     := ${word 1,${FIELDS}}

PARAMS := PARAMS.IS.UNDEFINED

ifeq "/${SCENE}" "/sunview"
######################################################################
# "sunview" scene

PROFILE   := ${word 2,${FIELDS}}
COLLTYPE  := ${word 3,${FIELDS}}
LATITUDE  := ${word 4,${FIELDS}}
SEASON    := ${word 5,${FIELDS}}
HOUR      := ${word 6,${FIELDS}}
ROOF_AZ   := ${word 7,${FIELDS}}
ROOF_INCL := ${word 8,${FIELDS}}

LATVAL := ${subst S,-,${subst N,+,${LATITUDE}}}

PARAMS := ${SCENE}-params.inc

make-params:
	@echo "// CREATED AUTOMATICALLY, ANY EDITS WILL BE LOST" > ${PARAMS}
	@printf '#declare profile = "%s"\n'         "${PROFILE}"   >> ${PARAMS}
	@printf '#declare colltype = "%s"\n'        "${COLLTYPE}"  >> ${PARAMS}
	@printf '#declare latitude = %s;\n'         "${LATVAL}"    >> ${PARAMS}
	@printf '#declare season = 0.%s;\n'         "${SEASON}"    >> ${PARAMS}
	@printf '#declare hour = %s;\n'             "${HOUR}"      >> ${PARAMS}
	@printf '#declare roof_azimuth = %s;\n'     "${ROOF_AZ}"   >> ${PARAMS}
	@printf '#declare roof_inclination = %s;\n' "${ROOF_INCL}" >> ${PARAMS}
        
WIDTH := 400
HEIGHT := 400
ICONWIDTH := 80
ICONHEIGHT := 80
NRAYS := 2

IMVIEW := display -title '%f'

# End sunview scene
######################################################################
endif

ifeq "/${SCENE}" "/sunmetric"
######################################################################
# "sunmetric" scene

PROFILE   := ${word 2,${FIELDS}}
COLLTYPE  := ${word 3,${FIELDS}}
LATITUDE  := ${word 4,${FIELDS}}
SEASON    := ${word 5,${FIELDS}}
HOUR      := ${word 6,${FIELDS}}
ROOF_AZ   := ${word 7,${FIELDS}}
ROOF_INCL := ${word 8,${FIELDS}}

LATVAL := ${subst S,-,${subst N,+,${LATITUDE}}}

PARAMS := ${SCENE}-params.inc

make-params:
	@echo "// CREATED AUTOMATICALLY, ANY EDITS WILL BE LOST" > ${PARAMS}
	@printf '#declare profile = "%s"\n'         "${PROFILE}"   >> ${PARAMS}
	@printf '#declare colltype = "%s"\n'        "${COLLTYPE}"  >> ${PARAMS}
	@printf '#declare latitude = %s;\n'         "${LATVAL}"    >> ${PARAMS}
	@printf '#declare season = 0.%s;\n'         "${SEASON}"    >> ${PARAMS}
	@printf '#declare hour = %s;\n'             "${HOUR}"      >> ${PARAMS}
	@printf '#declare roof_azimuth = %s;\n'     "${ROOF_AZ}"   >> ${PARAMS}
	@printf '#declare roof_inclination = %s;\n' "${ROOF_INCL}" >> ${PARAMS}
        
WIDTH := 100
HEIGHT := 100
ICONWIDTH := 25
ICONHEIGHT := 25
NRAYS := 2

IMVIEW := echo

# End sunmetric scene
######################################################################
endif

ifeq "/${SCENE}" "/cutaway"
######################################################################
# "cutaway" scene

PROFILE   := ${word 2,${FIELDS}}
COLLTYPE  := ${word 3,${FIELDS}}

PARAMS := ${SCENE}-params.inc

make-params:
	@echo "// CREATED AUTOMATICALLY, ANY EDITS WILL BE LOST" > ${PARAMS}
	@printf '#declare profile = "%s"\n'  "${PROFILE}"   >> ${PARAMS}
	@printf '#declare colltype = "%s"\n' "${COLLTYPE}"  >> ${PARAMS}

WIDTH := 400
HEIGHT := 400
ICONWIDTH := 80
ICONHEIGHT := 80
NRAYS := 2

IMVIEW := display -title '%f'

# End cutaway scene
######################################################################
endif

ifeq "/${SCENE}" "/sunpath"
######################################################################
# "sunpath" scene

LATITUDE  := ${word 2,${FIELDS}}

LATVAL := ${subst S,-,${subst N,+,${LATITUDE}}}

PARAMS := ${SCENE}-params.inc

make-params: 
	@echo "// CREATED AUTOMATICALLY, ANY EDITS WILL BE LOST" > ${PARAMS}
	@printf '#declare latitude = %s;\n'   "${LATVAL}"    >> ${PARAMS}

WIDTH := 400
HEIGHT := 400
ICONWIDTH := 80
ICONHEIGHT := 80
NRAYS := 2

IMVIEW := display -title '%f'

# End sunpath scene
######################################################################
endif

ICONFIG = ${FIG}-i

POVPUB = ${STOLFIHOME}/pkg/povray-3.50c-1/PUB
POVRAY = ${POVPUB}/i686-Linux-2.2/bin/povray
POVINC = ${POVPUB}/share/povray-3.5/include
POVTTF = ${STOLFIHOME}/PUB/povray/tt-fonts
CONVERT = convert

single: image showimage
# single: image
	@echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"

cleanup: 
	-/bin/rm -f ${FIG}.png

image: ${FIG}.png

showimage: ${FIG}.png
	-${IMVIEW} ${FIG}.png

${FIG}.png: ${SCENE}.pov make-params ${INCLUDES}
	@echo "@@@ ${FIG} @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
	-/bin/rm -f ${FIG}.png
	nice ${POVRAY} \
            +FN +Q9 \
            +W${WIDTH} +H${HEIGHT} \
            +AM1 +A0.0 +R${NRAYS} \
            +D +SP32 +EP4 \
            +L${POVINC} \
            +L${POVTTF} \
	    +I${SCENE}.pov \
	    +O${FIG}.png

${ICONFIG}.jpg: ${FIG}.jpg
	convert ${FIG}.png \
            -quality 99 \
            -resize 'x${ICONHEIGHT}' \
            ${ICONFIG}.jpg
        
endif
# End ${FIG} sub-makefile.
######################################################################

ALL_PNGS := ${addsuffix .png,${ALL_FIGS}}

EXDIR := ${STOLFIHOME}/public_html/lazo-heater

export: ${EXDIR} ${ALL_PNGS}
	cp -av ${ALL_PNGS} ${EXDIR}
        
