
! script name: plot.d/autoplotview
! topic: Sample - main view plotted on plotter at maximum scale

!A
!A NAME:
!A
!A 	Plot a View
!A
!A DESCRIPTION:
!A
!A	This script is for plotting a view on a plotter.  The Main View
!A 	is plotted on the plotter at the maximum scale allowed.
!A
!B INSTRUCTIONS:
!B
!B 	INPUT PAPER SIZE A B C D E: Enter the paper size to be used for
!B 	plotting.
!B
!C NOTES:
!C
!C 	The A size is the default paper.  The data files for the different
!C 	size paper are in:
!C
!C 	         "/usr/weber/util/tooldata/plotconfig"
!C
!C 	The files may need to be modified depending on the type of plotter
!C 	being used.  New files may be added by following the format of the
!C 	other files.  If a new file is added, make sure the option is added
!C 	to the question and answer selections.
!C
!C NOTE:
!C
!C 	This is an unsupported sample script.
!C

stat=ChangeLabelStr("ScriptNameStatus","Function: plot a view ")

OPTION BASE 1
DIM Destination$[256]
DIM Answer$[256]
DIM Filename$[256]
DIM Namelist$[32000]
DIM Plotname$[256]


Plot_to_device=1 ! 1 sends plot to device through synplot.ksh


! Generate plotfile name
Namelist$= DirectoryNamesStr("./","*",WsAscending,"plotfile",".hpgl")
IF NOT POS(Namelist$,"plotfile") THEN
        Plotname$="plotfile1.hpgl"
ELSE
        A$= NextNumberedName(Namelist$,"plotfile",",")
        Plotname$=A$&".hpgl"
END IF
PRINT Plotname$



P1x= -4500
P1y= -2790
P2x= 4500
P2y= 2790

Filename$="/usr/weber/util/tooldata/plotconfig"

Stat=SetInputFormat("a1",",A,B,C,D,E,")
Stat= GetValue("INPUT PAPER SIZE A B C D E ",Answer$)
IF (ExitScript(Destination$)) THEN Leave

CALL Setlinetypes(Answer$)

Filename$=FileNameString(Filename$,Answer$&"size")
Plot_config=ReadUserData(2013,"PLOT CONFIG",Filename$)
IF (NOT (ValidGeometry(Plot_config))) THEN Start
P1x=GetUserValue(Plot_config,"P1x:")
P1y=GetUserValue(Plot_config,"P1y:")
P2x=GetUserValue(Plot_config,"P2x:")
P2y=GetUserValue(Plot_config,"P2y:")

Start:Plotter_view= FindView("PLOTTER")
IF NOT Plotter_view THEN
	xmin= -10
	xmax= 10
	ymin= -10
	ymax= 10
	stat= MakePlotterView("PLOTTER",Plotname$,xmin,xmax,ymin,ymax,p1x,p1y,p2x,p2y)
	GOTO Start
ELSE
	Stat= ChPlotterViewFile(Plotter_view,Plotname$)
END IF

Source_view= 1
stat= OutputString(Plotname$,CHR$(10),WsNewFile)
stat= CopyViewTrans(Plotter_view,Source_view)
stat= CopyViewScale(Plotter_view,Source_view)
stat= TurnViewOn(Plotter_view)
UpdatePlot
stat= TurnViewOff(Plotter_view)
stat= OutputString(Plotname$,CHR$(10),WsAppend)

IF Plot_to_device THEN
	stat= StartProcess("synplot.ksh "&Plotname$&" &")
END IF

Leave:!
Stat= DeleteEntity(Plot_config)
Stat=SetInputFormat("n4","")
IF (NOT LEN(Destination$)) THEN
         LOAD "typecontrol"
ELSE
         LOAD Destination$
END IF
END

