def __init__(self):

        # ID OF THE NODE
        GeneralNode.id_counter += 1
        self.id = GeneralNode.id_counter

        # BASIC NODE PROPERTIES
        self.extra_header = 0
        self.widget = None
        self.max_streams = 16
        self.is_selected = False

        # STREAMS
        self.stream_count = 0
        self.streams = []

        # GRAPHICS OF THE NODE
        QtWidgets.QGraphicsPathItem.__init__(self)
        self.setFlags(QtWidgets.QGraphicsPathItem.ItemIsMovable)

        self.id_text = QtWidgets.QGraphicsSimpleTextItem(parent=self)
        self.proxy_add_btn = QtWidgets.QGraphicsProxyWidget(parent=self)
        self.proxy_remove_btn = QtWidgets.QGraphicsProxyWidget(parent=self)

        self.marquee = QtWidgets.QGraphicsPathItem(parent=self)

        # SETUP
        self.setup_node()
        self.add_stream()
        self.setup_widget()
    def setup_node(self):

        if self.stream_class:
            self.extra_header = 30
            self.widget = self.stream_class(parent=None)

        # BASIC SHAPE
        self.reconstruct_shape()
        self.setPen(QtGui.QPen(QtCore.Qt.black))

        # NODE NAME
        class_text = QtWidgets.QGraphicsSimpleTextItem(self.node_class, parent=self)
        node_class_font = QtGui.QFont('arial', 12)
        node_class_font.setUnderline(True)
        class_text.setFont(node_class_font)
        class_text.setPos(8, 6)

        # NODE WIDGET
        if self.stream_class:
            self.widget.setFixedSize(self.node_width - 10, HEADER_HEIGHT - 6)
            proxy = QtWidgets.QGraphicsProxyWidget(parent=self)
            proxy.setWidget(self.widget)
            proxy.moveBy(5, HEADER_HEIGHT + 3)
            proxy.setZValue(20)

        # HELP
        help_btn = QtWidgets.QPushButton(parent=None)
        help_btn.setFixedSize(16, 16)
        help_btn.setText('i')
        help_btn.setFont(QtGui.QFont('Monotype Corsiva', 10))
        help_btn.clicked.connect(self.show_help)
        proxy = QtWidgets.QGraphicsProxyWidget(parent=self)
        proxy.setWidget(help_btn)
        proxy.moveBy(self.node_width - 25, 7)

        # NODE ID
        self.id_text.setText('ID: {}'.format(self.id))
        node_id_font = QtGui.QFont('arial', 8)
        self.id_text.setFont(node_id_font)

        # ADD / DELETE STREAMS BUTTONS
        add_btn = QtWidgets.QPushButton(parent=None)
        add_btn.setFixedSize(16, 16)
        add_btn.setText('+')
        add_btn.setStyleSheet('color:lime')
        add_btn.setFont(QtGui.QFont('Impact', 11))
        add_btn.clicked.connect(self.add_stream)
        self.proxy_add_btn.setWidget(add_btn)

        remove_btn = QtWidgets.QPushButton(parent=None)
        remove_btn.setFixedSize(16, 16)
        remove_btn.setText('-')
        remove_btn.setStyleSheet('color:red')
        remove_btn.setFont(QtGui.QFont('Impact', 11))
        remove_btn.clicked.connect(self.remove_stream)
        self.proxy_remove_btn.setWidget(remove_btn)
