Example #1
0
    def addColumnHeaders(self):
        """This function add column headers data as each row of items in list
        view."""
        column_header_list_widget = self.form.columnHeaderListWidget

        ui = FreeCADGui.UiLoader()
        sorted_column_header_data = dict(
            sorted(self.column_headers_data.items(), key=lambda x: x[1][1]))
        for (
                column_header,
                column_header_tuple,
        ) in sorted_column_header_data.items():
            row_widget = QtWidgets.QWidget()
            row_widget_item = QtWidgets.QListWidgetItem()

            show_hide_checkbox = ui.createWidget("Gui::PrefCheckBox")
            if column_header_tuple[1] != 0:
                show_hide_checkbox.setChecked(True)
            column_name = QtWidgets.QLabel(column_header)
            column_name.setMinimumWidth(220)
            spreadsheet_column_header = ui.createWidget("Gui::PrefLineEdit")
            spreadsheet_column_header.setText(column_header_tuple[0])

            h_layout = QtWidgets.QHBoxLayout()
            h_layout.addWidget(show_hide_checkbox)
            h_layout.addWidget(column_name)
            h_layout.addWidget(spreadsheet_column_header)

            row_widget.setLayout(h_layout)
            row_widget_item.setSizeHint(row_widget.sizeHint())

            column_header_list_widget.addItem(row_widget_item)
            column_header_list_widget.setItemWidget(row_widget_item,
                                                    row_widget)
Example #2
0
    def __init__(self):
        QtGui.QWidget.__init__(self)
        gridCoords = QtGui.QGridLayout(self)
        loader = FreeCADGui.UiLoader()

        lbl01 = QtGui.QLabel("Global coords")
        lbl02 = QtGui.QLabel("Local Vector")

        lbl1 = QtGui.QLabel("Origin X")
        self.oX = loader.createWidget("Gui::InputField")
        lbl2 = QtGui.QLabel("Origin Y")
        self.oY = loader.createWidget("Gui::InputField")
        lbl3 = QtGui.QLabel("Origin Z")
        self.oZ = loader.createWidget("Gui::InputField")
        lbl4 = QtGui.QLabel("End X")
        self.eX = loader.createWidget("Gui::InputField")
        lbl5 = QtGui.QLabel("End Y")
        self.eY = loader.createWidget("Gui::InputField")
        self.retry = QtGui.QPushButton("redo")

        gridCoords.addWidget(lbl01, 0, 0, 1, 1)
        gridCoords.addWidget(lbl02, 0, 2, 1, 1)
        gridCoords.addWidget(lbl1, 1, 0, 1, 1)
        gridCoords.addWidget(self.oX, 1, 1, 1, 1)
        gridCoords.addWidget(lbl2, 2, 0, 1, 1)
        gridCoords.addWidget(self.oY, 2, 1, 1, 1)
        gridCoords.addWidget(lbl3, 3, 0, 1, 1)
        gridCoords.addWidget(self.oZ, 3, 1, 1, 1)
        gridCoords.addWidget(lbl4, 1, 2, 1, 1)
        gridCoords.addWidget(self.eX, 1, 3, 1, 1)
        gridCoords.addWidget(lbl5, 2, 2, 1, 1)
        gridCoords.addWidget(self.eY, 2, 3, 1, 1)
        gridCoords.addWidget(self.retry, 1, 4, 1, 1)
Example #3
0
    def taskbox(self):
        "sets up a taskbox widget"

        w = QtGui.QWidget()
        ui = Gui.UiLoader()
        w.setWindowTitle("Wall options")
        grid = QtGui.QGridLayout(w)

        matCombo = QtGui.QComboBox()
        matCombo.addItem("Wall Presets...")
        matCombo.setToolTip(
            "This list shows all the MultiMaterials objects of this document. Create some to define wall types."
        )
        self.multimats = []
        self.MultiMat = None
        for o in App.ActiveDocument.Objects:
            if Draft.getType(o) == "MultiMaterial":
                self.multimats.append(o)
                matCombo.addItem(o.Label)
        if hasattr(App, "LastArchMultiMaterial"):
            for i, o in enumerate(self.multimats):
                if o.Name == App.LastArchMultiMaterial:
                    matCombo.setCurrentIndex(i + 1)
                    self.MultiMat = o
        grid.addWidget(matCombo, 0, 0, 1, 2)

        label5 = QtGui.QLabel("Length")
        self.Length = ui.createWidget("Gui::InputField")
        self.Length.setText("0.00 mm")
        grid.addWidget(label5, 1, 0, 1, 1)
        grid.addWidget(self.Length, 1, 1, 1, 1)
        return w
    def createEditor(self, parent, option, index):

        if index.column() == 0:  # property name
            editor = QtGui.QLineEdit(parent)
        elif index.column() == 1:  # property type
            editor = QtGui.QComboBox(parent)
        else:  # property value
            ptype = index.sibling(index.row(), 1).data()
            if "Integer" in ptype:
                editor = QtGui.QSpinBox(parent)
            elif "Real" in ptype:
                editor = QtGui.QDoubleSpinBox(parent)
                editor.setDecimals(
                    FreeCAD.ParamGet(
                        "User parameter:BaseApp/Preferences/Units").GetInt(
                            "Decimals", 2))
            elif ("Boolean" in ptype) or ("Logical" in ptype):
                editor = QtGui.QComboBox(parent)
                editor.addItems(["True", "False"])
            elif "Measure" in ptype:
                editor = FreeCADGui.UiLoader().createWidget("Gui::InputField")
                editor.setParent(parent)
            else:
                editor = QtGui.QLineEdit(parent)
            editor.setObjectName("editor_" + ptype)
        return editor