SUB Setlinetypes(Answer$)
SELECT Answer$
CASE "A"
	stat= PlotLineTypeMap(2,"LT1,3")
	stat= PlotLineTypeMap(3,"LT1,5")
	stat= PlotLineTypeMap(4,"LT1,1.5")
	stat= PlotLineTypeMap(5,"LT2")
	stat= PlotLineTypeMap(6,"LT4")
	stat= PlotLineTypeMap(7,"LT5")
	stat= PlotLineTypeMap(8,"LT6")
	stat= PlotLineTypeMap(9,"LT")
	stat= PlotLineTypeMap(10,"LT5")
	stat= PlotLineTypeMap(11,"LT2")
	stat= PlotLineTypeMap(12,"LT6")
	stat= PlotLineTypeMap(13,"LT2")
	stat= PlotLineTypeMap(14,"LT6")
	stat= PlotLineTypeMap(15,"LT5")
CASE "B"
	stat= PlotLineTypeMap(2,"LT1,1")
	stat= PlotLineTypeMap(3,"LT1,2")
	stat= PlotLineTypeMap(4,"LT1,.5")
	stat= PlotLineTypeMap(5,"LT2,2")
	stat= PlotLineTypeMap(6,"LT4")
	stat= PlotLineTypeMap(7,"LT5")
	stat= PlotLineTypeMap(8,"LT6")
	stat= PlotLineTypeMap(9,"LT")
	stat= PlotLineTypeMap(10,"LT5")
	stat= PlotLineTypeMap(11,"LT2")
	stat= PlotLineTypeMap(12,"LT6")
	stat= PlotLineTypeMap(13,"LT2")
	stat= PlotLineTypeMap(14,"LT6")
	stat= PlotLineTypeMap(15,"LT5")
CASE "C"
	stat= PlotLineTypeMap(2,"LT1,.75")
	stat= PlotLineTypeMap(3,"LT1,1.5")
	stat= PlotLineTypeMap(4,"LT1,.375")
	stat= PlotLineTypeMap(5,"LT2,2")
	stat= PlotLineTypeMap(6,"LT4,1")
	stat= PlotLineTypeMap(7,"LT5,2")
	stat= PlotLineTypeMap(8,"LT6,2")
	stat= PlotLineTypeMap(9,"LT")
	stat= PlotLineTypeMap(10,"LT5,1")
	stat= PlotLineTypeMap(11,"LT2,2")
	stat= PlotLineTypeMap(12,"LT6,2")
	stat= PlotLineTypeMap(13,"LT2,2")
	stat= PlotLineTypeMap(14,"LT6,2")
	stat= PlotLineTypeMap(15,"LT5,2")
CASE "D"
	stat= PlotLineTypeMap(2,"LT1,.75")
	stat= PlotLineTypeMap(3,"LT1,1.5")
	stat= PlotLineTypeMap(4,"LT1,.375")
	stat= PlotLineTypeMap(5,"LT2,.5")
	stat= PlotLineTypeMap(6,"LT4,1")
	stat= PlotLineTypeMap(7,"LT5,2")
	stat= PlotLineTypeMap(8,"LT6,2")
	stat= PlotLineTypeMap(9,"LT")
	stat= PlotLineTypeMap(10,"LT5,1")
	stat= PlotLineTypeMap(11,"LT2,2")
	stat= PlotLineTypeMap(12,"LT6,2")
	stat= PlotLineTypeMap(13,"LT2,2")
	stat= PlotLineTypeMap(14,"LT6,2")
	stat= PlotLineTypeMap(15,"LT5,2")
CASE "E"
	stat= PlotLineTypeMap(2,"LT1,.5")
	stat= PlotLineTypeMap(3,"LT1,1")
	stat= PlotLineTypeMap(4,"LT1,.25")
	stat= PlotLineTypeMap(5,"LT2,.375")
	stat= PlotLineTypeMap(6,"LT4,1")
	stat= PlotLineTypeMap(7,"LT5,1.5")
	stat= PlotLineTypeMap(8,"LT6,1.5")
	stat= PlotLineTypeMap(9,"LT")
	stat= PlotLineTypeMap(10,"LT5,1")
	stat= PlotLineTypeMap(11,"LT2,2")
	stat= PlotLineTypeMap(12,"LT6,2")
	stat= PlotLineTypeMap(13,"LT2,2")
	stat= PlotLineTypeMap(14,"LT6,2")
	stat= PlotLineTypeMap(15,"LT5,2")
END SELECT
SUBEND
