Пример #1
0
class FlatCAMActivityView(QWidget):
    def __init__(self, parent=None):
        super(FlatCAMActivityView, self).__init__(parent=parent)

        self.setMinimumWidth(200)

        self.icon = QLabel(self)
        self.icon.setGeometry(0, 0, 12, 12)
        self.movie = QtGui.QMovie("share/active.gif")
        self.icon.setMovie(self.movie)
        #self.movie.start()

        layout = QHBoxLayout()
        layout.setContentsMargins(5, 0, 5, 0)
        layout.setAlignment(QtCore.Qt.AlignLeft)
        self.setLayout(layout)

        layout.addWidget(self.icon)
        self.text = QLabel(self)
        self.text.setText("Idle.")

        layout.addWidget(self.text)

    def set_idle(self):
        self.movie.stop()
        self.text.setText("Idle.")

    def set_busy(self, msg):
        self.movie.start()
        self.text.setText(msg)
Пример #2
0
    def __init__(self):
        QMainWindow.__init__(self)

        self.setMinimumSize(QSize(640, 480))
        self.setWindowTitle("Hello world - pythonprogramminglanguage.com")

        centralWidget = QWidget(self)
        self.setCentralWidget(centralWidget)

        gridLayout = QGridLayout(self)
        centralWidget.setLayout(gridLayout)

        title = QLabel("Hello World from PyQt", self)
        title.setAlignment(QtCore.Qt.AlignCenter)
        gridLayout.addWidget(title, 0, 0)
Пример #3
0
    def __init__(self, app):
        FlatCAMTool.__init__(self, app)

        self.setContentsMargins(0, 0, 0, 0)
        #self.layout.setMargin(0)
        self.layout.setContentsMargins(0, 0, 3, 0)

        self.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Maximum)

        self.point1 = None
        self.point2 = None
        self.label = QLabel("Click on a reference point ...")
        self.label.setFrameStyle(QFrame.StyledPanel | QFrame.Plain)
        self.label.setMargin(3)
        self.layout.addWidget(self.label)
        # self.layout.setMargin(0)
        self.setVisible(False)

        self.click_subscription = None
        self.move_subscription = None
Пример #4
0
    def __init__(self, parent=None):
        super(FlatCAMInfoBar, self).__init__(parent=parent)

        self.icon = QLabel(self)
        self.icon.setGeometry(0, 0, 12, 12)
        self.pmap = QtGui.QPixmap('share/graylight12.png')
        self.icon.setPixmap(self.pmap)

        layout = QHBoxLayout()
        layout.setContentsMargins(5, 0, 5, 0)
        self.setLayout(layout)

        layout.addWidget(self.icon)

        self.text = QLabel(self)
        self.text.setText("Hello!")
        self.text.setToolTip("Hello!")

        layout.addWidget(self.text)

        layout.addStretch()
Пример #5
0
    def __init__(self, parent=None):
        QWidget.__init__(self, parent=parent)

        layout = QVBoxLayout()
        self.setLayout(layout)

        hlay1 = QHBoxLayout()
        layout.addLayout(hlay1)
        unitslabel = QLabel('Units:')
        hlay1.addWidget(unitslabel)
        self.units_radio = RadioSet([{
            'label': 'inch',
            'value': 'IN'
        }, {
            'label': 'mm',
            'value': 'MM'
        }])
        hlay1.addWidget(self.units_radio)

        ####### Gerber #######
        # gerberlabel = QLabel('<b>Gerber Options</b>')
        # layout.addWidget(gerberlabel)
        self.gerber_group = GerberOptionsGroupUI()
        # self.gerber_group.setFrameStyle(QtGui.QFrame.StyledPanel)
        layout.addWidget(self.gerber_group)

        ####### Excellon #######
        # excellonlabel = QLabel('<b>Excellon Options</b>')
        # layout.addWidget(excellonlabel)
        self.excellon_group = ExcellonOptionsGroupUI()
        # self.excellon_group.setFrameStyle(QtGui.QFrame.StyledPanel)
        layout.addWidget(self.excellon_group)

        ####### Geometry #######
        # geometrylabel = QLabel('<b>Geometry Options</b>')
        # layout.addWidget(geometrylabel)
        self.geometry_group = GeometryOptionsGroupUI()
        # self.geometry_group.setStyle(QtGui.QFrame.StyledPanel)
        layout.addWidget(self.geometry_group)

        ####### CNC #######
        # cnclabel = QLabel('<b>CNC Job Options</b>')
        # layout.addWidget(cnclabel)
        self.cncjob_group = CNCJobOptionsGroupUI()
        # self.cncjob_group.setStyle(QtGui.QFrame.StyledPanel)
        layout.addWidget(self.cncjob_group)
Пример #6
0
    def __init__(self, app):
        FlatCAMTool.__init__(self, app)

        ## Title
        title_label = QLabel("<font size=4><b>%s</b></font>" % self.toolName)
        self.layout.addWidget(title_label)

        ## Form Layout
        form_layout = QFormLayout()
        self.layout.addLayout(form_layout)

        ## Layer to mirror
        self.object_combo = QComboBox()
        self.object_combo.setModel(self.app.collection.model)
        self.botlay_label = QLabel("Bottom Layer:")
        self.botlay_label.setToolTip("Layer to be mirrorer.")
        # form_layout.addRow("Bottom Layer:", self.object_combo)
        form_layout.addRow(self.botlay_label, self.object_combo)

        ## Axis
        self.mirror_axis = RadioSet([{
            'label': 'X',
            'value': 'X'
        }, {
            'label': 'Y',
            'value': 'Y'
        }])
        self.mirax_label = QLabel("Mirror Axis:")
        self.mirax_label.setToolTip(
            "Mirror vertically (X) or horizontally (Y).")
        # form_layout.addRow("Mirror Axis:", self.mirror_axis)
        form_layout.addRow(self.mirax_label, self.mirror_axis)

        ## Axis Location
        self.axis_location = RadioSet([{
            'label': 'Point',
            'value': 'point'
        }, {
            'label': 'Box',
            'value': 'box'
        }])
        self.axloc_label = QLabel("Axis Location:")
        self.axloc_label.setToolTip(
            "The axis should pass through a <b>point</b> or cut "
            "a specified <b>box</b> (in a Geometry object) in "
            "the middle.")
        # form_layout.addRow("Axis Location:", self.axis_location)
        form_layout.addRow(self.axloc_label, self.axis_location)

        ## Point/Box
        self.point_box_container = QVBoxLayout()
        self.pb_label = QLabel("Point/Box:")
        self.pb_label.setToolTip(
            "Specify the point (x, y) through which the mirror axis "
            "passes or the Geometry object containing a rectangle "
            "that the mirror axis cuts in half.")
        # form_layout.addRow("Point/Box:", self.point_box_container)
        form_layout.addRow(self.pb_label, self.point_box_container)

        self.point = EvalEntry()
        self.point_box_container.addWidget(self.point)
        self.box_combo = QComboBox()
        self.box_combo.setModel(self.app.collection.model)
        self.point_box_container.addWidget(self.box_combo)
        self.box_combo.hide()

        ## Alignment holes
        self.alignment_holes = EvalEntry()
        self.ah_label = QLabel("Alignment Holes:")
        self.ah_label.setToolTip("Alignment holes (x1, y1), (x2, y2), ... "
                                 "on one side of the mirror axis.")
        form_layout.addRow(self.ah_label, self.alignment_holes)

        ## Drill diameter for alignment holes
        self.drill_dia = LengthEntry()
        self.dd_label = QLabel("Drill diam.:")
        self.dd_label.setToolTip("Diameter of the drill for the "
                                 "alignment holes.")
        form_layout.addRow(self.dd_label, self.drill_dia)

        ## Buttons
        hlay = QHBoxLayout()
        self.layout.addLayout(hlay)
        hlay.addStretch()
        self.create_alignment_hole_button = QPushButton(
            "Create Alignment Drill")
        self.create_alignment_hole_button.setToolTip(
            "Creates an Excellon Object containing the "
            "specified alignment holes and their mirror "
            "images.")
        self.mirror_object_button = QPushButton("Mirror Object")
        self.mirror_object_button.setToolTip(
            "Mirrors (flips) the specified object around "
            "the specified axis. Does not create a new "
            "object, but modifies it.")
        hlay.addWidget(self.create_alignment_hole_button)
        hlay.addWidget(self.mirror_object_button)

        self.layout.addStretch()

        ## Signals
        self.create_alignment_hole_button.clicked.connect(
            self.on_create_alignment_holes)
        self.mirror_object_button.clicked.connect(self.on_mirror)

        self.axis_location.group_toggle_fn = self.on_toggle_pointbox

        ## Initialize form
        self.mirror_axis.set_value('X')
        self.axis_location.set_value('point')