Example #5
0
    def getWidget6(self):
        widget6 = QtGui.QWidget()
        widget6.setWindowTitle("Stirrup")
        widget6.setFixedHeight(150)

        self.image6Label = QtGui.QLabel(u"image6")
        self.image6Label.setParent(widget6)
        self.image6Label.setPixmap(
            QtGui.QPixmap(
                os.path.split(os.path.abspath(__file__))[0] +
                "/ui/Beam/StirrupRebar.svg"))

        self.DiaStirrupLabel = QtGui.QLabel(u"Dia =")
        self.DiaStirrupLabel.setParent(widget6)
        self.DiaStirrupLabel.setGeometry(50, 30, 40, 25)  # x,y ,w, h
        self.DiaStirrupLabel2 = QtGui.QLabel(u"@")
        self.DiaStirrupLabel2.setParent(widget6)
        self.DiaStirrupLabel2.setGeometry(140, 30, 40, 25)  # x,y ,w, h

        self.DiaStirrup = QtGui.QComboBox(widget6)
        self.DiaStirrup.addItem("6")
        self.DiaStirrup.addItem("9")
        self.DiaStirrup.addItem("12")
        self.DiaStirrup.setCurrentIndex(0)
        self.DiaStirrup.setGeometry(90, 30, 40, 25)

        self.Spacing = FreeCADGui.UiLoader().createWidget("Gui::InputField")
        self.Spacing.setText(
            FreeCAD.Units.Quantity(175, FreeCAD.Units.Length).UserString)
        self.Spacing.setParent(widget6)
        self.Spacing.setGeometry(170, 30, 100, 25)
        return widget6
Example #6
0
    def setTabTtw(self):

        ui = FreeCADGui.UiLoader()

        self.ttwGroup = QtGui.QGroupBox(translate('Rocket', "TTW Tab"), self)
        self.ttwGroup.setCheckable(True)

        self.ttwOffsetLabel = QtGui.QLabel(translate('Rocket', "Offset"), self)

        self.ttwOffsetInput = ui.createWidget("Gui::InputField")
        self.ttwOffsetInput.unit = 'mm'
        self.ttwOffsetInput.setFixedWidth(80)

        self.ttwLengthLabel = QtGui.QLabel(translate('Rocket', "Length"), self)

        self.ttwLengthInput = ui.createWidget("Gui::InputField")
        self.ttwLengthInput.unit = 'mm'
        self.ttwLengthInput.setFixedWidth(80)

        self.ttwHeightLabel = QtGui.QLabel(translate('Rocket', "Height"), self)

        self.ttwHeightInput = ui.createWidget("Gui::InputField")
        self.ttwHeightInput.unit = 'mm'
        self.ttwHeightInput.setFixedWidth(80)

        self.ttwThicknessLabel = QtGui.QLabel(translate('Rocket', "Thickness"),
                                              self)

        self.ttwThicknessInput = ui.createWidget("Gui::InputField")
        self.ttwThicknessInput.unit = 'mm'
        self.ttwThicknessInput.setFixedWidth(80)

        row = 0
        grid = QGridLayout()

        grid.addWidget(self.ttwOffsetLabel, row, 0)
        grid.addWidget(self.ttwOffsetInput, row, 1)
        row += 1

        grid.addWidget(self.ttwLengthLabel, row, 0)
        grid.addWidget(self.ttwLengthInput, row, 1)
        row += 1

        grid.addWidget(self.ttwHeightLabel, row, 0)
        grid.addWidget(self.ttwHeightInput, row, 1)
        row += 1

        grid.addWidget(self.ttwThicknessLabel, row, 0)
        grid.addWidget(self.ttwThicknessInput, row, 1)

        self.ttwGroup.setLayout(grid)

        layout = QVBoxLayout()
        layout.addWidget(self.ttwGroup)
        layout.addItem(
            QtGui.QSpacerItem(0, 0, QSizePolicy.Expanding,
                              QSizePolicy.Expanding))

        self.tabTtw.setLayout(layout)
Example #7
0
    def initUI(self):

        ui = FreeCADGui.UiLoader()

        # create our window
        # define window		xLoc,yLoc,xDim,yDim
        self.setGeometry(250, 250, 640, 480)
        self.setWindowTitle(
            translate('Rocket', "Minimum Thrust to Weight Calculator"))
        self.resize(QtCore.QSize(100, 100).expandedTo(
            self.minimumSizeHint()))  # sets size of the widget
        self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)

        self.weightLabel = QtGui.QLabel(translate('Rocket', "Weight"), self)

        self.weightInput = ui.createWidget("Gui::InputField")
        self.weightInput.unit = 'kg'
        self.weightInput.setFixedWidth(100)
        self.weightInput.setText("1.0")
        self.weightInput.textEdited.connect(self.onWeight)

        self.thrustLabel = QtGui.QLabel(translate('Rocket', "Minimum Thrust"),
                                        self)

        self.thrustInput = ui.createWidget("Gui::InputField")
        self.thrustInput.unit = 'N'
        self.thrustInput.setText("49.0")
        self.thrustInput.setFixedWidth(100)
        self.thrustInput.setReadOnly(True)

        # OK button
        okButton = QtGui.QPushButton('OK', self)
        okButton.setDefault(False)
        okButton.setAutoDefault(False)
        okButton.clicked.connect(self.onOk)

        layout = QVBoxLayout()
        line = QGridLayout()

        line.addWidget(self.weightLabel, 0, 0, 1, 2)
        line.addWidget(self.weightInput, 0, 1)

        line.addWidget(self.thrustLabel, 1, 0)
        line.addWidget(self.thrustInput, 1, 1)
        layout.addLayout(line)

        # layout.addStretch()

        line = QHBoxLayout()
        line.addStretch()
        line.addWidget(okButton)
        layout.addLayout(line)

        self.setLayout(layout)

        # now make the window visible
        self.show()
