Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Commit

Permalink
temporary settings for watermarks
Browse files Browse the repository at this point in the history
  • Loading branch information
AnsleyManke committed Sep 30, 2020
1 parent c780fe4 commit 240de90
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 75 deletions.
59 changes: 3 additions & 56 deletions JavaSource/resources/ferret/scripts/LAS_open_window.jnl
Original file line number Diff line number Diff line change
Expand Up @@ -50,66 +50,13 @@ IF `($win_aspect) GT 100` THEN DEFINE SYMBOL win_aspect = 1
IF `($win_aspect) LT 0.01` THEN DEFINE SYMBOL win_aspect = 1


! Set up the window. In PyFerret now use pixels to define the
! size and aspect ratio which will make the optional watermark
! easier to locate on the page.

! Here the value of symbol wmark is "ul" for the upper right-hand corner
! Settings for lower left is sketched out where this is used, in
! LAS_setup_watermark.jnl and set_full_margins.jnl.
! Set up the window. In PyFerret make the optional watermark
! on the page.


DEFINE SYMBOL wmark = 0
IF `($ferret_wmark_image"0|*>1") AND ($PROGRAM_NAME"|PyFerret>1|*>0) AND \
($ferret_version) GE 7.63` THEN DEFINE SYMBOL wmark = ul

! Watermark:
! The set window/aspect= /size= of classic Ferret sets up PPLUS symbols
! WITDTH and HEIGHT of the window. Here, set the window using pixel sizes
! with the larger dimension of size ~1000 pix for the typical setting of large plots,
! and assuming 100 pixels width for plot margins. This approximates the sizes we see
! in classic-Ferret and PyFerret using SET WINDOW/ASPECT.
! Placing the watermark in locations other than the upper left needs work. What
! is shown here when setting wmark=ll, to put it in the lower right, instead puts
! it about a third of the way above the bottom of the plot.

IF `($set_window_quals"0|*>1") EQ 0` THEN

