Пример #1
0
    def parBlock(self):
        item = self.scene.item
        dialog = IO_Dialog(self)
        dialog.spbInput.setValue(item.inp)
        dialog.spbOutput.setValue(item.outp)
        if item.insetble == False:
            dialog.spbInput.setEnabled(False)
        if item.outsetble == False:
            dialog.spbOutput.setEnabled(False)

        name = item.name
        flip = item.flip
        icon = item.icon
        params = item.params
        insetble = item.insetble
        outsetble = item.outsetble
        width = item.width
        res = dialog.exec_()
        if res == 1 and (insetble or outsetble):
            item.remove()
            inp = dialog.spbInput.value()
            outp = dialog.spbOutput.value()
            b = Block(None, self.scene, name, inp, outp, insetble, outsetble,
                      icon, params, width, flip)
            b.setPos(self.scene.evpos)
            ok = True
        else:
            ok = False
        return ok
Пример #2
0
 def loadBlock(self, item):
     b = Block(None, self, item.findtext('name'), int(item.findtext('inp')),
               int(item.findtext('outp')),
               item.findtext('ioset') == '1', item.findtext('icon'),
               item.findtext('params'),
               item.findtext('flip') == '1')
     b.setPos(float(item.findtext('posX')), float(item.findtext('posY')))
Пример #3
0
 def loadBlock(self, item, dx=0, dy=0):
     # --- For old files without block width ---
     try:
         width = int(item.findtext('width'))
     except:
         width = BWmin
     # --------------------------------------------------
     try:
         b = Block(None, self, item.findtext('name'),
                   int(item.findtext('inp')), int(item.findtext('outp')),
                   item.findtext('inset') == '1',
                   item.findtext('outset') == '1', item.findtext('icon'),
                   item.findtext('params'), width,
                   item.findtext('flip') == '1')
     except:
         # Compatibility of files from previous versions
         b = Block(None, self, item.findtext('name'),
                   int(item.findtext('inp')), int(item.findtext('outp')),
                   item.findtext('ioset') == '1',
                   item.findtext('ioset') == '1', item.findtext('icon'),
                   item.findtext('params'), width,
                   item.findtext('flip') == '1')
     b.setPos(
         float(item.findtext('posX')) + dx,
         float(item.findtext('posY')) + dy)
Пример #4
0
    def __init__(self, parent=None):
        QMainWindow.__init__(self, parent)

        self.centralWidget = QWidget()
        self.resize(800, 500)
        self.setWindowTitle('Library')
        self.libConfig = []
        self.readLib()
        self.closeFlag = False

        self.tabs = QTabWidget()
        tabS = ''

        index = 0
        for el in self.libConfig:
            if el['lib'] != tabS:
                if tabS != '':
                    tab = QWidget()
                    layout = QVBoxLayout()
                    layout.addWidget(view)
                    tab.setLayout(layout)
                    self.tabs.addTab(tab, tabS)
                    if tabS == 'common':
                        index = self.tabs.indexOf(tab)

                tabS = el['lib']
                diagram = CompViewer(self)
                view = QGraphicsView(diagram)
                diagram.compLock = True
                i = 1

            try:
                w = el['width']
            except:
                w = BWmin

            stbin = (el['stin'] == 1)
            stbout = (el['stout'] == 1)
            b = Block(None, diagram, el['name'], el['ip'], el['op'], stbin,
                      stbout, el['icon'], el['params'], w, False)
            px = (i - 1) % 2
            py = (i - 1) / 2
            b.setPos(px * 150, py * 200)
            i += 1

        tab = QWidget()
        layout = QVBoxLayout()
        layout.addWidget(view)
        tab.setLayout(layout)
        self.tabs.addTab(tab, tabS)

        layout = QHBoxLayout()
        layout.addWidget(self.tabs)
        self.widget = QWidget()
        self.widget.setLayout(layout)
        self.setCentralWidget(self.widget)
        self.tabs.setTabPosition(QTabWidget.West)
        self.tabs.setCurrentIndex(index)
Пример #5
0
 def dropEvent(self, event):
     if event.mimeData().hasText():
         self.DgmToUndo()
         msg = event.mimeData().text()
         root = etree.fromstring(msg)
         item = root.findall('block')[0]
         b = Block(None, self, item.findtext('name'),
                   int(item.findtext('inp')), int(item.findtext('outp')),
                   item.findtext('inset') == '1',
                   item.findtext('outset') == '1', item.findtext('icon'),
                   item.findtext('params'), int(item.findtext('width')),
                   item.findtext('flip') == '1')
         b.setPos(event.scenePos())
Пример #6
0
    def parBlock(self):
        item = self.scene.item
        dialog = IO_Dialog(self)
        dialog.spbInput.setValue(
            item.inp if isinstance(item.inp, int) else len(item.inp))
        dialog.spbOutput.setValue(
            item.outp if isinstance(item.outp, int) else len(item.outp))

        if item.inp == 0 or not item.parameters or not 'inp' in item.parameters:
            dialog.spbInput.setEnabled(False)
        else:
            dialog.spbInput.setMinimum(1)
        if item.outp == 0 or not item.parameters or not 'outp' in item.parameters:
            print(not item.parameters)
            dialog.spbOutput.setEnabled(False)
        else:
            dialog.spbOutput.setMinimum(1)

        res = dialog.exec_()
        if res == 1:
            item.remove()

            name = item.name
            blockname = item.blockname
            libname = item.libname
            flip = item.flip
            icon = item.icon
            libname = item.libname
            inp = dialog.spbInput.value()
            outp = dialog.spbOutput.value()

            attributes = {
                'name': name,
                'input': inp,
                'output': outp,
                'icon': icon,
                'flip': flip,
                'libname': libname
            }
            parameters = item.parameters
            properties = item.properties

            b = Block(attributes, parameters, properties, blockname, libname,
                      None, self.scene)
            b.setPos(self.scene.evpos)
Пример #7
0
 def dragLeaveEvent(self, event):
     self.DgmToUndo()
     data = event.mimeData().text()
     b = Block(None, self, data)
     b.setPos(event.scenePos())