This file is indexed.

/usr/share/elmerfront/tcl/ecif_tk_coordinatePanel.tcl is in elmer-common 6.1.0.svn.5396.dfsg2-4ubuntu4.

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
576
577
578
579
580
581
#/*****************************************************************************/
# *
# *  Elmer, A Finite Element Software for Multiphysical Problems
# *
# *  Copyright 1st April 1995 - , CSC - IT Center for Science Ltd., Finland
# * 
# *  This program is free software; you can redistribute it and/or
# *  modify it under the terms of the GNU General Public License
# *  as published by the Free Software Foundation; either version 2
# *  of the License, or (at your option) any later version.
# * 
# *  This program 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 General Public License for more details.
# *
# *  You should have received a copy of the GNU General Public License
# *  along with this program (in file fem/GPL-2); if not, write to the 
# *  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
# *  Boston, MA 02110-1301, USA.
# *
# *****************************************************************************/
  
#***********************************************************************
#Program:   ELMER Front 
#Module:    ecif_tk_coordinateDefPanel.tcl
#Language:  Tcl
#Date:      16.11.98
#Version:   1.00
#Author(s): Martti Verho
#Revisions: 
#
#Abstract:  A panel for defining the coordiante system
#
#************************************************************************


proc Coordinate::openPanel {} {
  ## This procedure displays the coordiante definition panel
  ## Global variables
  global Info Common Model Coordinate oldValues
  global platform
  upvar #0 Coordinate theArray

  set w $Coordinate(winName)
  set wgeom $Coordinate(winGeometry)

  set id [winfo atom $w]
  set Coordinate(winId) $id

  set Info(thisWindow) $w

  if { 1 == [Util::checkPanelWindow Coordinate $id $Coordinate(winTitle) $wgeom] } {
    return
  }  

  set Coordinate(dataChanged) 0
  set Coordinate(dataModified) 0

  set this $w
  toplevel $w
  focus $w

  wm title $w $Coordinate(winTitle)
  wm geometry $w $wgeom 

  Panel::resetFields Coordinate

  Panel::initFields Coordinate

  set id $Coordinate(parameterId)
  DataField::formDataFields Coordinate $Coordinate($id,data)

  Panel::backupFields Coordinate
  
  set Info(coordiantePanelApplied) 0

  #-----WIDGET CREATION
  #-We organise data into four frames. These frames are then
  #-packed below each other and devided internally if needed.
  frame $w.f1 ;#--Coordinate geometry 
  frame $w.f1.cd  ;#--Coordinate related stuff
  frame $w.f1.cd.1 -bd 2 -relief groove ;#--Coordinate systems
  frame $w.f1.cd.2 -bd 2 -relief groove ;#--Coordinate mapping
  frame $w.fB ;#--Buttons
  
  # Coordinate system radiobuttons
  # ==============================
  #
  set fld COORDINATE_SYSTEM
  set m $w.f1.cd.1
  frame $m.lf
  label $m.lf.l  -anchor nw -text "Coordinate system: "

  # Add help event for the label
  set wdg $m.lf.l
  bind $wdg <ButtonPress-3> "Widget::genericButton-3 Coordinate $fld $wdg"

  frame $m.rf
  radiobutton $m.rf.r1  -text "Cartesian 2D"        -value "Cartesian 2D" 
  radiobutton $m.rf.r2  -text "Axi Symmetric"       -value "Axi Symmetric" 
  radiobutton $m.rf.r3  -text "Cylindric Symmetric" -value "Cylindric Symmetric" 
  radiobutton $m.rf.r4  -text "Polar 2D"            -value "Polar 2D" 
  radiobutton $m.rf.r5  -text "Cartesian 3D"        -value "Cartesian 3D" 
  radiobutton $m.rf.r6  -text "Cylindrical"           -value "Cylindrical"
  radiobutton $m.rf.r7  -text "Polar 3D"            -value "Polar 3D" 
  
  set Coordinate(allWidgets,$fld) ""

  #-Set button variables etc.
  set coordinate_system_ids {1 2 3 4 5 6 7}
  set is2D  {1 1 1 1 0 0 0}

  foreach i $coordinate_system_ids is_2d $is2D {

    set wdg $m.rf.r$i

   # Add help event for the radiobutton, using text as field name!
    set wfld [DataField::fieldNameSifToGui [$wdg cget -text]]
    bind $wdg <ButtonPress-3> "Widget::genericButton-3 Coordinate $wfld $wdg"

    $wdg configure -anchor w -state normal \
                   -variable Coordinate($fld) \
                   -indicatoron 1 \
                   -command "Coordinate::setCoordinateStatus" \
                   -selectcolor $Info(select_color)

    # Disable wrong dimensions
    if { $Model(GEOMETRY_DIMENSION) == "2D" && !$is_2d ||
         $Model(GEOMETRY_DIMENSION) == "3D" && $is_2d  
       } {
        $wdg configure -state disabled
    }
    
    lappend Coordinate(allWidgets,$fld) $wdg
    bind $wdg <ButtonRelease-1> "Panel::panelDataChanged 1 Coordinate $wdg {%A %K}"
  }

  #-Labels according to different coordinate types
  set label_index [Coordinate::getLabelIndex]
  set labels [lindex $Coordinate(coordinateLabels) $label_index]

  # Coordinate mapping entries
  # ==========================
  #
  set fld COORDINATE_MAPPING
  set m $w.f1.cd.2
  frame $m.lf
  label $m.lf.l  -anchor nw -text "Coordinate mapping:"

  # Add help event for the label
  set wdg $m.lf.l
  bind $wdg <ButtonPress-3> "Widget::genericButton-3 Coordinate $fld $wdg"

  frame $m.ef

  label $m.ef.l1  -text [lindex $labels 0] -width 5
  entry $m.ef.e1  -textvariable Coordinate(COORDINATE_MAPPING_1) -width 2 -font $Info(entryFont)

  label $m.ef.l2  -text [lindex $labels 1] -width 5
  entry $m.ef.e2  -textvariable Coordinate(COORDINATE_MAPPING_2) -width 2 -font $Info(entryFont)

  #-third entry needs special handling according to the dimension!
  label $m.ef.l3  -text [lindex $labels 2] -width 5

  set state normal
  set bg_color white

  if { $Model(SIMULATION_DIMENSION) != "3D" } {
    set state disabled
    set bg_color gray
  }
  entry $m.ef.e3  -textvariable Coordinate(COORDINATE_MAPPING_3) -width 2 \
                  -bg $bg_color -state $state -font $Info(entryFont)


  # Store widgets and set bindings
  set Coordinate(allWidgets,label,$fld) ""
  set Coordinate(allWidgets,$fld) ""

  foreach i { 1 2 3 } {
    set lbl $m.ef.l$i
    set wdg $m.ef.e$i
    
    set var $fld
    append var "_$i"

    lappend Coordinate(allWidgets,label,$fld) $lbl
    lappend Coordinate(allWidgets,$fld) $wdg

    set Coordinate(allWidgets,$var) $wdg

    bind $wdg <KeyRelease> "Panel::panelDataChanged 1 Coordinate $wdg {%A %K}"
    Widget::setEntryBindings non_standard Coordinate $var $wdg
  }

 
  # Set values
  #
  foreach i {0 1 2} n {1 2 3} {

    set var $fld
    append var "_$n"
    
    set Coordinate($var) [lindex $Coordinate($fld) $i]

    # NOTE: This is needed because mapping vars are not "normal"
    set Coordinate($var,err) 0
    set Coordinate($var,mod) 0

    set Coordinate($var,prev) $Coordinate($var)
    set Coordinate($var,err,prev) 0
    set Coordinate($var,mod,prev) 0
  }
  

  #---WIDGET PACKING
  set fpx $Info(framePadX1)
  set fpy $Info(framePadY1)
  set fpx3 $Info(framePadX3)
  set fpy3 $Info(framePadY3)

  #-----Geometry & time widgets packing
  #pack $w.f1 -side top  -anchor nw -fill x -padx $fpx -pady $fpy
  pack $w.f1 -side top  -anchor nw -fill x -padx $fpx3 -pady $fpy3
  pack $w.f1.cd -side left  -anchor nw -fill x -padx $fpx -pady $fpy

  #---Coordinates

  # Coordinate systems
  set m $w.f1.cd.1
  pack $m -side top  -anchor nw -fill x -padx $fpx -pady $fpy
  pack $m.lf -side top  
  pack $m.lf.l -side top -anchor nw  
  pack $m.rf -side top  
  foreach i $coordinate_system_ids {
    pack $m.rf.r$i -side top -anchor nw
  }  

  # Mapping
  set m $w.f1.cd.2
  pack $m -side top  -anchor nw -fill x -padx $fpx -pady $fpy
  pack $m.lf -side top  
  pack $m.lf.l -side top -anchor nw  
  pack $m.ef -side top  
  pack $m.ef.l1 $m.ef.e1 -side left -anchor nw  
  pack $m.ef.l2 $m.ef.e2 -side left -anchor nw  
  pack $m.ef.l3 $m.ef.e3 -side left -anchor nw  

  #-----Buttons packing widgets packing
  pack $w.fB -side top  -padx $fpx -pady $fpy
  #-----Apply, Ok and cancel buttons creating and packing

  set ap $Info(defaultApplyState)
  set ca $Info(defaultCancelState)

  set ok_btn [button $w.fB.ok -text OK -command "Coordinate::panelOk $this"]
  set cn_btn [button $w.fB.cancel -text Cancel -command "Coordinate::panelCancel $this" \
                                  -state $ca]
  set ap_btn [button $w.fB.apply  -text Apply -command Coordinate::panelApply \
                                  -state $ap]

  focus $ok_btn
  set Coordinate(applyButton)  $ap_btn
  set Coordinate(cancelButton) $cn_btn

  pack $ok_btn $cn_btn $ap_btn -side left -padx $fpx 

  #-----Initialization
  #-Nothing so far
 
  
}


