Exemplo n.º 1
0
    def drawUI(self,Form):
        # the layout for the main window is vertical (top to down)
        self.mainLayout = QtGui.QVBoxLayout(Form)
        
        # Define the fields for the form ( label + widget )
        self.formLayout = QtGui.QFormLayout(Form)
        # Selected Link (the name as seen in the tree of the selected link)
        self.linkName = QtGui.QLineEdit(Form)
        self.linkName.setReadOnly(True)
        self.formLayout.addRow(QtGui.QLabel('Selected Link :'),self.linkName)

        # combobox showing all available App::Link
        self.parentList = QtGui.QComboBox(Form)
        self.parentList.setMaximumWidth(300)
        self.parentList.setToolTip('Choose the part in which the attachment\ncoordinate system is to be found')
        # the parent assembly is hardcoded, and made the first real element
        self.formLayout.addRow(QtGui.QLabel('Attach to :'),self.parentList)
        self.mainLayout.addLayout(self.formLayout)

        # with 2 columns
        self.columnsLayout = QtGui.QHBoxLayout(Form)
        self.leftLayout = QtGui.QVBoxLayout(Form)
        self.rightLayout = QtGui.QVBoxLayout(Form)
        # Part, left side
        #
        # the document containing the linked part
        self.leftLayout.addWidget(QtGui.QLabel("Linked Part :"))
        self.linkedDoc = QtGui.QLineEdit(Form)
        self.linkedDoc.setReadOnly(True)
        self.leftLayout.addWidget(self.linkedDoc)

        # The list of all LCS in the part is a QListWidget
        self.leftLayout.addWidget(QtGui.QLabel("Select LCS in Part :"))
        self.partLCSlist = QtGui.QListWidget(self.form)
        self.partLCSlist.setMinimumHeight(200)
        self.partLCSlist.setToolTip('Select a coordinate system from the list')
        self.leftLayout.addWidget(self.partLCSlist)

        # Assembly, Right side
        #
        # the document containing the linked object
        self.rightLayout.addWidget(QtGui.QLabel("Parent Part :"))
        self.parentDoc = QtGui.QLineEdit(Form)
        self.parentDoc.setReadOnly(True)
        self.rightLayout.addWidget(self.parentDoc)
        # The list of all attachment LCS in the assembly is a QListWidget
        # it is populated only when the parent combo-box is activated
        self.rightLayout.addWidget(QtGui.QLabel("Select LCS in Parent :"))
        self.attLCSlist = QtGui.QListWidget(self.form)
        self.attLCSlist.setMinimumHeight(200)
        self.attLCSlist.setToolTip('Select a coordinate system from the list')
        self.rightLayout.addWidget(self.attLCSlist)

        # add the 2 columns
        self.columnsLayout.addLayout(self.leftLayout)
        self.columnsLayout.addLayout(self.rightLayout)
        self.mainLayout.addLayout(self.columnsLayout)

        # X Translation Value
        self.XoffsetLayout = QtGui.QHBoxLayout(Form)
        self.XtranslSpinBoxLabel = self.XoffsetLayout.addWidget(QtGui.QLabel("X Translation :"))
        self.XtranslSpinBox = Asm4.QUnitSpinBox(Form)
        self.XtranslSpinBox.setRange(-999999.00, 999999.00)
        #self.XtranslSpinBox.setValue(self.Xtranslation)
        self.XtranslSpinBox.setToolTip("Translation along X axis")
        self.RotXButton = QtGui.QPushButton('Rotate X +90°')
        self.RotXButton.setToolTip("Rotate 90 deg around X axis")
        # add the QLDoubleSpinBox
        self.XoffsetLayout.addWidget(self.XtranslSpinBox)
        self.XoffsetLayout.addStretch()
        self.XoffsetLayout.addWidget(self.RotXButton)
        self.mainLayout.addLayout(self.XoffsetLayout)

        # Y Translation Value
        self.YoffsetLayout = QtGui.QHBoxLayout(Form)
        self.YtranslSpinBoxLabel = self.YoffsetLayout.addWidget(QtGui.QLabel("Y Translation :"))
        self.YtranslSpinBox = Asm4.QUnitSpinBox(Form)
        self.YtranslSpinBox.setRange(-999999.00, 999999.00)
        #self.YtranslSpinBox.setValue(self.Ytranslation)
        self.YtranslSpinBox.setToolTip("Translation along Y")
        self.RotYButton = QtGui.QPushButton('Rotate Y +90°')
        self.RotYButton.setToolTip("Rotate 90 deg around Y axis")
        # add the QLDoubleSpinBox
        self.YoffsetLayout.addWidget(self.YtranslSpinBox)
        self.YoffsetLayout.addStretch()
        self.YoffsetLayout.addWidget(self.RotYButton)
        self.mainLayout.addLayout(self.YoffsetLayout)

        # Z Translation Value
        self.ZoffsetLayout = QtGui.QHBoxLayout(Form)
        self.ZtranslSpinBoxLabel = self.ZoffsetLayout.addWidget(QtGui.QLabel("Z Translation :"))
        self.ZtranslSpinBox = Asm4.QUnitSpinBox(Form)
        self.ZtranslSpinBox.setRange(-999999.00, 999999.00)
        #self.ZtranslSpinBox.setValue(self.Ztranslation)
        self.ZtranslSpinBox.setToolTip("Translation along Z:")
        self.RotZButton = QtGui.QPushButton('Rotate Z +90°')
        self.RotZButton.setToolTip("Rotate 90 deg around Z axis")
        # add to the layout
        self.ZoffsetLayout.addWidget(self.ZtranslSpinBox)
        self.ZoffsetLayout.addStretch()
        self.ZoffsetLayout.addWidget(self.RotZButton)
        self.mainLayout.addLayout(self.ZoffsetLayout)

        # apply the layout to the main window
        self.form.setLayout(self.mainLayout)

        # Actions
        self.parentList.currentIndexChanged.connect( self.onParentSelected )
        self.parentList.activated.connect( self.onParentSelected )
        self.partLCSlist.itemClicked.connect( self.onLCSclicked )
        self.attLCSlist.itemClicked.connect(  self.onLCSclicked )
        self.RotXButton.clicked.connect( self.onRotX )
        self.RotYButton.clicked.connect( self.onRotY )
        self.RotZButton.clicked.connect( self.onRotZ )
        self.XtranslSpinBox.valueChanged.connect(self.onXTranslValChanged)
        self.YtranslSpinBox.valueChanged.connect(self.onYTranslValChanged)
        self.ZtranslSpinBox.valueChanged.connect(self.onZTranslValChanged)
