Skip to content

Commit

Permalink
Merge pull request #14 from gpilab/develop
Browse files Browse the repository at this point in the history
Merge develop to master for v2.0.0 release
  • Loading branch information
borupdaniel authored Jul 30, 2019
2 parents a1f1e2b + 2b2cdc7 commit 906a5f5
Show file tree
Hide file tree
Showing 34 changed files with 3,625 additions and 312 deletions.
5 changes: 3 additions & 2 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@
# License along with the GPI core node library. If not, see
# <http://www.gnu.org/licenses/>.

VERSION = '0.5.0-n1'
RELEASE_DATE = '2015Feb16'
VERSION = '2.0.0'
RELEASE_DATE = '2019Jul30'

20 changes: 10 additions & 10 deletions display/GPI/Audio_GPI.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Copyright (c) 2014, Dignity Health
#
#
# The GPI core node library is licensed under
# either the BSD 3-clause or the LGPL v. 3.
#
#
# Under either license, the following additional term applies:
#
#
# NO CLINICAL USE. THE SOFTWARE IS NOT INTENDED FOR COMMERCIAL
# PURPOSES AND SHOULD BE USED ONLY FOR NON-COMMERCIAL RESEARCH PURPOSES. THE
# SOFTWARE MAY NOT IN ANY EVENT BE USED FOR ANY CLINICAL OR DIAGNOSTIC
Expand All @@ -13,20 +13,20 @@
# TO LIFE SUPPORT OR EMERGENCY MEDICAL OPERATIONS OR USES. LICENSOR MAKES NO
# WARRANTY AND HAS NOR LIABILITY ARISING FROM ANY USE OF THE SOFTWARE IN ANY
# HIGH RISK OR STRICT LIABILITY ACTIVITIES.
#
#
# If you elect to license the GPI core node library under the LGPL the
# following applies:
#
#
# This file is part of the GPI core node library.
#
#
# The GPI core node library is free software: you can redistribute it
# and/or modify it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of the License,
# or (at your option) any later version. GPI core node library is distributed
# in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
# the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Lesser General Public License for more details.
#
#
# You should have received a copy of the GNU Lesser General Public
# License along with the GPI core node library. If not, see
# <http://www.gnu.org/licenses/>.
Expand All @@ -38,14 +38,14 @@
import tempfile
import scipy.io.wavfile as spio
import numpy as np
from gpi import QtGui
from gpi import QtMultimedia

import gpi


class ExternalNode(gpi.NodeAPI):

"""Converts numpy arrays into .wav format for reproduction on the audio system,
"""Converts numpy arrays into .wav format for reproduction on the audio system,
writes to /tmp directory, then plays .wav file.
INPUT:
Expand Down Expand Up @@ -86,7 +86,7 @@ def compute(self):

spio.write(self._tmpfile, rate, arr)

s = QtGui.QSound('')
s = QtMultimedia.QSound('')
if s.isAvailable():
self.setAttr('Audio Info', val='Sound facilities are available.')
else:
Expand Down
6 changes: 3 additions & 3 deletions display/GPI/CrossSection_GPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import math
import gpi
from gpi.numpyqt import numpy2qimage
from gpi import QtCore, QtGui
from gpi import QtCore, QtWidgets

import numpy as np
from matplotlib.figure import Figure
Expand Down Expand Up @@ -86,7 +86,7 @@ def create_main_frame(self):

self.canvas.mpl_connect('key_press_event', self.on_key_press)

