support group view
This commit is contained in:
		
							parent
							
								
									e38ffcfb63
								
							
						
					
					
						commit
						ddb9708ce9
					
				@ -1,6 +1,6 @@
 | 
				
			|||||||
# -*- coding: utf-8 -*-
 | 
					# -*- coding: utf-8 -*-
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Form implementation generated from reading ui file '/home/super/PycharmProjects/ISAT_with_segment_anything/ui/label_dock.ui'
 | 
					# Form implementation generated from reading ui file 'label_dock.ui'
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# Created by: PyQt5 UI code generator 5.15.7
 | 
					# Created by: PyQt5 UI code generator 5.15.7
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
@ -27,6 +27,15 @@ class Ui_Form(object):
 | 
				
			|||||||
        self.checkBox_visible = QtWidgets.QCheckBox(self.widget)
 | 
					        self.checkBox_visible = QtWidgets.QCheckBox(self.widget)
 | 
				
			||||||
        self.checkBox_visible.setObjectName("checkBox_visible")
 | 
					        self.checkBox_visible.setObjectName("checkBox_visible")
 | 
				
			||||||
        self.horizontalLayout.addWidget(self.checkBox_visible)
 | 
					        self.horizontalLayout.addWidget(self.checkBox_visible)
 | 
				
			||||||
 | 
					        self.comboBox_group_select = QtWidgets.QComboBox(self.widget)
 | 
				
			||||||
 | 
					        self.comboBox_group_select.setObjectName("comboBox_group_select")
 | 
				
			||||||
 | 
					        self.horizontalLayout.addWidget(self.comboBox_group_select)
 | 
				
			||||||
 | 
					        self.button_prev_group = QtWidgets.QPushButton(self.widget)
 | 
				
			||||||
 | 
					        self.button_prev_group.setObjectName("button_prev_group")
 | 
				
			||||||
 | 
					        self.horizontalLayout.addWidget(self.button_prev_group)
 | 
				
			||||||
 | 
					        self.button_next_group = QtWidgets.QPushButton(self.widget)
 | 
				
			||||||
 | 
					        self.button_next_group.setObjectName("button_next_group")
 | 
				
			||||||
 | 
					        self.horizontalLayout.addWidget(self.button_next_group)
 | 
				
			||||||
        self.verticalLayout.addWidget(self.widget)
 | 
					        self.verticalLayout.addWidget(self.widget)
 | 
				
			||||||
        self.listWidget = QtWidgets.QListWidget(Form)
 | 
					        self.listWidget = QtWidgets.QListWidget(Form)
 | 
				
			||||||
        self.listWidget.setObjectName("listWidget")
 | 
					        self.listWidget.setObjectName("listWidget")
 | 
				
			||||||
@ -39,3 +48,5 @@ class Ui_Form(object):
 | 
				
			|||||||
        _translate = QtCore.QCoreApplication.translate
 | 
					        _translate = QtCore.QCoreApplication.translate
 | 
				
			||||||
        Form.setWindowTitle(_translate("Form", "Form"))
 | 
					        Form.setWindowTitle(_translate("Form", "Form"))
 | 
				
			||||||
        self.checkBox_visible.setText(_translate("Form", "Visible"))
 | 
					        self.checkBox_visible.setText(_translate("Form", "Visible"))
 | 
				
			||||||
 | 
					        self.button_prev_group.setText(_translate("Form", "Previous"))
 | 
				
			||||||
 | 
					        self.button_next_group.setText(_translate("Form", "Next"))
 | 
				
			||||||
 | 
				
			|||||||
@ -42,6 +42,23 @@
 | 
				
			|||||||
        </property>
 | 
					        </property>
 | 
				
			||||||
       </widget>
 | 
					       </widget>
 | 
				
			||||||
      </item>
 | 
					      </item>
 | 
				
			||||||
 | 
					      <item>
 | 
				
			||||||
 | 
					       <widget class="QComboBox" name="comboBox_group_select"/>
 | 
				
			||||||
 | 
					      </item>
 | 
				
			||||||
 | 
					      <item>
 | 
				
			||||||
 | 
					       <widget class="QPushButton" name="button_prev_group">
 | 
				
			||||||
 | 
					        <property name="text">
 | 
				
			||||||
 | 
					         <string>Previous</string>
 | 
				
			||||||
 | 
					        </property>
 | 
				
			||||||
 | 
					       </widget>
 | 
				
			||||||
 | 
					      </item>
 | 
				
			||||||
 | 
					      <item>
 | 
				
			||||||
 | 
					       <widget class="QPushButton" name="button_next_group">
 | 
				
			||||||
 | 
					        <property name="text">
 | 
				
			||||||
 | 
					         <string>Next</string>
 | 
				
			||||||
 | 
					        </property>
 | 
				
			||||||
 | 
					       </widget>
 | 
				
			||||||
 | 
					      </item>
 | 
				
			||||||
     </layout>
 | 
					     </layout>
 | 
				
			||||||
    </widget>
 | 
					    </widget>
 | 
				
			||||||
   </item>
 | 
					   </item>
 | 
				
			||||||
 | 
				
			|||||||
