def __init__(self, **kwargs): parent = kwargs.get('parent', None) image = kwargs.get('image', test_image(shape=(16, 16))) ctab = kwargs.get('ctab', ct.color_table_interpolated()) signal_fast = kwargs.get('signal_fast', True) QWidget.__init__(self, parent) cp.ivimageaxes = self self.wimg = FWViewImage(self, image, coltab=ctab, origin='UL', scale_ctl='HV', signal_fast=signal_fast) self.rs_old = None r = self.wimg.sceneRect() rscx = QRectF(r.x(), 0, r.width(), 1) rscy = QRectF(0, r.y(), 1, r.height()) self.wax = FWViewAxis(None, rscx, side='U', origin='UL', scale_ctl=True, wwidth=30, wlength=200, signal_fast=signal_fast) self.way = FWViewAxis(None, rscy, side='R', origin='UR', scale_ctl=True, wwidth=60, wlength=200, signal_fast=signal_fast) self.but_reset = QPushButton('Reset') self.edi_info = QTextEdit('Info') self.box = QGridLayout() self.box.setSpacing(0) self.box.setVerticalSpacing(0) self.box.setHorizontalSpacing(0) self.box.addWidget(self.edi_info, 0, 0, 1, 11) self.box.addWidget(self.way, 1, 0, 9, 1) self.box.addWidget(self.wimg, 1, 1, 9, 10) self.box.addWidget(self.wax, 10, 1, 1, 10) self.box.addWidget(self.but_reset, 10, 0, alignment=Qt.AlignCenter) self.setLayout(self.box) self.set_tool_tips() self.set_style() self.connect_scene_rect_changed() self.but_reset.clicked.connect(self.on_but_reset) self.set_info_visible(True)
def test_wfviewimage(tname): print('%s:' % sys._getframe().f_code.co_name) #import numpy as np #arr = np.random.random((1000, 1000)) arr = image_with_random_peaks((1000, 1000)) #ctab = ct.color_table_rainbow(ncolors=1000, hang1=250, hang2=-20) ctab = ct.color_table_monochr256() #ctab = ct.color_table_interpolated() app = QApplication(sys.argv) w = None if tname == '0': w = FWViewImage(None, arr, coltab=ctab, origin='UL', scale_ctl='HV') elif tname == '1': w = FWViewImage(None, arr, coltab=ctab, origin='UL', scale_ctl='H') elif tname == '2': w = FWViewImage(None, arr, coltab=ctab, origin='UL', scale_ctl='V') elif tname == '3': w = FWViewImage(None, arr, coltab=ctab, origin='UL', scale_ctl='') elif tname == '4': arrct = ct.array_for_color_bar(orient='H') w = FWViewImage(None, arrct, coltab=None, origin='UL', scale_ctl='H') w.setGeometry(50, 50, 500, 40) elif tname == '5': arrct = ct.array_for_color_bar(orient='V') w = FWViewImage(None, arrct, coltab=None, origin='UL', scale_ctl='V') w.setGeometry(50, 50, 40, 500) elif tname == '6': #ctab= ct.color_table_rainbow(ncolors=1000, hang1=0, hang2=360) #ctab = ct.color_table_rainbow(ncolors=1000, hang1=250, hang2=-20) #ctab = ct.color_table_monochr256() ctab = ct.color_table_interpolated() arrct = ct.array_for_color_bar(ctab, orient='H') w = FWViewImage(None, arrct, coltab=None, origin='UL', scale_ctl='H') w.setGeometry(50, 50, 500, 40) elif tname == '7': a = np.arange(15).reshape((5, 3)) w = FWViewImage(None, a, coltab=ctab, origin='UL', scale_ctl='HV') else: print('test %s is not implemented' % tname) return w.connect_mouse_press_event_to(w.test_mouse_press_event_reception) w.connect_mouse_move_event_to(w.test_mouse_move_event_reception) w.connect_scene_rect_changed_to(w.test_scene_rect_changed_reception) w.show() app.exec_() del w del app