def createItem(minimum, preferred, maximum, name):
    w = QtWidgets.QGraphicsProxyWidget()

    w.setWidget(QtWidgets.QPushButton(name))
    w.setMinimumSize(minimum)
    w.setPreferredSize(preferred)
    w.setMaximumSize(maximum)
    w.setSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)

    return w
 def __init__(self, label, pen, brush, *params):
     super().__init__(*params)
     self.setPen(pen)
     self.setBrush(brush)
     self.label = label
     wlabel = QtWidgets.QLabel(label)
     wlabel.setAttribute(QtCore.Qt.WA_TranslucentBackground, True)
     wlabel.setStyleSheet(
         "color : black; font-weight: bold; font-size: 30px; ")
     wlabel.setAlignment(QtCore.Qt.AlignCenter)
     proxy = QtWidgets.QGraphicsProxyWidget(self)
     proxy.setWidget(wlabel)
     proxy.setPos(self.boundingRect().center() - wlabel.rect().center())
     self.setFlag(QtWidgets.QGraphicsItem.ItemIsMovable)
     self.connections = []
    def initilizeComponent(self):

        self.grapvw_sceneImage=VAT_QGraphicsView(self.wgt_sceneImage)
        self.grapvw_sceneImage.setEnabled(True)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.wgt_sceneImage.sizePolicy().hasHeightForWidth())
        self.grapvw_sceneImage.setSizePolicy(sizePolicy)
        self.grapvw_sceneImage.setMinimumSize(QtCore.QSize(650, 400))
        self.grapvw_sceneImage.setInteractive(True)
        self.lyt_sceneImage.addWidget(self.grapvw_sceneImage)
        self.grapvw_sceneImage.toggleDragMode()

        #canvas.begin
        from matplotlib.backends.backend_qt5agg import FigureCanvas
        from matplotlib.figure import Figure
        self.graphicsview = QtWidgets.QGraphicsView()
        self.scene = QtWidgets.QGraphicsScene(self.graphicsview)
        self.graphicsview.setScene(self.scene)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        #sizePolicy.setHeightForWidth(self.wgt_channelsImageHistograms.sizePolicy().hasHeightForWidth())
        self.graphicsview.setSizePolicy(sizePolicy)

        #self.wgt_histogram= QtWidgets.QWidget(self)
        self.canvas = FigureCanvas(Figure(figsize=(5,3),tight_layout=True))
        #self.canvas.figure.tight_layout()
        #vertical_layout = QVBoxLayout()
        #vertical_layout.addWidget(self.canvas)

        self.canvas.sumbu1 = self.canvas.figure.add_subplot(111)
        #self.canvas.figure.set_facecolor("xkcd:wheat")
        #self.canvas.sumbu1.set_title('Histogram')
        self.canvas.figure.subplots_adjust(top=250)
        self.canvas.figure.subplots_adjust(left=0.1, right=0.9, top=0.9, bottom=0.1)

        #self.wgt_histogram.setLayout(vertical_layout)

        self.proxy = QtWidgets.QGraphicsProxyWidget()
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.wgt_channelsImageHistograms.sizePolicy().hasHeightForWidth())
        self.proxy.setSizePolicy(sizePolicy)
        self.proxy.setWidget(self.canvas)
        self.proxy.setTransformOriginPoint(self.proxy.boundingRect().center())
        self.proxy.setRotation(270)

        self.scene.addItem(self.proxy)
        self.lyt_channelsImageHistograms.addWidget(self.graphicsview)
        #canvas.end

        #beginLoad
        self.btn_loadImages.clicked.connect(self.btn_loadImages_clicked)
        self.lstw_imagesRawList.itemActivated.connect(self.lstw_imagesRawList_itemActivated)
        self.sldr_images.valueChanged.connect(self.sldr_images_valueChanged)
        self.btn_viewRawImage.clicked.connect(self.btn_viewRawImage_clicked)
        #endLoad
        #beginChannels

        #endChannels
        #beginFilter
        self.btn_filterRgbToGray.clicked.connect(self.btn_filterRgbToGray_clicked)
        #self.sldr_rawImageOpacity.valueChanged.connect(self.sldr_rawImageOpacity_valueChanged)
        self.sldr_filteredImageOpacity.valueChanged.connect(self.sldr_filteredImageOpacity_valueChanged)
        self.btn_filterHistogramGlobalEqualization.clicked.connect(self.btn_filterHistogramGlobalEqualization_clicked)
        #self.btn_filterTest.clicked.connect(self.btn_filterTest_clicked)
        #self.btn_filterHistogramLocalEqualization.clicked.connect(self.btn_filterHistogramLocalEqualization_clicked)
        self.btn_filterSave.clicked.connect(self.btn_filterSave_clicked)
        self.btn_filterSaveAs.clicked.connect(self.btn_filterSaveAs_clicked)
        self.btn_filterOtsuBinarization.clicked.connect(self.btn_filterOtsuBinarization_clicked)
        self.btn_filterAdaptiveGaussianTreshold.clicked.connect(self.btn_filterAdaptiveGaussianTreshold_clicked)
        #endFilter
        # self.btn_applyFilters.clicked.connect(self.btn_applyFilters_clicked)

        self.sldr_images.setTracking(False)
        self.sldr_filteredImageOpacity.setEnabled(False)
        self.setWindowTitle("Vascular Graph Tool")