proc Coordinate::panelSave { {inform_front 1} } {
  global Info Coordinate Model

  set panel $Coordinate(parameterType)

  #--Store old values
  Panel::backupFields Coordinate

  set sdim1 $Model(SIMULATION_DIMENSION)
  Coordinate::applyCoordinateDimension $Coordinate(COORDINATE_SYSTEM)
  set sdim2 $Model(SIMULATION_DIMENSION)

  # If simulation dimension was changed
  #
  if { $sdim1 != "" && $sdim1 != $sdim2 } {

    StdPanelInit::updateEquationDataAndMasks 
    Equation::setOtherMasks
    StdPanelInit::createObjectTableMasks
    Equation::constructProblemMask

    # Solver variable dofs!
    set modified 0
    Solver::updateVariableDofs modified
    if { $modified } {
      Solver::panelSave
    }

    # Calculator variable dofs!
    set modified 0
    Calculator::updateVariableDofs modified
    if { $modified } {
      Calculator::okProcPre
      StdPanelExec::panelSave Calculator
    }

    Panel::checkMaskedParameters modified
  }

  #--Set vector data size
  set Coordinate(COORDINATE_MAPPING,dataSize) 3

  #--Form parameter data
  set Coordinate(ids) 1
  DataField::formNonStandardParameter Coordinate 1 "Coordinates1"

  #--Write data into model
  if {$inform_front} {
    set Model(Front,needsUpdate) 1
  }

  set Model(Solver,needsUpdate) 1

  Panel::panelDataChanged 0 Coordinate 
  Panel::panelDataModified 0 Coordinate 
  Util::cpp_exec coordinatePanelOk
}


