home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume18 / xmandel / part01 < prev    next >
Encoding:
Text File  |  1992-07-12  |  50.5 KB  |  1,730 lines

  1. Newsgroups: comp.sources.x
  2. Path: uunet!darwin.sura.net!mips!msi!dcmartin
  3. From: tony@ajfcal.cuc.ab.ca (Tony Field)
  4. Subject: v18i015: Xmandelbrot, Part01/03
  5. Message-ID: <csx-18i015-xmandel@uunet.UU.NET>
  6. Originator: dcmartin@fascet
  7. Sender: dcmartin@msi.com (David C. Martin - Moderator)
  8. Organization: Molecular Simulations, Inc.
  9. Date: Mon, 13 Jul 1992 15:46:10 GMT
  10. Approved: dcmartin@msi.com
  11. Lines: 1717
  12.  
  13. Submitted-by: tony@ajfcal.cuc.ab.ca (Tony Field)
  14. Posting-number: Volume 18, Issue 15
  15. Archive-name: xmandel/part01
  16.  
  17. This is a revised version of the old xmandel programme.  Enhancements include:
  18.  
  19.     1. Athena or Motif widgets for the GUI
  20.     2. gif output files
  21.     3. support for 1, 2, 4, or 8 bit displays
  22.     4. zooming on both the Mandelbrot or Julia sets
  23.     5. honouring of exposure events.
  24.  
  25. This version of xmandel works with the following systems:
  26.     SysV-386 Interactive Unix, X11R4  (Athena and Motif)
  27.     Sun Sparc (Athena tested only) 
  28.     HP9000s720 (Athena and Motif)
  29.     
  30. #!/bin/sh
  31. # This is a shell archive (produced by shar 3.50)
  32. # To extract the files from this archive, save it to a file, remove
  33. # everything above the "!/bin/sh" line above, and type "sh file_name".
  34. #
  35. # made 07/13/1992 15:40 UTC by dcmartin@fascet
  36. # Source directory /home/fascet/dcmartin/csx/src/tmp
  37. #
  38. # existing files will NOT be overwritten unless -c is specified
  39. #
  40. # This is part 1 of a multipart archive                                    
  41. # do not concatenate these parts, unpack them in order with /bin/sh        
  42. #
  43. # This shar contains:
  44. # length  mode       name
  45. # ------ ---------- ------------------------------------------
  46. #   1130 -rw-r--r-- Imakefile
  47. #    548 -rw-r--r-- MANIFEST
  48. #  11508 -rw-r--r-- Makefile.std
  49. #   2547 -rw-r--r-- README
  50. #   9512 -rw-r--r-- julia.c
  51. #    276 -rw-r--r-- main.c
  52. #  27742 -rw-r--r-- mainaw.c
  53. #  30806 -rw-r--r-- mainmotif.c
  54. #   7543 -rw-r--r-- mandel.bit
  55. #  15435 -rw-r--r-- mandel.c
  56. #   4079 -rw-r--r-- mandel.h
  57. #  17660 -rw-r--r-- writegif.c
  58. #   8293 -rw-r--r-- xmandel.man
  59. #    929 -rw-r--r-- xmandel.mot.ad
  60. #
  61. if test -r _shar_seq_.tmp; then
  62.     echo 'Must unpack archives in sequence!'
  63.     echo Please unpack part `cat _shar_seq_.tmp` next
  64.     exit 1
  65. fi
  66. # ============= Imakefile ==============
  67. if test -f 'Imakefile' -a X"$1" != X"-c"; then
  68.     echo 'x - skipping Imakefile (File already exists)'
  69.     rm -f _shar_wnt_.tmp
  70. else
  71. > _shar_wnt_.tmp
  72. echo 'x - extracting Imakefile (Text)'
  73. sed 's/^X//' << 'SHAR_EOF' > 'Imakefile' &&
  74. #  xmandel - Mandelbrot set and Julia generator
  75. # CC=gcc
  76. X
  77. # If you want ATHENA widgets, uncomment the following line
  78. MYLIBS = $(XAWLIB)
  79. X
  80. # If you want MOTIF rather than Athena widgets uncomment 2 lines
  81. # MOTIF = -DMOTIF
  82. # MYLIBS = $(MRMLIB) $(XMLIB)
  83. X
  84. # If your version of Motif needs X11/VaSimple.h
  85. # Interactive Unix X11R4 does with cc, not with gcc
  86. # VASIMPLE = -DVASIMPLE
  87. X
  88. # If you have bcopy() but not memcpy
  89. # BCOPY=-DHAVEBCOPY
  90. X
  91. # If you don't have bcopy() or memcpy()
  92. # MEMCPY=-DNEEDMEMCPY
  93. X
  94. # --- end config ---
  95. X
  96. LOCAL_LIBRARIES = $(MYLIBS) $(XTOOLLIB) $(XMULIB) $(XLIB) 
  97. DEFINES = $(MOTIF) $(BCOPY) $(MEMCPY) $(VASIMPLE)
  98. SRCS = main.c mandel.c julia.c writegif.c
  99. OBJS = main.o mandel.o julia.o writegif.o
  100. X
  101. ComplexProgramTarget(xmandel)
  102. X
  103. main.o:    mainaw.c mainmotif.c
  104. X
  105. tar:
  106. X    tar cvf mandel.tar README Imakefile Makefile Makefile.unix main.c mainaw.c mainmotif.c mandel.h mandel.c julia.c writegif.c xmandel.man xmandel.mot.ad mandel.bit
  107. X
  108. shar:
  109. X    makekit -m  README Imakefile Makefile.unix main.c mainaw.c mainmotif.c mandel.h mandel.c julia.c writegif.c xmandel.man xmandel.mot.ad mandel.bit
  110. X
  111. InstallAppDefaults(XMandel)
  112. X
  113. X
  114. SHAR_EOF
  115. chmod 0644 Imakefile ||
  116. echo 'restore of Imakefile failed'
  117. Wc_c="`wc -c < 'Imakefile'`"
  118. test 1130 -eq "$Wc_c" ||
  119.     echo 'Imakefile: original size 1130, current size' "$Wc_c"
  120. rm -f _shar_wnt_.tmp
  121. fi
  122. # ============= MANIFEST ==============
  123. if test -f 'MANIFEST' -a X"$1" != X"-c"; then
  124.     echo 'x - skipping MANIFEST (File already exists)'
  125.     rm -f _shar_wnt_.tmp
  126. else
  127. > _shar_wnt_.tmp
  128. echo 'x - extracting MANIFEST (Text)'
  129. sed 's/^X//' << 'SHAR_EOF' > 'MANIFEST' &&
  130. X   File Name        Archive #    Description
  131. -----------------------------------------------------------
  132. X Imakefile                  1    
  133. X MANIFEST                   1    This shipping list
  134. X Makefile.unix              1    
  135. X README                     1    
  136. X julia.c                    1    
  137. X main.c                     1    
  138. X mainaw.c                   3    
  139. X mainmotif.c                4    
  140. X mandel.bit                 1    
  141. X mandel.c                   2    
  142. X mandel.h                   1    
  143. X writegif.c                 2    
  144. X xmandel.man                1    
  145. X xmandel.mot.ad             1    
  146. SHAR_EOF
  147. chmod 0644 MANIFEST ||
  148. echo 'restore of MANIFEST failed'
  149. Wc_c="`wc -c < 'MANIFEST'`"
  150. test 548 -eq "$Wc_c" ||
  151.     echo 'MANIFEST: original size 548, current size' "$Wc_c"
  152. rm -f _shar_wnt_.tmp
  153. fi
  154. # ============= Makefile.std ==============
  155. if test -f 'Makefile.std' -a X"$1" != X"-c"; then
  156.     echo 'x - skipping Makefile.std (File already exists)'
  157.     rm -f _shar_wnt_.tmp
  158. else
  159. > _shar_wnt_.tmp
  160. echo 'x - extracting Makefile.std (Text)'
  161. sed 's/^X//' << 'SHAR_EOF' > 'Makefile.std' &&
  162. # Makefile generated by imake - do not edit!
  163. # $XConsortium: imake.c,v 1.65 91/07/25 17:50:17 rws Exp $
  164. #
  165. # The cpp used on this machine replaces all newlines and multiple tabs and
  166. # spaces in a macro expansion with a single space.  Imake tries to compensate
  167. # for this, but is not always successful.
  168. #
  169. X
  170. # -------------------------------------------------------------------------
  171. # Makefile generated from "Imake.tmpl" and </tmp/IIf.a03033>
  172. # $XConsortium: Imake.tmpl,v 1.139 91/09/16 08:52:48 rws Exp $
  173. #
  174. # Platform-specific parameters may be set in the appropriate <vendor>.cf
  175. # configuration files.  Site-specific parameters should be set in the file
  176. # site.def.  Full rebuilds are recommended if any parameters are changed.
  177. #
  178. # If your C preprocessor does not define any unique symbols, you will need
  179. # to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing
  180. # "make World" the first time).
  181. #
  182. X
  183. # -------------------------------------------------------------------------
  184. # site-specific configuration parameters that need to come before
  185. # the platform-specific parameters - edit site.def to change
  186. X
  187. # site:  $XConsortium: site.def,v 1.2 91/07/30 20:26:44 rws Exp $
  188. X
  189. # -------------------------------------------------------------------------
  190. # platform-specific configuration parameters - edit sun.cf to change
  191. X
  192. # platform:  $XConsortium: sun.cf,v 1.68 91/07/30 11:34:39 rws Exp $
  193. X
  194. # operating system:  SunOS 4.1.1
  195. X
  196. # $XConsortium: sunLib.rules,v 1.6 91/03/24 17:55:58 rws Exp $
  197. X
  198. # -------------------------------------------------------------------------
  199. # site-specific configuration parameters that go after
  200. # the platform-specific parameters - edit site.def to change
  201. X
  202. # site:  $XConsortium: site.def,v 1.2 91/07/30 20:26:44 rws Exp $
  203. X
  204. X            SHELL = /bin/sh
  205. X
  206. X              TOP = .
  207. X      CURRENT_DIR = .
  208. X
  209. X               AR = ar clq
  210. X  BOOTSTRAPCFLAGS =
  211. X               CC = cc
  212. X               AS = as
  213. X
  214. X         COMPRESS = compress
  215. X              CPP = /lib/cpp $(STD_CPP_DEFINES)
  216. X    PREPROCESSCMD = cc -E $(STD_CPP_DEFINES)
  217. X          INSTALL = install
  218. X               LD = ld
  219. X             LINT = lint
  220. X      LINTLIBFLAG = -C
  221. X         LINTOPTS = -axz
  222. X               LN = ln -s
  223. X             MAKE = make
  224. X               MV = mv
  225. X               CP = cp
  226. X
  227. X           RANLIB = ranlib
  228. X  RANLIBINSTFLAGS =
  229. X
  230. X               RM = rm -f
  231. X            TROFF = psroff
  232. X         MSMACROS = -ms
  233. X              TBL = tbl
  234. X              EQN = eqn
  235. X     STD_INCLUDES =
  236. X  STD_CPP_DEFINES =
  237. X      STD_DEFINES =
  238. X EXTRA_LOAD_FLAGS =
  239. X  EXTRA_LIBRARIES =
  240. X             TAGS = ctags
  241. X
  242. X    SHAREDCODEDEF = -DSHAREDCODE
  243. X         SHLIBDEF = -DSUNSHLIB
  244. X
  245. X    PROTO_DEFINES =
  246. X
  247. X     INSTPGMFLAGS =
  248. X
  249. X     INSTBINFLAGS = -m 0755
  250. X     INSTUIDFLAGS = -m 4755
  251. X     INSTLIBFLAGS = -m 0644
  252. X     INSTINCFLAGS = -m 0444
  253. X     INSTMANFLAGS = -m 0444
  254. X     INSTDATFLAGS = -m 0444
  255. X    INSTKMEMFLAGS = -m 4755
  256. X
  257. X      PROJECTROOT = /usr/X11/R5
  258. X
  259. X     TOP_INCLUDES = -I$(INCROOT)
  260. X
  261. X      CDEBUGFLAGS = -O
  262. X        CCOPTIONS = -pipe
  263. X
  264. X      ALLINCLUDES = $(INCLUDES) $(EXTRA_INCLUDES) $(TOP_INCLUDES) $(STD_INCLUDES)
  265. X       ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(EXTRA_DEFINES) $(PROTO_DEFINES) $(DEFINES)
  266. X           CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(ALLDEFINES)
  267. X        LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES)
  268. X
  269. X           LDLIBS = $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
  270. X
  271. X        LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS) $(LOCAL_LDFLAGS) -L$(USRLIBDIR)
  272. X
  273. X   LDCOMBINEFLAGS = -X -r
  274. X      DEPENDFLAGS =
  275. X
  276. X        MACROFILE = sun.cf
  277. X           RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut
  278. X
  279. X    IMAKE_DEFINES =
  280. X
  281. X         IRULESRC = $(CONFIGDIR)
  282. X        IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES)
  283. X
  284. X     ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/Imake.rules \
  285. X            $(IRULESRC)/Project.tmpl $(IRULESRC)/site.def \
  286. X            $(IRULESRC)/$(MACROFILE) $(EXTRA_ICONFIGFILES)
  287. X
  288. # -------------------------------------------------------------------------
  289. # X Window System Build Parameters
  290. # $XConsortium: Project.tmpl,v 1.138 91/09/10 09:02:12 rws Exp $
  291. X
  292. # -------------------------------------------------------------------------
  293. # X Window System make variables; this need to be coordinated with rules
  294. X
  295. X          PATHSEP = /
  296. X        USRLIBDIR = /usr/X11/R5/lib
  297. X           BINDIR = /usr/X11/R5/bin
  298. X          INCROOT = /usr/X11/R5/include
  299. X     BUILDINCROOT = $(TOP)
  300. X      BUILDINCDIR = $(BUILDINCROOT)/X11
  301. X      BUILDINCTOP = ..
  302. X           INCDIR = $(INCROOT)/X11
  303. X           ADMDIR = /usr/adm
  304. X           LIBDIR = $(USRLIBDIR)/X11
  305. X        CONFIGDIR = $(LIBDIR)/config
  306. X       LINTLIBDIR = $(USRLIBDIR)/lint
  307. X
  308. X          FONTDIR = $(LIBDIR)/fonts
  309. X         XINITDIR = $(LIBDIR)/xinit
  310. X           XDMDIR = $(LIBDIR)/xdm
  311. X           TWMDIR = $(LIBDIR)/twm
  312. X          MANPATH = /usr/X11/R5/man
  313. X    MANSOURCEPATH = $(MANPATH)/man
  314. X        MANSUFFIX = n
  315. X     LIBMANSUFFIX = 3
  316. X           MANDIR = $(MANSOURCEPATH)$(MANSUFFIX)
  317. X        LIBMANDIR = $(MANSOURCEPATH)$(LIBMANSUFFIX)
  318. X           NLSDIR = $(LIBDIR)/nls
  319. X        PEXAPIDIR = $(LIBDIR)/PEX
  320. X      XAPPLOADDIR = $(LIBDIR)/app-defaults
  321. X       FONTCFLAGS = -t
  322. X
  323. X     INSTAPPFLAGS = $(INSTDATFLAGS)
  324. X
  325. X            IMAKE = imake
  326. X           DEPEND = makedepend
  327. X              RGB = rgb
  328. X
  329. X            FONTC = bdftopcf
  330. X
  331. X        MKFONTDIR = mkfontdir
  332. X        MKDIRHIER = /bin/sh $(BINDIR)/mkdirhier
  333. X
  334. X        CONFIGSRC = $(TOP)/config
  335. X       DOCUTILSRC = $(TOP)/doc/util
  336. X        CLIENTSRC = $(TOP)/clients
  337. X          DEMOSRC = $(TOP)/demos
  338. X           LIBSRC = $(TOP)/lib
  339. X          FONTSRC = $(TOP)/fonts
  340. X       INCLUDESRC = $(TOP)/X11
  341. X        SERVERSRC = $(TOP)/server
  342. X          UTILSRC = $(TOP)/util
  343. X        SCRIPTSRC = $(UTILSRC)/scripts
  344. X       EXAMPLESRC = $(TOP)/examples
  345. X       CONTRIBSRC = $(TOP)/../contrib
  346. X           DOCSRC = $(TOP)/doc
  347. X           RGBSRC = $(TOP)/rgb
  348. X        DEPENDSRC = $(UTILSRC)/makedepend
  349. X         IMAKESRC = $(CONFIGSRC)
  350. X         XAUTHSRC = $(LIBSRC)/Xau
  351. X          XLIBSRC = $(LIBSRC)/X
  352. X           XMUSRC = $(LIBSRC)/Xmu
  353. X       TOOLKITSRC = $(LIBSRC)/Xt
  354. X       AWIDGETSRC = $(LIBSRC)/Xaw
  355. X       OLDXLIBSRC = $(LIBSRC)/oldX
  356. X      XDMCPLIBSRC = $(LIBSRC)/Xdmcp
  357. X      BDFTOSNFSRC = $(FONTSRC)/bdftosnf
  358. X      BDFTOSNFSRC = $(FONTSRC)/clients/bdftosnf
  359. X      BDFTOPCFSRC = $(FONTSRC)/clients/bdftopcf
  360. X     MKFONTDIRSRC = $(FONTSRC)/clients/mkfontdir
  361. X         FSLIBSRC = $(FONTSRC)/lib/fs
  362. X    FONTSERVERSRC = $(FONTSRC)/server
  363. X     EXTENSIONSRC = $(TOP)/extensions
  364. X         XILIBSRC = $(EXTENSIONSRC)/lib/xinput
  365. X      PHIGSLIBSRC = $(EXTENSIONSRC)/lib/PEX
  366. X
  367. # $XConsortium: sunLib.tmpl,v 1.11 91/07/31 11:32:08 rws Exp $
  368. X
  369. SHLIBLDFLAGS = -assert pure-text
  370. PICFLAGS = -pic
  371. X
  372. X  DEPEXTENSIONLIB =
  373. X     EXTENSIONLIB = -lXext
  374. X
  375. X          DEPXLIB = $(DEPEXTENSIONLIB)
  376. X             XLIB = $(EXTENSIONLIB) -lX11
  377. X
  378. X        DEPXMULIB = $(USRLIBDIR)/libXmu.sa.$(SOXMUREV)
  379. X           XMULIB = -lXmu
  380. X
  381. X       DEPOLDXLIB =
  382. X          OLDXLIB = -loldX
  383. X
  384. X      DEPXTOOLLIB = $(USRLIBDIR)/libXt.sa.$(SOXTREV)
  385. X         XTOOLLIB = -lXt
  386. X
  387. X        DEPXAWLIB = $(USRLIBDIR)/libXaw.sa.$(SOXAWREV)
  388. X           XAWLIB = -lXaw
  389. X
  390. X        DEPXILIB =
  391. X           XILIB = -lXi
  392. X
  393. X        SOXLIBREV = 4.10
  394. X          SOXTREV = 4.10
  395. X         SOXAWREV = 5.0
  396. X        SOOLDXREV = 4.10
  397. X         SOXMUREV = 4.10
  398. X        SOXEXTREV = 4.10
  399. X      SOXINPUTREV = 4.10
  400. X
  401. X      DEPXAUTHLIB = $(USRLIBDIR)/libXau.a
  402. X         XAUTHLIB =  -lXau
  403. X      DEPXDMCPLIB = $(USRLIBDIR)/libXdmcp.a
  404. X         XDMCPLIB =  -lXdmcp
  405. X
  406. X        DEPPHIGSLIB = $(USRLIBDIR)/libphigs.a
  407. X           PHIGSLIB =  -lphigs
  408. X
  409. X       DEPXBSDLIB = $(USRLIBDIR)/libXbsd.a
  410. X          XBSDLIB =  -lXbsd
  411. X
  412. X LINTEXTENSIONLIB = $(LINTLIBDIR)/llib-lXext.ln
  413. X         LINTXLIB = $(LINTLIBDIR)/llib-lX11.ln
  414. X          LINTXMU = $(LINTLIBDIR)/llib-lXmu.ln
  415. X        LINTXTOOL = $(LINTLIBDIR)/llib-lXt.ln
  416. X          LINTXAW = $(LINTLIBDIR)/llib-lXaw.ln
  417. X           LINTXI = $(LINTLIBDIR)/llib-lXi.ln
  418. X        LINTPHIGS = $(LINTLIBDIR)/llib-lphigs.ln
  419. X
  420. X          DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)
  421. X
  422. X         DEPLIBS1 = $(DEPLIBS)
  423. X         DEPLIBS2 = $(DEPLIBS)
  424. X         DEPLIBS3 = $(DEPLIBS)
  425. X
  426. # -------------------------------------------------------------------------
  427. # Imake rules for building libraries, programs, scripts, and data files
  428. # rules:  $XConsortium: Imake.rules,v 1.123 91/09/16 20:12:16 rws Exp $
  429. X
  430. # -------------------------------------------------------------------------
  431. # start of Imakefile
  432. X
  433. #  xmandel - Mandelbrot set and Julia generator
  434. #
  435. # CC=gcc
  436. X
  437. # If you want ATHENA widgets, uncomment the following line
  438. MYLIBS = $(XAWLIB)
  439. X
  440. # If you want MOTIF rather than Athena widgets uncomment 2 lines
  441. # MOTIF = -DMOTIF
  442. # MYLIBS = $(MRMLIB) $(XMLIB)
  443. X
  444. # If your version of Motif needs X11/VaSimple.h
  445. # Interactive Unix X11R4 does with cc, not with gcc
  446. # VASIMPLE = -DVASIMPLE
  447. X
  448. # If you have bcopy() but not memcpy
  449. # BCOPY=-DHAVEBCOPY
  450. X
  451. # If you don't have bcopy() or memcpy()
  452. # MEMCPY=-DNEEDMEMCPY
  453. X
  454. # --- end config ---
  455. X
  456. LOCAL_LIBRARIES = $(MYLIBS) $(XTOOLLIB) $(XMULIB) $(XLIB)
  457. DEFINES = $(MOTIF) $(BCOPY) $(MEMCPY) $(VASIMPLE)
  458. SRCS = main.c mandel.c julia.c writegif.c
  459. OBJS = main.o mandel.o julia.o writegif.o
  460. X
  461. X PROGRAM = xmandel
  462. X
  463. all:: xmandel
  464. X
  465. xmandel: $(OBJS) $(DEPLIBS)
  466. X    $(RM) $@
  467. X    $(CC) -o $@ $(OBJS) $(LDOPTIONS) $(LOCAL_LIBRARIES) $(LDLIBS) $(EXTRA_LOAD_FLAGS)
  468. X
  469. saber_xmandel:: $(SRCS)
  470. X    # load $(ALLDEFINES) $(SRCS) $(LOCAL_LIBRARIES) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
  471. X
  472. osaber_xmandel:: $(OBJS)
  473. X    # load $(ALLDEFINES) $(OBJS) $(LOCAL_LIBRARIES) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
  474. X
  475. install:: xmandel
  476. X    @if [ -d $(DESTDIR)$(BINDIR) ]; then set +x; \
  477. X    else (set -x; $(MKDIRHIER) $(DESTDIR)$(BINDIR)); fi
  478. X    $(INSTALL) -c $(INSTPGMFLAGS)  xmandel $(DESTDIR)$(BINDIR)
  479. X
  480. install.man:: xmandel.man
  481. X    @if [ -d $(DESTDIR)$(MANDIR) ]; then set +x; \
  482. X    else (set -x; $(MKDIRHIER) $(DESTDIR)$(MANDIR)); fi
  483. X    $(INSTALL) -c $(INSTMANFLAGS) xmandel.man $(DESTDIR)$(MANDIR)/xmandel.$(MANSUFFIX)
  484. X
  485. depend::
  486. X    $(DEPEND) $(DEPENDFLAGS) -s "# DO NOT DELETE" -- $(ALLDEFINES) -- $(SRCS)
  487. X
  488. lint:
  489. X    $(LINT) $(LINTFLAGS) $(SRCS) $(LINTLIBS)
  490. lint1:
  491. X    $(LINT) $(LINTFLAGS) $(FILE) $(LINTLIBS)
  492. X
  493. clean::
  494. X    $(RM) $(PROGRAM)
  495. X
  496. main.o:    mainaw.c mainmotif.c
  497. X
  498. tar:
  499. X    tar cvf mandel.tar README Imakefile Makefile Makefile.unix main.c mainaw.c mainmotif.c mandel.h mandel.c julia.c writegif.c xmandel.man xmandel.mot.ad mandel.bit
  500. X
  501. shar:
  502. X    makekit -m  README Imakefile Makefile.unix main.c mainaw.c mainmotif.c mandel.h mandel.c julia.c writegif.c xmandel.man xmandel.mot.ad mandel.bit
  503. X
  504. install:: XMandel.ad
  505. X    @if [ -d $(DESTDIR)$(XAPPLOADDIR) ]; then set +x; \
  506. X    else (set -x; $(MKDIRHIER) $(DESTDIR)$(XAPPLOADDIR)); fi
  507. X    $(INSTALL) -c $(INSTAPPFLAGS) XMandel.ad $(DESTDIR)$(XAPPLOADDIR)/XMandel
  508. X
  509. # -------------------------------------------------------------------------
  510. # common rules for all Makefiles - do not edit
  511. X
  512. emptyrule::
  513. X
  514. clean::
  515. X    $(RM_CMD) "#"*
  516. X
  517. Makefile::
  518. X    -@if [ -f Makefile ]; then set -x; \
  519. X    $(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \
  520. X    else exit 0; fi
  521. X    $(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR)
  522. X
  523. tags::
  524. X    $(TAGS) -w *.[ch]
  525. X    $(TAGS) -xw *.[ch] > TAGS
  526. X
  527. saber:
  528. X    # load $(ALLDEFINES) $(SRCS)
  529. X
  530. osaber:
  531. X    # load $(ALLDEFINES) $(OBJS)
  532. X
  533. # -------------------------------------------------------------------------
  534. # empty rules for directories that do not have SUBDIRS - do not edit
  535. X
  536. install::
  537. X    @echo "install in $(CURRENT_DIR) done"
  538. X
  539. install.man::
  540. X    @echo "install.man in $(CURRENT_DIR) done"
  541. X
  542. Makefiles::
  543. X
  544. includes::
  545. X
  546. # -------------------------------------------------------------------------
  547. # dependencies generated by makedepend
  548. X
  549. SHAR_EOF
  550. chmod 0644 Makefile.std ||
  551. echo 'restore of Makefile.std failed'
  552. Wc_c="`wc -c < 'Makefile.std'`"
  553. test 11508 -eq "$Wc_c" ||
  554.     echo 'Makefile.std: original size 11508, current size' "$Wc_c"
  555. rm -f _shar_wnt_.tmp
  556. fi
  557. # ============= README ==============
  558. if test -f 'README' -a X"$1" != X"-c"; then
  559.     echo 'x - skipping README (File already exists)'
  560.     rm -f _shar_wnt_.tmp
  561. else
  562. > _shar_wnt_.tmp
  563. echo 'x - extracting README (Text)'
  564. sed 's/^X//' << 'SHAR_EOF' > 'README' &&
  565. X        XMANDEL          May, 1992
  566. X
  567. This is a modified version of XMANDEL written originally by John L
  568. Freedman (jlf@cray.com). It has been suitably hacked and added to make it
  569. run on Interactive Unix X11R4 as well as SunOS.
  570. X
  571. The following enhacements to the original code have been made:
  572. X
  573. X    1. Athena or Motif GUI
  574. X    2. zooming on both the Mandelbrot or Julia sets
  575. X    3. support for 1,2,4 or 8 bit display systems
  576. X    4. GIF file output of images.
  577. X    5. exposure events are honoured
  578. X    6. the images may be rotated through the default colour map
  579. X
  580. GIF code was borrowed from the John Bradley's (bradley@cis.upenn.edu)
  581. XXV.2.11 sources.
  582. X
  583. The "quality" of the images is almost completely dependent upon the
  584. choice of the colour map! (It is unfortunate that this edition of xmandel
  585. cannot alter the colour map).  Usually, a decent default colour map
  586. may be installed with "xcolors".  Detailed editing of the color may
  587. may be done with xcoloredit, cpicker/pixedit or other color editors.
  588. X
  589. Still missing from this version:
  590. X    1. a GOOD method to colour the mandelbrot/julia images
  591. X    2. a history file of "pretty image" coordinates with
  592. X       the associated colour map.
  593. X    3. an XView3 implementation of the GUI.
  594. X
  595. TIMINGS: (full, unzoomed Mandelbrot set generation)
  596. ========
  597. On a 33mHz 386 with a 1024x768 image, display time = 13min 28 seconds
  598. On an HP9000s720 with 1024x768 image, display time = 24 seconds.
  599. X
  600. INSTALLATION
  601. ============
  602. An Imakefile is provided for use with imake/xmkmf.
  603. A Makefile.unix is useful if imake/xmkmf is not available.
  604. X
  605. Mofify the Imakefile or Makefile.unix to select the Athena or the Motif
  606. widget set. You may also need to specify the use of bcopy().
  607. X
  608. Follow normal make proceedures with "make", imake" or "xmkmf".
  609. X
  610. MOTIF RESOURCE FILE
  611. ===================
  612. If the MOTIF version of xmandel is created the "xmandel.mot.ad" file
  613. should be used to set reasonable mouse actions for the buttons. I
  614. attempted to hard code these translations into my Interactive Unix X11R4
  615. version of Motif, however it failed miserably. Thus, the application
  616. resource file should be created in the appropriate directory, eg:
  617. X
  618. X    cp xmandel.mot.ad /usr/lib/X11/app-defaults/XMandel
  619. X
  620. This file is NOT needed for the Athena widget version of xmandel.
  621. X
  622. BUGS
  623. ====
  624. Some event processing might not be done in the proper way in
  625. mandel.c and julia.c.
  626. X
  627. XXmandel does NOT run on an Apollo!  It fails on a call to XtDisplay:
  628. X
  629. X    display = XtDisplay(toplevel);
  630. X
  631. for "no reason".
  632. X
  633. X
  634. ===================================================
  635. Tony Field      tony@ajfcal.cuc.ab.ca             May, 1992
  636. SHAR_EOF
  637. chmod 0644 README ||
  638. echo 'restore of README failed'
  639. Wc_c="`wc -c < 'README'`"
  640. test 2547 -eq "$Wc_c" ||
  641.     echo 'README: original size 2547, current size' "$Wc_c"
  642. rm -f _shar_wnt_.tmp
  643. fi
  644. # ============= julia.c ==============
  645. if test -f 'julia.c' -a X"$1" != X"-c"; then
  646.     echo 'x - skipping julia.c (File already exists)'
  647.     rm -f _shar_wnt_.tmp
  648. else
  649. > _shar_wnt_.tmp
  650. echo 'x - extracting julia.c (Text)'
  651. sed 's/^X//' << 'SHAR_EOF' > 'julia.c' &&
  652. /* ta=4 */
  653. X
  654. #include <stdio.h>
  655. #include <X11/Intrinsic.h>
  656. #include "mandel.h"
  657. X
  658. struct imageparm juliaparm = { 0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0, NULL, NULL, "\0", "\0", "\0", "\0" };
  659. static struct zoomd *zoomtmp;
  660. extern struct imageparm manparm;
  661. X
  662. void julia ();
  663. X
  664. int     julia_in_progress = 0;
  665. X
  666. extern Display *display;
  667. extern Screen *screen;
  668. extern int depth;
  669. extern int dots_per_byte;
  670. X
  671. static int scanline = -1;
  672. static int bottomscan = 0;
  673. X
  674. static GC draw_gc;
  675. static XImage *ximage = NULL;
  676. static char *image_data = NULL;
  677. static XWindowAttributes draw_wattr;
  678. static double a = 1.2;
  679. static double b = 1.2;
  680. X
  681. /************************************************************************
  682. *    do_mandel()            button: mandel,     compute mandelbort set        *
  683. ************************************************************************/
  684. X
  685. void start_julia (destroy_pixmap, newimage)
  686. int        destroy_pixmap;
  687. int        newimage;
  688. {
  689. X    if (juliaparm.window == 0)
  690. X        return;
  691. X    if (juliaparm.zoom)
  692. X    {    while (zoomtmp = juliaparm.zoom->zp) 
  693. X        {    free(juliaparm.zoom);
  694. X            juliaparm.zoom = zoomtmp;
  695. X        }
  696. X    } 
  697. X    else 
  698. X    {    juliaparm.zoom = (struct zoomd *) malloc(sizeof (struct zoomd));
  699. X        juliaparm.zoom->zp = NULL;    /* NULL means last in stack - don't pop */
  700. X    }
  701. X    juliaparm.zoom->lx = juliaparm.lx;
  702. X    juliaparm.zoom->ux = juliaparm.ux;
  703. X    juliaparm.zoom->ly = juliaparm.ly;
  704. X    juliaparm.zoom->uy = juliaparm.uy;
  705. X
  706. X    julia (destroy_pixmap, 1);
  707. }
  708. X
  709. X
  710. /************************************************************************
  711. *    do_julia()            button:    julia        compute julia set.            *
  712. ************************************************************************/
  713. X
  714. void julia (destroy_pixmap, newimage)
  715. int        destroy_pixmap;
  716. int        newimage;
  717. {
  718. X    XEvent ev;
  719. X    double wx, wy, oldwx;
  720. X    double sx, x, y;
  721. X    double incrx, incry;
  722. X    int ix, iy;
  723. X    long    save_event_mask;
  724. X    int        shift, mirror;
  725. X    Visual *draw_v;
  726. X
  727. X    if (manparm.zoom == NULL  ||  juliaparm.window == 0)
  728. X        return;
  729. X    juliaparm.lx = juliaparm.zoom->lx;
  730. X    juliaparm.ly = juliaparm.zoom->ly;
  731. X    juliaparm.ux = juliaparm.zoom->ux;
  732. X    juliaparm.uy = juliaparm.zoom->uy;
  733. X    update_coordinates (&juliaparm, 1);
  734. X
  735. X    scanline = -1;
  736. X    julia_in_progress = 1;
  737. X
  738. X    draw_gc = screen->default_gc;
  739. X    draw_v = screen->root_visual;
  740. X    XGetWindowAttributes(display, manparm.window, &draw_wattr);
  741. X    save_event_mask = draw_wattr.your_event_mask;
  742. X
  743. X    if (newimage)
  744. X    {
  745. X        /*    user must provide a point in the Mandelbrot window */
  746. X
  747. X        a = b = 0;
  748. X        XSelectInput (display, manparm.window, ButtonPressMask | ButtonReleaseMask
  749. X                    | PointerMotionHintMask | PointerMotionMask | ExposureMask);
  750. X        while (1) 
  751. X        {    XEvent report;
  752. X
  753. X            XNextEvent (display, &report);
  754. X            if (report.type == ButtonRelease  &&  report.xmotion.window == manparm.window)
  755. X            {    a = ( (double) report.xbutton.x / (double) draw_wattr.width);
  756. X                b = ( (double) report.xbutton.y / (double) draw_wattr.height);
  757. X                a = (a * (manparm.zoom->ux - manparm.zoom->lx)) + manparm.zoom->lx;
  758. X                b = manparm.zoom->uy - (b * (manparm.zoom->uy - manparm.zoom->ly));
  759. X                juliaparm.px = a;
  760. X                juliaparm.py = b;
  761. X                update_point (&juliaparm);
  762. X                break;
  763. X            }
  764. X            else if (report.type == MotionNotify)
  765. X            {    Window    root,  child;
  766. X                int        pos_x, pos_y;
  767. X                unsigned int keys_buttons;
  768. X                int        root_x, root_y;
  769. X                if (XQueryPointer (display, report.xmotion.window,
  770. X                        &root, &child, &root_x, &root_y,
  771. X                        &pos_x, &pos_y, &keys_buttons)  &&  report.xmotion.window  == manparm.window)
  772. X                {
  773. X                    a = ( (double) pos_x / (double) draw_wattr.width);
  774. X                    b = ( (double) pos_y / (double) draw_wattr.height);
  775. X                    a = (a * (manparm.zoom->ux - manparm.zoom->lx)) + manparm.zoom->lx;
  776. X                    b = manparm.zoom->uy - (b * (manparm.zoom->uy - manparm.zoom->ly));
  777. X                    juliaparm.px = a;
  778. X                    juliaparm.py = b;
  779. X                    juliaparm.pcolour = pixel_colour (&manparm, pos_x, pos_y);
  780. X                    update_point (&juliaparm);
  781. X                }
  782. X            }
  783. X            else
  784. X                XtDispatchEvent (&report);
  785. X            continue;
  786. X        }
  787. X    }
  788. X    XSelectInput (display, manparm.window, save_event_mask);
  789. X
  790. X    XGetWindowAttributes (display, juliaparm.window, &draw_wattr);
  791. X    if (destroy_pixmap)
  792. X    {    if (ximage)
  793. X            XDestroyImage(ximage);             /* also deallocated image_data */
  794. X        if (juliaparm.pix)
  795. X            free (juliaparm.pix);
  796. X        image_data         = NULL;  
  797. X        juliaparm.pix     = NULL; 
  798. X        ximage             = NULL;
  799. X        juliaparm.pixwidth = juliaparm.pixheight = -9999;
  800. X
  801. X    }
  802. X
  803. X    XClearWindow (display, juliaparm.window);
  804. X    XSelectInput(display, juliaparm.window, ExposureMask | ButtonPressMask | ButtonReleaseMask);
  805. X    if (juliaparm.pixwidth != draw_wattr.width  ||  juliaparm.pixheight != draw_wattr.height)
  806. X    {
  807. X        /*    if window changes size, rebuild the image information */
  808. X    
  809. X        juliaparm.pixwidth = draw_wattr.width;
  810. X        juliaparm.bytewidth = (juliaparm.pixwidth + dots_per_byte - 1) / dots_per_byte;
  811. X
  812. X        if (ximage)
  813. X            XDestroyImage (ximage); 
  814. X        if (juliaparm.pix)
  815. X            free (juliaparm.pix);
  816. X
  817. X        image_data = malloc (juliaparm.bytewidth + 1);
  818. X        juliaparm.pix = (unsigned char *) malloc (draw_wattr.height * juliaparm.bytewidth);
  819. X        if (image_data == NULL  ||  juliaparm.pix == NULL) 
  820. X        {    printf ("malloc failed\n"); 
  821. X            return; 
  822. X        }
  823. X        ximage = XCreateImage (display, draw_v, depth, ZPixmap, 0, image_data, juliaparm.pixwidth, 1, 8, juliaparm.bytewidth);
  824. X        ximage->byte_order = MSBFirst;
  825. X        ximage->bitmap_bit_order = MSBFirst;
  826. X    }
  827. X    juliaparm.pixheight = draw_wattr.height;
  828. X
  829. X
  830. X    /*    compute julia set for given coordinates */
  831. X
  832. X    sx = x = juliaparm.lx;
  833. X    y = juliaparm.uy;
  834. X    incrx = (juliaparm.ux - juliaparm.lx)  / draw_wattr.width;
  835. X    incry = (juliaparm.ly - juliaparm.uy)  / draw_wattr.height;
  836. X    scanline = -1;
  837. X    bottomscan = draw_wattr.height;
  838. X    for (iy = 0; iy < draw_wattr.height;  iy++, y+=incry) 
  839. X    {    int i;
  840. X
  841. X        x = sx;
  842. X        if (depth < 8) 
  843. X        {    for (i = 0 ; i < juliaparm.bytewidth; i++) 
  844. X                *(image_data + i) = 0;
  845. X        }
  846. X
  847. X        /*    build all points for one scan line of output */
  848. X
  849. X        for (ix = 0; ix < draw_wattr.width; ix++, x+=incrx) 
  850. X        {
  851. X            /*    compute the colour of a single pixel */
  852. X
  853. X            wx = x; wy = y;
  854. X            for (i = 0; i < ITERATION_DEPTH; i++) 
  855. X            {    oldwx = wx;
  856. X                wx = wx * wx - wy * wy + a;
  857. X                wy = 2 * oldwx * wy + b;
  858. X                if (wx * wx + wy * wy > 4) 
  859. X                    goto useit;
  860. X            }
  861. X            if (depth == 8)
  862. X            {    if (INFINITY_COLOR >= 0)
  863. X                    i = INFINITY_COLOR - COLOR_BIAS;
  864. X            }
  865. X            else
  866. X            {    if (INFINITY_COLOR >= 0)
  867. X                    i = INFINITY_COLOR;
  868. X            }
  869. X
  870. useit:        /*    assign colour to point based on screen depth */
  871. X
  872. X            switch (depth)
  873. X            {
  874. X            case 8:
  875. X                *(image_data + ix) = i + COLOR_BIAS;
  876. X                break;
  877. X
  878. X            case 4:
  879. X                if (ix % 2)
  880. X                    image_data[ix >> 1] |= (i % 16);
  881. X                else
  882. X                    image_data[ix >> 1] |= ((i % 16) << 4);
  883. X                break;
  884. X
  885. X            case 2:
  886. X                switch (ix % 4)
  887. X                {
  888. X                case 0:        shift = 6;    break;
  889. X                case 1:        shift = 4;    break;
  890. X                case 2:        shift = 2;    break;
  891. X                case 3:        shift = 0;    break;
  892. X                }
  893. X                image_data[ix >> 2] |= (i % 4) << shift;
  894. X                break;
  895. X            case 1:
  896. X                if (i % 2)
  897. X                    image_data[ix >> 3] |= 1 << (7 - ix%8);
  898. X            }
  899. X        }
  900. X
  901. X        /*    save a copy of the scan line for exposure events or gif output */
  902. X
  903. X        memcpy (juliaparm.pix + iy * juliaparm.bytewidth, image_data, juliaparm.bytewidth);
  904. X        scanline = iy;
  905. X        /*    send the image line to the screen */
  906. X
  907. X        XPutImage (display, juliaparm.window, draw_gc, ximage, 0,0, 0, iy, juliaparm.pixwidth, 1);
  908. X
  909. X        /*    handle exposure or button pressed events */
  910. X
  911. X        if (iy % EXPOSURE_TEST == 0)
  912. X        {    XSync (display, False);
  913. X            while (XCheckTypedEvent (display, Expose, &ev) == True)
  914. X                XtDispatchEvent (&ev);
  915. X            while (XCheckWindowEvent (display, juliaparm.window, ButtonPressMask | ButtonReleaseMask, &ev) == True)
  916. X            {    if (ev.type == ButtonRelease)
  917. X                    goto escape;
  918. X            }
  919. X        }
  920. X    }
  921. escape:
  922. X    XSync (display, False);
  923. X    julia_in_progress = 0;
  924. }
  925. X
  926. X
  927. /************************************************************************
  928. *    expose_julia()        handle exposure event on julia window.            *
  929. ************************************************************************/
  930. X
  931. void expose_julia (w, unused, event)
  932. Widget w;
  933. caddr_t unused;
  934. XXExposeEvent *event;
  935. {
  936. X    if (juliaparm.window == 0)
  937. X        return;
  938. X    if (event  &&  juliaparm.pix  && scanline >= 0)
  939. X        redraw_julia (event);
  940. }
  941. X
  942. /************************************************************************
  943. *    redraw_julia()        send julia from image bit vectors                *
  944. ************************************************************************/
  945. X
  946. void redraw_julia (event)
  947. XXExposeEvent *event;
  948. {
  949. X    int  iy;
  950. X    XWindowAttributes draw_wattr;
  951. X    int        jump;
  952. X    int    maxy;
  953. X
  954. X    if (juliaparm.window == 0)
  955. X        return;
  956. X    if (juliaparm.pix == NULL  ||  scanline < 0)
  957. X        return;
  958. X
  959. X    XGetWindowAttributes (display, juliaparm.window, &draw_wattr);
  960. X    jump = 1;
  961. X    if (event == NULL)
  962. X    {
  963. X        /*    refresh entire image */
  964. X
  965. X        maxy = MIN (draw_wattr.height, juliaparm.pixheight);
  966. X        for (iy = 0; iy <= scanline; iy++) 
  967. X        {    memcpy (image_data, juliaparm.pix + iy * juliaparm.bytewidth, juliaparm.bytewidth);
  968. X            XPutImage (display, juliaparm.window, draw_gc, ximage, 0,0, 0, iy, juliaparm.pixwidth, 1);
  969. X        }
  970. X    }
  971. X    else
  972. X    {    /*    refresh only exposed area */
  973. X
  974. X        int    first_byte, last_byte, nbytes, first_dot, last_dot, ndots;
  975. X
  976. X        if (event->x < juliaparm.pixwidth)
  977. X        {    first_byte = event->x / dots_per_byte;
  978. X            first_dot  = first_byte * dots_per_byte;
  979. X            last_dot   = MIN (juliaparm.pixwidth - 1, event->x + event->width - 1);
  980. X            last_byte  = (last_dot + dots_per_byte - 1) / dots_per_byte;
  981. X            nbytes     = last_byte - first_byte + 1;
  982. X            ndots      = last_dot - first_dot + 1;
  983. X            maxy       = MIN (event->y + event->height, juliaparm.pixheight);
  984. X            for (iy = event->y; iy <= scanline; iy++) 
  985. X            {    memcpy (image_data, juliaparm.pix + iy * juliaparm.bytewidth + first_byte , nbytes);
  986. X                XPutImage (display, juliaparm.window, draw_gc, ximage, 0,0, event->x, iy, ndots, 1);
  987. X            }
  988. X        }
  989. X    }
  990. X    XFlush(display);
  991. }
  992. X
  993. SHAR_EOF
  994. chmod 0644 julia.c ||
  995. echo 'restore of julia.c failed'
  996. Wc_c="`wc -c < 'julia.c'`"
  997. test 9512 -eq "$Wc_c" ||
  998.     echo 'julia.c: original size 9512, current size' "$Wc_c"
  999. rm -f _shar_wnt_.tmp
  1000. fi
  1001. # ============= main.c ==============
  1002. if test -f 'main.c' -a X"$1" != X"-c"; then
  1003.     echo 'x - skipping main.c (File already exists)'
  1004.     rm -f _shar_wnt_.tmp
  1005. else
  1006. > _shar_wnt_.tmp
  1007. echo 'x - extracting main.c (Text)'
  1008. sed 's/^X//' << 'SHAR_EOF' > 'main.c' &&
  1009. /* ta=4 */
  1010. /************************************************************************
  1011. *            mandebrot and julia set generator                            *
  1012. ************************************************************************/
  1013. X
  1014. #ifdef MOTIF
  1015. #include "mainmotif.c"
  1016. #else
  1017. #include "mainaw.c"
  1018. #endif
  1019. X
  1020. SHAR_EOF
  1021. chmod 0644 main.c ||
  1022. echo 'restore of main.c failed'
  1023. Wc_c="`wc -c < 'main.c'`"
  1024. test 276 -eq "$Wc_c" ||
  1025.     echo 'main.c: original size 276, current size' "$Wc_c"
  1026. rm -f _shar_wnt_.tmp
  1027. fi
  1028. # ============= mainaw.c ==============
  1029. if test -f 'mainaw.c' -a X"$1" != X"-c"; then
  1030.     echo 'x - skipping mainaw.c (File already exists)'
  1031.     rm -f _shar_wnt_.tmp
  1032. else
  1033. > _shar_wnt_.tmp
  1034. echo 'x - extracting mainaw.c (Text)'
  1035. sed 's/^X//' << 'SHAR_EOF' > 'mainaw.c' &&
  1036. /* ta=4     (tabstop=4)
  1037. X *
  1038. X * Xmandel - written by John Freeman at Cray Research
  1039. X *
  1040. X *    modified to work on Interactive Unix X11 R4 and added gif output.
  1041. X *      Tony Field (tony@ajfcal.cuc.ab.ca)
  1042. X *
  1043. X * This file contains the main routine for driving the mandelbrot generator
  1044. X */
  1045. X
  1046. #include <X11/IntrinsicP.h>
  1047. #include <X11/Shell.h>
  1048. #include <X11/StringDefs.h>
  1049. #include <X11/Xaw/Cardinals.h>
  1050. #include <X11/Xaw/Box.h>
  1051. #include <X11/Xaw/Form.h>
  1052. #include <X11/Xaw/Command.h>
  1053. #include <X11/Xaw/Paned.h>
  1054. #include <X11/Xaw/Dialog.h>
  1055. X
  1056. #include <stdio.h>
  1057. #include "mandel.h"
  1058. #include "mandel.bit"
  1059. X
  1060. #ifdef __STDC__
  1061. static void do_mandel(Widget w, caddr_t client_data, caddr_t call_data);
  1062. static void do_julia(Widget w, caddr_t client_data, caddr_t call_data);
  1063. static void do_remove(Widget w, caddr_t client_data, caddr_t call_data);
  1064. static void do_quit(Widget w, caddr_t client_data, caddr_t call_data);
  1065. static void do_toggle(Widget w, caddr_t client_data, caddr_t call_data);
  1066. static void do_recalc(Widget w, caddr_t client_data, caddr_t call_data);
  1067. static void set_image(char *s);
  1068. static void do_gif(Widget w, caddr_t client_data, caddr_t call_data);
  1069. static String tidy(String s);
  1070. static void MandelFname(Widget w, caddr_t client_data, caddr_t call_data);
  1071. static void JuliaFname(Widget w, caddr_t client_data, caddr_t call_data);
  1072. static void FnameCancel(Widget w, caddr_t client_data, caddr_t call_data);
  1073. static void do_colour(Widget w, caddr_t client_data, caddr_t call_data);
  1074. static void MandelRotate(Widget w, caddr_t client_data, caddr_t call_data);
  1075. static void JuliaRotate(Widget w, caddr_t client_data, caddr_t call_data);
  1076. static void rotate_selected(void);
  1077. static void rotateplus(Widget w, caddr_t client_data, caddr_t call_data);
  1078. static void rotateminus(Widget w, caddr_t client_data, caddr_t call_data);
  1079. static void CancelRotate(Widget w, caddr_t client_data, caddr_t call_data);
  1080. static void rotate(struct imageparm *parm, int val);
  1081. static XtActionProc nothing(Widget w, XButtonEvent *event, String *params, Cardinal *num_params);
  1082. static void reshape_widgets(Widget parent, char **full_size, char **small_size);
  1083. static Widget *ConvertNamesToWidgets(Widget parent, char **names);
  1084. #else
  1085. static void do_mandel();
  1086. static void do_julia();
  1087. static void do_remove();
  1088. static void do_quit();
  1089. static void do_toggle();
  1090. static void do_recalc();
  1091. static void set_image();
  1092. static void do_gif();
  1093. static String tidy();
  1094. static void MandelFname();
  1095. static void JuliaFname();
  1096. static void FnameCancel();
  1097. static void do_colour();
  1098. static void MandelRotate();
  1099. static void JuliaRotate();
  1100. static void rotate_selected();
  1101. static void rotateplus();
  1102. static void rotateminus();
  1103. static void CancelRotate();
  1104. static void rotate();
  1105. static XtActionProc nothing();
  1106. static void reshape_widgets();
  1107. static Widget *ConvertNamesToWidgets();
  1108. #endif
  1109. X
  1110. Display *display;
  1111. Screen    *screen;
  1112. Widget drawform;
  1113. Window root;
  1114. int depth;                            /*    bits per pixel (colour depth)     */
  1115. int dots_per_byte;                    /*    pixel dots in a byte            */
  1116. X
  1117. extern struct imageparm manparm;
  1118. extern struct imageparm juliaparm;
  1119. struct imageparm *activeimage = &manparm;
  1120. static Widget toplevel, juliashell = NULL;
  1121. extern int julia_in_progress;
  1122. X
  1123. static Pixmap         mandel_pixmap, julim_pixmap;
  1124. X
  1125. Widget pshell, pressme, fnameDialog, dialogDone, dialogCancel, juliaFname;
  1126. Widget jshell, cshell, colourit, rotate_mandel, rotate_julia, rotate_cancel;
  1127. Widget toggle;
  1128. X
  1129. /*    kill use of the carriage return */
  1130. X
  1131. char *kset = "#override \n\
  1132. X    Ctrl<Key>M:     nothing() \n\
  1133. X    <Key>Return:    nothing()";
  1134. X
  1135. XXtActionsRec gif_actions[] =
  1136. {    { (String) "nothing", (XtActionProc) nothing }
  1137. } ;
  1138. X
  1139. X
  1140. /*    buttons name, callback, parent for basic user buttons    */
  1141. X
  1142. struct button_list button[] = 
  1143. {    { "mandel",        do_mandel     },
  1144. X    { "julia",        do_julia     },
  1145. X    { "toggle",        do_toggle     },
  1146. X    { "zoom",        do_zoom         },
  1147. X    { "unzoom",        do_unzoom     },
  1148. X    { "colour",        do_colour     },
  1149. X    { "+colour",    rotateplus     },
  1150. X    { "-colour",    rotateminus     },
  1151. X    { "recalc",        do_recalc    },
  1152. X    { "gif",        do_gif         },
  1153. X    { "remove",        do_remove     },
  1154. X    { "quit",        do_quit         },
  1155. X    { NULL,            NULL         }
  1156. };
  1157. X
  1158. char *is_mandel = "Image: Mandel ";
  1159. char *is_julia  = "Image: Julia  ";
  1160. int    mandel_window_high;
  1161. X
  1162. main (argc, argv)
  1163. int argc;
  1164. char **argv;
  1165. {
  1166. X    Widget pane, box, form, new;
  1167. X    Arg av[10];
  1168. X    Cardinal i;
  1169. X    int    n;
  1170. X    int    wide, high;
  1171. X    double dx, dy;
  1172. X    char depth_str[10];
  1173. X    XtTranslations mytranslations;
  1174. X    static char *on_separate_lines[] = { "label", "value", NULL };
  1175. X    static char *on_single_line[] = { "Mandelbrot", "Julia", "Cancel", NULL };
  1176. X
  1177. X    toplevel = XtInitialize (argv[0], "XMandel", NULL, 0, &argc, argv);
  1178. X
  1179. X    display = XtDisplay(toplevel);
  1180. X    root = RootWindow (display, DefaultScreen(display));
  1181. X    depth = DefaultDepthOfScreen (XtScreen(toplevel));
  1182. X    screen  = XtScreen (toplevel);
  1183. X    switch (depth)
  1184. X    {
  1185. X    case 8:        dots_per_byte = 1;  break;
  1186. X    case 4:        dots_per_byte = 2;  break;
  1187. X    case 2:        dots_per_byte = 4;    break;
  1188. X    case 1:        dots_per_byte = 8;    break;
  1189. X    default:    printf ("Cannot handle %d bit colour\n", depth);
  1190. X                exit (1);
  1191. X    }
  1192. X    sprintf (depth_str, "%d", depth);        /*    default for "colour" button */
  1193. X    manparm.rotation = juliaparm.rotation = depth;
  1194. X    printf ("%d bit color\n", depth);
  1195. X    manparm.totrot   = 0;
  1196. X    manparm.window   = 0;
  1197. X    manparm.pix      = NULL;
  1198. X    juliaparm.totrot = 0;
  1199. X    juliaparm.window = 0;
  1200. X    juliaparm.pix    = NULL;
  1201. X
  1202. X    /*    create a resizable container for user buttons and graphics */
  1203. X
  1204. X    pane = XtCreateManagedWidget ("pane", panedWidgetClass, toplevel, NULL, ZERO);
  1205. X
  1206. X    /*    create a button box within the pane for user selection */
  1207. X
  1208. X    box = XtCreateManagedWidget ("box", boxWidgetClass, pane, NULL, ZERO);
  1209. X
  1210. X    /*    create all user button widgets + associated callbacks, add to "box" */
  1211. X
  1212. X    for (n = 0;  button[n].ident;  n++)
  1213. X    {    new =  XtCreateManagedWidget (button[n].ident, commandWidgetClass, box, NULL, ZERO);
  1214. X        XtAddCallback (new, XtNcallback, button[n].bcall , 0);
  1215. X    }
  1216. X
  1217. X    new = XtNameToWidget (box, "mandel");
  1218. X    i = 0;    
  1219. X    XtSetArg (av[i], XtNlabel, "  Mandelbrot  "); i++;
  1220. X    XtSetValues(new, av, i);
  1221. X
  1222. X    new = XtNameToWidget (box, "julia");
  1223. X    i = 0;    
  1224. X    XtSetArg (av[i], XtNlabel, "    Julia     "); i++;
  1225. X    XtSetValues(new, av, i);
  1226. X
  1227. X    toggle = XtNameToWidget (box, "toggle");
  1228. X    set_image (is_mandel);
  1229. X
  1230. X    /*    create a form widget within the pane to hold the graphics. */
  1231. X
  1232. X    form = XtCreateManagedWidget ("form", formWidgetClass, pane, NULL, ZERO);
  1233. X
  1234. X    dx = START_UX - START_LX;
  1235. X    dx = ABS (dx);
  1236. X    dy = START_UY - START_LY;
  1237. X    dy = ABS (dy);
  1238. X    wide = 225;
  1239. X    high = (double) wide * (dy / dx);
  1240. X    mandel_window_high = high;
  1241. X
  1242. X    /*    add the drawing area to the form widget */
  1243. X
  1244. X    i = 0;
  1245. X    XtSetArg (av[i], XtNtop, XtChainTop); i++;
  1246. X    XtSetArg (av[i], XtNbottom, XtChainBottom); i++;
  1247. X    XtSetArg (av[i], XtNleft, XtChainLeft); i++;
  1248. X    XtSetArg (av[i], XtNright, XtChainRight); i++;
  1249. X    XtSetArg (av[i], XtNwidth, wide); i++;
  1250. X    XtSetArg (av[i], XtNheight, high); i++;
  1251. X    drawform = XtCreateManagedWidget ("mandelbrot", widgetClass, form, av, i);
  1252. X
  1253. X    /*    popup to request gif output file name */
  1254. X
  1255. X    i = 0;
  1256. X    pshell = XtCreatePopupShell("Write Gif", transientShellWidgetClass, toplevel, av, i);
  1257. X
  1258. X    i = 0;
  1259. X    XtSetArg (av[i], XtNvalue, ""); i++;
  1260. X    XtSetArg (av[i], XtNlabel, "Output GIF file name. Select Mandelbrot or Julia.");  i++;
  1261. X    fnameDialog = XtCreateManagedWidget("fname", dialogWidgetClass, pshell, av, i);
  1262. X
  1263. X    i = 0;
  1264. X    dialogDone = XtCreateManagedWidget("Mandelbrot", commandWidgetClass, fnameDialog, av, i);
  1265. X
  1266. X    i = 0;
  1267. X    juliaFname = XtCreateManagedWidget("Julia", commandWidgetClass, fnameDialog, av, i);
  1268. X
  1269. X    i = 0;
  1270. X    dialogCancel = XtCreateManagedWidget("Cancel", commandWidgetClass, fnameDialog, av, i);
  1271. X
  1272. X    XtAddCallback(dialogDone, XtNcallback, MandelFname, fnameDialog);
  1273. X    XtAddCallback(juliaFname, XtNcallback, JuliaFname, fnameDialog);
  1274. X    XtAddCallback(dialogCancel, XtNcallback, FnameCancel, fnameDialog);
  1275. X
  1276. X    /*    popup to request colour rotate */
  1277. X
  1278. X    i = 0;
  1279. X    cshell = XtCreatePopupShell("Colour Rotate", transientShellWidgetClass, toplevel, av, i);
  1280. X
  1281. X    i = 0;
  1282. X    XtSetArg (av[i], XtNvalue, ""); i++;
  1283. X    XtSetArg (av[i], XtNlabel, "Rotate current colour values by:");  i++;
  1284. X    XtSetArg (av[i], XtNvalue, depth_str);  i++;
  1285. X    colourit = XtCreateManagedWidget("colour", dialogWidgetClass, cshell, av, i);
  1286. X
  1287. X    i = 0;
  1288. X    rotate_mandel = XtCreateManagedWidget("Mandelbrot", commandWidgetClass, colourit, av, i);
  1289. X
  1290. X    i = 0;
  1291. X    rotate_julia = XtCreateManagedWidget("Julia", commandWidgetClass, colourit, av, i);
  1292. X
  1293. X    i = 0;
  1294. X    rotate_cancel = XtCreateManagedWidget("Cancel", commandWidgetClass, colourit, av, i);
  1295. X
  1296. X    XtAddCallback(rotate_mandel, XtNcallback, MandelRotate, colourit);
  1297. X    XtAddCallback(rotate_julia, XtNcallback, JuliaRotate, colourit);
  1298. X    XtAddCallback(rotate_cancel, XtNcallback, CancelRotate, colourit);
  1299. X
  1300. X    /*    disable <enter> in fnameDialog box */
  1301. X
  1302. X    XtAddActions (gif_actions, XtNumber (gif_actions));
  1303. X
  1304. X    /*    create julia window as a popup shell */
  1305. X
  1306. X    i = 0;
  1307. X    jshell = XtCreatePopupShell("Julia Set", transientShellWidgetClass, toplevel, av, i);
  1308. X    XtAddEventHandler (jshell, ExposureMask, FALSE,  expose_julia, NULL);
  1309. X
  1310. X    /*    setup function to handle exposure events    */
  1311. X
  1312. X    XtAddEventHandler (drawform, ExposureMask, FALSE,  expose_mandel, NULL);
  1313. X    reshape_widgets (fnameDialog, on_separate_lines, on_single_line);
  1314. X    reshape_widgets (colourit, on_separate_lines, on_single_line);
  1315. X
  1316. X    /*    kill use of the carriage return */
  1317. X
  1318. X    new = XtNameToWidget (fnameDialog, "value");
  1319. X    mytranslations = XtParseTranslationTable (kset);
  1320. X    XtOverrideTranslations (new,   mytranslations);
  1321. X
  1322. X    new = XtNameToWidget (colourit, "value");
  1323. X    mytranslations = XtParseTranslationTable (kset);
  1324. X    XtOverrideTranslations (new,   mytranslations);
  1325. X
  1326. X    mandel_pixmap = XCreateBitmapFromData (XtDisplay (toplevel),
  1327. X                        RootWindowOfScreen (XtScreen (toplevel)),
  1328. X                        mandel_bits,
  1329. X                        mandel_width,
  1330. X                        mandel_height);
  1331. X    XtSetArg (av[0], XtNiconPixmap, mandel_pixmap);
  1332. X    XtSetValues (toplevel, av, 1);
  1333. X
  1334. X    XtRealizeWidget (toplevel);
  1335. X    juliaparm.pix = NULL;
  1336. X    manparm.pix = NULL;
  1337. X    XtMainLoop ();
  1338. }
  1339. X
  1340. /*    callbacks    /
  1341. X
  1342. /************************************************************************
  1343. *    do_mandel()        button = mandel:    create/use mandelbrot window    *
  1344. ************************************************************************/
  1345. X
  1346. static void do_mandel (w, client_data, call_data)
  1347. Widget w;
  1348. caddr_t client_data;
  1349. caddr_t call_data;
  1350. {    unsigned int    high, wide;
  1351. X    double            dx, dy;
  1352. X
  1353. X    manparm.lx = START_LX;
  1354. X    manparm.ly = START_LY;
  1355. X    manparm.ux = START_UX;
  1356. X    manparm.uy = START_UY;
  1357. X    dx = START_UX - START_LX;
  1358. X    dx = ABS (dx);
  1359. X    dy = START_UY - START_LY;
  1360. X    dy = ABS (dy);
  1361. X    wide = 225;
  1362. X    high = (double) wide * (dy / dx);
  1363. X    manparm.window = XtWindow (drawform);
  1364. X    manparm.totrot = 0;
  1365. X    start_mandel ();
  1366. }
  1367. X
  1368. /************************************************************************
  1369. *    do_julia()        button = julia:        create/use julia window            *
  1370. ************************************************************************/
  1371. X
  1372. static void do_julia (w, client_data, call_data)
  1373. Widget w;
  1374. caddr_t client_data;
  1375. caddr_t call_data;
  1376. {    int        i;
  1377. X    Arg        av[10];
  1378. X
  1379. X    if (manparm.window == 0)
  1380. X        return;
  1381. X
  1382. X    juliaparm.lx = -1.5;
  1383. X    juliaparm.ly = -1.5;
  1384. X    juliaparm.ux = 1.5;
  1385. X    juliaparm.uy = 1.5;
  1386. X    if (juliaparm.window == 0)
  1387. X    {
  1388. X        if (juliashell == NULL)
  1389. X        {    i = 0;
  1390. X            XtSetArg (av[i], XtNwidth,       mandel_window_high);        i++;
  1391. X            XtSetArg (av[i], XtNheight,      mandel_window_high);        i++;
  1392. X            XtSetArg (av[i], XtNtitle,        "Julia");                    i++;
  1393. X            XtSetArg (av[i], XtNiconName,    "Julia");                    i++;
  1394. X            juliashell = XtCreateApplicationShell ("Juliashell", topLevelShellWidgetClass, av, i);
  1395. X            XtAddEventHandler (juliashell, ExposureMask, FALSE,  expose_julia, NULL);
  1396. X
  1397. X            julim_pixmap = XCreateBitmapFromData (XtDisplay (juliashell),
  1398. X                        RootWindowOfScreen (XtScreen (juliashell)),
  1399. X                        julim_bits,
  1400. X                        julim_width,
  1401. X                        julim_height);
  1402. X            XtSetArg (av[0], XtNiconPixmap, julim_pixmap);
  1403. X            XtSetValues (juliashell, av, 1);
  1404. X
  1405. X            XtRealizeWidget (juliashell);
  1406. X        }
  1407. X        else
  1408. X            XtMapWidget (juliashell);
  1409. X        juliaparm.window = XtWindow (juliashell);
  1410. X    }
  1411. X    juliaparm.window = XtWindow (juliashell);
  1412. X    juliaparm.totrot = 0;
  1413. X    start_julia (1, 1);
  1414. X    printf ("\n");
  1415. }
  1416. X
  1417. /************************************************************************
  1418. *    do_recalc            button = recalc.    recalculate current set.    *
  1419. ************************************************************************/
  1420. X
  1421. static void do_recalc (w, client_data, call_data)
  1422. Widget w;
  1423. caddr_t client_data;
  1424. caddr_t call_data;
  1425. {
  1426. X    if (activeimage == &manparm)
  1427. X        redo_mandel();
  1428. X    else
  1429. X        julia (1,0);
  1430. }
  1431. X
  1432. X
  1433. /************************************************************************
  1434. *    do_remove():        button = remove.  unmap julia widget            *
  1435. ************************************************************************/
  1436. X
  1437. static void do_remove (w, client_data, call_data)
  1438. Widget w;
  1439. caddr_t client_data;
  1440. caddr_t call_data;
  1441. {
  1442. X    if (julia_in_progress)
  1443. X        return;
  1444. X
  1445. X    if (juliaparm.window)
  1446. X        XtUnmapWidget (juliashell);
  1447. X
  1448. X    juliaparm.window = 0;
  1449. X    activeimage = &manparm;
  1450. X    set_image (is_mandel);
  1451. }
  1452. X
  1453. /************************************************************************
  1454. *    do_quit():        button = quit,   leave xmandel.                        *
  1455. ************************************************************************/
  1456. X
  1457. static void do_quit (w, client_data, call_data)
  1458. Widget w;
  1459. caddr_t client_data;
  1460. caddr_t call_data;
  1461. {
  1462. X    printf ("\n");
  1463. X    exit (0);
  1464. }
  1465. X
  1466. /************************************************************************
  1467. *    do_toggle():        button = quit,   leave xmandel.                        *
  1468. ************************************************************************/
  1469. X
  1470. static void do_toggle (w, client_data, call_data)
  1471. Widget w;
  1472. caddr_t client_data;
  1473. caddr_t call_data;
  1474. {    char    *which;
  1475. X
  1476. X    if (juliaparm.window == 0)
  1477. X        return;
  1478. X    if (activeimage == &manparm)
  1479. X    {    activeimage = &juliaparm;
  1480. X        which = is_julia;
  1481. X    }
  1482. X    else
  1483. X    {    activeimage = &manparm;
  1484. X        which = is_mandel;
  1485. X    }
  1486. X    set_image (which);
  1487. X        
  1488. }
  1489. X
  1490. static void set_image (s)
  1491. char *s;
  1492. {    int        i;
  1493. X    Arg        av[10];
  1494. X
  1495. X    i = 0;    
  1496. X    XtSetArg (av[i], XtNlabel, s); i++;
  1497. X    XtSetValues(toggle, av, i);
  1498. }
  1499. X
  1500. /************************************************************************
  1501. *    do_gif ()        button = gif,   ask user for file name                *
  1502. ************************************************************************/
  1503. X
  1504. static void do_gif (w, client_data, call_data)
  1505. Widget w;
  1506. caddr_t client_data;
  1507. caddr_t call_data;
  1508. {
  1509. X    Position x, y;
  1510. X    Dimension width, height;
  1511. X    Arg arg[2];
  1512. X    int i;
  1513. X
  1514. X    /*     get the coordinates of the middle of toplevel widget.    */
  1515. X
  1516. X    i = 0;
  1517. X    XtSetArg(arg[i], XtNwidth, &width);    i++;
  1518. X    XtSetArg(arg[i], XtNheight, &height);  i++;
  1519. X    XtGetValues(toplevel, arg, i);
  1520. X    
  1521. X    /*    translate coordinates in application top-level window
  1522. X        into coordinates from root window origin.
  1523. X    */
  1524. X    XtTranslateCoords(toplevel,                /* Widget */
  1525. X                (Position) width/2,            /* x */
  1526. X                (Position) height/2,        /* y */
  1527. X                &x, &y);                    /* coords on root window */
  1528. X
  1529. X    /* move popup shell to this position (it's not visible yet) */
  1530. X
  1531. X    i = 0;
  1532. X    XtSetArg(arg[i], XtNx, x);          i++;
  1533. X    XtSetArg(arg[i], XtNy, y);          i++;
  1534. X    XtSetValues(pshell, arg, i);
  1535. X
  1536. X    /*    Indicate to user that no other application functions are
  1537. X        valid while fnameDialog is popped up...
  1538. X    */
  1539. X    XtPopup(pshell, XtGrabNonexclusive);
  1540. }
  1541. X
  1542. /************************************************************************
  1543. *    tidy()        return the first non-blank word (ascii dependent!)        *
  1544. ************************************************************************/
  1545. X
  1546. static String tidy (s)
  1547. String s;
  1548. {    String cs;
  1549. X
  1550. X    while (*s  &&  *s == ' ')
  1551. X        s++;
  1552. X    cs = s;
  1553. X    while (*s  &&  *s > ' '  &&  *s <= 'z')
  1554. X        s++;
  1555. X    *s = 0;
  1556. X    return (cs);
  1557. }
  1558. X
  1559. /************************************************************************
  1560. *    MandelFname ()    button = gif/accept   write image to gif file        *
  1561. ************************************************************************/
  1562. X
  1563. static void MandelFname (w, client_data, call_data)
  1564. Widget w;
  1565. caddr_t client_data;
  1566. caddr_t call_data;
  1567. {
  1568. X    String string, s;
  1569. X
  1570. X    string = XawDialogGetValueString(fnameDialog);
  1571. X    s = tidy (string);
  1572. X    if (*s  && manparm.pix)
  1573. X    {    activeimage = &manparm;
  1574. X        printf ("Mandelbrot gif file = %s\n", s);
  1575. X        write_gif_image (s, activeimage);
  1576. X    }
  1577. X    XtPopdown(pshell);
  1578. X    set_image (is_mandel);
  1579. X    XFlush (display);
  1580. }
  1581. X
  1582. /************************************************************************
  1583. *    JuliaFname ()    button = gif/accept   write image to gif file        *
  1584. ************************************************************************/
  1585. X
  1586. static void JuliaFname (w, client_data, call_data)
  1587. Widget w;
  1588. caddr_t client_data;
  1589. caddr_t call_data;
  1590. {
  1591. X    String string, s;
  1592. X
  1593. X    string = XawDialogGetValueString(fnameDialog);
  1594. X    s = tidy (string);
  1595. X    if (*s  &&  juliaparm.pix)
  1596. X    {    activeimage = &juliaparm;
  1597. X        printf ("Julia gif file = %s\n", s);
  1598. X        write_gif_image (s, activeimage);
  1599. X    }
  1600. X    XtPopdown(pshell);
  1601. X    set_image (is_julia);
  1602. X    XFlush (display);
  1603. }
  1604. X
  1605. /************************************************************************
  1606. *    FnameCancel()        button = gif/cancel        ignore file write rq.    *
  1607. ************************************************************************/
  1608. X
  1609. static void FnameCancel (w, client_data, call_data)
  1610. Widget w;
  1611. caddr_t client_data;
  1612. caddr_t call_data;
  1613. {
  1614. X    XtPopdown(pshell);
  1615. X    XFlush (display);
  1616. }
  1617. X
  1618. X
  1619. /************************************************************************
  1620. *    do_colour()        button = gif,   ask user for file name                *
  1621. ************************************************************************/
  1622. X
  1623. static void do_colour (w, client_data, call_data)
  1624. Widget w;
  1625. caddr_t client_data;
  1626. caddr_t call_data;
  1627. {
  1628. X    Position x, y;
  1629. X    Dimension width, height;
  1630. X    Arg arg[2];
  1631. X    int i;
  1632. X
  1633. X    /*     get the coordinates of the middle of toplevel widget.    */
  1634. X
  1635. X    i = 0;
  1636. X    XtSetArg(arg[i], XtNwidth, &width);    i++;
  1637. X    XtSetArg(arg[i], XtNheight, &height);  i++;
  1638. X    XtGetValues(w, arg, i);
  1639. X
  1640. X    XtTranslateCoords(w,                    /* Widget */
  1641. X                (Position) 0,            /* x */
  1642. X                (Position) height+2,        /* y */
  1643. X                &x, &y);                    /* coords on root window */
  1644. X
  1645. X    /* move popup shell to this position (it's not visible yet) */
  1646. X
  1647. X    i = 0;
  1648. X    XtSetArg(arg[i], XtNx, x);          i++;
  1649. X    XtSetArg(arg[i], XtNy, y);          i++;
  1650. X    XtSetValues(cshell, arg, i);
  1651. X
  1652. X    /*    Indicate to user that no other application functions are
  1653. X        valid while fnameDialog is popped up...
  1654. X    */
  1655. X    XtPopup(cshell, XtGrabNonexclusive);
  1656. }
  1657. X
  1658. /************************************************************************
  1659. *    MandelRotate             button = colour/mandelbort:    rotate colour    *
  1660. ************************************************************************/
  1661. X
  1662. static void MandelRotate (w, client_data, call_data)
  1663. Widget w;
  1664. caddr_t client_data;
  1665. caddr_t call_data;
  1666. {
  1667. X    if (manparm.window)
  1668. X    {    activeimage = &manparm;
  1669. X        set_image (is_mandel);
  1670. X        rotate_selected ();
  1671. X    }
  1672. }
  1673. X
  1674. /************************************************************************
  1675. *    JuliaRotate()            button = colour/julia    rotate julia colour    *
  1676. ************************************************************************/
  1677. X
  1678. static void JuliaRotate (w, client_data, call_data)
  1679. Widget w;
  1680. caddr_t client_data;
  1681. caddr_t call_data;
  1682. {
  1683. X    if (juliaparm.window)
  1684. X    {    activeimage = &juliaparm;
  1685. X        set_image (is_julia);
  1686. X        rotate_selected ();
  1687. X    }
  1688. }
  1689. X
  1690. /************************************************************************
  1691. *    JuliaRotate()            button = colour/julia    rotate julia colour    *
  1692. ************************************************************************/
  1693. X
  1694. static void rotate_selected ()
  1695. {    String string, s;
  1696. X    int        atoi();
  1697. X
  1698. X    XtPopdown(cshell);
  1699. X    XFlush (display);
  1700. X    string = XawDialogGetValueString(colourit);
  1701. X    s = tidy (string);
  1702. X    if (*s  && manparm.pix)
  1703. X    {    activeimage->rotation = atoi (s);
  1704. X    }
  1705. }
  1706. X
  1707. /************************************************************************
  1708. *    rotateplus            button = +colour    rotate colour positive        *
  1709. ************************************************************************/
  1710. X
  1711. static void rotateplus (w, client_data, call_data)
  1712. Widget w;
  1713. caddr_t client_data;
  1714. caddr_t call_data;
  1715. {
  1716. X    rotate (activeimage,  activeimage->rotation);
  1717. SHAR_EOF
  1718. true || echo 'restore of mainaw.c failed'
  1719. fi
  1720. echo 'End of  part 1'
  1721. echo 'File mainaw.c is continued in part 2'
  1722. echo 2 > _shar_seq_.tmp
  1723. exit 0
  1724. -- 
  1725. --
  1726. Molecular Simulations, Inc.            mail: dcmartin@msi.com
  1727. 796 N. Pastoria Avenue                uucp: uunet!dcmartin
  1728. Sunnyvale, California 94086            at&t: 408/522-9236
  1729.