def __init__(self,
                 name,
                 text,
                 isExclusive,
                 thisGroupOption,
                 stateChanged,
                 parent=None):
        QGroupBox.__init__(self, text, parent)
        qss = "QGroupBox::title {subcontrol-origin: margin; subcontrol-position: top left; padding: 0 3px; color : red; font-weight:bold; }"
        self.setStyleSheet(qss)

        self.flayout = FloatingLayout()
        self.flayout.setSpacing(40)
        self.flayout.setMargin(4)

        self.name = str(name)
        self.text = text

        self.groupOptionDescListTuple = thisGroupOption
        self.stateChanged = stateChanged

        self.checkbox_group = QButtonGroup()
        self.checkbox_group.setExclusive(isExclusive)
        self.isExclusive = isExclusive

        self.checkboxWidgetsInfo = {
        }  # dict. checkboxWidgetsInfo[checkboxName] = [checkboxWidget, checkboxText, checkboxStyleSheet]
        self.popupWidgetsInfo = {
        }  # dict. popupWidgetsInfo[popupbutton_name] = [*, *, * , * , *]

        self._maxCheckedNum = 100
        self._maxSeperateWidgetNum = 100

        self._checked_checkbox_widgets = []
Esempio n. 2
0
    def __init__(self, attribute, values, parent=None):
        QGroupBox.__init__(self, attribute, parent)
        self._attribute      = attribute
        self._current_items  = []
        self._defaults       = {}
        self._inputField     = None
        self._inputFieldType = None
        self._insertIndex    = -1
        self._insertAtEnd    = False
        self._shortcuts      = {}

        # Setup GUI
        self._layout = FloatingLayout()
        self.setLayout(self._layout)
        self._buttons = {}
        self._labels = {}

        #Abhishek : Add Label Dropdown
        self.ann_input_combo = ExtendedCombo(self)
        self._layout.insertWidget(0,self.ann_input_combo)
        self.ann_input_combo.show()
        self.modelItem = QStandardItemModel()
        self.ann_input_combo.setModel(self.modelItem)
        self.ann_input_combo.setModelColumn(0)

        self.ann_input_combo.currentIndexChanged.connect(self.onAnnotationValueSelected)

        # Add interface elements
        self.updateValues(values)
Esempio n. 3
0
    def __init__(self, name, parent=None):
        QGroupBox.__init__(self, name, parent)
        self.setLayout(FloatingLayout())

        self.name = name
        self.button_group = QButtonGroup()
        self.button_group.setExclusive(False)
        self.buttonWidgets = {}
Esempio n. 4
0
    def _setupGUI(self):
        self._class_buttons = {}
        self._class_shortcuts = {}
        self._label_editor = None

        # Label class buttons
        self._classbox = QGroupBox("Labels", self)
        self._classbox_layout = FloatingLayout()
        self._classbox.setLayout(self._classbox_layout)

        # Global widget
        self._layout = MyVBoxLayout()
        self.setLayout(self._layout)
        self._layout.addWidget(self._classbox, 0)
        self._layout.addStretch(1)
Esempio n. 5
0
    def _setupGUI(self, _groupBoxName):
        self._widgets_dict = {}
        self._class_shortcuts = {}

        # Label class buttons
        qss = "QGroupBox::title {subcontrol-origin: margin; subcontrol-position: top left; padding: 0 3px; color : red; font-weight:bold; }"
        self._inserterButtonGroupbox = QGroupBox(_groupBoxName, self)
        self._inserterButtonGroupbox.setStyleSheet(qss)
        self._inserterButtonGroup_layout = FloatingLayout()
        self._inserterButtonGroupbox.setLayout(
            self._inserterButtonGroup_layout)

        # Global widget
        self._layout = MyVBoxLayout()
        self.setLayout(self._layout)
        self._layout.addWidget(self._inserterButtonGroupbox, 0)
        self._layout.addStretch(1)