proc Coordinate::panelOk {w} {
  global Coordinate
    
  #---No changes
  if { !$Coordinate(dataChanged) } {
    Panel::cancel $w; return
  }

  #---Error in data
  if { ![Coordinate::checkPanelData] } {
    return
  }

  #---Ok 
  Coordinate::panelSave
  Panel::cancel $w
}


proc Coordinate::panelApply {} {
  global Info Coordinate

  #---No changes
  if { !$Coordinate(dataChanged) } {
    return
  }

  if { ![Coordinate::checkPanelData] } {
    return
  }
   
  Coordinate::panelSave

  # This is needed to make mapping fields in
  # correct status in the panel
  Coordinate::setCoordinateStatus
}


proc Coordinate::getLabelIndex {} {
  global Coordinate

  switch $Coordinate(COORDINATE_SYSTEM) {
    "Cartesian 2D"        -
    "Cartesian 3D"        {return 0}
    "Axi Symmetric"       -
    "Cylindric Symmetric" -
    "Cylindrical"         {return 1}
    "Polar 2D"            -
    "Polar 3D"            {return 2}
  }

  #-Default if not found!
  return 0
}


proc Coordinate::updateLabels {} {
  global Coordinate

  set index [Coordinate::getLabelIndex]
  set Coordinate(coordinateLabelIndex) $index
  set labels [lindex $Coordinate(coordinateLabels) $index]

  foreach wid $Coordinate(allWidgets,label,COORDINATE_MAPPING) lbl $labels {
    set text $lbl
    append text ":"
    $wid configure -text $text
  }
}

proc Coordinate::panelCancel {w} {
  global Coordinate

  if { ![Panel::verifyCancel Coordinate] } {
    return
  }

  #---Reset into old values
  Panel::restoreFields Coordinate

  Panel::cancel $w
}


