| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| import FreeCAD, FreeCADGui |
| import traceback |
| from PySide import QtCore, QtGui |
| from .WizardShaftTable import WizardShaftTable |
| from .Shaft import Shaft |
|
|
| translate = FreeCAD.Qt.translate |
|
|
|
|
| class TaskWizardShaft: |
| "Shaft Wizard" |
|
|
| App = FreeCAD |
| Gui = FreeCADGui |
|
|
| def __init__(self, doc): |
| mw = QtGui.QApplication.activeWindow() |
| |
| cw = mw.findChild(QtGui.QMdiArea) |
| self.doc = doc |
|
|
| |
| |
| |
| if self.doc is None: |
| self.Gui.activateWorkbench("PartDesignWorkbench") |
| self.doc = self.App.newDocument() |
| |
| featureWindow = cw.subWindowList()[-1] |
| else: |
| featureWindow = cw.activeSubWindow() |
|
|
| |
| buttonLayout = QtGui.QGridLayout() |
| all = translate("TaskWizardShaft", "All") |
| bnames = [ |
| [f"{all} [x]", f"{all} [y]", f"{all} [z]"], |
| ["N [x]", "Q [y]", "Q [z]"], |
| ["Mt [x]", "Mb [z]", "Mb [y]"], |
| ["", "w [y]", "w [z]"], |
| ["sigma [x]", "sigma [y]", "sigma [z]"], |
| ["tau [x]", "sigmab [z]", "sigmab [y]"], |
| ] |
| slots = [ |
| [self.slotAllx, self.slotAlly, self.slotAllz], |
| [self.slotFx, self.slotQy, self.slotQz], |
| [self.slotMx, self.slotMz, self.slotMy], |
| [self.slotNone, self.slotWy, self.slotWz], |
| [self.slotSigmax, self.slotSigmay, self.slotSigmaz], |
| [self.slotTaut, self.slotSigmabz, self.slotSigmaby], |
| ] |
| self.buttons = [ |
| [None, None, None], |
| [None, None, None], |
| [None, None, None], |
| [None, None, None], |
| [None, None, None], |
| [None, None, None], |
| ] |
|
|
| for col in range(3): |
| for row in range(6): |
| button = QtGui.QPushButton(bnames[row][col]) |
| buttonLayout.addWidget(button, row, col) |
| self.buttons[row][col] = button |
| button.clicked.connect(slots[row][col]) |
|
|
| |
| self.shaft = Shaft(self) |
| |
| self.form = QtGui.QWidget() |
| self.table = WizardShaftTable(self, self.shaft) |
|
|
| |
| layout = QtGui.QVBoxLayout() |
| layout.setObjectName( |
| "ShaftWizard" |
| ) |
| sublayout = QtGui.QVBoxLayout() |
| sublayout.setObjectName("ShaftWizardLayout") |
| sublayout.addWidget(self.table.widget) |
| sublayout.addLayout(buttonLayout) |
| layout.addLayout(sublayout) |
| self.form.setLayout(layout) |
|
|
| |
| mdi = FreeCADGui.getMainWindow().findChild(QtGui.QMdiArea) |
| cw.setActiveSubWindow(featureWindow) |
|
|
| def showDiagram(self, diagram): |
| try: |
| self.shaft.showDiagram(diagram) |
| except ImportError as e: |
| msgBox = QtGui.QMessageBox() |
| msgBox.setIcon(msgBox.Information) |
| msgBox.setWindowTitle(translate("TaskWizardShaft", "Missing Module")) |
| msgBox.setText( |
| translate( |
| "TaskWizardShaft", |
| "The Plot add-on is not installed. Install it to enable this feature.", |
| ) |
| ) |
| msgBox.setDetailedText(traceback.format_exc()) |
| msgBox.exec_() |
|
|
| def slotAllx(self): |
| self.showDiagram("Allx") |
|
|
| def slotAlly(self): |
| self.showDiagram("Ally") |
|
|
| def slotAllz(self): |
| self.showDiagram("Allz") |
|
|
| def slotFx(self): |
| self.showDiagram("Nx") |
|
|
| def slotQy(self): |
| self.showDiagram("Qy") |
|
|
| def slotQz(self): |
| self.showDiagram("Qz") |
|
|
| def slotMx(self): |
| self.showDiagram("Mx") |
|
|
| def slotMz(self): |
| self.showDiagram("Mz") |
|
|
| def slotMy(self): |
| self.showDiagram("My") |
|
|
| def slotNone(self): |
| pass |
|
|
| def slotWy(self): |
| self.showDiagram("wy") |
|
|
| def slotWz(self): |
| self.showDiagram("wz") |
|
|
| def slotSigmax(self): |
| self.showDiagram("sigmax") |
|
|
| def slotSigmay(self): |
| self.showDiagram("sigmay") |
|
|
| def slotSigmaz(self): |
| self.showDiagram("sigmaz") |
|
|
| def slotTaut(self): |
| self.showDiagram("taut") |
|
|
| def slotSigmabz(self): |
| self.showDiagram("sigmabz") |
|
|
| def slotSigmaby(self): |
| self.showDiagram("sigmaby") |
|
|
| def updateButton(self, row, col, flag): |
| self.buttons[row][col].setEnabled(flag) |
|
|
| def updateButtons(self, col, flag): |
| for row in range(len(self.buttons)): |
| self.updateButton(row, col, flag) |
|
|
| def getStandardButtons(self): |
| return QtGui.QDialogButtonBox.Ok |
|
|
| def accept(self): |
| if self.table: |
| del self.table |
| if self.shaft: |
| del self.shaft |
| if self.form: |
| del self.form |
| return True |
|
|
| def isAllowedAlterDocument(self): |
| return False |
|
|
|
|
| |
| |
| |
| |
| |
| |
| WizardShaftDlg = None |
|
|
|
|
| class WizardShaftGui: |
| def Activated(self): |
| global WizardShaftDlg |
| WizardShaftDlg = TaskWizardShaft(FreeCAD.ActiveDocument) |
| FreeCADGui.Control.showDialog(WizardShaftDlg) |
|
|
| def GetResources(self): |
| IconPath = FreeCAD.ConfigGet("AppHomePath") + "Mod/PartDesign/WizardShaft/WizardShaft.svg" |
| MenuText = QtCore.QT_TRANSLATE_NOOP("PartDesign_WizardShaft", "Shaft Design Wizard") |
| ToolTip = QtCore.QT_TRANSLATE_NOOP( |
| "PartDesign_WizardShaft", "Starts the shaft design wizard" |
| ) |
| return {"Pixmap": IconPath, "MenuText": MenuText, "ToolTip": ToolTip} |
|
|
| def IsActive(self): |
| return FreeCAD.ActiveDocument is not None |
|
|
| def __del__(self): |
| global WizardShaftDlg |
| WizardShaftDlg = None |
|
|
|
|
| class WizardShaftGuiCallback: |
| def Activated(self): |
| global WizardShaftDlg |
| if WizardShaftDlg is not None and WizardShaftDlg.table is not None: |
| WizardShaftDlg.table.finishEditConstraint() |
|
|
| def isActive(self): |
| global WizardShaftDlg |
| return WizardShaftDlg is not None |
|
|
| def GetResources(self): |
| IconPath = FreeCAD.ConfigGet("AppHomePath") + "Mod/PartDesign/WizardShaft/WizardShaft.svg" |
| MenuText = QtCore.QT_TRANSLATE_NOOP( |
| "PartDesign_WizardShaftCallBack", "Shaft design wizard..." |
| ) |
| ToolTip = QtCore.QT_TRANSLATE_NOOP( |
| "PartDesign_WizardShaftCallBack", "Start the shaft design wizard" |
| ) |
| return {"Pixmap": IconPath, "MenuText": MenuText, "ToolTip": ToolTip} |
|
|
|
|
| FreeCADGui.addCommand("PartDesign_WizardShaft", WizardShaftGui()) |
| FreeCADGui.addCommand("PartDesign_WizardShaftCallBack", WizardShaftGuiCallback()) |
|
|
| |
| |
|
|