Beispiel #1
0
    def __init__(self,
                 comboPannelProperty=None,
                 idName=None,
                 displayName=None,
                 groupBoxName=None,
                 parent=None):
        QWidget.__init__(self, parent)
        # print "comboPannelProperty = {}".format(comboPannelProperty)
        insertersProperty = getInsertersProperty(comboPannelProperty)
        attrAreaProperty = getAttrAreaProperty(comboPannelProperty)
        self.attrAreaWidget = AttrAreaWidget(attrAreaProperty, idName,
                                             displayName, self)
        self.propertyEditorWidget = PropertyEditor(insertersProperty,
                                                   idName,
                                                   displayName,
                                                   groupBoxName,
                                                   parent=self)

        self._displayName = displayName
        self._idName = idName

        self.vlayout = QVBoxLayout()
        self.vlayout.setAlignment(Qt.AlignTop)
        self.vlayout.setSpacing(4)
        self.vlayout.setMargin(4)
        #self.vlayout.setContentsMargins(0, 0, 0, 44)
        self.vlayout.addWidget(self.propertyEditorWidget)
        self.vlayout.addWidget(self.attrAreaWidget)
        self.vlayout.addStretch(1)
        self.setLayout(self.vlayout)
        return
Beispiel #2
0
    def setupGui(self):
        self.ui = uic.loadUi(os.path.join(GUIDIR, "labeltool.ui"), self)

        # get inserters and items from labels
        # FIXME for handling the new-style config correctly
        inserters = dict([
            (label['attributes']['class'], label['inserter'])
            for label in config.LABELS
            if 'class' in label.get('attributes', {}) and 'inserter' in label
        ])
        items = dict([
            (label['attributes']['class'], label['item'])
            for label in config.LABELS
            if 'class' in label.get('attributes', {}) and 'item' in label
        ])

        # Property Editor
        self.property_editor = PropertyEditor(config.LABELS)
        self.ui.dockProperties.setWidget(self.property_editor)

        # Scene
        self.scene = AnnotationScene(self.labeltool,
                                     items=items,
                                     inserters=inserters)
        self.property_editor.insertionModeStarted.connect(
            self.scene.onInsertionModeStarted)
        self.property_editor.insertionModeEnded.connect(
            self.scene.onInsertionModeEnded)

        # SceneView
        self.view = GraphicsView(self)
        self.view.setSizePolicy(QSizePolicy.MinimumExpanding,
                                QSizePolicy.MinimumExpanding)
        self.view.setScene(self.scene)

        self.central_widget = QWidget()
        self.central_layout = QVBoxLayout()
        self.controls = ControlButtonWidget()
        self.controls.back_button.clicked.connect(self.labeltool.gotoPrevious)
        self.controls.forward_button.clicked.connect(self.labeltool.gotoNext)

        self.central_layout.addWidget(self.controls)
        self.central_layout.addWidget(self.view)
        self.central_widget.setLayout(self.central_layout)
        self.setCentralWidget(self.central_widget)

        self.initShortcuts(config.HOTKEYS)
        self.initOptions()
        self.initAnnotationMenu()

        self.treeview = AnnotationTreeView()
        self.treeview.setSizePolicy(QSizePolicy.MinimumExpanding,
                                    QSizePolicy.Preferred)
        self.ui.dockAnnotations.setWidget(self.treeview)

        self.scene.selectionChanged.connect(self.scene.onSelectionChanged)
        self.treeview.selectedItemsChanged.connect(
            self.scene.onSelectionChangedInTreeView)

        self.posinfo = QLabel("-1, -1")
        self.posinfo.setFrameStyle(QFrame.StyledPanel)
        self.statusBar().addPermanentWidget(self.posinfo)
        self.scene.mousePositionChanged.connect(self.onMousePositionChanged)

        self.image_resolution = QLabel("[no image]")
        self.image_resolution.setFrameStyle(QFrame.StyledPanel)
        self.statusBar().addPermanentWidget(self.image_resolution)

        self.zoominfo = QLabel()
        self.zoominfo.setFrameStyle(QFrame.StyledPanel)
        self.statusBar().addPermanentWidget(self.zoominfo)
        self.view.scaleChanged.connect(self.onScaleChanged)
        self.onScaleChanged(self.view.getScale())

        self.sb_progress = QProgressBar()

        # View menu
        self.ui.menu_Views.addAction(self.ui.dockProperties.toggleViewAction())
        self.ui.menu_Views.addAction(
            self.ui.dockAnnotations.toggleViewAction())

        # Annotation menu
        self.copyAnnotations = CopyAnnotations(self.labeltool)
        self.interpolateRange = InterpolateRange(self.labeltool)

        # Show the UI.  It is important that this comes *after* the above
        # adding of custom widgets, especially the central widget.  Otherwise the
        # dock widgets would be far to large.
        self.ui.show()

        ## connect action signals
        self.connectActions()
Beispiel #3
0
    def setupGui(self):
        inserters = dict([
            (label['attributes']['class'], label['inserter'])
            for label in config.LABELS
            if 'class' in label.get('attributes', {}) and 'inserter' in label
        ])
        items = dict([
            (label['attributes']['class'], label['item'])
            for label in config.LABELS
            if 'class' in label.get('attributes', {}) and 'item' in label
        ])

        self.ui = uic.loadUi(os.path.join(GUIDIR, "labeltool.ui"), self)

        self.view = GraphicsView()
        self.scene = AnnotationScene(self.tool,
                                     inserters=inserters,
                                     items=items)
        self.view.setScene(self.scene)

        self.central_widget = QWidget()
        self.central_layout = QVBoxLayout()
        self.controls = ControlButtonWidget()
        self.controls.back_button.clicked.connect(self.tool.gotoPrevious)
        self.controls.forward_button.clicked.connect(self.tool.gotoNext)

        self.central_layout.addWidget(self.controls)
        self.central_layout.addWidget(self.view)
        self.central_widget.setLayout(self.central_layout)
        self.setCentralWidget(self.central_widget)

        self.initShortcuts(config.HOTKEYS)

        self.treeview = AnnotationTreeView()
        self.treeview.setSizePolicy(QSizePolicy.MinimumExpanding,
                                    QSizePolicy.Preferred)
        self.ui.dockAnnotations.setWidget(self.treeview)

        self.propertyEditor = PropertyEditor(config, self.tool)
        self.ui.dockProperties.setWidget(self.propertyEditor)
        self.propertyEditor.insertionModeStarted.connect(
            self.scene.onInsertionModeStarted)
        self.propertyEditor.insertionModeEnded.connect(
            self.scene.onInsertionModeEnded)

        self.inftable = CaseInformationWidget(self.tool)
        self.ui.dockInformation.setWidget(self.inftable)

        self.statusBar = QStatusBar()
        self.posinfo = QLabel("-1, -1")
        self.posinfo.setFrameStyle(QFrame.StyledPanel)
        self.statusBar.addPermanentWidget(self.posinfo)

        self.image_resolution = QLabel('[No Image]')
        self.image_resolution.setFrameStyle(QFrame.StyledPanel)
        self.statusBar.addPermanentWidget(self.image_resolution)

        self.image_download = QLabel('[Image Download]')
        self.image_download.setFrameStyle(QFrame.StyledPanel)
        self.statusBar.addPermanentWidget(self.image_download)

        self.zoominfo = QLabel()
        self.zoominfo.setFrameStyle(QFrame.StyledPanel)
        self.statusBar.addPermanentWidget(self.zoominfo)

        self.setStatusBar(self.statusBar)