This file is indexed.

/usr/share/xcrysden/Tcl/scriptingScalarField3D.tcl is in xcrysden-data 1.5.53-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
#############################################################################
# Author:                                                                   #
# ------                                                                    #
#  Anton Kokalj                                  Email: Tone.Kokalj@ijs.si  #
#  Department of Physical and Organic Chemistry  Phone: x 386 1 477 3523    #
#  Jozef Stefan Institute                          Fax: x 386 1 477 3811    #
#  Jamova 39, SI-1000 Ljubljana                                             #
#  SLOVENIA                                                                 #
#                                                                           #
# Source: $XCRYSDEN_TOPDIR/Tcl/scriptingScalarField3D.tcl
# ------                                                                    #
# Copyright (c) 1996-2003 by Anton Kokalj                                   #
#############################################################################


# ------------------------------------------------------------------------
#****c* Scripting/scripting::scalarField3D
#
# NAME
# scripting::scalarField3D
#
# PURPOSE

# Encapsulate the scripting interface for manipulating the 3D scalar
# field and display of isosurfaces and colorplane+contour plots. A
# typical usage of the interface is the following. First the scalar
# field is loaded with the "load" command. Then with the "configure"
# command the isosurface and/or contours display parameters are set.
# Finally the isosurface and/or contours are displayed using the
# "render" command. It is possible to make several snapshots of
# isosurface and/or contours by changing configuration options, this
# would look as:
#
# load
# configure ...
# render
# configure ..
# render
# ...

#
# COMMANDS

#
# -- scripting::scalarField3D::load

# Loads the scalar field.

#
# -- scripting::scalarField3D::configure

# Configure the display parameters for isosurface and/or contours
# plot.

#
# -- scripting::scalarField3D::render

# Renders the sosurface and/or contours.

#****
# ------------------------------------------------------------------------

namespace eval scripting::scalarField3D {
    variable scalarField3D
    
    set scalarField3D(loaded)     0
    set scalarField3D(configured) 0
    set scalarField3D(basalplane) -1
}


# ------------------------------------------------------------------------
#****f* Scripting/scripting::scalarField3D::load
#
# NAME
# scripting::scalarField3D::load
#
# USAGE
# scripting::scalarField3D::load
#
# PURPOSE

# This proc loads the 3D scalar field. Prior to calling this routine
# the XSF file with the description of 3D scalar filed should be
# loaded by "scripting::open --xsf file.xsf" call.

#
# RETURN VALUE
# Undefined.
#
# WARNINGS
# Prior to calling this routine the XSF file with the description of
# 3D scalar filed should be loaded by "scripting::open --xsf file.xsf"
# call.
#
# EXAMPLE
# scripting::open --xsf file.xsf
# scripting::scalarField3D::load
#
#****
# ------------------------------------------------------------------------

proc scripting::scalarField3D::load {} {
    variable scalarField3D
    
    #
    # load datagrid 
    #    
    set dim [DataGridOK [DataGrid]]
    if { $dim != "3D" } {
	error "datagrid is not 3D, but $dim"
    }
    set scalarField3D(loaded) 1

    # load the scalar-field 3D defaults

    IsoControl_InitVar
}



# ------------------------------------------------------------------------
#****f* Scripting/scripting::scalarField3D::configure
#
# NAME
# scripting::scalarField3D::configure
#
# USAGE
# scripting::scalarField3D::configure -option value ?-option value? ...
#
# PURPOSE

# This proc configures the display parameters of isosurface and/or
# contours plot.

