def __call__(self, restriction=None): """ This could be used to return a fieldproxy binded on the same fieldHandler than self, but with options that restrict the usage to a domain specified by the given arguments (restricted to a component, to a part of the mesh, ...). """ medcalc.wrn("Not implemented yet. Return the field itself") self.__restriction = restriction return self
def eventListenerIsRunning(): global __eventListener if __eventListener is not None: return True # Try to define the event listener connectEventListener() if __eventListener is None: # it definitely does not work medcalc.wrn( "the GUI is not loaded yet and will not be notified of the modification" ) return False return True
def connectEventListener(): global __eventListener try: eventListenerIOR = dataManager.getEventListenerIOR() __eventListener = salome.orb.string_to_object(eventListenerIOR) except SALOME.SALOME_Exception as e: medcalc.wrn("The event listener is not running yet") msg = "When you'll have loaded the MED GUI, " msg += "call explicitly \"medcalc.medevents.connectEventListener()\" " msg += "to connect the GUI event listener" medcalc.inf(msg) __eventListener = None except Exception as e: medcalc.err("An unknown error occurs. Check if this ior=%s is valid." % eventListenerIOR) print(e)
def __setattr__(self, name, value): """ This method realizes the write proxy pattern toward the field handler. Only some attributes are writable. The list is specified in the PROXY_ATTRIBUTES_MAP table. """ if name in list(PROXY_ATTRIBUTES_MAP.keys()): if PROXY_ATTRIBUTES_MAP[name] is not None: medcalc.wrn( "The modification of this attribute can't be done that way" ) msg = "Use f.update(%s=\"%s\") instead to ensure synchronisation of data." medcalc.inf(msg % (PROXY_ATTRIBUTES_MAP[name], value)) else: medcalc.err( "The modification of the attribute %s is not possible" % name) else: self.__dict__[name] = value
def getEnvironment(local=True, remote=False): """ This function return the status of the medcalc context, i.e. the list of fields defined in this python session. """ status="" if local is True: dvars = pyConsoleGlobals if dvars is None: medcalc.wrn("The stat function required the specification of the python context") medcalc.inf("Type this command \"import medcalc; medcalc.setConsoleGlobals(globals())") if remote is True: status="========= Fields used in the current context ===\n" for varkey in list(dvars.keys()): var = dvars[varkey] if isinstance(var, medcalc.FieldProxy): status+="%s \t(id=%s, name=%s)\n"%(varkey,var.id,var.fieldname) if remote is True: if local is True: status+="\n========= Fields available in the data manager ===\n" fieldHandlerList = dataManager.getFieldHandlerList() for fieldHandler in fieldHandlerList: status+="id=%s\tname\t= %s\n\tmesh\t= %s\n\t(it,dt)\t= (%s,%s)\n\tsource\t= %s\n"%( fieldHandler.id, fieldHandler.fieldname, fieldHandler.meshname, fieldHandler.iteration, fieldHandler.order, fieldHandler.source) status+="---------\n" if len(fieldHandlerList) > 0: status+="(use 'f=accessField(id)' to get a field in the current context)" return status
def __iadd__(self, operande): """ These methods implements the augmented arithmetic assignments (+=) """ medcalc.wrn("NOT IMPLEMENTED YET")