Пример #7
0
class DblSidedTool(FlatCAMTool):

    toolName = "Double-Sided PCB Tool"

    def __init__(self, app):
        FlatCAMTool.__init__(self, app)

        ## Title
        title_label = QLabel("<font size=4><b>%s</b></font>" % self.toolName)
        self.layout.addWidget(title_label)

        ## Form Layout
        form_layout = QFormLayout()
        self.layout.addLayout(form_layout)

        ## Layer to mirror
        self.object_combo = QComboBox()
        self.object_combo.setModel(self.app.collection.model)
        self.botlay_label = QLabel("Bottom Layer:")
        self.botlay_label.setToolTip("Layer to be mirrorer.")
        # form_layout.addRow("Bottom Layer:", self.object_combo)
        form_layout.addRow(self.botlay_label, self.object_combo)

        ## Axis
        self.mirror_axis = RadioSet([{
            'label': 'X',
            'value': 'X'
        }, {
            'label': 'Y',
            'value': 'Y'
        }])
        self.mirax_label = QLabel("Mirror Axis:")
        self.mirax_label.setToolTip(
            "Mirror vertically (X) or horizontally (Y).")
        # form_layout.addRow("Mirror Axis:", self.mirror_axis)
        form_layout.addRow(self.mirax_label, self.mirror_axis)

        ## Axis Location
        self.axis_location = RadioSet([{
            'label': 'Point',
            'value': 'point'
        }, {
            'label': 'Box',
            'value': 'box'
        }])
        self.axloc_label = QLabel("Axis Location:")
        self.axloc_label.setToolTip(
            "The axis should pass through a <b>point</b> or cut "
            "a specified <b>box</b> (in a Geometry object) in "
            "the middle.")
        # form_layout.addRow("Axis Location:", self.axis_location)
        form_layout.addRow(self.axloc_label, self.axis_location)

        ## Point/Box
        self.point_box_container = QVBoxLayout()
        self.pb_label = QLabel("Point/Box:")
        self.pb_label.setToolTip(
            "Specify the point (x, y) through which the mirror axis "
            "passes or the Geometry object containing a rectangle "
            "that the mirror axis cuts in half.")
        # form_layout.addRow("Point/Box:", self.point_box_container)
        form_layout.addRow(self.pb_label, self.point_box_container)

        self.point = EvalEntry()
        self.point_box_container.addWidget(self.point)
        self.box_combo = QComboBox()
        self.box_combo.setModel(self.app.collection.model)
        self.point_box_container.addWidget(self.box_combo)
        self.box_combo.hide()

        ## Alignment holes
        self.alignment_holes = EvalEntry()
        self.ah_label = QLabel("Alignment Holes:")
        self.ah_label.setToolTip("Alignment holes (x1, y1), (x2, y2), ... "
                                 "on one side of the mirror axis.")
        form_layout.addRow(self.ah_label, self.alignment_holes)

        ## Drill diameter for alignment holes
        self.drill_dia = LengthEntry()
        self.dd_label = QLabel("Drill diam.:")
        self.dd_label.setToolTip("Diameter of the drill for the "
                                 "alignment holes.")
        form_layout.addRow(self.dd_label, self.drill_dia)

        ## Buttons
        hlay = QHBoxLayout()
        self.layout.addLayout(hlay)
        hlay.addStretch()
        self.create_alignment_hole_button = QPushButton(
            "Create Alignment Drill")
        self.create_alignment_hole_button.setToolTip(
            "Creates an Excellon Object containing the "
            "specified alignment holes and their mirror "
            "images.")
        self.mirror_object_button = QPushButton("Mirror Object")
        self.mirror_object_button.setToolTip(
            "Mirrors (flips) the specified object around "
            "the specified axis. Does not create a new "
            "object, but modifies it.")
        hlay.addWidget(self.create_alignment_hole_button)
        hlay.addWidget(self.mirror_object_button)

        self.layout.addStretch()

        ## Signals
        self.create_alignment_hole_button.clicked.connect(
            self.on_create_alignment_holes)
        self.mirror_object_button.clicked.connect(self.on_mirror)

        self.axis_location.group_toggle_fn = self.on_toggle_pointbox

        ## Initialize form
        self.mirror_axis.set_value('X')
        self.axis_location.set_value('point')

    def on_create_alignment_holes(self):
        axis = self.mirror_axis.get_value()
        mode = self.axis_location.get_value()

        if mode == "point":
            px, py = self.point.get_value()
        else:
            selection_index = self.box_combo.currentIndex()
            bb_obj = self.app.collection.object_list[
                selection_index]  # TODO: Direct access??
            xmin, ymin, xmax, ymax = bb_obj.bounds()
            px = 0.5 * (xmin + xmax)
            py = 0.5 * (ymin + ymax)

        xscale, yscale = {"X": (1.0, -1.0), "Y": (-1.0, 1.0)}[axis]

        dia = self.drill_dia.get_value()
        tools = {"1": {"C": dia}}

        # holes = self.alignment_holes.get_value()
        holes = eval('[{}]'.format(self.alignment_holes.text()))
        drills = []

        for hole in holes:
            point = Point(hole)
            point_mirror = affinity.scale(point,
                                          xscale,
                                          yscale,
                                          origin=(px, py))
            drills.append({"point": point, "tool": "1"})
            drills.append({"point": point_mirror, "tool": "1"})

        def obj_init(obj_inst, app_inst):
            obj_inst.tools = tools
            obj_inst.drills = drills
            obj_inst.create_geometry()

        self.app.new_object("excellon", "Alignment Drills", obj_init)

    def on_mirror(self):
        selection_index = self.object_combo.currentIndex()
        fcobj = self.app.collection.object_list[selection_index]

        # For now, lets limit to Gerbers and Excellons.
        # assert isinstance(gerb, FlatCAMGerber)
        if not isinstance(fcobj, FlatCAMGerber) and \
                not isinstance(fcobj, FlatCAMExcellon) and \
                not isinstance(fcobj, FlatCAMGeometry):
            self.app.inform.emit(
                "ERROR: Only Gerber, Excellon and Geometry objects can be mirrored."
            )
            return

        axis = self.mirror_axis.get_value()
        mode = self.axis_location.get_value()

        if mode == "point":
            px, py = self.point.get_value()
        else:
            selection_index = self.box_combo.currentIndex()
            bb_obj = self.app.collection.object_list[
                selection_index]  # TODO: Direct access??
            xmin, ymin, xmax, ymax = bb_obj.bounds()
            px = 0.5 * (xmin + xmax)
            py = 0.5 * (ymin + ymax)

        # Ensure that the selected object will display when it is mirrored.
        # If an object's plot setting is False it will still be available in
        # the combo box. If the plot is not enforced to True then the user
        # gets no feedback of the operation.
        fcobj.options["plot"] = True

        fcobj.mirror(axis, [px, py])
        fcobj.plot()

    def on_toggle_pointbox(self):
        if self.axis_location.get_value() == "point":
            self.point.show()
            self.box_combo.hide()
        else:
            self.point.hide()
            self.box_combo.show()