# ARGUMENTS
# args -- various configuration "-option value" pairs (see Options).
#
# OPTIONS
# ------------------------------------------------------------------------
#   OPTION::                 ALLOWED-VALUES + Description        
# ------------------------------------------------------------------------
#   -isosurface              0|1                                 
#                            0 = do not render isosurface
#                            1 = render isosurface
#
#   -interpolation_degree    integer                             
#                            degree of scalar-field interpolation
#
#   -isolevel                real                                
#                            the isovalue of isosurface
#
#   -plusminus               0|1
#                            0 = display only the isosurface of isovalue 
#                                specified by -isolevel
#                            1 = display the two isosurfaces of +-isovalue
#
#   -revertsides             pos|neg|{pos neg}
#                            pos = revert the front- and back-side of isovalue 
#                                  isosurface
#                            neg = revert the front- and back-side of -isovalue
#                                  isosurface
#   -revertnormals           pos|neg|{pos neg}
#                            pos = revert the normals of isovalue isosurface
#                            neg = revert the normals of -isovalue isosurface
#
#   -expand                  none|whole|specify
#                            none = do not expand the isosurface along the 
#                                   periodic directions
#                            whole = expand the isosurface over the
#                                    whole structure along the periodic 
#                                    directions
#                            specify = expand the isosurface along the
#                                      periodic directions as specified by 
#                                      -expand_X, -expand_Y, and -expand_Z 
#                                      factors
#
#   -expand_X                positive-integer
#                            expand  isosurface n-times along the 1st
#                            periodic dimension
#
#
#   -expand_Y                positive-integer
#                            expand  isosurface n-times along the 2nd
#                            periodic dimension
#
#   -expand_Z                positive-integer
#                            expand  isosurface n-times along the 3rd
#                            periodic dimension
#
#   -basalplane              0|1|2
#                            show the ith basal plane (0=xy, 1=xz, 2=yz)
#                            as colorplane and/or isolines (as specified by
#                            -colorplane and -isoline options)
#
#   -colorbasis              MONOCHROME|RAINBOW|RGB|GEOGRAPHIC|BLUE-WHITE-RED|BLACK-BROWN-WHITE
#                            the color basis for the colorplane
#
#   -scalefunction           LINEAR|LOG10|SQRT|3th-ROOT|EXP(x)|EXP(x^2)
#                            the scalefunctions for contour/colorplane plots
#
#   -expand2D                none|whole|specify
#                            none = do not expand the contour/colorplane plots
#                                   along the periodic directions
#                            whole = expand the contour/colorplane plots
#                                    over the whole structure along the 
#                                    periodic directions
#                            specify = expand the contour/colorplane plots
#                                    along the periodic directions as specified
#                                    by -expand2D_X, -expand2D_Y, and 
#                                    -expand2D_Z factors
#
#   -expand2D_X              positive-integer
#                            expand  contour/colorplane n-times along the 1st
#                            periodic dimension
#
#
#   -expand2D_Y              positive-integer
#                            expand  contour/colorplane n-times along the 2nd
#                            periodic dimension
#
#   -expand2D_Z              positive-integer
#                            expand  contour/colorplane n-times along the 3rd
#                            periodic dimension
#
#   -colorplane              0|1
#                            do not display|display the colorplane
#
#   -isoline                 0|1
#                            do not display|display the isolines
#             
#   -colorplane_lighting     0|1
#                            0 = do not perform lighting for colorplane
#                            1 = perform lighting for colorplane
#
#   -cpl_transparency        0|1
#                            0 = render colorplane as non-transparent
#                            1 = render colorplane as transparent
#
#   -cpl_thermometer         0|1
#                            0 = do not make a legend (i.e. thermometer) for 
#                                colorplane colors
#                            1 = make a legend (i.e. thermometer) for 
#                                colorplane colors
#
#   -2Dlowvalue              real
#                            minimum rendered value of colorplane/isolines
#
#   -2Dhighvalue             real
#                            maximum rendered value of colorplane/isolines
#              
#   -2Dnisoline              positive-integer
#                            number of isoline
#
#   -anim_step               positive-integer
#                            animation step
#
#   -current_slide           positive-integer
#                            iD (i.e. sequential number) of colorplane
#
#   -isoline_color           monocolor|{property color}
#                            monocolor = all isolines have the same color
#                            {property color} = isolines are colorer according
#                            to color-basis
#
#   -isoline_width           positive-integer
#                            width (i.e. thickness) of isolines
#
#   -isoline_monocolor       #rgb
#                            color of the monolor-type isolines
#
# ------------------------------------------------------------------------
#
# RETURN VALUE
# Undefined.
#
# EXAMPLE
# scripting::scalarField3D::configure \
#     -isosurface           1 \
#     -interpolation_degree 2 \
#     -isolevel             0.1 \
#     -plusminus            1 \
#     -revertsides          {pos neg} \
#     -revertnormal         {pos neg} \
#     -expand               specify \
#     -expand_X 	    1 \
#     -expand_Y             1 \
#     -expand_Z             1 \
#     -basalplane           0 \
#     -colorbasis           BLUE-WHITE-RED \
#     -scalefunction        LINEAR \
#     -expand2D             specify \
#     -expand2D_X 	    1 \
#     -expand2D_Y           1 \
#     -expand2D_Z           1 \
#     -colorplane           1 \
#     -isoline              1 \
#     -colorplane_lighting  0 \
#     -cpl_transparency     0 \
#     -cpl_thermometer      1 \
#     -2Dlowvalue           -0.1 \
#     -2Dhighvalue          +0.1 \
#     -2Dnisoline           11 \
#     -anim_step            1 \
#     -current_slide        30 \
#     -isoline_color        monocolor \
#     -isoline_width        3 \
#     -isoline_monocolor    \#000000
# 
#****
# ------------------------------------------------------------------------

