NB. Isigraph viewer

coclass 'jigdemo'
coextend 'jgl2'
COCLASSPATH copath coname''

0!:0 < jpath '~system\packages\misc\evolute.ijs'
0!:0 < jpath '~system\examples\graphics\isigraph\iscolor.ijs'

ISTYPE=: 0
ISSLIDES=: 0

j=. 'TITLE 0 EVOLUTE1 1 EVOLUTE2 1'
j=. j,' SIERCAR1 1 SIERCAR2 1 SIERTRI1 1 SIERTRI2 1 SIERTRI3 1 SIERTRI4 0'
j=. j,' PLASMA1 1 FRIEZE1 1 IFS1 0 IFS2 1'
j=. j,' KOCH 0 POLYGON 0 SPIRALS 0'
j=. j,' POWER 1 SINES 0'
j=. j,' POUSSE 2 PAINT 2 SMESSER 0'
j=. _2 [\ ;:j
ISDEMONAMES=: {."1 j
ISDEMOTYPE=: ". &> {:"1 j

ISDEMOVER=: 1.7
ISDEMOSEL=: 'TITLE'
ISDEMOPATH=: jpath '~system\examples\graphics\isigraph\'

ISHANDLERS=: <;._2 (0 : 0)
isdemo_g_char
isdemo_g_mbldown
)

OPENISDEMO=: 0 : 0
pc isdemo closeok;pn "J Graphics";
menupop "&Options";
menu view "&View Definition" "" "" "";
menusep ;
menu clip "&Clip" "" "" "";
menusep ;
menu savebmp "&Save isdemo.bmp" "" "" "";
menusep ;
menu print "&Print" "" "" "";
menusep ;
menu exit "E&xit" "" "" "";
menupopz;
menupop "&Basic";
menu MTITLE "Isigraph Graphics" "" "" "";
menusep ;
menu MEVOLUTE1 "E&volute 1" "" "" "";
menu MEVOLUTE2 "E&volute 2" "" "" "";
menupopz;
menupop "&IFS";
menupop "&Sierpinski";
menu MSIERCAR1 "&Carpet 1" "" "" "";
menu MSIERCAR2 "&Carpet 2" "" "" "";
menusep ;
menu MSIERTRI1 "&Triangle 1" "" "" "";
menu MSIERTRI2 "&Triangle 2" "" "" "";
menu MSIERTRI3 "&Triangle 3" "" "" "";
menu MSIERTRI4 "&Triangle 4" "" "" "";
menupopz;
menusep ;
menu MPLASMA1 "&Plasma Cloud 1" "" "" "";
menu MFRIEZE1 "&Frieze Pattern 1" "" "" "";
menusep ;
menu MIFS1 "&IFS1" "" "" "";
menu MIFS2 "&IFS2" "" "" "";
menupopz;
menupop "&Shapes";
menu MKOCH "&Koch" "" "" "";
menu MPOLYGON "&Polygon" "" "" "";
menu MSPIRALS "&Spirals" "" "" "";
menu MPOWER "&Power" "" "" "";
menu MSINES "&Sines" "" "" "";
menupopz;
menupop "&Extras";
menu MPOUSSE "&Pousse" "" "" "";
menusep ;
menu MPAINT "&Paint" "" "" "";
menusep ;
menu MSMESSER "&Screen Roller" "" "" "";
menupopz;
menupop "&Help";
menu MF12 "&F12 Next" "" "" "";
menu MF12S "&Shift F12 Previous" "" "" "";
menusep ;
menu about "&About" "" "" "";
menupopz;
xywh 0 0 170 150;cc g isigraph rightmove bottommove;
xywh 0 0 170 150;cc p isipicture rightmove bottommove;
xywh 20 40 130 105;cc p2 isipicture topscale rightmove bottommove;
pas 0 0;pcenter;
rem form end;
)

0 : 0
menupop "&Star";
menu MSTAR1 "&Star 1" "" "" "";
menupopz;
menusep ;

menu MEIGENPIC "&Eigenpicture" "" "" "";
menusep ;
menu MENIGMA "&Enigma" "" "" "";
menusep ;
)

NB. =========================================
isdemo=: 3 : 0
wd OPENISDEMO
ISDEMOSEL=: ISDEMOSEL,(0=#ISDEMOSEL)#'TITLE'
wd 'set M',ISDEMOSEL,' 1'
glnoerasebkgnd 1
glrgb 128 64 128
glbrush''
glrect 0 0 1000 1000
isdemo_run''
wd 'pshow'
)

NB. ===============================================
isdemo_run=: 3 : 0
if. wdisparent 'isdemo' do.
  isdemo_run1 ISDEMODAT=: fread ISDEMOPATH,ISDEMOSEL,'.ijs'
end.
)