Esempio n. 6
0
    def __init__(self, attribute, values, parent=None):
        QGroupBox.__init__(self, attribute, parent)
        self._attribute = attribute
        self._current_items = []
        self._defaults = {}
        self._inputField = None
        self._inputFieldType = None
        self._insertIndex = -1
        self._insertAtEnd = False
        self._shortcuts = {}

        # Setup GUI
        self._layout = FloatingLayout()
        self.setLayout(self._layout)
        self._buttons = {}

        # Add interface elements
        self.updateValues(values)
Esempio n. 7
0
    def __init__(self,
                 checkboxGroupName,
                 checkboxGroupText,
                 isExclusive,
                 checkGroupDescListTuple,
                 checkboxStateChangedSignal,
                 thisGroup_maxCheckedNum=100,
                 thisGroup_maxSeperateWidgetNum=100,
                 parent=None):
        QGroupBox.__init__(self, checkboxGroupText, parent)
        qss = "QGroupBox::title {subcontrol-origin: margin; subcontrol-position: top left; padding: 0 3px; color : red; font-weight:bold; }"
        self.setStyleSheet(qss)

        self.flayout = FloatingLayout()
        self.flayout.setSpacing(40)
        self.flayout.setMargin(4)

        self.groupName = str(checkboxGroupName)

        self.checkGroupDescListTuple = checkGroupDescListTuple
        self.checkboxStateChangedSignal = checkboxStateChangedSignal

        self.checkbox_group = QButtonGroup()
        self.checkbox_group.setExclusive(isExclusive)
        self.isExclusive = isExclusive

        self.checkboxWidgetsInfo = {
        }  # dict. checkboxWidgetsInfo[checkboxName] = [checkboxWidget, checkboxText, checkboxColor, checkboxStyleSheet]
        self.popupWidgetsInfo = {
        }  # dict. popupWidgetsInfo[popupbutton_name] = [*, *, * , * , *]

        self._maxCheckedNum = thisGroup_maxCheckedNum
        self._maxSeperateWidgetNum = thisGroup_maxSeperateWidgetNum

        self._checked_checkbox_widgets = []

        # create all checkboxes in this group
        optCnt = 0
        defaultCheckboxName = None
        firstCheckboxName = None
        for checkboxOption in checkGroupDescListTuple:

            thisCheckboxName = checkboxOption[config.METADATA_ATTR_VALUE_TOKEN]
            thisCheckboxText = checkboxOption[
                config.METADATA_DISPLAYTEXT_TOKEN]
            thisCheckboxIsDefault = checkboxOption.get(
                config.METADATA_IS_DEFAULT_TOKEN, False)
            defaultCheckboxName = thisCheckboxName if thisCheckboxIsDefault else defaultCheckboxName
            firstCheckboxName = thisCheckboxName if firstCheckboxName is None else firstCheckboxName

            if (checkboxGroupName
                    == config.ANNOTATION_PERSONBIKE_TYPE_GROUP_TOKEN) or (
                        checkboxGroupName
                        == config.ANNOTATION_VEHICLE_TYPE_GROUP_TOKEN):
                checkboxWidgetMinWidthInPixels = 52
            else:
                checkboxWidgetMinWidthInPixels = 38

            # get widget display color
            _thisCheckboxBkgColor = None
            _thisCheckboxBkgColorChecked = checkboxOption.get(
                config.COLOR_ATTR_RGB_VALUE_TOKEN, None)
            if _thisCheckboxBkgColorChecked:
                _thisCheckboxBkgColor = _thisCheckboxBkgColorChecked
            else:
                _thisCheckboxBkgColorChecked = checkboxOption.get(
                    config.METADATA_DISPLAYCOLOR_TOKEN, None)

            # print u"thisCheckboxName = {} thisCheckboxText = {} _thisCheckboxBkgColor = {} _thisCheckboxBkgColorChecked = {}".format(

