Ejemplo n.º 1
0
class TaskPanelBodyTube:
    def __init__(self, obj, mode):
        self._obj = obj

        self._btForm = _BodyTubeDialog()
        self._db = TaskPanelDatabase(obj, COMPONENT_TYPE_BODYTUBE)
        self._dbForm = self._db.getForm()

        self.form = [self._btForm, self._dbForm]
        self._btForm.setWindowIcon(
            QtGui.QIcon(FreeCAD.getUserAppDataDir() +
                        "Mod/Rocket/Resources/icons/Rocket_BodyTube.svg"))

        self._btForm.idInput.textEdited.connect(self.onIdChanged)
        self._btForm.odInput.textEdited.connect(self.onOdChanged)
        self._btForm.lengthInput.textEdited.connect(self.onLengthChanged)

        self._db.dbLoad.connect(self.onLookup)

        self.update()

        if mode == 0:  # fresh created
            self._obj.Proxy.execute(self._obj)  # calculate once
            FreeCAD.Gui.SendMsgToActiveView("ViewFit")

    def transferTo(self):
        "Transfer from the dialog to the object"
        self._obj.InnerDiameter = self._btForm.idInput.text()
        self._obj.OuterDiameter = self._btForm.odInput.text()
        self._obj.Length = self._btForm.lengthInput.text()

    def transferFrom(self):
        "Transfer from the object to the dialog"
        self._btForm.idInput.setText(self._obj.InnerDiameter.UserString)
        self._btForm.odInput.setText(self._obj.OuterDiameter.UserString)
        self._btForm.lengthInput.setText(self._obj.Length.UserString)

    def onIdChanged(self, value):
        try:
            self._obj.InnerDiameter = FreeCAD.Units.Quantity(value).Value
            self._obj.Proxy.execute(self._obj)
        except ValueError:
            pass

    def onOdChanged(self, value):
        try:
            self._obj.OuterDiameter = FreeCAD.Units.Quantity(value).Value
            self._obj.Proxy.execute(self._obj)
        except ValueError:
            pass

    def onLengthChanged(self, value):
        try:
            self._obj.Length = FreeCAD.Units.Quantity(value).Value
            self._obj.Proxy.execute(self._obj)
        except ValueError:
            pass

    def onLookup(self):
        result = self._db.getLookupResult()

        self._obj.InnerDiameter = _valueWithUnits(
            result["inner_diameter"], result["inner_diameter_units"])
        self._obj.OuterDiameter = _valueWithUnits(
            result["outer_diameter"], result["outer_diameter_units"])
        self._obj.Length = _valueWithUnits(result["length"],
                                           result["length_units"])

        self.update()
        self._obj.Proxy.execute(self._obj)

    def getStandardButtons(self):
        return int(QtGui.QDialogButtonBox.Ok) | int(
            QtGui.QDialogButtonBox.Cancel) | int(QtGui.QDialogButtonBox.Apply)

    def clicked(self, button):
        if button == QtGui.QDialogButtonBox.Apply:
            #print "Apply"
            self.transferTo()
            self._obj.Proxy.execute(self._obj)

    def update(self):
        'fills the widgets'
        self.transferFrom()

    def accept(self):
        self.transferTo()
        FreeCAD.ActiveDocument.recompute()
        FreeCADGui.ActiveDocument.resetEdit()

    def reject(self):
        FreeCAD.ActiveDocument.abortTransaction()
        FreeCAD.ActiveDocument.recompute()
        FreeCADGui.ActiveDocument.resetEdit()