Exemple #6
0
if __name__ == '__main__':

    import sys

    app = QtWidgets.QApplication(sys.argv)

    # Text edit and button.
    edit = QtWidgets.QTextEdit()
    edit.setText("asdf lkjha yuoiqwe asd iuaysd u iasyd uiy "
                 "asdf lkjha yuoiqwe asd iuaysd u iasyd uiy "
                 "asdf lkjha yuoiqwe asd iuaysd u iasyd uiy "
                 "asdf lkjha yuoiqwe asd iuaysd u iasyd uiy!")

    button = QtWidgets.QPushButton()
    buttonProxy = QtWidgets.QGraphicsProxyWidget()
    buttonProxy.setWidget(button)
    editProxy = QtWidgets.QGraphicsProxyWidget()
    editProxy.setWidget(edit)

    box = QtWidgets.QGroupBox()
    box.setFlat(True)
    box.setTitle("Options")

    layout2 = QtWidgets.QVBoxLayout()
    box.setLayout(layout2)
    layout2.addWidget(QtWidgets.QRadioButton("Herring"))
    layout2.addWidget(QtWidgets.QRadioButton("Blue Parrot"))
    layout2.addWidget(QtWidgets.QRadioButton("Petunias"))
    layout2.addStretch()
Exemple #7
0
 def testCase(self):
     widget = QtWidgets.QGraphicsProxyWidget()
     custom = CustomWidget()
     custom.setParentItem(widget)
Exemple #8
0
    def addRowColList(self, rowColList, rowWise=True, _parent=None, _col=0):
        #we can use this to add widgets from a list.
        #the list must have the form:
        #[row1, row2, row3, ...]
        #where each row is either itself a list (in this case we interpret it as columns and call this function recursively),
        #or a QGraphicsWidget subclass, in which case we just append it,
        #or a QWidget/QLayout subclass, in which case we build a proxy for it and add it
        #If an item has a rowspan(colspan) attribute, we use it. (TBD)
        colWise = not rowWise
        if _parent is None: _parent = self

        try:
            nrOfRows = len(_parent.rows)
        except:
            nrOfRows = 0

        try:
            elems = tuple(iter(rowColList))
        except:
            #if we are here, we are not a list
            if isinstance(rowColList, QtWidgets.QGraphicsWidget):
                row = 0 if colWise else nrOfRows + 1
                _parent.addItem(rowColList, row=row, col=_col)
                rowColList._row = row
            if isinstance(rowColList, pg.GraphicsLayout):
                row = 0 if colWise else nrOfRows + 1
                _parent.addLayout(rowColList, row=row, col=_col)
                rowColList._row = row

            if isinstance(rowColList, QtWidgets.QWidget):
                _parent.addWidget(rowColList)
            if isinstance(rowColList, QtWidgets.QLayout):
                _parent.addLayout(rowColList)
            return
        #if we are here, we can iterate
        proxyneededlambda = lambda x: isinstance(
            x, QtWidgets.QWidget) or isinstance(x, QtWidgets.QLayout)
        proxyneeded = all(proxyneededlambda(x) for x in elems)
        if proxyneeded:
            P = QtWidgets.QGraphicsProxyWidget()
            self.proxys.append(P)
            W = QtWidgets.QWidget()
            W.setAttribute(QtCore.Qt.WA_TranslucentBackground)
            W.setAttribute(QtCore.Qt.WA_NoSystemBackground)
            L = QtWidgets.QHBoxLayout() if rowWise else QtWidgets.QVBoxLayout()
            L.setSpacing(0)
            L.setContentsMargins(0, 0, 0, 0)
            W.setLayout(L)
            P.setWidget(W)
            _parent.addItem(P, row=0 if colWise else nrOfRows + 1, col=_col)
            _subparent = L
        else:
            _subparent = _parent.addLayout(row=0 if colWise else nrOfRows + 1,
                                           col=_col)
        for idx, x in enumerate(elems):
            col = 0 if colWise else idx
            self.addRowColList(x,
                               rowWise=not rowWise,
                               _parent=_subparent,
                               _col=col)
        if proxyneeded:
            _subparent.addItem(
                QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Expanding,
                                      QtWidgets.QSizePolicy.Expanding))