Exemplo n.º 2
0
    def drawUI(self):
        # Build the window layout
        self.mainLayout = QtGui.QVBoxLayout()

        # the name as seen in the tree of the selected link
        self.formLayout = QtGui.QFormLayout()
        self.selectedObject = QtGui.QLineEdit()
        self.selectedObject.setReadOnly(True)
        self.formLayout.addRow(QtGui.QLabel('Selected Object :'),
                               self.selectedObject)
        # combobox showing all available App::Link
        self.parentList = QtGui.QComboBox()
        self.parentList.setMaximumWidth(300)
        self.formLayout.addRow(QtGui.QLabel('Attach to :'), self.parentList)
        self.mainLayout.addLayout(self.formLayout)

        # the document containing the linked object
        self.parentDoc = QtGui.QLineEdit()
        self.parentDoc.setReadOnly(True)
        self.mainLayout.addWidget(self.parentDoc)

        # The list of all attachment LCS in the assembly is a QListWidget
        # it is populated only when the parent combo-box is activated
        self.mainLayout.addWidget(
            QtGui.QLabel("Select attachment LCS in parent Part :"))
        self.attLCSlist = QtGui.QListWidget()
        self.mainLayout.addWidget(self.attLCSlist)

        # X Translation Value
        self.XoffsetLayout = QtGui.QHBoxLayout()
        self.XtranslSpinBoxLabel = self.XoffsetLayout.addWidget(
            QtGui.QLabel("X Translation :"))
        self.XtranslSpinBox = Asm4.QUnitSpinBox()
        self.XtranslSpinBox.setRange(-999999.00, 999999.00)
        self.XtranslSpinBox.setToolTip("Translation along X axis")
        self.RotXButton = QtGui.QPushButton('Rotate X +90°')
        self.RotXButton.setToolTip("Rotate 90 deg around X axis")
        # add the QLDoubleSpinBox
        self.XoffsetLayout.addWidget(self.XtranslSpinBox)
        self.XoffsetLayout.addStretch()
        self.XoffsetLayout.addWidget(self.RotXButton)
        self.mainLayout.addLayout(self.XoffsetLayout)

        # Y Translation Value
        self.YoffsetLayout = QtGui.QHBoxLayout()
        self.YtranslSpinBoxLabel = self.YoffsetLayout.addWidget(
            QtGui.QLabel("Y Translation :"))
        self.YtranslSpinBox = Asm4.QUnitSpinBox()
        self.YtranslSpinBox.setRange(-999999.00, 999999.00)
        self.YtranslSpinBox.setToolTip("Translation along Y")
        self.RotYButton = QtGui.QPushButton('Rotate Y +90°')
        self.RotYButton.setToolTip("Rotate 90 deg around Y axis")
        # add the QLDoubleSpinBox
        self.YoffsetLayout.addWidget(self.YtranslSpinBox)
        self.YoffsetLayout.addStretch()
        self.YoffsetLayout.addWidget(self.RotYButton)
        self.mainLayout.addLayout(self.YoffsetLayout)

        # Z Translation Value
        self.ZoffsetLayout = QtGui.QHBoxLayout()
        self.ZtranslSpinBoxLabel = self.ZoffsetLayout.addWidget(
            QtGui.QLabel("Z Translation :"))
        self.ZtranslSpinBox = Asm4.QUnitSpinBox()
        self.ZtranslSpinBox.setRange(-999999.00, 999999.00)
        self.ZtranslSpinBox.setToolTip("Translation along Z:")
        self.RotZButton = QtGui.QPushButton('Rotate Z +90°')
        self.RotZButton.setToolTip("Rotate 90 deg around Z axis")
        # add to the layout
        self.ZoffsetLayout.addWidget(self.ZtranslSpinBox)
        self.ZoffsetLayout.addStretch()
        self.ZoffsetLayout.addWidget(self.RotZButton)
        self.mainLayout.addLayout(self.ZoffsetLayout)

        # apply the layout to the main window
        self.form.setLayout(self.mainLayout)

        # Actions
        self.parentList.currentIndexChanged.connect(self.onParentList)
        self.parentList.activated.connect(self.onParentList)
        ##self.attLCSlist.itemClicked.connect( self.onDatumClicked )
        self.attLCSlist.itemClicked.connect(self.onApply)
        self.RotXButton.clicked.connect(self.onRotX)
        self.RotYButton.clicked.connect(self.onRotY)
        self.RotZButton.clicked.connect(self.onRotZ)
        self.XtranslSpinBox.valueChanged.connect(self.movePart)
        self.YtranslSpinBox.valueChanged.connect(self.movePart)
        self.ZtranslSpinBox.valueChanged.connect(self.movePart)