NB. Plot viewer

coclass 'jdplot'

plotrun=: 3 : 0
0!:100 y.
pd 'show'
)

plotruns=: 3 : 0
0!:100 ". y.
pd 'show'
)

PLTIMER=: 3000
IFWINCE=: 7=9!:12''
PLDEMOVER=: 5.04
SLIDES=: 0

NB. =========================================================
PLOTDEMO=: 0 : 0
pc plotdemo closeok;pn "Plot";
menupop "&Options";
menu view "&View Definition" "" "" "";
menusep;
menu clip "&Clip" "" "" "";
menusep;
menu saveeps "&Save EPS" "" "" "";
menusep;
menu savepdf "&Save PDF" "" "" "";
menusep;
menu print "&Print" "" "" "";
menusep;
menu slides "&Slide Show" "" "" "";
menusep;
menu exit "E&xit" "" "" "";
menupopz;
menupop "&2D";
menu MJGRAPHICS "J Plot" "" "" "";
menusep;
menu MLINE "Line Plots" "" "" "";
menusep;
menu MLINES "Line Sampler" "" "" "";
menu MLINESTYLE "Line Options" "" "" "";
menu MLINE2Y "Line Second Y Axes" "" "" "";
menu MLINEPATTERN "Line Patterns" "" "" "";
menusep;
menu MAREA "Area" "" "" "";
menu MDOT "Dot" "" "" "";
menu MMARKER "Marker" "" "" "";
menu MSYMBOL "Symbol" "" "" "";
menu MPOLAR "Polar" "" "" "";
menu MSTICK "Stick" "" "" "";
menusep;
menu MBAR "Bar" "" "" "";
menu MBARS "Bar Sampler" "" "" "";
menu MHIST "Histogram" "" "" "";
menusep;
menu MERRORBAR "Error Bar" "" "" "";
menu MHILO "HiLo" "" "" "";
menusep;
menu MPIE "Pie" "" "" "";
menu MRADAR "Radar" "" "" "";
menusep;
menu MPOLY "Poly" "" "" "";
menusep;
menu MCONTOUR "Contour" "" "" "";
menu MDENSITY "Density" "" "" "";
menupopz;
menupop "&3D";
menu MLINE3D "Line" "" "" "";
menu MSTICK3D "Stick" "" "" "";
menu MWIRE "Wire" "" "" "";
menusep;
menu MSURFACE "Surface" "" "" "";
menu MSURFACEREV "Surface of Revolution" "" "" "";
menusep;
menu MSURFACES "Surface Sampler" "" "" "";
menusep;
menu MSPHERE "Sphere" "" "" "";
menusep;
menu MSOLID "Solids" "" "" "";
menu MSTELLATE "Stellates" "" "" "";
menupopz;
menupop "&Multi";
menu MMULTI1 "Simple Multiplot" "" "" "";
menusep;
menu MMULTI2 "Y Grouped Multiplot" "" "" "";
menusep;
menu MMULTI3 "XY Grouped Multiplot" "" "" "";
menusep;
menu MMULTI4 "Mixed Multiplot" "" "" "";
menupopz;
menupop "&Styles";
menu MSAMPLER "Plot Sampler" "" "" "";
menu MRULE "Rule Sampler" "" "" "";
menu MKEYS "Key Styles" "" "" "";
menusep;
menu MCOLOR1 "Style 1" "" "" "";
menu MCOLOR2 "Style 2" "" "" "";
menu MCOLOR3 "Style 3" "" "" "";
menusep;
menu MLOGS "Log Examples" "" "" "";
menupopz;
menupop "&Gallery";
menu MLINE1 "Line 1" "" "" "";
menu MLINE2 "Line 2" "" "" "";
menusep;
menu MCURVEFIT "Curve Fitting" "" "" "";
menu MLEGENDRE "Legendre" "" "" "";
menu MPRIMERACE "Prime Race" "" "" "";
menu MCONTOUR1 "Contour vs Density" "" "" "";
menusep;
menu MPAT1 "Patterns 1" "" "" "";
menu MPAT2 "Patterns 2" "" "" "";
menusep;
menu MWIRES "Wire" "" "" "";
menu MGAMMA "Gamma Function" "" "" "";
menu MDRUM "Drum" "" "" "";
menu MSURFACE1 "Surface" "" "" "";
menupopz;
menupop "&Help";
menu next "&F12 Next" "" "" "";
menu prev "&Shift F12 Previous" "" "" "";
menusep;
menu about "&About" "" "" "";
menupopz;
xywh 0 0 360 260;cc ps isigraph rightmove bottommove;
pas 0 0;pcenter;ptop;
rem form end;
)