Пример #8
0
class ToolTransform(FlatCAMTool):

    toolName = "Object Transformation"
    rotateName = "Rotate Transformation"
    skewName = "Skew/Shear Transformation"
    flipName = "Flip Transformation"

    def __init__(self, app):
        FlatCAMTool.__init__(self, app)

        self.transform_lay = QVBoxLayout()
        self.layout.addLayout(self.transform_lay)
        ## Title
        title_label = QLabel("<font size=4><b>%s</b></font><br>" %
                             self.toolName)
        self.transform_lay.addWidget(title_label)

        self.empty_label = QLabel("")
        self.empty_label.setFixedWidth(80)
        self.empty_label1 = QLabel("")
        self.empty_label1.setFixedWidth(80)
        self.empty_label2 = QLabel("")
        self.empty_label2.setFixedWidth(80)
        self.transform_lay.addWidget(self.empty_label)

        ## Rotate Title
        rotate_title_label = QLabel("<font size=3><b>%s</b></font>" %
                                    self.rotateName)
        self.transform_lay.addWidget(rotate_title_label)

        ## Form Layout
        form_layout = QFormLayout()
        self.transform_lay.addLayout(form_layout)

        self.rotate_entry = FCEntry()
        self.rotate_entry.setFixedWidth(70)
        self.rotate_entry.setAlignment(QtCore.Qt.AlignRight
                                       | QtCore.Qt.AlignVCenter)
        self.rotate_label = QLabel("Angle Rotation:")
        self.rotate_label.setToolTip("Angle for Rotation action, in degrees.\n"
                                     "Float number between -360 and 359.\n"
                                     "Positive numbers for CW motion.\n"
                                     "Negative numbers for CCW motion.")
        self.rotate_label.setFixedWidth(80)

        self.rotate_button = FCButton()
        self.rotate_button.set_value("Rotate")
        self.rotate_button.setToolTip(
            "Rotate the selected object(s).\n"
            "The point of reference is the middle of\n"
            "the bounding box for all selected objects.\n")
        self.rotate_button.setFixedWidth(70)

        form_layout.addRow(self.rotate_label, self.rotate_entry)
        form_layout.addRow(self.empty_label, self.rotate_button)

        self.transform_lay.addWidget(self.empty_label1)

        ## Skew Title
        skew_title_label = QLabel("<font size=3><b>%s</b></font>" %
                                  self.skewName)
        self.transform_lay.addWidget(skew_title_label)

        ## Form Layout
        form1_layout = QFormLayout()
        self.transform_lay.addLayout(form1_layout)

        self.skewx_entry = FCEntry()
        self.skewx_entry.setAlignment(QtCore.Qt.AlignRight
                                      | QtCore.Qt.AlignVCenter)
        self.skewx_entry.setFixedWidth(70)
        self.skewx_label = QLabel("Angle SkewX:")
        self.skewx_label.setToolTip("Angle for Skew action, in degrees.\n"
                                    "Float number between -360 and 359.")
        self.skewx_label.setFixedWidth(80)

        self.skewx_button = FCButton()
        self.skewx_button.set_value("Skew_X")
        self.skewx_button.setToolTip(
            "Skew/shear the selected object(s).\n"
            "The point of reference is the middle of\n"
            "the bounding box for all selected objects.\n")
        self.skewx_button.setFixedWidth(70)

        self.skewy_entry = FCEntry()
        self.skewy_entry.setAlignment(QtCore.Qt.AlignRight
                                      | QtCore.Qt.AlignVCenter)
        self.skewy_entry.setFixedWidth(70)
        self.skewy_label = QLabel("Angle SkewY:")
        self.skewy_label.setToolTip("Angle for Skew action, in degrees.\n"
                                    "Float number between -360 and 359.")
        self.skewy_label.setFixedWidth(80)

        self.skewy_button = FCButton()
        self.skewy_button.set_value("Skew_Y")
        self.skewy_button.setToolTip(
            "Skew/shear the selected object(s).\n"
            "The point of reference is the middle of\n"
            "the bounding box for all selected objects.\n")
        self.skewy_button.setFixedWidth(70)

        form1_layout.addRow(self.skewx_label, self.skewx_entry)
        form1_layout.addRow(self.empty_label, self.skewx_button)
        form1_layout.addRow(self.skewy_label, self.skewy_entry)
        form1_layout.addRow(self.empty_label, self.skewy_button)

        self.transform_lay.addWidget(self.empty_label2)

        ## Flip Title
        flip_title_label = QLabel("<font size=3><b>%s</b></font>" %
                                  self.flipName)
        self.transform_lay.addWidget(flip_title_label)

        ## Form Layout
        form2_layout = QFormLayout()
        self.transform_lay.addLayout(form2_layout)

        self.flipx_button = FCButton()
        self.flipx_button.set_value("Flip_X")
        self.flipx_button.setToolTip(
            "Flip the selected object(s) over the X axis.\n"
            "Does not create a new object.\n ")
        self.flipx_button.setFixedWidth(70)

        self.flipy_button = FCButton()
        self.flipy_button.set_value("Flip_Y")
        self.flipy_button.setToolTip(
            "Flip the selected object(s) over the X axis.\n"
            "Does not create a new object.\n ")
        self.flipy_button.setFixedWidth(70)

        form2_layout.setSpacing(16)
        form2_layout.addRow(self.flipx_button, self.flipy_button)

        self.transform_lay.addStretch()

        ## Signals
        self.rotate_button.clicked.connect(self.on_rotate)
        self.skewx_button.clicked.connect(self.on_skewx)
        self.skewy_button.clicked.connect(self.on_skewy)
        self.flipx_button.clicked.connect(self.on_flipx)
        self.flipy_button.clicked.connect(self.on_flipy)

        self.rotate_entry.returnPressed.connect(self.on_rotate)
        self.skewx_entry.returnPressed.connect(self.on_skewx)
        self.skewy_entry.returnPressed.connect(self.on_skewy)

        ## Initialize form
        self.rotate_entry.set_value('0')
        self.skewx_entry.set_value('0')
        self.skewy_entry.set_value('0')

    def on_rotate(self):
        value = float(self.rotate_entry.get_value())
        self.on_rotate_action(value)
        return

    def on_flipx(self):
        self.on_flip("Y")
        return

    def on_flipy(self):
        self.on_flip("X")
        return

    def on_skewx(self):
        value = float(self.skewx_entry.get_value())
        self.on_skew("X", value)
        return

    def on_skewy(self):
        value = float(self.skewy_entry.get_value())
        self.on_skew("Y", value)
        return

    def on_rotate_action(self, num):
        obj_list = self.app.collection.get_selected()
        xminlist = []
        yminlist = []
        xmaxlist = []
        ymaxlist = []

        if not obj_list:
            self.app.inform.emit("WARNING: No object selected.")
            msg = "Please Select an object to rotate!"
            warningbox = QtGui.QMessageBox()
            warningbox.setText(msg)
            warningbox.setWindowTitle("Warning ...")
            warningbox.setWindowIcon(QtGui.QIcon('share/warning.png'))
            warningbox.setStandardButtons(QtGui.QMessageBox.Ok)
            warningbox.setDefaultButton(QtGui.QMessageBox.Ok)
            warningbox.exec_()
        else:
            try:
                # first get a bounding box to fit all
                for obj in obj_list:
                    xmin, ymin, xmax, ymax = obj.bounds()
                    xminlist.append(xmin)
                    yminlist.append(ymin)
                    xmaxlist.append(xmax)
                    ymaxlist.append(ymax)

                # get the minimum x,y and maximum x,y for all objects selected
                xminimal = min(xminlist)
                yminimal = min(yminlist)
                xmaximal = max(xmaxlist)
                ymaximal = max(ymaxlist)

                for sel_obj in obj_list:
                    px = 0.5 * (xminimal + xmaximal)
                    py = 0.5 * (yminimal + ymaximal)

                    sel_obj.rotate(-num, point=(px, py))
                    sel_obj.plot()
                self.app.inform.emit('Object was rotated ...')
            except Exception as e:
                self.app.inform.emit(
                    "[ERROR] Due of %s, rotation movement was not executed." %
                    str(e))
                raise

    def on_flip(self, axis):
        obj_list = self.app.collection.get_selected()
        xminlist = []
        yminlist = []
        xmaxlist = []
        ymaxlist = []

        if not obj_list:
            self.app.inform.emit("WARNING: No object selected.")
            msg = "Please Select an object to flip!"
            warningbox = QtGui.QMessageBox()
            warningbox.setText(msg)
            warningbox.setWindowTitle("Warning ...")
            warningbox.setWindowIcon(QtGui.QIcon('share/warning.png'))
            warningbox.setStandardButtons(QtGui.QMessageBox.Ok)
            warningbox.setDefaultButton(QtGui.QMessageBox.Ok)
            warningbox.exec_()
            return
        else:
            try:
                # first get a bounding box to fit all
                for obj in obj_list:
                    xmin, ymin, xmax, ymax = obj.bounds()
                    xminlist.append(xmin)
                    yminlist.append(ymin)
                    xmaxlist.append(xmax)
                    ymaxlist.append(ymax)

                # get the minimum x,y and maximum x,y for all objects selected
                xminimal = min(xminlist)
                yminimal = min(yminlist)
                xmaximal = max(xmaxlist)
                ymaximal = max(ymaxlist)

                px = 0.5 * (xminimal + xmaximal)
                py = 0.5 * (yminimal + ymaximal)

                # execute mirroring
                for obj in obj_list:
                    if axis is 'X':
                        obj.mirror('X', [px, py])
                        obj.plot()
                        self.app.inform.emit('Flipped on the Y axis ...')
                    elif axis is 'Y':
                        obj.mirror('Y', [px, py])
                        obj.plot()
                        self.app.inform.emit('Flipped on the X axis ...')

            except Exception as e:
                self.app.inform.emit(
                    "[ERROR] Due of %s, Flip action was not executed.")
                raise

    def on_skew(self, axis, num):
        obj_list = self.app.collection.get_selected()
        xminlist = []
        yminlist = []

        if not obj_list:
            self.app.inform.emit("WARNING: No object selected.")
            msg = "Please Select an object to skew/shear!"
            warningbox = QtGui.QMessageBox()
            warningbox.setText(msg)
            warningbox.setWindowTitle("Warning ...")
            warningbox.setWindowIcon(QtGui.QIcon('share/warning.png'))
            warningbox.setStandardButtons(QtGui.QMessageBox.Ok)
            warningbox.setDefaultButton(QtGui.QMessageBox.Ok)
            warningbox.exec_()
        else:
            try:
                # first get a bounding box to fit all
                for obj in obj_list:
                    xmin, ymin, xmax, ymax = obj.bounds()
                    xminlist.append(xmin)
                    yminlist.append(ymin)

                # get the minimum x,y and maximum x,y for all objects selected
                xminimal = min(xminlist)
                yminimal = min(yminlist)

                for obj in obj_list:
                    if axis is 'X':
                        obj.skew(num, 0, point=(xminimal, yminimal))
                    elif axis is 'Y':
                        obj.skew(0, num, point=(xminimal, yminimal))
                    obj.plot()
                self.app.inform.emit('Object was skewed on %s axis ...' %
                                     str(axis))
            except Exception as e:
                self.app.inform.emit(
                    "[ERROR] Due of %s, Skew action was not executed." %
                    str(e))
                raise