IF ($PROGRAM_NAME"|PyFerret>1|*>0) THEN

! The sizes in ferret_size are 0.8333, 0.5, etc and are square roots of
! the nominal set win/size= settings in classic Ferret.

LET win_base_size = ($ferret_size"0.5")^0.5 * 1000

LET pix_xtra = 0.1* win_base_size

IF `($win_aspect) LE 1` THEN
LET pix_x = win_base_size
LET pix_y = win_base_size* ($win_aspect) + pix_xtra
ELSE
LET pix_y = win_base_size
LET pix_x = (win_base_size + pix_xtra*($win_aspect)) / ($win_aspect)
ENDIF

DEFINE SYMBOL set_window_quals = ($set_window_quals)/XPIXEL=`pix_x`/YPIXEL=`pix_y`

! Add any watermark settings added to set_window_quals

IF ($wmark"0|*>1") THEN GO LAS_setup_watermark

ELSE ! not pyferret,

DEFINE SYMBOL set_window_quals = ($set_window_quals)/SIZE=($ferret_size"0.5")

IF ($ferret_set_aspect"1|default>1|no>0|yes>1|0|1") THEN
IF `($region_x_range"0") NE 0 AND ($region_y_range"0") NE 0` THEN \
DEFINE SYMBOL set_window_quals = ($set_window_quals)/ASPECT = ($win_aspect):axis
ENDIF

ENDIF

ENDIF
($ferret_version) GE 7.63` THEN GO LAS_setup_watermark

! Open the window. For PyFerret, use /OUTLINE to take care of the pesky white-line issue
IF ($program_name"0|PyFerret>1|*>0") THEN DEFINE SYMBOL set_window_quals = ($set_window_quals)/OUTLINE=0.7 1
Expand Down
86 changes: 71 additions & 15 deletions JavaSource/resources/ferret/scripts/LAS_setup_watermark.jnl
Original file line number Diff line number Diff line change
@@ -1,26 +1,82 @@
! LAS_setup_watermark.jnl
! Add the settings for a watermark image to the
! quqlifiers in symbol set_window_quals
! qualifiers in symbol set_window_quals
!
! If they asked for a watermark, place it on the page. This uses "plot inches"
! expressed as fractions of 1000 measured from the upper-left corner.
! Make a plot to load pplus symbols

! How do we know what the size of the watermark image is?
! Assume it's ~100 pixels; The LAS configurer creates the right size image?
! The linux command returns the image info including size in pixels.
! Ferret properties for the dataset, variable or the entire LAS:
! * The image name
! * The (approx) image size, in pixels. Assumes 100 if not given.
! The linux command "identify" returns the image info including size in pixels:
! identify -ping imagefile.png
!
! * A scale factor to use, default 1
!
! * The opacity to use in percent, default 50
!
! * Where to place the watermark within the image. These are defined here:
! ulc, urc, llc, lrc upper left corner, upper right corner, lower left...
! uli, uli, lli, lri upper left within the image, ...
! More, such as centered along the bottom ?
!
! <ferret>
! <wmark_image>/home/users/ansley/socat_cat.png</wmark_image>
! <wmark_size>200</wmark_size>
! <wmark_scale>0.5</wmark_scale>
! <wmark_opacity>50</wmark_opacity>
! <wmark_loc>lli</wmark_loc>
! </ferret>
!

LET wmscale = 1 ! scale factor:
LET wmopac = 50 ! percent opacity
IF `($ferret_wmark_image"0|*>1") EQ 0` THEN EXIT/SCRIPT

! Watermark in the upper left
IF ($wmark"0|ul>1|*>0") THEN
LET wmxloc = 5 ! pixels from upper left corner
LET wmyloc = 5 ! pixels from upper left corner
LET wmsize = ($ferret_wmark_size"100|*") ! image size
LET wmscale = ($ferret_wmark_scale"1|*") ! scale factor to use
LET wmopac = ($ferret_wmark_opacity"50|*") ! opacity to use


! Location for the watermark within ghe plot

! ulc, urc, llc, lrc for upper left corner, upper right corner...
! By default, or if unrecognized value, use upper left corner

DEFINE SYMBOL wmark_loc = ($ferret_wmark_loc"ulc|uli|ulc|urc|llc|lrc|uli|uli|lli|lri|*>ulc|uli")

!!!! Right now the only one that works well is upper=left corner

DEFINE SYMBOL wmark_loc = ulc

! To account for the size of the watermark image.
let fudge = wmscale* wmsize

! Make a plot to get pplus symbols for this window

shade/x=0:1/y=0:1/nolab/noax x+y

show sym ppl$width, ppl$xorg, ppl$height, ppl$yorg
DEFINE SYMBOL x_rt_margin = `($ppl$width) - ($ppl$xlen) - ($ppl$xorg)`
DEFINE SYMBOL y_up_margin = `($ppl$height) - ($ppl$ylen) - ($ppl$yorg)`

show sym ppl$width, ppl$xlen, ppl$xorg, x_rt_margin
show sym ppl$height, ppl$ylen, ppl$yorg, y_up_margin


! Watermark in the upper left corner
IF ($wmark_loc"0|ulc>1|*>0") THEN
LET wmxloc = 5
LET wmyloc = 5
ENDIF

! Watermark in the lower left
IF ($wmark"0|ll>1|*>0") THEN
LET wmxloc = 5 ! pixels from upper left corner
LET wmyloc = pix_y - 100 ! pixels from upper left corner
! Watermark in the lower left corner
IF ($wmark_loc"0|llc>1|*>0") THEN
LET wmxloc = 5
LET wmyloc = 100* (($ppl$ylen) + ($y_up_margin)) - fudge
ENDIF

IF ($wmark"0|*>1") THEN DEFINE SYMBOL set_window_quals = ($set_window_quals)\

DEFINE SYMBOL set_window_quals = ($set_window_quals)\
/wmark="($ferret_wmark_image)"/wmscale=`wmscale`/wmopac=`wmopac`/wmxloc=`wmxloc`/wmyloc=`wmyloc`

SET WINDOW/CLEAR
8 changes: 4 additions & 4 deletions JavaSource/resources/ferret/scripts/set_full_margins.jnl
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@ IF `STRLEN("($ferret_view)") GE 2 AND ($win_aspect"1") LT 0.2` THEN
LET y_up_t = 0.99
ENDIF

IF ($wmark"0|*>1") THEN
IF ($wmark_loc"0|*>1") THEN

! These settings to make space for a watermark.
! Give the margin some extra vertial space. Note the
! viewport settings are in percentage of the window.

! These if putting it in the upper left corner.
IF ($wmark%|ul>1|*>0%) THEN
LET y_up = `y_up - 0.05`
IF ($wmark_loc%|ulc>1|*>0%) THEN
LET y_up = `y_up - 0.07`
LET y_up_t = `y_up_t - 0.1`
ENDIF

! These if putting it in the lower left
IF ($wmark%|ll>1|*>0%) THEN
IF ($wmark_loc%|llc>1|*>0%) THEN
LET y_dn = 0.16
ENDIF

Expand Down

0 comments on commit 240de90

Please sign in to comment.