Creates a new filter/source proxy as a child of the specified parent proxy. Returns the proxy state for the newly created proxy as a JSON object.
(
self,
functionName,
parentId,
initialValues={},
skipDomain=False,
subProxyValues={},
)
| 3138 | |
| 3139 | @exportRpc("pv.proxy.manager.create") |
| 3140 | def create( |
| 3141 | self, |
| 3142 | functionName, |
| 3143 | parentId, |
| 3144 | initialValues={}, |
| 3145 | skipDomain=False, |
| 3146 | subProxyValues={}, |
| 3147 | ): |
| 3148 | """ |
| 3149 | Creates a new filter/source proxy as a child of the specified |
| 3150 | parent proxy. Returns the proxy state for the newly created |
| 3151 | proxy as a JSON object. |
| 3152 | """ |
| 3153 | name = self.validate(functionName) |
| 3154 | |
| 3155 | if not name: |
| 3156 | return { |
| 3157 | "success": False, |
| 3158 | "reason": '"' |
| 3159 | + functionName |
| 3160 | + '" was not valid and could not be evaluated', |
| 3161 | } |
| 3162 | |
| 3163 | pid = parentId |
| 3164 | parentProxy = self.mapIdToProxy(parentId) |
| 3165 | if parentProxy: |
| 3166 | simple.SetActiveSource(parentProxy) |
| 3167 | else: |
| 3168 | pid = "0" |
| 3169 | |
| 3170 | # Create new source/filter |
| 3171 | sanitizedInitialValues = sanitizeKeys(initialValues) |
| 3172 | allowed = self.allowedProxies[name] |
| 3173 | newProxy = paraview.simple.__dict__[allowed](**sanitizedInitialValues) |
| 3174 | |
| 3175 | # Update subproxy values |
| 3176 | if newProxy: |
| 3177 | for subProxyName in subProxyValues: |
| 3178 | subProxy = newProxy.GetProperty(subProxyName).GetData() |
| 3179 | if subProxy: |
| 3180 | for propName in subProxyValues[subProxyName]: |
| 3181 | prop = subProxy.SMProxy.GetProperty(propName) |
| 3182 | value = subProxyValues[subProxyName][propName] |
| 3183 | if isinstance(value, list): |
| 3184 | prop.SetElements(value) |
| 3185 | else: |
| 3186 | prop.SetElements([value]) |
| 3187 | subProxy.UpdateVTKObjects() |
| 3188 | |
| 3189 | # To make WebGL export work |
| 3190 | simple.Show() |
| 3191 | simple.Render() |
| 3192 | self.getApplication().InvokeEvent("UpdateEvent") |
| 3193 | |
| 3194 | try: |
| 3195 | if not skipDomain: |
| 3196 | self.applyDomains(parentProxy, newProxy.GetGlobalIDAsString()) |
| 3197 | except Exception as inst: |
nothing calls this directly
no test coverage detected