# end of file
Пример #9
0
    def __init__(self, app):
        FlatCAMTool.__init__(self, app)

        self.transform_lay = QVBoxLayout()
        self.layout.addLayout(self.transform_lay)
        ## Title
        title_label = QLabel("<font size=4><b>%s</b></font><br>" %
                             self.toolName)
        self.transform_lay.addWidget(title_label)

        self.empty_label = QLabel("")
        self.empty_label.setFixedWidth(80)
        self.empty_label1 = QLabel("")
        self.empty_label1.setFixedWidth(80)
        self.empty_label2 = QLabel("")
        self.empty_label2.setFixedWidth(80)
        self.transform_lay.addWidget(self.empty_label)

        ## Rotate Title
        rotate_title_label = QLabel("<font size=3><b>%s</b></font>" %
                                    self.rotateName)
        self.transform_lay.addWidget(rotate_title_label)

        ## Form Layout
        form_layout = QFormLayout()
        self.transform_lay.addLayout(form_layout)

        self.rotate_entry = FCEntry()
        self.rotate_entry.setFixedWidth(70)
        self.rotate_entry.setAlignment(QtCore.Qt.AlignRight
                                       | QtCore.Qt.AlignVCenter)
        self.rotate_label = QLabel("Angle Rotation:")
        self.rotate_label.setToolTip("Angle for Rotation action, in degrees.\n"
                                     "Float number between -360 and 359.\n"
                                     "Positive numbers for CW motion.\n"
                                     "Negative numbers for CCW motion.")
        self.rotate_label.setFixedWidth(80)

        self.rotate_button = FCButton()
        self.rotate_button.set_value("Rotate")
        self.rotate_button.setToolTip(
            "Rotate the selected object(s).\n"
            "The point of reference is the middle of\n"
            "the bounding box for all selected objects.\n")
        self.rotate_button.setFixedWidth(70)

        form_layout.addRow(self.rotate_label, self.rotate_entry)
        form_layout.addRow(self.empty_label, self.rotate_button)

        self.transform_lay.addWidget(self.empty_label1)

        ## Skew Title
        skew_title_label = QLabel("<font size=3><b>%s</b></font>" %
                                  self.skewName)
        self.transform_lay.addWidget(skew_title_label)

        ## Form Layout
        form1_layout = QFormLayout()
        self.transform_lay.addLayout(form1_layout)

        self.skewx_entry = FCEntry()
        self.skewx_entry.setAlignment(QtCore.Qt.AlignRight
                                      | QtCore.Qt.AlignVCenter)
        self.skewx_entry.setFixedWidth(70)
        self.skewx_label = QLabel("Angle SkewX:")
        self.skewx_label.setToolTip("Angle for Skew action, in degrees.\n"
                                    "Float number between -360 and 359.")
        self.skewx_label.setFixedWidth(80)

        self.skewx_button = FCButton()
        self.skewx_button.set_value("Skew_X")
        self.skewx_button.setToolTip(
            "Skew/shear the selected object(s).\n"
            "The point of reference is the middle of\n"
            "the bounding box for all selected objects.\n")
        self.skewx_button.setFixedWidth(70)

        self.skewy_entry = FCEntry()
        self.skewy_entry.setAlignment(QtCore.Qt.AlignRight
                                      | QtCore.Qt.AlignVCenter)
        self.skewy_entry.setFixedWidth(70)
        self.skewy_label = QLabel("Angle SkewY:")
        self.skewy_label.setToolTip("Angle for Skew action, in degrees.\n"
                                    "Float number between -360 and 359.")
        self.skewy_label.setFixedWidth(80)

        self.skewy_button = FCButton()
        self.skewy_button.set_value("Skew_Y")
        self.skewy_button.setToolTip(
            "Skew/shear the selected object(s).\n"
            "The point of reference is the middle of\n"
            "the bounding box for all selected objects.\n")
        self.skewy_button.setFixedWidth(70)

        form1_layout.addRow(self.skewx_label, self.skewx_entry)
        form1_layout.addRow(self.empty_label, self.skewx_button)
        form1_layout.addRow(self.skewy_label, self.skewy_entry)
        form1_layout.addRow(self.empty_label, self.skewy_button)

        self.transform_lay.addWidget(self.empty_label2)

        ## Flip Title
        flip_title_label = QLabel("<font size=3><b>%s</b></font>" %
                                  self.flipName)
        self.transform_lay.addWidget(flip_title_label)

        ## Form Layout
        form2_layout = QFormLayout()
        self.transform_lay.addLayout(form2_layout)

        self.flipx_button = FCButton()
        self.flipx_button.set_value("Flip_X")
        self.flipx_button.setToolTip(
            "Flip the selected object(s) over the X axis.\n"
            "Does not create a new object.\n ")
        self.flipx_button.setFixedWidth(70)

        self.flipy_button = FCButton()
        self.flipy_button.set_value("Flip_Y")
        self.flipy_button.setToolTip(
            "Flip the selected object(s) over the X axis.\n"
            "Does not create a new object.\n ")
        self.flipy_button.setFixedWidth(70)

        form2_layout.setSpacing(16)
        form2_layout.addRow(self.flipx_button, self.flipy_button)

        self.transform_lay.addStretch()

        ## Signals
        self.rotate_button.clicked.connect(self.on_rotate)
        self.skewx_button.clicked.connect(self.on_skewx)
        self.skewy_button.clicked.connect(self.on_skewy)
        self.flipx_button.clicked.connect(self.on_flipx)
        self.flipy_button.clicked.connect(self.on_flipy)

        self.rotate_entry.returnPressed.connect(self.on_rotate)
        self.skewx_entry.returnPressed.connect(self.on_skewx)
        self.skewy_entry.returnPressed.connect(self.on_skewy)

        ## Initialize form
        self.rotate_entry.set_value('0')
        self.skewx_entry.set_value('0')
        self.skewy_entry.set_value('0')
Пример #10
0
class Measurement(FlatCAMTool):

    toolName = "Measurement Tool"

    def __init__(self, app):
        FlatCAMTool.__init__(self, app)

        self.setContentsMargins(0, 0, 0, 0)
        #self.layout.setMargin(0)
        self.layout.setContentsMargins(0, 0, 3, 0)

        self.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Maximum)

        self.point1 = None
        self.point2 = None
        self.label = QLabel("Click on a reference point ...")
        self.label.setFrameStyle(QFrame.StyledPanel | QFrame.Plain)
        self.label.setMargin(3)
        self.layout.addWidget(self.label)
        # self.layout.setMargin(0)
        self.setVisible(False)

        self.click_subscription = None
        self.move_subscription = None

    def install(self, icon=None, separator=None, **kwargs):
        FlatCAMTool.install(self, icon, separator, **kwargs)
        self.app.ui.right_layout.addWidget(self)
        self.app.plotcanvas.mpl_connect('key_press_event', self.on_key_press)

    def run(self):
        self.toggle()

    def on_click(self, event):
        if self.point1 is None:
            self.point1 = (event.xdata, event.ydata)
        else:
            self.point2 = copy(self.point1)
            self.point1 = (event.xdata, event.ydata)
        self.on_move(event)

    def on_key_press(self, event):
        if event.key == 'r':
            self.toggle()

    def toggle(self):
        if self.isVisible():
            self.setVisible(False)
            self.app.plotcanvas.mpl_disconnect(self.move_subscription)
            self.app.plotcanvas.mpl_disconnect(self.click_subscription)
        else:
            self.setVisible(True)
            self.move_subscription = self.app.plotcanvas.mpl_connect(
                'motion_notify_event', self.on_move)
            self.click_subscription = self.app.plotcanvas.mpl_connect(
                'button_press_event', self.on_click)

    def on_move(self, event):
        if self.point1 is None:
            self.label.setText("Click on a reference point...")
        else:
            try:
                dx = event.xdata - self.point1[0]
                dy = event.ydata - self.point1[1]
                d = sqrt(dx**2 + dy**2)
                self.label.setText("D = %.4f  D(x) = %.4f  D(y) = %.4f" %
                                   (d, dx, dy))
            except TypeError:
                pass
        if self.update is not None:
            self.update()
