RPC Callback to render a view and obtain the rendered image.
(self, options)
| 246 | class vtkWebViewPortImageDelivery(vtkWebProtocol): |
| 247 | @exportRpc("viewport.image.render") |
| 248 | def stillRender(self, options): |
| 249 | """ |
| 250 | RPC Callback to render a view and obtain the rendered image. |
| 251 | """ |
| 252 | beginTime = int(round(time.time() * 1000)) |
| 253 | view = self.getView(options["view"]) |
| 254 | size = [view.GetSize()[0], view.GetSize()[1]] |
| 255 | # use existing size, overridden only if options["size"] is set. |
| 256 | resize = size != options.get("size", size) |
| 257 | if resize: |
| 258 | size = options["size"] |
| 259 | if size[0] > 0 and size[1] > 0: |
| 260 | view.SetSize(size) |
| 261 | t = 0 |
| 262 | if options and "mtime" in options: |
| 263 | t = options["mtime"] |
| 264 | quality = 100 |
| 265 | if options and "quality" in options: |
| 266 | quality = options["quality"] |
| 267 | localTime = 0 |
| 268 | if options and "localTime" in options: |
| 269 | localTime = options["localTime"] |
| 270 | reply = {} |
| 271 | app = self.getApplication() |
| 272 | if t == 0: |
| 273 | app.InvalidateCache(view) |
| 274 | reply["image"] = app.StillRenderToString(view, t, quality) |
| 275 | # Check that we are getting image size we have set. If not, wait until we |
| 276 | # do. The render call will set the actual window size. |
| 277 | tries = 10 |
| 278 | while resize and list(view.GetSize()) != size and size != [0, 0] and tries > 0: |
| 279 | app.InvalidateCache(view) |
| 280 | reply["image"] = app.StillRenderToString(view, t, quality) |
| 281 | tries -= 1 |
| 282 | |
| 283 | reply["stale"] = app.GetHasImagesBeingProcessed(view) |
| 284 | reply["mtime"] = app.GetLastStillRenderToMTime() |
| 285 | reply["size"] = [view.GetSize()[0], view.GetSize()[1]] |
| 286 | reply["format"] = "jpeg;base64" |
| 287 | reply["global_id"] = str(self.getGlobalId(view)) |
| 288 | reply["localTime"] = localTime |
| 289 | |
| 290 | endTime = int(round(time.time() * 1000)) |
| 291 | reply["workTime"] = endTime - beginTime |
| 292 | |
| 293 | return reply |
| 294 | |
| 295 | |
| 296 | # ============================================================================= |
nothing calls this directly
no test coverage detected