Exemple #1
0
 def __init__(self):
     super().__init__()
     self.color_list: List[Color] = []
     self.position_list: List[float] = []
     self.move_ind = None
     self.image = convert_colormap_to_image(Colormap([(0, 0, 0)]))
     self.setMinimumHeight(60)
Exemple #2
0
 def clear(self):
     """
     Remove color markers. Reset to initial state.
     """
     self.color_list = []
     self.position_list = []
     self.image = convert_colormap_to_image(Colormap([(0, 0, 0), (1, 1, 1)]))
     self.repaint()
Exemple #3
0
 def __init__(self):
     super().__init__()
     self.color_list: List[Color] = []
     self.position_list: List[float] = []
     self.move_ind = None
     self.image = convert_colormap_to_image(
         ColorMap((ColorPosition(0, Color(0, 0, 0)),
                   ColorPosition(1, Color(255, 255, 255)))))
     self.setMinimumHeight(60)
Exemple #4
0
 def clear(self):
     """
     Remove color markers. Reset to initial state.
     """
     self.color_list = []
     self.position_list = []
     self.image = convert_colormap_to_image(
         ColorMap((ColorPosition(0, Color(0, 0, 0)),
                   ColorPosition(1, Color(255, 255, 255)))))
     self.repaint()
Exemple #5
0
    def __init__(self,
                 colormap: BaseColormap,
                 accepted: bool,
                 name: str,
                 removable: bool = False,
                 used: bool = False):
        super().__init__()
        self.image = convert_colormap_to_image(colormap)
        self.name = name
        self.removable = removable
        self.checked = QCheckBox()
        self.checked.setChecked(accepted)
        self.checked.setDisabled(used)
        self.setMinimumWidth(80)
        metrics = QFontMetrics(QFont())
        layout = QHBoxLayout()
        layout.addWidget(self.checked)
        layout.addStretch(1)
        self.remove_btn = QToolButton()
        self.remove_btn.setIcon(_icon_selector.close_icon)
        if removable:
            self.remove_btn.setToolTip("Remove colormap")
        else:
            self.remove_btn.setToolTip("This colormap is protected")
        self.remove_btn.setEnabled(not accepted and self.removable)

        self.edit_btn = QToolButton()
        self.edit_btn.setIcon(_icon_selector.edit_icon)
        layout.addWidget(self.remove_btn)
        layout.addWidget(self.edit_btn)
        self.setLayout(layout)
        self.checked.stateChanged.connect(self._selection_changed)
        self.edit_btn.clicked.connect(partial(self.edit_request.emit, name))
        if isinstance(colormap, ColorMap):
            self.edit_btn.clicked.connect(
                partial(self.edit_request[ColorMap].emit, colormap))
            self.edit_btn.setToolTip("Create colormap base on this")
        else:
            self.edit_btn.setDisabled(True)
            self.edit_btn.setToolTip("This colormap is not editable")
        self.remove_btn.clicked.connect(partial(self.remove_request.emit,
                                                name))
        self.setMinimumHeight(
            max(metrics.height(), self.edit_btn.minimumHeight(),
                self.checked.minimumHeight()) + 20)
Exemple #6
0
 def refresh(self):
     """Recreate presented image and force repaint event"""
     self.image = convert_colormap_to_image(self.colormap)
     self.repaint()