Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

consume CharEvents s and w in viewers #218

Merged
merged 3 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.md
paskino marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# ChangeLog

## vx.x.x
* Consume events 's' and 'w' in viewers to avoid render changes between wireframe and surface
* Added argument parser to idvc command. This allows the user to specify the debugging level.
* Add setting to set the number of OpenMP threads to use during DVC analysis
* Use os.path.join to create all filepaths, previously in some cases we were forcing "\" or "/" to be in some paths
* renames input files with names reference and correlate for the relative images, if data are copied in the session.
Expand Down
16 changes: 16 additions & 0 deletions src/idvc/idvc.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
import PySide2
from PySide2 import QtWidgets, QtGui
import os, sys
import logging
import argparse


def main():

parser = argparse.ArgumentParser(description='iDVC - Digital Volume Correlation Software')

parser.add_argument('--debug', type=str)
args = parser.parse_args()

if args.debug in ['debug', 'info', 'warning', 'error', 'critical']:
level = eval(f'logging.{args.debug.upper()}')
logging.basicConfig(level=level)
logging.info(f"iDVC: Setting debugging level to {args.debug.upper()}")

app = QtWidgets.QApplication([])

file_dir = os.path.dirname(__file__)
Expand All @@ -23,6 +37,8 @@ def main():
window.show()
splash.finish(window)



sys.exit(app.exec_())

if __name__ == "__main__":
Expand Down
17 changes: 16 additions & 1 deletion src/idvc/ui/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os

import ccpi.viewer.viewerLinker as vlink
import PySide2

import vtk
from ccpi.viewer import viewer2D, viewer3D
from ccpi.viewer.CILViewer2D import (SLICE_ORIENTATION_XY,
Expand All @@ -19,6 +19,7 @@
from idvc.ui.widgets import *

from idvc.utilities import RunResults
import logging


class VisualisationWindow(QtWidgets.QMainWindow):
Expand All @@ -41,6 +42,7 @@ def __init__(self, parent, viewer=viewer2D, interactorStyle=vlink.Linked2DIntera
self.interactorStyle = interactorStyle
self.createEmptyFrame()
self.threadpool = QThreadPool()
self._consume_CharEvent = ['s', 'w']

def getViewer(self):
return self.frame.viewer
Expand Down Expand Up @@ -99,6 +101,10 @@ def displayImageData(self):
vs_widgets['coords_combobox'].setEnabled(False)
vs_widgets['coords_combobox'].setCurrentIndex(0)

# consume 's' and 'w' events
# https://github.com/vais-ral/CILViewer/issues/332#issuecomment-1888940327
self.getInteractor().AddObserver('CharEvent', self.consumeCharEvent, 10.)

self.frame.viewer.setInput3DData(self.image_data)
interactor = self.frame.viewer.getInteractor()

Expand Down Expand Up @@ -150,6 +156,15 @@ def setImageData(self, image_data):
def getImageData(self):
return self.image_data

def consumeCharEvent(self, interactor, event):
'''Changes the event in self._consume_CharEvent to "" so that the event is not processed by the viewer.

This prevents the viewer from changing the rendered scene to surface or wireframe mode when the user presses 's' or 'w' respectively.
'''
if interactor.GetKeyCode() in self._consume_CharEvent:
logging.info("Consuming event: " + interactor.GetKeyCode())
interactor.SetKeyCode("")

class GraphsWindow(QMainWindow):
'''creates a new window with graphs from results saved in the selected run folder.
'''
Expand Down