Example #8
0
    def addColumnHeaders(self):
        """This function add column headers data as each row of items in list
        view."""
        column_header_list_widget = self.form.columnHeaderListWidget

        ui = FreeCADGui.UiLoader()
        for (
                column_header,
                column_header_disp,
        ) in self.column_headers_data.items():
            row_widget = QtWidgets.QWidget()
            row_widget_item = QtWidgets.QListWidgetItem()

            show_hide_checkbox = ui.createWidget("Gui::PrefCheckBox")
            show_hide_checkbox.setChecked(True)
            column_name = QtWidgets.QLabel(column_header)
            column_name.setMinimumWidth(220)
            column_header_disp_widget = ui.createWidget("Gui::PrefLineEdit")
            column_header_disp_widget.setText(column_header_disp)

            h_layout = QtWidgets.QHBoxLayout()
            h_layout.addWidget(show_hide_checkbox)
            h_layout.addWidget(column_name)
            h_layout.addWidget(column_header_disp_widget)

            row_widget.setLayout(h_layout)
            row_widget_item.setSizeHint(row_widget.sizeHint())

            column_header_list_widget.addItem(row_widget_item)
            column_header_list_widget.setItemWidget(row_widget_item,
                                                    row_widget)

        # Add hidden columns in UI
        for column_header, column_header_disp in COLUMN_HEADERS.items():
            if column_header not in self.column_headers_data:
                row_widget = QtWidgets.QWidget()
                row_widget_item = QtWidgets.QListWidgetItem()

                show_hide_checkbox = ui.createWidget("Gui::PrefCheckBox")
                show_hide_checkbox.setChecked(False)
                column_name = QtWidgets.QLabel(column_header)
                column_name.setMinimumWidth(160)
                column_header_disp_widget = ui.createWidget(
                    "Gui::PrefLineEdit")
                column_header_disp_widget.setText(column_header_disp)

                h_layout = QtWidgets.QHBoxLayout()
                h_layout.addWidget(show_hide_checkbox)
                h_layout.addWidget(column_name)
                h_layout.addWidget(column_header_disp_widget)

                row_widget.setLayout(h_layout)
                row_widget_item.setSizeHint(row_widget.sizeHint())

                column_header_list_widget.addItem(row_widget_item)
                column_header_list_widget.setItemWidget(
                    row_widget_item, row_widget)
Example #9
0
    def setTabShoulder(self):
        ui = FreeCADGui.UiLoader()

        self.shoulderLabel = QtGui.QLabel(translate('Rocket', "Shoulder"),
                                          self)

        self.shoulderCheckbox = QtGui.QCheckBox(self)
        self.shoulderCheckbox.setCheckState(QtCore.Qt.Unchecked)

        self.shoulderDiameterLabel = QtGui.QLabel(
            translate('Rocket', "Diameter"), self)

        self.shoulderDiameterInput = ui.createWidget("Gui::InputField")
        self.shoulderDiameterInput.unit = 'mm'
        self.shoulderDiameterInput.setFixedWidth(80)
        self.shoulderDiameterInput.setEnabled(False)

        self.shoulderLengthLabel = QtGui.QLabel(translate('Rocket', "Length"),
                                                self)

        self.shoulderLengthInput = ui.createWidget("Gui::InputField")
        self.shoulderLengthInput.unit = 'mm'
        self.shoulderLengthInput.setFixedWidth(80)
        self.shoulderLengthInput.setEnabled(False)

        self.shoulderThicknessLabel = QtGui.QLabel(
            translate('Rocket', "Thickness"), self)

        self.shoulderThicknessInput = ui.createWidget("Gui::InputField")
        self.shoulderThicknessInput.unit = 'mm'
        self.shoulderThicknessInput.setFixedWidth(80)
        self.shoulderThicknessInput.setEnabled(False)

        layout = QGridLayout()
        row = 0

        layout.addWidget(self.shoulderLabel, row, 0, 1, 2)
        layout.addWidget(self.shoulderCheckbox, row, 1)
        row += 1

        layout.addWidget(self.shoulderLengthLabel, row, 0)
        layout.addWidget(self.shoulderLengthInput, row, 1)
        row += 1

        layout.addWidget(self.shoulderDiameterLabel, row, 0)
        layout.addWidget(self.shoulderDiameterInput, row, 1)
        row += 1

        layout.addWidget(self.shoulderThicknessLabel, row, 0)
        layout.addWidget(self.shoulderThicknessInput, row, 1)

        layout.addItem(
            QtGui.QSpacerItem(0, 0, QSizePolicy.Expanding,
                              QSizePolicy.Expanding))

        self.tabShoulder.setLayout(layout)
Example #10
0
 def addSet(self):
     sets = len(self.RoundingSpinBoxList)
     # Create Rounding Combo Box
     ui = FreeCADGui.UiLoader()
     rounding = ui.createWidget("Gui::PrefSpinBox")
     rounding.setValue(2)
     form_layout = self.form.formLayout
     index = sets
     form_layout.insertRow(index, "Set " + str(sets + 1), rounding)
     self.RoundingSpinBoxList.append(rounding)
 def addSet(self):
     sets = len(self.RebarTypeComboBoxList)
     # Create Rebar Type Combo Box
     ui = FreeCADGui.UiLoader()
     rebar_type = ui.createWidget("Gui::PrefComboBox")
     rebar_type.addItems(["StraightRebar", "LShapeRebar"])
     form_layout = self.form.formLayout
     index = sets
     form_layout.insertRow(index, "Set " + str(sets + 1), rebar_type)
     self.RebarTypeComboBoxList.append(rebar_type)
