#!/bin/sh
# This is a shell archive (produced by GNU sharutils 4.2.1).
# To extract the files from this archive, save it to some FILE, remove
# everything before the `!/bin/sh' line above, then type `sh FILE'.
#
# Made on 2002-06-20 07:45 EDT by <dfs@fry>.
# Source directory was `/l/fsc/dfs/xgobi/distrib'.
#
# Existing files will *not* be overwritten unless `-c' is specified.
#
# This shar contains:
# length mode       name
# ------ ---------- ------------------------------------------
#   5126 -rw-r--r-- xgobi/S/clust-docu.S
#   4591 -rw-r--r-- xgobi/S/xgvis.d
#   4825 -rw-r--r-- xgobi/S/xgvis.S
#   4665 -rw-r--r-- xgobi/S/xgobi.d
#   6881 -rw------- xgobi/S/xgobi.S
#   8728 -rw-r--r-- xgobi/ps/xgobi.head.ps
#  16929 -rw-r--r-- xgobi/src/XGobiServer.h
#   6113 -rw-r--r-- xgobi/src/xgv_qsort.c
#  29759 -rw-r--r-- xgobi/src/spin.c
#  33621 -rw-r--r-- xgobi/src/xgobiexterns.h
#  28944 -rw-r--r-- xgobi/src/xgobi_init.c
#   5637 -rw-r--r-- xgobi/src/Imakefile
#  26930 -rw-r--r-- xgobi/src/tour_init.c
#   1365 -rw-r--r-- xgobi/src/DrawingAP.h
#   5146 -rw-r--r-- xgobi/src/xgv_stressplot.c
#  45892 -rw-r--r-- xgobi/src/var_panel.c
#  27260 -rw-r--r-- xgobi/src/brush_init.c
#   5598 -rwxr-xr-x xgobi/src/install-sh
#  38073 -rw-r--r-- xgobi/src/widgets.c
#  17405 -rw-r--r-- xgobi/src/xgobitop.h
#  19859 -rw-r--r-- xgobi/src/gt_ctls.c
#   8744 -rw-r--r-- xgobi/src/texture.c
#   8262 -rw-r--r-- xgobi/src/legendre.c
#   4807 -rw-r--r-- xgobi/src/Corba.nw
#    787 -rw-r--r-- xgobi/src/rpc_aiiac_err.h
#   7686 -rw-r--r-- xgobi/src/rpc_dce.idl
#    408 -rw-r--r-- xgobi/src/rpc_dce.acf
#  13252 -rw-r--r-- xgobi/src/move_points.c
#  18845 -rw-r--r-- xgobi/src/.#Makefile.1.1.1.1
#   2266 -rw-r--r-- xgobi/src/Makefile.corba
#  17037 -rw-r--r-- xgobi/src/xgv_help.c
#  23020 -rw-r--r-- xgobi/src/subset.c
#   4816 -rw-r--r-- xgobi/src/corr_index.c
#    763 -rw-r--r-- xgobi/src/rpc_dceclient.h
#   9987 -rw-r--r-- xgobi/src/rpc_dce.h
#   7651 -rw-r--r-- xgobi/src/svd.c
#   5317 -rw-r--r-- xgobi/src/mt19937-1.c
#  16051 -rw-r--r-- xgobi/src/plot1d.c
#   9735 -rw-r--r-- xgobi/src/XGobiCorbaServer.idl
#  11617 -rw-r--r-- xgobi/src/jitter.c
#   5311 -rw-r--r-- xgobi/src/diffs
#  76763 -rw-r--r-- xgobi/src/make.out
#  22199 -rw-r--r-- xgobi/src/rpc_server_svc.c
#    409 -rw-r--r-- xgobi/src/rpc_dceclient.acf
#   1240 -rw-r--r-- xgobi/src/rpc_dceclient.idl
#  18766 -rw-r--r-- xgobi/src/Makefile
#  22325 -rw-r--r-- xgobi/src/vc_lists.c
#   9929 -rw-r--r-- xgobi/src/help.c
#    348 -rw-r--r-- xgobi/src/.purify
#  21487 -rw-r--r-- xgobi/src/brush.c
#   8669 -rw-r--r-- xgobi/src/redesign
#  13071 -rw-r--r-- xgobi/src/sphere.c
#   3356 -rw-r--r-- xgobi/src/central_mass.c
#  19662 -rw-r--r-- xgobi/src/xgv_cbacks.c
#   6972 -rw-r--r-- xgobi/src/smoothsk.c
#  16007 -rw-r--r-- xgobi/src/spin_cbacks.c
#  31586 -rw-r--r-- xgobi/src/tour_cbacks.c
#   4184 -rw-r--r-- xgobi/src/f2c.h
#  22000 -rw-r--r-- xgobi/src/make_axes.c
#  19979 -rw-r--r-- xgobi/src/rpc_spatial.c
#   5021 -rw-r--r-- xgobi/src/initialize.c
#   3693 -rw-r--r-- xgobi/src/xgvis.h
#  12943 -rw-r--r-- xgobi/src/xgvis.c
#   1931 -rw-r--r-- xgobi/src/rpc_vars.h
#   4290 -rw-r--r-- xgobi/src/show_message.c
#  12057 -rw-r--r-- xgobi/src/brush_cbacks.c
#  20498 -rw-r--r-- xgobi/src/identify.c
#   9901 -rw-r--r-- xgobi/src/natrl_hermite.c
#  33701 -rw-r--r-- xgobi/src/.#missing.c.1.1.1.1
#  11597 -rw-r--r-- xgobi/src/new_data.c
#  14585 -rw-r--r-- xgobi/src/scale_cbacks.c
#    506 -rw-r--r-- xgobi/src/rpc_client.h
#  12257 -rw-r--r-- xgobi/src/rpc_client.c
#   9339 -rw-r--r-- xgobi/src/smooth_fns.c
#  21887 -rw-r--r-- xgobi/src/plot_once.c
#   4847 -rw-r--r-- xgobi/src/ash1d.c
#  19646 -rw-r--r-- xgobi/src/inference.c
# 119396 -rw-r--r-- xgobi/src/tour_pp.c
#  50466 -rw-r--r-- xgobi/src/prt_plotwin.c
#  35190 -rw-r--r-- xgobi/src/line_editor.c
#  13513 -rw-r--r-- xgobi/src/rpc_functions.c
#   7881 -rw-r--r-- xgobi/src/utils.c
#  11202 -rw-r--r-- xgobi/src/paint.c
#   1399 -rw-r--r-- xgobi/src/DrawingA.h
#   5116 -rw-r--r-- xgobi/src/DrawingA.c
#  45118 -rw-r--r-- xgobi/src/transform.c
#   2521 -rw-r--r-- xgobi/src/stdize.c
# 103012 -rw-r--r-- xgobi/src/rpc_xgobi.c
#    936 -rw-r--r-- xgobi/src/rpc_xgobi.h
#   1062 -rw-r--r-- xgobi/src/xincludes.h
#  24072 -rw-r--r-- xgobi/src/xgv_mds.c
#   7874 -rw-r--r-- xgobi/src/tour_send.c
#  23905 -rw-r--r-- xgobi/src/brush_send.c
#  36452 -rw-r--r-- xgobi/src/xgv_widgets.c
#  25317 -rw-r--r-- xgobi/src/corr_pursuit.c
#   6896 -rw-r--r-- xgobi/src/rpc_server.h
#   3941 -rw-r--r-- xgobi/src/skewness.c
#  20224 -rw-r--r-- xgobi/src/rpc_server_proc.c
#   7677 -rw-r--r-- xgobi/src/tour_util.c
#   5551 -rw-r--r-- xgobi/src/.#Imakefile.1.1.1.1
#   2200 -rw-r--r-- xgobi/src/corr_util.c
#  23613 -rw-r--r-- xgobi/src/xgv_read_data.c
#  29720 -rw-r--r-- xgobi/src/read_array.c
#   9004 -rw-r--r-- xgobi/src/tour_section.c
#   3319 -rw-r--r-- xgobi/src/holes.c
#  13333 -rw-r--r-- xgobi/src/xyplot.c
#  13070 -rw-r--r-- xgobi/src/callbacks.c
#  22188 -rw-r--r-- xgobi/src/xgv_anchor.c
#   8081 -rw-r--r-- xgobi/src/de_indices.c
#  37969 -rw-r--r-- xgobi/src/.#widgets.c.1.1.1.1
#    965 -rw-r--r-- xgobi/src/rpc_dceerror.h
#   3334 -rw-r--r-- xgobi/src/dummy.c
#  56396 -rw-r--r-- xgobi/src/parcoords.c
#  12968 -rw-r--r-- xgobi/src/xgv_histogram.c
#  65849 -rw-r--r-- xgobi/src/save_data.c
#   9771 -rw-r--r-- xgobi/src/kernel.c
#  60980 -rw-r--r-- xgobi/src/pspline.c
#  11290 -rw-r--r-- xgobi/src/scaling.c
#  18755 -rw-r--r-- xgobi/src/xgobitypes.h
#  33825 -rw-r--r-- xgobi/src/missing.c
#   3432 -rw-r--r-- xgobi/src/xgobivars.h
#  22510 -rw-r--r-- xgobi/src/pipeline.c
#   9295 -rw-r--r-- xgobi/src/hermite.c
#   6840 -rw-r--r-- xgobi/src/getfname.c
#   1015 -rw-r--r-- xgobi/src/README.corba
#  19399 -rw-r--r-- xgobi/src/xgobi.c
#  16543 -rw-r--r-- xgobi/src/rpc_xpl.c
#  26801 -rw-r--r-- xgobi/src/exclusion.c
#   2026 -rw-r--r-- xgobi/src/aclocal.m4
#   1334 -rw-r--r-- xgobi/src/qnorm.c
#  79289 -rw-r--r-- xgobi/src/corr.c
#  23811 -rw-r--r-- xgobi/src/smooth.c
#  61105 -rw-r--r-- xgobi/src/tour.c
#  60326 -rw-r--r-- xgobi/src/read_data.c
#    673 -rw-r--r-- xgobi/src/rpc_aiiac.h
#    146 -rw-r--r-- xgobi/makefiles/Readme
#   2504 -rw-r--r-- xgobi/makefiles/Makefile
#   3833 -rw-r--r-- xgobi/manpages/xgvis.1
#  15345 -rw-r--r-- xgobi/manpages/xgobi.html
#   4320 -rw-r--r-- xgobi/manpages/xgvis.html
#  14866 -rw-r--r-- xgobi/manpages/xgobi.1
#   1126 -rw-r--r-- xgobi/help/xgv_stress.tex
#    667 -rw-r--r-- xgobi/help/Help
#   1336 -rw-r--r-- xgobi/help/DisplayOptions
#    600 -rw-r--r-- xgobi/help/Tour_PC_Axes
#   2018 -rw-r--r-- xgobi/help/ToPP
#    614 -rw-r--r-- xgobi/help/Tour_IOMenu
#   7427 -rw-r--r-- xgobi/help/VarPanel
#    125 -rw-r--r-- xgobi/help/Ro_Pause
#    109 -rw-r--r-- xgobi/help/TourPP_BMSZ
#    625 -rw-r--r-- xgobi/help/Sc_Center
#   1069 -rw-r--r-- xgobi/help/Print
#   8146 -rw-r--r-- xgobi/help/AV2XGErrTable
#    191 -rw-r--r-- xgobi/help/Ro_Reinit
#    644 -rw-r--r-- xgobi/help/Corr_Optmz
#    549 -rw-r--r-- xgobi/help/LE_AddLines
#    201 -rw-r--r-- xgobi/help/ToPP_ScaleXAxis
#    694 -rw-r--r-- xgobi/help/Identify_Cycle
#    205 -rw-r--r-- xgobi/help/LE_ShowLines
#   1889 -rw-r--r-- xgobi/help/Tour_Linking
#   2617 -rw-r--r-- xgobi/help/ExtendFileSet
#    219 -rw-r--r-- xgobi/help/VarList
#   1513 -rw-r--r-- xgobi/help/Tour_Backtrack
#    272 -rw-r--r-- xgobi/help/Brush_Erase
#    248 -rw-r--r-- xgobi/help/MP_Reset
#    177 -rw-r--r-- xgobi/help/Br_BrushOn
#    430 -rw-r--r-- xgobi/help/Br_PointsLines
#    845 -rw-r--r-- xgobi/help/Corr_Manip
#   2169 -rw-r--r-- xgobi/help/CreateFileSet
#     83 -rw-r--r-- xgobi/help/Ro_Chdir
#    442 -rw-r--r-- xgobi/help/Ro_Speed
#    166 -rw-r--r-- xgobi/help/Id_RmLabels
#   2529 -rw-r--r-- xgobi/help/ReadData
#    179 -rw-r--r-- xgobi/help/Options
#    167 -rw-r--r-- xgobi/help/ToPP_Bitmap
#    681 -rw-r--r-- xgobi/help/Br_GlyphMenu
#    130 -rw-r--r-- xgobi/help/Tour_Store
#    360 -rw-r--r-- xgobi/help/Tour_Speed
#    956 -rw-r--r-- xgobi/help/XYPlot_Cycle
#   7735 -rw-r--r-- xgobi/help/xgvis_controls
#    458 -rw-r--r-- xgobi/help/CaseList
#    514 -rw-r--r-- xgobi/help/FileMenu
#    199 -rw-r--r-- xgobi/help/Tour_BtrackDir
#   1044 -rw-r--r-- xgobi/help/Subset
#    182 -rw-r--r-- xgobi/help/Sc_ResetScale
#   1157 -rw-r--r-- xgobi/help/Corr_Pursuit
#    101 -rw-r--r-- xgobi/help/Sc_ResetShift
#    215 -rw-r--r-- xgobi/help/TourPP_RF
#    506 -rw-r--r-- xgobi/help/MP_Groups
#   1513 -rw-r--r-- xgobi/help/LinkBrush
#    147 -rw-r--r-- xgobi/help/Corr_SyncAxes
#    117 -rw-r--r-- xgobi/help/Tour_Pause
#    494 -rw-r--r-- xgobi/help/JumpBrush
#   2154 -rw-r--r-- xgobi/help/AboutXGobi
#    127 -rw-r--r-- xgobi/help/Tour_HistOn
#    973 -rw-r--r-- xgobi/help/TourPP_TermsinExp
#    194 -rw-r--r-- xgobi/help/Sc_PlotSquare
#   9531 -rw-r--r-- xgobi/help/ViewMenu
#    507 -rw-r--r-- xgobi/help/Sm_Width
#    484 -rw-r--r-- xgobi/help/SyncBrush
#     16 -rw-r--r-- xgobi/help/Magnify
#     81 -rw-r--r-- xgobi/help/TourPP_ShowPoints
#    973 -rw-r--r-- xgobi/help/ToPP_TermsExp
#   1316 -rw-r--r-- xgobi/help/Ro_SaveRMat
#   2086 -rw-r--r-- xgobi/help/xgvis_input_file_formats
#    367 -rw-r--r-- xgobi/help/LE_RmLines
#     16 -rw-r--r-- xgobi/help/Sc_ScaleType
#   1863 -rw-r--r-- xgobi/help/MissingData
#    818 -rw-r--r-- xgobi/help/Sc_ScaleCtrl
#   4409 -rw-r--r-- xgobi/help/xgvis
#    654 -rw-r--r-- xgobi/help/ToPP_Jumpsz
#    640 -rw-r--r-- xgobi/help/ToPP_Optmz
#   1638 -rw-r--r-- xgobi/help/Corr_Backtrack
#    225 -rw-r--r-- xgobi/help/Tour_SendUpdate
#    586 -rw-r--r-- xgobi/help/Tour_InterpMenu
#    336 -rw-r--r-- xgobi/help/Br_ResetMenu
#    488 -rw-r--r-- xgobi/help/Sc_ShiftCtrl
#    516 -rw-r--r-- xgobi/help/Stdize_NDev
#    754 -rw-r--r-- xgobi/help/Jitter
#    236 -rw-r--r-- xgobi/help/Tour_LocalScan
#    255 -rw-r--r-- xgobi/help/LE_RmAllLines
#    516 -rw-r--r-- xgobi/help/Brush_Modes
#    934 -rw-r--r-- xgobi/help/Sc_StdizeMenu
#    219 -rw-r--r-- xgobi/help/Tour_Reinit
#   1566 -rw-r--r-- xgobi/help/ParCoords
#    286 -rw-r--r-- xgobi/help/Corr_Reinit
#    152 -rw-r--r-- xgobi/help/TourPP_ShowLines
#    605 -rw-r--r-- xgobi/help/Tour_PrinComp
#   1158 -rw-r--r-- xgobi/help/Tour_Manip
#   1631 -rw-r--r-- xgobi/help/Transformations
#    224 -rw-r--r-- xgobi/help/Tour_StepGo
#    397 -rw-r--r-- xgobi/help/Ro_Interp
#     85 -rw-r--r-- xgobi/help/TourSectionEps
#    368 -rw-r--r-- xgobi/help/Tour_PathLen
#    360 -rw-r--r-- xgobi/help/ReshapeBrush
#   1654 -rw-r--r-- xgobi/help/ToolMenu
#    485 -rw-r--r-- xgobi/help/TourPP_RetnToBM
#    725 -rw-r--r-- xgobi/help/Plot1D_Cycle
#    478 -rw-r--r-- xgobi/help/Tour_Section
#    552 -rw-r--r-- xgobi/help/Plot1D
#    650 -rw-r--r-- xgobi/help/LinkIdent
#    953 -rw-r--r-- xgobi/help/xgvis_MDS_background
#    218 -rw-r--r-- xgobi/help/SubsetRescale
#   1145 -rw-r--r-- xgobi/help/Smooth
#    918 -rw-r--r-- xgobi/help/TourPP_RecordBM
#    199 -rw-r--r-- xgobi/help/Corr_BtrackDir
#    129 -rw-r--r-- xgobi/help/Corr_Pause
#    662 -rw-r--r-- xgobi/help/LinkLineBrush
#   2613 -rw-r--r-- xgobi/help/ToPP_IndexMenu
#    760 -rw-r--r-- xgobi/help/Br_ColorMenu
#    337 -rw-r--r-- xgobi/help/Br_SendUpdate
#   1508 -rw-r--r-- xgobi/help/Ro_SaveCoefs
#   1236 -rw-r--r-- xgobi/help/PlotWindow
#   1536 -rw-r--r-- xgobi/help/HideOrExclude
#    182 -rw-r--r-- xgobi/help/Ro_Axis
#    334 -rw-r--r-- xgobi/help/Sm_Menu
#    380 -rw-r--r-- xgobi/help/Ro_Rock
#    218 -rw-r--r-- xgobi/help/Sm_Show
#    684 -rw-r--r-- xgobi/help/Sm_Step
#    154 -rw-r--r-- xgobi/help/Corr_Sphere
#  13284 -rw-r--r-- xgobi/Changes
#    980 -rw-r--r-- xgobi/XGobi.ex
#   1680 -rw-r--r-- xgobi/corba/GNUmakefile
#    124 -rw-r--r-- xgobi/corba/Readme
#    753 -rw-r--r-- xgobi/Readme.S
#   9048 -rw-r--r-- xgobi/Readme.install
#    289 -rw-r--r-- xgobi/bitmaps/toff16.xbm
#    286 -rw-r--r-- xgobi/bitmaps/ton16.xbm
#    290 -rw-r--r-- xgobi/bitmaps/downarrow.xbm
#    290 -rw-r--r-- xgobi/bitmaps/leftarrow.xbm
#    284 -rw-r--r-- xgobi/bitmaps/lrarrow.xbm
#    284 -rw-r--r-- xgobi/bitmaps/uparrow.xbm
#  41140 -rw-r--r-- xgobi/bitmaps/strain_torgerson_gower.ps
#  40749 -rw-r--r-- xgobi/bitmaps/stress_torgersen_gower.ps
#    275 -rw-r--r-- xgobi/bitmaps/plus.xbm
#   3092 -rw-r--r-- xgobi/bitmaps/Bellcore.xbm
#   2996 -rw-r--r-- xgobi/bitmaps/stress_kruskal_shepard.tex
# 412382 -rw-r--r-- xgobi/bitmaps/stress_kruskal_shepard.xbm
#    482 -rw-r--r-- xgobi/bitmaps/rightarrow20.xbm
#    241 -rw-r--r-- xgobi/bitmaps/toff12.xbm
#    238 -rw-r--r-- xgobi/bitmaps/ton12.xbm
#    278 -rw-r--r-- xgobi/bitmaps/minus.xbm
#    479 -rw-r--r-- xgobi/bitmaps/leftarrow20.xbm
#    269 -rw-r--r-- xgobi/bitmaps/xy_mask.xbm
#  80934 -rw-r--r-- xgobi/bitmaps/splash.xbm
#    293 -rw-r--r-- xgobi/bitmaps/rightarrow.xbm
#    278 -rw-r--r-- xgobi/bitmaps/xy.xbm
#  41988 -rw-r--r-- xgobi/bitmaps/stress_kruskal_shepard.ps
#    239 -rw-r--r-- xgobi/bitmaps/menu12.xbm
# 195416 -rw-r--r-- xgobi/bitmaps/stress.xbm
# 396269 -rw-r--r-- xgobi/bitmaps/strain_torgerson_gower.xbm
#   2835 -rw-r--r-- xgobi/bitmaps/strain_torgerson_gower.tex
# 392195 -rw-r--r-- xgobi/bitmaps/stress_torgersen_gower.xbm
#   2835 -rw-r--r-- xgobi/bitmaps/stress_torgersen_gower.tex
#   1457 -rw-r--r-- xgobi/Copyright
#   1546 -rw-r--r-- xgobi/Readme.PC
#   1710 -rw-r--r-- xgobi/data_xgobi/c60
#     40 -rw-r--r-- xgobi/data_xgobi/sphere1.resources
#     40 -rw-r--r-- xgobi/data_xgobi/sphere2.resources
#    157 -rw-r--r-- xgobi/data_xgobi/prim7.res
#   1323 -rw-r--r-- xgobi/data_xgobi/prim7.doc
#   2937 -rw-r--r-- xgobi/data_xgobi/olive.colors
#  27521 -rw-r--r-- xgobi/data_xgobi/prim7
#   5752 -rw-r--r-- xgobi/data_xgobi/prim7.colors
#    688 -rw-r--r-- xgobi/data_xgobi/flea.row
#   1583 -rw-r--r-- xgobi/data_xgobi/flea.dat
#    699 -rw-r--r-- xgobi/data_xgobi/flea.doc
#     52 -rw-r--r-- xgobi/data_xgobi/flea.col
#    836 -rw-r--r-- xgobi/data_xgobi/death1987.row
#     11 -rw-r--r-- xgobi/data_xgobi/death1987.col
#   1500 -rw-r--r-- xgobi/data_xgobi/prim7.glyphs
#    217 -rw-r--r-- xgobi/data_xgobi/places.resources
#    120 -rw-r--r-- xgobi/data_xgobi/laser.resources
#    140 -rw-r--r-- xgobi/data_xgobi/randu.doc
#   2267 -rw-r--r-- xgobi/data_xgobi/sleep.table
#     34 -rw-r--r-- xgobi/data_xgobi/kai.resources
#  17000 -rw-r--r-- xgobi/data_xgobi/randu
#   2585 -rw-r--r-- xgobi/data_xgobi/river
#   1098 -rw-r--r-- xgobi/data_xgobi/cube6.lines
#    515 -rw-r--r-- xgobi/data_xgobi/tips.doc
#  11224 -rw-r--r-- xgobi/data_xgobi/tips.dat
#     41 -rw-r--r-- xgobi/data_xgobi/tips.col
#   1393 -rw-r--r-- xgobi/data_xgobi/olive.glyphs
#     88 -rw-r--r-- xgobi/data_xgobi/olive.col
#   8171 -rw-r--r-- xgobi/data_xgobi/olive.row
#    768 -rw-r--r-- xgobi/data_xgobi/cube6
#    669 -rw-r--r-- xgobi/data_xgobi/laser.doc
#     26 -rw-r--r-- xgobi/data_xgobi/laser.col
#     59 -rw-r--r-- xgobi/data_xgobi/olive.resources
#    314 -rw-r--r-- xgobi/data_xgobi/sphere2.doc
#  13269 -rw-r--r-- xgobi/data_xgobi/sphere2.dat
#    270 -rw-r--r-- xgobi/data_xgobi/river.doc
#     16 -rw-r--r-- xgobi/data_xgobi/river.col
#   2794 -rw-r--r-- xgobi/data_xgobi/places.doc
#     96 -rw-r--r-- xgobi/data_xgobi/places.col
#   6874 -rw-r--r-- xgobi/data_xgobi/places.row
#    417 -rw-r--r-- xgobi/data_xgobi/death1987.lines
#   1572 -rw-r--r-- xgobi/data_xgobi/sleep.doc
#   3554 -rw-r--r-- xgobi/data_xgobi/sleep.dat
#     60 -rw-r--r-- xgobi/data_xgobi/sleep.col
#    739 -rw-r--r-- xgobi/data_xgobi/sleep.row
#    313 -rw-r--r-- xgobi/data_xgobi/sphere1.doc
#  13280 -rw-r--r-- xgobi/data_xgobi/sphere1.dat
#    960 -rw-r--r-- xgobi/data_xgobi/c60.linecolors
#    522 -rw-r--r-- xgobi/data_xgobi/kai.doc
#    308 -rw-r--r-- xgobi/data_xgobi/kai.dat
#     52 -rw-r--r-- xgobi/data_xgobi/kai.row
#    217 -rw-r--r-- xgobi/data_xgobi/death1987.resources
#    724 -rw-r--r-- xgobi/data_xgobi/flea.colors
#     68 -rw-r--r-- xgobi/data_xgobi/prim7.lines
#     26 -rw-r--r-- xgobi/data_xgobi/kai.lines
#    201 -rw-r--r-- xgobi/data_xgobi/flea.glyphs
#    513 -rw-r--r-- xgobi/data_xgobi/c60.lines
#    196 -rw-r--r-- xgobi/data_xgobi/prim7.resources
#   1302 -rw-r--r-- xgobi/data_xgobi/sleep.missing
#  23781 -rw-r--r-- xgobi/data_xgobi/places
#   1216 -rw-r--r-- xgobi/data_xgobi/laser
#      8 -rw-r--r-- xgobi/data_xgobi/laser.vgroups
#    830 -rw-r--r-- xgobi/data_xgobi/death1987
#  19776 -rw-r--r-- xgobi/data_xgobi/olive
#    328 -rw-r--r-- xgobi/data_xgvis/perm4.linecolors
#    513 -rw-r--r-- xgobi/data_xgvis/buckyball.lines
#    452 -rw-r--r-- xgobi/data_xgvis/morsecodes.colors
#    440 -rw-r--r-- xgobi/data_xgvis/morsecodes.linecolors
#  12960 -rw-r--r-- xgobi/data_xgvis/perm6.pos
#    468 -rw-r--r-- xgobi/data_xgvis/basket.pos
#   2160 -rw-r--r-- xgobi/data_xgvis/perm5.pos
#    384 -rw-r--r-- xgobi/data_xgvis/torus2.edges
#    804 -rw-r--r-- xgobi/data_xgvis/torus1.edges
#    450 -rw-r--r-- xgobi/data_xgvis/grid5.pos
#    108 -rw-r--r-- xgobi/data_xgvis/morsecodes.glyphs
#    120 -rw-r--r-- xgobi/data_xgvis/perm4.row
#    456 -rw-r--r-- xgobi/data_xgvis/perm4.pos
#    212 -rw-r--r-- xgobi/data_xgvis/grid5.edges
#   8352 -rw-r--r-- xgobi/data_xgvis/hyper8.edges
#   1710 -rw-r--r-- xgobi/data_xgvis/buckyball.dat
#   2661 -rw-r--r-- xgobi/data_xgvis/morsecodes.R
#    630 -rw-r--r-- xgobi/data_xgvis/torus2.pos
#   5040 -rw-r--r-- xgobi/data_xgvis/perm6.labels
#    720 -rw-r--r-- xgobi/data_xgvis/perm5.labels
#   1140 -rw-r--r-- xgobi/data_xgvis/torus1.pos
#   4994 -rw-r--r-- xgobi/data_xgvis/morsecodes.dist
#     46 -rw-r--r-- xgobi/data_xgvis/buckyball.resources
#  13860 -rw-r--r-- xgobi/data_xgvis/perm6.edges
#   1488 -rw-r--r-- xgobi/data_xgvis/perm5.edges
#    189 -rw-r--r-- xgobi/data_xgvis/perm4.edges
#    235 -rw-r--r-- xgobi/data_xgvis/basket.edges
#   2069 -rw-r--r-- xgobi/data_xgvis/morsecodes.doc
#   1728 -rw-r--r-- xgobi/data_xgvis/morsecodes.dat
#     63 -rw-r--r-- xgobi/data_xgvis/morsecodes.col
#   4644 -rw-r--r-- xgobi/data_xgvis/morsecodes.sim
#    240 -rw-r--r-- xgobi/data_xgvis/morsecodes.row
#   3393 -rw-r--r-- xgobi/data_xgvis/morsecodes.raw
#   1728 -rw-r--r-- xgobi/data_xgvis/morsecodes.pos
#    206 -rw-r--r-- xgobi/data_xgvis/morsecodes.lines
#    540 -rw-r--r-- xgobi/data_xgvis/buckyball.linecolors
#   4608 -rw-r--r-- xgobi/data_xgvis/hyper8.pos
#
save_IFS="${IFS}"
IFS="${IFS}:"
gettext_dir=FAILED
locale_dir=FAILED
first_param="$1"
for dir in $PATH
do
  if test "$gettext_dir" = FAILED && test -f $dir/gettext \
     && ($dir/gettext --version >/dev/null 2>&1)
  then
    set `$dir/gettext --version 2>&1`
    if test "$3" = GNU
    then
      gettext_dir=$dir
    fi
  fi
  if test "$locale_dir" = FAILED && test -f $dir/shar \
     && ($dir/shar --print-text-domain-dir >/dev/null 2>&1)
  then
    locale_dir=`$dir/shar --print-text-domain-dir`
  fi
done
IFS="$save_IFS"
if test "$locale_dir" = FAILED || test "$gettext_dir" = FAILED
then
  echo=echo
else
  TEXTDOMAINDIR=$locale_dir
  export TEXTDOMAINDIR
  TEXTDOMAIN=sharutils
  export TEXTDOMAIN
  echo="$gettext_dir/gettext -s"
fi
if mkdir _sh573576; then
  $echo 'x -' 'creating lock directory'
else
  $echo 'failed to create lock directory'
  exit 1
fi
# ============= xgobi/S/clust-docu.S ==============
if test ! -d 'xgobi'; then
  $echo 'x -' 'creating directory' 'xgobi'
  mkdir 'xgobi'
fi
if test ! -d 'xgobi/S'; then
  $echo 'x -' 'creating directory' 'xgobi/S'
  mkdir 'xgobi/S'
fi
if test -f 'xgobi/S/clust-docu.S' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/S/clust-docu.S' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/S/clust-docu.S' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/S/clust-docu.S' &&
xgobi.tree _ function( c.hclust, c.dat, glyph.types=c(16,31) ) {
X  c.n  _ dim(c.dat)[1]
X  c.xy _ cbind( order( c.hclust$order ), 0 )    # coordinates for points
X  c.cl _ cbind( rep(0,c.n-1), 0 )               # coordinates for cluster nodes
X  c.mu _ matrix(0,c.n-1,dim(c.dat)[2])          # multivariate coordinates for cluster nodes
X  c.nn _ rep(0,c.n)
X  c.lk _ matrix( 0, ncol=2, nrow=2*(c.n-1) )    # list of links
X  for(i in 1:(c.n-1) ) {
X    ii _ c.hclust$merge[i,1];  jj _ c.hclust$merge[i,2]
X    if(ii<0 & jj<0) { c.xy[-ii,2] _ 0
X                      c.xy[-jj,2] _ 0
X                      c.cl[  i,1] _ ( c.xy[-ii,1] + c.xy[-jj,1] )/2
X                      c.cl[  i,2] _ c.hclust$height[i]
X                      c.nn[i]     _ 2
X                      c.mu[i,]    _ ( c.dat[-ii,] + c.dat[-jj,] )/c.nn[i]
X                    }
X    if(ii<0 & jj>0) { c.xy[-ii,2] _ c.hclust$height[jj]
X                      c.cl[  i,1] _ ( c.xy[-ii,1] + c.cl[jj,1] )/2
X                      c.cl[  i,2] _ c.hclust$height[i]
X                      c.nn[i]     _ c.nn[jj] + 1
X                      c.mu[i,]    _ ( c.dat[-ii,] + c.nn[jj]*c.mu[jj,] )/c.nn[i]
X                    }
X    if(ii>0 & jj<0) { c.xy[-jj,2] _ c.hclust$height[ii]
X                      c.cl[  i,1] _ ( c.xy[-jj,1] + c.cl[ii,1] )/2
X                      c.cl[  i,2] _ c.hclust$height[i]
X                      c.nn[i]     _ c.nn[ii] + 1
X                      c.mu[i,]    _ ( c.nn[ii]*c.mu[ii,] + c.dat[-jj,] )/c.nn[i]
X                    }
X    if(ii>0 & jj>0) { c.cl[  i,1] _ ( c.cl[ii,1] + c.cl[jj,1] )/2
X                      c.cl[  i,2] _ c.hclust$height[i]
X                      c.nn[i]     _ c.nn[ii] + c.nn[jj]
X                      c.mu[i,]    _ ( c.nn[ii]*c.mu[ii,] + c.nn[jj]*c.mu[jj,] )/c.nn[i]
X                    }
X    c.lk[2*i-1,1] _ ifelse(ii>0,c.n+ii,-ii)
X    c.lk[2*i-1,2] _ c.n+i
X    c.lk[2*i,  1] _ ifelse(jj>0,c.n+jj,-jj)
X    c.lk[2*i,  2] _ c.n+i
X    if( i%%10 == 0 ) print( c(i,ii,jj) )
X    }
X  list( data=cbind( rbind(c.xy,c.cl), rbind(c.dat,c.mu), c(rep(0,c.n),rep(1,c.n-1)) ),
X        lines=c.lk,
X        collab=c("Objects","Merge Level",dimnames(c.dat)[[2]], "Nodes"),
X        glyphs=c(rep(glyph.types[1],c.n),rep(glyph.types[2],c.n-1))
X      )
X  }
X
# example:
X
# first line: the iris data come in a 3-way array; collapse into a matrix and append a
# grouping vector
c.dat _ cbind( rbind(iris[,,1],iris[,,2],iris[,,3]), ,grp=rep(1:3,rep(50,3)) )
# interpoint distances computed from all variables except the grouping variable:
c.dist _ dist( c.dat[,-5] )
# hclust:
c.hclust _ hclust( dist=c.dist, method="ave" )
X
# call the above function to compute cluster node points and lines:
c.tox _ xgobi.tree( c.hclust, c.dat )
X
# call xgobi twice for linking:
xgobi( c.tox$dat, lines=c.tox$lines, collab=c.tox$coll, 
X       glyphs=c.tox$glyphs, colors=rep("Yellow",299), title="", 
X       nlinkable=dim(c.dat)[1] )  # remove this argument if it bombs
X
# or write out to files and call xgobi from unix:
write( t(c.tox$dat),   file="iris.tree.dat",    ncol=dim(c.tox$dat)[2] )
write( t(c.tox$lines), file="iris.tree.lines",  ncol=2 )
write( c.tox$coll,     file="iris.tree.col",    ncol=1 )
write( c.tox$glyphs,   file="iris.tree.glyphs", ncol=1 )
write( dim(c.dat)[1],  file="iris.tree.nlinkable" ) # does your xgobi version have this?
write( rep("Yellow",dim(c.tox$dat)[1]), file="iris.tree.colors", ncol=1 )
!xgobi iris.tree &
!xgobi iris.tree &
# Although it looks like more work, I prefer the use of xgobi outside S: 
# sometimes a new feature has not made it into the xgobi S function, 
# but it may be present in the raw xgobi.  An example is the "nlinkable"
# feature which allows you to brush the terminal nodes only and not the
# branches.
X
X
# Now do the following: it's really fun!
# 1st xgobi: place at top of screen, make as wide as you can;
#            widen the plotting area by pulling the handles in the bottom corners;
#            select "LineEdit" or hit "l" to show lines (play toggle "Show Lines");
#            select "Scale" or hit "s" and scale plot to fit the wide plotting area;
# 2nd xgobi: place underneath, widen the plotting area to square shape;
#            select "LineEdit" or hit "l" if you want to see the tree
#            select "Tour" or hit "t" to enter the grand tour;
#            select the four variables ".. width" and ".. length" by clicking/toggling
#            the variable boxes; deselect the first two variables;
#            adjust speed (>0) by pulling the gauge above the "Pause" button;
#            the following works only if you have the most recent version of xgobi:
#              manual control of projections: depress "<Shift>" and click on the circle
#              of the variable "MergeLevel": it gets marked by an inside circle;
#              now depress left anytime on the plot and drag the mouse in any direction:
#              you will be pulling the "MergeLevel" into the projection; as you release,
#              "MergeLevel" will gradually fade out of the projection;
# 1s xgobi:  select "Brush" or hit "b" and brush parts of the tree with another 
#            color and glyph;
X
X
SHAR_EOF
  chmod 0644 'xgobi/S/clust-docu.S' ||
  $echo 'restore of' 'xgobi/S/clust-docu.S' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/S/clust-docu.S:' 'MD5 check failed'
b0701ea95614e91d18d92e392e9226ea  xgobi/S/clust-docu.S
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/S/clust-docu.S'`"
    test 5126 -eq "$shar_count" ||
    $echo 'xgobi/S/clust-docu.S:' 'original size' '5126,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/S/xgvis.d ==============
if test -f 'xgobi/S/xgvis.d' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/S/xgvis.d' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/S/xgvis.d' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/S/xgvis.d' &&
X.tr @@
X.BG
X.FN xgvis
X.TL
xgvis: interactive multidimensional scaling using xgobi for display
X.DN
an interactive multidimensional scaling (MDS) program that
consists of a control panel to manipulate the parameters of the
MDS stress function and an xgobi window for data display.  It
can be used either for visualization of dissimilarity data, for
dimension reduction, or for graph layout.  Graph layout is
usually done in 2D, but xgvis allows layouts in arbitrary
dimensions, 3D being the default.  It permits missing values,
which can be used to implement multidimensional unfolding.
X.CS
xgvis(matrx,
edges=NULL, pos=NULL, rowlab=NULL, colors=NULL, glyphs=NULL,
erase=NULL, lines=NULL, linecolors=NULL, resources=NULL,
display=NULL)
X.RA
X.AG matrx
A n nxn distance matrix
X.AG edges
Line segments: specifications for the pattern of line segments which
connect pairs of points.  The file must contain at least two numbers per
line.  The first two numbers represent the row numbers of the two
points that should be connected.  (This is exactly like the structure
of a fname.lines file in xgobi.)  In addition, if a third number is
present, it is taken to be an edge weight.
X.B NOTE:
If this line is present and the distance matrix is absent, then
the distance matrix is computed from it, with each
edge representing a distance of one.
X.AG pos
Starting positions:  an n x p matrix, with entries separated by
white space and one row per line. 
X.B NOTE:
If this file is present and a
distance file is absent, the distance matrix is computed from it.
X.AG rowlab
Optional character vector of row labels; the default is
`dimnames(matrx)[[1]]'.  If no default exists, xgobi constructs its own
defaults.
X.AG colors
Optional character vector, used to supply initial point colors to be used;
the default is that all points are the same color.
X.AG glyphs
Optional integer vector, used to supply glyphs to be used on
startup; the default is that all points are drawn with the same glyph.
X.AG erase
Optional integer vector of length equal to the number of rows in the
data and composed of 1s and 0s.  A 1 in position i specifies that 
point i should be erased.  The default is a vector of 0s.
X.AG lines
Optional integer matrix, n by 2, which specifies by row number
pairs of points to be connected by line segments.
X.B NOTE:
If this file is present, then the edges
file is used to create the distance matrix but the lines file is
used to draw the edges.
X.AG linecolors
Optional integer vector, of length n where n is the number of
lines specified by the 'lines' argument.  It is used to supply
line colors to be used on startup; the default is for all the
lines to be drawn in the standard foreground color.
X.AG resources
Optional character vector created by clicking on the "Save
Resources" button in XGobi (if this XGvis was initiated during
an S session).
X.AG display
Optional character string, identifying the monitor on which to display
the xgvis window.  The default is `"machine:0.0"' where `machine' is the
name of the user's workstation.  See documentation for X.
X.RT
The UNIX `status' upon completion, i.e. `0' if ok.
X.SE
The xgvis S function executes a call to the C program of the same name,
and returns control of the S shell to the user.
X.SH REFERENCE
http://www.research.att.com/areas/stat/xgobi/
http://www.public.iastate.edu/~dicook/
X.SH CONTACT
D. F. Swayne dfs@research.att.com
X.EX
The following examples use sample data files in the data_xgvis
directory in the xgobi and xgvis distribution directory.
X
morsecodes.dist _ matrix(scan("data_xgvis/morsecodes.dist"),
X  ncol=36, byrow=T)
morsecodes.pos _ matrix(scan("data_xgvis/morsecodes.pos"),
X  ncol=12, byrow=T)
morsecodes.lines _ matrix(scan("data_xgvis/morsecodes.lines"),
X  ncol=2, byrow=T)
morsecodes.glyphs _ scan("data_xgvis/morsecodes.glyphs")
morsecodes.colors _ scan("data_xgvis/morsecodes.colors", what="")
morsecodes.linecolors _ scan("data_xgvis/morsecodes.linecolors", what="")
morsecodes.row _ scan("data_xgvis/morsecodes.row", what="")
xgvis(dmat=morsecodes.dist, 
X      pos=morsecodes.pos, 
X      row=morsecodes.row,
X      colors=morsecodes.colors,
X      glyphs=morsecodes.glyphs,
X      lines=morsecodes.lines,
X      linecolors=morsecodes.linecolors)
X
perm4.edges _ matrix(scan("data_xgvis/perm4.edges"), ncol=2, byrow=T)
perm4.colors _ scan("data_xgvis/perm4.colors", what="")
perm4.linecolors _ scan("data_xgvis/perm4.linecolors", what="")
xgvis(edges=perm4.edges)
xgvis(edges=perm4.edges,
X  colors=perm4.colors,
X  linecolors=perm4.linecolors)
X
X.KW dynamic, interactive, graphics, plotting, multidimensional scaling
X.WR
SHAR_EOF
  chmod 0644 'xgobi/S/xgvis.d' ||
  $echo 'restore of' 'xgobi/S/xgvis.d' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/S/xgvis.d:' 'MD5 check failed'
2bfc565f3583ce49f910b311a41b9cae  xgobi/S/xgvis.d
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/S/xgvis.d'`"
    test 4591 -eq "$shar_count" ||
    $echo 'xgobi/S/xgvis.d:' 'original size' '4591,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/S/xgvis.S ==============
if test -f 'xgobi/S/xgvis.S' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/S/xgvis.S' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/S/xgvis.S' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/S/xgvis.S' &&
X
xgvis <-
X  function(dmat       = NULL,
X           edges      = NULL,
X           pos        = NULL,
X           rowlab     = NULL,
X           colors     = NULL,
X           glyphs     = NULL,
X           erase      = NULL,
X           lines      = NULL,
X           linecolors = NULL,
X           resources  = NULL,
X           display    = NULL)
{
X  if (missing(edges) && missing(pos) && missing(dmat)) {
X    cat("One of dmat, edges, or pos must be present\n")
X    return()
X  }
X
X  tpath <- getenv("S_TMP")
X  if(nchar(tpath) == 0) tpath <- getenv("TEMP")
X  basefile <- paste(tpath, tempfile("xgvis"), sep = "/")
X
X  ### distance matrix ###
X  if (!missing(dmat)) {
X    dmat <- eval(dmat)
X    if (sum(abs(dmat[!is.na(dmat)])) == Inf > 0) {
X      cat("xgvis can't handle Infs in dmat, replaced with NA\n")
X      dmat[dmat==Inf] <- NA
X    }
X    dfile <- paste(basefile, ".dist", sep="")
X    write(t(dmat), file = dfile, ncolumns = ncol(dmat))
X    on.exit(unlink(dfile), add=T)
X  }
X
X  ### Edges ###
X  if (!missing(edges))
X    {
X      # check data type
X      if (!is.matrix(edges) || !is.numeric(edges) || dim(edges)[2] != 2) {
X        cat("The 'edges' argument must be a numeric 2-column matrix\n")
X        return()
X      }
X
X      edgesfile <- paste(basefile, ".edges", sep="")
X      if (nrow(edges) > 0) {
X	write(t(edges), file = edgesfile, ncol=2)
X      }
X      on.exit(unlink(edgesfile), add=T)
X    }
X
X  ### position matrix ###
X  if (!missing(pos)) {
X    pos <- eval(pos)
X    if (sum(abs(pos[!is.na(pos)])) == Inf > 0)
X      {
X        cat("xgvis can't handle Inf in pos; replaced with NA\n")
X        pos[pos==Inf] <- NA
X      }
X    pfile <- paste(basefile, ".pos", sep="")
X    write(t(pos), file = pfile, ncolumns = ncol(pos))
X    on.exit(unlink(pfile), add = T)
X  }
X
X  ### Row labels ###
X  if (!missing(rowlab))
X    # check data type
X    if (!is.vector(rowlab) || !is.character(rowlab)) {
X      cat("The 'rowlab' argument needs to be a character vector\n")
X      return()
X    }
X  if (length(rowlab) > 0) {
X    rowfile <- paste(basefile, ".row", sep="")
X    write(rowlab, file = rowfile, ncol=1)
X    on.exit(unlink(rowfile), add = T)
X  }
X
X  ### Colors ###
X  if (!missing(colors)) {
X    # check data type
X    if (!is.vector(colors) || !is.character(colors)) {
X      cat("The 'colors' argument needs to be a character vector\n")
X      return()
X    }
X    colorfile <- paste(basefile, ".colors", sep="")
X    write(colors, file = colorfile, ncol=1)
X    on.exit(unlink(colorfile), add = T)
X  }
X  
X  ### Glyphs ###
X  if (!missing(glyphs)) {
X    # check data type
X    if (!is.vector(glyphs) || !is.numeric(glyphs)) {
X      cat("The 'glyphs' argument needs to be a numeric vector\n")
X      return()
X    }
X    glyphfile <- paste(basefile, ".glyphs", sep="")
X    write(glyphs, file = glyphfile, ncol=1)
X    on.exit(unlink(glyphfile), add = T)
X  }
X  
X  ### Erase ###
X  if (!missing(erase)) {
X    # check data type
X    if (!is.vector(erase) || !is.numeric(erase)) {
X      cat("The 'erase' argument needs to be a numeric vector\n")
X      return()
X    }
X    erasefile <- paste(basefile, ".erase", sep="")
X    write(erase, file = erasefile, ncol=1)
X    on.exit(unlink(erasefile), add = T)
X  }
X
X  ### Connected lines ###
X  if (!missing(lines)) {
X    # check data type
X    if (!is.matrix(lines) || !is.numeric(lines) || dim(lines)[2] != 2) {
X      cat("The 'lines' argument must be a numeric 2-column matrix\n")
X      return()
X    }
X
X    linesfile <- paste(basefile, ".lines", sep="")
X    if (nrow(lines) > 0) {
X      write(t(lines), file = linesfile, ncol=2)
X      on.exit(unlink(linesfile), add = T)
X    }
X  }
X
X  ### Line colors ###
X  if ((!missing(lines) || !missing(edges)) && !missing(linecolors)) {
X    # check data type
X    if (!is.vector(linecolors) || !is.character(linecolors)) {
X      cat("The 'linecolors' argument must be a character vector\n")
X      return()
X    }
X    linecolorfile <- paste(basefile, ".linecolors", sep="")
X    write(linecolors, file = linecolorfile, ncol=1)
X    on.exit(unlink(linecolorfile), add = T)
X  }
X
X  ### Resources ###
X  if (!missing(resources)) {
X    # check data type
X    if (!is.vector(resources) || !is.character(resources)) {
X      cat("The 'resources' argument must be a character vector\n")
X      return()
X    }
X    resourcefile <- paste(basefile, ".resources", sep="")
X    write(resources, file = resourcefile, ncol=1)
X    on.exit(unlink(resourcefile), add = T)
X  }
X
X
X  # Note to installer:
X  # Here you need to specify the path to the xgvis batch file/ executable
X  # on your system.
X  #
X  # dos example:
#  xgpath <- "c:/packages/xgobi/xgvis.bat"
X  # unix example:
X  xgpath <- "/usr/dfs/xgobi/joint/src/xgvis"
X  command <- paste(xgpath, basefile)
X  cat(command, "\n")
X  # dos:
#  invisible(dos(command, multi = F, minimized = T, output.to.S = F, translate = T))
X  # unix:
X  invisible(unix(command))
}
X
SHAR_EOF
  chmod 0644 'xgobi/S/xgvis.S' ||
  $echo 'restore of' 'xgobi/S/xgvis.S' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/S/xgvis.S:' 'MD5 check failed'
5bf79e4a97cc1abedfc15bb0211cec2c  xgobi/S/xgvis.S
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/S/xgvis.S'`"
    test 4825 -eq "$shar_count" ||
    $echo 'xgobi/S/xgvis.S:' 'original size' '4825,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/S/xgobi.d ==============
if test -f 'xgobi/S/xgobi.d' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/S/xgobi.d' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/S/xgobi.d' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/S/xgobi.d' &&
X.tr @@
X.BG
X.FN xgobi
X.TL
XXGobi: Dynamic Graphics for Data Analysis
X.DN
Dynamic graphics, including  brushing, rotation, grand tour, projection
pursuit, slicing. Most effectively used when called more than once on same
data, which then allows linked plots.  Brushing with several glyphs and
colors is supported.  (On monochrome displays, only glyphs can be used.)
X.CS
xgobi(matrx,
collab=NULL, rowlab=NULL,
colors=NULL, glyphs=NULL, erase=NULL,
lines=NULL, linecolors=NULL,
resources=NULL, title=NULL,
vgroups=NULL, std="mmx",
nlinkable=0, subset=NULL,
display=NULL)
X.RA
X.AG matrx
Any numeric matrix or data.frame.
X.OA
X.AG collab
Optional character vector of column labels; the default is
`dimnames(matrx)[[2]]'.  If no default exists, xgobi constructs its own
defaults.
X.AG rowlab
Optional character vector of row labels; the default is
`dimnames(matrx)[[1]]'.  If no default exists, xgobi constructs its own
defaults.
X.AG colors
Optional character vector, used to supply initial point colors to be used;
the default is that all points are the same color.
X.AG glyphs
Optional integer vector, used to supply glyphs to be used on
startup; the default is that all points are drawn with the same glyph.
X.AG erase
Optional integer vector of length equal to the number of rows in the
data and composed of 1s and 0s.  A 1 in position i specifies that 
point i should be erased.  The default is a vector of 0s.
X.AG lines
Optional integer matrix, n by 2, which specifies by row number
pairs of points to be connected by line segments.  The default
connecting line matrix connects each point to the one that follows
it in the data; that is, (1 2), (2 3), (3 4), ..., (n-1, n).
X.AG linecolors
Optional integer vector, of length n where n is the number of
lines specified by the 'lines' argument.  It is used to supply
line colors to be used on startup; the default is for all the
lines to be drawn in the standard foreground color.
X.AG resources
Optional character vector created by clicking on the "Save
Resources" button in XGobi (if this XGobi was initiated during
an S session).
X.AG title
Optional character string which defines the `-title' argument used by
XX. The default is the name of the current matrix matrx.  See documentation
for xgobi, or for X.
X.AG vgroups
Optional integer vector, used to assign columns to groups for 
transformation and axis scaling.  This vector must contain one integer
for each variable.  Columns to be grouped together should share the
same integer.  Default is the vector 1:(ncol(matrx)).
X.AG std
Optional string; which standardization of view to use.  Default is
`"mmx"', minimum-maximum scaling, in which the view is centered at the
midpoint of the data, and all the data fits inside the plotting
window.  Alternatives are `"msd"', in which the plot is centered at the
mean of the data, or `"mmd"' in which the plot is centered at the median.
In those two cases, the view is standardized using the largest distance.
X.AG dev
Optional numeric scalar; the number of standard deviations (if `"msd"'
is chosen) or median absolute deviations (if `"mmd"' is chosen) that will
be plotted inside the plotting window.  Default is 2.
X.AG nlinkable
Optional integer scalar, the number of rows to be used in linking
of brushing and identification;
the default is for all rows to be used.  This feature can be used
to link ordinary scatterplots with plots that have some decorations
requiring additional points, such as clustering trees.
X.AG subset
Optional integer scalar, the number of rows to be included in the
initial display.  That is, all data will be read in, but an
initial random sample will be drawn for display.  Use the Subset
panel on the Tools Menu to select a new subset during the session.
X.AG display
Optional character string, identifying the monitor on which to display
the xgobi window.  The default is `"machine:0.0"' where `machine' is the
name of the user's workstation.  See documentation for xgobi or for X.
X.RT
The UNIX `status' upon completion, i.e. `0' if ok.
X.SE
The xgobi S function executes a call to the C program of the same name,
an interactive statistical graphics program which runs under the X
Window System, and returns control of the S shell to the user.
X.PP
XXGobi can be used to create vectors of brushing information and rotation
coefficients; see the documentation for XGobi for details.
X.SH REFERENCE
http://www.research.att.com/areas/stat/xgobi/
http://www.public.iastate.edu/~dicook/
X.SH CONTACT
D. F. Swayne dfs@research.att.com
X.EX
xgobi(x) 
xgobi(cbind(x,y,z), name="laser")
xgobi(x, collabels, rowlabels, subset=5000)
X
X.KW dynamic, interactive, graphics, plotting, rotation, grand tour, identify
X.WR
SHAR_EOF
  chmod 0644 'xgobi/S/xgobi.d' ||
  $echo 'restore of' 'xgobi/S/xgobi.d' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/S/xgobi.d:' 'MD5 check failed'
6e163792ec1744ae85c007423ed9288f  xgobi/S/xgobi.d
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/S/xgobi.d'`"
    test 4665 -eq "$shar_count" ||
    $echo 'xgobi/S/xgobi.d:' 'original size' '4665,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/S/xgobi.S ==============
if test -f 'xgobi/S/xgobi.S' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/S/xgobi.S' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/S/xgobi.S' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/S/xgobi.S' &&
xgobi <- function(matrx,
X                  collab     = dimnames(matrx)[[2]],
X                  rowlab     = dimnames(matrx)[[1]],
X                  colors     = NULL,
X                  glyphs     = NULL,
X                  erase      = NULL,
X                  lines      = NULL,
X                  linecolors = NULL,
X                  resources  = NULL,
X                  title      = NULL,
X                  vgroups    = NULL,
X                  std        = "mmx",
X                  nlinkable  = NULL,
X                  subset     = NULL,
X                  display    = NULL)
{
X    if (!missing(matrx))
X    {
X        ### data matrix ###
X        x <- eval(matrx)
X        if (sum(abs(x[!is.na(x)])) == Inf > 0)
X        {
X          cat("Sorry, xgobi can't handle Infs\n")
X          return()
X        }
X        dfile <- tempfile("unix")
#       cat(t(x), file = dfile, fill = 80)
X        x <- as.matrix(x)
X        cat(t(x), file=dfile, sep=c(rep(" ",ncol(x)-1),"\n"))
X
X        args <- ""
X
X        ### Column labels ###
X        if (missing(collab))
X          collab <- dimnames(x)[[2]]
X        else {
X          # check data type
X          if (!is.vector(collab) || !is.character(collab)) {
X            cat("The 'collab' argument needs to be a character vector\n")
X            return()
X          }
X        }
X        if (length(collab) > 0)
X        {
X          colfile <- paste(dfile, ".col", sep="")
X          cat(collab, file = colfile, sep="\n")
X        }
X
X        ### Row labels ###
X        if (missing(rowlab))
X          rowlab <- dimnames(x)[[1]]
X        else {
X          # check data type
X          if (!is.vector(rowlab) || !is.character(rowlab)) {
X            cat("The 'rowlab' argument needs to be a character vector\n")
X            return()
X          }
X        }
X        if (length(rowlab) > 0) {
X            rowfile <- paste(dfile, ".row", sep="")
X            cat(rowlab, file = rowfile, sep="\n")
X        }
X
X        ### Variable groups ###
X        if (!missing(vgroups)) {
X            # check data type
X            if (!is.vector(vgroups) || !is.numeric(vgroups)) {
X              cat("The 'vgroups' argument needs to be a numeric vector\n")
X              return()
X            }
X
X            vgroupfile <- paste(dfile, ".vgroups", sep="")
X            cat(vgroups, file = vgroupfile, sep="\n")
X        }
X
X        ### Colors ###
X        if (!missing(colors)) {
X            # check data type
X            if (!is.vector(colors) || !is.character(colors)) {
X              cat("The 'colors' argument needs to be a character vector\n")
X              return()
X            }
X            colorfile <- paste(dfile, ".colors", sep="")
X            cat(colors, file = colorfile, sep="\n")
X        }
X        ### Glyphs ###
X        if (!missing(glyphs))
X        {
X            # check data type
X            if (!is.vector(glyphs) || !is.numeric(glyphs)) {
X              cat("The 'glyphs' argument needs to be a numeric vector\n")
X              return()
X            }
X            glyphfile <- paste(dfile, ".glyphs", sep="")
X            cat(glyphs, file = glyphfile, sep="\n")
X        }
X        ### Erase ###
X        if (!missing(erase))
X        {
X            # check data type
X            if (!is.vector(erase) || !is.numeric(erase)) {
X              cat("The 'erase' argument needs to be a numeric vector\n")
X              return()
X            }
X            erasefile <- paste(dfile, ".erase", sep="")
X            cat(erase, file = erasefile, sep="\n")
X        }
X
X        ### Connected lines ###
X        if (!missing(lines))
X        {
X            # check data type
X            if (!is.matrix(lines) || !is.numeric(lines) || dim(lines)[2] != 2) {                cat("The 'lines' argument must be a numeric 2-column matrix\n")
X                return()
X            }
X
X            linesfile <- paste(dfile, ".lines", sep="")
X            unix(paste("rm -f", linesfile), output=F)
X            if (nrow(lines) > 0) {
X                for (i in 1:nrow(lines))
X                    cat(lines[i,], "\n", file = linesfile, append=T)
X            }
X            ### Line colors ###
X            if (!missing(linecolors)) {
X                # check data type
X                if (!is.vector(linecolors) || !is.character(linecolors)) {
X                   cat("The 'linecolors' argument must be a character vector\n")
X                   return()
X                }
X                linecolorfile <- paste(dfile, ".linecolors", sep="")
X                cat(linecolors, file = linecolorfile, sep="\n")
X            }
X        }
X        ### Resources ###
X        if (!missing(resources))
X        {
X            # check data type
X            if (!is.vector(resources) || !is.character(resources)) {
X                cat("The 'resources' argument must be a character vector\n")
X                return()
X            }
X            resourcefile <- paste(dfile, ".resources", sep="")
X            cat(resources, file = resourcefile, sep	="\n")
X        }
X        ### nlinkable ###
X        if (!missing(nlinkable)) {
X            # check data type
X            nlinkable <- as.integer(nlinkable)
X            if (length(nlinkable) > 1) {
X                cat("The 'nlinkable' argument must be a scalar integer\n")
X                return()
X            }
X            linkablefile <- paste(dfile, ".nlinkable", sep="")
X            cat(nlinkable, "\n", file = linkablefile)
X        }
X        ### subset ###
X        subsetarg <- ""
X        if (!missing(subset)) {
X            # check data type
X            subset <- as.integer(subset)
X            if (length(subset) > 1) {
X                cat("The 'subset' argument must be a scalar integer\n")
X                return()
X            }
X            else if (subset == 0 || subset > nrow(x)) {
X                cat("The 'subset' argument must be >0 and <= nrows\n")
X                return()
X            }
X            subsetarg <- paste(" -subset ", subset, sep="")
X            args <- paste(args, subsetarg, sep=" ")
X        }
X
X        if (!missing(display)) {
X            if (!is.character(display))
X                warning("display must be a character string")
X            else
X                args <- paste("-display", display, args)
X        }
X
X        if (!missing(title)) {
X            if (!is.character(title)) {
X                warning("title must be a character string")
X                title <- deparse(substitute(matrx))
X            }
X        }
X        else
X            title <- deparse(substitute(matrx))
X        args <- paste("-title", paste("'", title, "'", sep=""), args)
X
X
# Note to installer:
# Here you will need to specify the path to the xgobi executable
# on your system.
X        path <- paste("/usr/local/bin/")
X
X        command <- paste(path, "xgobi", sep="")
X        command <- paste(command, args)
X        command <- paste(command, dfile, "&")
X        cat(command, "\n")
X
X        invisible(unix(command,output.to.S=F))
X    }
X    else
X      cat("Matrix argument required\n")
}
SHAR_EOF
  chmod 0600 'xgobi/S/xgobi.S' ||
  $echo 'restore of' 'xgobi/S/xgobi.S' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/S/xgobi.S:' 'MD5 check failed'
36c46102fa8273df028754f7cd6e062d  xgobi/S/xgobi.S
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/S/xgobi.S'`"
    test 6881 -eq "$shar_count" ||
    $echo 'xgobi/S/xgobi.S:' 'original size' '6881,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/ps/xgobi.head.ps ==============
if test ! -d 'xgobi/ps'; then
  $echo 'x -' 'creating directory' 'xgobi/ps'
  mkdir 'xgobi/ps'
fi
if test -f 'xgobi/ps/xgobi.head.ps' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/ps/xgobi.head.ps' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/ps/xgobi.head.ps' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/ps/xgobi.head.ps' &&
% Start of postscript setup
% $Header: /home/anoncvs/src/xgobi/ps/xgobi.head.ps,v 1.1.1.1 2000/01/03 18:14:30 root Exp $
X
/Helvetica findfont pointsize scalefont setfont
/ticksize pointsize 2 div def
/gobiinit {  % fg.r fg.g fg.b bg.r bg.g bg.b xmin ymin xmax ymax -> init state
X	/ymax exch def /xmax exch def
X	/ymin exch def /xmin exch def
X	/blue exch def /green exch def /red exch def
X	/fblue exch def /fgreen exch def /fred exch def
X	newpath
X	xmin ymin moveto
X	xmin ymax lineto
X	xmax ymax lineto
X	xmax ymin lineto
X	closepath
X	clip
X	% fill background
X	red green blue setrgbcolor clippath fill
X	fred fgreen fblue setrgbcolor
X	newpath clippath stroke
} def
X
% use a dictionary so we can index into an array of functions
% addglyph
%/gobobdict 7 dict def
/gobobdict 8 dict def
X
/plus {	% size -> plus on page in that size at current point
X	save
X	exch
X	/size exch def
X	/incr size 2 div def
X	save
X	0 incr rmoveto
X	0 0 size sub  rlineto
X	stroke
X	restore
X	0 incr sub 0 rmoveto
X	size 0 rlineto
X	stroke
X	restore
} def
gobobdict 1 /plus cvx put
X
/xglyph { 	% size -> x drawn at current point
X	save
X	exch
X	/size exch def
X	/incr size 2 div def
X	save
X	incr incr rmoveto
X	0 size sub dup rlineto
X	stroke
X	restore
X	0 incr sub incr rmoveto
X	size 0 size sub rlineto
X	stroke
X	restore
} def
gobobdict 2 /xglyph cvx put
X
% addglyph
/opensquare	% size -> opensquare at current point
{
X	save
X	exch
X	/size exch def
X 	/incr size 2 div def
X 	incr incr rmoveto
X 	0 size sub 0 rlineto
X 	0 0 size sub rlineto
X 	size 0 rlineto
X	closepath
X	stroke
X	restore
} def
gobobdict 3 /opensquare cvx put
X
% addglyph
/filledsquare	% size -> filledsquare at current point
{
X	save
X	exch
X	/size exch def
X 	/incr size 2 div def
X 	incr incr rmoveto
X 	0 size sub 0 rlineto
X 	0 0 size sub rlineto
X 	size 0 rlineto
X    fill  % will this do it?  dfs
X	closepath
X	stroke
X	restore
} def
gobobdict 4 /filledsquare cvx put
X
/opencircle { % size -> circle on page in that size at current point
X	save
X	exch
X	/dotsize exch def
X	currentpoint /myy exch def /myx exch def
X	% put out a point at currentpoint
X	newpath myx myy dotsize 2 div 0 360  arc closepath stroke
X	restore
} def
% addglyph
gobobdict 5 /opencircle cvx put
X
/filledcircle { % size -> circle on page in that size at current point
X	save
X	exch
X	/dotsize exch def
X	currentpoint /myy exch def /myx exch def
X	% put out a point at currentpoint
X	newpath myx myy dotsize 2 div 0 360 arc fill closepath stroke
X	restore
} def
% addglyph
gobobdict 6 /filledcircle cvx put
X
/point { % size -> dot on page in that size at current point
% Realize a point as a 1x1 filled rectangle.
%	save
%	exch
%	/dotsize exch def
%	currentpoint /myy exch def /myx exch def
%	put out a point at currentpoint
%	newpath myx myy dotsize 360 0  arc closepath fill
%	restore
X	save
X	exch
X	/size exch def
X 	/incr size 2 div def
X 	incr incr rmoveto
X 	0 size sub 0 rlineto
X 	0 0 size sub rlineto
X 	size 0 rlineto
X	closepath
X    fill
X	stroke
X	restore
} def
% addglyph
gobobdict 7 /point cvx put
X
% r g b type size x y pg -> print it
/pg { 
X	save
X	8 1 roll	% put save obj at bottom of our args
X	/y exch def /x exch def /size exch def /type exch def
X    /myblue exch def /mygreen exch def /myred exch def
X	% got args, now do something
X	
X	myred mygreen myblue setrgbcolor
X	x y moveto 
X	size
X	gobobdict type get
X	exec
X	restore
X
} def
X
% ln: red green blue width x1 y1 x2 y2
/ln {
X    save
X    9 1 roll    % put save obj at bottom of our args
X    /y2 exch def /x2 exch def /y1 exch def /x1 exch def
X    /width exch def
X    /myblue exch def /mygreen exch def /myred exch def
X    myred mygreen myblue setrgbcolor
X    newpath
X    x1 y1 moveto
X    x2 y2 lineto
X    width setlinewidth
X    stroke
X    restore
} def
X
/lndashed {
X    [2] 1 setdash
X	save
X	8 1 roll	% put save obj at bottom of our args
X	/y2 exch def /x2 exch def /y1 exch def /x1 exch def
X    /myblue exch def /mygreen exch def /myred exch def
X	myred mygreen myblue setrgbcolor
X	newpath
X	x1 y1 moveto
X	x2 y2 lineto
X	stroke
X	restore
X    [] 0 setdash
} def
X
/arbax { % arbitrary axis; label r g b x1 y1 x2 y2
X	save
X	9 1 roll	% put save obj at bottom of our args
X	/y2 exch def /x2 exch def /y1 exch def /x1 exch def
X    /myblue exch def /mygreen exch def /myred exch def
X	/label exch def
X	myred mygreen myblue setrgbcolor
X	newpath
X	x1 y1 moveto
X	x2 y2 lineto
X	stroke
X	x2 y2 moveto
X	pointsize 2 div dup rmoveto
X	label show
X	restore
} def
X
/yax { % yax: (label) red green blue x1 y1 x2 y2
X	save
X	9 1 roll	% put save obj at bottom of our args
X    /y2 exch def /x2 exch def /y1 exch def /x1 exch def
X    /myblue exch def /mygreen exch def /myred exch def
X    /label exch def
X	myred mygreen myblue setrgbcolor
X	newpath
X	x1 y1 moveto
X	x2 y2 lineto
X	stroke
% axis label
X	newpath
X	x1 y1 moveto
X	/diff y2 y1 sub def
X	0 diff 2 div rmoveto
X	label stringwidth	% wx wy on stack
X	pop
X	2 div neg
X	0 exch rmoveto
X	save
X	90 rotate
X	0 pointsize 3.0 mul rmoveto
X	label show
X	restore
X	restore
} def
X
/xax { % xax: (label) red green blue x1 y1 x2 y2
X	save
X	9 1 roll	% put save obj at bottom of our args
X    /y2 exch def /x2 exch def /y1 exch def /x1 exch def
X    /myblue exch def /mygreen exch def /myred exch def
X    /label exch def
X	myred mygreen myblue setrgbcolor
X	newpath
X	x1 y1 moveto
X	x2 y2 lineto
X	stroke
% axis label
X	newpath
X	x1 y1 moveto
X	/diff x2 x1 sub def
X	diff 2 div 0 rmoveto
X	label stringwidth	% wx wy on stack
X	pop
X	2 div 
X	neg 0 rmoveto
X	0 pointsize -3.3 mul rmoveto
X	label show
X	restore
} def
X
/ytx { % ytx: (label) red green blue x y
X	save
X	7 1 roll	% put save  obj at bottom of our args
X    /y exch def /x exch def
X    /myblue exch def /mygreen exch def /myred exch def
X    /label exch def
X	myred mygreen myblue setrgbcolor
X	newpath
X	x y moveto
X	ticksize neg 0 rlineto stroke
X	x y moveto
X	save
X	label stringwidth	% wx wy on stack
X	pop
X	2 div
X	90 rotate
X	%neg pointsize 1.5 mul rmoveto
X	neg pointsize 1.2 mul rmoveto
X	label show
X	restore
X	restore
} def
X
/xtx { % xtx: (label) red green blue x y
X	save
X	7 1 roll
X    /y exch def /x exch def
X    /myblue exch def /mygreen exch def /myred exch def
X    /label exch def
X	myred mygreen myblue setrgbcolor
X	newpath
X	x y moveto
X	0 ticksize neg rlineto stroke
X	x y moveto
X	label stringwidth	% wx wy on stack
X	pop
X	2 div
X	%neg pointsize neg 2 mul rmoveto
X	neg pointsize neg 1.6 mul rmoveto
X	label show
X	restore
} def
X
/sticky { % sticky: (string) red green blue x y
X	save
X	7 1 roll	% put save obj at bottom of our args
X    /y exch def /x exch def
X    /myblue exch def /mygreen exch def /myred exch def
X    /label exch def
X	myred mygreen myblue setrgbcolor
X	x y moveto
X	pointsize 4 div dup rlineto stroke
X	x y moveto
X	pointsize 4 div dup rmoveto
X	label show
X	restore
} def
X
% Routine for drawing the bitmaps
% r g b size x y bitmap -> print it
/bitmap {
X    save
X    7 1 roll    % put save obj at bottom of our args
X    /y exch def /x exch def /size exch def
X    /myblue exch def /mygreen exch def /myred exch def
X
X    myred mygreen myblue setrgbcolor
X    x y moveto
X 	0 0 size sub rlineto
X 	0 size sub 0 rlineto
X 	0 size rlineto
X	closepath
X	stroke
X	restore
} def
X
% Routine for drawing the arcs on the projection pursuit window
% r g b radius ang1 ang2 x y pparc -> print it
/pparc {
X    save
X    9 1 roll    % put save obj at bottom of our args
X    /y exch def /x exch def
X    /ang2 exch def /ang1 exch def
X    /radius exch def
X    /myblue exch def /mygreen exch def /myred exch def
X
X    myred mygreen myblue setrgbcolor
X    x y moveto
X    x y radius ang1 ang2 arc
X	closepath
X	fill
X    stroke
X	restore
} def
X
% Routine for drawing y axis and label for projection pursuit plot
% ppyax: (label) red green blue x1 y1 x2 y2
/ppyax {
X    save
X    9 1 roll    % put save obj at bottom of our args
X    /y2 exch def /x2 exch def /y1 exch def /x1 exch def
X    /myblue exch def /mygreen exch def /myred exch def
X    /label exch def
X    myred mygreen myblue setrgbcolor
X    newpath
X    x1 y1 moveto
X    x2 y2 lineto
X    stroke
% axis label
X    newpath
X    x1 y1 moveto
X    /diff y2 y1 sub def
X    0 diff 2 div rmoveto
X    label stringwidth   % wx wy on stack
X    pop
X    2 div neg
X    0 exch rmoveto
X    save
X    90 rotate
X    0 pointsize 3.0 mul rmoveto
X    label show
X    restore
X    restore
} def
X
% Routine for drawing y-axis tick marks and labels on pp plot
% ppytx: (label) red green blue x y
/ppytx {
X    save
X    7 1 roll    % put save  obj at bottom of our args
X    /y exch def /x exch def
X    /myblue exch def /mygreen exch def /myred exch def
X    /label exch def
X    myred mygreen myblue setrgbcolor
X    newpath
X    x y moveto
X    ticksize neg 0 rlineto stroke
X    x y moveto
X    save
X    label stringwidth   % wx wy on stack
X    pop
X    2 div
X    90 rotate
X    %neg pointsize 1.5 mul rmoveto
X    neg pointsize 1.2 mul rmoveto
X    label show
X    restore
X    restore
} def
SHAR_EOF
  chmod 0644 'xgobi/ps/xgobi.head.ps' ||
  $echo 'restore of' 'xgobi/ps/xgobi.head.ps' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/ps/xgobi.head.ps:' 'MD5 check failed'
5b64c8eb439bcd6dcf50bc71519063e7  xgobi/ps/xgobi.head.ps
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/ps/xgobi.head.ps'`"
    test 8728 -eq "$shar_count" ||
    $echo 'xgobi/ps/xgobi.head.ps:' 'original size' '8728,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/XGobiServer.h ==============
if test ! -d 'xgobi/src'; then
  $echo 'x -' 'creating directory' 'xgobi/src'
  mkdir 'xgobi/src'
fi
if test -f 'xgobi/src/XGobiServer.h' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/XGobiServer.h' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/XGobiServer.h' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/XGobiServer.h' &&
#ifndef _XGOBISERVER_H_
#define _XGOBISERVER_H_
X
#include <stdio.h>
X
#include "RSCorba.h"
#include "Sequences.h"
//#include "Matrix.h"      // from IDLTypes
#include "BaseMatrixImpl.h"      // from IDLTypes
X
X
#include "XGobiCorbaServer_skel.h"
#include "xgobitypes.h"
#include "xgobivars.h"
X
#include "Sequences.h"
#include <stdlib.h>
extern "C" {
extern int read_data_from_file(char *filename, xgobidata *xg);
extern void update_world(xgobidata *);
extern void alloc_block(int, xgobidata *);
extern void realloc_lines(xgobidata *);
extern int glyphIDfromName(char *);
extern void refreshXGobiDisplay(xgobidata *xg);
extern void plot_once(xgobidata *);
X
extern void refresh_vbox(xgobidata *, int, int);
extern void refresh_vlab(xgobidata *, int);
X
extern char **GetPlotViewTypes(int *num);
extern int SetPlotModeName(const char *name, xgobidata *xg) ;
X
extern void update_cprof_selectedvars(xgobidata *);
extern void update_cprof_plot(xgobidata *);
extern void reset_nvars_cprof_plot(xgobidata *);
extern int varno_from_name(xgobidata *, char *);
extern Boolean selectVariable(xgobidata *, int, int, int);
extern int glyphNames(char **);
X
void initializeNewData(xgobidata *xg, char *name, int ncols_prev, int ncols_used_prev, int readFiles);
void reinit_1 (xgobidata *xg, int ncols_prev, int ncols_used_prev);
}
X
X
class XGobiServer : public XGobi_XGobi_skel {
X protected:
X   xgobidata *xgobi;
X
X public:
X   XGobiServer() {};  // basic constructor.
X   XGobiServer(xgobidata *data) : xgobi(data) { };  
X
X   XGobi_XGobi* replicate(CORBABoolean linked, const char *name) {
X     extern void Clone_XGobi ();
X     //       Clone_XGobi();
X     return(this); // This is not correct. Wait till we change the cloning.
X     // and get back a reference to it as a CORBA object.
X  }
X
X  char * fileName() {
X    return(CORBA_string_dup(xgobi->datafilename));
X  }
X
X  void fileName(const char *fileName) {
X    // load up a new file.
X    // see the callback for 
X    read_data_from_file((char *)fileName, xgobi);
X  }
X
X
X  // See new_data.c
X  void setData(Omegahat_BaseMatrix *m, const Sequences_StringSequence &names) {
X
X    long numVars = names.length();
X    Sequences_DoubleSequence *mdata = m->allData(true);
X
X    long c = m->ncol();
X
X    if(numVars != c) {
X      // Throw an error.
X      return;
X    }
X    long r = m->nrow();
X
X    int old_ncols = xgobi->ncols;
X    int old_ncols_used = xgobi->ncols_used;
//  int old_nrows = xgobi->nrows;
X
X    reinit_1(xgobi, old_ncols, old_ncols_used);
X    
X    xgobi->ncols = xgobi->ncols_used = c;
X    xgobi->nrows = r;
X
X    // realloc dataArea
X    alloc_block(1, xgobi);
X    float ** dataArea = xgobi->raw_data; 
X    int i;
X    for(i = 0; i <  r; i++) {
X      for(int j = 0; j < c ; j++) {
X        dataArea[i][j] = (float) (*mdata)[i*c + j];
X      }
X    } 
X
// See end of  reinit_1(xgobi, xgobi-);
X    xgobi->collab = (char **) malloc(numVars*sizeof(char*));
X    for(int k = 0; k < numVars; k++) {
X      /*xgobi->collab[k] = strdup(names[k]);*/
X      strncpy(xgobi->collab[k], names[k], COLLABLEN);
X      xgobi->collab[k][COLLABLEN-1] = '\0';
X    }
X      
X    /* Allocate and create default row labels */
X    xgobi->rowlab = (char **)
X      XtMalloc((Cardinal) xgobi->nrows * sizeof (char *));
X    for (i=0; i<xgobi->nrows; i++) {
X      xgobi->rowlab[i] = (char *) XtMalloc((Cardinal) ROWLABLEN * sizeof(char));
X      (void) sprintf(xgobi->rowlab[i], "%d", i+1);
X    }
X
X    xgobi->vgroup_ids = (int *) XtMalloc((Cardinal) xgobi->ncols * sizeof(int));
X    int j;
X    for (j=0; j<xgobi->ncols; j++)
X      xgobi->vgroup_ids[j] = 0;
X
X    xgobi->collab = (char **)
X      XtMalloc((Cardinal) xgobi->ncols * sizeof(char *));
X    xgobi->collab_tform1 = (char **)
X      XtMalloc((Cardinal) xgobi->ncols * sizeof(char *));
X    xgobi->collab_tform2 = (char **)
X      XtMalloc((Cardinal) xgobi->ncols * sizeof(char *));
X
X    for (j=0; j<xgobi->ncols-1; j++) {
X      strncpy(xgobi->collab[j], names[j], COLLABLEN);
X      xgobi->collab[j][COLLABLEN-1] = '\0';
X
X      strncpy(xgobi->collab_tform1[j], names[j], COLLABLEN+16);
X      xgobi->collab[j][COLLABLEN+16-1] = '\0';
X
X      strncpy(xgobi->collab_tform2[j], names[j], COLLABLEN+2*16);
X      xgobi->collab[j][COLLABLEN+2*16-1] = '\0';
X
X      /*xgobi->collab_tform2[j] = strdup( xgobi->collab[j]);*/
X    }
X
X    // don't read the files
X    initializeNewData(xgobi, "CORBA Data", old_ncols, old_ncols_used, 0);
X  }
X
X
X  Omegahat_BaseMatrix *getData() {
X    Omegahat_BaseMatrix *m;
X    long nrow = xgobi->nrows;
X    long ncol = xgobi->ncols_used;
X    long n =  nrow * ncol;
X    double *vals = (double*) malloc(sizeof(double)*n);
X
X    for(int j = 0; j < ncol; j++) {
X      for(int i = 0; i < nrow; i++) {
X        vals[j*nrow + i] = xgobi->raw_data[i][j];
X       }
X     }
X
X     m = new BaseMatrixImpl((CORBALong)nrow, (CORBALong)ncol, vals);
X     return(m);
X  }
X
X  long addVariable(const Sequences_DoubleSequence &data, const char *name) {
X    return(-1);
X  }
X
X  long
X  addVariables(Omegahat_BaseMatrix *data,
X    const Sequences_StringSequence &names)
X  {
X    return(-1);
X  }
X
X  void setVariableName(long int which, const char *name) {
X    char *oname, strtmp1[COLLABLEN+16], strtmp2[COLLABLEN+2*16];
X    char newname[COLLABLEN];
X    int i, j;
X
X    if(which < 0 || which >= xgobi->ncols_used) {
X      // should throw an exception.
X      return;
X    }
X    oname = XtMalloc(COLLABLEN * sizeof(char));
X    oname = xgobi->collab[which];
X
X    sprintf(newname, "%s", name);
X    if (strlen(name) >= COLLABLEN) newname[COLLABLEN-1] = '\0';
X
X    strcpy(xgobi->collab[which], newname);
X    XtVaSetValues(xgobi->varlabw[which],
X      XtNlabel, xgobi->collab_tform2[which],
X      NULL);
X
X    // And what about collab_tform1 and collab_tform2?
X    // replace oname by xgobi->collab[which] in those strings.
X
X    for (i=0, j=0; i<strlen(xgobi->collab_tform1[which]); i++, j++) {
X      if (strncmp(xgobi->collab_tform1[which], oname, strlen(oname)) == 0) {
X        strcat(strtmp1, oname);
X        i += strlen(oname);
X      } else {
X        strtmp1[i] = oname[j];
X      }
X      if (i >= COLLABLEN+16) {
X        i = COLLABLEN+16;
X        break;
X      }
X    }
X    strtmp1[i] = '\0';
X    xgobi->collab_tform1[which] = strtmp1;
X
X    for (i=0, j=0; i<strlen(xgobi->collab_tform2[which]); i++, j++) {
X      if (strncmp(xgobi->collab_tform2[which], oname, strlen(oname)) == 0) {
X        strcat(strtmp2, oname);
X        i += strlen(oname);
X      } else {
X        strtmp2[i] = oname[j];
X      }
X      if (i >= COLLABLEN+2*16) {
X        i = COLLABLEN+2*16;
X        break;
X      }
X    }
X    strtmp2[i] = '\0';
X    xgobi->collab_tform2[which] = strtmp1;
X
X    // Update the plot in case labels are displayed
X    plot_once(xgobi);
X  }
X
X  void setRowNames(const Sequences_StringSequence &names) {
X    int i, nnames = names.length();
X    nnames = nnames < xgobi->nrows ? nnames : xgobi->nrows;
X    for (i=0; i<nnames; i++) {
X      strncpy(xgobi->rowlab[i], names[i], ROWLABLEN);
X      xgobi->rowlab[i][ROWLABLEN-1] = '\0';
X    }
X  }
X
X  void setRowName(long int which, const char *name) {
X
X    if(which < 0 || which >= xgobi->nrows) {
X      // should throw an exception.
X      return;
X    }
X
X    strncpy(xgobi->rowlab[which], name, ROWLABLEN);
X    xgobi->rowlab[which][ROWLABLEN-1] = '\0';
X  }
X
X  /* Get the name of the current view. */
X  char * getView() {
X    char *tmp = "<Unknown>";
X    int num = -1;
X    char **names =  GetPlotViewTypes(&num);
X
X    for(int i = 0; i < num; i++) {
X      /* Match by simple index. */
X      if(xgobi->plot_mode == i) {
X        tmp = names[i] + strlen("View: "); 
X        break;
X      }
X    }
X    return(CORBA_string_dup(tmp));
X  }
X
X
X  /* Set the view to the specified on. */
X  CORBABoolean setView(const char *viewName) {
X    CORBABoolean ans =  (SetPlotModeName(viewName, xgobi) > -1);
X    return(ans);
X  }
X
X  /* return the list of potential views. */
X  Sequences_StringSequence *getViewTypes() {
X    int num = -1;
X    char **names = GetPlotViewTypes(&num);
X
X    char *tmp;
X    Sequences_StringSequence *seq = new Sequences_StringSequence();
X    seq->length(num);
X
X    for(int i = 0; i < num ; i++) {
X       // 
X      tmp = names[i] + strlen("View: ");
X      (*seq)[i] = CORBA_string_dup(tmp);
X    }
X    return(seq);
X  }
X
X  void disconnectObservations(Omegahat_Matrix_ptr pairs) {
X  }
X
X  void disconnectAllObservations() {
X  }
X
X  /* Add the specified pairs - rowwise - as connected by lines.
X     I.e. this augments the existing connected pairs with the new ones.
X  */
X  void connectObservations(Omegahat_Matrix_ptr pairs) {
X    if(pairs->ncol() != 2) {
X      // throw an exception.
X      return;
X    }
X   
X    long nrow = pairs->nrow();
X    Sequences_DoubleSequence *data = pairs->allData(true);
X
X    int offset = xgobi->nlines;
X    xgobi->nlines += nrow;
X    realloc_lines(xgobi);
X
X    for(int i = 0; i < 2*nrow; i+=2, offset++) {
X      xgobi->connecting_lines[offset].a = (int) (*data)[i];
X      xgobi->connecting_lines[offset].b = (int) (*data)[i+1];
X    }
X  }
X
X  Omegahat_BaseMatrix_ptr getConnectedObservations() {
X    BaseMatrixImpl *m;
X
X    double *data = (double*)malloc(2*xgobi->nlines*sizeof(double));
X    for(int k=0; k < xgobi->nlines; k++) {
X      data[2*k] = xgobi->connecting_lines[k].a;
X      data[2*k+1] = xgobi->connecting_lines[k].b;
X    }
X
X    m = new BaseMatrixImpl(xgobi->nlines, 2, data);
X
X    return(m);
X  }
X
/*
X  CORBABoolean connectObservations(long int i, long int j) {
X    int n = xgobi->nlines;
X    xgobi->nlines += 1;
X    realloc_lines(xgobi);
X
X    xgobi->connecting_lines[n].a = i+1;
X    xgobi->connecting_lines[n].b = j+1;
X
X    return(true);
X  }
*/
X
X  CORBABoolean setObservationColor(const char *colName, long int which) {
X    if(which < 0 || which > xgobi->nrows ||
X      colName == (char*)NULL || colName[0] == (char)NULL)
X    {
X      return(false);
X    }
X
X    CORBABoolean ans = false;
X    for(int i = 0; i < ncolors; i++) {
X      if(strcmp(color_names[i], colName) == 0) {
X        xgobi->color_ids[which] = xgobi->color_now[which] = color_nums[i];
X        ans = true;
X        break;
X      }
X    }
X
X    if(ans)
X     plot_once(xgobi);
X
X    return(ans);
X  }
X
X  CORBABoolean setObservationColors(const char *colName,
X    const Sequences_LongSequence &rows)
X  {
X    int i;
X    CORBABoolean ans = false;
X    long color = -1;
X    for(int k = 0; k < ncolors; k++) {
X      if(strcmp(color_names[k], colName) == 0) {
X        color = color_nums[k];
X        ans = true;
X        break;
X      }
X    }
X
X    if (ans) {
X      for (int k=0; k<rows.length(); k++) {
X        i = rows[k] - 1;
X        if (i >= 0 && i < xgobi->nrows)
X          xgobi->color_ids[i] = xgobi->color_now[i] = color;
X      }
X
X      plot_once(xgobi);
X    }
X
X    return(ans);
X  }
X
X  CORBABoolean setObservationSymbol(const char *glyphName, long int glyphSize,
X    long int which)
X  {
X    if (glyphSize < 1 || glyphSize > 5 || which < 0 || which >= xgobi->nrows) {
X      return(false);
X    }
X
X    CORBABoolean ans = true;
X    int id = glyphIDfromName((char *) glyphName);
X    ans = (id > 0);
X
X    if(ans) {
X      xgobi->glyph_ids[which].type = xgobi->glyph_now[which].type = id;
X      xgobi->glyph_ids[which].size = xgobi->glyph_now[which].size = glyphSize;
X      plot_once(xgobi);
X    }
X
X    return(ans);
X  }
X
X  CORBABoolean setObservationSymbols(const char *glyphName, long int glyphSize,
X    const Sequences_LongSequence &rows)
X  {
X    if (glyphSize < 1 || glyphSize > 5) {
X      return(false);
X    }
X
X    CORBABoolean ans = true;
X    int i;
X    int id = glyphIDfromName((char *) glyphName);
X    ans = (id > 0);
X
X    if(ans) {
X      for (int k=0; k<rows.length(); k++) {
X        i = rows[k] - 1;
X        if (i >= 0 && i < xgobi->nrows) {
X          xgobi->glyph_ids[i].type = xgobi->glyph_now[i].type = id;
X          xgobi->glyph_ids[i].size = xgobi->glyph_now[i].size = glyphSize;
X        }
X      }
X      plot_once(xgobi);
X    }
X
X    return(ans);
X  }
X
/* I don't actually know what would be useful to return -- probably
X * maybe the strings that I test for -- filledcircle, opencircle, etc
*/
X  Sequences_StringSequence *getSymbolNames() {
X    char* names[32];
X    int i, n = glyphNames(names);
X    Sequences_StringSequence *seq = new Sequences_StringSequence();
X    seq->length(n);
X
X    for (i=0; i<n; i++)
X      (*seq)[i] = CORBA_string_dup(names[i]);
X
X    return(seq);
X  }
X
X  long int setX(const char *name, CORBABoolean append) {
X    int varno = varno_from_name(xgobi, (char *) name);
X    if (varno != -1) {
X      selectVariable(xgobi, varno, 1, 0);  /* button 1 */
X    }
X
X    return(varno);
X  }    
X
X  long int setY(const char *name, CORBABoolean append) {
X    int varno = varno_from_name(xgobi, (char *) name);
X    if (varno != -1) {
X      selectVariable(xgobi, varno, 2, 0);  /* button 2 */
X    }
X
X    return(varno);
X  }    
X
X
X  /*
X   * Set the selected state for a variable -- used to manipulate
X   * the parallel coordinates plot
X  */
X  CORBABoolean setSelected(const char *name, CORBABoolean select) {
X
X    int varno = varno_from_name(xgobi, (char *) name);
X    CORBABoolean ans = (varno != -1);
X
X    if (ans && xgobi->is_cprof_plotting) {
X      xgobi->selectedvars[varno] = (Boolean) select;
X      if (xgobi->is_cprof_plotting) {
X        update_cprof_selectedvars(xgobi);
X        reset_nvars_cprof_plot(xgobi);
X      }
X    }
X
X    return(ans);
X  }
X
X  /* Returns a list of the selected variables.     
X     There are as many elements in the returned sequence
X     as thre are selected variables. (i.e. not the total number
X     of variables with an indicator of whether it is selected.)
X   */
X  Sequences_StringSequence *getSelectedVariables() {
X
X    Sequences_StringSequence  *seq = new Sequences_StringSequence();
X
X    int num = 0, i;
X    for(i = 0; i < xgobi->ncols_used; i++) {
X      if(xgobi->varchosen[i])
X      num++;
X    } 
X    seq->length(num);
X
X    num = 0;
X    for(i = 0; i < xgobi->ncols_used; i++) {
X      if (xgobi->varchosen[i]) {
X        (*seq)[num++] = CORBA_string_dup(xgobi->collab[i]);
X      }
X    } 
X    return(seq);
X  }
X
X  /* Returns whether the identified variable is selected in the
X     variable panel or not.
X   */
X  CORBABoolean isSelected(const char *varName) {
X
X    int varno = varno_from_name(xgobi, (char *) varName);
X    CORBABoolean ans = (varno != -1);
X
X    return(ans);
X  }
X
X  Sequences_StringSequence* getVariableNames() {
X    Sequences_StringSequence *seq;
X    seq = new Sequences_StringSequence();
X    seq->length(xgobi->ncols);
X    for(int i = 0; i < xgobi->ncols ; i++) {
X      (*seq)[i] = CORBA_string_dup(xgobi->collab[i]);
X    }
X    return(seq);
X  }
X
X  Sequences_StringSequence* getRowNames() {
X
X     Sequences_StringSequence *seq;
X     seq = new Sequences_StringSequence();
X     seq->length(xgobi->nrows);
X     for(int i = 0; i < xgobi->nrows ; i++) {
X       (*seq)[i] = CORBA_string_dup(xgobi->rowlab[i]);
X     }
X     return(seq);
X  }
X
X  Sequences_StringSequence* getRowColors() {
X    Sequences_StringSequence *seq = new Sequences_StringSequence();
X    seq->length(xgobi->nrows);
X    for (int i=0; i<xgobi->nrows; i++) {
X      for (int k=0; k<ncolors; k++) {
X        if(color_nums[k] == xgobi->color_now[i]) {
X          (*seq)[i] = CORBA_string_dup(color_names[k]);
X          break;
X        }
X      }
X    }
X
X    return(seq);
X  }
X
X  Sequences_StringSequence* getColorNames() {
X    Sequences_StringSequence *seq = new Sequences_StringSequence();
X    seq->length(ncolors);
X    for (int k=0; k<ncolors; k++) {
X      (*seq)[k] = CORBA_string_dup(color_names[k]);
X
X    }
X    return(seq);
X  }
X
X
X  void setSelectedIndices(const Sequences_LongSequence &rows) {
X  }
X
X  Sequences_LongSequence* getSelectedIndices() {
X    return(NULL);
X  }
X
X  void setRotation(Omegahat_BaseMatrix_ptr rotation) {
X    for(int j =0; j < 3; j++) {
X      for(int i =0; i < 3; i++) {
X        xgobi->Rmat0[i][j] = rotation->getElement(i,j);
X      }
X    }
X  }
X
X  Omegahat_BaseMatrix_ptr getRotation() {
X     BaseMatrixImpl *m;
X
X     double *data = (double*)malloc(9*sizeof(double));
X     for(int j =0; j < 3; j++) {
X       for(int i =0; i < 3; i++) {
X         data[j*3 + i] = xgobi->Rmat0[i][j];
X       }
X     }
X     m = new BaseMatrixImpl(3,3, data);
X
X     return(m);
X  }
X
X  Sequences_DoubleSequence* getCoefficients() {
X    return(NULL);
X  }
X
X  Sequences_DoubleSequence* getVariable(const char* name)
X  {
X    Sequences_DoubleSequence *seq = new Sequences_DoubleSequence();
X    seq->length(xgobi->nrows);
X
X    int varno = varno_from_name(xgobi, (char *) name);
X
X    if (varno != -1) {
X      for (int i = 0; i < xgobi->nrows; i++) {
X        (*seq)[i] = xgobi->raw_data[i][varno];
X      }
X    }
X
X    return(seq);
X  }
X
X  CORBA_Double getCurrentVariableValue(const char* name) {
X     return(-100.0);
X  }
X
X  Sequences_DoubleSequence* getCurrentValues() {
X     return(NULL);
X  }
X
/*
X    Sequences_StringSequence* getColorNames();
X    Sequences_StringSequence* getSelectedVariableNames();
X    CORBABoolean loadDataFrame(Omegahat_DataFrame_ptr df);
X    CORBABoolean loadMatrix(Omegahat_BaseMatrix_ptr df);
*/
};
X
#endif  // end of conditional inclusion of this file.
SHAR_EOF
  chmod 0644 'xgobi/src/XGobiServer.h' ||
  $echo 'restore of' 'xgobi/src/XGobiServer.h' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/XGobiServer.h:' 'MD5 check failed'
0ad3072f6c6172f10f5bbd02da0ff09d  xgobi/src/XGobiServer.h
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/XGobiServer.h'`"
    test 16929 -eq "$shar_count" ||
    $echo 'xgobi/src/XGobiServer.h:' 'original size' '16929,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/xgv_qsort.c ==============
if test -f 'xgobi/src/xgv_qsort.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/xgv_qsort.c' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/xgv_qsort.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/xgv_qsort.c' &&
typedef int (*CompareFunc)(const void *, const void *);
void Myqsort(void* bot, int nmemb, int size, CompareFunc compar);
X
/*
X * MTHRESH is the smallest partition for which we compare for a median
X * value instead of using the middle value.
X * THRESH is the minimum number of entries in a partition for continued
X * partitioning.
X */
const int MTHRESH = 6;
const int THRESH = 4;
X
X
static void quick_sort(char *bot, int nmemb, int size, CompareFunc compar);
static void insertion_sort(char *bot, int nmemb, int size, CompareFunc compar);
X
X
void Myqsort(void* bot, int nmemb, int size, CompareFunc compar)
{
X	if (nmemb <= 1) return;
X
X	if (nmemb >= THRESH) quick_sort((char*)bot, nmemb, size, compar);
X	else insertion_sort((char*)bot, nmemb, size, compar);
}
X
X
/*
X * Swap two areas of size number of bytes.  Although qsort(3) permits random
X * blocks of memory to be sorted, sorting pointers is almost certainly the
X * common case (and, were it not, could easily be made so).  Regardless, it
X * isn't worth optimizing; the SWAP's get sped up by the cache, and pointer
X * arithmetic gets lost in the time required for comparison function calls.
X */
#define	SWAP(a, b) { \
X	cnt = size; \
X	do { \
X		ch = *a; \
X		*a++ = *b; \
X		*b++ = ch; \
X	} while (--cnt); \
}
X
/*
X * Knuth, Vol. 3, page 116, Algorithm Q, step b, argues that a single pass
X * of straight insertion sort after partitioning is complete is better than
X * sorting each small partition as it is created.  This isn't correct in this
X * implementation because comparisons require at least one (and often two)
X * function calls and are likely to be the dominating expense of the sort.
X * Doing a final insertion sort does more comparisons than are necessary
X * because it compares the "edges" and medians of the partitions which are
X * known to be already sorted.
X *
X * This is also the reasoning behind selecting a small THRESH value (see
X * Knuth, page 122, equation 26), since the quicksort algorithm does less
X * comparisons than the insertion sort.
X */
#define	SORT(bot, n) { \
X	if (n > 1) \
X		if (n == 2) { \
X			t1 = bot + size; \
X			if (compar(t1, bot) < 0) \
X				SWAP(t1, bot); \
X		} else \
X			insertion_sort(bot, n, size, compar); \
}
X
static void quick_sort(char *bot, int nmemb, int size, CompareFunc compar)
{
X	register int cnt;
X	register unsigned char ch;
X	register char *top, *mid, *t1, *t2;
X	register int n1, n2;
X	char *bsv;
X
X	/* bot and nmemb must already be set. */
partition:
X
X	/* find mid and top elements */
X	mid = bot + size * (nmemb >> 1);
X	top = bot + (nmemb - 1) * size;
X
X	/*
X	 * Find the median of the first, last and middle element (see Knuth,
X	 * Vol. 3, page 123, Eq. 28).  This test order gets the equalities
X	 * right.
X	 */
X	if (nmemb >= MTHRESH) {
X		n1 = compar(bot, mid);
X		n2 = compar(mid, top);
X		if (n1 < 0 && n2 > 0)
X			t1 = compar(bot, top) < 0 ? top : bot;
X		else if (n1 > 0 && n2 < 0)
X			t1 = compar(bot, top) > 0 ? top : bot;
X		else
X			t1 = mid;
X
X		/* if mid element not selected, swap selection there */
X		if (t1 != mid) {
X			SWAP(t1, mid);
X			mid -= size;
X		}
X	}
X
X	/* Standard quicksort, Knuth, Vol. 3, page 116, Algorithm Q. */
#define	didswap	n1
#define	newbot	t1
#define	replace	t2
X	didswap = 0;
X	for (bsv = bot;;) {
X		for (; bot < mid && compar(bot, mid) <= 0; bot += size) ;
X		while (top > mid) {
X			if (compar(mid, top) <= 0) {
X				top -= size;
X				continue;
X			}
X			newbot = bot + size;	/* value of bot after swap */
X			if (bot == mid)		/* top <-> mid, mid == top */
X				replace = mid = top;
X			else {			/* bot <-> top */
X				replace = top;
X				top -= size;
X			}
X			goto swap;
X		}
X		if (bot == mid)
X			break;
X
X		/* bot <-> mid, mid == bot */
X		replace = mid;
X		newbot = mid = bot;		/* value of bot after swap */
X		top -= size;
X
swap:		SWAP(bot, replace);
X		bot = newbot;
X		didswap = 1;
X	}
X
X	/*
X	 * Quicksort behaves badly in the presence of data which is already
X	 * sorted (see Knuth, Vol. 3, page 119) going from O N lg N to O N^2.
X	 * To avoid this worst case behavior, if a re-partitioning occurs
X	 * without swapping any elements, it is not further partitioned and
X	 * is insert sorted.  This wins big with almost sorted data sets and
X	 * only loses if the data set is very strangely partitioned.  A fix
X	 * for those data sets would be to return prematurely if the insertion
X	 * sort routine is forced to make an excessive number of swaps, and
X	 * continue the partitioning.
X	 */
X	if (!didswap) {
X		insertion_sort(bsv, nmemb, size, compar);
X		return;
X	}
X
X	/*
X	 * Re-partition or sort as necessary.  Note that the mid element
X	 * itself is correctly positioned and can be ignored.
X	 */
#define	nlower	n1
#define	nupper	n2
X	bot = bsv;
X	nlower = (mid - bot) / size;	/* size of lower partition */
X	mid += size;
X	nupper = nmemb - nlower - 1;	/* size of upper partition */
X
X	/*
X	 * If must call recursively, do it on the smaller partition; this
X	 * bounds the stack to lg N entries.
X	 */
X	if (nlower > nupper) {
X		if (nupper >= THRESH)
X			quick_sort(mid, nupper, size, compar);
X		else {
X			SORT(mid, nupper);
X			if (nlower < THRESH) {
X				SORT(bot, nlower);
X				return;
X			}
X		}
X		nmemb = nlower;
X	} else {
X		if (nlower >= THRESH)
X			quick_sort(bot, nlower, size, compar);
X		else {
X			SORT(bot, nlower);
X			if (nupper < THRESH) {
X				SORT(mid, nupper);
X				return;
X			}
X		}
X		bot = mid;
X		nmemb = nupper;
X	}
X	goto partition;
X	/* NOTREACHED */
}
X
static void insertion_sort(char *bot, int nmemb, int size, CompareFunc compar)
{
X	register int cnt;
X	register unsigned char ch;
X	register char *s1, *s2, *t1, *t2, *top;
X
X	/*
X	 * A simple insertion sort (see Knuth, Vol. 3, page 81, Algorithm
X	 * S).  Insertion sort has the same worst case as most simple sorts
X	 * (O N^2).  It gets used here because it is (O N) in the case of
X	 * sorted data.
X	 */
X	top = bot + nmemb * size;
X	for (t1 = bot + size; t1 < top;) {
X		for (t2 = t1; (t2 -= size) >= bot && compar(t1, t2) < 0;) ;
X		if (t1 != (t2 += size)) {
X			/* Bubble bytes up through each element. */
X			for (cnt = size; cnt--; ++t1) {
X				ch = *t1;
X				for (s1 = s2 = t1; (s2 -= size) >= t2; s1 = s2)
X					*s1 = *s2;
X				*s1 = ch;
X			}
X		} else
X			t1 += size;
X	}
}
SHAR_EOF
  chmod 0644 'xgobi/src/xgv_qsort.c' ||
  $echo 'restore of' 'xgobi/src/xgv_qsort.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/xgv_qsort.c:' 'MD5 check failed'
b6b050342ee527644a59849778d0ee34  xgobi/src/xgv_qsort.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/xgv_qsort.c'`"
    test 6113 -eq "$shar_count" ||
    $echo 'xgobi/src/xgv_qsort.c:' 'original size' '6113,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/spin.c ==============
if test -f 'xgobi/src/spin.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/spin.c' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/spin.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/spin.c' &&
/* spin.c */
/************************************************************
X *                                                          *
X *  Permission is hereby granted  to  any  individual   or  *
X *  institution   for  use,  copying, or redistribution of  *
X *  the xgobi code and associated documentation,  provided  *
X *  that   such  code  and documentation are not sold  for  *
X *  profit and the  following copyright notice is retained  *
X *  in the code and documentation:                          *
X *        Copyright (c) 1990, ..., 1996 Bellcore            *
X *                                                          *
X *  We welcome your questions and comments, and request     *
X *  that you share any modifications with us.               *
X *                                                          *
X *    Deborah F. Swayne            Dianne Cook              *
X *   dfs@research.att.com       dicook@iastate.edu          *
X *      (973) 360-8423    www.public.iastate.edu/~dicook/   *
X *                                                          *
X *                    Andreas Buja                          *
X *                andreas@research.att.com                  *
X *              www.research.att.com/~andreas/              *
X *                                                          *
X ************************************************************/
X
#include <math.h>
#include <stdio.h>
#include "xincludes.h"
#include "xgobitypes.h"
#include "xgobivars.h"
#include "xgobiexterns.h"
X
/* Used in oblique rotation code */
static struct {float x, y, z;} ob_axis;
static float Rmat1[3][3], Rmat2[3][3];
long lRmat[3][3];
float *spin_coef;
X
static int spin_dir = 1, turn = -1, curdir = 1;
static icoords qd;
X
/* --------- Dynamic allocation section ----------- */
X
void
alloc_rotate_arrays(xgobidata *xg)
/*
X * Dynamically allocate arrays.
*/
{
X  Cardinal nc = (Cardinal) xg->ncols;
X
X  spin_coef = (float *)
X    XtMalloc((unsigned int) 2 * nc * sizeof(float));
}
X
void
free_rotate_arrays()
/*
X * Dynamically free arrays.
*/
{
X  XtFree((XtPointer) spin_coef);
}
X
X
/* --------- End of dynamic allocation section ----------- */
X
void
init_trig(xgobidata *xg)
/*
X * Initiallize icost and isint, which are scaled up so that the rotation
X * calculations can be done in integer arithmetic.
*/
{
X  xg->theta.yaxis = xg->theta.xaxis = 0.0;
X
X  xg->cost.y = xg->cost.x = (float) cos((double) xg->theta0);
X  xg->sint.y = xg->sint.x = (float) sin((double) xg->theta0);
X  xg->ocost.y = xg->ocost.x = xg->icost.y = xg->icost.x =
X    (int) (xg->cost.y * PRECISION2);
X  xg->osint.y = xg->osint.x = xg->isint.y = xg->isint.x =
X    (int) (xg->sint.y * PRECISION2);
}
X
void
find_Rmat(xgobidata *xg)
{
X  float cosn = (float) cos((double) xg->theta.oblique);
X  float sinn = (float) sin((double) xg->theta.oblique);
X  float cosm;
/*
X * Calculate new rotation matrix
*/
X  cosm = 1.0 - cosn;
X  Rmat2[0][0] = (cosm * ob_axis.x * ob_axis.x) + cosn;
X  Rmat2[0][1] = (cosm * ob_axis.x * ob_axis.y) + (sinn * ob_axis.z);
X  Rmat2[0][2] = (cosm * ob_axis.x * ob_axis.z) - (sinn * ob_axis.y);
X  Rmat2[1][0] = (cosm * ob_axis.x * ob_axis.y) - (sinn * ob_axis.z);
X  Rmat2[1][1] = (cosm * ob_axis.y * ob_axis.y) + cosn;
X  Rmat2[1][2] = (cosm * ob_axis.y * ob_axis.z) + (sinn * ob_axis.x);
X  Rmat2[2][0] = (cosm * ob_axis.x * ob_axis.z) + (sinn * ob_axis.y);
X  Rmat2[2][1] = (cosm * ob_axis.y * ob_axis.z) - (sinn * ob_axis.x);
X  Rmat2[2][2] = (cosm * ob_axis.z * ob_axis.z) + cosn;
}
X
void print_Rmat(float Rmat[3][3], char *lbl) {
X  int j;
X  fprintf(stderr, "%s\n", lbl);
X  for (j=0; j<3; j++)
X    fprintf(stderr, "%f %f %f\n", 
X      Rmat[0][j], Rmat[1][j], Rmat[2][j]);
}
void print_lRmat(long Rmat[3][3], char *lbl) {
X  int j;
X  fprintf(stderr, "%s\n", lbl);
X  for (j=0; j<3; j++)
X    fprintf(stderr, "%ld %ld %ld\n", 
X      Rmat[0][j], Rmat[1][j], Rmat[2][j]);
}
X
void
init_ob_rotate(xgobidata *xg)
{
X  int j, k;
X
X  xg->theta.oblique = 0.;
X
/*
X * Initialize the axis of rotation.
*/
X  ob_axis.x = 0;
X  ob_axis.y = 1;
X  ob_axis.z = 0;
X
X  for (j=0; j<3; j++) {
X    for (k=0; k<3; k++) {
X      if (j==k)
X        xg->Rmat0[k][j] = Rmat1[j][k] = Rmat2[j][k] = 1.;
X      else
X        xg->Rmat0[k][j] = Rmat1[j][k] = Rmat2[j][k] = 0.;
X    }
X  }
X
X  find_Rmat(xg);
}
X
void
init_rotate_vars(xgobidata *xg)
{
X  static Boolean firsttime = True;
X
X  if (firsttime) {
X    xg->is_spin_paused = False;
X    xg->is_interp = False;
X    xg->is_rocking = False;
X    xg->run_spin_axis_proc = False;
X    xg->run_rock_proc = False;
X    xg->run_interp_proc = False;
X    xg->run_spin_oblique_proc = False;
X    xg->is_spin_type.xaxis = xg->is_spin_type.yaxis = False;
X    xg->is_spin_type.oblique = True;
X
X    xg->theta0 = THETA0;
X    xg->xax.x = RADIUS;
X    xg->xax.y = 0;
X    xg->yax.x = 0;
X    xg->yax.y = RADIUS;
X    xg->zax.x = 0;
X    xg->zax.y = 0;
X
X    firsttime = False;
X  }
X
X  xg->is_spinning = False;
X  init_trig(xg);
X  init_ob_rotate(xg);
X
X  xg->spin_vars.x = 0;
X  xg->spin_vars.z = 1;
X  xg->spin_vars.y = 2;
}
X
X
void
change_spin_direction()
{
X  spin_dir = -1 * spin_dir;
}
X
void
ax_rot_reproject(xgobidata *xg)
{
X  int j;
X  long nx, ny;
X  int ix = xg->spin_vars.x;
X  int iy = xg->spin_vars.y;
X  int iz = xg->spin_vars.z;
X
X  if (xg->is_spin_type.yaxis) {   /* Rotate around y, vertical axis */
X    for (j=0; j<xg->nrows; j++) {
X      nx = xg->icost.y * xg->world_data[j][ix] +
X         /*xg->isint.y * xg->world_data[j][iz];*/
X         xg->isint.y * xg->world_data[j][iy];
X      xg->planar[j].x = nx/PRECISION2;
X      /*xg->planar[j].y = xg->world_data[j][iy];*/
X      xg->planar[j].y = xg->world_data[j][iz];
X    }
X  }
X  else {                          /* Rotate around z, horizontal axis */
X    for (j=0; j<xg->nrows; j++) {
X      xg->planar[j].x = xg->world_data[j][iz];
X      ny = xg->icost.x * xg->world_data[j][ix] +
X         /*xg->isint.x * xg->world_data[j][iz];*/
X         xg->isint.x * xg->world_data[j][iy];
X      xg->planar[j].y = ny/PRECISION2;
X    }
X  }
}
X
void
reset_interp_proc()
{
X  turn = -1;
X  curdir = 1;
X  if (spin_dir == 0)
X    spin_dir = 1;
}
X
void
find_quadrant(xgobidata *xg)
/*
X * Figure out in which quadrant theta lies.
*/
{
X  spin_dir = 1;
X
X  xg->theta.yaxis = (float) fabs((double) xg->theta.yaxis);
X  if (xg->theta.yaxis >= 3*M_PI_2 && xg->theta.yaxis < 2*M_PI)
X    qd.y = 4;
X  else if (xg->theta.yaxis >= M_PI)
X    qd.y = 3;
X  else if (xg->theta.yaxis >= M_PI_2)
X    qd.y = 2;
X  else
X    qd.y = 1;
X
X  xg->theta.xaxis = (float) fabs((double) xg->theta.xaxis);
X  if (xg->theta.xaxis >= 3*M_PI_2 && xg->theta.yaxis < 2*M_PI)
X    qd.x = 4;
X  else if (xg->theta.xaxis >= M_PI)
X    qd.x = 3;
X  else if (xg->theta.xaxis >= M_PI_2)
X    qd.x = 2;
X  else
X    qd.x = 1;
}
X
void
spin_once(xgobidata *xg)
/*
X * Recalculate the new position for the data in planar[], that is,
X * the data being displayed scaled to +-32K.  The array 'world_data'
X * holds all the data similarly scaled.
*/
{
X  world_to_plane(xg);
X
X  if (xg->is_spin_type.yaxis) {  /* Use vertical axis */
X    xg->cost.y = (float) cos((double) xg->theta.yaxis);
X    xg->sint.y = (float) sin((double) xg->theta.yaxis);
X    xg->icost.y = (int) (xg->cost.y * PRECISION2);
X    xg->isint.y = (int) (xg->sint.y * PRECISION2);
X
X    xg->theta.yaxis = xg->theta.yaxis + (float) spin_dir * xg->theta0;
X    if (xg->theta.yaxis > MAXTHETA)
X      xg->theta.yaxis -= TWOPI;
X    else if (xg->theta.yaxis < -MAXTHETA)
X      xg->theta.yaxis += TWOPI;
X  } else if (xg->is_spin_type.xaxis) {
X    /*
X     * Use horizontal axis in the plane of the screen
X    */
X    xg->cost.x = (float) cos((double) xg->theta.xaxis);
X    xg->sint.x = (float) sin((double) xg->theta.xaxis);
X    xg->icost.x = (int) (xg->cost.x * PRECISION2);
X    xg->isint.x = (int) (xg->sint.x * PRECISION2);
X
X    xg->theta.xaxis = xg->theta.xaxis +
X      (float) spin_dir * xg->theta0;
X    if (xg->theta.xaxis > MAXTHETA)
X      xg->theta.xaxis -= TWOPI;
X    else if (xg->theta.xaxis < -MAXTHETA)
X      xg->theta.xaxis += TWOPI;
X  }
}
X
void
ob_rotate_once(xgobidata *xg)
/*
X * Recalculate the new position for the data in planar[], that is,
X * the data being displayed scaled to +-32K.  The array world_data[]
X * holds all the data similarly scaled.
*/
{
X  find_Rmat(xg);  /* calculates Rmat2 */
X  world_to_plane(xg);  /* calculates Rmat0 from Rmat2 and Rmat1 */
X
X  xg->theta.oblique = xg->theta.oblique + (float) spin_dir * xg->theta0;
X  if (xg->theta.oblique > MAXTHETA)
X    xg->theta.oblique -= TWOPI;
X  else if (xg->theta.oblique < -MAXTHETA)
X    xg->theta.oblique += TWOPI;
}
X
void
spin_proc(xgobidata *xg)
{
X  spin_once(xg);
X  plane_to_screen(xg);
X  plot_once(xg);
X  spin_var_lines(xg);
}
X
void
interp_proc(xgobidata *xg)
{
X  float angle;
X  int quadrant;
X
X  spin_once(xg);
X  plane_to_screen(xg);
X  plot_once(xg);
X  spin_var_lines(xg);
X
X  if (xg->is_spin_type.yaxis) {
X    angle = xg->theta.yaxis;
X    quadrant = qd.y;
X  }
X  else {
X    angle = xg->theta.xaxis;
X    quadrant = qd.x;
X  }
X
X  if (turn == 0) {
X    curdir = -1 * curdir;
X    spin_dir = curdir;
X    turn = -1;
X  } else if (turn < 0) {
X    switch(quadrant) {
X      case 1:
X        if (curdir == 1) {
X          if (angle >= M_PI_2 - xg->theta0) {
X            angle = M_PI_2;
X            turn = 7;
X          }
X        } else {
X          if (angle <= xg->theta0) {
X            angle = 0;
X            turn = 7;
X          }
X        }
X        break;
X
X      case 2:
X        if (curdir == 1) {
X          if (angle >= M_PI - xg->theta0) {
X            angle = M_PI;
X            turn = 7;
X          }
X        } else {
X          if (angle <= M_PI_2 + xg->theta0) {
X            angle = M_PI_2;
X            turn = 7;
X          }
X        }
X        break;
X
X      case 3:
X        if (curdir == 1) {
X          if (angle >= 3*M_PI_2 - xg->theta0) {
X            angle = 3*M_PI_2;
X            turn = 7;
X          }
X        } else {
X          if (angle <= M_PI + xg->theta0) {
X            angle = M_PI;
X            turn = 7;
X          }
X        }
X        break;
X
X      case 4:
X        if (curdir == 1) {
X          if (angle >= 2*M_PI - xg->theta0) {
X            angle = 2*M_PI;
X            turn = 7;
X          }
X        }
X        else {
X          if (angle <= 3*M_PI_2 + xg->theta0) {
X            angle = 3*M_PI_2;
X            turn = 7;
X          }
X        }
X        break;
X      }
X
X  }
X
X  if (turn > 0) {
X    spin_dir = 0;
X    turn--;
X  }
X  if (xg->is_spin_type.yaxis)
X    xg->theta.yaxis = angle;
X  else
X    xg->theta.xaxis = angle;
}
X
X
void
rock_proc(xgobidata *xg)
{
X  static int j = 0;
X
X  if (j == 10) {
X    spin_dir *= -1;
X    j = 0;
X  }
X  else
X    j++;
X
X  if (xg->is_spin_type.oblique) {
X    ob_rotate_once(xg);
X    draw_ob_var_lines(xg);
X  } else {
X    spin_once(xg);
X    spin_var_lines(xg);
X  }
X  plane_to_screen(xg);
X  plot_once(xg);
}
X
void
draw_ax_spin_axes(xgobidata *xg)
{
X  int naxes = 6;
X  int raw_axis_len = MIN(xg->mid.x, xg->mid.y);
X  XSegment spin_axes[10];
X  icoords cntr;
X
X  if (xg->is_axes_centered) {
X    cntr.x = xg->cntr.x;
X    cntr.y = xg->cntr.y;
X  } else {
X    raw_axis_len /= 2.0;
X    cntr.x = 1.1 * raw_axis_len * xg->scale.x;
X    cntr.y = xg->plotsize.height - (1.1 * raw_axis_len * xg->scale.y);
X  }
X
X  if (xg->is_spin_type.yaxis) {
X
X    /* horizontal axis ... x */
X    spin_axes[0].x1 = cntr.x;
X    spin_axes[0].x2 = cntr.x +
X      (int) (raw_axis_len * xg->scale.x) * xg->icost.y/PRECISION2;
X    spin_axes[0].y1 = spin_axes[0].y2 = cntr.y;
X    /* end of x axis */
X    spin_axes[1].x1 = spin_axes[1].x2 = spin_axes[0].x2;
X    spin_axes[1].y1 = spin_axes[0].y1 - 2;
X    spin_axes[1].y2 = spin_axes[0].y1 + 2;
X
X    /* horizontal axis ... y */
X    spin_axes[2].x1 = cntr.x;
X    spin_axes[2].x2 = cntr.x +
X      (int) (raw_axis_len * xg->scale.x) * xg->isint.y/PRECISION2;
X    spin_axes[2].y1 = spin_axes[2].y2 = cntr.y;
X    /* end of y axis */
X    spin_axes[3].x1 = spin_axes[3].x2 = spin_axes[2].x2;
X    spin_axes[3].y1 = spin_axes[2].y1 - 2;
X    spin_axes[3].y2 = spin_axes[2].y1 + 2;
X
X    /* vertical axis ... z */
X    spin_axes[4].x1 = spin_axes[4].x2 = cntr.x;
X    spin_axes[4].y1 = cntr.y;
X    spin_axes[4].y2 = cntr.y -
X      (int) (raw_axis_len * xg->scale.y);
X    /* end of z axis */
X    spin_axes[5].x1 = spin_axes[4].x1 - 2;
X    spin_axes[5].x2 = spin_axes[4].x1 + 2;
X    spin_axes[5].y1 = spin_axes[5].y2 = spin_axes[4].y2;
X
X  } else {
X
X    /* horizontal axis ... z */
X    spin_axes[4].x1 = cntr.x;
X    spin_axes[4].x2 = cntr.x +
X      (int) (raw_axis_len * xg->scale.x);
X    spin_axes[4].y1 = spin_axes[4].y2 = cntr.y;
X    /* end of z axis */
X    spin_axes[5].x1 = spin_axes[5].x2 = spin_axes[4].x2;
X    spin_axes[5].y1 = spin_axes[4].y1 - 2;
X    spin_axes[5].y2 = spin_axes[4].y1 + 2;
X
X    /* vertical axis ... x */
X    spin_axes[0].x1 = spin_axes[0].x2 = cntr.x;
X    spin_axes[0].y1 = cntr.y;
X    spin_axes[0].y2 = cntr.y -
X      (int) (raw_axis_len * xg->scale.x) * xg->icost.x/PRECISION2;
X    /* end of z axis */
X    spin_axes[1].x1 = spin_axes[0].x1 - 2;
X    spin_axes[1].x2 = spin_axes[0].x1 + 2;
X    spin_axes[1].y1 = spin_axes[1].y2 = spin_axes[0].y2;
X
X    /* vertical axis ... y */
X    spin_axes[2].x1 = spin_axes[2].x2 = cntr.x;
X    spin_axes[2].y1 = cntr.y;
X    spin_axes[2].y2 = cntr.y -
X      (int) (raw_axis_len * xg->scale.x) * xg->isint.x/PRECISION2;
X    /* end of y axis */
X    spin_axes[3].y1 = spin_axes[3].y2 = spin_axes[2].y2;
X    spin_axes[3].x1 = spin_axes[2].x1 - 2;
X    spin_axes[3].x2 = spin_axes[2].x1 + 2;
X  }
/*
X * Draw axes of rotation.
*/
X  XSetForeground(display, copy_GC, plotcolors.fg);
X  XDrawSegments(display, xg->pixmap0, copy_GC, spin_axes, naxes);
/*
X * Add axis labels.
*/
X  XDrawString(display, xg->pixmap0, copy_GC,
X    spin_axes[0].x2 + 6, spin_axes[0].y2 - 5,
X    xg->collab_tform2[xg->spin_vars.x],
X    strlen(xg->collab_tform2[xg->spin_vars.x]));
X
X  XDrawString(display, xg->pixmap0, copy_GC,
X    spin_axes[2].x2 + 6, spin_axes[2].y2 - 5,
X    xg->collab_tform2[xg->spin_vars.y],
X    strlen(xg->collab_tform2[xg->spin_vars.y]));
X
X  XDrawString(display, xg->pixmap0, copy_GC,
X    spin_axes[4].x2 + 6, spin_axes[4].y2 - 5,
X    xg->collab_tform2[xg->spin_vars.z],
X    strlen(xg->collab_tform2[xg->spin_vars.z]));
}
X
void
store_Rmat(xgobidata *xg)
{
X  int j, k;
/*
X * Copy previous rotation matrix into Rmat1.
*/
X  for (j=0; j<3; j++)
X    for (k=0; k<3; k++)
X      Rmat1[k][j] = xg->Rmat0[k][j];
}
X
void
ob_rot_reproject(xgobidata *xg)
{
X  int i, j, k;
X  long nx, ny;
X  float ftmp;
X  int ix = xg->spin_vars.x;
X  int iy = xg->spin_vars.y;
X  int iz = xg->spin_vars.z;
/*
X * Find the matrix product of the new matrix and the previous one.
*/
X  for (i=0; i<3; i++) {
X    for (j=0; j<3; j++) {
X      ftmp = 0.;
X      for (k=0; k<3; k++)
X        ftmp = ftmp + (Rmat2[i][k] * Rmat1[k][j]);
X      xg->Rmat0[i][j] = ftmp;
X    }
X  }
/*
X * Convert rotation matrix to type long.
X * We'll fill lRmat even though the 3rd column isn't used here;
X * it is needed in move_points.c, and it could be used here for
X * depth cuing some day.
*/
X  for (j=0; j<3; j++)
X    for (k=0; k<3; k++)
X      lRmat[k][j] = (long) (xg->Rmat0[k][j] * PRECISION2);
/*
X * Find new position of the data.
*/
X  for (k=0; k<xg->nrows_in_plot; k++) {
X    j = xg->rows_in_plot[k];
X    nx =
X      lRmat[0][0] * xg->world_data[j][ix] +
X      lRmat[0][1] * xg->world_data[j][iy] +
X      lRmat[0][2] * xg->world_data[j][iz];
X
X    xg->planar[j].x = nx/PRECISION2;
X    ny =
X      lRmat[1][0] * xg->world_data[j][ix] +
X      lRmat[1][1] * xg->world_data[j][iy] +
X      lRmat[1][2] * xg->world_data[j][iz];
X
X    xg->planar[j].y = ny/PRECISION2;
X  }
}
X
void
draw_ob_spin_axes(xgobidata *xg)
{
X  int naxes = 3;
X  int raw_axis_len = MIN(xg->mid.x, xg->mid.y);
X  XSegment spin_axes[3];
X  icoords cntr;
X
X  if (xg->is_axes_centered) {
X    cntr.x = xg->cntr.x;
X    cntr.y = xg->cntr.y;
X  } else {
X    raw_axis_len /= 2.0;
X    cntr.x = 1.1 * raw_axis_len * xg->scale.x;
X    cntr.y = xg->plotsize.height - (1.1 * raw_axis_len * xg->scale.y);
X  }
X
X  /* horizontal axis ... x */
X  spin_axes[0].x1 = cntr.x;
X  spin_axes[0].x2 = cntr.x +
X    (int) (raw_axis_len * xg->scale.x) * xg->Rmat0[0][0];
X  spin_axes[0].y1 = cntr.y;
X  spin_axes[0].y2 = cntr.y -
X    (int) (raw_axis_len * xg->scale.y) * xg->Rmat0[1][0];
X
X  /* vertical axis ... y */
X  spin_axes[1].x1 = cntr.x;
X  spin_axes[1].x2 = cntr.x +
X    (int) (raw_axis_len * xg->scale.x) * xg->Rmat0[0][1];
X  spin_axes[1].y1 = cntr.y;
X  spin_axes[1].y2 = cntr.y -
X    (int) (raw_axis_len * xg->scale.y) * xg->Rmat0[1][1];
X
X  /* horizontal axis ... z */
X  spin_axes[2].x1 = cntr.x;
X  spin_axes[2].x2 = cntr.x +
X    (int) (raw_axis_len * xg->scale.x) * xg->Rmat0[0][2];
X  spin_axes[2].y1 = cntr.y;
X  spin_axes[2].y2 = cntr.y -
X    (int) (raw_axis_len * xg->scale.y) * xg->Rmat0[1][2];
/*
X * Draw x, y, z axes.
*/
X  XSetForeground(display, copy_GC, plotcolors.fg);
X  XDrawSegments(display, xg->pixmap0, copy_GC, spin_axes, naxes);
/*
X * Add axis labels.
*/
X  XDrawString(display, xg->pixmap0, copy_GC,
X    spin_axes[0].x2 + 6, spin_axes[0].y2 - 5,
X    xg->collab_tform2[xg->spin_vars.x],
X    strlen(xg->collab_tform2[xg->spin_vars.x]));
X  XDrawString(display, xg->pixmap0, copy_GC,
X    spin_axes[1].x2 + 6, spin_axes[1].y2 - 5,
X    xg->collab_tform2[xg->spin_vars.y],
X    strlen(xg->collab_tform2[xg->spin_vars.y]));
X  XDrawString(display, xg->pixmap0, copy_GC,
X    spin_axes[2].x2 + 6, spin_axes[2].y2 - 5,
X    xg->collab_tform2[xg->spin_vars.z],
X    strlen(xg->collab_tform2[xg->spin_vars.z]));
}
X
void
ob_rotate_proc(xgobidata *xg)
{
X  ob_rotate_once(xg);
X  plane_to_screen(xg);
X  plot_once(xg);
X  draw_ob_var_lines(xg);
}
X
/* ARGSUSED */
XXtEventHandler
ob_button(Widget w, xgobidata *xg, XEvent *evnt)
{
X  static icoords pos, prev_pos;
X  float distx, disty, len_motion;
X  float phi, cosphi, sinphi, cosm;
X  float denom = (float) MIN(xg->mid.x, xg->mid.y);
X
X  if (evnt->type == ButtonPress) {
X    XButtonEvent *xbutton = (XButtonEvent *) evnt;
X    if (evnt->xbutton.button == 1 || evnt->xbutton.button == 2) {
X      stop_spin_proc(xg);
X
X      pos.x = prev_pos.x = xbutton->x;
X      pos.y = prev_pos.y = xbutton->y;
X    }
X  } else if (evnt->type == MotionNotify) {
X    XMotionEvent *xmotion = (XMotionEvent *) evnt;
X    prev_pos.x = pos.x;
X    prev_pos.y = pos.y;
X    pos.x = xmotion->x;
X    pos.y = xmotion->y;
X    distx = pos.x - prev_pos.x;
X    disty = prev_pos.y - pos.y;
X
X    if (xg->is_spin_type.oblique) {
X      /* 
X       * Done by imitating some notes in Computer Graphics, Vol 22,
X       * Number 4, August 1988, pp 127-128; SIGGRAPH '88
X      */
X      len_motion = (float)
X        sqrt((double) pow((double) disty, (double) 2.0) +
X           (double) pow((double) distx, (double) 2.0));
X      if (len_motion != 0) {
X        phi = len_motion / denom;
X
X        ob_axis.x = -disty/len_motion;
X        ob_axis.y = distx/len_motion;
X        ob_axis.z = 0;
X
X        store_Rmat(xg);
X        cosphi = (float) cos((double) phi);
X        sinphi = (float) sin((double) phi);
X        /*
X         * Calculate new rotation matrix.
X        */
X        cosm = 1.0 - cosphi;
X        Rmat2[0][0] = (cosm * ob_axis.x * ob_axis.x) + cosphi;
X        Rmat2[0][1] = (cosm * ob_axis.x * ob_axis.y) +
X                (sinphi * ob_axis.z);
X        Rmat2[0][2] = (cosm * ob_axis.x * ob_axis.z) -
X                (sinphi * ob_axis.y);
X        Rmat2[1][0] = (cosm * ob_axis.x * ob_axis.y) -
X                (sinphi * ob_axis.z);
X        Rmat2[1][1] = (cosm * ob_axis.y * ob_axis.y) + cosphi;
X        Rmat2[1][2] = (cosm * ob_axis.y * ob_axis.z) +
X                (sinphi * ob_axis.x);
X        Rmat2[2][0] = (cosm * ob_axis.x * ob_axis.z) +
X                (sinphi * ob_axis.y);
X        Rmat2[2][1] = (cosm * ob_axis.y * ob_axis.z) -
X                (sinphi * ob_axis.x);
X        Rmat2[2][2] = (cosm * ob_axis.z * ob_axis.z) + cosphi;
X
X        world_to_plane(xg);
X        draw_ob_var_lines(xg);
X      }
X    } else if (xg->is_spin_type.yaxis) {
X      xg->theta.yaxis = xg->theta.yaxis + distx/denom;
X
X      xg->cost.y = (float) cos((double) xg->theta.yaxis);
X      xg->sint.y = (float) sin((double) xg->theta.yaxis);
X      xg->icost.y = (int) (xg->cost.y * PRECISION2);
X      xg->isint.y = (int) (xg->sint.y * PRECISION2);
X      if (xg->theta.yaxis > MAXTHETA)
X           xg->theta.yaxis -= TWOPI;
X      else if (xg->theta.yaxis < -MAXTHETA)
X           xg->theta.yaxis += TWOPI;
X
X      world_to_plane(xg);
X      spin_var_lines(xg);
X    } else if (xg->is_spin_type.xaxis) {
X      xg->theta.xaxis = xg->theta.xaxis - disty/denom;
X
X      xg->cost.x = (float) cos((double) xg->theta.xaxis);
X      xg->sint.x = (float) sin((double) xg->theta.xaxis);
X      xg->icost.x = (int) (xg->cost.x * PRECISION2);
X      xg->isint.x = (int) (xg->sint.x * PRECISION2);
X      if (xg->theta.xaxis > MAXTHETA)
X           xg->theta.xaxis -= TWOPI;
X      else if (xg->theta.xaxis < -MAXTHETA)
X           xg->theta.xaxis += TWOPI;
X
X      world_to_plane(xg);
X      spin_var_lines(xg);
X    }
X    plane_to_screen(xg);
X    plot_once(xg);
X  } else if (evnt->type == ButtonRelease) {
X    if (xg->is_spin_type.oblique) {
X      store_Rmat(xg);
X      xg->theta.oblique = xg->theta0;
X    }
X    start_spin_proc(xg);
X  }
}
X
X
/*
X * Here's the code for writing the rotation coefficients that
X * produced this particular 2d projection,
X * followed by code for writing and reading the rotation matrix.
*/
X
#define SPIN_COEF(n,p) spin_coef[(2*(n)) + (p)]
/* ARGSUSED */
XXtCallbackProc
spin_place_save_coefs_popup(Widget w, xgobidata *xg, XtPointer callback_data)
/*
X * Determine where to place the popup window in which the user enters
X * a filename; invoked before spin_save.
*/
{
X  /*
X   * Shut off spinning until the file name is entered.
X  */
X  stop_spin_proc(xg);
X  (void) strcpy(xg->save_type, SAVE_SPIN_COEFS );
X  fname_popup(w, xg);
}
X
void
spin_save_coefs(Widget w, xgobidata *xg)
{
X  char *filename;
X  int j;
X  long foo;
X  float xfoo;
X  char Spath[50];
X  int x = xg->spin_vars.x, y = xg->spin_vars.y, z = xg->spin_vars.z;
X  FILE *fp;
X
/*
X * spin_coef will contain the coefficients
X * of rotation:  The x coefficients will be in column 0 and
X * the y coefficients in column 1.
*/
X  for (j=0; j<2*xg->ncols_used; j++)
X    spin_coef[j] = 0.0;
X
X  if (xg->is_spin_type.yaxis) {
X    SPIN_COEF(x, 0) = xg->cost.y /
X      (xg->lim[x].max - xg->lim[x].min);
X    SPIN_COEF(z, 0) = xg->sint.y /
X      (xg->lim[z].max - xg->lim[z].min);
X    SPIN_COEF(y, 1) = 1.0;
X  } else if (xg->is_spin_type.xaxis) {
X    SPIN_COEF(x, 0) = 1.0;
X    SPIN_COEF(y, 1) = xg->cost.x /
X      (xg->lim[y].max - xg->lim[y].min);
X    SPIN_COEF(z, 1) = xg->sint.x /
X      (xg->lim[z].max - xg->lim[z].min);
X  } else if (xg->is_spin_type.oblique) {
X    SPIN_COEF(x, 0) = xg->Rmat0[0][0] /
X      (xg->lim[x].max - xg->lim[x].min);
X    SPIN_COEF(x, 1) = xg->Rmat0[1][0] /
X      (xg->lim[x].max - xg->lim[x].min);
X    SPIN_COEF(y, 0) = xg->Rmat0[0][1] /
X      (xg->lim[y].max - xg->lim[y].min);
X    SPIN_COEF(y, 1) = xg->Rmat0[1][1] /
X      (xg->lim[y].max - xg->lim[y].min);
X    SPIN_COEF(z, 0) = xg->Rmat0[0][2] /
X      (xg->lim[z].max - xg->lim[z].min);
X    SPIN_COEF(z, 1) = xg->Rmat0[1][2] /
X      (xg->lim[z].max - xg->lim[z].min);
X  }
X
X  filename = XtMalloc(132 * sizeof(char));
X  XtVaGetValues(w, XtNstring, (String) &filename, NULL);
/*
X * In S, just write them out as a vector, column 0 then column 1.
*/
X  if (xg->data_mode == Sprocess) {
X    (void) strcpy(Spath, Spath0);
X    (void) strcat(Spath, filename);
X    if ( (fp = fopen(Spath, "w")) == NULL) {
X      char message[MSGLENGTH];
X      sprintf(message, "Failed to open the file '%s' for writing.\n", Spath);
X      show_message(message, xg);
X    } else {
X      /*
X       * "1" indicates that the following is an
X       * S data structure of one element.
X      */
X      (void) fprintf(fp, "%cS data%c", (char) 0 , (char) 1);
X      /*
X       * "3" indicates that the following is of type
X       * single; "4" would imply numeric, or double.
X      */
X      foo = (long) 3;
X      if (fwrite((char *) &foo, sizeof(foo), 1, fp) == 0)
X        fprintf(stderr, "xgobi: error in writing coefficients\n");
X      /*
X       * "2*ncols_used" says the following has "2*ncols_used" elements."
X      */
X      foo = (long) (2*xg->ncols_used);
X      if (fwrite((char *) &foo, sizeof(foo), 1, fp) == 0)
X        fprintf(stderr, "xgobi: error in writing coefficients\n");
X
X      for (j=0; j<2*xg->ncols_used; j++) {
X        xfoo = spin_coef[j];
X        if (fwrite((char *) &xfoo, sizeof(xfoo), 1, fp) == 0)
X          fprintf(stderr, "xgobi: error in writing coefficients\n");
X      }
X      if (fclose(fp) == EOF)
X        fprintf(stderr, "xgobi: error in writing coefficients\n");
X    }
X  }
/*
X * In ascii, write out a two-column file.
*/
X  else if (xg->data_mode == ascii || xg->data_mode == binary) { /* if not S */
X    if ( (fp = fopen(filename, "w")) == NULL) {
X      char message[MSGLENGTH];
X      sprintf(message, "Failed to open the file '%s' for writing.\n", filename);
X      show_message(message, xg);
X    } else {
X      for (j=0; j<xg->ncols_used; j++)
X        (void) fprintf(fp, "%f %f\n",
X          SPIN_COEF(j, 0), SPIN_COEF(j, 1));
X
X      if (fclose(fp) == EOF)
X        fprintf(stderr, "error in fclose in spin_save_coefs_cback\n");
X    }
X  }
X
X  XtFree(filename);
/*
X * Restart interpolation or rotation after saving data.
*/
X  start_spin_proc(xg);
}
#undef SPIN_COEF
X
/* ARGSUSED */
XXtCallbackProc
spin_place_save_rmat_popup(Widget w, xgobidata *xg, XtPointer callback_data)
/*
X * Determine where to place the popup window in which the user enters
X * a filename; invoked before spin_save.
*/
{
X  /*
X   * Shut off spinning until the file name is entered.
X  */
X  stop_spin_proc(xg);
X  (void) strcpy(xg->save_type, SAVE_SPIN_RMAT);
X  fname_popup(w, xg);
}
X
void
spin_save_rmat(Widget w, xgobidata *xg)
{
X  char *filename;
X  int j;
X  FILE *fp;
X
X  filename = XtMalloc(132 * sizeof(char));
X  XtVaGetValues(w, XtNstring, (String) &filename, NULL);
X
/*
X * In S, don't do this ...
*/
X  if (xg->data_mode == Sprocess) {
X    ;
X  }
X
/*
X * In ascii, write out a three-column file.
*/
X  else if (xg->data_mode == ascii || xg->data_mode == binary) { /* if not S */
X    if ( (fp = fopen(filename, "w")) == NULL) {
X      char message[MSGLENGTH];
X      sprintf(message, "Failed to open the file '%s' for writing.\n", filename);
X      show_message(message, xg);
X    } else {
X      /*
X       * In order that rotation restarts smoothly, it seems I have
X       * to save an extraordinary amount of variables ...
X      */
X      for (j=0; j<3; j++)
X        fprintf(fp, "%f %f %f\n",
X          xg->Rmat0[j][0], xg->Rmat0[j][1], xg->Rmat0[j][2]);
X      for (j=0; j<3; j++)
X        fprintf(fp, "%f %f %f\n",
X          Rmat1[j][0], Rmat1[j][1], Rmat1[j][2]);
X      fprintf(fp, "%f\n", xg->theta.oblique);
X      fprintf(fp, "%f %f %f\n", ob_axis.x, ob_axis.y, ob_axis.z);
X
X      if (fclose(fp) == EOF)
X        fprintf(stderr, "error in fclose in spin_save_rmat_cback\n");
X    }
X  }
X
/* XtFree(filename); */
X
/*
X * Restart interpolation or rotation after saving data.
*/
X  start_spin_proc(xg);
}
X
/* ARGSUSED */
XXtCallbackProc
spin_place_read_rmat_popup(Widget w, xgobidata *xg, XtPointer callback_data)
/*
X * Determine where to place the popup window in which the user enters
X * a filename; invoked before spin_save.
*/
{
X  /*
X   * Shut off spinning ...
X  */
X  stop_spin_proc(xg);
X  (void) strcpy(xg->save_type, READ_SPIN_RMAT);
X  fname_popup(w, xg);
}
X
void
spin_read_rmat(Widget w, xgobidata *xg)
{
X  char *filename;
X  int j, k;
X  int x = xg->spin_vars.x, y = xg->spin_vars.y, z = xg->spin_vars.z;
X  FILE *fp;
X  long nx, ny;
X
X  filename = XtMalloc(132 * sizeof(char));
X  XtVaGetValues(w, XtNstring, (String) &filename, NULL);
X
/*
X * No reading from S ...
*/
X  if (xg->data_mode == Sprocess)
X    return;
X
/*
X * In ascii, read in the two-column file.
*/
X  else if (xg->data_mode == ascii || xg->data_mode == binary) { /* if not S */
X    if ( (fp = fopen(filename, "r")) == NULL) {
X      char message[MSGLENGTH];
X      sprintf(message, "Failed to open the file '%s' for reading.\n", filename);
X      show_message(message, xg);
X    } else {
X
X      for (j=0; j<3; j++) {
X        for (k=0; k<3; k++) {
X          if ( fscanf(fp, "%f\n", &xg->Rmat0[j][k]) < 0) {
X            char msg[MSGLENGTH];
X            sprintf(msg,
X              "The rotation matrix file %s is smaller than 3x3\n", filename);
X            show_message(msg, xg);
X            break;
X      } } }
X      for (j=0; j<3; j++) {
X        for (k=0; k<3; k++) {
X          if ( fscanf(fp, "%f\n", &Rmat1[j][k]) < 0) {
X            char msg[MSGLENGTH];
X            sprintf(msg,
X              "The rotation matrix file %s is smaller than 3x3\n", filename);
X            show_message(msg, xg);
X            break;
X      } } }
X      fscanf(fp, "%f\n", &xg->theta.oblique);
X      fscanf(fp, "%f %f %f\n", &ob_axis.x, &ob_axis.y, &ob_axis.z);
X            
X
X      if (fclose(fp) == EOF)
X        fprintf(stderr, "error in fclose in spin_read_rmat_cback\n");
X
X    }
X  }
X
X  find_Rmat(xg);
X
X  /* XtFree(filename); */
X
X  /* run through pipeline and replot -- this is
X   * the latter half of ob_rot_reproject; this is what
X   * would happen if world_to_plane were called
X  */
X
X  /*
X   * Convert rotation matrix to type long.
X  */
X  for (j=0; j<3; j++)
X    for (k=0; k<2; k++)
X      lRmat[k][j] = (long) (xg->Rmat0[k][j] * PRECISION2);
X
X  /*
X   * Find new position of the data.
X  */
X  for (k=0; k<xg->nrows_in_plot; k++) {
X    j = xg->rows_in_plot[k];
X    nx =
X      lRmat[0][0] * xg->world_data[j][x] +
X      lRmat[0][1] * xg->world_data[j][y] +
X      lRmat[0][2] * xg->world_data[j][z];
X
X    xg->planar[j].x = nx/PRECISION2;
X    ny =
X      lRmat[1][0] * xg->world_data[j][x] +
X      lRmat[1][1] * xg->world_data[j][y] +
X      lRmat[1][2] * xg->world_data[j][z];
X
X    xg->planar[j].y = ny/PRECISION2;
X  }
X
X  plane_to_screen(xg);
X  plot_once(xg);
X  spin_var_lines(xg);
X
/*
X * In this case, don't restart rotation.  That can't possibly
X * be what the user would want.
*/
X
}
X
SHAR_EOF
  chmod 0644 'xgobi/src/spin.c' ||
  $echo 'restore of' 'xgobi/src/spin.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/spin.c:' 'MD5 check failed'
c9b12f20fef93127e8843c834f43cf9c  xgobi/src/spin.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/spin.c'`"
    test 29759 -eq "$shar_count" ||
    $echo 'xgobi/src/spin.c:' 'original size' '29759,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/xgobiexterns.h ==============
if test -f 'xgobi/src/xgobiexterns.h' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/xgobiexterns.h' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/xgobiexterns.h' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/xgobiexterns.h' &&
/* xgobiexterns.h */
X
#include <stdio.h>
X
extern Boolean plotted_var_missing(int from, int to, xgobidata *xg);
X
extern Boolean set_plot1dvar(xgobidata *, int);
extern Boolean set_xyplotxvar(xgobidata *, int);
extern Boolean set_xyplotyvar(xgobidata *, int);
X
extern void init_missing_array(int nr, int nc, xgobidata *xg);
extern void alloc_transform_tp(xgobidata *xg);
extern void update_nrgroups_in_plot(xgobidata *xg);
extern void resort_vgroup_ids(xgobidata *, int *);
extern double randvalue(void);
extern void rnorm2(double *, double *);
extern void AllocBox(xgobidata *);
extern Widget CreateCommand(xgobidata *, char *, Boolean, Widget, Widget, Widget, char *);
extern Widget CreateToggle(xgobidata *, char *, Boolean, Widget, Widget, Widget, Boolean, int, Widget, char *);
extern float NiceValue(float);
extern XtCallbackProc PopupCaselist(Widget, xgobidata *, XtPointer);
extern XtCallbackProc PopupVarlist(Widget, xgobidata *, XtPointer);
extern Boolean RunWorkProc(xgobidata *);
extern Boolean RunWorkProcs(void *);
extern void SetNiceRange(int, xgobidata *);
extern void setToggleBitmap(Widget, Boolean);
extern int Sread_array(xgobidata *);
extern XtCallbackProc about_xgobi_cback(Widget, xgobidata *, XtPointer);
extern XtCallbackProc reset_clusters_cback(Widget, xgobidata *, XtPointer);
extern void active_paint_lines(xgobidata *);
extern Boolean active_paint_points(xgobidata *);
extern void add_menupb_help(int *n, Widget w, char *fname);
extern void add_pb_help(int *n, Widget w, char *fname);
extern void add_sbar_help(int *n, Widget w, char *fname);
extern XtEventHandler add_tform_menu(Widget, xgobidata *, XEvent *);
extern void add_under_brush_label(xgobidata *xg);
extern void add_x_axis(xgobidata *, icoords *, int, tickinfo *);
extern void add_x_gridlines(xgobidata *, int, int, tickinfo *);
extern void add_y_axis(xgobidata *, icoords *, int, tickinfo *);
extern void add_y_gridlines(xgobidata *, int, int, tickinfo *);
extern void adjust_limits(float *, float *);
extern void all_tour_reproject(xgobidata *);
extern void alloc_axis_arrays(xgobidata *);
extern void alloc_bin_entropy(int);
extern void alloc_bin_fts(int);
extern void alloc_brush_arrays(xgobidata *);
extern void alloc_central_mass(int);
extern void alloc_corr(xgobidata *);
extern void alloc_hermite(int, int);
extern void alloc_holes(int);
extern void alloc_legendre(int, int);
extern void alloc_line_edit_arrays(xgobidata *);
extern void alloc_natural_hermite(int, int);
extern void alloc_pipeline_arrays(xgobidata *);
extern void alloc_plot_arrays(xgobidata *);
extern void alloc_rotate_arrays(xgobidata *);
extern void alloc_skewness(int);
extern void alloc_smooth_arrays(xgobidata *);
extern void alloc_std_vars(xgobidata *);
extern void alloc_tour(xgobidata *);
extern void alloc_transform_types(xgobidata *);
extern void announce_brush_data(xgobidata *);
extern void announce_ids(xgobidata *);
extern void announce_line_brush_data(xgobidata *);
extern void announce_rows_in_plot(xgobidata *);
extern void announce_tour_coefs(xgobidata *);
extern void assign_points_to_bins(xgobidata *);
extern void ax_rot_reproject(xgobidata *);
extern void basis_dir_ang(xgobidata *);
extern float bin_entropy_index(float **, int, int *, float);
extern void bin_fts_deriv(float **, float **, float *, float *, float **, int, int *, int, int, int *, float);
extern float bin_fts_index(float **, int, int *, float);
extern void bm_cancel(void);
extern XtCallbackProc br_complement_cback(Widget, xgobidata *, XtPointer);
extern XtCallbackProc br_linkopt_menu_cback(Widget, xgobidata *, XtPointer);
extern XtCallbackProc br_opt_menu_cback(Widget, xgobidata *, XtPointer);
extern XtCallbackProc br_perst_cback(Widget, xgobidata *, XtPointer);
extern XtCallbackProc br_save_to_group_var(Widget, xgobidata *, XtPointer);
extern void save_brush_groups(xgobidata *xg);
extern XtCallbackProc br_trans_cback(Widget, xgobidata *, XtPointer);
extern XtCallbackProc br_undo_cback(Widget, xgobidata *, XtPointer);
extern XtCallbackProc br_update_cback(Widget, xgobidata *, XtPointer);
extern XtCallbackProc brush_active_cback(Widget, xgobidata *, XtPointer);
extern XtEventHandler brush_button(Widget, xgobidata *, XEvent *);
extern XtCallbackProc brush_cback(Widget, xgobidata *, XtPointer);
extern XtCallbackProc brush_lines_cback(Widget, xgobidata *, XtPointer);
extern XtEventHandler brush_motion(Widget, xgobidata *, XEvent *, Boolean *);
extern void brush_on(xgobidata *);
extern Boolean brush_once(xgobidata *, Boolean force);
extern XtCallbackProc brush_points_cback(Widget, xgobidata *, XtPointer);
extern void build_caselist(xgobidata *);
extern void build_circle(icoords *, int, XArc *, int, short);
extern void build_glyph(xgobidata *, int, icoords *, int, XPoint *, int *, XSegment *, int *, XRectangle *, int *, XRectangle *, int *, XArc *, int *, XArc *, int *);
extern void build_labelled_menu(Widget *, Widget *, char *, Widget *, Widget *, Widget *, char **, char **, int, int, Widget, Widget, XtOrientation, XFontStruct *, char *, xgobidata *);
extern void build_plus(icoords *, int, XSegment *, int, short);
extern void build_rect(icoords *, int, XRectangle *, int, short);
extern void build_varlist(xgobidata *);
extern void build_x(icoords *, int, XSegment *, int, short);
extern float calc_norm(float *, int);
extern float calc_norm_sq(float *, int);
extern void calc_var_xy(xgobidata *, int, int, int *, int *);
extern void carry_corr_vars(xgobidata *);
extern void carry_plot1d_vars(xgobidata *);
extern void carry_spin_vars(xgobidata *);
extern void carry_tour_vars(xgobidata *);
extern void carry_xyplot_vars(xgobidata *);
extern void central_mass_deriv(float **, float **, float *, float *, float **, int, int *, int, int, int *);
extern float central_mass_index(float **, int, int *);
extern void change_first_projection(int, int, xgobidata *);
extern void change_spin_direction(void);
extern void check_cprof_fac_and_offsets(float *, float *, float *, float *, float *, float *, int);
extern void check_deselection(int, xgobidata *);
extern void check_pp_fac_and_offsets(xgobidata *, float *, float *, float *, float *, float *, float *, int);
extern int check_proximity(float **, float **, int);
extern Boolean check_singular_vc(void);
extern int check_x_axis(xgobidata *, int, tickinfo *);
extern int check_y_axis(xgobidata *, int, tickinfo *);
extern XtCallbackProc choose_tour_interp_cback(Widget, xgobidata *, XtPointer);
extern XtCallbackProc choose_tour_io_cback(Widget, xgobidata *, XtPointer);
extern XtCallbackProc clone_xgobi_cback(Widget, xgobidata *, XtPointer);
extern XtCallbackProc scatmat_xgobi_cback(Widget, xgobidata *, XtPointer);
extern void compute_vc_matrix(xgobidata *);
extern void convert_axes(tickinfo *, xgobidata *);
extern void convert_ticks(int, int, tickinfo *, xgobidata *);
extern void copy_basis(float **, float **, int);
extern void copy_brushinfo_to_senddata(xgobidata *);
extern Boolean copy_impnames(char *, xgobidata *);
extern Boolean copy_imputations(char *, xgobidata *);
extern void copy_matrix(float **, float **, int, int);
extern void copy_raw_to_tform(xgobidata *);
extern void copy_resources(char *, xgobidata *);
extern void copy_tform_to_sphered(xgobidata *);
extern void copy_u0_to_pd0(xgobidata *);
extern void copy_u1_to_pd1(xgobidata *);
extern Boolean corr_backtracking(xgobidata *);
extern void corr_event_handlers(xgobidata *, Boolean);
extern void corr_proc(xgobidata *);
extern void corr_reproject(xgobidata *);
extern void corr_span_planes(xgobidata *);
extern void corr_tour_on(xgobidata *);
extern int corr_varselect(int, int, int, xgobidata *);
extern void cp_index(xgobidata *, int, int);
extern XtCallbackProc cprof_plot_cback(Widget, xgobidata *, XtPointer);
extern void cprof_plot_once(xgobidata *);
extern void create_default_lines(xgobidata *);
extern void destroy_varsel_widgets(int, xgobidata *);
extern void plot1d_cycle_proc(xgobidata *);
extern void plot1d_reproject(xgobidata *);
extern void plot1d_texture_var(xgobidata *);
extern Boolean plot1d_varselect(int, int, int, xgobidata *);
extern void draw_ax_spin_axes(xgobidata *);
extern void draw_brush(xgobidata *);
extern void draw_cmanip_var(xgobidata *);/* interactive gt*/
extern void draw_connecting_lines(xgobidata *);
extern void draw_corr_axes(xgobidata *);
extern void draw_current_glyph(xgobidata *);
extern void draw_diamond_around_point(int, Drawable, xgobidata *);
extern void draw_editing_lines(xgobidata *);
extern void draw_last_touched(xgobidata *);
extern void draw_manip_var(xgobidata *);/* interactive gt*/
extern void draw_ob_spin_axes(xgobidata *);
extern void draw_ob_var_lines(xgobidata *);
extern void draw_tour_axes(xgobidata *);
extern int dsvd(float **, int, int, float *, float **);
extern void entropy_deriv(float **, float **, float **, int, int *, int, float *, float *, float, int, int *);
extern float entropy_index(float **, int, int *, float);
extern XtCallbackProc exit_panel_cback(Widget, xgobidata *, XtPointer);
extern XtCallbackProc exit_solo_cback(Widget, xgobidata *, XtPointer);
extern XtEventHandler expose_cback(Widget, xgobidata *, XEvent *, Boolean *);
extern void extend_axes(int, int, tickinfo *, xgobidata *);
extern void fill_extra_column(xgobidata *);
extern void find_Rmat(xgobidata *);
extern void find_extended_brush_corners(icoords *, icoords *, xgobidata *);
extern int find_gid(glyphv *);
extern void find_glyph_type_and_size(int, glyphv *);
extern int find_mono(void);
extern int find_nearest_point(icoords *, xgobidata *);
extern void find_plot_center(xgobidata *);
extern void find_quadrant(xgobidata *);
extern void find_root_name_of_data(char *, char *);
extern void find_tick_label(xgobidata *, int, int, float *, char *);
extern void fname_popup(Widget, xgobidata *);
extern void free_axis_arrays(xgobidata *);
extern void free_bin_entropy(void);
extern void free_bin_fts(void);
extern void free_brush_arrays(xgobidata *);
extern void free_caselist(xgobidata *);
extern void free_central_mass(void);
extern void free_corr(xgobidata *);
extern void free_hermite(int);
extern void free_holes(void);
extern void free_legendre(int);
extern void free_lgroups(xgobidata *);
extern void free_line_edit_arrays(xgobidata *);
extern void free_natural_hermite(int);
extern void free_pipeline_arrays(xgobidata *);
extern void free_plot_arrays(void);
extern void free_rgroups(xgobidata *);
extern void free_rotate_arrays(void);
extern void free_skewness(void);
extern void free_smooth_arrays(void);
extern void free_std_vars(xgobidata *);
extern void free_tour(xgobidata *);
extern void free_txtr_var(void);
extern void free_varlist(xgobidata *);
extern void fts_deriv(float **, float **, float **, int, int *, int, float *, float *, float, int, int *);
extern float fts_index(float **, int, int *, float);
extern void gen_norm_variates(int, int, float *);
extern void get_cprof_win_dims(float *, float *, xgobidata *);
extern void get_pp_win_dims(xgobidata *, float *, float *);
extern void get_sph_vars(xgobidata *);/*sphere*/
extern void get_evals(int , float *);/*sphere*/
extern int glyph_color_pointtype(xgobidata *, int);
extern void gram_schmidt(float *, float *, int);
extern void grand_tour_on(xgobidata *);
extern void help(Widget, char *, xgobidata *);
extern XtCallbackProc help_cback(Widget, xgobidata *, XtPointer);
extern void hermite_deriv1(float **, float **, float *, float *, float **, int, int *, int, int *, int, int);
extern float hermite_index1(float **, int, int *, int);
extern void highlight_backtrack_cmd(void);
extern void highlight_pause_cmd(void);
extern void holes_deriv(float **, float **, float *, float *, float **, int, int *, int, int, int *);
extern float holes_index(float **, int, int *);
extern void id_proc(xgobidata *xg);
extern void identify_on(xgobidata *);
extern void init_GCs(xgobidata *);
extern void init_V(xgobidata *);
extern void init_axes(xgobidata *, Boolean);
extern void init_basis(xgobidata *);
extern void init_brush_colors(AppData *);
extern void init_brush_menus(void);
extern void init_brush_size(xgobidata *);
extern void init_brush_vars(xgobidata *);
extern void init_color_ids(xgobidata *);
extern void init_corr(xgobidata *);
extern void init_plot1d_vars(xgobidata *);
extern void init_erase(xgobidata *);
extern void init_glyph_ids(xgobidata *);
extern void init_help(xgobidata *);
extern void init_identify_vars(xgobidata *);
extern void init_line_colors(xgobidata *);
extern void init_line_edit_vars(xgobidata *);
extern void init_missing_groupvar(xgobidata *);
extern void init_ob_rotate(xgobidata *);
extern void init_options(xgobidata *);
extern void init_parcoords(xgobidata *);
extern void init_plotwindow_vars(xgobidata *, int);
extern void init_point_moving(xgobidata *);
extern void init_rotate_vars(xgobidata *);
extern void init_scale_vars(xgobidata *);
extern void init_stdview_menu(xgobidata *);
extern void init_tickdelta(xgobidata *);
extern void init_ticks(icoords *, xgobidata *);
extern void init_tour(xgobidata *, int);
extern void init_tour_interp_menu(void);
extern void init_tour_pp_GCs(xgobidata *);
extern void init_tour_pp_menu(void);
extern void init_transform_types(xgobidata *);
extern float inv_transform(int, int, xgobidata *);
extern void init_trig(xgobidata *);
extern void init_xyplot_vars(xgobidata *);
extern float inner_prod(float *, float *, int);
extern void interp_proc(xgobidata *);
extern void invert_proj_coords(xgobidata *);
extern XtCallbackProc launch_missing_cback(Widget, xgobidata *, XtPointer);
extern void legendre_deriv(float **, float **, float *, float *, float **, int, int *, int, int *, int, int);
extern float legendre_index(float **, int, int *, int);
extern void line_edit_proc(xgobidata *);
extern void line_editor_on(xgobidata *);
extern void make_arrows(xgobidata *);
extern void make_brush(xgobidata *);
extern void make_corr(xgobidata *);
extern void make_plot1d(xgobidata *);
extern void make_erase_menu(xgobidata *, Widget);
extern void make_identify(xgobidata *);
extern void make_line_editor(xgobidata *);
extern void make_move_points(xgobidata *);
extern void make_plot_window(xgobidata *);
extern void make_plotwindow_mouse_labels(xgobidata *);
extern void make_pp_panel(xgobidata *, Widget);
extern void make_rotate(xgobidata *);
extern void make_scaling(xgobidata *);
extern void make_section_panel(xgobidata *, Widget, Dimension);
extern void make_stdview(xgobidata *, Widget);
extern void make_tour(xgobidata *);
extern void make_varpanel(xgobidata *);
extern void make_widgets(xgobidata *);
extern void make_xyplot(xgobidata *);
extern void map_brush(xgobidata *, Boolean);
extern void map_group_var(xgobidata *);
extern void map_section_panel(Boolean);
extern void map_tour_panel(xgobidata *, Boolean);
extern void map_tour_pp_panel(Boolean);
extern void map_xyplot(Boolean);
extern void matrix_mult(float **, float **, float **, int, int, int);
extern float mean_fn(float *, int, int *);
extern float mean_fn2(float *, float *, int, int *);
extern void min_max(xgobidata *, float **, int *, int, float *, float *);
extern float median_largest_dist(xgobidata *, float **, int *, int, float *, float *);
extern float mean_largest_dist(xgobidata *, float **, int *, int, float *, float *);
extern void move_points_on(xgobidata *);
extern void move_points_proc(xgobidata *);
extern void natural_hermite_deriv(float **, float **, float *, float *, float **, int, int *, int, int *, int, int);
extern float natural_hermite_index(float **, int, int *, int);
extern void nback_update_label(xgobidata *);
extern void new_basis(xgobidata *);
extern void norm(float *, int);
extern void number_length(float, int *);
extern XtEventHandler ob_button(Widget, xgobidata *, XEvent *);
extern void ob_rot_reproject(xgobidata *);
extern void ob_rotate_proc(xgobidata *);
extern XtCallbackProc open_exclusion_popup_cback(Widget, xgobidata *, XtPointer);
extern XtCallbackProc open_tform_popup_cback(Widget, xgobidata *, XtPointer);
extern XtCallbackProc open_sphere_popup_cback(Widget, xgobidata *, XtPointer);
extern XtCallbackProc open_extend_xgobi_popup_cback(Widget, xgobidata *, XtPointer);
extern XtCallbackProc open_import_xgobi_popup_cback(Widget, xgobidata *, XtPointer);
extern XtCallbackProc open_imputation_popup_cback(Widget, xgobidata *, XtPointer);
extern XtCallbackProc open_jitter_popup_cback(Widget, xgobidata *, XtPointer);
extern XtCallbackProc open_infer_popup_cback(Widget, xgobidata *, XtPointer);
extern XtCallbackProc open_new_xgobi_popup_cback(Widget, xgobidata *, XtPointer);
extern XtCallbackProc open_smooth_popup_cback(Widget, xgobidata *, XtPointer);
extern XtConvertSelectionProc pack_brush_data(Widget, Atom *, Atom *, Atom *, XtPointer *, unsigned long *, int *);
extern XtConvertSelectionProc pack_erase_data(Widget, Atom *, Atom *, Atom *, XtPointer *, unsigned long *, int *);
extern XtSelectionCallbackProc unpack_erase_data(Widget, XtPointer,
X  Atom *, Atom *, XtPointer, unsigned long *, int *);
extern XtSelectionDoneProc pack_brush_done(Widget, Atom *, Atom *);
extern XtSelectionDoneProc pack_erase_done(Widget, Atom *, Atom *);
extern XtLoseSelectionProc pack_brush_lose(Widget, Atom *, XtPointer);
extern XtLoseSelectionProc pack_erase_lose(Widget, Atom *, XtPointer);
extern XtConvertSelectionProc pack_ids(Widget, Atom *, Atom *, Atom *, XtPointer *, unsigned long *, int *);
extern XtSelectionDoneProc pack_ids_done(Widget, Atom *, Atom *);
extern XtLoseSelectionProc pack_ids_lose(Widget, Atom *, XtPointer);
extern XtConvertSelectionProc pack_line_brush_data(Widget, Atom *, Atom *, Atom *, XtPointer *, unsigned long *, int *);
extern XtSelectionDoneProc pack_line_brush_done(Widget, Atom *, Atom *);
extern XtLoseSelectionProc pack_line_brush_lose(Widget, Atom *, XtPointer);
extern XtConvertSelectionProc pack_rowsinplot_data(Widget, Atom *, Atom *, Atom *, XtPointer *, unsigned long *, int *);
extern void passive_update_cprof_plot(xgobidata *);
extern XtCallbackProc pc_axes_cback(Widget, xgobidata *, XtPointer);/* interactive gt*/
extern void plane_to_screen(xgobidata *);
extern void plot_bins(xgobidata *);
extern void plot_nearest_id(xgobidata *, Drawable);
extern void plot_once(xgobidata *);
extern void possibly_draw_bandwidth(xgobidata *);
extern void pp_dir(xgobidata *);
extern void pp_index(xgobidata *, int, int);
extern float pp_index_retval(xgobidata *);
extern void princ_angs(xgobidata *);
extern XtCallbackProc princ_comp_cback(Widget, xgobidata *, XtPointer);
extern void princ_dirs(xgobidata *);
extern XtCallbackProc print_panel_cback(Widget, xgobidata *, XtPointer);
extern void quickplot_once(xgobidata *);
extern void read_array(xgobidata *);
extern void read_bm_filename(Widget, xgobidata *);
extern Boolean read_collabels(char *, Boolean, xgobidata *);
extern Boolean read_connecting_lines(char *, Boolean, xgobidata *);
extern Boolean read_erase(char *, Boolean, xgobidata *);
extern int read_extra_resources(char *);
extern void read_ids(xgobidata *);
extern void read_imputation_data(xgobidata *);
extern void read_imputation_names(xgobidata *);
extern Boolean read_jitter_values(char *, Boolean, xgobidata *);
extern Boolean read_line_colors(char *, Boolean, Boolean, xgobidata *);
extern void read_line_paint(xgobidata *);
extern Boolean read_nlinkable(char *, Boolean, xgobidata *);
extern void read_paint(xgobidata *);
extern void read_erase_sent(xgobidata *);
extern Boolean read_point_colors(char *, Boolean, Boolean, xgobidata *);
extern Boolean read_point_glyphs(char *, Boolean, Boolean, xgobidata *);
extern Boolean read_rowlabels(char *, Boolean, xgobidata *);
extern void read_rows_in_plot(xgobidata *);
extern void read_tour_coefs(xgobidata *);
extern Boolean read_vgroups(char *, Boolean, xgobidata *);
extern void realloc_lines(xgobidata *);
extern void realloc_tform(xgobidata *);
extern void recalc_vc(int, xgobidata *);
extern void refresh_all_var_labels(xgobidata *);
extern void refresh_vbox(xgobidata *, int, int);
extern void refresh_vboxes(xgobidata *);
extern void refresh_vlab(int, xgobidata *);
extern void reinit_brush_colors(xgobidata *);
extern void reinit_corr(xgobidata *);
extern void reinit_nsteps(void);
extern void reinit_spin(xgobidata *);
extern void reinit_tour(xgobidata *);
extern void reinit_tour_hist(xgobidata *);
extern void reinit_transient_brushing(xgobidata *);
extern void reset_3d_cmds(xgobidata *);
extern void reset_backtrack_cmd(Boolean, Boolean, Boolean, Boolean);
extern void reset_br_types(xgobidata *);
extern XtCallbackProc reset_brush_cback(Widget, xgobidata *, XtPointer);
extern void reset_corr_pursuit_cmd(xgobidata *, Boolean);
extern void reset_corr_pause_cmd(xgobidata *);
extern void reset_cp_plot(void);
extern void reset_cycleback_cmd(Boolean, Boolean, char *);
extern XtCallbackProc reset_glyphs_cback(Widget, xgobidata *, XtPointer);
extern void reset_interp_cmd(int);
extern void reset_interp_proc(void);
extern void reset_last_touched(xgobidata *);
extern XtCallbackProc reset_line_colors_cback(Widget, xgobidata *, XtPointer);
extern void reset_nvars_cprof_plot(xgobidata *);
extern void reset_one_label(xgobidata *, int, int);
extern void reset_spin_pause_cmd(xgobidata *);
extern void reset_tour_pause_cmd(xgobidata *);
extern XtCallbackProc reset_point_colors_cback(Widget, xgobidata *, XtPointer);
extern void reset_pp_plot(void);
extern void reset_princ_comp(Boolean, xgobidata *);
extern void reset_rows_in_plot(xgobidata *, Boolean);
extern void reset_tour_cont_fact_menu(xgobidata *);/* interactive gt*/
extern void reset_tour_link_menu(xgobidata *);
extern void reset_tourhist_cmds(xgobidata *, int);
extern void reset_var_labels(xgobidata *, int);
extern void reset_var_panel(xgobidata *);
extern XtEventHandler resize_cback(Widget, xgobidata *, XEvent *, Boolean *);
extern void retrieve_basis(xgobidata *);
extern void rock_proc(xgobidata *);
extern void rotate_on(xgobidata *);
extern int save_collabels(char *, int *, int, int, xgobidata *);
extern Boolean save_missing(char *, int *, int, int *, int, xgobidata *);
extern int save_resources(char *, xgobidata *);
extern int save_rowlabels(char *, int *, int, xgobidata *);
extern XtEventHandler scale_button_event(Widget, xgobidata *, XEvent *);
extern void scale_proc(xgobidata *);
extern void scaling_on(xgobidata *);
extern void scaling_proc(xgobidata *);
extern void set_br_linkopt_menu_marks(xgobidata *);
extern void set_br_opt_menu_marks(xgobidata *);
extern void set_bt_firsttime(void);
extern void set_counting_to_stop(int);
extern int set_deci(float);
/*extern void set_deletion(Boolean);*/
extern void set_display_menu_marks(xgobidata *);
extern void set_fac_and_offsets(float, float, float, float *, float *, float *);
extern void set_fading_var(int);
extern void set_id_linkopt_menu_marks(xgobidata *);
extern void set_local_scan_dir_in(xgobidata *);
extern void set_manip_var(xgobidata *, int);/* interactive gt*/
extern void set_tourvar(xgobidata *, int);/* interactive gt*/
extern void set_xcorrvar(xgobidata *, int);/* interactive gt*/
extern void set_ycorrvar(xgobidata *, int);/* interactive gt*/
extern void set_cmanip_var(xgobidata *, unsigned int, int);/* interactive gt*/
extern void set_cxfrozen_var(xgobidata *, int);/* interactive gt*/
extern void set_cyfrozen_var(xgobidata *, int);/* interactive gt*/
extern void set_mono(Widget w);
extern void set_ready_to_stop_now(Boolean);
extern void set_sens_go(Boolean);
extern void set_sens_interp(Boolean);
extern void set_sens_io(xgobidata *, int, int, int);
extern void set_sens_link_menu(int);
extern void set_sens_localscan(Boolean);
extern void set_sens_optimz(int);
extern void set_sens_pp_btn(xgobidata *xg, int);
extern void set_sens_princ_comp(xgobidata *xg, int);
extern void set_sens_reinit(Boolean);
extern void set_sens_speed(Boolean);
extern void set_sens_step(Boolean);
extern void set_sens_tour_update(int);
extern void set_shift_wrld0(xgobidata *);
extern void set_showarrows_option(Boolean, xgobidata *);
extern void set_showlines(Boolean);
extern void set_showlines_option(Boolean, xgobidata *);
extern XtEventHandler set_sticky(Widget, xgobidata *, XEvent *);
extern void set_title_and_icon(char *, xgobidata *);
extern void set_sph_labs(xgobidata *xg, int);
extern void restore_sph_labs(xgobidata *xg);
extern void set_sph_tform_tp(xgobidata *);
extern XtCallbackProc set_tour_cont_fact_cback(Widget, xgobidata *, XtPointer);/* interactive gt*/
extern XtCallbackProc set_tour_link_state_cback(Widget, xgobidata *, XtPointer);
extern XtCallbackProc set_tour_manip_type_cback(Widget, xgobidata *, XtPointer);/* interactive gt*/
extern void set_tour_section_eps(float, xgobidata *, int);
extern void set_varpanel_for_receive_tour(xgobidata *);
extern void set_varsel_label(xgobidata *);
extern void set_wm_protocols(Widget);
extern void shift_proc(xgobidata *);
extern void show_message(String, xgobidata *);
extern XtCallbackProc showlines_cback(Widget, XtPointer, XtPointer);
extern XtCallbackProc showpoints_cback(Widget, XtPointer, XtPointer);
extern void skewness_deriv(float **, float **, float *, float *, float **, int, int *, int, int, int *);
extern float skewness_index(float **, int, int *);
extern XtCallbackProc smooth_cback(Widget, XtPointer, XtPointer);
extern void span_planes(xgobidata *);
extern void spherize_data(xgobidata *, int, int, int *);
extern XtCallbackProc spin_place_read_rmat_popup(Widget, xgobidata *, XtPointer);
extern XtCallbackProc spin_place_save_coefs_popup(Widget, xgobidata *, XtPointer);
extern XtCallbackProc spin_place_save_rmat_popup(Widget, xgobidata *, XtPointer);
extern void spin_proc(xgobidata *);
extern void spin_var_lines(xgobidata *);
extern int spin_varselect(int, int, int, xgobidata *) ;
extern float sq_inner_prod(float *, float *, int);
extern void start_corr_proc(xgobidata *);
extern void start_spin_proc(xgobidata *);
extern void start_tour_proc(xgobidata *);
extern void stop_spin_proc(xgobidata *);
extern void stop_tour_proc(xgobidata *);
extern void store_Rmat(xgobidata *);
extern void store_basis(xgobidata *, float **);
extern void strip_blanks(char *);
extern XtCallbackProc subset_panel_cback(Widget, xgobidata *, XtPointer);
extern void textur(float *, float *, int, int, float, int);
extern XtCallbackProc tour_backtrack_cback(Widget, xgobidata *, XtPointer);
extern XtCallbackProc tour_cycleback_cback(Widget, xgobidata *, XtPointer);
extern void tour_event_handlers(xgobidata *, Boolean);
extern XtCallbackProc tour_local_cback(Widget, xgobidata *, XtPointer);
extern Boolean tour_on(xgobidata *);
extern XtCallbackProc tour_pause_cback(Widget, xgobidata *, XtPointer);
extern XtCallbackProc tour_pp_cback(Widget, xgobidata *, XtPointer);
extern void tour_proc(xgobidata *);
extern void tour_read_hist(Widget, xgobidata *);
extern XtCallbackProc tour_reinit_cback(Widget, xgobidata *, XtPointer);
extern void tour_save_coefs(Widget, xgobidata *);
extern void tour_save_hist(Widget, xgobidata *);
extern void tour_section_calcs(xgobidata *, int);
extern XtCallbackProc tour_section_cback(Widget, xgobidata *, XtPointer);
extern XtCallbackProc tour_speed_cback(Widget, xgobidata *, XtPointer);
extern XtCallbackProc tour_step_cback(Widget, xgobidata *, XtPointer);
extern XtCallbackProc tour_step_go_cback(Widget, xgobidata *, XtPointer);
extern XtCallbackProc tour_storbas_cback(Widget, xgobidata *, XtPointer);
extern XtCallbackProc tour_update_cback(Widget, xgobidata *, XtPointer);
extern void tour_var_lines(xgobidata *);
extern int tour_varselect(int, int, xgobidata *);
extern XtCallbackProc tourhist_on_cback(Widget, xgobidata *, XtPointer);
extern void turn_off_cprof_plotting(xgobidata *);
extern void turn_off_local_scan(xgobidata *);
extern void turn_off_optimz(xgobidata *);
extern void turn_off_pc(xgobidata *);
extern void turn_off_pp(xgobidata *);
extern void turn_off_section_tour(xgobidata *);
extern void turn_off_stepping(void);
extern void turn_on_showlines_option(xgobidata *);
extern void turn_on_xyplotting(xgobidata *);
extern int under_brush(xgobidata *, int);
extern void update_cprof_plot(xgobidata *xg);
extern void update_cprof_selectedvars(xgobidata *);
extern void update_lims(xgobidata *);
extern void update_list_selection(xgobidata *, int, Boolean);
extern void update_sphered(xgobidata *xg, int *, int);
extern void update_sticky_ids(xgobidata *);
extern int update_vc_active_and_do_svd(xgobidata *,int , int *);
extern void update_world(xgobidata *);
extern XtEventHandler varexpose(Widget, xgobidata *, XEvent *, Boolean *);
extern void varlist_add_group_var(xgobidata *);
extern XtEventHandler varselect(Widget, xgobidata *, XEvent *, Boolean *);
extern void world_to_plane(xgobidata *);
extern int write_ascii_data(char *, int *, int, int *, int, int, int, xgobidata *);
extern int write_binary_data(char *, int *, int, int *, int, int, xgobidata *);
extern int xed_by_brush(xgobidata *, int, int);
extern void xfer_brushinfo(xgobidata *);
extern void xy_cycle_proc(xgobidata *);
extern void xy_reproject(xgobidata *);
extern Boolean xy_varselect(int, int, int, xgobidata *);
extern void zero_ab(xgobidata *xg);
extern void zero_corr_taus(void);
extern void zero_princ_angles(xgobidata *xg);
extern void zero_tau(xgobidata *xg);
extern void zero_tinc(xgobidata *);
extern void plot1d_on(xgobidata *);
extern void xyplot_on(xgobidata *);
extern void get_planar_range(xgobidata *, long *, long *, long *, long *);
extern void alloc_corr_index(xgobidata *);
extern void free_corr_index(xgobidata *);
extern void get_corr_index(xgobidata *, float *, float *, float *);
extern XtCallbackProc corr_pursuit_cback(Widget, xgobidata *, XtPointer);
extern void make_cp_plot(xgobidata *, Widget);
extern void make_cp_panel(xgobidata *, Widget);
extern void reset_corr_sphere_cmd(xgobidata *, Boolean);
extern void set_sens_corr_reinit_cmd(xgobidata *, Boolean);
extern void cp_dir(xgobidata *);
extern void stop_corr_proc(xgobidata *);
extern void init_corr_basis(xgobidata *);
extern void read_missing_values(xgobidata *);
extern void strip_suffixes(xgobidata *);
extern Boolean read_rgroups(char *, Boolean, xgobidata *);
extern void set_lgroups(Boolean, xgobidata *);
extern void jitter_data(xgobidata *);
extern void init_jitfac(xgobidata *);
extern int sample_xgobi(int, xgobidata *);
extern int plot_too_big(xgobidata *);
extern int brush_save_colors(char *, int *, int, xgobidata *);
extern int brush_save_glyphs(char *, int *, int, xgobidata *);
extern int brush_save_erase(char *, int *, int, xgobidata *);
extern int save_lines(char *, int *, int, xgobidata *);
extern int save_line_colors(char *, int *, int, xgobidata *);
extern void Clone_XGobi(void);
extern void Clone_XGobi_Scatmat(void);
extern void spin_save_coefs(Widget, xgobidata *);
extern void spin_save_rmat(Widget, xgobidata *);
extern void generate_ticks(int, int, lims *, tickinfo *, xgobidata *);
extern void spin_read_rmat(Widget, xgobidata *);
extern int derivs_equal_zero(xgobidata *);
extern void zero_indx_prev(void);
extern float mean_fn4(float *, float *, float *, float *, int, int *);
extern int find_selected_cols(xgobidata *xg, int *cols);
extern int numvargroups(xgobidata *);
extern void add_vgroups(xgobidata *, int *, int *);
extern void jitter_one_value(int, int, xgobidata *);
extern void set_sens_missing_menu_btns(Boolean);
extern void reset_tform(xgobidata *);
extern Boolean reread_dat(char *, xgobidata *);
extern void read_new_data(Widget w, xgobidata *xg);
extern int find_pgsize(int, int);
extern int make_xgobi(Boolean, char *, float **, char *, Boolean, short **, Boolean, int, int, char **, int, char **, int, connect_lines *, xgobidata *, Widget, Boolean plot_p);
extern void set_sens_direction(Boolean);
extern FILE *open_file(char *, char *, char *);
extern FILE *open_xgobi_file(char *, int, char **, char *, Boolean);
X
extern void read_binary(FILE *, xgobidata *);
extern Boolean find_data_start(FILE *);
extern void print_cprof_win(xgobidata *, FILE *, float, float, float, float, float, XColor *, XColor *, unsigned int);
extern void print_pp_win(xgobidata *, FILE *, float, float, float, float, float, XColor *);
X
/* juergen */
extern void set_brush_menu_cmd(Boolean);
extern void reset_io_line_read_menu_cmd(xgobidata *);
extern void set_Edit_Lines_cmd(xgobidata *, Boolean);
X
#ifdef XPLORE
extern XtCallbackProc start_xplore_cback(Widget, xgobidata *, XtPointer);
extern XtCallbackProc stop_xplore_cback(Widget, xgobidata *, XtPointer);
extern XtCallbackProc pass_data_xplore_cback(Widget, xgobidata *, XtPointer);
extern XtCallbackProc pass_projection_xplore_cback(Widget, xgobidata *, XtPointer);
#endif
X
extern void gen_unif_variates(int, int, float *, float); /* jitter */
X
/* inna & sigbert */
extern void median_smoother(long *, long *, int, long *, int, unsigned long *,
X  int *, int);
extern void mean_smoother(long *, long *, int, long *, int, unsigned long *,
X  int *, int);
extern void nadaraya_watson_smoother(long *, long *, int, long *, int,
X  unsigned long *, int *);
extern void spline_smoother(long *, long *, int, long *, int, unsigned long *,
X  int *);
extern void smooth_data(xgobidata *);
extern void init_smooth_vars(xgobidata *);
X
/* frozen variables */
extern int add_variable(xgobidata *, int);
extern void remove_variable(xgobidata *, int);
extern Boolean var_frozen(xgobidata *, int);
extern void draw_frozen_var(xgobidata *);
extern void set_frozen_var(xgobidata *, int);
extern void draw_cfrozen_var(xgobidata *);
extern void set_cxfrozen_var(xgobidata *, int);
extern void set_cyfrozen_var(xgobidata *, int);
extern void add_xvariable(xgobidata *, int);
extern void remove_xvariable(xgobidata *, int, int);
extern void copy_vector(float *, float *, int);
X
SHAR_EOF
  chmod 0644 'xgobi/src/xgobiexterns.h' ||
  $echo 'restore of' 'xgobi/src/xgobiexterns.h' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/xgobiexterns.h:' 'MD5 check failed'
c24c47a79451e39d291f13b85a83eb41  xgobi/src/xgobiexterns.h
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/xgobiexterns.h'`"
    test 33621 -eq "$shar_count" ||
    $echo 'xgobi/src/xgobiexterns.h:' 'original size' '33621,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/xgobi_init.c ==============
if test -f 'xgobi/src/xgobi_init.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/xgobi_init.c' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/xgobi_init.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/xgobi_init.c' &&
/* xgobi_init.c */
/************************************************************
X *                                                          *
X *  Permission is hereby granted  to  any  individual   or  *
X *  institution   for  use,  copying, or redistribution of  *
X *  the xgobi code and associated documentation,  provided  *
X *  that   such  code  and documentation are not sold  for  *
X *  profit and the  following copyright notice is retained  *
X *  in the code and documentation:                          *
X *        Copyright (c) 1990, ..., 1996 Bellcore            *
X *                                                          *
X *  We welcome your questions and comments, and request     *
X *  that you share any modifications with us.               *
X *                                                          *
X *    Deborah F. Swayne            Dianne Cook              *
X *   dfs@research.att.com       dicook@iastate.edu          *
X *      (973) 360-8423    www.public.iastate.edu/~dicook/   *
X *                                                          *
X *                    Andreas Buja                          *
X *                andreas@research.att.com                  *
X *              www.research.att.com/~andreas/              *
X *                                                          *
X ************************************************************/
X
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
X
#include "xincludes.h"
#include "xgobitypes.h"
#include "xgobivars.h"
#include "xgobiexterns.h"
#include <X11/bitmaps/target>
X
static XtResource resources[] = {
/* Monochrome defaults */
X  {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
X  XtOffset(AppDataPtr, fg), XtRString, "Black"},
X  {XtNbackground, XtCBackground, XtRPixel, sizeof(Pixel),
X  XtOffset(AppDataPtr, bg), XtRString, "White"},
X  {XtNborderColor, XtCBorderColor, XtRPixel, sizeof(Pixel),
X  XtOffset(AppDataPtr, border), XtRString, "Black"},
X
X  {"axisColor", "AxisColor", XtRString, sizeof(String),
X  XtOffset(AppDataPtr, axisColor), XtRString, "White"},
X
/* Font for labels and buttons */
X  {"font", "Font", XtRFontStruct, sizeof(XFontStruct *),
X  XtOffset(AppDataPtr, font), XtRString,
X    "-*-helvetica-bold-r-*-*-14-*-*-*-*-*-*-*"},
/* Font for PlotWindow */
X  {"plotFont", "PlotFont", XtRFontStruct, sizeof(XFontStruct *),
X  XtOffset(AppDataPtr, plotFont), XtRString,
X    "-*-helvetica-medium-r-*-*-17-*-*-*-*-*-*-*"},
/* Help font */
X  {"helpFont", "HelpFont", XtRFontStruct, sizeof (XFontStruct *),
X  XtOffset(AppDataPtr, helpFont), XtRString,
X    "-*-helvetica-medium-r-*-*-17-*-*-*-*-*-*-*"},
/* Brushing color defaults */
X  {"brushColor0", "BrushColor0", XtRString, sizeof(String),
X  XtOffset(AppDataPtr, brushColor0), XtRString, "Red"},
X  {"brushColor1", "BrushColor1", XtRString, sizeof(String),
X  XtOffset(AppDataPtr, brushColor1), XtRString, "Orange"},
X  {"brushColor2", "BrushColor2", XtRString, sizeof(String),
X  XtOffset(AppDataPtr, brushColor2), XtRString, "Yellow"},
X  {"brushColor3", "BrushColor3", XtRString, sizeof(String),
X  XtOffset(AppDataPtr, brushColor3), XtRString, "SkyBlue"},
X  {"brushColor4", "BrushColor4", XtRString, sizeof(String),
X  XtOffset(AppDataPtr, brushColor4), XtRString, "Blue"},
X  {"brushColor5", "BrushColor5", XtRString, sizeof(String),
X  XtOffset(AppDataPtr, brushColor5), XtRString, "PaleGreen"},
X  {"brushColor6", "BrushColor6", XtRString, sizeof(String),
X  XtOffset(AppDataPtr, brushColor6), XtRString, "Green"},
X  {"brushColor7", "BrushColor7", XtRString, sizeof(String),
X  XtOffset(AppDataPtr, brushColor7), XtRString, "Maroon"},
X  {"brushColor8", "BrushColor8", XtRString, sizeof(String),
X  XtOffset(AppDataPtr, brushColor8), XtRString, "Orchid"},
X  {"brushColor9", "BrushColor9", XtRString, sizeof(String),
X  XtOffset(AppDataPtr, brushColor9), XtRString, "Peru"},
/* Should axes, points, lines be drawn on startup? */
X  {"showAxes", "ShowAxes", XtRBoolean, sizeof(Boolean),
X  XtOffset(AppDataPtr, showAxes), XtRString, "True"},
X  {"showPoints", "ShowPoints", XtRBoolean, sizeof(Boolean),
X  XtOffset(AppDataPtr, showPoints), XtRString, "True"},
X  {"showLines", "ShowLines", XtRBoolean, sizeof(Boolean),
X  XtOffset(AppDataPtr, showLines), XtRString, "True"},
/* Linking options */
/*
X  {"linkBrush", "LinkBrush", XtRBoolean, sizeof(Boolean),
X  XtOffset(AppDataPtr, linkBrush), XtRString, "True"},
*/
X  {"linkGlyphBrush", "LinkGlyphBrush", XtRBoolean, sizeof(Boolean),
X  XtOffset(AppDataPtr, linkGlyphBrush), XtRString, "True"},
X  {"linkColorBrush", "LinkColorBrush", XtRBoolean, sizeof(Boolean),
X  XtOffset(AppDataPtr, linkColorBrush), XtRString, "True"},
X  {"linkEraseBrush", "LinkEraseBrush", XtRBoolean, sizeof(Boolean),
X  XtOffset(AppDataPtr, linkEraseBrush), XtRString, "True"},
X
X  {"linkLineBrush", "LinkLineBrush", XtRBoolean, sizeof(Boolean),
X  XtOffset(AppDataPtr, linkLineBrush), XtRString, "True"},
X  {"linkIdentify", "LinkIdentify", XtRBoolean, sizeof(Boolean),
X  XtOffset(AppDataPtr, linkIdentify), XtRString, "True"},
/* Brushing options */
X  {"jumpBrush", "JumpBrush", XtRBoolean, sizeof(Boolean),
X  XtOffset(AppDataPtr, jumpBrush), XtRString, "True"},
X  {"reshapeBrush", "ReshapeBrush", XtRBoolean, sizeof(Boolean),
X  XtOffset(AppDataPtr, reshapeBrush), XtRString, "False"},
X  {"syncBrush", "SyncBrush", XtRBoolean, sizeof(Boolean),
X  XtOffset(AppDataPtr, syncBrush), XtRString, "True"},
X  {"carryVars", "CarryVars", XtRBoolean, sizeof(Boolean),
X  XtOffset(AppDataPtr, carryVars), XtRString, "False"},
/* Scaling: start with plot square or not? */
X  {"plotSquare", "PlotSquare", XtRBoolean, sizeof(Boolean),
X  XtOffset(AppDataPtr, plotSquare), XtRString, "True"},
X
/* Starting glyph type and size */
X  {"glyphType", "GlyphType", XtRInt, sizeof(int),
X  XtOffset(AppDataPtr, glyphType), XtRString, "1"},
X  {"glyphSize", "GlyphSize", XtRInt, sizeof(int),
X  XtOffset(AppDataPtr, glyphSize), XtRString, "1"},   /* TINY */
X
/* Starting glyph and color */
X  {"defaultGlyph", "DefaultGlyph", XtRInt, sizeof(int),
X  XtOffset(AppDataPtr, defaultGlyph), XtRString, "26"},
X  {"defaultColor", "DefaultColor", XtRString, sizeof(String),
X  XtOffset(AppDataPtr, defaultColor), XtRString, "white"},
X  {"axisColor", "AxisColor", XtRString, sizeof(String),
X  XtOffset(AppDataPtr, axisColor), XtRString, "LightGray"},
X
/* pointer color */
X  {"pointerColor", "PointerColor", XtRString, sizeof(String),
X  XtOffset(AppDataPtr, pointerColor), XtRString, "Red"},
/* name of postscript printer */
X  {"defaultPrintCmd", "DefaultPrintCmd", XtRString, sizeof(String),
X  XtOffset(AppDataPtr, defaultPrintCmd), XtRString, "/usr/ucb/lpr -Pps1"},
/* clone information; users shouldn't set these in resource files */
X  {"isCloned", "IsCloned", XtRBoolean, sizeof(Boolean),
X  XtOffset(AppDataPtr, isCloned), XtRString, "False"},
X  {"clonePID", "ClonePID", XtRInt, sizeof(int),
X  XtOffset(AppDataPtr, clonePID), XtRString, "0"},
X  {"cloneTime", "CloneTime", XtRInt, sizeof(int),
X  XtOffset(AppDataPtr, cloneTime), XtRString, "0"},
X  {"cloneType", "CloneType", XtRInt, sizeof(int),
X  XtOffset(AppDataPtr, cloneType), XtRString, "0"},
X  {"cloneName", "CloneName", XtRString, sizeof(String),
X  XtOffset(AppDataPtr, cloneName), XtRString, "XGobi"},
X  {"deleteCloneData", "DeleteCloneData", XtRBoolean, sizeof(Boolean),
X  XtOffset(AppDataPtr, deleteCloneData), XtRString, "False"},
};
X
Boolean
RunWorkProc(xgobidata *xg)
/*
X * If there is a work proc attached to this xgobi, run it.
*/
{
X  Boolean run_work_proc = False;
X
X  if (xg->is_identify)
X  {
X    id_proc(xg);
X    run_work_proc = True;
X  }
X  else if (xg->is_line_editing)
X  {
X    line_edit_proc(xg);
X    run_work_proc = True;
X  }
X  else if (xg->is_point_moving)
X  {
X    move_points_proc(xg);
X    run_work_proc = True;
X  }
X  else if (xg->is_scaling)
X  {
X    if (xg->run_scale_proc)
X      scale_proc(xg);
X    if (xg->run_shift_proc)
X      shift_proc(xg);
X    scaling_proc(xg);
X    run_work_proc = True;
X  }
X  else if (xg->run_tour_proc)
X  {
X    tour_proc(xg);
X    run_work_proc = True;
X  }
X  else if (xg->run_corr_proc)
X  {
X    corr_proc(xg);
X    run_work_proc = True;
X  }
X  else if (xg->run_spin_oblique_proc)
X  {
X    ob_rotate_proc(xg);
X    run_work_proc = True;
X  }
X  else if (xg->run_spin_axis_proc)
X  {
X    spin_proc(xg);
X    run_work_proc = True;
X  }
X  else if (xg->run_rock_proc)
X  {
X    rock_proc(xg);
X    run_work_proc = True;
X  }
X  else if (xg->run_interp_proc)
X  {
X    interp_proc(xg);
X    run_work_proc = True;
X  }
X  else if (xg->is_xyplotting)
X  {
X    if (xg->is_xy_cycle)
X    {
X      xy_cycle_proc(xg);
X      run_work_proc = True;
X    }
X  }
X  else if (xg->is_plot1d_cycle)
X  {
X    plot1d_cycle_proc(xg);
X    run_work_proc = True;
X  }
X
X  return(run_work_proc);
}
X
int
find_mono()
{
X  Visual *vis;
X  int scrn, mono;
X  /*
X   * Determine whether this is a monochrome display -- treat
X   * grayscale machines as monochrome for now.
X  */
X  scrn = DefaultScreen(display);
X  depth = DefaultDepth(display, scrn);
X  vis = DefaultVisual(display, scrn);
X  if (depth == 1)
X    mono = 1;
X  else if (vis->class == GrayScale || vis->class == StaticGray)
X    mono = 1;
X  else
X    mono = 0;
X
X  return(mono);
}
X
void
set_wm_protocols(Widget w)
/*
X * to make xgobi work with the motif title bar menu
*/
{
X  Atom wm_delete_window;
X
X  XtOverrideTranslations(w,
X    XtParseTranslationTable("<Message>WM_PROTOCOLS: wm_quit()"));
X
X  wm_delete_window = XInternAtom(display, "WM_DELETE_WINDOW", False);
X  (void) XSetWMProtocols(display, XtWindow(w),
X     &wm_delete_window, 1);
}
X
static void
init_atoms() {
X
X  /*
X   * Initialize Atoms used to pass xg->rows_in_plot
X  */
X  XG_ROWSINPLOT_ANNC = XInternAtom(display, "Announce Rows in Plot", 0);
X  XG_ROWSINPLOT_ANNC_TYPE = XInternAtom(display,
X    "Announce Rows in Plot Type", 0);
X  XG_ROWSINPLOT = XInternAtom(display, "Rows in Plot", 0);
X  XG_ROWSINPLOT_TYPE = XInternAtom(display, "Rows in Plot Type", 0);
X
X  /*
X   * Initialize Atoms used to pass xg->erased
X  */
X  XG_ERASE_ANNC = XInternAtom(display, "Announce Erase", 0);
X  XG_ERASE_ANNC_TYPE = XInternAtom(display, "Announce Erase Type", 0);
X  XG_ERASE = XInternAtom(display, "Erase", 0);
X  XG_ERASE_TYPE = XInternAtom(display, "Erase Type", 0);
X
X  /*
X   * Initialize Atoms used in linked glyph and color brushing;
X   * points only.
X  */
X  XG_NEWPAINT_ANNC = XInternAtom(display, "Announce New Paint", 0);
X  XG_NEWPAINT_ANNC_TYPE = XInternAtom(display, "Announce New Paint Type", 0);
X  XG_NEWPAINT = XInternAtom(display, "New Paint", 0);
X  XG_NEWPAINT_TYPE = XInternAtom(display, "New Paint Type", 0);
X
X  /*
X   * Initialize Atoms used in linked line brushing.
X  */
X  XG_NEWLINEPAINT_ANNC = XInternAtom(display, "Announce New Line Paint", 0);
X  XG_NEWLINEPAINT_ANNC_TYPE = XInternAtom(display,
X    "Announce New Line Paint Type", 0);
X  XG_NEWLINEPAINT = XInternAtom(display, "New Line Paint", 0);
X  XG_NEWLINEPAINT_TYPE = XInternAtom(display, "New Line Paint Type", 0);
X
X  /*
X   * Initialize Atoms used in linked identification.
X  */
X  XG_IDS_ANNC = XInternAtom(display, "Announce NearestPoint", 0);
X  XG_IDS_ANNC_TYPE = XInternAtom(display, "Announce NearestPoint Type", 0);
X  XG_IDS = XInternAtom(display, "NearestPoint", 0);
X  XG_IDS_TYPE = XInternAtom(display, "NearestPoint Type", 0);
X
X  /*
X   * Initialize Atoms used in linked touring.
X  */
X  XG_NEWTOUR_ANNC = XInternAtom(display, "Announce New Tour Coefs", 0);
X  XG_NEWTOUR_ANNC_TYPE = XInternAtom(display,
X    "Announce New Tour Coefs Type", 0);
X  XG_NEWTOUR = XInternAtom(display, "New Tour Coefs", 0);
X  XG_NEWTOUR_TYPE = XInternAtom(display, "New Tour Coefs Type", 0);
}
X
static Boolean
get_data_from_parent(char *data_in, float **datap,
X  Boolean missingpflag, short **missingp,
X  Boolean mv_is_missing_values_xgobi, int mv_nmissing, 
X  int nlines, connect_lines *connecting_lines,
X  int nr, char **rowp, int nc, char **colp,
X  Boolean firsttime, xgobidata *xg)
{
X
/*
X * Parent can override previous definitions made in
X *  set_title_and_icon()
X * These set on command line:
X *  nrows, nrows_in_plot, ncols, nlines, raw_data[]
X *  collab[], rowlab[]
X *  connecting_lines[]
X * Where can these come from? Parent must allocate?
X *  collab_tform1[]
X *  collab_tform2[]
X *  nlinkable
X *  vgroup_ids[]
X *  erased[]
X *  delete_erased_pts
X * Parent could handle read_extra_resources() in some other way.
*/
X  int ok = true;
X  int i, j;
X  int ncols_prev;
X
X  if (!firsttime)
X    ncols_prev = xg->ncols;
X
/*
X * Define nrows, ncols
*/
X
X  xg->nrows = nr;
X  if (xg->nrows_in_plot < 2 || xg->nrows_in_plot > nr)
X    xg->nrows_in_plot = nr;
X  if (data_in != NULL)
X    xg->nrows_in_plot = nr;
X
X  xg->ncols = nc;
X  xg->ncols_used = nc-1;
X
X  if (xg->nrows < 1 || xg->ncols_used < 1 || datap == NULL) {
X    (void) fprintf(stderr, "problem with input data\n");
X    ok = false;
X    return(ok);
X  }
X
/*
X * Allocate and copy raw data.  (why not just pass the pointer?)
*/
X
X  xg->raw_data = (float **) XtMalloc ((Cardinal) xg->nrows *
X    sizeof (float *));
X  for (i = 0; i < xg->nrows; i++)
X    xg->raw_data[i] = (float *) XtMalloc ((Cardinal) xg->ncols *
X    sizeof (float));
X
X  for (i = 0; i < xg->nrows; i++)
X    for (j = 0; j < xg->ncols_used; j++)
X      xg->raw_data[i][j] = datap[i][j];
X
/*
X * Deal with missing data
*/
X
X  if (missingpflag) {
X    if (missingp == NULL) {
X      (void) fprintf(stderr,
X        "problem with missing values arrays in input data\n");
X      ok = false;
X      return(ok);
X    }
X    xg->is_missing = (short **) XtMalloc ((Cardinal) xg->nrows *
X      sizeof (short *));
X    for (i = 0; i < xg->nrows; i++)
X      xg->is_missing[i] = (short *) XtMalloc ((Cardinal) xg->ncols *
X      sizeof (short));
X
X    for (i = 0; i < xg->nrows; i++) /* copy missings from missingp */
X      for (j = 0; j < xg->ncols_used; j++)
X        xg->is_missing[i][j] = missingp[i][j];
X
X    xg->missing_values_present = True;
X    xg->is_missing_values_xgobi = False;
X    xg->nmissing = mv_nmissing;
X  }
X  else {
X    xg->missing_values_present = False;
X    xg->is_missing_values_xgobi = mv_is_missing_values_xgobi;
X  }
X
/*
X * Populate extra column
*/
X  fill_extra_column(xg);
X
/*
X * For now, force each column to be its own group.
X * The group ids have to be sorted, and the first one
X * has to be zero.  (numvargroups is awfully stupid)
*/
X  read_vgroups(xg->datafname, True, xg);
X
/* For row groups, I'm going to try just setting the number */
X  xg->nrgroups = 0;
X
/*
X * Assume the links will always be supplied.
*/
X  xg->nlines = nlines;
X  xg->connecting_lines = connecting_lines ;
X
/*
X * Allocate and populate row and column labels
*/
X
/* I probably just broke this -- dfs */
X  alloc_rowlabels(xg);
X  if (rowp)                         /* Copy labels */
X    for (i = 0; i< xg->nrows; i++)
X       strcpy(xg->rowlab[i], rowp[i]);
X  else                              /* Use default row labels */
X    for (i=0; i<xg->nrows; i++)
X      (void) sprintf(xg->rowlab[i], "%d", i+1);
X
X  alloc_collabels(xg);
X  if (colp)
X    for (i = 0; i<xg->ncols_used; i++) {
X       strcpy(xg->collab[i], colp[i]);
X      (void) sprintf(xg->collab_short[i], "V%d", i+1);  /* for now */
X    }
X  else
X    for (i=0; i<xg->ncols; i++) {
X      (void) sprintf(xg->collab[i], "Var %d", i+1);
X      (void) sprintf(xg->collab_short[i], "V%d", i+1);
X    }
X
X  /*
X   * Set the label for the last variable
X  */
X  strcpy(xg->collab[xg->ncols-1], "group");
X
X  /*
X   * Copy collab into the collab_tform arrays
X  */
X  for (j=0; j<xg->ncols; j++) {
X    (void) strcpy(xg->collab_tform1[j], xg->collab[j]);
X    (void) strcpy(xg->collab_tform2[j], xg->collab[j]);
X  }
X
X  if (! firsttime)
X    destroy_varsel_widgets(ncols_prev, xg);
X
X  xg->nlinkable = xg->nrows;
X
X  return ok;
}
X
X
int
make_xgobi(Boolean datapflag, char *data_in, float **datap, char *xgobi_title,
X Boolean missingpflag, short **missingp, Boolean mv_is_missing_values_xgobi,
X int mv_nmissing,
X int nr, char **rowp, int nc, char **colp,
X int nlines, connect_lines *connecting_lines,
X xgobidata *xg, Widget parent, Boolean plotp)
X
/*
X  Boolean datapflag  * calling program supplies pointer to data? *
X  char *data_in      * if datapflag = F; name of data file, or stdin *
X  float **datap      * if datapflag = T; data pointer *
X  char *xgobi_title  * title to use in window manager (optional) *
X
X  Boolean missingpflag  * if datapflag = T; are there missings? *
X  short **missingp      * if missingpflag = T; pointer to missings array *
X  Boolean mv_is_missing_values_xgobi  * if missingpflag = T *
X  int mv_nmissing                     * if missingpflag = T *
X
X  int nr, nc          * if datapflag = T; number of rows and cols *
X  char **rowp, **colp * if datapflag = T; pointers to row and col labels *
X
X  int nlines                        * if datapflag = T *
X  connect_lines *connecting_lines   * if datapflag = T; pointer to lines *
X
X  xgobidata *xg;
X  Widget parent;
*/
{
X  int i;
X  Colormap cmap;
X  XColor cfore, cback, exact;
X  static int firsttime = 1;
X  extern void init_random_seed(void);
X
X  xg->is_realized = False;
X
X  if (firsttime)
X  {
X    /*
X     * Create the shell if it hasn't already been created.
X    */
X    if (parent)
X      xg->shell = XtVaCreatePopupShell("XGobi",
X         topLevelShellWidgetClass, parent,
X         NULL);
X  
X    init_random_seed();  /* before any data values are read */
X    init_atoms();
X
X    /*
X     * Initialize the strings in the save_types[] array.
X    */
X    SAVE_SPIN_COEFS = "spin coefs";
X    SAVE_SPIN_RMAT = "save spin matrix";
X    READ_SPIN_RMAT = "read spin matrix";
X    SAVE_TOUR_COEFS = "tour coefs";
X    SAVE_TOUR_HIST = "tour savehist";
X    READ_POINT_COLORS_GLYPHS = "read brush vec";
X    READ_TOUR_HIST = "tour readhist";
X    OPEN_BITMAP_FILE = "open bitmap file";
X  }
X
X  /*
X   * xg->datafilename is the full file name including path and suffixes
X   * xg->datafname is the name of the data file without any suffixes
X  */
X  if (data_in != NULL) {
X    strcpy(xg->datafilename, data_in);
X    (void) strip_suffixes(xg);
X  }
X  else {
X    xg->datafilename[0] = '\0';
X    xg->datafname[0] = '\0';
X  }
X
X  /*
X   * Read data-specific resource file and merge all resources.
X  */
X  (void) read_extra_resources(xg->datafname);
X
X  if (xgobi_title != NULL) {
X    strcpy(xg->title, xgobi_title);
X    set_title_and_icon(xg->title, xg);
X  } else {
X    if (xg->isCloned)
X      set_title_and_icon(xg->clone_Name, xg);
X    else
X      set_title_and_icon(xg->datafname, xg);
X  }
X
X  /*
X   * Input data:
X   *  If data is being supplied by by a calling program,
X   *  set up xg->nrows and xg->ncols and grab the data:
X   *  either copy it into xg->raw_data or assign it.
X   *  Else, read data from ascii files.
X  */
X  if (parent && datapflag)
X  {
X    get_data_from_parent(data_in, datap,
X      missingpflag, missingp, mv_nmissing, mv_nmissing,
X      nlines, connecting_lines,
X      nr, rowp, nc, colp, firsttime, xg);
X
X    read_erase(xg->datafname, True, xg);
X  }
X  else
X  {
X    /* Initialize missing values variables */
X    xg->nmissing = 0;
X    xg->missing_values_present = False;
X    xg->is_missing_values_xgobi = False;
X    xg->is_missing = (short **) NULL;
X
X    /*
X     * Read input data files
X    */
X
X    if (xg->data_mode == Sprocess)
X      (void) Sread_array(xg); /* it doesn't matter which file name */
X    else if (xg->data_mode == ascii || xg->data_mode == binary) /* if not S */
X    {
X      (void) read_array(xg);
X      /* This should take care of the .bin case as well ... */
X      if (!xg->is_missing_values_xgobi)
X        read_missing_values(xg);
X      fill_extra_column(xg);
X    }
X
X    /*
X     * nrows_in_plot can be preset in xgobi.c; make sure it's sensible.
X    */
X    if (xg->nrows_in_plot < 2 || xg->nrows_in_plot > xg->nrows)
X      xg->nrows_in_plot = xg->nrows;
X
X    (void) read_collabels(xg->datafname, True, xg);
X    (void) read_rowlabels(xg->datafname, True, xg);
X  
X    if (xg->is_missing_values_xgobi || xg->is_scatmat)
X      init_single_vgroup(xg);  /* force all variable into one group */
X    else
X      read_vgroups(xg->datafname, True, xg);
X
X    (void) read_nlinkable(xg->datafname, True, xg);
X    (void) read_erase(xg->datafname, True, xg);
X    read_rgroups(xg->datafname, True, xg);
X
X    if (!xg->is_scatmat) {
X      (void) read_connecting_lines(xg->datafname, True, xg);
X      set_lgroups(True, xg);
X    }
X  }
X
X  xg->last_forward = (int *) XtMalloc((Cardinal) xg->nrows * sizeof(int));
X  for (i=0; i<xg->nrows; i++)
X    xg->last_forward[i] = -1;
X
X  xg->xgobi_is_up = True;
X
X  /*
X   * Get the application foreground and background colors, as well
X   * as the brushing colors.
X   * This needs to be done after read_extra_resources()
X  */
X  if (parent)
X    XtGetApplicationResources(parent, (XtPointer) &appdata, resources,
X      XtNumber(resources), (ArgList) NULL, 0);
X  else
X    XtGetApplicationResources(xg->shell, (XtPointer) &appdata, resources,
X        XtNumber(resources), (ArgList) NULL, 0);
X
X  /*
X   * Force white on black -- this is the easiest way
X   * to get decent pictures for publications.
X  */
X  if (mono) {
X    appdata.fg = BlackPixelOfScreen(DefaultScreenOfDisplay(display));
X    appdata.bg = WhitePixelOfScreen(DefaultScreenOfDisplay(display));
X    appdata.border = appdata.fg;
X    xg->axisColor = appdata.fg;
X  }
X
X  if (!mono)
X    init_brush_colors(&appdata);
X
X  /*
X   * Initialize variables: the sequence of these is important.
X  */
X  alloc_pipeline_arrays(xg);
X  alloc_plot_arrays(xg);
X
X  /*
X   * Set up the widgets and add the callbacks.
X  */
X
X  init_help(xg);
X  make_widgets(xg);
X
X  init_options(xg);
X
X  build_varlist(xg);
X  build_caselist(xg);
X
X  make_arrows(xg);
X
X  init_plot1d_vars(xg);
X  make_plot1d(xg);
X
X  init_xyplot_vars(xg);
X  make_xyplot(xg);
X
X  alloc_rotate_arrays(xg);
X  init_rotate_vars(xg);
X  make_rotate(xg);
X
X  alloc_brush_arrays(xg);
X  init_brush_vars(xg);
X  make_brush(xg);
X
X  init_scale_vars(xg);
X  make_scaling(xg);
X
X  init_identify_vars(xg);
X  make_identify(xg);
X
X  init_parcoords(xg);
X
X  alloc_transform_tp(xg);
X  reset_tform(xg);  /* initialize */
X
X  if (xg->ncols_used > 2)
X  {
X    alloc_tour(xg);
X    init_tour(xg, 1); /* Some lines here have to precede sphered_data_fn() */
X  }
X  make_tour(xg);
X
X  if (xg->ncols_used > 2)
X  {
X    alloc_corr(xg);
X    init_corr(xg);
X  }
X  make_corr(xg);
X
X  alloc_line_edit_arrays(xg);
X  init_line_edit_vars(xg);
X  make_line_editor(xg);
X
X  init_point_moving(xg);
X  make_move_points(xg);
X
X  alloc_smooth_arrays(xg);
X  init_smooth_vars(xg);
X
X  if (xg->nrows_in_plot < xg->nrows)
X    sample_xgobi(xg->nrows_in_plot, xg);
X
X  /* This must be made late, after at least one mouse label */
X  make_plot_window(xg);
X  /* Let's try the mouse labels below the workspace */
X  make_plotwindow_mouse_labels(xg);
X
/*
X * alloc_transform_types(xg);
X * init_transform_types(xg);
*/
X  make_varpanel(xg);
X
X  /*
X   * Put a NULL at the end of the help tables.
X  */
X  add_pb_help(&xg->nhelpids.pb, (Widget) NULL, "");
X  add_menupb_help(&xg->nhelpids.menupb, (Widget) NULL, "");
X  add_sbar_help(&xg->nhelpids.sbar, (Widget) NULL, "");
X
X  if (firsttime)
X    XtRealizeWidget(xg->shell);
X
X  XtInstallAllAccelerators(xg->form0, xg->form0);
X  /*XtInstallAllAccelerators(xg->box2, xg->box2);*/
X
X  if (firsttime)
X  {
X    /*
X     * Get the colors of the plot window and the tour_pp plotting window.
X     * These are needed for setting the GC colors.
X    */
X    XtVaGetValues(xg->pp_plot_wksp,
X      XtNforeground, (Pixel) &tour_pp_colors.fg,
X      XtNbackground, (Pixel) &tour_pp_colors.bg,
X      XtNborderColor, (Pixel) &tour_pp_colors.border,
X      NULL);
X    init_tour_pp_GCs(xg);
X
X    XtVaGetValues(xg->workspace,
X      XtNforeground, (Pixel) &plotcolors.fg,
X      XtNbackground, (Pixel) &plotcolors.bg,
X      XtNborderColor, (Pixel) &plotcolors.border,
X      NULL);
X    init_GCs(xg);
X
X    /*
X     * Define cursors, set their colors.
X    */
X    default_cursor = XCreateFontCursor(display, XC_center_ptr);
X    scale_cursor = XCreateFontCursor(display, XC_fleur);
X    spin_cursor = XCreateFontCursor(display, XC_hand2);
X    /* used in identify and projection pursuit */
X    crosshair_cursor = XCreateFontCursor(display, XC_tcross);
X
X    if (!mono) {
X      cmap = DefaultColormap(display, DefaultScreen(display));
X      if (XParseColor(display, cmap, appdata.pointerColor, &exact))
X        cfore.pixel =
X          XAllocColor(display, cmap, &exact) ? exact.pixel : plotcolors.fg;
X
X      /* Work out the color for axes and gridlines */
X      if (XParseColor(display, cmap, appdata.axisColor, &exact))
X        if (XAllocColor(display, cmap, &exact))
X          xg->axisColor = exact.pixel;
X
X      /*
X       * Test to see whether we've made the pointer invisible,
X       * and if so, assume that to be a mistake.  Make the
X       * pointer the same color as the plotting foreground color.
X      */
X      if (cfore.pixel == plotcolors.bg)
X        cfore.pixel = plotcolors.fg;
X
X      cback.pixel = plotcolors.bg ;
X      XQueryColor(display, cmap, &cfore);
X      XQueryColor(display, cmap, &cback);
X      XRecolorCursor(display, default_cursor, &cfore, &cback);
X      XRecolorCursor(display, spin_cursor, &cfore, &cback);
X      XRecolorCursor(display, scale_cursor, &cfore, &cback);
X      XRecolorCursor(display, crosshair_cursor, &cfore, &cback);
X    }
X
X    menu_mark = XCreateBitmapFromData(display,
X      RootWindowOfScreen(XtScreen(xg->shell)),
X      target_bits, target_width, target_height);
X    /*
X     * Once the menu_mark has been created,
X     * make sure a couple of menus are properly marked.
X    */
X    set_display_menu_marks(xg);
X    set_br_linkopt_menu_marks(xg);
X    set_br_opt_menu_marks(xg);
X    set_id_linkopt_menu_marks(xg);
X
X    reinit_brush_colors(xg);
X  }
X
X  /*
X   * Create the background pixmap and clear it.
X  */
X  XtVaGetValues(xg->workspace,
X    XtNwidth, &xg->plotsize.width,
X    XtNheight, &xg->plotsize.height, NULL);
X
X  xg->plot_window = XtWindow(xg->workspace);
X  xg->pixmap0 = XCreatePixmap(display, xg->plot_window,
X    xg->plotsize.width,
X    xg->plotsize.height,
X    depth);
X  XFillRectangle(display, xg->pixmap0, clear_GC,
X    0, 0, xg->plotsize.width, xg->plotsize.height);
X
/*
X * These are the vars which depend on the plot window having
X * been realized: size, color.
*/
X  init_plotwindow_vars(xg, 1);
X
X  copy_raw_to_tform(xg);
X  if (xg->ncols_used > 2)
X    compute_vc_matrix(xg);
X  update_lims(xg);
X  update_world(xg);
X
/*
X * Reinitialize variable selection panel.
*/
X  if (! firsttime) {
X    set_varsel_label(xg);
X    XSync(display, False);
X    reset_var_panel(xg);
X  }
X
X  /*
X   * The line color arrays are set up in allocate_line_edit_arrays(),
X   * after which we can try to read in the line colors file.
X  */
X  if (xg->nlines > 0) {
X    if (read_line_colors(xg->datafname, True, True, xg) == 0) {
X      init_line_colors(xg);
X    }
X  }
X
X  /*
X   * Mark the default menu selections.
X  */
X  init_brush_menus();
X  init_tour_interp_menu();
X  init_tour_pp_menu();
X
X  /* Draw the current glyph in the glyph workspace on the brush panel */
X  draw_current_glyph(xg);
X
X  if (parent)
X  {
X    XtPopup(xg->shell, XtGrabNone);
X  }
X  XDefineCursor(display, XtWindow(xg->form0), default_cursor);
X  xg->is_realized = True;
X  xg->is_iconified = False;
X
/*
X * This needs to be done after the brush menus are initialized
X * and the brushing arrays are allocated.
*/
X  (void) read_point_colors(xg->datafname, True, True, xg);
X  (void) read_point_glyphs(xg->datafname, True, True, xg);
X
X  if (xg->isCloned)
X  {
X    char command[200];
X
X    xg->xy_vars.x = 0; /* do not swap x & y axis */
X    xg->xy_vars.y = 1;
X
X    strcpy (xg->datafilename, xg->clone_Name);
X
X    if (xg->clone_Type == CDF1) {
X      xg->xy_vars.x = 1; /* swap x & y axis */
X      xg->xy_vars.y = 0;
X    }
X
X    /* disable options not required for cdf mode */
X    if ((xg->clone_Type == CDF1) || (xg->clone_Type == CDFm)) {
X      set_Edit_Lines_cmd (xg, False);
X      set_brush_menu_cmd (False);
X    }
X
X    /* Delete for cloning but not for copying */
X    if (xg->delete_clone_data) {
X      sprintf (command, "rm /tmp/%s_%d_%d.* &", xg->datarootname,
X        xg->clone_PID, xg->clone_Time);
X      system (command);
X    }
X  }
X
X  /*
X   * Just before opening the window, when we know the plot mode etc,
X   * jitter the 0s and 1s for the missing values xgobi.
X  */
X  if (xg->is_missing_values_xgobi) {
X    init_jitfac(xg);
X    jitter_data(xg);
X    update_world(xg);  /* So the jittering takes effect */
X  }
X
X  /*
X   * Scale data to planar and then to screen coordinates.
X  */
X  world_to_plane(xg);
X  plane_to_screen(xg);
X
X  /*
X   * Initialize axes and ticks.
X  */
X  alloc_axis_arrays(xg);
X  init_axes(xg, True);
X  init_ticks(&xg->xy_vars, xg);
X
X  /*
X   * First scatter plot.
X  */
X  if (xg->delete_erased_pts) {
X    for (i=0; i<xg->nrows; i++) xg->excluded[i] = xg->erased[i];
X    update_nrgroups_in_plot(xg);
X    reset_rows_in_plot(xg, True);
X  }
X  if (plotp)
X    plot_once(xg);
X  refresh_vlab(xg->xy_vars.x, xg);
X  refresh_vlab(xg->xy_vars.y, xg);
X
X  if (firsttime)
X    set_wm_protocols(xg->shell);
X
X  firsttime = 0;
X  return(1);
}
X
X
void
GetApplResources (xgobidata *xg)
{
X    XtGetApplicationResources(xg->shell, (XtPointer) &appdata, resources,
X        XtNumber(resources), (ArgList) NULL, 0);
}
X
SHAR_EOF
  chmod 0644 'xgobi/src/xgobi_init.c' ||
  $echo 'restore of' 'xgobi/src/xgobi_init.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/xgobi_init.c:' 'MD5 check failed'
3eb3589e1cfa86331c1ff477f76e89a3  xgobi/src/xgobi_init.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/xgobi_init.c'`"
    test 28944 -eq "$shar_count" ||
    $echo 'xgobi/src/xgobi_init.c:' 'original size' '28944,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/Imakefile ==============
if test -f 'xgobi/src/Imakefile' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/Imakefile' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/Imakefile' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/Imakefile' &&
/**/#
/**/#	This is an Imakefile for the XGobi program.  The only change that
/**/#	might need to be made is for the XGOBID variable.
/**/#
X
/**/# Remove the comment delimeters on the second to next line to
/**/# compile for CORBA.
/**/# Requires some Omegahat code - see README.corba.
/**/#define USE_CORBA 1
X
/**/#  Set XGOBID to the directory containing 
/**/#  the xgobi directories src, help, ps, etc.
X         XGOBID = $(PWD)/..
X
/**/# Use the gnu C compiler
X            CC = gcc
X     CCOPTIONS = -ansi -w
X
/**/# Or use the C compiler on your system, and whatever options it requires.
#             CC = cc
#      CCOPTIONS = -xansi -n32
X
X             LD = 
X     CDEBUGFLAGS = -g
#EXTRA_LDOPTIONS = -static
X
#ifdef USE_CORBA
#include "Makefile.corba"
#endif   /* End of USE_CORBA */
X
X
/**/#
/**/# RPC: Remote Procedure Calls
/**/#
X
/**/# If you plan to use RPC, uncomment this #define
/**/# RPC is the define for any kind of RPC
/* #define RPC */
X
/**/# Special RPCs
/* #define DCE_RPC */
/**/# If you plan to use XPLORE, uncomment this #define
/* #define XPLORE */
X
#ifdef HPArchitecture
X       CCOPTIONS = -Aa -D_HPUX_SOURCE -DXLIB_ILLEGAL_ACCESS 
#endif
X
X LOCAL_LIBRARIES =  XawClientLibs
#ifdef DCE_RPC
X   SYS_LIBRARIES = -lm -ldce -lpthread
#else
X   SYS_LIBRARIES = -lm
#endif
X         DEFINES = -DDEFAULTDIR=\"$(XGOBID)\"
X
JOINTSRC = xgobi_init.c pipeline.c read_array.c \
X	initialize.c widgets.c callbacks.c getfname.c \
X	xyplot.c make_axes.c line_editor.c missing.c  \
X	spin_cbacks.c spin.c scaling.c scale_cbacks.c \
X	identify.c var_panel.c transform.c sphere.c stdize.c inference.c \
X	brush_init.c brush_cbacks.c brush.c paint.c brush_send.c \
X	help.c prt_plotwin.c subset.c vc_lists.c exclusion.c \
X	plot_once.c plot1d.c texture.c ash1d.c move_points.c \
X	show_message.c smooth.c smooth_fns.c smoothsk.c pspline.c \
X	save_data.c new_data.c read_data.c jitter.c parcoords.c utils.c \
X	tour_init.c tour_util.c tour.c tour_cbacks.c tour_send.c gt_ctls.c \
X	tour_pp.c svd.c kernel.c \
X	legendre.c hermite.c natrl_hermite.c de_indices.c \
X	central_mass.c holes.c skewness.c \
X	tour_section.c corr.c corr_index.c corr_pursuit.c corr_util.c \
X	DrawingA.c mt19937-1.c
JOINTOBJ = xgobi_init.o pipeline.o read_array.o \
X	initialize.o widgets.o callbacks.o getfname.o \
X	xyplot.o make_axes.o line_editor.o missing.o  \
X	spin_cbacks.o spin.o scaling.o scale_cbacks.o \
X	identify.o var_panel.o transform.o sphere.o stdize.o inference.o \
X	brush_init.o brush_cbacks.o brush.o paint.o brush_send.o \
X	help.o prt_plotwin.o subset.o vc_lists.o exclusion.o \
X	plot_once.o plot1d.o texture.o ash1d.o move_points.o \
X	show_message.o smooth.o smooth_fns.o smoothsk.o pspline.o \
X	save_data.o new_data.o read_data.o jitter.o parcoords.o utils.o \
X	tour_init.o tour_util.o tour.o tour_cbacks.o tour_send.o gt_ctls.o \
X	tour_pp.o svd.o kernel.o \
X	legendre.o hermite.o natrl_hermite.o de_indices.o \
X	central_mass.o holes.o skewness.o \
X	tour_section.o corr.o corr_index.o corr_pursuit.o corr_util.o \
X	DrawingA.o mt19937-1.o
X
#ifdef RPC
X
#ifdef XPLORE
EXTRA_DEFINES = -DRPC_USED -DXPLORE
RPCSRC = rpc_client.c rpc_functions.c rpc_server_proc.c \
X	rpc_server_svc.c rpc_spatial.c rpc_xgobi.c rpc_xpl.c
RPCOBJ = rpc_client.o rpc_functions.o rpc_server_proc.o \
X	rpc_server_svc.o rpc_spatial.o rpc_xgobi.o rpc_xpl.o
X
#else
#ifdef DCE_RPC
EXTRA_DEFINES = -DDCE_RPC_USED
RPCSRC = rpc_client.c rpc_functions.c rpc_server_proc.c \
X	rpc_server_svc.c rpc_spatial.c rpc_xgobi.c rpc_xpl.c
RPCOBJ = rpc_client.o rpc_functions.o rpc_server_proc.o \
X	rpc_server_svc.o rpc_spatial.o rpc_xgobi.o rpc_xpl.o \
X	rpc_dce_sstub.o rpc_dceclient_cstub.o
X
rpc_dceclient_sstub.o : rpc_dceclient_sstub.c
X	$(CC) -c -o rpc_dceclient_sstub.o rpc_dceclient_sstub.c $(CFLAGS) -I.
X
rpc_dceclient_cstub.o : rpc_dceclient_cstub.c
X	$(CC) -c -o rpc_dceclient_cstub.o rpc_dceclient_cstub.c $(CFLAGS) -I.
X
rpc_dceclient.h rpc_dceclient_cstub.c rpc_dceclient_sstub.c : rpc_dceclient.idl rpc_dceclient.acf
X	idl rpc_dceclient.idl -keep c_source
X
rpc_dce_sstub.o : rpc_dce_sstub.c
X	$(CC) -c -o rpc_dce_sstub.o rpc_dce_sstub.c $(CFLAGS) -I.
X
rpc_dce_cstub.o : rpc_dce_cstub.c
X	$(CC) -c -o rpc_dce_cstub.o rpc_dce_cstub.c $(CFLAGS) -I.
X
rpc_dce.h rpc_dce_cstub.c rpc_dce_sstub.c : rpc_dce.idl rpc_dce.acf
X	idl rpc_dce.idl -keep c_source
X
#else
EXTRA_DEFINES = -DRPC_USED
RPCSRC = rpc_client.c rpc_functions.c rpc_server_proc.c \
X	rpc_server_svc.c rpc_spatial.c rpc_xgobi.c rpc_xpl.c
RPCOBJ = rpc_client.o rpc_functions.o rpc_server_proc.o \
X	rpc_server_svc.o rpc_spatial.o rpc_xgobi.o rpc_xpl.o
#endif
#endif
X
#else
RPCSRC =
RPCOBJ =
#endif
X
XXGOBISRC = xgobi.c $(JOINTSRC) $(RPCSRC) $(CORBASRC)
XXGOBIOBJ = xgobi.o $(JOINTOBJ) $(RPCOBJ) $(CORBAOBJ)
X
XXGVISSRC = xgvis.c xgv_histogram.c xgv_qsort.c xgv_mds.c \
X	xgv_read_data.c xgv_help.c \
X	xgv_stressplot.c xgv_cbacks.c xgv_widgets.c xgv_anchor.c $(JOINTSRC) 
XXGVISOBJ = xgvis.o xgv_histogram.o xgv_qsort.o xgv_mds.o \
X	xgv_read_data.o xgv_help.o \
X	xgv_stressplot.o xgv_cbacks.o xgv_widgets.o xgv_anchor.o $(JOINTOBJ) 
X
all:: xgvis xgobi
X
foo:
X	echo $(USRLIBDIR)
X	echo "$(LDPRELIBS) $(origin LDPRELIBS)"
X
SingleProgramTarget(xgobi, $(XGOBIOBJ), NullParameter, $(CORBA_LIBRARIES) $(LOCAL_LIBRARIES))
SingleProgramTarget(xgvis, $(XGVISOBJ), NullParameter, $(LOCAL_LIBRARIES))
X
purexgobi: xgobi.o $(JOINTOBJ)
X	purify -cache-dir=/tmp  -always-use-cache-dir=yes \
X	${CC} ${CFLAGS} ${LD} ${LDOPTIONS} -o xgobi ${XGOBIOBJ} ${LOCAL_LIBRARIES} \
X	${SYS_LIBRARIES}
X
purexgvis: xgvis.o $(XGVISOBJ)
X	purify -cache-dir=/tmp  -always-use-cache-dir=yes \
X	${CC} ${CFLAGS} ${LD} ${LDOPTIONS} -o xgvis ${XGVISOBJ} ${LOCAL_LIBRARIES} \
X	${SYS_LIBRARIES}
X
X
SHAR_EOF
  chmod 0644 'xgobi/src/Imakefile' ||
  $echo 'restore of' 'xgobi/src/Imakefile' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/Imakefile:' 'MD5 check failed'
7108ebba4f46f78c89a19ed7022f30e0  xgobi/src/Imakefile
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/Imakefile'`"
    test 5637 -eq "$shar_count" ||
    $echo 'xgobi/src/Imakefile:' 'original size' '5637,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/tour_init.c ==============
if test -f 'xgobi/src/tour_init.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/tour_init.c' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/tour_init.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/tour_init.c' &&
/* tour_init.c */
/************************************************************
X *                                                          *
X *  Permission is hereby granted  to  any  individual   or  *
X *  institution   for  use,  copying, or redistribution of  *
X *  the xgobi code and associated documentation,  provided  *
X *  that   such  code  and documentation are not sold  for  *
X *  profit and the  following copyright notice is retained  *
X *  in the code and documentation:                          *
X *        Copyright (c) 1990, ..., 1996 Bellcore            *
X *                                                          *
X *  We welcome your questions and comments, and request     *
X *  that you share any modifications with us.               *
X *                                                          *
X *    Deborah F. Swayne            Dianne Cook              *
X *   dfs@research.att.com       dicook@iastate.edu          *
X *      (973) 360-8423    www.public.iastate.edu/~dicook/   *
X *                                                          *
X *                    Andreas Buja                          *
X *                andreas@research.att.com                  *
X *              www.research.att.com/~andreas/              *
X *                                                          *
X ************************************************************/
X
#include <stdio.h>
#include "xincludes.h"
#include "xgobitypes.h"
#include "xgobivars.h"
#include "xgobiexterns.h"
X
Widget tour_panel, tour_cmd[10], tour_label[2];
Widget tour_sbar;
Widget tour_interp_menu_cmd, tour_interp_menu, tour_interp_menu_btn[3];
int tour_interp_btn = 0;
X
#define PAUSE     tour_cmd[0]
#define REINIT    tour_cmd[1]
#define STEP      tour_cmd[2]
#define GO        tour_cmd[3]
#define LOCALSCAN tour_cmd[4]
#define BACKTRACK tour_cmd[5]
#define DIRECTION tour_cmd[6]
#define HIST_ON   tour_cmd[7]
#define STORBAS   tour_cmd[8]
X
/* To manage the tour link state */
Widget link_menu_label, link_menu_cmd, link_menu, link_menu_btn[3], 
X  tour_update_cmd;
char *link_menu_name[] = {"Send", "Receive", "Unlink"};
#define SEND_BTN    link_menu_btn[0]
#define RECEIVE_BTN link_menu_btn[1]
#define UNLINK_BTN  link_menu_btn[2]
#define SEND_NAME    link_menu_name[0]
#define RECEIVE_NAME link_menu_name[1]
#define UNLINK_NAME  link_menu_name[2]
X
/* For setting the type of manipulation */
Widget manip_type_menu_label, manip_type_menu_cmd, manip_type_menu, 
X  manip_type_menu_btn[5];
char *manip_type_menu_name[] = {"Oblique", "Vert", "Horiz", 
X				  "Radial", "Angle"};
#define OBLIQUE_BTN    manip_type_menu_btn[0]
#define VERTICAL_BTN  manip_type_menu_btn[1]
#define HORIZONTAL_BTN manip_type_menu_btn[2]
#define RADIAL_BTN  manip_type_menu_btn[3]
#define ANGULAR_BTN  manip_type_menu_btn[4]
#define OBLIQUE_NAME    manip_type_menu_name[0]
#define VERTICAL_NAME  manip_type_menu_name[1]
#define HORIZONTAL_NAME manip_type_menu_name[2]
#define RADIAL_NAME  manip_type_menu_name[3]
#define ANGULAR_NAME  manip_type_menu_name[4]
X
/* For setting continuation factor */
Widget cont_fact_menu_label, cont_fact_menu_cmd, cont_fact_menu, 
X  cont_fact_menu_btn[9];
char *cont_fact_menu_name[] = {"1/10", "1/5", "1/4", "1/3", "1/2", "1", 
X				  "2", "10", "Infinite"};
#define TENTH_BTN cont_fact_menu_btn[0]
#define FIFTH_BTN cont_fact_menu_btn[1]
#define QUARTER_BTN cont_fact_menu_btn[2]
#define THIRD_BTN cont_fact_menu_btn[3]
#define HALF_BTN cont_fact_menu_btn[4]
#define ONE_BTN cont_fact_menu_btn[5]
#define TWO_BTN cont_fact_menu_btn[6]
#define TEN_BTN cont_fact_menu_btn[7]
#define INFINITE_BTN cont_fact_menu_btn[8]
#define TENTH_NAME cont_fact_menu_name[0]
#define FIFTH_NAME cont_fact_menu_name[1]
#define QUARTER_NAME cont_fact_menu_name[2]
#define THIRD_NAME cont_fact_menu_name[3]
#define HALF_NAME cont_fact_menu_name[4]
#define ONE_NAME cont_fact_menu_name[5]
#define TWO_NAME cont_fact_menu_name[6]
#define TEN_NAME cont_fact_menu_name[7]
#define INFINITE_NAME cont_fact_menu_name[8]
X
void
set_sens_link_menu(int sens)
{
X  XtVaSetValues(link_menu_cmd,
X    XtNsensitive, (Boolean) sens,
X    NULL);
}
X
void
set_sens_tour_update(int sens)
{
X  XtVaSetValues(tour_update_cmd,
X    XtNsensitive, (Boolean) sens,
X    NULL);
}
X
void
turn_off_local_scan(xgobidata *xg)
{
X  XtCallCallbacks(LOCALSCAN, XtNcallback, (XtPointer) xg);
X  XtVaSetValues(LOCALSCAN,
X    XtNstate, (Boolean) False,
X    NULL);
}
X
void
make_tour_io_menu(xgobidata *xg, Widget parent)
{
X  int k;
X
X  xg->tour_io_menu_cmd = XtVaCreateManagedWidget("MenuButton",
X    menuButtonWidgetClass, parent,
X    XtNlabel, (String) "I/O",
X    XtNmenuName, (String) "Menu",
X    XtNfromVert, (Widget) HIST_ON,
X    NULL);
X  if (mono) set_mono(xg->tour_io_menu_cmd);
X  add_menupb_help(&xg->nhelpids.menupb,
X    xg->tour_io_menu_cmd, "Tour_IOMenu");
X
X  xg->tour_io_menu = XtVaCreatePopupShell("Menu",
X    simpleMenuWidgetClass,
X    xg->tour_io_menu_cmd,
X    NULL);
X  if (mono) set_mono(xg->tour_io_menu);
X
X  xg->tour_io_menu_btn[0] = XtVaCreateWidget("Command",
X    smeBSBObjectClass, xg->tour_io_menu,
X    XtNlabel, (String) "Save Coeffs",
X    NULL);
X  if (mono) set_mono(xg->tour_io_menu_btn[0]);
X
X  xg->tour_io_menu_btn[1] = XtVaCreateWidget("Command",
X    smeBSBObjectClass, xg->tour_io_menu,
X    XtNlabel, (String) "Save History",
X    XtNsensitive, (Boolean) False,
X    NULL);
X  if (mono) set_mono(xg->tour_io_menu_btn[1]);
X
X  xg->tour_io_menu_btn[2] = XtVaCreateWidget("Command",
X    smeBSBObjectClass, xg->tour_io_menu,
X    XtNlabel, (String) "Read History",
X    NULL);
X  if (mono) set_mono(xg->tour_io_menu_btn[2]);
X
X  XtManageChildren(xg->tour_io_menu_btn, 3);
X
X  for (k=0; k<3; k++)
X  {
X    XtAddCallback(xg->tour_io_menu_btn[k], XtNcallback,
X      (XtCallbackProc) choose_tour_io_cback, (XtPointer) xg);
X  }
}
X
void
reset_tour_link_menu(xgobidata *xg)
{
X  char *label;
X
X  if (xg->tour_link_state == send_state)
X    label = link_menu_name[0];
X  else if (xg->tour_link_state == receive)
X    label = link_menu_name[1];
X  else if (xg->tour_link_state == unlinked)
X    label = link_menu_name[2];
X
X  XtVaSetValues(link_menu_cmd, XtNlabel, label, NULL);
}
X
void
make_tour_link_menu(xgobidata *xg, Widget parent, Widget vref)
{
X  Dimension width = 0, maxwidth = 0;
X  int longest = 0;
X  int k;
X
X  link_menu_label = XtVaCreateManagedWidget("Label",
X    labelWidgetClass, parent,
X    XtNfromVert, vref,
X    XtNlabel, "Link:",
X    NULL);
X  if (mono) set_mono(link_menu_label);
X
X  for (k=0; k<3; k++)
X  {
X    width =
X      XTextWidth(appdata.font, link_menu_name[k], strlen(link_menu_name[k]) +
X      2*ASCII_TEXT_BORDER_WIDTH);
X    if (width > maxwidth)
X    {
X      maxwidth = width;
X      longest = k;
X    }
X  }
X
X  /*
X   * Initialize this widget to use the longest name in order
X   * to ensure that it is wide enough.
X  */
X  link_menu_cmd = XtVaCreateManagedWidget("MenuButton",
X    menuButtonWidgetClass, parent,
X    XtNlabel, (String) link_menu_name[longest],
X    XtNmenuName, (String) "Menu",
X    XtNfromVert, vref,
X    XtNfromHoriz, link_menu_label,
X    XtNresize, False,
X    NULL);
X  if (mono) set_mono(link_menu_cmd);
X  add_menupb_help(&xg->nhelpids.menupb,
X    link_menu_cmd, "Tour_Linking");
X  reset_tour_link_menu(xg);
X
X  link_menu = XtVaCreatePopupShell("Menu",
X    simpleMenuWidgetClass, link_menu_cmd,
X    NULL);
X  if (mono) set_mono(link_menu_cmd);
X
X  SEND_BTN = XtVaCreateManagedWidget("Command",
X    smeBSBObjectClass, link_menu,
X    XtNlabel, SEND_NAME,
X    NULL);
X  if (mono) set_mono(SEND_BTN);
X  XtAddCallback(SEND_BTN, XtNcallback,
X    (XtCallbackProc) set_tour_link_state_cback, (XtPointer) xg);
X
X  RECEIVE_BTN = XtVaCreateManagedWidget("Command",
X    smeBSBObjectClass, link_menu,
X    XtNlabel, RECEIVE_NAME,
X    NULL);
X  if (mono) set_mono(RECEIVE_BTN);
X  XtAddCallback(RECEIVE_BTN, XtNcallback,
X    (XtCallbackProc) set_tour_link_state_cback, (XtPointer) xg);
X
X  UNLINK_BTN = XtVaCreateManagedWidget("Command",
X    smeBSBObjectClass, link_menu,
X    XtNlabel, UNLINK_NAME,
X    NULL);
X  if (mono) set_mono(UNLINK_BTN);
X  XtAddCallback(UNLINK_BTN, XtNcallback,
X    (XtCallbackProc) set_tour_link_state_cback, (XtPointer) xg);
X
X  tour_update_cmd = CreateCommand(xg, "Send Tour Update",
X    False, (Widget) NULL, (Widget) link_menu_label,
X    parent, "Tour_SendUpdate");
X  XtManageChild(tour_update_cmd);
X  XtAddCallback(tour_update_cmd, XtNcallback,
X    (XtCallbackProc) tour_update_cback, (XtPointer) xg);
}
X
void
make_tour_manip_type_menu(xgobidata *xg, Widget parent, Widget vref)
{
X  Dimension width = 0, maxwidth = 0;
X  int longest = 0;
X  int k;
X
X  manip_type_menu_label = XtVaCreateManagedWidget("Label",
X    labelWidgetClass, parent,
X    XtNfromVert, vref,
X    XtNlabel, "Manip:",
X    NULL);
X  if (mono) set_mono(manip_type_menu_label);
X
X  for (k=0; k<5; k++)
X  {
X    width =
X      XTextWidth(appdata.font, manip_type_menu_name[k], 
X        strlen(manip_type_menu_name[k]) + 2*ASCII_TEXT_BORDER_WIDTH);
X    if (width > maxwidth)
X    {
X      maxwidth = width;
X      longest = k;
X    }
X  }
X
X  /*
X   * Initialize this widget to use the longest name in order
X   * to ensure that it is wide enough.
X  */
X  manip_type_menu_cmd = XtVaCreateManagedWidget("MenuButton",
X    menuButtonWidgetClass, parent,
X    XtNlabel, (String) manip_type_menu_name[longest],
X    XtNmenuName, (String) "Menu",
X    XtNfromVert, vref,
X    XtNfromHoriz, manip_type_menu_label,
X    XtNresize, False,
X    NULL);
X  if (mono) set_mono(manip_type_menu_cmd);
X  add_menupb_help(&xg->nhelpids.menupb,
X    manip_type_menu_cmd, "Tour_Manip");
X
X  manip_type_menu = XtVaCreatePopupShell("Menu",
X    simpleMenuWidgetClass, manip_type_menu_cmd,
X    NULL);
X  if (mono) set_mono(manip_type_menu);
X
X  OBLIQUE_BTN = XtVaCreateManagedWidget("Command",
X    smeBSBObjectClass, manip_type_menu,
X    XtNlabel, OBLIQUE_NAME,
X    NULL);
X  if (mono) set_mono(OBLIQUE_BTN);
X  XtAddCallback(OBLIQUE_BTN, XtNcallback,
X    (XtCallbackProc) set_tour_manip_type_cback, (XtPointer) xg);
X
X  VERTICAL_BTN = XtVaCreateManagedWidget("Command",
X    smeBSBObjectClass, manip_type_menu,
X    XtNlabel, VERTICAL_NAME,
X    NULL);
X  if (mono) set_mono(VERTICAL_BTN);
X  XtAddCallback(VERTICAL_BTN, XtNcallback,
X    (XtCallbackProc) set_tour_manip_type_cback, (XtPointer) xg);
X
X  HORIZONTAL_BTN = XtVaCreateManagedWidget("Command",
X    smeBSBObjectClass, manip_type_menu,
X    XtNlabel, HORIZONTAL_NAME,
X    NULL);
X  if (mono) set_mono(HORIZONTAL_BTN);
X  XtAddCallback(HORIZONTAL_BTN, XtNcallback,
X    (XtCallbackProc) set_tour_manip_type_cback, (XtPointer) xg);
X
X  RADIAL_BTN = XtVaCreateManagedWidget("Command",
X    smeBSBObjectClass, manip_type_menu,
X    XtNlabel, RADIAL_NAME,
X    NULL);
X  if (mono) set_mono(RADIAL_BTN);
X  XtAddCallback(RADIAL_BTN, XtNcallback,
X    (XtCallbackProc) set_tour_manip_type_cback, (XtPointer) xg);
X
X  ANGULAR_BTN = XtVaCreateManagedWidget("Command",
X    smeBSBObjectClass, manip_type_menu,
X    XtNlabel, ANGULAR_NAME,
X    NULL);
X  if (mono) set_mono(ANGULAR_BTN);
X  XtAddCallback(ANGULAR_BTN, XtNcallback,
X    (XtCallbackProc) set_tour_manip_type_cback, (XtPointer) xg);
X
}
X
void
reset_tour_cont_fact_menu(xgobidata *xg)
{
X  char *label;
X
X  if (xg->tour_cont_fact == tenth)
X    label = cont_fact_menu_name[0];
X  else if (xg->tour_cont_fact == fifth)
X    label = cont_fact_menu_name[1];
X  else if (xg->tour_cont_fact == quarter)
X    label = cont_fact_menu_name[2];
X  else if (xg->tour_cont_fact == third)
X    label = cont_fact_menu_name[3];
X  else if (xg->tour_cont_fact == half)
X    label = cont_fact_menu_name[4];
X  else if (xg->tour_cont_fact == one)
X    label = cont_fact_menu_name[5];
X  else if (xg->tour_cont_fact == two)
X    label = cont_fact_menu_name[6];
X  else if (xg->tour_cont_fact == ten)
X    label = cont_fact_menu_name[7];
X  else if (xg->tour_cont_fact == infinite)
X    label = cont_fact_menu_name[8];
X
X  XtVaSetValues(cont_fact_menu_cmd, XtNlabel, label, NULL);
}
X
void
make_tour_cont_fact_menu(xgobidata *xg, Widget parent, Widget vref)
{
/*
X  Dimension width = 0, maxwidth = 0;
X  int k;
*/
X
X  cont_fact_menu_label = XtVaCreateManagedWidget("Label",
X    labelWidgetClass, parent,
X    XtNfromVert, vref,
X    XtNlabel, "Path Len:",
X    NULL);
X  if (mono) set_mono(cont_fact_menu_label);
X
/*
X  for (k=0; k<9; k++)
X  {
X    width =
X      XTextWidth(appdata.font, cont_fact_menu_name[k], 
X        strlen(cont_fact_menu_name[k]) + 2*ASCII_TEXT_BORDER_WIDTH);
X    if (width > maxwidth)
X    {
X      maxwidth = width;
X    }
X  }
*/
X
X  /*
X   * Initialize this widget to use the longest name in order
X   * to ensure that it is wide enough.
X  */
X  cont_fact_menu_cmd = XtVaCreateManagedWidget("MenuButton",
X    menuButtonWidgetClass, parent,
X    XtNlabel, (String) "Infinite",
X    XtNmenuName, (String) "Menu",
X    XtNfromVert, vref,
X    XtNfromHoriz, cont_fact_menu_label,
X    XtNresize, False,
X    NULL);
X  if (mono) set_mono(cont_fact_menu_cmd);
X  add_menupb_help(&xg->nhelpids.menupb,
X    cont_fact_menu_cmd, "Tour_PathLen");
X
X  cont_fact_menu = XtVaCreatePopupShell("Menu",
X    simpleMenuWidgetClass, cont_fact_menu_cmd,
X    NULL);
X  if (mono) set_mono(cont_fact_menu_cmd);
X
X  TENTH_BTN = XtVaCreateManagedWidget("Command",
X    smeBSBObjectClass, cont_fact_menu,
X    XtNlabel, TENTH_NAME,
X    NULL);
X  if (mono) set_mono(TENTH_BTN);
X  XtAddCallback(TENTH_BTN, XtNcallback,
X    (XtCallbackProc) set_tour_cont_fact_cback, (XtPointer) xg);
X
X  FIFTH_BTN = XtVaCreateManagedWidget("Command",
X    smeBSBObjectClass, cont_fact_menu,
X    XtNlabel, FIFTH_NAME,
X    NULL);
X  if (mono) set_mono(FIFTH_BTN);
X  XtAddCallback(FIFTH_BTN, XtNcallback,
X    (XtCallbackProc) set_tour_cont_fact_cback, (XtPointer) xg);
X
X  QUARTER_BTN = XtVaCreateManagedWidget("Command",
X    smeBSBObjectClass, cont_fact_menu,
X    XtNlabel, QUARTER_NAME,
X    NULL);
X  if (mono) set_mono(QUARTER_BTN);
X  XtAddCallback(QUARTER_BTN, XtNcallback,
X    (XtCallbackProc) set_tour_cont_fact_cback, (XtPointer) xg);
X
X  THIRD_BTN = XtVaCreateManagedWidget("Command",
X    smeBSBObjectClass, cont_fact_menu,
X    XtNlabel, THIRD_NAME,
X    NULL);
X  if (mono) set_mono(THIRD_BTN);
X  XtAddCallback(THIRD_BTN, XtNcallback,
X    (XtCallbackProc) set_tour_cont_fact_cback, (XtPointer) xg);
X
X  HALF_BTN = XtVaCreateManagedWidget("Command",
X    smeBSBObjectClass, cont_fact_menu,
X    XtNlabel, HALF_NAME,
X    NULL);
X  if (mono) set_mono(HALF_BTN);
X  XtAddCallback(HALF_BTN, XtNcallback,
X    (XtCallbackProc) set_tour_cont_fact_cback, (XtPointer) xg);
X
X  ONE_BTN = XtVaCreateManagedWidget("Command",
X    smeBSBObjectClass, cont_fact_menu,
X    XtNlabel, ONE_NAME,
X    NULL);
X  if (mono) set_mono(ONE_BTN);
X  XtAddCallback(ONE_BTN, XtNcallback,
X    (XtCallbackProc) set_tour_cont_fact_cback, (XtPointer) xg);
X
X  TWO_BTN = XtVaCreateManagedWidget("Command",
X    smeBSBObjectClass, cont_fact_menu,
X    XtNlabel, TWO_NAME,
X    NULL);
X  if (mono) set_mono(TWO_BTN);
X  XtAddCallback(TWO_BTN, XtNcallback,
X    (XtCallbackProc) set_tour_cont_fact_cback, (XtPointer) xg);
X
X  TEN_BTN = XtVaCreateManagedWidget("Command",
X    smeBSBObjectClass, cont_fact_menu,
X    XtNlabel, TEN_NAME,
X    NULL);
X  if (mono) set_mono(TEN_BTN);
X  XtAddCallback(TEN_BTN, XtNcallback,
X    (XtCallbackProc) set_tour_cont_fact_cback, (XtPointer) xg);
X
X  INFINITE_BTN = XtVaCreateManagedWidget("Command",
X    smeBSBObjectClass, cont_fact_menu,
X    XtNlabel, INFINITE_NAME,
X    NULL);
X  if (mono) set_mono(INFINITE_BTN);
X  XtAddCallback(INFINITE_BTN, XtNcallback,
X    (XtCallbackProc) set_tour_cont_fact_cback, (XtPointer) xg);
X
X  XtVaSetValues(cont_fact_menu_cmd, XtNlabel, "1", NULL);
}
X
void
init_tour_interp_menu(void)
{
X  XtVaSetValues(tour_interp_menu_btn[0],
X    XtNleftBitmap, menu_mark, NULL);
}
X
void
make_tour_interp_menu(xgobidata *xg, Widget parent)
/*
X * Build a menu to contain interpolation choices.
*/
{
X  int j;
X
X  tour_interp_menu_cmd = XtVaCreateManagedWidget("MenuButton",
X    menuButtonWidgetClass, parent,
X    XtNlabel, (String) "Interp",
X    XtNmenuName, (String) "Menu",
X    XtNfromHoriz, (Widget) xg->tour_io_menu_cmd,
X    XtNfromVert, (Widget) HIST_ON,
X    NULL);
X  if (mono) set_mono(tour_interp_menu_cmd);
X  add_menupb_help(&xg->nhelpids.menupb,
X    tour_interp_menu_cmd, "Tour_InterpMenu");
X
X  tour_interp_menu = XtVaCreatePopupShell("Menu",
X    simpleMenuWidgetClass,
X    tour_interp_menu_cmd, NULL);
X  if (mono) set_mono(tour_interp_menu);
X
X  tour_interp_menu_btn[0] = XtVaCreateWidget("Command",
X    smeBSBObjectClass, tour_interp_menu,
X    XtNlabel, (String) "Geodesic",
X    XtNleftMargin, (Dimension) 24,
X    NULL);
X  if (mono) set_mono(tour_interp_menu_btn[0]);
X
X  tour_interp_menu_btn[1] = XtVaCreateWidget("Command",
X    smeBSBObjectClass, tour_interp_menu,
X    XtNlabel, (String) "Householder",
X    XtNleftMargin, (Dimension) 24,
X    NULL);
X  if (mono) set_mono(tour_interp_menu_btn[1]);
X
X  tour_interp_menu_btn[2] = XtVaCreateWidget("Command",
X    smeBSBObjectClass, tour_interp_menu,
X    XtNlabel, (String) "Givens",
X    XtNleftMargin, (Dimension) 24,
X    NULL);
X  if (mono) set_mono(tour_interp_menu_btn[2]);
X
X  XtManageChildren(tour_interp_menu_btn, 3);
X
X  for (j=0; j<3; j++)
X    XtAddCallback(tour_interp_menu_btn[j], XtNcallback,
X      (XtCallbackProc) choose_tour_interp_cback, (XtPointer) xg);
}
X
void
make_tour(xgobidata *xg)
{
X  Dimension width;
X  char str[30];
X  Dimension max_width;
/*
X * Widest button label used in this panel.
*/
X  sprintf(str, "ProjPrstSection");
X  max_width = XTextWidth(appdata.font, str, strlen(str)) +
X    4 * ASCII_TEXT_BORDER_WIDTH + 3 + 2;
X  /* borders around text, spacing between widgets, widget borders */
X
/*
X * TourPanel
*/
X  tour_panel = XtVaCreateManagedWidget("TourPanel",
X    formWidgetClass, xg->box0,
X    XtNleft, (XtEdgeType) XtChainLeft,
X    XtNright, (XtEdgeType) XtChainLeft,
X    XtNtop, (XtEdgeType) XtChainTop,
X    XtNbottom, (XtEdgeType) XtChainTop,
X    XtNmappedWhenManaged, (Boolean) False,
X    NULL);
X  if (mono) set_mono(tour_panel);
/*
X * tour speed scrollbar
*/
X  tour_sbar = XtVaCreateManagedWidget("Scrollbar",
X    scrollbarWidgetClass, tour_panel,
X    XtNwidth, (Dimension) max_width,
X    XtNorientation, (XtOrientation) XtorientHorizontal,
X    NULL);
X  if (mono) set_mono(tour_sbar);
X
X  add_sbar_help(&xg->nhelpids.sbar,
X    tour_sbar, "Tour_Speed");
X
X  XawScrollbarSetThumb(tour_sbar, 20.*TOURSTEP0 + .05, -1.);
X  XtAddCallback(tour_sbar, XtNjumpProc,
X    (XtCallbackProc) tour_speed_cback, (XtPointer) xg);
X
/*
X * tour pause control
*/
X  PAUSE = CreateToggle(xg, "Pause",
X    True, (Widget) NULL, tour_sbar, (Widget) NULL, False, ANY_OF_MANY,
X    tour_panel, "Tour_Pause");
X  XtAddCallback(PAUSE, XtNcallback,
X    (XtCallbackProc) tour_pause_cback, (XtPointer) xg);
X
/*
X * Reinit button
*/
X  REINIT = CreateCommand(xg, "Reinit",
X    True, PAUSE, tour_sbar,
X    tour_panel, "Tour_Reinit");
X  XtAddCallback(REINIT, XtNcallback,
X    (XtCallbackProc) tour_reinit_cback, (XtPointer) xg);
X
/*
X * Menu to manage linked touring
*/
X  make_tour_link_menu(xg, tour_panel, REINIT);
X
/*
X * Menu to manage manipulation type 
*/ 
X  make_tour_manip_type_menu(xg, tour_panel, tour_update_cmd);
X
/*
X * Menu to manage manipulation type 
*/ 
X  make_tour_cont_fact_menu(xg, tour_panel, manip_type_menu_label);
X
/*
X * Button to allow stepping instead of continuous grand tour
*/
X  STEP = CreateToggle(xg, "Step",
X    True, (Widget) NULL, cont_fact_menu_label, (Widget) NULL, False, 
X    ANY_OF_MANY, tour_panel, "Tour_StepGo");
X  XtAddCallback(STEP, XtNcallback,
X    (XtCallbackProc) tour_step_cback, (XtPointer) xg);
/* */
X
X  GO = CreateCommand(xg, "Go",
X    False, STEP, cont_fact_menu_label,
X    tour_panel, "Tour_StepGo");
X  XtAddCallback(GO, XtNcallback,
X    (XtCallbackProc) tour_step_go_cback, (XtPointer) xg);
X
/*
X * Button for local scan
*/
X  LOCALSCAN = CreateToggle(xg, "Local Scan",
X    True, (Widget) NULL, STEP, (Widget) NULL, False, ANY_OF_MANY,
X    /*True, (Widget) GO, cont_fact_menu_label, (Widget) NULL, False, ANY_OF_MANY,*/
X    tour_panel, "Tour_LocalScan");
X  XtAddCallback(LOCALSCAN, XtNcallback,
X    (XtCallbackProc) tour_local_cback, (XtPointer) xg);
X
/*
X * tour backtrack control: initiate insensitive, turn on
X * when there are more than two or three elements in the
X * history file
*/
X  BACKTRACK = CreateToggle(xg, "Backtrck",
X    False, (Widget) NULL, LOCALSCAN, (Widget) NULL, False, ANY_OF_MANY,
X    tour_panel, "Tour_Backtrack");
X  XtAddCallback(BACKTRACK, XtNcallback,
X    (XtCallbackProc) tour_backtrack_cback, (XtPointer) xg);
X
/*
X * label to record number of bases in history file
*/
X  sprintf(str, "%d ", MAXHIST);
X  width = XTextWidth(appdata.font, str, strlen(str));
X
X  tour_label[0] = XtVaCreateManagedWidget("TourLabel",
X    asciiTextWidgetClass, tour_panel,
X    XtNfromVert, (Widget) LOCALSCAN,
X    XtNfromHoriz, (Widget) BACKTRACK,
X    XtNstring, (String) "1",
X    XtNdisplayCaret, (Boolean) False,
X    XtNwidth, (Dimension) width,
X    NULL);
X  if (mono) set_mono(tour_label[0]);
X
/*
X * Button to allow cycling backwards and forwards through backtracking
*/
X  DIRECTION = CreateCommand(xg, "F",
X    False, tour_label[0], LOCALSCAN,
X    tour_panel, "Tour_BtrackDir");
X  XtAddCallback(DIRECTION, XtNcallback,
X    (XtCallbackProc) tour_cycleback_cback, (XtPointer) xg);
X
X  XtManageChildren(&PAUSE, 7);
X
/*
X * Button for recording history
*/
X  HIST_ON = CreateToggle(xg, "Hist On",
X    True, (Widget) NULL, BACKTRACK, (Widget) NULL, True,
X    ANY_OF_MANY,
X    tour_panel, "Tour_HistOn");
X  XtManageChild(HIST_ON);
X  XtAddCallback(HIST_ON, XtNcallback,
X    (XtCallbackProc) tourhist_on_cback, (XtPointer) xg);
X
/*
X * Store basis
*/
X  STORBAS = CreateCommand(xg, "Store",
X    True, HIST_ON, BACKTRACK,
X    tour_panel, "Tour_Store");
X  XtManageChild(STORBAS);
X  XtAddCallback(STORBAS, XtNcallback,
X    (XtCallbackProc) tour_storbas_cback, (XtPointer) xg);
X
X  make_tour_io_menu(xg, tour_panel );
X
X  make_tour_interp_menu(xg, tour_panel);
X
/*
X * Button for switching to principal component axes
*/
X  xg->princ_comp_cmd = CreateToggle(xg, "PC Basis",
X    True, (Widget) NULL, xg->tour_io_menu_cmd, (Widget) NULL, False,
X    ANY_OF_MANY,
X    tour_panel, "Tour_PrinComp");
X  XtManageChild(xg->princ_comp_cmd);
X  XtAddCallback(xg->princ_comp_cmd, XtNcallback,
X    (XtCallbackProc) princ_comp_cback, (XtPointer) xg);
X
/*
X * Button for switching between axes in raw data space or pc space
*/
X  xg->pc_axes_cmd = CreateToggle(xg, "PC Axes",
X    False, (Widget) xg->princ_comp_cmd, xg->tour_io_menu_cmd, 
X    (Widget) NULL, False, ANY_OF_MANY,
X    tour_panel, "Tour_PC_Axes");
X  XtManageChild(xg->pc_axes_cmd);
X  XtAddCallback(xg->pc_axes_cmd, XtNcallback,
X    (XtCallbackProc) pc_axes_cback, (XtPointer) xg);
X
/*
X * tour projection pursuit control
*/
X  xg->proj_pursuit_cmd = CreateToggle(xg, "ProjPrst",
X    True, (Widget) NULL, (Widget) xg->princ_comp_cmd,
X    (Widget) NULL, False, ANY_OF_MANY,
X    tour_panel, "ToPP");
X  XtManageChild(xg->proj_pursuit_cmd);
X  XtAddCallback(xg->proj_pursuit_cmd, XtNcallback,
X    (XtCallbackProc) tour_pp_cback, (XtPointer) xg);
X
/*
X * Button for section tour
*/
X  xg->tour_section_cmd = CreateToggle(xg, "Section",
X    True, (Widget) xg->proj_pursuit_cmd, (Widget)  xg->princ_comp_cmd,
X    (Widget) xg->proj_pursuit_cmd, False, ANY_OF_MANY,
X    tour_panel, "Tour_Section");
X  XtManageChild(xg->tour_section_cmd);
X  XtAddCallback(xg->tour_section_cmd, XtNcallback,
X    (XtCallbackProc) tour_section_cback, (XtPointer) xg);
X
X  make_pp_panel(xg, tour_panel);
X  make_section_panel(xg, tour_panel, max_width);
}
X
void
highlight_pause_cmd()
{
X  XtVaSetValues(PAUSE, XtNstate, (Boolean) True, NULL);
}
X
void
reset_tour_pause_cmd(xgobidata *xg)
{
X  XtCallCallbacks(PAUSE, XtNcallback, (XtPointer) xg);
X  XtVaSetValues(PAUSE, XtNstate, xg->is_tour_paused, NULL);
}
X
void
reset_cycleback_cmd(Boolean set, Boolean sens, char *label)
{
X  if (set)
X    XtVaSetValues(DIRECTION,
X      XtNsensitive, sens,
X      XtNlabel, (String) label,
X      NULL);
X  else
X    XtVaSetValues(DIRECTION,
X      XtNlabel, (String) label,
X      NULL);
}
X
void
set_sens_localscan(Boolean sens)
{
X  XtVaSetValues(LOCALSCAN,
X    XtNsensitive, sens,
X    NULL);
}
X
void
set_sens_reinit(Boolean sens)
{
X  XtVaSetValues(REINIT, XtNsensitive, sens, NULL);
}
X
void
set_sens_go(Boolean sens)
{
X  XtVaSetValues(GO, XtNsensitive, sens, NULL);
}
X
void
turn_off_stepping(void)
{
X  XtCallCallbacks(STEP, XtNcallback, (XtPointer) NULL);
X  XtVaSetValues(STEP, XtNstate, False, NULL);
X
}
X
void
set_sens_step(Boolean sens)
{
X  XtVaSetValues(STEP, XtNsensitive, sens, NULL);
}
X
void
set_sens_speed(Boolean sens)
{
X  XtVaSetValues(tour_sbar, XtNsensitive, sens, NULL);
}
X
void
set_sens_interp(Boolean sens)
{
X  XtVaSetValues(tour_interp_menu_cmd, XtNsensitive, sens, NULL);
}
X
void
set_sens_io(xgobidata *xg, int sens0, int sens1, int sens2)
{
X  XtVaSetValues(xg->tour_io_menu_btn[0],
X    XtNsensitive, (Boolean) sens0,
X    NULL);
X  XtVaSetValues(xg->tour_io_menu_btn[1],
X    XtNsensitive, (Boolean) sens1,
X    NULL);
X  XtVaSetValues(xg->tour_io_menu_btn[2],
X    XtNsensitive, (Boolean) sens2,
X    NULL);
}
X
void
highlight_backtrack_cmd()
{
X  XtVaSetValues(BACKTRACK, XtNstate, (Boolean) False, NULL);
}
X
void
reset_backtrack_cmd(Boolean reset, Boolean set, Boolean sens, Boolean activ)
{
X  if (reset)
X    XtVaSetValues(BACKTRACK,
X      XtNstate, set,
X      XtNsensitive, sens,
X      NULL);
X  else
X    XtVaSetValues(BACKTRACK,
X      XtNsensitive, sens,
X      NULL);
X
X  if (activ)
X    XtCallCallbacks(BACKTRACK, XtNcallback, (XtPointer) NULL);
}
X
void
set_sens_direction(Boolean sens)
{
X  XtVaSetValues(DIRECTION,
X    XtNsensitive, sens,
X    NULL);
}
X
void
reset_tourhist_cmds(xgobidata *xg, int sens)
{
X  XtVaSetValues(xg->tour_io_menu_btn[1],
X    XtNsensitive, (Boolean) sens,
X    NULL);
X
X  XtVaSetValues(xg->tour_io_menu_btn[2],
X    XtNsensitive, (Boolean) sens,
X    NULL);
}
X
void
reset_interp_cmd(int sens)
{
X  XtVaSetValues(tour_interp_menu_cmd,
X    XtNsensitive, (Boolean) sens,
X    NULL);
}
X
void
map_tour_panel(xgobidata *xg, Boolean is_tour_on)
{
X  if (is_tour_on)
X  {
X    XtMapWidget(tour_panel);
X    XtMapWidget(xg->tour_mouse);
X   }
X  else
X  {
X    XtUnmapWidget(tour_panel);
X    XtUnmapWidget(xg->tour_mouse);
X  }
}
X
void
nback_update_label(xgobidata *xg)
{
X  char str[10];
X
X  (void) sprintf(str, "%d", xg->nhist_list);
X  XtVaSetValues(tour_label[0],
X    XtNstring, (String) str,
X    NULL);
}
X
void
reinit_tour(xgobidata *xg)
{
X  XtCallCallbacks(REINIT, XtNcallback, (XtPointer) xg);
}
X
#undef PANEL1
#undef PANEL2
#undef PANEL3
X
#undef PAUSE
#undef STEP
#undef GO
#undef LOCALSCAN
#undef BACKTRACK
#undef DIRECTION
#undef REINIT
#undef HIST_ON
#undef STORBAS
X
#undef OBLIQUE_BTN
#undef VERTICAL_BTN
#undef HORIZONTAL_BTN
#undef RADIAL_BTN
#undef ANGULAR_BTN
#undef OBLIQUE_NAME
#undef VERTICAL_NAME
#undef HORIZONTAL_NAME
#undef RADIAL_NAME
#undef ANGULAR_NAME
X
#undef TENTH_BTN
#undef FIFTH_BTN
#undef QUARTER_BTN
#undef THIRD_BTN
#undef HALF_BTN
#undef ONE_BTN
#undef TWO_BTN
#undef TEN_BTN
#undef INFINITE_BTN
#undef TENTH_NAME
#undef FIFTH_NAME
#undef QUARTER_NAME
#undef THIRD_NAME
#undef HALF_NAME
#undef ONE_NAME
#undef TWO_NAME
#undef TEN_NAME
#undef INFINITE_NAME
SHAR_EOF
  chmod 0644 'xgobi/src/tour_init.c' ||
  $echo 'restore of' 'xgobi/src/tour_init.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/tour_init.c:' 'MD5 check failed'
de5a5f8b2a37d4396e2f177cf194168c  xgobi/src/tour_init.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/tour_init.c'`"
    test 26930 -eq "$shar_count" ||
    $echo 'xgobi/src/tour_init.c:' 'original size' '26930,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/DrawingAP.h ==============
if test -f 'xgobi/src/DrawingAP.h' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/DrawingAP.h' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/DrawingAP.h' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/DrawingAP.h' &&
/* DrawingArea Private header file */
X
/* Copyright 1990, David Nedde
X *
X * Permission to use, copy, modify, and distribute this
X * software and its documentation for any purpose and without fee
X * is granted provided that the above copyright notice appears in all copies.
X * It is provided "as is" without express or implied warranty.
*/
X
#ifndef _XawDrawingAreaP_h
#define _XawDrawingAreaP_h
X
#include "DrawingA.h"
#ifdef X11_R3
#include <X11/SimpleP.h>
#else
#include <X11/Xaw/SimpleP.h>
#endif
X
/* The drawing area's contribution to the class record */
typedef struct _DrawingAreaClassPart {
X  int ignore;
} DrawingAreaClassPart;
X
/* Drawing area's full class record */
typedef struct _DrawingAreaClassRec {
X    CoreClassPart	core_class;
X    SimpleClassPart	simple_class;
X    DrawingAreaClassPart drawing_area;
} DrawingAreaClassRec;
X
extern DrawingAreaClassRec drawingAreaClassRec;
X
/* Resources added and status of drawing area widget */
typedef struct _XsDrawingAreaPart {
X  /* Resources */
X  XtCallbackList	expose_callback;
X  XtCallbackList	input_callback;
X  XtCallbackList	motion_callback;
X  XtCallbackList	resize_callback;
} DrawingAreaPart;
X
X
/* Drawing area's instance record */
typedef struct _DrawingAreaRec {
X    CorePart         core;
X    SimplePart	     simple;
X    DrawingAreaPart  drawing_area;
} DrawingAreaRec;
X
#endif /* _XawDrawingAreaP_h */
SHAR_EOF
  chmod 0644 'xgobi/src/DrawingAP.h' ||
  $echo 'restore of' 'xgobi/src/DrawingAP.h' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/DrawingAP.h:' 'MD5 check failed'
2f47ec8574f523001b9180217bf1bd28  xgobi/src/DrawingAP.h
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/DrawingAP.h'`"
    test 1365 -eq "$shar_count" ||
    $echo 'xgobi/src/DrawingAP.h:' 'original size' '1365,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/xgv_stressplot.c ==============
if test -f 'xgobi/src/xgv_stressplot.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/xgv_stressplot.c' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/xgv_stressplot.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/xgv_stressplot.c' &&
#include <sys/types.h>
#include <stdio.h>
#include "xincludes.h"
#include "xgobitypes.h"
#include "xgobivars.h"
#include "xgobiexterns.h"
#include "xgvis.h"
X
/*
X * Plot the stress function.
*/
X
#define MAXSTRVALUES 1000
#define STR_VMARGIN 10
#define STR_HMARGIN 10
Widget stress_form;
Widget str_wksp;
Pixmap str_pixmap = (Pixmap) NULL;
Drawable str_window;
int nstrValues = 0;
int maxnstrValues = MAXSTRVALUES;
double strValues[MAXSTRVALUES];
Dimension str_height = 120;
Dimension str_width = 295;
double default_stress = -1;  /* stress before running mds_once */
X
extern void mds_once(Boolean);
X
extern Dimension runPanelWidth, mdsPanelWidth;
X
X
void
reinit_stress(void)
{
X  /* nstrValues = 0; */
X  mds_once(False);
}
X
void
make_str_pixmap(void) {
X  str_pixmap = XCreatePixmap(display, str_window,
X			     str_width, str_height, depth);
}
X
void
clear_str_pixmap(void) {
X  XFillRectangle(display, str_pixmap, clear_GC,
X    0, 0, str_width, str_height);
}
X
void
copy_str_pixmap(void) {
X  /* copy the pixmap to the screen */
X  XCopyArea(display, str_pixmap, str_window, copy_GC,
X    0, 0, str_width, str_height, 0, 0 );
}
X
void
add_stress_value(double stress)
{
X  int i;
X
X  if (nstrValues == maxnstrValues) {
X    for (i=0; i < (maxnstrValues-1); i++) {
X      strValues[i] = strValues[i+1];
X    }
X    nstrValues--;
X  }
X
X  strValues[nstrValues] = stress;
X  nstrValues++;
}
X
void
draw_stress(void) {
X  int i, j, npoints, start, end;
X  /*float width = (float) (str_width) - 2. * (float) STR_HMARGIN;*/
X  /*float maxwidth = (float) MAXSTRVALUES;*/
X  float height = (float) (str_height) - 2. * (float) STR_VMARGIN;
X  float x, y;
X  static Boolean initd = False;
X  XPoint axes[3];
X  char str[32];
X  static int strwidth;
X  XPoint strPts[MAXSTRVALUES];
X
X  if (!initd) {
X    str_window = XtWindow(str_wksp);
X    make_str_pixmap();
X
X    sprintf(str, ".9999");
X    strwidth = XTextWidth(appdata.plotFont, str, strlen(str));
X
X    initd = True;
X  }
X
X  /*
X   * The starting point should be zero until npoints has
X   * been surpassed; after that, it should be nstrValues
X   * minus npoints.  Define the indices for strPts.
X  */
X  /* plotting one point per pixel ... */
X  npoints = MIN(str_width - 2*STR_HMARGIN, nstrValues);
X  start = MAX(0, nstrValues - npoints);
X  end = nstrValues;
X
X  for (i=start, j=0; i<end; i++, j++) {
X    x = (float) j ;
X    strPts[j].x = (int) (x + STR_HMARGIN);
X    y = (float) (1 - strValues[i]) * height;
X    strPts[j].y = (int) (y + STR_VMARGIN);
X  }
X
X  /* axes */
X  axes[0].x = STR_HMARGIN;
X  axes[0].y = STR_VMARGIN;
X  axes[1].x = STR_HMARGIN;
X  axes[1].y = str_height - STR_VMARGIN;
X  axes[2].x = str_width - STR_HMARGIN;
X  axes[2].y = str_height - STR_VMARGIN;
X
X  /* stress as a fraction */
X  sprintf(str, "%2.4f", strValues[nstrValues-1]);
X
X  XSetForeground(display, copy_GC, plotcolors.fg);
X  clear_str_pixmap();
X  XDrawLines(display, str_pixmap, copy_GC,
X    axes, 3, CoordModeOrigin);
X  if (nstrValues) {
X    XDrawString(display, str_pixmap, copy_GC,
X      str_width - 2*STR_HMARGIN - strwidth,
X      FONTHEIGHT(appdata.plotFont),
X      str,
X      strlen(str));
X    XSetLineAttributes(display, copy_GC, 2, LineSolid,
X      CapRound, JoinBevel);
X    XDrawLines(display, str_pixmap, copy_GC,
X      strPts, npoints, CoordModeOrigin);
X    XSetLineAttributes(display, copy_GC, 1, LineSolid,
X      CapRound, JoinBevel);
X  }
X  copy_str_pixmap();
}
X
/* ARGSUSED */
XXtCallbackProc
str_expose_cback(Widget w, XtPointer client_data, XtPointer callback_data)
{
X  if (str_pixmap)
X    copy_str_pixmap();
}
X
/* ARGSUSED */
XXtCallbackProc
str_resize_cback(Widget w, XtPointer client_data, XtPointer callback_data)
{
X  XtVaGetValues(str_wksp,
X    XtNwidth, &str_width,
X    XtNheight, &str_height,
X    NULL);
X
X  XFreePixmap(display, str_pixmap);
X  make_str_pixmap();
X  clear_str_pixmap();
X  draw_stress();
}
X
void
build_stress_plotwin(Widget parent, Widget href, Widget vref)
{
X  Widget str_label;
X
X  stress_form = XtVaCreateManagedWidget("Stress",
X    formWidgetClass, parent,
X    XtNfromHoriz, href,
X    XtNfromVert, vref,
X    NULL);
X  if (mono) set_mono(stress_form);
X
X  str_width = runPanelWidth + mdsPanelWidth + 15;
X
X  str_label = XtVaCreateManagedWidget("Label",
X    labelWidgetClass, stress_form,
X    XtNlabel, "Stress function",
X    XtNleft, (XtEdgeType) XtChainLeft,
X    XtNright, (XtEdgeType) XtChainRight,
X    XtNtop, (XtEdgeType) XtChainTop,
X    XtNbottom, (XtEdgeType) XtChainTop,
X    XtNwidth, str_width,
X    XtNborderWidth, 0,
X    NULL); 
X  if (mono) set_mono(str_label);
X
X  str_wksp = XtVaCreateManagedWidget("Stress",
X    labelWidgetClass, stress_form,
X    XtNfromVert, str_label,
X    XtNresizable, (Boolean) True,
X    XtNleft, (XtEdgeType) XtChainLeft,
X    XtNtop, (XtEdgeType) XtChainTop,
X    XtNright, (XtEdgeType) XtChainRight,
X    XtNbottom, (XtEdgeType) XtChainBottom,
X    XtNheight, str_height,
X    XtNwidth, str_width,
X    XtNlabel, (String) "",
X    NULL);
X  if (mono) set_mono(str_wksp);
X
X  XtAddEventHandler(str_wksp, ExposureMask,
X    FALSE, (XtEventHandler) str_expose_cback, (XtPointer) NULL);
X  XtAddEventHandler(str_wksp, StructureNotifyMask,
X    FALSE, (XtEventHandler) str_resize_cback, (XtPointer) NULL);
}
X
SHAR_EOF
  chmod 0644 'xgobi/src/xgv_stressplot.c' ||
  $echo 'restore of' 'xgobi/src/xgv_stressplot.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/xgv_stressplot.c:' 'MD5 check failed'
03c3875827acf478979a237e453b6cf9  xgobi/src/xgv_stressplot.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/xgv_stressplot.c'`"
    test 5146 -eq "$shar_count" ||
    $echo 'xgobi/src/xgv_stressplot.c:' 'original size' '5146,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/var_panel.c ==============
if test -f 'xgobi/src/var_panel.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/var_panel.c' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/var_panel.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/var_panel.c' &&
/* var_panel.c */
/************************************************************
X *                                                          *
X *  Permission is hereby granted  to  any  individual   or  *
X *  institution   for  use,  copying, or redistribution of  *
X *  the xgobi code and associated documentation,  provided  *
X *  that   such  code  and documentation are not sold  for  *
X *  profit and the  following copyright notice is retained  *
X *  in the code and documentation:                          *
X *        Copyright (c) 1990, ..., 1996 Bellcore            *
X *                                                          *
X *  We welcome your questions and comments, and request     *
X *  that you share any modifications with us.               *
X *                                                          *
X *    Deborah F. Swayne            Dianne Cook              *
X *   dfs@research.att.com       dicook@iastate.edu          *
X *      (973) 360-8423    www.public.iastate.edu/~dicook/   *
X *                                                          *
X *                    Andreas Buja                          *
X *                andreas@research.att.com                  *
X *              www.research.att.com/~andreas/              *
X *                                                          *
X ************************************************************/
X
#include <stdio.h>
#include "xincludes.h"
#include "xgobitypes.h"
#include "xgobivars.h"
#include "xgobiexterns.h"
X
#include "../bitmaps/xy.xbm"
X
extern xgobidata xgobi;
X
static Widget var_mouse, var_mouse_tform, var_mouse_tour, var_mouse_corr;
static Widget var_mouse_oblique, var_mouse_plot1d;
static int cursor_in_panel = 0 ;
static int last_touched = 0 ;
X
static int focus_var = -1;
X
static struct {
X	Widget cascade;
X	Widget btn[10];
} varsel_menu;
X
/* ARGSUSED */
XXtEventHandler
set_focus_var(Widget w, xgobidata *xg, XEvent *evnt)
{
X  int j;
X  for (j=0; j<xg->ncols_used; j++)
X    if (xg->vardraww[j] == w)
X      break;
X
X  focus_var = (evnt->type == EnterNotify) ? j : -1;
X  refresh_vbox(xg, j, False);
}
X
/* ARGSUSED */
XXtEventHandler
set_var_tform_label(Widget w, xgobidata *xg, XEvent *evnt)
{
X  if (evnt->type == EnterNotify) {
X    XtUnmapWidget(var_mouse);
X    XtUnmapWidget(var_mouse_plot1d);
X    XtUnmapWidget(var_mouse_oblique);
X    XtUnmapWidget(var_mouse_tour);
X    XtUnmapWidget(var_mouse_corr);
X    XtMapWidget(var_mouse_tform);
X  }
X  else if (evnt->type == LeaveNotify)
X  {
X    XtUnmapWidget(var_mouse_tform);
X    if (xg->is_touring && !xg->is_backtracking && !xg->is_local_scan)
X      XtMapWidget(var_mouse_tour);
X    else if (xg->is_spinning && xg->is_spin_type.oblique)
X      XtMapWidget(var_mouse_oblique);
X    else if (xg->is_plotting1d)
X      XtMapWidget(var_mouse_plot1d);
X    else if (xg->is_corr_touring && !(corr_backtracking(xg)))
X      XtMapWidget(var_mouse_corr);
X    else if (xg->is_xyplotting ||
X        (xg->is_spinning && !xg->is_spin_type.oblique))
X      XtMapWidget(var_mouse);
X  }
}
X
void
set_varsel_label(xgobidata *xg)
/*
X * Set the label above the variable selection panel.
*/
{
X  if (xg->is_touring)
X  {
X    XtUnmapWidget(var_mouse);
X    XtUnmapWidget(var_mouse_oblique);
X    XtUnmapWidget(var_mouse_plot1d);
X    XtUnmapWidget(var_mouse_corr);
X    if (xg->is_backtracking || xg->is_local_scan)
X      XtUnmapWidget(var_mouse_tour);
X    else
X      XtMapWidget(var_mouse_tour);
X  }
X  else if (xg->is_corr_touring)
X  {
X    XtUnmapWidget(var_mouse);
X    XtUnmapWidget(var_mouse_oblique);
X    XtUnmapWidget(var_mouse_plot1d);
X    XtUnmapWidget(var_mouse_tour);
X    if (corr_backtracking(xg))
X      XtUnmapWidget(var_mouse_corr);
X    else
X      XtMapWidget(var_mouse_corr);
X  }
X  else if (xg->is_spinning && xg->is_spin_type.oblique)
X  {
X    XtUnmapWidget(var_mouse);
X    XtUnmapWidget(var_mouse_plot1d);
X    XtUnmapWidget(var_mouse_tour);
X    XtUnmapWidget(var_mouse_corr);
X    XtMapWidget(var_mouse_oblique);
X  }
X  else if (xg->is_xyplotting ||
X       (xg->is_spinning && !xg->is_spin_type.oblique))
X  {
X    XtUnmapWidget(var_mouse_tour);
X    XtUnmapWidget(var_mouse_corr);
X    XtUnmapWidget(var_mouse_plot1d);
X    XtUnmapWidget(var_mouse_oblique);
X    XtMapWidget(var_mouse);
X  }
X  else if (xg->is_plotting1d)
X  {
X    XtUnmapWidget(var_mouse_tour);
X    XtUnmapWidget(var_mouse_corr);
X    XtUnmapWidget(var_mouse_oblique);
X    XtUnmapWidget(var_mouse);
X    XtMapWidget(var_mouse_plot1d);
X  }
}
X
int
spin_varsel_ax_from_menu(int varno, int button, xgobidata *xg)
{
/*
X * Here x and y are plotted horizontally; z is plotted vertically.
X * or
X * x and y are plotted vertically; z is plotted horizontally.
*/
X  int prev = -1, newvar = 1;
X
X  if (button == 1) {  /* new x variable */
X
X    if (varno == xg->spin_vars.x) 
X      ;
X    else if (varno == xg->spin_vars.z) /* exchange the two */
X      xg->spin_vars.z = xg->spin_vars.x; 
X    else if (varno == xg->spin_vars.y) /* exchange the two */
X      xg->spin_vars.y = xg->spin_vars.x;
X    else {  /* new variable */
X      prev = xg->spin_vars.x;
X    }
X
X    xg->spin_vars.x = varno;
X    last_touched = varno;
X
X  } else if (button == 2) {  /* new y variable */
X
X    if (varno == xg->spin_vars.y) 
X      ;
X    else if (varno == xg->spin_vars.x) { /* exchange the two */
X      xg->spin_vars.x = xg->spin_vars.y; 
X    } else if (varno == xg->spin_vars.z) { /* exchange the two */
X      xg->spin_vars.z = xg->spin_vars.y;
X    } else {  /* new variable */
X      prev = xg->spin_vars.y;
X    }
X
X    xg->spin_vars.y = varno;
X    last_touched = varno;
X
X  } else if (button == 3) {  /* new z variable */
X
X    if (varno == xg->spin_vars.z)
X      newvar = 0;
X
X    else if (varno == xg->spin_vars.x) {
X      last_touched = xg->spin_vars.x = xg->spin_vars.z;
X    } else if (varno == xg->spin_vars.y) {
X      last_touched = xg->spin_vars.y = xg->spin_vars.z;
X    } else {
X      prev = xg->spin_vars.z;
X    }
X    xg->spin_vars.z = varno;
X  }
X
X  if (prev != -1) {
X    xg->varchosen[prev] = False;
X    refresh_vbox(xg, prev, 1);
X    xg->varchosen[varno] = True;
X  }
X
X  return(newvar);
}
X
int
spin_varsel_oblique_from_menu(int varno, int button, xgobidata *xg)
{
X  int prev = -1, newvar = 1;
X
X  if (button == 1) {  /* new x variable */
X    if (varno == xg->spin_vars.x)
X      newvar = 0;
X    else if (varno == xg->spin_vars.y)
X      xg->spin_vars.y = xg->spin_vars.x;
X    else if (varno == xg->spin_vars.z)
X      xg->spin_vars.z = xg->spin_vars.x;
X    else
X      prev = xg->spin_vars.x;
X
X    xg->spin_vars.x = varno;
X
X  } else if (button == 2) {  /* new y variable */
X    if (varno == xg->spin_vars.y)
X      newvar = 0;
X    else if (varno == xg->spin_vars.x)
X      xg->spin_vars.x = xg->spin_vars.y;
X    else if (varno == xg->spin_vars.z)
X      xg->spin_vars.z = xg->spin_vars.y;
X    else
X      prev = xg->spin_vars.y;
X
X    xg->spin_vars.y = varno;
X
X  } else if (button == 3) {  /* new z variable */
X    if (varno == xg->spin_vars.z)
X      newvar = 0;
X    else if (varno == xg->spin_vars.x)
X      xg->spin_vars.x = xg->spin_vars.z;
X    else if (varno == xg->spin_vars.y)
X      xg->spin_vars.y = xg->spin_vars.z;
X    else
X      prev = xg->spin_vars.z;
X
X    xg->spin_vars.z = varno;
X  }
X
X  last_touched = varno;
X
X  if (prev != -1) {
X    xg->varchosen[prev] = False;
X    refresh_vbox(xg, prev, 1);
X    xg->varchosen[varno] = True;
X  }
X
X  return(newvar);
}
X
X
/* ARGSUSED */
static XtCallbackProc
varsel_choose_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  Widget label = XtParent(XtParent(w));
X  int varno = -1;
X  Boolean newvar = false;
X
X  for (varno=0; varno<xg->ncols_used; varno++)
X    if (xg->varlabw[varno] == label)
X      break;
X
X  if (xg->is_plotting1d) {
X    extern Boolean plot1d_vertically;
X    plot1d_vertically = (varsel_menu.btn[1] == w);
X    newvar = set_plot1dvar(xg, varno);
X    if (newvar)
X      plot1d_texture_var(xg);
X  }
X  else if (xg->is_xyplotting) {
X
X    if (varsel_menu.btn[0] == w)
X      newvar = set_xyplotxvar(xg, varno);
X    else if (varsel_menu.btn[1] == w)
X      newvar = set_xyplotyvar(xg, varno);
X  }
X  else if (xg->is_touring) {
X
X    if (varsel_menu.btn[0] == w) {
X      set_tourvar(xg, varno);
X    }
X    else if (varsel_menu.btn[1] == w) {
X      set_manip_var(xg, varno);
X    }
X    else if (varsel_menu.btn[2] == w) {
X      set_frozen_var(xg, varno);
X    }
X  }
X  else if (xg->is_corr_touring) {
X    if (varsel_menu.btn[0] == w) {
X      set_xcorrvar(xg, varno);
X    }
X    else if (varsel_menu.btn[1] == w) {
X      set_ycorrvar(xg, varno);
X    }
X    else if (varsel_menu.btn[2] == w) {
X      set_cmanip_var(xg, 1, varno);
X    }
X    else if (varsel_menu.btn[3] == w) {
X      set_cmanip_var(xg, 2, varno);
X    }
X    else if (varsel_menu.btn[5] == w) {
X      set_cxfrozen_var(xg, varno);
X    }
X    else if (varsel_menu.btn[6] == w) {
X      set_cyfrozen_var(xg, varno);
X    }
X  } else if (xg->is_spinning) {
X    int menu_button;
X    if (varsel_menu.btn[0] == w) menu_button = 1;
X    else if (varsel_menu.btn[1] == w) menu_button = 2;
X    else menu_button = 3;
X
/*
X * If I alter the code such that both yaxis and xaxis rotate
X * around the z axis, then I don't need separate variable
X * selection routines for them.
*/
X    if (xg->is_spin_type.yaxis)
X      spin_varsel_ax_from_menu(varno, menu_button, xg);
X    else if (xg->is_spin_type.xaxis)
X      spin_varsel_ax_from_menu(varno, menu_button, xg);
X    else if (xg->is_spin_type.oblique)
X      spin_varsel_oblique_from_menu(varno, menu_button, xg);
X
X    refresh_vbox(xg, xg->spin_vars.x, 1);
X    refresh_vbox(xg, xg->spin_vars.y, 1);
X    refresh_vbox(xg, xg->spin_vars.z, 1);
X  }
X
X  if (newvar)
X  {
X    world_to_plane(xg);
X    plane_to_screen(xg);
X
X    if (xg->is_xyplotting)
X      init_ticks(&xg->xy_vars, xg);
X    else if (xg->is_plotting1d)
X      init_ticks(&xg->plot1d_vars, xg);
X
X    /*
X     * If brushing, screen coordinates just changed and
X     * need to re-bin points before plotting.
X    */
X    if (xg->is_brushing) {
X      assign_points_to_bins(xg);
X
X      if (xg->brush_mode == transient)
X        reinit_transient_brushing(xg);
X    }
X
X    plot_once(xg);
X  }
X
X  XtDestroyWidget((Widget) varsel_menu.cascade);
}
X
/* ARGSUSED */
XXtEventHandler
rm_varsel_menu(Widget w, xgobidata *xg, XEvent *evnt)
/*
X * Remove menus for choosing a data transformation.
*/
{
X  if ((Widget) varsel_menu.cascade != NULL)
X    XtDestroyWidget((Widget) varsel_menu.cascade);
}
X
/* ARGSUSED */
XXtEventHandler
add_varsel_menu(Widget w, xgobidata *xg, XEvent *evnt)
/*
X * Add menus for choosing a data transformation.
*/
{
X  int k, varno, nitems;
X  static char *varsel_menu_name[10];
X
X  if (xg->is_plotting1d)
X  {
X    varsel_menu_name[0] = "Select in X   L";
X    varsel_menu_name[1] = "Select in Y   M",
X    nitems = 2;
X  }
X  else if (xg->is_xyplotting) {
X    varsel_menu_name[0] =  "Select as X   L";
X    varsel_menu_name[1] =  "Select as Y   M";
X    nitems = 2;
X  }
X  else if (xg->is_touring)
X  {
X    varsel_menu_name[0] =  "Tour  L,M";
X    varsel_menu_name[1] =  "Manip  <Shft> L,M";
X    varsel_menu_name[2] =  "Freeze  <Ctrl> L,M";
X    nitems = 3;
X  }
X  else if (xg->is_corr_touring) {
X    varsel_menu_name[0] =  "Tour X   L";
X    varsel_menu_name[1] =  "Tour Y   M";
X    varsel_menu_name[2] =  "Manip X  <Shft> L";
X    varsel_menu_name[3] =  "Manip Y  <Shft> M";
X    varsel_menu_name[4] =  "Freeze X  <Ctrl> L";
X    varsel_menu_name[5] =  "Freeze Y <Ctrl> M";
X    nitems = 6;
X  }
X  else if (xg->is_spinning) {
X    varsel_menu_name[0] =  "X";
X    varsel_menu_name[1] =  "Y";
X    varsel_menu_name[2] =  "Z";
X    nitems = 3;
X  }
X
X  for (varno=0; varno<xg->ncols; varno++)
X    if (xg->varlabw[varno] == w)
X      break;
X
X  varsel_menu.cascade = XtVaCreatePopupShell("menu",
X    simpleMenuWidgetClass, xg->varlabw[varno],
X    XtNinput, True,
X    NULL);
X  if (mono) set_mono(varsel_menu.cascade);
X
X  for (k=0; k<nitems; k++) {
X    varsel_menu.btn[k] = XtVaCreateManagedWidget("Command",
X      smeBSBObjectClass, varsel_menu.cascade,
X      XtNlabel, (String) varsel_menu_name[k],
X      XtNleftMargin, (Dimension) 5,
X      NULL);
X    if (mono) set_mono(varsel_menu.btn[k]);
X    XtAddCallback(varsel_menu.btn[k], XtNcallback,
X      (XtCallbackProc) varsel_choose_cback, (XtPointer) xg);
X  }
X
}
X
void
make_varboxes(xgobidata *xg)
{
X  int j;
X
X  for (j=0; j<xg->ncols-1; j++)
X  {
X    xg->varboxw[j] = XtVaCreateWidget("VarForm",
X      boxWidgetClass, xg->var_panel,
X      NULL);
X    if (mono) set_mono(xg->varboxw[j]);
X  }
X  /*
X   * Create a variable box for the variable that can
X   * be defined in brushing,
X  */
X  xg->varboxw[xg->ncols-1] = XtVaCreateWidget("VarForm",
X    boxWidgetClass, xg->var_panel,
X    XtNmappedWhenManaged, (Boolean) False,
X    NULL);
X  if (mono) set_mono(xg->varboxw[xg->ncols-1]);
X
X  for (j=0; j<xg->ncols; j++) {
X    xg->varlabw[j] = XtVaCreateManagedWidget("VarLabel",
X      menuButtonWidgetClass, xg->varboxw[j],
X      XtNlabel, (String) xg->collab[j],
X      /*XtNleftBitmap, (Pixmap) NULL,*/
X      NULL);
X    if (mono) set_mono(xg->varlabw[j]);
X
X    add_menupb_help(&xg->nhelpids.menupb,
X      xg->varlabw[j], "VarPanel");
X
X    XtAddEventHandler(xg->varlabw[j],
X      ButtonPressMask, FALSE,
X      (XtEventHandler) add_varsel_menu, 
X      (XtPointer) xg);
X    XtAddEventHandler(xg->varlabw[j],
X      ButtonReleaseMask, FALSE,
X      (XtEventHandler) rm_varsel_menu, 
X      (XtPointer) xg);
X  }
X
X  for (j=0; j<xg->ncols; j++) {
X    xg->vardraww[j] = XtVaCreateManagedWidget("VarWindow",
X      labelWidgetClass, xg->varboxw[j],
X      XtNfromVert, (Widget) xg->varlabw[j],
X      XtNlabel, (String) "",
X      NULL);
X    if (mono) set_mono(xg->vardraww[j]);
X
X    if (j == xg->ncols-1)
X      XtVaSetValues(xg->vardraww[j], XtNborderWidth, 1, NULL);
X
X    add_pb_help(&xg->nhelpids.pb,
X      xg->vardraww[j], "VarPanel");
X
X    XtAddEventHandler(xg->vardraww[j],
X      ExposureMask, FALSE,
X      (XtEventHandler) varexpose, (XtPointer) xg);
X    XtAddEventHandler(xg->vardraww[j],
X      ButtonPressMask | ShiftMask | ControlMask | KeyPressMask | 
X      KeyReleaseMask, FALSE,
X      (XtEventHandler) varselect, (XtPointer) xg);
X    XtAddEventHandler(xg->vardraww[j],
X      EnterWindowMask | LeaveWindowMask, FALSE,
X      (XtEventHandler) set_focus_var, (XtPointer) xg);
X  }
X
X  xg->varchosen[0] = True;
X  xg->varchosen[1] = True;
X  for (j=2; j<xg->ncols; j++)
X    xg->varchosen[j] = False;
}
X
void
make_var_mouses(xgobidata *xg)
{
/*
X * VarMouseLabel: the variable selection mouse label for use in
X * xyplotting and axis rotation and correlation tour (var_mouse),
X * grand tour (var_mouse_tour),
X * oblique rotation (var_mouse_oblique),
X * and the var transformation mouse label (var_mouse_tform).
*/
X  Arg args[5];
X
X  XtSetArg(args[0], XtNfromVert, xg->var_panel);
X  XtSetArg(args[1], XtNtop, XtChainBottom);
X  XtSetArg(args[2], XtNbottom, XtChainBottom);
X
X  XtSetArg(args[3], XtNlabel, "L: Select X,  M: Y ");
X  var_mouse = XtCreateManagedWidget("VarMouseLabel",
X    labelWidgetClass, xg->box2, args, 4);
X  if (mono) set_mono(var_mouse);
X
/* The remainder are not initially mapped */
X  XtSetArg(args[3], XtNmappedWhenManaged, False);
X
X  XtSetArg(args[4], XtNlabel, "L: Select X,  M: Y ");
X  var_mouse_plot1d = XtCreateManagedWidget("VarMouseLabel",
X    labelWidgetClass, xg->box2, args, 5);
X  if (mono) set_mono(var_mouse_plot1d);
X
X  XtSetArg(args[4], XtNlabel, "L/M: Select Variable ");
X  var_mouse_oblique = XtCreateManagedWidget("VarMouseLabel",
X    labelWidgetClass, xg->box2, args, 5);
X  if (mono) set_mono(var_mouse_oblique);
X
X  XtSetArg(args[4], XtNlabel, "L/M: Toggle (see Help)");
X  var_mouse_tour = XtCreateManagedWidget("VarMouseLabel",
X    labelWidgetClass, xg->box2, args, 5);
X  if (mono) set_mono(var_mouse_tour);
X
X  XtSetArg(args[4], XtNlabel, "L: X, M: Y (see Help)");
X  var_mouse_corr = XtCreateManagedWidget("VarMouseLabel",
X    labelWidgetClass, xg->box2, args, 5);
X  if (mono) set_mono(var_mouse_corr);
X
X  XtSetArg(args[4], XtNlabel, "L: Transform Variable ");
X  var_mouse_tform = XtCreateManagedWidget("VarMouseLabel",
X    labelWidgetClass, xg->box2, args, 5);
X  if (mono) set_mono(var_mouse_tform);
}
X
void
make_varpanel(xgobidata *xg)
{
X  int j;
X  Dimension width, height;
X
/*
X * VarPanel: contains all variable selection widgets.
*/
X  XtVaGetValues(xg->workspace, XtNheight, &height, NULL);
X
X  xg->var_panel = XtVaCreateManagedWidget("VarPanel",
X    boxWidgetClass, xg->box2,
X    XtNheight, (Dimension) height,
X    /*XtNfromVert, (Widget) var_mouse,*/
X    NULL);
X  if (mono) set_mono(xg->var_panel);
X
X  xg->varboxw = (Widget *) XtMalloc(
X    (Cardinal) xg->ncols * sizeof(Widget));
X  xg->varlabw = (Widget *) XtMalloc(
X    (Cardinal) xg->ncols * sizeof(Widget));
X  xg->vardraww = (Widget *) XtMalloc(
X    (Cardinal) xg->ncols * sizeof(Widget));
X  xg->varchosen = (Boolean *) XtMalloc(
X    (Cardinal) xg->ncols * sizeof(Boolean));
X
X  make_varboxes(xg);
X  XtManageChildren(xg->varboxw, (unsigned int) xg->ncols);
X
/*
X * Force the variable drawing area to be square; assign the
X * value of radius which is used in drawing the lines.
*/
X  XtVaGetValues(xg->vardraww[0], XtNwidth, &width, NULL);
X  xg->radius = width/2 - 1;
X
X  for (j=0; j<xg->ncols; j++)
X    XtVaSetValues(xg->vardraww[j], XtNheight, (Dimension) width, NULL);
X
X  make_var_mouses(xg);
}
X
void
draw_last_touched(xgobidata *xg)
/*
X * If the cursor is inside the var_panel widget, then draw the
X * circle indicating which variable is last_touched.
*/
{
X  if (cursor_in_panel)
X  {
X    XDrawArc(display, XtWindow(xg->vardraww[last_touched]),
X      varpanel_copy_GC,
X      (int) (xg->radius - 5), (int) (xg->radius - 5),
X      (unsigned int) 10, (unsigned int) 10,
X      0, 360*64);
X  }
}
X
void
get_vlab_colors(xgobidata *xg, WidgetColors *vlab_colors)
{
X  int j;
X
X  XtVaGetValues(xg->varlabw[0],
X    XtNforeground, &vlab_colors->fg,
X    XtNbackground, &vlab_colors->bg,
X    XtNborderColor, &vlab_colors->border, NULL);
X
X  for (j=1; j<xg->ncols_used; j++) {
X    if (xg->varchosen[j] == False) {
X      XtVaGetValues(xg->varlabw[j],
X        XtNforeground, &vlab_colors->fg,
X        XtNbackground, &vlab_colors->bg,
X        XtNborderColor, &vlab_colors->border, NULL);
X      break;
X    }
X  }
}
X
void
refresh_vlab(int varno, xgobidata *xg)
/*
X * this routine will check what highlighting the variable has
X * and will change it or leave it the same according to whether
X * caller wants a highlighted or a dehighlighted label.
*/
{
X  static int init = 0;
X  Boolean chosen = xg->varchosen[varno];
X  static WidgetColors vlab_colors;
X
X  if (!init)
X  {
X    get_vlab_colors(xg, &vlab_colors);
X    init = 1;
X  }
X
X  if (chosen)
X  {
X    XtVaSetValues(xg->varlabw[varno],
X      XtNforeground, vlab_colors.bg,
X      XtNbackground, vlab_colors.fg, NULL);
X  }
X  else
X  {
X    XtVaSetValues(xg->varlabw[varno],
X      XtNforeground, vlab_colors.fg,
X      XtNbackground, vlab_colors.bg, NULL);
X  }
}
X
void
refresh_vbox(xgobidata *xg, int varno, int do_label)
/*
X * the purpose of this function is to refresh the variable bars
X * appropriately when changing between modes
X * and to refresh the labels.
*/
{
X  int x, y;
X  Widget vwsp = xg->vardraww[varno];
X  Window vwin = XtWindow(vwsp);
X  unsigned int r = xg->radius;
X  XGCValues *gcv, gcv_inst;
X  Boolean initd = False;
X
X  if (!initd) {
X    int j;
X    long varfg, varbg;
X    Pixmap xyp;
X    XColor fc, bc;
X    Colormap cmap = DefaultColormap(display, DefaultScreen(display));
X
X    xyp = XCreateBitmapFromData(display,
X        DefaultRootWindow(display),
X        (char *) xy_bits, xy_width, xy_height);
X
X    XtVaGetValues(vwsp,
X      XtNforeground, &varfg,
X      XtNbackground, &varbg,
X      NULL);
X
X    fc.pixel = varfg;
X    bc.pixel = varbg;
X    XQueryColor(display, cmap, &fc);
X    XQueryColor(display, cmap, &bc);
X
X    xy_cursor = XCreatePixmapCursor(display, xyp, xyp,
X      &fc, &bc, 1, 1);
X
X    for (j=0; j<xg->ncols; j++)
X      XDefineCursor(display, XtWindow(xg->vardraww[j]), xy_cursor);
X
X    initd = True;
X  }
X
X  XGetGCValues(display, varpanel_xor_GC, GCCapStyle|GCJoinStyle, &gcv_inst);
X  gcv = &gcv_inst;
X  XClearWindow(display, vwin);
X
X  if (varno == focus_var)
X    XSetLineAttributes(display, varpanel_xor_GC, 3, LineSolid,
X      gcv->cap_style, gcv->join_style);
X  else if (xg->varchosen[varno])
X    XSetLineAttributes(display, varpanel_xor_GC, 2, LineSolid,
X      gcv->cap_style, gcv->join_style);
X
X  XDrawArc(display, vwin, varpanel_xor_GC, 0, 0,
X    (unsigned int) 2*r, (unsigned int) 2*r,
X    0, 360*64);
X
X  if (xg->is_xyplotting) {
X    if (xg->varchosen[varno]) {
X      if (varno == xg->xy_vars.x) {
X        ChooseX(vwin, r, r);
X      } else if (varno == xg->xy_vars.y) {
X        ChooseY(vwin, r, r);
X      }
X    }
X  }
X
X  else if (xg->is_plotting1d) {
X    if (xg->varchosen[varno]) {
X      if (varno == xg->plot1d_vars.y) {
X        ChooseY(vwin, r, r);
X      } else if (varno == xg->plot1d_vars.x) {
X        ChooseX(vwin, r, r);
X      }
X    }
X  }
X
X  else if (xg->is_spinning)
X  {
X    static Boolean spin_initd = false;
X    static int rx, ry;
X    if (!spin_initd) {
X      int ascent, descent, direction;
X      XCharStruct overall;
X      XTextExtents(appdata.font, "x", 1,
X        &direction, &ascent, &descent, &overall);
X      ry = r + ascent + descent - 1;
X      rx = r + r/4;
X      spin_initd = true;
X    }
X    if (xg->varchosen[varno]) {
X      if (xg->is_spin_type.yaxis) {   /* Using vertical axis */
X        if (varno == xg->spin_vars.x) {
X          ChooseX(vwin, r, r * xg->ocost.y/PRECISION2);
X          XDrawString(display, vwin, varpanel_copy_GC, rx, ry, "x", 2);
X        } else if (varno == xg->spin_vars.y) {
X          ChooseX(vwin, r, r * xg->osint.y/PRECISION2);
X          XDrawString(display, vwin, varpanel_copy_GC, rx, ry, "y", 2);
X        } else if (varno == xg->spin_vars.z) {
X          ChooseY(vwin, r, r);
X          XDrawString(display, vwin, varpanel_copy_GC, rx, ry, "z", 2);
X        }
X      }
X      else if (xg->is_spin_type.xaxis) {  /* Using horizontal axis */
X        if (varno == xg->spin_vars.x) {
X          ChooseY(vwin, r, r * xg->ocost.x/PRECISION2);
X          XDrawString(display, vwin, varpanel_copy_GC, rx, ry, "x", 2);
X        } else if (varno == xg->spin_vars.y) {
X          ChooseY(vwin, r, r * xg->osint.x/PRECISION2);
X          XDrawString(display, vwin, varpanel_copy_GC, rx, ry, "y", 2);
X        } else if (varno == xg->spin_vars.z) {
X          ChooseX(vwin, r, r);
X          XDrawString(display, vwin, varpanel_copy_GC, rx, ry, "z", 2);
X        }
X      }
X      else if (xg->is_spin_type.oblique) {
X        float fr = (float) r;
X        if (varno == xg->spin_vars.x) {
X          xg->xax.x = INT(fr * xg->Rmat0[0][0]);
X          xg->xax.y = INT(fr * xg->Rmat0[1][0]);
X          ChooseVar(vwin, r, xg->xax.x, xg->xax.y);
X          XDrawString(display, vwin, varpanel_copy_GC, rx, ry, "x", 2);
X        } else if (varno == xg->spin_vars.y) {
X          xg->yax.x = INT(fr * xg->Rmat0[0][1]);
X          xg->yax.y = INT(fr * xg->Rmat0[1][1]);
X          ChooseVar(vwin, r, xg->yax.x, xg->yax.y);
X          XDrawString(display, vwin, varpanel_copy_GC, rx, ry, "y", 2);
X        } else if (varno == xg->spin_vars.z) {
X          xg->zax.x = INT(fr * xg->Rmat0[0][2]);
X          xg->zax.y = INT(fr * xg->Rmat0[1][2]);
X          ChooseVar(vwin, r, xg->zax.x, xg->zax.y);
X          XDrawString(display, vwin, varpanel_copy_GC, rx, ry, "z", 2);
X        }
X      }
X      if (varno == last_touched)
X        draw_last_touched(xg);
X    }
X  }
X  else if (xg->is_touring) {
X    x = INT(FLOAT(r) * xg->uold[0][varno]);
X    y = INT(FLOAT(r) * xg->uold[1][varno]);
X    ChooseVar(vwin, r, x, y);
X    if (varno == xg->manip_var)
X        draw_manip_var(xg);
X    draw_frozen_var(xg);
X  }
X  else if (xg->is_corr_touring) {
X    calc_var_xy(xg, (int) r, varno, &x, &y);
X    ChooseVar(vwin, r, x, y);
X    if (varno == xg->corr_xmanip_var || varno == xg->corr_ymanip_var)
X      draw_cmanip_var(xg);
X    draw_cfrozen_var(xg);
X  }
X
X  if (xg->varchosen[varno] || varno == focus_var)
X    XSetLineAttributes(display, varpanel_xor_GC, 0, LineSolid,
X      gcv->cap_style, gcv->join_style);
X
X  if (do_label)
X    refresh_vlab(varno, xg);
}
X
void
refresh_vboxes(xgobidata *xg)
{
X  int j;
X  int do_label = 1;
X
X  for (j=0; j<xg->ncols_used; j++)
X    refresh_vbox(xg, j, do_label);
X  if (xg->is_spinning)
X    draw_last_touched(xg);
X  if (xg->is_touring)
X  {
X    draw_manip_var(xg);
X    draw_frozen_var(xg);
X  }
X  if (xg->is_corr_touring)
X  {
X    draw_cmanip_var(xg);
X    draw_cfrozen_var(xg);
X  }
}
X
X
/********** Rotation **************/
X
/* ARGSUSED */
XXtActionProc
ShowTarget(Widget w, XEvent *event, String *params, Cardinal nparams)
{
/*
X * If the cursor is outside the variable selection panel, check
X * for its entry.
*/
X  XCrossingEvent *evnt = (XCrossingEvent *) event;
X
X  if (xgobi.is_spinning &&
X    !cursor_in_panel &&
X    evnt->type == EnterNotify)
X  {
X    cursor_in_panel = 1;
X    draw_last_touched(&xgobi);
X  }
}
X
/* ARGSUSED */
XXtActionProc
DontShowTarget(Widget w, XEvent *event, String *params, Cardinal nparams)
{
/*
X * If the cursor is inside the variable selection panel, look for
X * LeaveNotify events.  The detail member of the XCrossing Event
X * structure is NotifyInferior if the cursor has entered the window
X * belonging to a child widget of the window receiving the event.
*/
X  XCrossingEvent *evnt = (XCrossingEvent *) event;
X
X  if (xgobi.is_spinning &&
X    cursor_in_panel &&
X    evnt->type == LeaveNotify &&
X    evnt->detail != NotifyInferior)
X  {
X    cursor_in_panel = 0;
X    refresh_vbox(&xgobi, last_touched, 0);
X  }
}
X
void
reset_last_touched(xgobidata *xg)
{
/*
X * Reset the last_touched variable when moving between
X * y axis and x axis rotation.
*/
X  if (xg->is_spin_type.yaxis)
X  {
X    if (last_touched == xg->spin_vars.y)
X      last_touched = xg->spin_vars.x;
X  }
X  else if (xg->is_spin_type.xaxis)
X  {
X    if (last_touched == xg->spin_vars.x)
X      last_touched = xg->spin_vars.y;
X  }
}
X
void
spin_var_lines(xgobidata *xg)
{
X  Window vwin;
X  static Boolean spin_initd = false;
X  unsigned int r = xg->radius;
X  static int rx, ry;
X  XGCValues *gcv, gcv_inst;
X  XGetGCValues(display, varpanel_xor_GC, GCCapStyle|GCJoinStyle, &gcv_inst);
X  gcv = &gcv_inst;
X
X  XSetLineAttributes(display, varpanel_xor_GC, 2, LineSolid,
X    gcv->cap_style, gcv->join_style);
X
X  if (!spin_initd) {
X    int ascent, descent, direction;
X    XCharStruct overall;
X    XTextExtents(appdata.font, "x", 1,
X      &direction, &ascent, &descent, &overall);
X    ry = r + ascent + descent - 1;
X    rx = r + r/4;
X    spin_initd = true;
X  }
X    
X  if (xg->is_spin_type.yaxis)   /* Using vertical axis */
X  {
X    vwin = XtWindow(xg->vardraww[xg->spin_vars.x]);
X    ChooseX(vwin, xg->radius, xg->radius * xg->ocost.y/PRECISION2);
X    ChooseX(vwin, xg->radius, xg->radius * xg->icost.y/PRECISION2);
X    XDrawString(display, vwin, varpanel_copy_GC, rx, ry, "x", 2);
X
X    vwin = XtWindow(xg->vardraww[xg->spin_vars.y]);
X    ChooseX(vwin, xg->radius, xg->radius * xg->osint.y/PRECISION2);
X    ChooseX(vwin, xg->radius, xg->radius * xg->isint.y/PRECISION2);
X    XDrawString(display, vwin, varpanel_copy_GC, rx, ry, "y", 2);
X
X    xg->ocost.y = xg->icost.y;
X    xg->osint.y = xg->isint.y;
X  }
X  /*
X   * Using horizontal axis in the plane of the screen
X  */
X  else if (xg->is_spin_type.xaxis)
X  {
X    vwin = XtWindow(xg->vardraww[xg->spin_vars.x]);
X    ChooseY(vwin, xg->radius, xg->radius * xg->ocost.x/PRECISION2);
X    ChooseY(vwin, xg->radius, xg->radius * xg->icost.x/PRECISION2);
X    XDrawString(display, vwin, varpanel_copy_GC, rx, ry, "x", 2);
X
X    vwin = XtWindow(xg->vardraww[xg->spin_vars.y]);
X    ChooseY(vwin, xg->radius, xg->radius * xg->osint.x/PRECISION2);
X    ChooseY(vwin, xg->radius, xg->radius * xg->isint.x/PRECISION2);
X    XDrawString(display, vwin, varpanel_copy_GC, rx, ry, "y", 2);
X
X    xg->ocost.x = xg->icost.x;
X    xg->osint.x = xg->isint.x;
X  }
X
X  XSetLineAttributes(display, varpanel_xor_GC, 0, LineSolid,
X    gcv->cap_style, gcv->join_style);
X
X  draw_last_touched(xg);
}
X
int
spin_varsel_oblique(int varno, xgobidata *xg)
{
X  int prev, newvar = 1;
X
X  if (varno == xg->spin_vars.x ||
X    varno == xg->spin_vars.y ||
X    varno == xg->spin_vars.z)
X   {
X    prev = last_touched;
X    last_touched = varno;
X    refresh_vbox(xg, prev, 0);
X    newvar = 0;
X  }
X  else
X  {
X    if (last_touched == xg->spin_vars.x)
X      xg->spin_vars.x = varno;
X    else if (last_touched == xg->spin_vars.y)
X      xg->spin_vars.y = varno;
X    else if (last_touched == xg->spin_vars.z)
X      xg->spin_vars.z = varno;
X
X    prev = last_touched;
X    xg->varchosen[prev] = False;
X    refresh_vbox(xg, prev, 1);
X
X    last_touched = varno;
X    xg->varchosen[varno] = True;
X  }
X  return(newvar);
}
X
int
spin_varsel_ax(int varno, int button, int state, xgobidata *xg)
{
/*
X * Here x and y are plotted horizontally; z is plotted vertically.
X * or
X * x and y are plotted vertically; z is plotted horizontally.
*/
X  int prev = -1, newvar = 1;
X  Boolean leftClick = (button == 1 && state != 8); /* alt not pressed */
X  Boolean rightClick = (button == 2 || button == 1 && state == 8);
X
X  if ((xg->is_spin_type.yaxis && leftClick) ||
X      (xg->is_spin_type.xaxis && rightClick))
X  {
X
X    if (varno == xg->spin_vars.x || varno == xg->spin_vars.y)
X      ;
X
X    else if (varno == xg->spin_vars.z) {
X
X      /*
X       * If it's the chosen y variable, exchange y and last_touched.
X      */
X      if (last_touched == xg->spin_vars.x) {
X        last_touched = xg->spin_vars.z = xg->spin_vars.x;
X        xg->spin_vars.x = varno;
X      } else if (last_touched == xg->spin_vars.y) {
X        last_touched = xg->spin_vars.z = xg->spin_vars.y;
X        xg->spin_vars.y = varno;
X      }
X    }
X    /*
X     * Else, the new variable replaces last_touched.
X    */
X    else {
X      prev = last_touched;
X      if (last_touched == xg->spin_vars.x) {
X        xg->spin_vars.x = varno;
X      } else if (last_touched == xg->spin_vars.y) {
X        xg->spin_vars.y = varno;
X      }
X    }
X    last_touched = varno;
X
X  } else if ((xg->is_spin_type.yaxis && rightClick) ||
X             (xg->is_spin_type.xaxis && leftClick))
X  {
X
X    /*
X     * Is it already a chosen z variable?  If so, ignore.
X    */
X    if (varno == xg->spin_vars.z)
X      newvar = 0;
X    /*
X     * If it's the chosen x variable, exchange z for the chosen x.
X    */
X    else if (varno == xg->spin_vars.x) {
X      last_touched = xg->spin_vars.x = xg->spin_vars.z;
X    } else if (varno == xg->spin_vars.y) {
X      last_touched = xg->spin_vars.y = xg->spin_vars.z;
X    } else {
X      prev = xg->spin_vars.z;
X    }
X    xg->spin_vars.z = varno;
X  }
X
X  if (prev != -1) {
X    xg->varchosen[prev] = False;
X    refresh_vbox(xg, prev, 1);
X    xg->varchosen[varno] = True;
X  }
X
X  return(newvar);
}
X
X
int
spin_varselect(int varno, int button, int state, xgobidata *xg)
/*
X * This is the routine called during rotation to handle changes in
X * variables entering the plot.  Call refresh_vbox() with instructions
X * to call refresh_vlab().
*/
{
X  int newvar = 1;
X
X  if (xg->is_spin_type.yaxis || xg->is_spin_type.xaxis)
X    newvar = spin_varsel_ax(varno, button, state, xg);
X
X  else if (xg->is_spin_type.oblique)
X    newvar = spin_varsel_oblique(varno, xg);
X
X  if (newvar)
X    refresh_vboxes(xg);
X
X  return(newvar);
}
X
void
draw_ob_var_lines(xgobidata *xg)
{
X  Window vwin;
X  static Boolean spin_initd = false;
X  int r = xg->radius;
X  static int rx, ry;
X  float fr = (float) xg->radius;
X  XGCValues *gcv, gcv_inst;
X  XGetGCValues(display, varpanel_xor_GC, GCCapStyle|GCJoinStyle, &gcv_inst);
X  gcv = &gcv_inst;
X
X  XSetLineAttributes(display, varpanel_xor_GC, 2, LineSolid,
X    gcv->cap_style, gcv->join_style);
X
X  if (!spin_initd) {
X    int ascent, descent, direction;
X    XCharStruct overall;
X    XTextExtents(appdata.font, "x", 1,
X      &direction, &ascent, &descent, &overall);
X    ry = r + ascent + descent - 1;
X    rx = r + r/4;
X    spin_initd = true;
X  }
X
X  vwin = XtWindow(xg->vardraww[xg->spin_vars.x]);
X  ChooseVar(vwin, r, xg->xax.x, xg->xax.y);
X  xg->xax.x = INT(fr * xg->Rmat0[0][0]);
X  xg->xax.y = INT(fr * xg->Rmat0[1][0]);
X  ChooseVar(vwin, r, xg->xax.x, xg->xax.y);
X  XDrawString(display, vwin, varpanel_copy_GC, rx, ry, "x", 2);
X
X  vwin = XtWindow(xg->vardraww[xg->spin_vars.y]);
X  ChooseVar(vwin, r, xg->yax.x, xg->yax.y);
X  xg->yax.x = INT(fr * xg->Rmat0[0][1]);
X  xg->yax.y = INT(fr * xg->Rmat0[1][1]);
X  ChooseVar(vwin, r, xg->yax.x, xg->yax.y);
X  XDrawString(display, vwin, varpanel_copy_GC, rx, ry, "y", 2);
X
X  vwin = XtWindow(xg->vardraww[xg->spin_vars.z]);
X  ChooseVar(vwin, r, xg->zax.x, xg->zax.y);
X  xg->zax.x = INT(fr * xg->Rmat0[0][2]);
X  xg->zax.y = INT(fr * xg->Rmat0[1][2]);
X  ChooseVar(vwin, r, xg->zax.x, xg->zax.y);
X  XDrawString(display, vwin, varpanel_copy_GC, rx, ry, "z", 2);
X
X  XSetLineAttributes(display, varpanel_xor_GC, 0, LineSolid,
X    gcv->cap_style, gcv->join_style);
X
X  draw_last_touched(xg);
}
X
/********** Grand Tour ************/
X
void
tour_var_lines(xgobidata *xg)
{
X  int j;
X  int x, y;
X  int r = xg->radius;
X  float fr = (float) xg->radius;
X  Window vwin;
X  XGCValues *gcv, gcv_inst;
X  XGetGCValues(display, varpanel_xor_GC, GCCapStyle|GCJoinStyle, &gcv_inst);
X  gcv = &gcv_inst;
X
X  if (xg->is_touring) {
X    for (j=0; j<xg->ncols_used; j++) {
X      if (xg->varchosen[j])
X        XSetLineAttributes(display, varpanel_xor_GC, 2, LineSolid,
X          gcv->cap_style, gcv->join_style);
X    
X      vwin = XtWindow(xg->vardraww[j]);
X      x = INT(fr * xg->uold[0][j]);
X      y = INT(fr * xg->uold[1][j]);
X      ChooseVar(vwin, r, x, y);
X      x = INT(fr * xg->u[0][j]);
X      y = INT(fr * xg->u[1][j]);
X      ChooseVar(vwin, r, x, y);
X      xg->uold[0][j] = xg->u[0][j];
X      xg->uold[1][j] = xg->u[1][j];
X
X      if (xg->varchosen[j])
X        XSetLineAttributes(display, varpanel_xor_GC, 0, LineSolid,
X          gcv->cap_style, gcv->join_style);
X    }
X  }
}
X
int
add_variable(xgobidata *xg, int varno)
{
X  int found, i, j;
X
X  xg->varchosen[varno] = True;
X  found = 0;
X  if (varno < xg->tour_vars[0])
X  {
X    for (j=xg->numvars_t; j>0; j--)
X      xg->tour_vars[j] = xg->tour_vars[j-1];
X    xg->tour_vars[0] = varno;
X    xg->numvars_t += 1;
X    found = 1;
X  }
X  i = 0;
X  while (!found && i < xg->numvars_t-1 )
X  {
X    if ( varno > xg->tour_vars[i]  &&
X         varno < xg->tour_vars[i+1] )
X    {
X      for (j=xg->numvars_t; j>i; j--)
X        xg->tour_vars[j+1] = xg->tour_vars[j];
X       xg->tour_vars[i+1] = varno;
X       xg->numvars_t += 1;
X       found = 1;
X    }
X    i++;
X  }
X  if (!found && (varno > xg->tour_vars[xg->numvars_t-1]))
X  {
X    xg->tour_vars[xg->numvars_t] = varno;
X    xg->numvars_t += 1;
X    found = 1;
X  }
X
X  return(found);
}
X
void
remove_variable(xgobidata *xg, int varno)
{
X  int i, j, found, itmp;
X
X  /* for frozen variables we want this to remain true -
X     if this routine is ever called for another purpose this line will 
X     need to be changed */
X  xg->varchosen[varno] = True;
X  i = 0;
X  found = 0;
X  while (!found)
X  {
X    if (varno == xg->tour_vars[i])
X    {
X      itmp = i;
X
X      xg->numvars_t -= 1;
X      for (j=itmp; j<xg->numvars_t; j++)
X        xg->tour_vars[j] = xg->tour_vars[j+1];
X
X      found = 1;
X      refresh_vbox(xg, varno, 1);
X    }
X    i++;
X  } /* end while */
X
}
X
X
int
tour_varselect(int varno, int state, xgobidata *xg)
/*
X * This routine is called during grand touring to handle changes
X * in variables included in plot. It calls refresh_vbox() with
X * further call to refresh_vlab() to handle variable box refreshes
X * and label highlighting.
*/
{
X  int newvar = 0;
X
X  if (state == 0)
X    set_tourvar(xg, varno);
X  else if (state == 1)
X    set_manip_var(xg, varno);
X  else if (state == 4)
X    set_frozen_var(xg, varno);
X  
X  return(newvar);
}
X
void
set_varpanel_for_receive_tour(xgobidata *xg)
{
X  int j, var;
X  void refresh_vlab();
X
X  if (xg->tour_link_state == receive)  /* If receive was just turned on ... */
X  {
X    for (j=0; j<xg->ncols_used; j++)
X    {
X      if (xg->varchosen[j])
X      {
X        xg->varchosen[j] = False;
X        refresh_vbox(xg, j, True);
X      }
X    }
X  }
X  else  /* else if receive was just turned off ... */
X  {
X    for (j=0; j<xg->numvars_t; j++)
X    {
X      var = xg->tour_vars[j];
X      xg->varchosen[var] = True;
X      refresh_vbox(xg, j, True);
X    }
X  }
}
X
void
map_group_var(xgobidata *xg)
{
X  XtVaSetValues(xg->varlabw[xg->ncols-1],
X    XtNlabel, (String) xg->collab_tform2[xg->ncols-1],
X    NULL);
X  XtMapWidget(xg->varboxw[xg->ncols-1]);
}
X
void
carry_spin_vars(xgobidata *xg)
{
X  int j;
X
X  if (xg->is_plotting1d) {
X   if (xg->plot1d_vars.y != -1) {
X      xg->spin_vars.y = xg->plot1d_vars.y;
X      for (j=0; j<xg->ncols; j++)
X        if (j != xg->spin_vars.y) {
X          xg->spin_vars.x = j;
X          break;
X        }
X    } else {
X      xg->spin_vars.x = xg->plot1d_vars.x;
X      for (j=0; j<xg->ncols; j++)
X        if (j != xg->spin_vars.x) {
X          xg->spin_vars.y = j;
X          break;
X        }
X    }
X
X    for (j=0; j<xg->ncols; j++) {
X      if (j != xg->spin_vars.x && j != xg->spin_vars.y) {
X        xg->spin_vars.z = j;
X        break;
X      }
X    }
X  }
X  else if (xg->is_xyplotting) {
X    xg->spin_vars.x = xg->xy_vars.x;
X    xg->spin_vars.y = xg->xy_vars.y;
X    for (j=0; j<xg->ncols; j++)
X      if (j != xg->spin_vars.x && j != xg->spin_vars.y) {
X        xg->spin_vars.z = j;
X        break;
X      }
X  }
X  else if (xg->is_touring) {
X    xg->spin_vars.x = xg->tour_vars[0];
X    xg->spin_vars.z = xg->tour_vars[2];
X    xg->spin_vars.y = xg->tour_vars[1];
X  }
X  else if (xg->is_corr_touring) {
X    xg->spin_vars.x = xg->corr_xvars[0];
X    xg->spin_vars.z = xg->corr_xvars[1];
X    xg->spin_vars.y = xg->corr_yvars[0];
X  }
X
X  /*
X   * The target variable may have been deselected.
X  */
X  if (last_touched != xg->spin_vars.x &&
X    last_touched != xg->spin_vars.y &&
X    last_touched != xg->spin_vars.z)
X  {
X    last_touched = xg->spin_vars.z;
X  }
X
X  reinit_spin(xg);
X  reset_last_touched(xg);
}
X
void
carry_tour_vars(xgobidata *xg)
{
X  int i, inc;
X
X  if (xg->is_plotting1d) {
X    inc = 0;
X    for (i=0; i<xg->numvars_t; i++) {
X      if (xg->tour_vars[i] == xg->plot1d_vars.y ||
X          xg->tour_vars[i] == xg->plot1d_vars.x)
X      {
X        inc = 1;
X        break;
X      }
X    }
X
X    if (inc) {
X      if (xg->tour_vars[1] == xg->plot1d_vars.y ||
X          xg->tour_vars[1] == xg->plot1d_vars.x)
X        ;
X      else {
X        for (i=0; i<xg->numvars_t; i++) {
X          if (xg->tour_vars[i] == xg->plot1d_vars.y ||
X              xg->tour_vars[i] == xg->plot1d_vars.x)
X          {
X            xg->tour_vars[i] = xg->tour_vars[1];
X            xg->tour_vars[1] = (xg->plot1d_vars.y != -1) ?
X              xg->plot1d_vars.y : xg->plot1d_vars.x;
X            break;
X          }
X        }
X      }
X    } else {
X      xg->tour_vars[xg->numvars_t] = xg->tour_vars[1];
X      xg->tour_vars[1] = (xg->plot1d_vars.y != -1) ?
X        xg->plot1d_vars.y : xg->plot1d_vars.x;
X      xg->numvars_t++;
X    }
X  }
X
X  else if (xg->is_xyplotting) {
X  /*
X   * First see if xy_vars.x is included.
X  */
X    inc = 0;
X    for (i=0; i<xg->numvars_t; i++) {
X      if (xg->tour_vars[i] == xg->xy_vars.x) {
X        inc = 1;
X        break;
X      }
X    }
X
X    if (inc) {
X      if (xg->tour_vars[0] == xg->xy_vars.x)
X        ;
X      else {
X        for (i=0; i<xg->numvars_t; i++) {
X          if (xg->tour_vars[i] == xg->xy_vars.x) {
X            xg->tour_vars[i] = xg->tour_vars[0];
X            xg->tour_vars[0] = xg->xy_vars.x;
X            break;
X          }
X        }
X      }
X    } else {
X      xg->tour_vars[xg->numvars_t] = xg->tour_vars[0];
X      xg->tour_vars[0] = xg->xy_vars.x;
X      xg->numvars_t++;
X    }
X
X  /*
X   * Then see if xy_vars.y is included.
X  */
X    inc = 0;
X    for (i=0; i<xg->numvars_t; i++) {
X      if (xg->tour_vars[i] == xg->xy_vars.y) {
X        inc = 1;
X        break;
X      }
X    }
X
X    if (inc) {
X      if (xg->tour_vars[1] == xg->xy_vars.y)
X        ;
X      else {
X        for (i=0; i<xg->numvars_t; i++) {
X          if (xg->tour_vars[i] == xg->xy_vars.y) {
X            xg->tour_vars[i] = xg->tour_vars[1];
X            xg->tour_vars[1] = xg->xy_vars.y;
X            break;
X          }
X        }
X      }
X    } else {
X      xg->tour_vars[xg->numvars_t] = xg->tour_vars[1];
X      xg->tour_vars[1] = xg->xy_vars.y;
X      xg->numvars_t++;
X    }
X  }
X
X  else if (xg->is_spinning) {
X    /*
X     * Switch to three variables ...
X    */
X    xg->tour_vars[0] = xg->spin_vars.x;
X    xg->tour_vars[1] = xg->spin_vars.y;
X    xg->tour_vars[2] = xg->spin_vars.z;
X    xg->numvars_t = 3;
X    reinit_tour(xg);
X  }
X  else if (xg->is_corr_touring) {
X    xg->numvars_t = 0;
X
X    for (i=0; i<xg->ncorr_xvars; i++) {
X      xg->tour_vars[i] = xg->corr_xvars[i];
X      xg->numvars_t++ ;
X    }
X    for (i=0;i<xg->ncorr_yvars;i++) {
X      xg->tour_vars[i+xg->ncorr_xvars] = xg->corr_yvars[i];
X      xg->numvars_t++ ;
X    }
X    reinit_tour(xg);
X  }
}
X
void
carry_xyplot_vars(xgobidata *xg)
{
/*
X * When entering XYPlot from another mode with carry_vars
X * set to True, do this ...
*/
X  if (xg->is_plotting1d) {
X    if (xg->xy_vars.y == xg->plot1d_vars.y)
X      ;
X    else if (xg->xy_vars.x == xg->plot1d_vars.x)
X      ;
X    else if (xg->xy_vars.x == xg->plot1d_vars.y) {
X      xg->xy_vars.x = xg->xy_vars.y;
X      xg->xy_vars.y = xg->plot1d_vars.y;
X
X    } else if (xg->xy_vars.y == xg->plot1d_vars.x) {
X      xg->xy_vars.y = xg->xy_vars.x;
X      xg->xy_vars.x = xg->plot1d_vars.x;
X    }
X  }
X  else if (xg->is_spinning) {
X    xg->xy_vars.y = xg->spin_vars.y;
X    xg->xy_vars.x = xg->spin_vars.x;
X  }
X  else if (xg->is_touring) {
X    xg->xy_vars.y = xg->tour_vars[1];
X    xg->xy_vars.x = xg->tour_vars[0];
X  }
X  else if (xg->is_corr_touring) {
X    xg->xy_vars.x = xg->corr_xvars[0];
X    xg->xy_vars.y = xg->corr_yvars[0];
X  }
}
X
void
carry_plot1d_vars(xgobidata *xg)
{
/*
X * When entering Plot1D from another mode with carry_vars
X * set to True, do this ...
*/
X
X  if (xg->is_xyplotting) {
X    if (xg->plot1d_vars.y != -1)
X      xg->plot1d_vars.y = xg->xy_vars.y;
X    else
X      xg->plot1d_vars.x = xg->xy_vars.x;
X  }
X
X  else if (xg->is_spinning) {
X    if (xg->plot1d_vars.y != -1)
X      xg->plot1d_vars.y = xg->spin_vars.y;
X    else
X      xg->plot1d_vars.x = xg->spin_vars.x;
X  }
X
X  else if (xg->is_touring) {
X    if (xg->plot1d_vars.y != -1)
X      xg->plot1d_vars.y = xg->tour_vars[1];
X    else
X      xg->plot1d_vars.x = xg->tour_vars[0];
X  }
X
X  else if (xg->is_corr_touring) {
X    if (xg->plot1d_vars.y != -1)
X      xg->plot1d_vars.y = xg->corr_yvars[0];
X    else
X      xg->plot1d_vars.x = xg->corr_xvars[0];
X  }
}
X
/* dfs: asking di for help with this one */
void
carry_corr_vars(xgobidata *xg)
{
X  int i, inc;
X
X  if (xg->is_plotting1d) {
X    inc = 0;
X    for (i=0; i<xg->ncorr_yvars; i++) {
X      if (xg->corr_xvars[i] == xg->plot1d_vars.y) {
X        inc = 1;
X        break;
X      }
X    }
X
X    if (inc) {
X      if (i != 0) {
X        xg->corr_yvars[i] = xg->corr_yvars[0];
X        xg->corr_yvars[0] = xg->plot1d_vars.y;
X      }
X    } else {
X      xg->corr_yvars[xg->ncorr_yvars] = xg->corr_yvars[0];
X      xg->corr_yvars[0] = xg->plot1d_vars.y;
X      xg->ncorr_yvars++;
X    }
X  }
X
X  else if (xg->is_xyplotting) {
X  /*
X   * First see if xy_vars.x is included.
X  */
X    inc = 0;
X    for (i=0; i<xg->ncorr_xvars; i++) {
X      if (xg->corr_xvars[i] == xg->xy_vars.x) {
X        inc = 1;
X        break;
X      }
X    }
X
X    if (inc) {
X      if (i != 0) {
X        xg->corr_xvars[i] = xg->corr_xvars[0];
X        xg->corr_xvars[0] = xg->xy_vars.x;
X      }
X    } else {
X      xg->corr_xvars[xg->ncorr_xvars] = xg->corr_xvars[0];
X      xg->corr_xvars[0] = xg->xy_vars.x;
X      xg->ncorr_xvars++;
X    }
X
X  /*
X   * Then see if xy_vars.y is included.
X  */
X    inc = 0;
X    for (i=0; i<xg->ncorr_yvars; i++) {
X      if (xg->corr_yvars[i] == xg->xy_vars.y) {
X        inc = 1;
X        break;
X      }
X    }
X
X    if (inc) {
X      if (i != 0) {
X        xg->corr_yvars[i] = xg->corr_yvars[0];
X        xg->corr_yvars[0] = xg->xy_vars.y;
X      }
X    } else {
X      xg->corr_yvars[xg->ncorr_yvars] = xg->corr_yvars[0];
X      xg->corr_yvars[0] = xg->xy_vars.y;
X      xg->ncorr_yvars++;
X    }
X  }
X
X  else if (xg->is_spinning) {
X    /*
X     * Switch to three variables ...
X    */
X    xg->corr_xvars[0] = xg->spin_vars.x;
X    xg->corr_xvars[1] = xg->spin_vars.z;
X    xg->corr_yvars[0] = xg->spin_vars.y;
X    xg->ncorr_xvars = 2;
X    xg->ncorr_yvars = 1;
X    reinit_corr(xg);
X  }
X  else if (xg->is_touring) {
X    /* take variable with largest y contribution to be single y variable */
X    float max;
X
X    max = xg->tour_vars[0];
X    for (i=0; i<xg->numvars_t; i++)
X      if (xg->u[1][i] > max)
X        max = xg->tour_vars[i];
X    xg->corr_yvars[0] = max;
X    xg->ncorr_yvars = 1;    
X
X    xg->ncorr_xvars = 0;
X    for (i=0; i<xg->numvars_t; i++)
X      if (xg->tour_vars[i] != xg->corr_yvars[0])
X        xg->corr_xvars[xg->ncorr_xvars++] = xg->tour_vars[i];
X    reinit_corr(xg);
X  }
}
X
/********** For New Data **********/
X
void
destroy_varsel_widgets(int ncols_prev, xgobidata *xg)
{
X  int j;
X
X  XtUnmapWidget(xg->var_panel);
X  XtUnmanageChild(xg->var_panel);
X  /*
X   * Destroy all the variable boxes.
X  */
X  XtUnmanageChildren(xg->varboxw, ncols_prev);
X  for (j=0; j<ncols_prev; j++)
X    XtDestroyWidget(xg->varboxw[j]);
}
X
void
reset_var_panel(xgobidata *xg)
{
X  int j;
X
X  /*
X   * Reallocate the variable panel and menus for the new ncols.
X  */
X  xg->varboxw = (Widget *)
X    XtRealloc((char *) xg->varboxw,
X    (Cardinal) xg->ncols * sizeof(Widget));
X  xg->varlabw = (Widget *)
X    XtRealloc((char *) xg->varlabw,
X    (Cardinal) xg->ncols * sizeof(Widget));
X  xg->vardraww = (Widget *)
X    XtRealloc((char *) xg->vardraww,
X    (Cardinal) xg->ncols * sizeof(Widget));
X  xg->varchosen = (Boolean *)
X    XtRealloc((char *) xg->varchosen,
X    (Cardinal) xg->ncols * sizeof(Boolean));
X
X  /*
X   * Create the new variable boxes.
X  */
X  make_varboxes(xg);
X
X  for (j=0; j<xg->ncols; j++)
X  {
X    XtVaSetValues(xg->vardraww[j],
X      XtNwidth, (Dimension) (2*(xg->radius+1)),
X      XtNheight, (Dimension) (2*(xg->radius+1)), NULL);
X    /* This line is important! */
X    XtRealizeWidget(xg->varboxw[j]);
X  }
X  XtManageChildren(xg->varboxw, (unsigned int) xg->ncols);
X
X  XtMapWidget(xg->var_panel);
X
X  for (j=0; j<xg->ncols_used; j++)
X    refresh_vbox(xg, j, 1);
}
SHAR_EOF
  chmod 0644 'xgobi/src/var_panel.c' ||
  $echo 'restore of' 'xgobi/src/var_panel.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/var_panel.c:' 'MD5 check failed'
2d722311e7dc3bb1dffd4891d7838966  xgobi/src/var_panel.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/var_panel.c'`"
    test 45892 -eq "$shar_count" ||
    $echo 'xgobi/src/var_panel.c:' 'original size' '45892,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/brush_init.c ==============
if test -f 'xgobi/src/brush_init.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/brush_init.c' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/brush_init.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/brush_init.c' &&
/* brush_init.c */
/************************************************************
X *                                                          *
X *  Permission is hereby granted  to  any  individual   or  *
X *  institution   for  use,  copying, or redistribution of  *
X *  the xgobi code and associated documentation,  provided  *
X *  that   such  code  and documentation are not sold  for  *
X *  profit and the  following copyright notice is retained  *
X *  in the code and documentation:                          *
X *        Copyright (c) 1990, ..., 1996 Bellcore            *
X *                                                          *
X *  We welcome your questions and comments, and request     *
X *  that you share any modifications with us.               *
X *                                                          *
X *    Deborah F. Swayne            Dianne Cook              *
X *   dfs@research.att.com       dicook@iastate.edu          *
X *      (973) 360-8423    www.public.iastate.edu/~dicook/   *
X *                                                          *
X *                    Andreas Buja                          *
X *                andreas@research.att.com                  *
X *              www.research.att.com/~andreas/              *
X *                                                          *
X ************************************************************/
X
#include <stdio.h>
#include "xincludes.h"
#include "xgobitypes.h"
#include "xgobivars.h"
#include "xgobiexterns.h"
X
static Widget brush_panel[4] ;
static Widget brush_active_cmd;
static Widget glyph_menu_cmd, glyph_menu, glyph_menu_btn[NGLYPHS+1] ;
static Widget color_menu_cmd, color_menu, color_menu_btn[NCOLORS+3];
static Widget glyph_wksp;
static Widget br_type[3], br_update;
static Widget reset_menu_cmd, reset_menu, reset_menu_btn[4];
static Widget brush_points_cmd, brush_lines_cmd;
X
Widget br_opt_menu_cmd, br_opt_menu, br_opt_menu_btn[3];
X
Widget br_linkopt_menu_cmd, br_linkopt_menu, br_linkopt_menu_btn[6];
#define LINK_P_TO_P 0
#define LINK_L_TO_L 1
#define LINK_P_TO_L 2
#define LINK_COLOR  3
#define LINK_GLYPH  4
#define LINK_ERASE  5
X
#define PERST_CMD br_type[0]
#define TRANS_CMD br_type[1]
#define UNDO_CMD br_type[2]
X
#define JUMP_BRUSH    0
#define RESHAPE_BRUSH 1
#define SYNC_BRUSH    2
X
#define PANEL0 brush_panel[0]
#define PANEL1 brush_panel[1]
#define PANEL2 brush_panel[2]
#define PANEL3 brush_panel[3]
X
void
draw_current_glyph(xgobidata *xg)
{
/*
X * Draw the current glyph in the current color in the
X * glyph_wksp.  If no glyph is chosen, draw a border.
*/
X  Drawable gwin = XtWindow(glyph_wksp);
X  icoords xypos[1];
X  unsigned long col;
X
X  /* Clear it */
X  XFillRectangle(display, gwin, clear_GC, 0, 0, 40, 40);
X
/*
X * The center is at 20, 20 ... 
*/
X  xypos[0].x = xypos[0].y = 20;
X
X  /* Set the foreground color */
X  if (!mono) {
X    col = (xg->color_id == plotcolors.bg) ? plotcolors.fg : xg->color_id;
X    XSetForeground(display, copy_GC, col);
X  }
X
X  if (xg->is_glyph_painting) {
X    int type = xg->glyph_id.type;
X    int size = xg->glyph_id.size;
X
X    if (type == PLUS_GLYPH) {
X      XSegment segv[2];
X      build_plus(xypos, 0, segv, 0, size);
X      XDrawSegments(display, gwin, copy_GC,
X        segv, 2);
X    }
X    else if (type == X_GLYPH) {
X      XSegment segv[2];
X      build_x(xypos, 0, segv, 0, size);
X      XDrawSegments(display, gwin, copy_GC,
X        segv, 2);
X    }
X    else if (type == OPEN_RECTANGLE_GLYPH) {
X      XRectangle rectv[1];
X      build_rect(xypos, 0, rectv, 0, size);
X      XDrawRectangles(display, gwin, copy_GC, rectv, 1);
X    }
X    else if (type == FILLED_RECTANGLE_GLYPH) {
X      XRectangle rectv[1];
X      build_rect(xypos, 0, rectv, 0, size);
X      XFillRectangles(display, gwin, copy_GC, rectv, 1);
X    }
X    else if (type == OPEN_CIRCLE_GLYPH) {
X      XArc circ[1];
X      build_circle(xypos, 0, circ, 0, size);
X      XDrawArcs(display, gwin, copy_GC, circ, 1);
X    }
X    else if (type == FILLED_CIRCLE_GLYPH) {
X      XArc circ[1];
X      build_circle(xypos, 0, circ, 0, size);
X      XFillArcs(display, gwin, copy_GC, circ, 1);
X    }
X    else if (type == POINT_GLYPH) {
X      XDrawPoint(display, gwin, copy_GC, xypos[0].x, xypos[0].y);
X    }
X
X  /* If color painting only */
X  } else if (xg->is_color_painting) {
X    XDrawRectangle(display, gwin, copy_GC, 0, 0, 39, 39);
X  }
X
X  /* If painting in the background color, signal that with a diagonal */
X  if (xg->color_id == plotcolors.bg)
X    XDrawLine(display, gwin, copy_GC, 0, 0, 40, 40);
X
X  XFlush(display);
X  XSync(display, False);
X
}
X
/* ARGSUSED */
static XtEventHandler
glyph_expose(Widget w, xgobidata *xg, XEvent *evnt, Boolean *cont)
{
X  draw_current_glyph(xg);
}
X
static Boolean
choose_color(xgobidata *xg, int color_btn)
{
X  int i;
X  Boolean is_cpainting;
X  Arg args[5];
X
/*
X * Turn off margin indicator on each menu item.
*/
X  XtSetArg(args[0], XtNleftBitmap, (Pixmap) None);
X  for (i=0; i<ncolors+1; i++)
X    XtSetValues(color_menu_btn[i], args, 1);
X
/*
X * Shade the menu button to indicate that it is presently inactive.
*/
X  if (color_btn == 0)
X    is_cpainting = False;
X  else {
X    is_cpainting = True;
X    xg->color_id = (unsigned long) color_nums[color_btn-1];
X  }
X
X  XtVaSetValues(color_menu_btn[color_btn],
X    XtNleftBitmap, (Pixmap) menu_mark,
X    NULL);
X
X  return(is_cpainting);
}
X
/* ARGSUSED */
XXtCallbackProc
choose_color_cback (Widget w, xgobidata *xg, XtPointer callback_data)
/*
X * Choose brushing color:  only available on color displays.
*/
{
X  int j;
X  int color_btn;
X
X  for (j=0; j<ncolors+1; j++) {
X    if (color_menu_btn[j] == w) {
X      color_btn = j;
X      break;
X    }
X  }
X
X  if (xg->brush_mode == undo)
X  {
X    char message[MSGLENGTH];
X    sprintf(message, "Cannot change color when in undo brushing mode\n");
X    show_message(message, xg);
X  }
X  else
X  {
X    xg->is_color_painting = choose_color(xg, color_btn);
X    draw_current_glyph(xg);
X
X    for (j=0; j<xg->nrows; j++) {
X      xg->color_prev[j] = xg->color_ids[j];
X
X      /* experiment; dfs */
X      xg->glyph_prev[j].type = xg->glyph_ids[j].type;
X      xg->glyph_prev[j].size = xg->glyph_ids[j].size;
X    }
X
X    plot_once(xg);
X  }
}
X
void
reinit_brush_colors(xgobidata *xg)
{
X  int j;
X  Boolean fg_present = false, bg_present = false;
X
X  /*
X   * Find out whether the foreground and background colors of the
X   * plot_window are included in the brushing colors.  If not, then
X   * append them to the list of colors and add them to the color
X   * brushing menu.
X  */
X  for (j=0; j<ncolors; j++) {
X    if (color_nums[j] == plotcolors.fg)
X      fg_present = true;
X    else if (color_nums[j] == plotcolors.bg)
X      bg_present = true;
X  }
X
X  if (!bg_present) {
X    color_nums[ncolors] = plotcolors.fg;
X    color_names[ncolors] = "Default";
X    color_menu_btn[ncolors+1] = XtVaCreateManagedWidget("Command",
X      smeBSBObjectClass, color_menu,
X      XtNlabel, (String) color_names[ncolors],
X      XtNleftMargin, (Dimension) 24,
X      XtNforeground, color_nums[ncolors],
X      NULL);
X    XtAddCallback(color_menu_btn[ncolors+1], XtNcallback,
X      (XtCallbackProc) choose_color_cback, (XtPointer) xg);
X    ncolors++;
X  }
X
X  if (!fg_present) {
X    color_nums[ncolors] = plotcolors.bg;
X    color_names[ncolors] = "<Background color>";
X    color_menu_btn[ncolors+1] = XtVaCreateManagedWidget("Command",
X      smeBSBObjectClass, color_menu,
X      XtNlabel, (String) color_names[ncolors],
X      XtNleftMargin, (Dimension) 24,
X      XtNforeground, plotcolors.fg,
X      NULL);
X    XtAddCallback(color_menu_btn[ncolors+1], XtNcallback,
X      (XtCallbackProc) choose_color_cback, (XtPointer) xg);
X    ncolors++;
X  }
X
X  if (ncolors > NCOLORS+2)
X    fprintf(stderr, "Error in reinit_brush_colors: Too many colors\n");
}
X
/*
X * 1-5     +
X * 6-10    x
X * 11-15   orect
X * 16-20   crect
X * 21-25   ocirc
X * 26-30   ccirc
X * 31      point
*/
void
find_glyph_type_and_size(int gid, glyphv *glyph)
{
X  glyph->type = ( (gid-1) / NGLYPHSIZES ) + 1 ;
X  glyph->size = ( (gid-1) % NGLYPHSIZES ) + 1 ;
}
X
static Boolean
choose_glyph(xgobidata *xg, int glyph_btn)
{
X  Boolean is_gpainting;
X  glyphv glyph;
X  int i;
X  Arg args[5];
X
X  XtSetArg(args[0], XtNleftBitmap, (Pixmap) None);
X  for (i=0; i<NGLYPHS+1; i++)
X    XtSetValues(glyph_menu_btn[i], args, 1);
X
X  if (glyph_btn == 0) {
X    is_gpainting = False;
X  }
X  else {
X    is_gpainting = True;
X
X    find_glyph_type_and_size(glyph_btn, &glyph);
X    xg->glyph_id.type = glyph.type ;
X    xg->glyph_id.size = glyph.size ;
X  }
X
X  XtSetArg(args[0], XtNleftBitmap, (Pixmap) menu_mark);
X  XtSetValues(glyph_menu_btn[glyph_btn], args, 1);
X
X  return(is_gpainting);
}
X
/* ARGSUSED */
XXtCallbackProc
choose_glyph_cback (Widget w, xgobidata *xg, XtPointer callback_data)
{
X  int j;
X  int glyph_btn;
X
X  for (j=0; j<NGLYPHS+1; j++)
X  {
X    if (glyph_menu_btn[j] == w)
X    {
X      glyph_btn = j;
X      break;
X    }
X  }
X
X  if (xg->brush_mode == undo)
X  {
X    char message[MSGLENGTH];
X    sprintf(message, "Cannot change glyph when in undo brushing mode\n");
X    show_message(message, xg);
X  }
X  else
X  {
X    xg->is_glyph_painting = choose_glyph(xg, glyph_btn);
X    draw_current_glyph(xg);
X
X    for (j=0; j<xg->nrows; j++)
X    {
X      xg->glyph_prev[j].type = xg->glyph_ids[j].type;
X      xg->glyph_prev[j].size = xg->glyph_ids[j].size;
X
X      /* experiment; dfs */
X      xg->color_prev[j] = xg->color_ids[j];
X    }
X  }
}
X
void
make_color_menu(xgobidata *xg, Widget parent, Widget vref)
{
X  int i, j;
X
/*
X * Menu for choosing the current brushing color.
*/
X  color_menu_cmd = XtVaCreateManagedWidget("MenuButton",
X    menuButtonWidgetClass, parent,
X    XtNlabel, (String) "Color",
X    XtNmenuName, (String) "Menu",
X    XtNfromVert, vref,
X    NULL);
X  if (mono)
X  {
X    set_mono(color_menu_cmd);
X    XtVaSetValues(color_menu_cmd,
X      XtNsensitive, (Boolean) False,
X      NULL);
X  }
X  add_menupb_help(&xg->nhelpids.menupb,
X    color_menu_cmd, "Br_ColorMenu");
X
X  color_menu = XtVaCreatePopupShell("Menu",
X    simpleMenuWidgetClass, color_menu_cmd,
X    NULL);
X
/*
X * Color brushing starts out disabled for now ...
*/
X  color_menu_btn[0] = XtVaCreateWidget("Command",
X    smeBSBObjectClass, color_menu,
X    XtNlabel, (String) "Disable Color Painting",
X    XtNleftMargin, (Dimension) 24,
X    NULL);
X
X  for (j=0; j<ncolors; j++) {
X    color_menu_btn[j+1] = XtVaCreateWidget("Command",
X      smeBSBObjectClass, color_menu,
X      XtNlabel, (String) color_names[j],
X      XtNleftMargin, (Dimension) 24,
X      XtNforeground, color_nums[j],
X      NULL);
X  }
X  XtManageChildren(color_menu_btn, ncolors+1);
X
X  for (i=0; i<ncolors+1; i++) {
X    XtAddCallback(color_menu_btn[i], XtNcallback,
X      (XtCallbackProc) choose_color_cback, (XtPointer) xg);
X  }
}
X
void
make_glyph_menu(xgobidata *xg, Widget parent, Widget vref, Widget href)
{
X  int j;
X  static char *glyph_names[] = {
X    "Tiny Plus (1)",
X    "Small Plus (2)",
X    "Medium Plus (3)",
X    "Large Plus (4)",
X    "Jumbo Plus (5)",
X    "Tiny X (6)",
X    "Small X (7)",
X    "Medium X (8)",
X    "Large X (9)",
X    "Jumbo X (10)",
X    "Tiny Open Rectangle (11)",
X    "Small Open Rectangle (12)",
X    "Medium Open Rectangle (13)",
X    "Large Open Rectangle (14)",
X    "Jumbo Open Rectangle (15)",
X    "Tiny Filled Rectangle (16)",
X    "Small Filled Rectangle (17)",
X    "Medium Filled Rectangle (18)",
X    "Large Filled Rectangle (19)",
X    "Jumbo Filled Rectangle (20)",
X    "Tiny Open Circle (21)",
X    "Small Open Circle (22)",
X    "Medium Open Circle (23)",
X    "Large Open Circle (24)",
X    "Jumbo Open Circle (25)",
X    "Tiny Filled Circle (26)",
X    "Small Filled Circle (27)",
X    "Medium Filled Circle (28)",
X    "Large Filled Circle (29)",
X    "Jumbo Filled Circle (30)",
X    "Point (31)"
X  };
X
/*
X * Menu for choosing the current brushing glyph.
*/
X  glyph_menu_cmd = XtVaCreateManagedWidget("MenuButton",
X    menuButtonWidgetClass, parent,
X    XtNlabel, (String) "Glyph",
X    XtNmenuName, (String) "Menu",
X    XtNfromVert, vref,
X    XtNfromHoriz, href,
X    NULL);
X  if (mono) set_mono(glyph_menu_cmd);
X  add_menupb_help(&xg->nhelpids.menupb,
X    glyph_menu_cmd, "Br_GlyphMenu");
X
X  glyph_menu = XtVaCreatePopupShell("Menu",
X    simpleMenuWidgetClass, glyph_menu_cmd,
X    NULL);
X  if (mono) set_mono(glyph_menu);
/*
X * Set the background of the initial glyph.
*/
X  glyph_menu_btn[0] = XtVaCreateWidget("Command",
X    smeBSBObjectClass, glyph_menu,
X    XtNlabel, (String) "Disable Glyph Painting",
X    XtNleftMargin, (Dimension) 24,
X    XtNleftBitmap, menu_mark,
X    NULL);
X  if (mono) set_mono(glyph_menu_btn[0]);
X
X  /*for (j=0; j<NGLYPHS+1; j++)*/
X  for (j=0; j<NGLYPHS; j++)
X  {
X    glyph_menu_btn[j+1] = XtVaCreateWidget("Command",
X      smeBSBObjectClass, glyph_menu,
X      XtNlabel, (String) glyph_names[j],
X      XtNleftMargin, (Dimension) 24,
X      XtNleftBitmap, None,
X      NULL);
X    if (mono) set_mono(glyph_menu_btn[j+1]);
X  }
X  XtManageChildren(glyph_menu_btn, NGLYPHS+1);
X
X  for (j=0; j<NGLYPHS+1; j++)
X    XtAddCallback(glyph_menu_btn[j], XtNcallback,
X      (XtCallbackProc) choose_glyph_cback, (XtPointer) xg);
}
X
void
make_reset_menu(xgobidata *xg, Widget parent, Widget vref)
/*
X * Build a menu to contain brushing reset operations.
*/
{
X  int j;
X  static char *reset_names[] = {
X    "Reset brush size",
X    "Reset point colors",
X    "Reset line colors",
X    "Reset glyphs"
X  };
X
X  reset_menu_cmd = XtVaCreateManagedWidget("MenuButton",
X    menuButtonWidgetClass, parent,
X    XtNlabel, (String) "Reset",
X    XtNmenuName, (String) "Menu",
X    XtNfromVert, vref,
X    NULL);
X  if (mono) set_mono(reset_menu_cmd);
X  add_menupb_help(&xg->nhelpids.menupb,
X    reset_menu_cmd, "Br_ResetMenu");
X
X  reset_menu = XtVaCreatePopupShell("Menu",
X    simpleMenuWidgetClass, reset_menu_cmd,
X    NULL);
X  if (mono) set_mono(reset_menu);
X
X  for (j=0; j<4; j++)
X  {
X    reset_menu_btn[j] = XtVaCreateWidget("Command",
X      smeBSBObjectClass, reset_menu,
X      XtNlabel, (String) reset_names[j],
X      NULL);
X    if (mono) set_mono(reset_menu_btn[j]);
X  }
X  XtManageChildren(reset_menu_btn, 4);
X
X  XtAddCallback(reset_menu_btn[0], XtNcallback,
X    (XtCallbackProc) reset_brush_cback, (XtPointer) xg);
X  XtAddCallback(reset_menu_btn[1], XtNcallback,
X    (XtCallbackProc) reset_point_colors_cback, (XtPointer) xg);
X  XtAddCallback(reset_menu_btn[2], XtNcallback,
X    (XtCallbackProc) reset_line_colors_cback, (XtPointer) xg);
X  XtAddCallback(reset_menu_btn[3], XtNcallback,
X    (XtCallbackProc) reset_glyphs_cback, (XtPointer) xg);
}
X
void
set_br_linkopt_menu_marks(xgobidata *xg)
{
X  XtVaSetValues(br_linkopt_menu_btn[LINK_P_TO_P],
X    XtNleftBitmap, (xg->link_points_to_points) ? menu_mark : None,
X    NULL);
X
X  XtVaSetValues(br_linkopt_menu_btn[LINK_L_TO_L],
X    XtNleftBitmap, (xg->link_lines_to_lines) ? menu_mark : None,
X    NULL);
X
X  XtVaSetValues(br_linkopt_menu_btn[LINK_P_TO_L],
X    XtNleftBitmap, (xg->link_points_to_lines) ? menu_mark : None,
X    NULL);
X
X  XtVaSetValues(br_linkopt_menu_btn[LINK_COLOR],
X    XtNleftBitmap, (xg->link_color_brushing) ? menu_mark : None,
X    NULL);
X
X  XtVaSetValues(br_linkopt_menu_btn[LINK_GLYPH],
X    XtNleftBitmap, (xg->link_glyph_brushing) ? menu_mark : None,
X    NULL);
X
X  XtVaSetValues(br_linkopt_menu_btn[LINK_ERASE],
X    XtNleftBitmap, (xg->link_erase_brushing) ? menu_mark : None,
X    NULL);
}
X
/* ARGSUSED */
XXtCallbackProc
br_linkopt_menu_cback (Widget w, xgobidata *xg, XtPointer callback_data)
{
X  int btn;
X
X  for (btn=0; btn<5; btn++)
X    if (br_linkopt_menu_btn[btn] == w)
X      break;
X
X  switch (btn) {
X
X    case LINK_P_TO_P :
X      xg->link_points_to_points = !xg->link_points_to_points;
X      if (xg->link_points_to_points) {
X        xg->link_points_to_lines = False;
X        XtSetSensitive(br_linkopt_menu_btn[LINK_GLYPH], True);
X        XtSetSensitive(br_linkopt_menu_btn[LINK_ERASE], True);
X      }
X      break;
X
X    case LINK_L_TO_L :
X      xg->link_lines_to_lines = !xg->link_lines_to_lines;
X      if (xg->link_lines_to_lines) {
X        xg->link_points_to_lines = False;
X        XtSetSensitive(br_linkopt_menu_btn[LINK_GLYPH], True);
X        XtSetSensitive(br_linkopt_menu_btn[LINK_ERASE], True);
X      }
X      break;
X
X    case LINK_P_TO_L :
X      xg->link_points_to_lines = !xg->link_points_to_lines;
X      if (xg->link_points_to_lines) {
X        xg->link_points_to_points = False;
X        xg->link_lines_to_lines = False;
X        /* linking of glyphs or erasing is undefined here */
X        xg->link_erase_brushing = False;
X        xg->link_glyph_brushing = False;
X        XtSetSensitive(br_linkopt_menu_btn[LINK_GLYPH], False);
X        XtSetSensitive(br_linkopt_menu_btn[LINK_ERASE], False);
X      }
X      break;
X
X    case LINK_COLOR :
X      xg->link_color_brushing = !xg->link_color_brushing;
X      break;
X    case LINK_GLYPH :
X      xg->link_glyph_brushing = !xg->link_glyph_brushing;
X      break;
X    case LINK_ERASE :
X      xg->link_erase_brushing = !xg->link_erase_brushing;
X      break;
X  }
X
X  /*
X   * If points -> points is false and points -> lines is also
X   * false, then it makes no sense to have erase/glyph/color
X   * linking true -- turn them all off.
X  */
X  if (!xg->link_points_to_points && !xg->link_points_to_lines) {
X    xg->link_erase_brushing = False;
X    xg->link_glyph_brushing = False;
X    xg->link_color_brushing = False;
X  }
X
X  set_br_linkopt_menu_marks(xg);
}
X
void
make_br_linkopt_menu(xgobidata *xg, Widget parent, Widget href, Widget vref)
{
X  int k;
X
X  static char *br_linkopt_menu_name[] = {
X    "Link points <-> points",
X    "Link lines <-> lines",
X    "Link points <-> lines",
X    "Link color brushing",
X    "Link glyph brushing",
X    "Link hidden state",
X  };
X
X  br_linkopt_menu_cmd = XtVaCreateManagedWidget("LinkBrushButton",
X    menuButtonWidgetClass, parent,
X    XtNlabel, (String) "Link",
X    XtNmenuName, (String) "Menu",
X    XtNfromHoriz, href,
X    XtNfromVert, vref,
X    NULL);
X  if (mono) set_mono(br_linkopt_menu_cmd);
X  add_menupb_help(&xg->nhelpids.menupb,
X    br_linkopt_menu_cmd, "LinkBrush");
X
X  br_linkopt_menu = XtVaCreatePopupShell("Menu",
X    simpleMenuWidgetClass, br_linkopt_menu_cmd,
X    XtNinput, True,
X    NULL);
X  if (mono) set_mono(br_linkopt_menu);
X
X  for (k=0; k<6; k++) {
X    br_linkopt_menu_btn[k] = XtVaCreateManagedWidget("Command",
X      smeBSBObjectClass, br_linkopt_menu,
X      XtNleftMargin, (Dimension) 24,
X      XtNleftBitmap, menu_mark,
X      XtNlabel, (String) br_linkopt_menu_name[k],
X      NULL);
X    if (mono) set_mono(br_linkopt_menu_btn[k]);
X
X    if (k==2) {
X      Widget line = XtVaCreateManagedWidget("Line",
X        smeLineObjectClass, br_linkopt_menu,
X        NULL);
X      if (mono) set_mono(line);
X    }
X
X    XtAddCallback(br_linkopt_menu_btn[k], XtNcallback,
X      (XtCallbackProc) br_linkopt_menu_cback, (XtPointer) xg);
X  }
X
}
X
void
set_br_opt_menu_marks(xgobidata *xg)
{
X  if (xg->jump_brush)
X    XtVaSetValues(br_opt_menu_btn[JUMP_BRUSH],
X      XtNleftBitmap, (Pixmap) menu_mark,
X      NULL);
X  else
X    XtVaSetValues(br_opt_menu_btn[JUMP_BRUSH],
X      XtNleftBitmap, (Pixmap) None,
X      NULL);
X
X  if (xg->reshape_brush)
X    XtVaSetValues(br_opt_menu_btn[RESHAPE_BRUSH],
X      XtNleftBitmap, (Pixmap) menu_mark,
X      NULL);
X  else
X    XtVaSetValues(br_opt_menu_btn[RESHAPE_BRUSH],
X      XtNleftBitmap, (Pixmap) None,
X      NULL);
X
X  if (xg->sync_brush)
X    XtVaSetValues(br_opt_menu_btn[SYNC_BRUSH],
X      XtNleftBitmap, (Pixmap) menu_mark,
X      NULL);
X  else
X    XtVaSetValues(br_opt_menu_btn[SYNC_BRUSH],
X      XtNleftBitmap, (Pixmap) None,
X      NULL);
}
X
/* ARGSUSED */
XXtCallbackProc
br_opt_menu_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  int btn;
X
X  for (btn=0; btn<3; btn++)
X    if (br_opt_menu_btn[btn] == w)
X      break;
X
X  switch (btn) {
X    case JUMP_BRUSH :
X      xg->jump_brush = !xg->jump_brush;
X      break;
X    case RESHAPE_BRUSH :
X      xg->reshape_brush = !xg->reshape_brush;
X      break;
X    case SYNC_BRUSH :
X      xg->sync_brush = !xg->sync_brush;
X      break;
X  }
X  set_br_opt_menu_marks(xg);
}
X
void
make_br_opt_menu(xgobidata *xg, Widget parent, Widget href, Widget vref)
{
X  int k;
X
X  static char *br_opt_menu_name[] = {
X    "Brush jumps to cursor",
X    "Reshape brush when re-entering brushing",
X    "Update linked brushing continuously",
X  };
X
X  br_opt_menu_cmd = XtVaCreateManagedWidget("LinkBrushButton",
X    menuButtonWidgetClass, parent,
X    XtNlabel, (String) "Options",
X    XtNmenuName, (String) "Menu",
X    XtNfromHoriz, href,
X    XtNfromVert, vref,
X    NULL);
X  if (mono) set_mono(br_opt_menu_cmd);
X  add_menupb_help(&xg->nhelpids.menupb,
X    br_opt_menu_cmd, "IdentifyLink");
X
X  br_opt_menu = XtVaCreatePopupShell("Menu",
X    simpleMenuWidgetClass, br_opt_menu_cmd,
X    XtNinput, True,
X    NULL);
X  if (mono) set_mono(br_opt_menu);
X
X  for (k=0; k<3; k++)
X  {
X    br_opt_menu_btn[k] = XtVaCreateWidget("Command",
X      smeBSBObjectClass, br_opt_menu,
X      XtNleftMargin, (Dimension) 24,
X      XtNleftBitmap, menu_mark,
X      XtNlabel, (String) br_opt_menu_name[k],
X      NULL);
X    if (mono) set_mono(br_opt_menu_btn[k]);
X
X    XtAddCallback(br_opt_menu_btn[k], XtNcallback,
X      (XtCallbackProc) br_opt_menu_cback, (XtPointer) xg);
X  }
X
X  XtManageChildren(br_opt_menu_btn, 3);
}
X
void
make_brush(xgobidata *xg)
{
X  Widget hide_cmd;
X
/*
X * BrushPanel:  define but don't map.  It goes in the same spot
X * occupied by spin_panel[0].
*/
X  PANEL0 = XtVaCreateManagedWidget("BrushPanel",
X    formWidgetClass, xg->box0,
X    XtNleft, (XtEdgeType) XtChainLeft,
X    XtNright, (XtEdgeType) XtChainLeft,
X    XtNtop, (XtEdgeType) XtChainTop,
X    XtNbottom, (XtEdgeType) XtChainTop,
X    XtNmappedWhenManaged, (Boolean) False,
X    XtNorientation, (XtOrientation) XtorientVertical,
X    NULL);
X  if (mono) set_mono(PANEL0);
/*
X * Button to turn active painting on and off.
*/
X  brush_active_cmd = CreateToggle(xg, "Brush on",
X    True, (Widget) NULL, (Widget) NULL, (Widget) NULL, True, ANY_OF_MANY,
X    PANEL0, "Br_BrushOn");
X  XtManageChild(brush_active_cmd);
X  XtAddCallback(brush_active_cmd, XtNcallback,
X    (XtCallbackProc) brush_active_cback, (XtPointer) xg);
X
/*
X * Panel for specifying line and/or point brushing.
*/
X  PANEL1 = XtVaCreateManagedWidget("Panel",
X    boxWidgetClass, PANEL0,
X    XtNorientation, (XtOrientation) XtorientHorizontal,
X    XtNfromVert, brush_active_cmd,
X    NULL);
X  if (mono) set_mono(PANEL1);
X  brush_points_cmd = CreateToggle(xg, "Points",
X    True, (Widget) NULL, (Widget) NULL, (Widget) NULL, True, ANY_OF_MANY,
X    PANEL1, "Br_PointsLines");
X  XtManageChild(brush_points_cmd );
X  XtAddCallback(brush_points_cmd, XtNcallback,
X    (XtCallbackProc) brush_points_cback, (XtPointer) xg);
X
/*
X * Only activate this if the machine is not monochrome
*/
X  brush_lines_cmd = CreateToggle(xg, "Lines",
X    !mono, (Widget) NULL, (Widget) NULL, (Widget) NULL, False, ANY_OF_MANY,
X    PANEL1, "Br_PointsLines");
X  XtManageChild(brush_lines_cmd );
X  XtAddCallback(brush_lines_cmd, XtNcallback,
X    (XtCallbackProc) brush_lines_cback, (XtPointer) xg);
/*
X * Menus for choosing the brushing color and glyph.
*/
X  make_color_menu(xg, PANEL0, PANEL1 );  /* ... parent, vref */
X  make_glyph_menu(xg, PANEL0, PANEL1, color_menu_cmd );  /* ... vref, href */
X
/*
X * How about a small window with the current glyph drawn in it,
X * in the current color?
*/
X  glyph_wksp = XtVaCreateManagedWidget("PlotWindow",
X    labelWidgetClass, PANEL0,
X    XtNresizable, (Boolean) False,
X    XtNfromVert, (Widget) color_menu_cmd,
X    XtNlabel, (String) "",
X    XtNbackground, plotcolors.bg,
X    XtNwidth, 40,
X    XtNheight, 40,
X    NULL);
X  if (mono) set_mono(glyph_wksp);
X  add_pb_help(&xg->nhelpids.pb,
X    xg->workspace, "Brushing");
X  XtAddEventHandler(glyph_wksp, ExposureMask,
X    FALSE, (XtEventHandler) glyph_expose, (XtPointer) xg);
X
/*
X * Next, the labels to indicate the brushing type: persistent, transient,
X * undo.
*/
X  PANEL2 = XtVaCreateManagedWidget("Panel",
X    formWidgetClass, PANEL0,
X    XtNfromVert, glyph_wksp,
X    NULL);
X  if (mono) set_mono(PANEL2);
X
X  /* Transient brushing is the default */
X  PERST_CMD = CreateToggle(xg, "Persistent",
X    True, (Widget) NULL, (Widget) NULL, (Widget) NULL, False, ONE_OF_MANY,
X    PANEL2, "Brush_Modes");
X  XtVaSetValues(PERST_CMD, 
X    XtNleft, (XtEdgeType) XtChainLeft,
X    XtNright, (XtEdgeType) XtChainRight,
X    NULL);
X  TRANS_CMD = CreateToggle(xg, "Transient",
X    True, (Widget) NULL, PERST_CMD, PERST_CMD, True, ONE_OF_MANY,
X    PANEL2, "Brush_Modes");
X  XtVaSetValues(TRANS_CMD, 
X    XtNleft, (XtEdgeType) XtChainLeft,
X    XtNright, (XtEdgeType) XtChainRight,
X    NULL);
X  UNDO_CMD = CreateToggle(xg, "Undo",
X    True, (Widget) NULL, TRANS_CMD, PERST_CMD, False, ONE_OF_MANY,
X    PANEL2, "Brush_Modes");
X  XtVaSetValues(UNDO_CMD, 
X    XtNleft, (XtEdgeType) XtChainLeft,
X    XtNright, (XtEdgeType) XtChainRight,
X    NULL);
X  XtManageChildren(br_type, 3);
X
X  XtAddCallback(PERST_CMD, XtNcallback,
X    (XtCallbackProc) br_perst_cback, (XtPointer) xg);
X  XtAddCallback(TRANS_CMD, XtNcallback,
X    (XtCallbackProc) br_trans_cback, (XtPointer) xg);
X  XtAddCallback(UNDO_CMD, XtNcallback,
X    (XtCallbackProc) br_undo_cback, (XtPointer) xg);
X
X  hide_cmd = CreateCommand(xg, "Hide or exclude ...",
X    True, (Widget) NULL, (Widget) PANEL2,
X    PANEL0, "HideOrExclude");
X  XtManageChild(hide_cmd);
X  XtAddCallback(hide_cmd, XtNcallback,
X    (XtCallbackProc) open_exclusion_popup_cback, (XtPointer) xg);
X  if (xg->is_scatmat)
X    XtSetSensitive(hide_cmd, False);
X
X  br_update = CreateCommand(xg, "Send Update",
X    True, (Widget) NULL, (Widget) hide_cmd,
X    PANEL0, "Br_SendUpdate");
X  XtManageChild(br_update);
X  XtAddCallback(br_update, XtNcallback,
X    (XtCallbackProc) br_update_cback, (XtPointer) xg);
X
/*
X * Labels to indicate brushing commands: reset brush or points.
*/
X  make_reset_menu(xg, PANEL0, br_update );
X
X  /*
X   * If a .nlinkable file is used, then deletion
X   * is to be disabled.
X  */
/*
X  if (xg->nlinkable != xg->nrows)
X    set_deletion(False);
*/
X  /* */
X
X  make_br_linkopt_menu(xg, PANEL0, (Widget) NULL, reset_menu_cmd);
X  make_br_opt_menu(xg, PANEL0, (Widget) NULL, br_linkopt_menu_cmd);
X
}
X
void
update_linked_brushing(xgobidata *xg) {
X  XtCallCallbacks(br_update, XtNcallback, (XtPointer) xg);
}
X
void
reset_br_types(xgobidata *xg)
{
X  XtVaSetValues(PERST_CMD,
X    XtNstate, xg->brush_mode == persistent,
X    NULL);
X  setToggleBitmap(PERST_CMD, xg->brush_mode == persistent);
X
X  XtVaSetValues(TRANS_CMD,
X    XtNstate, xg->brush_mode == transient,
X    NULL);
X  setToggleBitmap(TRANS_CMD, xg->brush_mode == transient);
X
X  XtVaSetValues(UNDO_CMD,
X    XtNstate, xg->brush_mode == undo,
X    NULL);
X  setToggleBitmap(UNDO_CMD, xg->brush_mode == undo);
}
X
void
set_brush_menu_cmd(Boolean lgl)
{
X  XtVaSetValues(color_menu_cmd,
X    XtNsensitive, (Boolean) lgl,
X    NULL);
X  XtVaSetValues(PERST_CMD,
X    XtNsensitive, (Boolean) lgl,
X    NULL);
X  XtVaSetValues(UNDO_CMD,
X    XtNsensitive, (Boolean) lgl,
X    NULL);
}
X
X
void
init_brush_menus()
{
/*
X * Now add the mark beside the default values.
*/
X  XtVaSetValues(color_menu_btn[0],
X    XtNleftBitmap, menu_mark,
X    NULL);
X  XtVaSetValues(glyph_menu_btn[0],
X    XtNleftBitmap, menu_mark,
X    NULL);
}
X
void
map_brush(xgobidata *xg, Boolean brushon)
{
X  if (brushon)
X  {
X    XtMapWidget( PANEL0 );
X    XtMapWidget( xg->brush_mouse );
X  }
X  else
X  {
X    XtUnmapWidget( PANEL0 );
X    XtUnmapWidget(xg->brush_mouse);
X  }
}
X
#undef PANEL0
#undef PANEL1
#undef PANEL2
#undef PANEL3
SHAR_EOF
  chmod 0644 'xgobi/src/brush_init.c' ||
  $echo 'restore of' 'xgobi/src/brush_init.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/brush_init.c:' 'MD5 check failed'
eec7752c4766b4adc814c7dc42dfa010  xgobi/src/brush_init.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/brush_init.c'`"
    test 27260 -eq "$shar_count" ||
    $echo 'xgobi/src/brush_init.c:' 'original size' '27260,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/install-sh ==============
if test -f 'xgobi/src/install-sh' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/install-sh' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/install-sh' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/install-sh' &&
#!/bin/sh
#
# install - install a program, script, or datafile
# This comes from X11R5 (mit/util/scripts/install.sh).
#
# Copyright 1991 by the Massachusetts Institute of Technology
#
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
# the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation, and that the name of M.I.T. not be used in advertising or
# publicity pertaining to distribution of the software without specific,
# written prior permission.  M.I.T. makes no representations about the
# suitability of this software for any purpose.  It is provided "as is"
# without express or implied warranty.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch.  It can only install one file at a time, a restriction
# shared with many OS's install programs.
X
X
# set DOITPROG to echo to test this script
X
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
X
X
# put in absolute paths if you don't have them in your path; or use env. vars.
X
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
X
transformbasename=""
transform_arg=""
instcmd="$mvprog"
chmodcmd="$chmodprog 0755"
chowncmd=""
chgrpcmd=""
stripcmd=""
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=""
dst=""
dir_arg=""
X
while [ x"$1" != x ]; do
X    case $1 in
X	-c) instcmd="$cpprog"
X	    shift
X	    continue;;
X
X	-d) dir_arg=true
X	    shift
X	    continue;;
X
X	-m) chmodcmd="$chmodprog $2"
X	    shift
X	    shift
X	    continue;;
X
X	-o) chowncmd="$chownprog $2"
X	    shift
X	    shift
X	    continue;;
X
X	-g) chgrpcmd="$chgrpprog $2"
X	    shift
X	    shift
X	    continue;;
X
X	-s) stripcmd="$stripprog"
X	    shift
X	    continue;;
X
X	-t=*) transformarg=`echo $1 | sed 's/-t=//'`
X	    shift
X	    continue;;
X
X	-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
X	    shift
X	    continue;;
X
X	*)  if [ x"$src" = x ]
X	    then
X		src=$1
X	    else
X		# this colon is to work around a 386BSD /bin/sh bug
X		:
X		dst=$1
X	    fi
X	    shift
X	    continue;;
X    esac
done
X
if [ x"$src" = x ]
then
X	echo "install:	no input file specified"
X	exit 1
else
X	true
fi
X
if [ x"$dir_arg" != x ]; then
X	dst=$src
X	src=""
X	
X	if [ -d $dst ]; then
X		instcmd=:
X		chmodcmd=""
X	else
X		instcmd=mkdir
X	fi
else
X
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
# might cause directories to be created, which would be especially bad 
# if $src (and thus $dsttmp) contains '*'.
X
X	if [ -f $src -o -d $src ]
X	then
X		true
X	else
X		echo "install:  $src does not exist"
X		exit 1
X	fi
X	
X	if [ x"$dst" = x ]
X	then
X		echo "install:	no destination specified"
X		exit 1
X	else
X		true
X	fi
X
# If destination is a directory, append the input filename; if your system
# does not like double slashes in filenames, you may need to add some logic
X
X	if [ -d $dst ]
X	then
X		dst="$dst"/`basename $src`
X	else
X		true
X	fi
fi
X
## this sed command emulates the dirname command
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
X
# Make sure that the destination directory exists.
#  this part is taken from Noah Friedman's mkinstalldirs script
X
# Skip lots of stat calls in the usual case.
if [ ! -d "$dstdir" ]; then
defaultIFS='	
'
IFS="${IFS-${defaultIFS}}"
X
oIFS="${IFS}"
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
IFS="${oIFS}"
X
pathcomp=''
X
while [ $# -ne 0 ] ; do
X	pathcomp="${pathcomp}${1}"
X	shift
X
X	if [ ! -d "${pathcomp}" ] ;
X        then
X		$mkdirprog "${pathcomp}"
X	else
X		true
X	fi
X
X	pathcomp="${pathcomp}/"
done
fi
X
if [ x"$dir_arg" != x ]
then
X	$doit $instcmd $dst &&
X
X	if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
X	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
X	if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
X	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
else
X
# If we're going to rename the final executable, determine the name now.
X
X	if [ x"$transformarg" = x ] 
X	then
X		dstfile=`basename $dst`
X	else
X		dstfile=`basename $dst $transformbasename | 
X			sed $transformarg`$transformbasename
X	fi
X
# don't allow the sed command to completely eliminate the filename
X
X	if [ x"$dstfile" = x ] 
X	then
X		dstfile=`basename $dst`
X	else
X		true
X	fi
X
# Make a temp file name in the proper directory.
X
X	dsttmp=$dstdir/#inst.$$#
X
# Move or copy the file name to the temp name
X
X	$doit $instcmd $src $dsttmp &&
X
X	trap "rm -f ${dsttmp}" 0 &&
X
# and set any options; do chmod last to preserve setuid bits
X
# If any of these fail, we abort the whole thing.  If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $instcmd $src $dsttmp" command.
X
X	if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
X	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
X	if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
X	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
X
# Now rename the file to the real destination.
X
X	$doit $rmcmd -f $dstdir/$dstfile &&
X	$doit $mvcmd $dsttmp $dstdir/$dstfile 
X
fi &&
X
X
Xexit 0
SHAR_EOF
  chmod 0755 'xgobi/src/install-sh' ||
  $echo 'restore of' 'xgobi/src/install-sh' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/install-sh:' 'MD5 check failed'
5afe8eb5573965dfb58378e4e46f3813  xgobi/src/install-sh
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/install-sh'`"
    test 5598 -eq "$shar_count" ||
    $echo 'xgobi/src/install-sh:' 'original size' '5598,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/widgets.c ==============
if test -f 'xgobi/src/widgets.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/widgets.c' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/widgets.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/widgets.c' &&
/* widgets.c */
/************************************************************
X *                                                          *
X *  Permission is hereby granted  to  any  individual   or  *
X *  institution   for  use,  copying, or redistribution of  *
X *  the xgobi code and associated documentation,  provided  *
X *  that   such  code  and documentation are not sold  for  *
X *  profit and the  following copyright notice is retained  *
X *  in the code and documentation:                          *
X *        Copyright (c) 1990, ..., 1996 Bellcore            *
X *                                                          *
X *  We welcome your questions and comments, and request     *
X *  that you share any modifications with us.               *
X *                                                          *
X *    Deborah F. Swayne            Dianne Cook              *
X *   dfs@research.att.com       dicook@iastate.edu          *
X *      (973) 360-8423    www.public.iastate.edu/~dicook/   *
X *                                                          *
X *                    Andreas Buja                          *
X *                andreas@research.att.com                  *
X *              www.research.att.com/~andreas/              *
X *                                                          *
X ************************************************************/
X
#include <stdio.h>
#include <stdlib.h>
#include "xincludes.h"
#include "xgobitypes.h"
#include "xgobivars.h"
#include "xgobiexterns.h"
#include <X11/Xatom.h>
#include <X11/Xproto.h>
X
#include "../bitmaps/leftarrow.xbm"
#include "../bitmaps/rightarrow.xbm"
#include "../bitmaps/uparrow.xbm"
#include "../bitmaps/downarrow.xbm"
#include "../bitmaps/plus.xbm"
#include "../bitmaps/minus.xbm"
#include "../bitmaps/lrarrow.xbm"
X
/*  bitmaps for checkboxes */
#include "../bitmaps/ton16.xbm"
#include "../bitmaps/toff16.xbm"
X
static Widget form1, main_panel;
X
#ifdef XPLORE
#define NFILEBTNS 7 /* xplore */
#else
#define NFILEBTNS 5
#endif
X
static Widget file_menu_cmd, file_menu, file_menu_btn[NFILEBTNS];
#define EXIT       file_menu_btn[NFILEBTNS-1]
X
/* NVIEWMODES is defined in xgobitypes.h */
static Widget view_menu_cmd, view_menu, view_menu_btn[NVIEWMODES];
static char *view_menu_labelname[] = {
X  "View: 1DPlot",
X  "View: XYPlot",
X  "View: Rotate",
X  "View: GrTour",
X  "View: CoTour",
X  "View: Scale",
X  "View: Brush",
X  "View: Ident",
X  "View: LineEd",
X  "View: MovePts",
};
char *view_menu_accel[] = {
X  "d", "x", "r", "g", "c", "s", "b", "i", "l", "m",
};
X
/*
X * CORBA method:  returns the char ** view_menu_labelname which
X * is static in this file.  Also, returns the number of elements
X * in the array.
*/
char ** GetPlotViewTypes(int *num);
X
X
#ifdef XPLORE
#define NTOOLBTNS 15 /* xplore */
#else
#define NTOOLBTNS 13
#endif
X
Widget tool_menu_cmd, tool_menu, tool_menu_btn[NTOOLBTNS];
X
/*------ these all pertain to subsets of cases -------*/
#define EXCLUSION_BTN 0
#define SUBSET_BTN    1
/*------ these affect the current plot -------*/
#define SMOOTH_BTN    2
#define JITTER_BTN    3
#define INFER_BTN     4
/*------ open some new plotting window -------*/
#define PARCOORD_BTN  5
#define CLONE_BTN     6
#define SCATMAT_BTN   7
/*------ variable-wise, case-wise -------*/
#define VARTFORM_BTN  8
#define VARLIST_BTN   9
#define CASELIST_BTN  10
/*------ these both pertain to missing values -------*/
#define LAUNCH_MISSING_BTN   11
#define IMPUTE_BTN           12
/*------ XploRe -------*/
#ifdef XPLORE
#define XPLORE_BTN          13 /* xplore */
#define XPLORE_END_BTN      14 /* xplore */
#endif
X
#define NDISPLAYBTNS 7
static Widget display_menu_cmd, display_menu, display_menu_btn[NDISPLAYBTNS];
#define ADDAXES        0
#define ADDGRID        1
#define CENTERAXES     2
#define SHOWPOINTS     3
#define SHOWLINES      4
#define SHOWARROWS     5
#define CARRYVARS      6
X
void
init_options(xgobidata *xg)
{
X  /* These are now on the brush panel */
X  xg->link_points_to_points = (Boolean) appdata.linkGlyphBrush | 
X    (Boolean) appdata.linkColorBrush;
X  xg->link_points_to_lines =  False;
X  xg->link_lines_to_lines =  (Boolean) appdata.linkLineBrush;
X  xg->link_glyph_brushing =   appdata.linkGlyphBrush;
X  xg->link_color_brushing =   appdata.linkColorBrush;
X  xg->link_erase_brushing =   appdata.linkEraseBrush;
X
X  xg->jump_brush =            appdata.jumpBrush;
X  xg->reshape_brush =         appdata.reshapeBrush;
X  xg->sync_brush =            appdata.syncBrush;
X
X  /* This is now on the identify panel */
X  xg->link_identify =         appdata.linkIdentify;
X
X  xg->is_axes =               appdata.showAxes;
X  xg->is_axes_centered =      True;
X  xg->plot_the_points =       appdata.showPoints;
X  xg->plot_the_arrows =       False;
X  xg->connect_the_points =    appdata.showLines;
X  xg->carry_vars =            appdata.carryVars;
X
X  /* For cloning */
X  xg->isCloned =              appdata.isCloned;
X  xg->clone_PID =             appdata.clonePID;
X  xg->clone_Time =            appdata.cloneTime;
X  xg->clone_Type =            (enum clone_data_type) appdata.cloneType;
X  xg->clone_Name =            appdata.cloneName;
X  xg->delete_clone_data =     appdata.deleteCloneData;
}
X
void
set_mono(Widget w)
{
X  XtVaSetValues(w,
X    XtNforeground, appdata.fg,
X    XtNbackground, appdata.bg,
X    XtNborderColor, appdata.fg,
X    NULL);
}
X
/* ARGSUSED */
void
set_Edit_Lines_cmd(xgobidata *xg, Boolean lgl)
{
X  XtVaSetValues(view_menu_btn[LINEEDIT_MODE], XtNsensitive, lgl, NULL);
}
X
/* ARGSUSED */
void
set_Smooth_cmd(xgobidata *xg, Boolean lgl)
{
X  XtVaSetValues(tool_menu_btn[SMOOTH_BTN], XtNsensitive, lgl, NULL);
}
X     
/* ARGSUSED */
void
reset_Exit_cmd(xgobidata *xg)
{
X  XtVaSetValues(EXIT, XtNsensitive, False, NULL);
}
X
Widget
CreateCommand(xgobidata *xg, char *label, Boolean sensitive, Widget href,
Widget vref, Widget parent, char *helpLabel)
{
X  Widget pb;
X
X  if (mono)
X    pb = XtVaCreateWidget("Command",
X      commandWidgetClass, parent,
X      XtNlabel, (String) label,
X      XtNsensitive, (Boolean) sensitive,
X      XtNfromHoriz, (Widget) href,
X      XtNfromVert, (Widget) vref,
X      XtNforeground, appdata.fg,
X      XtNbackground, appdata.bg,
X      XtNborderColor, appdata.fg,
X      NULL);
X  else
X    pb = XtVaCreateWidget("Command",
X      commandWidgetClass, parent,
X      XtNlabel, (String) label,
X      XtNsensitive, (Boolean) sensitive,
X      XtNfromHoriz, (Widget) href,
X      XtNfromVert, (Widget) vref,
X      NULL);
X
X  add_pb_help(&xg->nhelpids.pb, pb, helpLabel);
X  return(pb);
}
X
void
make_bitmaps(void) {
X  toggle_off = XCreateBitmapFromData(display, DefaultRootWindow(display),
X    (char *) toff16_bits, toff16_width, toff16_height);
X  toggle_on = XCreateBitmapFromData(display, DefaultRootWindow(display),
X    (char *) ton16_bits, ton16_width, ton16_height);
}
X
void
setToggleBitmap(Widget pb, Boolean set) {
X  static Boolean initd = False;
X
X  if (!initd) {
X    make_bitmaps();
X    initd = True;
X  }
X
X  if (set)
X    XtVaSetValues(pb, XtNleftBitmap, toggle_on, NULL);
X  else
X    XtVaSetValues(pb, XtNleftBitmap, toggle_off, NULL);
}
X
Widget
CreateToggle(xgobidata *xg, char *label, Boolean sensitive,
Widget href, Widget vref, Widget radioref,
Boolean set, int type, Widget parent, char *helpLabel)
{
X  Widget pb;
X  char name[8];
X
X  /*
X   * Using the fallback resources, we force some
X   * toggle widgets to follow "one of many" behavior
X   * while others are permitted to be unselected.
X  */
X  if (type == ONE_OF_MANY)
X    strcpy(name, "Toggle");
X  else
X    strcpy(name, "Command");
X
X  if (mono)
X    pb = XtVaCreateWidget(name,
X      toggleWidgetClass, parent,
X      XtNlabel, (String) label,
X      XtNsensitive, (Boolean) sensitive,
X      XtNfromHoriz, (Widget) href,
X      XtNfromVert, (Widget) vref,
X      XtNradioGroup, (Widget) radioref,
X      XtNstate, (Boolean) set,
X      XtNforeground, appdata.fg,
X      XtNbackground, appdata.bg,
X      XtNborderColor, appdata.fg,
X      /*XtNborderWidth, 0,*/
X      NULL);
X  else
X    pb = XtVaCreateWidget(name,
X      toggleWidgetClass, parent,
X      XtNlabel, (String) label,
X      XtNsensitive, (Boolean) sensitive,
X      XtNfromHoriz, (Widget) href,
X      XtNfromVert, (Widget) vref,
X      XtNradioGroup, (Widget) radioref,
X      XtNstate, (Boolean) set,
X      /*XtNborderWidth, 0,*/
X      NULL);
X
X  setToggleBitmap(pb, set);
X
X  add_pb_help(&xg->nhelpids.pb, pb, helpLabel);
X  return(pb);
}
X
void
build_labelled_menu(Widget *box, Widget *labelw, char *labelstr, Widget *cmd,
X  Widget *menu, Widget *btn, char **btn_names, char **btn_nicknames, int nbtns,
X  int initval, Widget parent, Widget vref, XtOrientation orientation,
X  XFontStruct *fn, char *helplbl, xgobidata *xg)
{
X  Dimension width = 0, maxwidth = 0;
X  int longest = 0;
X  int k;
X
X  *box = XtVaCreateManagedWidget("Panel",
X    boxWidgetClass, parent,
X    XtNorientation, (XtOrientation) orientation,
X    XtNfromVert, vref,
X    XtNhSpace, 1,
X    XtNvSpace, 1,
X    NULL);
X  if (mono) set_mono(*box);
X
X  /* Find the widest label */
X  *labelw = XtVaCreateManagedWidget("Label",
X    labelWidgetClass, *box,
X    XtNlabel, labelstr,
X    NULL);
X  if (mono) set_mono(*labelw);
X
X  for (k=0; k<nbtns; k++) {
X    width = XTextWidth(fn, btn_nicknames[k], strlen(btn_nicknames[k])) +
X      2*ASCII_TEXT_BORDER_WIDTH;
X    if (width > maxwidth) {
X      maxwidth = width;
X      longest = k;
X    }
X  }
X
X  *cmd = XtVaCreateManagedWidget("MenuButton",
X    menuButtonWidgetClass, *box,
X    XtNlabel, (String) btn_nicknames[longest],
X    XtNmenuName, (String) "Menu",
X    XtNfromHoriz, *labelw,
X    XtNresize, False,
X    NULL);
X  if (mono) set_mono(*cmd);
X  if (xg != NULL)
X    add_menupb_help(&xg->nhelpids.menupb,
X      *cmd, helplbl);
X
X  *menu = XtVaCreatePopupShell("Menu",
X    simpleMenuWidgetClass, *cmd,
X    NULL);
X  if (mono) set_mono(*menu);
X
X  for (k=0; k<nbtns; k++) {
X    btn[k] = XtVaCreateWidget("Command",
X      smeBSBObjectClass, *menu,
X      XtNlabel, btn_names[k],
X      NULL);
X    if (mono) set_mono(btn[k]);
X  }
X  XtManageChildren(btn, (Cardinal) nbtns);
X
X  XtVaSetValues(*cmd,
X    XtNlabel, (String) btn_nicknames[initval],
X    NULL);
}
X
Boolean
tour_on(xgobidata *xg)
{
X  return(xg->plot_mode == GTOUR_MODE);
}
X
void
set_showlines_option(Boolean lgl, xgobidata *xg)
{
/*
X * This is needed because we're going to duplicate
X * this button on the line editing panel, and they
X * both need to show the same state, but we don't
X * want to call the callback twice.
*/
X  XtVaSetValues(display_menu_btn[SHOWLINES], XtNstate, lgl, NULL);
X  set_display_menu_marks(xg);
}
X
void
set_showarrows_option(Boolean lgl, xgobidata *xg)
{
X  XtVaSetValues(display_menu_btn[SHOWARROWS], XtNstate, lgl, NULL);
X  set_display_menu_marks(xg);
}
X
void
turn_on_showlines_option(xgobidata *xg)
{
/*
X * This is called when line editing is entered.
X * It sets xg->connect_the_points to True if it's False,
X * and calls the callback, and then makes certain the
X * toggle in the options menu is set to True.
*/
X  if (!xg->connect_the_points) {
X    XtCallCallbacks(display_menu_btn[SHOWLINES], XtNcallback, (XtPointer) xg);
X    set_showlines_option(True, xg);
X  }
}
X
void
make_plotwindow_mouse_labels(xgobidata *xg)
{
X  Arg args[4];
X
X  XtSetArg(args[0], XtNfromVert, (Widget) xg->workspace);
X  XtSetArg(args[1], XtNtop, (XtEdgeType) XtChainBottom);
X  XtSetArg(args[2], XtNbottom, (XtEdgeType) XtChainBottom);
X
X  XtSetArg(args[3], XtNlabel, "Drag L or M: Move points ");
X  xg->spin_mouse = XtCreateManagedWidget("MouseLabel",
X    labelWidgetClass, xg->box1, args, 4);
X  if (mono) set_mono(xg->spin_mouse);
X
X  XtSetArg(args[3], XtNlabel, "Drag L: Move pts; Drag M: Shape pts ");
X  xg->scale_mouse = XtCreateManagedWidget("MouseLabel",
X    labelWidgetClass, xg->box1, args, 4);
X  if (mono) set_mono(xg->scale_mouse);
X
X  XtSetArg(args[3], XtNlabel, "Drag/Click L: paint; Drag M: shape ");
X  xg->brush_mouse = XtCreateManagedWidget("MouseLabel",
X    labelWidgetClass, xg->box1, args, 4);
X  if (mono) set_mono(xg->brush_mouse);
X
X  XtSetArg(args[3], XtNlabel, "L: Toggle sticky labels ");
X  xg->identify_mouse = XtCreateManagedWidget("MouseLabel",
X    labelWidgetClass, xg->box1, args, 4);
X  if (mono) set_mono(xg->identify_mouse);
X
X  XtSetArg(args[3], XtNlabel, "Drag L: Add line, M: Remove last ");
X  xg->le_add_mouse = XtCreateManagedWidget("MouseLabel",
X    labelWidgetClass, xg->box1, args, 4);
X  if (mono) set_mono(xg->le_add_mouse);
X
X  XtSetArg(args[3], XtNlabel, "L: Delete line, M: Put it back ");
X  xg->le_delete_mouse = XtCreateManagedWidget("MouseLabel",
X    labelWidgetClass, xg->box1, args, 4);
X  if (mono) set_mono(xg->le_delete_mouse);
X
X  XtSetArg(args[3], XtNlabel, "Drag L: Move point/group/all");
X  xg->movepts_mouse = XtCreateManagedWidget("MouseLabel",
X    labelWidgetClass, xg->box1, args, 4);
X  if (mono) set_mono(xg->movepts_mouse);
X
X  XtSetArg(args[3], XtNlabel, "Drag L or M: Manipulate Variable ");
X  xg->tour_mouse = XtCreateManagedWidget("MouseLabel",
X    labelWidgetClass, xg->box1, args, 4);
X  if (mono) set_mono(xg->tour_mouse);
X
X  XtSetArg(args[3], XtNlabel, "Drag L or M: Manipulate Variable ");
X  xg->corr_mouse = XtCreateManagedWidget("MouseLabel",
X    labelWidgetClass, xg->box1, args, 4);
X  if (mono) set_mono(xg->corr_mouse);
}
X
void
make_plot_window(xgobidata *xg)
/*
X * PlotWindow: the plot window
*/
{
X  xg->workspace = XtVaCreateManagedWidget("PlotWindow",
X    labelWidgetClass, xg->box1,
X    XtNresizable, (Boolean) True,
X    XtNleft, (XtEdgeType) XtChainLeft,
X    XtNtop, (XtEdgeType) XtChainTop,
X    XtNright, (XtEdgeType) XtRubber,
X    XtNbottom, (XtEdgeType) XtChainBottom,
X    /*XtNbottom, (XtEdgeType) XtRubber,*/
X    /*XtNfromVert, (Widget) xg->scale_mouse,*/
X    XtNlabel, (String) "",
X    NULL);
X  if (mono) set_mono(xg->workspace);
X  add_pb_help(&xg->nhelpids.pb,
X    xg->workspace, "PlotWindow");
X
X  XtAddEventHandler(xg->workspace, ExposureMask,
X    FALSE, (XtEventHandler) expose_cback, (XtPointer) xg);
X  XtAddEventHandler(xg->workspace, StructureNotifyMask,
X    FALSE, (XtEventHandler) resize_cback, (XtPointer) xg);
}
X
X
void
make_arrows(xgobidata *xg) {
X  Drawable root_window = RootWindowOfScreen(XtScreen(xg->shell));
X
X  /*
X   * Define arrows.  (depth is a global variable)
X  */
X  leftarr = XCreatePixmapFromBitmapData(display, root_window,
X    leftarrow_bits, leftarrow_width, leftarrow_height,
X    appdata.fg, appdata.bg, depth);
X  rightarr = XCreatePixmapFromBitmapData(display, root_window,
X    rightarrow_bits, rightarrow_width, rightarrow_height,
X    appdata.fg, appdata.bg, depth);
X  uparr = XCreatePixmapFromBitmapData(display, root_window,
X    uparrow_bits, uparrow_width, uparrow_height,
X    appdata.fg, appdata.bg, depth);
X  downarr = XCreatePixmapFromBitmapData(display, root_window,
X    downarrow_bits, downarrow_width, downarrow_height,
X    appdata.fg, appdata.bg, depth);
X  plus = XCreatePixmapFromBitmapData(display, root_window,
X    plus_bits, plus_width, plus_height,
X    appdata.fg, appdata.bg, depth);
X  minus =  XCreatePixmapFromBitmapData(display, root_window,
X    minus_bits, minus_width, minus_height,
X    appdata.fg, appdata.bg, depth);
X
X  /* Used in the missing panel */
X  lrarr = XCreatePixmapFromBitmapData(display, root_window,
X    lrarrow_bits, lrarrow_width, lrarrow_height,
X    appdata.fg, appdata.bg, depth);
}
X
void
reset_3d_cmds(xgobidata *xg)
{
X  Boolean sens = True;
X
X  if (xg->ncols_used < 3)
X    sens = False;
X
X  XtVaSetValues(view_menu_btn[ROTATE_MODE],
X    XtNsensitive, (Boolean) sens,
X    NULL);
X  XtVaSetValues(view_menu_btn[GTOUR_MODE],
X    XtNsensitive, (Boolean) sens,
X    NULL);
X  XtVaSetValues(view_menu_btn[CTOUR_MODE],
X    XtNsensitive, (Boolean) sens,
X    NULL);
}
X
/*ARGSUSED*/
XXtActionProc
KeyFileMenu(Widget w, XEvent *event, String *params, Cardinal nparams)
{
X  extern xgobidata xgobi;
X  xgobidata *xg = &xgobi;
X
X  if (strcmp(params[0], "0") == 0) {
X    XtCallCallbacks(EXIT, XtNcallback, (XtPointer) xg);
X  }
}
X
void
make_file_menu(xgobidata *xg, Widget parent)
{
X  int j;
X
X  static char *file_menu_accel[] = {
X    "Q",
X  };
X
X  static char *file_menu_names[] = {
X    "Read ...",
X    "Save (extend current file set) ...",
X    "Save (create new file set) ...",
X    "Print ...",
X
#ifdef XPLORE
X    "XploRe (pass variables) ...",
X    "XploRe (pass projection) ...",
#endif
X
X    "Quit (Q)",
X  };
X
X  char *accelerators;
X  accelerators = XtMalloc(512 * sizeof(char));
X  sprintf(accelerators,
X    ":<Key>%s:KeyFileMenu(%d)",  /* modifiers:  Alt, Ctrl, Shift<Key>%s */
X     file_menu_accel[0], 0);
X
X  file_menu_cmd = XtVaCreateManagedWidget("Command",
X    menuButtonWidgetClass, parent,
X    XtNlabel, (String) "File",
X    XtNmenuName, (String) "Menu",
X    NULL);
X  if (mono) set_mono(file_menu_cmd);
X  add_menupb_help(&xg->nhelpids.menupb,
X    file_menu_cmd, "FileMenu");
X
X  file_menu = XtVaCreatePopupShell("Menu",
X    simpleMenuWidgetClass, file_menu_cmd,
X    XtNaccelerators, XtParseAcceleratorTable(accelerators),
X    NULL);
X  if (mono) set_mono(file_menu);
X
X  for (j=0; j<NFILEBTNS; j++)
X  {
X    file_menu_btn[j] = XtVaCreateWidget("Command",
X      smeBSBObjectClass, file_menu,
X      XtNlabel, (String) file_menu_names[j],
X      NULL);
X    if (mono) set_mono(file_menu_btn[j]);
X
#ifdef XPLORE
X    /* Add a line after the 3rd and 5th entries */
X    if (j == 3 || j == 5)
#else
X    /* Add a line after the 3rd and 4th entries */
X    if (j == 2 || j == 3)
#endif
X
X      (void) XtVaCreateManagedWidget("Line",
X        smeLineObjectClass, file_menu,
X        NULL);
X  }
X
#ifdef XPLORE
X  /* Initially make the XploRe buttons insensitive. */
X  XtVaSetValues(file_menu_btn[4],
X     XtNsensitive, False,
X     NULL);
X  XtVaSetValues(file_menu_btn[5],
X     XtNsensitive, False,
X     NULL);
#endif
X
X  XtManageChildren(file_menu_btn, NFILEBTNS);
X
X  XtAddCallback(file_menu_btn[0], XtNcallback,
X    (XtCallbackProc) open_import_xgobi_popup_cback, (XtPointer) xg);
X  XtAddCallback(file_menu_btn[1], XtNcallback,
X    (XtCallbackProc) open_extend_xgobi_popup_cback, (XtPointer) xg);
X  XtAddCallback(file_menu_btn[2], XtNcallback,
X    (XtCallbackProc) open_new_xgobi_popup_cback, (XtPointer) xg);
X  XtAddCallback(file_menu_btn[3], XtNcallback,
X    (XtCallbackProc) print_panel_cback, (XtPointer) xg);
X
#ifdef XPLORE
X  XtAddCallback(file_menu_btn[4], XtNcallback,
X    (XtCallbackProc) pass_data_xplore_cback, (XtPointer) xg);
X  XtAddCallback(file_menu_btn[5], XtNcallback,
X    (XtCallbackProc) pass_projection_xplore_cback, (XtPointer) xg);
#endif
X
/* I probably need a variable to handle this -- how do I
X * know whether I was called as a function or I'm running
X * as a standalone xgobi?
*/
/*
X  if (parent)
X    XtAddCallback(EXIT, XtNcallback,
X      (XtCallbackProc) exit_panel_cback, (XtPointer) xg);
X  else
*/
X    XtAddCallback(EXIT, XtNcallback,
X      (XtCallbackProc) exit_solo_cback, (XtPointer) xg);
X
X  XtFree((char *) accelerators);
}
X
int
reset_plot_mode(Cardinal mode, xgobidata *xg)
{
/*
X * Rotation and grand tour do not work when there are fewer
X * than three columns.
*/
X  Boolean threeD = True;
X
X  if (xg->ncols_used < 3)
X    threeD = False;
X
X  switch (mode) {
X   case PLOT1D_MODE:
X    plot1d_on(xg);
X    break;
X   case XYPLOT_MODE:
X    xyplot_on(xg);
X    break;
X   case ROTATE_MODE:
X    if (threeD)
X      rotate_on(xg);
X    break;
X   case GTOUR_MODE:
X    if (threeD)
X      grand_tour_on(xg);
X    break;
X   case CTOUR_MODE:
X    if (threeD)
X      corr_tour_on(xg);
X    break;
X   case SCALE_MODE:
X    scaling_on(xg);
X    break;
X   case BRUSH_MODE:
X    brush_on(xg);
X    break;
X   case IDENTIFY_MODE:
X    identify_on(xg);
X    break;
X   case LINEEDIT_MODE:
X    line_editor_on(xg);
X    break;
X   case MOVEPTS_MODE:
X    move_points_on(xg);
X    break;
X   default:
X    /* Failed: unknown index. */
X    return (-1);
X  }
X  return mode;
}
X
/* ARGSUSED */
XXtCallbackProc
view_menu_cback(Widget w, xgobidata *xg, XtPointer callback_data)
/*
X * Set the xgobi mode for plots and interaction
*/
{
X  int j;
X
X  xg->prev_plot_mode = xg->plot_mode;
X  for (j=0; j<NVIEWMODES; j++) {
X    if (view_menu_btn[j] == w) {
X      xg->plot_mode = j;
X      break;
X    }
X  }
X  XtVaSetValues(view_menu_cmd,
X    XtNlabel, (String) view_menu_labelname[xg->plot_mode],
X    NULL);
X
X  if (xg->plot_mode != xg->prev_plot_mode) {
X    /* turn off previous mode */
X    reset_plot_mode(xg->prev_plot_mode, xg);
X    /* turn on new mode */
X    reset_plot_mode(xg->plot_mode, xg);
X  }
}
X
int
SetPlotModeIndex(int pmode, xgobidata *xg)
{
X  int old = xg->plot_mode;
X
X  if (pmode != xg->plot_mode) {
X    xg->prev_plot_mode = xg->plot_mode;
X    xg->plot_mode = pmode;
X
X    /* turn off previous mode */
X    reset_plot_mode(xg->prev_plot_mode, xg);
X    /* turn on new mode */
X    reset_plot_mode(xg->plot_mode, xg);
X
X    XtVaSetValues(view_menu_cmd,
X      XtNlabel, (String) view_menu_labelname[xg->plot_mode],
X      NULL);
X  }
X  return (old);
}
X
X
/*ARGSUSED*/
XXtActionProc
SetPlotMode(Widget w, XEvent *event, String *params, Cardinal nparams)
{
X  extern xgobidata xgobi;
X  xgobidata *xg = &xgobi;
X  int pmode;
X
X  pmode = atoi(params[0]);
X  SetPlotModeIndex(pmode, xg);
}
X
/*
X * Changes to the specified view identified by name.
X * This is the name of the label on the menu with the
X * "View:" prefix and key accelerator removed.
*/
int SetPlotModeName(const char *name, xgobidata *xg)
{
X  /*
X   * Look up the index corresponding to the specified identifier.
X   * The identifier should come from the list.
X  */
X  
X  int num = -1;
X  char **names = GetPlotViewTypes(&num);
X  char *tmp;
X  int id = -1;
X  int i;
X
X  for (i=0; i<num; i++) {
X    /* Match by simple index. */
X    tmp = names[i] + strlen("View: ");
X    if (strcmp(tmp, name) == 0) {
X      id = (Cardinal) i;
X      break;
X    }
X  }
X  if (id > -1)
X    id = SetPlotModeIndex((Cardinal) id, xg);
X
X  return (id);
}
X
X
/*
X * CORBA: returns an array (and its length) or the menu names
X * for controlling the plot/view type.
*/
char **
GetPlotViewTypes(int *num) 
{
X  *num = sizeof(view_menu_labelname) / sizeof(view_menu_labelname[0]) ;
X  return (view_menu_labelname);
}
X
void
make_view_menu(xgobidata *xg, Widget parent)
{
X  int j, k;
X  Dimension width, maxwidth;
X  int longest = 0;
X
X  static char *view_menu_fullname[] = {
X    "1DPlot (d)",
X    "XYPlot (x)",
X    "Rotation (r)",
X    "Grand Tour (g)",
X    "Correlation Tour (c)",
X    "Scale (s)",
X    "Brush (b)",
X    "Identify (i)",
X    "Line Editing (l)",
X    "Move Points (m)",
X  };
X  char *accelerators;
X  accelerators = XtMalloc(512 * sizeof(char));
X
X  sprintf(accelerators,
X    "<Key>%s:SetPlotMode(%d)\n\
X     <Key>%s:SetPlotMode(%d)\n\
X     <Key>%s:SetPlotMode(%d)\n\
X     <Key>%s:SetPlotMode(%d)\n\
X     <Key>%s:SetPlotMode(%d)\n\
X     <Key>%s:SetPlotMode(%d)\n\
X     <Key>%s:SetPlotMode(%d)\n\
X     <Key>%s:SetPlotMode(%d)\n\
X     <Key>%s:SetPlotMode(%d)\n\
X     <Key>%s:SetPlotMode(%d)",
X     view_menu_accel[PLOT1D_MODE], PLOT1D_MODE,
X     view_menu_accel[XYPLOT_MODE], XYPLOT_MODE,
X     view_menu_accel[ROTATE_MODE], ROTATE_MODE,
X     view_menu_accel[GTOUR_MODE], GTOUR_MODE,
X     view_menu_accel[CTOUR_MODE], CTOUR_MODE,
X     view_menu_accel[SCALE_MODE], SCALE_MODE,
X     view_menu_accel[BRUSH_MODE], BRUSH_MODE,
X     view_menu_accel[IDENTIFY_MODE], IDENTIFY_MODE,
X     view_menu_accel[LINEEDIT_MODE], LINEEDIT_MODE,
X     view_menu_accel[MOVEPTS_MODE], MOVEPTS_MODE);
X
X  maxwidth = 0;
X  longest = k = 0;
X  for (k=0; k<NVIEWMODES; k++)
X  {
X    /*
X     * add 3 borderwidths, 2 at the edges and one between the
X     * menu bitmap and text, and add the width of menu bitmap
X    */
X    width = XTextWidth(appdata.font, view_menu_labelname[k],
X      strlen(view_menu_labelname[k])) + 3*ASCII_TEXT_BORDER_WIDTH + 12;
X    if (width > maxwidth) {
X      maxwidth = width;
X      longest = k;
X    }
X  }
X
X  xg->plot_mode = xg->prev_plot_mode = XYPLOT_MODE;
X  view_menu_cmd = XtVaCreateManagedWidget("Command",
X    menuButtonWidgetClass, parent,
X    /* Create the widget using the longest label */
X    XtNlabel, (String) view_menu_labelname[longest],
X    XtNwidth, maxwidth,
X    XtNresize, False,
X    XtNmenuName, (String) "Menu",
X    NULL);
X  if (mono) set_mono(view_menu_cmd);
X  add_menupb_help(&xg->nhelpids.menupb,
X    view_menu_cmd, "ViewMenu");
X
X  view_menu = XtVaCreatePopupShell("Menu",
X    simpleMenuWidgetClass, view_menu_cmd,
X    XtNinput, True,
X    XtNaccelerators, XtParseAcceleratorTable(accelerators),
X    NULL);
X  if (mono) set_mono(view_menu);
X
X  for (j=0; j<NVIEWMODES; j++) {
X    view_menu_btn[j] = XtVaCreateWidget("Command",
X      smeBSBObjectClass, view_menu,
X      XtNlabel, (String) view_menu_fullname[j],
X      NULL);
X    if (mono) set_mono(view_menu_btn[j]);
X
X    XtAddCallback(view_menu_btn[j], XtNcallback,
X      (XtCallbackProc) view_menu_cback, (XtPointer) xg);
X
X    /* Add a line after the 5th entry */
X    if (j == 4)
X      (void) XtVaCreateManagedWidget("Line",
X          smeLineObjectClass, view_menu,
X          NULL);
X  }
X
X  XtManageChildren(view_menu_btn, NVIEWMODES);
/* Now reset the mode */
X  XtVaSetValues(view_menu_cmd,
X    XtNlabel, (String) view_menu_labelname[XYPLOT_MODE],
X    NULL);
X
X  XtFree((char *) accelerators);
}
X
void
set_display_menu_marks(xgobidata *xg)
{
X  XtVaSetValues(display_menu_btn[ADDAXES],
X    XtNleftBitmap, (xg->is_axes) ? (Pixmap) menu_mark : (Pixmap) None,
X    NULL);
X  XtVaSetValues(display_menu_btn[ADDGRID],
X    XtNleftBitmap, (xg->add_gridlines) ? (Pixmap) menu_mark : (Pixmap) None,
X    NULL);
X  XtVaSetValues(display_menu_btn[CENTERAXES],
X    XtNleftBitmap, (xg->is_axes_centered) ? (Pixmap) menu_mark : (Pixmap) None,
X    NULL);
X  XtVaSetValues(display_menu_btn[SHOWPOINTS],
X    XtNleftBitmap, (xg->plot_the_points) ? (Pixmap) menu_mark : (Pixmap) None,
X    NULL);
X  XtVaSetValues(display_menu_btn[SHOWARROWS],
X    XtNleftBitmap, (xg->plot_the_arrows) ? (Pixmap) menu_mark : (Pixmap) None,
X    NULL);
X  XtVaSetValues(display_menu_btn[SHOWLINES],
X    XtNleftBitmap,
X      (xg->connect_the_points) ? (Pixmap) menu_mark : (Pixmap) None,
X    NULL);
X  XtVaSetValues(display_menu_btn[CARRYVARS],
X    XtNleftBitmap, (xg->carry_vars) ? (Pixmap) menu_mark : (Pixmap) None,
X    NULL);
}
X
/* ARGSUSED */
static XtCallbackProc
display_menu_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  int btn;
X
X  for (btn=0; btn<NDISPLAYBTNS; btn++)
X    if (display_menu_btn[btn] == w)
X      break;
X
X  switch (btn) {
X    case ADDAXES :
X      xg->is_axes = !xg->is_axes;
X      plot_once(xg);
X      break;
X    case ADDGRID :
X      xg->add_gridlines = !xg->add_gridlines;
X      plot_once(xg);
X      break;
X    case CENTERAXES :
X      xg->is_axes_centered = !xg->is_axes_centered;
X      plot_once(xg);
X      break;
X    case SHOWPOINTS :
X      xg->plot_the_points = !xg->plot_the_points;
X      plot_once(xg);
X      break;
X    case SHOWLINES :  /* undirected lines */
X      xg->connect_the_points = !xg->connect_the_points;
X
X      if (xg->connect_the_points)
X        xg->plot_the_arrows = False;
X
X      /*
X       * Set this to 1 in case there are line colors.
X      */
X      xg->got_new_paint = True;
X      plot_once(xg);
X      break;
X
X    case SHOWARROWS : /* directed lines */
X      xg->plot_the_arrows = !xg->plot_the_arrows;
X
X      if (xg->plot_the_arrows)
X        xg->connect_the_points = False;
X
X      xg->got_new_paint = True;
X      plot_once(xg);
X      break;
X    case CARRYVARS :
X      xg->carry_vars = !xg->carry_vars;
X      break;
X  }
X
X  /*
X   * Show/don't show all the lines. Make sure the duplicate
X   * toggle on the line editor panel has the right value.
X  */
X  set_showlines(xg->connect_the_points || xg->plot_the_arrows);
X
X  set_display_menu_marks(xg);
}
X
/*ARGSUSED*/
XXtActionProc
KeyDisplayMenu(Widget w, XEvent *event, String *params, Cardinal nparams)
{
X  extern xgobidata xgobi;
X  xgobidata *xg = &xgobi;
X  int accel = atoi(params[0]);
X  XtCallCallbacks(display_menu_btn[accel], XtNcallback, (XtPointer) xg);
}
/*ARGSUSED*/
XXtActionProc
KeyToolMenu(Widget w, XEvent *event, String *params, Cardinal nparams)
{
X  extern xgobidata xgobi;
X  xgobidata *xg = &xgobi;
X
X  if (strcmp(params[0], "8") == 0) {
X    XtCallCallbacks(tool_menu_btn[8], XtNcallback, (XtPointer) xg);
X  }
}
X
X
static void
make_display_menu(xgobidata *xg, Widget parent)
{
X  int k;
X
X  static char *menu_accel[] = {
X    "a", "n"
X  };
X
X  static char *display_menu_name[] = {
X    "Add axes to plot (a)",
X    "Add gridlines to plot (n)",
X    "Center axes in 3D+ modes",
X    "Plot the points",
X    "Show undirected lines",
X    "Show directed lines",
X    "Carry variables between views",
X  };
X
X  char *accelerators;
X  accelerators = XtMalloc(512 * sizeof(char));
X  sprintf(accelerators,
X    "<Key>%s:KeyDisplayMenu(%d)\n\
X     <Key>%s:KeyDisplayMenu(%d)",  /* modifiers:  Alt, Ctrl, Shift<Key>%s */
X     menu_accel[ADDAXES], ADDAXES,
X     menu_accel[ADDGRID], ADDGRID);
X
X  display_menu_cmd = XtVaCreateManagedWidget("Command",
X    menuButtonWidgetClass, parent,
X    XtNlabel, (String) "Display",
X    XtNmenuName, (String) "Menu",
X    NULL);
X  if (mono) set_mono(display_menu_cmd);
X  add_menupb_help(&xg->nhelpids.menupb,
X    display_menu_cmd, "DisplayOptions");
X
X  display_menu = XtVaCreatePopupShell("Menu",
X    simpleMenuWidgetClass, display_menu_cmd,
X    XtNaccelerators, XtParseAcceleratorTable(accelerators),
X    XtNinput, True,
X    NULL);
X  if (mono) set_mono(display_menu);
X
X  for (k=0; k<NDISPLAYBTNS; k++)
X  {
X    display_menu_btn[k] = XtVaCreateWidget("Command",
X      smeBSBObjectClass, display_menu,
X      XtNleftMargin, (Dimension) 24,
X      XtNleftBitmap, menu_mark,
X      XtNlabel, (String) display_menu_name[k],
X      NULL);
X    if (mono) set_mono(display_menu_btn[k]);
X
X    XtAddCallback(display_menu_btn[k], XtNcallback,
X      (XtCallbackProc) display_menu_cback, (XtPointer) xg);
X
X    /* Add a line after the 6th entry */
X    if (k == 5)
X      (void) XtVaCreateManagedWidget("Line",
X          smeLineObjectClass, display_menu,
X          NULL);
X  }
X
X  XtManageChildren(display_menu_btn, NDISPLAYBTNS);
X
X  XtFree((char *) accelerators);
}
X
void
turn_on_xyplotting(xgobidata *xg)
{
X  XtCallCallbacks(view_menu_btn[XYPLOT_MODE], XtNcallback, (XtPointer) xg);
}
X
void
turn_off_cprof_plotting(xgobidata *xg)
{
X  XtCallCallbacks(tool_menu_btn[PARCOORD_BTN], XtNcallback, (XtPointer) xg);
}
X
void
set_sens_missing_menu_btns(Boolean sens)
{
X  XtSetSensitive(tool_menu_btn[LAUNCH_MISSING_BTN], sens);
X  XtSetSensitive(tool_menu_btn[IMPUTE_BTN], sens);
}
X
void
make_tool_menu(xgobidata *xg, Widget parent)
{
X  int j;
X
X  static char *tool_menu_fullname[] = {
X    "Hide or exclude ...",
X    "Sample or subset ...",
X    "Smooth ...",
X    "Jitter ...",
X    "Graphical inference ...",
X    "Parallel coordinates plot ...",
X    "Clone XGobi ...",
X    "Scatterplot matrix ...",
X    "Variable transformation ... (t)",
X    "Variable list ...",
X    "Case list ...",
X    "Launch missing data XGobi ...",
X    "Impute missing values ...",
X
X  #ifdef XPLORE
X    "Start XploRe ...",
X    "Stop XploRe ...",
X  #endif
X
X  };
X
X  static char *menu_accel[] = {
X    "t",
X  };
X
X  char *accelerators;
X  accelerators = XtMalloc(512 * sizeof(char));
X  sprintf(accelerators,
X    "<Key>%s:KeyToolMenu(%d)",  /* modifiers:  Alt, Ctrl, Shift<Key>%s */
X     menu_accel[0], 8);
X
X  tool_menu_cmd = XtVaCreateManagedWidget("ToolMenuButton",
X    menuButtonWidgetClass, parent,
X    XtNlabel,    "Tools",
X    XtNmenuName, "Menu",
X    NULL);
X  if (mono) set_mono(tool_menu_cmd);
X  add_menupb_help(&xg->nhelpids.menupb,
X    tool_menu_cmd, "ToolMenu");
X
X  tool_menu = XtVaCreatePopupShell("Menu",
X    simpleMenuWidgetClass, tool_menu_cmd,
X    XtNaccelerators, XtParseAcceleratorTable(accelerators),
X    XtNinput, True,
X    NULL);
X  if (mono) set_mono(tool_menu);
X
X  for (j=0; j<NTOOLBTNS; j++)
X  {
X    tool_menu_btn[j] = XtVaCreateWidget("Command",
X      smeBSBObjectClass, tool_menu,
X      XtNlabel, (String) tool_menu_fullname[j],
X      NULL);
X    if (mono) set_mono(tool_menu_btn[j]);
X
X    /* Add some lines ... */
X
#ifdef XPLORE
X    if (j == 1 || j == 4 || j == 7 || j == 10 || j == 11)
#else
X    if (j == 1 || j == 4 || j == 7 || j == 10)
#endif
X
X      (void) XtVaCreateManagedWidget("Line",
X          smeLineObjectClass, tool_menu,
X          NULL);
X  }
X
X  set_sens_missing_menu_btns(xg->missing_values_present);
X
X  if (xg->nrgroups > 0)
X    XtSetSensitive(tool_menu_btn[SCATMAT_BTN], False);
X
X  XtAddCallback(tool_menu_btn[CLONE_BTN], XtNcallback,
X    (XtCallbackProc) clone_xgobi_cback, (XtPointer) xg);
X  XtAddCallback(tool_menu_btn[JITTER_BTN], XtNcallback,
X    (XtCallbackProc) open_jitter_popup_cback, (XtPointer) xg);
X  XtAddCallback(tool_menu_btn[LAUNCH_MISSING_BTN], XtNcallback,
X    (XtCallbackProc) launch_missing_cback, (XtPointer) xg);
X  XtAddCallback(tool_menu_btn[IMPUTE_BTN], XtNcallback,
X    (XtCallbackProc) open_imputation_popup_cback, (XtPointer) xg);
X  XtAddCallback(tool_menu_btn[SMOOTH_BTN], XtNcallback,
X    (XtCallbackProc) open_smooth_popup_cback, (XtPointer) xg);
X  XtAddCallback(tool_menu_btn[PARCOORD_BTN], XtNcallback,
X    (XtCallbackProc) cprof_plot_cback, (XtPointer) xg);
X  XtAddCallback(tool_menu_btn[SUBSET_BTN], XtNcallback,
X    (XtCallbackProc) subset_panel_cback, (XtPointer) xg);
X  XtAddCallback(tool_menu_btn[VARTFORM_BTN], XtNcallback,
X    (XtCallbackProc) open_tform_popup_cback, (XtPointer) xg);
X  XtAddCallback(tool_menu_btn[VARLIST_BTN], XtNcallback,
X    (XtCallbackProc) PopupVarlist, (XtPointer) xg);
X  XtAddCallback(tool_menu_btn[CASELIST_BTN], XtNcallback,
X    (XtCallbackProc) PopupCaselist, (XtPointer) xg);
X  XtAddCallback(tool_menu_btn[SCATMAT_BTN], XtNcallback,
X    (XtCallbackProc) scatmat_xgobi_cback, (XtPointer) xg);
X  XtAddCallback(tool_menu_btn[INFER_BTN], XtNcallback,
X    (XtCallbackProc) open_infer_popup_cback, (XtPointer) xg);
X  XtAddCallback(tool_menu_btn[EXCLUSION_BTN], XtNcallback,
X    (XtCallbackProc) open_exclusion_popup_cback, (XtPointer) xg);
X
#ifdef XPLORE
X  XtAddCallback(tool_menu_btn[XPLORE_BTN], XtNcallback,
X    (XtCallbackProc) start_xplore_cback, (XtPointer) xg);
X  XtAddCallback(tool_menu_btn[XPLORE_END_BTN], XtNcallback,
X    (XtCallbackProc) stop_xplore_cback, (XtPointer) xg);
#endif
X
X  /*
X   * If a .nlinkable file is used, then subsetting
X   * is to be disabled.
X  XtVaSetValues(tool_menu_btn[SUBSET_BTN],
X    XtNsensitive, (xg->nlinkable == xg->nrows),
X    NULL);
X  */
X
#ifdef XPLORE
X   XtVaSetValues(tool_menu_btn[XPLORE_END_BTN],
X     XtNsensitive, False,
X     NULL);
#endif
X
X  /*
X   * If there's no missing data, disable the 'missing' buttons.
X   * Ditto if this is already the missing values xgobi.
X  */
X  if (!xg->missing_values_present || xg->is_missing_values_xgobi) {
X    XtVaSetValues(tool_menu_btn[LAUNCH_MISSING_BTN],
X      XtNsensitive, False,
X      NULL);
X    XtVaSetValues(tool_menu_btn[IMPUTE_BTN],
X      XtNsensitive, False,
X      NULL);
X  }
X
X  XtManageChildren(tool_menu_btn, NTOOLBTNS);
X
X  XtFree((char *) accelerators);
}
X
void active_xplore_buttons ()
X
{
#ifdef XPLORE
X
X   XtVaSetValues(tool_menu_btn[XPLORE_BTN], /* Start XploRe */
X     XtNsensitive, False,
X     NULL);
X
X   XtVaSetValues(tool_menu_btn[XPLORE_END_BTN], /* End XploRe */
X     XtNsensitive, True,
X     NULL);
X
X   XtVaSetValues(file_menu_btn[4], /* XploRe (pass variables) */
X     XtNsensitive, True,
X     NULL);
X
X   XtVaSetValues(file_menu_btn[5], /* XploRe (pass projection) */
X     XtNsensitive, True,
X     NULL);
X
#endif
}
X
void inactive_xplore_buttons ()
{
#ifdef XPLORE
X
X   XtVaSetValues(tool_menu_btn[XPLORE_BTN], /* Start XploRe */
X     XtNsensitive, True,
X     NULL);
X
X   XtVaSetValues(tool_menu_btn[XPLORE_END_BTN], /* End XploRe */
X     XtNsensitive, False,
X     NULL);
X
X   XtVaSetValues(file_menu_btn[4], /* XploRe (pass variables) */
X     XtNsensitive, False,
X     NULL);
X
X   XtVaSetValues(file_menu_btn[5], /* XploRe (pass projection) */
X     XtNsensitive, False,
X     NULL);
X
#endif
}
X
void
make_widgets(xgobidata *xg)
{
X  Widget info_menu_cmd, info_menu, info_menu_btn[2];
X
X  xg->form0 = XtVaCreateManagedWidget("Form0",
X    formWidgetClass, xg->shell,
X    NULL);
X  if (mono) set_mono(xg->form0);
X
/*
X * Define main_panel, the main control panel
*/
X  main_panel = XtVaCreateManagedWidget("MainPanel",
X    boxWidgetClass, xg->form0,
X    XtNorientation, (XtOrientation) XtorientHorizontal,
X    XtNleft, (XtEdgeType) XtChainLeft,
X    XtNright, (XtEdgeType) XtChainLeft,
X    XtNtop, (XtEdgeType) XtChainTop,
X    XtNbottom, (XtEdgeType) XtChainTop,
X    NULL);
X  if (mono) set_mono(main_panel);
X
X  make_file_menu(xg, main_panel);
X  make_view_menu(xg, main_panel);
X  make_tool_menu(xg, main_panel);
X  make_display_menu(xg, main_panel);
X
X  info_menu_cmd = XtVaCreateManagedWidget("MenuButton",
X    menuButtonWidgetClass, main_panel,
X    XtNlabel, (String) "Info",
X    XtNmenuName, (String) "Menu",
X    /*XtNfromHoriz, IO,*/
X    NULL);
X  if (mono) set_mono(info_menu_cmd);
X
/* Build the info menu right here */
X  info_menu = XtVaCreatePopupShell("Menu",
X    simpleMenuWidgetClass, info_menu_cmd,
X    NULL);
X  info_menu_btn[0] = XtVaCreateManagedWidget("Command",
X    smeBSBObjectClass, info_menu,
X    XtNlabel, (String) "About XGobi ... ",
X    NULL);
X  XtAddCallback(info_menu_btn[0], XtNcallback,
X    (XtCallbackProc) about_xgobi_cback, (XtPointer) xg);
X  info_menu_btn[1] = XtVaCreateManagedWidget("Command",
X    smeBSBObjectClass, info_menu,
X    XtNlabel, (String) "About help ... ",
X    NULL);
X  XtAddCallback(info_menu_btn[1], XtNcallback,
X    (XtCallbackProc) help_cback, (XtPointer) xg);
/* End of info menu */
X
/*
X * Paned widget to help users adjust the plot window and the
X * variable selection panel.
*/
X  form1 = XtVaCreateManagedWidget("Form1",
X    panedWidgetClass, xg->form0,
X    XtNfromVert, (Widget) main_panel,
X    XtNleft, (XtEdgeType) XtChainLeft,
X    XtNright, (XtEdgeType) XtChainRight,
X    XtNtop, (XtEdgeType) XtChainTop,
X    XtNbottom, (XtEdgeType) XtRubber,
X    XtNorientation, (XtOrientation) XtorientHorizontal,
X    NULL);
X  if (mono) set_mono(form1);
X
X  xg->box0 = XtVaCreateManagedWidget("Box0",
X    formWidgetClass, form1,
X    XtNmin, 5,
X    NULL);
X  if (mono) set_mono(xg->box0);
X
X  xg->box1 = XtVaCreateManagedWidget("Box1",
X    formWidgetClass, form1,
X    XtNmin, 5,
X    NULL);
X  if (mono) set_mono(xg->box1);
X
X  xg->box2 = XtVaCreateManagedWidget("Box2",
X    formWidgetClass, form1,
X    XtNmin, 5,
X    NULL);
X  if (mono) set_mono(xg->box2);
}
X
#undef NDISPLAYBTNS
#undef NFILEBTNS
#undef NTOOLBTNS
SHAR_EOF
  chmod 0644 'xgobi/src/widgets.c' ||
  $echo 'restore of' 'xgobi/src/widgets.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/widgets.c:' 'MD5 check failed'
803f6579c32f164c4d403d88a3bfcc6a  xgobi/src/widgets.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/widgets.c'`"
    test 38073 -eq "$shar_count" ||
    $echo 'xgobi/src/widgets.c:' 'original size' '38073,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/xgobitop.h ==============
if test -f 'xgobi/src/xgobitop.h' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/xgobitop.h' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/xgobitop.h' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/xgobitop.h' &&
/* xgobitop.h */
/************************************************************
X *                                                          *
X *  Permission is hereby granted  to  any  individual   or  *
X *  institution   for  use,  copying, or redistribution of  *
X *  the xgobi code and associated documentation,  provided  *
X *  that   such  code  and documentation are not sold  for  *
X *  profit and the  following copyright notice is retained  *
X *  in the code and documentation:                          *
X *        Copyright (c) 1990, ..., 1996 Bellcore            *
X *                                                          *
X *  We welcome your questions and comments, and request     *
X *  that you share any modifications with us.               *
X *                                                          *
X *    Deborah F. Swayne            Dianne Cook              *
X *   dfs@research.att.com       dicook@iastate.edu          *
X *      (973) 360-8423    www.public.iastate.edu/~dicook/   *
X *                                                          *
X *                    Andreas Buja                          *
X *                andreas@research.att.com                  *
X *              www.research.att.com/~andreas/              *
X *                                                          *
X ************************************************************/
X
/* ARGSUSED */
XXtActionProc
SetCurrentWindow(Widget w, XEvent *event, String *params, Cardinal nparams)
{
X  xgobi.current_window = 1;
X  /* CORBA */
X  return (NULL);
}
X
/* ARGSUSED */
XXtActionProc
UnsetCurrentWindow(Widget w, XEvent *event, String *params, Cardinal nparams)
{
X  XCrossingEvent *evnt = (XCrossingEvent *) event;
X
X  if (evnt->detail != NotifyInferior)
X    xgobi.current_window = 0;
X  /* CORBA */
X  return (NULL);
}
X
/* to make xgobi work with motif */
/* ARGSUSED */
XXtActionProc
WM_Quit(Widget w, XEvent *event, String *params, Cardinal nparams)
{
X  if (w == xgobi.shell)
X  {
X    xgobi.is_realized = False;
X    XtDestroyApplicationContext(XtWidgetToApplicationContext(w));
X    exit(0);
X  }
X  else
X    XtPopdown(w);
X  /* CORBA */
X  return (NULL);
}
X
/*ARGSUSED*/
XXtActionProc
TogglePause(Widget w, XEvent *event, String *params, Cardinal nparams)
{
X  extern xgobidata xgobi;
X  xgobidata *xg = &xgobi;
X
X  if (xg->is_spinning) 
X    reset_spin_pause_cmd(xg);
X  else if (xg->is_touring) 
X    reset_tour_pause_cmd(xg);
X  else if (xg->is_corr_touring) 
X    reset_corr_pause_cmd(xg);
X  else if (xg->is_xyplotting) {
X    extern Widget xy_cycle_cmd;
X    XtCallCallbacks(xy_cycle_cmd, XtNcallback, (XtPointer) xg);
X    XtVaSetValues(xy_cycle_cmd, XtNstate, xg->is_xy_cycle, NULL);
X  } else if (xg->is_plotting1d) {
X    extern Widget plot1d_cycle_cmd;
X    XtCallCallbacks(plot1d_cycle_cmd, XtNcallback, (XtPointer) xg);
X    XtVaSetValues(plot1d_cycle_cmd, XtNstate, xg->is_plot1d_cycle, NULL);
X  }
X  /* CORBA */
X  return (NULL);
}
X
/*ARGSUSED*/
static XtActionProc
RepeatAction(Widget w, XEvent *event, String *params, Cardinal nparams)
{
X  extern void permute_again(xgobidata *);
X  extern xgobidata xgobi;
X  xgobidata *xg = &xgobi;
X
X  permute_again(xg);
X
X  /* Maybe with an argument? */
X  /* jitter_again(xg); */
X  /* CORBA */
X  return (NULL);
}
/*ARGSUSED*/
static XtActionProc
RestoreAction(Widget w, XEvent *event, String *params, Cardinal nparams)
{
/*
X * This is intended to restore a variable to its untransformed state.
X * It's a bit more complicated than RepeatAction, because it must also
X * affect menus.  The same sort of thing could happen with jittering.
*/
X  extern void restore_variables(xgobidata *);
X  extern xgobidata xgobi;
X  xgobidata *xg = &xgobi;
X
X  restore_variables(xg);
X  /* CORBA */
X  return (NULL);
}
X
XXtActionProc HelpSelect(), Bell();
XXtActionProc ShowTarget(), DontShowTarget();
XXtActionProc NullNearestPoint();
XXtActionProc SetPlotMode(), KeyFileMenu(), KeyDisplayMenu(), KeyToolMenu();
XXtActionProc StartScaleByArrow(), StopScaleByArrow();
/* For variable and case lists */
/* XtActionProc GetListSelection(); */
XXtActionProc ToggleCurrentLine();
XXtActionsRec added_actions[] = {
X  {"HelpSelect", (XtActionProc) HelpSelect},
X  {"Bell", (XtActionProc) Bell},
X  {"SetCurrentWindow", (XtActionProc) SetCurrentWindow},
X  {"UnsetCurrentWindow", (XtActionProc) UnsetCurrentWindow},
X  {"ShowTarget", (XtActionProc) ShowTarget},
X  {"DontShowTarget", (XtActionProc) DontShowTarget},
X  {"NullNearestPoint", (XtActionProc) NullNearestPoint},
/* For variable and case lists */
X  /* {"GetListSelection", (XtActionProc) GetListSelection}, */
X  {"ToggleCurrentLine", (XtActionProc) ToggleCurrentLine},
/* to make xgobi work with motif */
X  {"wm_quit", (XtActionProc) WM_Quit}, 
/* view menu */
X  {"SetPlotMode", (XtActionProc) SetPlotMode},
/* file menu */
X  {"KeyFileMenu", (XtActionProc) KeyFileMenu},
/* display and tool menus */
X  {"KeyDisplayMenu", (XtActionProc) KeyDisplayMenu},
X  {"KeyToolMenu", (XtActionProc) KeyToolMenu},
/* toggle pause in all rotation modes; toggle cycle in xyplot and plot1d */
X  {"TogglePause", (XtActionProc) TogglePause},
/* to allow certain actions to be repeated with the "." key */
X  {"RepeatAction", (XtActionProc) RepeatAction},
/* to allow certain restore actions to be performed with the "," key */
X  {"RestoreAction", (XtActionProc) RestoreAction},
/* scale using the arrow keys */
X  {"StartScaleByArrow", (XtActionProc) StartScaleByArrow},
X  {"StopScaleByArrow", (XtActionProc) StopScaleByArrow},
};
X
String
fallback_resources[] = {
X  "*XGobi.title:    XGobi",
X  "*XGobi.iconName: XGobi",
X  "*font:          -*-helvetica-bold-r-*-*-14-*-*-*-*-*-*-*",
X  "*plotFont:      -*-helvetica-bold-r-*-*-14-*-*-*-*-*-*-*",
X  "*helpFont:      -*-helvetica-bold-r-*-*-14-*-*-*-*-*-*-*",
X
X  /* for Motif and LessTif */
X  "*fontList:      -*-helvetica-bold-r-*-*-14-*-*-*-*-*-*-*",
X
X  "*showAxes:      True",
X  "*showPoints:    True",
X  "*showLines:     False",
X  "*linkGlyphBrush: True",
X  "*linkColorBrush: True",
X  "*linkEraseBrush: True",
X  "*linkLineBrush: True",
X  "*linkIdentify:  True",
X  "*carryVars:     False",
X  "*jumpBrush:     True",
X  "*reshapeBrush:  False",
X  "*plotSquare:    True",
X  "*glyphType:     6",
X  "*glyphSize:     1",
X
X  "*defaultGlyph:  26",
X  "*defaultColor:  white",
X  "*axisColor:     lightgray",
X
X  "*brushColor0:   DeepPink",
X  "*brushColor1:   OrangeRed1",
X  "*brushColor2:   DarkOrange",
X  "*brushColor3:   Gold",
X  "*brushColor4:   Yellow",
X  "*brushColor5:   DeepSkyBlue1",
X  "*brushColor6:   SlateBlue1",
X  "*brushColor7:   YellowGreen",
X  "*brushColor8:   MediumSpringGreen",
X  "*brushColor9:   MediumOrchid",
X  "*defaultPrintCmd: lp",
X
X  "*XGobi*horizDistance: 5",
X  "*XGobi*vertDistance: 5",
X  "*XGobi*Options*vertDistance: 2",
X
X  "*XGobi*Form1.gripIndent: 5",
X  "*XGobi*MainPanel.defaultDistance: 2",
X
X  "*XGobi*PlotWindow.height: 300",
X  "*XGobi*PlotWindow.width: 300",
X
X  "*XGobi*VarPanel.hSpace: 1",
X  "*XGobi*VarPanel.vSpace: 1",
X  "*XGobi*VarPanel.borderWidth: 0",
X  "*XGobi*VarPanel.width: 180",
X  "*XGobi*VarPanel.top: ChainTop",
X  "*XGobi*VarPanel.left: ChainLeft",
X  "*XGobi*VarPanel.right: ChainRight",
X  "*XGobi*VarPanel.bottom: ChainBottom",
X
X  "*XGobi*VarForm.borderWidth: 0",
X  "*XGobi*VarForm.hSpace: 0",
X  "*XGobi*VarForm.vSpace: 0",
X  "*XGobi*VarWindow.borderWidth: 0",
X  "*XGobi*VarWindow.width: 44",
X  "*XGobi*VarWindow.vertDistance: 0",
X
X  "*XGobi*TourPanel*hSpace: 3",
X  "*XGobi*TourPanel*vSpace: 3",
X  "*XGobi*TourPanel*vertDistance: 3",
X  "*XGobi*TourPanel*horizDistance: 3",
X  "*XGobi*TourPanel*Panel.Scrollbar.vertDistance: 0",
X
X  "*XGobi*PPplot.height:  180",
X  "*XGobi*PPplot.width:   500",
X
X  "*XGobi*ScaleShiftPanel*hSpace: 3",
X  "*XGobi*ScaleShiftPanel*vSpace: 3",
X  "*XGobi*ScaleShiftPanel*Icon.horizDistance: 0",
X  "*XGobi*ScaleShiftPanel*Icon.vertDistance: 0",
X
X  "*XGobi*StdizePanel*hSpace: 3",
X  "*XGobi*StdizePanel*vSpace: 3",
X  "*XGobi*StdizePanel*horizDistance: 3",
X  "*XGobi*StdizePanel*vertDistance: 3",
X
X  "*XGobi*BrushPanel.Panel.hSpace: 2",
X  "*XGobi*BrushPanel.Panel.vSpace: 2",
X
X  "*XGobi*FSavePopup*FSaveName.height: 25",
X  "*XGobi*FSavePopup*FSaveName.width: 265",
X  "*XGobi*FSavePopup*FSaveText.height: 25",
X
X  "*XGobi*Help*Text.height: 250",
X  "*XGobi*Help*Text.width: 600",
X
X  "*XGobi*MouseLabel.left: ChainLeft",
X  "*XGobi*MouseLabel.right: ChainLeft",
X  "*XGobi*MouseLabel.top: ChainTop",
X  "*XGobi*MouseLabel.bottom: ChainTop",
X  "*XGobi*MouseLabel.mappedWhenManaged: False",
X  "*XGobi*VarMouseLabel.left: ChainLeft",
X  "*XGobi*VarMouseLabel.right: ChainLeft",
X  "*XGobi*VarMouseLabel.top: ChainTop",
X  "*XGobi*VarMouseLabel.bottom: ChainTop",
X
X  /* An alternate method of programming accelerators */
X  "*XGobi*Form0.accelerators: #augment \\n\
X    <Key>p: TogglePause()",
X
/* "." : permutation with a keystroke */
/* " " : restore variable transformation */
/* It doesn't work inside the variable circles, I think
X * because there's a KeyPressMask in use there.
*/
X  "*XGobi*VarPanel.accelerators: #augment \\n\
X    <Key>.: RepeatAction() \\n\
X    <Key>Return: RestoreAction()",
X
X  /* Translations */
X  "*XGobi*Form0.Translations: #augment \\n\
X    <EnterWindow>:  SetCurrentWindow() \\n\
X    <LeaveWindow>:  UnsetCurrentWindow()",
X
X  "*XGobi*VarPanel.Translations: #augment \\n\
X    <EnterWindow>:  ShowTarget() \\n\
X    <LeaveWindow>:  DontShowTarget()",
X
X  "*XGobi*Scrollbar.Translations: #override \\n\
X    <Btn1Down>:   StartScroll(Continuous) MoveThumb() NotifyThumb() \\n\
X    <Btn1Motion>: MoveThumb() NotifyThumb() \\n\
X    <Btn3Down>:   HelpSelect()",
X
X  "*XGobi*List.Translations: #augment \\n\
X    <EnterWindow>:  SetCurrentWindow() \\n\
X    <LeaveWindow>:  UnsetCurrentWindow()",
X  "*XGobi*List*Text.Translations: #replace \\n\
X    <Btn1Down>:     select-start() ToggleCurrentLine(p) \\n\
X    <Btn1Motion>:   select-start() ToggleCurrentLine(m)",
X
X  "*XGobi*PrintText.Translations: #override <Key>Return: Bell()",
X  "*XGobi*MissingText.Translations: #override <Key>Return: Bell()",
X
X  "*XGobi*Toggle.Translations: #override \\n\
X    <EnterWindow>:         highlight(Always) \\n\
X    <LeaveWindow>:         unhighlight() \\n\
X    <Btn1Down>, <Btn1Up>:  set()notify() \\n\
X    <Btn3Down>:            HelpSelect()",
X
X  "*XGobi*Command.Translations: #override <Btn3Down>: HelpSelect()",
X  "*XGobi*MenuButton.Translations: #override <Btn3Down>: HelpSelect()",
X  "*XGobi*PlotWindow.Translations: #override \\n\
X     <LeaveWindow>:  NullNearestPoint() \\n\
X     <Btn3Down>:     HelpSelect()",
X
X  "*XGobi*VarLabel.Translations: #override <Btn3Down>: HelpSelect()",
X  "*XGobi*VarWindow.Translations: #override <Btn3Down>: HelpSelect()",
X  "*XGobi*Icon.Translations: #override <Btn3Down>: HelpSelect()",
X
X  /* Menu Icon */
X  "*XGobi*MenuButton.leftBitmap: menu12",
X  /* "*XGobi*MenuButton.leftBitmap: ../bitmaps/menu12", */
X
X  /* Colors */
X
X  "*XGobi*background: Moccasin",
X  "*XGobi*foreground: NavyBlue",
X  "*pointerColor: White",
X  "*XGobi*MainPanel.background: DarkKhaki",
X  "*XGobi*PlotWindow.background: blue4",
X  "*XGobi*PlotWindow.foreground: white",
X  "*XGobi*Command.background: SandyBrown",
X  "*XGobi*Command.borderColor: NavyBlue",
X  "*XGobi*Command.foreground: NavyBlue",
X  "*XGobi*Toggle.background: SandyBrown",
X  "*XGobi*Toggle.borderColor: NavyBlue",
X  "*XGobi*Toggle.foreground: NavyBlue",
X  "*XGobi*MenuButton.background: SandyBrown",
X  "*XGobi*MenuButton.borderColor: NavyBlue",
X  "*XGobi*MenuButton.foreground: NavyBlue",
X  "*XGobi*Scrollbar.background: SandyBrown",
X  "*XGobi*Scrollbar.borderColor: NavyBlue",
X  "*XGobi*Scrollbar.foreground: NavyBlue",
X  /*
X   * This is ignored; the arrows are created with certain
X   * color characteristics.  See make_arrows() in widgets.c.
X  "*XGobi*Arrow.background: SandyBrown",
X  "*XGobi*Arrow.borderColor: NavyBlue",
X  */
X
X  "*XGobi*PPplot.background: Blue4",
X  "*XGobi*PPplot.foreground: white",
X
X  "*XGobi*BrushPanel.background: PeachPuff",
X  "*XGobi*BrushPanel.Panel.background: DarkKhaki",
X  "*XGobi*BrushPanel*Menu*background: NavyBlue",
X  "*XGobi*BrushPanel*Menu*borderColor: White",
X  "*XGobi*BrushPanel*Menu*foreground: White",
X  "*XGobi*Help*background: Gray85",
X  "*XGobi*Help*foreground: NavyBlue",
X  "*XGobi*Help*Done.background: Moccasin",
X
X  "*XGobi*IdentifyPanel.Panel.background: DarkKhaki",
X
X  "*XGobi*ScalePanel.background: DarkKhaki",
X  "*XGobi*ShiftPanel.background: DarkKhaki",
X  "*XGobi*StdizePanel.background: DarkKhaki",
X
X  "*XGobi*Subset*Param.background: DarkKhaki",
X
X  "*XGobi*SpinPanel.Panel.background: DarkKhaki",
X  "*XGobi*SpinPanel.background: PeachPuff",
X  "*XGobi*TourPanel*Menu*background: DarkKhaki",
X  "*XGobi*TourPanel*Menu*foreground: NavyBlue",
X  "*XGobi*TourPanel*Panel.background: DarkKhaki",
X  "*XGobi*TourPanel*TourLabel.background: PeachPuff",
X  "*XGobi*TourPanel.background: PeachPuff",
X  "*XGobi*XYPlotPanel.background: PeachPuff",
X
X  /*"*XGobi*VarPanel.foreground: DarkKhaki",*/
X  "*XGobi*VarPanel*VarLabel.background: PeachPuff",
X  "*XGobi*VarPanel*VarLabel.foreground: NavyBlue",
X
X  "*XGobi*MouseLabel.background: Salmon",
X  "*XGobi*MouseLabel.foreground: NavyBlue",
X  "*XGobi*VarMouseLabel.background: Salmon",
X  "*XGobi*VarMouseLabel.foreground: NavyBlue",
X
X  "*XGobi*ParCoords.Panel.background: DarkKhaki",
X
X  /* For Juergen */
X  "*isCloned:  False",
X  "*clonePID:  0",
X  "*cloneTime: 0",
X  "*cloneType: 0",
X  "*cloneName: XGobi",
X  "*deleteCloneData: True",
X
X  NULL
};
X
void
XXGobiMainLoop(xgobidata *xg)
{
X  XEvent event;
X  XEvent ahead;
X  Drawable root_window = DefaultRootWindow(display);
X  Boolean RunWorkProcs(void *);
X
/*
X * Set up to receive Property Change events.
*/
X  XSelectInput(display, DefaultRootWindow(display), PropertyChangeMask);
X
/* ? dfs */
X  xgobi.current_window = 0;
X
X  while (1)
X  {
X    XtAppNextEvent(app_con, &event);
X    /*printf("event.type = %d\n", event.type);*/
X
X    if (event.type == MotionNotify &&
X        event.xmotion.window == xg->plot_window)
X    {
X      /* Compress motion events */
X      while (XEventsQueued(display, QueuedAfterFlush) > 0)
X      {
X        XPeekEvent(display, &ahead);
X        if (ahead.type == MotionNotify &&
X            ahead.xmotion.window == xg->plot_window)
X        {
X          XtAppNextEvent(app_con, &event);
X        }
X        else if ( (ahead.type == PropertyNotify ||
X                   ahead.type == NoExpose) &&
X                   ahead.xany.window == xg->plot_window )
X        {
X          XtAppNextEvent(app_con, &ahead);
X        }
X        else
X          break;
X      }
X      XtDispatchEvent(&event);
X    }
X
X    else if (event.type == PropertyNotify &&
X             event.xproperty.window == root_window)
X    {
X      if (event.xproperty.atom == XG_NEWTOUR_ANNC)
X      {
X        if (xg->is_touring &&
X            xg->tour_link_state == receive &&
X            !xg->is_tour_paused &&
X            !xg->is_scaling && !xg->is_brushing &&
X            !xg->is_line_editing && !xg->is_identify)
X        {
X          read_tour_coefs(xg);
X        }
X      }
X      else
X      {
X        /*fprintf(stderr, "property notify event\n");*/
X
X        if (!xg->current_window &&
X           ( (event.xproperty.atom == XG_ROWSINPLOT_ANNC &&
X              xg->link_points_to_points) || /* points-to-lines handled here? */
X             (event.xproperty.atom == XG_NEWPAINT_ANNC &&
X              xg->link_points_to_points || xg->link_points_to_lines) ||
X             (event.xproperty.atom == XG_NEWLINEPAINT_ANNC &&
X              xg->link_lines_to_lines || xg->link_points_to_lines) ||
X             (event.xproperty.atom == XG_IDS_ANNC &&
X              xg->link_identify) ||
X             (event.xproperty.atom == XG_ERASE_ANNC && xg->link_points_to_points)
X          )
X          )
X        {
X           /* Compress PropertyNotify events */
/*
X * Danger:  if line brushing and point brushing at the same
X * time, will some important events be thrown away?
*/
X          while (XEventsQueued(display, QueuedAfterFlush) > 0)
X          {
X            XPeekEvent(display, &ahead);
X            if (ahead.type == PropertyNotify && 
X                ahead.xproperty.window == event.xproperty.window &&
X                ahead.xproperty.atom == event.xproperty.atom)
X            {
X              XtAppNextEvent(app_con, &event);
X            }
X            else
X              break;
X          }
X        
X          if (event.xproperty.atom == XG_ROWSINPLOT_ANNC)
X            read_rows_in_plot(xg);
X          else if (event.xproperty.atom == XG_NEWPAINT_ANNC)
X            read_paint(xg);
X          else if (event.xproperty.atom == XG_NEWLINEPAINT_ANNC)
X            read_line_paint(xg);
X          else if (event.xproperty.atom == XG_IDS_ANNC)
X            read_ids(xg) ;
X        }
X      }
X    }
X    /*
X     * This section is to turn off identification when xgobi is
X     * iconified.
X    */
X      /* Shut off the work proc if the main window is iconified */
X    else if (event.type == UnmapNotify &&
X             event.xany.window == XtWindow(xgobi.shell))
X    {
X      xgobi.is_iconified = True;
X    }
X    /*
X     * Restart the work proc if deiconified.  If there shouldn't
X     * be a work proc running, it will turn itself off after one
X     * run-through
X    */
X    else if (event.type == MapNotify)
X    {
X      xgobi.is_iconified = False;
X      XtAppAddWorkProc(app_con, RunWorkProcs, (XtPointer) NULL);
X    }
X    else if (event.xany.window == XtWindow(xgobi.shell) &&
X             event.type == DestroyNotify)
X    {
X      XtDestroyApplicationContext(app_con);
X      exit(0);
X    }
X
X    else
X      XtDispatchEvent(&event);
X  }
}
X
X
SHAR_EOF
  chmod 0644 'xgobi/src/xgobitop.h' ||
  $echo 'restore of' 'xgobi/src/xgobitop.h' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/xgobitop.h:' 'MD5 check failed'
fd69073cd129f142c613a34be0441506  xgobi/src/xgobitop.h
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/xgobitop.h'`"
    test 17405 -eq "$shar_count" ||
    $echo 'xgobi/src/xgobitop.h:' 'original size' '17405,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/gt_ctls.c ==============
if test -f 'xgobi/src/gt_ctls.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/gt_ctls.c' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/gt_ctls.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/gt_ctls.c' &&
/* gt_ctls.c */
/************************************************************
X *                                                          *
X *  Permission is hereby granted  to  any  individual   or  *
X *  institution   for  use,  copying, or redistribution of  *
X *  the xgobi code and associated documentation,  provided  *
X *  that   such  code  and documentation are not sold  for  *
X *  profit and the  following copyright notice is retained  *
X *  in the code and documentation:                          *
X *     Copyright (c) held jointly by Dianne Cook and        *
X *     AT&T Bell Labs (1995).                               *
X *  All Rights Reserved.                                    *
X *                                                          *
X *  We welcome your questions and comments, and request     *
X *  that you share any modifications with us.               *
X *                                                          *
X *      Dianne Cook                Andreas Buja             *
X *    dicook@iastate.edu       andreas@research.att.com     *
X *                                                          *
X ************************************************************/
X
#include <stdio.h>
#include <math.h>
#include "xincludes.h"
#include "xgobitypes.h"
#include "xgobivars.h"
#include "xgobiexterns.h"
X
static float **Rmat1, **Rmat2;
static float *ftmp_vec;
static float **manip_var_basis;
static float **mvar_3dbasis;
static float **old_mvar_3dbasis;
static int actual_numvars_t;
X
#define OWN_TOUR_SELECTION XtOwnSelection( (Widget) xg->workspace, \
X  (Atom) XG_NEWTOUR, (Time) CurrentTime, \
X  (XtConvertSelectionProc) pack_tour_data, \
X  (XtLoseSelectionProc) pack_tour_lose , \
X  (XtSelectionDoneProc) pack_tour_done )
XXtConvertSelectionProc pack_tour_data() ;
XXtSelectionDoneProc pack_tour_done() ;
XXtLoseSelectionProc pack_tour_lose() ;
X
void alloc_gt_ctls(xgobidata *xg)
{
X  int k;
X  Cardinal nc = xg->ncols;
X
X  manip_var_basis = (float **) XtMalloc((Cardinal) 3 * sizeof(float *));
X  for (k=0; k<3; k++)
X    manip_var_basis[k] = (float *) XtMalloc(nc * sizeof(float));
X  mvar_3dbasis = (float **) XtMalloc((Cardinal) 3 * sizeof(float *));
X  for (k=0; k<3; k++)
X    mvar_3dbasis[k] = (float *) XtMalloc((Cardinal) 3 * sizeof(float));
X  old_mvar_3dbasis = (float **) XtMalloc((Cardinal) 3 * sizeof(float *));
X  for (k=0; k<3; k++)
X    old_mvar_3dbasis[k] = (float *) XtMalloc((Cardinal) 3 * sizeof(float));
X  ftmp_vec = (float *) XtMalloc(nc * sizeof(float *));
X
X  Rmat1 = (float **)XtMalloc(3 * sizeof(float *));
X  for (k=0; k<3; k++)
X    Rmat1[k] = (float *) XtMalloc(3 * sizeof(float));
X  Rmat2 = (float **)XtMalloc(3 * sizeof(float *));
X  for (k=0; k<3; k++)
X    Rmat2[k] = (float *) XtMalloc(3 * sizeof(float));
}
X
void free_gt_ctls(void)
{
X  int k;
X
X  for (k=0; k<3; k++)
X    XtFree((XtPointer) manip_var_basis[k]);
X  XtFree((XtPointer) manip_var_basis);
X  for (k=0; k<3; k++)
X    XtFree((XtPointer) mvar_3dbasis[k]);
X  XtFree((XtPointer) mvar_3dbasis);
X  for (k=0; k<3; k++)
X    XtFree((XtPointer) old_mvar_3dbasis[k]);
X  XtFree((XtPointer) old_mvar_3dbasis);
X  XtFree((XtPointer) ftmp_vec);
X  for (k=0; k<3; k++)
X    XtFree((XtPointer) Rmat1[k]);
X  XtFree((XtPointer) Rmat1);
X  for (k=0; k<3; k++)
X    XtFree((XtPointer) Rmat2[k]);
X  XtFree((XtPointer) Rmat2);
}
X
/* ARGSUSED */
XXtCallbackProc
set_tour_manip_type_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  int k;
X  extern Widget manip_type_menu_cmd;
X  extern Widget manip_type_menu_btn[];
X  extern char *manip_type_menu_name[];
X  int manip_type_menu_id;
X
X  for (k=0; k<5; k++)
X  {
X    if (w == manip_type_menu_btn[k])
X    {
X      manip_type_menu_id = k;
X      break;
X    }
X  }
X  
X  XtVaSetValues(manip_type_menu_cmd,
X    XtNlabel, manip_type_menu_name[manip_type_menu_id],
X    NULL);
X
X  if (manip_type_menu_id == 0)
X    xg->tour_manip_type = oblique;
X  else if (manip_type_menu_id == 1)
X    xg->tour_manip_type = vertical;
X  else if (manip_type_menu_id == 2)
X    xg->tour_manip_type = horizontal;
X  else if (manip_type_menu_id == 3)
X    xg->tour_manip_type = radial;
X  else if (manip_type_menu_id == 4)
X    xg->tour_manip_type = angular;
X
}
X
/* ARGSUSED */
XXtCallbackProc
set_tour_cont_fact_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  int k;
X  extern Widget cont_fact_menu_cmd;
X  extern Widget cont_fact_menu_btn[];
X  extern char *cont_fact_menu_name[];
X  int cont_fact_menu_id;
X
X  for (k=0; k<9; k++)
X  {
X    if (w == cont_fact_menu_btn[k])
X    {
X      cont_fact_menu_id = k;
X      break;
X    }
X  }
X  
X  XtVaSetValues(cont_fact_menu_cmd,
X    XtNlabel, cont_fact_menu_name[cont_fact_menu_id],
X    NULL);
X
X  if (cont_fact_menu_id == 0)
X  {
X    xg->tour_cont_fact = tenth;
X    xg->fcont_fact = 0.1;
X    set_sens_localscan(true);
X    if (xg->nhist_list >= 3)
X      reset_backtrack_cmd(false, false, true, false);
X  }
X  else if (cont_fact_menu_id == 1)
X  {
X    xg->tour_cont_fact = fifth;
X    xg->fcont_fact = 0.2;
X    set_sens_localscan(true);
X    if (xg->nhist_list >= 3)
X      reset_backtrack_cmd(false, false, true, false);
X  }
X  else if (cont_fact_menu_id == 2)
X  {
X    xg->tour_cont_fact = quarter;
X    xg->fcont_fact = 0.25;
X    set_sens_localscan(true);
X    if (xg->nhist_list >= 3)
X      reset_backtrack_cmd(false, false, true, false);
X  }
X  else if (cont_fact_menu_id == 3)
X  {
X    xg->tour_cont_fact = third;
X    xg->fcont_fact = 0.3333;
X    set_sens_localscan(true);
X    if (xg->nhist_list >= 3)
X      reset_backtrack_cmd(false, false, true, false);
X  }
X  else if (cont_fact_menu_id == 4)
X  {
X    xg->tour_cont_fact = half;
X    xg->fcont_fact = 0.5;
X    set_sens_localscan(true);
X    if (xg->nhist_list >= 3)
X      reset_backtrack_cmd(false, false, true, false);
X  }
X  else if (cont_fact_menu_id == 5)
X  {
X    xg->tour_cont_fact = one;
X    xg->fcont_fact = 1;
X    set_sens_localscan(true);
X    if (xg->nhist_list >= 3)
X      reset_backtrack_cmd(false, false, true, false);
X  }
X  else if (cont_fact_menu_id == 6)
X  {
X    xg->tour_cont_fact = two;
X    xg->fcont_fact = 2;
X    set_sens_localscan(true);
X    if (xg->nhist_list >= 3)
X      reset_backtrack_cmd(false, false, true, false);
X  }
X  else if (cont_fact_menu_id == 7)
X  {
X    xg->tour_cont_fact = ten;
X    xg->fcont_fact = 10;
X    set_sens_localscan(true);
X    if (xg->nhist_list >= 3)
X      reset_backtrack_cmd(false, false, true, false);
X  }
X  else if (cont_fact_menu_id == 8)
X  {
X    xg->tour_cont_fact = infinite;
X    set_sens_localscan(false);
X    reset_backtrack_cmd(false, false, false, false);
X  }
X
X  if (xg->tour_cont_fact != infinite)
X  {
X    init_basis(xg);
X    if (xg->is_store_history)
X      store_basis(xg, xg->u0); 
X    /* reset angles to start tour */
X    zero_tau(xg);
X  }
}
X
void
draw_manip_var(xgobidata *xg)
{
X  XDrawArc(display, XtWindow(xg->vardraww[xg->manip_var]),
X    varpanel_copy_GC,
X    (int) 5, (int) 5,
X    (unsigned int) (2*xg->radius - 10), (unsigned int) (2*xg->radius - 10),
X    0, 360*64);
}
X
void
draw_frozen_var(xgobidata *xg)
{
X  int k;
X  XGCValues *gcv, gcv_inst;
X
X  XGetGCValues(display, varpanel_xor_GC, GCCapStyle|GCJoinStyle, &gcv_inst);
X  gcv = &gcv_inst;
X
X  XSetLineAttributes(display, varpanel_copy_GC, 0, LineOnOffDash,
X    gcv->cap_style, gcv->join_style);
X  for (k=0; k<xg->nfrozen_vars; k++)
X  {
X    XDrawArc(display, XtWindow(xg->vardraww[xg->frozen_vars[k]]),
X      varpanel_copy_GC,
X      (int) 10, (int) 10,
X      (unsigned int) (2*xg->radius - 20), (unsigned int) (2*xg->radius - 20),
X      0, 360*64);
X  }
X  XSetLineAttributes(display, varpanel_copy_GC, 0, LineSolid,
X    gcv->cap_style, gcv->join_style);
}
X
void
set_manip_var(xgobidata *xg, int varno)
{
X  xg->manip_var = varno;
X  draw_manip_var(xg);
X  refresh_vboxes(xg);
}
X
Boolean 
var_frozen(xgobidata *xg, int varno)
{
X  int k;
X  Boolean chosen;
X
X  chosen = False;
X  for (k=0; k<xg->nfrozen_vars; k++)
X  {
X    if (xg->frozen_vars[k] == varno)
X      chosen = True;
X  }
X
X  return(chosen);
}
X
void
set_frozen_var(xgobidata *xg, int varno)
{
X  int j, k, chosen_id;
X  Boolean chosen, actv;
X
X  chosen = False;
X  for (k=0; k<xg->nfrozen_vars; k++)
X  {
X    if (xg->frozen_vars[k] == varno)
X    {
X      chosen = True;
X      chosen_id = k;
X    }
X  }
X
X  if (chosen)
X  {
X    for (k=chosen_id+1; k<xg->nfrozen_vars; k++)
X      xg->frozen_vars[k-1] = xg->frozen_vars[k];
X    xg->nfrozen_vars--;
X    xg->uwarm[0][varno] = xg->ufrozen[0][varno];
X    xg->uwarm[1][varno] = xg->ufrozen[1][varno];
X    xg->ufrozen[0][varno] = 0.;
X    xg->ufrozen[1][varno] = 0.;
X    zero_tau(xg);
X    zero_princ_angles(xg);
X    set_sens_pp_btn(xg, 1);
X    set_sens_princ_comp(xg, 1);
X    reset_backtrack_cmd(false, false, true, false);
X    if (xg->tour_cont_fact == infinite)
X      xg->new_direction_flag = True;
X    /* add to the active list */
X    if (add_variable(xg, varno))
X      ;
X  }
X  else
X  {
X    actv = False;
X    for (j=0; j<xg->numvars_t; j++)
X    {
X      if (xg->tour_vars[j] == varno)
X        actv = True;
X    }
X    if (actv) /* only freeze if it is already active */
X    {
X      xg->frozen_vars[xg->nfrozen_vars] = varno;
X      xg->ufrozen[0][varno] = xg->u[0][varno];
X      xg->ufrozen[1][varno] = xg->u[1][varno];
X      if (xg->nfrozen_vars == 0)
X      {
X        copy_basis(xg->u, xg->u0, xg->ncols_used);
X        xg->u0[0][varno] = 0.;
X        xg->u0[1][varno] = 0.;
X        copy_basis(xg->u0, xg->uwarm, xg->ncols_used);
X      }
X      else
X      {
X        xg->uwarm[0][varno] = 0.;
X        xg->uwarm[1][varno] = 0.;
X      }
X      xg->nfrozen_vars++;
X      zero_tau(xg);
X      zero_princ_angles(xg);
X      remove_variable(xg, varno);
X      set_sens_pp_btn(xg, 0);
X      set_sens_princ_comp(xg, 0);
X      reset_backtrack_cmd(false, false, false, false);
X      if (xg->tour_cont_fact == infinite)
X        xg->new_direction_flag = True;
X    }
X  }
X  draw_frozen_var(xg);
X  refresh_vboxes(xg);
}
X
void
make_coord_basis(xgobidata *xg)
{
X  int j, k;
X  float tol = 0.001, ftmp;
X  
X  for (j=0; j<xg->ncols_used; j++)
X  {
X    manip_var_basis[0][j] = xg->u0[0][j];
X    manip_var_basis[1][j] = xg->u0[1][j];
X    manip_var_basis[2][j] = 0.;
X  }
X  manip_var_basis[2][xg->manip_var] = 1.;
X  gram_schmidt(manip_var_basis[0],  manip_var_basis[2],
X    xg->ncols_used);
X  gram_schmidt(manip_var_basis[1],  manip_var_basis[2],
X    xg->ncols_used);
X  ftmp = calc_norm(manip_var_basis[2], xg->ncols_used);
X  while (ftmp < tol)
X  {
X    gen_norm_variates(1, xg->numvars_t, ftmp_vec);
X    for (j=0; j<xg->ncols_used; j++)
X      manip_var_basis[2][j] = 0.;
X    for (j=0; j<xg->numvars_t; j++)
X      manip_var_basis[2][xg->tour_vars[j]] = ftmp_vec[j];
X    norm(manip_var_basis[2], xg->ncols_used);
X    gram_schmidt(manip_var_basis[0],  manip_var_basis[2],
X      xg->ncols_used);
X    gram_schmidt(manip_var_basis[1],  manip_var_basis[2],
X      xg->ncols_used);
X    ftmp = calc_norm(manip_var_basis[2], xg->ncols_used);
X  }
X  for (j=0; j<3; j++)
X  {
X    for (k=0; k<3; k++)
X      mvar_3dbasis[j][k] = old_mvar_3dbasis[j][k] = 0.;
X    mvar_3dbasis[j][j] = old_mvar_3dbasis[j][j] = 1.;
X  }
X  for (j=0; j<xg->ncols_used; j++)
X  {
X    xg->uold[0][j] = xg->u[0][j] = manip_var_basis[0][j];
X    xg->uold[1][j] = xg->u[1][j] = manip_var_basis[1][j];
X  }
}
X
/* 
X   Preproject the data into the 3d manipulation space: 
X   uses 3 of the 4 vectors of the usual grand tour preprojection.
*/
void
gti_span_planes(xgobidata *xg)
{
X  int i, j, m;
X
X  for (m=0; m<xg->nrows_in_plot; m++)
X  {
X    i = xg->rows_in_plot[m];
X    for (j=0; j<xg->ncols_used; j++)
X      xg->tnx[j] = FLOAT(xg->world_data[i][j]);
X      xg->xi0[i][0] = (long)(inner_prod(xg->tnx,
X        manip_var_basis[0], xg->ncols_used));
X      xg->xi0[i][1] = (long)(inner_prod(xg->tnx,
X        manip_var_basis[1], xg->ncols_used));
X      xg->xi1[i][0] = (long)(inner_prod(xg->tnx,
X        manip_var_basis[2], xg->ncols_used));
X  }
}
X
void
gti_reproject(xgobidata *xg)
{
X  int i, j, m;
X
X  for (m=0; m<xg->nrows_in_plot; m++)
X  {
X    i = xg->rows_in_plot[m];
X
X    xg->planar[i].x = (long) (mvar_3dbasis[0][0]*(float)xg->xi0[i][0] +
X      mvar_3dbasis[0][1]*(float)xg->xi0[i][1] +
X      mvar_3dbasis[0][2]*(float)xg->xi1[i][0]) ;
X    xg->planar[i].y = (long) (mvar_3dbasis[1][0]*(float)xg->xi0[i][0] +
X      mvar_3dbasis[1][1]*(float)xg->xi0[i][1] +
X      mvar_3dbasis[1][2]*(float)xg->xi1[i][0]) ;
X  }  
X
X  for (j=0; j<xg->ncols_used; j++)
X  {
X    xg->u[0][j] = manip_var_basis[0][j]*mvar_3dbasis[0][0] +
X      manip_var_basis[1][j]*mvar_3dbasis[0][1] +
X      manip_var_basis[2][j]*mvar_3dbasis[0][2];
X    xg->u[1][j] = manip_var_basis[0][j]*mvar_3dbasis[1][0] +
X      manip_var_basis[1][j]*mvar_3dbasis[1][1] +
X      manip_var_basis[2][j]*mvar_3dbasis[1][2];
X  }/* handle sphereing somehow */
X
X  if (xg->is_tour_section)
X    tour_section_calcs(xg, 1);
}
X
/* ARGSUSED */
XXtEventHandler
interact_gt(Widget w, xgobidata *xg, XEvent *evnt)
{
X  int i;
X  static icoords pos, prev_pos;
X  float distx, disty, len_motion;
X  static float rx, ry;
X  float phi, cosphi, sinphi, cosm;
X  static float cospsi, sinpsi; /* angular constrained vars */
X  float x1, y1, x2, y2; 
X  float denom = (float) MIN(xg->mid.x, xg->mid.y);
X  float ca, sa;
X  float tol = 0.01;
X  double dtmp1, dtmp2;
X  static Boolean no_dir_flag = False;
X  Boolean overlap = False;
X
X  if (evnt->type == ButtonPress)
X  {
X    XButtonEvent *xbutton = (XButtonEvent *) evnt;
X    if (evnt->xbutton.button == 1 || evnt->xbutton.button == 2)
X    {
X      stop_tour_proc(xg);
X      while (xg->nfrozen_vars > 0)
X        set_frozen_var(xg, xg->frozen_vars[0]);
X
X      pos.x = prev_pos.x = xbutton->x;
X      pos.y = prev_pos.y = xbutton->y;
X
X      actual_numvars_t = xg->numvars_t;
X      overlap = False;
X      for (i=0; i<xg->numvars_t; i++)
X        if (xg->manip_var == xg->tour_vars[i])
X          overlap = True;
X      if (!overlap)
X        actual_numvars_t++;
X
X      if (actual_numvars_t > 2)
X      {
X        init_basis(xg);
X        if (xg->is_store_history)
X          store_basis(xg, xg->u0); 
X        /* reset angles to start tour */
X        zero_tau(xg);
X
X        alloc_gt_ctls(xg);
X        make_coord_basis(xg);
/* Set rotation axis in the radial manipulation type */
X        if (xg->tour_manip_type == radial)
X        {
X          if ((xg->u0[0][xg->manip_var]*xg->u0[0][xg->manip_var] +
X            xg->u0[1][xg->manip_var]*xg->u0[1][xg->manip_var]) < tol)
X            no_dir_flag = True;
X          else
X          {
X            rx = xg->u0[0][xg->manip_var];
X            ry = xg->u0[1][xg->manip_var];
X            dtmp1 = sqrt(rx*rx+ry*ry);
X            rx /= dtmp1;
X            ry /= dtmp1;
X          }
X        }
X  
X        gti_span_planes(xg);
X        gti_reproject(xg);
X        plane_to_screen(xg);
X        plot_once(xg);
X        tour_var_lines(xg);
X      }
X    }
X  }
X  else if (evnt->type == MotionNotify)
X  {
X    XMotionEvent *xmotion = (XMotionEvent *) evnt;
X    prev_pos.x = pos.x;
X    prev_pos.y = pos.y;
X    pos.x = xmotion->x;
X    pos.y = xmotion->y;
X
X    if (actual_numvars_t > 2)
X    {
X      if (xg->tour_manip_type != angular)
X      {
X        if (xg->tour_manip_type == oblique)
X        {
X          distx = pos.x - prev_pos.x;
X          disty = prev_pos.y - pos.y;
X        }
X        else if (xg->tour_manip_type == vertical)
X        {
X          distx = 0.;
X          disty = prev_pos.y - pos.y;
X        }
X        else if (xg->tour_manip_type == horizontal)
X        {
X          distx = pos.x - prev_pos.x;
X          disty = 0.;
X        }
X        else if (xg->tour_manip_type == radial)
X        {
X          if (no_dir_flag)
X          {
X            distx = pos.x - prev_pos.x;
X            disty = prev_pos.y - pos.y;
X            rx = distx;
X            ry = disty; 
X            dtmp1 = sqrt(rx*rx+ry*ry);
X            rx /= dtmp1;
X            ry /= dtmp1;
X            no_dir_flag = False;
X          }
X          distx = (rx*(pos.x - prev_pos.x) + ry*(prev_pos.y - pos.y))*rx;
X          disty = (rx*(pos.x - prev_pos.x) + ry*(prev_pos.y - pos.y))*ry;
X        }
X        dtmp1 = (double) (distx*distx+disty*disty);
X        len_motion = (float) sqrt(dtmp1);
X    
X        if (len_motion != 0)
X        {
X          phi = len_motion / denom;
X    
X          ca = distx/len_motion;
X          sa = disty/len_motion;
X    
X          cosphi = (float) cos((double) phi);
X          sinphi = (float) sin((double) phi);
X          cosm = 1.0 - cosphi;
X          Rmat2[0][0] = ca*ca*cosphi + sa*sa;
X          Rmat2[0][1] = -cosm*ca*sa;
X          Rmat2[0][2] = sinphi*ca;
X          Rmat2[1][0] = -cosm*ca*sa;
X          Rmat2[1][1] = sa*sa*cosphi + ca*ca;
X          Rmat2[1][2] = sinphi*sa;
X          Rmat2[2][0] = -sinphi*ca;
X          Rmat2[2][1] = -sinphi*sa;
X          Rmat2[2][2] = cosphi;
X          matrix_mult(mvar_3dbasis, Rmat2, Rmat1, 3, 3, 3);
X          copy_matrix(Rmat1, mvar_3dbasis, 3, 3);
X      
X          gram_schmidt(mvar_3dbasis[0], mvar_3dbasis[1], 3);
X          gram_schmidt(mvar_3dbasis[0], mvar_3dbasis[2], 3);
X          gram_schmidt(mvar_3dbasis[1], mvar_3dbasis[2], 3);
X    
X          gti_reproject(xg);
X          plane_to_screen(xg);
X          plot_once(xg);
X          tour_var_lines(xg);
X          if (xg->tour_link_state == send_state)
X          {
X            xg->new_basis_ind = False;
X            OWN_TOUR_SELECTION ;
X            announce_tour_coefs(xg);
X          }
X          if (xg->is_pp)
X            pp_index(xg,0,0);
X        }
X      }
X      else /* angular constrained manipulation */
X      {
X        if (prev_pos.x != xg->mid.x && prev_pos.y != xg->mid.y &&
X          pos.x != xg->mid.x && pos.y != xg->mid.y)
X        {
X          x1 = prev_pos.x - xg->mid.x;
X          y1 = prev_pos.y - xg->mid.y;
X          dtmp1 = sqrt(x1*x1+y1*y1);
X          x1 /= dtmp1;
X          y1 /= dtmp1;
X          x2 = pos.x - xg->mid.x;
X          y2 = pos.y - xg->mid.y;
X          dtmp2 = sqrt(x2*x2+y2*y2);
X          x2 /= dtmp2;
X          y2 /= dtmp2;
X          if (dtmp1 > tol && dtmp2 > tol)
X          {
X            cospsi = x1*x2+y1*y2;
X            sinpsi = x1*y2-y1*x2;
X          }
X          else
X          {
X            cospsi = 1.;
X            sinpsi = 0.;
X          }
X        }
X        else
X        {
X          cospsi = 1.;
X          sinpsi = 0.;
X        }
X        Rmat2[0][0] = cospsi;
X        Rmat2[0][1] = sinpsi;
X        Rmat2[0][2] = 0.;
X        Rmat2[1][0] = -sinpsi;
X        Rmat2[1][1] = cospsi;
X        Rmat2[1][2] = 0.;
X        Rmat2[2][0] = 0.;
X        Rmat2[2][1] = 0.;
X        Rmat2[2][2] = 1.;
X        matrix_mult(mvar_3dbasis, Rmat2, Rmat1, 3, 3, 3);
X        copy_matrix(Rmat1, mvar_3dbasis, 3, 3);
X    
X        gram_schmidt(mvar_3dbasis[0], mvar_3dbasis[1], 3);
X        gram_schmidt(mvar_3dbasis[0], mvar_3dbasis[2], 3);
X        gram_schmidt(mvar_3dbasis[1], mvar_3dbasis[2], 3);
X  
X        gti_reproject(xg);
X        plane_to_screen(xg);
X        plot_once(xg);
X        tour_var_lines(xg);
X        if (xg->tour_link_state == send_state)
X        {
X          xg->new_basis_ind = False;
X          OWN_TOUR_SELECTION ;
X          announce_tour_coefs(xg);
X        }
X        if (xg->is_pp)
X          pp_index(xg,0,0);
X      }
X    }
X  }
X  else if (evnt->type == ButtonRelease)
X  {
X    if (actual_numvars_t > 2)
X    {
X    /* need to get current projection and store it */
X      init_basis(xg);
X      if (xg->is_store_history)
X        store_basis(xg, xg->u0);
X      copy_u0_to_pd0(xg);
X      zero_tau(xg);
X      if (xg->tour_cont_fact == infinite)
X        xg->new_direction_flag = True; 
X      free_gt_ctls();
X    }
X    actual_numvars_t = 0;
X    start_tour_proc(xg);
X  }
}
X
void
tour_event_handlers(xgobidata *xg, Boolean add)
{
X  if (add)
X  {
X    XtAddEventHandler(xg->workspace,
X      ButtonPressMask | ButtonReleaseMask |
X      Button1MotionMask | Button2MotionMask,
X      FALSE, (XtEventHandler) interact_gt, (XtPointer) xg);
X    XDefineCursor(display, XtWindow(xg->workspace), spin_cursor);
X  }
X  else
X  {
X    XtRemoveEventHandler(xg->workspace, XtAllEvents,
X      TRUE, (XtEventHandler) interact_gt, (XtPointer) xg);
X    XDefineCursor(display, XtWindow(xg->workspace), default_cursor);
X  }
}
SHAR_EOF
  chmod 0644 'xgobi/src/gt_ctls.c' ||
  $echo 'restore of' 'xgobi/src/gt_ctls.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/gt_ctls.c:' 'MD5 check failed'
a12f27eb602284e9816d440cdadcc97b  xgobi/src/gt_ctls.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/gt_ctls.c'`"
    test 19859 -eq "$shar_count" ||
    $echo 'xgobi/src/gt_ctls.c:' 'original size' '19859,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/texture.c ==============
if test -f 'xgobi/src/texture.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/texture.c' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/texture.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/texture.c' &&
/************************************************************
X *                                                          *
X *  Permission is hereby granted  to  any  individual   or  *
X *  institution   for  use,  copying, or redistribution of  *
X *  the xgobi code and associated documentation,  provided  *
X *  that   such  code  and documentation are not sold  for  *
X *  profit and the  following copyright notice is retained  *
X *  in the code and documentation:                          *
X *        Copyright (c) 1990, ..., 1996 Bellcore            *
X *                                                          *
X *  We welcome your questions and comments, and request     *
X *  that you share any modifications with us.               *
X *                                                          *
X *    Deborah F. Swayne            Dianne Cook              *
X *   dfs@research.att.com       dicook@iastate.edu          *
X *      (973) 360-8423    www.public.iastate.edu/~dicook/   *
X *                                                          *
X *                    Andreas Buja                          *
X *                andreas@research.att.com                  *
X *              www.research.att.com/~andreas/              *
X *                                                          *
X ************************************************************/
X
#include <stdlib.h>
#include <stdio.h>
#include <limits.h>
#include <float.h>
#include <math.h>
#include "xincludes.h"
#include "xgobitypes.h"
#include "xgobivars.h"
#include "xgobiexterns.h"
X
/*
X * The code in this file is taken from code written by Paul Tukey and
X * John Tukey, as described in their paper entitled
X * "Strips Displaying Empirical Distributions:  I.  Textured Dot
X * Strips."   I've converted it to C from ratfor and modfied it so
X * that it returns the texture axis in the order of the original
X * data.
*/
X
int myrnd(int);
float *gy;
X
int
psort(const void *arg1, const void *arg2)
{
X  int val = 0;
X  int *x1 = (int *) arg1;
X  int *x2 = (int *) arg2;
X
X  if (gy[*x1] < gy[*x2])
X    val = -1;
X  else if (gy[*x1] > gy[*x2])
X    val = 1;
X
X  return(val);
}
X
void
next5(int *xlast, int *perm)
{
/*
X * Extend a 5-string by 5 more numbers:
X * Given a last perm of length 5, choose a next perm, subject to restrictions
X *
X * perms is the list of all 32 possible permutations of (0,1,2,3,4)
X *   with no runs up or down of length 3
X * Note: for every perm in the list, (4 - perm) is also in the list,
X *   symmetrically placed.
*/
X  int i, j, last[5];
X  int nperms = 32;
X  static int cumcnt[5] = {4,11,19,26,31};
X  static int perms[32][5] = {
X    0,2,1,4,3,  0,3,1,4,2,  0,3,2,4,1,  0,4,1,3,2,
X    0,4,2,3,1,  1,0,3,2,4,  1,0,4,2,3,  1,2,0,4,3,
X    1,3,0,4,2,  1,3,2,4,0,  1,4,0,3,2,  1,4,2,3,0,
X    2,0,3,1,4,  2,0,4,1,3,  2,1,3,0,4,  2,1,4,0,3,
X    2,3,0,4,1,  2,3,1,4,0,  2,4,0,3,1,  2,4,1,3,0,
X    3,0,2,1,4,  3,0,4,1,2,  3,1,2,0,4,  3,1,4,0,2,
X    3,2,4,0,1,  3,4,0,2,1,  3,4,1,2,0,  4,0,2,1,3,
X    4,0,3,1,2,  4,1,2,0,3,  4,1,3,0,2,  4,2,3,0,1
X  };
X
X  for (i=0; i<5; i++)
X    last[i] = xlast[i];
X
X  if(last[0]==0 && last[1]==0)
X  {
X  /*
X   * Initialize a new perm by choosing a perm at random
X  */
X    j = myrnd(nperms) - 1;
X    for (i=0; i<5; i++)
X      last[i] = perms[j][i] ;
X  }
/*
X *  Randomly choose a permutation perm(1-5) from among those
X *  that do not start with the previous digit and that make a
X *  transition which reverses the previous direction.
*/
X
X  if(last[3] < last[4])
X  {
X    j = myrnd(cumcnt[last[4]]) - 1;
X    for (i=0; i<5; i++)
X      perm[i] = perms[j][i];
X  }
X  else
X  {
X    j = myrnd(cumcnt[3-last[4]]) - 1;
X    for (i=0; i<5; i++)
X      perm[i] = 4 - perms[j][i];
X  }
X  return;
}
X
X
void
next25(int *tt, int *bigt, int *smallt)
{
/*
X *  Calculate the next 25 values of a 2nd-stage shift vector
X *   by interleaving five 5-strings
*/
X  int i, j, k;
X
X  if(bigt[0]==0 && bigt[1]==0)
X  {
X  /*
X   * Force initialization
X  */
X    bigt[20] = 0;
X    bigt[21] = 0;
X    for (i=0; i<25; i++)
X      smallt[i] = 0;
X  }
X
X  /*
X   * Get next 25 elements of bigt, 5 at a time
X  */
X  next5(&bigt[20], bigt);
X  for (j=5; j<21; j=j+5)
X    next5(&bigt[j-5], &bigt[j]);
X
X  /*
X   * Extend each of the smallt series by 5
X  */
X  for (j=0; j<21; j=j+5)
X    next5(&smallt[j], &smallt[j]);
X
X  /*
X   * Interleave the smallt series according to bigt
X  */
X  for (i=0; i<5; i++)
X    for (j=0; j<5; j++)
X    {
X      k   = 5*i + j;
X      tt[k] = smallt[i + 5*bigt[k]];
X    }
X
X  return;
}
X
void
textur(float *yy, float *shft, int ny, int option, float del, int stages)
{
/*
X * Calculate a texturing shft vector based on data yy
X * Note: data vector yy is returned sorted
X *
X * Return shft resorted into the original order of yy.
X * Use the default values for these arguments, as follow:
X * option=1, del=1.0, stages=3
X *
X * A bit of work is needed if we want to use option=2.
*/
X  float lohnge, hihnge, delta;
X  float srnge, slo, shi;
X  int nny, window, mid, g, h, gg, hh;
X  int tmp5x5[25];
X  int tlarge[25], tsmall[25];
X  int i, ii;
X  int *indx;
X  float *xx;
X  extern int fcompare(const void *, const void *);
X
/*
X * Force initialization on first calls to next5.
*/
X  for (i=0; i<2; i++)
X    tlarge[i] = tsmall[i] = 0;
X
X  indx = (int *) XtMalloc((Cardinal) ny * sizeof(int));
/*
X * gy is needed solely for the psort routine:  psort is used by
X * qsort to put an index vector in the order that yy will assume.
*/
X  gy = (float *) XtMalloc((Cardinal) ny * sizeof(float));
X  xx = (float *) XtMalloc((Cardinal) ny * sizeof(float));
X
X  for (i=0; i<ny; i++)
X  {
X    indx[i] = i;
X    gy[i] = yy[i];
X  }
X
X  qsort((void *) indx, (size_t) ny, sizeof(int), psort);
X  qsort((void *) yy, (size_t) ny, sizeof(float), fcompare);
X
/*
X * Bug here:  this is screwy if ny < 4.
*/
X  lohnge = yy[ny/4 - 1];
X  hihnge = yy[ny - ny/4 - 1];
X  delta  = del * .03 * (hihnge-lohnge);
X
/*
X *  Do the first two stages of shift, based on 5-strings
*/
X  nny = ny;
/*
X *  if( option == 2 )
X *    nny = MIN(nny, 50);
*/
X
X  for (i=0; i<nny; i++) {
X    ii = (i % 25);
X    if(ii==0)
X      next25(tsmall, tlarge, tmp5x5);
X
X    if(stages >= 2)
X      shft[i] = (float) (20*tlarge[ii] + 4*tsmall[ii]) + 2;
X    else
X      shft[i] = (float) (20*tlarge[ii]) + 2;
X
X  /*
X   *  Note: we use the same tlarge 5-string both for gross shift
X   *  and to interleave the 2nd-stage 5-strings.
X  */
X  }
X
X  if (stages<=1)
X    return;
X
/*
X * Optionally, add a tiny bit of uniform jitter on the smallest scale
*/
X  if (option == 1) {
X    for (i=0; i<ny; i++) {
X      shft[i] = shft[i] + ((float) randvalue()) * 4 - 2;
X    }
X  }
X
/*
X * Optionally, repeat first block of 50, shifting the first 25 by a bit
X *  else if (option == 2)
X *  {
X *    for (i=0; i<25 && i<ny; i++)
X *      shft[i] = shft[i] - 2;
X *    for(i=50; i<ny; i++)
X *      shft[i] = shft[i-50];
X *  }
*/
X
/*
X * Now look at y values, and stretch bunched-up sections out to the edges
*/
X  window = 5;
X  mid  = (window+1)/2;
X  h    = mid;
X  while(h-mid+window < ny)
X  {
X     /*for(g = h; g-mid+window < ny; g = g+window)*/ /* bug */
X     for(g = h; g-mid+window < ny && g+window < ny; g = g+window)
X       if( yy[g+window] > yy[h] + 10.*delta )
X  	    break;
X    if( g-mid+window >= ny )
X      break;
X    hh = h - mid;
X    gg = g - h + window;
X    slo = 5;
X    shi = 0;
X    for(i=hh; i<hh+gg; i++)
X    {
X      if(shft[i]<slo)
X        slo = shft[i];
X      if(shft[i]>shi)
X        shi = shft[i];
X    }
X    srnge = shi - slo;
X    for (i=hh; i<gg; i++)
X      shft[i] = 100 * (shft[i] - slo) / srnge;
X    h = g + window;
X  }
X
X
/*
X * Again looking at y values, pull points back to center thread,
X * or to the 30% and 70% positions, in sparse regions
*/
X  for(i=1; i<ny-1; i++)
X  {
X    if( ( yy[i]   - yy[i-1] > delta ) &&
X      ( yy[i+1] - yy[i]   > delta ) )
X    {
X  	  shft[i] = 50;
X  	}
X  }
X
X  for(i=1; i<ny-2; i++)
X  {
X    if( ( yy[i]   - yy[i-1] > delta ) &&
X      ( yy[i+2] - yy[i+1] > delta ) &&
X      ( yy[i+1] - yy[i]   < delta ) )
X    {
X  	  shft[i]   = 30;
X  	  shft[i+1] = 70;
X  	}
X  }
X
X
X  if( yy[1]  - yy[0]  > delta )
X    shft[0]  = 50;
X  if( yy[ny-1] - yy[ny-2] > delta )
X    shft[ny-1] = 50;
X
X  if( ( yy[2] - yy[1] > delta ) &&
X    ( yy[1] - yy[0] < delta ) )
X  {
X    shft[0] = 30;
X    shft[1] = 70;
X  }
X  if( ( yy[ny-1]   - yy[ny-2] < delta ) &&
X    ( yy[ny-2] - yy[ny-3] > delta ) )
X  {
X    shft[ny-2] = 30;
X    shft[ny-1] = 70;
X  }
X
X  for (i=0; i<ny; i++)
X    xx[indx[i]] = shft[i];
X
X  for (i=0; i<ny; i++)
X    shft[i] = xx[i];
X
X  XtFree((XtPointer) indx);
X  XtFree((XtPointer) gy);
X  XtFree((XtPointer) xx);
X
X  return;
}
X
int
myrnd(int n)
{
/*
X * Select a random integer between 1 and n
*/
X  int nn, myrndval;
X  float rrand;
X  nn = MAX(n,1);
X
X  rrand = (float) randvalue();
X  myrndval = MIN(nn, (int) (rrand * (float) nn) + 1);
X  return(myrndval);
}
SHAR_EOF
  chmod 0644 'xgobi/src/texture.c' ||
  $echo 'restore of' 'xgobi/src/texture.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/texture.c:' 'MD5 check failed'
1fbbbc2ef6a4b9bef3458a33d0804e0b  xgobi/src/texture.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/texture.c'`"
    test 8744 -eq "$shar_count" ||
    $echo 'xgobi/src/texture.c:' 'original size' '8744,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/legendre.c ==============
if test -f 'xgobi/src/legendre.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/legendre.c' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/legendre.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/legendre.c' &&
/* legendre.c */
/************************************************************
X *                                                          *
X *  Permission is hereby granted  to  any  individual   or  *
X *  institution   for  use,  copying, or redistribution of  *
X *  the xgobi code and associated documentation,  provided  *
X *  that   such  code  and documentation are not sold  for  *
X *  profit and the  following copyright notice is retained  *
X *  in the code and documentation:                          *
X *        Copyright (c) 1990, ..., 1996 Bellcore            *
X *                                                          *
X *  We welcome your questions and comments, and request     *
X *  that you share any modifications with us.               *
X *                                                          *
X *    Deborah F. Swayne            Dianne Cook              *
X *   dfs@research.att.com       dicook@iastate.edu          *
X *      (973) 360-8423    www.public.iastate.edu/~dicook/   *
X *                                                          *
X *                    Andreas Buja                          *
X *                andreas@research.att.com                  *
X *              www.research.att.com/~andreas/              *
X *                                                          *
X ************************************************************/
X
#include <math.h>
#include "xincludes.h"
#include "xgobitypes.h"
#include "xgobivars.h"
#include "xgobiexterns.h"
X
#define SQRT2PI 2.5066282746310007
X
static float **P0, **P1, **Rp, **Pp0, **Pp1;
static float **acoefs;
X
/* This index is discussed in "Exploratory Projection Pursuit" by
X * Jerome H. Friedman, JASA 1987
*/
X
void
alloc_legendre(int n, int maxlJ)
{
X  int i;
X
X  P0 = (float **) XtMalloc(
X    (unsigned int) maxlJ*sizeof(float *));
X  for (i=0; i<maxlJ; i++)
X    P0[i] = (float *) XtMalloc(
X      (unsigned int) n*sizeof(float));
X  P1 = (float **) XtMalloc(
X    (unsigned int) maxlJ*sizeof(float *));
X  for (i=0; i<maxlJ; i++)
X    P1[i] = (float *) XtMalloc(
X      (unsigned int) n*sizeof(float));
X  Rp = (float **) XtMalloc(
X    (unsigned int) 2*sizeof(float *));
X  for (i=0; i<2; i++)
X    Rp[i] = (float *) XtMalloc(
X      (unsigned int) n*sizeof(float));
X  Pp0 = (float **) XtMalloc(
X    (unsigned int) maxlJ*sizeof(float *));
X  for (i=0; i<maxlJ; i++)
X    Pp0[i] = (float *) XtMalloc(
X      (unsigned int) n*sizeof(float));
X  Pp1 = (float **) XtMalloc(
X    (unsigned int) maxlJ*sizeof(float *));
X  for (i=0; i<maxlJ; i++)
X    Pp1[i] = (float *) XtMalloc(
X    (unsigned int) n*sizeof(float));
X  acoefs = (float **) XtMalloc(
X    (unsigned int) maxlJ*sizeof(float *));
X  for (i=0; i<maxlJ; i++)
X    acoefs[i] = (float *) XtMalloc(
X      (unsigned int) maxlJ*sizeof(float));
}
X
void
free_legendre(int maxlJ)
{
X  int i;
X
X  for (i=0; i<maxlJ; i++)
X    XtFree((XtPointer) P0[i]);
X  XtFree((XtPointer) P0);
X  for (i=0; i<maxlJ; i++)
X    XtFree((XtPointer) P1[i]);
X  XtFree((XtPointer) P1);
X  for (i=0; i<2; i++)
X    XtFree((XtPointer) Rp[i]);
X  XtFree((XtPointer) Rp);
X  for (i=0; i<maxlJ; i++)
X    XtFree((XtPointer) Pp0[i]);
X  XtFree((XtPointer) Pp0);
X  for (i=0; i<maxlJ; i++)
X    XtFree((XtPointer) Pp1[i]);
X  XtFree((XtPointer) Pp1);
X  for (i=0; i<maxlJ; i++)
X    XtFree((XtPointer) acoefs[i]);
X  XtFree((XtPointer) acoefs);
}
X
float
legendre_index(float **proj_data, int n, int *rows_in_plot, int lJ)
{
X  int i,j,k;
X  float tmpf1, tmpf2;
X  float indx_val;
X
/* calculate R */
X  for (i=0; i<n; i++)
X  {
X    k = rows_in_plot[i];
X    tmpf1 = proj_data[0][k];
X    tmpf1 /= (sqrt((double) 2.));
X    if (tmpf1 >= 0.)
X      tmpf2 = (1. + erf(tmpf1)) / 2.;
X    else
X      tmpf2 = erfc(fabs(tmpf1)) / 2.;
X    Rp[0][k] = tmpf2*2. - 1.;
X    tmpf1 = proj_data[1][k];
X    tmpf1 /= (sqrt((double) 2.));
X    if (tmpf1 >= 0.)
X      tmpf2 = (1. + erf(tmpf1)) / 2.;
X    else
X      tmpf2 = erfc(fabs(tmpf1)) / 2.;
X    Rp[1][k] = tmpf2*2. - 1.;
X  }
X
/* calculate P's */
X  for (i=0; i<n; i++)
X  {
X    k = rows_in_plot[i];
X    P0[0][k] = Rp[0][k];
X    P1[0][k] = Rp[1][k];
X  }
X  if (lJ > 1)
X  {
X    for (i=0; i<n; i++)
X    {
X      k = rows_in_plot[i];
X      P0[1][k] = (3. * Rp[0][k] * Rp[0][k] - 1.) / 2.;
X      P1[1][k] = (3. * Rp[1][k] * Rp[1][k] - 1.) / 2.;
X    }
X    for (i=2; i<lJ; i++)
X    {
X      for (j=0; j<n; j++)
X      {
X        k = rows_in_plot[j];
X        P0[i][k] = ((2.*(i+1)-1.)*Rp[0][k]*P0[i-1][k]
X          -(i*P0[i-2][k]))/(i+1);
X        P1[i][k] = ((2.*(i+1)-1.)*Rp[1][k]*P1[i-1][k]
X          -(i*P1[i-2][k]))/(i+1);
X      }
X    }
X  }
X
/* calculate PP index */
X  indx_val = 0.;
X  tmpf1 = 0.;
X  tmpf2 = 0.;
X  for (i=0; i<lJ; i++)
X  {
X    tmpf1 = mean_fn(P0[i], n, rows_in_plot);
X    tmpf2 = mean_fn(P1[i], n, rows_in_plot);
X    tmpf1 *= tmpf1;
X    tmpf2 *= tmpf2;
X    indx_val += (tmpf1 * (2.*(i+1)+1.) / 4.);
X    indx_val += (tmpf2 * (2.*(i+1)+1.) / 4.);
X  }
X
X  tmpf1 = 0.;
X  for (i=0; i<lJ; i++)
X  {
X    for (j=0; j<(lJ-i-1); j++)
X    {
X      acoefs[i][j] = mean_fn2(P0[i], P1[j],
X        n, rows_in_plot);
X      tmpf1 = (acoefs[i][j]*acoefs[i][j]*(2.*(i+1)+1.)*(2.*(j+1)+1.)/4.);
X      indx_val += tmpf1;
X    }
X  }
X  return(indx_val);
}
X
void
legendre_deriv(float **data, float **proj_data, float *alpha, float *beta,
float **derivs, int n, int *rows_in_plot, int p, int *active_vars,
int nactive, int lJ)
{
X  int i, j, k, l, m;
X  float tmpf1, tmpf2, tmpf3;
X
/* calculate Pp's */
X  for (i=0; i<n; i++)
X  {
X    Pp0[0][rows_in_plot[i]] = 0;
X    Pp0[1][rows_in_plot[i]] = 1;
X  }
X  if (lJ > 1)
X  {
X    for (i=0; i<n; i++)
X    {
X      Pp1[0][rows_in_plot[i]] = 0;
X      Pp1[1][rows_in_plot[i]] = 1;
X    }
X    for (i=2; i<lJ; i++)
X    {
X      for (j=0; j<n; j++)
X      {
X        m = rows_in_plot[j];
X        Pp0[i][m] = Rp[0][m]*Pp0[i-1][m] + (i+1)*P0[i-1][m];
X        Pp1[i][m] = Rp[1][m]*Pp1[i-1][m] + (i+1)*P1[i-1][m];
X      }
X    }
X  }
/* calculate derivatives */
/* alpha */
X  for (k=0; k<p; k++)
X    derivs[0][k] = 0.;
X
X  for (k=0; k<nactive; k++)
X  {
X    for (i=0; i<lJ; i++)
X    {
X      tmpf2 = 0.;
X      for (j=0; j<n; j++)
X      {
X        m = rows_in_plot[j];
X        tmpf3 = data[m][active_vars[k]];
X        tmpf2 += (Pp0[i][m]*exp(-proj_data[0][m] * proj_data[0][m]/2.)*
X             (tmpf3 -
X             alpha[active_vars[k]] * proj_data[0][m] -
X             beta[active_vars[k]] * proj_data[1][m]));
X      }
X      tmpf1 = mean_fn(P0[i], n, rows_in_plot);
X      tmpf2 /= ((float)n);
X      derivs[0][active_vars[k]] += ((2.*(i+1)+1.)*tmpf1*tmpf2);
X    }
X    for (i=0; i<lJ; i++)
X    {
X      for (j=0; j<(lJ-i-1); j++)
X      {
X        tmpf2 =0.;
X        for (l=0; l<n; l++)
X        {
X          m = rows_in_plot[l];
X          tmpf3 = data[m][active_vars[k]];
X          tmpf2 += (Pp0[i][m]*P1[j][m] *
X            exp(-proj_data[0][m]*proj_data[0][m]/2.)*
X            (tmpf3 -
X            alpha[active_vars[k]]*proj_data[0][m] -
X            beta[active_vars[k]]*proj_data[1][m]));
X        }
X        tmpf2 /= ((float)n);
X        derivs[0][active_vars[k]] += ((2.*(i+1)+1)*
X          (2.*(j+1)+1)*acoefs[i][j]*tmpf2);
X      }
X    }
X    derivs[0][active_vars[k]] /= ((float)SQRT2PI);
X  }
/* beta */
X  for (k=0; k<p; k++)
X    derivs[1][k] = 0.;
X
X  for (k=0; k<nactive; k++) {
X    for (i=0; i<lJ; i++) {
X      tmpf2 = 0.;
X      for (j=0; j<n; j++) {
X        m = rows_in_plot[j];
X        tmpf3 = data[m][active_vars[k]];
X        tmpf2 += (Pp1[i][m]*exp(-proj_data[1][m]*proj_data[1][m]/2.)*
X          (tmpf3 -
X          alpha[active_vars[k]]*proj_data[0][m]
X          - beta[active_vars[k]]*proj_data[1][m]));
X      }
X      tmpf1 = mean_fn(P1[i], n, rows_in_plot);
X      tmpf2 /= ((float)n);
X      derivs[1][active_vars[k]] += ((2.*(i+1)+1.)*tmpf1*tmpf2);
X    }
X    for (i=0; i<lJ; i++)
X      for (j=0; j<(lJ-i-1); j++) {
X        tmpf2 =0.;
X        for (l=0; l<n; l++) {
X          m = rows_in_plot[l];
X          tmpf3 = data[m][active_vars[k]];
X          tmpf2 += (P0[i][m]*Pp1[j][m] *
X            exp(-proj_data[1][m]*proj_data[1][m]/2.)*
X            (tmpf3 -
X             alpha[active_vars[k]]*proj_data[0][m] -
X             beta[active_vars[k]]*proj_data[1][m]));
X        }
X        tmpf2 /= ((float)n);
X        derivs[1][active_vars[k]] += ((2.*(i+1)+1)*
X          (2.*(j+1)+1)*acoefs[i][j]*tmpf2);
X      }
X    derivs[1][active_vars[k]] /= ((float)SQRT2PI);
X  }
}
X
SHAR_EOF
  chmod 0644 'xgobi/src/legendre.c' ||
  $echo 'restore of' 'xgobi/src/legendre.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/legendre.c:' 'MD5 check failed'
009b502f9a6323882c2bb86f5a7360bc  xgobi/src/legendre.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/legendre.c'`"
    test 8262 -eq "$shar_count" ||
    $echo 'xgobi/src/legendre.c:' 'original size' '8262,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/Corba.nw ==============
if test -f 'xgobi/src/Corba.nw' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/Corba.nw' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/Corba.nw' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/Corba.nw' &&
@
<<*>>=
<<Includes>>
<<Globals>>
<<Initialization>>
<<Create Server>>
<<Event Loop>>
<<Error>>
<<Parse Corba Name>>
X
@
<<Global Declarations>>=
extern char **CorbaNameElements;
extern int    CorbaNameLength;
X
@
<<Globals>>=
X  char *DefaultCorbaName[] = {"XGobi"};
X    /* The elements of the name to use to register the CORBA name server. */
X  char **CorbaNameElements = NULL;
X    /* The number of elements in the name to use for the CORBA server. */
X  int  CorbaNameLength = -1;
X
@ 
<<Header>>=
#ifndef XGOBI_CORBA_H
#define XGOBI_CORBA_H
X
#include <Corba/RSCorba.h>
X
X  // the basic xgobi 
#include "xincludes.h"
#include "xgobitypes.h"
X
X  // the auto-generated file from the IDL source.
#include "XGobiCorbaServer.h"
#include "XGobiCorbaServer_skel.h"
X
#include <Corba/CorbaGlobals.h> // for the CORBACOnnection struct
X
#include "stdarg.h" // for Error.
X
<<Global Declarations>>
X
#ifdef __cplusplus
extern "C" {
#endif
X
<<C Prototypes>>
X
#ifdef __cplusplus
}
#endif
X
<<Prototypes>>
X
#endif
X
X
@ 
<<Globals>>=
X CORBAConnection *LocalCorbaGlobals = NULL;
X
@
<<C Prototypes>>=
XXGobi_XGobi_skel *
initCorba(char **argv, long length, char **name, long nameLength,
X            XtAppContext *Xcontext,
X              xgobidata *xgobi);
X
@ 
X  This is called after the X11 application context
X  has been constructed. This is then used to setup
X  the corba server and the X11 reactor/event handler
X  which takes care of both the CORBA events and the X
X  events.
X
X   This is Orbacus specific. See X11 Reactor and 
X   customized event handlers (page 124) in the 
X   Orbacus manual. 
X      (http://www.ooc.com/ob/download/OB-3.1.3.pdf.gz)
X
X   This returns the newly generated CORBA server.
<<Initialization>>=
XXGobi_XGobi_skel *
initCorba(char **argv, long length,  char **name, long nameLength,
X          //           CORBAConnection *LocalcorbaGlobals,
X             XtAppContext *Xcontext,
X               xgobidata *xgobi)
{
X  OBX11Init(*Xcontext);
X
X
X  if(CorbaNameElements == NULL) {
X    parseCorbaName((const char *)NULL);
X  }
X
X  if(LocalCorbaGlobals == NULL) {
X    LocalCorbaGlobals = new CORBAConnection();
X  }
X
X bool both = true;
X  InitializeLocalOrb(argv, length, LocalCorbaGlobals, both);
X
X  XGobi_XGobi_skel *corbaServer =  createServer(xgobi, LocalCorbaGlobals);
X  if(name == NULL || nameLength == 0) {
X    extern char *DefaultCorbaName[];
X    extern int CorbaNameLength;
X    /*
X      char *defaultServerName[] = {"XGobi"};
X      name = defaultServerName;
X      nameLength = sizeof(defaultServerName)/sizeof(defaultServerName[0]);
X    */
X    name = DefaultCorbaName;
X    nameLength = CorbaNameLength;  
X  }
X  registerObject((const char **)name, nameLength, corbaServer, LocalCorbaGlobals);
X
X  
X return(corbaServer);
}
X
X
@ 
<<Prototypes>>=
XXGobi_XGobi_skel *createServer(xgobidata *xgobi, CORBAConnection *corbaGlobals);
X
@ 
<<Create Server>>=
XXGobi_XGobi_skel *
createServer(xgobidata *xgobi, CORBAConnection *corbaGlobals)
{
X
X  return(new XGobiServer(xgobi)); //, corbaGlobals));
X  //  return(new XGobiServer(xgobi, corbaGlobals));
}
X
X
@
<<C Prototypes>>=
int parseCorbaName(const char *name);
X
X
@
<<Parse Corba Name>>=
/*
X  Here we parse the specified name into different components
X  that identify the nested path in the CORBA naming context.
X
X  The basic idea is that 
X */
int
parseCorbaName(const char *name)
{
X  if(name == NULL) {
X   if(CorbaNameLength < 0) {
X     CorbaNameLength = sizeof(DefaultCorbaName)/sizeof(DefaultCorbaName[0]);
X     CorbaNameElements  = DefaultCorbaName;
X   }
X   return(CorbaNameLength);
X  }
X    
X
X  if(strchr(name, '*') == NULL) {
X    CorbaNameLength = 1;
X    CorbaNameElements = DefaultCorbaName; 
X    CorbaNameElements[0] = (char *)name;
X  } else {
X   char *tmp, *ptr;
X   int i;
X    name = strdup(name);
X    CorbaNameLength = 0;
X
X    tmp = (char*)name;
X    while(tmp < name + strlen(name)) {
X     CorbaNameLength++;
X     ptr = strchr(tmp, '*');
X     if(ptr == NULL)
X      break;
X     tmp = ptr+1;
X    }
X
X   CorbaNameElements = (char**)calloc(CorbaNameLength, sizeof(char*));
X    tmp = (char *)name;
X    for(i = 0; i < CorbaNameLength -1; i++) {
X     ptr =  strchr(tmp, '*');
X     ptr[0]  = '\0';
X     CorbaNameElements[i] = tmp;
X     tmp = ptr + 1;
X    }
X    CorbaNameElements[i] = tmp;
X  }
X
X return(CorbaNameLength);
}
X
@ 
<<Prototypes>>=
void Error(char *str, ...);
X
@ 
<<Error>>=
void Error(char *str, ...)
{
X  fprintf(stderr, "Problem: %s", str);
X  fflush(stderr);
}
X
X
@ 
<<C Prototypes>>=
void CorbaEventLoop(xgobidata *xgobidata);
X
@ 
<<Event Loop>>=
void
CorbaEventLoop(xgobidata *xgobidata) {
X
X  LocalCorbaGlobals->boa->impl_is_ready(CORBANil); 
X
}
X
@ 
<<Includes>>=
#include "Corba.h"
#include <OB/X11.h>
X
#include "XGobiServer.h"
X
#include "CORBAinit.h"    // for the InitializeLocalOrb()
#include "NamingService.h" // for the registerObject()
X
#include <stdio.h>
SHAR_EOF
  chmod 0644 'xgobi/src/Corba.nw' ||
  $echo 'restore of' 'xgobi/src/Corba.nw' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/Corba.nw:' 'MD5 check failed'
0ce97697822a5b92be7fa47422a7b01f  xgobi/src/Corba.nw
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/Corba.nw'`"
    test 4807 -eq "$shar_count" ||
    $echo 'xgobi/src/Corba.nw:' 'original size' '4807,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/rpc_aiiac_err.h ==============
if test -f 'xgobi/src/rpc_aiiac_err.h' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/rpc_aiiac_err.h' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/rpc_aiiac_err.h' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/rpc_aiiac_err.h' &&
/* @(#)aiiac_err.h	1.1 3/28/94 11:28:47 */
X
#define ERR_NOERROR                 0
X
#define ERR_SERVER_ALREADY_OPEN     101
#define ERR_CANT_CREATE_FILE        105
#define ERR_CANT_START_DISPATCHER   106
#define ERR_CANT_GET_HOSTNAME       109
#define ERR_CANT_CREATE_DISP_HANDLE 107
#define ERR_NO_SERVER               100
X
X
#define ERR_BAD_NUMBER_ARGS         5 /* Match AML's BAD_NARGS error */
#define ERR_CANNOT_OPEN_FILE       100
#define ERR_REACHED_MAX_SERVERS    101
#define ERR_BAD_PROGNUM            102
#define ERR_BAD_VERNUM             103
#define ERR_BAD_SERVER             100
#define ERR_BAD_TIMEOUT            104
#define ERR_BAD_PROCNUM            101
#define ERR_NO_CLIENT_HANDLE       109
#define ERR_TIMED_OUT              110
#define ERR_GENERAL_ERROR          199
SHAR_EOF
  chmod 0644 'xgobi/src/rpc_aiiac_err.h' ||
  $echo 'restore of' 'xgobi/src/rpc_aiiac_err.h' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/rpc_aiiac_err.h:' 'MD5 check failed'
28c5fab1dd54cbea33c8b52d11992b85  xgobi/src/rpc_aiiac_err.h
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/rpc_aiiac_err.h'`"
    test 787 -eq "$shar_count" ||
    $echo 'xgobi/src/rpc_aiiac_err.h:' 'original size' '787,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/rpc_dce.idl ==============
if test -f 'xgobi/src/rpc_dce.idl' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/rpc_dce.idl' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/rpc_dce.idl' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/rpc_dce.idl' &&
/* rpc_dce.idl */
/***********************************************************************
X * Permission is hereby granted to any individual or institution       *
X * for use, copying, or redistribution of the rpc_dce C code           *
X * and associated documentation, provided such code and documentation  *
X * are not sold for profit and the following copyright notice is       *
X * retained in the code and documentation:                             *
X *                                                                     *
X *   Copyright (c) 1999 George Mason University                        *
X *                                                                     *
X * We encourage you to share questions, comments and modifications.    *
X *                                                                     *
X *   Martin Schneider (maschn@informatik.uni-marburg.de)               *
X *   Juergen Symanzik (symanzik@galaxy.gmu.edu)                        *
X ***********************************************************************/
X
[
uuid(b32b5c76-cf33-1022-8901-0800690559d0),
version(1.0)
]
X
#define STR_OUTSIZE 100
/* Ein kritischer Wert! */
#define STR_OUTSIZE_BIGGER 10000
X
interface xgobi_goes_dce
{
X
/*
X   Usage:     In - colp[ncols] : ncols x Str[COLLABLEN]
X   Function:  01
*/
void RPC_Send_Colnames ([in, string, ref] char *instr,[out, string, ref] char outstr[STR_OUTSIZE]);
X
/*
X   Usage:     In - rowp[nrows] : nrows x Str[ROWLABLEN]
X   Function:  02
*/
void RPC_Send_Rownames ([in, string, ref] char *instr,[out, string, ref] char outstr[STR_OUTSIZE]);
X
/*
X   Usage:     In - NULL	
X   Function:  03
*/
void RPC_Clone_XGobi ([in, string, ref] char *instr,[out, string, ref] char outstr[STR_OUTSIZE]);
X
/*
X   Usage:     In - NULL	
X   Function:  04
*/
void RPC_Xfer_Colornames ([in, string, ref] char *instr,[out, string, ref] char outstr[STR_OUTSIZE]);
X
/*
X   Usage:     In - (name, ncols, nrows) : (String, int, int)
X   Function:  11
*/
void RPC_Init_Data ([in, string, ref] char *instr,[out, string, ref] char outstr[STR_OUTSIZE]);
X
/*
X   Usage:     In - datap[nrows, ncols] : (nrows * ncols) x float
X   Function:  12
*/
void RPC_Send_Init_Data ([in, string, ref] char *instr,[out, string, ref] char outstr[STR_OUTSIZE]);
X
/*
X   Usage:     In - size_color_glyph[nrows] : nrows x int	
X   Function:  13
*/
void RPC_Send_Init_Symbols ([in, string, ref] char *instr,[out, string, ref] char outstr[STR_OUTSIZE]);
X
/*
X   Usage:     In - NULL	
X   Function:  14
*/
void RPC_Make_XGobi ([in, string, ref] char *instr,[out, string, ref] char outstr[STR_OUTSIZE]);
X
/*
X   Usage:     In - size_color_glyph[nrows] : nrows x int
X   Function:  15
*/
void RPC_Update_All_Symbols ([in, string, ref] char *instr,[out, string, ref] char outstr[STR_OUTSIZE]);
X
/*
X   Usage:     In - list of index:size_color_glyph : list of (int:int)
X   Function:  16
*/
void RPC_Update_Some_Symbols ([in, string, ref] char *instr,[out, string, ref] char outstr[STR_OUTSIZE]);
X
/*
X   Usage:     In - (name, ncols, nrows) : (String, int, int)
X   Function:  21
*/
void RPC_Init_CDF_Data ([in, string, ref] char *instr,[out, string, ref] char outstr[STR_OUTSIZE]);
X
/*
X   Usage:     In - datap[nrows, ncols - 1] : (nrows * (ncols - 1)) x float
X   Function:  22
*/
void RPC_Send_Init_CDF_Data ([in, string, ref] char *instr,[out, string, ref] char outstr[STR_OUTSIZE]);
X
/*
X   Usage:     In - size_color_glyph[NCDFTYPES] : NCDFTYPES x int	
X   Function:  23
*/
void RPC_Send_Init_CDF_Symbols ([in, string, ref] char *instr,[out, string, ref] char outstr[STR_OUTSIZE]);
X
/*
X   Usage:     In - NULL	
X   Function:  24
*/
void RPC_Make_CDF_XGobi ([in, string, ref] char *instr,[out, string, ref] char outstr[STR_OUTSIZE]);
X
/*
X   Usage:     In - (pointcolor, cdf_bitmap[pointcolor][nrows]) : (int, nrows x {0,1}) 
X   Function:  25
*/
void RPC_Add_CDF_Bitmap ([in, string, ref] char *instr,[out, string, ref] char outstr[STR_OUTSIZE]);
X
/*
X   Usage:     In - (pointcolor, cdftype) : (int, {0,1,2})
X   Function:  26
*/
void RPC_Add_CDF_Type ([in, string, ref] char *instr,[out, string, ref] char outstr[STR_OUTSIZE]);
X
/*
X   Usage:     In - pointcolor : int
X   Function:  27
*/
void RPC_Delete_CDF_Bitmap_and_Type ([in, string, ref] char *instr,[out, string, ref] char outstr[STR_OUTSIZE]);
X
/*
X   Usage:     In - cdf_brush_bitmap[nrows] : nrows x {0,1}
X   Function:  28
*/
void RPC_Brush_All_CDF_Symbols ([in, string, ref] char *instr,[out, string, ref] char outstr[STR_OUTSIZE]); 
X
/*
X   Usage:     In - cdf_weights[nrows] : nrows x double
X   Function:  29
*/
void RPC_Send_CDF_Weights ([in, string, ref] char *instr,[out, string, ref] char outstr[STR_OUTSIZE]);
X
/*
X   Usage:     In - (name, p, n, distance) : (String, int, int, double)
X   Function:  31
*/
void RPC_Init_VARIO_Data ([in, string, ref] char *instr,[out, string, ref] char outstr[STR_OUTSIZE]);
X
/*
X   Usage:     In - datap[n, p + 2] : (n * (p + 2)) x float
X   Function:  32
*/
void RPC_Send_Init_VARIO_Data ([in, string, ref] char *instr,[out, string, ref] char outstr[STR_OUTSIZE]); 
X
/*
X   Usage:     In - size_color_glyph : int	
X   Function:  33
*/
void RPC_Send_Init_VARIO_Symbols ([in, string, ref] char *instr,[out, string, ref] char outstr[STR_OUTSIZE]);
X
/*
X   Usage:     In - NULL	
X   Function:  34
*/
void RPC_Make_VARIO_XGobi ([in, string, ref] char *instr,[out, string, ref] char outstr[STR_OUTSIZE]);
X
/*
X   Usage:     In - brushtype, list of index:size_color_glyph : int, list of (int:int)
X   Function:  35
*/
void RPC_Update_Some_VARIO_Symbols ([in, string, ref] char *instr,[out, string, ref] char outstr[STR_OUTSIZE_BIGGER]); 
X
/*
X   Usage:     In - (name, p, n, distance) : (String, int, int, double)
X   Function:  41
*/
void RPC_Init_LAG_Data ([in, string, ref] char *instr,[out, string, ref] char outstr[STR_OUTSIZE]);
X
/*
X   Usage:     In - datap[n, p + 2] : (n * (p + 2)) x float
X   Function:  42
*/
void RPC_Send_Init_LAG_Data ([in, string, ref] char *instr,[out, string, ref] char outstr[STR_OUTSIZE]); 
X
/*
X   Usage:     In - size_color_glyph : int	
X   Function:  43
*/
void RPC_Send_Init_LAG_Symbols ([in, string, ref] char *instr,[out, string, ref] char outstr[STR_OUTSIZE]); 
X
/*
X   Usage:     In - NULL	
X   Function:  44
*/
void RPC_Make_LAG_XGobi ([in, string, ref] char *instr,[out, string, ref] char outstr[STR_OUTSIZE]);
X
/*
X   Usage:     In - brushtype, list of index:size_color_glyph : int, list of (int:int)
X   Function:  45
*/
void RPC_Update_Some_LAG_Symbols ([in, string, ref] char *instr,[out, string, ref] char outstr[STR_OUTSIZE_BIGGER]); 
X
/*
X   Usage:     In - colp[lag_p] : lag_p x Str[COLLABLEN]
X   Function:  46
*/
void RPC_Send_LAG_Colnames ([in, string, ref] char *instr,[out, string, ref] char outstr[STR_OUTSIZE]); 
X
/*
X   Usage:     In - (name, p, n, distance) : (String, int, int, double)
X   Function:  51
*/
void RPC_Init_VARIO2_Data ([in, string, ref] char *instr,[out, string, ref] char outstr[STR_OUTSIZE]); 
X
/*
X   Usage:     In - datap[n, p + 2] : (n * (p + 2)) x float
X   Function:  52
*/
void RPC_Send_Init_VARIO2_Data ([in, string, ref] char *instr,[out, string, ref] char outstr[STR_OUTSIZE]);
X
/*
X   Usage:     In - size_color_glyph : int	
X   Function:  53
*/
void RPC_Send_Init_VARIO2_Symbols ([in, string, ref] char *instr,[out, string, ref] char outstr[STR_OUTSIZE]); 
X
/*
X   Usage:     In - NULL	
X   Function:  54
*/
void RPC_Make_VARIO2_XGobi ([in, string, ref] char *instr,[out, string, ref] char outstr[STR_OUTSIZE]);
X
/*
X   Usage:     In - brushtype, list of index:size_color_glyph : int, list of (int:int)
X   Function:  55
*/
void RPC_Update_Some_VARIO2_Symbols ([in, string, ref] char *instr,[out, string, ref] char outstr[STR_OUTSIZE_BIGGER]); 
X
} /* von Interface */
SHAR_EOF
  chmod 0644 'xgobi/src/rpc_dce.idl' ||
  $echo 'restore of' 'xgobi/src/rpc_dce.idl' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/rpc_dce.idl:' 'MD5 check failed'
c33a536433555c319f3d4f550843efd8  xgobi/src/rpc_dce.idl
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/rpc_dce.idl'`"
    test 7686 -eq "$shar_count" ||
    $echo 'xgobi/src/rpc_dce.idl:' 'original size' '7686,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/rpc_dce.acf ==============
if test -f 'xgobi/src/rpc_dce.acf' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/rpc_dce.acf' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/rpc_dce.acf' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/rpc_dce.acf' &&
/*************************************************************/
/**                                                         **/
/**  xgobi DCE-ACF-Datei                                    **/
/**                                                         **/
/*************************************************************/
X
[ implicit_handle(handle_t xgobi_server_binding_handle) ]
interface xgobi_goes_dce
{
}
SHAR_EOF
  chmod 0644 'xgobi/src/rpc_dce.acf' ||
  $echo 'restore of' 'xgobi/src/rpc_dce.acf' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/rpc_dce.acf:' 'MD5 check failed'
a3b9b50bd239677f8315b51643281a06  xgobi/src/rpc_dce.acf
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/rpc_dce.acf'`"
    test 408 -eq "$shar_count" ||
    $echo 'xgobi/src/rpc_dce.acf:' 'original size' '408,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/move_points.c ==============
if test -f 'xgobi/src/move_points.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/move_points.c' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/move_points.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/move_points.c' &&
/* move_points.c */
/************************************************************
X *                                                          *
X *  Permission is hereby granted  to  any  individual   or  *
X *  institution   for  use,  copying, or redistribution of  *
X *  the xgobi code and associated documentation,  provided  *
X *  that   such  code  and documentation are not sold  for  *
X *  profit and the  following copyright notice is retained  *
X *  in the code and documentation:                          *
X *     Copyright (c)  AT&T Labs (1998).                     *
X *  All Rights Reserved.                                    *
X *                                                          *
X *  We welcome your questions and comments, and request     *
X *  that you share any modifications with us.               *
X *                                                          *
X *      Deborah Swayne             Andreas Buja             *
X *    dfs@research.att.com     andreas@research.att.com     *
X *                                                          *
X ************************************************************/
X
#include <stdio.h>
#include "xincludes.h"
#include "xgobitypes.h"
#include "xgobivars.h"
#include "xgobiexterns.h"
X
#define SAMEGLYPH(i,j) \
( xg->color_now[(i)] == xg->color_now[(j)] && \
X  xg->glyph_now[(i)].type == xg->glyph_now[(j)].type && \
X  xg->glyph_now[(i)].size == xg->glyph_now[(j)].size ) \
X
int moving_point = -1;
int move_type = 0;
/* for selections elsewhere, e.g., xgvis anchor group; initalize to first point */
int point_midbutton = NULL;
X
/* choose a cursor at some point */
X
#define UP 0
#define DOWN 1
static Boolean buttonpos = UP;
static int last_moved = -1;
static int last_x = -1, last_y = -1;
lcoords eps;
X
X
static Widget mp_panel;
static Widget reset_all_cmd, reset_one_cmd;
X
static Widget move_type_cmd[3], movePanel;
X
static Widget mpdir_menu_label, mpdir_menu_cmd, mpdir_menu, mpdir_menu_btn[3];
static char *mpdir_menu_btn_label[] = {"Both", "Vert", "Horiz"};
static enum {both, vert, horiz} mpdir_type = both;
X
/********** Reverse pipeline in pipeline.c ********************/
X
void
init_point_moving(xgobidata *xg)
{
X  xg->is_point_moving = False;
}
X
/* ARGSUSED */
XXtEventHandler
mp_button(Widget w, xgobidata *xg, XEvent *evnt, Boolean *cont)
{
X  XButtonEvent *xbutton = (XButtonEvent *) evnt;
X
X  if (xbutton->button == 1) {
X    if (xbutton->type == ButtonPress) {
X      buttonpos = DOWN;
X      last_moved = xg->nearest_point;
X      last_x = xg->screen[xg->nearest_point].x;
X      last_y = xg->screen[xg->nearest_point].y;
X    }
X    else if (xbutton->type == ButtonRelease) {
X      buttonpos = UP;
X
X      moving_point = -1;
X    }
X  }
X
X  /* AB select a point for use in xgvis */
X  if (xbutton->button == 2) {
X    if(xbutton->type == ButtonPress) {
X      point_midbutton = xg->nearest_point;
X      printf("point_midbutton = %d\n", point_midbutton);
X    }
X  }
X
}
X
void
move_pt_pipeline(int id, lcoords *eps, xgobidata *xg)
{
X  extern void plane_to_world(xgobidata *, int, lcoords *);
X  extern void world_to_raw(xgobidata *, int);
X
X  /* run the earliest parts of the pipeline backwards */
X  plane_to_world(xg, id, eps);
X  world_to_raw(xg, id);
}
X
void
move_pt(int id, int x, int y, xgobidata *xg) {
X  int i, k;
X
X  if (mpdir_type == horiz || mpdir_type == both)
X    xg->screen[id].x = x;
X  if (mpdir_type == vert || mpdir_type == both)
X    xg->screen[id].y = y;
X
X  /* Move the selected point */
X  screen_to_plane(xg, id, &eps,
X		  (mpdir_type == horiz || mpdir_type == both),
X		  (mpdir_type == vert || mpdir_type == both));
X  move_pt_pipeline(id, &eps, xg);  /*-- eps won't be changed here --*/
X
X  /* Move all points with same glyph as the selected point */
X  if (move_type == 1) {
X    for (i=0; i<xg->nrows_in_plot; i++) {
X      k = xg->rows_in_plot[i];
X      if (k!=id && !xg->erased[k] && SAMEGLYPH(k,id)) {
X	if (mpdir_type == horiz || mpdir_type == both) { xg->planar[k].x += eps.x; }
X	if (mpdir_type == vert  || mpdir_type == both) { xg->planar[k].y += eps.y; }
X	move_pt_pipeline(k, &eps, xg);
X  }}}  /* sorry AB */
X
X  /* Move ALL points */
X  if (move_type == 2) {
X    for (i=0; i<xg->nrows_in_plot; i++) {
X      k = xg->rows_in_plot[i];
X      if (k!=id && !xg->erased[k]) {
X	if (mpdir_type == horiz || mpdir_type == both) { xg->planar[k].x += eps.x; }
X	if (mpdir_type == vert  || mpdir_type == both) { xg->planar[k].y += eps.y; }
X	move_pt_pipeline(k, &eps, xg);
X  }}}  /* sorry AB */
X
X  /* and now forward again, all the way ... */
X  update_world(xg);
X  world_to_plane(xg);
X  plane_to_screen(xg);
X  if (xg->is_brushing) {
X    assign_points_to_bins(xg);
X    if (xg->brush_mode == transient)
X      reinit_transient_brushing(xg);
X  }
X  plot_once(xg);
X  if (xg->is_cprof_plotting && xg->link_cprof_plotting)
X    update_cprof_plot(xg);
}
X
void
move_points_proc(xgobidata *xg)
{
X  int root_x, root_y;
X  unsigned int kb;
X  Window root, child;
X  static int ocpos_x = 0, ocpos_y = 0;
X  icoords cpos;
X  static int inwindow = 1;
X  int wasinwindow;
X  Boolean pointer_moved = False;
X
X  wasinwindow = inwindow;
X
/*
X * Find the nearest point, just as in identification, and highlight it
*/
X
/*
X * Get the current pointer position.
*/
X  if (XQueryPointer(display, xg->plot_window, &root, &child,
X            &root_x, &root_y, &cpos.x, &cpos.y, &kb))
X  {
X    inwindow = (0 < cpos.x && cpos.x < xg->max.x &&
X                0 < cpos.y && cpos.y < xg->max.y) ;
X    /*
X     * If the pointer is inside the plotting region ...
X    */
X    if (inwindow)
X    {
X      /*
X       * If the pointer has moved ...
X      */
X      if ((cpos.x != ocpos_x) || (cpos.y != ocpos_y)) {
X        pointer_moved = True;
X        ocpos_x = cpos.x;
X        ocpos_y = cpos.y;
X      }
X    }
X  }
X
X  if (pointer_moved) {
X    
X    if (buttonpos == UP) {
X      moving_point = -1;
X      if ( (xg->nearest_point = find_nearest_point(&cpos, xg)) != -1) {
X        quickplot_once(xg);
X	/* AB would like to draw a point in bottom right with selected glyph/color */
X      }
X    }
X    else {
X      /*
X       * If the left button is down, move the point: compute the
X       * data pipeline in reverse, (then run it forward again?) and
X       * draw the plot.
X      */
X      if (buttonpos == DOWN && xg->nearest_point != -1) {
X        moving_point = xg->nearest_point;
X        move_pt(xg->nearest_point, cpos.x, cpos.y, xg);
X      }
X    }
X  }
X
X  if (!inwindow && wasinwindow) {
X    /*
X     * Don't draw the diamond if the pointer leaves the plot window.
X    */
X    xg->nearest_point = -1;
X    quickplot_once(xg);
X  }
}
X
static void
map_move_points(xgobidata *xg, Boolean movepts) 
{
X  if (movepts) 
X    {
X      XtMapWidget(xg->movepts_mouse);
X      XtMapWidget(mp_panel);
X    }
X  else
X    {
X    XtUnmapWidget(xg->movepts_mouse);
X    XtUnmapWidget(mp_panel);
X    }
}
X
/* ARGSUSED */
static XtCallbackProc
reset_all_cback(Widget w, xgobidata *xg, XtPointer cb_data) {
/*
X * read the raw data back in here instead of having to go
X * to the file menu to accomplish it.
*/
X  Boolean reset = False;
X
X  if (xg->datafilename != "") {
X    if (reread_dat(xg->datafilename, xg)) {
X      plot_once(xg);
X      reset = True;
X    }
X  }
X
X  if (!reset)
X    show_message(
X     "Sorry, I can\'t reset because I can\'t reread the data file\n", xg);
}
X
/* ARGSUSED */
static XtCallbackProc
reset_one_cback(Widget w, xgobidata *xg, XtPointer cb_data) {
/*
X * move the most recently moved point back to its position
X * when the mouse went down
*/
X  if (last_moved >=0 && last_moved < xg->nrows_in_plot) {
X    if ((last_x > -1 && last_x < xg->plotsize.width) &&
X        (last_y > -1 && last_y < xg->plotsize.height))
X    {
X      move_pt(last_moved, last_x, last_y, xg);
X    }
X  }
}
X
/* ARGSUSED */
void
reset_move_type(xgobidata *xg)
{
X
X  /* move point */
X  XtVaSetValues(move_type_cmd[0],
X    XtNstate, move_type == 0,
X    NULL);
X  setToggleBitmap(move_type_cmd[0], move_type == 0);
X
X  /* move group */
X  XtVaSetValues(move_type_cmd[1],
X    XtNstate, move_type == 1,
X    NULL);
X  setToggleBitmap(move_type_cmd[1], move_type == 1);
X
X  /* move all */
X  XtVaSetValues(move_type_cmd[2],
X    XtNstate, move_type == 2,
X    NULL);
X  setToggleBitmap(move_type_cmd[2], move_type == 2);
X
}
X
/* ARGSUSED */
static XtCallbackProc
setMoveTypePointCback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  if(move_type != 0) {
X    move_type = 0;
X    reset_move_type(xg);
X  }
}
X
/* ARGSUSED */
static XtCallbackProc
setMoveTypeGroupCback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  if(move_type != 1) {
X    move_type = 1;
X    reset_move_type(xg);
X  }
}
/* ARGSUSED */
static XtCallbackProc
setMoveTypeAllCback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  if(move_type != 2) {
X    move_type = 2;
X    reset_move_type(xg);
X  }
}
X
/* ARGSUSED */
XXtCallbackProc
set_mpdir_cback(Widget w, xgobidata *xg, XtPointer cb)
{
X  int k;
X  int id;
X
X  for (k=0; k<3; k++) {
X    if (w == mpdir_menu_btn[k]) {
X      id = k;
X      break;
X    }
X  }
X
X  XtVaSetValues(mpdir_menu_cmd,
X    XtNlabel, mpdir_menu_btn_label[id],
X    NULL);
X
X  if (id == 0)
X    mpdir_type = both;
X  else if (id == 1)
X    mpdir_type = vert;
X  else if (id == 2)
X    mpdir_type = horiz;
}
X
void
make_move_points(xgobidata *xg) {
X  /*  Widget use_groups_cmd;*/
X  Widget mpdir_box;
X  int k;
X
X  mp_panel = XtVaCreateManagedWidget("MvPtsPanel",
X    boxWidgetClass, xg->box0,
X    XtNleft, (XtEdgeType) XtChainLeft,
X    XtNright, (XtEdgeType) XtChainLeft,
X    XtNtop, (XtEdgeType) XtChainTop,
X    XtNbottom, (XtEdgeType) XtChainTop,
X    XtNmappedWhenManaged, (Boolean) False,
X    NULL);
X  if (mono) set_mono(mp_panel);
X
X  build_labelled_menu(&mpdir_box, &mpdir_menu_label, "MotionDir:",
X    &mpdir_menu_cmd, &mpdir_menu, mpdir_menu_btn,
X    mpdir_menu_btn_label, mpdir_menu_btn_label,  /* no nicknames */
X    3, 0, mp_panel, mpdir_box,
X    XtorientHorizontal, appdata.font, "MovePts", xg);
X  for (k=0; k<3; k++)
X    XtAddCallback(mpdir_menu_btn[k],  XtNcallback,
X      (XtCallbackProc) set_mpdir_cback, (XtPointer) xg);
X
X  movePanel = XtVaCreateManagedWidget("Panel",
X    boxWidgetClass, mp_panel,
X    XtNhorizDistance, 5,
X    XtNvertDistance, 5,
X    XtNorientation, (XtOrientation) XtorientVertical,
X    XtNleft, (XtEdgeType) XtChainLeft,
X    XtNtop, (XtEdgeType) XtChainTop,
X    XtNright, (XtEdgeType) XtChainLeft,
X    XtNbottom, (XtEdgeType) XtChainTop,
X    NULL);
X  if (mono) set_mono(movePanel);
X  move_type_cmd[0] = XtVaCreateWidget("XGVToggle",
X    toggleWidgetClass, movePanel,
X    XtNstate, (Boolean) True,
X    XtNlabel, (String) "Move Point  ",
X    NULL);
X  if (mono) set_mono(move_type_cmd[0]);
X  move_type_cmd[1] = XtVaCreateWidget("XGVToggle",
X    toggleWidgetClass, movePanel,
X    XtNlabel, (String) "Move Group",
X    XtNradioGroup, move_type_cmd[0],
X    NULL);
X  if (mono) set_mono(move_type_cmd[1]);
X  move_type_cmd[2] = XtVaCreateWidget("XGVToggle",
X    toggleWidgetClass, movePanel,
X    XtNlabel, (String) "Move All      ",
X    XtNradioGroup, move_type_cmd[0],
X    NULL);
X  if (mono) set_mono(move_type_cmd[2]);
X  XtManageChildren(move_type_cmd, 3);
X
X  setToggleBitmap(move_type_cmd[0], True);
X  setToggleBitmap(move_type_cmd[1], False);
X  setToggleBitmap(move_type_cmd[2], False);
X  XtAddCallback(move_type_cmd[0], XtNcallback,
X    (XtCallbackProc) setMoveTypePointCback, (XtPointer) xg);
X  XtAddCallback(move_type_cmd[1], XtNcallback,
X    (XtCallbackProc) setMoveTypeGroupCback, (XtPointer) xg);
X  XtAddCallback(move_type_cmd[2], XtNcallback,
X    (XtCallbackProc) setMoveTypeAllCback, (XtPointer) xg);
X
X  reset_all_cmd = CreateCommand(xg, "Reset all",
X    True, (Widget) NULL, (Widget) NULL,
X    mp_panel, "MP_Reset");
X  XtManageChild(reset_all_cmd);
X  if (xg->progname == NULL)
X    XtSetSensitive(reset_all_cmd, False);
X  XtAddCallback(reset_all_cmd, XtNcallback,
X    (XtCallbackProc) reset_all_cback, (XtPointer) xg);
X
X  reset_one_cmd = CreateCommand(xg, "Undo last",
X    True, (Widget) NULL, (Widget) NULL,
X    mp_panel, "MP_Reset");
X  XtManageChild(reset_one_cmd);
X  XtAddCallback(reset_one_cmd, XtNcallback,
X    (XtCallbackProc) reset_one_cback, (XtPointer) xg);
}
X
void move_points_on (xgobidata *xg)
{
/*
X *  If this mode is currently selected, turn it off.
*/
X  if (xg->prev_plot_mode == MOVEPTS_MODE && xg->plot_mode != MOVEPTS_MODE)
X  {
X    xg->is_point_moving = False;
X    XtRemoveEventHandler(xg->workspace,
X      XtAllEvents, TRUE,
X      (XtEventHandler) mp_button, (XtPointer) xg);
X    map_move_points(xg, False);
X    xg->nearest_point = -1;
X    plot_once(xg);
X  }
X  /* Else -- if xyplotting -- turn it on */
X  else if (xg->plot_mode == MOVEPTS_MODE &&
X           xg->prev_plot_mode != MOVEPTS_MODE)
X  {
X    if (xg->is_xyplotting || xg->is_spinning ||
X      (xg->is_touring && !xg->is_pp) ||
X      (xg->is_corr_touring && !xg->is_corr_pursuit))
X    {
X      xg->is_point_moving = True;
X      map_move_points(xg, True);
X      XtAddEventHandler(xg->workspace,
X        ButtonPressMask | ButtonReleaseMask, FALSE,
X        (XtEventHandler) mp_button, (XtPointer) xg);
X      (void) XtAppAddWorkProc(app_con, RunWorkProcs, (XtPointer) NULL);
X      /* Should use a different cursor ... */
X
X    } else {
X      show_message("Moving points won\'t work in this mode; sorry\n", xg);
X
X      /*
X       * It may be necessary to disable point moving if xg->std_type != 0
X      */
X    }
X  }
}
X
SHAR_EOF
  chmod 0644 'xgobi/src/move_points.c' ||
  $echo 'restore of' 'xgobi/src/move_points.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/move_points.c:' 'MD5 check failed'
307946c6393b5dc6677407a7824b9fac  xgobi/src/move_points.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/move_points.c'`"
    test 13252 -eq "$shar_count" ||
    $echo 'xgobi/src/move_points.c:' 'original size' '13252,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/.#Makefile.1.1.1.1 ==============
if test -f 'xgobi/src/.#Makefile.1.1.1.1' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/.#Makefile.1.1.1.1' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/.#Makefile.1.1.1.1' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/.#Makefile.1.1.1.1' &&
# Makefile generated by imake - do not edit!
# $XConsortium: imake.c /main/90 1996/11/13 14:43:23 lehors $
X
# ----------------------------------------------------------------------
# Makefile generated from "Imake.tmpl" and </tmp/IIf.a06wDM>
# $TOG: Imake.tmpl /main/245 1997/05/20 10:05:47 kaleb $
#
X
X.SUFFIXES: .i
X
# $TOG: Imake.cf /main/28 1997/06/25 08:31:36 barstow $
X
# -----------------------------------------------------------------------
# site-specific configuration parameters that need to come before
# the platform-specific parameters - edit site.def to change
X
# site:  $XConsortium: site.def /main/revisionist/4 1996/12/31 08:02:07 kaleb $
X
# ----------------------------------------------------------------------
# platform-specific configuration parameters - edit sgi.cf to change
X
# platform:  $XConsortium: sgi.cf,v 1.43 94/06/03 21:38:45 matt Exp $
X
# operating system:				IRIX
X
X     SGIISALIBDIR = /usr/lib32/mips3
X     SGIGFXLIBDIR = /usr/gfx/common/lib32
X
X     SGIABIOPTS   = -n32 -mips3
X     SGIABIDEFS   =
X
X        OPTIMIZER = -O2
X
X           MANUSR = /usr/share/local
X
X       CATMAN1DIR = $(MANUSR)/catman/u_man/cat1
X       CATMAN3DIR = $(MANUSR)/catman/p_man/cat3
X          MAN1DIR = $(MANUSR)/man/u_man/man1
X          MAN3DIR = $(MANUSR)/man/p_man/man3
X       CATMAN4DIR = $(MANUSR)/catman/u_man/cat4
X       CATMAN5DIR = $(MANUSR)/catman/u_man/cat5
X          MAN4DIR = $(MANUSR)/man/u_man/man4
X          MAN5DIR = $(MANUSR)/man/u_man/man5
X
X       MANPACKAGE = /X11
X
# $XConsortium: sgiLib.rules,v 1.8 93/09/11 17:59:30 rws Exp $
X
# ----------------------------------------------------------------------
# site-specific configuration parameters that go after
# the platform-specific parameters - edit site.def to change
X
# site:  $XConsortium: site.def /main/revisionist/4 1996/12/31 08:02:07 kaleb $
X
# ---------------------------------------------------------------------
# Imake rules for building libraries, programs, scripts, and data files
# rules:  $TOG: Imake.rules /main/220 1997/06/05 18:05:16 kaleb $
X
X          PATHSEP = /
X            SHELL = 	/bin/sh
X
X              TOP = .
X      CURRENT_DIR = .
X
X            IMAKE = imake
X           DEPEND = makedepend
X        MKDIRHIER = mkdirhier
X    EXPORTLISTGEN = 	exportlistgen
X        CONFIGSRC = $(TOP)/config
X         IMAKESRC = $(CONFIGSRC)/imake
X        DEPENDSRC = $(CONFIGSRC)/makedepend
X
X          INCROOT = /usr/include
X        USRLIBDIR = /usr/lib
X         SHLIBDIR = /usr/lib32
X       LINTLIBDIR = $(USRLIBDIR)/lint
X          MANPATH = /usr/share/man
X    MANSOURCEPATH = $(MANPATH)/man
X           MANDIR = $(CATMAN1DIR)$(MANPACKAGE)
X        LIBMANDIR = $(CATMAN3DIR)$(MANPACKAGE)
X       FILEMANDIR = $(MANSOURCEPATH)$(FILEMANSUFFIX)
X         MANDIR_4 = $(CATMAN4DIR)$(MANPACKAGE)
X         MANDIR_5 = $(CATMAN5DIR)$(MANPACKAGE)
X
X               AR = $(TOOLROOT)/usr/bin/ar cq
X  BOOTSTRAPCFLAGS = $(OPTIMIZER)
X               CC = $(TOOLROOT)/usr/bin/cc
X               AS = $(TOOLROOT)/usr/bin/as $(SGIABIOPTS)
X
X.SUFFIXES: .cc
X
X              CXX = CC
X          CXXFILT = c++filt
X           CXXLIB =
X    CXXDEBUGFLAGS = $(OPTIMIZER)
CXXDEPENDINCLUDES = -I$(ROOT)/usr/include/CC
X CXXEXTRA_DEFINES =
CXXEXTRA_INCLUDES =
X   CXXSTD_DEFINES = -DSYSV -DSVR4 -nostdinc -I$(ROOT)/usr/include $(CXXPROJECT_DEFINES)
X       CXXOPTIONS =
X      CXXINCLUDES = $(INCLUDES) $(TOP_INCLUDES) $(CXXEXTRA_INCLUDES)
X       CXXDEFINES = $(CXXINCLUDES) $(CXXSTD_DEFINES) $(THREADS_CXXDEFINES) $(CXXEXTRA_DEFINES) $(DEFINES)
X         CXXFLAGS = $(CXXDEBUGFLAGS) $(CXXOPTIONS) $(THREADS_CXXFLAGS) $(CXXDEFINES)
X
X         COMPRESS = compress
X          GZIPCMD = gzip
X              CPP = /lib/cpp $(STD_CPP_DEFINES)
X    PREPROCESSCMD = $(TOOLROOT)/usr/bin/cc -E $(STD_CPP_DEFINES)
X          INSTALL = bsdinst
X     INSTALLFLAGS = -c
X               LD = $(TOOLROOT)/usr/bin/ld $(SGIABIOPTS)
X              LEX = lex
X           LEXLIB = -ll
X             YACC = yacc
X           CCYACC = yacc
X             LINT = lint
X      LINTLIBFLAG = -o
X         LINTOPTS = -bh
X               LN = ln -s
X             MAKE = $(TOOLROOTSAFE) $(TOOLROOT)/sbin/make
X               MV = mv
X               CP = cp
X
X               RM = rm -f
X        MANSUFFIX = 1
X     LIBMANSUFFIX = 3
X    FILEMANSUFFIX = 4
X            TROFF = psroff -t
X            NROFF = nroff
X         MSMACROS = -ms
X        MANMACROS = -man
X              TBL = tbl
X              EQN = eqn
X             NEQN = neqn
X              COL = col
X
X            DVIPS = dvips
X            LATEX = latex
X
X     STD_INCLUDES = -nostdinc -I$(ROOT)/usr/include
X  STD_CPP_DEFINES = -DSYSV -DSVR4 $(PROJECT_DEFINES)
X      STD_DEFINES = -DSYSV -DSVR4 $(PROJECT_DEFINES)
X EXTRA_LOAD_FLAGS =
X  EXTRA_LDOPTIONS =
X  EXTRA_LIBRARIES =
X             TAGS = ctags
X
X    SHAREDCODEDEF =
X         SHLIBDEF =
X
X    PROTO_DEFINES = -DFUNCPROTO=7 -DNARROWPROTO
X
X     INSTPGMFLAGS =
X
X     INSTBINFLAGS = -m 0755
X     INSTUIDFLAGS = -m 4711
X     INSTLIBFLAGS = -m 0644
X     INSTINCFLAGS = -m 0444
X     INSTMANFLAGS = -m 0444
X     INSTDATFLAGS = -m 0444
X    INSTKMEMFLAGS = -m 2755 -g sys
X
X      CDEBUGFLAGS = $(OPTIMIZER)
X        CCOPTIONS = -xansi $(SGIABIOPTS) $(SGIABIDEFS)
X
X      ALLINCLUDES = $(INCLUDES) $(EXTRA_INCLUDES) $(TOP_INCLUDES) $(STD_INCLUDES)
X       ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(EXTRA_DEFINES) $(PROTO_DEFINES) $(THREADS_DEFINES) $(DEFINES)
X           CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(THREADS_CFLAGS) $(ALLDEFINES)
X        LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES) $(DEPEND_DEFINES)
X         LDPRELIB =
X        LDPOSTLIB = -nostdlib -L$(ROOT)$(SGIISALIBDIR) -L$(ROOT)$(SHLIBDIR)
X        LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS)  $(EXTRA_LDOPTIONS) $(THREADS_LDFLAGS) $(LOCAL_LDFLAGS) $(LDPRELIBS)
X     CXXLDOPTIONS = $(CXXDEBUGFLAGS) $(CXXOPTIONS) $(EXTRA_LDOPTIONS) $(THREADS_CXXLDFLAGS) $(LOCAL_LDFLAGS) $(LDPRELIBS)
X
X           LDLIBS = $(LDPOSTLIBS) $(THREADS_LIBS) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
X
X           CCLINK = $(CC)
X
X          CXXLINK = $(CXX)
X
X     LDSTRIPFLAGS = -x
X   LDCOMBINEFLAGS = -r
X      DEPENDFLAGS =
X
X        MACROFILE = sgi.cf
X           RM_CMD = $(RM)
X
X    IMAKE_DEFINES =
X
X         IRULESRC = $(CONFIGDIR)
X        IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES)
X
X     ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/X11.tmpl \
X			$(IRULESRC)/site.def $(IRULESRC)/$(MACROFILE) \
X			$(IRULESRC)/host.def $(EXTRA_ICONFIGFILES)
X
# $TOG: X11.rules /main/4 1997/04/30 15:23:24 kaleb $
X
# ----------------------------------------------------------------------
# X Window System Build Parameters and Rules
# $TOG: X11.tmpl /main/292 1997/05/20 10:05:59 kaleb $
X
# -----------------------------------------------------------------------
# X Window System make variables; these need to be coordinated with rules
X
X             XTOP = $(TOP)
X           BINDIR = /usr/bin/X11
X     BUILDINCROOT = $(TOP)/exports
X      BUILDINCDIR = $(BUILDINCROOT)/include/X11
X      BUILDINCTOP = ../../..
X      BUILDLIBDIR = $(TOP)/exports/lib
X      BUILDLIBTOP = ../..
X      BUILDBINDIR = $(TOP)/exports/bin
X      BUILDBINTOP = ../..
X    XBUILDINCROOT = $(XTOP)/exports
X     XBUILDINCDIR = $(XBUILDINCROOT)/include/X11
X     XBUILDINCTOP = ../../..
X     XBUILDBINDIR = $(XBUILDINCROOT)/bin
X           INCDIR = $(INCROOT)/X11
X           ADMDIR = /usr/adm
X           LIBDIR = $(USRLIBDIR)/X11
X   TOP_X_INCLUDES =
X
X          FONTDIR = $(LIBDIR)/fonts
X         XINITDIR = $(LIBDIR)/xinit
X           XDMDIR = 			/var/X11/xdm
X           TWMDIR = $(LIBDIR)/twm
X           XSMDIR = $(LIBDIR)/xsm
X           NLSDIR = $(LIBDIR)/nls
X       XLOCALEDIR = $(LIBDIR)/locale
X        PEXAPIDIR = $(LIBDIR)/PEX
X      LBXPROXYDIR = $(LIBDIR)/lbxproxy
X  PROXYMANAGERDIR = $(LIBDIR)/proxymngr
X        XPRINTDIR = $(LIBDIR)
X      XAPPLOADDIR = $(LIBDIR)/app-defaults
X       FONTCFLAGS = -t
X
X     INSTAPPFLAGS = $(INSTDATFLAGS)
X
X              RGB = rgb
X            FONTC = bdftopcf
X        MKFONTDIR = mkfontdir
X
X       DOCUTILSRC = $(XTOP)/doc/util
X       XDOCMACROS = $(DOCUTILSRC)/macros.t
X       XIDXMACROS = $(DOCUTILSRC)/indexmacros.t
X       PROGRAMSRC = $(TOP)/programs
X           LIBSRC = $(XTOP)/lib
X          FONTSRC = $(XTOP)/fonts
X       INCLUDESRC = $(BUILDINCROOT)/include/X11
X      XINCLUDESRC = $(INCLUDESRC)/X11
X        SERVERSRC = $(XTOP)/programs/Xserver
X       CONTRIBSRC = $(XTOP)/../contrib
X   UNSUPPORTEDSRC = $(XTOP)/unsupported
X           DOCSRC = $(XTOP)/doc
X           RGBSRC = $(XTOP)/programs/rgb
X      BDFTOPCFSRC = $(PROGRAMSRC)/bdftopcf
X     MKFONTDIRSRC = $(PROGRAMSRC)/mkfontdir
X    FONTSERVERSRC = $(PROGRAMSRC)/xfs
X       FONTINCSRC = $(XTOP)/include/fonts
X        EXTINCSRC = $(XTOP)/include/extensions
X     TRANSCOMMSRC = $(LIBSRC)/xtrans
X   TRANS_INCLUDES = -I$(TRANSCOMMSRC)
X
X   CLIENTENVSETUP =
X
# Supporting dynamic shared object libraries for IRIX 5.0
X
# These defines mimic what is in /usr/include/make/commondefs
# (Should be in sync with Revision 1.99)
X
X       DSOREGFILE = $$ROOT$(SHLIBDIR)/so_locations
X      DSOSTARTOPT = -update_registry $(DSOREGFILE)
X       DSONAMEOPT = -soname $@
X       DSOVERSION = sgi1.0
X    DSOVERSIONOPT = -set_version $(DSOVERSION)
X        LDDSOOPTS = -n32 -mips3 -shared -no_unresolved $(VLDDSOOPTS) \
X  $(LLDDSOOPTS) $(GLDDSOOPTS)
X       GLDDSOOPTS = -all $(DSOSTARTOPT) $(DSONAMEOPT) $(DSOVERSIONOPT)
X
X          XLIBSRC = $(LIBSRC)/X11
X
SOXLIBREV = .1
DEPXONLYLIB =  $(ROOT)$(SHLIBDIR)/libX11.so$(SOXLIBREV)
XXONLYLIB =  -lX11
X
LINTXONLY =  $(LINTLIBDIR)/llib-lX11.ln
X
X         XLIBONLY = $(XONLYLIB)
X
X      XEXTLIBSRC = $(LIBSRC)/Xext
X
SOXEXTREV =
DEPEXTENSIONLIB =  $(ROOT)$(SHLIBDIR)/libXext.so$(SOXEXTREV)
EXTENSIONLIB =  -lXext
X
LINTEXTENSION =  $(LINTLIBDIR)/llib-lXext.ln
X
LINTEXTENSIONLIB = $(LINTEXTENSION)
X          DEPXLIB = $(DEPEXTENSIONLIB) $(DEPXONLYLIB)
X             XLIB = $(EXTENSIONLIB) $(XONLYLIB)
X         LINTXLIB = $(LINTXONLYLIB)
X
X         XAUTHSRC = $(LIBSRC)/Xau
X
DEPXAUTHLIB =  $(USRLIBDIR)/libXau.a
XXAUTHLIB =  -lXau
X
LINTXAUTH =  $(LINTLIBDIR)/llib-lXau.ln
X
X      XDMCPLIBSRC = $(LIBSRC)/Xdmcp
X
DEPXDMCPLIB =  $(USRLIBDIR)/libXdmcp.a
XXDMCPLIB =  -lXdmcp
X
LINTXDMCP =  $(LINTLIBDIR)/llib-lXdmcp.ln
X
X           XMUSRC = $(LIBSRC)/Xmu
X
SOXMUREV =
DEPXMULIB =  $(ROOT)$(SHLIBDIR)/libXmu.so$(SOXMUREV)
XXMULIB =  -lXmu
X
LINTXMU =  $(LINTLIBDIR)/llib-lXmu.ln
X
X       OLDXLIBSRC = $(LIBSRC)/oldX
X
DEPOLDXLIB =  $(USRLIBDIR)/liboldX.a
OLDXLIB =  -loldX
X
LINTOLDX =  $(LINTLIBDIR)/llib-loldX.ln
X
X         XPLIBSRC = $(LIBSRC)/Xp
X
SOXPREV = 6.2
DEPXPLIB =  $(ROOT)$(SHLIBDIR)/libXp.so$(SOXPREV)
XXPLIB =  -lXp
X
LINTXP =  $(LINTLIBDIR)/llib-lXp.ln
X
X       TOOLKITSRC = $(LIBSRC)/Xt
X
SOXTREV =
DEPXTOOLONLYLIB =  $(ROOT)$(SHLIBDIR)/libXt.so$(SOXTREV)
XXTOOLONLYLIB =  -lXt
X
LINTXTOOLONLY =  $(LINTLIBDIR)/llib-lXt.ln
X
X      DEPXTOOLLIB = $(DEPXTOOLONLYLIB) $(DEPSMLIB) $(DEPICELIB)
X         XTOOLLIB = $(XTOOLONLYLIB) $(SMLIB) $(ICELIB)
X     LINTXTOOLLIB = $(LINTXTOOLONLYLIB)
X
X       XALIBSRC = $(LIBSRC)/Xa
X
SOXAREV = 1.0
DEPXALIB =  $(ROOT)$(SHLIBDIR)/libXa.so$(SOXAREV)
XXALIB =  -lXa
X
LINTXA =  $(LINTLIBDIR)/llib-lXa.ln
X
X       AWIDGETSRC = $(LIBSRC)/Xaw
X
SOXAWREV = .2
DEPXAWLIB =  $(ROOT)$(SHLIBDIR)/libXaw.so$(SOXAWREV)
XXAWLIB =  -lXaw
X
LINTXAW =  $(LINTLIBDIR)/llib-lXaw.ln
X
X         XILIBSRC = $(LIBSRC)/Xi
X
SOXINPUTREV =
DEPXILIB =  $(ROOT)$(SHLIBDIR)/libXi.so$(SOXINPUTREV)
XXILIB =  -lXi
X
LINTXI =  $(LINTLIBDIR)/llib-lXi.ln
X
X      XTESTLIBSRC = $(LIBSRC)/Xtst
X
DEPXTESTLIB =  $(USRLIBDIR)/libXtst.a
XXTESTLIB =  -lXtst
X
LINTXTEST =  $(LINTLIBDIR)/llib-lXtst.ln
X
X        PEXLIBSRC = $(LIBSRC)/PEX5
X
DEPPEXLIB =  $(ROOT)$(SHLIBDIR)/libPEX5.a
PEXLIB =  -lPEX5
X
LINTPEX =  $(LINTLIBDIR)/llib-lPEX5.ln
X
X        XNMBXLIBSRC = $(LIBSRC)/nmbx
X
SONMBXREV =
DEPXNMBXLIB =  $(ROOT)$(SHLIBDIR)/libXnmbx.so$(SONMBXREV)
XXNMBXLIB =  -lXnmbx
X
LINTXNMBX =  $(LINTLIBDIR)/llib-lXnmbx.ln
X
X        XTRAPLIBSRC = $(LIBSRC)/xtrap
X
DEPXTRAPLIB =  $(ROOT)$(SHLIBDIR)/libxtrap.a
XXTRAPLIB =  -lxtrap
X
LINTXTRAP =  $(LINTLIBDIR)/llib-lxtrap.ln
X
X        XIELIBSRC = $(LIBSRC)/XIE
X
DEPXIELIB =  $(USRLIBDIR)/libXIE.a
XXIELIB =  -lXIE
X
LINTXIE =  $(LINTLIBDIR)/llib-lXIE.ln
X
X      PHIGSLIBSRC = $(LIBSRC)/PHIGS
X
DEPPHIGSLIB =  $(USRLIBDIR)/libphigs.a
PHIGSLIB =  -lphigs
X
LINTPHIGS =  $(LINTLIBDIR)/llib-lphigs.ln
X
DEPXBSDLIB =  $(USRLIBDIR)/libXbsd.a
XXBSDLIB =  -lXbsd
X
LINTXBSD =  $(LINTLIBDIR)/llib-lXbsd.ln
X
X           ICESRC = $(LIBSRC)/ICE
X
SOICEREV =
DEPICELIB =  $(ROOT)$(SHLIBDIR)/libICE.so$(SOICEREV)
ICELIB =  -lICE
X
LINTICE =  $(LINTLIBDIR)/llib-lICE.ln
X
X            SMSRC = $(LIBSRC)/SM
X
SOSMREV =
DEPSMLIB =  $(ROOT)$(SHLIBDIR)/libSM.so$(SOSMREV)
SMLIB =  -lSM
X
LINTSM =  $(LINTLIBDIR)/llib-lSM.ln
X
X           XKEYSRC = $(LIBSRC)/Xkey
X
SOXKEYREV = 6.0
DEPXKEYLIB =  $(ROOT)$(SHLIBDIR)/libXkey.so$(SOXKEYREV)
XXKEYLIB =  -lXkey
X
LINTXKEY =  $(LINTLIBDIR)/llib-lXkey.ln
X
X         FSLIBSRC = $(LIBSRC)/FS
X
DEPFSLIB =  $(USRLIBDIR)/libFS.a
FSLIB =  -lFS
X
LINTFS =  $(LINTLIBDIR)/llib-lFS.ln
X
X         FONTLIBSRC = $(LIBSRC)/font
X
DEPFONTLIB =  $(USRLIBDIR)/libfont.a
FONTLIB =  -lfont
X
LINTFONT =  $(LINTLIBDIR)/llib-lfont.ln
X
X    XKBFILELIBSRC = $(LIBSRC)/xkbfile
X
DEPXKBFILELIB =  $(USRLIBDIR)/libxkbfile.a
XXKBFILELIB =  -lxkbfile
X
LINTXKBFILE =  $(LINTLIBDIR)/llib-lxkbfile.ln
X
X     XKBCOMPCMD = xkbcomp
X
X          DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)
X
X         DEPLIBS1 = $(DEPLIBS)
X         DEPLIBS2 = $(DEPLIBS)
X         DEPLIBS3 = $(DEPLIBS)
X         DEPLIBS4 = $(DEPLIBS)
X         DEPLIBS5 = $(DEPLIBS)
X         DEPLIBS6 = $(DEPLIBS)
X         DEPLIBS7 = $(DEPLIBS)
X         DEPLIBS8 = $(DEPLIBS)
X         DEPLIBS9 = $(DEPLIBS)
X         DEPLIBS10 = $(DEPLIBS)
X
IMAKE_DEFINES = -DBuild32bit=1
X
X        CONFIGDIR = $(LIBDIR)/config
X
X    USRLIBDIRPATH = $(USRLIBDIR)
X        LDPRELIBS =
X       LDPOSTLIBS = -nostdlib -L$(ROOT)$(SGIISALIBDIR) -L$(ROOT)$(SHLIBDIR)
X     TOP_INCLUDES =  $(TOP_X_INCLUDES)
X  PROJECT_DEFINES =
X
CXXPROJECT_DEFINES =
X
# ----------------------------------------------------------------------
# start of Imakefile
X
#
#	This is an Imakefile for the XGobi program.  The only changes that
#	should need to be made is for the XGOBID variable and sometimes
#	the random number generator.
#
#  Set XGOBID to the directory containing
#  the xgobi directories src, help, ps, etc.
X         #XGOBID = $(PWD)/..
# I'm defining DEFAULTDIR without using XGOBID; I suddenly
# starting having a weird problem with PWD.  If you're not
# building xgobi as we hand it out, this shouldn't bother
# you at all.
X             CC = cc
X             LD =
X     CDEBUGFLAGS = -g
# EXTRA_LDOPTIONS = -static
X      # for gcc
X      #CCOPTIONS = -ansi -w -DDEBUG
X      CCOPTIONS = -xansi -DDEBUG
X
#  Choose a random number generator, random or drand48
X               R = USE_RANDOM
X              #R = USE_DRAND48
X
#
# RPC: Remote Procedure Calls
#
X
# If you plan to use RPC, uncomment this #define
# RPC is the define for any kind of RPC
X
# Special RPCs
X
# If you plan to use XPLORE, uncomment this #define
X
X LOCAL_LIBRARIES = $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB)
X
X   SYS_LIBRARIES = -lm
X
X         DEFINES = -D$(R) -DDEFAULTDIR=\"$(PWD)/..\"
X        #DEFINES = -D$(R) -DDEFAULTDIR=\"$(XGOBID)/..\"
X
JOINTSRC = xgobi_init.c pipeline.c read_array.c \
X	initialize.c widgets.c callbacks.c getfname.c \
X	xyplot.c make_axes.c line_editor.c missing.c  \
X	spin_cbacks.c spin.c scaling.c scale_cbacks.c \
X	identify.c var_panel.c transform.c stdize.c inference.c \
X	brush_init.c brush_cbacks.c brush.c paint.c brush_send.c \
X	help.c prt_plotwin.c subset.c vc_lists.c exclusion.c \
X	plot_once.c plot1d.c texture.c ash1d.c move_points.c \
X	show_message.c smooth.c smooth_fns.c smoothsk.c pspline.c \
X	save_data.c new_data.c read_data.c jitter.c parcoords.c utils.c \
X	tour_init.c tour_util.c tour.c tour_cbacks.c tour_send.c gt_ctls.c \
X	tour_pp.c svd.c kernel.c \
X	legendre.c hermite.c natrl_hermite.c de_indices.c \
X	central_mass.c holes.c skewness.c \
X	tour_section.c corr.c corr_index.c corr_pursuit.c corr_util.c \
X	DrawingA.c
JOINTOBJ = xgobi_init.o pipeline.o read_array.o \
X	initialize.o widgets.o callbacks.o getfname.o \
X	xyplot.o make_axes.o line_editor.o missing.o  \
X	spin_cbacks.o spin.o scaling.o scale_cbacks.o \
X	identify.o var_panel.o transform.o stdize.o inference.o \
X	brush_init.o brush_cbacks.o brush.o paint.o brush_send.o \
X	help.o prt_plotwin.o subset.o vc_lists.o exclusion.o \
X	plot_once.o plot1d.o texture.o ash1d.o move_points.o \
X	show_message.o smooth.o smooth_fns.o smoothsk.o pspline.o \
X	save_data.o new_data.o read_data.o jitter.o parcoords.o utils.o \
X	tour_init.o tour_util.o tour.o tour_cbacks.o tour_send.o gt_ctls.o \
X	tour_pp.o svd.o kernel.o \
X	legendre.o hermite.o natrl_hermite.o de_indices.o \
X	central_mass.o holes.o skewness.o \
X	tour_section.o corr.o corr_index.o corr_pursuit.o corr_util.o \
X	DrawingA.o
X
RPCSRC =
RPCOBJ =
X
XXGOBISRC = xgobi.c $(JOINTSRC) $(RPCSRC)
XXGOBIOBJ = xgobi.o $(JOINTOBJ) $(RPCOBJ)
X
XXGVISSRC = xgvis.c xgv_dissim.c xgv_mds.c \
X	xgv_molecule.c xgv_read_data.c xgv_help.c \
X	xgv_stress.c xgv_cbacks.c xgv_widgets.c $(JOINTSRC)
XXGVISOBJ = xgvis.o xgv_dissim.o xgv_mds.o \
X	xgv_molecule.o xgv_read_data.o xgv_help.o \
X	xgv_stress.o xgv_cbacks.o xgv_widgets.o $(JOINTOBJ)
X
all:: xgvis xgobi
X
xgobi:  $(XGOBIOBJ)
X	  $(RM) $@
X	 $(CCLINK) -o $@ $(LDOPTIONS)  $(XGOBIOBJ)   $(LDLIBS)  $(LOCAL_LIBRARIES) $(EXTRA_LOAD_FLAGS)
X
clean::
X	 $(RM) xgobi
X
xgvis:  $(XGVISOBJ)
X	  $(RM) $@
X	 $(CCLINK) -o $@ $(LDOPTIONS)  $(XGVISOBJ)   $(LDLIBS)  $(LOCAL_LIBRARIES) $(EXTRA_LOAD_FLAGS)
X
clean::
X	 $(RM) xgvis
X
purexgobi: xgobi.o $(JOINTOBJ)
X	purify -cache-dir=/tmp  -always-use-cache-dir=yes \
X	${CC} ${CFLAGS} ${LD} ${LDOPTIONS} -o xgobi ${XGOBIOBJ} ${LOCAL_LIBRARIES} \
X	${SYS_LIBRARIES}
X
purexgvis: xgvis.o $(XGVISOBJ)
X	purify -cache-dir=/tmp  -always-use-cache-dir=yes \
X	${CC} ${CFLAGS} ${LD} ${LDOPTIONS} -o xgvis ${XGVISOBJ} ${LOCAL_LIBRARIES} \
X	${SYS_LIBRARIES}
X
# ----------------------------------------------------------------------
# common rules for all Makefiles - do not edit
X
X.c.i:
X	  $(RM) $@
X	 	$(CC) -E $(CFLAGS) $(_NOOP_) $*.c > $@
X
emptyrule::
X
clean::
X	$(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut   "#"*
X
Makefile::
X	 -@if [ -f Makefile ]; then set -x; \
X	 $(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \
X	else exit 0; fi
X	$(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR)
X
tags::
X	$(TAGS) -w *.[ch]
X	$(TAGS) -xw *.[ch] > TAGS
X
man_keywords::
X
# ----------------------------------------------------------------------
# empty rules for directories that do not have SUBDIRS - do not edit
X
install::
X	@echo "install in $(CURRENT_DIR) done"
X
install.man::
X	@echo "install.man in $(CURRENT_DIR) done"
X
install.linkkit::
X	@echo "install.linkkit in $(CURRENT_DIR) done"
X
Makefiles::
X
includes::
X
depend::
X
# ----------------------------------------------------------------------
# dependencies generated by makedepend
X
SHAR_EOF
  chmod 0644 'xgobi/src/.#Makefile.1.1.1.1' ||
  $echo 'restore of' 'xgobi/src/.#Makefile.1.1.1.1' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/.#Makefile.1.1.1.1:' 'MD5 check failed'
3198859cefee25d7939b04249cd72d6c  xgobi/src/.#Makefile.1.1.1.1
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/.#Makefile.1.1.1.1'`"
    test 18845 -eq "$shar_count" ||
    $echo 'xgobi/src/.#Makefile.1.1.1.1:' 'original size' '18845,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/Makefile.corba ==============
if test -f 'xgobi/src/Makefile.corba' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/Makefile.corba' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/Makefile.corba' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/Makefile.corba' &&
X
X ###### dfs adding to test ############################
ifndef OMEGA_HOME
X OMEGA_HOME=/n/project2/swtoolbin/duncan/org/omegahat
endif
X
ifndef INSTALL_HOME
X  INSTALL_HOME=$(OMEGA_HOME)
endif
ifndef IDLTYPES_DIR
X  IDLTYPES_DIR=$(OMEGA_HOME)/include/IDL
endif
X
X
CXX=g++
X
X ######################################################
X
X   # Include the CORBA material.
CORBACONFIG=$(OMEGA_HOME)/Interfaces/CORBA/CORBAConfig
include $(CORBACONFIG)/Makefile.CORBA
X
include $(OMEGA_HOME)/Config/GNUmakefile.config
X
OMEGA_INCLUDES=$(INSTALL_HOME)/include
X
X # Assume all the omegahat header files have been installed as part
X # of the omegahat distribution.
INCLUDES=\
X         -I$(OMEGA_INCLUDES) \
X         -I$(OMEGA_INCLUDES)/Corba \
X         -I/usr/local/include \
X         -I/usr/local/include/OB \
X         -I.
X
CORBA_LIB_DIR=$(OMEGA_HOME)/lib
X
CORBA_LIBRARIES= -L$(CORBA_LIB_DIR)  -lCorbaUtils -lOmegaCorba -lCosNaming -lOBX11 -lOB
IDLCFLAGS=-I. -I$(IDLTYPES_DIR)
X
#ALL_LIBS:= $(CORBA_LIBRARIES) $(ALL_LIBS)
X
CPPFLAGS+= -DCORBA_USED=1  $(INCLUDES)
CXXFLAGS+= $(CPPFLAGS) 
CFLAGS+= $(CPPFLAGS) 
X
X
include $(OMEGA_HOME)/Config/GNUmakefile.rules
X
Corba.o: Corba.h Corba.cc XGobiCorbaServer.h XGobiServer.h
X
XXGobiCorbaServer.h: XGobiCorbaServer.idl
XXGobiCorbaServer.cpp: XGobiCorbaServer.idl
XXGobiCorbaServer_skel.cpp: XGobiCorbaServer.idl
XXGobiCorbaServer_skel.h: XGobiCorbaServer.idl
X
X
X # xgobi: Corba.o  XGobiCorbaServer.o
X
CORBASRC=Corba.cc XGobiCorbaServer_skel.cpp  XGobiCorbaServer.cpp
CORBAOBJ=Corba.o XGobiCorbaServer_skel.o XGobiCorbaServer.o
X
X
OMEGA_IDL_INCLUDES=$(OMEGA_HOME)/Interfaces/CORBA/IDLTypes
X
X
IDLCFLAGS=-I$(OMEGA_IDL_INCLUDES)
X
X
%.cpp: %.idl
X	$(IDLCC) $(IDLCFLAGS) $<
X
%.c: %.idl
X	$(IDLCC) $(IDLCFLAGS) $<
X
%.h: %.idl
X	$(IDLCC) $(IDLCFLAGS) $<
X
%.h: %.nw
X	$(WEB) -RHeader $< > $@
X
%.cc: %.nw
X	$(WEB) $< > $@
X
X
%.o: %.cc
X	$(CXX) -g $(CXXFLAGS) -c $< -o $@
X
%.o: %.cpp
X	$(CXX) -g $(CXXFLAGS) -c $< -o $@
X
X
XXGobiCorbaServer.o: XGobiCorbaServer.cpp XGobiCorbaServer.h
X
X
X
X.PRECIOUS:	Corba.cc Corba.h
X
Corba.tar.gz:
X	tar zcvf $@ GNUmakefile Imakefile Corba.nw XGobiCorbaServer.idl XGobiServer.h xgobi.c xgobitop.h xgobitypes.h xincludes.h
X
X
TAGS: $(shell ls *.[ch])
X	etags *.[ch]
X
irfeed:
X	irfeed -I${OMEGA_HOME}/Interfaces/CORBA/IDLTypes XGobiCorbaServer.idl
X
SHAR_EOF
  chmod 0644 'xgobi/src/Makefile.corba' ||
  $echo 'restore of' 'xgobi/src/Makefile.corba' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/Makefile.corba:' 'MD5 check failed'
3126734efe73563a64774607cb0cb7d4  xgobi/src/Makefile.corba
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/Makefile.corba'`"
    test 2266 -eq "$shar_count" ||
    $echo 'xgobi/src/Makefile.corba:' 'original size' '2266,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/xgv_help.c ==============
if test -f 'xgobi/src/xgv_help.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/xgv_help.c' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/xgv_help.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/xgv_help.c' &&
#include <stdlib.h>
#include <stdio.h>
#include "xincludes.h"
#include "xgobitypes.h"
#include "xgobivars.h"
#include "xgobiexterns.h"
#include "xgvis.h"
X
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
X
/* bitmaps: */
#include "../bitmaps/stress_kruskal_shepard.xbm"
#include "../bitmaps/strain_torgerson_gower.xbm"
X
X
/* ARGSUSED */
XXtCallbackProc
xgvis_help_done_cback(Widget w, XtPointer client_data, XtPointer callback_data)
{
X  XtDestroyWidget(XtParent(XtParent(w)));
}
X
/* ARGSUSED */
XXtCallbackProc
xgvis_help_MDS_background_cback(Widget w, XtPointer client_data, XtPointer callback_data)
{
X  char fname[100];
X  char message[MSGLENGTH];
X  char *xgobidir;
X  FILE *fp;
X  extern xgobidata xgobi;  /* defined in xgvis.c */
X  Dimension width, height;
X
X  xgobidir = getenv("XGOBID");
X  if (xgobidir == NULL || strlen(xgobidir) == 0)
X  {
X    xgobidir = (char *) XtMalloc((Cardinal) 150 * sizeof(char));
X    (void) strcpy(xgobidir, DEFAULTDIR);
X    if (xgobidir == NULL || strlen(xgobidir) == 0)
X    {
X      sprintf(message,
X       "XGOBID is not defined in your environment, and\n");
X      strcat(message,
X       "DEFAULTDIR is not defined in the XGobi Makefile;\n");
X      strcat(message,
X        "see the person who installed XGobi for help.\n");
X      show_message(message, &xgobi);
X      return;
X    }
X    else
X    {
X      (void) strcpy(fname, xgobidir);
X      XtFree((XtPointer) xgobidir);
X    }
X  }
X  else
X  {
X    (void) strcpy(fname, xgobidir);
X  }
X
/*
X * Check that the file is good.
*/
X  (void) strcat(fname, "/help/xgvis_MDS_background");
X  if ((fp = fopen(fname, "r")) == NULL)
X  {
X    sprintf(message,
X      "Unable to open %s.\n", fname);
X    strcat(message,
X      "Is the shell variable XGOBID the name of the directory\n");
X    strcat(message,
X      "which contains the help subdirectory? \n");
X    show_message(message, &xgobi);
X    return((XtCallbackProc) 0);
X  }
X  else {
X    Widget hpopup, hframe, htext, hdone;
X
X    /* 80 columns x 20 rows, I hope */
X    width = 45 * XTextWidth(appdata.helpFont, "M", 1) ;
X    height = 30 * FONTHEIGHT(appdata.helpFont);
X
X  /*
X   * Create the popup itself.
X  */
X    hpopup = XtVaCreatePopupShell("Help",
X      topLevelShellWidgetClass, shell,
X      XtNtitle, (String) "XGvis Help Window",
X      XtNiconName, (String) "XGvis Help Window",
X      NULL);
X    if (mono) set_mono(hpopup);
X  /*
X   * Create the paned widget.
X  */
X    hframe = XtVaCreateManagedWidget("Form",
X      panedWidgetClass, hpopup,
X      XtNorientation, (XtOrientation) XtorientVertical,
X      NULL);
X    if (mono) set_mono(hframe);
X
X  /*
X   * Create the text widget.
X  */
X    htext = XtVaCreateManagedWidget("Text",
X      asciiTextWidgetClass, hframe,
X      XtNscrollVertical, (XawTextScrollMode) XawtextScrollAlways,
X      XtNallowResize, (Boolean) True,
X      XtNshowGrip, (Boolean) False,
X      XtNtype, (XawAsciiType) XawAsciiFile,
X      XtNstring, (String) fname,
X      XtNdisplayCaret, (Boolean) False,
X      XtNfont, (XFontStruct *) appdata.helpFont,
X      XtNheight, (Dimension) height,
X      XtNwidth, (Dimension) width,
X      NULL);
X    if (mono) set_mono(htext);
X
X  /*
X   * Create the Done button.
X  */
X    hdone = XtVaCreateManagedWidget("Done",
X      commandWidgetClass, hframe,
X      XtNshowGrip, (Boolean) False,
X      XtNskipAdjust, (Boolean) True,
X      XtNlabel, (String) "Click here to dismiss",
X      NULL);
X    if (mono) set_mono(hdone);
X
X    XtAddCallback(hdone, XtNcallback,
X      (XtCallbackProc) xgvis_help_done_cback, (XtPointer) NULL);
X
X    XtPopup(hpopup, XtGrabNone);
X    XRaiseWindow(display, XtWindow(hpopup));
X
X    set_wm_protocols(hpopup);
X
X    fclose(fp);
X  }
}
X
X
/* ARGSUSED */
XXtCallbackProc
xgvis_help_controls_cback(Widget w, XtPointer client_data, XtPointer callback_data)
{
X  char fname[100];
X  char message[MSGLENGTH];
X  char *xgobidir;
X  FILE *fp;
X  extern xgobidata xgobi;  /* defined in xgvis.c */
X  Dimension width, height;
X
X  xgobidir = getenv("XGOBID");
X  if (xgobidir == NULL || strlen(xgobidir) == 0)
X  {
X    xgobidir = (char *) XtMalloc((Cardinal) 150 * sizeof(char));
X    (void) strcpy(xgobidir, DEFAULTDIR);
X    if (xgobidir == NULL || strlen(xgobidir) == 0)
X    {
X      sprintf(message,
X       "XGOBID is not defined in your environment, and\n");
X      strcat(message,
X       "DEFAULTDIR is not defined in the XGobi Makefile;\n");
X      strcat(message,
X        "see the person who installed XGobi for help.\n");
X      show_message(message, &xgobi);
X      return;
X    }
X    else
X    {
X      (void) strcpy(fname, xgobidir);
X      XtFree((XtPointer) xgobidir);
X    }
X  }
X  else
X  {
X    (void) strcpy(fname, xgobidir);
X  }
X
/*
X * Check that the file is good.
*/
X  (void) strcat(fname, "/help/xgvis_controls");
X  if ((fp = fopen(fname, "r")) == NULL)
X  {
X    sprintf(message,
X      "Unable to open %s.\n", fname);
X    strcat(message,
X      "Is the shell variable XGOBID the name of the directory\n");
X    strcat(message,
X      "which contains the help subdirectory? \n");
X    show_message(message, &xgobi);
X    return((XtCallbackProc) 0);
X  }
X  else {
X    Widget hpopup, hframe, hform, hfunc, htext, hdone;
X
X    /* 80 columns x 20 rows, I hope */
X    width = 45 * XTextWidth(appdata.helpFont, "M", 1) ;
X    height = 30 * FONTHEIGHT(appdata.helpFont);
X
X  /*
X   * Create the popup itself.
X  */
X    hpopup = XtVaCreatePopupShell("Help",
X      topLevelShellWidgetClass, shell,
X      XtNtitle, (String) "XGvis Help Window",
X      XtNiconName, (String) "XGvis Help Window",
X      NULL);
X    if (mono) set_mono(hpopup);
X  /*
X   * Create the paned widget.
X  */
X    hframe = XtVaCreateManagedWidget("Form",
X      panedWidgetClass, hpopup,
X      XtNorientation, (XtOrientation) XtorientVertical,
X      NULL);
X    if (mono) set_mono(hframe);
X
X  /*
X   * Create the text widget.
X  */
X    htext = XtVaCreateManagedWidget("Text",
X      asciiTextWidgetClass, hframe,
X      XtNscrollVertical, (XawTextScrollMode) XawtextScrollAlways,
X      XtNallowResize, (Boolean) True,
X      XtNshowGrip, (Boolean) False,
X      XtNtype, (XawAsciiType) XawAsciiFile,
X      XtNstring, (String) fname,
X      XtNdisplayCaret, (Boolean) False,
X      XtNfont, (XFontStruct *) appdata.helpFont,
X      XtNheight, (Dimension) height,
X      XtNwidth, (Dimension) width,
X      NULL);
X    if (mono) set_mono(htext);
X
X  /*
X   * Create the Done button.
X  */
X    hdone = XtVaCreateManagedWidget("Done",
X      commandWidgetClass, hframe,
X      XtNshowGrip, (Boolean) False,
X      XtNskipAdjust, (Boolean) True,
X      XtNlabel, (String) "Click here to dismiss",
X      NULL);
X    if (mono) set_mono(hdone);
X
X    XtAddCallback(hdone, XtNcallback,
X      (XtCallbackProc) xgvis_help_done_cback, (XtPointer) NULL);
X
X    XtPopup(hpopup, XtGrabNone);
X    XRaiseWindow(display, XtWindow(hpopup));
X
X    set_wm_protocols(hpopup);
X
X    fclose(fp);
X  }
}
X
X
/* ARGSUSED */
XXtCallbackProc
xgvis_help_torgerson_gower_cback(Widget w, XtPointer client_data, XtPointer callback_data)
{
X  char fname[100];
X  char message[MSGLENGTH];
X  char *xgobidir;
X  FILE *fp;
X  extern xgobidata xgobi;  /* defined in xgvis.c */
/*
X  Dimension height;
*/
X
X  xgobidir = getenv("XGOBID");
X  if (xgobidir == NULL || strlen(xgobidir) == 0)
X  {
X    xgobidir = (char *) XtMalloc((Cardinal) 150 * sizeof(char));
X    (void) strcpy(xgobidir, DEFAULTDIR);
X    if (xgobidir == NULL || strlen(xgobidir) == 0)
X    {
X      sprintf(message,
X       "XGOBID is not defined in your environment, and\n");
X      strcat(message,
X       "DEFAULTDIR is not defined in the XGobi Makefile;\n");
X      strcat(message,
X        "see the person who installed XGobi for help.\n");
X      show_message(message, &xgobi);
X      return;
X    }
X    else
X    {
X      (void) strcpy(fname, xgobidir);
X      XtFree((XtPointer) xgobidir);
X    }
X  }
X  else
X  {
X    (void) strcpy(fname, xgobidir);
X  }
X
/*
X * Check that the file is good.
*/
X  (void) strcat(fname, "/bitmaps/strain_torgerson_gower.xbm");
X  if ((fp = fopen(fname, "r")) == NULL)
X  {
X    sprintf(message,
X      "Unable to open %s.\n", fname);
X    strcat(message,
X      "Is the shell variable XGOBID the name of the directory\n");
X    strcat(message,
X      "which contains the help subdirectory? \n");
X    show_message(message, &xgobi);
X    return((XtCallbackProc) 0);
X  }
X  else {
X    Widget hpopup, hframe, hform, hfunc, hdone;
X    Screen *scrn;
X    Pixmap func_pix;
X    Pixel funcfg, funcbg;
X
X    /*
X     * Read in the bitmap of the function.
X    */
X    scrn = XtScreen(shell);
X    funcbg = WhitePixelOfScreen(scrn);
X    funcfg = BlackPixelOfScreen(scrn);
X
X    func_pix = XCreatePixmapFromBitmapData(display,
X      RootWindowOfScreen(scrn),
X      strain_torgerson_gower_bits, 
X      strain_torgerson_gower_width, 
X      strain_torgerson_gower_height,
X      funcfg, funcbg,
X      depth);
X
X    /* 80 columns x 20 rows, I hope */
X    /* width = 85 * XTextWidth(appdata.helpFont, "M", 1) ; */
/*
X    height = 20 * FONTHEIGHT(appdata.helpFont);
*/
X
X  /*
X   * Create the popup itself.
X  */
X    hpopup = XtVaCreatePopupShell("Help",
X      topLevelShellWidgetClass, shell,
X      XtNtitle, (String) "XGvis Help Window",
X      XtNiconName, (String) "XGvis Help Window",
X      NULL);
X    if (mono) set_mono(hpopup);
X  /*
X   * Create the paned widget.
X  */
X    hframe = XtVaCreateManagedWidget("Form",
X      panedWidgetClass, hpopup,
X      XtNorientation, (XtOrientation) XtorientVertical,
X      NULL);
X    if (mono) set_mono(hframe);
X
X  /*
X   * Create a form widget to hold the label and text.
X  */
X    hform = XtVaCreateManagedWidget("Help",
X      formWidgetClass, hframe,
X      XtNbackground, funcbg,
X      NULL);
X
X    hfunc = XtVaCreateManagedWidget("Help",
X      labelWidgetClass, hform,
X      XtNinternalHeight, (Dimension) 0,
X      XtNinternalWidth, (Dimension) 0,
X      /* --------- bitmap goes here ---------------- */
X      XtNbitmap, (Pixmap) func_pix,
X      XtNborderWidth, 0,
X      NULL);
X
X  /*
X   * Create the Done button.
X  */
X    hdone = XtVaCreateManagedWidget("Done",
X      commandWidgetClass, hframe,
X      XtNshowGrip, (Boolean) False,
X      XtNskipAdjust, (Boolean) True,
X      XtNlabel, (String) "Click here to dismiss",
X      NULL);
X    if (mono) set_mono(hdone);
X
X    XtAddCallback(hdone, XtNcallback,
X      (XtCallbackProc) xgvis_help_done_cback, (XtPointer) NULL);
X
X    XtPopup(hpopup, XtGrabNone);
X    XRaiseWindow(display, XtWindow(hpopup));
X
X    set_wm_protocols(hpopup);
X
X    fclose(fp);
X  }
}
X
X
/* ARGSUSED */
XXtCallbackProc
xgvis_help_kruskal_shepard_cback(Widget w, XtPointer client_data, XtPointer callback_data)
{
X  char fname[100];
X  char message[MSGLENGTH];
X  char *xgobidir;
X  FILE *fp;
X  extern xgobidata xgobi;  /* defined in xgvis.c */
/*
X  Dimension height;
*/
X
X  xgobidir = getenv("XGOBID");
X  if (xgobidir == NULL || strlen(xgobidir) == 0)
X  {
X    xgobidir = (char *) XtMalloc((Cardinal) 150 * sizeof(char));
X    (void) strcpy(xgobidir, DEFAULTDIR);
X    if (xgobidir == NULL || strlen(xgobidir) == 0)
X    {
X      sprintf(message,
X       "XGOBID is not defined in your environment, and\n");
X      strcat(message,
X       "DEFAULTDIR is not defined in the XGobi Makefile;\n");
X      strcat(message,
X        "see the person who installed XGobi for help.\n");
X      show_message(message, &xgobi);
X      return;
X    }
X    else
X    {
X      (void) strcpy(fname, xgobidir);
X      XtFree((XtPointer) xgobidir);
X    }
X  }
X  else
X  {
X    (void) strcpy(fname, xgobidir);
X  }
X
/*
X * Check that the file is good.
*/
X  (void) strcat(fname, "/bitmaps/stress_kruskal_shepard.xbm");
X  if ((fp = fopen(fname, "r")) == NULL)
X  {
X    sprintf(message,
X      "Unable to open %s.\n", fname);
X    strcat(message,
X      "Is the shell variable XGOBID the name of the directory\n");
X    strcat(message,
X      "which contains the help subdirectory? \n");
X    show_message(message, &xgobi);
X    return((XtCallbackProc) 0);
X  }
X  else {
X    Widget hpopup, hframe, hform, hfunc, hdone;
X    Screen *scrn;
X    Pixmap func_pix;
X    Pixel funcfg, funcbg;
X
X    /*
X     * Read in the bitmap of the function.
X    */
X    scrn = XtScreen(shell);
X    funcbg = WhitePixelOfScreen(scrn);
X    funcfg = BlackPixelOfScreen(scrn);
X
X    func_pix = XCreatePixmapFromBitmapData(display,
X      RootWindowOfScreen(scrn),
X      stress_kruskal_shepard_bits, 
X      stress_kruskal_shepard_width, 
X      stress_kruskal_shepard_height,
X      funcfg, funcbg,
X      depth);
X
X    /* 80 columns x 20 rows, I hope */
X    /* width = 85 * XTextWidth(appdata.helpFont, "M", 1) ; */
/*
X    height = 20 * FONTHEIGHT(appdata.helpFont);
*/
X
X  /*
X   * Create the popup itself.
X  */
X    hpopup = XtVaCreatePopupShell("Help",
X      topLevelShellWidgetClass, shell,
X      XtNtitle, (String) "XGvis Help Window",
X      XtNiconName, (String) "XGvis Help Window",
X      NULL);
X    if (mono) set_mono(hpopup);
X  /*
X   * Create the paned widget.
X  */
X    hframe = XtVaCreateManagedWidget("Form",
X      panedWidgetClass, hpopup,
X      XtNorientation, (XtOrientation) XtorientVertical,
X      NULL);
X    if (mono) set_mono(hframe);
X
X  /*
X   * Create a form widget to hold the label and text.
X  */
X    hform = XtVaCreateManagedWidget("Help",
X      formWidgetClass, hframe,
X      XtNbackground, funcbg,
X      NULL);
X
X    hfunc = XtVaCreateManagedWidget("Help",
X      labelWidgetClass, hform,
X      XtNinternalHeight, (Dimension) 0,
X      XtNinternalWidth, (Dimension) 0,
X      /* --------- bitmap goes here ---------------- */
X      XtNbitmap, (Pixmap) func_pix,
X      XtNborderWidth, 0,
X      NULL);
X
X  /*
X   * Create the Done button.
X  */
X    hdone = XtVaCreateManagedWidget("Done",
X      commandWidgetClass, hframe,
X      XtNshowGrip, (Boolean) False,
X      XtNskipAdjust, (Boolean) True,
X      XtNlabel, (String) "Click here to dismiss",
X      NULL);
X    if (mono) set_mono(hdone);
X
X    XtAddCallback(hdone, XtNcallback,
X      (XtCallbackProc) xgvis_help_done_cback, (XtPointer) NULL);
X
X    XtPopup(hpopup, XtGrabNone);
X    XRaiseWindow(display, XtWindow(hpopup));
X
X    set_wm_protocols(hpopup);
X
X    fclose(fp);
X  }
}
X
X
/* ARGSUSED */
XXtCallbackProc
xgvis_help_input_file_formats_cback(Widget w, XtPointer client_data, XtPointer callback_data)
{
X  char fname[100];
X  char message[MSGLENGTH];
X  char *xgobidir;
X  FILE *fp;
X  extern xgobidata xgobi;  /* defined in xgvis.c */
X  Dimension width, height;
X
X  xgobidir = getenv("XGOBID");
X  if (xgobidir == NULL || strlen(xgobidir) == 0)
X  {
X    xgobidir = (char *) XtMalloc((Cardinal) 150 * sizeof(char));
X    (void) strcpy(xgobidir, DEFAULTDIR);
X    if (xgobidir == NULL || strlen(xgobidir) == 0)
X    {
X      sprintf(message,
X       "XGOBID is not defined in your environment, and\n");
X      strcat(message,
X       "DEFAULTDIR is not defined in the XGobi Makefile;\n");
X      strcat(message,
X        "see the person who installed XGobi for help.\n");
X      show_message(message, &xgobi);
X      return;
X    }
X    else
X    {
X      (void) strcpy(fname, xgobidir);
X      XtFree((XtPointer) xgobidir);
X    }
X  }
X  else
X  {
X    (void) strcpy(fname, xgobidir);
X  }
X
/*
X * Check that the file is good.
*/
X  (void) strcat(fname, "/help/xgvis_input_file_formats");
X  if ((fp = fopen(fname, "r")) == NULL)
X  {
X    sprintf(message,
X      "Unable to open %s.\n", fname);
X    strcat(message,
X      "Is the shell variable XGOBID the name of the directory\n");
X    strcat(message,
X      "which contains the help subdirectory? \n");
X    show_message(message, &xgobi);
X    return((XtCallbackProc) 0);
X  }
X  else {
X    Widget hpopup, hframe, htext, hdone;
X
X    /* 80 columns x 20 rows, I hope */
X    width = 45 * XTextWidth(appdata.helpFont, "M", 1) ;
X    height = 30 * FONTHEIGHT(appdata.helpFont);
X
X  /*
X   * Create the popup itself.
X  */
X    hpopup = XtVaCreatePopupShell("Help",
X      topLevelShellWidgetClass, shell,
X      XtNtitle, (String) "XGvis Help Window",
X      XtNiconName, (String) "XGvis Help Window",
X      NULL);
X    if (mono) set_mono(hpopup);
X  /*
X   * Create the paned widget.
X  */
X    hframe = XtVaCreateManagedWidget("Form",
X      panedWidgetClass, hpopup,
X      XtNorientation, (XtOrientation) XtorientVertical,
X      NULL);
X    if (mono) set_mono(hframe);
X
X  /*
X   * Create the text widget.
X  */
X    htext = XtVaCreateManagedWidget("Text",
X      asciiTextWidgetClass, hframe,
X      XtNscrollVertical, (XawTextScrollMode) XawtextScrollAlways,
X      XtNallowResize, (Boolean) True,
X      XtNshowGrip, (Boolean) False,
X      XtNtype, (XawAsciiType) XawAsciiFile,
X      XtNstring, (String) fname,
X      XtNdisplayCaret, (Boolean) False,
X      XtNfont, (XFontStruct *) appdata.helpFont,
X      XtNheight, (Dimension) height,
X      XtNwidth, (Dimension) width,
X      NULL);
X    if (mono) set_mono(htext);
X
X  /*
X   * Create the Done button.
X  */
X    hdone = XtVaCreateManagedWidget("Done",
X      commandWidgetClass, hframe,
X      XtNshowGrip, (Boolean) False,
X      XtNskipAdjust, (Boolean) True,
X      XtNlabel, (String) "Click here to dismiss",
X      NULL);
X    if (mono) set_mono(hdone);
X
X    XtAddCallback(hdone, XtNcallback,
X      (XtCallbackProc) xgvis_help_done_cback, (XtPointer) NULL);
X
X    XtPopup(hpopup, XtGrabNone);
X    XRaiseWindow(display, XtWindow(hpopup));
X
X    set_wm_protocols(hpopup);
X
X    fclose(fp);
X  }
}
X
X
SHAR_EOF
  chmod 0644 'xgobi/src/xgv_help.c' ||
  $echo 'restore of' 'xgobi/src/xgv_help.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/xgv_help.c:' 'MD5 check failed'
8701d6b5bd522a49c6c5919eac21eaaa  xgobi/src/xgv_help.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/xgv_help.c'`"
    test 17037 -eq "$shar_count" ||
    $echo 'xgobi/src/xgv_help.c:' 'original size' '17037,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/subset.c ==============
if test -f 'xgobi/src/subset.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/subset.c' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/subset.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/subset.c' &&
/* subset.c */
/************************************************************
X *                                                          *
X *  Permission is hereby granted  to  any  individual   or  *
X *  institution   for  use,  copying, or redistribution of  *
X *  the xgobi code and associated documentation,  provided  *
X *  that   such  code  and documentation are not sold  for  *
X *  profit and the  following copyright notice is retained  *
X *  in the code and documentation:                          *
X *        Copyright (c) 1990, ..., 1996 Bellcore            *
X *                                                          *
X *  We welcome your questions and comments, and request     *
X *  that you share any modifications with us.               *
X *                                                          *
X *    Deborah F. Swayne            Dianne Cook              *
X *   dfs@research.att.com       dicook@iastate.edu          *
X *      (973) 360-8423    www.public.iastate.edu/~dicook/   *
X *                                                          *
X *                    Andreas Buja                          *
X *                andreas@research.att.com                  *
X *              www.research.att.com/~andreas/              *
X *                                                          *
X ************************************************************/
X
/*
X * November 5, 1999: Modifying to use nlinkable instead of
X * nrows.  The rows beyond nlinkable will not now be sampled;
X * however, they will all be included in each sample.
X *
X * Also, modifying to sample rgroup_ids when rgroups are
X * being used.
*/
X
X
/*************************************************************
X * Modified by James Brook, Oct 1994
X * British Telecommunications Labs, UK, jamesb@aom.bt.co.uk
X * Want to add another option to the subsetting panel, to
X * choose all rows with a particular identifier.
X ************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <float.h>
#include <math.h>
#include "xincludes.h"
#include "xgobitypes.h"
#include "xgobivars.h"
#include "xgobiexterns.h"
X
#include "../bitmaps/rightarrow20.xbm"
#include "../bitmaps/leftarrow20.xbm"
X
static Widget spopup;
static Widget from_text, to_text;
static char *from_str, *blocksize_str;
static Widget sample_text;
static char *sample_str;
static Widget everyn_text, everyn_init_text;
static char *everyn_str, *everyn_init_str;
X
/*************************************************************
X * Added by James Brook, Oct 1994
X ************************************************************/
static Widget id_label, id_text;
static char *id_str;
/************************************************************/
X
static Widget apply, restore, close;
static Boolean rescale = False;
X
#define NSTYPEBTNS 5
#define BLOCK  0
#define SAMPLE 1
#define EVERYN 2
#define STICKY 3
#define ROWID  4
static int subset_type = SAMPLE;
/*****/
static Widget stype_menu_cmd, stype_menu, stype_menu_btn[NSTYPEBTNS];
static Widget stype_menu_box, stype_menu_lab;
static char *stype_menu_str = "Subsetting method:";
static char *stype_menu_name[] = {
X  "Consecutive block",
X  "Random sample without replacement",
X  "Every nth case",
X  "Cases with row label == one of the current sticky labels",
X  "Cases with the specified row label",
};
static char *stype_menu_nickname[] = {
X  "Consecutive block",
X  "Random sample",
X  "Every nth case",
X  "Sticky labels",
X  "Specified cases",
};
X
static Widget stype_box[NSTYPEBTNS];
X
static void
clear_subset(xgobidata *xg) {
X  int i, rgid;
X
X  xg->nrows_in_plot = 0;
X
X  for (i=0; i<xg->nlinkable; i++)
X    xg->erased[i] = 1;
X
X  if (xg->nrgroups > 0) {
X    rgid = xg->rgroup_ids[i];
X    xg->rgroups[rgid].excluded = True;
X  }
}
X
static void
add_to_subset(int i, xgobidata *xg) {
X
X  if (xg->nrgroups > 0) {
X    int j, el;
X
X    xg->rgroups[i].excluded = False;
X    for (j=0; j<xg->rgroups[i].nels; j++) {
X      el = xg->rgroups[i].els[j];
X      xg->erased[el] = 0;
X      xg->rows_in_plot[xg->nrows_in_plot++] = el;
X    }
X
X  } else {
X    xg->erased[i] = 0;
X    xg->rows_in_plot[xg->nrows_in_plot++] = i;
X  }
}
X
/* ARGSUSED */
static XtCallbackProc
rescale_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  rescale = !rescale;
X  setToggleBitmap(w, rescale);
}
X
/*
X * This algorithm taken from Knuth, Seminumerical Algorithms;
X * Vol 2 of his series.
*/
int
sample_xgobi(int n, xgobidata *xg) {
X  int t, m;
X  int doneit = 0;
X  float rrand;
X
/*
X * dfs 5 November 99, replacing nrows with nlinkable,
X * enabling rgroups subsetting
*/
X
X  int top = (xg->nrgroups > 0) ? xg->nrgroups : xg->nlinkable;
X
X  if (n > 0 && n < top) {
X
X    for (t=0, m=0; t<top && m<n; t++)
X    {
X      rrand = (float) randvalue();
X      if ( ((top - t) * rrand) < (n - m) ) {
X        add_to_subset(t, xg);
X        m++;
X      }
X    }
X
X    doneit = 1;
X  }
X  return(doneit);
}
X
/* ARGSUSED */
XXtCallbackProc
ahead_block_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  int from_n, bsize;
X  char str[32];
X  int top = (xg->nrgroups > 0) ? xg->nrgroups : xg->nlinkable;
X
X  XtVaGetValues(from_text, XtNstring, (String) &from_str, NULL);
X  XtVaGetValues(to_text, XtNstring, (String) &blocksize_str, NULL);
X
X  from_n = atoi(from_str);
X  bsize = atoi(blocksize_str);
X
X  from_n += bsize/2;
X  from_n = MIN(from_n, top-2);
X
X  sprintf(str, "%d", from_n);
X  XtVaSetValues(from_text, XtNstring, str, NULL);
X  sprintf(str, "%d", bsize);
X  XtVaSetValues(to_text, XtNstring, str, NULL);
X
X  XtCallCallbacks(apply, XtNcallback, (XtPointer) xg);
}
/* ARGSUSED */
XXtCallbackProc
back_block_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  int from_n, bsize;
X  char str[32];
X
X  XtVaGetValues(from_text, XtNstring, (String) &from_str, NULL);
X  XtVaGetValues(to_text, XtNstring, (String) &blocksize_str, NULL);
X
X  from_n = atoi(from_str);
X  bsize = atoi(blocksize_str);
X  
X  from_n -= bsize/2;
X  if (from_n < 1) from_n = 1;
X
X  sprintf(str, "%d", from_n);
X  XtVaSetValues(from_text, XtNstring, str, NULL);
X  sprintf(str, "%d", bsize);
X  XtVaSetValues(to_text, XtNstring, str, NULL);
X
X  XtCallCallbacks(apply, XtNcallback, (XtPointer) xg);
}
X
/* ARGSUSED */
XXtCallbackProc
subset_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  int i, j, k;
X  int doneit = 0;
X  int from_n, to_n;
X  int sample_size;
X  int everyn_n, everyn_init;
X
X  /*int prev_nrows_in_plot = xg->nrows_in_plot;*/
X  int top = (xg->nrgroups > 0) ? xg->nrgroups : xg->nlinkable;
X
X  switch (subset_type) {
X
X    case BLOCK:
X      XtVaGetValues(from_text, XtNstring, (String) &from_str, NULL);
X      XtVaGetValues(to_text, XtNstring, (String) &blocksize_str, NULL);
X
X      from_n = atoi(from_str);
X      to_n = from_n + atoi(blocksize_str) - 1;
X      to_n = (to_n >= top) ? top-1 : to_n;
X
X      if (to_n > 0 && to_n <= top &&
X          from_n > 0 && from_n < top &&
X          from_n < to_n)
X      {
X        clear_subset(xg);
X
X        for (i=(from_n - 1), k=0; i<to_n; i++, k++)
X          add_to_subset(i, xg);
X
X        xg->delete_erased_pts = True;
X        doneit = 1;
X      }
X      else {
X        char message[MSGLENGTH];
X        sprintf(message, "The limits aren't correctly specified.\n");
X        show_message(message, xg);
X      }
X      break;
X
X    case SAMPLE:
X
X      XtVaGetValues(sample_text, XtNstring, (String) &sample_str, NULL);
X      sample_size = atoi(sample_str);
X      if (sample_size > 0) {
X        clear_subset(xg);
X        doneit = sample_xgobi(sample_size, xg);
X      }
X      break;
X
X    case EVERYN:
X      XtVaGetValues(everyn_text, XtNstring, (String) &everyn_str, NULL);
X      everyn_n = atoi(everyn_str);
X
X      XtVaGetValues(everyn_init_text,
X        XtNstring, (String) &everyn_init_str, NULL);
X      everyn_init = atoi(everyn_init_str);
X
X      if (everyn_n > 0 && everyn_n < top &&
X        everyn_init > 0 && everyn_init < (top-1) )
X      {
X        clear_subset(xg);
X
X        for (i=(everyn_init-1), k=0; i<top; i=i+everyn_n, k++)
X          add_to_subset(i, xg);
X
X        doneit = 1;
X      }
X      else
X      {
X        char message[MSGLENGTH];
X        sprintf(message, "Interval 'n' not correctly specified.\n");
X        show_message(message, xg);
X      }
X      break;
X
X    case STICKY:
X
X      /*************************************************************
X       * Added by James Brook, Oct 1994
X       ************************************************************/
X
X      clear_subset(xg);
X
X      for (i=0; i<xg->nlinkable; i++) {
X        for (j=0; j<xg->nsticky_ids; j++) {
X          if (!strcmp(xg->rowlab[i], xg->rowlab[xg->sticky_ids[j]])) {
X
X            if (xg->nrgroups > 0)
X              add_to_subset(xg->rgroup_ids[i], xg);
X            else
X              add_to_subset(i, xg);
X
X            break;
X          }
X        }
X      }
X
X      xg->delete_erased_pts = True;
X      doneit = 1;
X      break;
X
X    case ROWID:
X
X      /***************************************************************
X       * Could use the same format as the others, i.e. loop over rows 
X       * setting them erased then unerasing the ones we want, but it
X       * seems quicker this way
X       ***************************************************************/
X
X      XtVaGetValues(id_text, XtNstring, (String) &id_str, NULL);
X
X      clear_subset(xg);
X
X      for (i=0; i<xg->nlinkable; i++) {
X        if (!strcmp(xg->rowlab[i], id_str)) {
X          if (xg->nrgroups > 0)
X            add_to_subset(xg->rgroup_ids[i], xg);
X          else
X            add_to_subset(i, xg);
X        }
X      }
X
X      xg->delete_erased_pts = True;
X      doneit = 1;
X  /************************************************************/
X  }
X
X  if (doneit)
X  {
X    /* add all the unlinkable guys to the sample */
X    for (i=xg->nlinkable; i<xg->nrows; i++) {
X      xg->rows_in_plot[xg->nrows_in_plot++] = i;
X    }
X
X    update_nrgroups_in_plot(xg);
X    reset_rows_in_plot(xg, rescale);
X
X    copy_brushinfo_to_senddata(xg);
X    assign_points_to_bins(xg);
X    plot_once(xg);
X
X    if (xg->is_cprof_plotting && xg->link_cprof_plotting)
X      passive_update_cprof_plot(xg);
X  }
}
X
/* ARGSUSED */
XXtCallbackProc
restore_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  int i;
X
X  for (i=0; i<xg->nrows; i++)
X  {
X    xg->erased[i] = 0;
X    xg->rows_in_plot[i] = i;
X  }
X  xg->nrows_in_plot = xg->nrows;
X
X  update_nrgroups_in_plot(xg);
X  reset_rows_in_plot(xg, rescale);
X
X  copy_brushinfo_to_senddata(xg);
X  assign_points_to_bins(xg);
X  plot_once(xg);
X
X  if (xg->is_cprof_plotting && xg->link_cprof_plotting)
X    passive_update_cprof_plot(xg);
}
X
/* ARGSUSED */
static XtCallbackProc
close_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  XtPopdown(spopup);
}
X
/* ARGSUSED */     
static XtCallbackProc
stype_menu_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  int btn;      
X
X  if (subset_type != STICKY)
X    XtUnmapWidget(stype_box[subset_type]);
X
X  for (btn=0; btn<NSTYPEBTNS; btn++)
X    if (stype_menu_btn[btn] == w)
X      break;
X
X  XtVaSetValues(stype_menu_cmd,
X    XtNlabel, stype_menu_nickname[btn],
X    NULL);
X  subset_type = btn;
X
X  if (subset_type != STICKY)
X    XtMapWidget(stype_box[subset_type]);
}
X
X
/* ARGSUSED */
XXtCallbackProc
subset_panel_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  Widget sframe, sform, paramform;
X  Widget sample_label;
X  Widget rescale_cmd;
X  Widget from_label, to_label;
X  Widget aheadw, backw;
X  Widget everyn_label;
X  Widget everyn_init_label;
X  Dimension width, height;
X  Position x, y;
X  static int initd = 0;
X  int k;
X
X  if (!initd)
X  {
X    Pixmap rightarr20, leftarr20;
X    rightarr20 = XCreatePixmapFromBitmapData(display,
X      DefaultRootWindow(display),
X      (char *) rightarrow20_bits, rightarrow20_width, rightarrow20_height,
X      appdata.fg, appdata.bg, depth);
X    leftarr20 = XCreatePixmapFromBitmapData(display,
X      DefaultRootWindow(display),
X      (char *) leftarrow20_bits, leftarrow20_width, leftarrow20_height,
X      appdata.fg, appdata.bg, depth);
X
X    from_str = (char *) XtMalloc((Cardinal) 20 * sizeof(char));
X    blocksize_str = (char *) XtMalloc((Cardinal) 20 * sizeof(char));
X    everyn_str = (char *) XtMalloc((Cardinal) 20 * sizeof(char));
X    everyn_init_str = (char *) XtMalloc((Cardinal) 20 * sizeof(char));
X    sample_str = (char *) XtMalloc((Cardinal) 20 * sizeof(char));
X    /*************************************************************
X     * Added by James Brook, Oct 1994
X     ************************************************************/
X    id_str = (char *) XtMalloc((Cardinal) 32 * sizeof(char));
X    /*****************************************************************/
X    
X    (void) sprintf(from_str, "1");
X    if (xg->nrgroups) {
X      (void) sprintf(blocksize_str, "%d", (int) (xg->nrgroups/5));
X      (void) sprintf(sample_str, "%d", xg->nrgroups);
X    } else {
X      (void) sprintf(blocksize_str, "%d", (int) (xg->nrows/10));
X      (void) sprintf(sample_str, "%d", xg->nrows_in_plot);
X    }
X    (void) sprintf(everyn_str, "1");
X    (void) sprintf(everyn_init_str, "1");
X    /*************************************************************
X     * Added by James Brook, Oct 1994
X     ************************************************************/
X    (void) sprintf(id_str, xg->rowlab[0]);
X    /*****************************************************************/
X
X    XtVaGetValues(xg->shell,
X      XtNwidth, &width,
X      XtNheight, &height, NULL);
X    XtTranslateCoords(xg->shell,
X      (Position) (width/2), (Position) (height/2), &x, &y);
X    /*
X     * Create the popup to solicit subsetting arguments.
X    */
X    spopup = XtVaCreatePopupShell("Form0",
X      /*transientShellWidgetClass, w,*/
X      topLevelShellWidgetClass, xg->shell,
X      XtNx, (Position) x,
X      XtNy, (Position) y,
X      XtNinput, (Boolean) True,
X      /*XtNallowShellResize, (Boolean) False,*/
X      XtNtitle, (String) "Subset data",
X      XtNiconName, (String) "Subset",
X      NULL);
X    if (mono) set_mono(spopup);
X
X    /*
X     * Create a paned widget so the 'Click here ...'
X     * can be all across the bottom.
X    */
X    sframe = XtVaCreateManagedWidget("Form",
X      panedWidgetClass, spopup,
X      XtNorientation, (XtOrientation) XtorientVertical,
X      NULL);
X
X    /*
X     * Create the form widget.
X    */
X    sform = XtVaCreateManagedWidget("Form",
X      formWidgetClass, sframe,
X      NULL);
X    if (mono) set_mono(sform);
X
X    paramform = XtVaCreateManagedWidget("Param",
X      formWidgetClass, sform,
X      NULL);
X    if (mono) set_mono(paramform);
X
X    build_labelled_menu(&stype_menu_box, &stype_menu_lab, stype_menu_str,
X      &stype_menu_cmd, &stype_menu, stype_menu_btn,
X      stype_menu_name, stype_menu_nickname,
X      NSTYPEBTNS, subset_type, paramform, NULL,
X      XtorientHorizontal, appdata.font, "Subset", xg);
X    for (k=0; k<NSTYPEBTNS; k++)
X      XtAddCallback(stype_menu_btn[k],  XtNcallback,
X        (XtCallbackProc) stype_menu_cback, (XtPointer) xg);
X
X    for (k=0; k<NSTYPEBTNS; k++) {
X      stype_box[k] = XtVaCreateManagedWidget("Subset",
X        boxWidgetClass, paramform,
X        XtNfromVert, stype_menu_box,
X        XtNmappedWhenManaged, (subset_type == k) ? True : False,
X        XtNorientation, (XtOrientation) XtorientHorizontal,
X        XtNleft, (XtEdgeType) XtChainLeft,
X        XtNright, (XtEdgeType) XtChainLeft,
X        XtNtop, (XtEdgeType) XtChainTop,
X        XtNbottom, (XtEdgeType) XtChainTop,
X        XtNhSpace, 1,
X        XtNvSpace, 1,
X        NULL);
X      if (mono) set_mono(stype_box[k]);
X    }
X
/* parameters for consecutive block subsetting */
X
X    backw = XtVaCreateManagedWidget("Icon",
X      commandWidgetClass, stype_box[BLOCK],
X      XtNinternalHeight, (Dimension) 0,
X      XtNinternalWidth, (Dimension) 0,
X      XtNborderColor, (Pixel) appdata.fg,
X      XtNbitmap, (Pixmap) leftarr20,
X      NULL);
X    XtAddCallback(backw, XtNcallback,
X      (XtCallbackProc) back_block_cback, (XtPointer) xg);
X
X    from_label = XtVaCreateManagedWidget("Subset",
X      labelWidgetClass, stype_box[BLOCK],
X      XtNfromHoriz, (Widget) backw,
X      XtNlabel, (String) "Initial row ",
X      XtNleft, (XtEdgeType) XtChainLeft,
X      XtNright, (XtEdgeType) XtChainLeft,
X      XtNtop, (XtEdgeType) XtChainTop,
X      XtNbottom, (XtEdgeType) XtChainTop,
X      NULL);
X    if (mono) set_mono(from_label);
X
X    from_text = XtVaCreateManagedWidget("Subset",
X      asciiTextWidgetClass, stype_box[BLOCK],
X      XtNfromHoriz, (Widget) from_label,
X      XtNleft, (XtEdgeType) XtChainLeft,
X      XtNright, (XtEdgeType) XtChainLeft,
X      XtNtop, (XtEdgeType) XtChainTop,
X      XtNbottom, (XtEdgeType) XtChainTop,
X      XtNresizable, (Boolean) True,
X      XtNeditType, (int) XawtextEdit,
X      XtNresize, (XawTextResizeMode) XawtextResizeWidth,
X      XtNstring, (String) from_str,
X      NULL);
X    if (mono) set_mono(from_text);
X
X    to_label = XtVaCreateManagedWidget("Subset",
X      labelWidgetClass, stype_box[BLOCK],
X      XtNfromHoriz, (Widget) from_text,
X      XtNlabel, (String) "Block size",
X      XtNleft, (XtEdgeType) XtChainLeft,
X      XtNright, (XtEdgeType) XtChainLeft,
X      XtNtop, (XtEdgeType) XtChainTop,
X      XtNbottom, (XtEdgeType) XtChainTop,
X      NULL);
X    if (mono) set_mono(to_label);
X
X    to_text = XtVaCreateManagedWidget("Subset",
X      asciiTextWidgetClass, stype_box[BLOCK],
X      XtNfromHoriz, (Widget) to_label,
X      XtNleft, (XtEdgeType) XtChainLeft,
X      XtNright, (XtEdgeType) XtChainLeft,
X      XtNtop, (XtEdgeType) XtChainTop,
X      XtNbottom, (XtEdgeType) XtChainTop,
X      XtNresizable, (Boolean) True,
X      XtNeditType, (int) XawtextEdit,
X      XtNresize, (XawTextResizeMode) XawtextResizeWidth,
X      XtNstring, (String) blocksize_str,
X      NULL);
X    if (mono) set_mono(to_text);
X
X    aheadw = XtVaCreateManagedWidget("Command",
X      commandWidgetClass, stype_box[BLOCK],
X      XtNfromHoriz, (Widget) to_text,
X      XtNinternalHeight, (Dimension) 0,
X      XtNinternalWidth, (Dimension) 0,
/*
X      XtNborderColor, (Pixel) appdata.fg,
*/
X      XtNbitmap, (Pixmap) rightarr20,
X      NULL);
X    XtAddCallback(aheadw, XtNcallback,
X      (XtCallbackProc) ahead_block_cback, (XtPointer) xg);
X
/* parameters for random sampling */
X
X    sample_label = XtVaCreateManagedWidget("Subset",
X      labelWidgetClass, stype_box[SAMPLE],
X      XtNlabel, (String) "Sample of size",
X      XtNleft, (XtEdgeType) XtChainLeft,
X      XtNright, (XtEdgeType) XtChainLeft,
X      XtNtop, (XtEdgeType) XtChainTop,
X      XtNbottom, (XtEdgeType) XtChainTop,
X      NULL);
X    if (mono) set_mono(sample_label);
X
X    sample_text = XtVaCreateManagedWidget("Subset",
X      asciiTextWidgetClass, stype_box[SAMPLE],
X      XtNfromHoriz, (Widget) sample_label,
X      XtNleft, (XtEdgeType) XtChainLeft,
X      XtNright, (XtEdgeType) XtChainRight,
X      XtNtop, (XtEdgeType) XtChainTop,
X      XtNbottom, (XtEdgeType) XtChainTop,
X      XtNresizable, (Boolean) True,
X      XtNeditType, (int) XawtextEdit,
X      XtNresize, (XawTextResizeMode) XawtextResizeWidth,
X      XtNstring, (String) sample_str,
X      NULL);
X    if (mono) set_mono(sample_text);
X
/* parameters for "every nth row" subsetting */
X
X    everyn_label = XtVaCreateManagedWidget("Subset",
X      labelWidgetClass, stype_box[EVERYN],
X      XtNlabel, (String) " n ",
X      XtNleft, (XtEdgeType) XtChainLeft,
X      XtNright, (XtEdgeType) XtChainLeft,
X      XtNtop, (XtEdgeType) XtChainTop,
X      XtNbottom, (XtEdgeType) XtChainTop,
X      NULL);
X    if (mono) set_mono(everyn_label);
X
X    everyn_text = XtVaCreateManagedWidget("Subset",
X      asciiTextWidgetClass, stype_box[EVERYN],
X      XtNfromHoriz, (Widget) everyn_label,
X      XtNleft, (XtEdgeType) XtChainLeft,
X      XtNright, (XtEdgeType) XtChainLeft,
X      XtNtop, (XtEdgeType) XtChainTop,
X      XtNbottom, (XtEdgeType) XtChainTop,
X      XtNresizable, (Boolean) True,
X      XtNeditType, (int) XawtextEdit,
X      XtNresize, (XawTextResizeMode) XawtextResizeWidth,
X      XtNstring, (String) everyn_str,
X      NULL);
X    if (mono) set_mono(everyn_text);
X
X    everyn_init_label = XtVaCreateManagedWidget("Subset",
X      labelWidgetClass, stype_box[EVERYN],
X      XtNfromHoriz, (Widget) everyn_text,
X      XtNlabel, (String) "starting with",
X      XtNleft, (XtEdgeType) XtChainLeft,
X      XtNright, (XtEdgeType) XtChainLeft,
X      XtNtop, (XtEdgeType) XtChainTop,
X      XtNbottom, (XtEdgeType) XtChainTop,
X      NULL);
X    if (mono) set_mono(everyn_init_label);
X
X    everyn_init_text = XtVaCreateManagedWidget("Subset",
X      asciiTextWidgetClass, stype_box[EVERYN],
X      XtNfromHoriz, (Widget) everyn_init_label,
X      XtNleft, (XtEdgeType) XtChainLeft,
X      XtNright, (XtEdgeType) XtChainRight,
X      XtNtop, (XtEdgeType) XtChainTop,
X      XtNbottom, (XtEdgeType) XtChainTop,
X      XtNresizable, (Boolean) True,
X      XtNeditType, (int) XawtextEdit,
X      XtNresize, (XawTextResizeMode) XawtextResizeWidth,
X      XtNstring, (String) everyn_init_str,
X      NULL);
X    if (mono) set_mono(everyn_init_text);
X
/* parameters for "use row id" subsetting */
X
X    id_label = XtVaCreateManagedWidget("Subset",
X      labelWidgetClass, stype_box[ROWID],
X      XtNlabel, (String) "Row id ",
X      XtNleft, (XtEdgeType) XtChainLeft,
X      XtNright, (XtEdgeType) XtChainLeft,
X      XtNtop, (XtEdgeType) XtChainTop,
X      XtNbottom, (XtEdgeType) XtChainTop,
X      NULL);
X    if (mono) set_mono(id_label);
X
X    id_text = XtVaCreateManagedWidget("Subset",
X      asciiTextWidgetClass, stype_box[ROWID],
X      XtNfromHoriz, (Widget) id_label,
X      XtNleft, (XtEdgeType) XtChainLeft,
X      XtNright, (XtEdgeType) XtChainRight,
X      XtNtop, (XtEdgeType) XtChainTop,
X      XtNbottom, (XtEdgeType) XtChainTop,
X      XtNresizable, (Boolean) True,
X      XtNeditType, (int) XawtextEdit,
X      XtNresize, (XawTextResizeMode) XawtextResizeWidth,
X      XtNstring, (String) id_str,
X      NULL);
X    if (mono) set_mono(id_text);
X
X    apply = (Widget) CreateCommand(xg, "Subset the data",
X      1, (Widget) NULL, (Widget) paramform,
X      sform, "Subset");
X    XtManageChild(apply);
X    XtAddCallback(apply, XtNcallback,
X      (XtCallbackProc) subset_cback, (XtPointer) xg);
X
X    rescale_cmd = (Widget) CreateToggle(xg, "Rescale", True,
X      apply, paramform, (Widget) NULL, rescale, ANY_OF_MANY,
X      sform, "SubsetRescale");
X    XtManageChild(rescale_cmd);
X    XtAddCallback(rescale_cmd, XtNcallback,
X      (XtCallbackProc) rescale_cback, (XtPointer) xg);
X
X    restore = (Widget) CreateCommand(xg, "Include all data",
X      True, (Widget) rescale_cmd, (Widget) paramform,
X      sform, "Subset");
X    XtManageChild(restore);
X    XtAddCallback(restore, XtNcallback,
X      (XtCallbackProc) restore_cback, (XtPointer) xg);
X
X    close = XtVaCreateManagedWidget("Close",
X      commandWidgetClass, sframe,
X      XtNshowGrip, (Boolean) False,
X      XtNskipAdjust, (Boolean) True,
X      XtNlabel, (String) "Click here to dismiss",
X      NULL);
X    if (mono) set_mono(close);
X    XtAddCallback(close, XtNcallback,
X      (XtCallbackProc) close_cback, (XtPointer) xg);
X  }
X
X  XtPopup(spopup, (XtGrabKind) XtGrabNone);
X  XRaiseWindow(display, XtWindow(spopup));
X
X  if (!initd)
X  {
X    set_wm_protocols(spopup);
X    initd = 1;
X  }
}
X
SHAR_EOF
  chmod 0644 'xgobi/src/subset.c' ||
  $echo 'restore of' 'xgobi/src/subset.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/subset.c:' 'MD5 check failed'
8858807946aa30be74da7f5e050c675f  xgobi/src/subset.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/subset.c'`"
    test 23020 -eq "$shar_count" ||
    $echo 'xgobi/src/subset.c:' 'original size' '23020,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/corr_index.c ==============
if test -f 'xgobi/src/corr_index.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/corr_index.c' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/corr_index.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/corr_index.c' &&
/* corr_index.c */
/************************************************************
X *                                                          *
X *  Permission is hereby granted  to  any  individual   or  *
X *  institution   for  use,  copying, or redistribution of  *
X *  this  code and associated documentation,  provided      *
X *  that   such  code  and documentation are not sold  for  *
X *  profit and the  following copyright notice is retained  *
X *  in the code and documentation:                          *
X *     Copyright (c) of code not pertaining to manual       *
X *     control is owned by Dianne Cook (1994, 1995).        *
X *     Copyright (c) of code pertaining to manual           *
X *     control of the correlation tour is owned jointly by  *
X *     Dianne Cook and AT&T Bell Labs (1995).               *
X *  All Rights Reserved.                                    *
X *                                                          *
X *  We welcome your questions and comments, and request     *
X *  that you share any modifications with us.               *
X *                                                          *
X *      Dianne Cook                Andreas Buja             *
X *    dicook@iastate.edu     andreas@research.att.com       *
X * www.public.iastate.edu/~dicook/                          *
X *                           www.research.att.com/~andreas/ *
X *                                                          *
X ************************************************************/
X
/*
X * The code in this file was written with a great deal of help
X * from Phil Jones, a graduate student at Iowa State University.
*/
X
#include <math.h>
#include <stdio.h>
#include "xincludes.h"
#include "xgobitypes.h"
#include "xgobivars.h"
#include "xgobiexterns.h"
X
static double xsum, ysum, xbar, ybar, xy, x2, y2,
X              *z1sum, *z2sum, *z1bar, *z2bar, *xz1, *xz2, *yz1, *yz2;
X
void
alloc_corr_index(xgobidata *xg)
{
X  /*  unsigned int px = (unsigned int) xg->ncorr_xvars;
X  unsigned int py = (unsigned int) xg->ncorr_yvars;*/
X  unsigned int px = (unsigned int) xg->ncols;
X  unsigned int py = (unsigned int) xg->ncols;
X  static int firsttime = 1;
X
X  if (firsttime == 1)
X  {
X    z1sum = (double *) XtMalloc(px * sizeof(double));
X    z2sum = (double *) XtMalloc(py * sizeof(double));
X    z1bar = (double *) XtMalloc(px * sizeof(double));
X    z2bar = (double *) XtMalloc(py * sizeof(double));
X    xz1 = (double *) XtMalloc(px * sizeof(double));
X    xz2 = (double *) XtMalloc(px * sizeof(double));
X    yz1 = (double *) XtMalloc(py * sizeof(double));
X    yz2 = (double *) XtMalloc(py * sizeof(double));
X  }
}
X
void
free_corr_index(xgobidata *xg)
{
X  if (z1sum != NULL)
X    XtFree((XtPointer) z1sum);
X  if (z2sum != NULL)
X    XtFree((XtPointer) z2sum);
X  if (z1bar != NULL)
X    XtFree((XtPointer) z1bar);
X  if (z2bar != NULL)
X    XtFree((XtPointer) z2bar);
X  if (xz1 != NULL)
X    XtFree((XtPointer) xz1);
X  if (xz2 != NULL)
X    XtFree((XtPointer) xz2);
X  if (yz1 != NULL)
X    XtFree((XtPointer) yz1);
X  XtFree((XtPointer) yz2);
}
X
/* Note get_corr_index returns the squared correlation coefficient
X   and associated derivatives.
*/
void
get_corr_index(xgobidata *xg, float *corr_index, float *didx, float *didy)
{
X  int i, j, m;
X  int p1 = xg->ncorr_xvars;
X  int p2 = xg->ncorr_yvars;
X  int nr = xg->nrows_in_plot;
X
X  xsum = ysum = xy = x2 = y2 = 0;
X  for (j=0; j<p1; j++)
X    z1sum[j] = xz1[j] = yz1[j] = 0;
X  for (j=0; j<p2; j++)
X    z2sum[j] = xz2[j] = yz2[j] = 0;
X
X  for (m=0; m<nr; m++)
X  {
X    i = xg->rows_in_plot[m];
X    xsum += xg->planar[i].x;
X    ysum += xg->planar[i].y;
X    for (j=0; j<p1; j++)
X      z1sum[j] += xg->world_data[i][xg->corr_xvars[j]];
X    for (j=0; j<p2; j++)
X      z2sum[j] += xg->world_data[i][xg->corr_yvars[j]];
X  }
X
X  xbar = xsum/nr;
X  ybar = ysum/nr;
X  for (j=0; j<p1; j++)
X    z1bar[j] = z1sum[j]/nr;
X  for (j=0; j<p2; j++)
X    z2bar[j] = z2sum[j]/nr;
X
X  for (m=0; m<nr; m++)
X  {
X    i = xg->rows_in_plot[m];
X    xy += (xg->planar[i].x - xbar)*(xg->planar[i].y - ybar);
X    x2 += (xg->planar[i].x - xbar)*(xg->planar[i].x - xbar);
X    y2 += (xg->planar[i].y - ybar)*(xg->planar[i].y - ybar);
X    for (j=0; j<p1; j++)
X    {
X      xz1[j] += (xg->planar[i].x - xbar)*
X	(xg->world_data[i][xg->corr_xvars[j]] - z1bar[j]);
X      yz1[j] += (xg->planar[i].y - ybar)*
X	(xg->world_data[i][xg->corr_xvars[j]] - z1bar[j]);
X    }
X    for (j=0; j<p2; j++)
X    {
X      xz2[j] += (xg->planar[i].x - xbar)*
X	(xg->world_data[i][xg->corr_yvars[j]] - z2bar[j]);
X      yz2[j] += (xg->planar[i].y - ybar)*
X	(xg->world_data[i][xg->corr_yvars[j]] - z2bar[j]);
X    }
X  }
X
X  *corr_index = (float) xy*xy/(x2*y2);
X  for (j=0; j<p1; j++)
X    didx[j] = (float) (2*xy*(x2*yz1[j] - xy*xz1[j])/(x2*x2*y2));
X  for (j=0; j<p2; j++)
X    didy[j] = (float) (2*xy*(y2*xz2[j] - xy*yz2[j])/(x2*y2*y2));
}
X
SHAR_EOF
  chmod 0644 'xgobi/src/corr_index.c' ||
  $echo 'restore of' 'xgobi/src/corr_index.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/corr_index.c:' 'MD5 check failed'
21d67d8c6e9ca540aff4ab012de3ab6b  xgobi/src/corr_index.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/corr_index.c'`"
    test 4816 -eq "$shar_count" ||
    $echo 'xgobi/src/corr_index.c:' 'original size' '4816,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/rpc_dceclient.h ==============
if test -f 'xgobi/src/rpc_dceclient.h' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/rpc_dceclient.h' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/rpc_dceclient.h' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/rpc_dceclient.h' &&
/* Generated by IDL compiler version OSF DCE T1.2.0-09 */
#ifndef xgobi_dceclient_v1_0_included
#define xgobi_dceclient_v1_0_included
#ifndef IDLBASE_H
#include <dce/idlbase.h>
#endif
#include <dce/rpc.h>
X
#ifdef __cplusplus
X    extern "C" {
#endif
X
#ifndef nbase_v0_0_included
#include <dce/nbase.h>
#endif
extern void Xfer_Brushinfo(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr
#endif
);
globalref handle_t xgobi_client_binding_handle;
typedef struct xgobi_dceclient_v1_0_epv_t {
void (*Xfer_Brushinfo)(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr
#endif
);
} xgobi_dceclient_v1_0_epv_t;
extern rpc_if_handle_t xgobi_dceclient_v1_0_c_ifspec;
extern rpc_if_handle_t xgobi_dceclient_v1_0_s_ifspec;
X
#ifdef __cplusplus
X    }
X
#else
#endif
#endif
SHAR_EOF
  chmod 0644 'xgobi/src/rpc_dceclient.h' ||
  $echo 'restore of' 'xgobi/src/rpc_dceclient.h' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/rpc_dceclient.h:' 'MD5 check failed'
dd605ce8cd7a9bf318c1a8ee66792f39  xgobi/src/rpc_dceclient.h
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/rpc_dceclient.h'`"
    test 763 -eq "$shar_count" ||
    $echo 'xgobi/src/rpc_dceclient.h:' 'original size' '763,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/rpc_dce.h ==============
if test -f 'xgobi/src/rpc_dce.h' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/rpc_dce.h' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/rpc_dce.h' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/rpc_dce.h' &&
/* Generated by IDL compiler version OSF DCE T1.2.0-09 */
#ifndef xgobi_goes_dce_v1_0_included
#define xgobi_goes_dce_v1_0_included
#ifndef IDLBASE_H
#include <dce/idlbase.h>
#endif
#include <dce/rpc.h>
X
#ifdef __cplusplus
X    extern "C" {
#endif
X
#ifndef nbase_v0_0_included
#include <dce/nbase.h>
#endif
extern void RPC_Send_Colnames(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
extern void RPC_Send_Rownames(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
extern void RPC_Clone_XGobi(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
extern void RPC_Xfer_Colornames(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
extern void RPC_Init_Data(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
extern void RPC_Send_Init_Data(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
extern void RPC_Send_Init_Symbols(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
extern void RPC_Make_XGobi(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
extern void RPC_Update_All_Symbols(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
extern void RPC_Update_Some_Symbols(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
extern void RPC_Init_CDF_Data(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
extern void RPC_Send_Init_CDF_Data(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
extern void RPC_Send_Init_CDF_Symbols(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
extern void RPC_Make_CDF_XGobi(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
extern void RPC_Add_CDF_Bitmap(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
extern void RPC_Add_CDF_Type(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
extern void RPC_Delete_CDF_Bitmap_and_Type(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
extern void RPC_Brush_All_CDF_Symbols(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
extern void RPC_Send_CDF_Weights(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
extern void RPC_Init_VARIO_Data(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
extern void RPC_Send_Init_VARIO_Data(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
extern void RPC_Send_Init_VARIO_Symbols(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
extern void RPC_Make_VARIO_XGobi(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
extern void RPC_Update_Some_VARIO_Symbols(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[10000]
#endif
);
extern void RPC_Init_LAG_Data(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
extern void RPC_Send_Init_LAG_Data(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
extern void RPC_Send_Init_LAG_Symbols(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
extern void RPC_Make_LAG_XGobi(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
extern void RPC_Update_Some_LAG_Symbols(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[10000]
#endif
);
extern void RPC_Send_LAG_Colnames(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
extern void RPC_Init_VARIO2_Data(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
extern void RPC_Send_Init_VARIO2_Data(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
extern void RPC_Send_Init_VARIO2_Symbols(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
extern void RPC_Make_VARIO2_XGobi(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
extern void RPC_Update_Some_VARIO2_Symbols(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[10000]
#endif
);
globalref handle_t xgobi_server_binding_handle;
typedef struct xgobi_goes_dce_v1_0_epv_t {
void (*RPC_Send_Colnames)(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
void (*RPC_Send_Rownames)(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
void (*RPC_Clone_XGobi)(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
void (*RPC_Xfer_Colornames)(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
void (*RPC_Init_Data)(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
void (*RPC_Send_Init_Data)(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
void (*RPC_Send_Init_Symbols)(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
void (*RPC_Make_XGobi)(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
void (*RPC_Update_All_Symbols)(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
void (*RPC_Update_Some_Symbols)(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
void (*RPC_Init_CDF_Data)(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
void (*RPC_Send_Init_CDF_Data)(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
void (*RPC_Send_Init_CDF_Symbols)(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
void (*RPC_Make_CDF_XGobi)(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
void (*RPC_Add_CDF_Bitmap)(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
void (*RPC_Add_CDF_Type)(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
void (*RPC_Delete_CDF_Bitmap_and_Type)(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
void (*RPC_Brush_All_CDF_Symbols)(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
void (*RPC_Send_CDF_Weights)(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
void (*RPC_Init_VARIO_Data)(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
void (*RPC_Send_Init_VARIO_Data)(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
void (*RPC_Send_Init_VARIO_Symbols)(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
void (*RPC_Make_VARIO_XGobi)(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
void (*RPC_Update_Some_VARIO_Symbols)(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[10000]
#endif
);
void (*RPC_Init_LAG_Data)(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
void (*RPC_Send_Init_LAG_Data)(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
void (*RPC_Send_Init_LAG_Symbols)(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
void (*RPC_Make_LAG_XGobi)(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
void (*RPC_Update_Some_LAG_Symbols)(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[10000]
#endif
);
void (*RPC_Send_LAG_Colnames)(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
void (*RPC_Init_VARIO2_Data)(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
void (*RPC_Send_Init_VARIO2_Data)(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
void (*RPC_Send_Init_VARIO2_Symbols)(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
void (*RPC_Make_VARIO2_XGobi)(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[100]
#endif
);
void (*RPC_Update_Some_VARIO2_Symbols)(
#ifdef IDL_PROTOTYPES
X    /* [in] */ idl_char *instr,
X    /* [out] */ idl_char outstr[10000]
#endif
);
} xgobi_goes_dce_v1_0_epv_t;
extern rpc_if_handle_t xgobi_goes_dce_v1_0_c_ifspec;
extern rpc_if_handle_t xgobi_goes_dce_v1_0_s_ifspec;
X
#ifdef __cplusplus
X    }
X
#else
#endif
#endif
SHAR_EOF
  chmod 0644 'xgobi/src/rpc_dce.h' ||
  $echo 'restore of' 'xgobi/src/rpc_dce.h' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/rpc_dce.h:' 'MD5 check failed'
098b8fa99520b85b806df8535a241c7d  xgobi/src/rpc_dce.h
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/rpc_dce.h'`"
    test 9987 -eq "$shar_count" ||
    $echo 'xgobi/src/rpc_dce.h:' 'original size' '9987,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/svd.c ==============
if test -f 'xgobi/src/svd.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/svd.c' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/svd.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/svd.c' &&
/*
X * svdcomp - SVD decomposition routine.
X * Takes an mxn matrix a and decomposes it into udv, where u,v are
X * left and right orthogonal transformation matrices, and d is a
X * diagonal matrix of singular values.
X *
X * This routine is adapted from svdecomp.c in XLISP-STAT 2.1 which is
X * code from Numerical Recipes adapted by Luke Tierney and David Betz.
X *
X * Input to dsvd is as follows:
X *   a = mxn matrix to be decomposed, gets overwritten with u
X *   m = row dimension of a
X *   n = column dimension of a
X *   w = returns the vector of singular values of a
X *   v = returns the right orthogonal transformation matrix
*/
X
#include <math.h>
#include "stdio.h"
#include "xincludes.h"
#include "xgobitypes.h"
X
static double PYTHAG(double a, double b)
{
X  double at = fabs(a), bt = fabs(b), ct, result;
X
X  if (at > bt)     { ct = bt / at; result = at * sqrt(1.0 + ct * ct); }
X  else if (bt > 0.0) { ct = at / bt; result = bt * sqrt(1.0 + ct * ct); }
X  else result = 0.0;
X  return(result);
}
X
X
int
dsvd(float **a, int m, int n, float *w, float **v)
{
X  int flag, i, its, j, jj, k, l, nm;
X  double c, f, h, s, x, y, z;
X  double anorm = 0.0, g = 0.0, scale = 0.0;
X  double *rv1;
X
X  if (m < n)
X  {
X    fprintf(stderr, "#rows must be > #cols \n");
X    return(0);
X  }
X
X  rv1 = (double *)XtMalloc((Cardinal) n*sizeof(double));
X
/* Householder reduction to bidiagonal form */
X  for (i = 0; i < n; i++)
X  {
X    /* left-hand reduction */
X    l = i + 1;
X    rv1[i] = scale * g;
X    g = s = scale = 0.0;
X    if (i < m)
X    {
X      for (k = i; k < m; k++)
X        scale += fabs((double)a[k][i]);
X      if (scale)
X      {
X        for (k = i; k < m; k++)
X        {
X          a[k][i] = (float)((double)a[k][i]/scale);
X          s += ((double)a[k][i] * (double)a[k][i]);
X        }
X        f = (double)a[i][i];
X        g = -SIGN(sqrt(s), f);
X        h = f * g - s;
X        a[i][i] = (float)(f - g);
X        if (i != n - 1)
X        {
X          for (j = l; j < n; j++)
X          {
X            for (s = 0.0, k = i; k < m; k++)
X              s += ((double)a[k][i] * (double)a[k][j]);
X            f = s / h;
X            for (k = i; k < m; k++)
X              a[k][j] += (float)(f * (double)a[k][i]);
X          }
X        }
X        for (k = i; k < m; k++)
X          a[k][i] = (float)((double)a[k][i]*scale);
X      }
X    }
X    w[i] = (float)(scale * g);
X
X    /* right-hand reduction */
X    g = s = scale = 0.0;
X    if (i < m && i != n - 1)
X    {
X      for (k = l; k < n; k++)
X        scale += fabs((double)a[i][k]);
X      if (scale)
X      {
X        for (k = l; k < n; k++)
X        {
X          a[i][k] = (float)((double)a[i][k]/scale);
X          s += ((double)a[i][k] * (double)a[i][k]);
X        }
X        f = (double)a[i][l];
X        g = -SIGN(sqrt(s), f);
X        h = f * g - s;
X        a[i][l] = (float)(f - g);
X        for (k = l; k < n; k++)
X          rv1[k] = (double)a[i][k] / h;
X        if (i != m - 1)
X        {
X          for (j = l; j < m; j++)
X          {
X            for (s = 0.0, k = l; k < n; k++)
X              s += ((double)a[j][k] * (double)a[i][k]);
X            for (k = l; k < n; k++)
X              a[j][k] += (float)(s * rv1[k]);
X          }
X        }
X        for (k = l; k < n; k++)
X          a[i][k] = (float)((double)a[i][k]*scale);
X      }
X    }
X    anorm = MAX(anorm, (fabs((double)w[i]) + fabs(rv1[i])));
X  }
X
X  /* accumulate the right-hand transformation */
X  for (i = n - 1; i >= 0; i--)
X  {
X    if (i < n - 1)
X    {
X      if (g)
X      {
X        for (j = l; j < n; j++)
X          v[j][i] = (float)(((double)a[i][j] / (double)a[i][l]) / g);
X          /* double division to avoid underflow */
X        for (j = l; j < n; j++)
X        {
X          for (s = 0.0, k = l; k < n; k++)
X            s += ((double)a[i][k] * (double)v[k][j]);
X          for (k = l; k < n; k++)
X            v[k][j] += (float)(s * (double)v[k][i]);
X        }
X      }
X      for (j = l; j < n; j++)
X        v[i][j] = v[j][i] = 0.0;
X    }
X    v[i][i] = 1.0;
X    g = rv1[i];
X    l = i;
X  }
X
X  /* accumulate the left-hand transformation */
X  for (i = n - 1; i >= 0; i--)
X  {
X    l = i + 1;
X    g = (double)w[i];
X    if (i < n - 1)
X      for (j = l; j < n; j++)
X        a[i][j] = 0.0;
X    if (g)
X    {
X      g = 1.0 / g;
X      if (i != n - 1)
X      {
X        for (j = l; j < n; j++)
X        {
X          for (s = 0.0, k = l; k < m; k++)
X            s += ((double)a[k][i] * (double)a[k][j]);
X          f = (s / (double)a[i][i]) * g;
X          for (k = i; k < m; k++)
X            a[k][j] += (float)(f * (double)a[k][i]);
X        }
X      }
X      for (j = i; j < m; j++)
X        a[j][i] = (float)((double)a[j][i]*g);
X    }
X    else
X    {
X      for (j = i; j < m; j++)
X        a[j][i] = 0.0;
X    }
X    ++a[i][i];
X  }
X
X  /* diagonalize the bidiagonal form */
X  for (k = n - 1; k >= 0; k--)
X  {               /* loop over singular values */
X    for (its = 0; its < 30; its++)
X    {             /* loop over allowed iterations */
X      flag = 1;
X      for (l = k; l >= 0; l--)
X      {           /* test for splitting */
X        nm = l - 1;
X        if (fabs(rv1[l]) + anorm == anorm)
X        {
X          flag = 0;
X          break;
X        }
X        if (fabs((double)w[nm]) + anorm == anorm)
X          break;
X      }
X      if (flag)
X      {
X        c = 0.0;
X        s = 1.0;
X        for (i = l; i <= k; i++)
X        {
X          f = s * rv1[i];
X          if (fabs(f) + anorm != anorm)
X          {
X            g = (double)w[i];
X            h = PYTHAG(f, g);
X            w[i] = (float)h;
X            h = 1.0 / h;
X            c = g * h;
X            s = (- f * h);
X            for (j = 0; j < m; j++)
X            {
X              y = (double)a[j][nm];
X              z = (double)a[j][i];
X              a[j][nm] = (float)(y * c + z * s);
X              a[j][i] = (float)(z * c - y * s);
X            }
X          }
X        }
X      }
X      z = (double)w[k];
X      if (l == k)
X      {          /* convergence */
X        if (z < 0.0)
X        {        /* make singular value nonnegative */
X          w[k] = (float)(-z);
X          for (j = 0; j < n; j++)
X            v[j][k] = (-v[j][k]);
X        }
X        break;
X      }
X      if (its >= 30) {
X        XtFree((XtPointer) rv1);
X        fprintf(stderr, "No convergence after 30,000! iterations \n");
X        return(0);
X      }
X
X      /* shift from bottom 2 x 2 minor */
X      x = (double)w[l];
X      nm = k - 1;
X      y = (double)w[nm];
X      g = rv1[nm];
X      h = rv1[k];
X      f = ((y - z) * (y + z) + (g - h) * (g + h)) / (2.0 * h * y);
X      g = PYTHAG(f, 1.0);
X      f = ((x - z) * (x + z) + h * ((y / (f + SIGN(g, f))) - h)) / x;
X
X      /* next QR transformation */
X      c = s = 1.0;
X      for (j = l; j <= nm; j++)
X      {
X        i = j + 1;
X        g = rv1[i];
X        y = (double)w[i];
X        h = s * g;
X        g = c * g;
X        z = PYTHAG(f, h);
X        rv1[j] = z;
X        c = f / z;
X        s = h / z;
X        f = x * c + g * s;
X        g = g * c - x * s;
X        h = y * s;
X        y = y * c;
X        for (jj = 0; jj < n; jj++)
X        {
X          x = (double)v[jj][j];
X          z = (double)v[jj][i];
X          v[jj][j] = (float)(x * c + z * s);
X          v[jj][i] = (float)(z * c - x * s);
X        }
X        z = PYTHAG(f, h);
X        w[j] = (float)z;
X        if (z)
X        {
X          z = 1.0 / z;
X          c = f * z;
X          s = h * z;
X        }
X        f = (c * g) + (s * y);
X        x = (c * y) - (s * g);
X        for (jj = 0; jj < m; jj++)
X        {
X          y = (double)a[jj][j];
X          z = (double)a[jj][i];
X          a[jj][j] = (float)(y * c + z * s);
X          a[jj][i] = (float)(z * c - y * s);
X        }
X      }
X      rv1[l] = 0.0;
X      rv1[k] = f;
X      w[k] = (float)x;
X    }
X  }
X  XtFree((XtPointer) rv1);
X  return(1);
}
SHAR_EOF
  chmod 0644 'xgobi/src/svd.c' ||
  $echo 'restore of' 'xgobi/src/svd.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/svd.c:' 'MD5 check failed'
7238ab471aa20600766652143b0d0376  xgobi/src/svd.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/svd.c'`"
    test 7651 -eq "$shar_count" ||
    $echo 'xgobi/src/svd.c:' 'original size' '7651,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/mt19937-1.c ==============
if test -f 'xgobi/src/mt19937-1.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/mt19937-1.c' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/mt19937-1.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/mt19937-1.c' &&
/* A C-program for MT19937: Real number version (1999/10/28)    */
/*   genrand() generates one pseudorandom real number (double)  */
/* which is uniformly distributed on [0,1]-interval, for each   */
/* call. sgenrand(seed) sets initial values to the working area */
/* of 624 words. Before genrand(), sgenrand(seed) must be       */
/* called once. (seed is any 32-bit integer.)                   */
/* Integer generator is obtained by modifying two lines.        */
/*   Coded by Takuji Nishimura, considering the suggestions by  */
/* Topher Cooper and Marc Rieffel in July-Aug. 1997.            */
X
/* This library is free software; you can redistribute it and/or   */
/* modify it under the terms of the GNU Library General Public     */
/* License as published by the Free Software Foundation; either    */
/* version 2 of the License, or (at your option) any later         */
/* version.                                                        */
/* This library is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of  */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.            */
/* See the GNU Library General Public License for more details.    */
/* You should have received a copy of the GNU Library General      */
/* Public License along with this library; if not, write to the    */
/* Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA   */ 
/* 02111-1307  USA                                                 */
X
/* Copyright (C) 1997, 1999 Makoto Matsumoto and Takuji Nishimura. */
/* When you use this, send an email to: matumoto@math.keio.ac.jp   */
/* with an appropriate reference to your work.                     */
X
/* REFERENCE                                                       */
/* M. Matsumoto and T. Nishimura,                                  */
/* "Mersenne Twister: A 623-Dimensionally Equidistributed Uniform  */
/* Pseudo-Random Number Generator",                                */
/* ACM Transactions on Modeling and Computer Simulation,           */
/* Vol. 8, No. 1, January 1998, pp 3--30.                          */
X
#include<stdio.h>
X
/* Period parameters */  
#define N 624
#define M 397
#define MATRIX_A 0x9908b0df   /* constant vector a */
#define UPPER_MASK 0x80000000 /* most significant w-r bits */
#define LOWER_MASK 0x7fffffff /* least significant r bits */
X
/* Tempering parameters */   
#define TEMPERING_MASK_B 0x9d2c5680
#define TEMPERING_MASK_C 0xefc60000
#define TEMPERING_SHIFT_U(y)  (y >> 11)
#define TEMPERING_SHIFT_S(y)  (y << 7)
#define TEMPERING_SHIFT_T(y)  (y << 15)
#define TEMPERING_SHIFT_L(y)  (y >> 18)
X
static unsigned long mt[N]; /* the array for the state vector  */
static int mti=N+1; /* mti==N+1 means mt[N] is not initialized */
X
/* Initializing the array with a seed */
void
sgenrand(seed)
X    unsigned long seed;	
{
X    int i;
X
X    for (i=0;i<N;i++) {
X         mt[i] = seed & 0xffff0000;
X         seed = 69069 * seed + 1;
X         mt[i] |= (seed & 0xffff0000) >> 16;
X         seed = 69069 * seed + 1;
X    }
X    mti = N;
}
X
/* Initialization by "sgenrand()" is an example. Theoretically,      */
/* there are 2^19937-1 possible states as an intial state.           */
/* This function allows to choose any of 2^19937-1 ones.             */
/* Essential bits in "seed_array[]" is following 19937 bits:         */
/*  (seed_array[0]&UPPER_MASK), seed_array[1], ..., seed_array[N-1]. */
/* (seed_array[0]&LOWER_MASK) is discarded.                          */ 
/* Theoretically,                                                    */
/*  (seed_array[0]&UPPER_MASK), seed_array[1], ..., seed_array[N-1]  */
/* can take any values except all zeros.                             */
void
lsgenrand(seed_array)
X    unsigned long seed_array[];
X    /* the length of seed_array[] must be at least N */
{
X    int i;
X
X    for (i=0;i<N;i++) 
X      mt[i] = seed_array[i];
X    mti=N;
}
X
double /* generating reals */
/* unsigned long */ /* for integer generation */
genrand()
{
X    unsigned long y;
X    static unsigned long mag01[2]={0x0, MATRIX_A};
X    /* mag01[x] = x * MATRIX_A  for x=0,1 */
X
X    if (mti >= N) { /* generate N words at one time */
X        int kk;
X
X        if (mti == N+1)   /* if sgenrand() has not been called, */
X            sgenrand(4357); /* a default initial seed is used   */
X
X        for (kk=0;kk<N-M;kk++) {
X            y = (mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK);
X            mt[kk] = mt[kk+M] ^ (y >> 1) ^ mag01[y & 0x1];
X        }
X        for (;kk<N-1;kk++) {
X            y = (mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK);
X            mt[kk] = mt[kk+(M-N)] ^ (y >> 1) ^ mag01[y & 0x1];
X        }
X        y = (mt[N-1]&UPPER_MASK)|(mt[0]&LOWER_MASK);
X        mt[N-1] = mt[M-1] ^ (y >> 1) ^ mag01[y & 0x1];
X
X        mti = 0;
X    }
X  
X    y = mt[mti++];
X    y ^= TEMPERING_SHIFT_U(y);
X    y ^= TEMPERING_SHIFT_S(y) & TEMPERING_MASK_B;
X    y ^= TEMPERING_SHIFT_T(y) & TEMPERING_MASK_C;
X    y ^= TEMPERING_SHIFT_L(y);
X
X    return ( (double)y * 2.3283064370807974e-10 ); /* reals */
X    /* return y; */ /* for integer generation */
}
X
/* This main() outputs first 1000 generated numbers.  */
/*
main()
{ 
X    int i;
X
X    sgenrand(4357);
X    for (i=0; i<1000; i++) {
X        printf("%10.8f ", genrand());
X        if (i%5==4) printf("\n");
X    }
}
*/
SHAR_EOF
  chmod 0644 'xgobi/src/mt19937-1.c' ||
  $echo 'restore of' 'xgobi/src/mt19937-1.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/mt19937-1.c:' 'MD5 check failed'
4bd43c22af5aca50af73cb7a7554de94  xgobi/src/mt19937-1.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/mt19937-1.c'`"
    test 5317 -eq "$shar_count" ||
    $echo 'xgobi/src/mt19937-1.c:' 'original size' '5317,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/plot1d.c ==============
if test -f 'xgobi/src/plot1d.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/plot1d.c' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/plot1d.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/plot1d.c' &&
/* plot1d.c */
/************************************************************
X *                                                          *
X *  Permission is hereby granted  to  any  individual   or  *
X *  institution   for  use,  copying, or redistribution of  *
X *  the xgobi code and associated documentation,  provided  *
X *  that   such  code  and documentation are not sold  for  *
X *  profit and the  following copyright notice is retained  *
X *  in the code and documentation:                          *
X *        Copyright (c) 1990, ..., 1996 Bellcore            *
X *                                                          *
X *  We welcome your questions and comments, and request     *
X *  that you share any modifications with us.               *
X *                                                          *
X *    Deborah F. Swayne            Dianne Cook              *
X *   dfs@research.att.com       dicook@iastate.edu          *
X *      (973) 360-8423    www.public.iastate.edu/~dicook/   *
X *                                                          *
X *                    Andreas Buja                          *
X *                andreas@research.att.com                  *
X *              www.research.att.com/~andreas/              *
X *                                                          *
X ************************************************************/
X
#include <stdio.h>
#include "xincludes.h"
#include "xgobitypes.h"
#include "xgobivars.h"
#include "xgobiexterns.h"
#include <X11/keysym.h>
X
/*
X * min and max for 'forget it' dotplot's texturing axis;
X * they're defined so as to locate the plot in the center of
X * the window, with the texturing values returned on a range
X * of [0,100].
X *
X * The min and max are calculated on the fly for the ash.
*/
#define FORGETITAXIS_MIN -100.
#define FORGETITAXIS_MAX 200.
X
Boolean plot1d_vertically;
X
#define ASH     0
#define DOTPLOT 1
int plot1d_type = ASH;
Widget plot1d_type_cmd[2];
X
static Widget plot1d_panel;
static Widget plot1d_delay_sbar, plot1d_chdir_cmd;
Widget plot1d_cycle_cmd;
static int plot1d_cycle_dir = 1;
static XtIntervalId cycle_timeout_id = 0;
static float delay = 2.0;
X
static float *plot1d_data;
static lims   plot1d_lim;
X
Widget nASHes_sbar, nASHes_label;
int nbins = 200;
int nASHes = 20;
X
void
init_plot1d_vars(xgobidata *xg)
{
X  xg->is_plotting1d = False;
X  xg->is_plot1d_cycle = False;
X
X  plot1d_vertically = False;
X  xg->plot1d_vars.x = 0 ;
X  xg->plot1d_vars.y = -1;
}
X
Boolean
set_plot1dvar(xgobidata *xg, int varno) {
X  int prev;
X  Boolean newvar = false;
X
X  /*
X   * If we're dotplotting, and the selected variable is the
X   * current variable, pretend it's a new variable, and set
X   * newvar to true in order to generate a new plot1d.
X  */
X  if (plot1d_type == DOTPLOT)
X    newvar = (plot1d_vertically && varno == xg->plot1d_vars.y ||
X             !plot1d_vertically && varno == xg->plot1d_vars.x);
X
X  /*
X   * Otherwise choose the new variable
X  */
X  if (!newvar) {
X    prev = (xg->plot1d_vars.y != -1) ? xg->plot1d_vars.y : xg->plot1d_vars.x;
X    xg->varchosen[prev] = False;
X    refresh_vbox(xg, prev, 1);
X
X    xg->plot1d_vars.y = (plot1d_vertically) ? varno : -1;
X    xg->plot1d_vars.x = (plot1d_vertically) ? -1 : varno;
X
X    xg->varchosen[varno] = True;
X    refresh_vbox(xg, varno, 1);
X    newvar = true;
X  }
X
X  return newvar;
}
X
X
Boolean
plot1d_varselect(int varno, int button, int state, xgobidata *xg)
{
X  if (button == 1 && state != 8)
X    plot1d_vertically = False;
X  else if ((button == 1 && state == 8) || button == 2) /* alt-left = middle */
X    plot1d_vertically = True;
X  else
X    return 0;
X
X  return (set_plot1dvar(xg, varno));
}
X
void
plot1d_reproject(xgobidata *xg)
{
/*
X * Project the y variable down from the ncols-dimensional world_data[]
X * to the 2-dimensional array planar[]; get the x variable directly
X * from plot1d_data[].
*/
X  int i, k;
X  float rdiff = plot1d_lim.max - plot1d_lim.min;
X  float ftmp;
X  float precis = PRECISION1;
X  int jvar = (plot1d_vertically) ? xg->plot1d_vars.y : xg->plot1d_vars.x;
X
X  for (i=0; i<xg->nrows_in_plot; i++) {
X    k = xg->rows_in_plot[i];
X
X    /*
X     * Use plot1d_data[i] not [k] because plot1d_data[]
X     * is of length xg->nrows_in_plot rather than xg->nrows.
X    */
X    ftmp = -1.0 + 2.0*(plot1d_data[i] - plot1d_lim.min)/rdiff;
X
X    /*
X     * Now here's a charming kludge:  since we'd rather have the
X     * jitter perpendicular to the axes, subtract it from the
X     * selected variable and swap it onto the jitter variable.
X     * November 1999 -- dfs
X    */
X    if (plot1d_vertically) {
X      xg->planar[k].x = (long) (precis * ftmp) + xg->jitter_data[k][jvar];
X      xg->planar[k].y = xg->world_data[k][jvar] - xg->jitter_data[k][jvar];
X    } else {
X      xg->planar[k].x = xg->world_data[k][jvar] - xg->jitter_data[k][jvar];
X      xg->planar[k].y = (long) (precis * ftmp) + xg->jitter_data[k][jvar];
X    }
X  }
}
X
void
plot1d_texture_var(xgobidata *xg)
{
/*
X * Set up the next dot plot.
*/
X  int i;
X  float *yy;
X  float del = 1.;
X  int option = 1, stages = 3;
X  int jvar = (plot1d_vertically) ? xg->plot1d_vars.y : xg->plot1d_vars.x;
X  extern int do_ash();
X
X  /*
X   * yy is a temporary variable.  It's used by textur, and then
X   * junked immediately afterward.
X  */
X  yy = (float *) XtMalloc((Cardinal) xg->nrows_in_plot * sizeof(float));
X
X  for (i=0; i<xg->nrows_in_plot; i++)
X    yy[i] = xg->tform2[ xg->rows_in_plot[i] ][jvar];
X
X  if (plot1d_type == ASH) {
X    float min, max;
X    extern void do_ash1d(float *, int, int, int, float *, float *, float *);
/*
X    int nbins = MAX((int) (xg->scale.x * xg->plotsize.width),
X                    (int) (xg->scale.y * xg->plotsize.height));
*/
X
X    do_ash1d(yy, xg->nrows_in_plot, nbins, nASHes, plot1d_data, &min, &max);
X    plot1d_lim.min = min;
X    plot1d_lim.max = max;
X  }
X  else {
X    plot1d_lim.min = FORGETITAXIS_MIN ;
X    plot1d_lim.max = FORGETITAXIS_MAX ;
X    textur(yy, plot1d_data, xg->nrows_in_plot, option, del, stages);
X  }
X
X  XtFree((XtPointer) yy);
}
X
void
free_txtr_var()
{
X  XtFree((XtPointer) plot1d_data);
}
X
/* ARGSUSED */
static void
turn_on_plot1d_animation(xgobidata *xg, XtIntervalId id)
{
X  xg->is_plot1d_cycle = True;
X  (void) XtAppAddWorkProc(app_con, RunWorkProcs, (XtPointer) NULL);
X
X  setToggleBitmap(plot1d_cycle_cmd, xg->is_plot1d_cycle);
}
X
void
plot1d_cycle_proc(xgobidata *xg)
{
X  int varno, varno_prev;
X
X  varno_prev = (plot1d_vertically) ? xg->plot1d_vars.y : xg->plot1d_vars.x;
X
X  if (plot1d_cycle_dir == 1)
X  {
X    varno = varno_prev + 1;
X    if (varno > xg->ncols_used-1)
X      varno = 0;
X  } else {
X    varno = varno_prev - 1;
X    if (varno < 0)
X      varno = xg->ncols_used-1;
X  }
X  xg->varchosen[varno_prev] = False;
X  refresh_vbox(xg, varno_prev, 1);
X
X  if (plot1d_vertically)
X    xg->plot1d_vars.y = varno;
X  else
X    xg->plot1d_vars.x = varno;
X
X  xg->varchosen[varno] = True;
X  refresh_vbox(xg, varno, 1);
X
X  plot1d_texture_var(xg);
X  world_to_plane(xg);      /* just calls plot1d_reproject */
X  plane_to_screen(xg);
X  init_ticks(&xg->plot1d_vars, xg);
X  plot_once(xg);
X  XSync(display, False);
X
X  xg->is_plot1d_cycle = False;
X  cycle_timeout_id =  XtAppAddTimeOut(app_con,
X     (unsigned long) (1000*delay),
X     (XtTimerCallbackProc) turn_on_plot1d_animation, (XtPointer) xg);
}
X
void
reset_plot1d_type(xgobidata *xg)
{
X  XtVaSetValues(plot1d_type_cmd[DOTPLOT],
X    XtNstate, plot1d_type == DOTPLOT,
X    NULL);
X  setToggleBitmap(plot1d_type_cmd[DOTPLOT], plot1d_type == DOTPLOT);
X
X  XtVaSetValues(plot1d_type_cmd[ASH],
X    XtNstate, plot1d_type == ASH,
X    NULL);
X  setToggleBitmap(plot1d_type_cmd[ASH], plot1d_type == ASH);
X
X  XtSetSensitive(nASHes_sbar, plot1d_type == ASH);
X
X  plot1d_texture_var(xg);
X
X  update_world(xg);
X  world_to_plane(xg);
X  plane_to_screen(xg);
X  init_ticks(&xg->plot1d_vars, xg);
X  plot_once(xg);
}
/* ARGSUSED */
XXtCallbackProc
ptype_dotplot_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  plot1d_type = DOTPLOT;
X  reset_plot1d_type(xg);
}
/* ARGSUSED */
XXtCallbackProc
ptype_ash_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  plot1d_type = ASH;
X  reset_plot1d_type (xg);
}
X
/* ARGSUSED */
XXtCallbackProc
nASHes_cback (Widget w, xgobidata *xg, XtPointer slideposp)
{
X  float fslidepos = * (float *) slideposp;
X  char str[16];
X
X  nASHes = (int) (nbins * (fslidepos+.01) / 2.0);
X
X  sprintf(str, "%1.3f", (float) nASHes/(float) nbins);
X  XtVaSetValues(nASHes_label, XtNlabel, str, NULL);
X
X  plot1d_texture_var(xg);
X  world_to_plane(xg);
X  plane_to_screen(xg);
X  init_ticks(&xg->plot1d_vars, xg);
X  plot_once(xg);
X  world_to_plane(xg);
X  plane_to_screen(xg);
X  init_ticks(&xg->plot1d_vars, xg);
X  plot_once(xg);
}
X
/* ARGSUSED */
XXtCallbackProc
plot1d_cycle_cback(Widget w, xgobidata *xg, XtPointer callback_data)
/*
X * Turn on cycling.
*/
{
X  if (!xg->is_plot1d_cycle && cycle_timeout_id == 0L) {
X    xg->is_plot1d_cycle = True;
X    (void) XtAppAddWorkProc(app_con, RunWorkProcs, (XtPointer) NULL);
X  }
X  else {
X    XtRemoveTimeOut(cycle_timeout_id);
X    cycle_timeout_id = 0L;
X    xg->is_plot1d_cycle = False;
X  }
X
X  setToggleBitmap(plot1d_cycle_cmd, xg->is_plot1d_cycle);
}
X
/* ARGSUSED */
XXtCallbackProc
plot1d_cycle_delay_cback(Widget w, xgobidata *xg, XtPointer slideposp)
/*
X * Change the cycling speed.
*/
{
X  float fslidepos = * (float *) slideposp;
X  delay = 1.0 / (2.0 * fslidepos + 0.2) ;
}
X
/* ARGSUSED */
XXtCallbackProc
plot1d_chdir_cback(Widget w, xgobidata *xg, XtPointer callback_data)
/*
X * Change the direction of cycling.
*/
{
X  plot1d_cycle_dir = -1 * plot1d_cycle_dir;
}
X
static void
map_plot1d(Boolean on)
{
X  if (on)
X    XtMapWidget(plot1d_panel);
X  else
X    XtUnmapWidget(plot1d_panel);
}
X
X
void
make_plot1d(xgobidata *xg)
{
/*
X * Plot1DPanel: plot1d_panel
*/
X  char str[35];
X  Dimension width, max_width;
X  Widget ptype_box, cycle_box, ash_box;
/*
X * Widest button label used in this panel.
*/
X  (void) sprintf(str, "ASH smoothness");
X  max_width = XTextWidth(appdata.font, str, strlen(str));
X
X  plot1d_panel = XtVaCreateManagedWidget("Plot1DPanel",
X    boxWidgetClass, xg->box0,
X    XtNleft, (XtEdgeType) XtChainLeft,
X    XtNright, (XtEdgeType) XtChainLeft,
X    XtNtop, (XtEdgeType) XtChainTop,
X    XtNbottom, (XtEdgeType) XtChainTop,
X    XtNmappedWhenManaged, (Boolean) False,
X    XtNorientation, (XtOrientation) XtorientVertical,
X    NULL);
X  if (mono) set_mono(plot1d_panel);
X
X  ptype_box = XtVaCreateManagedWidget("Plot1DPanel",
X    boxWidgetClass, plot1d_panel,
X    XtNleft, (XtEdgeType) XtChainLeft,
X    XtNright, (XtEdgeType) XtChainLeft,
X    XtNtop, (XtEdgeType) XtChainTop,
X    XtNbottom, (XtEdgeType) XtChainTop,
X    XtNorientation, (XtOrientation) XtorientVertical,
X    NULL);
X  if (mono) set_mono(ptype_box);
X
X  plot1d_type_cmd[DOTPLOT] = CreateToggle(xg, "Plot1D", True,
X    (Widget) NULL, (Widget) NULL, (Widget) NULL,
X    (plot1d_type == DOTPLOT), ONE_OF_MANY, ptype_box, "Plot1D");
X  XtManageChild(plot1d_type_cmd[DOTPLOT]);
X  XtAddCallback(plot1d_type_cmd[DOTPLOT], XtNcallback,
X    (XtCallbackProc) ptype_dotplot_cback, (XtPointer) xg);
X
X  plot1d_type_cmd[ASH] = CreateToggle(xg, "1D ASH", True,
X    (Widget) NULL, (Widget) NULL, plot1d_type_cmd[DOTPLOT],
X    (plot1d_type == ASH), ONE_OF_MANY, ptype_box, "Plot1D");
X  XtManageChild(plot1d_type_cmd[ASH]);
X  XtAddCallback(plot1d_type_cmd[ASH], XtNcallback,
X    (XtCallbackProc) ptype_ash_cback, (XtPointer) xg);
X
/* ASH parameter */
X  ash_box = XtVaCreateManagedWidget("Plot1DPanel",
X    boxWidgetClass, plot1d_panel,
X    NULL);
X
X  (void) XtVaCreateManagedWidget("Label",
X    labelWidgetClass, ash_box,
X    XtNlabel, "ASH smoothness",
X    NULL);
X
X  nASHes_sbar = XtVaCreateManagedWidget("Scrollbar",
X    scrollbarWidgetClass, ash_box,
X    XtNorientation, (XtOrientation) XtorientHorizontal,
X    XtNwidth, (Dimension) max_width,
X    NULL);
X  if (mono) set_mono(nASHes_sbar);
X  /*
X   * range of the scrollbar: 0 to 1.0
X   * desired range:  .01 + (0 to .5), which is nASHes/nbins
X   * 
X   * (float) (nASHes) / (float) nbins = (slidepos+.01) / 2;
X   * nASHes = (int) (nbins * (slidepos+.01) / 2.0);
X
X   * slidepos = 2 * (float) nASHes / (float) nbins - .01;
X  */
X  XawScrollbarSetThumb(nASHes_sbar,
X    2 * (float) nASHes / (float) nbins  - .01,  /*-- 2*20/200 - .01 --*/
X    -1.);
X  XtAddCallback(nASHes_sbar, XtNjumpProc,
X    (XtCallbackProc) nASHes_cback, (XtPointer) xg);
X  add_sbar_help(&xg->nhelpids.sbar,
X    nASHes_sbar, "Plot1D");
X
X  sprintf(str, "%1.4f", 0.9999);
X  width = XTextWidth(appdata.font, str, strlen(str));
X  sprintf(str, "%1.3f", (float)nASHes/(float)nbins);
X  nASHes_label = XtVaCreateManagedWidget("Plot1D",
X    labelWidgetClass,  ash_box,
X    XtNlabel,    str,
X    XtNwidth,    width,
X    NULL);
X  if (mono) set_mono(nASHes_label);
/*  */
X
X  cycle_box = XtVaCreateManagedWidget("Plot1DPanel",
X    boxWidgetClass, plot1d_panel,
X    NULL);
X
X  plot1d_cycle_cmd = CreateToggle(xg, "Cycle",
X    True, (Widget) NULL, (Widget) NULL, (Widget) NULL, False, ANY_OF_MANY,
X    cycle_box, "Plot1D_Cycle");
X  XtManageChild(plot1d_cycle_cmd);
X  XtAddCallback(plot1d_cycle_cmd, XtNcallback,
X    (XtCallbackProc) plot1d_cycle_cback, (XtPointer) xg);
X
X  plot1d_delay_sbar = XtVaCreateManagedWidget("Scrollbar",
X    scrollbarWidgetClass, cycle_box,
X    XtNorientation, (XtOrientation) XtorientHorizontal,
X    XtNwidth, (Dimension) max_width,
X    XtNfromVert, (Widget) plot1d_cycle_cmd,
X    NULL);
X  if (mono) set_mono(plot1d_delay_sbar);
X
X  /*
X   * delay = 1 / (2*slidepos + .2)
X   * slidepos = 1 / (2*delay) - .1
X  */
X  XawScrollbarSetThumb(plot1d_delay_sbar, 1.0 / (2.0 * delay) - 0.1, -1.);
X  XtAddCallback(plot1d_delay_sbar, XtNjumpProc,
X    (XtCallbackProc) plot1d_cycle_delay_cback, (XtPointer) xg);
X  add_sbar_help(&xg->nhelpids.sbar,
X    plot1d_delay_sbar, "Plot1D_Cycle");
X
X  plot1d_chdir_cmd = CreateCommand(xg, "Change direction",
X    True, (Widget) NULL, (Widget) NULL,
X    cycle_box, "Plot1D_Cycle");
X  XtManageChild(plot1d_chdir_cmd);
X  XtAddCallback(plot1d_chdir_cmd, XtNcallback,
X    (XtCallbackProc) plot1d_chdir_cback, (XtPointer) NULL);
X
}
X
void
plot1d_on(xgobidata *xg)
/*
X * Turn on and off the plot1d mode.
*/
{
X  int j;
X  Boolean cycle_on;
X  extern xgobidata xgobi;
X  int jvar = (plot1d_vertically) ? xg->plot1d_vars.y : xg->plot1d_vars.x;
X
/*
X *  If this mode is currently selected, turn it off.
*/
X  if (xg->prev_plot_mode == PLOT1D_MODE && xg->plot_mode != PLOT1D_MODE) {
X    map_plot1d(False);
X
X    xg->is_plot1d_cycle = False;
X    if (cycle_timeout_id)
X    {
X      XtRemoveTimeOut(cycle_timeout_id);
X      cycle_timeout_id = 0L;
X    }
X  }
X  /* Else turn it on */
X  else if (xg->plot_mode == PLOT1D_MODE &&
X           xg->prev_plot_mode != PLOT1D_MODE)
X  {
X    map_plot1d(True);
X
X    if (!xg->is_plotting1d) {
X      if (xg->is_touring && xg->is_princ_comp) {
X	set_sph_labs(xg, xg->nsph_vars);
X        xg->is_touring = False;
/*        reset_var_labels(xg, PRINCCOMP_OFF);i think not needed anymore
X                                             sphering transformation*/
X      }
X
X      if (xg->carry_vars)
X        carry_plot1d_vars(xg);
X
X      xg->is_xyplotting = xg->is_spinning = xg->is_touring = False;
X      xg->is_plotting1d = True;
X      xg->is_corr_touring = False;
X
X      plot1d_data = (float *) XtMalloc( (Cardinal)
X        xg->nrows_in_plot * sizeof(float));
X
X      plot1d_texture_var(xg);
X
X      update_lims(xg);
X      update_world(xg);
X      world_to_plane(xg);
X      plane_to_screen(xg);
X
X      init_ticks(&xg->plot1d_vars, xg);
X
X      plot_once(xg);
X      /*
X       * Reinitialize the sin and cos variables.  Why???
X      */
X      init_trig(xg);
X
X      for (j=0; j<xg->ncols; j++) {
X        if (j == jvar)
X          xg->varchosen[j] = True;
X        else
X          xg->varchosen[j] = False;
X      }
X
X      set_varsel_label(xg);
X      refresh_vboxes(xg);
X    }
X    /*
X     * If the cycle button is activated, start cycling.
X    */
X    XtVaGetValues(plot1d_cycle_cmd, XtNstate, &cycle_on, NULL);
X
X    if (cycle_on) {
X      xg->is_plot1d_cycle = True;
X      (void) XtAppAddWorkProc(app_con, RunWorkProcs, (XtPointer) NULL);
X    }
X  }
X
X  setToggleBitmap(plot1d_cycle_cmd, xg->is_plot1d_cycle);
}
SHAR_EOF
  chmod 0644 'xgobi/src/plot1d.c' ||
  $echo 'restore of' 'xgobi/src/plot1d.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/plot1d.c:' 'MD5 check failed'
f2ca0439924ece4701d124690c368c8c  xgobi/src/plot1d.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/plot1d.c'`"
    test 16051 -eq "$shar_count" ||
    $echo 'xgobi/src/plot1d.c:' 'original size' '16051,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/XGobiCorbaServer.idl ==============
if test -f 'xgobi/src/XGobiCorbaServer.idl' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/XGobiCorbaServer.idl' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/XGobiCorbaServer.idl' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/XGobiCorbaServer.idl' &&
/**
X This is an attempt to define an external interface
X to XGobi.
X
X The initial functionality is somewhat related to 
X the methods provided via the RPC mechanism.
X Additionally, Ross Ihaka and I have identified some other
X information that may be useful to have in a client (e.g. S)
X to 
X   1) produce plots locally from the current view in the XGobi
X      application,
X   2) control the XGobi application
X
X
@author  Ross Ihaka and Duncan Temple Lang 
@date    July 18th 1999
*/
X
X
X /* Get the definition of matrix, etc. from the Omegahat material. */
#include <Omega.idl>
#include <Matrix.idl>
X
module XGobi  {
X
X     /** A basic exception that can be thrown when 
X        not enough information is provided in a call, 
X        e.g when we set the view to an XY plot but there
X        is only on/e variable selected.
X      */
X  exception InsufficientInformationException {
X   };
X
X
X    /** This is the interface defining how clients can communicate
X        with an instance of XGobi.
X      */
X
X  interface XGobi {
X
X       /** 
X          clone the XGobi window, creating a new one.
X
X          linked: true or false indicating whether the new
X                  instance of the server should be linked to the
X                  other.
X          name: the name to use by which it is registered with the
X                CORBA naming. Also, this can be used in the titlebar 
X                of the new window.
X        */
X    XGobi replicate(in boolean linked, in string name);
X
X       /**
X          The current file loaded in XGobi.
X
X          This might be generalized to the identify whether
X          the data was loaded directly from a client's data
X          in the form of a Matrix or Data frame.
X
X           Methods to set and get this value are available.
X           The latter loads a new file.
X        */
X
X    attribute string fileName;
X
X
X
X       /**
X          Load data from a Matrix object. 
X          The variables are taken to be the columns of the matrix
X          and their names are provided in the second argument.
X        */
X    void setData(in Omegahat::BaseMatrix data, in Sequences::StringSequence names);
X
X
X      /**
X         A client can ask for the current data being used by the
X         server. It is returned as a Matrix.
X         The are no names with matrix. This is currently a separate
X         call.  (Synchronization issues are a problem.) We will
X         add methods to return a Data Frame which will contain the
X         names of the variables, etc.
X        */
X    Omegahat::BaseMatrix getData();
X
X
X      /** Add a single variable to the current data being displayed by
X         the server
X       */
X
X    long addVariable(in Sequences::DoubleSequence values, in string name);
X
X      /** Add a collection of variables to the list of variables
X         currently being displayed. The names are given 
X         in the second argument. This works much like the setData
X         method, but augments the existing data if the variables have 
X         the same length. Otherwise, an exception is thrown. It should
X         be specified here.
X       */
X    long addVariables(in Omegahat::BaseMatrix data, in Sequences::StringSequence names);
X
X
X      /** Get the names of the variables currently being displayed. */      
X    Sequences::StringSequence getVariableNames();
X      /* Set the name of the i-th variable. */
X    void                      setVariableName(in long which, in string name);
X
X
X     /** Get the names of the observations in the currently displayed data. */
X    Sequences::StringSequence getRowNames();
X
X     /**
X        Set the names of the observations in the currently displayed
X        data. 
X      */
X    void setRowNames(in Sequences::StringSequence names);
X
X      /**
X         Set an individual observation name.
X        */
X    void setRowName(in long which, in string name);
X
X
X      /** Get the names of the colors currently being used to display
X         each point. 
X         This is useful for being able to reproduce the plot in a
X         client application.
X       */
X    Sequences::StringSequence getRowColors();
X
X 
/** The following two methods relate to the XGobi server rather than
X    the data. They are more structural/system capabilities.
*/
X
X
X      /** Retrieve the list of available colors understood by the XGobi
X         server.  This allows the client to ensure that commands to
X         set a color will be understood since the selection can be
X         made from this list.
X       */
X    Sequences::StringSequence getColorNames();
X
X      /** Return the name of the glyphs understood by the XGobi server.
X       */
X    Sequences::StringSequence getSymbolNames();
X
X
X     /** Set the display color of an individual observation. 
X        The observation is identified by index.
X      */
X    boolean setObservationColor(in string color, in long row);
X
X     /** Set the display color of many individual observations.
X        The observations are identified by index.
X      */
X    boolean setObservationColors(in string color,
X      in Sequences::LongSequence rows);
X
X     /** Set the glyph and glyph size for an individual observation. */
X    boolean setObservationSymbol(in string symbolName, in long size,
X      in long row);
X     /** Set the glyph and glyph size for a vector of observations. */
X    boolean setObservationSymbols(in string symbolName, in long size,
X      in Sequences::LongSequence rows);
X
X      /** Specify the variable identified by the first argument
X         to be considered as a predictor or X variable.
X         The second argument indicate whether this should clear
X         existing values first (false) or simply add this variable
X         to the existing list of predictors.
X       */
X    long setX(in string name, in boolean append);
X
X      /**
X         Similar to setX(), this specifies the appropriate variable
X         as a response.
X       */
X    long setY(in string name, in boolean append);
X
X      /** This turns on or off the selection for the specified
X         variable.
X       */
X    boolean setSelected(in string name, in boolean select);
X
X
X        /** Retrieve the names of the currently selected variables. */ 
X    Sequences::StringSequence getSelectedVariables();
X
X       /** Determine whether the specified variable is currently
X          selected. 
X        */
X    boolean isSelected(in string name);
X
X
X      /**
X         Retrieve a list of indeces identifying which 
X         observations are currently selected.
X       */
X    Sequences::LongSequence getSelectedIndices();
X
X      /**
X         Set the observations identified by index in the 
X         argument sequence to be selected.
X       */
X    void setSelectedIndices(in Sequences::LongSequence rows);
X
X
X      /** 
X         Specify the rotation to use in the current view. 
X         This allows the client to control the current view.
X        */
X    void setRotation(in Omegahat::BaseMatrix rotation);
X
X      /**
X        Get the  rotation matrix for the current view.
X        This can be used in the client to extract useful information
X        either for plotting or for transforming variables locally
X        according to this view, etc.
X       */
X    Omegahat::BaseMatrix getRotation();
X
X      /** This returns the coefficients as they are displayed in the
X          variable dials in the variable panel of the XGobi display.
X       */
X    Sequences::DoubleSequence getCoefficients();
X
X     /** This retrieves the data associated with a given variable. */
X    Omegahat::DataVector getVariable(in string name);              
X
X     /** This is the value on the dial. */
X    double getCurrentVariableValue(in string name);
X      /** List of all values on the dial */
X    Sequences::DoubleSequence getCurrentValues();
X
X
X      /** Sethe view to the specfied type (e.g. xyplot, grand tour,
X           etc.)
X        */
X    boolean setView(in string name);
X      /**
X        Retrieve the name of the  current view type.
X       */
X    string  getView()  raises (InsufficientInformationException);
X      /**
X        Obtain a list of the names of all the possible views
X           understood by the XGobi server.
X       */
X    Sequences::StringSequence getViewTypes();
X
X
X    
/** For efficiency purposes and ease of use in the client (R and S)
X   we return this as a matrix or two parallel sequences.
X   Alternatively, we can convey type information by returning
X   a sequence of pairs
*/
X
X
X
X     /** These methods relate to connectivity between observations.  
X        They allow a client to control whether two points are
X        connected and also to get all pairs of connected observations.
X      */
X
X
X      /** Get current collection of connections. */
X    Omegahat::BaseMatrix  getConnectedObservations();
X
X      /** Connect each pair of observations with a line segment 
X         that are identified row-wise in the specified matrix.
X       */
X    void connectObservations(in Omegahat::Matrix pairs);
X
X      /** Remove the connection between the pairs of points
X         identifed in the matrix.
X       */
X    void disconnectObservations(in Omegahat::Matrix pairs);
X
X      /**
X         Clear all connections between observations.
X       */
X    void disconnectAllObservations();
X
X
/**
X  An alternative of implementing the connections
X  is to use more structure than a simple matrix.
X  We can control the specification to be indices
X  and actually pairs of indices.
X  It is probably easier for the client to use
X  matrices.
X
X    typedef sequence<unsigned long,2> IndexPair;
X    typedef sequence<IndexPair> IndexPairSequence;
X
X    IndexPairSequence getConnectedObservations();
X    boolean  connectObservations(in IndexPairSequence ids);
*/  
X
X
/** In the (very) near future, we will add Data Frame support.
X    boolean loadDataFrame(in Omegahat::DataFrame df);
*/
X  };
};
X
X
SHAR_EOF
  chmod 0644 'xgobi/src/XGobiCorbaServer.idl' ||
  $echo 'restore of' 'xgobi/src/XGobiCorbaServer.idl' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/XGobiCorbaServer.idl:' 'MD5 check failed'
31b246d35c9e4f03347215b512ea913a  xgobi/src/XGobiCorbaServer.idl
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/XGobiCorbaServer.idl'`"
    test 9735 -eq "$shar_count" ||
    $echo 'xgobi/src/XGobiCorbaServer.idl:' 'original size' '9735,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/jitter.c ==============
if test -f 'xgobi/src/jitter.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/jitter.c' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/jitter.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/jitter.c' &&
/* jitter.c */
/************************************************************
X *                                                          *
X *  Permission is hereby granted  to  any  individual   or  *
X *  institution   for  use,  copying, or redistribution of  *
X *  the xgobi code and associated documentation,  provided  *
X *  that   such  code  and documentation are not sold  for  *
X *  profit and the  following copyright notice is retained  *
X *  in the code and documentation:                          *
X *        Copyright (c) 1990, ..., 1996 Bellcore            *
X *                                                          *
X *  We welcome your questions and comments, and request     *
X *  that you share any modifications with us.               *
X *                                                          *
X *    Deborah F. Swayne            Dianne Cook              *
X *   dfs@research.att.com       dicook@iastate.edu          *
X *      (973) 360-8423    www.public.iastate.edu/~dicook/   *
X *                                                          *
X *                    Andreas Buja                          *
X *                andreas@research.att.com                  *
X *              www.research.att.com/~andreas/              *
X *                                                          *
X ************************************************************/
X
#include <limits.h>
#include <float.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "xincludes.h"
#include "xgobitypes.h"
#include "xgobivars.h"
#include "xgobiexterns.h"
X
#define JITFAC .2
static float jitfac = JITFAC;
float *jitfacv = (float *) NULL;
X
#define UNIFORM 0
#define NORMAL  1
X
static Widget jpopup = (Widget) NULL;
static Widget jittype[2];
static Boolean jitter_type = UNIFORM;
static Boolean jitter_vgroup = True;
Widget rejitter_cmd;
X
Boolean convex_jittering = True;
X
void
init_jitfac(xgobidata *xg)
{
X  int j;
X
X  if (xg->is_missing_values_xgobi)
X    jitfac = JITFAC;
X  else
X    jitfac = 0.;
X
/*
X * If there's going to be a different jitfac for each column ...
X *  The tricky part is that when a new variable is selected, if
X *  the jitter window is open, it should reset the scrollbar for
X *  the appropriate jitfac.  But it isn't quite possible, really,
X *  given that the two or more variables in the window might have
X *  very different jitfacs.
*/
X  jitfacv = (float *) XtMalloc((unsigned) xg->ncols * sizeof(float));
X  for (j=0; j<xg->ncols; j++)
X    jitfacv[j] = jitfac;
}
X
float
randval(int type)
{
/*
X * generate a random value.
*/
X  double drand;
X  static double dsave;
X  static Boolean isave = false;
X
X  if (type == UNIFORM) {
X    drand = randvalue();
X    /*
X     * Center and scale to [-1, 1]
X    */
X    drand = (drand - .5) * 2;
X
X  } else if (type == NORMAL) {
X
X    Boolean check = true;
X    double d, dfac;
X
X    if (isave) {
X      isave = false;
X      /* prepare to return the previously saved value */
X      drand = dsave;
X    } else {
X      isave = true;
X      while (check) {
X
X        rnorm2(&drand, &dsave);
X        d = drand*drand + dsave*dsave;
X
X        if (d < 1.0) {
X          check = false;
X          dfac = sqrt(-2. * log(d)/d);
X          drand = drand * dfac;
X          dsave = dsave * dfac;
X        }
X      } /* end while */
X    } /* end else */
X
X    /*
X     * Already centered; scale to approximately [-1, 1]
X    */
X    drand = (drand / 3.0);
X  }
X  return((float)drand);
}
X
void
jitter_data(xgobidata *xg)
{
X  int *cols;
X  int i, j, k, m, ncols = 0;
X  int nvgroups = numvargroups(xg);
X
/*
X * First determine the variables to be jittered:
X * this depends first on plotting mode and second on
X * vgroups (if jitter_vgroup is True)
*/
X
X  cols = (int *) XtMalloc((Cardinal) xg->ncols * sizeof(int));
X  ncols = find_selected_cols(xg, cols);
X
/*
X * Then vgroups ...  and the missing values xgobi should have
X * already been set up with vgroups = (0, ..., 0)
*/
X  if (jitter_vgroup && nvgroups < xg->ncols_used)
X    add_vgroups(xg, cols, &ncols);
X
X  for (i=0; i<xg->nrows_in_plot; i++) {
X    if ((m = xg->rows_in_plot[i]) >= xg->nlinkable)
X      break;
X    for (j=0; j<ncols; j++) {
X      k = cols[j];
X      jitfacv[k] = jitfac;
X
X      jitter_one_value(m, k, xg);
X    }
X  }
X
X  XtFree((char *) cols);
}
X
void
jitter_one_value(int m, int k, xgobidata *xg)
X  /* m is the row index, k is the column index */
{
X  long lrand, worldx;
X  float rjit;
X
X  lrand = (long) (randval(jitter_type) * (float) PRECISION1);
X
X  /*
X   * Confound: the world_data used here is already jittered:
X   * subtract out the previous jittered value ...
X  */
X  if (convex_jittering) {
X    worldx = xg->world_data[m][k] - xg->jitter_data[m][k];
X    rjit = jitfacv[k] * (float) (lrand - worldx);
X  }
X  else
X    rjit = jitfacv[k] * (float) lrand;
X
X  xg->jitter_data[m][k] = (long) rjit;
}
X
static void
setToggles(void) {
X  setToggleBitmap(jittype[0], jitter_type == UNIFORM);
X  setToggleBitmap(jittype[1], jitter_type == NORMAL);
}
X
/* ARGSUSED */
XXtCallbackProc
normal_jitter_cback(Widget w, xgobidata *xg, XtPointer slideposp)
{
X  Boolean set;
X
X  XtVaGetValues(w, XtNstate, &set, NULL);
X  if (set) {
X    jitter_type = NORMAL;
X    XtCallCallbacks(rejitter_cmd, XtNcallback, (XtPointer) xg);
X  }
X  setToggles();
}
X
/* ARGSUSED */
XXtCallbackProc
uniform_jitter_cback(Widget w, xgobidata *xg, XtPointer slideposp)
{
X  Boolean set;
X
X  XtVaGetValues(w, XtNstate, &set, NULL);
X  if (set) {
X    jitter_type = UNIFORM;
X    XtCallCallbacks(rejitter_cmd, XtNcallback, (XtPointer) xg);
X  }
X  setToggles();
}
X
void
jitter_again(xgobidata *xg) {
X  XtCallCallbacks(rejitter_cmd, XtNcallback, (XtPointer) xg);
}
X
/* ARGSUSED */
XXtCallbackProc
jitfac_cback(Widget w, xgobidata *xg, XtPointer slideposp)
{
X  float slidepos = * (float *) slideposp;
X
X  /* slidepos is on [0,1]; jitfac is also on [0,1] for now */
X  jitfac = (float) slidepos * (float) slidepos;
X  XtCallCallbacks(rejitter_cmd, XtNcallback, (XtPointer) xg);
}
X
/* ARGSUSED */
XXtCallbackProc
rejitter_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  jitter_data(xg);
X
X  /* jitter is added to world_data in tform_to_world and sphered_to_world */
X  update_world(xg);
X
X  world_to_plane(xg);
X  plane_to_screen(xg);
X
X  if (xg->is_brushing) {
X    assign_points_to_bins(xg);
X    if (xg->brush_mode == transient)
X      reinit_transient_brushing(xg);
X  }
X
X  plot_once(xg);
X  if (xg->is_cprof_plotting && xg->link_cprof_plotting)
X    update_cprof_plot(xg);
}
X
/* ARGSUSED */
static XtCallbackProc
close_jit_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  XtPopdown(jpopup);
}
X
/* ARGSUSED */
static XtCallbackProc
use_vgroups_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  jitter_vgroup = !jitter_vgroup;
X
X  setToggleBitmap(w, jitter_vgroup);
}
X
/* ARGSUSED */
XXtCallbackProc
open_jitter_popup_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  static Boolean initd = False;
X  Widget mframe, mform;
X  Widget use_vgroups_cmd, close_cmd;
X  Widget jitfac_label, jitfac_sbar;
X  Widget jittype_box;
X  char str[512];
X
X  if (!initd)
X  {
X    Dimension width, height;
X    Position x, y;
X
X    XtVaGetValues(w,
X      XtNwidth, &width,
X      XtNheight, &height, NULL);
X    XtTranslateCoords(w,
X      (Position) (width/2), (Position) (height/2), &x, &y);
X
X    /*
X     * Create the missing data popup
X    */
X    jpopup = XtVaCreatePopupShell("Jitter",
X      /*transientShellWidgetClass, XtParent(w),*/
X      topLevelShellWidgetClass, XtParent(w),
X      XtNinput,            (Boolean) True,
X      XtNallowShellResize, (Boolean) True,
X      XtNtitle,            (String) "Jitter data",
X      XtNiconName,         (String) "Jitter",
X      XtNx,                x,
X      XtNy,                y,
X      NULL);
X    if (mono) set_mono(jpopup);
X
X    /*
X     * Create a paned widget so the 'Click here ...'
X     * can be all across the bottom.
X    */
X    mframe = XtVaCreateManagedWidget("Form",
X      panedWidgetClass, jpopup,
X      XtNorientation, (XtOrientation) XtorientVertical,
X      NULL);
X    /*
X     * Create the form widget.
X    */
X    mform = XtVaCreateManagedWidget("Jitter",
X      formWidgetClass, mframe,
X      NULL);
X    if (mono) set_mono(mform);
X
X    init_jitfac(xg);
X
X    sprintf(str, "Degree of jitter");
X    width = XTextWidth(appdata.font, str, strlen(str)) +
X      2*ASCII_TEXT_BORDER_WIDTH;
X    jitfac_label = XtVaCreateManagedWidget("Jitter",
X      labelWidgetClass, mform,
X      XtNlabel, str,
X      XtNleft, (XtEdgeType) XtChainLeft,
X      XtNright, (XtEdgeType) XtChainLeft,
X      XtNtop, (XtEdgeType) XtChainTop,
X      XtNbottom, (XtEdgeType) XtChainTop,
X      NULL);
X    if (mono) set_mono(jitfac_label);
X
X    jitfac_sbar = XtVaCreateManagedWidget("Scrollbar",
X      scrollbarWidgetClass, mform,
X      XtNfromVert, (Widget) jitfac_label,
X      XtNvertDistance, (int) 0,
X      XtNwidth, width,
X      XtNorientation, (XtOrientation) XtorientHorizontal,
X      XtNleft, (XtEdgeType) XtChainLeft,
X      XtNright, (XtEdgeType) XtChainLeft,
X      XtNtop, (XtEdgeType) XtChainTop,
X      XtNbottom, (XtEdgeType) XtChainTop,
X      NULL);
X    if (mono) set_mono(jitfac_sbar);
X    add_sbar_help(&xg->nhelpids.sbar,
X      jitfac_sbar, "Jitter");
X    XawScrollbarSetThumb(jitfac_sbar, jitfac, -1.);
X    XtAddCallback(jitfac_sbar, XtNjumpProc,
X      (XtCallbackProc) jitfac_cback, (XtPointer) xg);
X
X    rejitter_cmd = (Widget) CreateCommand(xg, "Rejitter",
X      True, (Widget) NULL, (Widget) jitfac_sbar,
X      mform, "Jitter");
X    XtVaSetValues(rejitter_cmd,
X      XtNleft, (XtEdgeType) XtChainLeft,
X      XtNright, (XtEdgeType) XtChainLeft,
X      XtNtop, (XtEdgeType) XtChainTop,
X      XtNbottom, (XtEdgeType) XtChainTop,
X      NULL);
X    XtManageChild(rejitter_cmd);
X    XtAddCallback(rejitter_cmd, XtNcallback,
X      (XtCallbackProc) rejitter_cback, (XtPointer) xg);
X 
X    /* Uniform or normal variates? */
X
X    jittype_box = XtVaCreateManagedWidget("Panel",
X      boxWidgetClass, mform,
X      XtNleft, (XtEdgeType) XtChainLeft,
X      XtNright, (XtEdgeType) XtChainLeft,
X      XtNtop, (XtEdgeType) XtChainTop,
X      XtNbottom, (XtEdgeType) XtChainTop,
X      XtNorientation, (XtOrientation) XtorientHorizontal,
X      XtNfromVert, rejitter_cmd,
X      NULL);
X    if (mono) set_mono(jittype_box);
X
X    jittype[UNIFORM] = (Widget) CreateToggle(xg, "Uniform",
X      True, (Widget) NULL, (Widget) NULL, (Widget) NULL,
X      True, ONE_OF_MANY, jittype_box, "Jitter");
X    jittype[NORMAL] = (Widget) CreateToggle(xg, "Normal",
X      True, (Widget) NULL, (Widget) NULL, (Widget) jittype[UNIFORM],
X      False, ONE_OF_MANY, jittype_box, "Jitter");
X    XtManageChildren(jittype, 2);
X
X    XtAddCallback(jittype[UNIFORM], XtNcallback,
X      (XtCallbackProc) uniform_jitter_cback, (XtPointer) xg);
X    XtAddCallback(jittype[NORMAL], XtNcallback,
X      (XtCallbackProc) normal_jitter_cback, (XtPointer) xg);
X
X    use_vgroups_cmd = (Widget) CreateToggle(xg, "Jitter vgroup",
X      True, (Widget) NULL, (Widget) jittype_box, (Widget) NULL,
X      jitter_vgroup, ANY_OF_MANY, mform, "Jitter");
X    XtManageChild(use_vgroups_cmd);
X    XtAddCallback(use_vgroups_cmd, XtNcallback,
X      (XtCallbackProc) use_vgroups_cback, (XtPointer) xg);
X
X    close_cmd = XtVaCreateManagedWidget("Close",
X      commandWidgetClass, mframe,
X      XtNshowGrip, (Boolean) False,
X      XtNskipAdjust, (Boolean) True,
X      XtNlabel, (String) "Click here to dismiss",
X      NULL);
X    if (mono) set_mono(close_cmd);
X    XtAddCallback(close_cmd, XtNcallback,
X      (XtCallbackProc) close_jit_cback, (XtPointer) xg);
X  }
X
X  XtPopup(jpopup, (XtGrabKind) XtGrabNone);
X  XRaiseWindow(display, XtWindow(jpopup));
X
X  if (!initd)
X  {
X    set_wm_protocols(jpopup);
X    initd = True;
X  }
}
SHAR_EOF
  chmod 0644 'xgobi/src/jitter.c' ||
  $echo 'restore of' 'xgobi/src/jitter.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/jitter.c:' 'MD5 check failed'
402b6e0f0dda7aef08b1cf895a369511  xgobi/src/jitter.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/jitter.c'`"
    test 11617 -eq "$shar_count" ||
    $echo 'xgobi/src/jitter.c:' 'original size' '11617,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/diffs ==============
if test -f 'xgobi/src/diffs' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/diffs' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/diffs' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/diffs' &&
:::corr.c:::
42d41
< /*
47d45
< */
49c47
< /*static int counting_to_stop;*/
---
> static int counting_to_stop;
1770a1769
>   Boolean y_selected;
1837a1837
>   Boolean x_selected;
X
:::exclusion.c:::
277a278
>   Boolean excluded;
X
:::inference.c:::
42a43
> static Boolean inf_bgroup = False;
44c45
< static int ntform_cols, *tform_cols = NULL;
---
> static int    ntform_cols, *tform_cols = NULL;
165c166
<   int j, n;
---
>   int j, n, gid;
167d167
< /*
170d169
< */
385c384
<   register int j;
---
>   register int j, k;
X
:::kernel.c:::
127c127
<   float tmpf, dm, hf;/* window_width3;*/
---
>   float indx_val, tmpf, dm, hf;/* window_width3;*/
X
:::read_data.c:::
594c594
<   static char *suffixes[] = {".vgroups", ".vgroup"};
---
>   static char *suffixes[] = {".vgroups"};
605c605
<     if ( (fp = open_xgobi_file(data_in, 2, suffixes, "r", true)) != NULL)
---
>     if ( (fp = open_xgobi_file(data_in, 1, suffixes, "r", true)) != NULL)
942,944c942,943
<             (void) fprintf(stderr,
<               "!!Error in reading %s.glyphs; using defaults.\n",
<               data_in);
---
>             (void) fprintf(stderr, "!!Error in reading %s; using defaults.\n",
>               lab_file);
1221,1222c1220
<               "behavior during brushing and prevent you from saving colors.\n");
<             fprintf (stderr, "To read how to set the brushing\n");
---
>               "behavior during brushing.  To read how to set the brushing\n");
1509c1507
<   int i, j;
---
>   int i;
1510a1509
>   char *fname;
1562,1563c1561
<                   "Error in reading %s.linecolors; using defaults.\n",
<                   rootname);
---
>                   "Error in reading %s; using defaults.\n", fname);
1577,1579d1574
<         } else { /* no color name; initialize with default color */
<           xg->line_color_ids[i] = xg->line_color_now[i] =
<             xg->line_color_prev[i] = plotcolors.fg;
1583,1613d1577
< 
<       /*
<        * The colors that were supplied in the .linecolors
<        * should match the brushing colors (color_nums)
<        * If they don't, instruct the user to set the color
<        * resources.
<       */
<       for (i=0; i<xg->nlines; i++) {
<         found = False;
<         for (j=0; j<ncolors; j++) {
<           if (xg->line_color_now[i] == color_nums[j]) {
<             found = True;
<             break;
<           }
<         }
<         if (!found)
<           break;
<       }
<       if (!found)
<       {
<         fprintf(stderr,
<           "Warning:  Your .linecolors file contains colors that are not\n");
<         fprintf(stderr,
<           "available as brushing colors, which will cause weird\n");
<         fprintf(stderr,
<           "behavior during brushing and prevent you from saving colors.\n");
<         fprintf (stderr, "To read how to set the brushing\n");
<         fprintf(stderr,
<           "colors, click right on the Color Menu button.\n");
<       }
< 
X
:::save_data.c:::
1334d1333
<   XtFree(fname);
1342a1342
>       XtFree(fname);
1392d1391
<   XtFree(fname);
1400a1400
>       XtFree(fname);
1423d1422
<   Boolean color_found;
1472d1470
<           color_found = False;
1477d1474
<               color_found = True;
1481,1483d1477
<           if (!color_found) {  /*-- color not found, use Default --*/
<             (void) strcpy(NAMESV(ir), "Default");
<           }
1862d1855
<       XtFree (fname);
1873,1874d1865
< 
<   XtFree (fname);
1889d1879
<   Boolean color_found;
1912d1901
<       color_found = False;
1916c1905
<           color_found = True;
---
>           nameslen = nameslen + strlen(NAMESV(k)) + 1;
1920,1923d1908
<       if (!color_found) {  /*-- color not found, use Default --*/
<         (void) strcpy(NAMESV(k), "Default");
<       }
<       nameslen = nameslen + strlen(NAMESV(k)) + 1;
1927a1913
>      *
X
:::sphere.c:::
192c192
<   register int j;
---
>   register int j, k;
198a199,200
>   Dimension maxwidth = 0;
> 
259c261
<       sprintf(npc_lab,"%d", xg->nsph_vars);
---
>       sprintf(npc_lab,"%d %",xg->nsph_vars);
X
:::tour_pp.c:::
1599c1599
<   int i;
---
>   int i, j;
X
:::transform.c:::
181c181
<   int j;
---
>   int j, k;
322c322
<   int i;
---
>   int i, j, n;
347c347
<   int /* i, j, k, n, */ np;
---
>   int i, j, k, n, np;
355c355
<     j = jvar;
---
>     j = jvar;/*cols[n];*/
360c360
<   }*/
---
> /*  }*/
876,877c876
<   int j, n;
< /*
---
>   int j, n, gid;
879d877
< */
946c944
<   int tfno, j /*, k, groupno*/;
---
>   int tfno, j, k, groupno;
X
:::widgets.c:::
313d312
<   /* Find the widest label */
319a319
>   /* Find the widest label */
X
:::xgobi.c:::
60c60
< static char *version_date = "November 29, 2001";
---
> static char *version_date = "September 15, 2000";
X
X
:::xgv_help.c:::
79c79
<     Widget hpopup, hframe, htext, hdone;
---
>    Widget hpopup, hframe, htext, hdone;
198c198
<     Widget hpopup, hframe, hform, hfunc, htext, hdone;
---
>     Widget hpopup, hframe, htext, hdone;
272,274d271
< /*
<   Dimension height;
< */
322a320
>     Dimension height;
341d338
< /*
343d339
< */
413,415d408
< /*
<   Dimension height;
< */
463a457
>     Dimension height;
482d475
< /*
484d476
< */
X
:::xgv_histogram.c:::
255a256
>   /*
257c258
< 
---
>   */
X
:::xgvis.h:::
68c68
< XGVIS_ Boolean *anchored INIT(= NULL);
---
> XGVIS_ Boolean *anchor_group INIT(= NULL); 
SHAR_EOF
  chmod 0644 'xgobi/src/diffs' ||
  $echo 'restore of' 'xgobi/src/diffs' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/diffs:' 'MD5 check failed'
5a8330804f26e5d5a017028658910ab7  xgobi/src/diffs
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/diffs'`"
    test 5311 -eq "$shar_count" ||
    $echo 'xgobi/src/diffs:' 'original size' '5311,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/make.out ==============
if test -f 'xgobi/src/make.out' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/make.out' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/make.out' '(binary)'
  sed 's/^X//' << 'SHAR_EOF' | uudecode &&
begin 600 xgobi/src/make.out
M8V,@+6<@+7AA;G-I("UN,S(@("`@("UN;W-T9&EN8R`M22]U<W(O:6YC;'5D
M92`M1%-94U8@+4135E(T("`@+41&54Y#4%)/5$\]-R`M1$Y!4E)/5U!23U1/
M("`M1$1%1D%53%1$25(]7"(O=7-R+V1F<R]X9V]B:2]X9V]B:2]S<F,O+BY<
M(B`@("UC('AG=FES+F,@+6\@>&=V:7,N;PIC8R`M9R`M>&%N<VD@+6XS,B`@
M("`@+6YO<W1D:6YC("U)+W5S<B]I;F-L=61E("U$4UE35B`M1%-64C0@("`M
M1$953D-04D]43STW("U$3D%24D]74%)/5$\@("U$1$5&055,5$1)4CU<(B]U
M<W(O9&9S+WAG;V)I+WAG;V)I+W-R8R\N+EPB("`@+6,@>&=V7VAI<W1O9W)A
M;2YC("UO('AG=E]H:7-T;V=R86TN;PIC8RTQ,3$V(&-C.B!705).24Y'($9I
M;&4@/2!X9W9?:&ES=&]G<F%M+F,L($QI;F4@/2`R,C$*("!.;VXM=F]I9"!F
M=6YC=&EO;B`B=&AR7V5X<&]S95]C8F%C:R(@*&1E8VQA<F5D(&%T(&QI;F4@
M,C$X*2!S:&]U;&0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:5]I;FET+F\*8V,@+6<@+7AA;G-I("UN,S(@
M("`@("UN;W-T9&EN8R`M22]U<W(O:6YC;'5D92`M1%-94U8@+4135E(T("`@
M+41&54Y#4%)/5$\]-R`M1$Y!4E)/5U!23U1/("`M1$1%1D%53%1$25(]7"(O
M=7-R+V1F<R]X9V]B:2]X9V]B:2]S<F,O+BY<(B`@("UC('!I<&5L:6YE+F,@
M+6\@<&EP96QI;F4N;PIC8R`M9R`M>&%N<VD@+6XS,B`@("`@+6YO<W1D:6YC
M("U)+W5S<B]I;F-L=61E("U$4UE35B`M1%-64C0@("`M1$953D-04D]43STW
M("U$3D%24D]74%)/5$\@("U$1$5&055,5$1)4CU<(B]U<W(O9&9S+WAG;V)I
M+WAG;V)I+W-R8R\N+EPB("`@+6,@<F5A9%]A<G)A>2YC("UO(')E861?87)R
M87DN;PIC8RTQ-34R(&-C.B!705).24Y'($9I;&4@/2!R96%D7V%R<F%Y+F,L
M($QI;F4@/2`S-3D*("!4:&4@=F%R:6%B;&4@(F-H(B!I<R!S970@8G5T(&YE
M=F5R('5S960N"@H@("`@:6YT(&DL(&9I;&5?<F]W+"!C:#L@("\J(&-H(&ES
M('5S960L(&YO(&UA='1E<B!W:&%T('1H92!C;VUP:6QE<B!S87ES("HO"B`@
M("`@("`@("`@("`@("`@("`@(%X*"F-C("UG("UX86YS:2`M;C,R("`@("`M
M;F]S=&1I;F,@+4DO=7-R+VEN8VQU9&4@+41365-6("U$4U92-"`@("U$1E5.
M0U!23U1//3<@+41.05)23U=04D]43R`@+41$149!54Q41$E2/5PB+W5S<B]D
M9G,O>&=O8FDO>&=O8FDO<W)C+RXN7"(@("`M8R!I;FET:6%L:7IE+F,@+6\@
M:6YI=&EA;&EZ92YO"F-C("UG("UX86YS:2`M;C,R("`@("`M;F]S=&1I;F,@
M+4DO=7-R+VEN8VQU9&4@+41365-6("U$4U92-"`@("U$1E5.0U!23U1//3<@
M+41.05)23U=04D]43R`@+41$149!54Q41$E2/5PB+W5S<B]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4N8RP@3&EN92`](#0S"B`@3F]N+79O:60@9G5N
M8W1I;VX@(F-H;V]S95]S=&1V:65W7V-B86-K(B`H9&5C;&%R960@870@;&EN
M92`Q,2D@<VAO=6QD(')E='5R;B!A"B`@("`@("`@("!V86QU92X*"B`@?0H@
M(%X*"F-C("UG("UX86YS:2`M;C,R("`@("`M;F]S=&1I;F,@+4DO=7-R+VEN
M8VQU9&4@+41365-6("U$4U92-"`@("U$1E5.0U!23U1//3<@+41.05)23U=0
M4D]43R`@+41$149!54Q41$E2/5PB+W5S<B]D9G,O>&=O8FDO>&=O8FDO<W)C
M+RXN7"(@("`M8R!I;F9E<F5N8V4N8R`M;R!I;F9E<F5N8V4N;PIC8RTQ,3$V
M(&-C.B!705).24Y'($9I;&4@/2!I;F9E<F5N8V4N8RP@3&EN92`](#(Q-0H@
M($YO;BUV;VED(&9U;F-T:6]N(")C;&]S95]C8F%C:R(@*&1E8VQA<F5D(&%T
M(&QI;F4@,C$Q*2!S:&]U;&0@<F5T=7)N(&$@=F%L=64N"@H@('T*("!>"@IC
M8RTQ,38T(&-C.B!705).24Y'($9I;&4@/2!I;F9E<F5N8V4N8RP@3&EN92`]
M(#(S-0H@($%R9W5M96YT(&]F('1Y<&4@(FEN="`H*BDH9FQO870@*BP@9FQO
M870@*BDB(&ES(&EN8V]M<&%T:6)L92!W:71H('!A<F%M971E<B!O9@H@("`@
M("`@("`@='EP92`B:6YT("@J*2AC;VYS="!V;VED("HL(&-O;G-T('9O:60@
M*BDB+@H*("`@("`@<7-O<G0H*&-H87(@*BD@<V]R=%]D871A+"!X9RT^;G)O
M=W,L('-I>F5O9BAF;&]A="DL('-O<G1?8V]M<&%R92D["B`@("`@("`@("`@
M("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@
M("!>"@IC8RTQ,3$V(&-C.B!705).24Y'($9I;&4@/2!I;F9E<F5N8V4N8RP@
M3&EN92`](#(T-`H@($YO;BUV;VED(&9U;F-T:6]N(")S;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.;VXM=F]I9"!F=6YC=&EO;B`B8VAO;W-E
M7V-O;&]R7V-B86-K(B`H9&5C;&%R960@870@;&EN92`Q.#(I('-H;W5L9"!R
M971U<FX@80H@("`@("`@("`@=F%L=64N"@H@('T*("!>"@IC8RTQ,3$V(&-C
M.B!705).24Y'($9I;&4@/2!B<G5S:%]I;FET+F,L($QI;F4@/2`S-3(*("!.
M;VXM=F]I9"!F=6YC=&EO;B`B8VAO;W-E7V=L>7!H7V-B86-K(B`H9&5C;&%R
M960@870@;&EN92`S,3@I('-H;W5L9"!R971U<FX@80H@("`@("`@("`@=F%L
M=64N"@H@('T*("!>"@IC8RTQ,3$V(&-C.B!705).24Y'($9I;&4@/2!B<G5S
M:%]I;FET+F,L($QI;F4@/2`V,S4*("!.;VXM=F]I9"!F=6YC=&EO;B`B8G)?
M;&EN:V]P=%]M96YU7V-B86-K(B`H9&5C;&%R960@870@;&EN92`U-S$I('-H
M;W5L9"!R971U<FX*("`@("`@("`@(&$@=F%L=64N"@H@('T*("!>"@IC8RTQ
M,3$V(&-C.B!705).24Y'($9I;&4@/2!B<G5S:%]I;FET+F,L($QI;F4@/2`W
M-#,*("!.;VXM=F]I9"!F=6YC=&EO;B`B8G)?;W!T7VUE;G5?8V)A8VLB("AD
M96-L87)E9"!A="!L:6YE(#<R,RD@<VAO=6QD(')E='5R;B!A"B`@("`@("`@
M("!V86QU92X*"B`@?0H@(%X*"F-C("UG("UX86YS:2`M;C,R("`@("`M;F]S
M=&1I;F,@+4DO=7-R+VEN8VQU9&4@+41365-6("U$4U92-"`@("U$1E5.0U!2
M3U1//3<@+41.05)23U=04D]43R`@+41$149!54Q41$E2/5PB+W5S<B]D9G,O
M>&=O8FDO>&=O8FDO<W)C+RXN7"(@("`M8R!B<G5S:%]C8F%C:W,N8R`M;R!B
M<G5S:%]C8F%C:W,N;PIC8RTQ,3$V(&-C.B!705).24Y'($9I;&4@/2!B<G5S
M:%]C8F%C:W,N8RP@3&EN92`](#0R"B`@3F]N+79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-K(B`H9&5C;&%R960@870@;&EN92`R,C<I('-H;W5L9"!R971U<FX@
M80H@("`@("`@("`@=F%L=64N"@H@('T*("!>"@IC8RTQ,3$V(&-C.B!705).
M24Y'($9I;&4@/2!B<G5S:%]C8F%C:W,N8RP@3&EN92`](#,V,@H@($YO;BUV
M;VED(&9U;F-T:6]N(")D96QE=&5?97)A<V5D7V-B86-K(B`H9&5C;&%R960@
M870@;&EN92`S,C@I('-H;W5L9"!R971U<FX@80H@("`@("`@("`@=F%L=64N
M"@H@('T*("!>"@IC8R`M9R`M>&%N<VD@+6XS,B`@("`@+6YO<W1D:6YC("U)
M+W5S<B]I;F-L=61E("U$4UE35B`M1%-64C0@("`M1$953D-04D]43STW("U$
M3D%24D]74%)/5$\@("U$1$5&055,5$1)4CU<(B]U<W(O9&9S+WAG;V)I+WAG
M;V)I+W-R8R\N+EPB("`@+6,@8G)U<V@N8R`M;R!B<G5S:"YO"F-C+3$Q,38@
M8V,Z(%=!4DY)3D<@1FEL92`](&)R=7-H+F,L($QI;F4@/2`S-C(*("!.;VXM
M=F]I9"!F=6YC=&EO;B`B8G)U<VA?;6]T:6]N(B`H9&5C;&%R960@870@;&EN
M92`S,#4I('-H;W5L9"!R971U<FX@82!V86QU92X*"B`@?0H@(%X*"F-C+3$Q
M,38@8V,Z(%=!4DY)3D<@1FEL92`](&)R=7-H+F,L($QI;F4@/2`U,3D*("!.
M;VXM=F]I9"!F=6YC=&EO;B`B8G)U<VA?8G5T=&]N(B`H9&5C;&%R960@870@
M;&EN92`S-S0I('-H;W5L9"!R971U<FX@82!V86QU92X*"B`@?0H@(%X*"F-C
M("UG("UX86YS:2`M;C,R("`@("`M;F]S=&1I;F,@+4DO=7-R+VEN8VQU9&4@
M+41365-6("U$4U92-"`@("U$1E5.0U!23U1//3<@+41.05)23U=04D]43R`@
M+41$149!54Q41$E2/5PB+W5S<B]D9G,O>&=O8FDO>&=O8FDO<W)C+RXN7"(@
M("`M8R!P86EN="YC("UO('!A:6YT+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`H9&5C;&%R960@870@;&EN92`V,S$I
M('-H;W5L9"!R971U<FX*("`@("`@("`@(&$@=F%L=64N"@H@('!A8VM?;&EN
M95]B<G5S:%]D;VYE*%=I9&=E="!W+"!!=&]M("IS96QE8W1I;VXL($%T;VT@
M*G1A<F=E="D@>R!]"B`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@
M("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@(%X*"F-C+3$Q,38@
M8V,Z(%=!4DY)3D<@1FEL92`](&)R=7-H7W-E;F0N8RP@3&EN92`](#8S-0H@
M($YO;BUV;VED(&9U;F-T:6]N(")P86-K7VQI;F5?8G)U<VA?;&]S92(@*&1E
M8VQA<F5D(&%T(&QI;F4@-C,U*2!S:&]U;&0@<F5T=7)N"B`@("`@("`@("!A
M('9A;'5E+@H*("!P86-K7VQI;F5?8G)U<VA?;&]S92A7:61G970@=RP@071O
M;2`J<V5L96-T:6]N+"!8=%!O:6YT97(@>&=O8FDI('L@?0H@("`@("`@("`@
M("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@
M("`@("`@("`@("`@("!>"@IC8RTQ,3$V(&-C.B!705).24Y'($9I;&4@/2!B
M<G5S:%]S96YD+F,L($QI;F4@/2`W,#@*("!.;VXM=F]I9"!F=6YC=&EO;B`B
M<&%C:U]L:6YE7V)R=7-H7V1A=&$B("AD96-L87)E9"!A="!L:6YE(#8U,RD@
M<VAO=6QD(')E='5R;@H@("`@("`@("`@82!V86QU92X*"B`@?0H@(%X*"F-C
M+3$Q,38@8V,Z(%=!4DY)3D<@1FEL92`](&)R=7-H7W-E;F0N8RP@3&EN92`]
M(#<X-0H@($YO;BUV;VED(&9U;F-T:6]N(")U;G!A8VM?;&EN95]B<G5S:%]D
M871A(B`H9&5C;&%R960@870@;&EN92`W,3(I('-H;W5L9`H@("`@("`@("`@
M<F5T=7)N(&$@=F%L=64N"@H@('T*("!>"@IC8RTQ-34R(&-C.B!705).24Y'
M($9I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`Q-#<*("!.;VXM=F]I
M9"!F=6YC=&EO;B`B8G-P;'9B9FY?(B`H9&5C;&%R960@870@;&EN92`Q,#8I
M('-H;W5L9"!R971U<FX@82!V86QU92X*"B`@?2`O*B!B<W!L=F)F;E\@*B\*
M("!>"@IC8RTQ-34R(&-C.B!705).24Y'($9I;&4@/2!P<W!L:6YE+F,L($QI
M;F4@/2`Y,C(*("!4:&4@=F%R:6%B;&4@(FQP,2(@:7,@<V5T(&)U="!N979E
M<B!U<V5D+@H*("`@("`@<W1A=&EC(&EN=&5G97(@:6QI;2P@:2P@:RP@;"P@
M:W`Q+"!L<#$L(&UP,2P@:7!K+"!I<&P["B`@("`@("`@("`@("`@("`@("`@
M("`@("`@("`@("`@("`@("`@("`@7@H*8V,M,34U,B!C8SH@5T%23DE.1R!&
M:6QE(#T@<'-P;&EN92YC+"!,:6YE(#T@,3`S.`H@(%1H92!V87)I86)L92`B
M;G=O<FMS:7HB(&ES('-E="!B=70@;F5V97(@=7-E9"X*"B`@("`@('-T871I
M8R!I;G1E9V5R(&YM;F]R9&5R+"!I>6]F9G-E="P@;G=O<FMS:7HL(&DL(&HL
M(&PL(&TL(&YB86YD.PH@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@
M("`@("`@("`@(%X*"F-C("UG("UX86YS:2`M;C,R("`@("`M;F]S=&1I;F,@
M+4DO=7-R+VEN8VQU9&4@+41365-6("U$4U92-"`@("U$1E5.0U!23U1//3<@
M+41.05)23U=04D]43R`@+41$149!54Q41$E2/5PB+W5S<B]D9G,O>&=O8FDO
M>&=O8FDO<W)C+RXN7"(@("`M8R!S879E7V1A=&$N8R`M;R!S879E7V1A=&$N
M;PIC8RTQ,3$V(&-C.B!705).24Y'($9I;&4@/2!S879E7V1A=&$N8RP@3&EN
M92`](#$R,@H@($YO;BUV;VED(&9U;F-T:6]N(")S879E7W1O9V=L95]C8F%C
M:R(@*&1E8VQA<F5D(&%T(&QI;F4@,3$W*2!S:&]U;&0@<F5T=7)N(&$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05).24Y'($9I;&4@/2!J:71T97(N8RP@3&EN92`](#(Q-0H@($YO;BUV;VED
M(&9U;F-T:6]N(")U;FEF;W)M7VII='1E<E]C8F%C:R(@*&1E8VQA<F5D(&%T
M(&QI;F4@,C`U*2!S:&]U;&0@<F5T=7)N"B`@("`@("`@("!A('9A;'5E+@H*
M("!]"B`@7@H*8V,M,3$Q-B!C8SH@5T%23DE.1R!&:6QE(#T@:FET=&5R+F,L
M($QI;F4@/2`R,S$*("!.;VXM=F]I9"!F=6YC=&EO;B`B:FET9F%C7V-B86-K
M(B`H9&5C;&%R960@870@;&EN92`R,C0I('-H;W5L9"!R971U<FX@82!V86QU
M92X*"B`@?0H@(%X*"F-C+3$Q,38@8V,Z(%=!4DY)3D<@1FEL92`](&II='1E
M<BYC+"!,:6YE(#T@,C4T"B`@3F]N+79O:60@9G5N8W1I;VX@(G)E:FET=&5R
M7V-B86-K(B`H9&5C;&%R960@870@;&EN92`R,S4I('-H;W5L9"!R971U<FX@
M80H@("`@("`@("`@=F%L=64N"@H@('T*("!>"@IC8RTQ,3$V(&-C.B!705).
M24Y'($9I;&4@/2!J:71T97(N8RP@3&EN92`](#(V,0H@($YO;BUV;VED(&9U
M;F-T:6]N(")C;&]S95]J:71?8V)A8VLB("AD96-L87)E9"!A="!L:6YE(#(U
M."D@<VAO=6QD(')E='5R;B!A"B`@("`@("`@("!V86QU92X*"B`@?0H@(%X*
M"F-C+3$Q,38@8V,Z(%=!4DY)3D<@1FEL92`](&II='1E<BYC+"!,:6YE(#T@
M,C<P"B`@3F]N+79O:60@9G5N8W1I;VX@(G5S95]V9W)O=7!S7V-B86-K(B`H
M9&5C;&%R960@870@;&EN92`R-C4I('-H;W5L9"!R971U<FX@80H@("`@("`@
M("`@=F%L=64N"@H@('T*("!>"@IC8RTQ,3$V(&-C.B!705).24Y'($9I;&4@
M/2!J:71T97(N8RP@3&EN92`](#0R,PH@($YO;BUV;VED(&9U;F-T:6]N(")O
M<&5N7VII='1E<E]P;W!U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C:R(@*&1E
M8VQA<F5D(&%T(&QI;F4@,30X.2D@<VAO=6QD(')E='5R;B!A"B`@("`@("`@
M("!V86QU92X*"B`@?0H@(%X*"F-C+3$Q,38@8V,Z(%=!4DY)3D<@1FEL92`]
M('!A<F-O;W)D<RYC+"!,:6YE(#T@,3<T,PH@($YO;BUV;VED(&9U;F-T:6]N
M(")C<')O9E]P;&]T7V-B86-K(B`H9&5C;&%R960@870@;&EN92`Q-3`V*2!S
M:&]U;&0@<F5T=7)N(&$*("`@("`@("`@('9A;'5E+@H*("!]"B`@7@H*8V,M
M,34U,B!C8SH@5T%23DE.1R!&:6QE(#T@<&%R8V]O<F1S+F,L($QI;F4@/2`X
M-PH@(%1H92!V87)I86)L92`B<&-R7WET:6-K7W-E9W,B(&ES('-E="!B=70@
M;F5V97(@=7-E9"X*"B`@<W1A=&EC(%A396=M96YT('!C<E]Y=&EC:U]S96=S
M6S$P,%T["B`@("`@("`@("`@("`@("`@(%X*"F-C("UG("UX86YS:2`M;C,R
M("`@("`M;F]S=&1I;F,@+4DO=7-R+VEN8VQU9&4@+41365-6("U$4U92-"`@
M("U$1E5.0U!23U1//3<@+41.05)23U=04D]43R`@+41$149!54Q41$E2/5PB
M+W5S<B]D9G,O>&=O8FDO>&=O8FDO<W)C+RXN7"(@("`M8R!U=&EL<RYC("UO
M('5T:6QS+F\*8V,@+6<@+7AA;G-I("UN,S(@("`@("UN;W-T9&EN8R`M22]U
M<W(O:6YC;'5D92`M1%-94U8@+4135E(T("`@+41&54Y#4%)/5$\]-R`M1$Y!
M4E)/5U!23U1/("`M1$1%1D%53%1$25(]7"(O=7-R+V1F<R]X9V]B:2]X9V]B
M:2]S<F,O+BY<(B`@("UC('1O=7)?:6YI="YC("UO('1O=7)?:6YI="YO"F-C
M("UG("UX86YS:2`M;C,R("`@("`M;F]S=&1I;F,@+4DO=7-R+VEN8VQU9&4@
M+41365-6("U$4U92-"`@("U$1E5.0U!23U1//3<@+41.05)23U=04D]43R`@
M+41$149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)N(&$*("`@("`@
M("`@('9A;'5E+@H*("!]"B`@7@H*8V,@+6<@+7AA;G-I("UN,S(@("`@("UN
M;W-T9&EN8R`M22]U<W(O:6YC;'5D92`M1%-94U8@+4135E(T("`@+41&54Y#
M4%)/5$\]-R`M1$Y!4E)/5U!23U1/("`M1$1%1D%53%1$25(]7"(O=7-R+V1F
M<R]X9V]B:2]X9V]B:2]S<F,O+BY<(B`@("UC('-V9"YC("UO('-V9"YO"F-C
M("UG("UX86YS:2`M;C,R("`@("`M;F]S=&1I;F,@+4DO=7-R+VEN8VQU9&4@
M+41365-6("U$4U92-"`@("U$1E5.0U!23U1//3<@+41.05)23U=04D]43R`@
M+41$149!54Q41$E2/5PB+W5S<B]D9G,O>&=O8FDO>&=O8FDO<W)C+RXN7"(@
M("`M8R!K97)N96PN8R`M;R!K97)N96PN;PIC8R`M9R`M>&%N<VD@+6XS,B`@
M("`@+6YO<W1D:6YC("U)+W5S<B]I;F-L=61E("U$4UE35B`M1%-64C0@("`M
M1$953D-04D]43STW("U$3D%24D]74%)/5$\@("U$1$5&055,5$1)4CU<(B]U
M<W(O9&9S+WAG;V)I+WAG;V)I+W-R8R\N+EPB("`@+6,@;&5G96YD<F4N8R`M
M;R!L96=E;F1R92YO"F-C("UG("UX86YS:2`M;C,R("`@("`M;F]S=&1I;F,@
M+4DO=7-R+VEN8VQU9&4@+41365-6("U$4U92-"`@("U$1E5.0U!23U1//3<@
M+41.05)23U=04D]43R`@+41$149!54Q41$E2/5PB+W5S<B]D9G,O>&=O8FDO
M>&=O8FDO<W)C+RXN7"(@("`M8R!H97)M:71E+F,@+6\@:&5R;6ET92YO"F-C
M("UG("UX86YS:2`M;C,R("`@("`M;F]S=&1I;F,@+4DO=7-R+VEN8VQU9&4@
M+41365-6("U$4U92-"`@("U$1E5.0U!23U1//3<@+41.05)23U=04D]43R`@
M+41$149!54Q41$E2/5PB+W5S<B]D9G,O>&=O8FDO>&=O8FDO<W)C+RXN7"(@
M("`M8R!N871R;%]H97)M:71E+F,@+6\@;F%T<FQ?:&5R;6ET92YO"F-C("UG
M("UX86YS:2`M;C,R("`@("`M;F]S=&1I;F,@+4DO=7-R+VEN8VQU9&4@+413
M65-6("U$4U92-"`@("U$1E5.0U!23U1//3<@+41.05)23U=04D]43R`@+41$
M149!54Q41$E2/5PB+W5S<B]D9G,O>&=O8FDO>&=O8FDO<W)C+RXN7"(@("`M
M8R!D95]I;F1I8V5S+F,@+6\@9&5?:6YD:6-E<RYO"F-C("UG("UX86YS:2`M
M;C,R("`@("`M;F]S=&1I;F,@+4DO=7-R+VEN8VQU9&4@+41365-6("U$4U92
M-"`@("U$1E5.0U!23U1//3<@+41.05)23U=04D]43R`@+41$149!54Q41$E2
M/5PB+W5S<B]D9G,O>&=O8FDO>&=O8FDO<W)C+RXN7"(@("`M8R!C96YT<F%L
M7VUA<W,N8R`M;R!C96YT<F%L7VUA<W,N;PIC8R`M9R`M>&%N<VD@+6XS,B`@
M("`@+6YO<W1D:6YC("U)+W5S<B]I;F-L=61E("U$4UE35B`M1%-64C0@("`M
M1$953D-04D]43STW("U$3D%24D]74%)/5$\@("U$1$5&055,5$1)4CU<(B]U
M<W(O9&9S+WAG;V)I+WAG;V)I+W-R8R\N+EPB("`@+6,@:&]L97,N8R`M;R!H
M;VQE<RYO"F-C("UG("UX86YS:2`M;C,R("`@("`M;F]S=&1I;F,@+4DO=7-R
M+VEN8VQU9&4@+41365-6("U$4U92-"`@("U$1E5.0U!23U1//3<@+41.05)2
M3U=04D]43R`@+41$149!54Q41$E2/5PB+W5S<B]D9G,O>&=O8FDO>&=O8FDO
M<W)C+RXN7"(@("`M8R!S:V5W;F5S<RYC("UO('-K97=N97-S+F\*8V,@+6<@
M+7AA;G-I("UN,S(@("`@("UN;W-T9&EN8R`M22]U<W(O:6YC;'5D92`M1%-9
M4U8@+4135E(T("`@+41&54Y#4%)/5$\]-R`M1$Y!4E)/5U!23U1/("`M1$1%
M1D%53%1$25(]7"(O=7-R+V1F<R]X9V]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5D.PH@("`@("`@("`@("`@("`@("`@("`@
M("!>"@IC8RTQ,3<T(&-C.B!705).24Y'($9I;&4@/2!C;W)R+F,L($QI;F4@
M/2`R-S@Q"B`@5&AE('9A<FEA8FQE(")Y7V-V87)N;R(@=V%S(&1E8VQA<F5D
M(&)U="!N979E<B!R969E<F5N8V5D+@H*("`@(&EN="!Y7V-V87)N;RP@>%]C
M=F%R;F\["B`@("`@("`@7@H*8V,M,3$W-"!C8SH@5T%23DE.1R!&:6QE(#T@
M8V]R<BYC+"!,:6YE(#T@,C<X-`H@(%1H92!V87)I86)L92`B>5]S96QE8W1E
M9"(@=V%S(&1E8VQA<F5D(&)U="!N979E<B!R969E<F5N8V5D+@H*("`@($)O
M;VQE86X@>5]S96QE8W1E9"P@>%]S96QE8W1E9#L*("`@("`@("`@("`@7@H*
M8V,M,34U,B!C8SH@5T%23DE.1R!&:6QE(#T@8V]R<BYC+"!,:6YE(#T@-34*
M("!4:&4@=F%R:6%B;&4@(FUA>%]C;FAI<W1?;&ES="(@:7,@<V5T(&)U="!N
M979E<B!U<V5D+@H*("!S=&%T:6,@:6YT(&-N:&ES=%]L:7-T+"!O;&1?8VYH
M:7-T7VQI<W0L(&UA>%]C;FAI<W1?;&ES="P@8V)T7V1I<CL*("`@("`@("`@
M("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@(%X*"F-C("UG("UX
M86YS:2`M;C,R("`@("`M;F]S=&1I;F,@+4DO=7-R+VEN8VQU9&4@+41365-6
M("U$4U92-"`@("U$1E5.0U!23U1//3<@+41.05)23U=04D]43R`@+41$149!
M54Q41$E2/5PB+W5S<B]D9G,O>&=O8FDO>&=O8FDO<W)C+RXN7"(@("`M8R!C
M;W)R7VEN9&5X+F,@+6\@8V]R<E]I;F1E>"YO"F-C("UG("UX86YS:2`M;C,R
M("`@("`M;F]S=&1I;F,@+4DO=7-R+VEN8VQU9&4@+41365-6("U$4U92-"`@
M("U$1E5.0U!23U1//3<@+41.05)23U=04D]43R`@+41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6&UU("UL6'0@+6Q332`M
M;$E#12`M;%AE>'0@+6Q8,3$@"F-C("UG("UX86YS:2`M;C,R("`@("`M;F]S
M=&1I;F,@+4DO=7-R+VEN8VQU9&4@+41365-6("U$4U92-"`@("U$1E5.0U!2
M3U1//3<@+41.05)23U=04D]43R`@+41$149!54Q41$E2/5PB+W5S<B]D9G,O
M>&=O8FDO>&=O8FDO<W)C+RXN7"(@("`M8R!X9V]B:2YC("UO('AG;V)I+F\*
M8V,M,3$W."!C8SH@5T%23DE.1R!&:6QE(#T@>&=O8FDN8RP@3&EN92`](#,X
M-@H@($%R9W5M96YT(&ES(&EN8V]M<&%T:6)L92!W:71H('1H92!C;W)R97-P
M;VYD:6YG(&9O<FUA="!S=')I;F<@8V]N=F5R<VEO;BX*"B`@("`@("`@("`H
M=F]I9"D@<W-C86YF("@F879;,EU;,5TL("(E6UXG77,B+"`F>&=O8FDN=G1I
M=&QE*3L*("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@
M("`@("`@(%X*"F-C+3$Q-S@@8V,Z(%=!4DY)3D<@1FEL92`]('AG;V)I+F,L
M($QI;F4@/2`S.#@*("!!<F=U;65N="!I<R!I;F-O;7!A=&EB;&4@=VET:"!T
M:&4@8V]R<F5S<&]N9&EN9R!F;W)M870@<W1R:6YG(&-O;G9E<G-I;VXN"@H@
M("`@("`@("`@*'9O:60I('-S8V%N9B`H)F%V6S)=6S%=+"`B)5M>7")=<R(L
M("9X9V]B:2YV=&ET;&4I.PH@("`@("`@("`@("`@("`@("`@("`@("`@("`@
M("`@("`@("`@("`@("`@("`@(%X*"F-C+3$Q-S@@8V,Z(%=!4DY)3D<@1FEL
M92`]('AG;V)I+F,L($QI;F4@/2`S.3`*("!!<F=U;65N="!I<R!I;F-O;7!A
M=&EB;&4@=VET:"!T:&4@8V]R<F5S<&]N9&EN9R!F;W)M870@<W1R:6YG(&-O
M;G9E<G-I;VXN"@H@("`@("`@("`@*'9O:60I('-S8V%N9B`H879;,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E
M<F4N;R!S=&1I>F4N;R!I;F9E<F5N8V4N;R!B<G5S:%]I;FET+F\@8G)U<VA?
M8V)A8VMS+F\@8G)U<V@N;R!P86EN="YO(&)R=7-H7W-E;F0N;R!H96QP+F\@
M<')T7W!L;W1W:6XN;R!S=6)S970N;R!V8U]L:7-T<RYO(&5X8VQU<VEO;BYO
M('!L;W1?;VYC92YO('!L;W0Q9"YO('1E>'1U<F4N;R!A<V@Q9"YO(&UO=F5?
M<&]I;G1S+F\@<VAO=U]M97-S86=E+F\@<VUO;W1H+F\@<VUO;W1H7V9N<RYO
M('-M;V]T:'-K+F\@<'-P;&EN92YO('-A=F5?9&%T82YO(&YE=U]D871A+F\@
M<F5A9%]D871A+F\@:FET=&5R+F\@<&%R8V]O<F1S+F\@=71I;',N;R!T;W5R
M7VEN:70N;R!T;W5R7W5T:6PN;R!T;W5R+F\@=&]U<E]C8F%C:W,N;R!T;W5R
M7W-E;F0N;R!G=%]C=&QS+F\@=&]U<E]P<"YO('-V9"YO(&ME<FYE;"YO(&QE
M9V5N9')E+F\@:&5R;6ET92YO(&YA=')L7VAE<FUI=&4N;R!D95]I;F1I8V5S
M+F\@8V5N=')A;%]M87-S+F\@:&]L97,N;R!S:V5W;F5S<RYO('1O=7)?<V5C
M=&EO;BYO(&-O<G(N;R!C;W)R7VEN9&5X+F\@8V]R<E]P=7)S=6ET+F\@8V]R
M<E]U=&EL+F\@1')A=VEN9T$N;R!M=#$Y.3,W+3$N;R`@("`@+6YO<W1D;&EB
M("U,+W5S<B]L:6(S,B]M:7!S,R`M3"]U<W(O;&EB,S(@("UL;2`@("`M;%AA
F=R`M;%AM=2`M;%AT("UL4TT@+6Q)0T4@+6Q897AT("UL6#$Q(`H@
`
end
SHAR_EOF
  chmod 0644 'xgobi/src/make.out' ||
  $echo 'restore of' 'xgobi/src/make.out' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/make.out:' 'MD5 check failed'
ae4cbf9826fc37591591cd2ea350b08a  xgobi/src/make.out
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/make.out'`"
    test 76763 -eq "$shar_count" ||
    $echo 'xgobi/src/make.out:' 'original size' '76763,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/rpc_server_svc.c ==============
if test -f 'xgobi/src/rpc_server_svc.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/rpc_server_svc.c' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/rpc_server_svc.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/rpc_server_svc.c' &&
/***********************************************************************
X * Permission is hereby granted to any individual or institution       *
X * for use, copying, or redistribution of the AV2XGobi C code          *
X * and associated documentation, provided such code and documentation  *
X * are not sold for profit and the following copyright notice is       *
X * retained in the code and documentation:                             *
X *                                                                     *
X *   Copyright (c) 1995 Iowa State University                          *
X *                                                                     *
X * We encourage you to share questions, comments and modifications.    *
X *                                                                     *
X *   Juergen Symanzik (symanzik@iastate.edu)                           *
X *   Dianne Cook (dicook@iastate.edu)                                  *
X *   James J. Majure (majure@iastate.edu)                              *
X *   Martin Schneider (maschn@informatik.uni-marburg.de)               *
X *                                                                     *
X * The code in this file was generated by ESRI, using rpcgen.          *
X * It has been modified to provide the functionality required for      *
X * the AV2XGOBI link.                                                  *
X *                                                                     *
X ***********************************************************************/
X
/* @(#)aiserver.x	1.1 4/28/94 10:19:11 */
X
/* !!!MS!!! */
#ifdef DCE_RPC_USED
X
#define PROGINTERN
#include "rpc_vars.h"
X
void wait_for_rpcs(int wait_time)
{
X  /* Synchronize with the other p-Thread */
X  /* Free mutex (Test for RPC) */
X  pthread_mutex_unlock(&mutex);
X  
X  sleep(wait_time);
X
X  /* Lock mutex again (No RPC possible) */
X  pthread_mutex_lock(&mutex);
}
X
void dce_rpc_server_listen()
{
X    unsigned32 status;
X
X    rpc_server_listen(cMaxCalls,&status);
X    CHECK_DCE_ERROR(status,ABORT);
X
X    /* Will never happen, but ... */
X    rpc_server_unregister_if(xgobi_goes_dce_v1_0_s_ifspec,0,&status);
X    CHECK_DCE_ERROR(status,ABORT);
X    rpc_ep_unregister(xgobi_goes_dce_v1_0_s_ifspec,pbvBindings,0,&status);
X    CHECK_DCE_ERROR(status,ABORT);
X    rpc_binding_vector_free(&pbvBindings,&status);
X    CHECK_DCE_ERROR(status,ABORT);
}
X
void dce_rpc_server_main ()
{
X    unsigned32 status;
X    int ret;
X
X    strcpy(pszProtocolSequence,"ncacn_ip_tcp");
X    pszEndpoint = NULL;
X    cMaxCalls = 1;
X    pbvBindings = NULL;
X
X    pthread_mutex_init(&mutex,pthread_mutexattr_default);
X    /* No RPCs now! */
X    pthread_mutex_lock(&mutex);
X
X    /* Initialize DCE RPC */
X    rpc_server_use_protseq(pszProtocolSequence,cMaxCalls,&status);
X    CHECK_DCE_ERROR(status,ABORT);
X    rpc_server_inq_bindings(&pbvBindings,&status);
X    CHECK_DCE_ERROR(status,ABORT);
X    rpc_ep_register(xgobi_goes_dce_v1_0_s_ifspec,pbvBindings,0,0,&status);
X    CHECK_DCE_ERROR(status,ABORT);
X    rpc_server_register_if(xgobi_goes_dce_v1_0_s_ifspec,0,0,&status);
X    CHECK_DCE_ERROR(status,ABORT);
X
/* p-Thread to rpc_server_listen */
X    ret = pthread_create(&t_handle,pthread_attr_default,
X            (void *(*)(void *)) dce_rpc_server_listen,NULL);
}
X
#endif
X
#ifdef RPC_USED
X
#include <stdio.h>
#include <rpc/rpc.h>
#include "rpc_server.h"
X
#define PROGINTERN
#include "rpc_vars.h"
X
void wait_for_rpcs(int wait_time)
{
X  fd_set readfds,
X         writefds,
X         exceptfds;
X  struct timeval timeout;
X  int i;
X
X  FD_ZERO (&readfds);
X  FD_ZERO (&writefds);
X  FD_ZERO (&exceptfds);
X
X  timeout.tv_sec = 0;
X  timeout.tv_usec = 100;
X
X  for (i = 0; i < howmany (FD_SETSIZE, NFDBITS); i++)
X    readfds.fds_bits[i] = svc_fdset.fds_bits[i];
X
X  select (FD_SETSIZE, &readfds, &writefds, &exceptfds, &timeout);
X  svc_getreqset (&readfds);
}
X
unsigned long server_prognum;
unsigned long server_vernum;
X
X
static void aiserver_1();
X
X
void rpc_server_main (sv_prognum, sv_vernum)
X
unsigned long sv_prognum;
unsigned long sv_vernum;
X
{
X  register SVCXPRT *transp;
X
X  fd_set readfds,
X         writefds,
X         exceptfds;
X
X  static int firsttime = 1;
X
X  if (! firsttime)
X    return;
X
X        server_prognum = sv_prognum;
X        server_vernum = sv_vernum;
X
X	(void) pmap_unset(sv_prognum, sv_vernum);
X
X	transp = svcudp_create(RPC_ANYSOCK);
X	if (transp == NULL) {
X		fprintf(stderr, "cannot create udp service.");
X		exit(1);
X	}
X
X	if (!svc_register(transp, sv_prognum, sv_vernum, aiserver_1, IPPROTO_UDP)) {
X		fprintf(stderr, "unable to register (sv_prognum, sv_vernum, udp).");
X		exit(1);
X	}
X
X	transp = svctcp_create(RPC_ANYSOCK, 0, 0);
X	if (transp == NULL) {
X		fprintf(stderr, "cannot create tcp service.");
X		exit(1);
X	}
X
X	if (!svc_register(transp, sv_prognum, sv_vernum, aiserver_1, IPPROTO_TCP)) {
X		fprintf(stderr, "unable to register (sv_prognum, sv_vernum, tcp).");
X		exit(1);
X	}
X
X  firsttime = 0;
X
/*	svc_run();
X	fprintf(stderr, "svc_run returned");
X	exit(1); */
/*
X  typedef struct fd_set {
X          fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
X  } fd_set;
*/
X
X	/* NOTREACHED */
}
X
X
X
bool_t
xdr_strngrec(xdrs, objp)
X        XDR *xdrs;
X        strngrec *objp;
X
{
X        if (!xdr_string(xdrs, &objp->retstr, 1024)) {
X                return (FALSE);
X        }
X
X        return (TRUE);
}
X
X
X
static void
aiserver_1(rqstp, transp)
X	struct svc_req *rqstp;
X	register SVCXPRT *transp;
X
{
X	union {
X		char *procedure1_1_arg;
X		char *procedure2_1_arg;
X		char *procedure3_1_arg;
X		char *procedure4_1_arg;
X		char *procedure5_1_arg;
X		char *procedure6_1_arg;
X		char *procedure7_1_arg;
X		char *procedure8_1_arg;
X		char *procedure9_1_arg;
X		char *procedure10_1_arg;
X		char *procedure11_1_arg;
X		char *procedure12_1_arg;
X		char *procedure13_1_arg;
X		char *procedure14_1_arg;
X		char *procedure15_1_arg;
X		char *procedure16_1_arg;
X		char *procedure17_1_arg;
X		char *procedure18_1_arg;
X		char *procedure19_1_arg;
X		char *procedure20_1_arg;
X		char *procedure21_1_arg;
X		char *procedure22_1_arg;
X		char *procedure23_1_arg;
X		char *procedure24_1_arg;
X		char *procedure25_1_arg;
X		char *procedure26_1_arg;
X		char *procedure27_1_arg;
X		char *procedure28_1_arg;
X		char *procedure29_1_arg;
X		char *procedure30_1_arg;
X		char *procedure31_1_arg;
X		char *procedure32_1_arg;
X		char *procedure33_1_arg;
X		char *procedure34_1_arg;
X		char *procedure35_1_arg;
X		char *procedure36_1_arg;
X		char *procedure37_1_arg;
X		char *procedure38_1_arg;
X		char *procedure39_1_arg;
X		char *procedure40_1_arg;
X		char *procedure41_1_arg;
X		char *procedure42_1_arg;
X		char *procedure43_1_arg;
X		char *procedure44_1_arg;
X		char *procedure45_1_arg;
X		char *procedure46_1_arg;
X		char *procedure47_1_arg;
X		char *procedure48_1_arg;
X		char *procedure49_1_arg;
X		char *procedure50_1_arg;
X		char *procedure51_1_arg;
X		char *procedure52_1_arg;
X		char *procedure53_1_arg;
X		char *procedure54_1_arg;
X		char *procedure55_1_arg;
X		char *procedure56_1_arg;
X		char *procedure57_1_arg;
X		char *procedure58_1_arg;
X		char *procedure59_1_arg;
X		char *procedure60_1_arg;
X		char *procedure61_1_arg;
X		char *procedure62_1_arg;
X		char *procedure63_1_arg;
X		char *procedure64_1_arg;
X		char *procedure65_1_arg;
X		char *procedure66_1_arg;
X		char *procedure67_1_arg;
X		char *procedure68_1_arg;
X		char *procedure69_1_arg;
X		char *procedure70_1_arg;
X		char *procedure71_1_arg;
X		char *procedure72_1_arg;
X		char *procedure73_1_arg;
X		char *procedure74_1_arg;
X		char *procedure75_1_arg;
X		char *procedure76_1_arg;
X		char *procedure77_1_arg;
X		char *procedure78_1_arg;
X		char *procedure79_1_arg;
X		char *procedure80_1_arg;
X		char *procedure81_1_arg;
X		char *procedure82_1_arg;
X		char *procedure83_1_arg;
X		char *procedure84_1_arg;
X		char *procedure85_1_arg;
X		char *procedure86_1_arg;
X		char *procedure87_1_arg;
X		char *procedure88_1_arg;
X		char *procedure89_1_arg;
X		char *procedure90_1_arg;
X		char *procedure91_1_arg;
X		char *procedure92_1_arg;
X		char *procedure93_1_arg;
X		char *procedure94_1_arg;
X		char *procedure95_1_arg;
X		char *procedure96_1_arg;
X		char *procedure97_1_arg;
X		char *procedure98_1_arg;
X		char *procedure99_1_arg;
X		char *quit_1_arg;
X	} argument;
X
X	char *result;
X	bool_t (*xdr_argument)(), (*xdr_result)();
X	char *(*local)();
X
X	switch (rqstp->rq_proc) {
X	case NULLPROC:
X		(void) svc_sendreply(transp, (xdrproc_t) xdr_void, (char *)NULL);
X		return;
X
X	case Procedure1:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure1_1;
X		break;
X
X	case Procedure2:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure2_1;
X		break;
X
X	case Procedure3:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure3_1;
X		break;
X
X	case Procedure4:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure4_1;
X		break;
X
X	case Procedure5:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure5_1;
X		break;
X
X	case Procedure6:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure6_1;
X		break;
X
X	case Procedure7:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure7_1;
X		break;
X
X	case Procedure8:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure8_1;
X		break;
X
X	case Procedure9:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure9_1;
X		break;
X
X	case Procedure10:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure10_1;
X		break;
X
X	case Procedure11:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure11_1;
X		break;
X
X	case Procedure12:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure12_1;
X		break;
X
X	case Procedure13:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure13_1;
X		break;
X
X	case Procedure14:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure14_1;
X		break;
X
X	case Procedure15:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure15_1;
X		break;
X
X	case Procedure16:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure16_1;
X		break;
X
X	case Procedure17:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure17_1;
X		break;
X
X	case Procedure18:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure18_1;
X		break;
X
X	case Procedure19:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure19_1;
X		break;
X
X	case Procedure20:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure20_1;
X		break;
X
X	case Procedure21:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure21_1;
X		break;
X
X	case Procedure22:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure22_1;
X		break;
X
X	case Procedure23:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure23_1;
X		break;
X
X	case Procedure24:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure24_1;
X		break;
X
X	case Procedure25:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure25_1;
X		break;
X
X	case Procedure26:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure26_1;
X		break;
X
X	case Procedure27:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure27_1;
X		break;
X
X	case Procedure28:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure28_1;
X		break;
X
X	case Procedure29:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure29_1;
X		break;
X
X	case Procedure30:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure30_1;
X		break;
X
X	case Procedure31:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure31_1;
X		break;
X
X	case Procedure32:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure32_1;
X		break;
X
X	case Procedure33:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure33_1;
X		break;
X
X	case Procedure34:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure34_1;
X		break;
X
X	case Procedure35:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure35_1;
X		break;
X
X	case Procedure36:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure36_1;
X		break;
X
X	case Procedure37:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure37_1;
X		break;
X
X	case Procedure38:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure38_1;
X		break;
X
X	case Procedure39:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure39_1;
X		break;
X
X	case Procedure40:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure40_1;
X		break;
X
X	case Procedure41:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure41_1;
X		break;
X
X	case Procedure42:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure42_1;
X		break;
X
X	case Procedure43:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure43_1;
X		break;
X
X	case Procedure44:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure44_1;
X		break;
X
X	case Procedure45:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure45_1;
X		break;
X
X	case Procedure46:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure46_1;
X		break;
X
X	case Procedure47:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure47_1;
X		break;
X
X	case Procedure48:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure48_1;
X		break;
X
X	case Procedure49:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure49_1;
X		break;
X
X	case Procedure50:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure50_1;
X		break;
X
X	case Procedure51:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure51_1;
X		break;
X
X	case Procedure52:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure52_1;
X		break;
X
X	case Procedure53:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure53_1;
X		break;
X
X	case Procedure54:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure54_1;
X		break;
X
X	case Procedure55:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure55_1;
X		break;
X
X	case Procedure56:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure56_1;
X		break;
X
X	case Procedure57:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure57_1;
X		break;
X
X	case Procedure58:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure58_1;
X		break;
X
X	case Procedure59:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure59_1;
X		break;
X
X	case Procedure60:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure60_1;
X		break;
X
X	case Procedure61:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure61_1;
X		break;
X
X	case Procedure62:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure62_1;
X		break;
X
X	case Procedure63:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure63_1;
X		break;
X
X	case Procedure64:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure64_1;
X		break;
X
X	case Procedure65:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure65_1;
X		break;
X
X	case Procedure66:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure66_1;
X		break;
X
X	case Procedure67:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure67_1;
X		break;
X
X	case Procedure68:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure68_1;
X		break;
X
X	case Procedure69:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure69_1;
X		break;
X
X	case Procedure70:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure70_1;
X		break;
X
X	case Procedure71:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure71_1;
X		break;
X
X	case Procedure72:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure72_1;
X		break;
X
X	case Procedure73:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure73_1;
X		break;
X
X	case Procedure74:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure74_1;
X		break;
X
X	case Procedure75:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure75_1;
X		break;
X
X	case Procedure76:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure76_1;
X		break;
X
X	case Procedure77:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure77_1;
X		break;
X
X	case Procedure78:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure78_1;
X		break;
X
X	case Procedure79:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure79_1;
X		break;
X
X	case Procedure80:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure80_1;
X		break;
X
X	case Procedure81:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure81_1;
X		break;
X
X	case Procedure82:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure82_1;
X		break;
X
X	case Procedure83:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure83_1;
X		break;
X
X	case Procedure84:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure84_1;
X		break;
X
X	case Procedure85:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure85_1;
X		break;
X
X	case Procedure86:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure86_1;
X		break;
X
X	case Procedure87:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure87_1;
X		break;
X
X	case Procedure88:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure88_1;
X		break;
X
X	case Procedure89:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure89_1;
X		break;
X
X	case Procedure90:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure90_1;
X		break;
X
X	case Procedure91:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure91_1;
X		break;
X
X	case Procedure92:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure92_1;
X		break;
X
X	case Procedure93:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure93_1;
X		break;
X
X	case Procedure94:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure94_1;
X		break;
X
X	case Procedure95:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure95_1;
X		break;
X
X	case Procedure96:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure96_1;
X		break;
X
X	case Procedure97:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure97_1;
X		break;
X
X	case Procedure98:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure98_1;
X		break;
X
X	case Procedure99:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) procedure99_1;
X		break;
X
X	case Quit:
X		xdr_argument = xdr_wrapstring;
X		xdr_result = xdr_strngrec;
X		local = (char *(*)()) quit_1;
X		break;
X
X	default:
X		svcerr_noproc(transp);
X		return;
X	}
X
/* 	bzero((char *) &argument, sizeof(argument));
X
X        The command bzero does not exist on all machines.
X        Here is its description from the man pages:
X
X          void bzero (char *string, int length);
X
X          The bzero() function nulls the string in the string parameter, for the
X          value of the length parameter in bytes.
X
X        A patch that should work on most systems follows:
*/
X
X        strncpy ((char *) &argument, "", sizeof (argument));
X
X	if (!svc_getargs(transp, (xdrproc_t) xdr_argument, (char *) &argument)) {
X		svcerr_decode(transp);
X		return;
X	}
X
X	result = (*local)(&argument, rqstp);
X	if (result != NULL && !svc_sendreply(transp, (xdrproc_t) xdr_result, result)) {
X		svcerr_systemerr(transp);
X	}
X
X	if (!svc_freeargs(transp, (xdrproc_t) xdr_argument, (char *) &argument)) {
X		fprintf(stderr, "unable to free arguments");
X		exit(1);
X	}
X
X	return;
}
X
#endif
SHAR_EOF
  chmod 0644 'xgobi/src/rpc_server_svc.c' ||
  $echo 'restore of' 'xgobi/src/rpc_server_svc.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/rpc_server_svc.c:' 'MD5 check failed'
d29cd9dcb5e6ccf52e3ece5fa0d40a4f  xgobi/src/rpc_server_svc.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/rpc_server_svc.c'`"
    test 22199 -eq "$shar_count" ||
    $echo 'xgobi/src/rpc_server_svc.c:' 'original size' '22199,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/rpc_dceclient.acf ==============
if test -f 'xgobi/src/rpc_dceclient.acf' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/rpc_dceclient.acf' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/rpc_dceclient.acf' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/rpc_dceclient.acf' &&
/*************************************************************/
/**                                                         **/
/**  xgobi DCE-ACF-Datei Client                             **/
/**                                                         **/
/*************************************************************/
X
[ implicit_handle(handle_t xgobi_client_binding_handle) ]
interface xgobi_dceclient
{
}
SHAR_EOF
  chmod 0644 'xgobi/src/rpc_dceclient.acf' ||
  $echo 'restore of' 'xgobi/src/rpc_dceclient.acf' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/rpc_dceclient.acf:' 'MD5 check failed'
f1b083169697be8b1d916df1b96a635f  xgobi/src/rpc_dceclient.acf
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/rpc_dceclient.acf'`"
    test 409 -eq "$shar_count" ||
    $echo 'xgobi/src/rpc_dceclient.acf:' 'original size' '409,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/rpc_dceclient.idl ==============
if test -f 'xgobi/src/rpc_dceclient.idl' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/rpc_dceclient.idl' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/rpc_dceclient.idl' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/rpc_dceclient.idl' &&
/* rpc_dceclient.idl */
/***********************************************************************
X * Permission is hereby granted to any individual or institution       *
X * for use, copying, or redistribution of the rpc_dce C code           *
X * and associated documentation, provided such code and documentation  *
X * are not sold for profit and the following copyright notice is       *
X * retained in the code and documentation:                             *
X *                                                                     *
X *   Copyright (c) 1999 George Mason University                        *
X *                                                                     *
X * We encourage you to share questions, comments and modifications.    *
X *                                                                     *
X *   Martin Schneider (maschn@informatik.uni-marburg.de)               *
X *   Juergen Symanzik (symanzik@galaxy.gmu.edu)                        *
X ***********************************************************************/
X
[
uuid(b32b5f3c-cf33-1022-8901-0800690559d0),
version(1.0)
]
X
#define STR_OUTSIZE 100
X
interface xgobi_dceclient
{
X
void Xfer_Brushinfo ([in, string, ref] char *instr);
X
} /* von Interface */
SHAR_EOF
  chmod 0644 'xgobi/src/rpc_dceclient.idl' ||
  $echo 'restore of' 'xgobi/src/rpc_dceclient.idl' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/rpc_dceclient.idl:' 'MD5 check failed'
20e7ada181f826ebc3d1d1b799a1d8a9  xgobi/src/rpc_dceclient.idl
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/rpc_dceclient.idl'`"
    test 1240 -eq "$shar_count" ||
    $echo 'xgobi/src/rpc_dceclient.idl:' 'original size' '1240,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/Makefile ==============
if test -f 'xgobi/src/Makefile' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/Makefile' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/Makefile' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/Makefile' &&
# Makefile generated by imake - do not edit!
# $XConsortium: imake.c /main/90 1996/11/13 14:43:23 lehors $
X
# ----------------------------------------------------------------------
# Makefile generated from "Imake.tmpl" and </tmp/IIf.a07qU4>
# $TOG: Imake.tmpl /main/245 1997/05/20 10:05:47 kaleb $
#
X
X.SUFFIXES: .i
X
# $TOG: Imake.cf /main/28 1997/06/25 08:31:36 barstow $
X
# -----------------------------------------------------------------------
# site-specific configuration parameters that need to come before
# the platform-specific parameters - edit site.def to change
X
# site:  $XConsortium: site.def /main/revisionist/4 1996/12/31 08:02:07 kaleb $
X
# ----------------------------------------------------------------------
# platform-specific configuration parameters - edit sgi.cf to change
X
# platform:  $XConsortium: sgi.cf,v 1.43 94/06/03 21:38:45 matt Exp $
X
# operating system:				IRIX
X
X     SGIISALIBDIR = /usr/lib32/mips3
X     SGIGFXLIBDIR = /usr/gfx/common/lib32
X
X     SGIABIOPTS   = -n32 -mips3
X     SGIABIDEFS   =
X
X        OPTIMIZER = -O2
X
X           MANUSR = /usr/share/local
X
X       CATMAN1DIR = $(MANUSR)/catman/u_man/cat1
X       CATMAN3DIR = $(MANUSR)/catman/p_man/cat3
X          MAN1DIR = $(MANUSR)/man/u_man/man1
X          MAN3DIR = $(MANUSR)/man/p_man/man3
X       CATMAN4DIR = $(MANUSR)/catman/u_man/cat4
X       CATMAN5DIR = $(MANUSR)/catman/u_man/cat5
X          MAN4DIR = $(MANUSR)/man/u_man/man4
X          MAN5DIR = $(MANUSR)/man/u_man/man5
X
X       MANPACKAGE = /X11
X
# $XConsortium: sgiLib.rules,v 1.8 93/09/11 17:59:30 rws Exp $
X
# ----------------------------------------------------------------------
# site-specific configuration parameters that go after
# the platform-specific parameters - edit site.def to change
X
# site:  $XConsortium: site.def /main/revisionist/4 1996/12/31 08:02:07 kaleb $
X
# ---------------------------------------------------------------------
# Imake rules for building libraries, programs, scripts, and data files
# rules:  $TOG: Imake.rules /main/220 1997/06/05 18:05:16 kaleb $
X
X          PATHSEP = /
X            SHELL = 	/bin/sh
X
X              TOP = .
X      CURRENT_DIR = .
X
X            IMAKE = imake
X           DEPEND = makedepend
X        MKDIRHIER = mkdirhier
X    EXPORTLISTGEN = 	exportlistgen
X        CONFIGSRC = $(TOP)/config
X         IMAKESRC = $(CONFIGSRC)/imake
X        DEPENDSRC = $(CONFIGSRC)/makedepend
X
X          INCROOT = /usr/include
X        USRLIBDIR = /usr/lib
X         SHLIBDIR = /usr/lib32
X       LINTLIBDIR = $(USRLIBDIR)/lint
X          MANPATH = /usr/share/man
X    MANSOURCEPATH = $(MANPATH)/man
X           MANDIR = $(CATMAN1DIR)$(MANPACKAGE)
X        LIBMANDIR = $(CATMAN3DIR)$(MANPACKAGE)
X       FILEMANDIR = $(MANSOURCEPATH)$(FILEMANSUFFIX)
X         MANDIR_4 = $(CATMAN4DIR)$(MANPACKAGE)
X         MANDIR_5 = $(CATMAN5DIR)$(MANPACKAGE)
X
X               AR = $(TOOLROOT)/usr/bin/ar cq
X  BOOTSTRAPCFLAGS = $(OPTIMIZER)
X               CC = $(TOOLROOT)/usr/bin/cc
X               AS = $(TOOLROOT)/usr/bin/as $(SGIABIOPTS)
X
X.SUFFIXES: .cc
X
X              CXX = CC
X          CXXFILT = c++filt
X           CXXLIB =
X    CXXDEBUGFLAGS = $(OPTIMIZER)
CXXDEPENDINCLUDES = -I$(ROOT)/usr/include/CC
X CXXEXTRA_DEFINES =
CXXEXTRA_INCLUDES =
X   CXXSTD_DEFINES = -DSYSV -DSVR4 -nostdinc -I$(ROOT)/usr/include $(CXXPROJECT_DEFINES)
X       CXXOPTIONS =
X      CXXINCLUDES = $(INCLUDES) $(TOP_INCLUDES) $(CXXEXTRA_INCLUDES)
X       CXXDEFINES = $(CXXINCLUDES) $(CXXSTD_DEFINES) $(THREADS_CXXDEFINES) $(CXXEXTRA_DEFINES) $(DEFINES)
X         CXXFLAGS = $(CXXDEBUGFLAGS) $(CXXOPTIONS) $(THREADS_CXXFLAGS) $(CXXDEFINES)
X
X         COMPRESS = compress
X          GZIPCMD = gzip
X              CPP = /lib/cpp $(STD_CPP_DEFINES)
X    PREPROCESSCMD = $(TOOLROOT)/usr/bin/cc -E $(STD_CPP_DEFINES)
X          INSTALL = bsdinst
X     INSTALLFLAGS = -c
X               LD = $(TOOLROOT)/usr/bin/ld $(SGIABIOPTS)
X              LEX = lex
X           LEXLIB = -ll
X             YACC = yacc
X           CCYACC = yacc
X             LINT = lint
X      LINTLIBFLAG = -o
X         LINTOPTS = -bh
X               LN = ln -s
X             MAKE = $(TOOLROOTSAFE) $(TOOLROOT)/sbin/make
X               MV = mv
X               CP = cp
X
X               RM = rm -f
X        MANSUFFIX = 1
X     LIBMANSUFFIX = 3
X    FILEMANSUFFIX = 4
X            TROFF = psroff -t
X            NROFF = nroff
X         MSMACROS = -ms
X        MANMACROS = -man
X              TBL = tbl
X              EQN = eqn
X             NEQN = neqn
X              COL = col
X
X            DVIPS = dvips
X            LATEX = latex
X
X     STD_INCLUDES = -nostdinc -I$(ROOT)/usr/include
X  STD_CPP_DEFINES = -DSYSV -DSVR4 $(PROJECT_DEFINES)
X      STD_DEFINES = -DSYSV -DSVR4 $(PROJECT_DEFINES)
X EXTRA_LOAD_FLAGS =
X  EXTRA_LDOPTIONS =
X  EXTRA_LIBRARIES =
X             TAGS = ctags
X
X    SHAREDCODEDEF =
X         SHLIBDEF =
X
X    PROTO_DEFINES = -DFUNCPROTO=7 -DNARROWPROTO
X
X     INSTPGMFLAGS =
X
X     INSTBINFLAGS = -m 0755
X     INSTUIDFLAGS = -m 4711
X     INSTLIBFLAGS = -m 0644
X     INSTINCFLAGS = -m 0444
X     INSTMANFLAGS = -m 0444
X     INSTDATFLAGS = -m 0444
X    INSTKMEMFLAGS = -m 2755 -g sys
X
X      CDEBUGFLAGS = $(OPTIMIZER)
X        CCOPTIONS = -xansi $(SGIABIOPTS) $(SGIABIDEFS)
X
X      ALLINCLUDES = $(INCLUDES) $(EXTRA_INCLUDES) $(TOP_INCLUDES) $(STD_INCLUDES)
X       ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(EXTRA_DEFINES) $(PROTO_DEFINES) $(THREADS_DEFINES) $(DEFINES)
X           CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(THREADS_CFLAGS) $(ALLDEFINES)
X        LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES) $(DEPEND_DEFINES)
X         LDPRELIB =
X        LDPOSTLIB = -nostdlib -L$(ROOT)$(SGIISALIBDIR) -L$(ROOT)$(SHLIBDIR)
X        LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS)  $(EXTRA_LDOPTIONS) $(THREADS_LDFLAGS) $(LOCAL_LDFLAGS) $(LDPRELIBS)
X     CXXLDOPTIONS = $(CXXDEBUGFLAGS) $(CXXOPTIONS) $(EXTRA_LDOPTIONS) $(THREADS_CXXLDFLAGS) $(LOCAL_LDFLAGS) $(LDPRELIBS)
X
X           LDLIBS = $(LDPOSTLIBS) $(THREADS_LIBS) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
X
X           CCLINK = $(CC)
X
X          CXXLINK = $(CXX)
X
X     LDSTRIPFLAGS = -x
X   LDCOMBINEFLAGS = -r
X      DEPENDFLAGS =
X
X        MACROFILE = sgi.cf
X           RM_CMD = $(RM)
X
X    IMAKE_DEFINES =
X
X         IRULESRC = $(CONFIGDIR)
X        IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES)
X
X     ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/X11.tmpl \
X			$(IRULESRC)/site.def $(IRULESRC)/$(MACROFILE) \
X			$(IRULESRC)/host.def $(EXTRA_ICONFIGFILES)
X
# $TOG: X11.rules /main/4 1997/04/30 15:23:24 kaleb $
X
# ----------------------------------------------------------------------
# X Window System Build Parameters and Rules
# $TOG: X11.tmpl /main/292 1997/05/20 10:05:59 kaleb $
X
# -----------------------------------------------------------------------
# X Window System make variables; these need to be coordinated with rules
X
X             XTOP = $(TOP)
X           BINDIR = /usr/bin/X11
X     BUILDINCROOT = $(TOP)/exports
X      BUILDINCDIR = $(BUILDINCROOT)/include/X11
X      BUILDINCTOP = ../../..
X      BUILDLIBDIR = $(TOP)/exports/lib
X      BUILDLIBTOP = ../..
X      BUILDBINDIR = $(TOP)/exports/bin
X      BUILDBINTOP = ../..
X    XBUILDINCROOT = $(XTOP)/exports
X     XBUILDINCDIR = $(XBUILDINCROOT)/include/X11
X     XBUILDINCTOP = ../../..
X     XBUILDBINDIR = $(XBUILDINCROOT)/bin
X           INCDIR = $(INCROOT)/X11
X           ADMDIR = /usr/adm
X           LIBDIR = $(USRLIBDIR)/X11
X   TOP_X_INCLUDES =
X
X          FONTDIR = $(LIBDIR)/fonts
X         XINITDIR = $(LIBDIR)/xinit
X           XDMDIR = 			/var/X11/xdm
X           TWMDIR = $(LIBDIR)/twm
X           XSMDIR = $(LIBDIR)/xsm
X           NLSDIR = $(LIBDIR)/nls
X       XLOCALEDIR = $(LIBDIR)/locale
X        PEXAPIDIR = $(LIBDIR)/PEX
X      LBXPROXYDIR = $(LIBDIR)/lbxproxy
X  PROXYMANAGERDIR = $(LIBDIR)/proxymngr
X        XPRINTDIR = $(LIBDIR)
X      XAPPLOADDIR = $(LIBDIR)/app-defaults
X       FONTCFLAGS = -t
X
X     INSTAPPFLAGS = $(INSTDATFLAGS)
X
X              RGB = rgb
X            FONTC = bdftopcf
X        MKFONTDIR = mkfontdir
X
X       DOCUTILSRC = $(XTOP)/doc/util
X       XDOCMACROS = $(DOCUTILSRC)/macros.t
X       XIDXMACROS = $(DOCUTILSRC)/indexmacros.t
X       PROGRAMSRC = $(TOP)/programs
X           LIBSRC = $(XTOP)/lib
X          FONTSRC = $(XTOP)/fonts
X       INCLUDESRC = $(BUILDINCROOT)/include/X11
X      XINCLUDESRC = $(INCLUDESRC)/X11
X        SERVERSRC = $(XTOP)/programs/Xserver
X       CONTRIBSRC = $(XTOP)/../contrib
X   UNSUPPORTEDSRC = $(XTOP)/unsupported
X           DOCSRC = $(XTOP)/doc
X           RGBSRC = $(XTOP)/programs/rgb
X      BDFTOPCFSRC = $(PROGRAMSRC)/bdftopcf
X     MKFONTDIRSRC = $(PROGRAMSRC)/mkfontdir
X    FONTSERVERSRC = $(PROGRAMSRC)/xfs
X       FONTINCSRC = $(XTOP)/include/fonts
X        EXTINCSRC = $(XTOP)/include/extensions
X     TRANSCOMMSRC = $(LIBSRC)/xtrans
X   TRANS_INCLUDES = -I$(TRANSCOMMSRC)
X
X   CLIENTENVSETUP =
X
# Supporting dynamic shared object libraries for IRIX 5.0
X
# These defines mimic what is in /usr/include/make/commondefs
# (Should be in sync with Revision 1.99)
X
X       DSOREGFILE = $$ROOT$(SHLIBDIR)/so_locations
X      DSOSTARTOPT = -update_registry $(DSOREGFILE)
X       DSONAMEOPT = -soname $@
X       DSOVERSION = sgi1.0
X    DSOVERSIONOPT = -set_version $(DSOVERSION)
X        LDDSOOPTS = -n32 -mips3 -shared -no_unresolved $(VLDDSOOPTS) \
X  $(LLDDSOOPTS) $(GLDDSOOPTS)
X       GLDDSOOPTS = -all $(DSOSTARTOPT) $(DSONAMEOPT) $(DSOVERSIONOPT)
X
X          XLIBSRC = $(LIBSRC)/X11
X
SOXLIBREV = .1
DEPXONLYLIB =  $(ROOT)$(SHLIBDIR)/libX11.so$(SOXLIBREV)
XXONLYLIB =  -lX11
X
LINTXONLY =  $(LINTLIBDIR)/llib-lX11.ln
X
X         XLIBONLY = $(XONLYLIB)
X
X      XEXTLIBSRC = $(LIBSRC)/Xext
X
SOXEXTREV =
DEPEXTENSIONLIB =  $(ROOT)$(SHLIBDIR)/libXext.so$(SOXEXTREV)
EXTENSIONLIB =  -lXext
X
LINTEXTENSION =  $(LINTLIBDIR)/llib-lXext.ln
X
LINTEXTENSIONLIB = $(LINTEXTENSION)
X          DEPXLIB = $(DEPEXTENSIONLIB) $(DEPXONLYLIB)
X             XLIB = $(EXTENSIONLIB) $(XONLYLIB)
X         LINTXLIB = $(LINTXONLYLIB)
X
X         XAUTHSRC = $(LIBSRC)/Xau
X
DEPXAUTHLIB =  $(USRLIBDIR)/libXau.a
XXAUTHLIB =  -lXau
X
LINTXAUTH =  $(LINTLIBDIR)/llib-lXau.ln
X
X      XDMCPLIBSRC = $(LIBSRC)/Xdmcp
X
DEPXDMCPLIB =  $(USRLIBDIR)/libXdmcp.a
XXDMCPLIB =  -lXdmcp
X
LINTXDMCP =  $(LINTLIBDIR)/llib-lXdmcp.ln
X
X           XMUSRC = $(LIBSRC)/Xmu
X
SOXMUREV =
DEPXMULIB =  $(ROOT)$(SHLIBDIR)/libXmu.so$(SOXMUREV)
XXMULIB =  -lXmu
X
LINTXMU =  $(LINTLIBDIR)/llib-lXmu.ln
X
X       OLDXLIBSRC = $(LIBSRC)/oldX
X
DEPOLDXLIB =  $(USRLIBDIR)/liboldX.a
OLDXLIB =  -loldX
X
LINTOLDX =  $(LINTLIBDIR)/llib-loldX.ln
X
X         XPLIBSRC = $(LIBSRC)/Xp
X
SOXPREV = 6.2
DEPXPLIB =  $(ROOT)$(SHLIBDIR)/libXp.so$(SOXPREV)
XXPLIB =  -lXp
X
LINTXP =  $(LINTLIBDIR)/llib-lXp.ln
X
X       TOOLKITSRC = $(LIBSRC)/Xt
X
SOXTREV =
DEPXTOOLONLYLIB =  $(ROOT)$(SHLIBDIR)/libXt.so$(SOXTREV)
XXTOOLONLYLIB =  -lXt
X
LINTXTOOLONLY =  $(LINTLIBDIR)/llib-lXt.ln
X
X      DEPXTOOLLIB = $(DEPXTOOLONLYLIB) $(DEPSMLIB) $(DEPICELIB)
X         XTOOLLIB = $(XTOOLONLYLIB) $(SMLIB) $(ICELIB)
X     LINTXTOOLLIB = $(LINTXTOOLONLYLIB)
X
X       XALIBSRC = $(LIBSRC)/Xa
X
SOXAREV = 1.0
DEPXALIB =  $(ROOT)$(SHLIBDIR)/libXa.so$(SOXAREV)
XXALIB =  -lXa
X
LINTXA =  $(LINTLIBDIR)/llib-lXa.ln
X
X       AWIDGETSRC = $(LIBSRC)/Xaw
X
SOXAWREV = .2
DEPXAWLIB =  $(ROOT)$(SHLIBDIR)/libXaw.so$(SOXAWREV)
XXAWLIB =  -lXaw
X
LINTXAW =  $(LINTLIBDIR)/llib-lXaw.ln
X
X         XILIBSRC = $(LIBSRC)/Xi
X
SOXINPUTREV =
DEPXILIB =  $(ROOT)$(SHLIBDIR)/libXi.so$(SOXINPUTREV)
XXILIB =  -lXi
X
LINTXI =  $(LINTLIBDIR)/llib-lXi.ln
X
X      XTESTLIBSRC = $(LIBSRC)/Xtst
X
DEPXTESTLIB =  $(USRLIBDIR)/libXtst.a
XXTESTLIB =  -lXtst
X
LINTXTEST =  $(LINTLIBDIR)/llib-lXtst.ln
X
X        PEXLIBSRC = $(LIBSRC)/PEX5
X
DEPPEXLIB =  $(ROOT)$(SHLIBDIR)/libPEX5.a
PEXLIB =  -lPEX5
X
LINTPEX =  $(LINTLIBDIR)/llib-lPEX5.ln
X
X        XNMBXLIBSRC = $(LIBSRC)/nmbx
X
SONMBXREV =
DEPXNMBXLIB =  $(ROOT)$(SHLIBDIR)/libXnmbx.so$(SONMBXREV)
XXNMBXLIB =  -lXnmbx
X
LINTXNMBX =  $(LINTLIBDIR)/llib-lXnmbx.ln
X
X        XTRAPLIBSRC = $(LIBSRC)/xtrap
X
DEPXTRAPLIB =  $(ROOT)$(SHLIBDIR)/libxtrap.a
XXTRAPLIB =  -lxtrap
X
LINTXTRAP =  $(LINTLIBDIR)/llib-lxtrap.ln
X
X        XIELIBSRC = $(LIBSRC)/XIE
X
DEPXIELIB =  $(USRLIBDIR)/libXIE.a
XXIELIB =  -lXIE
X
LINTXIE =  $(LINTLIBDIR)/llib-lXIE.ln
X
X      PHIGSLIBSRC = $(LIBSRC)/PHIGS
X
DEPPHIGSLIB =  $(USRLIBDIR)/libphigs.a
PHIGSLIB =  -lphigs
X
LINTPHIGS =  $(LINTLIBDIR)/llib-lphigs.ln
X
DEPXBSDLIB =  $(USRLIBDIR)/libXbsd.a
XXBSDLIB =  -lXbsd
X
LINTXBSD =  $(LINTLIBDIR)/llib-lXbsd.ln
X
X           ICESRC = $(LIBSRC)/ICE
X
SOICEREV =
DEPICELIB =  $(ROOT)$(SHLIBDIR)/libICE.so$(SOICEREV)
ICELIB =  -lICE
X
LINTICE =  $(LINTLIBDIR)/llib-lICE.ln
X
X            SMSRC = $(LIBSRC)/SM
X
SOSMREV =
DEPSMLIB =  $(ROOT)$(SHLIBDIR)/libSM.so$(SOSMREV)
SMLIB =  -lSM
X
LINTSM =  $(LINTLIBDIR)/llib-lSM.ln
X
X           XKEYSRC = $(LIBSRC)/Xkey
X
SOXKEYREV = 6.0
DEPXKEYLIB =  $(ROOT)$(SHLIBDIR)/libXkey.so$(SOXKEYREV)
XXKEYLIB =  -lXkey
X
LINTXKEY =  $(LINTLIBDIR)/llib-lXkey.ln
X
X         FSLIBSRC = $(LIBSRC)/FS
X
DEPFSLIB =  $(USRLIBDIR)/libFS.a
FSLIB =  -lFS
X
LINTFS =  $(LINTLIBDIR)/llib-lFS.ln
X
X         FONTLIBSRC = $(LIBSRC)/font
X
DEPFONTLIB =  $(USRLIBDIR)/libfont.a
FONTLIB =  -lfont
X
LINTFONT =  $(LINTLIBDIR)/llib-lfont.ln
X
X    XKBFILELIBSRC = $(LIBSRC)/xkbfile
X
DEPXKBFILELIB =  $(USRLIBDIR)/libxkbfile.a
XXKBFILELIB =  -lxkbfile
X
LINTXKBFILE =  $(LINTLIBDIR)/llib-lxkbfile.ln
X
X     XKBCOMPCMD = xkbcomp
X
X          DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)
X
X         DEPLIBS1 = $(DEPLIBS)
X         DEPLIBS2 = $(DEPLIBS)
X         DEPLIBS3 = $(DEPLIBS)
X         DEPLIBS4 = $(DEPLIBS)
X         DEPLIBS5 = $(DEPLIBS)
X         DEPLIBS6 = $(DEPLIBS)
X         DEPLIBS7 = $(DEPLIBS)
X         DEPLIBS8 = $(DEPLIBS)
X         DEPLIBS9 = $(DEPLIBS)
X         DEPLIBS10 = $(DEPLIBS)
X
IMAKE_DEFINES = -DBuild32bit=1
X
X        CONFIGDIR = $(LIBDIR)/config
X
X    USRLIBDIRPATH = $(USRLIBDIR)
X        LDPRELIBS =
X       LDPOSTLIBS = -nostdlib -L$(ROOT)$(SGIISALIBDIR) -L$(ROOT)$(SHLIBDIR)
X     TOP_INCLUDES =  $(TOP_X_INCLUDES)
X  PROJECT_DEFINES =
X
CXXPROJECT_DEFINES =
X
# ----------------------------------------------------------------------
# start of Imakefile
X
#
#	This is an Imakefile for the XGobi program.  The only change that
#	might need to be made is for the XGOBID variable.
#
X
# Remove the comment delimeters on the second to next line to
# compile for CORBA.
# Requires some Omegahat code - see README.corba.
#define USE_CORBA 1
X
#  Set XGOBID to the directory containing
#  the xgobi directories src, help, ps, etc.
X         XGOBID = $(PWD)/..
X
X              CC = cc
X       CCOPTIONS = -xansi -n32
X
#           CC = gcc
#    CCOPTIONS = -ansi -w
X
X             LD =
X     CDEBUGFLAGS = -g
# EXTRA_LDOPTIONS = -static
X
#
# RPC: Remote Procedure Calls
#
X
# If you plan to use RPC, uncomment this #define
# RPC is the define for any kind of RPC
X
# Special RPCs
X
# If you plan to use XPLORE, uncomment this #define
X
X LOCAL_LIBRARIES =  $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB)
X
X   SYS_LIBRARIES = -lm
X
X         DEFINES = -DDEFAULTDIR=\"$(XGOBID)\"
X
JOINTSRC = xgobi_init.c pipeline.c read_array.c \
X	initialize.c widgets.c callbacks.c getfname.c \
X	xyplot.c make_axes.c line_editor.c missing.c  \
X	spin_cbacks.c spin.c scaling.c scale_cbacks.c \
X	identify.c var_panel.c transform.c sphere.c stdize.c inference.c \
X	brush_init.c brush_cbacks.c brush.c paint.c brush_send.c \
X	help.c prt_plotwin.c subset.c vc_lists.c exclusion.c \
X	plot_once.c plot1d.c texture.c ash1d.c move_points.c \
X	show_message.c smooth.c smooth_fns.c smoothsk.c pspline.c \
X	save_data.c new_data.c read_data.c jitter.c parcoords.c utils.c \
X	tour_init.c tour_util.c tour.c tour_cbacks.c tour_send.c gt_ctls.c \
X	tour_pp.c svd.c kernel.c \
X	legendre.c hermite.c natrl_hermite.c de_indices.c \
X	central_mass.c holes.c skewness.c \
X	tour_section.c corr.c corr_index.c corr_pursuit.c corr_util.c \
X	DrawingA.c mt19937-1.c
JOINTOBJ = xgobi_init.o pipeline.o read_array.o \
X	initialize.o widgets.o callbacks.o getfname.o \
X	xyplot.o make_axes.o line_editor.o missing.o  \
X	spin_cbacks.o spin.o scaling.o scale_cbacks.o \
X	identify.o var_panel.o transform.o sphere.o stdize.o inference.o \
X	brush_init.o brush_cbacks.o brush.o paint.o brush_send.o \
X	help.o prt_plotwin.o subset.o vc_lists.o exclusion.o \
X	plot_once.o plot1d.o texture.o ash1d.o move_points.o \
X	show_message.o smooth.o smooth_fns.o smoothsk.o pspline.o \
X	save_data.o new_data.o read_data.o jitter.o parcoords.o utils.o \
X	tour_init.o tour_util.o tour.o tour_cbacks.o tour_send.o gt_ctls.o \
X	tour_pp.o svd.o kernel.o \
X	legendre.o hermite.o natrl_hermite.o de_indices.o \
X	central_mass.o holes.o skewness.o \
X	tour_section.o corr.o corr_index.o corr_pursuit.o corr_util.o \
X	DrawingA.o mt19937-1.o
X
RPCSRC =
RPCOBJ =
X
XXGOBISRC = xgobi.c $(JOINTSRC) $(RPCSRC) $(CORBASRC)
XXGOBIOBJ = xgobi.o $(JOINTOBJ) $(RPCOBJ) $(CORBAOBJ)
X
XXGVISSRC = xgvis.c xgv_histogram.c xgv_qsort.c xgv_mds.c \
X	xgv_read_data.c xgv_help.c \
X	xgv_stressplot.c xgv_cbacks.c xgv_widgets.c xgv_anchor.c $(JOINTSRC)
XXGVISOBJ = xgvis.o xgv_histogram.o xgv_qsort.o xgv_mds.o \
X	xgv_read_data.o xgv_help.o \
X	xgv_stressplot.o xgv_cbacks.o xgv_widgets.o xgv_anchor.o $(JOINTOBJ)
X
all:: xgvis xgobi
X
foo:
X	echo $(USRLIBDIR)
X	echo "$(LDPRELIBS) $(origin LDPRELIBS)"
X
xgobi:  $(XGOBIOBJ)
X	  $(RM) $@
X	 $(CCLINK) -o $@ $(LDOPTIONS)  $(XGOBIOBJ)   $(LDLIBS)  $(CORBA_LIBRARIES) $(LOCAL_LIBRARIES) $(EXTRA_LOAD_FLAGS)
X
clean::
X	 $(RM) xgobi
X
xgvis:  $(XGVISOBJ)
X	  $(RM) $@
X	 $(CCLINK) -o $@ $(LDOPTIONS)  $(XGVISOBJ)   $(LDLIBS)  $(LOCAL_LIBRARIES) $(EXTRA_LOAD_FLAGS)
X
clean::
X	 $(RM) xgvis
X
purexgobi: xgobi.o $(JOINTOBJ)
X	purify -cache-dir=/tmp  -always-use-cache-dir=yes \
X	${CC} ${CFLAGS} ${LD} ${LDOPTIONS} -o xgobi ${XGOBIOBJ} ${LOCAL_LIBRARIES} \
X	${SYS_LIBRARIES}
X
purexgvis: xgvis.o $(XGVISOBJ)
X	purify -cache-dir=/tmp  -always-use-cache-dir=yes \
X	${CC} ${CFLAGS} ${LD} ${LDOPTIONS} -o xgvis ${XGVISOBJ} ${LOCAL_LIBRARIES} \
X	${SYS_LIBRARIES}
X
# ----------------------------------------------------------------------
# common rules for all Makefiles - do not edit
X
X.c.i:
X	  $(RM) $@
X	 	$(CC) -E $(CFLAGS) $(_NOOP_) $*.c > $@
X
emptyrule::
X
clean::
X	$(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut   "#"*
X
Makefile::
X	 -@if [ -f Makefile ]; then set -x; \
X	 $(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \
X	else exit 0; fi
X	$(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR)
X
tags::
X	$(TAGS) -w *.[ch]
X	$(TAGS) -xw *.[ch] > TAGS
X
man_keywords::
X
# ----------------------------------------------------------------------
# empty rules for directories that do not have SUBDIRS - do not edit
X
install::
X	@echo "install in $(CURRENT_DIR) done"
X
install.man::
X	@echo "install.man in $(CURRENT_DIR) done"
X
install.linkkit::
X	@echo "install.linkkit in $(CURRENT_DIR) done"
X
Makefiles::
X
includes::
X
depend::
X
# ----------------------------------------------------------------------
# dependencies generated by makedepend
X
SHAR_EOF
  chmod 0644 'xgobi/src/Makefile' ||
  $echo 'restore of' 'xgobi/src/Makefile' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/Makefile:' 'MD5 check failed'
a14ca1b1f0776e00caec245671d786c2  xgobi/src/Makefile
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/Makefile'`"
    test 18766 -eq "$shar_count" ||
    $echo 'xgobi/src/Makefile:' 'original size' '18766,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/vc_lists.c ==============
if test -f 'xgobi/src/vc_lists.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/vc_lists.c' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/vc_lists.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/vc_lists.c' &&
/* vc_lists.c */
/************************************************************
X *                                                          *
X *  Permission is hereby granted  to  any  individual   or  *
X *  institution   for  use,  copying, or redistribution of  *
X *  the xgobi code and associated documentation,  provided  *
X *  that   such  code  and documentation are not sold  for  *
X *  profit and the  following copyright notice is retained  *
X *  in the code and documentation:                          *
X *        Copyright (c) 1990, ..., 1996 Bellcore            *
X *                                                          *
X *  We welcome your questions and comments, and request     *
X *  that you share any modifications with us.               *
X *                                                          *
X *    Deborah F. Swayne            Dianne Cook              *
X *   dfs@research.att.com       dicook@iastate.edu          *
X *      (973) 360-8423    www.public.iastate.edu/~dicook/   *
X *                                                          *
X *                    Andreas Buja                          *
X *                andreas@research.att.com                  *
X *              www.research.att.com/~andreas/              *
X *                                                          *
X ************************************************************/
X
#include <stdio.h>
#include "xincludes.h"
#include "xgobitypes.h"
#include "xgobivars.h"
#include "xgobiexterns.h"
#include <X11/Xatom.h>
#include <X11/Xproto.h>
X
#define DEFAULT_PROP_SIZE (10240L)
X
#define TRANSIENT  0
#define PERSISTENT 1
static int casemode = TRANSIENT;
X
static Widget doallvarsbox, doallcasesbox, doallvars[2], doallcases[2];
static Widget varlist_text, varlist_close, varlist_mgr;
Widget varlist_popup = (Widget) NULL;
static Widget caselist_text, caselist_close, caselist_mgr;
Widget caselist_popup = (Widget) NULL;
static XawTextSelectType select_array[] = {XawselectLine, XawselectNull} ;
X
static char *allvarnames, *allcasenames;
static Cardinal *initvarpos, *initcasepos;
X
#define VSELECTALL   doallvars[0]
#define VDESELECTALL doallvars[1]
#define CSELECTALL   doallcases[0]
#define CDESELECTALL doallcases[1]
X
/* ARGSUSED */
XXtCallbackProc
persistent_casemode_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  casemode = !casemode;
X  setToggleBitmap(w, casemode);
}
X
/* ARGSUSED */
XXtCallbackProc
select_all_vars_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  int i;
X  XawTextBlock newtext;
X  XawTextPosition start, end;
X
X  for (i=0; i<xg->ncols_used; i++)
X  {
X    allvarnames[initvarpos[i]] = '+' ;
X    xg->selectedvars[i] = True ;
X  }
X
X  start = 0;
X  end = (long) strlen(allvarnames);
X  newtext.ptr = allvarnames ;
X  newtext.format = FMT8BIT ;
X  newtext.firstPos = start;
X  newtext.length = end;
X  XawTextReplace(varlist_text, start, end, &newtext) ;
X  XawTextInvalidate(varlist_text, start, end);
X
X  if (xg->is_cprof_plotting && xg->link_cprof_plotting) {
X    update_cprof_selectedvars(xg);
X    reset_nvars_cprof_plot(xg);
X  }
X
}
X
/* ARGSUSED */
XXtCallbackProc
select_all_cases_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  int i;
X  XawTextBlock newtext;
X  XawTextPosition start, end;
X
X  for (i=0; i<xg->nrows; i++)
X  {
X    allcasenames[initcasepos[i]] = '+' ;
X    xg->selectedcases[i] = True ;
X  }
X
X  start = 0;
X  end = (long) strlen(allcasenames);
X  newtext.ptr = allcasenames ;
X  newtext.format = FMT8BIT ;
X  newtext.firstPos = start;
X  newtext.length = end;
X  XawTextReplace(caselist_text, start, end, &newtext) ;
X  XawTextInvalidate(caselist_text, start, end);
X
X  update_sticky_ids(xg);
X  plot_once(xg);
X  if (xg->is_cprof_plotting && xg->link_cprof_plotting)
X    passive_update_cprof_plot(xg);
}
X
/* ARGSUSED */
XXtCallbackProc
deselect_all_cases_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  int i;
X  XawTextBlock newtext;
X  XawTextPosition start, end;
X
X  for (i=0; i<xg->nrows; i++)
X  {
X    allcasenames[initcasepos[i]] = ' ' ;
X    xg->selectedcases[i] = False ;
X  }
X  xg->nearest_point = -1;
X
X  start = 0;
X  end = (long) strlen(allcasenames);
X  newtext.ptr = allcasenames ;
X  newtext.format = FMT8BIT ;
X  newtext.firstPos = start;
X  newtext.length = end;
X  XawTextReplace(caselist_text, start, end, &newtext) ;
X  XawTextInvalidate(caselist_text, start, end);
X
X  update_sticky_ids(xg);
X  plot_once(xg);
X  if (xg->is_cprof_plotting && xg->link_cprof_plotting)
X    passive_update_cprof_plot(xg);
}
X
void
build_replacement_text(Cardinal indx,
Cardinal *initposvec, char *allnames, Boolean *selected)
{
X  Boolean has_plus;
X  int initpos = initposvec[indx];
X
X  if (allnames[initpos] == ' ')
X    has_plus = False;
X  else if (allnames[initpos] == '+')
X    has_plus = True;
X  else
X  {
X    fprintf(stderr, "Problem!\n");
X    return;
X  }
X
X  /* the mode is now always TOGGLE */
X  if (has_plus) {
X    allnames[initpos] = ' ' ;
X    selected[indx] = False ;
X  } else {
X    allnames[initpos] = '+' ;
X    selected[indx] = True ;
X  }
}
X
/* ARGSUSED */
void
reset_list_selection(Widget w, xgobidata *xg, char *allnames,
Cardinal *initpos, Boolean *selected, int n)
{
X  XawTextPosition start, end;
X  Cardinal indx;
X  XawTextBlock newtext;
X  Boolean error = False;
X  /*
X   * start is position 0
X   * end is the next unhighlighted position after the selection
X  */
X  XawTextGetSelectionPos(w, &start, &end);
X
X  /*
X   * Find the first index, then step through allnames[]
X  */
X  if (allnames[start] == '+' || allnames[start] == ' ')
X  {
X    (void) sscanf(&allnames[start+2], "%d", &indx);
X    if (indx < 1 || indx > n)
X      error = True;
X  }
X
X  if (error)
X  {
X    (void) fprintf(stderr,
X      "Selection imperfectly formed; please select again\n");
X  }
X  else
X  {
X    indx-- ;
X    while (indx < n) {
X      if (initpos[indx] < end - 4) {
X         build_replacement_text(indx, initpos, allnames, selected) ;
X         indx++ ;
X      }
X      else
X        break ;
X    }
X    newtext.ptr = allnames ;
X    newtext.format = FMT8BIT ;
X    newtext.firstPos = start ;
X    newtext.length = end - start ;
X    XawTextReplace(w, start, end, &newtext) ;
X    XawTextInvalidate(w, start, end);
X  }
}
X
/* ARGSUSED */
XXtActionProc
ToggleCurrentLine(Widget w, XEvent *evnt, String *params, Cardinal nparams)
{
X  extern xgobidata xgobi;
X  xgobidata *xg = &xgobi;
X  int line = -1;
X  Boolean ok = True;
X
X  XawTextPosition start, end;
X  int i;
X  static int prev_line = -1;
X
X  /* This routine was kicked off by a button press or by button motion */
X  Boolean button_press = True;
X  if (strcmp(params[0], "m") == 0) button_press = False;
X
X  /* Kludge */
X  xg->current_window = True;
X
X  if (w == caselist_text)
X  {
/*
X * Try a different way of getting the line number.
*/
X    XawTextGetSelectionPos(w, &start, &end);
X    for (i=0; i<xg->nrows; i++) {
X      if (initcasepos[i] >= start) {
X        line = i;
X        break;
X      }
X    }
X
X    if (line == -1)
X      return((XtActionProc) 0);
X
X    if (casemode == TRANSIENT)
X    {
X      /* For transient labels, try to prevent unnecessary redrawing */
X      if (line == prev_line)
X        return((XtActionProc) 0);
X
X      if (line >= 0 && line <= xg->nrows)
X          xg->nearest_point = line;
X      else
X        ok = False;
X
X    } else {  /* if PERSISTENT */
X
X       reset_list_selection(w, xg, allcasenames, initcasepos,
X         xg->selectedcases, xg->nrows);
X
X        update_sticky_ids(xg);
X        plot_once(xg);
X        if (xg->is_cprof_plotting && xg->link_cprof_plotting)
X          passive_update_cprof_plot(xg);
X    }
X
X    if (ok) {
X
X      if (xg->link_identify) {
X        XtOwnSelection( (Widget) xg->workspace,
X          (Atom) XG_IDS,
X          (Time) CurrentTime, /* doesn't work with XtLastTimeStamp...? */
X          /*(Time) XtLastTimestampProcessed(display),*/
X          (XtConvertSelectionProc) pack_ids,
X          (XtLoseSelectionProc) NULL ,
X          (XtSelectionDoneProc) NULL );
X        announce_ids(xg);
X      }
X
X      if ( (xg->is_plotting1d && xg->is_plot1d_cycle) ||
X           (xg->is_xyplotting && xg->is_xy_cycle) ||
X           (xg->is_spinning && !xg->is_spin_paused ) ||
X           (xg->is_touring && !xg->is_tour_paused) ||
X           (xg->is_corr_touring && !xg->is_corr_paused))
X        ;
X      else
X        quickplot_once(xg);
X  
X      if (xg->is_cprof_plotting && xg->link_cprof_plotting)
X        update_cprof_plot(xg);
X    }
X  }
X
X  else if (w == varlist_text) {
X
X    XawTextGetSelectionPos(w, &start, &end);
X    for (i=0; i<xg->ncols_used; i++) {
X      if (initvarpos[i] >= start) {
X        line = i;
X        break;
X      }
X    }
X
X    if (line == -1)
X      return((XtActionProc) 0);
X
X    /* If this event is responding to button motion, ignore repeated
X     * movements on the same line */
X    else if (line == prev_line && button_press == False)
X      return((XtActionProc) 0);
X
X    prev_line = line;
X
X    /* Always persistent ... */
X    reset_list_selection(w, xg, allvarnames,
X      initvarpos, xg->selectedvars, xg->ncols_used);
X
X    if (xg->is_cprof_plotting && xg->link_cprof_plotting) {
X      update_cprof_selectedvars(xg);
X      reset_nvars_cprof_plot(xg);
X    }
X  }
X
X  prev_line = line;
}
X
/* ARGSUSED */
static XtCallbackProc
PopdownCaselist(Widget w, xgobidata *xg, XtPointer callback_data)
/*
X * Pop down the caselist popup.
*/
{
X  /*fprintf(stderr, "%d\n", ((ShellWidget) caselist_popup)->shell.popped_up);*/
X  XtPopdown(caselist_popup);
X  /*fprintf(stderr, "%d\n", ((ShellWidget) caselist_popup)->shell.popped_up);*/
}
X
/* ARGSUSED */
static XtCallbackProc
PopdownVarlist(Widget w, xgobidata *xg, XtPointer callback_data)
/*
X * Pop down the scrollable variable list.
*/
{
X  XtPopdown(varlist_popup);
}
X
void
free_varlist(xgobidata *xg)
{
X  XtFree((XtPointer) allvarnames);
X  XtFree((XtPointer) initvarpos);
X  XtFree((XtPointer) xg->selectedvars);
X  /*XtDestroyWidget(varlist_popup);*/
}
X
void
varlist_add_group_var(xgobidata *xg)
{
X  char str[32];
X  XawTextBlock newtext;
X  XawTextPosition start, end;
X  Boolean popped_up = False;
X
X  sprintf(str, "\n  %d : group", xg->ncols);
X  initvarpos[xg->ncols-1] = strlen(allvarnames)+1 ;
X  strcat(allvarnames,  str);
X  /* Unselect it */
X  xg->selectedvars[xg->ncols-1] = False ;
X  allvarnames[initvarpos[xg->ncols-1]] = ' ' ;
X
X  if (varlist_popup != (Widget) NULL) {
X    if (((ShellWidget) varlist_popup)->shell.popped_up) {
X      XtPopdown(varlist_popup);
X      popped_up = true;
X    }
X    /* Update the text widget as well */
X    start = 0;
X    end = (long) strlen(allvarnames);
X    newtext.ptr = allvarnames ;
X    newtext.format = FMT8BIT ;
X    newtext.firstPos = start;
X    newtext.length = end;
X    XawTextReplace(varlist_text, start, end, &newtext) ;
X    XawTextInvalidate(varlist_text, start, end);
X    if (popped_up)
X      XtPopup(varlist_popup, XtGrabNone);
X  }
}
X
void
build_varlist(xgobidata *xg)
{
X  char strtmp[200];
X  int allvarlen = 0;
X  Cardinal j, len1name;
X
X  allvarnames = (char *) XtMalloc((Cardinal)
X    (xg->ncols * (COLLABLEN+2*16)) * sizeof(char));
X  initvarpos = (Cardinal *) XtMalloc((Cardinal)
X    xg->ncols * sizeof(Cardinal));
X  xg->selectedvars = (Boolean *) XtMalloc((Cardinal)
X    xg->ncols * sizeof(Boolean));
X
X  for (j=0; j<xg->ncols_used; j++)
X  {
X    xg->selectedvars[j] = True ;  /* Initialize to True, all but the last one */
X    sprintf(strtmp, "+ %d : %s\n", j+1, xg->collab[j]);
X    len1name = strlen(strtmp) ;
X    initvarpos[j] = allvarlen ;
/* bug fix a la mcintosh
*   allvarlen += len1name ;
*   strcat(allvarnames, strtmp);
*/
X    strcpy(allvarnames+allvarlen, strtmp);
X    allvarlen += len1name ;
X  }
X  /* unselect 'group' if it has already been created */
X  if (xg->ncols_used == xg->ncols) {
X    xg->selectedvars[xg->ncols-1] = False ;
X    allvarnames[initvarpos[xg->ncols-1]] = ' ' ;
X  }
X
X  allvarnames[allvarlen - 1] = '\0';
X
X  /* Make it long enough to contain the group variable later */
X  allvarlen += (COLLABLEN+2*16);
X  allvarnames = (char *)
X    XtRealloc((XtPointer) allvarnames, (Cardinal) allvarlen);
}
X
void
build_varlist_popup(xgobidata *xg)
{
X  char strtmp[200];
X  Cardinal j, len1name, longest_len = 0;
X  Cardinal longest_indx = 0;
X  Dimension width;
X  Widget pane;
X
X  for (j=0; j<xg->ncols_used; j++)
X  {
X    len1name = strlen(xg->collab[j]);
X    if (len1name > longest_len )
X    {
X      longest_len = len1name;
X      longest_indx = j;
X    }
X  }
X
X  sprintf(strtmp, "+ %d : %s", longest_indx+1, xg->collab[longest_indx]) ;
X  width = (Dimension) XTextWidth(appdata.font, strtmp, strlen(strtmp));
X
X  varlist_popup = XtVaCreatePopupShell("List",
X    topLevelShellWidgetClass, xg->shell,
X    XtNinput, True,
X    XtNtitle, "Variable List",
X    NULL);
X  if (mono) set_mono(varlist_popup);
X
X  pane = XtVaCreateManagedWidget("Form",
X    panedWidgetClass, varlist_popup,
X    XtNorientation, (XtOrientation) XtorientVertical,
X    NULL);
X
X  varlist_mgr = XtVaCreateManagedWidget("Panel",
X    formWidgetClass, pane,
X    NULL);
X  if (mono) set_mono(varlist_mgr);
X
X  /*
X   * Create the text widget.
X  */
X  varlist_text = XtVaCreateManagedWidget("Text",
X    asciiTextWidgetClass, varlist_mgr,
X    XtNfont, appdata.font,
X    XtNtop, (XtEdgeType) XtChainTop,
X    XtNbottom, (XtEdgeType) XtChainBottom,
X    XtNleft, (XtEdgeType) XtChainLeft,
X    XtNright, (XtEdgeType) XtChainRight,
X    XtNwidth, (Dimension)
X      (width + 2*ASCII_TEXT_BORDER_WIDTH + 14),  /* Margins, scrollbar */
X    XtNheight, (Dimension) MIN(xg->ncols_used,10)*FONTHEIGHT(appdata.font),
X    XtNallowResize, (Boolean) True,
X    XtNtype, (XawAsciiType) XawAsciiString,
/*
X * Setting editType to textRead makes the search popup behave correctly,
X * disabling the replace functions, but it also makes it impossible
X * for the programmer to change the text; ie, the '+' signs can't
X * be removed and added as needed.
*/
X    XtNeditType, (XawTextEditType) XawtextEdit,
X    XtNstring, (String) allvarnames,
X    XtNscrollVertical, (XawTextScrollMode) XawtextScrollWhenNeeded,
X    XtNdisplayCaret, (Boolean) False,
X    XtNselectTypes, (XawTextSelectType) select_array,
X    NULL);
X  if (mono) set_mono(varlist_text);
X
X  doallvarsbox = XtVaCreateManagedWidget("Panel",
X    boxWidgetClass, varlist_mgr,
X    XtNfromVert, (Widget) varlist_text,
X    XtNleft, (XtEdgeType) XtChainLeft,
X    XtNright, (XtEdgeType) XtChainLeft,
X    XtNtop, (XtEdgeType) XtChainBottom,
X    XtNbottom, (XtEdgeType) XtChainBottom,
X    XtNorientation, (XtOrientation) XtorientHorizontal,
X    NULL);
X  if (mono) set_mono(doallvarsbox);
X
X  VSELECTALL = (Widget) CreateCommand(xg, "Select All",
X    True, (Widget) NULL, (Widget) NULL, doallvarsbox, "VarList");
X  XtManageChildren(doallvars, 1);
X  XtAddCallback(VSELECTALL, XtNcallback,
X    (XtCallbackProc) select_all_vars_cback, (XtPointer) xg);
X
X  /*
X   * Create the Close button.
X  */
X  varlist_close = XtVaCreateManagedWidget("Click here to dismiss",
X    commandWidgetClass, pane,
X    XtNshowGrip, (Boolean) False,
X    XtNskipAdjust, (Boolean) True,
X    NULL);
X
X  if (mono) set_mono(varlist_close);
X  XtAddCallback(varlist_close, XtNcallback,
X    (XtCallbackProc) PopdownVarlist, (XtPointer) xg);
}
X
/* ARGSUSED */
XXtCallbackProc
PopupVarlist(Widget w, xgobidata *xg, XtPointer callback_data)
/*
X * Pop up the scrollable variable list.
*/
{
X  Dimension width, height;
X  Position x, y;
X  Boolean initd = True;
X  if (varlist_popup == NULL)
X    initd = False;
X
X  if (!initd)
X  {
X    build_varlist_popup(xg);
X
X    XtVaGetValues(w,
X      XtNwidth, &width,
X      XtNheight, &height, NULL);
X    XtTranslateCoords(w,
X      (Position) (width/2), (Position) (height/2), &x, &y);
X
X    XtVaSetValues(varlist_popup,
X      XtNx, (Position) x,
X      XtNy, (Position) y, NULL);
X  }
X
X  XtPopup(varlist_popup, XtGrabNone);
X  XRaiseWindow(display, XtWindow(varlist_popup));
X
X  if (!initd)
X    set_wm_protocols(varlist_popup);
}
X
void
free_caselist(xgobidata *xg)
{
X  XtFree((XtPointer) allcasenames);
X  XtFree((XtPointer) initcasepos);
X  XtFree((XtPointer) xg->selectedcases);
X  /*XtDestroyWidget(caselist_popup);*/
}
X
void
build_caselist(xgobidata *xg)
{
X  char strtmp[200];
X  int allcaselen = 0;
X  int j, len1name;
X
X  allcasenames = (char *) XtMalloc((Cardinal)
X    (xg->nrows * (ROWLABLEN+8)) * sizeof(char));
X  initcasepos = (Cardinal *) XtMalloc((Cardinal)
X    xg->nrows * sizeof(Cardinal));
X  xg->selectedcases = (Boolean *) XtMalloc((Cardinal)
X    xg->nrows * sizeof(Cardinal));
X
X  for (j=0; j<xg->nrows; j++)
X  {
X    xg->selectedcases[j] = False ;  /* Initialize to False */
X    sprintf(strtmp, "  %d : %s\n", j+1, xg->rowlab[j]);
X    len1name = strlen(strtmp) ;
X    initcasepos[j] = allcaselen ;
/* bug fix; mcintosh
*   allcaselen += len1name ;
*   strcat(allcasenames, strtmp);
*/
X    strcpy(allcasenames+allcaselen, strtmp);
X    allcaselen += len1name ;
X  }
X
X  allcasenames[allcaselen - 1] = '\0';
X  allcasenames = (char *)
X    XtRealloc((XtPointer) allcasenames, (Cardinal) allcaselen);
}
X
void
build_caselist_popup(xgobidata *xg)
{
X  char strtmp[200];
X  Cardinal j, len1name, longest_len = 0;
X  Cardinal longest_indx = 0;
X  Dimension width;
X  Widget modebox, modebtn;
X  Widget pane;
X
X  for (j=0; j<xg->nrows; j++)
X  {
X    len1name = strlen(xg->rowlab[j]) ;
X    if (len1name > longest_len )
X    {
X      longest_len = len1name;
X      longest_indx = j;
X    }
X  }
X
X  sprintf(strtmp, "+ %d : %s", longest_indx+1, xg->rowlab[longest_indx]) ;
X  width = (Dimension) XTextWidth(appdata.font, strtmp, strlen(strtmp));
X
X  caselist_popup = XtVaCreatePopupShell("List",
X    topLevelShellWidgetClass, xg->shell,
X    XtNinput, True,
X    XtNtitle, "Case List",
X    NULL);
X  if (mono) set_mono(caselist_popup);
X
X  pane = XtVaCreateManagedWidget("Form",
X    panedWidgetClass, caselist_popup,
X    XtNorientation, (XtOrientation) XtorientVertical,
X    NULL);
X
X  caselist_mgr = XtVaCreateManagedWidget("Panel",
X    formWidgetClass, pane,
X    NULL);
X  if (mono) set_mono(caselist_mgr);
X
X  /*
X   * Create the text widget.
X  */
X  caselist_text = XtVaCreateManagedWidget("Text",
X    asciiTextWidgetClass, caselist_mgr,
X    XtNfont, appdata.font,
X    XtNtop, (XtEdgeType) XtChainTop,
X    XtNbottom, (XtEdgeType) XtChainBottom,
X    XtNleft, (XtEdgeType) XtChainLeft,
X    XtNright, (XtEdgeType) XtChainRight,
X    XtNwidth, (Dimension)
X      (width + 2*ASCII_TEXT_BORDER_WIDTH + 20),  /* Margins, scrollbar */
X    XtNheight, (Dimension) MIN(xg->nrows,20)*FONTHEIGHT(appdata.font),
X    XtNallowResize, (Boolean) True,
X    XtNtype, (XawAsciiType) XawAsciiString,
X    XtNeditType, (XawTextEditType) XawtextEdit,
X    XtNstring, (String) allcasenames,
X    XtNscrollVertical, (XawTextScrollMode) XawtextScrollWhenNeeded,
X    XtNdisplayCaret, (Boolean) False,
X    XtNselectTypes, (XawTextSelectType) select_array,
X    NULL);
X  if (mono) set_mono(caselist_text);
X
X  /*
X   * Create the command buttons that all labels to be selected
X   * or deselected at once.
X  */
X  doallcasesbox = XtVaCreateManagedWidget("Panel",
X    boxWidgetClass, caselist_mgr,
X    XtNfromVert, (Widget) caselist_text,
X    XtNleft, (XtEdgeType) XtChainLeft,
X    XtNright, (XtEdgeType) XtChainLeft,
X    XtNtop, (XtEdgeType) XtChainBottom,
X    XtNbottom, (XtEdgeType) XtChainBottom,
X    XtNorientation, (XtOrientation) XtorientHorizontal,
X    NULL);
X  if (mono) set_mono(doallcasesbox);
X
X  CSELECTALL = (Widget) CreateCommand(xg, "Select All",
X    True, (Widget) NULL, (Widget) NULL, doallcasesbox, "CaseList");
X  CDESELECTALL = (Widget) CreateCommand(xg, "Deselect All",
X    True, (Widget) CSELECTALL, (Widget) NULL, doallcasesbox, "CaseList");
X  XtManageChildren(doallcases, 2);
X
X  XtAddCallback(CSELECTALL, XtNcallback,
X    (XtCallbackProc) select_all_cases_cback, (XtPointer) xg);
X  XtAddCallback(CDESELECTALL, XtNcallback,
X    (XtCallbackProc) deselect_all_cases_cback, (XtPointer) xg);
X
X  /*
X   * Create the buttons that set persistent or transient highlighting
X  */
X  modebox = XtVaCreateManagedWidget("Panel",
X    boxWidgetClass, caselist_mgr,
X    XtNfromVert, (Widget) doallcasesbox,
X    XtNleft, (XtEdgeType) XtChainLeft,
X    XtNright, (XtEdgeType) XtChainLeft,
X    XtNtop, (XtEdgeType) XtChainBottom,
X    XtNbottom, (XtEdgeType) XtChainBottom,
X    XtNorientation, (XtOrientation) XtorientHorizontal,
X    NULL);
X  if (mono) set_mono(modebox);
X
X  modebtn = (Widget) CreateToggle(xg, "Persistent Labels",
X    True, (Widget) NULL, (Widget) NULL, (Widget) NULL,
X    False, ANY_OF_MANY, modebox, "CaseList");
X  XtManageChild(modebtn);
X
X  XtAddCallback(modebtn, XtNcallback,
X    (XtCallbackProc) persistent_casemode_cback, (XtPointer) xg);
X
X  /*
X   * Create the Close button.
X  */
X  caselist_close = XtVaCreateManagedWidget("Click here to dismiss",
X    commandWidgetClass, pane,
X    XtNshowGrip, (Boolean) False,
X    XtNskipAdjust, (Boolean) True,
X    NULL);
X  if (mono) set_mono(caselist_close);
X  XtAddCallback(caselist_close, XtNcallback,
X    (XtCallbackProc) PopdownCaselist, (XtPointer) xg);
}
X
/* ARGSUSED */
XXtCallbackProc
PopupCaselist(Widget w, xgobidata *xg, XtPointer callback_data)
/*
X * Pop up the scrollable case list.
*/
{
X  Dimension width, height;
X  Position x, y;
X  int k;
X  Boolean initd = True;
X  if (caselist_popup == NULL)
X    initd = False;
X
X  if (!initd)
X  {
X    build_caselist_popup(xg);
X
X    XtVaGetValues(w,
X      XtNwidth, &width,
X      XtNheight, &height,
X      NULL);
X    XtTranslateCoords(w,
X      (Position) (width/2), (Position) (height/2), &x, &y);
X
X    XtVaSetValues(caselist_popup,
X      XtNx, (Position) x,
X      XtNy, (Position) y, NULL);
X  }
X
X  XtPopup(caselist_popup, XtGrabNone);
X  XRaiseWindow(display, XtWindow(caselist_popup));
X
X  /* Make sure current sticky labels are reflected in the display */
X  for (k=0; k<xg->nsticky_ids; k++) {
X    update_list_selection(xg, xg->sticky_ids[k], True);
X  }
X
X  if (!initd)
X    set_wm_protocols(caselist_popup);
}
X
void
update_list_selection(xgobidata *xg, int id, Boolean add) {
X  /* add or delete a selection */
X
X  XawTextPosition start, end;
X  XawTextBlock newtext;
X  char prevch, newch;
X
X  if (add) {
X    prevch = ' ';
X    newch = '+';
X  } else {
X    prevch = '+';
X    newch = ' ';
X  }
X
X  if (allcasenames[initcasepos[id]] == prevch) {
X    xg->selectedcases[id] = add;
X
X    start = (long) initcasepos[id];
X    end = (long) initcasepos[id+1];
X    allcasenames[start] = newch;
X    newtext.ptr = allcasenames ;
X    newtext.format = FMT8BIT ;
X    newtext.firstPos = start ;
X    newtext.length = end - start ;
X    XawTextReplace(caselist_text, start, end, &newtext) ;
X    XawTextInvalidate(caselist_text, start, end);
X  }
}
SHAR_EOF
  chmod 0644 'xgobi/src/vc_lists.c' ||
  $echo 'restore of' 'xgobi/src/vc_lists.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/vc_lists.c:' 'MD5 check failed'
77ac3d3d8e144bd3f200358a03cc2ea9  xgobi/src/vc_lists.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/vc_lists.c'`"
    test 22325 -eq "$shar_count" ||
    $echo 'xgobi/src/vc_lists.c:' 'original size' '22325,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/help.c ==============
if test -f 'xgobi/src/help.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/help.c' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/help.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/help.c' &&
/* help.c */
/************************************************************
X *                                                          *
X *  Permission is hereby granted  to  any  individual   or  *
X *  institution   for  use,  copying, or redistribution of  *
X *  the xgobi code and associated documentation,  provided  *
X *  that   such  code  and documentation are not sold  for  *
X *  profit and the  following copyright notice is retained  *
X *  in the code and documentation:                          *
X *        Copyright (c) 1990, ..., 1996 Bellcore            *
X *                                                          *
X *  We welcome your questions and comments, and request     *
X *  that you share any modifications with us.               *
X *                                                          *
X *    Deborah F. Swayne            Dianne Cook              *
X *   dfs@research.att.com       dicook@iastate.edu          *
X *      (973) 360-8423    www.public.iastate.edu/~dicook/   *
X *                                                          *
X *                    Andreas Buja                          *
X *                andreas@research.att.com                  *
X *              www.research.att.com/~andreas/              *
X *                                                          *
X ************************************************************/
X
#include <stdlib.h>
#include <stdio.h>
#include "xincludes.h"
#include "xgobitypes.h"
#include "xgobivars.h"
#include "xgobiexterns.h"
X
X
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
X
X
#define NMENUS NCOLS+40
#define NSBARS 32
#define NCOMMANDS 512
X
typedef struct {
X   Widget w;
X   char *helpFile;
} HelpTable;
X
HelpTable pb_table[NCOMMANDS];
HelpTable sbar_table[NSBARS];
HelpTable menupb_table[NMENUS];
X
/* ARGSUSED */
XXtActionProc
HelpSelect(Widget w, XEvent *evnt, String *params, Cardinal nparams)
/*
X * Search the help tables looking for w, then call help()
*/
{
X  int j = 0;
X  extern xgobidata xgobi;
X  xgobidata *xg = &xgobi;
X
X  while (pb_table[j].w != NULL)
X  {
X    if (pb_table[j].w == w)
X    {
X      help(w, pb_table[j].helpFile, xg);
X      break;
X    }
X    else
X      j++;
X  }
X
X  j = 0;
X  while (sbar_table[j].w != NULL)
X  {
X    if (sbar_table[j].w == w)
X    {
X      help(w, sbar_table[j].helpFile, xg);
X      break;
X    }
X    else
X      j++;
X  }
X
X  j = 0;
X  while (menupb_table[j].w != NULL)
X  {
X    if (menupb_table[j].w == w)
X    {
X      help(w, menupb_table[j].helpFile, xg);
X      break;
X    }
X    else
X      j++;
X  }
}
X
/* ARGSUSED */
XXtCallbackProc
help_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  help(XtParent(XtParent(w)), "Help", xg);
}
X
/* ARGSUSED */
XXtCallbackProc
about_xgobi_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  help(XtParent(XtParent(w)), "AboutXGobi", xg);
}
X
void
init_help(xgobidata *xg)
{
X  xg->nhelpids.pb = xg->nhelpids.menupb = xg->nhelpids.sbar = 0;
}
X
/* ARGSUSED */
XXtCallbackProc
help_done_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  XtDestroyWidget(XtParent(XtParent(w)));
}
X
/* ARGSUSED */
void
help(Widget popup_pop, char *helpfile, xgobidata *xg)
{
X  char fname[100];
X  char message[MSGLENGTH];
X  char *xgobidir;
X  FILE *fp;
X  extern xgobidata xgobi;
X
X  xgobidir = getenv("XGOBID");
X  if (xgobidir == NULL || strlen(xgobidir) == 0)
X  {
X    xgobidir = (char *) XtMalloc((Cardinal) 150 * sizeof(char));
X    (void) strcpy(xgobidir, DEFAULTDIR);
X    if (xgobidir == NULL || strlen(xgobidir) == 0)
X    {
X      sprintf(message,
X       "XGOBID is not defined in your environment, and\n");
X      strcat(message,
X       "DEFAULTDIR is not defined in the XGobi Makefile;\n");
X      strcat(message,
X        "see the person who installed XGobi for help.\n");
X      show_message(message, &xgobi);
X      return;
X    }
X    else
X    {
X      (void) strcpy(fname, xgobidir);
X      XtFree((XtPointer) xgobidir);
X    }
X  }
X  else
X  {
X    (void) strcpy(fname, xgobidir);
X  }
X
/*
X * Check that the file is good.
*/
X  (void) strcat(fname, "/help/");
X  (void) strcat(fname, helpfile);
X  if ((fp = fopen(fname, "r")) == NULL)
X  {
X    sprintf(message,
X      "Unable to open %s.\n", fname);
X    strcat(message,
X      "Is the shell variable XGOBID the name of the directory\n");
X    strcat(message,
X      "which contains the help subdirectory?\n");
X    show_message(message, &xgobi);
X    return;
X  }
X  else
X  {
X    Widget hpopup, hframe, htext, hdone;
X  /*
X   * Create the popup itself.
X  */
X    hpopup = XtVaCreatePopupShell("Help",
X      topLevelShellWidgetClass, popup_pop,
X      XtNtitle, (String) "XGobi Help Window",
X      XtNiconName, (String) "XGobi Help Window",
X      NULL);
X    if (mono) set_mono(hpopup);
X  /*
X   * Create the paned widget.
X  */
X    hframe = XtVaCreateManagedWidget("Form",
X      panedWidgetClass, hpopup,
X      XtNorientation, (XtOrientation) XtorientVertical,
X      NULL);
X    if (mono) set_mono(hframe);
X
X  /*
X   * Create the text widget.
X  */
X    htext = XtVaCreateManagedWidget("Text",
X      asciiTextWidgetClass, hframe,
X      XtNallowResize, (Boolean) True,
X      XtNshowGrip, (Boolean) False,
X      XtNtype, (XawAsciiType) XawAsciiFile,
X      XtNstring, (String) fname,
X      /* AB
X      XtNscrollVertical, (XawTextScrollMode) XawtextScrollWhenNeeded,
X      */
X      XtNscrollVertical, (XawTextScrollMode) XawtextScrollAlways,
X      XtNdisplayCaret, (Boolean) False,
X      XtNfont, (XFontStruct *) appdata.helpFont,
X      /* Moving these here from the fallback resources for xgvis */
X      XtNheight, 250,
X      XtNwidth, 600,
X      NULL);
X    if (mono) set_mono(htext);
X
X  /*
X   * Create the Done button.
X  */
X    hdone = XtVaCreateManagedWidget("Done",
X      commandWidgetClass, hframe,
X      XtNshowGrip, (Boolean) False,
X      XtNskipAdjust, (Boolean) True,
X      XtNlabel, (String) "Click here to dismiss",
X      NULL);
X    if (mono) set_mono(hdone);
X
X    XtAddCallback(hdone, XtNcallback,
X      (XtCallbackProc) help_done_cback, (XtPointer) NULL);
X
X    XtPopup(hpopup, XtGrabNone);
X    XRaiseWindow(display, XtWindow(hpopup));
X
X    set_wm_protocols(hpopup);
X
X    fclose(fp);
X  }
X  return;
}
X
void
add_pb_help(int *n, Widget w, char *fname)
/*
X * Add a widget to the helptable for pushbutton widgets.
*/
{
X  if (*n>0 && pb_table[*n-1].w == NULL)
X    (*n)--;
X
X  pb_table[*n].w = w;
X  pb_table[*n].helpFile = fname;
X  (*n)++;
X
X  if (*n == NCOMMANDS)
X    printf("Edit help.c and increase NCOMMANDS\n");
}
X
void
add_menupb_help(int *n, Widget w, char *fname)
/*
X * Add a widget to the helptable for menus.
*/
{
X  /*if (*n>0 && pb_table[*n-1].w == NULL)*/
X  if (*n>0 && menupb_table[*n-1].w == NULL)
X    (*n)--;
X
X  menupb_table[*n].w = w;
X  menupb_table[*n].helpFile = fname;
X  (*n)++;
X
X  if (*n == NMENUS)
X    printf("Edit help.c and increase NMENUS\n");
}
X
void
add_sbar_help(int *n, Widget w, char *fname)
/*
X * Add a widget to the helptable for scrollbar widgets.
*/
{
X  sbar_table[*n].w = w;
X  sbar_table[*n].helpFile = fname;
X  (*n)++;
X
X  if (*n == NSBARS)
X    printf("Edit help.c and increase NSBARS\n");
}
X
/****************************/
X
#include "../bitmaps/splash.xbm"
#include "../bitmaps/Bellcore.xbm"
Widget splashxgobi;
X
/*ARGSUSED*/
XXtCallbackProc
kill_splash(Widget w, XtPointer client_data, XtPointer callback_data)
{
X  XtDestroyWidget(XtParent(XtParent(w)));
X  splashxgobi = (Widget) NULL;
}
X
void
show_splash_screen(xgobidata *xg)
{
X  Screen *scrn;
X  Boolean ok;
X  Pixmap splashbcr_pix, splashxgobi_pix;
X  Widget splashshell, splashform, splashbcr;
X  Pixel splashfg, splashbg;
X  XColor exact;
X  Colormap cmap;
X  XEvent event;
X
/* show the splash screen */
X  scrn = XtScreen(xg->shell);
X  splashbg = WhitePixelOfScreen(scrn);
X  if (!mono)
X  {
X    cmap = DefaultColormap(display,  DefaultScreen(display));
X    ok = False;
/* Bellcore blue: R=0, G=96/24576, B=141/36096 */
X    if (XParseColor(display, cmap, "DeepSkyBlue4", &exact)) {
X      if (XAllocColor(display, cmap, &exact)) {
X        splashfg = exact.pixel;
X        ok = True;
X      }
X    }
X  }
X  if (mono || !ok)
X    splashfg = BlackPixelOfScreen(scrn);
X
X  splashbcr_pix = XCreatePixmapFromBitmapData(display,
X    RootWindowOfScreen(XtScreen(xg->shell)),
X    Bellcore_bits, Bellcore_width, Bellcore_height,
X    splashfg, splashbg,
X    depth);
X  splashxgobi_pix = XCreatePixmapFromBitmapData(display,
X    RootWindowOfScreen(XtScreen(xg->shell)),
X    splash_bits, splash_width, splash_height,
X    splashfg, splashbg,
X    depth);
X  splashshell = XtVaCreatePopupShell("Splash",
X    transientShellWidgetClass, xg->shell,
X    XtNinput, True,
X    XtNtitle, "XGobi",
X    XtNbackground, splashbg,
X    XtNx, 100,
X    XtNy, 100,
X    NULL);
X  splashform = XtVaCreateManagedWidget("Splash",
X    formWidgetClass, splashshell,
X    XtNbackground, splashbg,
X    NULL);
X  splashbcr = XtVaCreateManagedWidget("Splash",
X    labelWidgetClass, splashform,
X    XtNinternalHeight, (Dimension) 0,
X    XtNinternalWidth, (Dimension) 0,
X    XtNbitmap, (Pixmap) splashbcr_pix,
X    XtNborderWidth, 0,
X    NULL);
X  splashxgobi = XtVaCreateManagedWidget("Splash",
X    commandWidgetClass, splashform,
X    XtNinternalHeight, (Dimension) 0,
X    XtNinternalWidth, (Dimension) 0,
X    XtNbitmap, (Pixmap) splashxgobi_pix,
X    XtNfromVert, splashbcr,
X    XtNvertDistance, 0,
X    XtNborderWidth, 0,
X    NULL);
X
X  XtAddCallback(splashxgobi, XtNcallback,
X    (XtCallbackProc) kill_splash, (XtPointer) NULL);
X  XtPopup(splashshell, XtGrabNone);
X  XRaiseWindow(display, XtWindow(splashshell));
X
/*
printf("splashshell %d\n", XtWindow(splashshell));
printf("splashform %d\n", XtWindow(splashform));
printf("splashbcr %d\n", XtWindow(splashbcr));
printf("splashxgobi %d\n", XtWindow(splashxgobi));
*/
X
X  while (1) {
X    XtAppNextEvent(app_con, &event);
X    /*printf("event = %d, window = %d\n", event.type, event.xany.window);*/
X    XtDispatchEvent(&event);
X    /* Once the last widget gets an expose event, bail out */
X    if (event.type == 12 && event.xany.window == XtWindow(splashxgobi))
X      break;
X  }
}
SHAR_EOF
  chmod 0644 'xgobi/src/help.c' ||
  $echo 'restore of' 'xgobi/src/help.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/help.c:' 'MD5 check failed'
d153fe9506ae262698146c5510c78bf6  xgobi/src/help.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/help.c'`"
    test 9929 -eq "$shar_count" ||
    $echo 'xgobi/src/help.c:' 'original size' '9929,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/.purify ==============
if test -f 'xgobi/src/.purify' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/.purify' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/.purify' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/.purify' &&
suppress abr _mdbm_fetch; _ns_lookup; _gethostbyname_r; _X11TransSocketINETConnect
suppress umr _sendmsg
suppress umr _mdbm_fetch; _ns_lookup; _gethostbyname_r; _X11TransSocketINETConnect
suppress umr _XRead
suppress umr StoreLateBindings
suppress umr ObjectDestroy
suppress umr PaintCommandWidget
suppress umr _XReply
suppress umr GeometryManager
SHAR_EOF
  chmod 0644 'xgobi/src/.purify' ||
  $echo 'restore of' 'xgobi/src/.purify' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/.purify:' 'MD5 check failed'
fdef507b6fe54e2acb0fc508df302296  xgobi/src/.purify
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/.purify'`"
    test 348 -eq "$shar_count" ||
    $echo 'xgobi/src/.purify:' 'original size' '348,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/brush.c ==============
if test -f 'xgobi/src/brush.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/brush.c' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/brush.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/brush.c' &&
/* brush.c */
/************************************************************
X *                                                          *
X *  Permission is hereby granted  to  any  individual   or  *
X *  institution   for  use,  copying, or redistribution of  *
X *  the xgobi code and associated documentation,  provided  *
X *  that   such  code  and documentation are not sold  for  *
X *  profit and the  following copyright notice is retained  *
X *  in the code and documentation:                          *
X *        Copyright (c) 1990, ..., 1996 Bellcore            *
X *                                                          *
X *  We welcome your questions and comments, and request     *
X *  that you share any modifications with us.               *
X *                                                          *
X *    Deborah F. Swayne            Dianne Cook              *
X *   dfs@research.att.com       dicook@iastate.edu          *
X *      (973) 360-8423    www.public.iastate.edu/~dicook/   *
X *                                                          *
X *                    Andreas Buja                          *
X *                andreas@research.att.com                  *
X *              www.research.att.com/~andreas/              *
X *                                                          *
X ************************************************************/
X
#include <stdlib.h>
#include <math.h>
#include "xincludes.h"
#include "xgobitypes.h"
#include "xgobivars.h"
#include "xgobiexterns.h"
X
int button1down, button2down ;
X
static brush_coords brush_pos ;
/* static corner (x1, y1); corner where the cursor goes (x2,y2) */
X
static Boolean asyncchanged = False;
X
/* --------- Dynamic allocation section ----------- */
X
void
alloc_brush_arrays(xgobidata *xg)
/*
X * Dynamically allocate arrays.
*/
{
/*
X * It might be a good idea to use nrows_in_plot rather
X * than nrows for these.  It would require a lot of
X * Reallocing, but would enable XGobi to handle larger
X * matrices.
*/
X  Cardinal nr = (Cardinal) xg->nrows;
X  register unsigned int i, j;
X  int nhbins = NHBINS;
X  int nvbins = NVBINS;
X  unsigned int nsend;
X
X  xg->excluded = (unsigned short *) XtCalloc(nr, sizeof(unsigned short));
X
X  xg->under_new_brush = (unsigned short *) XtMalloc(
X    nr * sizeof(unsigned short));
X
X  xg->glyph_ids = (glyphv *) XtMalloc(nr * sizeof(glyphv));
X  xg->glyph_now = (glyphv *) XtMalloc(nr * sizeof(glyphv));
X  xg->glyph_prev = (glyphv *) XtMalloc(nr * sizeof(glyphv));
X
X  xg->color_ids = (unsigned long *) XtMalloc(
X        nr * sizeof(unsigned long));
X  xg->color_now = (unsigned long *) XtMalloc(
X        nr * sizeof(unsigned long));
X  xg->color_prev = (unsigned long *) XtMalloc(
X        nr * sizeof(unsigned long));
X
X  /* binning the plot window */
X  xg->binarray = (Cardinal ***) XtMalloc(
X    (Cardinal) nvbins * sizeof(Cardinal **) );
X  for (i=0; i<nvbins; i++)
X  {
X    xg->binarray[i] = (Cardinal **) XtMalloc(
X      (Cardinal) nhbins * sizeof(Cardinal *) );
X    for (j=0; j<nhbins; j++)
X      xg->binarray[i][j] = (Cardinal *) XtMalloc(sizeof(Cardinal));
X  }
X
X  xg->bincounts = (Cardinal **) XtMalloc(
X    (unsigned int) nvbins * sizeof(Cardinal *) );
X  for (i=0; i<nvbins; i++)
X    xg->bincounts[i] = (Cardinal *) XtMalloc(
X      (Cardinal) nhbins * sizeof(Cardinal) );
X
/*
X * nsend is the max of the length needed for linked for brushing
X * identification.  It's used by many linked modes.
*/
X  nsend = 9 + 2* ((xg->nrgroups) ? xg->nrgroups : xg->nlinkable);
X  xg->senddata = (unsigned long *) XtMalloc(
X        (unsigned int) nsend * sizeof(unsigned long));
X  for (i=0; i<nsend; i++) xg->senddata[i] = (unsigned long) 0;
}
X
void
free_brush_arrays(xgobidata *xg)
/*
X * Dynamically free arrays.
*/
{
X  int j,k;
X
X  XtFree((XtPointer) xg->under_new_brush);
X
X  XtFree((XtPointer) xg->glyph_ids);
X  XtFree((XtPointer) xg->glyph_now);
X  XtFree((XtPointer) xg->glyph_prev);
X
X  XtFree((XtPointer) xg->color_ids);
X  XtFree((XtPointer) xg->color_now);
X  XtFree((XtPointer) xg->color_prev);
X
X  for (k=0; k<xg->nvbins; k++)
X  {
X    for (j=0; j<xg->nhbins; j++)
X      XtFree((XtPointer) xg->binarray[k][j]);
X    XtFree((XtPointer) xg->binarray[k]);
X  }
X  XtFree((XtPointer) xg->binarray);
X
X  for (k=0; k<xg->nvbins; k++)
X    XtFree((XtPointer) xg->bincounts[k]);
X  XtFree((XtPointer) xg->bincounts);
X
X  XtFree((XtPointer) xg->senddata);
}
X
void
init_brush_vars(xgobidata *xg)
{
X  static Boolean firsttime = True;
X  int i;
X  glyphv glyph;
X  XColor exact;
X  Colormap cmap = DefaultColormap(display, DefaultScreen(display));
X
X  if (firsttime)
X  {
X    xg->is_brushing = False;
X    xg->brush_on = True;
X    xg->is_point_painting = True;
X    xg->is_line_painting = False;
X    xg->brush_mode = transient;
X    xg->is_glyph_painting = xg->is_color_painting = False;
X
X    find_glyph_type_and_size(appdata.defaultGlyph, &glyph);
X    xg->glyph_0.type = xg->glyph_id.type = glyph.type;
X    xg->glyph_0.size = xg->glyph_id.size = glyph.size;
X
X    if (XParseColor(display, cmap, appdata.defaultColor, &exact)) {
X      if (XAllocColor(display, cmap, &exact)) {
X        xg->color_0 = exact.pixel;
X      }
X    } else {
X      (void) fprintf(stderr, "finding %s failed\n", appdata.defaultColor);
X       xg->color_0 = appdata.fg;
X    }
X
X    /*
X     * Used in binning the plot window
X    */
X    xg->nhbins = NHBINS;
X    xg->nvbins = NVBINS;
X    /*
X     * These are initialized so that the first merge_brushbins()
X     * call will behave reasonably.
X    */
X    xg->bin0.x = xg->bin1.x = NHBINS;
X    xg->bin0.y = xg->bin1.y = NVBINS;
X
X    /*
X     * This is necessary when reshape_brush is False.
X    */
X    brush_pos.x1 = brush_pos.y1 = 20;
X    brush_pos.x2 = brush_pos.y2 = 40;
X
X    firsttime = False;
X  }
X  xg->delete_erased_pts = False;
X
X  /*
X   * Initialize rows_in_plot to be all the data : note this, dfs; work
X  */
X  for (i=0; i<xg->nrows_in_plot; i++)
X    xg->rows_in_plot[i] = i;
}
X
static int
point_in_which_bin(xgobidata *xg, int x, int y, int *ih, int *iv)
{
X  int inwindow = 1;
X
X  *ih = (int) ((float) xg->nhbins * (float) x / (xg->max.x+1.0));
X  *iv = (int) ((float) xg->nvbins * (float) y / (xg->max.y+1.0));
X
X  if (*ih < 0 || *ih > xg->nhbins - 1 || *iv < 0 || *iv > xg->nvbins - 1)
X    inwindow = 0;
X
X  return(inwindow);
}
X
Boolean
brush_once(xgobidata *xg, Boolean force)
{
/*
X * Determine which bins the brush is currently sitting in.
X * bin0 is the bin which contains of the upper left corner of the
X * brush; bin1 is the one containing of the lower right corner.
*/
X  int ulx = MIN(brush_pos.x1, brush_pos.x2);
X  int uly = MIN(brush_pos.y1, brush_pos.y2);
X  int lrx = MAX(brush_pos.x1, brush_pos.x2);
X  int lry = MAX(brush_pos.y1, brush_pos.y2);
X  Boolean changed = False;
X
X  if ( !point_in_which_bin(xg, ulx, uly, &xg->bin0.x, &xg->bin0.y) ) {
X    xg->bin0.x = MAX(xg->bin0.x, 0);
X    xg->bin0.x = MIN(xg->bin0.x, xg->nhbins - 1);
X    xg->bin0.y = MAX(xg->bin0.y, 0);
X    xg->bin0.y = MIN(xg->bin0.y, xg->nhbins - 1);
X  }
X  if ( !point_in_which_bin(xg, lrx, lry, &xg->bin1.x, &xg->bin1.y) ) {
X    xg->bin1.x = MAX(xg->bin1.x, 0);
X    xg->bin1.x = MIN(xg->bin1.x, xg->nhbins - 1);
X    xg->bin1.y = MAX(xg->bin1.y, 0);
X    xg->bin1.y = MIN(xg->bin1.y, xg->nhbins - 1);
X  }
X
/*
X * Now paint.
*/
X  if (xg->is_point_painting) {
X    changed = active_paint_points(xg);
X    if ((changed || force) && xg->sync_brush) {
X      if (xg->link_glyph_brushing ||
X          xg->link_color_brushing ||
X          xg->link_erase_brushing)
X      {
X        announce_brush_data(xg);
X
#if defined RPC_USED || defined DCE_RPC_USED
X        xfer_brushinfo(xg);
#endif
X      }
X    }
X  }
X
X  if (xg->is_line_painting) {
X    active_paint_lines(xg);
X    if (xg->sync_brush) {
X      if (xg->link_lines_to_lines || xg->link_points_to_lines)
X        announce_line_brush_data(xg);
X    }
X  }
X
/*
X * Now here's a troublesome one from the point of
X * view of modularity:
*/
X  if (changed && xg->sync_brush)
X    if (xg->is_cprof_plotting && xg->link_cprof_plotting)
X      cprof_plot_once(xg);
X
/*
X * To accumulative the knowledge of whether any points
X * have changed or not ...
*/
X  asyncchanged = asyncchanged || changed;
X  return(changed);
}
X
void
reinit_transient_brushing(xgobidata *xg)
{
/*
X * If a new variable is selected or a variable is transformed
X * during transient brushing,
X * restore all points to the permanent value, and then
X * re-execute brush_once() to brush the points that are
X * now underneath the brush.  For now, don't make the
X * same change for persistent or undo brushing.
*/
X  int j, k;
X
X  for (j=0; j<xg->nrows_in_plot; j++)
X  {
X    k = xg->rows_in_plot[j];
X    xg->color_now[k] = xg->color_ids[k] ;
X    xg->glyph_now[k].type = xg->glyph_ids[k].type;
X    xg->glyph_now[k].size = xg->glyph_ids[k].size;
X  }
X  copy_brushinfo_to_senddata(xg);
X  (void) brush_once(xg, False);
}
X
/* ARGSUSED */
XXtEventHandler
brush_motion(Widget w, xgobidata *xg, XEvent *evnt, Boolean *cont)
{
X  XMotionEvent *xmotion = (XMotionEvent *) evnt;
X  Boolean changed = False;
X
/*
X  XEvent ahead;
X  while (XEventsQueued(display, QueuedAlready) > 0) {
X    XPeekEvent(display, &ahead);
X    if (ahead.type == MotionNotify) {
X      xmotion = (XMotionEvent *) &ahead;
X      XtAppNextEvent(app_con, &ahead);
X    }
X    else if (ahead.type == PropertyNotify || ahead.type == NoExpose)
X      XtAppNextEvent(app_con, &ahead);
X    else
X      break;
X  }
*/
X
X  if (xg->is_point_painting || xg->is_line_painting) {
X    if (button1down) {
X      int xdist = brush_pos.x2 - brush_pos.x1 ;
X      int ydist = brush_pos.y2 - brush_pos.y1 ;
X      /*
X       * If this scheme works, then what's happening is that (x2,y2)
X       * is the corner that's moving.
X      */
X      brush_pos.x1 = xmotion->x - xdist ;
X      brush_pos.x2 = xmotion->x ;
X      brush_pos.y1 = xmotion->y - ydist ;
X      brush_pos.y2 = xmotion->y ;
X    }
X
X    if (button2down) {
X      brush_pos.x2 = xmotion->x ;
X      brush_pos.y2 = xmotion->y ;
X    }
X
X    if (xg->brush_on) {
X      changed = brush_once(xg, False);
X
X      /* must redraw everything if connected lines are showing */
X      if (xg->is_line_painting || xg->connect_the_points || xg->nrgroups > 0)
X      {
X        plot_once(xg);
X      }
X      else {
X        if (changed)
X          plot_bins(xg);
X        else quickplot_once(xg);
X      }
X    }
X    else {
X      quickplot_once(xg);
X    }
X  }
}
X
/* ARGSUSED */
void
init_brush_size(xgobidata *xg)
{
X  brush_pos.x1 = brush_pos.y1 = 20;
X  brush_pos.x2 = brush_pos.y2 = 40;
}
X
/* ARGSUSED */
XXtEventHandler
brush_button(Widget w, xgobidata *xg, XEvent *evnt)
{
X  XButtonEvent *xbutton = (XButtonEvent *) evnt;
X  Boolean changed = False;
X
X  if (xg->is_point_painting || xg->is_line_painting) {
X    if (xbutton->button == 1 || xbutton->button == 2) {
X      if (xbutton->type == ButtonPress) {
X        /*
X         * This covers a funny case:  two windows, both in
X         * brushing.  Brush persistently in one for a while,
X         * now brush transiently in the second.  Without this
X         * line, the transient brushing isn't sending the
X         * correct data.
X        */
X        copy_brushinfo_to_senddata(xg);
X
X        /*
X         * If jump_brush is True, redraw the brush where the
X         * pointer is, with the lower right corner of the brush
X         * at the pointer.
X        */
X        if (xg->jump_brush) {
X          int xdist = brush_pos.x2 - brush_pos.x1 ;
X          int ydist = brush_pos.y2 - brush_pos.y1 ;
X          /*
X           * If this scheme works, then what's happening is that (x2,y2)
X           * is the corner that's moving.
X          */
X          brush_pos.x1 = xbutton->x - xdist ;
X          brush_pos.x2 = xbutton->x ;
X          brush_pos.y1 = xbutton->y - ydist ;
X          brush_pos.y2 = xbutton->y ;
X        }
X        /*
X         * If jump_brush is False, move the pointer to the current
X         * lower right corner of the brush.
X        */
X        else {
X          XWarpPointer(display, None, xg->plot_window, 0,0,0,0,
X            brush_pos.x2, brush_pos.y2 );
X        }
X
X        if (xbutton->button == 1 && xbutton->state != 8) {
X          button1down = 1;
X        }
X        else if (xbutton->button == 2 ||
X                (xbutton->button == 1 && xbutton->state != 8))
X        {
X          button2down = 1;
X        }
X
X        if (xg->brush_on) {
X          changed = brush_once(xg, True);
X
X          if (xg->is_point_painting) {
X            if (xg->link_glyph_brushing ||
X                xg->link_color_brushing ||
X                xg->link_erase_brushing)
X            {
X              XtOwnSelection( (Widget) xg->workspace,
X                (Atom) XG_NEWPAINT,
X                (Time) CurrentTime,
X                (XtConvertSelectionProc) pack_brush_data,
X                (XtLoseSelectionProc) pack_brush_lose ,
X                (XtSelectionDoneProc) pack_brush_done );
X            }
X          }
X
X          /* If line brushing, update linked lines */
X          if (xg->is_line_painting &&
X             (xg->link_lines_to_lines || xg->link_points_to_lines))
X          {
X            XtOwnSelection( (Widget) xg->workspace,
X              (Atom) XG_NEWLINEPAINT,
X              (Time) CurrentTime, /* doesn't work with XtLastTimeStamp...? */
X              (XtConvertSelectionProc) pack_line_brush_data,
X              (XtLoseSelectionProc) pack_line_brush_lose ,
X              (XtSelectionDoneProc) pack_line_brush_done );
X          }
X        }
X
X        if (xg->jump_brush || xg->is_line_painting || changed) {
X          plot_once(xg);
X        }
X        else {  /* whether changed or not? */
X          plot_bins(xg);
X        }
X      }
X      else if (xbutton->type == ButtonRelease)
X      {
/*
X        int x1 = MIN(brush_pos.x1, brush_pos.x2);
X        int y1 = MIN(brush_pos.y1, brush_pos.y2);
X        int x2 = MAX(brush_pos.x1, brush_pos.x2);
X        int y2 = MAX(brush_pos.y1, brush_pos.y2);
*/
X
X        if (xbutton->button == 1)
X          button1down = 0;
X        else if (xbutton->button == 2)
X          button2down = 0;
X 
X        /*
X         * We're redrawing everything on buttonrelease; we have no
X         * way of knowing at this point whether things changed or
X         * not, since that information is not accumulated.
X        */
X        if (xg->brush_on && button1down == 0 && button2down == 0) {
X
X          if (xg->jump_brush || xg->is_line_painting) {
X            plot_once(xg);
X
X            /*
X             * Send brushing data:  this is needed if sync_brush is
X             * false, but it doesn't hurt to do it in all cases.
X             * ... but let's try only doing it for async brushing ...
X            */
X            if (!xg->sync_brush && asyncchanged) {
X              if (xg->link_glyph_brushing ||
X                  xg->link_color_brushing ||
X                  xg->link_erase_brushing)
X              {
X                announce_brush_data(xg);
X
#if defined RPC_USED || defined DCE_RPC_USED
X                xfer_brushinfo(xg);
#endif
X              }
X            }
X
X            if (xg->link_lines_to_lines || xg->link_points_to_lines)
X              announce_line_brush_data(xg);
X
X            if (!xg->sync_brush && asyncchanged &&
X                xg->is_cprof_plotting && xg->link_cprof_plotting)
X            {
X              cprof_plot_once(xg);
X            }
X          }
X        }
X        asyncchanged = False;
X      }
X    }
X  }
}
X
void
draw_brush(xgobidata *xg)
{
/*
X * Use brush_pos to draw the brush.
*/
X  int x1 = MIN( brush_pos.x1, brush_pos.x2 );
X  int x2 = MAX( brush_pos.x1, brush_pos.x2 );
X  int y1 = MIN( brush_pos.y1, brush_pos.y2 );
X  int y2 = MAX( brush_pos.y1, brush_pos.y2 );
X
X  if (!mono)
X  {
X    if (xg->is_color_painting && xg->color_id != plotcolors.bg)
X      XSetForeground(display, copy_GC, xg->color_id);
X    else
X      XSetForeground(display, copy_GC, plotcolors.fg);
X  }
X
X  if (xg->is_point_painting)
X  {
X    XDrawRectangle(display, xg->plot_window, copy_GC,
X      x1, y1, (unsigned) abs(x2-x1), (unsigned) abs(y2-y1));
X    /* Mark the corner to which the cursor will be attached */
X    XDrawRectangle(display, xg->plot_window, copy_GC,
X      brush_pos.x2-1, brush_pos.y2-1, 2, 2);
X
X    /*
X     * highlight brush
X    */
X    if (xg->brush_on) {
X      XDrawRectangle(display, xg->plot_window, copy_GC,
X        x1-1, y1-1, (unsigned) abs(x2-x1+2), (unsigned) abs(y2-y1+2));
X
X      /* Mark the corner to which the cursor will be attached */
X      XDrawRectangle(display, xg->plot_window, copy_GC,
X        brush_pos.x2-2, brush_pos.y2-2, 4, 4);
X    }
X  }
X
X  if (xg->is_line_painting)
X  {
X    XDrawLine(display, xg->plot_window, copy_GC,
X      x1 + (x2 - x1)/2, y1, x1 + (x2 - x1)/2, y2 );
X    XDrawLine(display, xg->plot_window, copy_GC,
X      x1, y1 + (y2 - y1)/2, x2, y1 + (y2 - y1)/2 );
X
X    if (xg->brush_on)
X    {
X      XDrawLine(display, xg->plot_window, copy_GC,
X        x1 + (x2 - x1)/2 + 1, y1, x1 + (x2 - x1)/2 + 1, y2 );
X      XDrawLine(display, xg->plot_window, copy_GC,
X        x1, y1 + (y2 - y1)/2 + 1, x2, y1 + (y2 - y1)/2 + 1 );
X    }
X  }
}
X
int
under_brush(xgobidata *xg, int k)
/*
X * Determine if point is under the brush.
*/
{
X  int pt;
X  int x1 = MIN( brush_pos.x1, brush_pos.x2 );
X  int x2 = MAX( brush_pos.x1, brush_pos.x2 );
X  int y1 = MIN( brush_pos.y1, brush_pos.y2 );
X  int y2 = MAX( brush_pos.y1, brush_pos.y2 );
X
X  pt = (xg->screen[k].x <= x2 && xg->screen[k].y <= y2 &&
X       xg->screen[k].x >= x1 && xg->screen[k].y >= y1) ? 1 : 0;
X  return(pt);
}
X
X
int
xed_by_brush(xgobidata *xg, int pta, int ptb)
/*
X * Determine if line intersects brush.
*/
{
X  int denom;
X  float m;              /* slope of the line (pta, ptb) */
X  int x, y;             /* coordinates of the intersection point */
X  int intersection = 0;
X
/* coordinates of the points, pta and ptb
X *  xg->screen[pta].x, xg->screen[pta].y
X *  xg->screen[ptb].x, xg->screen[ptb].y
*/
X
X  m = ((denom = xg->screen[ptb].x - xg->screen[pta].x) != 0) ?
X    (float) (xg->screen[ptb].y - xg->screen[pta].y) / (float) denom :
X    0;
X
/*
X * First check for intersection with the vertical line of the
X * crosshair brush.
*/
X
X  x = brush_pos.x1 + (brush_pos.x2 - brush_pos.x1)/2;
X  if (BETWEEN(xg->screen[pta].x, xg->screen[ptb].x, x)) {
X    if (BETWEEN(brush_pos.y1, brush_pos.y2,
X     (int) ( xg->screen[pta].y + m * (float) (x - xg->screen[pta].x) )))
X    {
X      intersection = 1;
X    }
X  }
X
/*
X * If nothing's turned up yet, check for intersection with the
X * horizontal line of the crosshair brush.
*/
X  if (!intersection) {
X
X    y = brush_pos.y1 + (brush_pos.y2 - brush_pos.y1)/2;
X    if (BETWEEN(xg->screen[pta].y, xg->screen[ptb].y, y)) {
X      if (m != 0) {
X        if (BETWEEN(brush_pos.x1, brush_pos.x2,
X          (int) (xg->screen[pta].x + (float) (y - xg->screen[pta].y) / m )))
X        {
X          intersection = 1;
X        }
X      }
X    }
X  }
X
X  /* What about vertical and horizontal lines? */
X  if (!intersection && (xg->screen[pta].x == xg->screen[ptb].x))
X    if (BETWEEN(brush_pos.x1, brush_pos.x2, xg->screen[pta].x))
X      intersection = 1;
X  if (!intersection && (xg->screen[pta].y == xg->screen[ptb].y))
X    if (BETWEEN(brush_pos.y1, brush_pos.y2, xg->screen[pta].y))
X      intersection = 1;
X
X  return(intersection);
}
X
void
assign_points_to_bins(xgobidata *xg)
{
X  int i, k, ih, iv;
X
X  /*
X   * Reset bin counts to zero.
X  */
X  for (ih=0; ih<xg->nhbins; ih++)
X    for (iv=0; iv<xg->nvbins; iv++)
X      xg->bincounts[ih][iv] = 0;
X
X  for (k=0; k<xg->nrows_in_plot; k++)
X  {
X    i = xg->rows_in_plot[k];
X
/*
X * One option for ignoring unlinkable points.  DFS
X
X    if (i >= xg->nlinkable)
X      break;
*/
X
X    if (xg->screen[i].x >=0 && xg->screen[i].x <= xg->max.x &&
X        xg->screen[i].y >=0 && xg->screen[i].y <= xg->max.y)
X    {
X      if (point_in_which_bin(xg, xg->screen[i].x, xg->screen[i].y, &ih, &iv))
X      {
X        xg->binarray[ih][iv] = (Cardinal *)
X          XtRealloc((XtPointer) xg->binarray[ih][iv],
X            (Cardinal) (xg->bincounts[ih][iv]+1) * sizeof(Cardinal) );
X        /*
X         * Binarray contains the
X         * index of rows_in_plot[] rather than the contents, so
X         * here the assignment is k rather than i
X        */
X        xg->binarray[ih][iv][xg->bincounts[ih][iv]] = (Cardinal) k;
X        (xg->bincounts[ih][iv])++;
X      }
X    }
X  }
}
X
void
find_extended_brush_corners(icoords *bin0, icoords *bin1, xgobidata *xg)
{
X  static brush_coords obrush;
X  static int initd = 0;
X  int x1 = MIN(brush_pos.x1, brush_pos.x2);
X  int y1 = MIN(brush_pos.y1, brush_pos.y2);
X  int x2 = MAX(brush_pos.x1, brush_pos.x2);
X  int y2 = MAX(brush_pos.y1, brush_pos.y2);
X  int ox1, oy1, ox2, oy2;
X
X  if (!initd)
X  {
X    /* from initial values */
X    obrush.x1 = obrush.y1 = 20;
X    obrush.x2 = obrush.y2 = 40;
X    initd = 1;
X  }
X
X  ox1 = MIN(obrush.x1, obrush.x2);
X  oy1 = MIN(obrush.y1, obrush.y2);
X  ox2 = MAX(obrush.x1, obrush.x2);
X  oy2 = MAX(obrush.y1, obrush.y2);
X
/*
X * What bins contain the brush and the previous brush?  Allow
X * extension for safety, using BRUSH_MARGIN.
*/
X
X  if (!point_in_which_bin(xg,
X    MIN(x1, ox1) - 2*BRUSH_MARGIN,
X    MIN(y1, oy1) - 2*BRUSH_MARGIN,
X    &bin0->x, &bin0->y) )
X  {
X    bin0->x = MAX(bin0->x, 0);
X    bin0->x = MIN(bin0->x, xg->nhbins - 1);
X    bin0->y = MAX(bin0->y, 0);
X    bin0->y = MIN(bin0->y, xg->nhbins - 1);
X  }
X  if (!point_in_which_bin(xg,
X    MAX(x2, ox2) + 2*BRUSH_MARGIN,
X    MAX(y2, oy2) + 2*BRUSH_MARGIN,
X    &bin1->x, &bin1->y) )
X  {
X    bin1->x = MAX(bin1->x, 0);
X    bin1->x = MIN(bin1->x, xg->nhbins - 1);
X    bin1->y = MAX(bin1->y, 0);
X    bin1->y = MIN(bin1->y, xg->nhbins - 1);
X  }
X
X  obrush.x1 = brush_pos.x1;
X  obrush.y1 = brush_pos.y1;
X  obrush.x2 = brush_pos.x2;
X  obrush.y2 = brush_pos.y2;
}
SHAR_EOF
  chmod 0644 'xgobi/src/brush.c' ||
  $echo 'restore of' 'xgobi/src/brush.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/brush.c:' 'MD5 check failed'
bda99b99a840d4e0829973463efc9a7a  xgobi/src/brush.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/brush.c'`"
    test 21487 -eq "$shar_count" ||
    $echo 'xgobi/src/brush.c:' 'original size' '21487,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/redesign ==============
if test -f 'xgobi/src/redesign' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/redesign' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/redesign' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/redesign' &&
Since we're planning to allow multiple plot windows, we can think
of them as displays.  Some of the display types are then the
usual scatterplot, the parallel coordinates plot, and the
scatterplot matrix.  It turns out that it's very convenient if we
add a sphered display -- that is, a display of the principal
components, the only display that would be pp-capable.  It would
then also be possible to look at xyplots (etc) of the principal 
components.  (The sphered display could also somehow provide the
factor loadings of the principal components; we haven't thought 
about how to do that yet.)
X
The pipeline now needs to be staged a bit more.  Every
display will use the first stage: 
X
X   raw_data -> tform_data
X   
Here it splits into
X
X   sphered_data -> sphered_world_data
X and
X   -> world_data
X   
This is just about what it does now, except that we currently
use the same world_data array for each branch of the tree.
X
These different legs of the pipeline should probably also
have their own lims[] array instead of having to overwrite
each others' as they do now.  I believe they share most of
the standardization code, except that the sphered pipeline
has some of its own.
X
Jittering stays where it is, as a final step in creating the
world_data and the sphered_world_data.
X
We thought about incorporating permutation and subsetting into
the pipeline, but we decided to handle them essentially as they
are handled now.  Subsetting will continue to be handled with a
rows_in_plot vector.  Permutation will be handled as a
transformation step -- the new transformation panel can handle
stages, and it can handle arbitrary variable groups, so   
permutation can be added as a third transformation stage,
allowing such things taking the log of 3 variables and then 
permuting them. 
X
The end of the pipeline is display-specific, with each display  
being responsible for the final stage:
X
X  -> planar_data -> screen_data
X
Brushing will work in a similar way:  there's a single vector of
brushing colors and glyphs, just as there is now, and each
display is responsible for getting data in and out of that
vector, transforming it to the form needed by the display --
hence the parallel coordinates plot will be brushable (yi), and
it will be responsible for turning the normal brushing data into
a form it can use. 
X
X... we could imagine making sphering be a
3rd-stage transformation, like permutation.  I won't typing it
all in, but I can show you a sketch the next time we talk.
X
Sorting is another 3rd-stage transformation.  It also needs to have
a "use color groups" or not toggle -- maybe other transformations
could use it, too. 
X
And don't forget to make sure the colors and glyphs get sorted, too.
X
___
X
Questions:
X
It seems to me that the routine mean_lgdist, which resets the
limits for sphering, could be viewed as doing another kind of
standardization -- indeed, resetting the limits is primarily what
the different standardization methods do.  How do you imagine
this happening in a single pipeline, Di?
X
Andreas suggested that we might set the default standardization
method to mean/stddev when the data are sphered, and reset to  
min/max otherwise.  This is a bit kludgey, but it could work.  
X
Could the standardization menu be disabled for sphered data?
And what should happen when there's a mix of sphered and
non-sphered data?
X
Another conflict between the current sphering pipeline and
the default pipeline is the use of vgroups, but that could
be solved by hanging onto vgroups_raw but writing vgroups_actual
as part of the sphering transformation.
X
Actually, the presence of vgroups raises another question:  how
do we envision the interaction between vgroups and the
transformation panel?  Maybe the the transformation panel can
overwrite vgroups_actual as well.
X
_______
X
Hm, come to think of it, let me ask what the function of PC subsetting
is.  If you run PP on sphered variables in the new scheme, you specify
in the gt the PC variables you want run on, right?  In the new scheme,
selection of variables for sphering and selection of variables for
gt/pp are two separate things.  As I interpret it, it is no longer so
that the selection of variables to be sphered determines that all PCs
are included in gt/pp.  So, what is the function of subsetting PCs?  
X
The issue that arises in my mind is to somehow offer a default of
sphered coordinates to the user when she is about to run PP on the
currently selected variables.  This could be solved with a pop up 
window that asks the user whether she wants the currently selected
variables sphered, and if yes, how many of the largest few PCs should
be selected for gt/pp in view of the eigenvalue profile at hand.
Alternatively, we could offer an automatic default selection of PCs,
e.g., by the rule sqrt(lambda_i) > sqrt(lambda_1)/20, implying that 
PCs with less than 1/20th the top standard deviation are deselected.
If the user doesn't like 1/20, she can always select or deselect PCs
by clicking on the variable circles.
X
I'm in favor of a human interface that does not force decision making
on the user when it can be avoided.  Instead, the HI should have
reasonable defaults so the choices don't get in the way.
X
_____
X
Di and I just agreed, for now, that we would make it impossible
to paint the unlinkable points.  It will continue to be possible
to define their appearance in .colors and .glyphs files, but
not paint them.  For that matter, it will be impossible to assign
them to a row group.
X
we do want to keep identification running over all xg->nrows. that
is important. but we might want transformation only to run on the
nlinkable - that matters for things like sorting - also for 
projection pursuit we only want to operate on the nlinkable points,
but touring we want to tour all points!! i think this list could grow.
X
X....i find that there are some points that i can't brush. there
must be some interaction between nlinkable, and rgroups, and rows-in-plot.
X
_____
X
1.  The more I think about it, the more I like the idea of
eliminating vgroups in favor of a panel like the variable
transformation panel that allows axis ranges to be specified.
It's not a difficult thing to do; I could build it in a couple
of hours, I'm sure.  
X
Does that idea have any tricky implications for sphering?
X
2.  nlinkable was a kludge in the first place, a lazy way to
handle the goal of being able to distinguish between data points
and non-data points.  Let's do it right this time, and add a
parallel set of matrices to hold the non-data points.  They can
be used when setting default variable ranges, and run through the
usual pipeline.
X
Users could specify whether they want to perform the interactive
operation on data or non-data or both -- with some exceptions.
(Scaling should always operate on both, I assume.)
X
Presumably we don't include them in the Hide/Exclude operations;
instead, there's just a button somewhere that allows users to
either show or hide the non-data.
X
This should help with the nlinkable/rgroups/rows_in_plot confusion,
since these guys would now be outside the rgroups and rows_in_plot
structure, and play no role in linking.
X
____
X
X
lims *lim0, *lim, *lim_tform, *lim_raw;
X
without sphering:
X
lim0:      created by applying min_max to tform_data using vgroups
lim_raw:   created by applying min_max to raw_data using vgroups
X
lim_tform: ...  min_max/mean_stddev/med_mad to tform_data using vgroups
lim:       lim_tform
X
sphering requires standardization:
X
lim and lim0 are both reset (equal to each other) by mean_lgdist,
X  which is applied to sphered_data and doesn't use vgroups
/*
X * Find the minimum and maximum values of each column,
X * scaling by mean and std_width standard deviations.
*/
X
--------------------------
When are the limits reset?
--------------------------
update_lims is called a lot!
X * when excluding cases
X * in corr_tour_on, dotplot_on, grand_tour_on, etc
X * turning princ_comp on and off
X * in update_imputation
X * with every loop in xgvis
X
--------------------------
How are the limits used?
--------------------------
X * in tform_to_world and in sphered_to_world (lim)
X * for saving the coefficients in rotation or touring (lim)
X * missing (lim)
X * for the reverse pipeline in point motion  (lim)
X
X * for parallel coordinates (lim_tform)
X
X * make_axes (lim and lim0)
X
X * transformw (lim0, lim_raw)
X
--------------------------
How is lim_tform used?
--------------------------
X * It is used exclusively in parcoords.c
--------------------------
How is lim_raw used?
--------------------------
X * It is used exclusively in transformw.c, to reinitiate a
X   transformation -- does transformation precede standardization? yes
SHAR_EOF
  chmod 0644 'xgobi/src/redesign' ||
  $echo 'restore of' 'xgobi/src/redesign' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/redesign:' 'MD5 check failed'
77301520eec56ead4616f549e4cab291  xgobi/src/redesign
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/redesign'`"
    test 8669 -eq "$shar_count" ||
    $echo 'xgobi/src/redesign:' 'original size' '8669,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/sphere.c ==============
if test -f 'xgobi/src/sphere.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/sphere.c' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/sphere.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/sphere.c' &&
/* sphere.c */
/************************************************************
X *                                                          *
X *  Permission is hereby granted  to  any  individual   or  *
X *  institution   for  use,  copying, or redistribution of  *
X *  the xgobi code and associated documentation,  provided  *
X *  that   such  code  and documentation are not sold  for  *
X *  profit and the  following copyright notice is retained  *
X *  in the code and documentation:                          *
X *        Copyright (c) 1990, ..., 1996 Bellcore            *
X *                                                          *
X *  We welcome your questions and comments, and request     *
X *  that you share any modifications with us.               *
X *                                                          *
X *    Deborah F. Swayne            Dianne Cook              *
X *   dfs@research.att.com       dicook@iastate.edu          *
X *      (973) 360-8423    www.public.iastate.edu/~dicook/   *
X *                                                          *
X *                    Andreas Buja                          *
X *                andreas@research.att.com                  *
X *              www.research.att.com/~andreas/              *
X *                                                          *
X ************************************************************/
X
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <float.h>
#include <math.h>
#include "xincludes.h"
#include "xgobitypes.h"
#include "xgobivars.h"
#include "xgobiexterns.h"
#include "DrawingA.h"
X
static Widget spane, spopup = NULL;
static Position popupx = -1, popupy = -1;
static Boolean is_sphere_mapped = False;
static Widget select_npc, npc, totvar, condnum, do_sph;
static Widget scree_plot_wksp;
static WidgetSize scree_wksp;
static Window scree_plot_window;
static Pixmap scree_plot_pixmap;
static float *evals;
static int numpcs = 0;
static  char str[20];
X
/* ARGSUSED */
static XtCallbackProc
close_sphere_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  XtDestroyWidget(spopup);
X  spopup = NULL;
X  is_sphere_mapped = False;
}
X
/* ARGSUSED */
static XtCallbackProc
scree_expose_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  XCopyArea(display, scree_plot_pixmap, scree_plot_window, copy_GC,
X    0, 0, scree_wksp.width, scree_wksp.height, 0, 0);
}
X   
/* ARGSUSED */
static XtCallbackProc
select_npc_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  int j;
X  float ftmp1=0.0, ftmp2=0.0;
X  char message[MSGLENGTH];
X  char *snumpcs;
X
X  XtVaGetValues(npc, XtNstring, (String) &snumpcs, NULL);
X  numpcs = atoi(snumpcs);
X
X  if (numpcs<1)
X  {
X     sprintf(message, "Need to choose at least 1 PC.\n");
X     show_message(message, xg);
X  XtVaSetValues(do_sph,
X                XtNsensitive, False,
X                NULL);
X  }
X  else if (numpcs > xg->nsph_vars)
X  {
X     sprintf(message, "Need to choose at most %d PCs.\n",xg->nsph_vars);
X     show_message(message, xg);
X
X  XtVaSetValues(do_sph,
X                XtNsensitive, False,
X                NULL);
X  } else {
X     
X  for (j=0; j<numpcs; j++)
X    ftmp1 += evals[j];
X  for (j=0; j<xg->nsph_vars; j++)
X    ftmp2 += evals[j];
X
X  sprintf(str, "Tot. Var.: %5.1f ", ftmp1/ftmp2);
X  XtVaSetValues(totvar,
X    XtNlabel, str,
X    NULL);
X
X  sprintf(str, "Cond. Num.: %.2e ", evals[0]/evals[numpcs-1]);
X  XtVaSetValues(condnum,
X    XtNlabel, str,
X    NULL);
X
X  XtVaSetValues(do_sph,
X                XtNsensitive, True,
X                NULL);
X  
X  }
X  
}
X
/* ARGSUSED */
static XtCallbackProc
do_sph_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  int j, n;
X  char message[MSGLENGTH];
X
X  if ((numpcs > 0) && (numpcs <= xg->nsph_vars))
X  {
X    if (evals[numpcs-1] == 0.0 || evals[0]/evals[numpcs-1] > 10000.0) {
X      sprintf(message, "Need to choose less PCs. Var-cov close to singular.\n");
X      show_message(message, xg);
X    }
X    else {
X       
X      spherize_data(xg, numpcs, xg->nsph_vars, xg->sph_vars);
X
/*      for (j=0; j<numpcs; j++)
X        recalc_vc(j, xg);
*/
X
X      set_sph_labs(xg, numpcs);
X
X      xg->is_princ_comp = True;
X      XtVaSetValues(xg->princ_comp_cmd, XtNstate, True, NULL);
X      setToggleBitmap(xg->princ_comp_cmd, True);
X
X      set_sens_pc_axes(True, xg);
X
X      update_lims(xg);
X      update_world(xg);
X
X      world_to_plane(xg);
X      plane_to_screen(xg);
X
X      /*
X      This bit of init_axes() is needed.
X      */
X      for (n=0; n<numpcs; n++) {
X        j = xg->sph_vars[n];
X        xg->nicelim[j].min = xg->lim0[j].min;
X        xg->nicelim[j].max = xg->lim0[j].max;
X        SetNiceRange(j, xg);
X        xg->deci[j] = set_deci(xg->tickdelta[j]);
X      }
X
X      if (xg->is_xyplotting) {
X        init_ticks(&xg->xy_vars, xg);
X      }
X      else if (xg->is_plotting1d)
X        init_ticks(&xg->plot1d_vars, xg);
X
X      if (xg->is_brushing) {
X        assign_points_to_bins(xg);
X        if (xg->brush_mode == transient)
X          reinit_transient_brushing(xg);
X      }
X
X      plot_once(xg);
X
X      if (xg->is_cprof_plotting)
X        update_cprof_plot(xg);
X    }
X  }
X  
}
X
/* ARGSUSED */
XXtCallbackProc
open_sphere_popup_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  Widget close;
X  Widget form0;
X  Dimension width, height;
X  register int j;
X  Widget box[2];
X  Boolean do_svd = false;
X  char npc_lab[5], tickmk[5];
X  int xstrt, ystrt, xpos, ypos;
X  char message[MSGLENGTH];
X  
X  if (!is_sphere_mapped) {
X     
X    if (spopup == NULL) {
X
X      if (popupx == -1 && popupy == -1) {
X        XtVaGetValues(xg->workspace,
X          XtNwidth, &width,
X          XtNheight, &height, NULL);
X        XtTranslateCoords(xg->workspace,
X          (Position) width, (Position) (height/2), &popupx, &popupy);
X      }
X
X      spopup = XtVaCreatePopupShell("Sphere Selected Variables",
X        topLevelShellWidgetClass, xg->shell,
X        XtNx,        popupx,
X        XtNy,        popupy,
X        XtNinput,    True,
X        XtNtitle,    "Sphere variables",
X        XtNiconName, "Sphere",
X        NULL);
X      if (mono) set_mono(spopup);
X
X      /*
X       * Create a paned widget so the 'Click here ...'
X       * can be all across the bottom.
X      */
X      spane = XtVaCreateManagedWidget("Form",
X        panedWidgetClass, spopup,
X        XtNorientation, (XtOrientation) XtorientVertical,
X        XtNresizable, False,
X        NULL);
X
X      form0 = XtVaCreateManagedWidget("Form",
X        formWidgetClass, spane,
X        XtNresizable, False,
X        NULL);
X      if (mono) set_mono(form0);
X
X     /* Controls panel */
X      box[0] = XtVaCreateManagedWidget("Close",
X        boxWidgetClass, form0,
X        XtNorientation, (XtOrientation) XtorientVertical,
X        XtNleft, (XtEdgeType) XtChainLeft,
X        XtNright, (XtEdgeType) XtChainLeft,
X        XtNtop, (XtEdgeType) XtChainTop,
X        XtNbottom, (XtEdgeType) XtChainTop,
X        NULL);
X
X      select_npc = (Widget) CreateCommand(xg, "Select Num PCs",
X        True, NULL, NULL, box[0], "Sphere");
X      XtVaSetValues(select_npc,
X        XtNleft, (XtEdgeType) XtChainLeft,
X        XtNright, (XtEdgeType) XtChainLeft,
X        XtNtop, (XtEdgeType) XtChainTop,
X        XtNbottom, (XtEdgeType) XtChainTop,
X        NULL);
X      XtManageChild(select_npc);
X      XtAddCallback(select_npc, XtNcallback,
X        (XtCallbackProc) select_npc_cback, (XtPointer) xg);
X
X      sprintf(npc_lab,"%d", xg->nsph_vars);
X      npc = XtVaCreateManagedWidget("Inference",
X        asciiTextWidgetClass, box[0],
X        XtNfromHoriz, (Widget) select_npc,
X        XtNleft, (XtEdgeType) XtChainLeft,
X        XtNright, (XtEdgeType) XtChainRight,
X        XtNtop, (XtEdgeType) XtChainTop,
X        XtNbottom, (XtEdgeType) XtChainTop,
X        XtNresizable, (Boolean) True,
X        XtNeditType, (int) XawtextEdit,
X        XtNresize, (XawTextResizeMode) XawtextResizeWidth,
X        XtNstring, (String) npc_lab,
X        NULL);
X      if (mono) set_mono(npc);
X
X      (void) sprintf(str, "Tot. Var: %5.1f ", 100.0);
X      width = XTextWidth(appdata.font, str,
X        strlen(str) + 2*ASCII_TEXT_BORDER_WIDTH);
X      (void) sprintf(str, "Tot. Var.: %5.1f ", 0.0);
X      totvar = XtVaCreateManagedWidget("Sphere",
X      labelWidgetClass,  box[0],
X      XtNlabel, (String) str,
X      XtNwidth, width,
X      NULL);
X      if (mono) set_mono(totvar);
X
X      (void) sprintf(str, "Cond. Num: %.2e  ", 10000.1234);
X      width = XTextWidth(appdata.font, str,
X        strlen(str) + 2*ASCII_TEXT_BORDER_WIDTH);
X      (void) sprintf(str, "Cond. Num.: %.2e  ", 0.0);
X      condnum = XtVaCreateManagedWidget("Sphere",
X      labelWidgetClass,  box[0],
X      XtNlabel, (String) str,
X      XtNwidth, width,
X      NULL);
X      if (mono) set_mono(condnum);
X
X      do_sph = (Widget) CreateCommand(xg, "Do Sphering",
X        False, NULL, NULL, box[0], "Sphere");
X      XtVaSetValues(do_sph,
X        XtNleft, (XtEdgeType) XtChainLeft,
X        XtNright, (XtEdgeType) XtChainLeft,
X        XtNtop, (XtEdgeType) XtChainTop,
X        XtNbottom, (XtEdgeType) XtChainTop,
X        NULL);
X      XtManageChild(do_sph);
X      XtAddCallback(do_sph, XtNcallback,
X        (XtCallbackProc) do_sph_cback, (XtPointer) xg);
X
X      /* Scree plot */
X      box[1] = XtVaCreateManagedWidget("Close",
X        boxWidgetClass, form0,
X        XtNorientation, (XtOrientation) XtorientVertical,
X        XtNleft, (XtEdgeType) XtChainLeft,
X        XtNright, (XtEdgeType) XtChainLeft,
X        XtNtop, (XtEdgeType) XtChainTop,
X        XtNbottom, (XtEdgeType) XtChainTop,
X        XtNfromHoriz, box[0],
X        NULL);
X
X      scree_plot_wksp = XtVaCreateManagedWidget("Inference",
X        labelWidgetClass, box[1],
X        XtNresizable, (Boolean) True,
X        XtNleft, (XtEdgeType) XtChainLeft,
X        XtNtop, (XtEdgeType) XtChainTop,
X        XtNright, (XtEdgeType) XtRubber,
X        XtNbottom, (XtEdgeType) XtRubber,
X        XtNwidth, 200,
X        XtNheight, 100,
X        XtNlabel, (String) "",
X        NULL);
X      if (mono) set_mono(scree_plot_wksp);
X 
X      XtVaGetValues(scree_plot_wksp,
X        XtNwidth, &scree_wksp.width,
X        XtNheight, &scree_wksp.height, NULL);
X      XtAddEventHandler(scree_plot_wksp,
X        ExposureMask,
X        FALSE, (XtEventHandler) scree_expose_cback, (XtPointer) NULL);
X
X      close = XtVaCreateManagedWidget("Close",
X        commandWidgetClass, spane,
X        XtNshowGrip, (Boolean) False,
X        XtNskipAdjust, (Boolean) True,
X        XtNlabel, (String) "Click here to dismiss",
X        NULL);
X      if (mono) set_mono(close);
X      XtAddCallback(close, XtNcallback,
X        (XtCallbackProc) close_sphere_cback, (XtPointer) xg);
X      
X    }
X
X    XtPopup(spopup, (XtGrabKind) XtGrabNone);
X    set_wm_protocols(spopup);
X    XRaiseWindow(display, XtWindow(spopup));
X
/*  if (doit) {
X    Dimension hgt;
X    XtVaGetValues(box[0], XtNheight, &hgt, NULL);
X    XtVaSetValues(vport, XtNheight, hgt, NULL);
X    XtMapWidget(vport);
X  }*/
X
X    is_sphere_mapped = True;
X
X    scree_plot_window = XtWindow(scree_plot_wksp);
X    scree_plot_pixmap = XCreatePixmap(display, scree_plot_window,
X      scree_wksp.width, scree_wksp.height, depth);
X    XFillRectangle(display, scree_plot_pixmap, clear_GC,
X      0, 0, scree_wksp.width, scree_wksp.height);
X
X  }
X
X  /* Now calculate the svd and display results */
X  restore_sph_labs(xg);
X  get_sph_vars(xg);
X  printf("num vars to be sph'd = %d: ",xg->nsph_vars);
X  for (j=0; j<xg->nsph_vars; j++)
X     printf("%d ",xg->sph_vars[j]);
X  printf("\n");
X  set_sph_tform_tp(xg);
X
X  compute_vc_matrix(xg); 
X   /* If xg->nsph_vars > 1 use svd routine, otherwise just standardize */
X  if (xg->nsph_vars > 1) {
X    do_svd = update_vc_active_and_do_svd(xg, xg->nsph_vars, xg->sph_vars);
X    if (!do_svd)
X    {
X       sprintf(message,"Variance-covariance is identity already!\n");
X       show_message(message,xg);
X    } else {
X      evals = (float *) XtMalloc((Cardinal) (xg->nsph_vars) * sizeof(float));
X      get_evals(xg->nsph_vars, evals);
X      for (j=0; j<xg->nsph_vars; j++)
X      {
X         /*evals[j] = sqrt((double)evals[j]);*/  /*on di's authority*/
X         printf("%f ",evals[j]);
X      }
X      printf("\n");
X      XFillRectangle(display, scree_plot_pixmap, clear_GC,
X        0, 0, scree_wksp.width, scree_wksp.height);
X      XDrawLine(display, scree_plot_pixmap, copy_GC, 10, 90, 190, 90);
X      XDrawLine(display, scree_plot_pixmap, copy_GC, 10, 90, 10, 10);
X      for (j=0; j<xg->nsph_vars; j++) {
X        sprintf(tickmk,"%d", j+1);
X        xpos = (int) (180./(float)(xg->nsph_vars-1)*j+10);
X        ypos = (int) (90.-evals[j]/evals[0]*80.);
X        XDrawString(display, scree_plot_pixmap, copy_GC,
X          xpos, 95, tickmk, strlen(tickmk));
X        if (j>0) 
X          XDrawLine(display, scree_plot_pixmap, copy_GC, xstrt, ystrt,
X            xpos, ypos);
X        xstrt = xpos;
X        ystrt = ypos;
X      }
X      XCopyArea(display, scree_plot_pixmap, scree_plot_window, copy_GC,
X        0, 0, scree_wksp.width, scree_wksp.height, 0, 0);
/*      XFillRectangle(display, scree_plot_pixmap, clear_GC,
X                     0, 0, scree_wksp.width, scree_wksp.height);*/
X    }
X    
X  } else {
/*     scale to variance=1*/
X  }
X  
X
}
X
SHAR_EOF
  chmod 0644 'xgobi/src/sphere.c' ||
  $echo 'restore of' 'xgobi/src/sphere.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/sphere.c:' 'MD5 check failed'
4c1b8467c9fa2a691e23f259ebdf056a  xgobi/src/sphere.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/sphere.c'`"
    test 13071 -eq "$shar_count" ||
    $echo 'xgobi/src/sphere.c:' 'original size' '13071,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/central_mass.c ==============
if test -f 'xgobi/src/central_mass.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/central_mass.c' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/central_mass.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/central_mass.c' &&
/* central_mass.c */
/************************************************************
X *                                                          *
X *  Permission is hereby granted  to  any  individual   or  *
X *  institution   for  use,  copying, or redistribution of  *
X *  the xgobi code and associated documentation,  provided  *
X *  that   such  code  and documentation are not sold  for  *
X *  profit and the  following copyright notice is retained  *
X *  in the code and documentation:                          *
X *        Copyright (c) 1990, ..., 1996 Bellcore            *
X *                                                          *
X *  We welcome your questions and comments, and request     *
X *  that you share any modifications with us.               *
X *                                                          *
X *    Deborah F. Swayne            Dianne Cook              *
X *   dfs@research.att.com       dicook@iastate.edu          *
X *      (973) 360-8423    www.public.iastate.edu/~dicook/   *
X *                                                          *
X *                    Andreas Buja                          *
X *                andreas@research.att.com                  *
X *              www.research.att.com/~andreas/              *
X *                                                          *
X ************************************************************/
X
#include <math.h>
#include "xincludes.h"
#include "xgobitypes.h"
#include "xgobivars.h"
#include "xgobiexterns.h"
X
#define EXPMINUS1 0.3678794411714423
#define ONEMINUSEXPMINUS1 0.63212056
X
static float *h0, *h1;
static float acoefs;
X
void
alloc_central_mass(int n)
{
X  h0 = (float *) XtMalloc((unsigned int) n*sizeof(float *));
X  h1 = (float *) XtMalloc((unsigned int) n*sizeof(float *));
}
X
void
free_central_mass()
{
X  XtFree((XtPointer) h0);
X  XtFree((XtPointer) h1);
}
X
float
central_mass_index(float **proj_data, int n, int *rows_in_plot)
{
X  int i, m;
X  float indx_val;
X
/* Calculate coefficients */
X  for (i=0; i<n; i++)
X  {
X    m = rows_in_plot[i];
X    h0[m] = exp(-proj_data[0][m]*proj_data[0][m]/2.) ;
X    h1[m] = exp(-proj_data[1][m]*proj_data[1][m]/2.) ;
X  }
X
/* Calculate index */
X  acoefs = mean_fn2(h0,h1,n,rows_in_plot);
X  indx_val = (acoefs - (float)EXPMINUS1)/(float)ONEMINUSEXPMINUS1 ;
X  return(indx_val);
}
X
void
central_mass_deriv(float **data, float **proj_data, float *alpha, float *beta,
float **derivs, int n, int *rows_in_plot, int p, int nactive, int *active_vars)
{
X  int i, k, m;
X  float tmpf;
X
X  for (i=0; i<2; i++)
X    for (k=0; k<p; k++)
X      derivs[i][k] = 0.;
X
/* alpha */
X  for (k=0; k<nactive; k++)
X  {
X    tmpf = 0.;
X    for (i=0; i<n; i++)
X    {
X      m = rows_in_plot[i];
X      tmpf -= (proj_data[0][m]*h0[m]*h1[m]*
X        (data[m][active_vars[k]] -
X        alpha[active_vars[k]]*proj_data[0][m] -
X        beta[active_vars[k]]*proj_data[1][m]));
X    }
X    tmpf /= ((float)n);
X    derivs[0][active_vars[k]] = tmpf;
X  }
X
/* beta */
X  for (k=0; k<nactive; k++)
X  {
X    tmpf = 0.;
X    for (i=0; i<n; i++)
X    {
X      m = rows_in_plot[i];
X      tmpf -= (proj_data[1][m]*h0[m]*h1[m]*
X        (data[m][active_vars[k]] -
X        alpha[active_vars[k]]*proj_data[0][m] -
X        beta[active_vars[k]]*proj_data[1][m]));
X    }
X    tmpf /= ((float)n);
X    derivs[1][active_vars[k]] = tmpf;
X  }
X
}
X
#undef EXPMINUS1
#undef ONEMINUSEXPMINUS1
SHAR_EOF
  chmod 0644 'xgobi/src/central_mass.c' ||
  $echo 'restore of' 'xgobi/src/central_mass.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/central_mass.c:' 'MD5 check failed'
afc2072f24ba8fc25c7f2ed09e78320a  xgobi/src/central_mass.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/central_mass.c'`"
    test 3356 -eq "$shar_count" ||
    $echo 'xgobi/src/central_mass.c:' 'original size' '3356,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/xgv_cbacks.c ==============
if test -f 'xgobi/src/xgv_cbacks.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/xgv_cbacks.c' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/xgv_cbacks.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/xgv_cbacks.c' &&
#include <limits.h>
#include <float.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <math.h>
#include <X11/keysym.h>
#include "xincludes.h"
#include "xgobitypes.h"
#include "xgobivars.h"
#include "xgobiexterns.h"
#include "xgvis.h"
X
#define IJ i*dist.ncols+j 
#define UNIFORM 0
#define NORMAL  1
X
extern void update_plot(xgobidata *);
extern void update_dissim_plot(void);
extern void mds_once(Boolean);
extern void set_vgroups(void);
extern void set_dist_matrix_from_edges(struct array *, struct array *, int);
extern void set_dist_matrix_from_pos(struct array *, struct array *, double);
extern void reinit_stress(void);
extern void scramble_pos(void);
extern void center_scale_pos(void);
extern double drandval(int);
X
static void
reset_dims_label(void) {
X  char str[32];
X  extern Widget mds_dims_label;
X
X  sprintf(str, "Dim (k): %d", mds_dims);
X  XtVaSetValues(mds_dims_label,
X    XtNstring, (String) str,
X    NULL);
}
X
/* ARGSUSED */
XXtCallbackProc
mds_dimsleft_cback(Widget w, XtPointer client_data, XtPointer callback_data)
{
X  if (mds_dims > 1) {
X    mds_dims--;
X    reset_dims_label();
X
X    set_vgroups();
X
X    update_plot(&xgobi);
X    plot_once(&xgobi);
X
X    mds_once(False);
X  }
}
X
/* ARGSUSED */
XXtCallbackProc
mds_dimsright_cback(Widget w, XtPointer client_data, XtPointer callback_data)
{
X  if (mds_dims < xgobi.ncols_used) {
X    mds_dims++;
X    reset_dims_label();
X
X    set_vgroups();
X
X    update_plot(&xgobi);
X    plot_once(&xgobi);
X
X    mds_once(False);
X  }
}
X
/* ARGSUSED */
XXtCallbackProc
PopUpDistMenu(Widget w, XtPointer client_data, XtPointer callback_data)
/*
X * Pop up the distance matrix menu.
*/
{
X  Dimension width, height;
X  Position x, y;
X  static int initd = 0;
X
X  if (!initd)
X  {
X    XtVaGetValues(w,
X      XtNwidth, &width,
X      XtNheight, &height, NULL);
X    XtTranslateCoords(w,
X      (Position) (width/2), (Position) (height/2), &x, &y);
X
X    XtVaSetValues(dist_popup,
X      XtNx, x, XtNy, y, NULL); 
X
X    initd = 1;
X  }
X
X  XtPopup(dist_popup, XtGrabNone);
}
X
/* ARGSUSED */
XXtCallbackProc
PopDownDistMenu(Widget w, XtPointer client_data, XtPointer callback_data)
/*
X * Close the distance matrix menu.
*/
{
X    XtPopdown(dist_popup);
}
X
/* ARGSUSED */
XXtCallbackProc
choose_dist_cback(Widget w, XtPointer client_data, XtPointer callback_data)
/*
X * Close the distance matrix menu.
*/
{
X  int i;
X  Arg args[1];
X  Boolean selected = False;
X
X  for (i=0; i<NDISTTYPES-1; i++)
X  {
X    XtSetArg(args[0], XtNstate, &selected);
X    XtGetValues(dist_types[i], args, 1);
X    if (selected)
X    {
X      dist_type = i ;
X      break;
X    }
X  }
X
X  if (dist_type < 0 || dist_type > NDISTTYPES-1)
X  {
X    fprintf(stderr, "Sorry, that's not a valid dist_type.\n");
X  }
X  else
X  {
X    /* dist_type has been set, let's call the right routine. */
X    switch (dist_type) {
X    case LINK:
X      set_dist_matrix_from_edges(&dist, &edges, pos.nrows);
X      break;
X    case EUCLIDIAN:
X      set_dist_matrix_from_pos(&dist, &pos, 2.0);
X      break;
X    case MANHATTAN:
X      set_dist_matrix_from_pos(&dist, &pos, 1.0);
X      break;
X    case DOTPROD:
X    case COSDIST:
X      break;
X    case USER_SUPPLIED:
X    case ADJACENCY:
X    case MAHALANOBIS:
X      fprintf(stderr, "Not implemented yet.\n");
X    }
X  }
}
X
/* ARGSUSED */
XXtCallbackProc
reset_cback(Widget w, XtPointer client_data, XtPointer callback_data)
{
X  int i, k;
X
X  for(k = 0; k < MIN(pos_orig.ncols, MAXDIMS-1); k++)
X    for(i = 0; i < pos.nrows; i++)
X      pos.data[i][k] = pos_orig.data[i][k];
X
X  center_scale_pos();
X
X  update_plot(&xgobi);
X  plot_once(&xgobi);
X
X  reinit_stress();
}
X
/* ARGSUSED */
XXtCallbackProc
scramble_cback(Widget w, XtPointer client_data, XtPointer callback_data)
{
X  scramble_pos();
X
X  update_plot(&xgobi);
X  plot_once(&xgobi);
X
X  reinit_stress();
}
X
/* ARGSUSED */
XXtCallbackProc
center_cback(Widget w, XtPointer client_data, XtPointer callback_data)
{
X
X  center_scale_pos();
X
X  update_plot(&xgobi);
X  plot_once(&xgobi);
X
X  reinit_stress();
}
X
/* ARGSUSED */
XXtCallbackProc
run_cback(Widget w, XtPointer client_data, XtPointer callback_data)
/*
X * This callback defines the actions associated with the run button.
*/
{
X  xgv_is_running = !xgv_is_running;
X
X  if (xgv_is_running) {
X
X    /*
X     * In case points have been moved in xgobi, we'd better
X     * copy in the current values in raw_data.
X    */
X    int i, j;
X    for (i=0; i<xgobi.nrows; i++)
X      for (j=0; j<xgobi.ncols_used; j++)
X        pos.data[i][j] = xgobi.raw_data[i][j] ;
X
X    (void) XtAppAddWorkProc(app_con, RunWorkProcs, NULL);
X  }
X
X  setToggleBitmap(w, xgv_is_running);
}
X
/* ARGSUSED */
static XtTimerCallbackProc
turn_off_scaling(xgobidata *xg, XtIntervalId id)
{
X    is_rescale = 0;
}
X
X
/* ARGSUSED */
XXtCallbackProc
Quit(Widget w, XtPointer client_data, XtPointer callback_data)
/*
X * This callback defines the actions associated with the 'exit' button.
*/
{
X    extern void do_exit(int);
X
X    do_exit(0);
}
X
/* ARGSUSED */
XXtCallbackProc
mds_lnorm_cback (Widget w, XtPointer client_data, XtPointer slideposp)
{
X  Arg args[1];
X  char str[30];
X  extern Widget mds_lnorm_label, mds_lnorm_sbar;
X
X  float slidepos = * (float *) slideposp;
X
X  mds_lnorm = floor(((double) (5.0 * slidepos * 1.04) + 1.0)*10.) / 10. ;
X  if(mds_lnorm > 6.) mds_lnorm = 6.;
X  sprintf(str, "Minkowski n'rm (m): %3.1f ", mds_lnorm);
X  XtSetArg(args[0], XtNstring, str);
X  XtSetValues(mds_lnorm_label, args, 1);
X  XawScrollbarSetThumb(mds_lnorm_sbar, (mds_lnorm-1.)/1.04/5.0 , -1.);
X
X  mds_lnorm_over_distpow = mds_lnorm/mds_distpow;
X  mds_distpow_over_lnorm = mds_distpow/mds_lnorm;
X
X  set_vgroups();
X
X  update_plot(&xgobi);
X  plot_once(&xgobi);
}
/* ARGSUSED */
XXtCallbackProc
mds_power_cback (Widget w, XtPointer client_data, XtPointer slideposp)
/*
X * Adjust the power to which we raise the dissim data matrix.
*/
{
X  Arg args[1];
X  char str[30];
X  extern Widget mds_power_label, mds_power_sbar;
X
X  float slidepos = * (float *) slideposp;
X
X  if (metric_nonmetric == METRIC) {
X    mds_power = floor(6. * slidepos * 1.04 * 10.) / 10. ;
X    if(mds_power > 6.) mds_power = 6.;
X    if(KruskalShepard_classic == KRUSKALSHEPARD) {
X      sprintf(str, "Data Power (D^p): %3.1f ",  mds_power);
X    } else {
X      sprintf(str, "Data Power (D^2p): %3.1f ",  mds_power);
X    }
X    XtSetArg(args[0], XtNstring, str);
X    XtSetValues(mds_power_label, args, 1);
X    XawScrollbarSetThumb(mds_power_sbar, mds_power/1.04/6.0, -1.);
X  } else { /* nonmetric */
X    mds_isotonic_mix = floor(slidepos * 1.04 * 100.)/100. ;
X    if(mds_isotonic_mix > 1.0) mds_isotonic_mix = 1.0;
X    sprintf(str, "Isotonic(D): %d%% ", (int) (mds_isotonic_mix*100));
X    XtSetArg(args[0], XtNstring, str);
X    XtSetValues(mds_power_label, args, 1);
X    XawScrollbarSetThumb(mds_power_sbar, mds_isotonic_mix/1.04, -1.);
X  }
X
/*
X * The third column of the diagnostics matrix has to be
X * reset as well, and this may be the easiest way to do it
X * because the indices are not simple.
*/
X  mds_once(False);
X  update_dissim_plot();
X
}
X
/* ARGSUSED */
XXtCallbackProc
mds_distpow_cback (Widget w, XtPointer client_data, XtPointer slideposp)
/*
X * Adjust the power to which we raise the distance matrix.
*/
{
X  Arg args[1];
X  char str[30];
X  extern Widget mds_distpow_label, mds_distpow_sbar;
X
X  float slidepos = * (float *) slideposp;
X
X  mds_distpow = floor(6. * slidepos * 1.04 * 10.) / 10. ;
X  if(mds_distpow > 6.) mds_distpow = 6.;
X  sprintf(str, "%s: %3.1f ", "Dist Power (d^q)", mds_distpow);
X  XtSetArg(args[0], XtNstring, str);
X  XtSetValues(mds_distpow_label, args, 1);
X  XawScrollbarSetThumb(mds_distpow_sbar, mds_distpow/1.04/6., -1.);
X
X  mds_lnorm_over_distpow = mds_lnorm/mds_distpow;
X  mds_distpow_over_lnorm = mds_distpow/mds_lnorm;
X
X  mds_once(False);
X  update_dissim_plot();
}
X
/* ARGSUSED */
XXtCallbackProc
mds_weightpow_cback (Widget w, XtPointer client_data, XtPointer slideposp)
/*
X * Adjust the power to which we raise the dissimilarity matrix to obtain weights.
*/
{
X  Arg args[1];
X  char str[30];
X  extern Widget mds_weightpow_label, mds_weightpow_sbar;
X
X  float slidepos = * (float *) slideposp;
X
X  mds_weightpow = floor((slidepos - 0.5) * 1.08 * 8.0 * 10.)/10.;
X  if(mds_weightpow > 4.) mds_weightpow = 4.;
X  if(mds_weightpow < -4.) mds_weightpow = -4.;
X  sprintf(str, "%s: %4.1f ", "Wght pow (w=D^r)", mds_weightpow);
X  XtSetArg(args[0], XtNstring, str);
X  XtSetValues(mds_weightpow_label, args, 1);
X  XawScrollbarSetThumb(mds_weightpow_sbar, mds_weightpow/1.08/8. + 0.5, -1.);
X
X  mds_once(False);
}
X
/* ARGSUSED */
XXtCallbackProc
mds_within_between_cback (Widget w, XtPointer client_data, XtPointer slideposp)
/*
X * Adjust the degree to which we use within and between grp dissimilarities
*/
{
X  Arg args[1];
X  char str[30];
X  extern Widget mds_within_between_label, mds_within_between_sbar;
X
X  float slidepos = * (float *) slideposp;
X
X  mds_within_between = floor(slidepos * 1.04 * 2.0 * 50.) / 50.;
X  if(mds_within_between > 2.0) mds_within_between = 2.0;
X  sprintf(str, "Withn=%3.2f Betwn=%3.2f", (2. - mds_within_between), mds_within_between);
X  XtSetArg(args[0], XtNstring, str);
X  XtSetValues(mds_within_between_label, args, 1);
X  XawScrollbarSetThumb(mds_within_between_sbar, mds_within_between/1.04/2., -1.);
X
X  mds_once(False);
}
X
/* ARGSUSED */
XXtCallbackProc
mds_rand_select_cback (Widget w, XtPointer client_data, XtPointer slideposp)
/*
X * Adjust the probability of random selection of a dist/diss
*/
{
X  Arg args[1];
X  char str[30];
X  int i;
X  extern Widget mds_rand_select_label, mds_rand_select_sbar;
X
X  float slidepos = * (float *) slideposp;
X
X  mds_rand_select_val = floor(slidepos*1.04 * 100.) / 100.;
X  if(mds_rand_select_val > 1.0) mds_rand_select_val = 1.0;
X  sprintf(str, "Select'n prob: %d%%", (int) (mds_rand_select_val*100));
X  XtSetArg(args[0], XtNstring, str);
X  XtSetValues(mds_rand_select_label, args, 1);
X  XawScrollbarSetThumb(mds_rand_select_sbar, mds_rand_select_val/1.04, -1.);
X
X  mds_once(False);
}
/* ARGSUSED */
XXtCallbackProc
mds_rand_select_new_cback (Widget w, XtPointer client_data, XtPointer callback_data)
/*
X * Call for new random selection vector
*/
{
X  mds_rand_select_new = TRUE;
X
X  mds_once(False);
}
X
/* ARGSUSED */
XXtCallbackProc
mds_perturb_cback (Widget w, XtPointer client_data, XtPointer slideposp)
/*
X * Adjust the degreee of perturbation of configuration
*/
{
X  Arg args[1];
X  char str[30];
X  extern Widget mds_perturb_label, mds_perturb_sbar;
X
X  float slidepos = * (float *) slideposp;
X
X  mds_perturb_val = floor(slidepos * 1.04 * 100.) / 100.;
X  if(mds_perturb_val > 1.0) mds_perturb_val = 1.0;
X  sprintf(str, "Perturb: %d%%", (int) (mds_perturb_val*100));
X  XtSetArg(args[0], XtNstring, str);
X  XtSetValues(mds_perturb_label, args, 1);
X  XawScrollbarSetThumb(mds_perturb_sbar, mds_perturb_val/1.04, -1.);
X
X  mds_once(False);
}
X
/* ARGSUSED */
XXtCallbackProc
mds_perturb_new_cback (Widget w, XtPointer client_data, XtPointer callback_data)
/*
X * Call for new perturbation with normal random numbers:
*/
{
X  int i, k;
X
X  for (i = 0; i < pos_orig.nrows; i++)
X    for (k = mds_freeze_var; k < mds_dims; k++) {
X      pos.data[i][k] = (1.0-mds_perturb_val)*pos.data[i][k] + (mds_perturb_val)*drandval(NORMAL);  /* standard normal */
X    }
X
X  center_scale_pos();
X
X  update_plot(&xgobi);
X  plot_once(&xgobi);
X
X  reinit_stress();
}
X
/* ARGSUSED */
XXtCallbackProc
mds_stepsize_cback (Widget w, XtPointer client_data, XtPointer slideposp)
/*
X * Adjust the stepsize (range: currently, 0.000:1.000).
*/
{
X  Arg args[1];
X  char str[30];
X  extern Widget mds_stepsize_label;
X
X  float slidepos = * (float *) slideposp;  /* 0:1 */
X
X  mds_stepsize = floor(0.2 * slidepos * slidepos * 10000.) / 10000.;
X  sprintf(str, "%s: %3.4f ", "Stepsize", mds_stepsize);
X  XtSetArg(args[0], XtNstring, str);
X  XtSetValues(mds_stepsize_label, args, 1);
}
X
/* ARGSUSED */
XXtCallbackProc
mds_iterate_cback (Widget w, XtPointer client_data, XtPointer callback_data)
/*
X * Step: one step through the mds loop.
*/
{
X  mds_once(True);
X  update_plot(&xgobi);
X  RunWorkProc((xgobidata *) &xgobi);
X  plot_once(&xgobi);
}
X
/* ARGSUSED */
static XtCallbackProc
fcancel_cback(Widget w, XtPointer client_data, XtPointer callback_data)
/*
X * If the plot window is fully or partially exposed, clear and redraw.
*/
{
X  XtDestroyWidget(XtParent(XtParent(w)));
X  printf("fcancel_cback: If the plot window is fully or partially exposed, clear and redraw. \n");
}
X
/* ARGSUSED */
XXtEventHandler
save_distance_matrix_go (Widget w, XtPointer cldata, XEvent *event)
{
X  XKeyPressedEvent *evnt = (XKeyPressedEvent *) event;
X  KeySym key;
X  char *fname;
X  FILE *fp;
X
X  key = XLookupKeysym(evnt, 0);
X  if (key == XK_Return)
X  {
X    /*
X     * w is ftext; XtParent(w) = fform
X     * XtParent(XtParent(w)) = fpopup
X     * XtParent(XtParent(XtParent(w))) = the parent we're interested in
X    */
X    XtVaSetValues(XtParent(XtParent(XtParent(w))),
X      XtNstate, (Boolean) False,
X      NULL);
X
X    XtVaGetValues(w, XtNstring, &fname, NULL);
X    if ( (fp = fopen(fname, "w")) == NULL)
X    {
X      char message[MSGLENGTH];
X      sprintf(message, "Failed to open the file '%s' for writing.\n", fname);
X      show_message(message, &xgobi);
X    }
X    else
X    {
X      int i, j;
X      for (i = 0; i < dist.nrows; i++) {
X        for (j = 0; j < dist.ncols; j++) {
X          fprintf(fp, "%2.4f ", dist.data[i][j]);
X        }
X        fprintf(fp, "\n");
X      }
X      fflush(fp);
X    }
X
X    XtDestroyWidget(XtParent(XtParent(w)));
X  }
}
X
/* ARGSUSED */
XXtCallbackProc
save_distance_matrix (Widget w, XtPointer client_data, XtPointer callback_data)
/*
X * Write out the distance matrix.
*/
{
/*
X * Create a popup window to get the name; then call
X * the save routine.
*/
X  Widget fpopup, fform, flabel, ftext, fcancel;
X  Dimension width, height;
X  Position x, y;
X  Cursor text_cursor = XCreateFontCursor(display, XC_xterm);
X
X  XtVaGetValues(shell,
X    XtNwidth, &width,
X    XtNheight, &height,
X    NULL);
X  XtTranslateCoords(w,
X    (Position) (width/2), (Position) (height/2), &x, &y);
X
/*
X * Create the popup itself.
*/
X  fpopup = XtVaCreatePopupShell("FSavePopup",
X    /*
X     * If this is a topLevelShell, the user is asked to
X     * place it; if it's transient, it pops up where we
X     * tell it to.
X    */
X    /*topLevelShellWidgetClass, w,*/
X    transientShellWidgetClass, shell,
X    XtNx, (Position) x,
X    XtNy, (Position) y,
X    XtNinput, (Boolean) True,
X    XtNallowShellResize, (Boolean) True,
X    XtNtitle, (String) "Solicit File Name",
X    NULL);
X
/*
X * Create the form widget.
*/
X  fform = XtVaCreateManagedWidget("FSaveForm",
X    formWidgetClass, fpopup,
X    NULL);
X
X  flabel = XtVaCreateManagedWidget("FSaveText",
X    labelWidgetClass, fform,
X    XtNleft, (XtEdgeType) XtChainLeft,
X    XtNright, (XtEdgeType) XtChainLeft,
X    XtNtop, (XtEdgeType) XtChainTop,
X    XtNbottom, (XtEdgeType) XtChainTop,
X    XtNlabel, (String) "Enter file name for distance matrix:",
X    NULL);
X
/*
X * Create the text widget to solicit the filename.
*/
X  ftext = XtVaCreateManagedWidget("FSaveName",
X    asciiTextWidgetClass, fform,
X    XtNfromVert, (Widget) flabel,
X    XtNleft, (XtEdgeType) XtChainLeft,
X    XtNright, (XtEdgeType) XtChainRight,
X    XtNtop, (XtEdgeType) XtChainTop,
X    XtNbottom, (XtEdgeType) XtChainTop,
X    XtNresizable, (Boolean) True,
X    XtNeditType, (int) XawtextEdit,
X    XtNresize, (XawTextResizeMode) XawtextResizeWidth,
X    NULL);
X
X  XtAddEventHandler(ftext, KeyPressMask, FALSE,
X     (XtEventHandler) save_distance_matrix_go, (XtPointer) NULL);
/*
X * Add a cancel button
*/
X  fcancel = XtVaCreateManagedWidget("Command",
X    commandWidgetClass, fform,
X    XtNfromVert, ftext,
X    XtNlabel, "Cancel",
X    NULL);
X  XtAddCallback(fcancel, XtNcallback,
X    (XtCallbackProc) fcancel_cback, (XtPointer) NULL);
X
X  XtPopup(fpopup, XtGrabExclusive);
X  XRaiseWindow(display, XtWindow(fpopup));
X
X  XDefineCursor(display, XtWindow(ftext), text_cursor);
/*
X * Should do something more clever here -- get the size
X * of the window and place the cursor that way.
*/
X  XWarpPointer(display, None, XtWindow(ftext), 0,0,0,0, 10,40);
}
X
X
/* ARGSUSED */
XXtCallbackProc
mds_launch_cback (Widget w, XtPointer client_data, XtPointer callback_data)
/*
X * Launch the xgobi child containing diagnostic data.
*/
{
X  extern xgobidata xgobi, xgobi_diag;
X  extern Widget mds_launch_ntxt;
X  int i, j;
X  char **col_name;
X  int nc = 7;
X  static char *clab[] = {"d_ij", "f(D_ij)", "D_ij", "Res_ij", "Wgt_ij", "i", "j"};
X  static char *blab[] = {"b_ij", "f(D_ij)", "D_ij", "Res_ij", "Wgt_ij", "i", "j"};
X  char fname[512], config_basename[512];
X  FILE *fp, *fpdat, *fprow, *fpvgrp;
X  static int iter = 0;
X  char message[MSGLENGTH];
X  char command[512];
X  char xgobi_exec[512];
X  char *xgobidir;
X  struct stat buf;
X  int subset_size=0;
X
X  subset_size = num_active_dist;
X
X  col_name = (char **) XtMalloc(
X    (Cardinal) nc * sizeof (char *));
X  if(KruskalShepard_classic == KRUSKALSHEPARD) {
X    for (j=0; j<nc; j++) col_name[j] = clab[j];
X  } else {
X    for (j=0; j<nc; j++) col_name[j] = blab[j];
X  }
X
X  sprintf(config_basename, "Shepard_Plot_%d", iter);
X  
X  /* Write out the data */
X  sprintf(fname, "%s.dat", config_basename);
X  if ( (fpdat = fopen(fname, "w")) == NULL) {
X    sprintf(message,
X	    "The file '%s' can not be created\n", fname);
X    show_message(message, &xgobi);
X    return(0);
X  } else {
X    sprintf(fname, "%s.row", config_basename);
X    if ( (fprow = fopen(fname, "w")) == NULL) {
X      sprintf(message,
X	      "The file '%s' can not be created\n", fname);
X      show_message(message, &xgobi);
X      fclose(fprow);
X      return(0);
X    } else {
X      sprintf(fname, "%s.vgroups", config_basename);
X      if ( (fpvgrp = fopen(fname, "w")) == NULL) {
X	sprintf(message,
X		"The file '%s' can not be created\n", fname);
X	show_message(message, &xgobi);
X	fclose(fpvgrp);
X	return(0);
X      }
X    }
X  }
X
X  /*
X   * This takes care of writing out the data and the row labels
X  */
X  {double dist_trans, dist_config, dist_data, weight, resid;
X  xgobidata *xg = (xgobidata *) &xgobi;
X  mds_once(FALSE);
X  for (i = 0; i < dist.nrows; i++) {
X    for (j = 0; j < dist.ncols; j++) {
X      dist_trans  = trans_dist[IJ];             	if (dist_trans  ==  DBL_MAX) continue;
X      dist_config = config_dist[IJ];
X      dist_data   = dist.data[i][j];
X      resid = (dist_trans - dist_config);
X      if(mds_weightpow == 0. && mds_within_between == 1.) { weight = 1.0; } else { weight = weights[IJ]; }
X      fprintf(fpdat, "%5.5g %5.5g %5.5g %5.5g %5.5g %d %d\n",
X	      dist_config, dist_trans, dist_data, resid, weight, i, j);
X      fprintf(fprow, "%s|%s\n", xg->rowlab[ i ], xg->rowlab[ j ]);
X    }
X  }
X  }
X
X  /* variable groups file: keep variables "i" and "j" on same scale */
X  fprintf(fpvgrp, "1\n2\n3\n4\n5\n6\n6\n");
X
X  fclose(fpdat);
X  fclose(fprow);
X  fclose(fpvgrp);
X
X  /* Write out the column labels */
X  sprintf(fname, "%s.col", config_basename);
X  if ( (fp = fopen(fname, "w")) == NULL) {
X    sprintf(message,
X      "The file '%s' can not be created\n", fname);
X    show_message(message, &xgobi);
X    return(0);
X  } else {
X    for (i=0; i<nc; i++) {
X      fprintf(fp, "%s\n", col_name[i]);
X    }
X    fclose(fp);
X  }
X  
X  XtFree((char *) col_name);
X
X  xgobidir = getenv("XGOBID");
X  if(xgobidir && strlen(xgobidir) > 0) { 
X    sprintf(xgobi_exec, "%s/bin/xgobi", xgobidir);
X
X    /* If no luck there, then just try 'xgobi' without a path name */
X    if (stat(xgobi_exec, &buf) != 0)
X      sprintf(xgobi_exec, "xgobi");
X  } else
X    sprintf(xgobi_exec, "xgobi");
X
X  if (mono)
X    strcat(xgobi_exec, " -mono");
X  sprintf(command,
X    "%s -subset %d %s &", xgobi_exec, subset_size, config_basename);
X  fprintf(stderr, "%s\n", command);
X
X  system (command);
X
X  iter++;
X
} /* end mds_launch_cback(... */
X
X
X
X
X
X
X
SHAR_EOF
  chmod 0644 'xgobi/src/xgv_cbacks.c' ||
  $echo 'restore of' 'xgobi/src/xgv_cbacks.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/xgv_cbacks.c:' 'MD5 check failed'
463a5c42e4a14e6f55da285134001006  xgobi/src/xgv_cbacks.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/xgv_cbacks.c'`"
    test 19662 -eq "$shar_count" ||
    $echo 'xgobi/src/xgv_cbacks.c:' 'original size' '19662,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/smoothsk.c ==============
if test -f 'xgobi/src/smoothsk.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/smoothsk.c' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/smoothsk.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/smoothsk.c' &&
/************************************************************
X *                                                          *
X *  Permission is hereby granted  to  any  individual   or  *
X *  institution   for  use,  copying, or redistribution of  *
X *  this  code and associated documentation,  provided      *
X *  that   such  code  and documentation are not sold  for  *
X *  profit and the  following copyright notice is retained  *
X *  in the code and documentation:                          *
X *    Copyright (c) 1997 Sigbert Klinke                     *
X *                       <sigbert@wiwi.hu-berlin.de>        *
X *  All Rights Reserved.                                    *
X *                                                          *
X ************************************************************/
X
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
X
#include "xincludes.h"
#include "xgobitypes.h"
#include "xgobivars.h"
#include "xgobiexterns.h"
X
#define malloc(x) XtMalloc((Cardinal) x)
#define free(x)   XtFree((char *) x)
X
double *xsort;
int *gsort;
X
int
indexsort (const void *left, const void *right)
{
X  if (xsort[*((int *) left)]>xsort[*((int *) right)]) return (1);
X  if (xsort[*((int *) left)]<xsort[*((int *) right)]) return (-1);
X  return (0);
}
X
int
groupsort (const void *left, const void *right)
{
X  if (gsort[*((int *)left)]>gsort[*((int *)right)]) return (1);
X  if (gsort[*((int *)left)]<gsort[*((int *)right)]) return (-1);
X  return (indexsort(left, right));
}
X
double
quartic (double x)
{
X  double x2 = x*x;
X  if (x2>1.0) return 0.0;
X  return (0.9375*(1-x2)*(1-x2));
}
X
void
nadaraya_watson (int n, double *x, double *y, int *group, double bandwidth, double *yest, int *index)
{
X  int i, j, k, maxgroup, start;
X  double diff, kern, *yup, *ydn;
X
X  yup   = (double *) malloc(n*sizeof(double));  
X  ydn   = (double *) malloc(n*sizeof(double));  
X
X  maxgroup = -1;
X  for (i=0; i<n; i++)
X  { index[i] = i;
X    if (group[i]>maxgroup) maxgroup = group[i]; 
X    ydn[i] = quartic(0);          /* K(0)     */
X    yup[i] = y[i]*quartic(0);     /* Y_i K(0) */
X  }
X
X  xsort = x;
X  qsort ((char *) index, n, sizeof(int), indexsort);
X
X  for (k=0; k<=maxgroup; k++)
X  { for (start=i=0; i<n; i++)
X    { if (group[index[i]]==k)
X      { for (j=start; j<i; j++)
X        { if (group[index[j]]==k)
X	  { diff = (x[index[i]]-x[index[j]])/bandwidth;
X            kern = quartic(diff);
X            if (kern==0.0) 
X              start++;
X            else
X	    { yup[index[i]] += y[index[j]]*kern;
X              yup[index[j]] += y[index[i]]*kern;
X	      ydn[index[i]] += kern;
X              ydn[index[j]] += kern;
X            }
X          }
X        }
X      }
X    }
X  }
X
X  for (i=0; i<n; i++)
X    yest[i] = yup[i]/ydn[i];
X
X  free (yup);
X  free (ydn);
}  
X
X
extern long *x_sm;
extern long *y_sm;
extern int *grp_id_sm;
X
void
nadaraya_watson_smoother(long *x, long *y, int n, long *sm_pars,
X  int num_grp, unsigned long *grp_id, int *pnum_pts)
X
/* Di uses global variables x_sm and y_sm for smoothing !! */
X
{
X  int i, *g, *index;
X  double *xsk, *ysk, *ye;
X
X  if (x_sm)
X    free (x_sm);
X  x_sm = (long *) malloc (n*sizeof(long));
X  if (y_sm)
X    free (y_sm);
X  y_sm = (long *) malloc (n*sizeof(long));
X  if (grp_id_sm)
X    free (grp_id_sm);
X  grp_id_sm = (int *) malloc (n*sizeof(int));
X
X  xsk = (double *) malloc (n*sizeof(double));
X  ysk = (double *) malloc (n*sizeof(double));
X
X  for (i=0; i<n; i++)
X  { xsk[i] = x[i];
X    ysk[i] = y[i];
X  } 
X  
X  ye = (double *) malloc (n*sizeof(double));
X  g  = (int *) malloc (n*sizeof(int));
X  for (i=0; i<n; i++)
X   g[i] = (int) grp_id[i]-1;    
X 
X  index = (int *) malloc (n*sizeof(int));
X  nadaraya_watson (n, xsk, ysk, g, (double) *sm_pars, ye, index);
X
X  xsort = xsk;
X  gsort = g;
X
X  qsort ((char *) index, n, sizeof(int), groupsort);
X
X  for (i=0; i<n; i++)
X  { x_sm[i] = (long) xsk[index[i]];
X    y_sm[i] = (long) ye[index[i]];
X    grp_id_sm[i] = g[index[i]]+1; 
X  }
X
X  *pnum_pts = n;
X
X  free (index);
X  free (ye);
X  free (g);
X  free (xsk);
X  free (ysk);
}
X
X
void
spline_smoother(long *x, long *y, int n, long *sm_pars, int num_grp,
X  unsigned long *grp_id, int *pnum_pts)
X
/* Di uses still (!) global variables x_sm and y_sm for smoothing !! */
X
{
X  int i, j, k, l, m, *index; 
X  double *xsk, *ysk, *ye, *w, *lev, gcv, cv, df, lambda, dfmax, *work, *xw, *yw, *ew;
X  long ng, nvar, norder, method, ierun, ier;
X  extern int pspline_();
X
X  if (x_sm)
X    free (x_sm);
X  x_sm = (long *) malloc (n*sizeof(long));
X  if (y_sm)
X    free (y_sm);
X  y_sm = (long *) malloc (n*sizeof(long));
X  if (grp_id_sm)
X    free (grp_id_sm);
X  grp_id_sm = (int *) malloc (n*sizeof(int));
X
X  xsk = (double *) malloc (n*sizeof(double));
X  ysk = (double *) malloc (n*sizeof(double));
X  xw  = (double *) malloc (n*sizeof(double));
X  yw  = (double *) malloc (n*sizeof(double));
X  w   = (double *) malloc (n*sizeof(double));
X  ye  = (double *) malloc (n*sizeof(double));
X  lev = (double *) malloc (n*sizeof(double));
X  ew  = (double *) malloc (n*sizeof(double));
X  work = (double *) malloc (((n-2)*11+n)*sizeof(double));
X  index = (int *) malloc (n*sizeof(int));
X
X  for (i=0; i<n; i++)
X  { xsk[i] = x[i];
X    ysk[i] = y[i];
X    w[i]   = 1.0;
X    index[i] = i;
X  } 
X
/* the range lambda might be adjusted to other datasets
X   the actual range works well for the flea data
X   SK
*/
X  lambda    = exp(7+*sm_pars/150);
X
X  nvar      = 1;
X  norder    = 2;
X  df        = norder+2;
X  method    = 1;
X  j         = 0;
X  *pnum_pts = 0;
X
X  for (k=1; k<=num_grp; k++)
X  { for (ng=i=0; i<n; i++)
X    { if (grp_id[i]==k)
X      { xsk[ng] = x[i];
X        ysk[ng] = y[i];
X        index[ng] = ng;
X        ng++;
X      }
X    }
X    xsort = xsk;
X    qsort ((char *) index, ng, sizeof(int), indexsort);
X    for (i=0;i<ng;i++)
X    { xw[i] = xsk[index[i]];
X      yw[i] = ysk[index[i]];
X    }
X    for (i=0;i<ng;i++)
X    { if (i && (xw[i]==xw[i-1]))
X      { for (l=i; xw[l]==xw[i]; l++);
X        for (m=i; m<l; m++)
X          xw[m] += ((double) (m-i+1))/((double) (l-i+1));
X      }        
X    }
X    dfmax = ng;
X    ier   = ierun = 0;
X    pspline_(&ng, &nvar, &norder, xw, w, yw, ew, lev, 
X             &gcv, &cv, &df, &lambda, &dfmax, work, &method,
X             &ierun, &ier);
X    if (ier)
X    { switch (ier)
X      { case 1 : printf ("spline: n<2*norder+1\n"); break;
X        case 2 : printf ("spline: norder out of range\n"); break;
X        case 3 : printf ("spline: nvar<1\n"); break;
X        case 4 : printf ("spline: lambda<0\n"); break;
X        case 5 : printf ("spline: x not strictly monotone\n"); break;
X        case 6 : printf ("spline: some w are negative\n"); break;
X        default: printf ("spline: Choleski decomposition failed\n"); break;
X      } 
X    }
X    else
X    { for (i=0; i<ng; i++, j++)
X      { x_sm[j] = (long) xw[i];
X        y_sm[j] = (long) ew[i];
X        grp_id_sm[j] = k;
X      } 
X    }
X  }
X  
X  *pnum_pts = j;
X
X  free (index);
X  free (ye);
X  free (xsk);
X  free (ysk);
X  free (w);
X  free (lev);
X  free (ew);
X  free (work);
X  free (xw);
X  free (yw);
}
SHAR_EOF
  chmod 0644 'xgobi/src/smoothsk.c' ||
  $echo 'restore of' 'xgobi/src/smoothsk.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/smoothsk.c:' 'MD5 check failed'
dca3bd044150f51d8a5b73651ecd6115  xgobi/src/smoothsk.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/smoothsk.c'`"
    test 6972 -eq "$shar_count" ||
    $echo 'xgobi/src/smoothsk.c:' 'original size' '6972,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/spin_cbacks.c ==============
if test -f 'xgobi/src/spin_cbacks.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/spin_cbacks.c' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/spin_cbacks.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/spin_cbacks.c' &&
/* spin_cbacks.c */
/************************************************************
X *                                                          *
X *  Permission is hereby granted  to  any  individual   or  *
X *  institution   for  use,  copying, or redistribution of  *
X *  the xgobi code and associated documentation,  provided  *
X *  that   such  code  and documentation are not sold  for  *
X *  profit and the  following copyright notice is retained  *
X *  in the code and documentation:                          *
X *        Copyright (c) 1990, ..., 1996 Bellcore            *
X *                                                          *
X *  We welcome your questions and comments, and request     *
X *  that you share any modifications with us.               *
X *                                                          *
X *    Deborah F. Swayne            Dianne Cook              *
X *   dfs@research.att.com       dicook@iastate.edu          *
X *      (973) 360-8423    www.public.iastate.edu/~dicook/   *
X *                                                          *
X *                    Andreas Buja                          *
X *                andreas@research.att.com                  *
X *              www.research.att.com/~andreas/              *
X *                                                          *
X ************************************************************/
X
#include <stdio.h>
#include "xincludes.h"
#include "xgobitypes.h"
#include "xgobivars.h"
#include "xgobiexterns.h"
X
static Widget spin_panel[3], spin_sbar ;
Widget spin_cmd[9];
static Widget spin_place_save_coefs;
static Widget spin_place_save_rmat, spin_place_read_rmat;
X
#define CHDIR  spin_cmd[0]
#define PAUSE  spin_cmd[1]
#define REINIT spin_cmd[2]
#define ROCK   spin_cmd[3]
#define INTERP spin_cmd[4]
#define YAXIS  spin_cmd[5]
#define XAXIS  spin_cmd[6]
#define OAXIS  spin_cmd[7]
X
void 
reset_spin_pause_cmd(xgobidata *xg)
{
X  XtCallCallbacks(PAUSE, XtNcallback, (XtPointer) xg);
X  XtVaSetValues(PAUSE, XtNstate, xg->is_spin_paused, NULL);
X  
X  setToggleBitmap(PAUSE, xg->is_spin_paused);
}
X
void
start_spin_proc(xgobidata *xg)
{
X  Boolean run;
X
X  if (!xg->is_spin_paused && xg->theta0 != 0.) {
X    if (xg->is_spin_type.oblique) {
X      if (xg->is_rocking)
X        xg->run_rock_proc = True;
X      else
X        xg->run_spin_oblique_proc = True;
X
X      run = xg->run_rock_proc || xg->run_spin_oblique_proc ;
X    }
X    else
X    {
X      if (xg->is_interp && !xg->run_interp_proc) {
X        find_quadrant(xg);
X        xg->run_interp_proc = True;
X      }
X      else if (xg->is_rocking)
X        xg->run_rock_proc = True;
X      else
X        xg->run_spin_axis_proc = True;
X
X      run = xg->run_interp_proc || xg->run_rock_proc || xg->run_spin_axis_proc;
X    }
X
X    if (run)
X      (void) XtAppAddWorkProc(app_con, RunWorkProcs, (XtPointer) NULL);
X  }
}
X
void
stop_spin_proc(xgobidata *xg)
{
X  if (xg->is_spin_type.oblique)
X  {
X    xg->run_spin_oblique_proc = False;
X    xg->run_rock_proc = False;
X  }
X  else
X  {
X    xg->run_spin_axis_proc = False;
X    xg->run_rock_proc = False;
X    if (xg->run_interp_proc)
X    {
X      xg->run_interp_proc = False;
X      reset_interp_proc();
X    }
X  }
}
X
void
reinit_spin(xgobidata *xg)
{
X  XtCallCallbacks(REINIT, XtNcallback, (XtPointer) xg);
}
X
void
map_spin(xgobidata *xg, Boolean on)
{
X  if (on)
X  {
X    XtMapWidget(spin_panel[0]);
X    XtMapWidget(xg->spin_mouse);
X  }
X  else {
X    XtUnmapWidget(spin_panel[0]);
X    XtUnmapWidget(xg->spin_mouse);
X  }
}
X
void
set_rspeed(float slidepos, xgobidata *xg)
{
X  if (xg->is_spin_type.oblique) {
X    if (slidepos < 0.05) {
X      stop_spin_proc(xg);
X      xg->theta0 = 0.0;
X    }
X    else {
X      xg->theta0 = slidepos / 10.;
X      start_spin_proc(xg);
X    }
X  }
X  else {
X    if (slidepos < 0.05) {
X      stop_spin_proc(xg);
X      xg->theta0 = 0.0;
X    }
X    else {
X      xg->theta0 = slidepos / 10.;
X    }
X  }
}
X
/* ARGSUSED */
XXtCallbackProc
rspeed_cback(Widget w, xgobidata *xg, XtPointer slideposp)
/*
X * Adjust the apparent speed of rotation using the slider bar.
X * Actually being altered is the angular distance between successive
X * replots, by means of changing theta0.
*/
{
X  float slidepos = * (float *) slideposp;
X
X  set_rspeed(slidepos, xg);
}
X
/* ARGSUSED */
XXtCallbackProc
rchdir_cback(Widget w, xgobidata *xg, XtPointer callback_data)
/*
X * Change the direction of rotation.
*/
{
X  change_spin_direction();
}
X
/* ARGSUSED */
XXtCallbackProc
rinterp_cback(Widget w, xgobidata *xg, XtPointer callback_data)
/*
X * With Y fixed, interpolate back and forth between two X variables.
*/
{
X  if (!xg->is_interp)
X  {
X    stop_spin_proc(xg);
X
X    xg->is_rocking = False;
X    xg->is_interp = True;
X
X    if (!xg->is_spin_paused && xg->theta0 != 0.0)
X    {
X      find_quadrant(xg);
X      xg->run_interp_proc = True;
X      (void) XtAppAddWorkProc(app_con, RunWorkProcs, (XtPointer) NULL);
X    }
X  }
X  else
X  {
X    xg->run_interp_proc = False;
X    reset_interp_proc();
X    if (xg->theta0 != 0.0 && !xg->is_spin_paused)
X    {
X      xg->run_spin_axis_proc = True;
X      (void) XtAppAddWorkProc(app_con, RunWorkProcs, (XtPointer) NULL);
X    }
X    xg->is_interp = False;
X  }
X
X  setToggleBitmap(ROCK, xg->is_rocking);
X  setToggleBitmap(INTERP, xg->is_interp);
}
X
/* ARGSUSED */
XXtCallbackProc
rock_cback(Widget w, xgobidata *xg, XtPointer callback_data)
/*
X * With Y fixed, rock back and forth around a fixed point.
*/
{
X  if (!xg->is_rocking)
X  {
X    stop_spin_proc(xg);
X
X    xg->is_interp = False;
X    xg->is_rocking = True;
X
X    if (!xg->is_spin_paused && xg->theta0 != 0.0)
X    {
X      xg->run_rock_proc = True;
X      (void) XtAppAddWorkProc(app_con, RunWorkProcs, (XtPointer) NULL);
X    }
X  }
X  else
X  {
X    xg->run_rock_proc = False;
X    xg->is_rocking = False;
X    start_spin_proc(xg);
X  }
X
X  setToggleBitmap(ROCK, xg->is_rocking);
X  setToggleBitmap(INTERP, xg->is_interp);
}
X
/* ARGSUSED */
XXtCallbackProc
spin_pause_on_cback(Widget w, xgobidata *xg, XtPointer callback_data)
/*
X * Stop the spinning without turning off the rotate button.
*/
{
X  if (!xg->is_spin_paused) {
X    xg->is_spin_paused = True;
X    stop_spin_proc(xg);
X  }
X  else {
X    xg->is_spin_paused = False;
X    start_spin_proc(xg);
X  }
X
X  setToggleBitmap(PAUSE, xg->is_spin_paused);
}
X
/* ARGSUSED */
XXtCallbackProc
spin_reinit_cback(Widget w, xgobidata *xg, XtPointer callback_data)
/*
X * Reinitialize rotation.
*/
{
/*
X * For variable circles.
*/
X  xg->xax.x = RADIUS;
X  xg->xax.y = xg->yax.x = 0;
X  xg->yax.y = RADIUS;
X  xg->zax.x = xg->zax.y = 0;
X
X  xg->theta.yaxis = xg->theta.xaxis = 0.0;
X  xg->cost.y = xg->cost.x = 1;
X  xg->sint.y = xg->sint.x = 0;
X  xg->icost.y = (int) (xg->cost.y * PRECISION2);
X  xg->isint.y = (int) (xg->sint.y * PRECISION2);
X  xg->icost.x = (int) (xg->cost.x * PRECISION2);
X  xg->isint.x = (int) (xg->sint.x * PRECISION2);
X
X  init_ob_rotate(xg);
X
X  world_to_plane(xg);
X  plane_to_screen(xg);
X  plot_once(xg);
X
X  refresh_vboxes(xg);
X  if (xg->is_spin_type.oblique)
X    draw_ob_var_lines(xg);
X  else
X    spin_var_lines(xg);
}
X
/* ARGSUSED */
XXtCallbackProc
spin_xaxis_on_cback(Widget w, xgobidata *xg, XtPointer callback_data)
/*
X * Let the x axis be the axis of rotation.
*/
{
X  if (xg->is_spin_type.xaxis) {
X    stop_spin_proc(xg);
X    xg->is_spin_type.xaxis = 0;
X  }
X  else
X  {
X    xg->is_spin_type.xaxis = True;
X    xg->is_spin_type.yaxis = xg->is_spin_type.oblique = False;
X    XtSetSensitive(spin_place_save_rmat, False);
X    XtSetSensitive(spin_place_read_rmat, False);
X    reset_last_touched(xg);
X
X    world_to_plane(xg);
X    plane_to_screen(xg);
X    plot_once(xg);
X
X    refresh_vboxes(xg);
X    set_varsel_label(xg);
X
X    start_spin_proc(xg);
X  }
X
X  setToggleBitmap(XAXIS, xg->is_spin_type.xaxis);
X  setToggleBitmap(YAXIS, xg->is_spin_type.yaxis);
X  setToggleBitmap(OAXIS, xg->is_spin_type.oblique);
}
X
/* ARGSUSED */
XXtCallbackProc
spin_yaxis_on_cback(Widget w, xgobidata *xg, XtPointer callback_data)
/*
X * Let the x axis be the axis of rotation.
*/
{
X  if (xg->is_spin_type.yaxis) {
X    xg->is_spin_type.yaxis = 0;
X    stop_spin_proc(xg);
X  }
X  else
X  {
X    xg->is_spin_type.yaxis = True;
X    xg->is_spin_type.xaxis = xg->is_spin_type.oblique = False;
X    XtSetSensitive(spin_place_save_rmat, False);
X    XtSetSensitive(spin_place_read_rmat, False);
X    reset_last_touched(xg);
X
X    world_to_plane(xg);
X    plane_to_screen(xg);
X    plot_once(xg);
X
X    refresh_vboxes(xg);
X    set_varsel_label(xg);
X
X    start_spin_proc(xg);
X  }
X  setToggleBitmap(XAXIS, xg->is_spin_type.xaxis);
X  setToggleBitmap(YAXIS, xg->is_spin_type.yaxis);
X  setToggleBitmap(OAXIS, xg->is_spin_type.oblique);
}
X
void
toggle_interpolation(Boolean sens)
{
X  XtVaSetValues(INTERP,
X    XtNsensitive, sens,
X    NULL);
}
X
/* ARGSUSED */
XXtCallbackProc
spin_oblique_on_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  if (xg->is_spin_type.oblique) {
X    stop_spin_proc(xg);
X
X    xg->is_spin_type.oblique = False;
X    xg->is_interp = False;
X    toggle_interpolation(True);
X  }
X  else
X  {
X    xg->is_spin_type.oblique = True;
X    xg->is_spin_type.yaxis = xg->is_spin_type.xaxis = False;
X    XtSetSensitive(spin_place_save_rmat, True);
X    XtSetSensitive(spin_place_read_rmat, True);
X    toggle_interpolation(False);
X
X    refresh_vboxes(xg);
X    set_varsel_label(xg);
X
X    find_plot_center(xg);
X    store_Rmat(xg);
X    find_Rmat(xg);
X    world_to_plane(xg);
X    plane_to_screen(xg);
X    plot_once(xg);
X
X    start_spin_proc(xg);
X  }
X  setToggleBitmap(XAXIS, xg->is_spin_type.xaxis);
X  setToggleBitmap(YAXIS, xg->is_spin_type.yaxis);
X  setToggleBitmap(OAXIS, xg->is_spin_type.oblique);
}
X
/*____Beginning of initialization section____*/
X
void
make_rotate(xgobidata *xg)
{
X  char str[30];
X  Dimension max_width;
X
/*
X * Widest button label used in this panel.
*/
X  sprintf(str, "Change Direction");
X  max_width = XTextWidth(appdata.font, str, strlen(str));
X
/*
X * SpinPanel:  Rotation control panel, spin_panel[0]
*/
X  spin_panel[0] = XtVaCreateManagedWidget("SpinPanel",
X    boxWidgetClass, xg->box0,
X    XtNleft, (XtEdgeType) XtChainLeft,
X    XtNright, (XtEdgeType) XtChainLeft,
X    XtNtop, (XtEdgeType) XtChainTop,
X    XtNbottom, (XtEdgeType) XtChainTop,
X    XtNmappedWhenManaged, (Boolean) False,
X    NULL);
X  if (mono) set_mono(spin_panel[0]);
X
X  spin_sbar = XtVaCreateManagedWidget("Scrollbar",
X    scrollbarWidgetClass, spin_panel[0],
X    XtNwidth, (Dimension) max_width,
X    XtNorientation, (XtOrientation) XtorientHorizontal,
X    NULL);
X  if (mono) set_mono(spin_sbar);
X  add_sbar_help(&xg->nhelpids.sbar,
X    spin_sbar, "Ro_Speed");
X  XawScrollbarSetThumb(spin_sbar, 10.*THETA0, -1.);
X  XtAddCallback(spin_sbar, XtNjumpProc,
X    (XtCallbackProc) rspeed_cback, (XtPointer) xg);
X
X  CHDIR = CreateCommand(xg, "Change Direction",
X    True, (Widget) NULL, (Widget) NULL,
X    spin_panel[0], "Ro_Chdir");
X  PAUSE = CreateToggle(xg, "Pause",
X    True, (Widget) NULL, (Widget) NULL, (Widget) NULL, False, ANY_OF_MANY,
X    spin_panel[0], "Ro_Pause");
X  REINIT = CreateCommand(xg, "Reinit",
X    True, (Widget) PAUSE, (Widget) CHDIR,
X    spin_panel[0], "Ro_Reinit");
X  XtManageChildren(&CHDIR, 3);
X  XtAddCallback(CHDIR, XtNcallback,
X    (XtCallbackProc) rchdir_cback, (XtPointer) xg);
X  XtAddCallback(PAUSE, XtNcallback,
X    (XtCallbackProc) spin_pause_on_cback, (XtPointer) xg);
X  XtAddCallback(REINIT, XtNcallback,
X    (XtCallbackProc) spin_reinit_cback, (XtPointer) xg);
/*
X * spin_panel[1] contains the buttons for interpolation and rocking,
X * which need to be mutually exclusive.
*/
X  spin_panel[1] = XtVaCreateManagedWidget("Panel",
X    boxWidgetClass, spin_panel[0],
X    NULL);
X  if (mono) set_mono(spin_panel[1]);
X  ROCK = CreateToggle(xg, "Rock",
X    True, (Widget) NULL, (Widget) NULL, (Widget) NULL, False, ANY_OF_MANY,
X    spin_panel[1], "Ro_Rock");
X  INTERP = CreateToggle(xg, "Interpolate",
X    False, (Widget) NULL, (Widget) NULL, ROCK, False, ANY_OF_MANY,
X    spin_panel[1], "Ro_Interp");
X  XtManageChildren(&ROCK, 2);
X  XtAddCallback(ROCK, XtNcallback,
X    (XtCallbackProc) rock_cback, (XtPointer) xg);
X  XtAddCallback(INTERP, XtNcallback,
X    (XtCallbackProc) rinterp_cback, (XtPointer) xg);
/*
X * spin_panel[2] contains the buttons for determining the axis of
X * rotation, and these need to be mutually exclusive.
*/
X  spin_panel[2] = XtVaCreateManagedWidget("Panel",
X    boxWidgetClass, spin_panel[0],
X    NULL);
X  if (mono) set_mono(spin_panel[2]);
X  YAXIS = CreateToggle(xg, "Y Axis",
X    True, (Widget) NULL, (Widget) NULL, (Widget) NULL, False, ONE_OF_MANY,
X    spin_panel[2], "Ro_Axis");
X  XAXIS = CreateToggle(xg, "X Axis",
X    True, (Widget) NULL, (Widget) NULL, YAXIS, False, ONE_OF_MANY,
X    spin_panel[2], "Ro_Axis");
X  OAXIS = CreateToggle(xg, "Oblique Axis",
X    True, (Widget) NULL, (Widget) NULL, YAXIS, True, ONE_OF_MANY,
X    spin_panel[2], "Ro_Axis");
X  XtManageChildren(&YAXIS, 3);
X  XtAddCallback(YAXIS, XtNcallback,
X    (XtCallbackProc) spin_yaxis_on_cback, (XtPointer) xg);
X  XtAddCallback(XAXIS, XtNcallback,
X    (XtCallbackProc) spin_xaxis_on_cback, (XtPointer) xg);
X  XtAddCallback(OAXIS, XtNcallback,
X    (XtCallbackProc) spin_oblique_on_cback, (XtPointer) xg);
X
X  spin_place_save_coefs = CreateCommand(xg, "Save Coeffs",
X    True, (Widget) NULL, (Widget) NULL,
X    spin_panel[0], "Ro_SaveCoefs");
X  XtManageChild(spin_place_save_coefs);
X  XtAddCallback(spin_place_save_coefs, XtNcallback,
X    (XtCallbackProc) spin_place_save_coefs_popup, (XtPointer) xg);
X
X  spin_place_save_rmat = CreateCommand(xg, "Save Rotation Mtrx",
X    True, (Widget) NULL, (Widget) NULL,
X    spin_panel[0], "Ro_SaveRMat");
X  XtManageChild(spin_place_save_rmat);
X  XtAddCallback(spin_place_save_rmat, XtNcallback,
X    (XtCallbackProc) spin_place_save_rmat_popup, (XtPointer) xg);
X
X  spin_place_read_rmat = CreateCommand(xg, "Read Rotation Mtrx",
X    True, (Widget) NULL, (Widget) NULL,
X    spin_panel[0], "Ro_SaveRMat");
X  XtManageChild(spin_place_read_rmat);
X  XtAddCallback(spin_place_read_rmat, XtNcallback,
X    (XtCallbackProc) spin_place_read_rmat_popup, (XtPointer) xg);
}
X
void
rotate_on(xgobidata *xg)
/*
X * Turn rotation on and off.
*/
{
X  int j;
X
/*
X *  If this mode is currently selected, turn it off.
*/
X  if (xg->prev_plot_mode == ROTATE_MODE && xg->plot_mode != ROTATE_MODE)
X  {
X    XtRemoveEventHandler(xg->workspace, XtAllEvents,
X      TRUE, (XtEventHandler) ob_button, (XtPointer) xg);
X    XDefineCursor(display, XtWindow(xg->workspace), default_cursor);
X
X    stop_spin_proc(xg);
X    map_spin(xg, False);
X  }
/* Else turn it on */
X  else if (xg->prev_plot_mode != ROTATE_MODE &&
X           xg->plot_mode == ROTATE_MODE)
X  {
X    XtAddEventHandler(xg->workspace,
X      ButtonPressMask | ButtonReleaseMask |
X      Button1MotionMask | Button2MotionMask,
X      FALSE, (XtEventHandler) ob_button, (XtPointer) xg);
X    XDefineCursor(display, XtWindow(xg->workspace), spin_cursor);
X
X    if (!xg->is_spinning)
X    {
X      if (xg->is_plotting1d)
X        free_txtr_var();
X      else if (xg->is_touring && xg->is_princ_comp)
X	set_sph_labs(xg, xg->nsph_vars);
/*        reset_var_labels(xg, PRINCCOMP_OFF);i think not needed anymore
X                                             sphering transformation*/
X
X      if (xg->carry_vars)
X        carry_spin_vars(xg);
X
X      xg->is_plotting1d = xg->is_xyplotting = False;
X      xg->is_touring = False;
X      xg->is_corr_touring = False;
X      xg->is_spinning = True;
X
X      find_plot_center(xg);
X      update_lims(xg);
X      update_world(xg);
X      world_to_plane(xg);
X      plane_to_screen(xg);
X      plot_once(xg);
X
X      for (j=0; j<xg->ncols_used; j++)
X      {
X        if (j == xg->spin_vars.x ||
X          j == xg->spin_vars.y ||
X          j == xg->spin_vars.z)
X            xg->varchosen[j] = True;
X        else
X            xg->varchosen[j] = False;
X      }
X      refresh_vboxes(xg);
X      set_varsel_label(xg);
X    }
X
X    map_spin(xg, True);
X    /*
X     * If we enter the rotation mode with is_spin_paused = False
X     * and theta0 > 0, start spinning.
X    */
X    start_spin_proc(xg);
X  }
}
X
#undef CHDIR
#undef PAUSE
#undef REINIT
#undef ROCK
#undef INTERP
#undef YAXIS
#undef XAXIS
#undef OAXIS
SHAR_EOF
  chmod 0644 'xgobi/src/spin_cbacks.c' ||
  $echo 'restore of' 'xgobi/src/spin_cbacks.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/spin_cbacks.c:' 'MD5 check failed'
d284ba4e65674cc37457204da333cc66  xgobi/src/spin_cbacks.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/spin_cbacks.c'`"
    test 16007 -eq "$shar_count" ||
    $echo 'xgobi/src/spin_cbacks.c:' 'original size' '16007,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/tour_cbacks.c ==============
if test -f 'xgobi/src/tour_cbacks.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/tour_cbacks.c' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/tour_cbacks.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/tour_cbacks.c' &&
/* tour_cbacks.c */
/************************************************************
X *                                                          *
X *  Permission is hereby granted  to  any  individual   or  *
X *  institution   for  use,  copying, or redistribution of  *
X *  the xgobi code and associated documentation,  provided  *
X *  that   such  code  and documentation are not sold  for  *
X *  profit and the  following copyright notice is retained  *
X *  in the code and documentation:                          *
X *        Copyright (c) 1990, ..., 1996 Bellcore            *
X *                                                          *
X *  We welcome your questions and comments, and request     *
X *  that you share any modifications with us.               *
X *                                                          *
X *    Deborah F. Swayne            Dianne Cook              *
X *   dfs@research.att.com       dicook@iastate.edu          *
X *      (973) 360-8423    www.public.iastate.edu/~dicook/   *
X *                                                          *
X *                    Andreas Buja                          *
X *                andreas@research.att.com                  *
X *              www.research.att.com/~andreas/              *
X *                                                          *
X ************************************************************/
X
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "xincludes.h"
#include "xgobitypes.h"
#include "xgobivars.h"
#include "xgobiexterns.h"
X
/* external variables */
extern Widget tour_interp_menu_btn[3];
extern int tour_interp_btn;
extern int got_new_basis;
X
#define OWN_TOUR_SELECTION XtOwnSelection( (Widget) xg->workspace, \
X  (Atom) XG_NEWTOUR, (Time) CurrentTime, \
X  (XtConvertSelectionProc) pack_tour_data, \
X  (XtLoseSelectionProc) pack_tour_lose , \
X  (XtSelectionDoneProc) pack_tour_done )
/* Functions used in this file */
XXtConvertSelectionProc pack_tour_data() ;
XXtSelectionDoneProc pack_tour_done() ;
XXtLoseSelectionProc pack_tour_lose() ;
X
void
start_tour_proc(xgobidata *xg)
{
X  if (!xg->is_tour_paused &&
X      xg->tour_link_state != receive &&
X      xg->step != 0)
/* Can't include xg->is_stepping check here because then
X * Go doesn't restart tour. So there will be a problem if leave
X * tour to use scale or brush, for eg, when return stepping will
X * not be on, although the button is highlighted. Turning Step on
X * and then off again fixes it.
*/
X  {
X    xg->run_tour_proc = True;
X    (void) XtAppAddWorkProc(app_con, RunWorkProcs, (XtPointer) NULL);
X  }
X
X  OWN_TOUR_SELECTION ;  /* Do this even when not linked to save trouble */
}
X
void
stop_tour_proc(xgobidata *xg)
{
X  xg->run_tour_proc = False;
}
X
void
set_tour_speed(float slidepos, xgobidata *xg)
{
/*
X * If the slider is near the start of its range, set step = 0.
X * and stop the touring.
*/
X  if (slidepos < .05)
X  {
X    stop_tour_proc(xg);
X    xg->step = 0.0;
X  }
X  else
X  {
X    if (!xg->is_tour_paused && xg->tour_link_state != receive)
X      start_tour_proc(xg);
X
X    /*
X     * To cause tour to speed up wildly at the right of the
X     * scrollbar range.
X    */
X    if (slidepos < 0.8)
X      xg->step = (slidepos - .05) / 20. ;
X    else if ((slidepos >= 0.8) && (slidepos < 0.9))
X      xg->step = pow((double)(slidepos-0.8),(double)0.90) + 0.0375;
X    else
X      xg->step = sqrt((double)(slidepos-0.8)) + 0.0375;
X  }
X  xg->delta = xg->step/xg->dv;
}
X
/* ARGSUSED */
XXtCallbackProc
tour_speed_cback(Widget w, xgobidata *xg, XtPointer slideposp)
{
X  float slidepos = * (float *) slideposp;
X  set_tour_speed(slidepos, xg);
}
X
/* ARGSUSED */
XXtCallbackProc
tour_pause_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  if (!xg->is_tour_paused)
X  {
X    xg->is_tour_paused = True;
X    stop_tour_proc(xg);
X    possibly_draw_bandwidth(xg);
X  }
X  else
X  {
X    if (xg->numvars_t > 1)
X    {/* pause is called in tour proc now when variables faded
X        to 2, or when returning to bitmap. in the first case
X        the tour proc shouldn't be turned on until more variables
X        are added, but in the second case it should
X      */
X      xg->is_tour_paused = False;
X      start_tour_proc(xg);
X    }
X  }
X  setToggleBitmap(w, xg->is_tour_paused);
}
X
void
desens_everything(xgobidata *xg)
{
X  /*
X   * Desensitize the local scan, reinit and principal components commands.
X  */
X  set_sens_princ_comp(xg, 0);
X  set_sens_localscan(false);
X  set_sens_reinit(false);
X  set_sens_link_menu(0);
X  if (xg->is_princ_comp)
X    reset_princ_comp(True, xg); /* this needs to be done because
X                                 * desensitizing turns off the
X                                 * highlighting. */
X  /*
X   * if princ comp off then desensitize projection pursuit button.
X  */
X  if (!xg->is_princ_comp)
X    set_sens_pp_btn(xg, 0);
X  if (xg->is_pp_optimz)
X    turn_off_optimz(xg);
X  if (xg->is_pp) /* desensitize optimize during backtrack */
X    set_sens_optimz(0);
}
X
void
resens_everything(xgobidata *xg)
{
X  /*
X   * Resensitize the local scan, reinit and principal components.
X  */
X  set_sens_localscan(true);
X  set_sens_reinit(true);
X  set_sens_princ_comp(xg, 1);
X  set_sens_link_menu(1);
X  /*
X   * if princ comp off then resensitize projection pursuit button.
X  */
X  if (!xg->is_princ_comp)
X    set_sens_pp_btn(xg, 1);
X  if (xg->is_pp) /* resensitize optimize when turn off backtracking */
X    set_sens_optimz(1);
}
X
/* ARGSUSED */
XXtCallbackProc
tour_backtrack_cback(Widget w, xgobidata *xg, XtPointer callback_data)
/*
X * This callback invokes scanning back through the history list.
*/
{
X  Boolean turn_it_on = False;
X
X  if (!xg->is_backtracking)
X  {
X    if (xg->tour_hist_just_read)
X    {
X      xg->backtrack_dir = FORWARD;
X      reset_cycleback_cmd(true, true, "F");
X      /*
X       * Break circular list and make end pointers NULL
X      */
X      xg->hend = xg->curr->prev;
X      xg->hend->next = NULL;
X      xg->hfirst->prev = NULL;
X
X      turn_it_on = True;
X      xg->tour_hist_just_read = False;
X    }
X    else
X    {
X      if ((xg->nhist_list > 2) ||
X        (!check_proximity(xg->u, xg->u0, xg->ncols_used) &&
X        xg->nhist_list == 2))
X      {
X        xg->backtrack_dir = BACKWARD;
X        reset_cycleback_cmd(true, true, "B");
X        /*
X         * Store current position if not arbitrarily close to
X         * last entry in history list.
X        */
X        if (!check_proximity(xg->u, xg->u0, xg->ncols_used))
X        {
X          init_basis(xg);
X          if (xg->is_store_history)
X            store_basis(xg, xg->u0);
X        }
X
X        if ((xg->nhist_list < MAXHIST) ||
X          ((xg->nhist_list == MAXHIST) &&
X          (xg->old_nhist_list == (MAXHIST-1))))
X        {
X          xg->nhist_list--;
X        }
X      /*
X       * Break circular list and make end pointers NULL
X      */
X        xg->hend = xg->curr;
X        xg->curr->next = NULL;
X        xg->hfirst->prev = NULL;
X
X        zero_tau(xg);
X        turn_it_on = True;
X      }
X    }
X    if (turn_it_on)
X    {
X      desens_everything(xg);
X      tour_event_handlers(xg, 0);
X      XtUnmapWidget(xg->tour_mouse);
X
X      if (xg->is_stepping)
X      {
X        set_ready_to_stop_now(1);
X        set_counting_to_stop(0);
X      }
X      xg->is_backtracking = True;
X      set_varsel_label(xg);
X      turn_it_on = False;
X    }
X    else
X    {
X      char message[MSGLENGTH];
X      sprintf(message,
X       "Can't start backtrack until more than %d basis in the history list.\n",
X       xg->nhist_list);
X      show_message(message, xg);
X      highlight_backtrack_cmd();
X    }
X  }
X  else /* is_backtracking, so turn it off */
X  {
X    if (xg->backtrack_dir == FORWARD)
X    {
X      /*
X       * If not at end of curr list save previous base,
X       * break links and load remaining bases onto the free list.
X      */
X      if (xg->curr->prev != NULL)
X      {
X        xg->hend = xg->curr->prev;
X        xg->fl = xg->curr;
X        xg->fl->prev = NULL;
X        while (xg->fl->next != NULL)
X          xg->fl = xg->fl->next;
X      }
X    }
X    else
X    {
X      /*
X       * If not at end of curr list save current base,
X       * break links and load remaining bases onto the free list.
X      */
X      if (xg->curr->next != NULL)
X      {
X        xg->hend = xg->curr;
X        nback_update_label(xg);
X        xg->curr = xg->curr->next;
X        xg->fl = xg->curr;
X        xg->fl->prev = NULL;
X        while (xg->fl->next != NULL)
X          xg->fl = xg->fl->next;
X      }
X      xg->nhist_list++;
X    }
X    /* ensure fl ends have NULL pointers */
X    if (xg->fl != NULL)
X      xg->fl->next = NULL;
X    xg->curr = xg->hend;
X    /*
X     * re-form circular links
X    */
X    xg->curr->next = xg->hfirst;
X    xg->hfirst->prev = xg->curr;
X    xg->old_nhist_list = xg->nhist_list - 1;
X    xg->max_nhist_list = MAXHIST;
X    zero_tau(xg);
X    reset_cycleback_cmd(true, false, "F");
X
X    resens_everything(xg);
X    tour_event_handlers(xg, 1);
X    XtMapWidget(xg->tour_mouse);
X
X    if (xg->is_stepping)
X    {
X      set_ready_to_stop_now(1);
X      set_counting_to_stop(0);
X    }
X    xg->is_backtracking = False;
X    set_varsel_label(xg);
X  }
X
X  setToggleBitmap(w, xg->is_backtracking);
}
X
/* ARGSUSED */
XXtCallbackProc
tour_cycleback_cback(Widget w, xgobidata *xg, XtPointer callback_data)
/*
X * This routine allows direction changes during backtracking
*/
{
X  int do_it = 1;
X
X  if (xg->is_backtracking)
X  {
X    if (xg->backtrack_dir == BACKWARD)
X    {
X      /*
X       * If at the end of the list, ignore user request.
X      */
X      if (!xg->curr->next)
X      {
X        char message[MSGLENGTH];
X        do_it = 0;
X        sprintf(message, "Can\'t go forward; at end of list.\n");
X        show_message(message, xg);
X      }
X      else
X      {
X        reset_cycleback_cmd(false, false, "F");
X        xg->backtrack_dir = FORWARD;
X        if (!xg->is_stepping)
X          xg->curr = xg->curr->next;
X      }
X    }
X    else if (xg->backtrack_dir == FORWARD)
X    {
X      /*
X       * If at the end of the list, ignore user request.
X      */
X      if (!xg->curr->prev)
X      {
X        char message[MSGLENGTH];
X        do_it = 0;
X        sprintf(message, "Can\'t go backward; at end of list.\n");
X        show_message(message, xg);
X      }
X      else
X      {
X        reset_cycleback_cmd(false, false, "B");
X        xg->backtrack_dir = BACKWARD;
X        if (!xg->is_stepping)
X          xg->curr = xg->curr->prev;
X      }
X    }
X
X    if (do_it)
X    {
X      init_basis(xg);
X      if (!xg->is_stepping)
X        xg->nhist_list += xg->backtrack_dir;
X      retrieve_basis(xg);
X      /*
X       * Sets specific behaviour in tour_proc
X      */
X      got_new_basis = 1;
X      if (xg->is_stepping)
X      {
X        set_ready_to_stop_now(1);
X        set_counting_to_stop(0);
X      }
X      zero_tau(xg);
X    }
X  }
}
X
/* ARGSUSED */
XXtCallbackProc
tourhist_on_cback(Widget w, xgobidata *xg, XtPointer callback_data)
/*
X * This routine allows direction changes during backtracking
*/
{
X  xg->is_store_history = !xg->is_store_history;
X
X  setToggleBitmap(w, xg->is_store_history);
}
X
/* ARGSUSED */
XXtCallbackProc
tour_storbas_cback(Widget w, xgobidata *xg, XtPointer callback_data)
/*
X * This routine allows direction changes during backtracking
*/
{
X  store_basis(xg, xg->u);
}
X
/* ARGSUSED */
XXtCallbackProc
tour_step_cback(Widget w, xgobidata *xg, XtPointer callback_data)
/*
X * This routine invokes step control during touring
*/
{
X  if (!xg->is_stepping)
X  {
X    xg->is_stepping = True;
X    set_sens_go(true);
X    /*
X     * If paused or step = 0.0, set this to force the tour
X     * to go forward when pause is turned off or speed increased.
X    */
X    set_ready_to_stop_now(1);
X    set_counting_to_stop(0);
X  }
X  else
X  {
X    xg->is_stepping = False;
X    set_sens_go(false);
X    set_counting_to_stop(0);
X    set_ready_to_stop_now(0);
X    start_tour_proc(xg);
X  }
X  setToggleBitmap(w, xg->is_stepping);
}
X
/* ARGSUSED */
XXtCallbackProc
tour_step_go_cback(Widget w, xgobidata *xg, XtPointer callback_data)
/*
X * This routine is used during step control of tour to restart tour_proc
*/
{
X  set_counting_to_stop(1);
X  set_ready_to_stop_now(0);
X  start_tour_proc(xg);
}
X
/* ARGSUSED */
XXtCallbackProc
tour_local_cback(Widget w, xgobidata *xg, XtPointer callback_data)
/*
X * This routine invokes local scanning. That is setting the current position
X * to be an anchor basis, and sequentially seaching randomly around it.
X * u0-u1-u0-u2-u0-u3-........
*/
{
X  if (!xg->is_local_scan) {
X    xg->is_local_scan = True;
X    set_local_scan_dir_in(xg);
X    zero_tau(xg);
X    /*
X     * Desensitize backtrack, reinit, principal components and the
X     * interpolation menu.
X    */
X    reset_backtrack_cmd(false, false, false, false);
X    set_sens_reinit(false);
X    set_sens_princ_comp(xg, 0);
X    reset_interp_cmd(0);
X    tour_event_handlers(xg, 0);
X    XtUnmapWidget(xg->tour_mouse);
X    if (xg->is_princ_comp)
X      reset_princ_comp(True, xg); /* this needs to be done because
X                                   * desensitizing turns off the
X                                   * highlighting. */
X    /*
X     * if princ comp off then desensitize projection pursuit button.
X    */
X    if (!xg->is_princ_comp)
X      set_sens_pp_btn(xg, 0);
X    if (xg->is_pp_optimz)
X      turn_off_optimz(xg);
X    if (xg->is_pp)
X      set_sens_optimz(0);
X    if (xg->is_stepping)
X    {
X      set_ready_to_stop_now(1);
X      set_counting_to_stop(0);
X    }
X  }
X  else
X  {
X    xg->is_local_scan = False;
X    zero_tau(xg);
X    /*
X     * Resensitize backtrack, reinit and principal components
X     * and the interpolation menu.
X    */
X    reset_backtrack_cmd(false, false, true, false);
X    set_sens_reinit(true);
X    set_sens_princ_comp(xg, 1);
X    reset_interp_cmd(1);
X    tour_event_handlers(xg, 1);
X    XtMapWidget(xg->tour_mouse);
X    /*
X     * if princ comp off then resensitize projection pursuit button.
X    */
X    if (!xg->is_princ_comp)
X      set_sens_pp_btn(xg, 1);
X    if (xg->is_pp)
X      set_sens_optimz(1);
X    if (xg->is_stepping)
X    {
X      set_ready_to_stop_now(1);
X      set_counting_to_stop(0);
X    }
X  }
X  set_varsel_label(xg);
X
X  setToggleBitmap(w, xg->is_local_scan);
}
X
/* ARGSUSED */
XXtCallbackProc
tour_reinit_cback(Widget w, xgobidata *xg, XtPointer callback_data)
/*
X * This callback invokes scanning back through the history list.
*/
{
X  int i, j;
X
/* set u0 to be the first two variables, and zero taus */
X  for (i=0; i<2; i++)
X    for (j=0; j<xg->ncols_used; j++)
X      xg->u0[i][j] = 0.;
X  xg->u0[0][xg->tour_vars[0]] = 1.0;
X  xg->u0[1][xg->tour_vars[1]] = 1.0;
X  for (i=0; i<2; i++)
X    for (j=0; j<xg->ncols_used; j++)
X      xg->u[i][j] = xg->u0[i][j];
X  for (i=0; i<2; i++)
X    for (j=0; j<xg->ncols_used; j++)
X      xg->u1[i][j] = xg->u0[i][j];
X  init_V(xg);
X
X  zero_tau(xg);
X  zero_princ_angles(xg);
X  /*
X   * Reset tour history linked list.
X  */
X  xg->nhist_list = 2;
X  reinit_tour_hist(xg);
X  reset_backtrack_cmd(false, false, false, false);
X  (void)set_bt_firsttime();
X  nback_update_label(xg);
X
X  if (xg->is_pp_optimz || xg->tour_cont_fact == infinite)
X    xg->new_direction_flag = True;
X  span_planes(xg);
X  world_to_plane(xg);
X  plane_to_screen(xg);
X  plot_once(xg);
X  tour_var_lines(xg);
X  if (xg->is_pp)
X  {
X    xg->recalc_max_min = True;
X    reset_pp_plot();
X    pp_index(xg,0,1);
X  }
}
X
void
tour_save_coefs(Widget w, xgobidata *xg)
{
X  FILE *fp;
X  char *filename;
X  int j, k, m;
X  long foo;
X  float xfoo;
X  char Spath[50];
X  char message[MSGLENGTH];
X
X  filename = XtMalloc(132 * sizeof(char));
X  XtVaGetValues(w, XtNstring, &filename, NULL);
X
/*
X * In S, just write them out as a vector, column 0 then column 1.
*/
X  if (xg->data_mode == Sprocess)
X  {
X    (void) strcpy(Spath, Spath0);
X    (void) strcat(Spath, filename);
X    if ( (fp = fopen(Spath, "w")) == NULL)
X    {
X      sprintf(message,
X        "Failed to open the file '%s' for writing.\n", Spath);
X      show_message(message, xg);
X    }
X    else
X    {
X      /*
X       * "1" indicates that the following is an
X       * S data structure of one element.
X      */
X      (void) fprintf(fp, "%cS data%c", (char) 0 , (char) 1);
X      /*
X       * "3" indicates that the following is of type
X       * single; "4" would imply numeric, or double.
X      */
X      foo = (long) 3;
X      if (fwrite((char *) &foo, sizeof(foo), 1, fp) == 0)
X        fprintf(stderr, "error in tour_savecoefs_cback");
X      /*
X       * "2*ncols" says the following has "2*ncols" elements."
X       * "2*numvars_t" says the following has "2*numvars_t" elements."
X      */
X      if (xg->is_princ_comp)
X        foo = (long) 2*xg->numvars_t;
X      else
X        foo = (long) 2*xg->ncols_used;
X      if (fwrite((char *) &foo, sizeof(foo), 1, fp) == 0)
X        fprintf(stderr, "error in tour_savecoefs_cback");
X
X      if (xg->is_princ_comp)
X      {
X        sprintf(message,
X          "Printing coefficients for active variables of sphered data only.\n");
X        strcat(message,
X          "In order to use these, you need also to save sphered data.\n");
X        strcat(message,
X          "(See Options panel.)\n");
X        show_message(message, xg);
X        for (j=0; j<xg->numvars_t; j++)
X        {
X          for (k=0; k<2; k++)
X          {
X            m = xg->tour_vars[j];
X            xfoo = xg->u[k][m] / (xg->lim[m].max - xg->lim[m].min);
X            if (fwrite((char *) &xfoo, sizeof(xfoo), 1, fp) == 0)
X              fprintf(stderr, "error in tour_savecoefs_cback");
X          }
X        }
X      }
X      else
X      {
X        for (j=0; j<xg->ncols_used; j++)
X        {
X          for (k=0; k<2; k++)
X          {
X            xfoo = xg->u[k][j] / (xg->lim[j].max - xg->lim[j].min);
X            if (fwrite((char *) &xfoo, sizeof(xfoo), 1, fp) == 0)
X              fprintf(stderr, "error in tour_savecoefs_cback");
X          }
X        }
X      }
X      if (fclose(fp) == EOF)
X        fprintf(stderr, "tour_savecoefs_cback");
X    }
X  }
/*
X * In ascii, write out a two-column file.
*/
X  else if (xg->data_mode == ascii || xg->data_mode == binary) /* if not S */
X  {
X    if ( (fp = fopen(filename, "w")) == NULL)
X    {
X      sprintf(message,
X        "Failed to open the file  '%s' for writing.\n", filename);
X      show_message(message, xg);
X    }
X    else
X    {
X      if (xg->is_princ_comp)
X      {
X        sprintf(message,
X          "Printing coefficients for active variables of sphered data only.\n");
X        strcat(message,
X          "In order to use these, you need also to save sphered data.\n");
X        strcat(message,
X          "(See Options panel.)\n");
X        show_message(message, xg);
X
X        for (j=0; j<xg->numvars_t; j++)
X        {
X          m = xg->tour_vars[j];
X          (void) fprintf(fp, "%f %f\n",
X            xg->u[0][m] / (xg->lim[m].max - xg->lim[m].min),
X            xg->u[1][m] / (xg->lim[m].max - xg->lim[m].min));
X        }
X      }
X      else
X      {
X        for (j=0; j<xg->ncols_used; j++)
X          (void) fprintf(fp, "%f %f\n",
X            xg->u[0][j] / (xg->lim[j].max - xg->lim[j].min),
X            xg->u[1][j] / (xg->lim[j].max - xg->lim[j].min));
X      }
X      if (fclose(fp) == EOF)
X        fprintf(stderr, "tour_savecoefs_cback");
X    }
X  }
X
X  XtFree(filename);
X
/*
X * Restart interpolation or rotation after saving data.
*/
X  start_tour_proc(xg);
}
X
void
tour_save_hist(Widget w, xgobidata *xg)
{
X  FILE *fp;
X  char *filename;
X  int i, j, k;
X  long foo;
X  float xfoo;
X  char Spath[50];
X  hist_rec *base;
X  int nhist;
X
X  if (xg->is_backtracking)
X    nhist = xg->max_nhist_list;
X  else
X    nhist = xg->nhist_list;
/*
X * Build an array, ncols_used by 2, that will contain the coefficients
X * of rotation:  The x coefficients will be in column 0 and
X * the y coefficients in the column 1.
*/
X
X  filename = XtMalloc(132 * sizeof(char));
X  XtVaGetValues(w, XtNstring, &filename, NULL);
X
/*
X * In S, just write them out as a vector, column 0 then column 1.
*/
X  if (xg->data_mode == Sprocess)
X  {
X    (void) strcpy(Spath, Spath0);
X    (void) strcat(Spath, filename);
X    if ( (fp = fopen(Spath, "w")) == NULL)
X      fprintf(stderr, "tour_savehist_cback");
X    else
X    {
X      /*
X       * "1" indicates that the following is an
X       * S data structure of one element.
X      */
X      (void) fprintf(fp, "%cS data%c", (char) 0 , (char) 1);
X      /*
X       * "3" indicates that the following is of type
X       * single; "4" would imply numeric, or double.
X      */
X      foo = (long) 3;
X      if (fwrite((char *) &foo, sizeof(foo), 1, fp) == 0)
X        fprintf(stderr, "tour_savehist_cback");
X      /*
X       * "2*ncols_used" says the following has "2*ncols_used" elements."
X      */
X      foo = (long) 2*xg->ncols_used;
X      if (fwrite((char *) &foo, sizeof(foo), 1, fp) == 0)
X        fprintf(stderr, "tour_savehist_cback");
X
X      k = 1;
X      base = xg->hfirst;
X      j = 0;
X      while ((base->next != NULL) && (j <= nhist))
X      {
X        xfoo = k;
X        if (fwrite((char *) &xfoo, sizeof(xfoo), 1, fp) == 0)
X          fprintf(stderr, "tour_savehist_cback");
X
X        for (j=0; j<2; j++)
X        {
X          for (i=0; i<xg->ncols_used; i++)
X          {
X            xfoo = base->hist[j][i];
X            if (fwrite((char *) &xfoo, sizeof(xfoo), 1, fp) == 0)
X              fprintf(stderr, "tour_savehist_cback");
X          }
X        }
X        base = base->next;
X        k++;
X      }
X      if (fclose(fp) == EOF)
X        fprintf(stderr, "tour_savehist_cback");
X    }
X  }
/*
X * In ascii, write out a two-column file.
*/
X  else if (xg->data_mode == ascii || xg->data_mode == binary) /* if not S */
X  {
X    if ( (fp = fopen(filename, "w")) == NULL)
X    {
X      char message[MSGLENGTH];
X      sprintf(message,
X        "Failed to open the file  '%s' for writing.\n", filename);
X      show_message(message, xg);
X    }
X    else
X    {
X      j = 1;
X      base = xg->hfirst;
X      while ((base->next != NULL) && (j <= nhist))
X      {
X        (void) fprintf(fp,"%d\n",j);
X        for (i=0; i<xg->ncols_used; i++)
X        {
X          (void) fprintf(fp, "%f %f\n",
X                   base->hist[0][i], base->hist[1][i]);
X        }
X        base = base->next;
X        j++;
X      }
X      if (fclose(fp) == EOF)
X        (void) fprintf(stderr, "tour_savehist_cback: fclose failed\n");
X    }
X  }
X
X  XtFree(filename);
X
/*
X * Restart interpolation or rotation after saving data.
*/
X  start_tour_proc(xg);
}
X
void
tour_read_hist(Widget w, xgobidata *xg)
{
X  char *filename;
X  int j, k;
X  char str[100], newline[100];
X  int istr, ostr = -1;
X  float tmpf1, tmpf2;
X  FILE *fp;
X
X  filename = XtMalloc(132 * sizeof(char));
X  XtVaGetValues(w, XtNstring, (String) &filename, NULL);
X
X  if ( (fp = fopen(filename, "r")) == NULL)
X  {
X      char message[MSGLENGTH];
X      sprintf(message,
X        "Failed to open the file '%s' for reading.\n", filename);
X      show_message(message, xg);
X  }
X  else
X  {
X    if (xg->is_backtracking)
X      reset_backtrack_cmd(true, false, true, true);
X        /* just to make it easier to think about what needs to be
X           done with the linked list of bases */
X    k = 0;
X    if (fgets(str, 60, fp) == NULL)
X      fprintf(stderr, "error in tour_read_hist");
X    else
X    {
X      istr = atoi(str);
X      xg->nhist_list = 0;
X      reinit_tour_hist(xg);
X      /* ostr should have some initial value ?? */
X      while ((istr > 0) && (istr != ostr))
X      {
X        k++;
X        for (j=0; j<xg->ncols_used; j++)
X        {
X          (void) fgets(newline, 60, fp);
X          (void) sscanf(newline,"%f %f", &tmpf1, &tmpf2);
X          xg->u0[0][j] = tmpf1;
X          xg->u0[1][j] = tmpf2;
X        }
X        if (xg->is_store_history)
X          store_basis(xg, xg->u0); /* this sets up circular link,
X          and increments nhist_list */
X        if (k == 1)
X          xg->hfirst = xg->curr;
X        ostr = istr;
X        (void) fgets(str,60,fp);
X        istr = atoi(str);
X      }
X
X      if (xg->nhist_list > 1)
X      {
X        xg->max_nhist_list = xg->nhist_list;
X
/* set the first basis in the list to be curr and set u0 to this */
X        xg->curr = xg->hfirst;
X        for (k=0; k<2; k++)
X          for (j=0; j<xg->ncols_used; j++)
X            xg->u0[k][j]= xg->u[k][j] = xg->v0[k][j] = xg->curr->hist[k][j];
X        xg->nhist_list = 1;
X
X        zero_tau(xg);
X        span_planes(xg);
X        world_to_plane(xg);
X        plane_to_screen(xg);
X        plot_once(xg);
X        tour_var_lines(xg);
X        XFlush(display);
X        XSync(display, False);
X
X        xg->tour_hist_just_read = 1;
X        reset_backtrack_cmd(true, true, true, true);
X
X        if (xg->is_pp)
X        {
X          xg->recalc_max_min = True;
X          reset_pp_plot();
X          pp_index(xg,0,1);
X        }
X      }
X      else
X      {
X        char message[MSGLENGTH];
X        sprintf(message, "History file has only one record.\n");
X        show_message(message, xg);
X      }
X
X      if (fclose(fp) == EOF)
X        (void) fprintf(stderr, "tour_readhist_cback: fclose failed\n");
X    }
X  }
X
X  XtFree(filename);
X
/*
X * Restart interpolation or rotation after saving data.
*/
X  start_tour_proc(xg);
}
X
/* ARGSUSED */
XXtCallbackProc
choose_tour_io_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  int k;
X  int io_btn;
X
X  for (k=0; k<3; k++)
X  {
X    if (xg->tour_io_menu_btn[k] == w)
X    {
X      io_btn = k;
X      break;
X    }
X  }
X  stop_tour_proc(xg);
X
X  switch(io_btn)
X  {
X    case 0:
X      (void) strcpy(xg->save_type, SAVE_TOUR_COEFS );
X      break;
X    case 1:
X      (void) strcpy(xg->save_type, SAVE_TOUR_HIST );
X      break;
X    case 2:
X      (void) strcpy(xg->save_type, READ_TOUR_HIST );
X      break;
X   }
X
X  fname_popup(XtParent(w), xg);
}
X
/* ARGSUSED */
XXtCallbackProc
choose_tour_interp_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  int k;
X
X  stop_tour_proc(xg);
X  XtVaSetValues(tour_interp_menu_btn[tour_interp_btn],
X    XtNleftBitmap, None, NULL);
X  for (k=0; k<3; k++)
X  {
X    if (tour_interp_menu_btn[k] == w)
X    {
X      tour_interp_btn = k;
X      break;
X    }
X  }
X  XtVaSetValues(tour_interp_menu_btn[tour_interp_btn],
X    XtNleftBitmap, menu_mark, NULL);
X  if (!check_proximity(xg->u0,xg->u, xg->ncols)) {
X    copy_basis(xg->u, xg->u0, xg->ncols);
X    if (xg->is_store_history)
X      store_basis(xg, xg->u0);
X  }
X  zero_tau(xg);
X  start_tour_proc(xg);
X
}
X
/* ARGSUSED */
XXtCallbackProc
set_tour_link_state_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  int k;
X  extern Widget link_menu_cmd;
X  extern Widget link_menu_btn[];
X  extern char *link_menu_name[];
X  int link_menu_id;
X  enum link_state prev_tour_link_state = xg->tour_link_state;
X
X  for (k=0; k<3; k++)
X  {
X    if (w == link_menu_btn[k])
X    {
X      link_menu_id = k;
X      break;
X    }
X  }
X  
X  XtVaSetValues(link_menu_cmd,
X    XtNlabel, link_menu_name[link_menu_id],
X    NULL);
X
X  if (link_menu_id == 0)
X  {
X    xg->tour_link_state = send_state;
X    set_sens_tour_update(1);
X  }
X  else if (link_menu_id == 1)
X  {
X    xg->tour_link_state = receive;
X    set_sens_tour_update(0);
X  }
X  else if (link_menu_id == 2)
X  {
X    xg->tour_link_state = unlinked;
X    set_sens_tour_update(0);
X  }
X
X  /* If we were receiving, and we're not any more, then turn off receiving */
X  if (prev_tour_link_state == receive && xg->tour_link_state != receive)
X  {
X    init_basis(xg);   /* copies u to u0 */
X    zero_tau(xg);
X    set_sens_speed(true);
X    set_sens_reinit(true);
X    set_sens_step(true);
X    set_sens_localscan(true);
X    reset_backtrack_cmd(false, false, true, false);
X    set_sens_interp(true);
X    set_sens_io(xg, 1, 1, 1);
X    if (xg->is_pp)
X      set_sens_optimz(1);
X    start_tour_proc(xg);
X  }
X
X  /* If we weren't linked, and we are now, nothing needs to be done */
/* Huh, maybe not: dfs */
X  if (prev_tour_link_state != send_state && xg->tour_link_state == send_state)
X  {
X    if (xg->tour_senddata == (unsigned long *) NULL)
X      xg->tour_senddata = (unsigned long *)
X        XtRealloc((XtPointer) xg->tour_senddata,
X        (Cardinal) (4 + 5*xg->ncols) * sizeof(long));
X  }
X
X  /* If we were sending, and we're not now, we need to disown the selection */
X  if (prev_tour_link_state == send_state && xg->tour_link_state == unlinked)
X    XtDisownSelection( (Widget) xg->workspace,
X      (Atom) XG_NEWTOUR,
X      (Time) XtLastTimestampProcessed(display));
X
X  /* If we were not receiving, and we are now, set up to receive */
X  if (prev_tour_link_state != receive && xg->tour_link_state == receive)
X  {
X    stop_tour_proc(xg);
X    set_sens_speed(false);
X    set_sens_reinit(false);
X    if (xg->is_stepping)
X    {
X      turn_off_stepping();
X      set_sens_go(false);
X    }
X    set_sens_step(false);
X    if (xg->is_local_scan)
X      turn_off_local_scan(xg);
X    set_sens_localscan(false);
X    reset_backtrack_cmd(xg->is_backtracking, xg->is_backtracking,
X      false, xg->is_backtracking);
X    if (xg->is_backtracking)
X      set_sens_direction(False);
X    set_sens_interp(false);
X    set_sens_io(xg, 1, 1, 0);
X    if (xg->is_pp_optimz)
X      turn_off_optimz(xg);
X    set_sens_optimz(0);
X  }
X
X  /*
X   * state changes from 'send' to 'unlink' should have no effect on the
X   * variable selection panel, only changes in and out of the 'receive'
X   * state.
X  */
X  if ((prev_tour_link_state == receive && xg->tour_link_state != receive) ||
X      (prev_tour_link_state != receive && xg->tour_link_state == receive))
X  {
X    set_varpanel_for_receive_tour(xg);
X  }
}
X
/* ARGSUSED */
XXtCallbackProc
tour_update_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  if (xg->tour_link_state == send_state) {
X    xg->new_basis_ind = False;
X    OWN_TOUR_SELECTION ;
X    announce_tour_coefs(xg);
X  }
}
X
void
grand_tour_on(xgobidata *xg)
{
X  int j, k;
X
/*
X *  If this mode is currently selected, turn it off.
*/
X  if (xg->prev_plot_mode == GTOUR_MODE && xg->plot_mode != GTOUR_MODE)
X  {
X    xg->run_tour_proc = False;
X    tour_event_handlers(xg, 0);
X    if (xg->is_pp)
X      map_tour_pp_panel(False);
X    else if (xg->is_tour_section)
X      map_section_panel(False);
X    map_tour_panel(xg, False);
X
X    /* Free the vector used for linked touring */
X    if (xg->tour_senddata != (unsigned long *) NULL) {
X      XtFree((char *) xg->tour_senddata);
X      xg->tour_senddata = (unsigned long *) NULL;
X    }
X  }
X  /* Else turn it on */
X  else if (xg->prev_plot_mode != GTOUR_MODE &&
X           xg->plot_mode == GTOUR_MODE)
X  {
X    if (!xg->is_touring)
X    {
X      if (xg->is_plotting1d)
X        free_txtr_var();
X
X      if (xg->carry_vars)
X        carry_tour_vars(xg);
X      xg->is_plotting1d = xg->is_xyplotting = False;
X      xg->is_spinning = False;
X      xg->is_corr_touring = False;
X      xg->is_touring = True;
X
X      /* Reallocate the vector used for linked touring */
X      xg->tour_senddata = (unsigned long *)
X        XtRealloc((XtPointer) xg->tour_senddata,
X        (Cardinal) (4 + 5*xg->ncols) * sizeof(long));
X
X      /*
X       * All these data pipeline calls should occur <after>
X       * the mode state variables have been reset; that is,
X       * xg->is_touring = 1.
X      */
/*      if (xg->is_princ_comp)
X      {
X        update_lims(xg);
X        reset_var_labels(xg, PRINCCOMP_ON);
X      }*//* bug fix: sphering transformation */
X
X      /*
X       * xgobi only needs this line if xg->is_princ_comp,
X       * but xgvis needs it in any case.
X      */
X      update_world(xg);
X
X      find_plot_center(xg);
X      world_to_plane(xg);
X      plane_to_screen(xg);
X      plot_once(xg);
X      tour_var_lines(xg);
X
X      for (j=0; j<xg->ncols_used; j++)
X        xg->varchosen[j] = False;
X      for (j=0; j<xg->numvars_t; j++)
X      {
X        k = xg->tour_vars[j];
X        xg->varchosen[k] = True;
X      }
X
X      refresh_vboxes(xg);
X    }
X
X    tour_event_handlers(xg, 1);
X  
X    map_tour_panel(xg, True);
X    if (xg->is_pp)
X      map_tour_pp_panel(True);
X    else if (xg->is_tour_section)
X      map_section_panel(True);
X    set_varsel_label(xg);
X  
X    start_tour_proc(xg);
X  }
}
SHAR_EOF
  chmod 0644 'xgobi/src/tour_cbacks.c' ||
  $echo 'restore of' 'xgobi/src/tour_cbacks.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/tour_cbacks.c:' 'MD5 check failed'
d6341129339db7f2494010c841e9dd0f  xgobi/src/tour_cbacks.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/tour_cbacks.c'`"
    test 31586 -eq "$shar_count" ||
    $echo 'xgobi/src/tour_cbacks.c:' 'original size' '31586,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/f2c.h ==============
if test -f 'xgobi/src/f2c.h' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/f2c.h' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/f2c.h' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/f2c.h' &&
/* f2c.h  --  Standard Fortran to C header file */
X
/**  barf  [ba:rf]  2.  "He suggested using FORTRAN, and everybody barfed."
X
X	- From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */
X
#ifndef F2C_INCLUDE
#define F2C_INCLUDE
X
typedef long int integer;
typedef char *address;
typedef short int shortint;
typedef float real;
typedef double doublereal;
typedef struct { real r, i; } complex;
typedef struct { doublereal r, i; } doublecomplex;
typedef long int logical;
typedef short int shortlogical;
typedef char logical1;
typedef char integer1;
X
#define TRUE_ (1)
#define FALSE_ (0)
X
/* Extern is for use with -E */
#ifndef Extern
#define Extern extern
#endif
X
/* I/O stuff */
X
#ifdef f2c_i2
/* for -i2 */
typedef short flag;
typedef short ftnlen;
typedef short ftnint;
#else
typedef long flag;
typedef long ftnlen;
typedef long ftnint;
#endif
X
/*external read, write*/
typedef struct
{	flag cierr;
X	ftnint ciunit;
X	flag ciend;
X	char *cifmt;
X	ftnint cirec;
} cilist;
X
/*internal read, write*/
typedef struct
{	flag icierr;
X	char *iciunit;
X	flag iciend;
X	char *icifmt;
X	ftnint icirlen;
X	ftnint icirnum;
} icilist;
X
/*open*/
typedef struct
{	flag oerr;
X	ftnint ounit;
X	char *ofnm;
X	ftnlen ofnmlen;
X	char *osta;
X	char *oacc;
X	char *ofm;
X	ftnint orl;
X	char *oblnk;
} olist;
X
/*close*/
typedef struct
{	flag cerr;
X	ftnint cunit;
X	char *csta;
} cllist;
X
/*rewind, backspace, endfile*/
typedef struct
{	flag aerr;
X	ftnint aunit;
} alist;
X
/* inquire */
typedef struct
{	flag inerr;
X	ftnint inunit;
X	char *infile;
X	ftnlen infilen;
X	ftnint	*inex;	/*parameters in standard's order*/
X	ftnint	*inopen;
X	ftnint	*innum;
X	ftnint	*innamed;
X	char	*inname;
X	ftnlen	innamlen;
X	char	*inacc;
X	ftnlen	inacclen;
X	char	*inseq;
X	ftnlen	inseqlen;
X	char 	*indir;
X	ftnlen	indirlen;
X	char	*infmt;
X	ftnlen	infmtlen;
X	char	*inform;
X	ftnint	informlen;
X	char	*inunf;
X	ftnlen	inunflen;
X	ftnint	*inrecl;
X	ftnint	*innrec;
X	char	*inblank;
X	ftnlen	inblanklen;
} inlist;
X
#define VOID void
X
union Multitype {	/* for multiple entry points */
X	shortint h;
X	integer i;
X	real r;
X	doublereal d;
X	complex c;
X	doublecomplex z;
X	};
X
typedef union Multitype Multitype;
X
typedef long Long;	/* No longer used; formerly in Namelist */
X
struct Vardesc {	/* for Namelist */
X	char *name;
X	char *addr;
X	ftnlen *dims;
X	int  type;
X	};
typedef struct Vardesc Vardesc;
X
struct Namelist {
X	char *name;
X	Vardesc **vars;
X	int nvars;
X	};
typedef struct Namelist Namelist;
X
#define abs(x) ((x) >= 0 ? (x) : -(x))
#define dabs(x) (doublereal)abs(x)
#define min(a,b) ((a) <= (b) ? (a) : (b))
#define max(a,b) ((a) >= (b) ? (a) : (b))
#define dmin(a,b) (doublereal)min(a,b)
#define dmax(a,b) (doublereal)max(a,b)
X
/* procedure parameter types for -A and -C++ */
X
#define F2C_proc_par_types 1
#ifdef __cplusplus
typedef int /* Unknown procedure type */ (*U_fp)(...);
typedef shortint (*J_fp)(...);
typedef integer (*I_fp)(...);
typedef real (*R_fp)(...);
typedef doublereal (*D_fp)(...), (*E_fp)(...);
typedef /* Complex */ VOID (*C_fp)(...);
typedef /* Double Complex */ VOID (*Z_fp)(...);
typedef logical (*L_fp)(...);
typedef shortlogical (*K_fp)(...);
typedef /* Character */ VOID (*H_fp)(...);
typedef /* Subroutine */ int (*S_fp)(...);
#else
typedef int /* Unknown procedure type */ (*U_fp)();
typedef shortint (*J_fp)();
typedef integer (*I_fp)();
typedef real (*R_fp)();
typedef doublereal (*D_fp)(), (*E_fp)();
typedef /* Complex */ VOID (*C_fp)();
typedef /* Double Complex */ VOID (*Z_fp)();
typedef logical (*L_fp)();
typedef shortlogical (*K_fp)();
typedef /* Character */ VOID (*H_fp)();
typedef /* Subroutine */ int (*S_fp)();
#endif
/* E_fp is for real functions when -R is not specified */
typedef VOID C_f;	/* complex function */
typedef VOID H_f;	/* character function */
typedef VOID Z_f;	/* double complex function */
typedef doublereal E_f;	/* real function with -R not specified */
X
/* undef any lower-case symbols that your C compiler predefines, e.g.: */
X
#ifndef Skip_f2c_Undefs
#undef cray
#undef gcos
#undef mc68010
#undef mc68020
#undef mips
#undef pdp11
#undef sgi
#undef sparc
#undef sun
#undef sun2
#undef sun3
#undef sun4
#undef u370
#undef u3b
#undef u3b2
#undef u3b5
#undef unix
#undef vax
#endif
#endif
SHAR_EOF
  chmod 0644 'xgobi/src/f2c.h' ||
  $echo 'restore of' 'xgobi/src/f2c.h' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/f2c.h:' 'MD5 check failed'
07c79796b517c6eae7f4febe00fe5b57  xgobi/src/f2c.h
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/f2c.h'`"
    test 4184 -eq "$shar_count" ||
    $echo 'xgobi/src/f2c.h:' 'original size' '4184,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/make_axes.c ==============
if test -f 'xgobi/src/make_axes.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/make_axes.c' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/make_axes.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/make_axes.c' &&
/* make_axes.c */
/************************************************************
X *                                                          *
X *  Permission is hereby granted  to  any  individual   or  *
X *  institution   for  use,  copying, or redistribution of  *
X *  the xgobi code and associated documentation,  provided  *
X *  that   such  code  and documentation are not sold  for  *
X *  profit and the  following copyright notice is retained  *
X *  in the code and documentation:                          *
X *        Copyright (c) 1990, ..., 1996 Bellcore            *
X *                                                          *
X *  We welcome your questions and comments, and request     *
X *  that you share any modifications with us.               *
X *                                                          *
X *    Deborah F. Swayne            Dianne Cook              *
X *   dfs@research.att.com       dicook@iastate.edu          *
X *      (973) 360-8423    www.public.iastate.edu/~dicook/   *
X *                                                          *
X *                    Andreas Buja                          *
X *                andreas@research.att.com                  *
X *              www.research.att.com/~andreas/              *
X *                                                          *
X ************************************************************/
X
/*
X * The code in this file was written by Nancy Hubbell during the
X * summer of 1990.
*/
X
#include <stdio.h>
#include <math.h>
#include <string.h>
#include "xincludes.h"
#include "xgobitypes.h"
#include "xgobivars.h"
#include "xgobiexterns.h"
X
#define DEFAULTNTICKS 10;
X
static lcoords axes[3];
X
/* --------- Dynamic allocation section ----------- */
void
alloc_axis_arrays(xgobidata *xg)
/*
X * Dynamically allocate arrays.
*/
{
X  Cardinal nc = (Cardinal) xg->ncols;
X
X  xg->nicelim = (lims *) XtMalloc(nc * sizeof(lims));
X  xg->tickdelta = (float *) XtMalloc(nc * sizeof(float));
X  xg->deci = (int *) XtMalloc(nc * sizeof(int));
}
X
void
free_axis_arrays(xgobidata *xg)
/*
X * Dynamically free arrays.
*/
{
X  XtFree((XtPointer) xg->nicelim);
X  XtFree((XtPointer) xg->tickdelta);
X  XtFree((XtPointer) xg->deci);
}
X
/* --------- End of dynamic allocation section ----------- */
X
static void
make_axes(void)
/*
X * Calculate plane-coordinates of axes
*/
{
X  float precis = PRECISION1;
X
/*   .(axes[0].x, axes[0].y
X *   |
X *   |
X *   |
X *   |
X *   |
X *   |
X *   .----------------. (axes[2].x, axes[2].y)
X * (axes[1].x, axes[1].y)
*/
X
X  axes[2].x = (long)(precis + (0.1 * precis));
X  axes[0].y = (long)(precis + (0.1 * precis));
X
}
X
void
convert_axes(tickinfo *tix, xgobidata *xg)
/*
X * convert plane-axes to screen-axes
*/
{
X  int k;
X  long ltmp;
X  icoords tmin;
X
X  ltmp = axes[2].x + xg->shift_wrld.x;
X  xg->screen_axes[2].x = (int) ((ltmp * xg->is.x) >> EXP1);
X  xg->screen_axes[2].x += xg->mid.x;
X
X  /*
X   * Note:  this is a subtraction though it's an addition for the points.
X  */
X  ltmp = axes[0].y - xg->shift_wrld.y;
X  xg->screen_axes[0].y = (int) ((ltmp * xg->is.y) >> EXP1);
X  xg->screen_axes[0].y += xg->mid.y;
X
X
/*
X * Find the screen value of the minimum x and y coordinates,
X * using the fact that the minimum value in world coordinates for
X * every column is -PRECISION1.
*/
X
X
X  if (xg->is_xyplotting) {
X
X    /*
X     * Vertical axis
X    */
X
X    ltmp = (long) -PRECISION1 + xg->shift_wrld.x;
X    tmin.x = (int) ((ltmp * xg->is.x) >> EXP1);
X    tmin.x += xg->mid.x;
X
X    if (tmin.x - tix->screen[0].x < 10)
X      xg->screen_axes[0].x = xg->screen_axes[1].x = tix->screen[0].x - 10;
X    else
X      xg->screen_axes[0].x = xg->screen_axes[1].x = tix->screen[0].x;
X
X    /*
X     * Horizontal axis
X    */
X
X    ltmp = (long) -PRECISION1 - xg->shift_wrld.y;
X    tmin.y = (int) ((ltmp * xg->is.y) >> EXP1);
X    tmin.y += xg->mid.y;
X
X    if (tix->screen[0].y - tmin.y < 10)
X      xg->screen_axes[2].y = xg->screen_axes[1].y = tix->screen[0].y + 10;
X    else
X      xg->screen_axes[2].y = xg->screen_axes[1].y = tix->screen[0].y;
X
X  } else if (xg->is_plotting1d) {
X
X    int min, max;
X
X    /*
X     * Vertical axis:
X     * Find the minimum x screen value of the data and subtract 10.
X    */
X
X    min = xg->screen[0].x ;
X    for (k=1; k<xg->nrows_in_plot; k++)
X      min = MIN(xg->screen[ xg->rows_in_plot[k] ].x, min);
X    xg->screen_axes[0].x = xg->screen_axes[1].x = min - 10 ;
X
X    /*
X     * Horizontal axis:
X     * Find the maximum y screen value of the data and add 10.
X    */
X
X    max = xg->screen[0].y ;
X    for (k=1; k<xg->nrows_in_plot; k++)
X      max = MAX(xg->screen[ xg->rows_in_plot[k] ].y, max);
X    xg->screen_axes[1].y = xg->screen_axes[2].y = max + 10 ;
X  }
X
}
X
int
set_deci(float tickdelt)
/*
X * Figure out how many decimal places each tickdelta contains
*/
{
X  int j;
X  int is_set;
X  float deci;
X  double ddelt = (double) tickdelt;
X
X  j=0;
X  is_set = 0;
X  while (!is_set) {
X    if (j == 10 ||
X      (fabs(ddelt) > .1 &&
X        ( fabs(ddelt - floor(ddelt)) < .0001 ||
X          fabs(ddelt - ceil(ddelt)) < .0001 )))
X    {
X      deci = j;
X      is_set = 1;
X    }
X    else
X    {
X      ddelt = 10.0 * ddelt;
X      j++;
X    }
X  }
X  return(deci);
}
X
void
number_length(float xy_tick, int *length)
/* find the length of the number */
{
X  int j;
X  int is_num;
X  float tmpnum;
X
X  j = 0;
X  tmpnum = xy_tick;
X  is_num = 0;
X  while (!is_num) {
X    if ((int)tmpnum == 0) {
X      *length = j;
X      is_num = 1;
X    }
X    else {
X      tmpnum = tmpnum/10;
X      j++;
X    }
X  }
}
X
int
plot_too_big(xgobidata *xg)
/*
X * Find out if the labels are too close to the left or the bottom
X * of the plotting window.
*/
{
X  int shrink = 0;
/*
X * Make sure the code here matches add_x_axis() and add_y_axis() in
X * plot_once.c.
*/
X  if ((xg->screen_axes[1].x - xg->maxwidth - 7) < 5)
X    shrink = 1;
X
X  if (shrink == 0) {
X    if ((xg->screen_axes[1].y + 2*FONTHEIGHT(appdata.plotFont) + 14) >
X        (xg->max.y - 5) )
X    {
X       shrink = 1;
X    }
X  }
X
/*
X * make sure the plot can't get <too> small.
*/
X  if (xg->screen_axes[1].y - xg->screen_axes[0].y <= 20 ||
X      xg->screen_axes[2].x - xg->screen_axes[1].x <= 20)
X  {
X       shrink = 0;
X  }
X
X  return(shrink);
}
X
X
void
extend_axes(int xindx, int yindx, tickinfo *tix, xgobidata *xg)
/*
X * If the last tick is larger than the end of an axis, then extend the axis.
*/
{
X  int k;
X
X  Boolean add_vertical_axis = xg->is_xyplotting ||
X                         (xg->is_plotting1d && xg->plot1d_vars.y != -1);
X  Boolean add_horizontal_axis = xg->is_xyplotting ||
X                         (xg->is_plotting1d && xg->plot1d_vars.x != -1);
X
X  if (add_horizontal_axis) {
X    k = tix->screen[tix->nticks[xindx]-1].x;
X    if (xg->screen_axes[2].x < k)
X      xg->screen_axes[2].x = k;
X  }
X
X  if (add_vertical_axis) {
X    k = tix->screen[tix->nticks[yindx]-1].y;
X    if (xg->screen_axes[0].y > k)
X      xg->screen_axes[0].y = k;
X  }
}
X
int
find_minindex(lims *limits, xgobidata *xg)
/*
X * Find the index of the column that has the smallest lim[].min.
*/
{
X  int j, minindex;
X  float ftmp;
X
X  minindex = 0;
X  ftmp = limits[0].min;
X  for (j=0; j<xg->ncols_used; j++) {
X    if (limits[j].min < ftmp) {
X      ftmp = limits[j].min;
X      minindex = j;
X    }
X  }
X  return(minindex);
}
X
int
find_maxwidth(lims *limits, xgobidata *xg)
/*
X * Find the longest tick label for all of the variables, and
X * use maxwidth to determine whether the plot needs to be
X * repositioned.
*/
{
X  int j;
X  float tmp, ftmp;
X  char str[50];
X  int width, length, maxwidth;
X
X  maxwidth = 0;
X  for (j=0; j<xg->ncols_used; j++) {
X    tmp = xg->nicelim[j].min;
X    while (tmp + xg->tickdelta[j] <=
X         limits[j].max + xg->tickdelta[j]/3)
X    {
X      tmp = tmp + xg->tickdelta[j];
X    }
X
X    if ((fabs((double) tmp) >= 10000. ||
X       xg->deci[j] > 4) &&
X       tmp != 0.0)
X    {
X
X      /* Use exponential notation */
X      (void) number_length(tmp, &length);
X      ftmp = tmp/ (float) pow((double)10, (double)(length-1));
X      if (ftmp == (float)(int)ftmp)
X        (void) sprintf (str, "%.0e", tmp);
X      else
X        (void) sprintf (str, "%.2e", tmp);
X    }
X    else {
X      switch(xg->deci[j]) {
X        case 0:
X          (void) sprintf(str, "%3.0f", tmp);
X          break;
X        case 1:
X          (void) sprintf(str, "%3.1f", tmp);
X          break;
X        case 2:
X          (void) sprintf(str, "%3.2f", tmp);
X          break;
X        case 3:
X          (void) sprintf(str, "%3.3f", tmp);
X          break;
X        case 4:
X          (void) sprintf(str, "%3.4f", tmp);
X          break;
X      }
X    }
X    width = XTextWidth(appdata.plotFont, str, strlen(str));
X    if (width > maxwidth)
X      maxwidth = width;
X  }
X  return(maxwidth);
}
X
X
float
NiceValue(float x)
{
X  float fvalue;
X
X  if (x <= 0)
X    fvalue = 0.0;
X  else
X  {
X    double dx = (double) x;
X    double dilx, lx, vv1, vv2, vv3, vv4;
X
X    lx = log(dx) / log(10.0);
X    dilx = floor(lx);
X
X    vv1 = pow(10.0, dilx);
X    vv2 = vv1 * 2.0;
X    vv3 = vv1 * 5.0;
X    vv4 = vv1 * 10.0;
X
X    if ((fabs(dx - vv1) < fabs(dx - vv2))
X     && (fabs(dx - vv1) < fabs(dx - vv3))
X     && (fabs(dx - vv1) < fabs(dx - vv4)))
X      fvalue = (float) vv1;
X
X    else if ((fabs(dx - vv2) < fabs(dx - vv3))
X        && (fabs(dx - vv2) < fabs(dx - vv4)))
X      fvalue = (float) vv2;
X
X    else if (fabs(dx - vv3) < fabs(dx - vv4))
X      fvalue = (float) vv3;
X
X    else
X      fvalue = (float) vv4;
X  }
X
X  return(fvalue);
}
X
void
SetNiceRange(int j, xgobidata *xg)
/*
X * ticks.nticks[]: number of ticks used by each column
X * tickdelta: increment between subsequent ticks for each column
*/
{
X  float nicearg;
X
X  xg->ticks.nticks[j] = DEFAULTNTICKS;
X  nicearg = (xg->nicelim[j].max - xg->nicelim[j].min) /
X               (float) (xg->ticks.nticks[j] - 1) ;
X  xg->tickdelta[j] = NiceValue( nicearg );
X
X  xg->nicelim[j].min = (float) floor( (double) (
X    xg->nicelim[j].min / xg->tickdelta[j])) * xg->tickdelta[j];
X  xg->nicelim[j].max = (float) ceil( (double) (
X    xg->nicelim[j].max / xg->tickdelta[j])) * xg->tickdelta[j];
X
X  /* add .01 for rounding */
X  xg->ticks.nticks[j] = 1 +
X    (.01 + (xg->nicelim[j].max - xg->nicelim[j].min) / xg->tickdelta[j]);
X
X  /*
X   * Initialize ticks0.nticks[]
X  */
X  xg->ticks0.nticks[j] = xg->ticks.nticks[j];
}
X
void
generate_ticks(int xindx, int yindx, lims *limits, tickinfo *tix, xgobidata *xg)
/*
X *  Generate a vector of x ticks and y ticks.
*/
{
X  int j;
X  Boolean add_vertical_axis = xg->is_xyplotting ||
X                         (xg->is_plotting1d && xg->plot1d_vars.y != -1);
X  Boolean add_horizontal_axis = xg->is_xyplotting ||
X                         (xg->is_plotting1d && xg->plot1d_vars.x != -1);
X  
X
X  if (add_horizontal_axis) {
X    tix->xticks[0] = xg->nicelim[xindx].min;
X    j = 1;
X    while (tix->xticks[j-1] + xg->tickdelta[xindx] <=
X       limits[xindx].max + xg->tickdelta[xindx]/2)
X    {
X      tix->xticks[j] = tix->xticks[j-1] + xg->tickdelta[xindx];
X      if (j++ == NTICKS-1)
X      {
X        fprintf(stderr, "warning: (generate_ticks) too many x ticks\n");
X        break;
X      }
X    }
X    tix->nticks[xindx] = j;
X  }
X
X  if (add_vertical_axis) {
X    tix->yticks[0] = xg->nicelim[yindx].min;
X    j = 1;
X    while (tix->yticks[j-1] + xg->tickdelta[yindx] <=
X         limits[yindx].max + xg->tickdelta[yindx]/2)
X    {
X      tix->yticks[j] = tix->yticks[j-1] + xg->tickdelta[yindx];
X      if (j++ == NTICKS-1)
X      {
X        fprintf(stderr, "warning: (generate_ticks) too many y ticks\n");
X        break;
X      }
X    }
X    tix->nticks[yindx] = j;
X  }
}
X
void
scale_ticks(int xindx, int yindx, lims *limits, tickinfo *tix, xgobidata *xg)
/*
X * calculate plane-coordinates of ticks
*/
{
X  int j;
X  float tmpf;
X  float precis = PRECISION1;
X  Boolean add_vertical_axis = xg->is_xyplotting ||
X                         (xg->is_plotting1d && xg->plot1d_vars.y != -1);
X  Boolean add_horizontal_axis = xg->is_xyplotting ||
X                         (xg->is_plotting1d && xg->plot1d_vars.x != -1);
X
X  if (add_horizontal_axis) {
X    for (j=0; j<tix->nticks[xindx]; j++) {
X      tmpf = -1.0 + 2.0*(tix->xticks[j] - limits[xindx].min)
X        /(limits[xindx].max - limits[xindx].min);
X      tix->plane[j].x = (long) (precis * tmpf);
X    }
X  }
X
X  if (add_vertical_axis) {
X    for (j=0; j<tix->nticks[yindx]; j++) {
X      tmpf = -1.0 + 2.0*(tix->yticks[j] - limits[yindx].min)
X        /(limits[yindx].max - limits[yindx].min);
X      tix->plane[j].y = (long) (precis * tmpf);
X    }
X  }
}
X
void
convert_ticks(int xindx, int yindx, tickinfo *tix, xgobidata *xg)
/*
X * Convert plane-ticks to screen-ticks
*/
{
X  int j;
X  long ltmp;
X  Boolean add_vertical_axis = xg->is_xyplotting ||
X                         (xg->is_plotting1d && xg->plot1d_vars.y != -1);
X  Boolean add_horizontal_axis = xg->is_xyplotting ||
X                         (xg->is_plotting1d && xg->plot1d_vars.x != -1);
X
X  if (add_horizontal_axis) {
X    for (j=0; j<tix->nticks[xindx]; j++) {
X      ltmp = tix->plane[j].x + xg->shift_wrld.x;
X      tix->screen[j].x = (int) ((ltmp * xg->is.x) >> EXP1);
X      tix->screen[j].x += xg->mid.x;
X    }
X  }
X
X  if (add_vertical_axis) {
X    for (j=0; j<tix->nticks[yindx]; j++) {
X      /*
X       *  Note:  this is a subtraction though it's an addition for the points.
X      */
X      ltmp = tix->plane[j].y - xg->shift_wrld.y;
X      tix->screen[j].y = (int) ((ltmp * xg->is.y) >> EXP1);
X      tix->screen[j].y += xg->mid.y;
X    }
X  }
}
X
void
init_axes(xgobidata *xg, Boolean firsttime)
/*
X * When reading in data, use the limits determined using min-max
X * standardization method to define the axes for xy plotting.
*/
{
X  int j;
X
X  if (firsttime)
X    make_axes();
X
X  for (j=0; j<xg->ncols_used; j++)
X  {
X    /*
X     * Find the nicelim values, which are chosen to make reasonable
X     * placement of the tick marks.
X    */
X    xg->nicelim[j].min = xg->lim0[j].min;
X    xg->nicelim[j].max = xg->lim0[j].max;
X    SetNiceRange(j, xg);
X    xg->deci[j] = set_deci(xg->tickdelta[j]);
X  }
X  xg->minindex = find_minindex(xg->lim0, xg);
X  generate_ticks(xg->minindex, xg->minindex, xg->lim0, &xg->ticks0, xg);
X  scale_ticks(xg->minindex, xg->minindex, xg->lim0, &xg->ticks0, xg);
X
X  /* This part is redone when shift and scale change */
X  convert_ticks(xg->minindex, xg->minindex, &xg->ticks0, xg);
X  convert_axes(&xg->ticks0, xg);
X
X  xg->maxwidth = find_maxwidth(xg->lim0, xg);
X  while (plot_too_big(xg))
X  {
X    xg->scale0.x = .97 * xg->scale0.x;
X    xg->scale.x = xg->scale0.x;
X    xg->scale0.y = .97 * xg->scale0.y;
X    xg->scale.y = xg->scale0.y;
X
X    plane_to_screen(xg);
X    convert_ticks(xg->minindex, xg->minindex, &xg->ticks0, xg);
X    convert_axes(&xg->ticks0, xg);
X  }
}
X
void
init_tickdelta(xgobidata *xg)
{
/*
X * Initialize the limits and tickdelta for the current variables.
*/
X  int j;
X
X  for (j=0; j<xg->ncols_used; j++)
X  {
X    xg->nicelim[j].min = xg->lim[j].min;
X    xg->nicelim[j].max = xg->lim[j].max;
X    SetNiceRange(j, xg);
X    xg->deci[j] = set_deci(xg->tickdelta[j]);
X  }
}
X
void
init_ticks(icoords *vars, xgobidata *xg)
{
/*
X * Set the ticks for the current standardization method.
X *
X * Construct current ticks.
X * This is redone when choosing new variables or when
X * re-entering xyplotting.
*/
X  /* use minindex and ticks0 to set the axes */
X  convert_ticks(xg->minindex, xg->minindex, &xg->ticks0, xg);
X  convert_axes(&xg->ticks0, xg);
X  /* now generate and scale current ticks */
X  generate_ticks(vars->x, vars->y, xg->lim, &xg->ticks, xg);
X  scale_ticks(vars->x, vars->y, xg->lim, &xg->ticks, xg);
X  convert_ticks(vars->x, vars->y, &xg->ticks, xg);
X  extend_axes(vars->x, vars->y, &xg->ticks, xg);
}
X
/* For drawing ticks and axes; used in plot_once() */
X
int
check_x_axis(xgobidata *xg, int xvar, tickinfo *tix)
/*
X * Check whether the first ticks are to the left of the perpendicular axis.
X * If so, they will simply not be drawn.
*/
{
X  int i;
X  int xt = 0;
X
X  for (i=0; i<tix->nticks[xvar]; i++)
X    if (xg->screen_axes[1].x > tix->screen[i].x)
X      xt++;
X  return(xt);
}
X
int
check_y_axis(xgobidata *xg, int yvar, tickinfo *tix)
/*
X * Check whether the first ticks are to the left of the perpendicular axis.
X * If so, they will simply not be drawn.
*/
{
X  int i;
X  int yt = 0;
X
X  for (i=0; i<tix->nticks[yvar]; i++)
X    if (xg->screen_axes[1].y < tix->screen[i].y)
X      yt = yt + 1;
X  return(yt);
}
X
void
add_x_axis(xgobidata *xg, icoords *vars, int xstart, tickinfo *tix)
{
X  int j, src, dest, right_edge, modval;
X  Boolean modval_ok;
X  char str[50];
X  XPoint vpnts[2];
X  int nticks = tix->nticks[vars->x];
X  int *width;
X  char **lbls;
X
X  lbls = (char **) XtMalloc((Cardinal) nticks * sizeof (char *));
X  for (j=0; j<nticks; j++)
X    lbls[j] = (char *) XtMalloc(64 * sizeof(char));
X  width = (int *) XtMalloc((Cardinal) nticks * sizeof (int));
X
X  /*
X   * Draw x axis
X  */
X  for (j=0; j<2; j++) {
X    vpnts[j].x = xg->screen_axes[j+1].x;
X    vpnts[j].y = xg->screen_axes[j+1].y;
X  }
X  XDrawLines(display, xg->pixmap0, copy_GC, vpnts, 2, CoordModeOrigin);
X
X  /*
X   * Set modval, the interval for plotting tick labels, while
X   * copying tick labels into lbls
X  */
X
X  for (j=xstart; j<nticks; j++) {
X    find_tick_label(xg, vars->x, j, tix->xticks, str);
X    for (src=0, dest=0; src<(INT(strlen(str))+1); src++)
X      if (str[src] != ' ')
X        str[dest++] = str[src];
X    width[j] = XTextWidth(appdata.plotFont, str, strlen(str));
X    strcpy(lbls[j], str);
X  }
X
X  modval = 1;
X  while (true) {
X    modval_ok = true;
X    right_edge = 0;
X    for (j=xstart; j<nticks; j++) {
X      if (j % modval == 0) {
X        if (tix->screen[j].x - width[j]/2 <= right_edge+2) { /* 2: margin */
X          modval++;
X          modval_ok = false;
X          break;
X        } else right_edge = tix->screen[j].x + width[j]/2;
X      }
X    }
X
X    if (j == xstart || modval_ok) break;
X  }
X
X  for (j=xstart; j<nticks; j++) {
X    if (j % modval == 0) {
X      XDrawImageString(display, xg->pixmap0, copy_GC,
X        tix->screen[j].x - width[j]/2,
X        xg->screen_axes[1].y + FONTHEIGHT(appdata.plotFont)+7,
X        lbls[j], strlen(lbls[j]));
X      XDrawLine(display, xg->pixmap0, copy_GC,
X        tix->screen[j].x, xg->screen_axes[1].y,
X        tix->screen[j].x, xg->screen_axes[1].y+6);
X    } else {
X      XDrawLine(display, xg->pixmap0, copy_GC,
X        tix->screen[j].x, xg->screen_axes[1].y,
X        tix->screen[j].x, xg->screen_axes[1].y+3);
X    }
X  }
X
X  /*
X   * Draw X Axis label
X  */
X  strcpy(str, xg->collab_tform2[vars->x]);
X  XDrawImageString(display, xg->pixmap0, copy_GC,
X    xg->screen_axes[1].x +
X     (xg->screen_axes[2].x - xg->screen_axes[1].x)/2 - 
X       XTextWidth(appdata.plotFont, str, strlen(str))/2,
X    xg->screen_axes[1].y + 2*FONTHEIGHT(appdata.plotFont) + 14,
X    str,
X    strlen(str));
X
X  XtFree((XtPointer) width);
X  for (j=0; j<nticks; j++)
X    XtFree((XtPointer) lbls[j]);
X  XtFree((XtPointer) lbls);
X  return;
}
X
void
add_y_axis(xgobidata *xg, icoords *vars, int ystart, tickinfo *tix)
{
X  int j, top_edge, modval, height, src, dest;
X  Boolean modval_ok;
X  char str[50];
X  XPoint vpnts[2];
X  /*Boolean plot1d_vertically = (xg->plot1d_vars.y != -1);*/
X
X  int nticks = tix->nticks[vars->y];
X  /*int nxticks = (xg->is_plotting1d) ? 0 : tix->nticks[vars->x];*/
X  char **lbls;
X
X  lbls = (char **) XtMalloc((Cardinal) nticks * sizeof (char *));
X  for (j=0; j<nticks; j++)
X    lbls[j] = (char *) XtMalloc(64 * sizeof(char));
X
/*
X * Draw y axis
*/
X  for (j=0; j<2; j++) {
X    vpnts[j].x = xg->screen_axes[j].x;
X    vpnts[j].y = xg->screen_axes[j].y;
X  }
X  XDrawLines(display, xg->pixmap0, copy_GC, vpnts, 2, CoordModeOrigin);
X
X  /*
X   * Set modval, the interval for plotting tick labels, while
X   * copying tick labels into lbls
X  */
X
X  for (j=ystart; j<nticks; j++) {
X    find_tick_label(xg, vars->y, j, tix->yticks, str);
X    for (src=0, dest=0; src<(INT(strlen(str))+1); src++)
X      if (str[src] != ' ')
X        str[dest++] = str[src];
X    strcpy(lbls[j], str);
X  }
X
X  height = FONTHEIGHT(appdata.plotFont); 
X  modval = 1;
X  while (true) {
X    modval_ok = true;
X    top_edge = xg->plotsize.height;
X    for (j=ystart; j<nticks; j++) {
X      if (j % modval == 0) {
X        if (tix->screen[j].y + height/2 >= top_edge+2) { /* 2: margin */
X          modval++;
X          modval_ok = false;
X          break;
X        } else top_edge = tix->screen[j].y - height/2;
X      }
X    }
X
X    if (j == ystart || modval_ok) break;
X  }
X
X  height = (appdata.plotFont)->max_bounds.ascent; 
X  for (j=ystart; j<nticks; j++) {
X    if (j % modval == 0) {
X      XDrawImageString(display, xg->pixmap0, copy_GC,
X        xg->screen_axes[1].x -
X        XTextWidth(appdata.plotFont, lbls[j], strlen(lbls[j])) - 7,
X        tix->screen[j].y + height/2,
X        lbls[j], strlen(lbls[j]));
X
X      XDrawLine(display, xg->pixmap0, copy_GC,
X        xg->screen_axes[1].x,   tix->screen[j].y,
X        xg->screen_axes[1].x-6, tix->screen[j].y);
X    } else {
X      XDrawLine(display, xg->pixmap0, copy_GC,
X        xg->screen_axes[1].x,   tix->screen[j].y,
X        xg->screen_axes[1].x-3, tix->screen[j].y);
X    }
X  }
X
X  /*
X   * Draw Y Axis label
X  */
X  strcpy(str, xg->collab_tform2[vars->y]);
X  XDrawImageString(display, xg->pixmap0, copy_GC,
X    xg->screen_axes[0].x - strlen(str)/2 - 6,
X    xg->screen_axes[0].y - 10,
X    str,
X    INT(strlen(str)));
X
X  for (j=0; j<nticks; j++)
X    XtFree((XtPointer) lbls[j]);
X  XtFree((XtPointer) lbls);
X  return;
}
X
X
void
add_y_gridlines(xgobidata *xg, int jvar, int ystart, tickinfo *tix)
{
/*
X * Add grid lines to the plot.  Each mode will have to be handled
X * separately.
*/
X  int j;
X
X  /*
X   * Draw y grid lines
X  */
X  for (j=ystart; j<tix->nticks[jvar]; j++) {
X    XDrawLine(display, xg->pixmap0, copy_GC,
X      xg->screen_axes[1].x, tix->screen[j].y,
X      xg->screen_axes[2].x, tix->screen[j].y);
X  }
}
X
void
add_x_gridlines(xgobidata *xg, int jvar, int xstart, tickinfo *tix)
{
/*
X * Add grid lines to the plot.  Each mode will have to be handled
X * separately.
*/
X  int j;
X
X  /*
X   * Draw x grid lines
X  */
X  for (j=xstart; j<tix->nticks[jvar]; j++) {
X    XDrawLine(display, xg->pixmap0, copy_GC,
X      tix->screen[j].x, xg->screen_axes[0].y,
X      tix->screen[j].x, xg->screen_axes[1].y);
X  }
}
SHAR_EOF
  chmod 0644 'xgobi/src/make_axes.c' ||
  $echo 'restore of' 'xgobi/src/make_axes.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/make_axes.c:' 'MD5 check failed'
508b366d293b26a4c322a3fb5b175c9d  xgobi/src/make_axes.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/make_axes.c'`"
    test 22000 -eq "$shar_count" ||
    $echo 'xgobi/src/make_axes.c:' 'original size' '22000,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/rpc_spatial.c ==============
if test -f 'xgobi/src/rpc_spatial.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/rpc_spatial.c' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/rpc_spatial.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/rpc_spatial.c' &&
/***********************************************************************
X * Permission is hereby granted to any individual or institution       *
X * for use, copying, or redistribution of the AV2XGobi C code          *
X * and associated documentation, provided such code and documentation  *
X * are not sold for profit and the following copyright notice is       *
X * retained in the code and documentation:                             *
X *                                                                     *
X *   Copyright (c) 1995, 1996, 1997 Iowa State University              *
X *                                                                     *
X * We encourage you to share questions, comments and modifications.    *
X *                                                                     *
X *   Juergen Symanzik (symanzik@iastate.edu)                           *
X *   Dianne Cook (dicook@iastate.edu)                                  *
X *   James J. Majure (majure@iastate.edu)                              *
X *   Inna Megretskaia                                                  *
X *   Philip G. Jones                                                   *
X *                                                                     *
X ***********************************************************************/
/* !!!MS!!! */
#if defined RPC_USED || defined DCE_RPC_USED
X
#include <stdlib.h>
#include <sys/types.h>
#include <math.h>
#include "xincludes.h"
#include <X11/keysym.h>
#include "xgobitypes.h"
#include "xgobivars.h"
X
typedef struct{
X        int fir_obs;
X        int sec_obs;
X      } vario_lag_record;
X
static int l = sizeof (unsigned int) * 8;
X
X
X
/* getbit: get bit from position p in unsigned int x */
X
unsigned getbit (x, p)
X
unsigned int x;
int p;
X   
{ 
X  return (x>>p&1);
}
X
X
X
/* setbit1: set to 1 bit in position p */
X
void setbit1(x, p)
X
unsigned int *x;
int p;
X
{
X  *x = *x | (1<<p);
}
X
X
X
/* setbit0: set to 0 bit in position p */
X
void setbit0 (x, p)
X
unsigned int *x;
int p;
X
{
X  *x = *x & (~(1<<p));
}  
X
X
X
void ecdf (z, s, n, p, num_pts)
X
X     float **z;
X     int *s;
X     int n, p;
X     int *num_pts;
X
/*
X   z    = (p+1) x n matrix of attributes, 
X          column 0 contains ecdf values when done
X   s    = n x 1 vector of location indicators
X   n    = number of points in z
X   p    = number of attributes
X   num_pts = number of values for which s = 1         
X
X   z[][0] returns the vector of empirical cdf values evaluated at
X   the points in z indicated by the vector s (i.e., those
X   z-values for which s = 1). 
X   Ecdf values are present only for those points
X   corresponding to s = 1; thus z[i][0] = ecdf value only if
X   s[i] = 1; otherwise z[i][0] = 0.
*/
X
{
X  int j, incl_pt;
X  int i, k, indic;
X
X  *num_pts = 0;
X  for (i = 0; i < n; i++)
X    if (s[i])
X      (*num_pts)++;
X
X  for (k=0; k < n; k++)
X  {
X    if (!s[k])
X      z[k][0] = 0.0;
X    else
X    {
X      indic = 0;
X      for (i = 0; i < n; i++)
X	if (s[i])
X	{
X	  incl_pt = 1;
X	  for (j = 1; j < p + 1; j++)
X	    if (z[i][j] > z[k][j])
X	      {
X		incl_pt = 0;
X		break;
X	      }
X	  if (incl_pt)
X	    indic++;
X	}
X      z[k][0] = ((float) indic) / ((float) (*num_pts));
X    }
X  }
}
X
X
X
void weighted_ecdf (z, s, n, p, num_pts, weights)
X
X     float **z;
X     int *s;
X     int n, p;
X     int *num_pts;
X     double *weights;
X
/*
X   z    = (p+1) x n matrix of attributes, 
X          column 0 contains ecdf values when done
X   s    = n x 1 vector of location indicators
X   n    = number of points in z
X   p    = number of attributes
X   num_pts = number of values for which s = 1
X   weights = n x 1 vector of weights      
X
X   z[][0] returns the vector of empirical cdf values evaluated at
X   the points in z indicated by the vector s (i.e., those
X   z-values for which s = 1). 
X   Ecdf values are present only for those points
X   corresponding to s = 1; thus z[i][0] = ecdf value only if
X   s[i] = 1; otherwise z[i][0] = 0.
*/
X
{
X  int i, j, k, incl_pt;
X  double indic, totalweight;
X
X  *num_pts = 0;
X  totalweight = 0.0;
X  for (i = 0; i < n; i++)
X    if (s[i])
X    {
X      (*num_pts)++;
X      totalweight += weights[i];
X    }
X
X  if (totalweight == 0.0)
X    totalweight = 1.0;
X
X  for (k = 0; k < n; k++)
X  {
X    if (!s[k])
X      z[k][0] = 0.0;
X    else
X    {
X      indic = 0.0;
X      for (i = 0; i < n; i++)
X	if (s[i])
X	{
X	  incl_pt = 1;
X	  for (j = 1; j < p + 1; j++)
X	    if (z[i][j] > z[k][j])
X	      {
X		incl_pt = 0;
X		break;
X	      }
X	  if (incl_pt)
X	    indic += weights[i];
X	}
X      z[k][0] = (float) (indic / totalweight);
X    }
X  }
}
X
X
X
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
X * This function constructs binary map for all pairs of records      *
X * in the initial table ( bit, that corresponds to pair (i,j) is set *       
X * to 1 if sqrt((z[i][0]-z[j][0])^2+(z[i][1]-z[j][1])^2)<=maxdist or *
X * to 0 otherwise.                                                   *
X * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
X 
void construct_vario_lag_bitmap (n, p, z, miss, maxdist, num_prs, np_e_p1, np_e_p2, bin_map)
X
int n, p;
float **z;
short **miss;
float maxdist;
int *num_prs;
int *np_e_p1;
int *np_e_p2;
unsigned int **bin_map;
X
X
/* z - nx(p+2) matrix of attributes
X   z[i][1],z[i][2]         - coordinates of point #i
X   z[i][3], ..., z[i][p+2] - different statistics measured at this point
X   n       - number of rows in z
X   maxdist - cutoff parameter (we consider only those pairs of points
X             for which eucledian distance between them is smaller than 
X             or equal to maxdist)
X 
X   bin_map - binary matrix nxn, organized as integer
X             matrix n x ceil(n/sizeof(int))
*/
X 
{
X  double maxdist2 = maxdist * maxdist;
X  int i, j; 
X  double x, y;
X
X  
X  for (i = 0; i < n; i++)
X    for (j = i; j < n ; j++)
X      if (! miss[i][0] && ! miss[j][0] && ! miss[i][1] && ! miss[j][1])
X      { 
X        x = z[i][0] - z[j][0];
X        y = z[i][1] - z[j][1];
X
X        if ((x * x + y * y) <= maxdist2)
X        { 
X          setbit1 (&bin_map[i][j/l], j%l);
X          ++(*num_prs);
X          ++np_e_p1[i];
X          ++np_e_p2[j];
X
X          if (i != j)
X          {
X            setbit1 (&bin_map[j][i/l], i%l);
X            ++(*num_prs);
X            ++np_e_p1[j];
X            ++np_e_p2[i];
X          }
X        }
X      }  
} 
X
X
X
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
X *  This function constructs table of records corresponding to all       *
X *  pairs of points in initial table that satisfy the cutoff condition   *
X *  and calculates p*p+3 different statistics for each of these          *
X *  pairs of points.                                                     *
X * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
X
void  construct_vario_data (n, p, z, miss, datap, missingp,
X        missing_present, num_missing,
X        np_e_p1, np_e_p2, bin_map, w, ptarr1, ptarr2)
X
int n, p;
float **z;
short **miss;
float **datap;
short **missingp;
Boolean *missing_present;
int *num_missing;
int *np_e_p1;
int *np_e_p2;
unsigned int **bin_map;
vario_lag_record *w;
int **ptarr1;
int **ptarr2;
X
/* z - n x (p+2) matrix of attributes  
X   n - number of rows in z
X   p - number of statistics measured in each point
*/
X
{
X  int i, j, m, s, mm, ss, numb;
X  float a;
X  double dx, dy, d, sum, msum, gms;
X  int p1 = p + 1;
X  int p2 = p + 2;
X  int n_obs = 0;
X
X
X  for (i = 0; i < n; i++)
X    for (j = 0; j < n; j++)
X      if (getbit (bin_map[i][j/l], j%l))
X      {
X        w[n_obs].fir_obs = i;
X        w[n_obs].sec_obs = j;
X        dx = -z[i][0] + z[j][0];
X        dy = -z[i][1] + z[j][1];
X        d = sqrt (dx * dx + dy * dy);
X        datap[n_obs][0] = (float) d;
X        missingp[n_obs][0] = 0;
X
X        if ((d == 0) && (j == i))
X        {
X          datap[n_obs][1] = - 90.0;
X          missingp[n_obs][1] = 0;
X          datap[n_obs][2] = 0;
X          missingp[n_obs][2] = 0;
X          datap[n_obs][3] = - 0.5;
X          missingp[n_obs][3] = 0;
X        }
X        if ((d == 0) && (j != i))
X        {
X          datap[n_obs][1] = - 45.0;
X          missingp[n_obs][1] = 0;
X          datap[n_obs][2] = 0;
X          missingp[n_obs][2] = 0;
X          datap[n_obs][3] = 0.5;
X          missingp[n_obs][3] = 0;
X        }
X        if (d != 0)
X        { 
X          a = (float) (acos (dx / d) / M_PI * 180.0);
X          if (dy < 0)
X            a = 360.0 - a;
X          datap[n_obs][1] = a; 
X          missingp[n_obs][1] = 0;
X          datap[n_obs][2] = (float) (dy / d);
X          missingp[n_obs][2] = 0;
X          datap[n_obs][3] = (float) (dx / d);
X          missingp[n_obs][3] = 0;
X        }
X
X        numb = 4;
X        for (m = 2; m < p2; m++)
X          for (s = 2; s < p2; s++)
X          { 
X            if (! miss[i][m] && ! miss[j][s])
X            {
X              gms = fabs ((double) (z[i][m] - z[j][s]));
X              datap[n_obs][numb] = (float) sqrt (gms);
X              missingp[n_obs][numb] = 0;
X            }
X            else
X              {
X                datap[n_obs][numb] = 0.0;
X                missingp[n_obs][numb] = 1;
X                *missing_present = True;
X                *num_missing++;
X              }
X            numb++;
X          }            
X
X        sum = pow ((double) datap[n_obs][4], 4.0);
X        msum = missingp[n_obs][4];
X        for (m = 1; m < p; m++)
X        {
X          sum += pow ((double) datap[n_obs][4 + m * p1], 4.0);
X          msum += missingp[n_obs][4 + m * p1];
X        }
X        if (! msum)
X        {
X          datap[n_obs][numb] = (float) sqrt (sum);
X          missingp[n_obs][numb] = 0;
X        }
X        else
X          {
X            datap[n_obs][numb] = 0.0;
X            missingp[n_obs][numb] = 1;
X            *missing_present = True;
X            *num_missing++;
X          }
X
X        mm = np_e_p1[i]++;
X        ss = np_e_p2[j]++;
X        ptarr1[i][mm] = ptarr2[j][ss] = n_obs;
X
X        n_obs++; 
X      }
}                
X
X
X
void  construct_vario2_data (n, p, z, miss, datap, missingp,
X        missing_present, num_missing,
X        np_e_p1, np_e_p2, bin_map, w, ptarr1, ptarr2)
X
int n, p;
float **z;
short **miss;
float **datap;
short **missingp;
Boolean *missing_present;
int *num_missing;
int *np_e_p1;
int *np_e_p2;
unsigned int **bin_map;
vario_lag_record *w;
int **ptarr1;
int **ptarr2;
X
/* z - n x (p+2) matrix of attributes  
X   n - number of rows in z
X   p - number of statistics measured in each point
*/
X
{
X  int i, j, m, s, mm, ss, numb;
X  float a;
X  double dx, dy, d, sum, msum, gms;
X  int p2 = p + 2;
X  int n_obs = 0;
X
X
X  for (i = 0; i < n; i++)
X    for (j = 0; j < n; j++)
X      if (getbit (bin_map[i][j/l], j%l))
X      {
X        w[n_obs].fir_obs = i;
X        w[n_obs].sec_obs = j;
X        dx = -z[i][0] + z[j][0];
X        dy = -z[i][1] + z[j][1];
X        d = sqrt (dx * dx + dy * dy);
X        if ((dx > 0) || ((dx == 0) && (dy >= 0)))
X          datap[n_obs][0] = (float) d;
X        else
X          datap[n_obs][0] = (float) (- d);
X        missingp[n_obs][0] = 0;
X
X        if ((d == 0) && (j == i))
X        {
X          datap[n_obs][1] = - 90.0;
X          missingp[n_obs][1] = 0;
X          datap[n_obs][2] = 0;
X          missingp[n_obs][2] = 0;
X          datap[n_obs][3] = - 0.5;
X          missingp[n_obs][3] = 0;
X        }
X        if ((d == 0) && (j != i))
X        {
X          datap[n_obs][1] = - 45.0;
X          missingp[n_obs][1] = 0;
X          datap[n_obs][2] = 0;
X          missingp[n_obs][2] = 0;
X          datap[n_obs][3] = 0.5;
X          missingp[n_obs][3] = 0;
X        }
X        if (d != 0)
X        { 
X          a = (float) (acos (dx / d) / M_PI * 180.0);
X          if (dy < 0)
X            a = 360.0 - a;
X          datap[n_obs][1] = a; 
X          missingp[n_obs][1] = 0;
X          datap[n_obs][2] = (float) (dy / d);
X          missingp[n_obs][2] = 0;
X          datap[n_obs][3] = (float) (dx / d);
X          missingp[n_obs][3] = 0;
X        }
X
X        numb = 4;
X        for (m = 2; m < p2; m++)
X          for (s = m; s < p2; s++)
X          { 
X            if (! miss[i][m] && ! miss[j][s])
X            {
X              gms = fabs ((double) (z[i][m] - z[j][s]));
X              datap[n_obs][numb] = (float) sqrt (gms);
X              missingp[n_obs][numb] = 0;
X            }
X            else
X              {
X                datap[n_obs][numb] = 0.0;
X                missingp[n_obs][numb] = 1;
X                *missing_present = True;
X                *num_missing++;
X              }
X            numb++;
X          }            
X
X        sum = pow ((double) datap[n_obs][4], 4.0);
X        msum = missingp[n_obs][4];
X        for (m = 1; m < p; m++)
X        {
X          sum += pow ((double) datap[n_obs][4 + m * p - m * (m - 1) / 2], 4.0);
X          msum += missingp[n_obs][4 + m * p - m * (m - 1) / 2];
X        }
X        if (! msum)
X        {
X          datap[n_obs][numb] = (float) sqrt (sum);
X          missingp[n_obs][numb] = 0;
X        }
X        else
X          {
X            datap[n_obs][numb] = 0.0;
X            missingp[n_obs][numb] = 1;
X            *missing_present = True;
X            *num_missing++;
X          }
X
X        mm = np_e_p1[i]++;
X        ss = np_e_p2[j]++;
X        ptarr1[i][mm] = ptarr2[j][ss] = n_obs;
X
X        n_obs++; 
X      }
} 
X
X
void  construct_vario2_data_old (n, p, z, miss, datap, missingp,
X        missing_present, num_missing,
X        np_e_p1, np_e_p2, bin_map, w, ptarr1, ptarr2)
X
int n, p;
float **z;
short **miss;
float **datap;
short **missingp;
Boolean *missing_present;
int *num_missing;
int *np_e_p1;
int *np_e_p2;
unsigned int **bin_map;
vario_lag_record *w;
int **ptarr1;
int **ptarr2;
X
/* z - n x (p+2) matrix of attributes  
X   n - number of rows in z
X   p - number of statistics measured in each point
*/
X
{
X  int i, j, m, s, mm, ss, mm1, ss1, numb;
X  float a;
X  double dx, dy, d, sum, sum1, gms;
X  int p2 = p + 2;
X  int n_obs = 0;
X  int n_obs1; 
X
X
X  for (i = 0; i < n; i++)
X    for (j = i; j < n; j++)
X      if (i == j)
X        {
X          w[n_obs].fir_obs = i;
X          w[n_obs].sec_obs = i;
X          datap[n_obs][0] = 0.0;
X          datap[n_obs][1] = - 90.0;
X          datap[n_obs][2] = 0;
X          datap[n_obs][3] = - 0.5;
X
X          numb = 4;
X          for (m = 2; m < p2; m++)
X            for (s = m; s < p2; s++)
X            { 
X              gms = fabs ((double) (z[i][m] - z[j][s]));
X              datap[n_obs][numb] = (float) sqrt (gms);
X              numb++;
X            }            
X
X          sum = pow ((double) datap[n_obs][4], 4.0);
X          for (m = 1; m < p; m++)
X            sum += pow ((double) datap[n_obs][4 + m * p - m * (m - 1) / 2], 4.0);
X          datap[n_obs][numb] = (float) sqrt (sum); 
X
X          mm = np_e_p1[i]++;
X          ss = np_e_p2[j]++;
X          ptarr1[i][mm] = ptarr2[j][ss] = n_obs;
X
X          n_obs++;
X        } 
X      else if (getbit (bin_map[i][j/l], j%l))
X      {
X        n_obs1 = n_obs + 1;
X        w[n_obs].fir_obs = i;
X        w[n_obs].sec_obs = j;
X        w[n_obs1].fir_obs = j;
X        w[n_obs1].sec_obs = i;
X        dx = -z[i][0] + z[j][0];
X        dy = -z[i][1] + z[j][1];
X        d = sqrt (dx * dx + dy * dy);
X        if (dx < 0)
X          d = -d;
X        datap[n_obs][0] = (float) d;
X        datap[n_obs1][0] = (float) -d;
X    
X        if (d == 0)
X        {
X          datap[n_obs][1] = - 45.0;
X          datap[n_obs][2] = 0;
X          datap[n_obs][3] = 0.5;
X          datap[n_obs1][1] = - 45.0;
X          datap[n_obs1][2] = 0;
X          datap[n_obs1][3] = 0.5;
X        }
X        if (d != 0)
X        { 
X          a = (float) (acos (dx / d) / M_PI * 180.0);
X          if (dy < 0)
X            a = 180.0 - a;
X          datap[n_obs][1] = a; 
X          datap[n_obs][2] = (float) sin (2.0 * a);
X          datap[n_obs][3] = (float) cos (2.0 * a);
X          datap[n_obs1][1] = a; 
X          datap[n_obs1][2] = (float) sin (2.0 * a);
X          datap[n_obs1][3] = (float) cos (2.0 * a);
X        }
X
X        numb = 4;
X        for (m = 2; m < p2; m++)
X          for (s = m; s < p2; s++)
X          { 
X            gms = fabs ((double) (z[i][m] - z[j][s]));
X            datap[n_obs][numb] = (float) sqrt (gms);
X            gms = fabs ((double) (z[i][s] - z[j][m]));
X            datap[n_obs1][numb] = (float) sqrt (gms);
X            numb++;
X          }            
X
X        sum = pow ((double) datap[n_obs][4], 4.0);
X        sum1 = pow ((double) datap[n_obs1][4], 4.0);
X        for (m = 1; m < p; m++)
X        {
X          sum += pow ((double) datap[n_obs][4 + m * p - m * (m - 1) / 2], 4.0);
X          sum1 += pow ((double) datap[n_obs1][4 + m * p - m * (m - 1) / 2], 4.0);
X        }
X        datap[n_obs][numb] = (float) sqrt (sum);
X        datap[n_obs1][numb] = (float) sqrt (sum1); 
X
X        mm = np_e_p1[i]++;
X        ss = np_e_p2[j]++;
X        ptarr1[i][mm] = ptarr2[j][ss] = n_obs;
X        mm1 = np_e_p1[j]++;
X        ss1 = np_e_p2[i]++;
X        ptarr1[j][mm1] = ptarr2[i][ss1] = n_obs1;
X
X        n_obs = n_obs + 2; 
X      }
}                
X
X
X
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
X *  This function constructs table of records corresponding to all       *
X *  pairs of points in initial table that satisfy the cutoff condition   *
X *  and calculates p*2+2 different statistics for each of these          *
X *  pairs of points.                                                     *
X * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
X
void  construct_lag_data (n, p, z, miss, datap, missingp,
X        missing_present, num_missing,
X        np_e_p1, np_e_p2, bin_map, w, ptarr1, ptarr2)
X
int n, p;
float **z;
short **miss;
float **datap;
short **missingp;
Boolean *missing_present;
int *num_missing;
int *np_e_p1;
int *np_e_p2;
unsigned int **bin_map;
vario_lag_record *w;
int **ptarr1;
int **ptarr2;
X
/* z - n x (p+2) matrix of attributes  
X   n - number of rows in z
X   p - number of statistics measured in each point
*/
X
{
X  int i, j, m, s, mm, ss, numb;
X  float a;
X  double dx, dy, d, sum, gms;
X  int p2 = p + 2;
X  int n_obs = 0;
X
X
X  for (i = 0; i < n; i++)
X    for (j = 0; j < n; j++)
X      if (getbit (bin_map[i][j/l], j%l))
X      {
X        w[n_obs].fir_obs = i;
X        w[n_obs].sec_obs = j;
X        dx = -z[i][0] + z[j][0];
X        dy = -z[i][1] + z[j][1];
X        d = sqrt (dx * dx + dy * dy);
X        datap[n_obs][0] = (float) d;
X        missingp[n_obs][0] = 0;
X
X        if ((d == 0) && (j == i))
X        {
X          datap[n_obs][1] = - 90.0;
X          missingp[n_obs][1] = 0;
X          datap[n_obs][2] = 0;
X          missingp[n_obs][2] = 0;
X          datap[n_obs][3] = - 0.5;
X          missingp[n_obs][3] = 0;
X        }
X        if ((d == 0) && (j != i))
X        {
X          datap[n_obs][1] = - 45.0;
X          missingp[n_obs][1] = 0;
X          datap[n_obs][2] = 0;
X          missingp[n_obs][2] = 0;
X          datap[n_obs][3] = 0.5;
X          missingp[n_obs][3] = 0;
X        }
X        if (d != 0)
X        {         
X          a = (float) (acos (dx / d) / M_PI * 180.0);
X          if (dy < 0)
X            a = 360.0 - a;
X          datap[n_obs][1] = a;
X          missingp[n_obs][1] = 0;
X          datap[n_obs][2] = (float) (dy / d);
X          missingp[n_obs][2] = 0;
X          datap[n_obs][3] = (float) (dx / d); 
X          missingp[n_obs][3] = 0;
X        }
X
X        numb = 4;
X        for (m = 2; m < p2; m++)
X        { 
X          if (! miss[i][m])
X          {
X            datap[n_obs][numb] = z[i][m];
X            missingp[n_obs][numb] = 0;
X          }
X          else
X            {
X              datap[n_obs][numb] = 0.0;
X              missingp[n_obs][numb] = 1;
X              *missing_present = True;
X              *num_missing++;
X            }
X          numb++;
X
X          if (! miss[j][m])
X          {
X            datap[n_obs][numb] = z[j][m];
X            missingp[n_obs][numb] = 0;
X          }
X          else
X            {
X              datap[n_obs][numb] = 0.0;
X              missingp[n_obs][numb] = 1;
X              *missing_present = True;
X              *num_missing++;
X            }
X          numb++;
X        }            
X
X        mm = np_e_p1[i]++;
X        ss = np_e_p2[j]++;
X        ptarr1[i][mm] = ptarr2[j][ss] = n_obs;
X
X        n_obs++; 
X      }
}
X
#endif
SHAR_EOF
  chmod 0644 'xgobi/src/rpc_spatial.c' ||
  $echo 'restore of' 'xgobi/src/rpc_spatial.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/rpc_spatial.c:' 'MD5 check failed'
76506ccb5191f68503d5b6051c77efe8  xgobi/src/rpc_spatial.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/rpc_spatial.c'`"
    test 19979 -eq "$shar_count" ||
    $echo 'xgobi/src/rpc_spatial.c:' 'original size' '19979,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/initialize.c ==============
if test -f 'xgobi/src/initialize.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/initialize.c' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/initialize.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/initialize.c' &&
/* initialize.c */
/************************************************************
X *                                                          *
X *  Permission is hereby granted  to  any  individual   or  *
X *  institution   for  use,  copying, or redistribution of  *
X *  the xgobi code and associated documentation,  provided  *
X *  that   such  code  and documentation are not sold  for  *
X *  profit and the  following copyright notice is retained  *
X *  in the code and documentation:                          *
X *        Copyright (c) 1990, ..., 1996 Bellcore            *
X *                                                          *
X *  We welcome your questions and comments, and request     *
X *  that you share any modifications with us.               *
X *                                                          *
X *    Deborah F. Swayne            Dianne Cook              *
X *   dfs@research.att.com       dicook@iastate.edu          *
X *      (973) 360-8423    www.public.iastate.edu/~dicook/   *
X *                                                          *
X *                    Andreas Buja                          *
X *                andreas@research.att.com                  *
X *              www.research.att.com/~andreas/              *
X *                                                          *
X ************************************************************/
X
#include <stdio.h>
#include "xincludes.h"
#include "xgobitypes.h"
#include "xgobivars.h"
#include "xgobiexterns.h"
X
void
init_brush_colors(AppData *appdat)
{
X  XColor exact;
X  register int j;
X  Colormap cmap = DefaultColormap(display, DefaultScreen(display));
X
X  ncolors = NCOLORS;
X  color_names[0] = (char *) appdat->brushColor0;
X  color_names[1] = (char *) appdat->brushColor1;
X  color_names[2] = (char *) appdat->brushColor2;
X  color_names[3] = (char *) appdat->brushColor3;
X  color_names[4] = (char *) appdat->brushColor4;
X  color_names[5] = (char *) appdat->brushColor5;
X  color_names[6] = (char *) appdat->brushColor6;
X  color_names[7] = (char *) appdat->brushColor7;
X  color_names[8] = (char *) appdat->brushColor8;
X  color_names[9] = (char *) appdat->brushColor9;
X
X  for (j=0; j<ncolors; j++) {
X    if (XParseColor(display, cmap, color_names[j], &exact)) {
X      if (XAllocColor(display, cmap, &exact)) {
X        color_nums[j] = exact.pixel;
X      }
X    }
X    else
X      (void) fprintf(stderr, "finding %s failed\n", color_names[j]);
X  }
}
X
void
init_GCs(xgobidata *xg)
{
X  unsigned long bg, fg;
X  Window root_window = RootWindowOfScreen(XtScreen(xg->shell));
X  XGCValues gcv;
X  unsigned long mask =
X    GCForeground | GCBackground | GCFunction ;
X
X  /* 
X   * Some documentation suggests that this might result
X   * in some speedup; I see no difference.  dfs 3/93
X  */
X  gcv.graphics_exposures = False;
X
X  if (mono) {
X    plotcolors.fg = appdata.fg;
X    plotcolors.bg = appdata.bg;
X  }
X
X  XtVaGetValues(xg->vardraww[0],
X    XtNbackground, &bg,
X    XtNforeground, &fg,
X    NULL);
X
X  /*
X   * Create a Graphics Context with copy drawing logic.  It's used
X   * for drawing the bull's eye or target circle in the middle of
X   * the variable circles as well as the circles and variable bars.
X  */
X
X  gcv.foreground = fg;
X  gcv.background = bg;
X  gcv.function = GXcopy;
X  varpanel_copy_GC = XCreateGC(display, root_window, mask, &gcv);
X
X  /*
X   * Create a Graphics Context and give it xor drawing logic.
X   * This GC is used in drawing the variable circles, and its
X   * foreground and background colors come from xor-ing the colors
X   * of the form widget with a 1, I think.  The reason for using
X   * xor logic here is the need for rapid redrawing of lines during
X   * rotation and touring.
X  */
X  gcv.foreground = (unsigned long) 0xffffffff;
X  gcv.background = bg;
X  gcv.function = GXxor;
X  varpanel_xor_GC = XCreateGC(display, root_window, mask, &gcv);
X  XSetPlaneMask(display, varpanel_xor_GC, fg ^ bg);
X
X  /*
X   * Create a Graphics Context and give it copy drawing logic.
X   * The copy_GC and the clear_GC are used for drawing inside the
X   * plot window.  Their fg and bg colors come from the resource
X   * values of PlotWorkspace.
X  */
X  gcv.foreground = plotcolors.fg;
X  gcv.background = plotcolors.bg;
X  gcv.function = GXcopy;
X  copy_GC = XCreateGC(display, root_window, mask, &gcv);
X  /*
X   * Create another Graphics Context and give it copy drawing logic.
X  */
X  gcv.foreground = plotcolors.bg;
X  gcv.background = plotcolors.fg;
X  gcv.function = GXcopy;
X  clear_GC = XCreateGC(display, root_window, mask, &gcv);
X  /*
X   * Set font for drawing labels; needed for axis label computations.
X  */
X  XSetFont(display, copy_GC, appdata.plotFont->fid);
X  XSetFont(display, clear_GC, appdata.plotFont->fid);
}
X
void
init_plotwindow_vars(xgobidata *xg, int firsttime)
{
X  if (firsttime)
X  {
X    xg->max.x = (int) xg->plotsize.width;
X    xg->max.y = (int) xg->plotsize.height;
X    xg->minxy = MIN(xg->max.x, xg->max.y);
X    xg->mid.x = xg->max.x / 2;
X    xg->mid.y = xg->max.y / 2;
X  }
X  if (!mono)
X    xg->color_id = plotcolors.fg;
}
SHAR_EOF
  chmod 0644 'xgobi/src/initialize.c' ||
  $echo 'restore of' 'xgobi/src/initialize.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/initialize.c:' 'MD5 check failed'
94dc742ab14aae8b486ba33daabf8833  xgobi/src/initialize.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/initialize.c'`"
    test 5021 -eq "$shar_count" ||
    $echo 'xgobi/src/initialize.c:' 'original size' '5021,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/xgvis.h ==============
if test -f 'xgobi/src/xgvis.h' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/xgvis.h' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/xgvis.h' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/xgvis.h' &&
#ifndef XGVISINTERN
#define XGVIS_ extern 
#define INIT(x)
#else
#define XGVIS_
#define INIT(x) x
#endif
X
XXGVIS_ xgobidata xgobi;
X
typedef struct {
X    XFontStruct *Font;
X    int mdsDimension;
} PanelData, *PanelDataPtr;
XXGVIS_ PanelData panel_data;
X
XXGVIS_ Widget shell;
XXGVIS_ Widget form0;
XXGVIS_ Widget dims_left, dims_right;
X
/* Defines. */
#define METRIC    0
#define NONMETRIC 1
X
#define KRUSKALSHEPARD 0
#define CLASSIC        1
X
#define USER_SUPPLIED 0
#define LINK 1
#define ADJACENCY 2
#define EUCLIDIAN 3
#define MANHATTAN 4
#define MAHALANOBIS 5
#define DOTPROD 6
#define COSDIST 7
#define CLOSE 8
#define NDISTTYPES (CLOSE+1)
XXGVIS_ Widget apply_dist_cmd;
X
#define MAXDIMS 13
X
#define EPSILON .00001
X
/* Global variables. */ 
XXGVIS_ int xgv_is_running INIT(= 0);
XXGVIS_ int max_dims INIT(= 10);
XXGVIS_ int is_rescale  INIT(= 0);
XXGVIS_ Widget dist_cmd, dist_popup, dist_mgr, dist_types[NDISTTYPES] ;
XXGVIS_ int dist_type INIT(= 0) ;
X
XXGVIS_ enum {deflt, within, between, anchorscales, anchorfixed} mds_group_ind;
XXGVIS_ double mds_stepsize  INIT(= 0.02);
XXGVIS_ double mds_power  INIT(= 1.0);
XXGVIS_ double mds_isotonic_mix  INIT(= 1.0);
XXGVIS_ double mds_distpow INIT(= 1.0);
XXGVIS_ double mds_lnorm  INIT(= 2.0);
XXGVIS_ double mds_distpow_over_lnorm  INIT(= 0.5);
XXGVIS_ double mds_lnorm_over_distpow  INIT(= 2.0);
XXGVIS_ double mds_weightpow INIT(= 0.0);
XXGVIS_ double mds_within_between INIT(=1.0);
XXGVIS_ double mds_rand_select_val INIT(=1.0);
XXGVIS_ double mds_rand_select_new INIT(=FALSE);
XXGVIS_ double mds_perturb_val INIT(=1.0);
XXGVIS_ double mds_threshold_high  INIT(= 0.0);
XXGVIS_ double mds_threshold_low  INIT(= 0.0);  /* what initial value? */
XXGVIS_ int    mds_dims INIT(= 3);
XXGVIS_ int    mds_freeze_var INIT(= 0);
XXGVIS_ Boolean *anchor_group INIT(= NULL);
X
/* Used in scaling during each mds loop; set in reset_data */
XXGVIS_ double *config_dist   INIT(= NULL); /* spave vs time: store configuration distances to save recalculation */
XXGVIS_ double *raw_dist      INIT(= NULL); /* pointer, a vector version of dist.data */
XXGVIS_ double *weights       INIT(= NULL); /* formed only when mds_weightpow != 0. */
XXGVIS_ double *trans_dist    INIT(= NULL); /* transformed dissimilarities: power (metric), isotonic (nonmetric) */
XXGVIS_ int *trans_dist_index INIT(= NULL); /* index array for sort of raw_dist */
XXGVIS_ int *bl               INIT(= NULL); /* blocklengths for isotonic regression */
XXGVIS_ double *bl_w          INIT(= NULL); /* blockweights for isotonic regression (only when mds_weightpow != 0.) */
XXGVIS_ double *rand_sel      INIT(= NULL); /* random selection probabilities (only when mds_rand_select != 1.) */
X
XXGVIS_ int ndistances;
XXGVIS_ int num_active_dist;
XXGVIS_ double dist_max INIT (= 0.0);
XXGVIS_ double dist_min INIT (= 0.0);
X
XXGVIS_ double configuration_factor;
X
/* Used to hold matrix structures. */
struct array {
X  double **data;
X  int nrows;
X  int ncols;
};
X
/* Global data structures. */
XXGVIS_ struct array dist_orig;
XXGVIS_ struct array dist;
XXGVIS_ struct array edges_orig;
XXGVIS_ struct array edges;
XXGVIS_ struct array lines;
XXGVIS_ struct array *linesptr; /* points to lines, if present; else to edges */
XXGVIS_ struct array pos_orig;
XXGVIS_ struct array pos;
XXGVIS_ double *pos_mean INIT (=NULL);
XXGVIS_ double pos_scl INIT (=0.);
XXGVIS_ char **rowlab INIT(= NULL);	/* Row labels. */
XXGVIS_ char *xgv_basename;
X
/* for diagnostic xgobi, for distance residuals */
XXGVIS_ struct array diagnostics;
XXGVIS_ char **drowlab INIT(= NULL);
X
XXGVIS_ char pcolorname[128];
XXGVIS_ char lcolorname[128];
XXGVIS_ char glyphname[128];
X
XXGVIS_ int metric_nonmetric INIT(= METRIC);
XXGVIS_ int KruskalShepard_classic INIT(= KRUSKALSHEPARD);
SHAR_EOF
  chmod 0644 'xgobi/src/xgvis.h' ||
  $echo 'restore of' 'xgobi/src/xgvis.h' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/xgvis.h:' 'MD5 check failed'
60264376d62e7791f484842f42a81cd8  xgobi/src/xgvis.h
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/xgvis.h'`"
    test 3693 -eq "$shar_count" ||
    $echo 'xgobi/src/xgvis.h:' 'original size' '3693,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/xgvis.c ==============
if test -f 'xgobi/src/xgvis.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/xgvis.c' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/xgvis.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/xgvis.c' &&
/* UNIX includes. */
#include <sys/types.h>
#include <stdlib.h>
#include <stdio.h>
X
/* X includes. */
#include "xincludes.h"
#include <X11/keysym.h>
X
/* XGobi includes. */
# define XGOBIINTERN
#include "xgobitypes.h"
#include "xgobivars.h"
#include "xgobiexterns.h"
xgobidata xgobi;
/* Diagnostic xgobi */
xgobidata xgobi_diag;
#include "xgobitop.h"
X
/* XGvis includes. */
#define XGVISINTERN
#include "xgvis.h"
X
/* Globals. */
lims *olims, *olims0;  /* min and max values to prevent rescaling */
connect_lines *xg_lines;    /* Lines. */
int xg_nlines = 0;    /* Lines. */
X
static XtResource panel_resources[] = {
X  {"font", "Font", XtRFontStruct, sizeof(XFontStruct *),
X  XtOffset(PanelDataPtr, Font), XtRString, "*"},
/* Is it possible to set the initial embedding dimension this way? */
X  {"mdsDimension", "MdsDimension", XtRInt, sizeof(int),
X  XtOffset(PanelDataPtr, mdsDimension), XtRString, "3"},
};
X
String
xgvis_fallback_resources[] = {
X  "*font:          -*-helvetica-bold-r-*-*-14-*-*-*-*-*-*-*",
X
X  "XGvis*Scrollbar.Translations: #override \\n\
X    <Btn1Down>:   StartScroll(Continuous) MoveThumb() NotifyThumb() \\n\
X    <Btn1Motion>: MoveThumb() NotifyThumb() \\n\
X    <Btn3Down>:   HelpSelect()",
X
X  /*
X   * It's important that this be an XGVToggle, because if it's
X   * just a Toggle, it collides with the XGobi resources; I don't
X   * honestly know why.  dfs
X  */
X  "XGvis*XGVToggle.Translations: #override \\n\
X    <EnterWindow>:         highlight(Always) \\n\
X    <LeaveWindow>:         unhighlight() \\n\
X    <Btn1Down>, <Btn1Up>:  set()notify() \\n\
X    <Btn3Down>:            HelpSelect()",
X
X  "*background: Moccasin",
X  "*foreground: NavyBlue",
X  "*pointerColor: White",
X  "*MainPanel.background: DarkKhaki",
X  "*PlotWindow.background: blue4",
X  "*PlotWindow.foreground: white",
X  "*Command.background: SandyBrown",
X  "*Command.borderColor: NavyBlue",
X  "*Command.foreground: NavyBlue",
X  "*Toggle.background: SandyBrown",
X  "*Toggle.borderColor: NavyBlue",
X  "*Toggle.foreground: NavyBlue",
X  "*MenuButton.background: SandyBrown",
X  "*MenuButton.borderColor: NavyBlue",
X  "*MenuButton.foreground: NavyBlue",
X  /* Menu Icon */
X  "*MenuButton.leftBitmap: menu12",
X  "*Scrollbar.background: SandyBrown",
X  "*Scrollbar.borderColor: NavyBlue",
X  "*Scrollbar.foreground: NavyBlue",
X  NULL
};
X
/* resource database */
XXrmDatabase dispdb;
X
/* ARGSUSED */
void  xfer_brushinfo (xgobidata *xg)
{
}
X
extern void mds_once(Boolean);
extern void initialize_data(int argc, char *argv[]);
extern void reset_data(void);
extern double distance(double *, double *, int, double);
extern double set_distance_factor(void);
extern void init_dissim(void);
extern void draw_stress(void);
extern void make_xgvis_widgets(void);
extern void set_vgroups(void);
X
void
copy_pos_to_raw(xgobidata *xg)
{
X  int i, j;
X
X  for (i = 0; i < pos.nrows; i++) {
X    for (j = 0; j < pos.ncols-1; j++)
X      xg->raw_data[i][j] = (float) pos.data[i][j];
X  }
}
X
void
copy_diag_to_raw(xgobidata *xg)
{
X  int i, j;
X  
X  for (i = 0; i < diagnostics.nrows; i++) {
X    for (j = 0; j < diagnostics.ncols; j++)
X      xg->raw_data[i][j] = (float) diagnostics.data[i][j];
X  }
}
X
/*
An X program always has an event loop running, looking for
input:  usually user-generated mouse motions and so forth.  The
XXGobi event loop is called XGobiMainLoop() and it's in
xgobitop.h.
X
A work proc is a routine that runs once whenever the event loop
finds no events, a sort of run-while-idle routine.  In XGobi,
continuous processes such as rotation are handled using work
procs:  for example, if no user input is found, spin_once().
Usually, an X programmer doesn't write her own RunWorkProcs()
routine, but we found it necessary to do so for XGobi.
X
In XGvis, we added a work proc to the set used in XGobi to
handle the multi-dimensional scaling routine, and here's the
RunWorkProcs() routine that we use here.  You are very likely
to need to edit this for your routine.
*/
X
void
update_plot(xgobidata *xg)
{
X  /* copy pos.data to xg->raw_data */
X  copy_pos_to_raw(xg);
X  copy_raw_to_tform(xg);
X  /* commented out July 17, 2001, in an effort to make point motion smoother */
X  /*update_lims(xg);*/
X  update_world(xg);
X  world_to_plane(xg);
X  plane_to_screen(xg);
X
X  init_tickdelta(xg);
X  if (xg->is_xyplotting)
X    init_ticks(&xg->xy_vars, xg);
X  else if (xg->is_plotting1d)
X    init_ticks(&xg->plot1d_vars, xg);
}
X
void
update_diagnostics_plot(xgobidata *xg)
{
X  copy_diag_to_raw(xg);
X  copy_raw_to_tform(xg);
X  update_lims(xg);
X  update_world(xg);
X  world_to_plane(xg);
X  plane_to_screen(xg);
X
X  init_tickdelta(xg);
X  if (xg->is_xyplotting)
X    init_ticks(&xg->xy_vars, xg);
X  else if (xg->is_plotting1d)
X    init_ticks(&xg->plot1d_vars, xg);
}
X
/* ARGSUSED */
Boolean
RunWorkProcs(void *dummyArgc)
{
X  Boolean keepgoing = False;
X
X  if (xgobi.is_realized)
X  {
X    if (xgv_is_running)  /* is mds running? */
X    {
X      keepgoing = True;
X      mds_once(True);
X
X      update_plot(&xgobi);
X    }
X
X    if (RunWorkProc((xgobidata *) &xgobi))
X      keepgoing = True;
X
X    if (xgv_is_running) {
X      plot_once(&xgobi);
X    }
X  }
X
X  if (keepgoing)
X    return FALSE;
X  else
X    return TRUE;
}
X
void
AddXGobiFallbackResources (Display *dpy)
{
X  int i, len, varlen;
X  XrmDatabase xgobidb0;
X  char *xgfbstr;
X
X  /*
X   * Read the fallback_resources, now an array of strings,
X   * into a single string.
X  */
X  len = 2048;
X  varlen = 0;
X  xgfbstr = XtMalloc(len * sizeof(char));
X  i = 0;
X  while (fallback_resources[i] != NULL) {
X    strcpy(xgfbstr+varlen, (char *) fallback_resources[i]);
X    varlen += strlen(fallback_resources[i]);
X    i++;
X    strcpy(xgfbstr+varlen, "\n");
X    varlen += 1;
X
X    if (fallback_resources[i] != NULL) {
X      if (varlen + strlen(fallback_resources[i]) + 2 > len) {
X        /* printf("reallocating\n"); */
X        len = 2*len;
X        xgfbstr = XtRealloc(xgfbstr, len*sizeof(char));
X      }
X    }
X  }
X
X  /* Now I can read it in and merge it with the default */
X  xgobidb0 = XrmGetStringDatabase(xgfbstr);
X  if (xgobidb0) {
X    XrmMergeDatabases(xgobidb0, &dispdb);
X    XrmSetDatabase(dpy, dispdb);
X  }
}
X
X
void
AddUserResources(Display *dpy, String classname)
/*
X * Read in the resource file for the application named "classname".
X * Use the shell variables XFILESEARCHPATH and/or XUSERFILESEARCHPATH,
X * or use XAPPLRESDIR.  If none of those exists, return NULL.
*/
{
X  char *filename;
X  XrmDatabase rdb = NULL;
X  XrmDatabase xpathrdb = NULL, xuserpathrdb = NULL, xapplpathrdb = NULL;
X
X  char *xpath = getenv("XFILESEARCHPATH");
X  char *xuserpath = getenv("XUSERFILESEARCHPATH");
X  char *xapplpath = getenv("XAPPLRESDIR");
X
X  if (xpath) {
X    if ((filename = XtResolvePathname(dpy, NULL, classname, NULL,
X        xpath, NULL, 0, NULL)) != NULL)
X    {
X      xpathrdb = XrmGetFileDatabase(filename);
X    }
X  }
X
X  if (xuserpath) {
X    if ((filename = XtResolvePathname(dpy, NULL, classname, NULL,
X        xuserpath, NULL, 0, NULL)) != NULL)
X    {
X      xuserpathrdb = XrmGetFileDatabase(filename);
X    }
X  }
X
X  if (!xpath && !xuserpath) {
X    if ((filename = XtResolvePathname(dpy, NULL, classname, NULL,
X        xapplpath, NULL, 0, NULL)) != NULL)
X    {
X      xapplpathrdb = XrmGetFileDatabase(filename);
X    }
X  }
X
X  if (xpathrdb) {
X    if (xuserpathrdb) {
X      XrmMergeDatabases(xuserpathrdb, &xpathrdb);
X    }
X    rdb = xpathrdb;
X  }
X  else {
X    if (xuserpathrdb)
X      rdb = xuserpathrdb;
X    else if (xapplpathrdb)
X      rdb = xapplpathrdb;
X  }
X
X  if (rdb) {
X    XrmMergeDatabases(rdb, &dispdb);
X    XrmSetDatabase(display, dispdb);
X  }
}
X
X
/* resource database */
XXrmDatabase dispdb;
X
main(int argc, char *argv[])
{
X  int i, j;
X  char **col_name;
X  float **fdata;
X  /*XrmDatabase db;*/
X
/*
X * X Initialization
*/
X  shell = XtAppInitialize(&app_con, "XGvis", NULL, 0,
X    &argc, argv, xgvis_fallback_resources, NULL, 0);
X  display = XtDisplay(shell);
X  XtAppAddActions(app_con, added_actions, XtNumber(added_actions));
X  find_mono();
X
/* More X stuff. */
X  dispdb = XrmGetDatabase(display);
X  /*XrmPutFileDatabase(dispdb, "/usr/dfs/xgvis/sgi/DB0");*/
X  AddXGobiFallbackResources (display);
X  /* db = XrmGetDatabase(display); */
X  /*XrmPutFileDatabase(db, "/usr/dfs/xgvis/sgi/DB1");*/
X  AddUserResources(display, "XGobi");
X  /* db = XrmGetDatabase(display); */
X  /*XrmPutFileDatabase(db, "/usr/dfs/xgvis/sgi/DB2");*/
X  XtGetApplicationResources(shell, &panel_data, panel_resources, 
X    XtNumber(panel_resources), NULL, 0);
X
X  /* db = XrmGetDatabase(display); */
X  /*XrmPutFileDatabase(db, "/usr/dfs/xgvis/sgi/DB3");*/
X
X  /* Allow the embedding dimension to be reset from the resources file */
X  /*mds_dims = panel_data.mdsDimension;*/
X
X  /* ... but probably the command line is most useful */
X  initialize_data(argc, argv);
X  reset_data();    /* Get fresh data. */
X
/*
X * Set up the control panel
*/
X  if (mono) {
X    /* These haven't yet been initialized at this point */
X    appdata.fg = BlackPixelOfScreen(XtScreen(shell));
X    appdata.bg = WhitePixelOfScreen(XtScreen(shell));
X  }
X
X  make_xgvis_widgets();
X
X  XtRealizeWidget(shell);
X
X  xgobi.std_type = 0;
X  /*xgobi.std_width = 2.0;*/  /* obsolete */
X  xgobi.is_iconified = False;
X  xgobi.data_mode = ascii;
X
/* Use more appropriate variable labels in XGobi */
X  col_name = (char **) XtMalloc(
X    (Cardinal) MAXDIMS * sizeof (char *));
X  for (i=0; i<MAXDIMS; i++) {
X    col_name[i] = (char *) XtMalloc(
X      (Cardinal) 32 * sizeof(char));
X    sprintf(col_name[i], "Dim %d", i+1);
X  }
X
/*
X * I'm using doubles internally now, so I have to initialize
X * a float data array for xgobi -- I can free it once xgobi
X * has been initialized.
*/
X
X  fdata = (float **) XtMalloc((unsigned) pos.nrows * sizeof(float *));
X  for (i=0; i<pos.nrows; i++) {
X    fdata[i] = (float *) XtMalloc((unsigned) pos.ncols * sizeof(float));
X    for (j=0; j<pos.ncols; j++)
X      fdata[i][j] = (float) pos.data[i][j];
X  }
X
/*
Boolean datapflag  -- from datap or from a file
char *data_in  -- NULL for us; usually a filename
float **datap  -- pointer to data
char *title -- the title for the XGobi window
short **missingp,
Boolean mv_missing_values_present -- unnecessary argument
Boolean mv_is_missing_values_xgobi
int mv_nmissing,
int nr, nc,
char** rowp, colp,
int nlinks
connect_lines * connecting_lines,
xgobidata * xg
Widget parent
*/
X  if (make_xgobi (True, (char *) NULL, fdata, "xgvis display",
X    False, (short **) NULL, False, 0,
X    pos.nrows, rowlab, pos.ncols, col_name,
X    xg_nlines, xg_lines,
X    &xgobi, shell, False /*don't plot yet*/) == 0)
X  {
X    return(0);
X  }
X  else {
X    /* A few things that must be done after xgobi is initiated */
/*
X * Setting height seems to be entirely ineffective *
X *
X *  Dimension hgt1, hgt2;
X *  extern Widget mds_dims_label;
X *  XtVaGetValues(dims_left, XtNheight, &hgt1, NULL);
X *  XtVaGetValues(mds_dims_label, XtNheight, &hgt2, NULL);
*/
X    XSync(display, False);
X
X    for (i=0; i<pos.nrows; i++)
X      XtFree((char *) fdata[i]);
X    XtFree((char *) fdata);
X
X    /* addsuffix = True */
X    if (strlen(pcolorname) == 0) sprintf(pcolorname, "%s", xgv_basename);
X    if (strlen(lcolorname) == 0) sprintf(lcolorname, "%s", xgv_basename);
X    if (strlen(glyphname) == 0) sprintf(glyphname, "%s", xgv_basename);
X
X    read_point_colors(pcolorname, True, True, &xgobi);
X    read_point_glyphs(glyphname, True, True, &xgobi);
X    read_line_colors(lcolorname, True, True, &xgobi);
X
X    set_vgroups();
X    update_lims(&xgobi);
X    update_world(&xgobi);
X    world_to_plane(&xgobi);
X    plane_to_screen(&xgobi);
X
X    init_tickdelta(&xgobi);
X    init_ticks(&xgobi.xy_vars, &xgobi);
X    plot_once(&xgobi);
X    /* seems like a kludge, but there's another plot_once called
X     * async afterwards which makes lines not show up */
X    xgobi.got_new_paint = True;
X
X    mds_once(False);
X    draw_stress();  /* initialize the stress plot */
X
X    /* initialize the dissimilarity plot */
X    init_dissim();
X
X    XtVaSetValues(dims_left,
X      XtNbitmap, (Pixmap) leftarr,
X      XtNborderColor, (Pixel) appdata.fg,
X      NULL);
X    XtVaSetValues(dims_right,
X      XtNbitmap, (Pixmap) rightarr,
X      XtNborderColor, (Pixel) appdata.fg,
X      NULL);
X
X    /* addsuffix = True */
/*
X    if (strlen(pcolorname) == 0) sprintf(pcolorname, "%s", xgv_basename);
X    if (strlen(lcolorname) == 0) sprintf(lcolorname, "%s", xgv_basename);
X    if (strlen(glyphname) == 0) sprintf(glyphname, "%s", xgv_basename);
X
X    read_point_colors(pcolorname, True, True, &xgobi);
X    read_point_glyphs(glyphname, True, True, &xgobi);
X    read_line_colors(lcolorname, True, True, &xgobi);
*/
X
X    /*
X     * I can't seem to make this work with resource files, so
X     * I'm going to override the resources here.  Ugly in principle,
X     * but probably desirable in practice.
X    */
X    xgobi.is_axes = False;
X    if (edges_orig.nrows > 0 || lines.nrows > 0) {
X      xgobi.connect_the_points = True;
X      xgobi.plot_the_arrows = False;
X    }
X    set_display_menu_marks(&xgobi);
X
X
X    XGobiMainLoop(&xgobi);
X  }
X
X  return 1;
}
SHAR_EOF
  chmod 0644 'xgobi/src/xgvis.c' ||
  $echo 'restore of' 'xgobi/src/xgvis.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/xgvis.c:' 'MD5 check failed'
9eab0c287ae32bb1c5a5cdd41ac6df43  xgobi/src/xgvis.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/xgvis.c'`"
    test 12943 -eq "$shar_count" ||
    $echo 'xgobi/src/xgvis.c:' 'original size' '12943,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/rpc_vars.h ==============
if test -f 'xgobi/src/rpc_vars.h' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/rpc_vars.h' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/rpc_vars.h' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/rpc_vars.h' &&
/************************************************************************/
/*                                                                      */
/* File "rpc_vars.h"                                                    */
/*                                                                      */
/* Author : Martin Schneider, Juergen Symanzik                          */
/* Date   : 28/07/99                                                    */
/*                                                                      */
/************************************************************************/
X
#ifndef PROGINTERN
#define PROG_ extern
#else
#define PROG_
#endif
X
#ifdef DEBUG
X
#define DTEXT(str) fprintf(stderr,str)
#define DTEXT1(str,p1) fprintf(stderr,str,p1)
#define DTEXT2(str,p1,p2) fprintf(stderr,str,p1,p2)
X
#else
X
#define DTEXT(str)
#define DTEXT1(str,p1)
#define DTEXT2(str,p1,p2)
X
#endif
X
#ifdef RPC_USED
X
#include <rpc/rpc.h>
/*
X * You might want some global variables
X */
PROG_ unsigned long xg_server_number /* previously av_client_number */;
PROG_ unsigned long av_server_number;
PROG_ unsigned long xpl_server_number;
PROG_ unsigned long vg_server_number;
PROG_ int av_server_id;
PROG_ int xpl_server_id;
PROG_ int vg_server_id;
PROG_ int is_running;
X
#endif
X
X
#ifdef DCE_RPC_USED
X
#include <dce/dce.h>
#include <dce/pthread.h>
#include "rpc_dce.h"
#include "rpc_dceerror.h"
X
/* For the xgobi server */
PROG_ pthread_mutex_t mutex;
PROG_ pthread_t t_handle;
PROG_ unsigned char *pszProtocolSequence[100];
PROG_ unsigned char *pszEndpoint;
PROG_ unsigned int   cMaxCalls;
PROG_ rpc_binding_vector_p_t pbvBindings;
PROG_ int is_running;
X
#define MAX_CALL_THREADS 10
/* For the RPC-calls xgobi->WorldView (f.i.) */
PROG_ unsigned char pszNWAddressCl[100];
PROG_ pthread_mutex_t mutexCl;
PROG_ anzThreads;
/* valid values starting always at index 0 */
PROG_ pthread_t t_handles_client[MAX_CALL_THREADS];
X
X
#endif
X
SHAR_EOF
  chmod 0644 'xgobi/src/rpc_vars.h' ||
  $echo 'restore of' 'xgobi/src/rpc_vars.h' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/rpc_vars.h:' 'MD5 check failed'
a825df0d41a73cbfb5e226dcc17dfeb9  xgobi/src/rpc_vars.h
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/rpc_vars.h'`"
    test 1931 -eq "$shar_count" ||
    $echo 'xgobi/src/rpc_vars.h:' 'original size' '1931,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/show_message.c ==============
if test -f 'xgobi/src/show_message.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/show_message.c' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/show_message.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/show_message.c' &&
/************************************************************
X *                                                          *
X *  Permission is hereby granted  to  any  individual   or  *
X *  institution   for  use,  copying, or redistribution of  *
X *  the xgobi code and associated documentation,  provided  *
X *  that   such  code  and documentation are not sold  for  *
X *  profit and the  following copyright notice is retained  *
X *  in the code and documentation:                          *
X *        Copyright (c) 1990, ..., 1996 Bellcore            *
X *                                                          *
X *  We welcome your questions and comments, and request     *
X *  that you share any modifications with us.               *
X *                                                          *
X *    Deborah F. Swayne            Dianne Cook              *
X *   dfs@research.att.com       dicook@iastate.edu          *
X *      (973) 360-8423    www.public.iastate.edu/~dicook/   *
X *                                                          *
X *                    Andreas Buja                          *
X *                andreas@research.att.com                  *
X *              www.research.att.com/~andreas/              *
X *                                                          *
X ************************************************************/
X
#include <stdio.h>
#include <string.h>
#include "xincludes.h"
#include "xgobitypes.h"
#include "xgobivars.h"
#include "xgobiexterns.h"
X
/* ARGSUSED */
XXtCallbackProc
dismiss_message_cback(w, popup, cback_data)
X  Widget w;
X  XtPointer *popup;
X  XtPointer cback_data;
{
X  Widget parent = (Widget) popup;
X  XtDestroyWidget(parent);
}
X
void
show_message(String message, xgobidata *xg)
{
X  Widget popup, frame, text, done;
X  Dimension width, height;
X  Dimension wksp_width, wksp_height;
X  Position x, y;
X  int nreturns;
X  int i, j, nchars, start;
X  Widget shell = xg->shell;
X
X  /*
X   * Figure out the necessary width and height of the window
X   * to contain the message.
X  */
X  for (i=0, j=0, nchars=0, nreturns=0, start=0; i<(int)strlen(message); i++)
X  {
X    j++ ;
X    if (message[i] == '\n')
X    {
X      if (j > nchars)
X      {
X        nchars = j ;
X        start = i - j + 1;
X      }
X      nreturns++ ;
X      j = 0;
X    }
X  }
X
X  width = 20 + XTextWidth(appdata.helpFont, &message[start], nchars) ;
X  height = (nreturns + 1) * FONTHEIGHT(appdata.helpFont);
X
X  /*
X   * Create the popup itself.
X  */
X  popup = XtVaCreatePopupShell("Message",
X    transientShellWidgetClass,
X    shell,       /* child of the shell itself? */
X    XtNtitle, (String) "XGobi Message Window",
X    XtNiconName, (String) "XGobi Message Window",
X    NULL);
X  if (mono) set_mono(popup);
X  /*
X   * Create the paned widget.
X  */
X  frame = XtVaCreateManagedWidget("Form",
X    panedWidgetClass, popup,
X    XtNorientation, (XtOrientation) XtorientVertical,
X    NULL);
X  if (mono) set_mono(frame);
X
X  /*
X   * Create the text widget.
X  */
X  text = XtVaCreateManagedWidget("Text",
X    asciiTextWidgetClass, frame,
X    XtNallowResize, (Boolean) True,
X    XtNshowGrip, (Boolean) False,
X    XtNtype, (XawAsciiType) XawAsciiString,
X    XtNstring, (String) message,
X    XtNwidth, (Dimension) width,
X    XtNheight, (Dimension) height,
X    XtNscrollVertical, (XawTextScrollMode) XawtextScrollWhenNeeded,
X    XtNdisplayCaret, (Boolean) False,
X    XtNfont, (XFontStruct *) appdata.helpFont,  /* for now */
X    NULL);
X  if (mono) set_mono(text);
X
X  /*
X   * Create the Done button.
X  */
X  done = XtVaCreateManagedWidget("Done",
X    commandWidgetClass, frame,
X    XtNshowGrip, (Boolean) False,
X    XtNskipAdjust, (Boolean) True,
X    XtNlabel, (String) "Click here to dismiss",
X    NULL);
X  if (mono) set_mono(done);
X
X  XtAddCallback(done, XtNcallback,
X    (XtCallbackProc) dismiss_message_cback, (XtPointer) popup);
X
X  /*
X   * Place the message in the middle of the XGobi window
X  */
X  XtVaGetValues(shell,
X    XtNwidth, &wksp_width,
X    XtNheight, &wksp_height, NULL);
X  XtTranslateCoords(shell,
X    (Position) (wksp_width/2), (Position) (wksp_height/2), &x, &y);
X
X  XtVaSetValues(popup,
X    XtNx, (Position) (x - width/2),
X    XtNy, (Position) (y - height/2),
X    NULL);
X
X  XtPopup(popup, XtGrabNone);
X  XRaiseWindow(display, XtWindow(popup));
X
X  set_wm_protocols(popup);
}
SHAR_EOF
  chmod 0644 'xgobi/src/show_message.c' ||
  $echo 'restore of' 'xgobi/src/show_message.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/show_message.c:' 'MD5 check failed'
490242fc93919d01f9f53f4f007b640b  xgobi/src/show_message.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/show_message.c'`"
    test 4290 -eq "$shar_count" ||
    $echo 'xgobi/src/show_message.c:' 'original size' '4290,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/brush_cbacks.c ==============
if test -f 'xgobi/src/brush_cbacks.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/brush_cbacks.c' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/brush_cbacks.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/brush_cbacks.c' &&
/* brush_cbacks.c */
/************************************************************
X *                                                          *
X *  Permission is hereby granted  to  any  individual   or  *
X *  institution   for  use,  copying, or redistribution of  *
X *  the xgobi code and associated documentation,  provided  *
X *  that   such  code  and documentation are not sold  for  *
X *  profit and the  following copyright notice is retained  *
X *  in the code and documentation:                          *
X *        Copyright (c) 1990, ..., 1996 Bellcore            *
X *                                                          *
X *  We welcome your questions and comments, and request     *
X *  that you share any modifications with us.               *
X *                                                          *
X *    Deborah F. Swayne            Dianne Cook              *
X *  dfs@research.att.com        dicook@iastate.edu          *
X *      (973) 360-8423    www.public.iastate.edu/~dicook/   *
X *                                                          *
X *                    Andreas Buja                          *
X *                andreas@research.att.com                  *
X *              www.research.att.com/~andreas/              *
X *                                                          *
X ************************************************************/
X
#include <stdio.h>
#include "xincludes.h"
#include "xgobitypes.h"
#include "xgobivars.h"
#include "xgobiexterns.h"
X
#define NAMESIZE 15
#define NAMESV(j) (namesv + j*NAMESIZE)
X
/* ARGSUSED */
XXtCallbackProc
brush_points_cback (Widget w, xgobidata *xg, XtPointer callback_data)
{
X  xg->is_point_painting = !xg->is_point_painting;
X  quickplot_once(xg);
X
X  setToggleBitmap(w, xg->is_point_painting);
}
X
/* ARGSUSED */
XXtCallbackProc
brush_active_cback (Widget w, xgobidata *xg, XtPointer callback_data)
{
X  xg->brush_on = !xg->brush_on ;
X  quickplot_once(xg);
X
X  setToggleBitmap(w, xg->brush_on);
}
X
/* ARGSUSED */
XXtCallbackProc
brush_lines_cback (Widget w, xgobidata *xg, XtPointer callback_data)
{
X  xg->is_line_painting = !xg->is_line_painting;
X  quickplot_once(xg);
X
X  setToggleBitmap(w, xg->is_line_painting);
}
X
/* ARGSUSED */
XXtCallbackProc
br_perst_cback (Widget w, xgobidata *xg, XtPointer callback_data)
/*
X * Turn persistent brushing on or off.
*/
{
X  if (xg->brush_mode != persistent)
X  { 
X    int j, k;
X
X    xg->brush_mode = persistent;
X
X    for (j=0; j<xg->nrows_in_plot; j++)
X    {
X      k = xg->rows_in_plot[j];
X      xg->color_ids[k] =      xg->color_now[k] ;
X      xg->glyph_ids[k].type = xg->glyph_now[k].type;
X      xg->glyph_ids[k].size = xg->glyph_now[k].size;
X    }
X  }
X
X  reset_br_types(xg);
X  plot_once(xg);
}
X
/* ARGSUSED */
XXtCallbackProc
br_trans_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  /*
X   * If transient brushing is being turned off, also
X   * restore colors and glyphs to persistent identities.
X  */
/* No, don't */
X  if (xg->brush_mode == transient)
X  {
/*
X    int j;
X    for (j=0; j<xg->nrows_in_plot; j++)
X    {
X      xg->glyph_now[j].type = xg->glyph_ids[j].type;
X      xg->glyph_now[j].size = xg->glyph_ids[j].size;
X      xg->color_now[j] = xg->color_ids[j];
X    }
*/
X  }
X  else {
X    xg->brush_mode = transient;
X  }
X
X  reset_br_types(xg);
X  plot_once(xg);
}
X
/* ARGSUSED */
XXtCallbackProc
br_undo_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  if (xg->brush_mode != undo) {
X    xg->brush_mode = undo;
X  }
X
X  reset_br_types(xg);
X  plot_once(xg);
}
X
/* ARGSUSED */
XXtCallbackProc
br_update_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  if (xg->plot_the_points) {
X    if (xg->link_glyph_brushing ||
X        xg->link_color_brushing ||
X        xg->link_erase_brushing)
X    {
X      XtOwnSelection( (Widget) xg->workspace,
X        (Atom) XG_ROWSINPLOT,
X        (Time) CurrentTime,
X        (XtConvertSelectionProc) pack_rowsinplot_data,
X        (XtLoseSelectionProc) pack_brush_lose ,
X        (XtSelectionDoneProc) pack_brush_done );
X      announce_rows_in_plot(xg);
X
X      XtOwnSelection( (Widget) xg->workspace,
X        (Atom) XG_NEWPAINT,
X        (Time) CurrentTime, /* doesn't work with XtLastTimeStamp...? */
X        (XtConvertSelectionProc) pack_brush_data,
X        (XtLoseSelectionProc) pack_brush_lose ,
X        (XtSelectionDoneProc) pack_brush_done );
X      announce_brush_data(xg);
X    }
X  }
X
X  if ((xg->link_points_to_points || xg->link_points_to_lines) &&
X    xg->connect_the_points)
X  {
X    XtOwnSelection( (Widget) xg->workspace,
X      (Atom) XG_NEWLINEPAINT,
X      (Time) CurrentTime, /* doesn't work with XtLastTimeStamp...? */
X      (XtConvertSelectionProc) pack_line_brush_data,
X      (XtLoseSelectionProc) pack_line_brush_lose ,
X      (XtSelectionDoneProc) pack_line_brush_done );
X    announce_line_brush_data(xg);
X  }
}
X
/* ARGSUSED */
XXtCallbackProc
reset_brush_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  init_brush_size(xg);
X  plot_once(xg);
}
X
/* ARGSUSED */
XXtCallbackProc
reset_point_colors_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  int j;
X
X  if (!mono)
X  {
X    for (j=0; j<xg->nrows; j++)
X      xg->color_ids[j] = xg->color_now[j] = plotcolors.fg;
X  }
X
X  copy_brushinfo_to_senddata(xg);
X  if (xg->link_color_brushing)
X  {
X    XtOwnSelection( (Widget) xg->workspace,
X      (Atom) XG_NEWPAINT,
X      (Time) CurrentTime, /* doesn't work with XtLastTimeStamp...? */
X      /*(Time) XtLastTimestampProcessed(display),*/
X      (XtConvertSelectionProc) pack_brush_data,
X      (XtLoseSelectionProc) pack_brush_lose ,
X      (XtSelectionDoneProc) pack_brush_done );
X    announce_brush_data(xg);
X  }
X  plot_once(xg);
}
X
/* ARGSUSED */
XXtCallbackProc
reset_line_colors_cback (Widget w, xgobidata *xg, XtPointer callback_data)
{
X  if (!mono)
X    init_line_colors(xg);
X  if (xg->link_points_to_points || xg->link_points_to_lines)
X  {
X    XtOwnSelection( (Widget) xg->workspace,
X      (Atom) XG_NEWLINEPAINT,
X      (Time) CurrentTime, /* doesn't work with XtLastTimeStamp...? */
X      (XtConvertSelectionProc) pack_line_brush_data,
X      (XtLoseSelectionProc) pack_line_brush_lose ,
X      (XtSelectionDoneProc) pack_line_brush_done );
X    announce_line_brush_data(xg);
X  }
X  plot_once(xg);
}
X
/* ARGSUSED */
XXtCallbackProc
reset_glyphs_cback (Widget w, xgobidata *xg, XtPointer callback_data)
{
X  init_glyph_ids(xg);
X
X  copy_brushinfo_to_senddata(xg);
X  if (xg->link_glyph_brushing)
X  {
X    XtOwnSelection( (Widget) xg->workspace,
X      (Atom) XG_NEWPAINT,
X      (Time) CurrentTime, /* doesn't work with XtLastTimeStamp...? */
X      /*(Time) XtLastTimestampProcessed(display),*/
X      (XtConvertSelectionProc) pack_brush_data,
X      (XtLoseSelectionProc) pack_brush_lose ,
X      (XtSelectionDoneProc) pack_brush_done );
X    announce_brush_data(xg);
X  }
X  plot_once(xg);
}
X
int
find_gid(glyphv *glyph)
{
X  int gid = 0;
X
X  gid = NGLYPHSIZES*(glyph->type-1) + glyph->size ;
X  return(gid);
}
X
void
update_nrgroups_in_plot(xgobidata *xg) {
X  /*
X   * Whenever rows_in_plot is reset, reset nrgroups_in_plot as well.
X   * Make sure the values of excluded are set.
X  */
X  if (xg->nrgroups > 0) {
X    int i;
X    xg->nrgroups_in_plot = 0;
X    for (i=0; i<xg->nrgroups; i++) {
X      if (xg->excluded[ xg->rgroups[i].els[0] ])
X        xg->rgroups[i].excluded = true;
X      else {
X        xg->rgroups[i].excluded = false;
X        xg->nrgroups_in_plot++;
X      }
X    }
X  }
}
X
void
reset_rows_in_plot(xgobidata *xg, Boolean reset_lims)
{
X  int i, j;
X
X  /*
X   * Make sure the value of nlinkable_in_plot corresponds to 
X   * nrows_in_plot
X  */
X  xg->nlinkable_in_plot = 0;
X  for (i=0; i<xg->nlinkable; i++)
X    if (!xg->excluded[i])
X      xg->nlinkable_in_plot++;
X  
X
X  if (xg->is_plotting1d)
X    plot1d_texture_var(xg);
X
X  /*
X   * dfs: changing 9 November 99, because update_vc gives me
X   * purify errors if tour hasn't been run.
X  */
X  if (xg->plot_mode == GTOUR_MODE && xg->ncols_used > 2)
X    update_sphered(xg, (int *) NULL, xg->ncols_used);
X  if (reset_lims)
X    update_lims(xg);
X  update_world(xg);
X  world_to_plane(xg);
X  plane_to_screen(xg);
X
X  if (reset_lims) {
X    if (xg->is_xyplotting) {
X      for (j=0; j<xg->ncols_used; j++) {
X        xg->nicelim[j].min = xg->lim0[j].min;
X        xg->nicelim[j].max = xg->lim0[j].max;
X        SetNiceRange(j, xg);
X        xg->deci[j] = set_deci(xg->tickdelta[j]);
X      }
X      init_ticks(&xg->xy_vars, xg);
X    }
X    else if (xg->is_plotting1d)
X      init_ticks(&xg->plot1d_vars, xg);
X  }
X
X  if (xg->is_pp) {
X    xg->recalc_max_min = True;
X    reset_pp_plot();
X    pp_index(xg,0,1);
X  }
}
X
/* ARGSUSED */
XXtCallbackProc
delete_erased_cback (Widget w, xgobidata *xg, XtPointer callback_data)
{
X  int i;
X  Boolean nerased = False;
X
X  /*
X   * First make sure that some points are erased.
X  */
X  for (i=0; i<xg->nrows; i++)
X    if (!xg->erased[i]) {
X      nerased = True;
X      break;
X    }
X
X  if (nerased) {
X
X    xg->nrows_in_plot = 0;
X    for (i=0; i<xg->nrows; i++) {
X      xg->excluded[i] = xg->erased[i];
X
X      if (!xg->erased[i]) {
X        xg->rows_in_plot[(xg->nrows_in_plot)++] = i;
X        xg->excluded[i] = 0;
X      }
X    }
X
X    update_nrgroups_in_plot(xg);
X
X    xg->delete_erased_pts = True;
X    reset_rows_in_plot(xg, True);
X
X    assign_points_to_bins(xg);
X    plot_once(xg);
X  }
}
X
void
brush_on(xgobidata *xg)
{
/*
X *  If this mode is currently selected, turn it off.
*/
X  if (xg->prev_plot_mode == BRUSH_MODE && xg->plot_mode != BRUSH_MODE)
X  {
X    XtDisownSelection( (Widget) xg->workspace,
X      (Atom) XG_NEWPAINT,
X      (Time) XtLastTimestampProcessed(display));
X      /*(XtConvertSelectionProc) pack_brush_data );*/
X
X    xg->is_brushing = False;
X    /* Remove event handler for the workspace widget. */
X    XtRemoveEventHandler(xg->workspace, XtAllEvents,
X      TRUE, (XtEventHandler) brush_button, (XtPointer) xg);
X    XtRemoveEventHandler(xg->workspace, XtAllEvents,
X      TRUE, (XtEventHandler) brush_motion, (XtPointer) xg);
X
X    /*
X     * If we've been using transient brushing, restore
X     * all points colors and glyphs to their persistent state.
X    if (xg->brush_mode == transient) {
X      int j;
X      for (j=0; j<xg->nrows_in_plot; j++) {
X        xg->glyph_now[j].type = xg->glyph_ids[j].type;
X        xg->glyph_now[j].size = xg->glyph_ids[j].size;
X        xg->color_now[j] = xg->color_ids[j];
X      }
X    }
X    */  /* No, don't. */
X
X    map_brush(xg, False);
X    plot_once(xg);
X  }
X  else if (xg->prev_plot_mode != BRUSH_MODE &&
X           xg->plot_mode == BRUSH_MODE)
X  {
X    /* Add event handlers for the workspace widget.  */
X    XtAddEventHandler(xg->workspace,
X      ButtonPressMask | ButtonReleaseMask,
X      FALSE, (XtEventHandler) brush_button, (XtPointer) xg);
X    XtAddEventHandler(xg->workspace,
X      Button1MotionMask | Button2MotionMask ,
X      FALSE, (XtEventHandler) brush_motion, (XtPointer) xg);
X
X    xg->is_brushing = True;
X    map_brush(xg, True);
X
X    if (xg->reshape_brush)
X      init_brush_size(xg);
X    draw_brush(xg);
X
X    assign_points_to_bins(xg);
X
X    /*
X     * The current transient brushing behavior is as follows:
X     * the selected points remain selected when leaving brushing.
X     * When re-entering brushing (or when selecting a new
X     * variable; see varselect() for very similar code), the
X     * brushing operations are performed so that the initial
X     * state matches what's under the brush.  This is necessary
X     * here to cover two cases:  a change of projection outside
X     * of brushing (either through change of mode or variable,
X     * or a transformation), and if reshape_brush is true.
X    */ 
X    if (xg->brush_mode == transient) {
X      int j, k;
X      for (j=0; j<xg->nrows_in_plot; j++) {
X        k = xg->rows_in_plot[j];
X        xg->color_now[k] = xg->color_ids[k] ;
X        xg->glyph_now[k].type = xg->glyph_ids[k].type;
X        xg->glyph_now[k].size = xg->glyph_ids[k].size;
X      }
X      brush_once(xg, False);
X      plot_once(xg);
X    }
X  /* */
X
X    copy_brushinfo_to_senddata(xg);
X
X    if (xg->is_tour_section)
X      turn_off_section_tour(xg);
X  }
}
X
#undef NAMESIZE
#undef NAMESV
#undef SMALL
#undef MEDIUM
#undef LARGE
SHAR_EOF
  chmod 0644 'xgobi/src/brush_cbacks.c' ||
  $echo 'restore of' 'xgobi/src/brush_cbacks.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/brush_cbacks.c:' 'MD5 check failed'
c8292521a909451d168f5308b0f6b3d4  xgobi/src/brush_cbacks.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/brush_cbacks.c'`"
    test 12057 -eq "$shar_count" ||
    $echo 'xgobi/src/brush_cbacks.c:' 'original size' '12057,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/identify.c ==============
if test -f 'xgobi/src/identify.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/identify.c' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/identify.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/identify.c' &&
/* identify.c */
/************************************************************
X *                                                          *
X *  Permission is hereby granted  to  any  individual   or  *
X *  institution   for  use,  copying, or redistribution of  *
X *  the xgobi code and associated documentation,  provided  *
X *  that   such  code  and documentation are not sold  for  *
X *  profit and the  following copyright notice is retained  *
X *  in the code and documentation:                          *
X *        Copyright (c) 1990, ..., 1996 Bellcore            *
X *                                                          *
X *  We welcome your questions and comments, and request     *
X *  that you share any modifications with us.               *
X *                                                          *
X *    Deborah F. Swayne            Dianne Cook              *
X *   dfs@research.att.com       dicook@iastate.edu          *
X *      (973) 360-8423    www.public.iastate.edu/~dicook/   *
X *                                                          *
X *                    Andreas Buja                          *
X *                andreas@research.att.com                  *
X *              www.research.att.com/~andreas/              *
X *                                                          *
X ************************************************************/
X
#include <X11/keysym.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include "xincludes.h"
#include "xgobitypes.h"
#include "xgobivars.h"
#include "xgobiexterns.h"
X
static Widget identify_panel, rm_sticky_cmd, all_sticky_cmd;
Widget id_linkopt_menu_cmd, id_linkopt_menu, id_linkopt_menu_btn[1];
extern Widget caselist_popup;
X
void
init_identify_vars(xgobidata *xg)
{
X  xg->is_identify = False;
X  xg->nearest_point = -1;
X  xg->nsticky_ids = 0;
}
X
/*
X * Code for cycling
*/
X
/* Not yet released */
X
/* End of cycling section */
X
/*
Add pack_ids_done and pack_ids_lose in wherever they belong ...
*/
X
/* ARGSUSED */
XXtSelectionDoneProc
pack_ids_done(Widget w, Atom *selection, Atom *target)
{
/*
X * This routine does nothing; its only purpose in life is to
X * prevent the Intrinsics from freeing the selection value.
*/
}
X
/* ARGSUSED */
XXtLoseSelectionProc
pack_ids_lose(Widget w, Atom *selection, XtPointer xgobi)
{
/*
X * This routine does nothing; its only purpose in life is to
X * prevent the Intrinsics from freeing the selection value.
*/
}
X
void
announce_ids(xgobidata *xg)
{
/*
X * Execute XChangeProperty(), sending no data, just to let
X * linked XGobis know that new ids are available.
*/
X  XChangeProperty( display,
X    RootWindowOfScreen(XtScreen(xg->shell)),
X    XG_IDS_ANNC, XG_IDS_ANNC_TYPE,
X    (int) 32, (int) PropModeReplace,
X    (unsigned char *) NULL, 0);
}
X
/* ARGSUSED */
XXtConvertSelectionProc
pack_ids(Widget w, Atom *selection, Atom *target,
Atom *type_ret, XtPointer *retdata, unsigned long *length_ret, int *format_ret)
/*
X  w           owning widget, xg->workspace
X  selection   XG_IDS
X  target      XG_IDS_TYPE
X  type_ret    XG_IDS_TYPE again
X  retdata     xg->nrows + xg->sticky_ids
X  length_ret  3 + xg->nsticky_ids
X  format_ret  type of retdata
*/
{
/*
X * pack up the nearest_point and the sticky_ids to send
*/
X  extern xgobidata xgobi;
X  int i;
X  unsigned long *rdata;
X
X  if (*target == XG_IDS_TYPE)
X  {
X    rdata = (unsigned long *) XtMalloc((Cardinal)
X      (3+xgobi.nsticky_ids) * sizeof(unsigned long) );
X
X    rdata[0] = (unsigned long) xgobi.nlinkable;
X    rdata[1] = (unsigned long) xgobi.nearest_point;
X    rdata[2] = (unsigned long) xgobi.nsticky_ids;
X    for (i=0; i<xgobi.nsticky_ids; i++)
X      if (i < xgobi.nlinkable)
X        rdata[i+3] = (unsigned long) xgobi.sticky_ids[i] ;
X
X    *type_ret = XG_IDS_TYPE ;
X    *retdata = (XtPointer) rdata ;
X    *length_ret = (unsigned long) (3+xgobi.nsticky_ids) ;
X    *format_ret = (int) 32 ;
X  }
}
X
/* ARGSUSED */
XXtSelectionCallbackProc
unpack_ids(Widget w, XtPointer xgobiptr, Atom *atom, Atom *atom_type,
XXtPointer retdata, unsigned long *lendata, int *fmt)
/*
X  atom         should be XG_IDS
X  atom_type    should be XG_IDS_TYPE
X  fmt          should be 32
*/
{
X  xgobidata *xg = (xgobidata *) xgobiptr;
X  int i, nids, nr;
X  unsigned long *rdata;
X
X  if (*atom == XG_IDS &&
X      /**atom_type != NULL &&*/
X      *atom_type &&
X      *atom_type == XG_IDS_TYPE )
X  {
X    if (*lendata > 0)
X    {
X      rdata = (unsigned long *) retdata;
X
X      nr = (int) *rdata++ ;
X      {
X        if (nr == xg->nlinkable)
X        {
X          xg->nearest_point = (int) *rdata++ ;
X          /*
X           * If the currently identified point has an index
X           * higher than the number of linkable points in
X           * this data, then we just won't show it.
X           * The sticky ids were checked out when they were
X           * packed.
X          */
X          if (xg->nearest_point >= xg->nlinkable)
X            xg->nearest_point = -1;
X
X          nids = (int) *rdata++ ;
X          xg->nsticky_ids = nids ;
X          xg->sticky_ids = (unsigned int *) XtRealloc(
X            (XtPointer) xg->sticky_ids,
X            (unsigned int) xg->nsticky_ids * sizeof(unsigned int) );
X
X          for (i=0; i<xg->nsticky_ids; i++)
X            xg->sticky_ids[i] = (int) *rdata++ ;
X
X          plot_once(xg);
X          passive_update_cprof_plot(xg);
X        }
X      }
/*
X * According to my reading of Asente and Swick, I can eliminate
X * this line if I don't specify a done procedure -- and purify
X * is complaining about the line, so that's what I'll do.  dfs 6/99
*/
X      /*XtFree((XtPointer) retdata) ;*/
X    }
X  }
}
X
void
read_ids(xgobidata *xg)
{
X  XtGetSelectionValue(
X    xg->workspace,
X    (Atom) XG_IDS,
X    (Atom) XG_IDS_TYPE,
X    (XtSelectionCallbackProc) unpack_ids,
X    (XtPointer) xg,
X    (Time) XtLastTimestampProcessed(display) );
X    /*(Time) CurrentTime );*/
}
X
/*___End of linked identification section___*/
X
void
map_identify(xgobidata *xg, Boolean ident)
{
X  if (ident)
X  {
X    XtMapWidget(xg->identify_mouse);
X    XtMapWidget(identify_panel);
X  }
X  else
X  {
X    XtUnmapWidget(xg->identify_mouse);
X    XtUnmapWidget(identify_panel);
X  }
}
X
/* ARGSUSED */
XXtCallbackProc
rm_sticky_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  /* see vc_lists.c */
X  if (caselist_popup && ((ShellWidget) caselist_popup)->shell.popped_up) {
X    int k;
X    for (k=0; k<xg->nsticky_ids; k++)
X      update_list_selection(xg, xg->sticky_ids[k], False);
X  }
X
X  xg->nsticky_ids = 0;
X
X  plot_once(xg);
X  if (xg->is_cprof_plotting && xg->link_cprof_plotting) {
X    realloc_tform(xg);  /* Done when nsticky_ids changes. */
X    update_cprof_plot(xg);
X  }
X
X  if (xg->link_identify)
X    announce_ids(xg);
X
}
X
/* ARGSUSED */
XXtCallbackProc
all_sticky_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  int i;
X
X  xg->nsticky_ids = xg->nrows_in_plot;
X  xg->sticky_ids = (Cardinal *) XtRealloc((XtPointer) xg->sticky_ids,
X    (Cardinal) xg->nsticky_ids * sizeof(Cardinal));
X  for (i=0; i<xg->nrows_in_plot; i++)
X    xg->sticky_ids[i] = xg->rows_in_plot[i];
X
X  /* see vc_lists.c */
X  if (caselist_popup && ((ShellWidget) caselist_popup)->shell.popped_up) {
X    int k;
X    for (k=0; k<xg->nsticky_ids; k++)
X      update_list_selection(xg, xg->sticky_ids[k], True);
X  }
X
X  plot_once(xg);
X  if (xg->is_cprof_plotting && xg->link_cprof_plotting) {
X    realloc_tform(xg);  /* Done when nsticky_ids changes. */
X    update_cprof_plot(xg);
X  }
X
X  if (xg->link_identify)
X    announce_ids(xg);
X
}
X
/* ARGSUSED */
XXtActionProc
NullNearestPoint(Widget w, XEvent *evnt, String *params, Cardinal nparams)
{
X  extern xgobidata xgobi;
X
X  if (xgobi.is_identify)
X  {
X    xgobi.nearest_point = -1;
X    /*
X     * Plot once ... then there won't be an id in the plot
X     * if the cursor is outside the plot window.
X    */
X    quickplot_once(&xgobi);
X    if (xgobi.link_identify)
X      announce_ids(&xgobi);
X  }
}
X
int
find_nearest_point(icoords *cursor_pos, xgobidata *xg)
{
/*
X * Returns index of nearest un-erased point
*/
X  int i, sqdist, near, xdist, ydist, npoint;
X
X  npoint = -1;
X  /*near = 1000*PRECISION1;*/
X
X  near = 20*20;  /* If nothing is close, don't show any label */
X
X  for (i=0; i<xg->nrows_in_plot; i++) {
X    if (!xg->erased[ xg->rows_in_plot[i] ]) {
X      xdist = xg->screen[ xg->rows_in_plot[i] ].x - cursor_pos->x;
X      ydist = xg->screen[ xg->rows_in_plot[i] ].y - cursor_pos->y;
X      sqdist = xdist*xdist + ydist*ydist;
X      if (sqdist < near) {
X        near = sqdist;
X        npoint = xg->rows_in_plot[i];
X      }
X    }
X  }
X  return(npoint);
}
X
void
id_proc(xgobidata *xg)
{
X  int root_x, root_y;
X  unsigned int kb;
X  Window root, child;
X  static int ocpos_x = 0, ocpos_y = 0;
X  icoords cpos;
X  static int inwindow = 1;
X  int wasinwindow;
X  int nearest = xg->nearest_point;
X
X  wasinwindow = inwindow;
/*
X * Get the current pointer position.
*/
X  if (XQueryPointer(display, xg->plot_window, &root, &child,
X            &root_x, &root_y, &cpos.x, &cpos.y, &kb))
X  {
X    inwindow = (0 < cpos.x && cpos.x < xg->max.x &&
X                0 < cpos.y && cpos.y < xg->max.y) ;
X    /*
X     * If the pointer is inside the plotting region ...
X    */
X    if (inwindow) {
X      /*
X       * If the pointer has moved ...
X      */
X      if ((cpos.x != ocpos_x) || (cpos.y != ocpos_y)) {
X        ocpos_x = cpos.x;
X        ocpos_y = cpos.y;
X        /*
X         * nearest_point ranges from 0 to nrows-1; 
X         * it is -1, nothing is near enough to draw.
X        */
X        xg->nearest_point = find_nearest_point(&cpos, xg);
X        if (xg->nearest_point != nearest) {
X          quickplot_once(xg);
X          if (xg->link_identify) {
X            XtOwnSelection( (Widget) xg->workspace,
X              (Atom) XG_IDS,
X              (Time) CurrentTime,
X              (XtConvertSelectionProc) pack_ids,
X              (XtLoseSelectionProc) pack_ids_lose ,
X              (XtSelectionDoneProc) NULL );
X              /* (XtSelectionDoneProc) pack_ids_done ); */
X            announce_ids(xg);
X          }
X          if (xg->is_cprof_plotting && xg->link_cprof_plotting)
X            update_cprof_plot(xg);
X        }
X      }
X    }
X  }
X
X  if (!inwindow && wasinwindow)
X  {
X    /*
X     * Don't draw the current label or update the profile plot
X     * if the pointer leaves the plot window.
X    */
X    xg->nearest_point = -1;
X    quickplot_once(xg);  /* dfs 4.27.94 */
X    if (xg->is_cprof_plotting && xg->link_cprof_plotting)
X      update_cprof_plot(xg);
X  }
}
X
void
plot_nearest_id(xgobidata *xg, Drawable win)
/*
X * Draw the id of the nearest point.
*/
{
X  if (xg->nearest_point > -1)  {
X    XDrawString(display, win, copy_GC,
X      xg->screen[ xg->nearest_point ].x + 3,
X      xg->screen[ xg->nearest_point ].y - 3,
X      xg->rowlab[ xg->nearest_point ],
X      strlen(xg->rowlab[ xg->nearest_point ]));
X
X    /* Also display the label at the lower left corner of the plot */
X    XDrawString(display, win, copy_GC,
X      5, 
X      xg->plotsize.height - 5,
X      xg->rowlab[ xg->nearest_point ],
X      strlen(xg->rowlab[ xg->nearest_point ]));
X  }
}
X
void
update_sticky_ids(xgobidata *xg)
/*
X * Called from the case selection procedures -- done when
X * new variables are selected using the case list.
*/
{
X  int *sticky_guys;
X  int nsticky_guys = 0;
X  int i, k, initval = 20, numinits = 1;
X
X  sticky_guys = (int *) XtMalloc((Cardinal) initval * sizeof(int));
X
X  for (i=0; i<xg->nrows_in_plot; i++)
X  {
X    k = xg->rows_in_plot[i] ;
X    if (xg->selectedcases[k]) {
X      sticky_guys[nsticky_guys++] = k ;
X      if (nsticky_guys >= initval*numinits) {
X        numinits++ ;
X        sticky_guys = (int *) XtRealloc((XtPointer) sticky_guys,
X          (Cardinal) (numinits * initval) * sizeof(Cardinal));
X      }
X    }
X  }
X
X  xg->nsticky_ids = nsticky_guys;
X  xg->sticky_ids = (Cardinal *) XtRealloc((XtPointer) xg->sticky_ids,
X    (Cardinal) xg->nsticky_ids * sizeof(Cardinal));
X
X  for (i=0; i<xg->nsticky_ids; i++)
X    xg->sticky_ids[i] = sticky_guys[i];
X
X  XtFree((XtPointer) sticky_guys);
}
X
/* ARGSUSED */
XXtEventHandler
set_sticky(Widget w, xgobidata *xg, XEvent *evnt)
{
X  XButtonEvent *xbutton = (XButtonEvent *) evnt;
X
X  if (xbutton->button == 1 || xbutton->button == 2)
X  {
X    int i, j, found = 0;
X
X    int root_x, root_y;
X    unsigned int kb;
X    Window root, child;
X    icoords cpos;
X
X    /*
X     * I see no reason why this should be needed, but it
X     * seems to be; otherwise, nearest_point keeps turning into
X     * -1 as soon as the button is clicked -- this happens to
X     * Di's students in Iowa and it happens on the SCA machine.
X   */
X    if (XQueryPointer(display, xg->plot_window, &root, &child,
X      &root_x, &root_y, &cpos.x, &cpos.y, &kb))
X        if ( (xg->nearest_point = find_nearest_point(&cpos, xg)) == -1 )
X          return ((XtEventHandler) 0);
X
X    for (i=0; i<xg->nsticky_ids; i++) {
X       if (xg->sticky_ids[i] == xg->nearest_point) {
X         found = 1;
X         xg->nsticky_ids-- ;
X         for (j=i; j<xg->nsticky_ids; j++) {
X           xg->sticky_ids[j] = xg->sticky_ids[j+1] ;
X         }
X         xg->sticky_ids = (unsigned int *) XtRealloc( (XtPointer)
X           xg->sticky_ids,
X           (unsigned) xg->nsticky_ids * sizeof(unsigned int) );
X
X         break;
X       }
X    }
X
X    if (!found) {
X
X      xg->nsticky_ids++ ;
X      xg->sticky_ids = (unsigned int *) XtRealloc( (XtPointer)
X        xg->sticky_ids,
X        (unsigned) xg->nsticky_ids * sizeof(unsigned int) );
X      xg->sticky_ids[xg->nsticky_ids-1] = xg->nearest_point;
X
X      /* see vc_lists.c */
X      if (caselist_popup && ((ShellWidget) caselist_popup)->shell.popped_up)
X        update_list_selection(xg, xg->nearest_point, True);
X    }
X
X    plot_once(xg);
X    if (xg->is_cprof_plotting && xg->link_cprof_plotting) {
X      realloc_tform(xg);  /* Done when nsticky_ids changes. */
X      update_cprof_plot(xg);
X    }
X    if (xg->link_identify)
X      announce_ids(xg);
X  }
}
X
void
set_id_linkopt_menu_marks(xgobidata *xg)
{
X  if (xg->link_identify)
X    XtVaSetValues(id_linkopt_menu_btn[0],
X      XtNleftBitmap, (Pixmap) menu_mark,
X      NULL);
X  else
X    XtVaSetValues(id_linkopt_menu_btn[0],
X      XtNleftBitmap, (Pixmap) None,
X      NULL);
}
X
/* ARGSUSED */
XXtCallbackProc
id_linkopt_menu_cback(Widget w, xgobidata *xg, XtPointer callback_data)
{
X  int btn;
X
X  for (btn=0; btn<1; btn++)
X    if (id_linkopt_menu_btn[btn] == w)
X      break;
X
X  switch (btn) {
X    case 0 :
X      xg->link_identify = !xg->link_identify;
X      break;
X  }
X  set_id_linkopt_menu_marks(xg);
}
X
X
void
make_id_linkopt_menu(xgobidata *xg, Widget parent, Widget href, Widget vref)
{
X  int k;
X
X  static char *id_linkopt_menu_name[] = {
X    "Link identification",
X  };
X
X  id_linkopt_menu_cmd = XtVaCreateManagedWidget("LinkBrushButton",
X    menuButtonWidgetClass, parent,
X    XtNlabel, (String) "Link",
X    XtNmenuName, (String) "Menu",
X    XtNfromHoriz, href,
X    XtNfromVert, vref,
X    NULL);
X  if (mono) set_mono(id_linkopt_menu_cmd);
X  add_menupb_help(&xg->nhelpids.menupb,
X    id_linkopt_menu_cmd, "IdentifyLink");
X
X  id_linkopt_menu = XtVaCreatePopupShell("Menu",
X    simpleMenuWidgetClass, id_linkopt_menu_cmd,
X    XtNinput, True,
X    NULL);
X  if (mono) set_mono(id_linkopt_menu);
X
X  for (k=0; k<1; k++)
X  {
X    id_linkopt_menu_btn[k] = XtVaCreateWidget("Command",
X      smeBSBObjectClass, id_linkopt_menu,
X      XtNleftMargin, (Dimension) 24,
X      XtNleftBitmap, menu_mark,
X      XtNlabel, (String) id_linkopt_menu_name[k],
X      NULL);
X    if (mono) set_mono(id_linkopt_menu_btn[k]);
X
X    XtAddCallback(id_linkopt_menu_btn[k], XtNcallback,
X      (XtCallbackProc) id_linkopt_menu_cback, (XtPointer) xg);
X  }
X
X  XtManageChildren(id_linkopt_menu_btn, 1);
}
X
X
void
make_identify(xgobidata *xg)
{
/*
X  char str[64];
X  Dimension max_width;
X *
X * Widest button label used in this panel; used to set width of sbar.
X *
X  (void) sprintf(str, "Change Direction");
X  max_width = XTextWidth(appdata.font, str, strlen(str));
*/
X
/*
X * IdentifyPanel
*/
X  identify_panel = XtVaCreateManagedWidget("IdentifyPanel",
X    boxWidgetClass, xg->box0,
X    XtNleft, (XtEdgeType) XtChainLeft,
X    XtNright, (XtEdgeType) XtChainLeft,
X    XtNtop, (XtEdgeType) XtChainTop,
X    XtNbottom, (XtEdgeType) XtChainTop,
X    XtNmappedWhenManaged, (Boolean) False,
X    NULL);
X  if (mono) set_mono(identify_panel);
X
X  /* Cycling */
X
/*
X * Reset identification labels button
*/
X  rm_sticky_cmd = CreateCommand(xg, "Remove Labels",
X    True, (Widget) NULL, (Widget) NULL,
X    (Widget) identify_panel, "Id_RmLabels");
X  XtManageChild(rm_sticky_cmd);
X
X  XtAddCallback(rm_sticky_cmd, XtNcallback,
X    (XtCallbackProc) rm_sticky_cback, (XtPointer) xg);
X
/*
X * Make them all sticky
*/
X  all_sticky_cmd = CreateCommand(xg, "Make all sticky",
X    True, (Widget) NULL, (Widget) NULL,
X    (Widget) identify_panel, "Id_AllLabels");
X  XtManageChild(all_sticky_cmd);
X
X  XtAddCallback(all_sticky_cmd, XtNcallback,
X    (XtCallbackProc) all_sticky_cback, (XtPointer) xg);
X
X  make_id_linkopt_menu(xg, identify_panel, (Widget) NULL, all_sticky_cmd);
X
/*
X * Initialize a couple of variables needed for linking case plotting
X * to the variable list.
X *cprof_selectedvars = (int *) XtMalloc((Cardinal)
X *  xg->ncols * sizeof(int));
*/
}
X
X
/*
X * This event handler allows the label of the current point to
X * be snarfed into the system cut buffer, and then copied into
X * any other xterm or browser text field etc
X *
X * It got messy once I realized that I was capturing the key strokes
X * that would otherwise be used as accelerators to change the view
X * mode.  I couldn't just send the event out again, because the same
X * event handler would pick it up, so I had to call SetPlotMode
X * directly.
*/
X
XXtEventHandler
copy_label(Widget w, xgobidata *xg, XEvent *event)
{
X  XKeyPressedEvent *evnt = (XKeyPressedEvent *) event;
X  KeySym key;
X  static char *params[1];
X  extern char *view_menu_accel[];  /* see widgets.c */
X  char *buf, sbuf[8];
X  int i;
X  XComposeStatus status_in_out;
X
X  buf = XtMalloc(8 * sizeof(char));
X  XLookupString(evnt, buf, 8, &key, &status_in_out);
X
X  sbuf[0] = buf[0];
X  sbuf[1] = '\0';
X
X  /* key = XLookupKeysym(evnt, 0); */
X  if (key == XK_w && xg->nearest_point >= 0) {
X    XStoreBytes(display, xg->rowlab[xg->nearest_point],
X      strlen(xg->rowlab[xg->nearest_point]));
X  } else {
X
X    for (i=0; i<NVIEWMODES; i++) {
X      if (strcmp(sbuf, view_menu_accel[i]) == 0) {
X        params[0] = XtMalloc(2 * sizeof(char));
X        sprintf(params[0], "%d", i);
X        SetPlotMode(w, event, params, 1);
X        break;
X      }
X    }
X  }
}
X
void
identify_on(xgobidata *xg)
{
/*
X *  If this mode is currently selected, turn it off.
*/
X  if (xg->prev_plot_mode == IDENTIFY_MODE && xg->plot_mode != IDENTIFY_MODE)
X  {
X    xg->nearest_point = -1;
X    announce_ids(xg);
X
X    XtRemoveEventHandler(xg->workspace,
X      XtAllEvents, TRUE,
X      (XtEventHandler) set_sticky, (XtPointer) xg);
X    XtRemoveEventHandler(xg->workspace,
X      XtAllEvents, TRUE,
X      (XtEventHandler) copy_label, (XtPointer) xg);
X
X    XDefineCursor(display, XtWindow(xg->workspace), default_cursor);
X    xg->is_identify = False;
X    xg->nearest_point = -1;
X    map_identify(xg, False);
X    plot_once(xg);
X
/*
X * I'm trying to work out how any linked xgobi's can be aware
X * that this xgobi isn't in identify mode any more -- sync'ing
X * and flushing don't do the trick.
X * I guess can just refuse to ever disown the selection;
X * I'm not sure what the downside is to that.  If it causes
X * memory leaks, I'll have to re-activate these lines.
*/
/*
X    XtDisownSelection( (Widget) xg->workspace,
X      (Atom) XG_IDS,
X      (Time) XtLastTimestampProcessed(display));
*/
X  }
X  /* Else turn it on */
X  else if (xg->plot_mode == IDENTIFY_MODE &&
X           xg->prev_plot_mode != IDENTIFY_MODE)
X  {
X    (void) XtAppAddWorkProc(app_con, RunWorkProcs, (XtPointer) NULL);
X    XtAddEventHandler(xg->workspace, ButtonPressMask,
X      FALSE, (XtEventHandler) set_sticky, (XtPointer) xg);
X    XtAddEventHandler(xg->workspace, KeyPressMask, FALSE,
X     (XtEventHandler) copy_label, (XtPointer) xg);
X
X    XDefineCursor(display, XtWindow(xg->workspace), crosshair_cursor);
X    xg->is_identify = True;
X    map_identify(xg, True);
X
/*
X printf("init: %x %x %x %x\n",
X XG_IDS_ANNC,XG_IDS_ANNC_TYPE,XG_IDS,XG_IDS_TYPE);
*/
X
X    XtOwnSelection( (Widget) xg->workspace,
X      (Atom) XG_IDS,
X      (Time) CurrentTime,
X      /*(Time) XtLastTimestampProcessed(display),*/
X      (XtConvertSelectionProc) pack_ids,
X      (XtLoseSelectionProc) pack_ids_lose ,
X      (XtSelectionDoneProc) NULL );
X      /*(XtSelectionDoneProc) pack_ids_done );*/
X  }
}
X
#undef LBMARGIN
#undef RTMARGIN
SHAR_EOF
  chmod 0644 'xgobi/src/identify.c' ||
  $echo 'restore of' 'xgobi/src/identify.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'xgobi/src/identify.c:' 'MD5 check failed'
b71c5b9abfa792d7470045c73bf33563  xgobi/src/identify.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'xgobi/src/identify.c'`"
    test 20498 -eq "$shar_count" ||
    $echo 'xgobi/src/identify.c:' 'original size' '20498,' 'current size' "$shar_count!"
  fi
fi
# ============= xgobi/src/natrl_hermite.c ==============
if test -f 'xgobi/src/natrl_hermite.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'xgobi/src/natrl_hermite.c' '(file already exists)'
else
  $echo 'x -' extracting 'xgobi/src/natrl_hermite.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'xgobi/src/natrl_hermite.c' &&
/* natrl_hermite.c */
/************************************************************
X *                                                          *
X *  Permission is hereby granted  to  any  individual   or  *
X *  institution   for  use,  copying, or redistribution of  *
X *  the xgobi code and associated documentation,  provided  *
X *  that   such  code  and documentation are not sold  for  *
X *  profit and the  following copyright notice is retained  *
X *  in the code and documentation:                          *
X *        Copyright (c) 1990, ..., 1996 Bellcore            *
X *                                                          *
X *  We welcome your questions and comments, and request     *
X *  that you share any modifications with us.               *
X *                                                          *
X *    Deborah F. Swayne            Dianne Cook              *
X *   dfs@research.att.com       dicook@iastate.edu          *
X *      (973) 360-8423    www.public.iastate.edu/~dicook/   *
X *                                                          *
X *                    Andreas Buja                          *
X *                andreas@research.att.com                  *
X *              www.research.att.com/~andreas/              *
X *                                                          *
X ************************************************************/
X
#include <math.h>
#include "xincludes.h"
#include "xgobitypes.h"
#include "xgobivars.h"
#include "xgobiexterns.h"
X
#define QUROOTPI 1.3313353638003898
#define SQROOTPI 1.7724538509055159
#define ONEON4PI 0.079577471545947673
X
float **h0, **h1, **hp0, **hp1, **capH0, **capH1, **phipi;
float **acoefs, *bcoefs;
X
void
alloc_natural_hermite(int n, int maxlJ)
{
X  int i;
X
X  h0 = (float **) XtMalloc(
X    (unsigned int) maxlJ*sizeof(float *));
X  for (i=0; i<maxlJ; i++)
X    h0[i] = (float *) XtMalloc(
X      (unsigned int) n*sizeof(float));
X  h1 = (float **) XtMalloc(
X    (unsigned int) maxlJ*sizeof(float *));
X  for (i=0; i<maxlJ; i++)
X    h1[i] = (float *) XtMalloc(
X      (unsigned int) n*sizeof(float));
X  hp0 = (float **) XtMalloc(
X    (unsigned int) maxlJ*sizeof(float *));
X  for (i=0; i<maxlJ; i++)
X    hp0[i] = (float *) XtMalloc(
X      (unsigned int) n*sizeof(float));
X  hp1 = (float **) XtMalloc(
X    (unsigned int) maxlJ*sizeof(float *));
X  for (i=0; i<maxlJ; i++)
X    hp1[i] = (float *) XtMalloc(
X      (unsigned int) n*sizeof(float));
X  capH0 = (float **) XtMalloc(
X    (unsigned int) maxlJ*sizeof(float *));
X  for (i=0; i<maxlJ; i++)
X    capH0[i] = (float *) XtMalloc(
X      (unsigned int) n*sizeof(float));
X  capH1 = (float **) XtMalloc(
X    (unsigned int) maxlJ*sizeof(float *));
X  for (i=0; i<maxlJ; i++)
X    capH1[i] = (float *) XtMalloc(
X      (unsigned int) n*sizeof(float));
X  phipi = (float **) XtMalloc(
X    (unsigned int) 2*sizeof(float *));
X  for (i=0; i<2; i++)
X    phipi[i] = (float *) XtMalloc(
X      (unsigned int) n*sizeof(float));
X  acoefs = (float **) XtMalloc(
X    (unsigned int) maxlJ*sizeof(float *));
X  for (i=0; i<maxlJ; i++)
X    acoefs[i] = (float *) XtMalloc(
X      (unsigned int) maxlJ*sizeof(float));
X  bcoefs = (float *) XtMalloc(
X    (unsigned int) maxlJ*sizeof(float *));
}
X
void
free_natural_hermite(int maxlJ)
{
X  int i;
X
X  for (i=0; i<maxlJ; i++)
X    XtFree((char *) h0[i]);
X  XtFree((char *) h0);
X  for (i=0; i<maxlJ; i++)
X    XtFree((char *) h1[i]);
X  XtFree((char *) h1);
X  for (i=0; i<maxlJ; i++)
X    XtFree((char *) hp0[i]);
X  XtFree((char *) hp0);
X  for (i=0; i<maxlJ; i++)
X    XtFree((char *) hp1[i]);
X  XtFree((char *) hp1);
X  for (i=0; i<maxlJ; i++)
X    XtFree((char *) capH0[i]);
X  XtFree((char *) capH0);
X  for (i=0; i<maxlJ; i++)
X    XtFree((char *) capH1[i]);
X  XtFree((char *) capH1);
X  for (i=0; i<2; i++)
X    XtFree((char *) phipi[i]);
X  XtFree((char *) phipi);
X  for (i=0; i<maxlJ; i++)
X    XtFree((char *) acoefs[i]);
X  XtFree((char *) acoefs);
X  XtFree((char *) bcoefs);
X
}
X
float
natural_hermite_index(float **proj_data, int n, int *rows_in_plot, int lJ)
{
X  int i,j,m;
X  float tmpf1, tmpf2;
X  float fact, pow2, twicefact;
X  float indx_val;
X
/* Calculate Hermite polynomials */
X  for (i=0; i<n; i++)
X  {
X    m = rows_in_plot[i];
X    capH0[0][m] = 1.;
X    capH1[0][m] = 1.;
X  }
X  if (lJ > 1)
X  {
X    for (i=0; i<n; i++)
X    {
X      m = rows_in_plot[i];
X      capH0[1][m] = proj_data[0][m];
X      capH1[1][m] = proj_data[1][m];
X    }
X    for (i=2; i<lJ; i++)
X    {
X      for (j=0; j<n; j++)
X      {
X        m = rows_in_plot[j];
X        capH0[i][m] = (proj_data[0][m]
X          * capH0[i-1][m] -
X          (i-1.)*capH0[i-2][m]);
X        capH1[i][m] = (proj_data[1][m]
X          * capH1[i-1][m] -
X          (i-1.)*capH1[i-2][m]);
X      }
X    }
X  }
X
/* Calculate constant term */
X  tmpf1 = (float)(sqrt((double) 2.)*(float)QUROOTPI);
X  for (i=0; i<n; i++)
X  {
X    m = rows_in_plot[i];
X    phipi[0][m] = exp(-proj_data[0][m]*proj_data[0][m]/2.) / 
X      sqrt((double)(2.*M_PI)) ;
X    phipi[1][m] = exp(-proj_data[1][m]*proj_data[1][m]/2.) / 
X      sqrt((double)(2.*M_PI)) ;
X  }
X
/* Calculate coefficients */
X  tmpf1 = (float)sqrt((double) 2.);
X  for (i=0; i<n; i++)
X  {
X    m = rows_in_plot[i];
X    h0[0][m] = capH0[0][m];
X    h1[0][m] = capH1[0][m];
X  }
X  if (lJ > 1)
X  {
X    for (i=0; i<n; i++)
X    {
X      m = rows_in_plot[i];
X      h0[1][m] = capH0[1][m];
X      h1[1][m] = capH1[1][m];
X    }
X    fact = 1.;
X    for (i=2; i<lJ; i++)
X    {
X      fact *= ((float)i);
X      tmpf2 = (float)sqrt((double) (fact));
X      for (j=0; j<n; j++)
X      {
X        m = rows_in_plot[j];
X        h0[i][m] =
X          capH0[i][m] / tmpf2;
X        h1[i][m] =
X          capH1[i][m] / tmpf2;
X      }
X    }
X  }
X
/* Calculate index */
X  for (i=0; i<lJ; i++)
X    for (j=0; j<(lJ-i); j++)
X      acoefs[i][j] = mean_fn4(h0[i],h1[j],phipi[0],phipi[1],n,
X        rows_in_plot);/*section*/
X  fact = 1.;
X  twicefact = 1.;
X  pow2 = 2.;
X  for (i=0; i<lJ; i++)
X  {
X    if (i%2 == 0)
X    {
X      j = i/2;
X      tmpf1 = (float)pow((double)-1.,(double)j);
X      bcoefs[i] = tmpf1*sqrt((double) twicefact)/
X        (fact*pow2*sqrt((double)M_PI));
X      if (i == 0)
X      {
X        twicefact *= ((float) (2.*(j+1)));
X      }
X      else
X      {
X        fact *= ((float) (j+1));
X        twicefact *= ((float) (2*(j+1)));
X        twicefact *= ((float) (2*(j+1)-1));
X      }
X      pow2 *= (4.);
X	}
X    else
X      bcoefs[i] = 0.;
X  }
X  indx_val = 0.;
X
X  for (i=0; i<lJ; i++)
X    for (j=0; j<(lJ-i); j++)
X    {
X    tmpf1 = acoefs[i][j]*acoefs[i][j];
X    indx_val += tmpf1;
X    }
X  for (i=0; i<lJ; i++)
X    for (j=0; j<(lJ-i); j++)
X    indx_val -= (2.*acoefs[i][j]*bcoefs[i]*bcoefs[j]);
X  indx_val += (1./(12.*(float)M_PI*(float)M_PI));
X
X  return(indx_val);
}
X
void
natural_hermite_deriv(float **data, float **proj_data, float *alpha,
float *beta, float **derivs, int n, int *rows_in_plot, int p,
int *active_vars, int nactive, int lJ)
{
X  int i, j, k, l, m;
X  float tmpf1, tmpf2, tmpf3;
X
/* Calculate derivatives of Hermite functions, in this case not
X * derivatives of Hermite functions but derivatives of the
X * coefficients, acoefs.
*/
X  for (i=0; i<n; i++) {
X    m = rows_in_plot[i];
X    hp0[0][m] = -proj_data[0][m] * phipi[0][m];
X    hp1[0][m] = -proj_data[1][m] * phipi[1][m];
X  }
X  for (i=1; i<lJ; i++)
X    for (j=0; j<n; j++) {
X      m = rows_in_plot[j];
X      hp0[i][m] = (sqrt((double) (i)) * h0[i-1][m] - proj_data[0][m] *
X        h0[i][m]) * phipi[0][m];
X      hp1[i][m] = (sqrt((double) (i)) * h1[i-1][m] - proj_data[1][m] *
X        h1[i][m]) * phipi[1][m];
X    }
X
/* alpha */
X  for (k=0; k<p; k++)
X    derivs[0][k] = 0.;
X
X
/* Calculate second term in derivative */
X  for (l=0; l<lJ; l++) {
X    for (j=0; j<lJ; j++) {
X      for (k=0; k<nactive; k++) {
X        tmpf1 = 0.;
X        for (i=0; i<n; i++) {
X          m = rows_in_plot[i];
X          tmpf3 = data[m][active_vars[k]] -
X            alpha[active_vars[k]]*proj_data[0][m] -
X            beta[active_vars[k]]*proj_data[1][m];
X          tmpf1 += (hp0[l][m] * h1[j][m] * phipi[1][m] *
X            tmpf3);
X        }/*section*/
X        tmpf1 /= ((float)n);
X        derivs[0][active_vars[k]] -= (2.*tmpf1*bcoefs[l]*bcoefs[j]);
X      }
X    }
X  }
/* Calculate first term */
X  for (l=0; l<lJ; l++) {
X    for (j=0; j<(lJ-l); j++) {
X      for (k=0; k<nactive; k++) {
X        tmpf2 = 0.;
X        for (i=0; i<n; i++) {
X          m = rows_in_plot[i];
X          tmpf3 = data[m][active_vars[k]] -
X            alpha[active_vars[k]] * proj_data[0][m] -
X            beta[active_vars[k]] * proj_data[1][m];
X          tmpf2 += (hp0[l][m] * h1[j][m] *
X            phipi[1][m] * tmpf3);
X        }/*section*/
X        tmpf2 /= ((float)n);
X        derivs[0][active_vars[k]] += (2.0*acoefs[l][j]*tmpf2);
X      }
X    }
X  }
X
/* beta */
X  for (k=0; k<p; k++)
X    derivs[1][k] = 0.;
X
/* Calculate second term in derivative */
X  for (l=0; l<lJ; l++) {
X    for (j=0; j<lJ; j++) {
X      for (k=0; k<nactive; k++) {
X        tmpf1 = 0.;
X        for (i=0; i<n; i++) {
X          m = rows_in_plot[i];
X          tmpf3 = data[m][active_vars[k]] -
X            alpha[active_vars[k]]*proj_data[0][m] -
X            beta[active_vars[k]]*proj_data[1][m];
X          tmpf1 += (h0[l][m] * phipi[0][m] * hp1[j][m] *
X            tmpf3);
X        }/*section*/
X        tmpf1 /= ((float)n);
X        derivs[1][active_vars[k]] -= (2.*tmpf1*bcoefs[l]*bcoefs[j]);
X      }
X    }
X  }
/* Calculate first term */
X  for (l=0; l<lJ; l++) {
X    for (j=0; j<(lJ-l); j++) {
X      for (k=0; k<nactive; k++) {
X        tmpf2 = 0.;
X        for (i=0; i<n; i++) {
X          m = rows_in_plot[i];
X          tmpf3 = data[m][active_var