Пример #11
0
    def __init__(self, parent=None):
        OptionsGroupUI.__init__(self, "CNC Job Options", parent=None)

        ## Plot options
        self.plot_options_label = QLabel("<b>Plot Options:</b>")
        self.layout.addWidget(self.plot_options_label)

        grid0 = QGridLayout()
        self.layout.addLayout(grid0)

        # Plot CB
        # self.plot_cb = QtGui.QCheckBox('Plot')
        self.plot_cb = FCCheckBox('Plot')
        self.plot_cb.setToolTip("Plot (show) this object.")
        grid0.addWidget(self.plot_cb, 0, 0)

        # Tool dia for plot
        tdlabel = QLabel('Tool dia:')
        tdlabel.setToolTip("Diameter of the tool to be\n"
                           "rendered in the plot.")
        grid0.addWidget(tdlabel, 1, 0)
        self.tooldia_entry = LengthEntry()
        grid0.addWidget(self.tooldia_entry, 1, 1)

        ## Export G-Code
        self.export_gcode_label = QLabel("<b>Export G-Code:</b>")
        self.export_gcode_label.setToolTip("Export and save G-Code to\n"
                                           "make this object to a file.")
        self.layout.addWidget(self.export_gcode_label)

        # Prepend to G-Code
        prependlabel = QLabel('Prepend to G-Code:')
        prependlabel.setToolTip(
            "Type here any G-Code commands you would\n"
            "like to add at the beginning of the G-Code file.")
        self.layout.addWidget(prependlabel)

        self.prepend_text = FCTextArea()
        self.layout.addWidget(self.prepend_text)

        # Append text to G-Code
        appendlabel = QLabel('Append to G-Code:')
        appendlabel.setToolTip("Type here any G-Code commands you would\n"
                               "like to append to the generated file.\n"
                               "I.e.: M2 (End of program)")
        self.layout.addWidget(appendlabel)

        self.append_text = FCTextArea()
        self.layout.addWidget(self.append_text)

        # Dwell
        grid1 = QGridLayout()
        self.layout.addLayout(grid1)

        dwelllabel = QLabel('Dwell:')
        dwelllabel.setToolTip("Pause to allow the spindle to reach its\n"
                              "speed before cutting.")
        dwelltime = QLabel('Duration [sec.]:')
        dwelltime.setToolTip("Number of second to dwell.")
        self.dwell_cb = FCCheckBox()
        self.dwelltime_cb = FCEntry()
        grid1.addWidget(dwelllabel, 0, 0)
        grid1.addWidget(self.dwell_cb, 0, 1)
        grid1.addWidget(dwelltime, 1, 0)
        grid1.addWidget(self.dwelltime_cb, 1, 1)
Пример #12
0
    def __init__(self, parent=None):
        OptionsGroupUI.__init__(self, "Geometry Options", parent=parent)

        ## Plot options
        self.plot_options_label = QLabel("<b>Plot Options:</b>")
        self.layout.addWidget(self.plot_options_label)

        # Plot CB
        self.plot_cb = FCCheckBox(label='Plot')
        self.plot_cb.setToolTip("Plot (show) this object.")
        self.layout.addWidget(self.plot_cb)

        # ------------------------------
        ## Create CNC Job
        # ------------------------------
        self.cncjob_label = QLabel('<b>Create CNC Job:</b>')
        self.cncjob_label.setToolTip("Create a CNC Job object\n"
                                     "tracing the contours of this\n"
                                     "Geometry object.")
        self.layout.addWidget(self.cncjob_label)

        grid1 = QGridLayout()
        self.layout.addLayout(grid1)

        cutzlabel = QLabel('Cut Z:')
        cutzlabel.setToolTip("Cutting depth (negative)\n"
                             "below the copper surface.")
        grid1.addWidget(cutzlabel, 0, 0)
        self.cutz_entry = LengthEntry()
        grid1.addWidget(self.cutz_entry, 0, 1)

        # Travel Z
        travelzlabel = QLabel('Travel Z:')
        travelzlabel.setToolTip("Height of the tool when\n"
                                "moving without cutting.")
        grid1.addWidget(travelzlabel, 1, 0)
        self.travelz_entry = LengthEntry()
        grid1.addWidget(self.travelz_entry, 1, 1)

        # Feedrate
        frlabel = QLabel('Feed Rate:')
        frlabel.setToolTip("Cutting speed in the XY\n"
                           "plane in units per minute")
        grid1.addWidget(frlabel, 2, 0)
        self.cncfeedrate_entry = LengthEntry()
        grid1.addWidget(self.cncfeedrate_entry, 2, 1)

        # Tooldia
        tdlabel = QLabel('Tool dia:')
        tdlabel.setToolTip("The diameter of the cutting\n"
                           "tool (just for display).")
        grid1.addWidget(tdlabel, 3, 0)
        self.cnctooldia_entry = LengthEntry()
        grid1.addWidget(self.cnctooldia_entry, 3, 1)

        spdlabel = QLabel('Spindle speed:')
        spdlabel.setToolTip("Speed of the spindle\n" "in RPM (optional)")
        grid1.addWidget(spdlabel, 4, 0)
        self.cncspindlespeed_entry = IntEntry(allow_empty=True)
        grid1.addWidget(self.cncspindlespeed_entry, 4, 1)

        # ------------------------------
        ## Paint area
        # ------------------------------
        self.paint_label = QLabel('<b>Paint Area:</b>')
        self.paint_label.setToolTip("Creates tool paths to cover the\n"
                                    "whole area of a polygon (remove\n"
                                    "all copper). You will be asked\n"
                                    "to click on the desired polygon.")
        self.layout.addWidget(self.paint_label)

        grid2 = QGridLayout()
        self.layout.addLayout(grid2)

        # Tool dia
        ptdlabel = QLabel('Tool dia:')
        ptdlabel.setToolTip("Diameter of the tool to\n"
                            "be used in the operation.")
        grid2.addWidget(ptdlabel, 0, 0)

        self.painttooldia_entry = LengthEntry()
        grid2.addWidget(self.painttooldia_entry, 0, 1)

        # Overlap
        ovlabel = QLabel('Overlap:')
        ovlabel.setToolTip("How much (fraction) of the tool\n"
                           "width to overlap each tool pass.")
        grid2.addWidget(ovlabel, 1, 0)
        self.paintoverlap_entry = LengthEntry()
        grid2.addWidget(self.paintoverlap_entry, 1, 1)

        # Margin
        marginlabel = QLabel('Margin:')
        marginlabel.setToolTip("Distance by which to avoid\n"
                               "the edges of the polygon to\n"
                               "be painted.")
        grid2.addWidget(marginlabel, 2, 0)
        self.paintmargin_entry = LengthEntry()
        grid2.addWidget(self.paintmargin_entry, 2, 1)

        # Method
        methodlabel = QLabel('Method:')
        methodlabel.setToolTip("Algorithm to paint the polygon:<BR>"
                               "<B>Standard</B>: Fixed step inwards.<BR>"
                               "<B>Seed-based</B>: Outwards from seed.")
        grid2.addWidget(methodlabel, 3, 0)
        self.paintmethod_combo = RadioSet([{
            "label": "Standard",
            "value": "standard"
        }, {
            "label": "Seed-based",
            "value": "seed"
        }, {
            "label": "Straight lines",
            "value": "lines"
        }],
                                          orientation='vertical')
        grid2.addWidget(self.paintmethod_combo, 3, 1)

        # Connect lines
        pathconnectlabel = QLabel("Connect:")
        pathconnectlabel.setToolTip("Draw lines between resulting\n"
                                    "segments to minimize tool lifts.")
        grid2.addWidget(pathconnectlabel, 4, 0)
        self.pathconnect_cb = FCCheckBox()
        grid2.addWidget(self.pathconnect_cb, 4, 1)

        # Paint contour
        contourlabel = QLabel("Contour:")
        contourlabel.setToolTip("Cut around the perimeter of the polygon\n"
                                "to trim rough edges.")
        grid2.addWidget(contourlabel, 5, 0)
        self.contour_cb = FCCheckBox()
        grid2.addWidget(self.contour_cb, 5, 1)

        # Polygon selection
        selectlabel = QLabel('Selection:')
        selectlabel.setToolTip("How to select the polygons to paint.")
        grid2.addWidget(selectlabel, 6, 0)
        # grid3 = QGridLayout()
        self.selectmethod_combo = RadioSet([
            {
                "label": "Single",
                "value": "single"
            },
            {
                "label": "All",
                "value": "all"
            },
            # {"label": "Rectangle", "value": "rectangle"}
        ])
        grid2.addWidget(self.selectmethod_combo, 6, 1)