vbox = QtGui.QVBoxLayout()
vbox = QtWidgets.QVBoxLayout()
vbox.addWidget(self.canvas) # the matplotlib canvas
vbox.addWidget(self.mpl_toolbar)
self.setLayout(vbox)
Expand Down Expand Up @@ -143,7 +143,7 @@ def __init__(self, title, parent=None):
self.pb = gpi.BasicPushButton()
self.pb.set_button_title('reset')
# layout
wdgLayout = QtGui.QVBoxLayout()
wdgLayout = QtWidgets.QVBoxLayout()
wdgLayout.addWidget(self.sl)
wdgLayout.addWidget(self.pb)
self.setLayout(wdgLayout)
Expand Down
32 changes: 16 additions & 16 deletions display/GPI/DataQuery_GPI.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Copyright (c) 2014, Dignity Health
#
#
# The GPI core node library is licensed under
# either the BSD 3-clause or the LGPL v. 3.
#
#
# Under either license, the following additional term applies:
#
#
# NO CLINICAL USE. THE SOFTWARE IS NOT INTENDED FOR COMMERCIAL
# PURPOSES AND SHOULD BE USED ONLY FOR NON-COMMERCIAL RESEARCH PURPOSES. THE
# SOFTWARE MAY NOT IN ANY EVENT BE USED FOR ANY CLINICAL OR DIAGNOSTIC
Expand All @@ -13,20 +13,20 @@
# TO LIFE SUPPORT OR EMERGENCY MEDICAL OPERATIONS OR USES. LICENSOR MAKES NO
# WARRANTY AND HAS NOR LIABILITY ARISING FROM ANY USE OF THE SOFTWARE IN ANY
# HIGH RISK OR STRICT LIABILITY ACTIVITIES.
#
#
# If you elect to license the GPI core node library under the LGPL the
# following applies:
#
#
# This file is part of the GPI core node library.
#
#
# The GPI core node library is free software: you can redistribute it
# and/or modify it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of the License,
# or (at your option) any later version. GPI core node library is distributed
# in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
# the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Lesser General Public License for more details.
#
#
# You should have received a copy of the GNU Lesser General Public
# License along with the GPI core node library. If not, see
# <http://www.gnu.org/licenses/>.
Expand All @@ -37,7 +37,7 @@
# Built of Reduce_GPI.py by Nick Zwart

import gpi
from gpi import QtCore, QtGui
from gpi import QtCore, QtWidgets

# WIDGET

Expand All @@ -56,9 +56,9 @@ def __init__(self, title, parent=None):
self.button_names = ['C/W']
self.buttons = []
cnt = 0
wdgLayout = QtGui.QGridLayout()
wdgLayout = QtWidgets.QGridLayout()
for name in self.button_names:
newbutton = QtGui.QPushButton(name)
newbutton = QtWidgets.QPushButton(name)
newbutton.setCheckable(True)
newbutton.setAutoExclusive(True)
self.buttons.append(newbutton)
Expand Down Expand Up @@ -143,7 +143,7 @@ def findValue(self, value):
if self._selection == 0: # C/W
self.sl.set_cwvisible(True)
self.setCropBounds()



