Пример #1
0
 def set_colorbar_table(self, ctab):
     """Sets color table ctab (np.array) - list of colors 32-bit unsigned words"""
     self._ctab = ct.np.array(ctab)
     arr = ct.array_for_color_bar(ctab, self.orient)
     self.set_pixmap_from_arr(arr, amin=arr[0],
                              amax=arr[-1])  # method of the FWViewImage
     self.new_color_table.emit()
Пример #2
0
def test_wfviewcolorbar(tname):
    print('%s:' % sys._getframe().f_code.co_name)
    import numpy as np
    arr = np.random.random((1000, 100))
    #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 = FWViewColorBar(None,
                           coltab=ctab,
                           orient='H',
                           change_mode=1,
                           scale_ctl='H')
    elif tname == '1':
        w = FWViewColorBar(None, coltab=ctab, orient='V')
    else:
        print('test %s is not implemented' % tname)
        return

    w.setWindowTitle(w._name)

    w.connect_mouse_move_event_to(w.test_mouse_move_event_reception)
    w.connect_new_color_table_index_is_selected_to(
        w.test_new_color_table_index_is_selected_reception)
    w.connect_new_color_table_to(w.test_new_color_table_reception)

    w.show()
    app.exec_()

    del w
    del app
Пример #3
0
    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)
Пример #4
0
 def set_colorbar_table(self, ctab):
     """Sets color table ctab (np.array) - list of colors 32-bit unsigned words"""
     self._ctab = ct.np.array(ctab)
     arr = ct.array_for_color_bar(ctab, self.orient)
     self.set_pixmap_from_arr(arr)  # method of the FWViewImage
     #print('XXX Color table:', ctab)
     #self.emit(QtCore.SIGNAL('new_color_table()'))
     self.new_color_table.emit()
Пример #5
0
 def __init__(self, parent=None,\
              coltab=ct.color_table_rainbow(ncolors=1000, hang1=250, hang2=-20),\
              orient='H', wlength=200, wwidth=50, change_mode=0o3, scale_ctl=''):
     self.orient = orient
     #print('XXX FWViewColorBar.orient: %s' % self.orient)
     arrct = ct.array_for_color_bar(coltab, orient)
     self._ctab_ind = None
     self._ctab = coltab
     self.wlength = wlength
     self.wwidth = wwidth
     self.change_mode = change_mode
     FWViewImage.__init__(self,
                          parent,
                          arrct,
                          coltab=None,
                          origin='UL',
                          scale_ctl=scale_ctl)
     self._name = self.__class__.__name__
Пример #6
0
    def __init__(self, parent=None, arr=None,\
                 coltab=ct.color_table_rainbow(ncolors=1000, hang1=250, hang2=-20),\
                 origin='UL', scale_ctl='HV') :

        FWViewImage.__init__(self, parent, arr, coltab, origin, scale_ctl)

        self.add_request = None
        self.lst_drag_items = []
        self.scale_ctl_normal = scale_ctl
Пример #7
0
 def set_colorbar_table_ind(self, ctab_ind=None):
     """Sets color table from the list of pre-set tables by their index.
        ctab_ind=None - set next table in a loop.
     """
     ctab = ct.next_color_table(ctab_ind)
     self._ctab_ind = ctab_ind if ctab_ind is not None else ct.STOR.color_table_index(
     )
     self.set_colorbar_table(ctab)
     #self.emit(QtCore.SIGNAL('new_color_table_index_is_selected(int)'), self._ctab_ind)
     self.new_color_table_index_is_selected.emit(self._ctab_ind)
Пример #8
0
    def __init__(self, parent=None, arr=None,\
                 coltab=ct.color_table_rainbow(ncolors=1000, hang1=250, hang2=-20),\
                 origin='UL', scale_ctl='HV') :

        h, w = arr.shape
        rscene = QRectF(0, 0, w, h)
        FWView.__init__(self, parent, rscene, origin, scale_ctl)
        self._name = self.__class__.__name__
        self.set_coltab(coltab)
        self.pmi = None
        self.set_pixmap_from_arr(arr)