Example #12
0
    def taskbox(self):
        """Returns the opening taskbox widget. 
        Used by the snapper to append the widget to the task panel. 
        """

        w = QtGui.QWidget()
        ui = Gui.UiLoader()
        w.setWindowTitle(translate("Arch","Opening options"))
        grid = QtGui.QGridLayout(w)
        return w
Example #13
0
    def taskbox(self):
        "sets up a taskbox widget"
        w = QtGui.QWidget()
        ui = FreeCADGui.UiLoader()
        w.setWindowTitle(translate("Arch","Wall options").decode("utf8"))
        grid = QtGui.QGridLayout(w)

        label5 = QtGui.QLabel(translate("Arch","Length").decode("utf8"))
        self.Length = ui.createWidget("Gui::InputField")
        self.Length.setText("0.00 mm")
        grid.addWidget(label5,0,0,1,1)
        grid.addWidget(self.Length,0,1,1,1)

        label1 = QtGui.QLabel(translate("Arch","Width").decode("utf8"))
        value1 = ui.createWidget("Gui::InputField")
        value1.setText(FreeCAD.Units.Quantity(self.Width,FreeCAD.Units.Length).UserString)
        grid.addWidget(label1,1,0,1,1)
        grid.addWidget(value1,1,1,1,1)

        label2 = QtGui.QLabel(translate("Arch","Height").decode("utf8"))
        value2 = ui.createWidget("Gui::InputField")
        value2.setText(FreeCAD.Units.Quantity(self.Height,FreeCAD.Units.Length).UserString)
        grid.addWidget(label2,2,0,1,1)
        grid.addWidget(value2,2,1,1,1)

        label3 = QtGui.QLabel(translate("Arch","Alignment").decode("utf8"))
        value3 = QtGui.QComboBox()
        items = ["Center","Left","Right"]
        value3.addItems(items)
        value3.setCurrentIndex(items.index(self.Align))
        grid.addWidget(label3,3,0,1,1)
        grid.addWidget(value3,3,1,1,1)

        label4 = QtGui.QLabel(translate("Arch","Con&tinue").decode("utf8"))
        value4 = QtGui.QCheckBox()
        value4.setObjectName("ContinueCmd")
        value4.setLayoutDirection(QtCore.Qt.RightToLeft)
        label4.setBuddy(value4)
        if hasattr(FreeCADGui,"draftToolBar"):
            value4.setChecked(FreeCADGui.draftToolBar.continueMode)
            self.continueCmd = FreeCADGui.draftToolBar.continueMode
        grid.addWidget(label4,4,0,1,1)
        grid.addWidget(value4,4,1,1,1)

        QtCore.QObject.connect(self.Length,QtCore.SIGNAL("valueChanged(double)"),self.setLength)
        QtCore.QObject.connect(value1,QtCore.SIGNAL("valueChanged(double)"),self.setWidth)
        QtCore.QObject.connect(value2,QtCore.SIGNAL("valueChanged(double)"),self.setHeight)
        QtCore.QObject.connect(value3,QtCore.SIGNAL("currentIndexChanged(int)"),self.setAlign)
        QtCore.QObject.connect(value4,QtCore.SIGNAL("stateChanged(int)"),self.setContinue)
        QtCore.QObject.connect(self.Length,QtCore.SIGNAL("returnPressed()"),value1.setFocus)
        QtCore.QObject.connect(self.Length,QtCore.SIGNAL("returnPressed()"),value1.selectAll)
        QtCore.QObject.connect(value1,QtCore.SIGNAL("returnPressed()"),value2.setFocus)
        QtCore.QObject.connect(value1,QtCore.SIGNAL("returnPressed()"),value2.selectAll)
        QtCore.QObject.connect(value2,QtCore.SIGNAL("returnPressed()"),self.createFromGUI)
        return w
 def addSet(self):
     sets = len(self.HookOrientationComboBoxList)
     # Create Hook Orientation Combo Box
     ui = FreeCADGui.UiLoader()
     hook_orientation = ui.createWidget("Gui::PrefComboBox")
     hook_orientation.addItems(
         ["Front Inside", "Front Outside", "Rear Inside", "Rear Outside"])
     form_layout = self.form.formLayout
     index = sets
     form_layout.insertRow(index, "Set " + str(sets + 1), hook_orientation)
     self.HookOrientationComboBoxList.append(hook_orientation)