NB. =========================================================
plotdemo_run=: 3 : 0

f=. jpath '~system\packages\graphics\'&, @ (,&'.ijs')
DATHILO=: }. 'm' fread jpath '~system\examples\data\dm0396.txt'

MyPlotDefaults=: '' NB. turn off user defaults

if. 0 ~: 4!:0 <'PLDEMOSEL' do.
  PLDEMOSEL=: 'JGRAPHICS'
end.

ASPECT=: 170%270
IfVGA=: 640>:{.0".wd 'qm'
PShow=: 0

wd PLOTDEMO
PForm=: 'plotdemo'
PFormhwnd=: wd 'qhwndp'
PId=: 'ps'
pd 'reset ',PForm
wd 'set M',PLDEMOSEL,' 1'

glbrush glrgb GRAY
glrect 0 0 1000 1000

NB. hard code CE form:
if. IFWINCE do.
  wd 'pmovex 220 -23 400 260'
  wd 'setenable clip 0'
  wd 'setenable print 0'
  wd 'setenable slides 0'
end.

plotruns 'D',PLDEMOSEL
)

NB. =========================================================
plotdemo_default=: 3 : 0
if. systype -: 'button' do.
  name=. }.syschild
  if. name -: PLDEMOSEL do.
    wd 'set M',PLDEMOSEL,' 1'
    return.
  end.
  if. (<name) e. PLOTNAMES do.
    wd 'set M',PLDEMOSEL,' 0'
    PLDEMOSEL=: name
    wd 'set M',PLDEMOSEL,' 1'
    pd 'reset ',PForm
    plotruns 'D',PLDEMOSEL
  end.
end.
''
)

NB. =========================================================
plotdemo_view_button=: 3 : 0
gedit_run PLDEMOSEL
)

NB. =========================================================
plotdemo_exit_button=: 3 : 0
wd 'psel plotdemo;pclose;'
try. wd 'psel gedit;pclose' catch. end.
)

NB. =========================================================
plotdemo_contents_button=: 3 : 0
wdinfo 'help contents'
)

NB. =========================================================
plotdemo_about_button=: 3 : 0
j=. 'Plot Demo V',(4.2 ": PLDEMOVER)
wdinfo 'Plot';j
)

NB. =========================================================
plotdemo_print_button=: 3 : 0
temp=. jpath '~temp\t1.wmf'
glfile temp
glsave 1 0 0
wd 'pc print;cc g0 isigraph'
glzcreate''
glzstartdoc 'print'
glzmap MM_TWIPS
glzdevmode 'orientation 2'
glzstartpage''
size=. 1440 * %/ (2 3 ,: 4 5) { glqprinter''
glplayxywh 0 0 ,size
glplay temp
glshow''
glzprint''
glzendpage''
glzenddoc''
wd 'pclose'
)

NB. =========================================================
plotdemo_clip_button=: 3 : 0
glfile ''
glsave 1 10000 7500
)

NB. =========================================================
plotdemo_slides_button=: 3 : 0
if. SLIDES do.
  wd 'timer 0'
  SLIDES=: 0
  erase 'sys_timer_z_'
else.
  wd 'timer ',":PLTIMER
  sys_timer_z_=: plotdemo_timer_jdplot_
  SLIDES=: 1
end.
wd 'set slides ',":SLIDES
)

NB. =========================================================
plotdemo_step=: 3 : 0
ndx=. (#PLOTALL) | y. + PLOTALL i. <'D',PLDEMOSEL
wd 'set M',PLDEMOSEL,' 0'
PLDEMOSEL=: }.ndx pick PLOTALL
wd 'set M',PLDEMOSEL,' 1'
pd 'reset ',PForm
plotruns 'D',PLDEMOSEL
)

NB. =========================================================
plotdemo_timer=: 3 : 0
if. wdisparent 'plotdemo' do.
  wd 'psel plotdemo'
  plotdemo_next_button''
else.
  wd 'timer 0'
  SLIDES=: 0
  erase 'sys_timer_z_'
end.
)

plotdemo_saveeps_button=: pd_jdplot_ bind 'eps'
plotdemo_savepdf_button=: pd_jdplot_ bind 'pdf'

NB. =========================================================
plotdemo_ps_size=: psize
plotdemo_next_button=: plotdemo_step bind 1
plotdemo_prev_button=: plotdemo_step bind _1
plotdemo_f10_fkey=: plotdemo_saveeps_button
plotdemo_f11_fkey=: plotdemo_savepdf_button
plotdemo_f12_fkey=: plotdemo_next_button
plotdemo_f12shift_fkey=: plotdemo_prev_button

plotdemo=: plotdemo_run
