25from .
import Base, Fields, Image, Logging
41 context = TestHelper.getInstance().getHelperContext()
42 modOffRend = context.module(
'oSSOffscreenRender')
43 if not modOffRend.field(
'supported').value:
44 Logging.warning(
'Offscreen rendering is not supported on this hardware. Cannot create screenshot.')
47 resultDirectory = Base.getResultDirectory()
52 filename = os.path.join(resultDirectory,
"Screenshot_%03d.png")
53 while os.path.isfile(filename % (i)):
57 path = os.path.join(resultDirectory, filename)
59 if os.path.isfile(path):
60 Logging.error(
"File with name %s already exists!" % (path))
65 changeSet.setFieldValue(
"oSSOffscreenRender.transparencyType", transparencyType)
67 changeSet.setFieldValue(
"oSSOffscreenRender.size", size)
69 changeSet.setFieldValue(
"oSSOffscreenRender.bgColor", backgroundColor)
71 modImgSave = context.module(
'oSSImgSave')
73 modOffRend.field(
"sceneGraph").connectFrom(Base.getTestCaseContext().field(SONodeName))
74 mevis.MLAB.processInventorQueue()
75 modOffRend.field(
"update").touch()
76 if not modOffRend.field(
'output0').isValid():
77 Logging.error(
'Creation of screenshot failed.')
80 modImgSave.field(
"format").value =
"PNG"
81 modImgSave.field(
'filename').value = path
82 modImgSave.field(
'save').touch()
90 helperModule = TestHelper.getInstance().getHelperContext()
92 pathname = Base.getResultDirectory()
95 Logging.error(
"ScreenShot failed (no window available)")
98 tabview = window.getTabViewControl()
107 mevis.MLAB.processEvents(
True)
110 for i
in range(0, tabview.countTabs()):
111 tabview.selectTabAtIndex(i)
113 mevis.MLAB.priv().repaintWidget(tabview.widget())
115 imgName = os.path.join(pathname, filename+
"."+str(i)+
".png")
117 if not window.createScreenshot(imgName):
118 Logging.warning(
"ScreenShot failed")
120 imgList.append(imgName)
createOffscreenScreenShot(SONodeName, filename=None, transparencyType=None, size=None, backgroundColor=None)
Create an screenshot of the given Inventor node that must be present in the given context.