;+
; NAME
; 	Customize_1D
; PURPOSE:
;	To change interactively with the help of menus
;	some system variable values, the shift
;	between plots for mdisp, allows to write text
;	on the display and redefine the default values for
;	postscript plots.
; CATEGORY:
; 	User interface
; CALLING SEQUENCE:
;	Customize_1D
; SIDE EFFECT
;	Uses menus and, on vt300 terminals, erases the display.
; RESTRICTION:
;	Use only in interactive mode.
;
; MODIFICATION HISTORY:
;	Created in June 1991 by A.Csillaghy, ETHZ
;	Modif. for sixel printing, Dec. 92, A.Cs
;-

PRO PSSpecif

;
; PURPOSE: changes in the postscript plot sizes
;

  GetPSSizes, xPos, yPos, width, height, landscape, color, encaps, logo

  psMenuLen = 10
  
  psMenu = StrArr( psMenuLen )
  psMenu( 0 ) = ' X origin: ' + StrTrim( xPos, 2 ) + ' cm'
  psMenu( 1 ) = ' Y origin: ' + StrTrim( yPos, 2 )+ ' cm'
  psMenu( 2 ) = ' Width: ' + StrTrim( width, 2 )+ ' cm'
  psMenu( 3 ) = ' Height: ' + StrTrim( height, 2 )+ ' cm'
  IF encaps EQ 0 THEN psMenu(4) = 'Not encapsulated' $
  ELSE psMenu(4) = 'Encapsulated mode'
  IF landscape THEN psMenu( 5 ) = 'Landscape mode' $
  ELSE psMenu( 5 ) = 'Portrait mode '
  IF color THEN psMenu( 5 ) = 'Color mode' $
  ELSE psMenu( 6 ) = 'Black/White mode '
  IF logo THEN psMenu(7) = 'Print Logo on the Bottom of the Page' $
  ELSE psMenu(7) = 'Dont  Print the Logo'
  psMenu(8 ) = 'Exit Poststcript Specification Menu'
  psMenu( 9 ) = 'Redisplay this Menu'

  REPEAT BEGIN

    choice = General_Menu( psMenu, $
	'Choose the attribute to change or exit' )
    CASE choice OF
      1: BEGIN
            Read_Test, 'Please enter the x origin in cm.', xPos, xPosP
            xPos = xPosP < 100 > 0
            psMenu( 0 ) = ' X origin: ' + StrTrim( xPos, 2 ) + ' cm'
          END
      2: BEGIN
            Read_Test, 'Please enter the y origin in cm.', yPos, yPosP
            yPos = yPosP < 100 > 0
            psMenu( 1 ) = ' Y origin: ' + StrTrim( yPos, 2 )+ ' cm'
          END
      3: BEGIN
            Read_Test, 'Please enter the width in cm.', width, widthP
            width = widthP < 100 > 0
            psMenu( 2 ) = ' Width: ' + StrTrim( width, 2 )+ ' cm'
          END
      4: BEGIN
            Read_Test, 'Please enter the height in cm.', height, heightP
            height = heightP < 100 > 0
            psMenu( 3 ) = ' Height: ' + StrTrim( height, 2 )+ ' cm'
          END
      5: BEGIN
            IF encaps EQ 1  THEN BEGIN
              encaps = 0
              psMenu( 4 ) = 'Not encapsulated'
            ENDIF ELSE BEGIN
              encaps = 1
              psMenu(4) = 'Encapsulated mode'
            ENDELSE
          END
      6:BEGIN
            IF landscape THEN BEGIN
              landscape = 0
              psMenu( 5 ) = 'Portrait mode'
            ENDIF ELSE BEGIN
              landscape = 1
              psMenu(5) = 'Landscape mode'
            ENDELSE
          END
      7: BEGIN
            IF  color  EQ 0 THEN BEGIN
              color = 1
              psMenu( 6 ) = 'Color mode ( after using once not reversible) '
            ENDIF ELSE BEGIN
              color = 0
              psMenu( 6 ) = 'Black/White mode'
            ENDELSE
          END
        8: BEGIN
            IF  logo  EQ 0 THEN BEGIN
              logo = 1
              psMenu( 7 ) = 'Print Logo on the Bottom of the Page '
            ENDIF ELSE BEGIN
              logo = 0
              psMenu( 7 ) = 'Do not Print the Logo'
            ENDELSE
          END
      ELSE:
    ENDCASE
  END UNTIL choice EQ psMenuLen-1

  PutPSSizes, xPos, yPos, width, height, landscape, color, encaps, logo

END ; postscript Specif

  
PRO ChangeAttr, text, array, index, result, $
	NUMBER = number

  IF NOT Keyword_Set( NUMBER ) THEN BEGIN
    result = ''
    Read, 'Please enter the new '+ text + ': ', result
    array( index ) = text + ': ' + result
  ENDIF ELSE BEGIN
    default = result
    Read_Test, 'Please enter the new ' + text, default, result
    array( index ) = text + ': ' + String( result )
  ENDELSE

END ; change an attribute

PRO SinglePlots