# Return 1 = ok, 0 = error
#
proc Coordinate::checkPanelData {} {
  global Info Coordinate Model

  # Coordinate mapping
  # ==================
  # we must have a list of {1 2 3} (in any order)!
  set mappings ""
  set is_ok 1

  # Note: We check from end to start to display
  # the possible same-value error for the smaller
  # number, because this is sensible for 2D, where
  # the 3rd coordinate should always be 3 when it is
  # not editable
  #
  foreach i {3 2 1} {
    set var COORDINATE_MAPPING_$i
    set val [string trim $Coordinate($var)]
    set Coordinate($var) $val

    # NOTE: This is needed because mapping vars are not "normal"
    set Coordinate($var,err) 0
    set Coordinate($var,mod) 0
    set is_ok 1

    # Illegal value or same values
    #
    if { ($val < 1 || $val > 3) ||
         -1 != [lsearch $mappings $val]    
      } {
      set Coordinate($var,err) 1
      set is_ok 0
    }

    Widget::setFieldStatus Coordinate $var
  
    if {$is_ok} {
      lappend mappings $val
    }
  }

  #--If error
  if { 3 != [llength $mappings] } {

    set Info(messageIcon) error
    Message::dispOkMessage {"Incorrect coordinate mapping!"} \
                  "$Info(FRONT_NAME) error message" \
                  $Coordinate(winName) 

    return 0
  }

  set Coordinate(COORDINATE_MAPPING) "" 

  #--If mapping data ok
  foreach i {1 2 3} {
 
    set var COORDINATE_MAPPING_$i

    # NOTE: This is needed because mapping vars are not "normal"
    set Coordinate($var,prev) $Coordinate($var)
    set Coordinate($var,err,prev) $Coordinate($var,err)
    set Coordinate($var,mod,prev) $Coordinate($var,mod)

    lappend Coordinate(COORDINATE_MAPPING) $Coordinate($var)
  }

  # Ok
  return 1
}


# Set coordinate panel widgets state according
# to the model geometry dimension
#
proc Coordinate::setCoordinateStatus {} {
  global Coordinate

  Coordinate::updateLabels

  switch $Coordinate(COORDINATE_SYSTEM) {
    "Cartesian 2D"        -
    "Polar 2D"            -
    "Axi Symmetric"       { set activate_3 0 }
    "Cylindric Symmetric" -
    "Cartesian 3D"        -
    "Cylindrical"         -
    "Polar 3D"            { set activate_3 1 }
  }

  set wdg [lindex $Coordinate(allWidgets,COORDINATE_MAPPING) 2]

  if { $activate_3 } {
    $wdg configure -state normal -bg white

  } else {
    $wdg configure -state disabled -bg gray

    # Note: We have to force a legal mapping if
    # dimension is changed, in practice this means
    # 2D and CylindricSymmetric changes
    set Coordinate(COORDINATE_MAPPING_3) 3

    if { $Coordinate(COORDINATE_MAPPING_1) <= \
         $Coordinate(COORDINATE_MAPPING_2)
       } {
      set Coordinate(COORDINATE_MAPPING_1) 1
      set Coordinate(COORDINATE_MAPPING_2) 2

    } else { 
      set Coordinate(COORDINATE_MAPPING_1) 2
      set Coordinate(COORDINATE_MAPPING_2) 1
    }

  }
}


# Updates system according to the simulation dimension value
#
proc Coordinate::applyCoordinateDimension {coordinate_system} {
  global Coordinate Model

  switch $coordinate_system {
    "Cartesian 2D"        -
    "Polar 2D"            -
    "Axi Symmetric"       { set Model(SIMULATION_DIMENSION) "2D" }
    "Cylindric Symmetric" -
    "Cartesian 3D"        -
    "Cylindrical"         -
    "Polar 3D"            { set Model(SIMULATION_DIMENSION) "3D" }
  }

  set Coordinate(coordinateLabelIndex) [Coordinate::getLabelIndex]
}


# Set default coordinate system
#
proc Coordinate::setDefaultCoordinateSystem {} {
  global Coordinate Model

  if { $Model(GEOMETRY_DIMENSION) == "2D" } {
    set Coordinate(COORDINATE_SYSTEM) "Cartesian 2D"

  } else {
    set Coordinate(COORDINATE_SYSTEM) "Cartesian 3D"
  }
    
  # Store new value in the parameter
  set id $Coordinate(parameterId)
  DataField::setFieldValue Coordinate $id COORDINATE_SYSTEM $Coordinate(COORDINATE_SYSTEM)

  execNsProc Coordinate panelSave 0
}



# end ecif_tk_coordinateDefPanel.tcl
# ********************