# thisCheckboxName, thisCheckboxText, _thisCheckboxBkgColor, _thisCheckboxBkgColorChecked)

            thisCheckboxBkgColor = None
            if _thisCheckboxBkgColor:
                dummy, thisCheckboxBkgColor = utils.getColorDesc(
                    _thisCheckboxBkgColor)

            thisCheckboxBkgColorChecked = None
            if _thisCheckboxBkgColorChecked:
                dummy, thisCheckboxBkgColorChecked = utils.getColorDesc(
                    _thisCheckboxBkgColorChecked)

            # calc widget text color
            # thisCheckboxBkgColorChecked string pattern: #123456
            txtColorChecked = None
            if thisCheckboxBkgColorChecked is not None:
                import math
                rgba = utils.hexColorStrToRGBA(thisCheckboxBkgColorChecked)
                distance = math.sqrt((rgba[0] - 255)**2 + (rgba[1] - 255)**2 +
                                     (rgba[2] - 255)**2)
                txtColorChecked = '#ffffff' if distance > config.GUI_COLOR_TAG_TEXT_BLACKWHITE_TOGGLE_THRESHOLD else '#000000'

            txtColor = txtColorChecked if checkboxGroupName == config.ANNOTATION_UPPER_COLOR_TOKEN or checkboxGroupName == config.ANNOTATION_LOWER_COLOR_TOKEN or checkboxGroupName == config.ANNOTATION_VEHICLE_COLOR_TOKEN else None

            # add widget to this group
            if optCnt < thisGroup_maxSeperateWidgetNum:
                self.add_checkbox(thisCheckboxName, thisCheckboxText,
                                  thisCheckboxBkgColor, txtColor,
                                  thisCheckboxBkgColorChecked, txtColorChecked,
                                  checkboxWidgetMinWidthInPixels)
            else:
                self.add_popup_button(
                    config.GUI_MORE_WIDGET_DISPLAYTEXT,
                    thisCheckboxName,
                    thisCheckboxText,
                    popupbutton_background_color="#808080",
                    popupbutton_text_color="#ffffff",
                    checkbox_background_color=thisCheckboxBkgColor,
                    checkbox_text_color=txtColor)

            optCnt += 1

        self._defaultCheckboxName = firstCheckboxName if defaultCheckboxName is None else defaultCheckboxName
        # print "CheckboxListWidget {}: defaultCheckboxName {}".format(self.groupName, self._defaultCheckboxName)

        # if self.groupName == "helmetcolor":
        #     unsetwidgetInfo = self.checkboxWidgetsInfo.get(config.TAG_UNSET_TOKEN, None)
        #     if unsetwidgetInfo: unsetwidgetInfo[0].hide()

        # thisGroupWidget.add_checkbox("Unset", u"Unset")
        self.setLayout(self.flayout)
        return
