Commit ccecd7ca authored by Ingo Meyer's avatar Ingo Meyer

Bugfix: The application does not crash any more when images or videos

are exported
parent a55ef275
......@@ -47,7 +47,7 @@ class GLWidget(QOpenGLWidget if has_qopenglwidget else QGLWidget):
return self.control.visualization
def initializeGL(self):
def minimumSizeHint(self):
return QtCore.QSize(400, 400)
......@@ -69,9 +69,7 @@ class ImageVideoTab(QtWidgets.QWidget):
ext = os.path.splitext(file_name)[1]
if not ext:
file_name += '.png'
for widget in QtWidgets.QApplication.topLevelWidgets():
for gl_widget in widget.findChildren(GLWidget):
def get_selected_frames(self):
file_list = self.main_window.file_dock.file_tab.file_list
......@@ -143,6 +141,7 @@ class MassScreenshotAndVideoDialog(QtWidgets.QDialog):
self.is_rejected = False
self.process = None
self.is_first_frame = True
if self.should_save_video:
self.setWindowTitle("Saving video...")
......@@ -159,8 +158,10 @@ class MassScreenshotAndVideoDialog(QtWidgets.QDialog):
image_file_name = os.path.join(self.dir_name, "{}.{:06d}.png".format(os.path.basename(file_name), frame_number+1))
self.control.visualize(file_name, frame_number)
gr3.export(image_file_name, width, height)
self.control.visualization.save_screenshot(image_file_name, width, height,
self.is_first_frame, not self.frames_to_write)
self.is_first_frame = False
if self.frames_to_write:
......@@ -32,6 +32,7 @@ class Visualization(object):
self.width = 0
self.height = 0
self.usecurrentframebuffer = False
self.assigned_opengl_context = None
self.results = None
self.settings = VisualizationSettings()
......@@ -217,6 +218,13 @@ class Visualization(object):
self.lookat_mat = create_look_at_matrix(pt + t, t, upt)
gr3.cameralookat(pt[0] + t[0], pt[1] + t[1], pt[2] + t[2], t[0], t[1], t[2], upt[0], upt[1], upt[2])
def assign_opengl_context(self, context):
Assigns an opengl context object that is set as current opengl context before rendering.
The object must have have ``makeCurrent`` and ``doneCurrent`` methods as an interface.
self.assigned_opengl_context = context
def paint(self, width, height, usecurrentframebuffer=None, device_pixel_ratio=1):
Refresh the OpenGL scene.
......@@ -231,11 +239,17 @@ class Visualization(object):
gr3.drawimage(0, width*device_pixel_ratio, 0, height*device_pixel_ratio,
width, height, gr3.GR3_Drawable.GR3_DRAWABLE_OPENGL)
def save_screenshot(self, file_name, width=3840, height=2160):
def save_screenshot(self, file_name, width=3840, height=2160, first=True, last=True):
Save a screenshot in the given resolution.
``first`` and ``last`` can be used to indicate if the first or last screenshot is taken when
multiple images are saved in a loop for example.
if first and self.assigned_opengl_context is not None:
gr3.export(file_name, width, height)
if last and self.assigned_opengl_context is not None:
def get_object_at_2dposition(self, x, y):
oid = gr3.c_int(0)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment