This file is indexed.

/usr/share/elmerfront/tcl/ecif_tk_equationVariablesPanel.tcl is in elmer-common 6.1.0.svn.5396.dfsg-2ubuntu1.

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
#/*****************************************************************************/
# *
# *  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_equationVariablesPanel.tcl
#Language:  Tcl
#Date:      17.05.99
#Version:   1.00
#Author(s): Martti Verho
#Revisions: 
#
#Abstract:  A panel for defining variables for specific equations
#
#************************************************************************


proc EquationVariable::openPanel { callingPanel } {
  ## This procedure displays the input and output files definition panel
  ## Global variables
  global Info Common Model EquationVariable Equation
  global platform
  
  if { $Equation(equationIndex) == "" } {
    return
  }

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

  set id [winfo atom $w]
  set EquationVariable(winId) $id
  set Info(thisWindow) $w

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

  set EquationVariable(dataChanged) 0
  set EquationVariable(dataModified) 0
  set EquationVariable(dataWasChanged) 0

  set this $w
  toplevel $w
  focus $w

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

  Panel::resetFields EquationVariable

  # We init here in the case that some new fields
  # have been added by user definition files!
  #
  Panel::initFields EquationVariable

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

  Panel::backupFields EquationVariable

  set Info(equationVariablesPanelApplied) 0

 #----WIDGET DEFINITION AND PACKING
  #
  set fpx1 $Info(framePadX1)
  set fpy1 $Info(framePadY1)
  set fpx2 $Info(framePadX2)
  set fpy2 $Info(framePadY2)

  #---Outer frames
  set f1 [frame $w.f1] ;#Title
  set f2 [frame $w.f2] ;#Help text
  set f3 [frame $w.f3] ;#Text entry
  set f4 [frame $w.f4] ;#Apply+Ok+cancel buttons frame
  #
  set ent_wid 30
  set ent_hig 16

  set eq_var [Equation::getFieldPropertyByIndex $Equation(equationIndex) EquationField]

  if { $eq_var == ""} {
    return
  }

  set EquationVariable(currentField) $eq_var

  set eq_lbl [DataField::getFieldProperty Equation $eq_var Label]

  # Label
  #
  label $f1.l  -text "$eq_lbl variables"
  pack $f1.l -side top

  set table_hdr    "\n\nEnter one variable name per line:"

  label $f2.l -text $table_hdr

  pack $f2.l -side top
  
  # Text widget
  #
  set wdg [text $f3.e  -width $ent_wid -height $ent_hig -font $Info(entryFont)]

  bind  $wdg <KeyRelease> "Panel::panelDataChanged 1 EquationVariable $wdg {%A %K}"
  bind  $wdg <KeyPress-Return> "EquationVariable::panelCheck
  "
  pack $wdg -side top -padx $fpx2 -pady $fpy2 
  
  set EquationVariable(allWidgets,variableNames) $wdg

  # Buttons
  #

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

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

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

  pack $ok_btn $cn_btn $ap_btn -side left -expand 1 -padx $fpx1

  pack $f1 $f2 $f3 $f4 -side top -expand 1 -padx $fpx2 -pady $fpy2

  # Init panel
  DataField::data2TextWidget EquationVariable $EquationVariable(currentField) $wdg
}


proc EquationVariable::panelSave { {inform_front 1} {update_equation_panel 1} } {
  global Common EquationVariable Equation Model

  set panel $EquationVariable(parameterType)

  #--Update variables and components
  # NOTE: This must be done before backup!!!
  #
  set old_names [EquationVariable::getOldVariableNames]
  set added_names [EquationVariable::getAddedVariableNames]
  set removed_names [EquationVariable::getRemovedVariableNames]

  set ename $EquationVariable(currentField)
  set emask [DataField::getFieldProperty Equation $ename EquationMask]
  set edofs [DataField::getFieldProperty Equation $ename VariableDofs "" 0]

  foreach rn $removed_names {
    DataField::unsetVariableComponents $rn $edofs
  }

  foreach an $added_names {
    DataField::setVariableComponents $ename $an 
  }
  
  #Panel::initFields Variables

  #--Store old values 
  Panel::backupFields EquationVariable

  #--Form active parameter
  EquationVariable::formActiveParameter

  #--Update list of all variables EquationVariable(allVariableNames) 
  EquationVariable::updateAllVariableNames

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

  Panel::panelDataChanged 0 EquationVariable
  Panel::panelDataModified 0 EquationVariable

  if { $update_equation_panel } {
    Equation::updateEquationVariables $old_names $added_names $removed_names
  }

  #--Set panel states
  Panel::panelDataModified 1 Equation 
  Panel::panelDataChanged 1 Equation 
  set EquationVariable(dataWasChanged) 1

  Util::cpp_exec equationVariablesPanelOk
}


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

  #---Error in data
  if { ![EquationVariable::panelCheck 1] } {
    return
  }

  EquationVariable::panelSave
  Panel::cancel $w
}


proc EquationVariable::panelApply {} {
  global EquationVariable

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

  #---Error in data
  if { ![EquationVariable::panelCheck 1] } {
    return
  }

  EquationVariable::panelSave
}