Example #15
0
        def setupUi(self, Dialog):
            self.view = FreeCADGui.ActiveDocument.ActiveView
            self.stack = []
            self.callback = self.view.addEventCallbackPivy(
                pvy.SoMouseButtonEvent.getClassTypeId(), self.getpoint)
            self.callmouse = self.view.addEventCallbackPivy(
                pvy.SoLocation2Event.getClassTypeId(), self.getmousepoint)
            self.distance = 0
            self.dialog = Dialog
            Dialog.setObjectName(_fromUtf8("Dialog"))
            Dialog.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)

            self.verticalLayout = QtGui.QVBoxLayout(Dialog)
            self.verticalLayout.setObjectName("verticalLayout")
            self.horizontalLayout = QtGui.QHBoxLayout()
            self.horizontalLayout.setObjectName("horizontalLayout")

            self.label = QtGui.QLabel(Dialog)
            self.label.setObjectName(_fromUtf8("label"))
            self.horizontalLayout.addWidget(self.label)

            self.quantity = FreeCADGui.UiLoader().createWidget(
                "Gui::InputField")
            self.quantity.setParent(Dialog)
            self.quantity.setProperty('unit', 'mm')
            self.quantity.setObjectName(_fromUtf8("QuantityField"))
            self.horizontalLayout.addWidget(self.quantity)

            self.label1 = QtGui.QLabel(Dialog)
            self.label1.setObjectName(_fromUtf8("label1"))

            self.buttonBox = QtGui.QDialogButtonBox(Dialog)
            self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
            self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel
                                              | QtGui.QDialogButtonBox.Ok)
            self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
            self.buttonBox.button(QtGui.QDialogButtonBox.Ok).setEnabled(False)

            self.verticalLayout.addLayout(self.horizontalLayout)
            self.verticalLayout.addWidget(self.label1)
            self.verticalLayout.addWidget(self.buttonBox)

            self.retranslateUi(Dialog)
            QtCore.QObject.connect(self.buttonBox,
                                   QtCore.SIGNAL(_fromUtf8("accepted()")),
                                   self.accept)
            QtCore.QObject.connect(self.buttonBox,
                                   QtCore.SIGNAL(_fromUtf8("rejected()")),
                                   self.reject)
            QtCore.QMetaObject.connectSlotsByName(Dialog)
            self.tracker = trackers.lineTracker(scolor=(1, 0, 0))
            self.tracker.raiseTracker()
            self.tracker.on()
            self.dialog.show()
Example #16
0
 def createEditor(self,parent,option,index):
     if index.column() == 1:
         editor = QtGui.QComboBox(parent)
     elif index.column() == 2:
         ui = FreeCADGui.UiLoader()
         editor = ui.createWidget("Gui::InputField")
         editor.setSizePolicy(QtGui.QSizePolicy.Preferred,QtGui.QSizePolicy.Minimum)
         editor.setParent(parent)
     else:
         editor = QtGui.QLineEdit(parent)
     return editor
