Beispiel #1
0
class ObjectUI(QtGui.QWidget):
    """
    Base class for the UI of FlatCAM objects. Deriving classes should
    put UI elements in ObjectUI.custom_box (QtGui.QLayout).
    """

    def __init__(self, icon_file='share/flatcam_icon32.png', title='FlatCAM Object', parent=None):
        QtGui.QWidget.__init__(self, parent=parent)

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

        ## Page Title box (spacing between children)
        self.title_box = QtGui.QHBoxLayout()
        layout.addLayout(self.title_box)

        ## Page Title icon
        pixmap = QtGui.QPixmap(icon_file)
        self.icon = QtGui.QLabel()
        self.icon.setPixmap(pixmap)
        self.title_box.addWidget(self.icon, stretch=0)

        ## Title label
        self.title_label = QtGui.QLabel("<font size=5><b>" + title + "</b></font>")
        self.title_label.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
        self.title_box.addWidget(self.title_label, stretch=1)

        ## Object name
        self.name_box = QtGui.QHBoxLayout()
        layout.addLayout(self.name_box)
        name_label = QtGui.QLabel("Name:")
        self.name_box.addWidget(name_label)
        self.name_entry = FCEntry()
        self.name_box.addWidget(self.name_entry)

        ## Box box for custom widgets
        # This gets populated in offspring implementations.
        self.custom_box = QtGui.QVBoxLayout()
        layout.addLayout(self.custom_box)

        ###########################
        ## Common to all objects ##
        ###########################

        #### Scale ####
        self.scale_label = QtGui.QLabel('<b>Scale:</b>')
        self.scale_label.setToolTip(
            "Change the size of the object."
        )
        layout.addWidget(self.scale_label)

        self.scale_grid = QtGui.QGridLayout()
        layout.addLayout(self.scale_grid)

        # Factor
        faclabel = QtGui.QLabel('Factor:')
        faclabel.setToolTip(
            "Factor by which to multiply\n"
            "geometric features of this object."
        )
        self.scale_grid.addWidget(faclabel, 0, 0)
        self.scale_entry = FloatEntry()
        self.scale_entry.set_value(1.0)
        self.scale_grid.addWidget(self.scale_entry, 0, 1)

        # GO Button
        self.scale_button = QtGui.QPushButton('Scale')
        self.scale_button.setToolTip(
            "Perform scaling operation."
        )
        layout.addWidget(self.scale_button)

        #### Offset ####
        self.offset_label = QtGui.QLabel('<b>Offset:</b>')
        self.offset_label.setToolTip(
            "Change the position of this object."
        )
        layout.addWidget(self.offset_label)

        self.offset_grid = QtGui.QGridLayout()
        layout.addLayout(self.offset_grid)

        self.offset_vectorlabel = QtGui.QLabel('Vector:')
        self.offset_vectorlabel.setToolTip(
            "Amount by which to move the object\n"
            "in the x and y axes in (x, y) format."
        )
        self.offset_grid.addWidget(self.offset_vectorlabel, 0, 0)
        self.offsetvector_entry = EvalEntry()
        self.offsetvector_entry.setText("(0.0, 0.0)")
        self.offset_grid.addWidget(self.offsetvector_entry, 0, 1)

        self.offset_button = QtGui.QPushButton('Offset')
        self.offset_button.setToolTip(
            "Perform the offset operation."
        )
        layout.addWidget(self.offset_button)

        layout.addStretch()
Beispiel #2
0
    def __init__(self, parent=None):
        ObjectUI.__init__(self, title='Gerber Object', parent=parent)

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

        grid0 = QtWidgets.QGridLayout()
        self.custom_box.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 = QtWidgets.QLabel(
            "<b>Isolation Routing:</b>")
        self.isolation_routing_label.setToolTip(
            "Create a Geometry object with\n"
            "toolpaths to cut outside polygons.")
        self.custom_box.addWidget(self.isolation_routing_label)

        grid1 = QtWidgets.QGridLayout()
        self.custom_box.addLayout(grid1)
        tdlabel = QtWidgets.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 = QtWidgets.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 = QtWidgets.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)

        # combine all passes CB
        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)

        self.generate_iso_button = QtWidgets.QPushButton('Generate Geometry')
        self.generate_iso_button.setToolTip("Create the Geometry Object\n"
                                            "for isolation routing.")
        self.custom_box.addWidget(self.generate_iso_button)

        ## Board cuttout
        self.board_cutout_label = QtWidgets.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.custom_box.addWidget(self.board_cutout_label)

        grid2 = QtWidgets.QGridLayout()
        self.custom_box.addLayout(grid2)
        tdclabel = QtWidgets.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 = QtWidgets.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 = QtWidgets.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 = QtWidgets.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)

        self.generate_cutout_button = QtWidgets.QPushButton(
            'Generate Geometry')
        self.generate_cutout_button.setToolTip("Generate the geometry for\n"
                                               "the board cutout.")
        self.custom_box.addWidget(self.generate_cutout_button)

        ## Non-copper regions
        self.noncopper_label = QtWidgets.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.custom_box.addWidget(self.noncopper_label)

        grid3 = QtWidgets.QGridLayout()
        self.custom_box.addLayout(grid3)

        # Margin
        bmlabel = QtWidgets.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)

        self.generate_noncopper_button = QtWidgets.QPushButton(
            'Generate Geometry')
        self.custom_box.addWidget(self.generate_noncopper_button)

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

        grid4 = QtWidgets.QGridLayout()
        self.custom_box.addLayout(grid4)

        bbmargin = QtWidgets.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)

        self.generate_bb_button = QtWidgets.QPushButton('Generate Geometry')
        self.generate_bb_button.setToolTip("Generate the Geometry object.")
        self.custom_box.addWidget(self.generate_bb_button)