Esempio n. 8
0
    def _setupGUI(self):
        self._class_buttons = {}
        self.label_menu = {}
        self.label_action = {}
        self._label_editor = None

        # Label class buttons
        self._parea = QGroupBox("Labels")
        self._classbox = QScrollArea()
        self._classbox_layout = FloatingLayout()
        self._parea.setLayout(self._classbox_layout)
        self._parea.setGeometry(0, 0, 200, 200)
        self._classbox.setWidget(self._parea)
        self._classbox.setGeometry(0, 0, 100, 100)
        # 添加txt模块
        self.combo_box = QComboBox()
        self._group_box_add_txt = QGroupBox('add_txt', self)
        self._group_box_add_txt_layout = QVBoxLayout()
        self._group_box_add_txt.setLayout(self._group_box_add_txt_layout)
        temp = cf.LABELS
        self.items = []
        # 获取所有的标签
        for i in temp:
            self.items.append(i['attributes']['class'])
        # 假如下拉框
        self.combo_box.addItems(self.items)
        self.add_txt_btn = QPushButton('add txt')
        self.add_txt_btn.clicked.connect(self.add_txt)
        # 加入下拉框和按钮
        self._group_box_add_txt_layout.addWidget(self.combo_box, 0)
        self._group_box_add_txt_layout.addWidget(self.add_txt_btn, 1)

        # 根据关键字搜索图片模块
        self._group_box_add_files = QGroupBox('add files', self)
        # 文件名包含的
        self._key_word = QLineEdit('')
        self._key_word.setPlaceholderText('Second')
        # 文件类型
        self._extension = QLineEdit('')
        self._extension.setPlaceholderText('bmp')
        self._search_btn = QPushButton('search files')
        self._group_box_add_files_layout = QVBoxLayout()
        # 加入控件
        self._group_box_add_files_layout.addWidget(self._key_word, 0)
        self._group_box_add_files_layout.addWidget(self._extension, 1)
        self._group_box_add_files_layout.addWidget(self._search_btn, 2)
        self._group_box_add_files.setLayout(self._group_box_add_files_layout)

        # 添加标签模块
        self._group_box_add_label = QGroupBox("添加标签", self)
        self._add_label_group_layout = QVBoxLayout()
        self._group_box_add_label.setLayout(self._add_label_group_layout)
        # 标签的class
        self.attributes_LineEdit = QLineEdit('')
        self.attributes_LineEdit.setPlaceholderText('attributes')
        # 标签画出来的类型
        self.attributes_type = QComboBox()
        self.attributes_type.addItems(self.get_attributes_type())
        # 快捷键,目前设置了只允许一个键
        self.hotkey = QLineEdit('')
        self.hotkey.setPlaceholderText('hotkey')
        self.regx = QRegExp("[a-z0-9]$")
        self.validator = QRegExpValidator(self.regx, self.hotkey)
        self.hotkey.setValidator(self.validator)
        # 标签显示
        self.text_LineEdit = QLineEdit('')
        self.text_LineEdit.setPlaceholderText('text')
        # 颜色
        color = QtGui.QColor(0, 0, 0)
        self.color_label = QtGui.QWidget()
        self.color_label.setStyleSheet("QWidget { background-color: %s }" %
                                       color.name())
        self.color_info = [0, 0, 0]
        self.color_layout = QtGui.QHBoxLayout()
        self.color_btn = QPushButton('选择颜色')
        self.color_btn.clicked.connect(self.color_dialog)
        self.color_layout.addWidget(self.color_label)
        self.color_layout.addWidget(self.color_btn)
        # 笔刷
        global brush2idx
        self.brush_combo_box = QComboBox()
        self.brush_combo_box.addItems(list(brush2idx.keys()))
        # 按钮
        self.attributes_add_btn = QPushButton('添加标签')
        self.attributes_add_btn.clicked.connect(self.add_attributes)
        # 加入控件
        self._add_label_group_layout.addWidget(self.attributes_LineEdit, 0)
        self._add_label_group_layout.addWidget(self.attributes_type, 1)
        self._add_label_group_layout.addWidget(self.hotkey, 2)
        self._add_label_group_layout.addWidget(self.text_LineEdit, 3)
        self._label_widget = QWidget()
        self._label_widget.setLayout(self.color_layout)
        self._add_label_group_layout.addWidget(self._label_widget, 4)
        self._add_label_group_layout.addWidget(self.brush_combo_box, 5)
        self._add_label_group_layout.addWidget(self.attributes_add_btn, 6)

        # 生成训练数据按钮
        self._file_button = QPushButton('生成训练数据')
        self._file_button.clicked.connect(self.generate)

        # Global widget
        self._layout = MyVBoxLayout()
        self.setLayout(self._layout)
        self._layout.addWidget(self._classbox, 1)
        self._layout.insertWidget(-1, self._group_box_add_label, 1)
        self._layout.insertWidget(-1, self._group_box_add_txt, 1)
        self._layout.insertWidget(-1, self._group_box_add_files, 1)
        self._layout.insertWidget(-1, self._file_button, 1)