Пример #13
0
    def __init__(self, parent=None):
        OptionsGroupUI.__init__(self, "Excellon Options", parent=parent)

        ## Plot options
        self.plot_options_label = QLabel("<b>Plot Options:</b>")
        self.layout.addWidget(self.plot_options_label)

        grid0 = QGridLayout()
        self.layout.addLayout(grid0)
        self.plot_cb = FCCheckBox(label='Plot')
        self.plot_cb.setToolTip("Plot (show) this object.")
        grid0.addWidget(self.plot_cb, 0, 0)
        self.solid_cb = FCCheckBox(label='Solid')
        self.solid_cb.setToolTip("Solid circles.")
        grid0.addWidget(self.solid_cb, 0, 1)

        ## Create CNC Job
        self.cncjob_label = QLabel('<b>Create CNC Job</b>')
        self.cncjob_label.setToolTip("Create a CNC Job object\n"
                                     "for this drill object.")
        self.layout.addWidget(self.cncjob_label)

        grid1 = QGridLayout()
        self.layout.addLayout(grid1)

        cutzlabel = QLabel('Cut Z:')
        cutzlabel.setToolTip("Drill depth (negative)\n"
                             "below the copper surface.")
        grid1.addWidget(cutzlabel, 0, 0)
        self.cutz_entry = LengthEntry()
        grid1.addWidget(self.cutz_entry, 0, 1)

        travelzlabel = QLabel('Travel Z:')
        travelzlabel.setToolTip("Tool height when travelling\n"
                                "across the XY plane.")
        grid1.addWidget(travelzlabel, 1, 0)
        self.travelz_entry = LengthEntry()
        grid1.addWidget(self.travelz_entry, 1, 1)

        frlabel = QLabel('Feed rate:')
        frlabel.setToolTip("Tool speed while drilling\n"
                           "(in units per minute).")
        grid1.addWidget(frlabel, 2, 0)
        self.feedrate_entry = LengthEntry()
        grid1.addWidget(self.feedrate_entry, 2, 1)

        toolchangezlabel = QLabel('Toolchange Z:')
        toolchangezlabel.setToolTip("Tool Z where user can change drill bit\n")
        grid1.addWidget(toolchangezlabel, 3, 0)
        self.toolchangez_entry = LengthEntry()
        grid1.addWidget(self.toolchangez_entry, 3, 1)

        spdlabel = QLabel('Spindle speed:')
        spdlabel.setToolTip("Speed of the spindle\n" "in RPM (optional)")
        grid1.addWidget(spdlabel, 4, 0)
        self.spindlespeed_entry = IntEntry(allow_empty=True)
        grid1.addWidget(self.spindlespeed_entry, 4, 1)

        #### Milling Holes ####
        self.mill_hole_label = QLabel('<b>Mill Holes</b>')
        self.mill_hole_label.setToolTip("Create Geometry for milling holes.")
        self.layout.addWidget(self.mill_hole_label)

        grid1 = QGridLayout()
        self.layout.addLayout(grid1)
        tdlabel = QLabel('Tool dia:')
        tdlabel.setToolTip("Diameter of the cutting tool.")
        grid1.addWidget(tdlabel, 0, 0)
        self.tooldia_entry = LengthEntry()
        grid1.addWidget(self.tooldia_entry, 0, 1)
Пример #14
0
    def __init__(self, parent=None):
        OptionsGroupUI.__init__(self, "Gerber Options", parent=parent)

        ## Plot options
        self.plot_options_label = QLabel("<b>Plot Options:</b>")
        self.layout.addWidget(self.plot_options_label)

        grid0 = QGridLayout()
        self.layout.addLayout(grid0)
        # Plot CB
        self.plot_cb = FCCheckBox(label='Plot')
        self.plot_options_label.setToolTip("Plot (show) this object.")

        grid0.addWidget(self.plot_cb, 0, 0)

        # Solid CB
        self.solid_cb = FCCheckBox(label='Solid')
        self.solid_cb.setToolTip("Solid color polygons.")
        grid0.addWidget(self.solid_cb, 0, 1)

        # Multicolored CB
        self.multicolored_cb = FCCheckBox(label='Multicolored')
        self.multicolored_cb.setToolTip("Draw polygons in different colors.")
        grid0.addWidget(self.multicolored_cb, 0, 2)

        ## Isolation Routing
        self.isolation_routing_label = QLabel("<b>Isolation Routing:</b>")
        self.isolation_routing_label.setToolTip(
            "Create a Geometry object with\n"
            "toolpaths to cut outside polygons.")
        self.layout.addWidget(self.isolation_routing_label)

        grid1 = QGridLayout()
        self.layout.addLayout(grid1)
        tdlabel = QLabel('Tool dia:')
        tdlabel.setToolTip("Diameter of the cutting tool.")
        grid1.addWidget(tdlabel, 0, 0)
        self.iso_tool_dia_entry = LengthEntry()
        grid1.addWidget(self.iso_tool_dia_entry, 0, 1)

        passlabel = QLabel('Width (# passes):')
        passlabel.setToolTip("Width of the isolation gap in\n"
                             "number (integer) of tool widths.")
        grid1.addWidget(passlabel, 1, 0)
        self.iso_width_entry = IntEntry()
        grid1.addWidget(self.iso_width_entry, 1, 1)

        overlabel = QLabel('Pass overlap:')
        overlabel.setToolTip("How much (fraction of tool width)\n"
                             "to overlap each pass.")
        grid1.addWidget(overlabel, 2, 0)
        self.iso_overlap_entry = FloatEntry()
        grid1.addWidget(self.iso_overlap_entry, 2, 1)

        self.combine_passes_cb = FCCheckBox(label='Combine Passes')
        self.combine_passes_cb.setToolTip("Combine all passes into one object")
        grid1.addWidget(self.combine_passes_cb, 3, 0)

        ## Board cuttout
        self.board_cutout_label = QLabel("<b>Board cutout:</b>")
        self.board_cutout_label.setToolTip("Create toolpaths to cut around\n"
                                           "the PCB and separate it from\n"
                                           "the original board.")
        self.layout.addWidget(self.board_cutout_label)

        grid2 = QGridLayout()
        self.layout.addLayout(grid2)
        tdclabel = QLabel('Tool dia:')
        tdclabel.setToolTip("Diameter of the cutting tool.")
        grid2.addWidget(tdclabel, 0, 0)
        self.cutout_tooldia_entry = LengthEntry()
        grid2.addWidget(self.cutout_tooldia_entry, 0, 1)

        marginlabel = QLabel('Margin:')
        marginlabel.setToolTip("Distance from objects at which\n"
                               "to draw the cutout.")
        grid2.addWidget(marginlabel, 1, 0)
        self.cutout_margin_entry = LengthEntry()
        grid2.addWidget(self.cutout_margin_entry, 1, 1)

        gaplabel = QLabel('Gap size:')
        gaplabel.setToolTip("Size of the gaps in the toolpath\n"
                            "that will remain to hold the\n"
                            "board in place.")
        grid2.addWidget(gaplabel, 2, 0)
        self.cutout_gap_entry = LengthEntry()
        grid2.addWidget(self.cutout_gap_entry, 2, 1)

        gapslabel = QLabel('Gaps:')
        gapslabel.setToolTip("Where to place the gaps, Top/Bottom\n"
                             "Left/Rigt, or on all 4 sides.")
        grid2.addWidget(gapslabel, 3, 0)
        self.gaps_radio = RadioSet([{
            'label': '2 (T/B)',
            'value': 'tb'
        }, {
            'label': '2 (L/R)',
            'value': 'lr'
        }, {
            'label': '4',
            'value': '4'
        }])
        grid2.addWidget(self.gaps_radio, 3, 1)

        ## Non-copper regions
        self.noncopper_label = QLabel("<b>Non-copper regions:</b>")
        self.noncopper_label.setToolTip("Create polygons covering the\n"
                                        "areas without copper on the PCB.\n"
                                        "Equivalent to the inverse of this\n"
                                        "object. Can be used to remove all\n"
                                        "copper from a specified region.")
        self.layout.addWidget(self.noncopper_label)

        grid3 = QGridLayout()
        self.layout.addLayout(grid3)

        # Margin
        bmlabel = QLabel('Boundary Margin:')
        bmlabel.setToolTip("Specify the edge of the PCB\n"
                           "by drawing a box around all\n"
                           "objects with this minimum\n"
                           "distance.")
        grid3.addWidget(bmlabel, 0, 0)
        self.noncopper_margin_entry = LengthEntry()
        grid3.addWidget(self.noncopper_margin_entry, 0, 1)

        # Rounded corners
        self.noncopper_rounded_cb = FCCheckBox(label="Rounded corners")
        self.noncopper_rounded_cb.setToolTip(
            "Creates a Geometry objects with polygons\n"
            "covering the copper-free areas of the PCB.")
        grid3.addWidget(self.noncopper_rounded_cb, 1, 0, 1, 2)

        ## Bounding box
        self.boundingbox_label = QLabel('<b>Bounding Box:</b>')
        self.layout.addWidget(self.boundingbox_label)

        grid4 = QGridLayout()
        self.layout.addLayout(grid4)

        bbmargin = QLabel('Boundary Margin:')
        bbmargin.setToolTip("Distance of the edges of the box\n"
                            "to the nearest polygon.")
        grid4.addWidget(bbmargin, 0, 0)
        self.bbmargin_entry = LengthEntry()
        grid4.addWidget(self.bbmargin_entry, 0, 1)

        self.bbrounded_cb = FCCheckBox(label="Rounded corners")
        self.bbrounded_cb.setToolTip("If the bounding box is \n"
                                     "to have rounded corners\n"
                                     "their radius is equal to\n"
                                     "the margin.")
        grid4.addWidget(self.bbrounded_cb, 1, 0, 1, 2)