Beispiel #3
0
class ObjectUI(QtWidgets.QWidget):
    """
    Base class for the UI of FlatCAM objects. Deriving classes should
    put UI elements in ObjectUI.custom_box (QtWidgets.QLayout).
    """
    def __init__(self,
                 icon_file='share/flatcam_icon32.png',
                 title='FlatCAM Object',
                 parent=None):
        QtWidgets.QWidget.__init__(self, parent=parent)

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

        ## Page Title box (spacing between children)
        self.title_box = QtWidgets.QHBoxLayout()
        layout.addLayout(self.title_box)

        ## Page Title icon
        pixmap = QtWidgets.QPixmap(icon_file)
        self.icon = QtWidgets.QLabel()
        self.icon.setPixmap(pixmap)
        self.title_box.addWidget(self.icon, stretch=0)

        ## Title label
        self.title_label = QtWidgets.QLabel("<font size=5><b>" + title +
                                            "</b></font>")
        self.title_label.setAlignment(QtCore.Qt.AlignLeft
                                      | QtCore.Qt.AlignVCenter)
        self.title_box.addWidget(self.title_label, stretch=1)

        ## Object name
        self.name_box = QtWidgets.QHBoxLayout()
        layout.addLayout(self.name_box)
        name_label = QtWidgets.QLabel("Name:")
        self.name_box.addWidget(name_label)
        self.name_entry = FCEntry()
        self.name_box.addWidget(self.name_entry)

        ## Box box for custom widgets
        # This gets populated in offspring implementations.
        self.custom_box = QtWidgets.QVBoxLayout()
        layout.addLayout(self.custom_box)

        ###########################
        ## Common to all objects ##
        ###########################

        #### Scale ####
        self.scale_label = QtWidgets.QLabel('<b>Scale:</b>')
        self.scale_label.setToolTip("Change the size of the object.")
        layout.addWidget(self.scale_label)

        self.scale_grid = QtWidgets.QGridLayout()
        layout.addLayout(self.scale_grid)

        # Factor
        faclabel = QtWidgets.QLabel('Factor:')
        faclabel.setToolTip("Factor by which to multiply\n"
                            "geometric features of this object.")
        self.scale_grid.addWidget(faclabel, 0, 0)
        self.scale_entry = FloatEntry()
        self.scale_entry.set_value(1.0)
        self.scale_grid.addWidget(self.scale_entry, 0, 1)

        # GO Button
        self.scale_button = QtWidgets.QPushButton('Scale')
        self.scale_button.setToolTip("Perform scaling operation.")
        layout.addWidget(self.scale_button)

        #### Offset ####
        self.offset_label = QtWidgets.QLabel('<b>Offset:</b>')
        self.offset_label.setToolTip("Change the position of this object.")
        layout.addWidget(self.offset_label)

        self.offset_grid = QtWidgets.QGridLayout()
        layout.addLayout(self.offset_grid)

        self.offset_vectorlabel = QtWidgets.QLabel('Vector:')
        self.offset_vectorlabel.setToolTip(
            "Amount by which to move the object\n"
            "in the x and y axes in (x, y) format.")
        self.offset_grid.addWidget(self.offset_vectorlabel, 0, 0)
        self.offsetvector_entry = EvalEntry()
        self.offsetvector_entry.setText("(0.0, 0.0)")
        self.offset_grid.addWidget(self.offsetvector_entry, 0, 1)

        self.offset_button = QtWidgets.QPushButton('Offset')
        self.offset_button.setToolTip("Perform the offset operation.")
        layout.addWidget(self.offset_button)

        self.auto_offset_button = QtWidgets.QPushButton('Offset auto')
        self.auto_offset_button.setToolTip(
            "Align the object with the x and y axes.")
        layout.addWidget(self.auto_offset_button)

        #### Mirror ####
        self.mirror_label = QtWidgets.QLabel('<b>Mirror:</b>')
        self.mirror_label.setToolTip("Flip the object along an axis.")
        layout.addWidget(self.mirror_label)

        self.mirror_axis_grid = QtWidgets.QGridLayout()
        layout.addLayout(self.mirror_axis_grid)

        axislabel = QtWidgets.QLabel('Axis:')
        axislabel.setToolTip("Mirror axis parallel to the x or y axis.")
        self.mirror_axis_grid.addWidget(axislabel, 0, 0)

        self.mirror_axis_radio = RadioSet([{
            'label': 'X',
            'value': 'X'
        }, {
            'label': 'Y',
            'value': 'Y'
        }])
        self.mirror_axis_radio.set_value('Y')
        self.mirror_axis_grid.addWidget(self.mirror_axis_radio, 0, 1)

        self.mirror_auto_center_cb = FCCheckBox(
            label='Center axis automatically')
        self.mirror_auto_center_cb.setToolTip(
            "Place the mirror axis on the middle of the object.")
        self.mirror_auto_center_cb.set_value(True)
        layout.addWidget(self.mirror_auto_center_cb)

        self.mirror_button = QtWidgets.QPushButton('Mirror')
        self.mirror_button.setToolTip("Perform the mirror operation.")
        layout.addWidget(self.mirror_button)

        layout.addStretch()
