def __init__(self, *args):
        QWidget.__init__(self, *args)

        self._browser = QTextEdit(self)
        self._browser.setStyleSheet("font: 9pt \"Courier\";")
        self._browser.setReadOnly(True)
        self._browser.document().setDefaultStyleSheet(
            self._browser.document().defaultStyleSheet() +
            "span {white-space:pre;}")

        self._edit = _ExpandableTextEdit(self, self)
        self._edit.historyNext.connect(self._on_history_next)
        self._edit.historyPrev.connect(self._on_history_prev)
        self.setFocusProxy(self._edit)

        layout = QVBoxLayout(self)
        layout.setSpacing(0)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(self._browser)
        layout.addWidget(self._edit)

        self._history = ['']  # current empty line
        self._historyIndex = 0

        self._edit.setFocus()
    def __init__(self, choices, orientation='horizontal', parent=None):
        """
        The choices are specified as a list of dictionaries containing:

        * 'label': Shown in the UI
        * 'value': The value returned is selected

        :param choices: List of choices. See description.
        :param orientation: 'horizontal' (default) of 'vertical'.
        :param parent: Qt parent widget.
        :type choices: list
        """
        super(RadioSet, self).__init__(parent)
        self.choices = copy(choices)

        if orientation == 'horizontal':
            layout = QHBoxLayout()
        else:
            layout = QVBoxLayout()

        group = QButtonGroup(self)

        for choice in self.choices:
            choice['radio'] = QRadioButton(choice['label'])
            group.addButton(choice['radio'])
            layout.addWidget(choice['radio'], stretch=0)
            choice['radio'].toggled.connect(self.on_toggle)

        layout.addStretch()
        self.setLayout(layout)

        self.group_toggle_fn = lambda: None
Esempio n. 3
0
    def __init__(self, title, parent=None):
        QGroupBox.__init__(self, title, parent=parent)
        self.setStyleSheet("""
        QGroupBox
        {
            font-size: 16px;
            font-weight: bold;
        }
        """)

        self.layout = QVBoxLayout()
        self.setLayout(self.layout)
    def __init__(self, app, parent=None):
        """

        :param app: The application this tool will run in.
        :type app: App
        :param parent: Qt Parent
        :return: FlatCAMTool
        """
        QWidget.__init__(self, parent)

        # self.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Maximum)

        self.layout = QVBoxLayout()
        self.setLayout(self.layout)

        self.app = app

        self.menuAction = None
Esempio n. 5
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')
Esempio n. 6
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()
Esempio n. 7
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
Esempio n. 8
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')
Esempio n. 9
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)
Esempio n. 10
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()