Пример #9
0
    def fill_list(self):
        for i in range(1, 9):
            item = QListWidgetItem('%02d' % i, self.list)
            item.setSizeHint(QSize(200, 30))
            item._coltab_index = i
            #item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
            lab = QLabel(parent=None)
            lab.setPixmap(ct.get_pixmap(i, size=(200, 30)))
            self.list.setItemWidget(item, lab)

        item = QListWidgetItem('cancel', self.list)
        self.list.setItemWidget(item, self.but_cancel)
Пример #10
0
    def __init__(self, parent=None, arr=None,\
                 coltab=ct.color_table_rainbow(ncolors=1000, hang1=250, hang2=-20),\
                 origin='UL', scale_ctl='HV', show_mode=0, signal_fast=True):

        h, w = arr.shape
        rscene = QRectF(0, 0, w, h)
        FWView.__init__(self, parent, rscene, origin, scale_ctl, show_mode,
                        signal_fast)
        self._name = self.__class__.__name__
        self.set_coltab(coltab)
        self.pmi = None
        self.arr_limits_old = None
        self.arr_in_rect = None
        self.set_pixmap_from_arr(arr)
Пример #11
0
    def set_pixmap_from_arr(self, arr, set_def=True):
        """Input array is scailed by color table. If color table is None arr set as is.
        """
        self.arr = arr
        anorm = arr if self.coltab is None else\
                ct.apply_color_table(arr, ctable=self.coltab)
        h, w = arr.shape

        image = QImage(anorm, w, h, QImage.Format_ARGB32)
        pixmap = QPixmap.fromImage(image)
        self.add_pixmap_to_scene(pixmap)

        if set_def:
            rs = QRectF(0, 0, w, h)
            self.set_rect_scene(rs, set_def)
Пример #12
0
    def __init__V0(self, parent=None):

        QDialog.__init__(self, parent)

        self.ctab_selected = None
        #self.list = QListWidget(parent)

        #self.fill_list(lst)
        #self.fill_list_icons(lst_icons)

        # Confirmation buttons
        self.but_cancel = QPushButton('&Cancel')
        #self.but_apply  = QPushButton('&Apply')
        #self.but_create = QPushButton('&Create')

        #cp.setIcons()
        #self.but_cancel.setIcon(cp.icon_button_cancel)
        #self.but_apply .setIcon(cp.icon_button_ok)
        #self.connect(self.but_cancel, QtCore.SIGNAL('clicked()'), self.onCancel)
        #self.connect(self.but_apply,  QtCore.SIGNAL('clicked()'), self.onApply)

        #self.hbox = QVBoxLayout()
        #self.hbox.addWidget(self.but_cancel)
        #self.hbox.addWidget(self.but_apply)
        ##self.hbox.addStretch(1)

        vbox = QVBoxLayout()
        for i in range(1, 9):
            lab = QLabel(parent=None)
            lab.setPixmap(ct.get_pixmap(i, size=(200, 30)))
            #lab.setText('%02d'%i) # set text !!!OR!!! pixmam
            #lab.setContentsMargins(QMargins(-5,-5,-5,-5))
            #lab.setFixedSize(200,10)
            lab._coltab_index = i
            vbox.addWidget(lab)

        vbox.addStretch()
        vbox.addWidget(self.but_cancel)
        self.setLayout(vbox)

        self.connect(self.but_cancel, QtCore.SIGNAL('clicked()'),
                     self.onCancel)

        self.showToolTips()
        self.setStyle()
Пример #13
0
    def set_pixmap_from_arr(self,
                            arr,
                            set_def=True,
                            amin=None,
                            amax=None,
                            frmin=0.01,
                            frmax=0.99):
        """Input array is scailed by color table. If color table is None arr set as is.
        """
        self.arr = arr
        anorm = arr if self.coltab is None else\
                ct.apply_color_table(arr, ctable=self.coltab, amin=amin, amax=amax, frmin=frmin, frmax=frmax)
        h, w = arr.shape

        image = QImage(anorm, w, h, QImage.Format_ARGB32)
        pixmap = QPixmap.fromImage(image)
        self.add_pixmap_to_scene(pixmap)

        if set_def:
            rs = QRectF(0, 0, w, h)
            self.set_rect_scene(rs, set_def)

        self.image_pixmap_changed.emit()
Пример #14
0
 def set_coltab(self,
                coltab=ct.color_table_rainbow(ncolors=1000,
                                              hang1=250,
                                              hang2=-20)):
     self.coltab = coltab
Пример #15
0
    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