;
; PURPOSE: changes in the single plots attributes
;

  IF No_Data() THEN BEGIN
    Error, 12, 'Single Plot Attributes'
    RETURN
  ENDIF

  namesMenu = GetNames( )
  idx = General_Menu( namesMenu, 'Select one plot ' )
  lsText = [ 'Solid', 'Dotted', 'Dashed', 'Dash Dot', $
	'Dash Dot Dot Dot', 'Long Dashes' ]
  symText = [ 'No Symbol', 'Plus Sign', 'Asterisk', 'Period', $
	'Diamond', 'Triangle', 'Square', 'X', 'User Defined', ' ', $
	'Histogram Style' ]

  LoadPlot, namesMenu( idx-1 ), len,d,d, d, d,d, $
                    title,  xTitle,  yTitle,  text,  color, $
 	lineStyle,  thick,  offset,  subTitle, overallQual, symsize

  singleLineStyle = lineStyle( 0 )

  length = 13
  attribute = StrArr( length  )
  attribute(0) = 'Title: ' + title
  attribute(1) = 'Subtitle: ' +  subTitle
  attribute(2) = 'X axis title: ' + xTitle
  attribute(3) = 'Y axis title: ' + yTitle
  attribute(4) = 'Color number: ' + String( Fix(color) )
  attribute(5) = 'Line style: ' + lsText( singleLineStyle )
  attribute(6) = 'Line thick: ' + String( thick )
  attribute(7) = 'Offset: ' + String( offset )

    attribute(8) = 'Overall symbol used: ' + symText( ABS(overallqual) )
    IF overallQual LE 0 THEN  $
      attribute(9) = 'Points connected by lines ' $
    ELSE attribute(9) = 'Points not connected by lines '

  attribute(10) = 'Symbol Size: ' + String( symsize )
  attribute(length-2) = 'Exit Change Plot Attributes'
  attribute(length-1) = 'Redisplay this Menu'

  opaque = BytArr(length )
  opaque(4) = 1B

  REPEAT BEGIN
    
    choice = General_Menu( attribute, 'Change Plot Attribute', $
	OPAQUE = opaque )

    CASE choice OF
      1: ChangeAttr, 'new title', attribute, 0, title
      2: ChangeAttr, 'new subtitle', attribute, 1, subtitle
      3: ChangeAttr, 'X axis title', attribute, 2, xTitle
      4: ChangeAttr, 'Y axis title', attribute, 3, yTitle
      5: BEGIN
            Read_Test, 'Please enter the new color number (0 .. 255) ',  $
	255,  color
            attribute(4) = 'Color number: ' + String( Fix( color ))
            color = Byte( color )
          END
       6: BEGIN
            singleLineStyle = (singleLineStyle + 1) MOD 6
            lineStyle = lineStyle*0 + singleLineStyle
            attribute(5) = 'Line style: ' + lsText( singleLineStyle )
          END
       7: ChangeAttr, 'line thickness', attribute, 6, thick, /NUMB
       8: ChangeAttr, 'offset', attribute, 7, offset, /NUMB
       9: BEGIN
             IF overallQual LE 0 THEN sign = -1 ELSE sign = +1
             overallQual = sign*(( ABS(overallQual) + 1 ) MOD 10 )
             IF ABS(overallQual) EQ 9 THEN overallQual = sign*10
             attribute(8) = 'Overall symbol used: ' $
	+ symText(ABS(overallQual) )
           END
       10: BEGIN
             overallQual = - overallQual
             IF overallQual LE 0 THEN $
               attribute(9) = 'Points connected by lines ' $
             ELSE attribute(9) = 'Points not connected by lines '
           END
         11: ChangeAttr, 'symbol size', attribute, 10, symsize, /NUMB
    ELSE:
    ENDCASE
  END UNTIL choice EQ length-1
 
  !p.title = title  & !p.subtitle = subtitle
  !x.title = xtitle & !y.title = ytitle

  IF overallQual EQ -10 THEN overallQual = 10 

  InsertPlot, namesMenu( idx-1 ), len, ud, ud, ud, ud, ud, $
	color, lineStyle, thick, offset, overallQual,  userSym, $
	title, xTitle,  yTitle,  subtitle, text, symsize

END ; single plots


PRO Customize_1D

mainMenuLength = 8
mainMenu=StrArr(mainMenuLength)

mainMenu(0)= 'Plot Attributes ... '
mainMenu(1)= 'Display Attributes ... '
mainMenu(2)= 'Texts to Overplot ...'
mainMenu(3)= 'Print File Attributes ...  '
mainMenu(4)= 'Redisplay Plot'
mainMenu(5)= 'Make PostScript File / Print'
mainMenu(6)= 'Return to Main Menu'
mainMenu(7) = 'Redisplay this Menu'
choice = 0

REPEAT BEGIN

  change = General_Menu(mainMenu, $
	'Customize: Choose What to Change', $
	OPAQUE = [ 0,0,0,0,0,0,0,1])
  CASE change OF
    1: SinglePlots
    2: OverallDisplay
    3: Overplot_Texts
    4: PSSpecif
    5: Data_Display, /MDISP
    6: BEGIN
          PrintInterface, status, /MDISP
          PS_Create_1D, /MDISP
          PrintInterface, status, /MDISP, /PRINT
        END
    ELSE:
  ENDCASE
END UNTIL change EQ mainMenuLength-1


END