proc EquationVariable::panelCancel {w} {
  global EquationVariable

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

  #-Restore old values
  Panel::restoreFields EquationVariable

  Panel::cancel $w
}


# Return 1 = ok, 0 = error
#
proc EquationVariable::panelCheck { {trim_empty_lines 0} } {
  global EquationVariable Model Info

  set is_ok 1

  #--Check widget data
  set ew $EquationVariable(allWidgets,variableNames)
  set data [$ew get 0.0 end]

  set fld $EquationVariable(currentField)

  #--Pick widget data
  DataField::textWidget2Data EquationVariable $fld $ew $trim_empty_lines

  #--Form data list
  set data [split $EquationVariable($fld) $Info(dataListSeparator)]

  if { $trim_empty_lines } {
    DataField::data2TextWidget EquationVariable $fld $ew
  }

  #--Check that no spaces or duplicate names
  # NOTE: duplicate checking is non-case sensitive because
  # Fortran does not differentiate case in variable names
  #
  set index 1
  foreach d1 $data {

    set d1 [Util::stringTrim $d1]

    if { -1 != [string first " "  $d1] ||
         -1 != [string first "\t" $d1]
       } {
      #set msg "Space is not allowed in a variable name!  ($d1)"

      #set Info(messageIcon) error
      #Message::dispOkMessage $msg
      #set is_ok 0
      #break
    }

    set data2 [lrange $data $index end]
    incr index

    foreach d2 $data2 {

      set d2 [Util::stringTrim $d2]

      if { [string tolower $d1] == [string tolower $d2] } {
        set msg "Duplicate variable name: $d1 $d2"
        set Info(messageIcon) error
        Message::dispOkMessage $msg
        set is_ok 0
      }
    }
  }

  #--Result
  return $is_ok
}


# ============
# Helper procs
# ============

# We have currently only one EquationVariable parameter!!!
#
proc EquationVariable::formActiveParameter {} {
  global EquationVariable

  set EquationVariable(ids) 1
  DataField::formNonStandardParameter EquationVariable 1 "EquationVariable1"
}


# Find old variable names
#
proc EquationVariable::getOldVariableNames {} {
  global EquationVariable

  set ename $EquationVariable(currentField)
  set sep [DataField::getFieldProperty EquationVariable $ename FieldDataSep]

  set old_names [split $EquationVariable($ename,old) $sep]

  return $old_names
}


# Find variable names that were added
#
proc EquationVariable::getAddedVariableNames {} {
  global EquationVariable

  set new_names ""

  set ename $EquationVariable(currentField)
  set sep [DataField::getFieldProperty EquationVariable $ename FieldDataSep]

  set old_names [split $EquationVariable($ename,old) $sep]
  set cur_names [split $EquationVariable($ename) $sep]

  foreach cur_name $cur_names {

    if { "" == [Equation::getMatchingVariableName $cur_name $old_names] } {
      lappend new_names $cur_name
    }
  }

  return $new_names
}


# Find variable names that were removed
#
proc EquationVariable::getRemovedVariableNames {} {
  global EquationVariable

  set removed_names ""

  set ename $EquationVariable(currentField)
  set sep [DataField::getFieldProperty EquationVariable $ename FieldDataSep]

  set old_names [split $EquationVariable($ename,old) $sep]
  set cur_names [split $EquationVariable($ename) $sep]

  foreach old_name $old_names {

    if { "" == [Equation::getMatchingVariableName $old_name $cur_names] } {
      lappend removed_names $old_name
    }
  }

  return $removed_names
}


# Check that all equation variable names are store in the
# equation-name fields
# NOTE: This problem could occur if a user definition changes
# the name in an existing multi-var equation (all user defined
# equations are by multi-var default and has an initial value for the
# equation variable!)
#
proc EquationVariable::updateFieldData {} {
  global Equation EquationVariable

  foreach eq_name $Equation(allFields) {

    if { ![Equation::isEquation $eq_name] } {
      continue
    }

    set vn [DataField::getFieldProperty EquationVariable $eq_name InitialValue]

    if { $vn == "" } {
      continue
    }
    
    # Add to the existing field (if not there)
    #
    if { [info exists EquationVariable($eq_name)] } {

      set sep [DataField::getFieldProperty EquationVariable $eq_name FieldDataSep]
      set old_list [split $EquationVariable($eq_name) $sep]
      
      # This belongs always to the list!
      set EquationVariable($eq_name) $vn

      # Add each of the olds which is different from '$vn', to the list
      #
      foreach old $old_list {

        if { ![string equal -nocase $vn $old] } {
          append EquationVariable($eq_name) "$sep$old"
        }
      }
   
    }
  }
}


# Update the list of all variable names
#
proc EquationVariable::updateAllVariableNames {} {
  global EquationVariable

  set EquationVariable(allVariableNames) ""

  foreach fld $EquationVariable(allFields) {

    set sep [DataField::getFieldProperty EquationVariable $fld FieldDataSep]

    set names [split $EquationVariable($fld) $sep]

    foreach name $names {
      lappend EquationVariable(allVariableNames) $name
    }
  }
}


#End ecif_equationVariables.tcl