Moved to real time reporting and cancel new stuff
This commit is contained in:
parent
efc67461b8
commit
9d8747f1f0
|
@ -44,11 +44,10 @@ header = """ #################################################################
|
|||
"""
|
||||
|
||||
class Plot(object):
|
||||
def __init__(self, ship, trim, drafts, points):
|
||||
def __init__(self, ship, trim, points):
|
||||
""" Constructor. performs plot and show it (Using pyxplot).
|
||||
@param ship Selected ship instance
|
||||
@param trim Trim in degrees.
|
||||
@param drafts List of drafts to be performed.
|
||||
@param points List of computed hydrostatics.
|
||||
"""
|
||||
self.points = points[:]
|
||||
|
@ -59,7 +58,7 @@ class Plot(object):
|
|||
# Save data
|
||||
if self.createDirectory():
|
||||
return
|
||||
if self.saveData(ship, trim, drafts):
|
||||
if self.saveData(ship, trim):
|
||||
return
|
||||
|
||||
def plotVolume(self):
|
||||
|
@ -324,11 +323,10 @@ class Plot(object):
|
|||
FreeCAD.Console.PrintError(msg + ':\n\t' + "\'"+ self.path + "\'\n")
|
||||
return False
|
||||
|
||||
def saveData(self, ship, trim, drafts):
|
||||
def saveData(self, ship, trim):
|
||||
""" Write data file.
|
||||
@param ship Selected ship instance
|
||||
@param trim Trim in degrees.
|
||||
@param drafts List of drafts to be performed.
|
||||
@return True if error happens.
|
||||
"""
|
||||
# Open the file
|
||||
|
@ -359,7 +357,7 @@ class Plot(object):
|
|||
Output.write(" #\n")
|
||||
Output.write(" #################################################################\n")
|
||||
# Print data
|
||||
for i in range(0,len(drafts)):
|
||||
for i in range(0,len(self.points)):
|
||||
point = self.points[i]
|
||||
string = "%f %f %f %f %f %f %f %f %f %f %f\n" % (point.disp, point.draft, point.wet, point.mom, point.xcb, point.farea, point.KBt, point.BMt, point.Cb, point.Cf, point.Cm)
|
||||
Output.write(string)
|
||||
|
|
|
@ -39,10 +39,13 @@ class TaskPanel:
|
|||
def __init__(self):
|
||||
self.ui = Paths.modulePath() + "/shipHydrostatics/TaskPanel.ui"
|
||||
self.ship = None
|
||||
self.running = False
|
||||
|
||||
def accept(self):
|
||||
if not self.ship:
|
||||
return False
|
||||
if self.running:
|
||||
return
|
||||
self.save()
|
||||
draft = self.form.minDraft.value()
|
||||
drafts = [draft]
|
||||
|
@ -52,7 +55,14 @@ class TaskPanel:
|
|||
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", "Can't detect external faces from ship object",
|
||||
None,QtGui.QApplication.UnicodeUTF8)
|
||||
|
@ -69,10 +79,19 @@ class TaskPanel:
|
|||
draft = drafts[i]
|
||||
point = Tools.Point(self.ship,faces,draft,self.form.trim.value())
|
||||
points.append(point)
|
||||
PlotAux.Plot(self.ship, self.form.trim.value(), drafts, points)
|
||||
self.timer.start(0.0)
|
||||
self.loop.exec_()
|
||||
if(not self.running):
|
||||
break
|
||||
PlotAux.Plot(self.ship, self.form.trim.value(), points)
|
||||
return True
|
||||
|
||||
def reject(self):
|
||||
if not self.ship:
|
||||
return False
|
||||
if self.running:
|
||||
self.running = False
|
||||
return
|
||||
return True
|
||||
|
||||
def clicked(self, index):
|
||||
|
@ -339,6 +358,10 @@ class TaskPanel:
|
|||
if (nPoints % 2) or (nPoints2 % 2):
|
||||
continue
|
||||
result.append(f)
|
||||
self.timer.start(0.0)
|
||||
self.loop.exec_()
|
||||
if(not self.running):
|
||||
break
|
||||
return result
|
||||
|
||||
def createTask():
|
||||
|
|
Loading…
Reference in New Issue
Block a user