| 12 | clipping_variables = ['nx', 'ny', 'nz', 'dist', 'dist2', 'enable', 'onlydomain', 'notdomain'] |
| 13 | |
| 14 | class TclVariables: |
| 15 | def __init__(self, name, update_cmd, attributes = []): |
| 16 | object.__setattr__(self, '_name', name) |
| 17 | object.__setattr__(self, '_update_cmd', update_cmd) |
| 18 | object.__setattr__(self, '_attributes', attributes) |
| 19 | |
| 20 | # set corresponding variable in tcl and call update_cmd |
| 21 | def __setattr__(self, attribute_name, value): |
| 22 | if not attribute_name in self._attributes: |
| 23 | raise KeyError() |
| 24 | tcl_string = 'set '+self._name+'.'+attribute_name+' '+str(value)+'; '+self._update_cmd+';\n' |
| 25 | ngsolve.solve.Tcl_Eval(tcl_string) |
| 26 | ngsolve.Redraw() |
| 27 | |
| 28 | # return list of possible attributes - for autocompletion |
| 29 | def __dir__(self): |
| 30 | return list(self.__dict__.keys()) + self._attributes |
| 31 | |
| 32 | # rlcomplete checks existence of attribute with this function |
| 33 | def __getattr__(self, name): |
| 34 | if name in self.__dict__: |
| 35 | return self.__dict__[name] |
| 36 | |
| 37 | if name in self._attributes: |
| 38 | return True |
| 39 | raise Exception() |
| 40 | def add_group( self, name, attributes=[] ): |
| 41 | self.__dict__[name] = TclVariables(self._name +'.'+name, self._update_cmd, attributes) |
| 42 | |
| 43 | |
| 44 | visoptions = TclVariables('::visoptions', 'Ng_Vis_Set parameters', visoptions_variables) |
no outgoing calls
no test coverage detected