NB. ===============================================
isdemo_run1=: 3 : 0
try. wd 'psel isdemo'
catch. return. 
end.
gopen''
0!:100 y.
gshow''
)

NB. ===============================================
isdemo_about_button=: 3 : 0
j=. 'Isigraph Graphics Demo V',(4.2 ": ISDEMOVER)
wdinfo 'Isigraph Graphics';j
)

NB. ===============================================
isdemo_default=: 3 : 0
if. 0=wdisparent 'isdemo' do. return. end.
if. systype -: 'button' do.
  name=. }.syschild

NB. permit reopening...
NB.   if. name -: ISDEMOSEL do.
NB.     wd 'set M',ISDEMOSEL,' 1'
NB.     return.
NB.   end.

  if. (<name) e. ISDEMONAMES do.
    isdemo_showname name
  end.
end.
''
)

NB. ===============================================
isdemo_f12_fkey=: 3 : 0
ndx=. (#ISDEMONAMES) | >: ISDEMONAMES i. <ISDEMOSEL
isdemo_showname ndx pick ISDEMONAMES
)

NB. ===============================================
isdemo_f12shift_fkey=: 3 : 0
ndx=. (#ISDEMONAMES) | <: ISDEMONAMES i. <ISDEMOSEL
isdemo_showname ndx pick ISDEMONAMES
)

isdemo_MF12_button=: isdemo_f12_fkey
isdemo_MF12S_button=: isdemo_f12shift_fkey

NB. ===============================================
isdemo_showname=: 3 : 0
wd 'set M',ISDEMOSEL,' 0'
ISDEMOSEL=: y.
ISTYPE=: ISDEMOTYPE {~ ISDEMONAMES i. <y.
wd 'set M',ISDEMOSEL,' 1'
isdemo_run''
)

NB. ===============================================
isdemo_slides_button=: 3 : 0
ISSLIDES=: -. ISSLIDES
wd 'set slides ',":ISSLIDES
if. ISSLIDES do.
  wd 'timer 3000'
  sys_timer_z_=: isdemo_slides_jigdemo_
else.
  wd 'timer 0'
  erase 'sys_timer_z_'
end.
empty''
)

NB. ===============================================
isdemo_nextslide=: 3 : 0
nms=. ISDEMONAMES -. ;:'PAINT ENIGMA SMESSER'
ndx=. nms i. <ISDEMOSEL
ndx=. (#nms) | >:ndx
isdemo_showname ndx pick nms
)

NB. ===============================================
isdemo_slides=: 3 : 0
try.
  isdemo_nextslide''
catch.
  wd 'timer 0'
  ISSLIDES=: 0
  erase 'sys_timer_z_'
end.
)

NB. ===============================================
isdemo_exit_button=: 3 : 0
try. wd 'psel isdemo;pclose;' catch. end.
)

NB. ===============================================
isdemo_view_button=: 3 : 0
isedit_run ISDEMODAT
)

NB. ===============================================
isdemo_clipper=: 4 : 0
glfile y.
glsave 0 10000 7500
if. 0=x. do. return. end.
wd 'pc print;cc g0 isigraph'
glzcreate''
glzstartdoc 'print'
glzmap MM_TWIPS
NB. glzdevmode 'orientation 1',":ORIENTATION
glzstartpage''
size=. 1440 * %/ (2 3 ,: 4 5) { glqprinter''
glplayxywh 0 0 ,size
glplay y.
glshow''
glzprint''
glzendpage''
glzenddoc''
wd 'pclose'
)

NB. =========================================
gback=: 3 : 0
glbrush glrgb y.
glrect 0 0 1000 1000
)

NB. =========================================
NB. gopen
gopen=: 3 : 0
try.
wd 'psel isdemo;pactive'
catch. return. 
end.
if. ISTYPE=0 do.
  glclear 1
  glnoerasebkgnd 1
end.
)

NB. =========================================
gshow=: ''&$: : (4 : 0)
try. wd 'psel isdemo'
catch. return. end.
select. ISTYPE
case. 0 do.
  if. 0=ISDEMOSEL-:'TITLE' do. wd 'setshow p2 0' end.
  wd 'setshow p 0'
  glshow''
case. 1 do.
  wd 'setshow p 1;setshow p2 0'
  wd 'set p "',(jpath '~temp\t1.bmp'),'"'
case. 2 do.
end.
wd 'pactive'
)

NB. ===============================================
isdemo_close=: isdemo_exit_button

isdemo_clip_button=:  0 & isdemo_clipper bind ''
isdemo_print_button=: 1 & isdemo_clipper bind (jpath '~temp\istemp.bmp')
isdemo_savebmp_button=: 0 & isdemo_clipper bind (jpath '~temp\isdemo.bmp')

clean=: 13 : 'y. * 1e_10 <: |y.'
mp=: +/ .*
viewbmp=: gshow
