def accept(self): if not self.ship: return False if self.running: return self.save() mw = self.getMainWindow() form = mw.findChild(QtGui.QWidget, "TaskPanel") form.trim = self.widget(QtGui.QLineEdit, "Trim") form.minDraft = self.widget(QtGui.QLineEdit, "MinDraft") form.maxDraft = self.widget(QtGui.QLineEdit, "MaxDraft") form.nDraft = self.widget(QtGui.QSpinBox, "NDraft") trim = Units.Quantity(form.trim.text()).getValueAs('deg').Value min_draft = Units.Quantity(form.minDraft.text()).getValueAs('m').Value max_draft = Units.Quantity(form.maxDraft.text()).getValueAs('m').Value n_draft = form.nDraft.value() draft = min_draft drafts = [draft] dDraft = (max_draft - min_draft) / (n_draft - 1) for i in range(1, n_draft): draft = draft + dDraft drafts.append(draft) # Compute data # Get external faces self.loop = QtCore.QEventLoop() self.timer = QtCore.QTimer() self.timer.setSingleShot(True) QtCore.QObject.connect(self.timer, QtCore.SIGNAL("timeout()"), self.loop, QtCore.SLOT("quit()")) self.running = True faces = self.externalFaces(self.ship.Shape) if not self.running: return False if len(faces) == 0: msg = QtGui.QApplication.translate( "ship_console", "Failure detecting external faces from the ship object", None, QtGui.QApplication.UnicodeUTF8) App.Console.PrintError(msg + '\n') return False faces = Part.makeShell(faces) # Get the hydrostatics msg = QtGui.QApplication.translate( "ship_console", "Computing hydrostatics", None, QtGui.QApplication.UnicodeUTF8) App.Console.PrintMessage(msg + '...\n') points = [] for i in range(len(drafts)): App.Console.PrintMessage("\t{} / {}\n".format(i + 1, len(drafts))) draft = drafts[i] point = Tools.Point(self.ship, faces, draft, trim) points.append(point) self.timer.start(0.0) self.loop.exec_() if(not self.running): break PlotAux.Plot(self.ship, trim, points) return True