class ExternalNode(gpi.NodeAPI):
Expand All @@ -158,7 +158,7 @@ class ExternalNode(gpi.NodeAPI):
I/O info: - shows size of input, output arrays, print data values specified by the user
Dimension[i]
C/W - sliders select the center and width of cropping range along the ith dimension
Compute - generate sliced/cropped data and display output values in the textbox
"""
def execType(self):
Expand All @@ -179,7 +179,7 @@ def initUI(self):
# IO Ports
self.addInPort('in', 'NPYarray', obligation=gpi.REQUIRED)
self.addOutPort('out', 'NPYarray')


def validate(self):
'''update the widget bounds based on the input data
Expand All @@ -194,7 +194,7 @@ def validate(self):
# visibility and bounds
for i in range(self.ndim):
if i < dilen:
self.setAttr(self.dim_base_name+str(-i-1)+']',
self.setAttr(self.dim_base_name+str(-i-1)+']',
visible=True, max=data.shape[-i-1])
# JGP for Pass, always max out floor and ceiling always
w = self.getVal(self.dim_base_name+str(-i-1)+']')
Expand Down Expand Up @@ -222,12 +222,12 @@ def compute(self):

# update UI info
self.setAttr('I/O Info:', val="input: "+str(data.shape)+"\nInput Type: "+str(data.dtype)+"\noutput: "+str(out.shape)+"\noutput Type: "+str(out.dtype)+"\n\n Data: "+str(out))


self.setData('out', out)
else:
return(0)
# do mask operations


return(0)
64 changes: 37 additions & 27 deletions display/GPI/GLViewer_GPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@
# start logger for this module
log = gpi.logger.manager.getLogger(__name__)

from gpi import QtCore, QtGui, Qimport
QtOpenGL = Qimport("QtOpenGL")
from gpi import QtCore, QtGui, Qimport, QtWidgets, QtOpenGL, QT_API_NAME

# TODO: QtOpenGL is deprecated in recent Qt 5
# could use newer QtWidgets.QOpenGLWidget, etc. instead

try:
from OpenGL import GL, GLU, GLUT
Expand All @@ -60,8 +62,8 @@
import OpenGL.GLUT

except ImportError:
app = QtGui.QApplication(sys.argv)
QtGui.QMessageBox.critical(None, "OpenGL grabber",
app = QtWidgets.QApplication(sys.argv)
QtWidgets.QMessageBox.critical(None, "OpenGL grabber",
"PyOpenGL must be installed to run this example.")
raise

Expand Down Expand Up @@ -341,7 +343,13 @@ def cacheGLCommands(self):
desc.setGLWidgetRef(self)

def wheelEvent(self, event):
if event.delta() > 0:
try:
# PyQt4
delta = event.delta()
except AttributeError:
# PyQt5
delta = event.angleDelta().y()
if delta > 0:
self.setViewScale(0.1)
else:
self.setViewScale(-0.1)
Expand Down Expand Up @@ -426,8 +434,10 @@ class OpenGLWindow(gpi.GenericWidgetGroup):
valueChanged = gpi.Signal()

def __init__(self, title, parent=None):
if QtOpenGL is None:
raise ImportError("QtOpenGL not available in the current Qt "
"package ({})".format(QT_API_NAME))
super(OpenGLWindow, self).__init__(title, parent)

f = QtOpenGL.QGLFormat()
f.setAccum(True)
f.setDoubleBuffer(True)
Expand All @@ -436,21 +446,21 @@ def __init__(self, title, parent=None):
f.setAlpha(True)
self.glWidget = GPIGLWidget(f)

self.glWidgetArea = QtGui.QScrollArea()
self.glWidgetArea = QtWidgets.QScrollArea()
self.glWidgetArea.setWidget(self.glWidget)
self.glWidgetArea.setWidgetResizable(True)
self.glWidgetArea.setHorizontalScrollBarPolicy(
QtCore.Qt.ScrollBarAlwaysOff)
self.glWidgetArea.setVerticalScrollBarPolicy(
QtCore.Qt.ScrollBarAlwaysOff)
self.glWidgetArea.setSizePolicy(QtGui.QSizePolicy.Ignored,
QtGui.QSizePolicy.Ignored)
self.glWidgetArea.setSizePolicy(QtWidgets.QSizePolicy.Ignored,
QtWidgets.QSizePolicy.Ignored)
self.glWidgetArea.setMinimumSize(50, 50)

# self.pixmapLabelArea = QtGui.QScrollArea()
# self.pixmapLabelArea = QtWidgets.QScrollArea()
# self.pixmapLabelArea.setWidget(self.pixmapLabel)
# self.pixmapLabelArea.setSizePolicy(QtGui.QSizePolicy.Ignored,
# QtGui.QSizePolicy.Ignored)
# self.pixmapLabelArea.setSizePolicy(QtWidgets.QSizePolicy.Ignored,
# QtWidgets.QSizePolicy.Ignored)
# self.pixmapLabelArea.setMinimumSize(50, 50)

xSlider = self.createSlider(self.glWidget.xRotationChanged,
Expand All @@ -471,7 +481,7 @@ def __init__(self, title, parent=None):
antialiasing = self.createCheckOption(
'AntiAliasing', self.glWidget.setAntiAliasing, initstate=0, enabled=enableaccum)

hardwareRender = QtGui.QLabel()
hardwareRender = QtWidgets.QLabel()
hardwareRender.setFrameStyle(2)
if self.glWidget.format().directRendering():
hardwareRender.setText('Rendering: Hardware')
Expand All @@ -483,7 +493,7 @@ def __init__(self, title, parent=None):

# self.createActions()
# self.createMenus()
centralLayout = QtGui.QGridLayout()
centralLayout = QtWidgets.QGridLayout()
centralLayout.addWidget(self.glWidgetArea, 2, 0, 4, 4)
# centralLayout.setColumnStretch(0,3)
centralLayout.setRowStretch(2, 2)
Expand Down Expand Up @@ -564,27 +574,27 @@ def clearPixmap(self):
self.setPixmap(QtGui.QPixmap())

def about(self):
QtGui.QMessageBox.about(self, "About Grabber",
QtWidgets.QMessageBox.about(self, "About Grabber",
"The <b>Grabber</b> example demonstrates two approaches for "
"rendering OpenGL into a Qt pixmap.")

def createActions(self):
self.renderIntoPixmapAct = QtGui.QAction("&Render into Pixmap...",
self.renderIntoPixmapAct = QtWidgets.QAction("&Render into Pixmap...",
self, shortcut="Ctrl+R", triggered=self.renderIntoPixmap)

self.grabFrameBufferAct = QtGui.QAction("&Grab Frame Buffer", self,
self.grabFrameBufferAct = QtWidgets.QAction("&Grab Frame Buffer", self,
shortcut="Ctrl+G", triggered=self.grabFrameBuffer)

self.clearPixmapAct = QtGui.QAction("&Clear Pixmap", self,
self.clearPixmapAct = QtWidgets.QAction("&Clear Pixmap", self,
shortcut="Ctrl+L", triggered=self.clearPixmap)

self.exitAct = QtGui.QAction("E&xit", self, shortcut="Ctrl+Q",
self.exitAct = QtWidgets.QAction("E&xit", self, shortcut="Ctrl+Q",
triggered=self.close)

self.aboutAct = QtGui.QAction("&About", self, triggered=self.about)
self.aboutAct = QtWidgets.QAction("&About", self, triggered=self.about)

self.aboutQtAct = QtGui.QAction("About &Qt", self,
triggered=QtGui.qApp.aboutQt)
self.aboutQtAct = QtWidgets.QAction("About &Qt", self,
triggered=QtWidgets.qApp.aboutQt)

def createMenus(self):
self.fileMenu = self.menuBar().addMenu("&File")
Expand All @@ -599,7 +609,7 @@ def createMenus(self):
self.helpMenu.addAction(self.aboutQtAct)

def createCheckOption(self, title, setterSlot, tristate=False, initstate=0, enabled=True):
checkbox = QtGui.QCheckBox(title)
checkbox = QtWidgets.QCheckBox(title)
checkbox.setTristate(tristate)
checkbox.setCheckState(initstate)
checkbox.stateChanged.connect(setterSlot)
Expand All @@ -608,12 +618,12 @@ def createCheckOption(self, title, setterSlot, tristate=False, initstate=0, enab
return checkbox

def createSlider(self, changedSignal, setterSlot):
slider = QtGui.QSlider(QtCore.Qt.Horizontal)
slider = QtWidgets.QSlider(QtCore.Qt.Horizontal)
slider.setRange(0, 360 * 16)
slider.setSingleStep(16)
slider.setPageStep(15 * 16)
slider.setTickInterval(15 * 16)
slider.setTickPosition(QtGui.QSlider.TicksRight)
slider.setTickPosition(QtWidgets.QSlider.TicksRight)

slider.valueChanged.connect(setterSlot)
changedSignal.connect(slider.setValue)
Expand All @@ -630,8 +640,8 @@ def setPixmap(self, pixmap):
self.pixmapLabel.resize(size)

def getSize(self):
text, ok = QtGui.QInputDialog.getText(self, "Grabber",
"Enter pixmap size:", QtGui.QLineEdit.Normal,
text, ok = QtWidgets.QInputDialog.getText(self, "Grabber",
"Enter pixmap size:", QtWidgets.QLineEdit.Normal,
"%d x %d" % (self.glWidget.width(), self.glWidget.height()))

if not ok:
Expand Down
Loading

0 comments on commit 906a5f5

Please sign in to comment.