@ -16,6 +16,11 @@ class LabelsDockWidget(QtWidgets.QWidget, Ui_Form):
 | 
				
			|||||||
        self.listWidget.itemSelectionChanged.connect(self.set_polygon_selected)
 | 
					        self.listWidget.itemSelectionChanged.connect(self.set_polygon_selected)
 | 
				
			||||||
        self.checkBox_visible.stateChanged.connect(self.set_all_polygon_visible)
 | 
					        self.checkBox_visible.stateChanged.connect(self.set_all_polygon_visible)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        # addded group view
 | 
				
			||||||
 | 
					        self.comboBox_group_select.currentIndexChanged.connect(self.set_group_polygon_visible)
 | 
				
			||||||
 | 
					        self.button_next_group.clicked.connect(self.go_to_next_group)
 | 
				
			||||||
 | 
					        self.button_prev_group.clicked.connect(self.go_to_prev_group)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        self.listWidget.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.CustomContextMenu)
 | 
					        self.listWidget.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.CustomContextMenu)
 | 
				
			||||||
        self.listWidget.customContextMenuRequested.connect(
 | 
					        self.listWidget.customContextMenuRequested.connect(
 | 
				
			||||||
            self.right_button_menu)
 | 
					            self.right_button_menu)
 | 
				
			||||||
@ -75,6 +80,11 @@ class LabelsDockWidget(QtWidgets.QWidget, Ui_Form):
 | 
				
			|||||||
        if self.mainwindow.load_finished:
 | 
					        if self.mainwindow.load_finished:
 | 
				
			||||||
            self.mainwindow.set_saved_state(False)
 | 
					            self.mainwindow.set_saved_state(False)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        unique_groups = {polygon.group for polygon in self.mainwindow.polygons}
 | 
				
			||||||
 | 
					        self.comboBox_group_select.clear()
 | 
				
			||||||
 | 
					        self.comboBox_group_select.addItem('All')  # add an option to view all groups
 | 
				
			||||||
 | 
					        self.comboBox_group_select.addItems(sorted(unique_groups))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def set_selected(self, polygon):
 | 
					    def set_selected(self, polygon):
 | 
				
			||||||
        item = self.polygon_item_dict[polygon]
 | 
					        item = self.polygon_item_dict[polygon]
 | 
				
			||||||
        if polygon.isSelected():
 | 
					        if polygon.isSelected():
 | 
				
			||||||
@ -114,3 +124,29 @@ class LabelsDockWidget(QtWidgets.QWidget, Ui_Form):
 | 
				
			|||||||
            check_box = widget.findChild(QtWidgets.QCheckBox, 'check_box')
 | 
					            check_box = widget.findChild(QtWidgets.QCheckBox, 'check_box')
 | 
				
			||||||
            check_box.setChecked(visible)
 | 
					            check_box.setChecked(visible)
 | 
				
			||||||
        self.checkBox_visible.setChecked(visible)
 | 
					        self.checkBox_visible.setChecked(visible)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def set_group_polygon_visible(self):
 | 
				
			||||||
 | 
					        selected_group = self.comboBox_group_select.currentText()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for polygon, item in self.polygon_item_dict.items():
 | 
				
			||||||
 | 
					            widget = self.listWidget.itemWidget(item)
 | 
				
			||||||
 | 
					            check_box = widget.findChild(QtWidgets.QCheckBox, 'check_box')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if selected_group == 'All' or polygon.group == selected_group:
 | 
				
			||||||
 | 
					                check_box.setChecked(True)
 | 
				
			||||||
 | 
					            else:
 | 
				
			||||||
 | 
					                check_box.setChecked(False)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def go_to_next_group(self):
 | 
				
			||||||
 | 
					        current_index = self.comboBox_group_select.currentIndex()
 | 
				
			||||||
 | 
					        max_index = self.comboBox_group_select.count() - 1
 | 
				
			||||||
 | 
					        if current_index < max_index:
 | 
				
			||||||
 | 
					            self.comboBox_group_select.setCurrentIndex(current_index + 1)
 | 
				
			||||||
 | 
					            self.set_group_polygon_visible()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def go_to_prev_group(self):
 | 
				
			||||||
 | 
					        current_index = self.comboBox_group_select.currentIndex()
 | 
				
			||||||
 | 
					        if current_index > 0:
 | 
				
			||||||
 | 
					            self.comboBox_group_select.setCurrentIndex(current_index - 1)
 | 
				
			||||||
 | 
					            self.set_group_polygon_visible()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user