Ejemplo n.º 2
0
class TaskPanelBulkhead:

    def __init__(self, obj, crPanel, mode):
        self._obj = obj
        self._crPanel = crPanel
        
        self._bulkForm = _BulkheadDialog(self._crPanel)
        if crPanel:
            self._db = TaskPanelDatabase(obj, COMPONENT_TYPE_CENTERINGRING)
        else:
            self._db = TaskPanelDatabase(obj, COMPONENT_TYPE_BULKHEAD)
        self._dbForm = self._db.getForm()

        self.form = [self._bulkForm, self._dbForm]
        if self._crPanel:
            self._bulkForm.setWindowIcon(QtGui.QIcon(FreeCAD.getUserAppDataDir() + "Mod/Rocket/Resources/icons/Rocket_CenterinRing.svg"))
        else:
            self._bulkForm.setWindowIcon(QtGui.QIcon(FreeCAD.getUserAppDataDir() + "Mod/Rocket/Resources/icons/Rocket_Bulkhead.svg"))
        
        self._bulkForm.diameterInput.textEdited.connect(self.onDiameter)
        self._bulkForm.thicknessInput.textEdited.connect(self.onThickness)

        self._bulkForm.stepCheckbox.stateChanged.connect(self.onStep)
        self._bulkForm.stepDiameterInput.textEdited.connect(self.onStepDiameter)
        self._bulkForm.stepThicknessInput.textEdited.connect(self.onStepThickness)

        self._bulkForm.holeCheckbox.stateChanged.connect(self.onHole)
        self._bulkForm.holeDiameterInput.textEdited.connect(self.onHoleDiameter)
        self._bulkForm.holeCenterInput.textEdited.connect(self.onHoleCenter)
        self._bulkForm.holeCountSpinBox.valueChanged.connect(self.onHoleCount)
        self._bulkForm.holeOffsetInput.textEdited.connect(self.onHoleOffset)

        if self._crPanel:
            self._bulkForm.centerDiameterInput.textEdited.connect(self.onCenterDiameter)

            self._bulkForm.notchedCheckbox.stateChanged.connect(self.onNotched)
            self._bulkForm.notchWidthInput.textEdited.connect(self.onNotchWidth)
            self._bulkForm.notchHeightInput.textEdited.connect(self.onNotchHeight)

        self._db.dbLoad.connect(self.onLookup)
        
        self.update()
        
        if mode == 0: # fresh created
            self._obj.Proxy.execute(self._obj)  # calculate once 
            FreeCAD.Gui.SendMsgToActiveView("ViewFit")
        
    def transferTo(self):
        "Transfer from the dialog to the object" 
        self._obj.Diameter = self._bulkForm.diameterInput.text()
        self._obj.Thickness = self._bulkForm.thicknessInput.text()

        self._obj.Step = self._bulkForm.stepCheckbox.isChecked()
        self._obj.StepDiameter = self._bulkForm.stepDiameterInput.text()
        self._obj.StepThickness = self._bulkForm.stepThicknessInput.text()

        self._obj.Holes = self._bulkForm.holeCheckbox.isChecked()
        self._obj.HoleDiameter = self._bulkForm.holeDiameterInput.text()
        self._obj.HoleCenter = self._bulkForm.holeCenterInput.text()
        self._obj.HoleCount = self._bulkForm.holeCountSpinBox.value()
        self._obj.HoleOffset = self._bulkForm.holeOffsetInput.text()

        if self._crPanel:
            self._obj.CenterDiameter = self._bulkForm.centerDiameterInput.text()

            self._obj.Notched = self._bulkForm.notchedCheckbox.isChecked()
            self._obj.NotchWidth = self._bulkForm.notchWidthInput.text()
            self._obj.NotchHeight = self._bulkForm.notchHeightInput.text()

    def transferFrom(self):
        "Transfer from the object to the dialog"
        self._bulkForm.diameterInput.setText(self._obj.Diameter.UserString)
        self._bulkForm.thicknessInput.setText(self._obj.Thickness.UserString)

        self._bulkForm.stepCheckbox.setChecked(self._obj.Step)
        self._bulkForm.stepDiameterInput.setText(self._obj.StepDiameter.UserString)
        self._bulkForm.stepThicknessInput.setText(self._obj.StepThickness.UserString)

        self._bulkForm.holeCheckbox.setChecked(self._obj.Holes)
        self._bulkForm.holeDiameterInput.setText(self._obj.HoleDiameter.UserString)
        self._bulkForm.holeCenterInput.setText(self._obj.HoleCenter.UserString)
        self._bulkForm.holeCountSpinBox.setValue(self._obj.HoleCount)
        self._bulkForm.holeOffsetInput.setText(self._obj.HoleOffset.UserString)

        if self._crPanel:
            self._bulkForm.centerDiameterInput.setText(self._obj.CenterDiameter.UserString)

            self._bulkForm.notchedCheckbox.setChecked(self._obj.Notched)
            self._bulkForm.notchWidthInput.setText(self._obj.NotchWidth.UserString)
            self._bulkForm.notchHeightInput.setText(self._obj.NotchHeight.UserString)
            self._setNotchedState()

        self._setStepState()
        self._setHoleState()
        
    def onDiameter(self, value):
        try:
            self._obj.Diameter = FreeCAD.Units.Quantity(value).Value
            self._obj.Proxy.execute(self._obj)
        except ValueError:
            pass
        
    def onThickness(self, value):
        try:
            self._obj.Thickness = FreeCAD.Units.Quantity(value).Value
            self._obj.Proxy.execute(self._obj)
        except ValueError:
            pass
        
    def onCenterDiameter(self, value):
        try:
            self._obj.CenterDiameter = FreeCAD.Units.Quantity(value).Value
            self._obj.Proxy.execute(self._obj)
        except ValueError:
            pass
        
    def _setStepState(self):
        self._bulkForm.stepDiameterInput.setEnabled(self._obj.Step)
        self._bulkForm.stepThicknessInput.setEnabled(self._obj.Step)
        
    def onStep(self, value):
        self._obj.Step = self._bulkForm.stepCheckbox.isChecked()
        self._setStepState()

        self._obj.Proxy.execute(self._obj)
        
    def onStepDiameter(self, value):
        try:
            self._obj.StepDiameter = FreeCAD.Units.Quantity(value).Value
            self._obj.Proxy.execute(self._obj)
        except ValueError:
            pass
        
    def onStepThickness(self, value):
        try:
            self._obj.StepThickness = FreeCAD.Units.Quantity(value).Value
            self._obj.Proxy.execute(self._obj)
        except ValueError:
            pass
        
    def _setHoleState(self):
        self._bulkForm.holeDiameterInput.setEnabled(self._obj.Holes)
        self._bulkForm.holeCenterInput.setEnabled(self._obj.Holes)
        self._bulkForm.holeCountSpinBox.setEnabled(self._obj.Holes)
        self._bulkForm.holeOffsetInput.setEnabled(self._obj.Holes)
        
    def onHole(self, value):
        self._obj.Holes = self._bulkForm.holeCheckbox.isChecked()
        self._setHoleState()

        self._obj.Proxy.execute(self._obj)
        
    def onHoleDiameter(self, value):
        try:
            self._obj.HoleDiameter = FreeCAD.Units.Quantity(value).Value
            self._obj.Proxy.execute(self._obj)
        except ValueError:
            pass
        
    def onHoleCenter(self, value):
        try:
            self._obj.HoleCenter = FreeCAD.Units.Quantity(value).Value
            self._obj.Proxy.execute(self._obj)
        except ValueError:
            pass
        
    def onHoleCount(self, value):
        self._obj.HoleCount = int(value)
        self._obj.Proxy.execute(self._obj)
        
    def onHoleOffset(self, value):
        try:
            self._obj.HoleOffset = FreeCAD.Units.Quantity(value).Value
            self._obj.Proxy.execute(self._obj)
        except ValueError:
            pass
        
    def _setNotchedState(self):
        self._bulkForm.notchWidthInput.setEnabled(self._obj.Notched)
        self._bulkForm.notchHeightInput.setEnabled(self._obj.Notched)
        
    def onNotched(self, value):
        self._obj.Notched = self._bulkForm.notchedCheckbox.isChecked()
        self._setNotchedState()

        self._obj.Proxy.execute(self._obj)
        
    def onNotchWidth(self, value):
        try:
            self._obj.NotchWidth = FreeCAD.Units.Quantity(value).Value
            self._obj.Proxy.execute(self._obj)
        except ValueError:
            pass
        
    def onNotchHeight(self, value):
        try:
            self._obj.NotchHeight = FreeCAD.Units.Quantity(value).Value
            self._obj.Proxy.execute(self._obj)
        except ValueError:
            pass
        
    def onLookup(self):
        result = self._db.getLookupResult()

        self._obj.Diameter = _valueWithUnits(result["outer_diameter"], result["outer_diameter_units"])
        self._obj.Thickness =_valueWithUnits(result["length"], result["length_units"])

        self._obj.Step = False
        self._obj.StepDiameter = 0.0
        self._obj.StepThickness = 0.0

        self._obj.Holes = False
        self._obj.HoleDiameter = 0.0
        self._obj.HoleCenter = 0.0
        self._obj.HoleCount = 1
        self._obj.HoleOffset = 0.0

        if self._crPanel:
            self._obj.CenterDiameter = _valueWithUnits(result["inner_diameter"], result["inner_diameter_units"])

            self._obj.Notched = False
            self._obj.NotchWidth = 0.0
            self._obj.NotchHeight = 0.0
        
        self.update()
        self._obj.Proxy.execute(self._obj) 
        
    def getStandardButtons(self):
        return int(QtGui.QDialogButtonBox.Ok) | int(QtGui.QDialogButtonBox.Cancel)| int(QtGui.QDialogButtonBox.Apply)

    def clicked(self,button):
        if button == QtGui.QDialogButtonBox.Apply:
            #print "Apply"
            self.transferTo()
            self._obj.Proxy.execute(self._obj) 
        
    def update(self):
        'fills the widgets'
        self.transferFrom()
                
    def accept(self):
        self.transferTo()
        FreeCAD.ActiveDocument.recompute()
        FreeCADGui.ActiveDocument.resetEdit()
        
                    
    def reject(self):
        FreeCAD.ActiveDocument.abortTransaction()
        FreeCAD.ActiveDocument.recompute()
        FreeCADGui.ActiveDocument.resetEdit()
