def __init__(self, msg): self.msg = msg paraview.print_debug_info("\nDEBUG: %s\n" % msg)
def setattr(proxy, pname, value): """ Attempts to emulate setattr() when called using a deprecated name for a proxy property. Will make a reasonable attempt to set the value of the property with the new name if the property was deprecated and the paraview compatibility version was set to a version older than when the property was deprecated. """ version = paraview.compatibility.GetVersion() if pname == "ColorAttributeType" and proxy.SMProxy.GetProperty("ColorArrayName"): if paraview.compatibility.GetVersion() <= 4.1: # set ColorAttributeType on ColorArrayName property instead. caProp = proxy.GetProperty("ColorArrayName") proxy.GetProperty("ColorArrayName").SetData((value, caProp[1])) raise Continue() else: # if ColorAttributeType is being used, print debug information. paraview.print_debug_info(\ "'ColorAttributeType' is obsolete. Simply use 'ColorArrayName' instead. Refer to ParaView Python API changes documentation online.") # we let the exception be raised as well, hence don't return here. if pname == "AspectRatio" and proxy.SMProxy.GetProperty("ScalarBarThickness"): if paraview.compatibility.GetVersion() <= 5.3: # We can't do this perfectly, so we set the ScalarBarThickness # property instead. Assume a reasonable modern screen size of # 1280x1024 with a Render view size of 1000x600. Even if we had # access to the View proxy to get the screen size, there is no # guarantee that the view size will remain the same later on in the # Python script. span = 600 # vertical if proxy.GetProperty("Orientation").GetData() == "Horizontal": span = 1000 # Assume a scalar bar length 40% of the span. thickness = 0.4 * span / value proxy.GetProperty("ScalarBarThickness").SetData(int(thickness)) raise Continue() else: #if AspectRatio is being used, print debug info paraview.print_debug_info(\ "'AspectRatio' is obsolete. Use the 'ScalarBarThickness' property to set the width instead") # we let the exception be raised as well, hence don't return here. if pname == "Position2" and proxy.SMProxy.GetProperty("ScalarBarLength"): if paraview.compatibility.GetVersion() <= 5.3: # The scalar bar length corresponds to Position2[0] when the # orientation is horizontal and Position2[1] when the orientation # is vertical. length = value[0] if proxy.Orientation == "Vertical": length = value[1] proxy.GetProperty("ScalarBarLength").SetData(length) else: #if Position2 is being used, print debug info paraview.print_debug_info(\ "'Position2' is obsolete. Use the 'ScalarBarLength' property to set the length instead") # we let the exception be raised as well, hence don't return here. if pname == "LockScalarRange" and proxy.SMProxy.GetProperty("AutomaticRescaleRangeMode"): if paraview.compatibility.GetVersion() <= 5.4: if value: from paraview.vtk.vtkPVServerManagerRendering import vtkSMTransferFunctionManager proxy.GetProperty("AutomaticRescaleRangeMode").SetData(vtkSMTransferFunctionManager.NEVER) else: pxm = proxy.SMProxy.GetSessionProxyManager() settingsProxy = pxm.GetProxy("settings", "GeneralSettings") mode = settingsProxy.GetProperty("TransferFunctionResetMode").GetElement(0) proxy.GetProperty("AutomaticRescaleRangeMode").SetData(mode) raise Continue() if not hasattr(proxy, pname): raise AttributeError() proxy.__dict__[pname] = value raise Continue()