def midLineDraw(self, event): newLine = QtCore.QLineF(self.line.line().p1(), event.scenePos()) self.line.setLine(newLine) # attach source or sink connection #if QtCore.Qt.AltModifier == getKeyboardModifiers(): # self.line.setPen(QtGui.QPen(QtCore.Qt.blue, 2)) # self.dumpCursorStack() # QtGui.QApplication.setOverrideCursor( # QtGui.QCursor(QtCore.Qt.CrossCursor)) # return #else: # self.line.setPen(QtGui.QPen(QtCore.Qt.red, 2)) startItems = self.items(event.scenePos()) if len(startItems) and startItems[0] == self.line: startItems.pop(0) self.dumpCursorStack() QtGui.QApplication.setOverrideCursor( QtGui.QCursor(QtCore.Qt.ForbiddenCursor)) if len(startItems): if isinstance(startItems[0], Port): self.dumpCursorStack() QtGui.QApplication.setOverrideCursor( QtGui.QCursor(QtCore.Qt.CrossCursor))
def __init__(self, title, parent=None): super(ReduceSliders, self).__init__(title, parent) self.sl = gpi.BasicCWFCSliders() self.sl.valueChanged.connect(self.valueChanged) # at least one button self.button_names = ['C/W', 'B/E', 'Slice', 'Pass'] self.buttons = [] cnt = 0 wdgLayout = QtGui.QGridLayout() for name in self.button_names: newbutton = QtGui.QPushButton(name) newbutton.setCheckable(True) newbutton.setAutoExclusive(True) self.buttons.append(newbutton) newbutton.clicked.connect(self.findValue) newbutton.clicked.connect(self.valueChanged) wdgLayout.addWidget(newbutton, 0, cnt, 1, 1) cnt += 1 # layout wdgLayout.addWidget(self.sl, 1, 0, 1, 4) wdgLayout.setVerticalSpacing(0) wdgLayout.setSpacing(0) self.setLayout(wdgLayout) # default self.set_min(1) self._selection = 3 # pass is default self.buttons[self._selection].setChecked(True) self.sl.set_allvisible(False)
def _init_toolbar(self): self.basedir = os.path.join(matplotlib.rcParams['datapath'], 'images') for text, tooltip_text, image_file, callback in self.toolitems: if text is None: self.addSeparator() else: a = self.addAction(self._icon(image_file + '.png'), text, getattr(self, callback)) self._actions[callback] = a if callback in ['zoom', 'pan']: a.setCheckable(True) if tooltip_text is not None: a.setToolTip(tooltip_text) self.buttons = {} # Add the x,y location widget at the right side of the toolbar # The stretch factor is 1 which means any resizing of the toolbar # will resize this label instead of the buttons. if self.coordinates: self.locLabel = QtGui.QLabel("", self) self.locLabel.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTop) self.locLabel.setSizePolicy( QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Ignored)) labelAction = self.addWidget(self.locLabel) labelAction.setVisible(True) # reference holder for subplots_adjust window self.adj_window = None
def startLineDraw(self, event): # highlight all ports that match startItems = self.items(event.scenePos()) if len(startItems): if isinstance(startItems[0], OutPort): if QtCore.Qt.AltModifier == getKeyboardModifiers(): startItems[0].toggleMemSaver() return self.portMatches = startItems[0].findMatchingInPorts() for port in self.portMatches: port.scaleUp() self.graph.viewAndSceneForcedUpdate() if isinstance(startItems[0], InPort): self.portMatches = startItems[0].findMatchingOutPorts() for port in self.portMatches: port.scaleUp() self.graph.viewAndSceneForcedUpdate() self.line = QtGui.QGraphicsLineItem( QtCore.QLineF(event.scenePos(), event.scenePos())) fade = QtGui.QColor(QtCore.Qt.red) fade.setAlpha(150) self.line.setPen(QtGui.QPen(fade, 2)) self.line.setZValue(10) self.addItem(self.line)
def setLayoutType(self, typ): '''The basic layout is VBox or HBox. ''' self._layoutType = typ if typ == 'vbox': self._layout = QtGui.QVBoxLayout() elif typ == 'hbox': self._layout = QtGui.QHBoxLayout()
def __init__(self, dry_run=False): super().__init__() self._updater = CondaUpdater(dry_run=dry_run) self._updater.getStatus_done.connect(self.showStatus) self._updater.getStatus_done.connect(self.showOKorUpdateButton) self._updater.failed.connect(self.initFailureMode) self._updater.updateAllPkgs_done.connect(self.relaunchProc) style = ''' QProgressBar { background-color: rgb(226,226,226); border: 1px solid rgb(222,222,222); border-radius: 2px; text-align: center; } QProgressBar::chunk { background-color: #0099FF; height: 15px; width: 1px; } ''' self._pbar = QtGui.QProgressBar(self) self._pbar.setStyleSheet(style) self._updater.pdone.connect(self.pdone) self._txtbox = TextBox('') self._txtbox.wdg.setTextFormat(QtCore.Qt.RichText) self._txtbox.set_wordwrap(True) self._txtbox.set_openExternalLinks(True) self._updater.message.connect(self._txtbox.set_val) self._txtbox.set_val('Checking for updates...') self._okButton = QtGui.QPushButton("OK") self._okButton.setVisible(False) self._cancelButton = QtGui.QPushButton("Cancel") self._cancelButton.clicked.connect(self.close) hbox = QtGui.QHBoxLayout() hbox.addStretch(1) hbox.addWidget(self._okButton) hbox.addWidget(self._cancelButton) vbox = QtGui.QVBoxLayout() vbox.addWidget(self._txtbox, 1) vbox.addWidget(self._pbar) vbox.addLayout(hbox) self.setLayout(vbox) self.setGeometry(300, 300, 400, 350) self.setWindowTitle('GPI Update') self.show() self.raise_() ExecRunnable(Runnable(self._updater.getStatus))
def generateNodeSearchActions(self, txt, menu, mousemenu): # user query txt = txt.lower() # NODE SEARCH # search using txt string sortedMods = [] if len(txt) > 2: # match anywhere in name for node in list(self._known_GPI_nodes.values()): if node.name.lower().find(txt) > -1: sortedMods.append(node) else: # only match from start of name for node in list(self._known_GPI_nodes.values()): if node.name.lower().startswith(txt): sortedMods.append(node) sortedMods = sorted(sortedMods, key=lambda x: x.name.lower()) # create actions and add them to the menu for node in sortedMods: a = QtGui.QAction(node.name+" (" + node.thrd_sec + ")", self._parent, statusTip="Click to instantiate the \'"+str(node.name)+"\' node.") s = {'subsig': node} # Somehow this lambda or the way this signal is connected, the # s-dict is fully copied which is required to pass the correct # mod name. self._parent.connect(a, QtCore.SIGNAL("triggered()"), lambda who=s: self.addNodeAndCloseMouseMenu(who, menu, mousemenu)) menu.addAction(a) # NETWORK SEARCH # search using txt string if True: sortedMods= [] if len(txt) > 2: for net in list(self._known_GPI_networks.values()): if net.name.lower().find(txt) > -1: sortedMods.append(net) else: for net in list(self._known_GPI_networks.values()): if net.name.lower().startswith(txt): sortedMods.append(net) sortedMods = sorted(sortedMods, key=lambda x: x.name.lower()) if len(sortedMods): menu.addSeparator() # create actions and add them to the menu for net in sortedMods: a = QtGui.QAction(net.name+" (net) (" + net.thrd_sec + ")", self._parent, statusTip="Click to instantiate the \'"+str(net.name)+"\' network.") s = {'sig': 'load', 'subsig': 'net', 'path': net.fullpath} self._parent.connect(a, QtCore.SIGNAL("triggered()"), lambda who=s: self.addNodeAndCloseMouseMenu(who, menu, mousemenu)) menu.addAction(a)
def __init__(self, graph, destPort, sourcePort): super(EdgeTracer, self).__init__() # show a faux copy of the delete menu menu = QtWidgets.QMenu() menu.addAction("Delete") # position of pipe end based on port type bindout_y = 5 bindin_y = -1 p1 = self.mapFromItem(sourcePort, 3.5, bindin_y) p2 = self.mapFromItem(destPort, 3.5, bindout_y) pos = graph.mapToGlobal(graph.mapFromScene((p1 - p2) / 2 + p2)) # render the menu without executing it try: # PyQt4 menupixmap = QtGui.QPixmap().grabWidget(menu) except AttributeError: menupixmap = menu.grab() # QtGui.QPixmap().grabWidget(menu) # round edges #mask = menupixmap.createMaskFromColor(QtGui.QColor(255, 255, 255), QtCore.Qt.MaskOutColor) #p = QtGui.QPainter(menupixmap) #p.setRenderHint(QtGui.QPainter.Antialiasing) #p.drawRoundedRect(0,0,menupixmap.width(),menupixmap.height(), 5,5) #p.drawPixmap(menupixmap.rect(), mask, mask.rect()) #p.end() # display the menu image (as a dummy menu as its being built) # TODO: this could probably be moved to the FauxMenu self._tracer = QtWidgets.QLabel() self._tracer.setWindowFlags(QtCore.Qt.Tool | QtCore.Qt.FramelessWindowHint) self._tracer.move(pos) self._tracer.setPixmap(menupixmap) self._tracer.show() self._tracer.raise_() # draw a faux selected line line = QtCore.QLineF(p1, p2) self.setPen( QtGui.QPen(QtGui.QColor(QtCore.Qt.red), 2, QtCore.Qt.DashLine, QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin)) self.setLine(line) self.setZValue(0) # cleanup both menu item and line by removing from scene (parent). self._timer = QtCore.QTimer() self._timer.singleShot(300, lambda: graph.scene().removeItem(self))
def __init__(self, title, parent=None): super(FFTW_GROUP, self).__init__(title, parent) self._val = {} self._val['length'] = 1 self._val['in_len'] = 1 # the original array length self.db = gpi.BasicDoubleSpinBox() # factor self.db.set_label('factor:') self.db.set_min(0.001) self.db.set_max(gpi.GPI_FLOAT_MAX) self.db.set_decimals(3) self.db.set_singlestep(0.001) self.db.set_val(1) self.sb = gpi.BasicSpinBox() # length self.sb.set_label('length:') self.sb.set_min(1) self.sb.set_val(1) self.sb.set_max(gpi.GPI_INT_MAX) self.db.valueChanged.connect(self.factChange) self.sb.valueChanged.connect(self.lenChange) vbox = QtGui.QHBoxLayout() vbox.addWidget(self.db) vbox.addWidget(self.sb) vbox.setStretch(0, 0) vbox.setStretch(1, 0) vbox.setStretch(2, 0) vbox.setContentsMargins(0, 0, 0, 0) # we don't need margins here vbox.setSpacing(0) self.setLayout(vbox)
def subplotSpacingOptions(self): if self.fig is None: return # don't allow the user to open extra windows if self.adj_window is not None: if self.adj_window.isActive(): self.adj_window.raise_() return self.adj_window = MainWin_close() self.adj_window.window_closed.connect(self.copySubplotSettings) win = self.adj_window win.setWindowTitle("Subplot Configuration Tool") image = os.path.join(matplotlib.rcParams['datapath'], 'images', 'matplotlib.png') win.setWindowIcon(QtGui.QIcon(image)) tool = SubplotToolQt(self.fig, win) win.setCentralWidget(tool) win.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred) win.show()
def create_main_frame(self): self.fig = Figure((6.0, 4.8), dpi=100, facecolor='0.98', linewidth=6.0, edgecolor='0.93') self.axes = None self.canvas = FigureCanvas(self.fig) self.canvas.setParent(self) self.canvas.setFocusPolicy(QtCore.Qt.StrongFocus) self.canvas.setFocus() self.canvas.setSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.MinimumExpanding) #self.mpl_toolbar = NavigationToolbar(self.canvas, self) self.mpl_toolbar = NavbarTools(self.canvas, self) self.mpl_toolbar.actionTriggered.connect(self.copySubplotSettings) self.canvas.mpl_connect('key_press_event', self.on_key_press) vbox = QtGui.QVBoxLayout() vbox.addWidget(self.canvas) # the matplotlib canvas vbox.addWidget(self.mpl_toolbar) return vbox
def getTitleWidth(self): '''Determine how long the module box is.''' buf = self.getMacroNodeName() fm = QtGui.QFontMetricsF(self.title_font) bw = fm.width(buf) + 11.0 bh = fm.height() return (bw, bh)
def __init__(self, title, parent=None): super(ComboBox_GROUP, self).__init__(title, parent) self._val = {} self._val['image_quality_left'] = 0 self._val['image_quality_right'] = 0 #image_quality_left self.iql = gpi.ComboBox('image_quality_left') self.iql.set_items(['choose..', 'excellent', 'good', 'diagnostic', 'non-diagnostic']) #self.iql.set_val('choose..') self.iql.set_index(0) #image_quality_right self.iqr = gpi.ComboBox('image_quality_right') self.iqr.set_items(['choose..', 'excellent', 'good', 'diagnostic', 'non-diagnostic']) #self.iqr.set_val('choose..') self.iqr.set_index(0) self.iql.valueChanged.connect(self.iqlChange) self.iqr.valueChanged.connect(self.iqrChange) vbox = QtGui.QHBoxLayout() vbox.addWidget(self.iql) vbox.addWidget(self.iqr) vbox.setStretch(0, 0) vbox.setStretch(1, 0) vbox.setContentsMargins(0, 0, 0, 0) # we don't need margins here vbox.setSpacing(0) self.setLayout(vbox)
def createCheckOption(self, title, setterSlot, tristate=False, initstate=0, enabled=True): checkbox = QtGui.QCheckBox(title) checkbox.setTristate(tristate) checkbox.setCheckState(initstate) checkbox.stateChanged.connect(setterSlot) if not enabled: checkbox.setEnabled(False) return checkbox
def expandMacro(self): # before expansion save the face position for load/paste purposes self._face_colpos = self._face.getPos() self._src.setPos(self._face.pos()) self._sink.setPos(self._src.pos()) self._face.hide() self._macroedge.show() self._sink.show() self._src.show() self.resetPortParents() for port in self._src.getPorts(): port.updateEdges() for port in self._sink.getPorts(): port.updateEdges() for node in self._encap_nodes: node.setPos(self._src.pos()) node.show() for edge in node.edges(): edge.show() # initialize animation stuff self._anim_timeline = QtCore.QTimeLine(300) self._anim_timeline.finished.connect(self.jawOpen) self._anim_timeline.setFrameRange(1, 100) self._anim = [] # close jaw self._anim.append(QtGui.QGraphicsItemAnimation()) self._anim[-1].setItem(self._sink) self._anim[-1].setTimeLine(self._anim_timeline) self._anim[-1].setPosAt(1, self._sink_pos + self._src.pos()) for node, pos in zip(self._encap_nodes, self._encap_nodepos): self._anim.append(QtGui.QGraphicsItemAnimation()) self._anim[-1].setItem(node) self._anim[-1].setTimeLine(self._anim_timeline) self._anim[-1].setPosAt(1, pos + self._src.pos()) self._anim_timeline.start()
def add_include_gz_pushbutton(self): """Adding PushButton toggle for Gz along with Rf.""" self.include_gz_pushbutton = QtGui.QPushButton('Add Gz event with Rf') self.include_gz_pushbutton.setCheckable(True) self.include_gz_pushbutton.setVisible(False) self.include_gz_pushbutton.clicked.connect(self.button_clicked) self.include_gz_pushbutton.clicked.connect(self.valueChanged) # Syntax: addWidget(widget, row, col, rowSpan, colSpan) self.wdg_layout.addWidget(self.include_gz_pushbutton, 12, 1, 1, 6)
def shape(self): # hitbox for selecting path = super(Edge, self).shape() delta = QtCore.QPointF(3, 3) # padding to make it thicker line = QtGui.QPolygonF([ self.sourcePoint + delta, self.destPoint + delta, self.destPoint - delta, self.sourcePoint - delta ]) path.addPolygon(line) return path
def applyShape(self): '''Grab external QT rendering command. ''' GL.glColor4d(*self._RGBA) f = QtGui.QFont(str(self._font), self._ptsize) p = self._position if self._glwdg is None: log.critical('Reference to GLWidget is not set! Aborting render.') else: self._glwdg.renderText(p[0], p[1], p[2], self._text, f)
def add_include_in_loop_pushbutton(self): """Adding PushButton to toggle Event being included/excluded in loop.""" self.include_in_loop_pushbutton = QtGui.QPushButton( 'Add event in loop') self.include_in_loop_pushbutton.setCheckable(True) self.include_in_loop_pushbutton.setChecked(True) self.include_in_loop_pushbutton.setVisible(False) self.include_in_loop_pushbutton.clicked.connect(self.button_clicked) self.include_in_loop_pushbutton.clicked.connect(self.valueChanged) # Syntax: addWidget(widget, row, col, rowSpan, colSpan) self.wdg_layout.addWidget(self.include_in_loop_pushbutton, 11, 1, 1, 6)
def plot(self): seq = self.getData('input')['seq'] fig = plt.figure(figsize=(7, 10)) f11, f12, f13 = fig.add_subplot(611), fig.add_subplot( 612), fig.add_subplot(613) f2 = [fig.add_subplot(614), fig.add_subplot(615), fig.add_subplot(616)] t0, time_range = 0, [0, np.inf] for iB in range(1, len(seq.block_events)): block = seq.get_block(iB) is_valid = time_range[0] <= t0 <= time_range[1] if is_valid: if block is not None: if 'adc' in block: adc = block['adc'] t = adc.delay + [ (x * adc.dwell) for x in range(0, int(adc.num_samples)) ] f11.plot((t0 + t), np.zeros(len(t))) if 'rf' in block: rf = block['rf'] t = rf.t f12.plot(np.squeeze(t0 + t), abs(rf.signal)) f13.plot(np.squeeze(t0 + t), np.angle(rf.signal)) grad_channels = ['gx', 'gy', 'gz'] for x in range(0, len(grad_channels)): if grad_channels[x] in block: grad = block[grad_channels[x]] if grad.type == 'grad': t = grad.t waveform = 1e-3 * grad.waveform else: t = np.cumsum([ 0, grad.rise_time, grad.flat_time, grad.fall_time ]) waveform = [ 1e-3 * grad.amplitude * x for x in [0, 1, 1, 0] ] f2[x].plot(np.squeeze(t0 + t), waveform) t0 += core.calcduration.calcduration(block) f11.set_ylabel('adc') f12.set_ylabel('rf mag hz') f13.set_ylabel('rf phase rad') [f2[x].set_ylabel(grad_channels[x]) for x in range(3)] # Save the plot temporarily as a PNG file to be displayed by the DisplayBox Widget plt.savefig('plot_temp.png') img = QtGui.QImage() img.load('plot_temp.png') self.setAttr('Sequence Plot', val=img) os.remove('plot_temp.png')
def launch(): '''Starts the main application loop, parses any user config and commandline args.''' # start main application # for debugging force widgetcount #app = QtGui.QApplication(sys.argv+['-widgetcount']) app = QtGui.QApplication(sys.argv) # parse commandline arguments Commands.parse(app.argv()) #print Commands # start a mainwindow widget instance widget = MainCanvas() # start splash # only raise in GUI mode, don't raise in cmdline mode. if not Commands.noGUI(): if not Commands.noSplash(): spl = Splash(PLOGO_PATH) def closeraise(): spl.finish(widget) widget.show() widget.raise_() spl.terms_accepted.connect(closeraise) spl.show() spl.raise_() app.processEvents() # allow gui to update else: dummy = QtGui.QSplashScreen() dummy.show() dummy.finish(widget) widget.show() widget.raise_() sys.exit(app.exec_())
def about(self): # Display image = QtGui.QImage(LOGO_PATH) dispbox = DisplayBox('') dispbox.set_pixmap(QtGui.QPixmap.fromImage(image)) dispbox.set_scale(0.157) dispbox.set_interp(True) # Text tab = ' ' txt = '<center><font size=4><b>Graphical Programming Interface (GPI)</b></font><br><b><a href=http://gpilab.com>gpilab.com</a></b><br><br>' +\ 'Nicholas Zwart<br>Barrow Neurological Institute<br>Phoenix, Arizona' +\ '<br><br>' +\ tab + 'Release: '+ str(VERSION) + ' (' + str(RELEASE_DATE) +')' +\ '<p>'+\ 'GPI is a graphical development environment designed for rapid prototyping '+\ 'of numeric algorithms.'+\ '</p>'+\ '<p>'+\ 'GPI development is sponsored by Philips Healthcare.'+\ '</p></center>' txtbox = TextBox('') txtbox.set_val(txt) txtbox.set_wordwrap(True) txtbox.set_openExternalLinks(True) # set layout wdgvbox = QtGui.QVBoxLayout() wdgvbox.addWidget(dispbox) wdgvbox.addWidget(txtbox) wdgvbox.setStretch(0, 2) # set master widget self.aboutWdg = QtGui.QWidget() self.aboutWdg.setLayout(wdgvbox) # self.aboutWdg.setSizePolicy(QtGui.QSizePolicy.Minimum, \ # QtGui.QSizePolicy.Preferred) # self.aboutWdg.setMaximumWidth(420) self.aboutWdg.show() self.aboutWdg.raise_() log.debug(str(dispbox.sizeHint()))
def createSlider(self, changedSignal, setterSlot): slider = QtGui.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.valueChanged.connect(setterSlot) changedSignal.connect(slider.setValue) return slider
def __init__(self, title, parent=None): super(OrderButtons, self).__init__(title, parent) # at least one button wdgLayout = QtGui.QGridLayout() self.wdg = GPITabBar() self.wdg.addTab('0') self.wdg.setMovable(True) self.wdg.currentChanged.connect(self.valueChanged.emit) # layout wdgLayout.addWidget(self.wdg) self.setLayout(wdgLayout)
def console(self): log.debug("MainCanvas(): console()") self.txtbox = TextEdit('Console') # Redirect stdio sys.stdout = Tee(sys.stdout) sys.stderr = Tee(sys.stderr) # NOTE: this is only good for QThread NOT Multiprocess. sys.stdout.newStreamTxt.connect(self.consoleWrite) sys.stderr.newStreamTxt.connect(self.consoleWrite) # set layout wdgvbox = QtGui.QVBoxLayout() wdgvbox.addWidget(self.txtbox) # set master widget self.consoleWdg = QtGui.QWidget() self.consoleWdg.setLayout(wdgvbox) self.consoleWdg.show() self.consoleWdg.raise_()
def collapseMacro(self): if self.validateSrcNodes(): return False if self.validateSinkNodes(): return False self.listEncapsulatedNodes() if manager.isDebug(): log.debug("nodes:") for node in self._encap_nodes: log.debug(node.name) self.saveNodePos() self._face.setPos(self._src.pos()) # initialize animation stuff self._anim_timeline = QtCore.QTimeLine(300) self._anim_timeline.finished.connect(self.jawClosed) self._anim_timeline.setFrameRange(1, 100) self._anim = [] # close jaw self._anim.append(QtGui.QGraphicsItemAnimation()) self._anim[-1].setItem(self._sink) self._anim[-1].setTimeLine(self._anim_timeline) self._anim[-1].setPosAt(1, self._src.pos()) for node in self._encap_nodes: self._anim.append(QtGui.QGraphicsItemAnimation()) self._anim[-1].setItem(node) self._anim[-1].setTimeLine(self._anim_timeline) self._anim[-1].setPosAt(1, self._src.pos()) self._anim_timeline.start() return True
def add_event_pushbuttons(self): """Adding PushButtons for the Events.""" col_count = 0 for name in self.button_names_list: new_button = QtGui.QPushButton(name) new_button.setCheckable(True) new_button.setAutoExclusive(True) new_button.clicked.connect(self.button_clicked) new_button.clicked.connect(self.valueChanged) # Syntax: addWidget(widget, row, col, rowSpan, colSpan) self.wdg_layout.addWidget(new_button, 0, col_count, 1, 1) self.buttons_list.append(new_button) col_count += 1
def compute(self): import numpy as np edgeval = self.getVal('edge') # make a copy for changes if self.getVal('LeftRight'): outright = self.getData('inleft') outleft = self.getData('inright') else: outleft = self.getData('inleft') outright = self.getData('inright') if self.getVal('Transition') == 0: # Toggle out = outleft elif self.getVal('Transition') == 1: # Fade cr = 0.01 * float(self.getVal('edge')) cl = 1. - cr out = cl * outleft.astype(np.float) + cr * outright.astype( np.float) elif self.getVal('Transition') == 2: # Horizontal out = np.append(outleft[:edgeval, :, :], outright[edgeval:, :, :], axis=0) elif self.getVal('Transition') == 3: # Vertical out = np.append(outleft[:, :edgeval, :], outright[:, edgeval:, :], axis=1) elif self.getVal('Transition') == 4: # Color out = np.copy(outleft) if self.getVal('edge') <= 1 or self.getVal('edge') == 5: out[:, :, 2] = outright[:, :, 2] # Red if self.getVal('edge') >= 1 and self.getVal('edge') <= 3: out[:, :, 1] = outright[:, :, 1] # Green if self.getVal('edge') >= 3: out[:, :, 0] = outright[:, :, 0] # Blue image1 = out.astype(np.uint8) h, w = out.shape[:2] format_ = QtGui.QImage.Format_RGB32 image = QtGui.QImage(image1.data, w, h, format_) image.ndarray = image1 if image.isNull(): self.log.warn("Image Viewer: cannot load image") self.setAttr('Viewport:', val=image) self.setData('out', image1) return 0
def __init__(self, title, parent=None): super(ConfigSeqWidgets, self).__init__(title, parent) self.button_names_list = [ 'Off', 'SincRfPulse', 'HardRfPulse', 'TrapGradPulse', 'TriangleGradPulse' ] self.clicked_button_name, self.clicked_button_index = '', 0 self.buttons_list, self.string_box_list = [], [] # Labels for StringBoxes to configure Events self.sinc_rf_labels = [ 'Name', 'Observe', 'ADCs', 'Apodization', 'Bandwidth', 'Axis', 'FlipAngle', 'Frequency', 'HardwareMode', 'InitialDelay', 'InitialPhase', 'Refocusing', 'Symmetry', 'Vector', ' Zeros' ] self.hard_rf_labels = [ 'Name', 'Observe', 'ADCs', 'Channel', 'Duration', 'FlipAngle', 'Frequency', 'HardwareMode', 'InitialDelay', 'InitialPhase', 'Refocusing', 'Symmetry', 'Vector' ] self.trap_grad_labels = [ 'Name', 'Observe', 'ADCs', 'Area', 'Asymmetric', 'Axis', 'Duration', 'EddyConvLength', 'EddyCurrents', 'FlatTopArea', 'FlatTopTime', 'Frequency', 'HardwareMode', 'Hide', 'InitialDelay', 'InitialPhase', 'MaxAmpl', 'NLG_field', 'PhaseLock', 'SlewRate' ] self.triangle_grad_labels = [ 'Name', 'Observe', 'ADCs', 'Amplitude', 'Axis', 'Duration', 'EddyConvLength', 'EddyCurrents', 'HardwareMode', 'Hide', 'InitialDelay', 'InitialPhase', 'MaxAmpl', 'NLG_field', 'PhaseLock', 'TriangleType', 'Vector' ] # Variable to denote the maximum number of StringBoxes to be added; obviously depends on the Event which has the # maximum number of configuration parameters_params self.num_string_boxes = max(len(self.hard_rf_labels), len(self.trap_grad_labels)) # First index is None because the first button is 'Off'. Look into event_def['event_values'] in get_val() self.labels = [ None, self.sinc_rf_labels, self.hard_rf_labels, self.trap_grad_labels, self.triangle_grad_labels ] self.wdg_layout = QtGui.QGridLayout() self.add_event_pushbuttons() self.add_config_stringboxes() self.setLayout(self.wdg_layout) self.buttons_list[0].setChecked(True)
def __init__(self, title, parent=None): super(SHAPES_GROUP, self).__init__(title, parent) self._val = {} self._val['size'] = 1 self._val['width'] = 1 self.sb = gpi.BasicSpinBox() # size self.sb.set_label('size:') self.sb.set_min(1) self.sb.set_val(1) self.sb.set_max(gpi.GPI_INT_MAX) self.slb = gpi.BasicSlider() # width self.slb.set_min(1) self.slb.set_val(1) self.slb.set_max(1) self.slider_label = QtGui.QLabel('width:') self.sb.valueChanged.connect(self.sizeChange) self.slb.valueChanged.connect(self.widthChange) hbox = QtGui.QHBoxLayout() hbox.addWidget(self.slider_label) hbox.addWidget(self.slb) hbox.setStretch(0, 0) hbox.setSpacing(5) hboxGroup = QtGui.QHBoxLayout() hboxGroup.addWidget(self.sb) hboxGroup.addLayout(hbox) hboxGroup.setStretch(0, 0) hboxGroup.setContentsMargins(0, 0, 0, 0) # we don't need margins here hboxGroup.setSpacing(30) self.setLayout(hboxGroup)