예제 #1
0
def unserialize(s, config, newformat=False, transl=None):
    '''
    Unserializes the string s, and returns the tuple (bit, boards, spacing)
    '''
    # new format uue encoding support
    if newformat:
        s = binascii.a2b_qp(s)
    else:
        s = s.encode()

    inp = BytesIO(s)

    u = pickle.Unpickler(inp)
    version = u.load()
    if config.debug:
        print('unserialized version:', version)
    # form the units
    metric = u.load()
    num_increments = u.load()
    units = utils.Units(config.english_separator, metric, num_increments,
                        transl)
    # form the bit
    width = u.load()
    depth = u.load()
    angle = u.load()
    bit = router.Router_Bit(units, width, depth, angle)
    # form the boards
    nb = u.load()
    boards = []
    for _ in range(nb):
        boards.append(router.Board(bit, 10))  # dummy width argument, for now
    for b in boards:
        b.width = u.load()
        b.height = u.load()
        b.wood = u.load()
        b.active = u.load()
        b.dheight = u.load()
    # form the spacing
    sp_type = u.load()
    if sp_type == 'Edit':
        if config.debug:
            print('unserialized edit spacing')
        cuts = u.load()
        sp = spacing.Edit_Spaced(bit, boards, config)
        sp.set_cuts(cuts)
    else:
        if sp_type == 'Equa':
            sp = spacing.Equally_Spaced(bit, boards, config)
        else:
            sp = spacing.Variable_Spaced(bit, boards, config)
        sp.params = u.load()
        if config.debug:
            print('unserialized ', sp_type, str(sp.params))
        if not newformat:
            sp.upgrade()
        sp.set_cuts()
    return (bit, boards, sp, sp_type)
예제 #2
0
def unserialize(s, config):
    '''
    Unserializes the string s, and returns the tuple (bit, boards, spacing)
    '''
    inp = StringIO.StringIO(s)
    u = pickle.Unpickler(inp)
    version = u.load()
    if config.debug:
        print('unserialized version:', version)
    # form the units
    metric = u.load()
    if metric:
        units = utils.Units(metric=True)
    else:
        ipi = u.load()
        units = utils.Units(ipi)
    # form the bit
    width = u.load()
    depth = u.load()
    angle = u.load()
    bit = router.Router_Bit(units, width, depth, angle)
    # form the boards
    nb = u.load()
    boards = []
    for i in lrange(nb):
        boards.append(router.Board(bit, 10))  # dummy width argument, for now
    for b in boards:
        b.width = u.load()
        b.height = u.load()
        b.wood = u.load()
        b.active = u.load()
        b.dheight = u.load()
    # form the spacing
    sp_type = u.load()
    if sp_type == 'Edit':
        if config.debug:
            print('unserialized edit spacing')
        cuts = u.load()
        sp = spacing.Edit_Spaced(bit, boards, config)
        sp.set_cuts(cuts)
    else:
        if sp_type == 'Equa':
            sp = spacing.Equally_Spaced(bit, boards, config)
        else:
            sp = spacing.Variable_Spaced(bit, boards, config)
        sp.params = u.load()
        if config.debug:
            print('unserialized ', sp_type, ` sp.params `)
        sp.set_cuts()
    return (bit, boards, sp, sp_type)
예제 #3
0
    def __init__(self, config, units, parent=None):
        QtWidgets.QDialog.__init__(self, parent)
        self.config = config
        self.new_config = self.config.__dict__.copy()
        self.line_edit_width = 80
        self.units = units
        self.transl = units.transl

        # Form these objects so that we can do error checking on their changes
        bit_width = self.units.abstract_to_increments(self.config.bit_width)
        bit_depth = self.units.abstract_to_increments(self.config.bit_depth,
                                                      False)
        bit_angle = self.units.abstract_to_float(self.config.bit_angle)
        bit_gentle = self.config.bit_gentle
        self.bit = router.Router_Bit(self.units, bit_width, bit_depth,
                                     bit_angle, bit_gentle)
        board_width = self.units.abstract_to_increments(
            self.config.board_width)
        self.board = router.Board(self.bit, width=board_width)

        # Form the tabs and their contents
        title_label = QtWidgets.QLabel(
            self.transl.tr(
                '<font color=blue size=4><b>pyRouterJig Preferences</b></font>'
            ))
        title_label.setAlignment(QtCore.Qt.AlignHCenter)
        vbox = QtWidgets.QVBoxLayout()
        vbox.addWidget(title_label)

        tabs = QtWidgets.QTabWidget()

        tabs.addTab(self.create_output(), self.transl.tr('Output'))
        tabs.addTab(self.create_boards(), self.transl.tr('Boards'))
        tabs.addTab(self.create_bit(), self.transl.tr('Bit'))
        tabs.addTab(self.create_units(), self.transl.tr('Units'))
        tabs.addTab(self.create_colors(), self.transl.tr('Colors'))
        tabs.addTab(self.create_misc(), self.transl.tr('Misc'))

        vbox.addWidget(tabs)
        vbox.addLayout(self.create_buttons())
        self.setLayout(vbox)

        self.change_state = 0
        self.initialize()