Esempio n. 9
0
    def __init__(self, parent = None, mainwindow = None, exitDialogSlot = None, exitDialogSlotArg1 = None, exitDialogSlotArg2 = None):
        QWidget.__init__(self, parent)

        self._exitDialogSlot = exitDialogSlot
        self._exitDialogSlotArg1 = exitDialogSlotArg1
        self._exitDialogSlotArg2 = exitDialogSlotArg2
        self._mainwindow = mainwindow

        # self.setWindowFlags(QtCore.Qt.FramelessWindowHint|QtCore.Qt.Dialog)
        self.setWindowFlags(QtCore.Qt.Window|QtCore.Qt.WindowCloseButtonHint)

        # zx comment: must be ApplicationModal. otherwise, this dialog cannot block following codes in same thread
        self.setWindowModality(QtCore.Qt.ApplicationModal)
        self.setEnabled(True)

        self._gLayout = QVBoxLayout() # QGridLayout()
        self.checkbox_groups = []
        self.widgetsInfo = {}   # format: { widgetGroupName: [[widgetObj, widgetName], ....],  }
    
        for displayOrder, groupElementsList  in config.STATISTICS_PLUGIN_DISPLAY_ELEMENTS_DICT.items():
           groupName = groupElementsList[0]
           groupElementsList = groupElementsList[1]
           group_box = QGroupBox(str(groupName), self)
           flayout = FloatingLayout()

           # Create buttongroup
           checkbox_group = QButtonGroup(group_box)
           checkbox_group.setExclusive(False)
           checkboxs = []
           for i, token in enumerate(groupElementsList):
               # print "i = {} token = {}".format(i, token)

               if token == config.ANNOTATION_UPPER_COLOR_TOKEN or token == config.ANNOTATION_LOWER_COLOR_TOKEN or token == config.ANNOTATION_VEHICLE_COLOR_TOKEN:
                   if token == config.ANNOTATION_UPPER_COLOR_TOKEN or token == config.ANNOTATION_LOWER_COLOR_TOKEN:
                       editor = self._mainwindow.property_editor4
                   else:
                       editor = self._mainwindow.property_editor6
                   names_list, texts_list, displaycolors_list = editor.get_group_config(token)
                   for t, text in enumerate(texts_list):
                       checkbox = QCheckBox(text)

                       # get widget display color
                       if token == config.ANNOTATION_UPPER_COLOR_TOKEN or token == config.ANNOTATION_LOWER_COLOR_TOKEN or token == config.ANNOTATION_VEHICLE_COLOR_TOKEN:
                           thisCheckboxBkgColorChecked = displaycolors_list[t]
                           thisCheckboxBkgColor = thisCheckboxBkgColorChecked
                       else:
                           thisCheckboxBkgColorChecked = displaycolors_list[t]
                           thisCheckboxBkgColor = None

                           # calc widget text color
                           # thisCheckboxBkgColorChecked string pattern: #123456
                       txtColorChecked = None
                       if thisCheckboxBkgColorChecked is not None:
                           import math
                           rgba = utils.hexColorStrToRGBA(thisCheckboxBkgColorChecked)
                           distance = math.sqrt((rgba[0] - 255) ** 2 + (rgba[1] - 255) ** 2 + (rgba[2] - 255) ** 2)
                           txtColorChecked = '#ffffff' if distance > config.GUI_COLOR_TAG_TEXT_BLACKWHITE_TOGGLE_THRESHOLD else '#000000'

                       txtColor = txtColorChecked if token == config.ANNOTATION_UPPER_COLOR_TOKEN or token == config.ANNOTATION_LOWER_COLOR_TOKEN or token == config.ANNOTATION_VEHICLE_COLOR_TOKEN else None

                       desc = utils.set_qobj_stylesheet(checkbox, 'QCheckBox', thisCheckboxBkgColor,
                                                        txtColor, thisCheckboxBkgColorChecked,
                                                        txtColorChecked)
                       checkbox_group.addButton(checkbox)
                       flayout.addWidget(checkbox)
                       # print u"checkbox_group.addcheckbox {}".format(checkbox.text())
                       checkbox.clicked.connect(self.onClickedWidget)
                       checkbox.setChecked(False)
                       checkboxs.append([checkbox, names_list[t]])
               else:
                   checkbox = QCheckBox(token)
                   desc = utils.set_qobj_stylesheet(checkbox, 'QCheckBox', "#ffffff", "#000000", "#ffffff", "#000000")
                   checkbox_group.addButton(checkbox)
                   flayout.addWidget(checkbox)
                   # print "checkbox_group.addButton {}".format(checkbox)
                   checkbox.clicked.connect(self.onClickedWidget)
                   checkboxs.append([checkbox, token])

              
           all = QRadioButton("All")
           desc = utils.set_qobj_stylesheet(all, 'QRadioButton', "#ffffff", "#000000", "#ffffff", "#000000")
           checkbox_group.addButton(all)
           flayout.addWidget(all)
           all.clicked.connect(self.selectAllWidgetsInCurrentGroup)
           checkboxs.append([all, "all"])
           group_box.setLayout(flayout)
           # add this checkboxgroup to layout
           self._gLayout.addWidget(group_box)
           
           self.checkbox_groups.append(checkbox_group)
           self.widgetsInfo[groupName] = checkboxs

        self._filtersGoup = QGroupBox("Filters", self)
        self._filtersGoup_layout = QHBoxLayout()
        self._filtersGoup.setLayout(self._filtersGoup_layout)
        self._gLayout.addWidget(self._filtersGoup)

        self._buttonStatisticWithFilterWidget = QPushButton("STATISTICS with filters")
        utils.set_qobj_stylesheet(self._buttonStatisticWithFilterWidget, 'QPushButton', '#C0C0C0', '#ff0000', '#909090', '#0080FF')
        self._buttonStatisticWithFilterWidget.clicked.connect(self.onClickedStatisticWithFilter)
        self._filtersGoup_layout.addWidget(self._buttonStatisticWithFilterWidget)

        """
        self._buttonStatisticAllColorsWidget = QPushButton("STATISTICS all colors")
        utils.set_qobj_stylesheet(self._buttonStatisticAllColorsWidget, 'QPushButton', '#C0C0C0', '#ff0000', '#909090', '#0080FF')
        self._buttonStatisticAllColorsWidget.clicked.connect(self.onClickedStatisticAllColors)
        self._filtersGoup_layout.addWidget(self._buttonStatisticAllColorsWidget)
        """

        self._buttonApplyFilterOnViewModeWidget = QPushButton("Apply filters on view mode")
        utils.set_qobj_stylesheet(self._buttonApplyFilterOnViewModeWidget, 'QPushButton', '#C0C0C0', '#ff0000', '#909090', '#0080FF')
        self._buttonApplyFilterOnViewModeWidget.clicked.connect(self.onClickedApplyFilterOnViewMode)
        self._filtersGoup_layout.addWidget(self._buttonApplyFilterOnViewModeWidget)

        self._statLabelWidget = QLabel(u'<font color="red">{}</font>'.format("statistics result"))
        self._statLabelWidget.setFont(QFont("Timers", 16, QFont.Bold))
        self._gLayout.addWidget(self._statLabelWidget)

        self._statResultTxtWidget = QTextEdit('')
        self._gLayout.addWidget(self._statResultTxtWidget)


        self.setLayout(self._gLayout)
        self.setWindowTitle(config.STATISTIC_OR_APPLY_OBJVIEWFILTER_FOR_CUR_JSON_FILE_PLUGIN_DISPLAYTEXT)
        self.resize(1000, 800)

        utils.centerGuiWidget(self)
        return