Пример #15
0
class FlatCAMInfoBar(QWidget):
    def __init__(self, parent=None):
        super(FlatCAMInfoBar, self).__init__(parent=parent)

        self.icon = QLabel(self)
        self.icon.setGeometry(0, 0, 12, 12)
        self.pmap = QtGui.QPixmap('share/graylight12.png')
        self.icon.setPixmap(self.pmap)

        layout = QHBoxLayout()
        layout.setContentsMargins(5, 0, 5, 0)
        self.setLayout(layout)

        layout.addWidget(self.icon)

        self.text = QLabel(self)
        self.text.setText("Hello!")
        self.text.setToolTip("Hello!")

        layout.addWidget(self.text)

        layout.addStretch()

    def set_text_(self, text):
        self.text.setText(text)
        self.text.setToolTip(text)

    def set_status(self, text, level="info"):
        level = str(level)
        self.pmap.fill()
        if level == "error":
            self.pmap = QtGui.QPixmap('share/redlight12.png')
        elif level == "success":
            self.pmap = QtGui.QPixmap('share/greenlight12.png')
        elif level == "warning":
            self.pmap = QtGui.QPixmap('share/yellowlight12.png')
        else:
            self.pmap = QtGui.QPixmap('share/graylight12.png')

        self.icon.setPixmap(self.pmap)
        self.set_text_(text)
