!******************************************************************************!
! Test for plotting a Type 2000 SL & QB datafile over a map which contains the actual (ARGB) colors
! (with transparency alpha values) to display on the Layer2D.
! This macro also tests the unconfigured nxm.sys.prim.convertargb primitive.
! This is a new test to see if this is a means of plotting rasters on top of each other
! for Jeremy's evaluation
!
! @issue   NXM-3598
! @author  Jeanette McCall
! Since:   NeXtMidas 3.9.3
!******************************************************************************!
startmacro l:defaultAlpha[128]
  switch INTERACTIVE interAct GET DEF=TRUE  SDEF=TRUE  ! for normal interactive test(s)
  switch BASELINE    baseline GET DEF=FALSE SDEF=TRUE  ! for defects or more obscure test case(s)

  set testfile_1           test_raster1.tmp{AUX=RAM}
  set testfile_2           test_raster2.tmp{AUX=RAM}
  set testfile_3           test_raster3.tmp{AUX=RAM}

  if interAct then
    call createRaster testfile_1 2 red    ! raster plot with bin 2 red
    call createRaster testfile_2 4 green
    call createRaster testfile_3 6 blue

    set instructions "3 raster plots, each with {LAYER={DC=true}}, are plotted on top of each other.\n\n&
                      Each raster plot has all the bins but one be java.awt.Color(0,0,0,0).\n\n&
                      The bin that does have color is increasing in alpha.\n\n&
                      RASTER:\n&
                      1 - has red in the second bin\n&
                      2 - has green in the forth bin\n&
                      3 - has blue in the sixth bin"
    pipe init
      panel/msgid=MAIN/setup/controls=gc
      gcontrol label mainLabel "Main"
        gcontrol menu main "Exit with Status = " "PASS,FAIL" /tleft
        set gc.main.itemColors {PASS=GREEN,FAIL=RED}
        gcontrol text idtext "Instructions" "^{instructions}" 30 20 /title

      plot/id=3rasterplots ^testfile_1{LAYER={DC=true}}|^testfile_2{LAYER={DC=true}}|^testfile_3{LAYER={DC=true}} view=iYX

    pipe off

  endif
endmacro

!******************************************************************************!
procedure processMessage m:msg
  !say "msg.name ^msg.name, data ^msg.data"

  if msg.name eqs "MAIN" then
    assert/text="^reg.main.name: User indicated tests for Layer2D using Direct Colors" msg.data eqss "PASS"
    pipe stop
  else
    ! do nothing
    say "Unhandled message name: ^msg.name from fid: ^msg.fid data: ^msg.data"
  endif

return

!******************************************************************************!
! Create an color bar of specified color image with increasing alpha
! values from completely translucent (alpha=0) to completely opaque (alpha=255).
! Put image in the middle of Canada.
procedure createRaster FN:outfilename S:stripe s:clr
  set l:fs 7
  file open/d/n outfile ^outfilename{TYPE=2000,FORM=SL,FS=^fs}

  ! generate RGB colors from translucent to opaque
  do l:i 0 255 1
    table tab create
    new java.awt.Color(i,0,0,i) red
    new java.awt.Color(0,i,0,i) green
    new java.awt.Color(0,0,i,i) blue
    new java.awt.Color(0,0,0,0) blk
    set tab.F1 blk.rgb
    set tab.F2 blk.rgb
    set tab.F3 blk.rgb
    set tab.F4 blk.rgb
    set tab.F5 blk.rgb
    set tab.F6 blk.rgb
    set tab.F7 blk.rgb
    set tab.F^stripe ^{clr}.rgb

    file write outfile tab
  enddo
  file close outfile

return
