MCPcopy Create free account
hub / github.com/Kitware/VTK / stillRender

Method stillRender

Web/Python/vtkmodules/web/protocols.py:248–293  ·  view source on GitHub ↗

RPC Callback to render a view and obtain the rendered image.

(self, options)

Source from the content-addressed store, hash-verified

246class 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# =============================================================================

Callers

nothing calls this directly

Calls 13

strFunction · 0.85
timeMethod · 0.80
getViewMethod · 0.80
StillRenderToStringMethod · 0.80
getGlobalIdMethod · 0.80
roundFunction · 0.50
listClass · 0.50
GetSizeMethod · 0.45
getMethod · 0.45
SetSizeMethod · 0.45
getApplicationMethod · 0.45

Tested by

no test coverage detected