Пример #16
0
    def __init__(self, version, name=None):
        super(FlatCAMGUI, self).__init__()

        # Divine icon pack by Ipapun @ finicons.com

        ############
        ### Menu ###
        ############
        self.menu = self.menuBar()

        ### File ###
        self.menufile = self.menu.addMenu('&File')

        # New
        self.menufilenew = QAction(QtGui.QIcon('share/file16.png'),
                                   '&New project', self)
        self.menufile.addAction(self.menufilenew)

        # Recent
        self.recent = self.menufile.addMenu(QtGui.QIcon('share/folder16.png'),
                                            "Open recent ...")

        # Separator
        self.menufile.addSeparator()

        # Open gerber ...
        self.menufileopengerber = QAction(QtGui.QIcon('share/folder16.png'),
                                          'Open &Gerber ...', self)
        self.menufile.addAction(self.menufileopengerber)

        # Open Excellon ...
        self.menufileopenexcellon = QAction(QtGui.QIcon('share/folder16.png'),
                                            'Open &Excellon ...', self)
        self.menufile.addAction(self.menufileopenexcellon)

        # Open G-Code ...
        self.menufileopengcode = QAction(QtGui.QIcon('share/folder16.png'),
                                         'Open G-&Code ...', self)
        self.menufile.addAction(self.menufileopengcode)

        # Open Project ...
        self.menufileopenproject = QAction(QtGui.QIcon('share/folder16.png'),
                                           'Open &Project ...', self)
        self.menufile.addAction(self.menufileopenproject)

        # Separator
        self.menufile.addSeparator()

        # Import SVG ...
        self.menufileimportsvg = QAction(QtGui.QIcon('share/folder16.png'),
                                         'Import &SVG ...', self)
        self.menufile.addAction(self.menufileimportsvg)

        # Export SVG ...
        self.menufileexportsvg = QAction(QtGui.QIcon('share/folder16.png'),
                                         'Export &SVG ...', self)
        self.menufile.addAction(self.menufileexportsvg)

        # Separator
        self.menufile.addSeparator()

        # Save Project
        self.menufilesaveproject = QAction(QtGui.QIcon('share/floppy16.png'),
                                           '&Save Project', self)
        self.menufile.addAction(self.menufilesaveproject)

        # Save Project As ...
        self.menufilesaveprojectas = QAction(QtGui.QIcon('share/floppy16.png'),
                                             'Save Project &As ...', self)
        self.menufile.addAction(self.menufilesaveprojectas)

        # Save Project Copy ...
        self.menufilesaveprojectcopy = QAction(
            QtGui.QIcon('share/floppy16.png'), 'Save Project C&opy ...', self)
        self.menufile.addAction(self.menufilesaveprojectcopy)

        # Save Defaults
        self.menufilesavedefaults = QAction(QtGui.QIcon('share/floppy16.png'),
                                            'Save &Defaults', self)
        self.menufile.addAction(self.menufilesavedefaults)

        # Separator
        self.menufile.addSeparator()

        # Quit
        self.exit_action = QAction(QtGui.QIcon('share/power16.png'), '&Exit',
                                   self)
        self.menufile.addAction(self.exit_action)
        # exitAction.setShortcut('Ctrl+Q')
        # exitAction.setStatusTip('Exit application')
        #self.exit_action.triggered.connect(QtGui.qApp.quit)

        ### Edit ###
        self.menuedit = self.menu.addMenu('&Edit')
        self.menueditnew = self.menuedit.addAction(
            QtGui.QIcon('share/new_geo16.png'), 'New Geometry')
        self.menueditedit = self.menuedit.addAction(
            QtGui.QIcon('share/edit16.png'), 'Edit Geometry')
        self.menueditok = self.menuedit.addAction(
            QtGui.QIcon('share/edit_ok16.png'), 'Update Geometry')
        # Separator
        self.menuedit.addSeparator()
        self.menueditjoin = self.menuedit.addAction(
            QtGui.QIcon('share/join16.png'), 'Join Geometry')
        self.menueditdelete = self.menuedit.addAction(
            QtGui.QIcon('share/trash16.png'), 'Delete')
        self.menuedit.addSeparator()

        ### Options ###
        self.menuoptions = self.menu.addMenu('&Options')
        self.menuoptions_transfer = self.menuoptions.addMenu(
            QtGui.QIcon('share/transfer.png'), 'Transfer options')
        self.menuoptions_transfer_a2p = self.menuoptions_transfer.addAction(
            "Application to Project")
        self.menuoptions_transfer_p2a = self.menuoptions_transfer.addAction(
            "Project to Application")
        self.menuoptions_transfer_p2o = self.menuoptions_transfer.addAction(
            "Project to Object")
        self.menuoptions_transfer_o2p = self.menuoptions_transfer.addAction(
            "Object to Project")
        self.menuoptions_transfer_a2o = self.menuoptions_transfer.addAction(
            "Application to Object")
        self.menuoptions_transfer_o2a = self.menuoptions_transfer.addAction(
            "Object to Application")

        ### View ###
        self.menuview = self.menu.addMenu('&View')
        self.menuviewdisableall = self.menuview.addAction(
            QtGui.QIcon('share/clear_plot16.png'), 'Disable all plots')
        self.menuviewdisableother = self.menuview.addAction(
            QtGui.QIcon('share/clear_plot16.png'),
            'Disable all plots but this one')
        self.menuviewenable = self.menuview.addAction(
            QtGui.QIcon('share/replot16.png'), 'Enable all plots')

        ### Tool ###

        self.menutool = QMenu('&Tool')
        self.menutoolaction = self.menu.addMenu(self.menutool)
        self.menutoolshell = self.menutool.addAction(
            QtGui.QIcon('share/shell16.png'), '&Command Line')

        ### Help ###
        self.menuhelp = self.menu.addMenu('&Help')
        self.menuhelp_about = self.menuhelp.addAction(
            QtGui.QIcon('share/tv16.png'), 'About FlatCAM')
        self.menuhelp_home = self.menuhelp.addAction(
            QtGui.QIcon('share/home16.png'), 'Home')
        self.menuhelp_manual = self.menuhelp.addAction(
            QtGui.QIcon('share/globe16.png'), 'Manual')

        ###############
        ### Toolbar ###
        ###############
        self.toolbarfile = QToolBar('File Toolbar')
        self.addToolBar(self.toolbarfile)
        self.open_gerber_btn = self.toolbarfile.addAction(
            QtGui.QIcon('share/flatcam_icon32.png'), "Open &Gerber")
        self.open_exc_btn = self.toolbarfile.addAction(
            QtGui.QIcon('share/drill32.png'), "Open &Excellon")
        self.open_gcode_btn = self.toolbarfile.addAction(
            QtGui.QIcon('share/cnc32.png'), "Open Gco&de")
        self.save_btn = self.toolbarfile.addAction(
            QtGui.QIcon('share/floppy32.png'), 'Save Project &As ...')

        self.toolbarview = QToolBar('View Toolbar')
        self.addToolBar(self.toolbarview)
        self.zoom_fit_btn = self.toolbarview.addAction(
            QtGui.QIcon('share/zoom_fit32.png'), "&Zoom Fit")
        self.zoom_out_btn = self.toolbarview.addAction(
            QtGui.QIcon('share/zoom_out32.png'), "&Zoom Out")
        self.zoom_in_btn = self.toolbarview.addAction(
            QtGui.QIcon('share/zoom_in32.png'), "&Zoom In")
        # Separator
        self.toolbarview.addSeparator()
        self.clear_plot_btn = self.toolbarview.addAction(
            QtGui.QIcon('share/clear_plot32.png'), "&Clear Plot")
        self.replot_btn = self.toolbarview.addAction(
            QtGui.QIcon('share/replot32.png'), "&Replot")

        self.toolbareditobj = QToolBar('Obj.Editor Toolbar')
        self.addToolBar(self.toolbareditobj)
        self.newgeo_btn = self.toolbareditobj.addAction(
            QtGui.QIcon('share/new_geo32.png'), "New Blank Geometry")
        self.editgeo_btn = self.toolbareditobj.addAction(
            QtGui.QIcon('share/edit32.png'), "Edit Geometry")
        self.updategeo_btn = self.toolbareditobj.addAction(
            QtGui.QIcon('share/edit_ok32.png'), "Update Geometry")
        self.updategeo_btn.setEnabled(False)

        self.toolbaredit = QToolBar('Edit Toolbar')
        self.addToolBar(self.toolbaredit)
        self.delete_btn = self.toolbaredit.addAction(
            QtGui.QIcon('share/delete32.png'), "&Delete")

        self.toolbartools = QToolBar('Tools Toolbar')
        self.addToolBar(self.toolbartools)
        self.shell_btn = self.toolbartools.addAction(
            QtGui.QIcon('share/shell32.png'), "&Command Line")
        self.measure_btn = self.toolbartools.addAction(
            QtGui.QIcon('share/measure32.png'), "&Measurement Tool")

        ################
        ### Splitter ###
        ################
        self.splitter = QSplitter()
        self.setCentralWidget(self.splitter)

        ################
        ### Notebook ###
        ################
        self.notebook = QTabWidget()

        # self.notebook.setMinimumWidth(250)

        ### Project ###
        project_tab = QWidget()
        project_tab.setMinimumWidth(250)  # Hack
        self.project_tab_layout = QVBoxLayout(project_tab)
        self.project_tab_layout.setContentsMargins(2, 2, 2, 2)
        self.notebook.addTab(project_tab, "Project")

        ### Selected ###
        self.selected_tab = QWidget()
        self.selected_tab_layout = QVBoxLayout(self.selected_tab)
        self.selected_tab_layout.setContentsMargins(2, 2, 2, 2)
        self.selected_scroll_area = VerticalScrollArea()
        self.selected_tab_layout.addWidget(self.selected_scroll_area)
        self.notebook.addTab(self.selected_tab, "Selected")

        ### Options ###
        self.options_tab = QWidget()
        self.options_tab.setContentsMargins(0, 0, 0, 0)
        self.options_tab_layout = QVBoxLayout(self.options_tab)
        self.options_tab_layout.setContentsMargins(2, 2, 2, 2)

        hlay1 = QHBoxLayout()
        self.options_tab_layout.addLayout(hlay1)

        self.icon = QLabel()
        self.icon.setPixmap(QtGui.QPixmap('share/gear48.png'))
        hlay1.addWidget(self.icon)

        self.options_combo = QComboBox()
        self.options_combo.addItem("APPLICATION DEFAULTS")
        self.options_combo.addItem("PROJECT OPTIONS")
        hlay1.addWidget(self.options_combo)
        hlay1.addStretch()

        self.options_scroll_area = VerticalScrollArea()
        self.options_tab_layout.addWidget(self.options_scroll_area)

        self.notebook.addTab(self.options_tab, "Options")

        ### Tool ###
        self.tool_tab = QWidget()
        self.tool_tab_layout = QVBoxLayout(self.tool_tab)
        self.tool_tab_layout.setContentsMargins(2, 2, 2, 2)
        self.notebook.addTab(self.tool_tab, "Tool")
        self.tool_scroll_area = VerticalScrollArea()
        self.tool_tab_layout.addWidget(self.tool_scroll_area)

        self.splitter.addWidget(self.notebook)

        ######################
        ### Plot and other ###
        ######################
        right_widget = QWidget()
        # right_widget.setContentsMargins(0, 0, 0, 0)
        self.splitter.addWidget(right_widget)
        self.right_layout = QVBoxLayout()
        #self.right_layout.setMargin(0)
        self.right_layout.setContentsMargins(0, 0, 0, 0)
        right_widget.setLayout(self.right_layout)

        ################
        ### Info bar ###
        ################
        infobar = self.statusBar()

        #self.info_label = QLabel("Welcome to FlatCAM.")
        #self.info_label.setFrameStyle(QtGui.QFrame.StyledPanel | QtGui.QFrame.Plain)
        #infobar.addWidget(self.info_label, stretch=1)
        self.fcinfo = FlatCAMInfoBar()
        infobar.addWidget(self.fcinfo, stretch=1)

        self.position_label = QLabel("")
        #self.position_label.setFrameStyle(QtGui.QFrame.StyledPanel | QtGui.QFrame.Plain)
        self.position_label.setMinimumWidth(110)
        infobar.addWidget(self.position_label)

        self.units_label = QLabel("[in]")
        # self.units_label.setFrameStyle(QtGui.QFrame.StyledPanel | QtGui.QFrame.Plain)
        self.units_label.setMargin(2)
        infobar.addWidget(self.units_label)

        self.progress_bar = QProgressBar()
        self.progress_bar.setMinimum(0)
        self.progress_bar.setMaximum(100)
        #infobar.addWidget(self.progress_bar)

        self.activity_view = FlatCAMActivityView()
        infobar.addWidget(self.activity_view)

        #############
        ### Icons ###
        #############
        self.app_icon = QtGui.QIcon()
        self.app_icon.addFile('share/flatcam_icon16.png', QtCore.QSize(16, 16))
        self.app_icon.addFile('share/flatcam_icon24.png', QtCore.QSize(24, 24))
        self.app_icon.addFile('share/flatcam_icon32.png', QtCore.QSize(32, 32))
        self.app_icon.addFile('share/flatcam_icon48.png', QtCore.QSize(48, 48))
        self.app_icon.addFile('share/flatcam_icon128.png',
                              QtCore.QSize(128, 128))
        self.app_icon.addFile('share/flatcam_icon256.png',
                              QtCore.QSize(256, 256))
        self.setWindowIcon(self.app_icon)

        self.setGeometry(100, 100, 1024, 650)
        title = 'FlatCAM {}'.format(version)
        if name is not None:
            title += ' - {}'.format(name)
        self.setWindowTitle(title)
        self.show()