Example #17
0
    def setupUi(self, Dialog):
        Dialog.setObjectName("GeodesicDome")
        self.dia = Dialog
        self.gridLayoutWidget = QtGui.QWidget(Dialog)
        self.gridLayoutWidget.setObjectName("gridLayoutWidget")
        self.gridLayout = QtGui.QGridLayout(self.gridLayoutWidget)
        #self.gridLayout.setContentsMargins(0, 0, 0, 0)
        self.gridLayout.setObjectName("gridLayout")

        self.labelHelp = QtGui.QLabel(self.gridLayoutWidget)
        self.labelHelp.setObjectName('labelHelp')
        self.gridLayout.addWidget(self.labelHelp, 0, 0, 1, 2)

        self.labelDomeRadius = QtGui.QLabel(self.gridLayoutWidget)
        self.labelDomeRadius.setObjectName('labelDomeRadius')
        self.gridLayout.addWidget(self.labelDomeRadius, 1, 0)
        fui = gui.UiLoader()
        self.lineEditRadius = fui.createWidget('Gui::InputField')
        self.lineEditRadius.setObjectName('lineEditRadius')
        self.gridLayout.addWidget(self.lineEditRadius, 1, 1)

        self.labelFrequency = QtGui.QLabel(self.gridLayoutWidget)
        self.labelFrequency.setObjectName('labelFrequency')
        self.gridLayout.addWidget(self.labelFrequency, 2, 0)
        self.lineEditFreq = QtGui.QLineEdit(self.gridLayoutWidget)
        self.lineEditFreq.setObjectName('lineEditFreq')
        self.gridLayout.addWidget(self.lineEditFreq, 2, 1)

        self.labelType = QtGui.QLabel(self.gridLayoutWidget)
        self.labelType.setObjectName('labelType')
        self.gridLayout.addWidget(self.labelType, 3, 0)
        self.typesWidget = QtGui.QWidget(self.gridLayoutWidget)
        layoutType = QtGui.QVBoxLayout(self.typesWidget)
        self.radioSolid = QtGui.QRadioButton()
        self.radioShell = QtGui.QRadioButton()
        self.radioWireframe = QtGui.QRadioButton()
        self.radioVertices = QtGui.QRadioButton()
        layoutType.addWidget(self.radioSolid)
        layoutType.addWidget(self.radioShell)
        layoutType.addWidget(self.radioWireframe)
        layoutType.addWidget(self.radioVertices)
        self.radioSolid.setChecked(True)
        self.gridLayout.addWidget(self.typesWidget, 3, 1)

        self.buttonBox = QtGui.QDialogButtonBox(self.gridLayoutWidget)
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
        self.buttonBox.setStandardButtons \
            (QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
        self.buttonBox.setObjectName("buttonBox")
        self.gridLayout.addWidget(self.buttonBox, 4, 1)

        self.retranslateUi(Dialog)
        self.buttonBox.accepted.connect(self.makeSomething)
        self.buttonBox.rejected.connect(self.makeNothing)
Example #18
0
    def taskbox(self):

        "sets up a taskbox widget"

        from PySide import QtCore, QtGui
        import FreeCADGui
        wid = QtGui.QWidget()
        ui = FreeCADGui.UiLoader()
        wid.setWindowTitle(translate("BIM", "Box dimensions"))
        grid = QtGui.QGridLayout(wid)

        label1 = QtGui.QLabel(translate("BIM", "Length"))
        self.Length = ui.createWidget("Gui::InputField")
        self.Length.setText(str(self.LengthValue) + "mm")
        grid.addWidget(label1, 0, 0, 1, 1)
        grid.addWidget(self.Length, 0, 1, 1, 1)
        if self.LengthValue:
            self.Length.setEnabled(False)

        label2 = QtGui.QLabel(translate("BIM", "Width"))
        self.Width = ui.createWidget("Gui::InputField")
        self.Width.setText(str(self.WidthValue) + "mm")
        grid.addWidget(label2, 1, 0, 1, 1)
        grid.addWidget(self.Width, 1, 1, 1, 1)
        if self.WidthValue or (not self.LengthValue):
            self.Width.setEnabled(False)

        label3 = QtGui.QLabel(translate("BIM", "Height"))
        self.Height = ui.createWidget("Gui::InputField")
        self.Height.setText(str(self.HeightValue) + "mm")
        grid.addWidget(label3, 2, 0, 1, 1)
        grid.addWidget(self.Height, 2, 1, 1, 1)
        if not self.WidthValue:
            self.Height.setEnabled(False)

        QtCore.QObject.connect(self.Length,
                               QtCore.SIGNAL("valueChanged(double)"),
                               self.setLength)
        QtCore.QObject.connect(self.Width,
                               QtCore.SIGNAL("valueChanged(double)"),
                               self.setWidth)
        QtCore.QObject.connect(self.Height,
                               QtCore.SIGNAL("valueChanged(double)"),
                               self.setHeight)

        QtCore.QObject.connect(self.Length, QtCore.SIGNAL("returnPressed()"),
                               self.setLengthUI)
        QtCore.QObject.connect(self.Width, QtCore.SIGNAL("returnPressed()"),
                               self.setWidthUI)
        QtCore.QObject.connect(self.Height, QtCore.SIGNAL("returnPressed()"),
                               self.setHeightUI)

        return wid
Example #19
0
 def addSet(self):
     sets = len(self.HookExtensionInputFieldList)
     # Create Hook Extension Combo Box
     ui = FreeCADGui.UiLoader()
     hook_extension = ui.createWidget("Gui::InputField")
     hook_extension.setProperty("unit", "mm")
     hook_extension.setProperty("minimum", 10)
     hook_extension.setText("40 mm")
     form_layout = self.form.formLayout
     index = sets
     form_layout.insertRow(index, "Set " + str(sets + 1), hook_extension)
     self.HookExtensionInputFieldList.append(hook_extension)
Example #20
0
    def setupTool(self, tool):
        PathLog.track()
        # Can't delete and add fields to the form because of dangling references in case of
        # a focus change. see https://forum.freecadweb.org/viewtopic.php?f=10&t=52246#p458583
        # Instead we keep widgets once created and use them for new properties, and hide all
        # which aren't being needed anymore.

        def labelText(name):
            return re.sub("([A-Z][a-z]+)", r" \1", re.sub("([A-Z]+)", r" \1", name))

        layout = self.form.bitParams.layout()
        ui = FreeCADGui.UiLoader()

        # for all properties either assign them to existing labels and editors
        # or create additional ones for them if not enough have already been
        # created.
        usedRows = 0
        for nr, name in enumerate(tool.Proxy.toolShapeProperties(tool)):
            if nr < len(self.widgets):
                PathLog.debug("re-use row: {} [{}]".format(nr, name))
                label, qsb, editor = self.widgets[nr]
                label.setText(labelText(name))
                editor.attachTo(tool, name)
                label.show()
                qsb.show()
            else:
                qsb = ui.createWidget("Gui::QuantitySpinBox")
                editor = PathGui.QuantitySpinBox(qsb, tool, name)
                label = QtGui.QLabel(labelText(name))
                self.widgets.append((label, qsb, editor))
                PathLog.debug("create row: {} [{}]  {}".format(nr, name, type(qsb)))
                if hasattr(qsb, "editingFinished"):
                    qsb.editingFinished.connect(self.updateTool)

            if nr >= layout.rowCount():
                layout.addRow(label, qsb)
            usedRows = usedRows + 1

        # hide all rows which aren't being used
        PathLog.track(usedRows, len(self.widgets))
        for i in range(usedRows, len(self.widgets)):
            label, qsb, editor = self.widgets[i]
            label.hide()
            qsb.hide()
            editor.attachTo(None)
            PathLog.debug("  hide row: {}".format(i))

        img = tool.Proxy.getBitThumbnail(tool)
        if img:
            self.form.image.setPixmap(QtGui.QPixmap(QtGui.QImage.fromData(img)))
        else:
            self.form.image.setPixmap(QtGui.QPixmap())
    def addLayer(self):
        layer = self.Layers + 1
        # Create Layer Spacing Input Field
        ui = FreeCADGui.UiLoader()
        layer_spacing = ui.createWidget("Gui::InputField")
        layer_spacing.setProperty("unit", "mm")
        layer_spacing.setText("30 mm")
        self.LayerSpacingInputFieldList.append(layer_spacing)

        layout = self.form.formLayout
        index = layer - 1
        layout.insertRow(index, "Layer" + str(layer), layer_spacing)
        self.Layers += 1
 def create_input_field(self, name, default_value, layout):
     ui_loader = Gui.UiLoader()
     input_field = ui_loader.createWidget('Gui::InputField')
     input_field.setObjectName(name)
     size_policy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,
                                     QtGui.QSizePolicy.Preferred)
     input_field.setSizePolicy(size_policy)
     input_field.setMinimumWidth(110)
     input_field.installEventFilter(self.form)
     input_field.setText(
         App.Units.Quantity(default_value, App.Units.Length).UserString)
     layout.addWidget(input_field)
     return input_field
 def addSetButtonClicked(self, button):
     layer = self.AddSetButtonList.index(button) + 1
     sets = len(self.SetsDict["layer" + str(layer)])
     self.SetsDict["layer" + str(layer)].append([])
     # Create horizontal layout and its components
     h_layout = QtWidgets.QHBoxLayout()
     set_label = QtWidgets.QLabel("Set " + str(sets + 1))
     set_label.setSizePolicy(
         QtWidgets.QSizePolicy(
             QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed
         )
     )
     number = QtWidgets.QSpinBox()
     number.setSizePolicy(
         QtWidgets.QSizePolicy(
             QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed
         )
     )
     number.setMinimum(1)
     ui = FreeCADGui.UiLoader()
     diameter = ui.createWidget("Gui::InputField")
     diameter.setSizePolicy(
         QtWidgets.QSizePolicy(
             QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed
         )
     )
     diameter.setProperty("unit", "mm")
     diameter.setText("16 mm")
     offset = ui.createWidget("Gui::InputField")
     offset.setSizePolicy(
         QtWidgets.QSizePolicy(
             QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed
         )
     )
     offset.setProperty("unit", "mm")
     offset.setText("20 mm")
     h_layout.addWidget(set_label)
     h_layout.addWidget(number)
     h_layout.addWidget(diameter)
     h_layout.addWidget(offset)
     v_layout = self.form.verticalLayout
     index = v_layout.indexOf(button)
     v_layout.insertLayout(index, h_layout)
     self.SetsDict["layer" + str(layer)][-1].append(set_label)
     self.SetsDict["layer" + str(layer)][-1].append(number)
     self.SetsDict["layer" + str(layer)][-1].append(diameter)
     self.SetsDict["layer" + str(layer)][-1].append(offset)
     self.SetsDict["layer" + str(layer)][-1].append(h_layout)
     sets += 1
     if sets == 2:
         self.RemoveSetButtonList[layer - 1].setEnabled(True)
