Example #1
0
    def ReInitUI(self):
        if self.layoutData is None:
            return

        if 'layoutName' in self.layoutData:
            self.SetTitle(self.layoutData['layoutName'])

        if "gridOn" in self.layoutData.keys():
            if 1 == self.layoutData['gridOn']:
                self.gridOn = True

        if "fastClockAddress" in self.layoutData.keys():
            self.fcAddress = int(str(self.layoutData['fastClockAddress']), 0)

        for text in self.layoutData['text']:
            newCell = TextCell()
            newCell.setText(text['value'])
            x = int(text['x'])
            y = int(text['y'])
            newCell.setXY(x, y)
            if text['type'] == 'blockname':
                newCell.setColor('#ccffff')
            self.cells.append(newCell)

        for signalconfig in self.layoutData['signals']:
            newSignal = Signal(signalconfig, self.txPacket)
            self.signals.append(newSignal)
            self.cells = self.cells + newSignal.getCells()
            self.clickables[newSignal.getClickXY()] = newSignal.onLeftClick

        for switchconfig in self.layoutData['switches']:
            newSwitch = Switch(switchconfig, self.txPacket)
            self.switches.append(newSwitch)
            self.cells = self.cells + newSwitch.getCells()
            self.clickables[newSwitch.getClickXY()] = newSwitch.onLeftClick

        for blockconfig in self.layoutData['blocks']:
            newBlock = Block(blockconfig, self.txPacket, self.cellXY)
            self.blocks.append(newBlock)
            self.cells = self.cells + newBlock.getCells()

        for cell in self.cells:
            # Build a cell finder
            self.cellXY[(cell.cell_x, cell.cell_y)] = cell

        for cpconfig in self.layoutData['controlPoints']:
            if cpconfig['type'] == 'cp3':
                newCP = ControlPoint_CP3(cpconfig, self.txPacket,
                                         self.getRailroadObject)
            else:
                newCP = ControlPoint(cpconfig, self.txPacket,
                                     self.getRailroadObject)
            self.controlpoints.append(newCP)