Ejemplo n.º 3
0
class TaskPanelTransition:
    def __init__(self, obj, mode):
        self._obj = obj

        self._tranForm = _TransitionDialog()
        self._db = TaskPanelDatabase(obj, COMPONENT_TYPE_TRANSITION)
        self._dbForm = self._db.getForm()

        self.form = [self._tranForm, self._dbForm]
        self._tranForm.setWindowIcon(
            QtGui.QIcon(FreeCAD.getUserAppDataDir() +
                        "Mod/Rocket/Resources/icons/Rocket_Transition.svg"))

        self._tranForm.transitionTypesCombo.currentTextChanged.connect(
            self.onTransitionType)
        self._tranForm.transitionStylesCombo.currentTextChanged.connect(
            self.onTransitionStyle)
        self._tranForm.lengthInput.textEdited.connect(self.onLength)
        self._tranForm.foreDiameterInput.textEdited.connect(
            self.onForeDiameter)
        self._tranForm.aftDiameterInput.textEdited.connect(self.onAftDiameter)
        self._tranForm.coreDiameterInput.textEdited.connect(
            self.onCoreDiameter)
        self._tranForm.thicknessInput.textEdited.connect(self.onThickness)
        self._tranForm.coefficientInput.textEdited.connect(self.onCoefficient)
        self._tranForm.clippedCheckbox.stateChanged.connect(self.onClipped)
        self._tranForm.foreShoulderCheckbox.stateChanged.connect(
            self.onForeShoulder)
        self._tranForm.foreShoulderDiameterInput.textEdited.connect(
            self.onForeShoulderDiameter)
        self._tranForm.foreShoulderLengthInput.textEdited.connect(
            self.onForeShoulderLength)
        self._tranForm.foreShoulderThicknessInput.textEdited.connect(
            self.onForeShoulderThickness)
        self._tranForm.aftShoulderCheckbox.stateChanged.connect(
            self.onAftShoulder)
        self._tranForm.aftShoulderDiameterInput.textEdited.connect(
            self.onAftShoulderDiameter)
        self._tranForm.aftShoulderLengthInput.textEdited.connect(
            self.onAftShoulderLength)
        self._tranForm.aftShoulderThicknessInput.textEdited.connect(
            self.onAftShoulderThickness)

        self._db.dbLoad.connect(self.onLookup)

        self.update()

        if mode == 0:  # fresh created
            self._obj.Proxy.execute(self._obj)  # calculate once
            FreeCAD.Gui.SendMsgToActiveView("ViewFit")

    def transferTo(self):
        "Transfer from the dialog to the object"
        self._obj.TransitionType = str(
            self._tranForm.transitionTypesCombo.currentText())
        self._obj.TransitionStyle = str(
            self._tranForm.transitionStylesCombo.currentText())
        self._obj.Length = self._tranForm.lengthInput.text()
        self._obj.ForeDiameter = self._tranForm.foreDiameterInput.text()
        self._obj.AftDiameter = self._tranForm.aftDiameterInput.text()
        self._obj.CoreDiameter = self._tranForm.coreDiameterInput.text()
        self._obj.Thickness = self._tranForm.thicknessInput.text()
        self._obj.Coefficient = _toFloat(
            self._tranForm.coefficientInput.text())
        self._obj.Clipped = self._tranForm.clippedCheckbox.isChecked()
        self._obj.ForeShoulder = self._tranForm.foreShoulderCheckbox.isChecked(
        )
        self._obj.ForeShoulderDiameter = self._tranForm.foreShoulderDiameterInput.text(
        )
        self._obj.ForeShoulderLength = self._tranForm.foreShoulderLengthInput.text(
        )
        self._obj.ForeShoulderThickness = self._tranForm.foreShoulderThicknessInput.text(
        )
        self._obj.AftShoulder = self._tranForm.aftShoulderCheckbox.isChecked()
        self._obj.AftShoulderDiameter = self._tranForm.aftShoulderDiameterInput.text(
        )
        self._obj.AftShoulderLength = self._tranForm.aftShoulderLengthInput.text(
        )
        self._obj.AftShoulderThickness = self._tranForm.aftShoulderThicknessInput.text(
        )

    def transferFrom(self):
        "Transfer from the object to the dialog"
        self._tranForm.transitionTypesCombo.setCurrentText(
            self._obj.TransitionType)
        self._tranForm.transitionStylesCombo.setCurrentText(
            self._obj.TransitionStyle)
        self._tranForm.lengthInput.setText(self._obj.Length.UserString)
        self._tranForm.foreDiameterInput.setText(
            self._obj.ForeDiameter.UserString)
        self._tranForm.aftDiameterInput.setText(
            self._obj.AftDiameter.UserString)
        self._tranForm.coreDiameterInput.setText(
            self._obj.CoreDiameter.UserString)
        self._tranForm.thicknessInput.setText(self._obj.Thickness.UserString)
        self._tranForm.coefficientInput.setText("%f" % self._obj.Coefficient)
        self._tranForm.clippedCheckbox.setChecked(self._obj.Clipped)
        self._tranForm.foreShoulderCheckbox.setChecked(self._obj.ForeShoulder)
        self._tranForm.foreShoulderDiameterInput.setText(
            self._obj.ForeShoulderDiameter.UserString)
        self._tranForm.foreShoulderLengthInput.setText(
            self._obj.ForeShoulderLength.UserString)
        self._tranForm.foreShoulderThicknessInput.setText(
            self._obj.ForeShoulderThickness.UserString)
        self._tranForm.aftShoulderCheckbox.setChecked(self._obj.AftShoulder)
        self._tranForm.aftShoulderDiameterInput.setText(
            self._obj.AftShoulderDiameter.UserString)
        self._tranForm.aftShoulderLengthInput.setText(
            self._obj.AftShoulderLength.UserString)
        self._tranForm.aftShoulderThicknessInput.setText(
            self._obj.AftShoulderThickness.UserString)

        self._showTransitionType()
        self._showClippable()
        self._showTransitionStyle()

    def _showClippable(self):
        if str(self._obj.TransitionType) in [TYPE_CONE, TYPE_OGIVE]:
            # These types aren't clippable
            self._obj.Clipped = False
            self._tranForm.clippedCheckbox.setChecked(self._obj.Clipped)
            self._tranForm.clippedCheckbox.setEnabled(False)
        else:
            self._tranForm.clippedCheckbox.setEnabled(True)

    def _showTransitionType(self):
        value = self._obj.TransitionType
        if value == TYPE_HAACK or value == TYPE_PARABOLIC:
            self._tranForm.coefficientInput.setEnabled(True)
        elif value == TYPE_POWER:
            self._tranForm.coefficientInput.setEnabled(True)
        elif value == TYPE_PARABOLA:
            # Set the coefficient, but don't enable it
            self._obj.Coefficient = 0.5
            self._tranForm.coefficientInput.setText("%f" %
                                                    self._obj.Coefficient)
            self._tranForm.coefficientInput.setEnabled(False)
        elif value == TYPE_VON_KARMAN:
            # Set the coefficient, but don't enable it
            self._obj.Coefficient = 0.0
            self._tranForm.coefficientInput.setText("%f" %
                                                    self._obj.Coefficient)
            self._tranForm.coefficientInput.setEnabled(False)
        else:
            self._tranForm.coefficientInput.setEnabled(False)

    def onTransitionType(self, value):
        self._obj.TransitionType = value

        self._showTransitionType()
        self._showClippable()

        self._obj.Proxy.execute(self._obj)

    def _showTransitionStyle(self):
        value = self._obj.TransitionStyle
        if value == STYLE_HOLLOW or value == STYLE_CAPPED:
            self._tranForm.thicknessInput.setEnabled(True)
            self._tranForm.coreDiameterInput.setEnabled(False)

            if self._tranForm.foreShoulderCheckbox.isChecked():
                self._tranForm.foreShoulderThicknessInput.setEnabled(True)
            else:
                self._tranForm.foreShoulderThicknessInput.setEnabled(False)

            if self._tranForm.aftShoulderCheckbox.isChecked():
                self._tranForm.aftShoulderThicknessInput.setEnabled(True)
            else:
                self._tranForm.aftShoulderThicknessInput.setEnabled(False)
        elif value == STYLE_SOLID_CORE:
            self._tranForm.thicknessInput.setEnabled(False)
            self._tranForm.coreDiameterInput.setEnabled(True)

            self._tranForm.foreShoulderThicknessInput.setEnabled(False)
            self._tranForm.aftShoulderThicknessInput.setEnabled(False)
        else:
            self._tranForm.thicknessInput.setEnabled(False)
            self._tranForm.coreDiameterInput.setEnabled(False)

            self._tranForm.foreShoulderThicknessInput.setEnabled(False)
            self._tranForm.aftShoulderThicknessInput.setEnabled(False)

    def onTransitionStyle(self, value):
        self._obj.TransitionStyle = value

        self._showTransitionStyle()
        self._obj.Proxy.execute(self._obj)

    def onLength(self, value):
        try:
            self._obj.Length = FreeCAD.Units.Quantity(value).Value
            self._obj.Proxy.execute(self._obj)
        except ValueError:
            pass

    def onForeDiameter(self, value):
        try:
            self._obj.ForeDiameter = FreeCAD.Units.Quantity(value).Value
            self._obj.Proxy.execute(self._obj)
        except ValueError:
            pass

    def onAftDiameter(self, value):
        try:
            self._obj.AftDiameter = FreeCAD.Units.Quantity(value).Value
            self._obj.Proxy.execute(self._obj)
        except ValueError:
            pass

    def onCoreDiameter(self, value):
        try:
            self._obj.CoreDiameter = FreeCAD.Units.Quantity(value).Value
            self._obj.Proxy.execute(self._obj)
        except ValueError:
            pass

    def onThickness(self, value):
        try:
            self._obj.Thickness = FreeCAD.Units.Quantity(value).Value
            self._obj.Proxy.execute(self._obj)
        except ValueError:
            pass

    def onCoefficient(self, value):
        self._obj.Coefficient = _toFloat(value)
        self._obj.Proxy.execute(self._obj)

    def onClipped(self, value):
        self._obj.Clipped = self._tranForm.clippedCheckbox.isChecked()
        self._obj.Proxy.execute(self._obj)

    def onForeShoulder(self, value):
        self._obj.ForeShoulder = self._tranForm.foreShoulderCheckbox.isChecked(
        )
        if self._obj.ForeShoulder:
            self._tranForm.foreShoulderDiameterInput.setEnabled(True)
            self._tranForm.foreShoulderLengthInput.setEnabled(True)

            selectedText = self._tranForm.transitionStylesCombo.currentText()
            if selectedText == STYLE_HOLLOW or selectedText == STYLE_CAPPED:
                self._tranForm.foreShoulderThicknessInput.setEnabled(True)
            else:
                self._tranForm.foreShoulderThicknessInput.setEnabled(False)
        else:
            self._tranForm.foreShoulderDiameterInput.setEnabled(False)
            self._tranForm.foreShoulderLengthInput.setEnabled(False)
            self._tranForm.foreShoulderThicknessInput.setEnabled(False)

        self._obj.Proxy.execute(self._obj)

    def onForeShoulderDiameter(self, value):
        try:
            self._obj.ForeShoulderDiameter = FreeCAD.Units.Quantity(
                value).Value
            self._obj.Proxy.execute(self._obj)
        except ValueError:
            pass

    def onForeShoulderLength(self, value):
        try:
            self._obj.ForeShoulderLength = FreeCAD.Units.Quantity(value).Value
            self._obj.Proxy.execute(self._obj)
        except ValueError:
            pass

    def onForeShoulderThickness(self, value):
        try:
            self._obj.ForeShoulderThickness = FreeCAD.Units.Quantity(
                value).Value
            self._obj.Proxy.execute(self._obj)
        except ValueError:
            pass

    def onAftShoulder(self, value):
        self._obj.AftShoulder = self._tranForm.aftShoulderCheckbox.isChecked()
        if self._obj.AftShoulder:
            self._tranForm.aftShoulderDiameterInput.setEnabled(True)
            self._tranForm.aftShoulderLengthInput.setEnabled(True)

            selectedText = self._tranForm.transitionStylesCombo.currentText()
            if selectedText == STYLE_HOLLOW or selectedText == STYLE_CAPPED:
                self._tranForm.aftShoulderThicknessInput.setEnabled(True)
            else:
                self._tranForm.aftShoulderThicknessInput.setEnabled(False)
        else:
            self._tranForm.aftShoulderDiameterInput.setEnabled(False)
            self._tranForm.aftShoulderLengthInput.setEnabled(False)
            self._tranForm.aftShoulderThicknessInput.setEnabled(False)

        self._obj.Proxy.execute(self._obj)

    def onAftShoulderDiameter(self, value):
        try:
            self._obj.AftShoulderDiameter = FreeCAD.Units.Quantity(value).Value
            self._obj.Proxy.execute(self._obj)
        except ValueError:
            pass

    def onAftShoulderLength(self, value):
        try:
            self._obj.AftShoulderLength = FreeCAD.Units.Quantity(value).Value
            self._obj.Proxy.execute(self._obj)
        except ValueError:
            pass

    def onAftShoulderThickness(self, value):
        try:
            self._obj.AftShoulderThickness = FreeCAD.Units.Quantity(
                value).Value
            self._obj.Proxy.execute(self._obj)
        except ValueError:
            pass

    def onLookup(self):
        result = self._db.getLookupResult()

        self._obj.TransitionType = str(result["shape"])
        self._obj.TransitionStyle = str(result["style"])
        self._obj.Length = _valueWithUnits(result["length"],
                                           result["length_units"])
        self._obj.ForeDiameter = _valueWithUnits(
            result["fore_outside_diameter"],
            result["fore_outside_diameter_units"])
        self._obj.AftDiameter = _valueWithUnits(
            result["aft_outside_diameter"],
            result["aft_outside_diameter_units"])
        self._obj.CoreDiameter = 0.0
        self._obj.Thickness = _valueWithUnits(result["thickness"],
                                              result["thickness_units"])
        self._obj.Coefficient = 0.0
        self._obj.Clipped = True
        self._obj.ForeShoulderDiameter = _valueWithUnits(
            result["fore_shoulder_diameter"],
            result["fore_shoulder_diameter_units"])
        self._obj.ForeShoulderLength = _valueWithUnits(
            result["fore_shoulder_length"],
            result["fore_shoulder_length_units"])
        self._obj.ForeShoulderThickness = self._obj.Thickness
        self._obj.AftShoulderDiameter = _valueWithUnits(
            result["aft_shoulder_diameter"],
            result["aft_shoulder_diameter_units"])
        self._obj.AftShoulderLength = _valueWithUnits(
            result["aft_shoulder_length"], result["aft_shoulder_length_units"])
        self._obj.AftShoulderThickness = self._obj.Thickness

        self._obj.ForeShoulder = (self._obj.ForeShoulderDiameter >
                                  0.0) and (self._obj.ForeShoulderLength >= 0)
        self._obj.AftShoulder = (self._obj.AftShoulderDiameter >
                                 0.0) and (self._obj.AftShoulderLength >= 0)

        self.update()
        self._obj.Proxy.execute(self._obj)

    def getStandardButtons(self):
        return int(QtGui.QDialogButtonBox.Ok) | int(
            QtGui.QDialogButtonBox.Cancel) | int(QtGui.QDialogButtonBox.Apply)

    def clicked(self, button):
        if button == QtGui.QDialogButtonBox.Apply:
            #print "Apply"
            self.transferTo()
            self._obj.Proxy.execute(self._obj)

    def update(self):
        'fills the widgets'
        self.transferFrom()

    def accept(self):
        self.transferTo()
        FreeCAD.ActiveDocument.recompute()
        FreeCADGui.ActiveDocument.resetEdit()

    def reject(self):
        FreeCAD.ActiveDocument.abortTransaction()
        FreeCAD.ActiveDocument.recompute()
        FreeCADGui.ActiveDocument.resetEdit()