Beispiel #4
0
    def __init__(self,
                 icon_file='share/flatcam_icon32.png',
                 title='FlatCAM Object',
                 parent=None):
        QtGui.QWidget.__init__(self, parent=parent)

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

        ## Page Title box (spacing between children)
        self.title_box = QtGui.QHBoxLayout()
        layout.addLayout(self.title_box)

        ## Page Title icon
        pixmap = QtGui.QPixmap(icon_file)
        self.icon = QtGui.QLabel()
        self.icon.setPixmap(pixmap)
        self.title_box.addWidget(self.icon, stretch=0)

        ## Title label
        self.title_label = QtGui.QLabel("<font size=5><b>" + title +
                                        "</b></font>")
        self.title_label.setAlignment(QtCore.Qt.AlignLeft
                                      | QtCore.Qt.AlignVCenter)
        self.title_box.addWidget(self.title_label, stretch=1)

        ## Object name
        self.name_box = QtGui.QHBoxLayout()
        layout.addLayout(self.name_box)
        name_label = QtGui.QLabel("Name:")
        self.name_box.addWidget(name_label)
        self.name_entry = FCEntry()
        self.name_box.addWidget(self.name_entry)

        ## Box box for custom widgets
        # This gets populated in offspring implementations.
        self.custom_box = QtGui.QVBoxLayout()
        layout.addLayout(self.custom_box)

        ###########################
        ## Common to all objects ##
        ###########################

        #### Scale ####
        self.scale_label = QtGui.QLabel('<b>Scale:</b>')
        self.scale_label.setToolTip("Change the size of the object.")
        layout.addWidget(self.scale_label)

        self.scale_grid = QtGui.QGridLayout()
        layout.addLayout(self.scale_grid)

        # Factor
        faclabel = QtGui.QLabel('Factor:')
        faclabel.setToolTip("Factor by which to multiply\n"
                            "geometric features of this object.")
        self.scale_grid.addWidget(faclabel, 0, 0)
        self.scale_entry = FloatEntry()
        self.scale_entry.set_value(1.0)
        self.scale_grid.addWidget(self.scale_entry, 0, 1)

        # GO Button
        self.scale_button = QtGui.QPushButton('Scale')
        self.scale_button.setToolTip("Perform scaling operation.")
        layout.addWidget(self.scale_button)

        #### Offset ####
        self.offset_label = QtGui.QLabel('<b>Offset:</b>')
        self.offset_label.setToolTip("Change the position of this object.")
        layout.addWidget(self.offset_label)

        self.offset_grid = QtGui.QGridLayout()
        layout.addLayout(self.offset_grid)

        self.offset_vectorlabel = QtGui.QLabel('Vector:')
        self.offset_vectorlabel.setToolTip(
            "Amount by which to move the object\n"
            "in the x and y axes in (x, y) format.")
        self.offset_grid.addWidget(self.offset_vectorlabel, 0, 0)
        self.offsetvector_entry = EvalEntry()
        self.offsetvector_entry.setText("(0.0, 0.0)")
        self.offset_grid.addWidget(self.offsetvector_entry, 0, 1)

        self.offset_button = QtGui.QPushButton('Offset')
        self.offset_button.setToolTip("Perform the offset operation.")
        layout.addWidget(self.offset_button)

        layout.addStretch()