Example #24
0
    def __init__(self, viewObject):
        self.viewObject = viewObject
        ui_file = os.path.join(os.path.dirname(__file__), "TaskTube.ui")
        ui = FreeCADGui.UiLoader()
        self.form = ui.load(ui_file)

        object = self.viewObject.Object
        self.form.tubeOuterRadius.setProperty("rawValue", object.OuterRadius.Value)
        self.form.tubeInnerRadius.setProperty("rawValue", object.InnerRadius.Value)
        self.form.tubeHeight.setProperty("rawValue", object.Height.Value)

        self.form.tubeOuterRadius.valueChanged.connect(lambda x: self.onChangeOuterRadius(x))
        self.form.tubeInnerRadius.valueChanged.connect(lambda x: self.onChangeInnerRadius(x))
        self.form.tubeHeight.valueChanged.connect(lambda x: self.onChangeHeight(x))
    def createUIBasedOnPhysics(self):
        for rowi in range(self.form.propertiesLayout.rowCount()):
            self.form.propertiesLayout.removeRow(0)

        if self.material['Type'] == 'Isothermal':
            self.fields = ['Density', 'DynamicViscosity']
        elif self.material['Type'] == 'Incompressible':
            self.fields = ['MolarMass', 'DensityPolynomial', 'CpPolynomial', 'DynamicViscosityPolynomial',
                           'ThermalConductivityPolynomial']
        else:
            self.fields = ['MolarMass', 'Cp', 'SutherlandTemperature', 'SutherlandRefTemperature',
                           'SutherlandRefViscosity']

        self.text_boxes = {}
        for name in self.fields:
            if name.endswith("Polynomial"):
                widget = FreeCADGui.UiLoader().createWidget("QLineEdit")
                widget.setObjectName(name)
                widget.setToolTip(
                    "Enter coefficients of temperature-polynomial starting from constant followed by higher powers")
                val = self.material.get(name, '0')
                self.form.propertiesLayout.addRow(name + ":", widget)
                self.text_boxes[name] = widget
                widget.setText(val)
                widget.textChanged.connect(self.manualEdit)
            else:
                widget = FreeCADGui.UiLoader().createWidget("Gui::InputField")
                widget.setObjectName(name)
                widget.setProperty("format", "g")
                val = self.material.get(name, '0')
                widget.setProperty("unit", val)
                widget.setProperty("minimum", 0)
                widget.setProperty("singleStep", 0.1)
                self.form.propertiesLayout.addRow(name+":", widget)
                self.text_boxes[name] = widget
                setQuantity(widget, val)
                widget.valueChanged.connect(self.manualEdit)
Example #26
0
    def setupTool(self, tool):
        PathLog.track()
        # Can't delete and add fields to the form because of dangling references in case of
        # a focus change. see https://forum.freecadweb.org/viewtopic.php?f=10&t=52246#p458583
        # Instead we keep widgets once created and use them for new properties, and hide all
        # which aren't being needed anymore.

        def labelText(name):
            return re.sub('([A-Z][a-z]+)', r' \1', re.sub('([A-Z]+)', r' \1', name))

        layout = self.form.bitParams.layout()
        ui = FreeCADGui.UiLoader()
        nr = 0

        # for all properties either assign them to existing labels and editors
        # or create additional ones for them if not enough have already been
        # created.
        for name in tool.PropertiesList:
            if tool.getGroupOfProperty(name) == PathToolBit.PropertyGroupBit:
                if nr < len(self.widgets):
                    PathLog.debug("re-use row: {} [{}]".format(nr, name))
                    label, qsb, editor = self.widgets[nr]
                    label.setText(labelText(name))
                    editor.attachTo(tool, name)
                    label.show()
                    qsb.show()
                else:
                    qsb    = ui.createWidget('Gui::QuantitySpinBox')
                    editor = PathGui.QuantitySpinBox(qsb, tool, name)
                    label  = QtGui.QLabel(labelText(name))
                    self.widgets.append((label, qsb, editor))
                    PathLog.debug("create row: {} [{}]".format(nr, name))
                if nr >= layout.rowCount():
                    layout.addRow(label, qsb)
                nr = nr + 1

        # hide all rows which aren't being used
        for i in range(nr, len(self.widgets)):
            label, qsb, editor = self.widgets[i]
            label.hide()
            qsb.hide()
            editor.attachTo(None)
            PathLog.debug("  hide row: {}".format(i))

        img = tool.Proxy.getBitThumbnail(tool)
        if img:
            self.form.image.setPixmap(QtGui.QPixmap(QtGui.QImage.fromData(img)))
        else:
            self.form.image.setPixmap(QtGui.QPixmap())