proc scripting::scalarField3D::configure {args} {
    variable scalarField3D
    global isosurf isoControl prop

    #
    # assuming the 3D grid !!!
    #

    set scalarField3D(configured) 1

    # if the colorplane/isolines are to be rendered, then "-basalplane
    # whichplane" should be specigied, and the iplane will be assigned
    # accordingly

    set iplane $scalarField3D(basalplane)

    # parse the options

    set i 0
    foreach option $args {
	incr i
	
	if { $i%2 } {
            set tag $option
	} else {	    
            switch -glob -- $tag {
		"-isosurface" {
		    switch -- $option {
			on - 1  { set isoControl(isosurf)  1 }
			off - 0 { set isoControl(isosurf)  0 }
			default {
			    ErrorDialog "wrong -isosurface value $option, must be 0 or 1"
			}
		    }
		}
		
		"-interpolation_degree" {
		    if { ! [string is integer $option] } {
			ErrorDialog "expected integer for -interpolationdegree option, but got $option"
		    } elseif { $option < 1 } {
			ErrorDialog "-interpolationdegree value should be greater then 0, but got $option"
		    } else {
			set isosurf(3Dinterpl_degree) $option
		    }
		}
		
		"-isolevel" {
		    if { ! [string is double $option] } {
			ErrorDialog "expected real-number for -isolevel option, but got $option"
		    } else {
			set prop(isolevel) $option
		    }
		}

		"-plusminus" {
		    switch -- $option {
			yes - on  - 1 { set prop(pm_isolevel) 1 }
			no  - off - 0 { set prop(pm_isolevel) 0 }
			default {
			    ErrorDialog "wrong -isosurface value $option, must be 0 or 1"
			}
		    }
		    IsoControlCommand
		}
		
		"-revertside*" {
		    foreach side $option {
			switch -- [string tolower $side] {
			    pos { RevertIsoSides pos }
			    neg { RevertIsoSides neg }
			    default {
				ErrorDialog "the value of -revertsides must be pos or neg, but got $option"	
			    }
			}
		    }
		}
		
		"-revertnormal*" {
		    foreach side $option {
			switch -- [string tolower $side] {
			    pos { RevertIsoNormals pos }
			    neg { RevertIsoNormals neg }
			    default {
				ErrorDialog "the value of -revertnormals must be pos or neg, but got $option"	
			    }
			}
		    }
		}

		"-basalplane" {
		    switch $option {
			1 { set iplane 1 }
			2 { set iplane 2 }
			3 { set iplane 3 }
			default {
			    ErrorDialog "the value of -basalplane must be 0, 1, or 2, but got $option" 
			    continue
			}
		    }
		    set scalarField3D(basalplane) $iplane
		    set t .iso
		    set ft  $t.ft
		    set fb1 $t.fb1
		    set fb2 $t.fb2
		    IsoControl_Show colorplane$iplane $fb1 $fb2 $ft.b1 $ft.b2 $ft.b3 $ft.b4
		}

		"-colorbasis" {
		    switch -exact -- $option {
			MONOCHROME - RAINBOW - RGB - GEOGRAPHIC - BLUE-WHITE-RED - BLACK-BROWN-WHITE { set cpl_basis $option }			    
			default {
			    ErrorDialog "wrong colorbasis $option, must be ..." 
			    continue
			}  
		    }
		}

		"-scalefunction" {
		    switch -exact -- $option {
			LINEAR - LOG10 - SQRT - 3th-ROOT - EXP(x) - EXP(x^2) {set cpl_function $option }
			default {			    
			    ErrorDialog "wrong scale-function $option, must be ..." 
			    continue
			}  
		    }
		}

		"-expand" -
		"-expand2D" {
		    set var [string trimleft $tag -]
		    switch -- $option {
			none - whole - specify { set $var $option }
			default {
			    ErrorDialog "wrong $tag value $option, must be none, whole, specify" 
			    continue
			}
		    }
		}
		"-expand_X" -	
		"-expand_Y" -
		"-expand_Z" -
		"-expand2D_X" -	
		"-expand2D_Y" -
		"-expand2D_Z" {
		    if { ! [string is integer $option] } {
			ErrorDialog "expected integer for $tag option, but got $option"
		    } elseif { $option < 1 } {
			ErrorDialog "$tag value should be greater then 0, but got $option"
		    } else {
			set var [string trimleft $tag -]
			set $var $option
		    }
		}
		
		"-colorplane" -
		"-isoline" -
		"-colorplane_lighting" -
		"-cpl_transparency" -
		"-cpl_thermometer" -
		"-2Dlowvalue" -
		"-2Dhighvalue" -
		"-2Dnisoline" -
		"-anim_step" -    
		"-current_slide" -
		"-isoline_color" -
		"-isoline_width" -
		"-isoline_monocolor" {
		    set var [string trimleft $tag -]
		    set $var $option
		}
	    }
	}
    }
    if { $i%2 } {
	ErrorDialog "scripting::scalarField3D::configure called with an odd number of arguments !!!"
    }

    if { [info exists expand]   } { set isosurf(expand)   $expand }
    if { [info exists expand_X] } { set isosurf(expand_X) $expand_X }
    if { [info exists expand_Y] } { set isosurf(expand_Y) $expand_Y }
    if { [info exists expand_Z] } { set isosurf(expand_Z) $expand_Z }
	

    if { $iplane > 0 } {

	if { [info exists cpl_basis] } {           set isoControl($iplane,cpl_basis)           $cpl_basis }
	if { [info exists cpl_function] } {        set isoControl($iplane,cpl_function)        $cpl_function }
	if { [info exists colorplane] } {          set isoControl($iplane,colorplane)          $colorplane }
	if { [info exists isoline] } {             set isoControl($iplane,isoline)             $isoline }
	if { [info exists colorplane_lighting] } { set isoControl($iplane,colorplane_lighting) $colorplane_lighting }
	if { [info exists cpl_transparency] } {    set isoControl($iplane,cpl_transparency)    $cpl_transparency }
	if { [info exists cpl_thermometer] } {     set isoControl($iplane,cpl_thermometer)     $cpl_thermometer }
	if { [info exists cpl_thermoTplw] } {      set isoControl($iplane,cpl_thermoTplw)      $cpl_thermoTplw }
	
	if { [info exists 2Dlowvalue]  } { set isoControl($iplane,2Dlowvalue)  $2Dlowvalue }
	if { [info exists 2Dhighvalue] } { set isoControl($iplane,2Dhighvalue) $2Dhighvalue }
	if { [info exists 2Dnisoline]  } { set isoControl($iplane,2Dnisoline)  $2Dnisoline }
	
	if { [info exists expand2D]   } { set isosurf($iplane,2Dexpand)   $expand2D }
	if { [info exists expand2D_X] } { set isosurf($iplane,2Dexpand_X) $expand2D_X }
	if { [info exists expand2D_Y] } { set isosurf($iplane,2Dexpand_Y) $expand2D_Y }
	if { [info exists expand2D_Z] } { set isosurf($iplane,2Dexpand_Z) $expand2D_Z }
	
	if { [info exists anim_step] } {        
	    set isoControl($iplane,anim_step) $anim_step 
	}
	if { [info exists current_slide] } {    
	    set isoControl($iplane,current_slide) $current_slide 
	    set isoControl(current_text_slide) "Current slide:  $isoControl($iplane,current_slide) / $isoControl($iplane,nslide)"	
	}
	
	if { [info exists isoline_color] } {    set isoControl($iplane,isoline_color)      $isoline_color }
	if { [info exists isoline_width] } {    set isoControl($iplane,isoline_width)      $isoline_width }
	if { [info exists isoline_monocolor] } {set isoControl($iplane,isoline_monocolor)  $isoline_monocolor }
	if { [info exists isoline_stipple] } {  set isoControl($iplane,isoline_stipple)    $isoline_stipple }

	# register the colorplane values
	IsoControl_SetColorPlaneVar 2nd $iplane
    }
}



# ------------------------------------------------------------------------
#****f* Scripting/scripting::scalarField3D::render
#
# NAME
# scripting::scalarField3D::render
#
# USAGE
# scripting::scalarField3D::render
#
# PURPOSE

# This proc displays the either isosurface or contours/colorplanes or
# both (depending on the configuration).

#
# RETURN VALUE
# Undefined.
#
# EXAMPLE
# scripting::scalarField3D::render
#
#****
# ------------------------------------------------------------------------

proc scripting::scalarField3D::render {} {
    variable scalarField3D

    if { !$scalarField3D(loaded) } {
	ErrorDialog "can't render isosurface/contours, the scalar field was not loaded. Call scripting::scalarField3D::load and scripting::scalarField3D::configure before calling scripting::scalarField3D::render"
	return
    }

    if { !$scalarField3D(configured) } {
	ErrorDialog "can't render isosurface/contours, since they were not configured. Call scripting::scalarField3D::configure before calling scripting::scalarField3D::render"
	return
    }

    #############
    UpdateIsosurf
}