Example #27
0
    def taskbox(self):

        "sets up a taskbox widget"

        w = QtGui.QWidget()
        ui = FreeCADGui.UiLoader()
        w.setWindowTitle(translate("Arch", "Profile settings"))
        grid = QtGui.QGridLayout(w)

        # categories box
        labelc = QtGui.QLabel(translate("Arch", "Category"))
        self.vCategory = QtGui.QComboBox()
        self.vCategory.addItems([" "] + self.Categories)
        grid.addWidget(labelc, 1, 0, 1, 1)
        grid.addWidget(self.vCategory, 1, 1, 1, 1)

        # presets box
        labelp = QtGui.QLabel(translate("Arch", "Preset"))
        self.vPresets = QtGui.QComboBox()
        self.pSelect = [None]
        fpresets = [" "]
        self.vPresets.addItems(fpresets)
        grid.addWidget(labelp, 2, 0, 1, 1)
        grid.addWidget(self.vPresets, 2, 1, 1, 1)

        # connect slots
        self.vCategory.currentIndexChanged.connect(self.setCategory)
        self.vPresets.currentIndexChanged.connect(self.setPreset)

        # restore preset
        stored = FreeCAD.ParamGet(
            "User parameter:BaseApp/Preferences/Mod/Arch").GetString(
                "StructurePreset", "")
        if stored:
            if ";" in stored:
                stored = stored.split(";")
                if len(stored) >= 3:
                    if stored[1] in self.Categories:
                        self.vCategory.setCurrentIndex(
                            1 + self.Categories.index(stored[1]))
                        self.setCategory(1 + self.Categories.index(stored[1]))
                        ps = [p[2] for p in self.pSelect]
                        if stored[2] in ps:
                            self.vPresets.setCurrentIndex(ps.index(stored[2]))
        return w
Example #28
0
 def addSet(self):
     layer = len(self.Layers)
     sets = len(self.RebarTypeComboBoxList[layer - 1])
     # Create horizontal layout and its components
     h_layout = QtWidgets.QHBoxLayout()
     set_label = QtWidgets.QLabel("Set " + str(sets + 1))
     set_label.setSizePolicy(
         QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed,
                               QtWidgets.QSizePolicy.Fixed))
     ui = FreeCADGui.UiLoader()
     rebar_type = ui.createWidget("Gui::PrefComboBox")
     rebar_type.addItems(["StraightRebar", "LShapeRebar"])
     h_layout.addWidget(set_label)
     h_layout.addWidget(rebar_type)
     v_layout = self.form.verticalLayout
     index = v_layout.indexOf(self.form.buttonBox)
     v_layout.insertLayout(index, h_layout)
     self.RebarTypeComboBoxList[layer - 1].append(rebar_type)
Example #29
0
 def setupTool(self, tool):
     layout = self.form.bitParams.layout()
     for i in range(layout.rowCount() - 1, -1, -1):
         layout.removeRow(i)
     editor = {}
     ui = FreeCADGui.UiLoader()
     for name in tool.PropertiesList:
         if tool.getGroupOfProperty(name) == PathToolBit.PropertyGroupBit:
             qsb = ui.createWidget('Gui::QuantitySpinBox')
             editor[name] = PathGui.QuantitySpinBox(qsb, tool, name)
             label = QtGui.QLabel(re.sub('([A-Z][a-z]+)', r' \1', re.sub('([A-Z]+)', r' \1', name)))
             layout.addRow(label, qsb)
     self.bitEditor = editor
     img = tool.Proxy.getBitThumbnail(tool)
     if img:
         self.form.image.setPixmap(QtGui.QPixmap(QtGui.QImage.fromData(img)))
     else:
         self.form.image.setPixmap(QtGui.QPixmap())
Example #30
0
 def addSet(self):
     layer = len(self.Layers)
     sets = len(self.RoundingSpinBoxList[layer - 1])
     # Create horizontal layout and its components
     h_layout = QtWidgets.QHBoxLayout()
     set_label = QtWidgets.QLabel("Set " + str(sets + 1))
     set_label.setSizePolicy(
         QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed,
                               QtWidgets.QSizePolicy.Fixed))
     ui = FreeCADGui.UiLoader()
     rounding = ui.createWidget("Gui::PrefSpinBox")
     rounding.setValue(2)
     h_layout.addWidget(set_label)
     h_layout.addWidget(rounding)
     v_layout = self.form.verticalLayout
     index = v_layout.indexOf(self.form.buttonBox)
     v_layout.insertLayout(index, h_layout)
     self.RoundingSpinBoxList[layer - 1].append(rounding)