Fixed outline draw tool (edges extracting fail)
This commit is contained in:
parent
ffa79f8bb7
commit
04703a22a2
|
@ -1,229 +1,229 @@
|
||||||
#***************************************************************************
|
#***************************************************************************
|
||||||
#* *
|
#* *
|
||||||
#* Copyright (c) 2011, 2012 *
|
#* Copyright (c) 2011, 2012 *
|
||||||
#* Jose Luis Cercos Pita <jlcercos@gmail.com> *
|
#* Jose Luis Cercos Pita <jlcercos@gmail.com> *
|
||||||
#* *
|
#* *
|
||||||
#* This program is free software; you can redistribute it and/or modify *
|
#* This program is free software; you can redistribute it and/or modify *
|
||||||
#* it under the terms of the GNU Lesser General Public License (LGPL) *
|
#* it under the terms of the GNU Lesser General Public License (LGPL) *
|
||||||
#* as published by the Free Software Foundation; either version 2 of *
|
#* as published by the Free Software Foundation; either version 2 of *
|
||||||
#* the License, or (at your option) any later version. *
|
#* the License, or (at your option) any later version. *
|
||||||
#* for detail see the LICENCE text file. *
|
#* for detail see the LICENCE text file. *
|
||||||
#* *
|
#* *
|
||||||
#* This program is distributed in the hope that it will be useful, *
|
#* This program is distributed in the hope that it will be useful, *
|
||||||
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
#* GNU Library General Public License for more details. *
|
#* GNU Library General Public License for more details. *
|
||||||
#* *
|
#* *
|
||||||
#* You should have received a copy of the GNU Library General Public *
|
#* You should have received a copy of the GNU Library General Public *
|
||||||
#* License along with this program; if not, write to the Free Software *
|
#* License along with this program; if not, write to the Free Software *
|
||||||
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
|
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
|
||||||
#* USA *
|
#* USA *
|
||||||
#* *
|
#* *
|
||||||
#***************************************************************************
|
#***************************************************************************
|
||||||
|
|
||||||
import math
|
import math
|
||||||
# FreeCAD modules
|
# FreeCAD modules
|
||||||
import FreeCAD as App
|
import FreeCAD as App
|
||||||
import FreeCADGui as Gui
|
import FreeCADGui as Gui
|
||||||
# Qt library
|
# Qt library
|
||||||
from PyQt4 import QtGui,QtCore
|
from PyQt4 import QtGui,QtCore
|
||||||
# Module
|
# Module
|
||||||
import Plot
|
import Plot
|
||||||
import Instance
|
import Instance
|
||||||
from shipUtils import Paths, Translator
|
from shipUtils import Paths, Translator
|
||||||
import Tools
|
import Tools
|
||||||
|
|
||||||
class TaskPanel:
|
class TaskPanel:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.ui = Paths.modulePath() + "/shipHydrostatics/TaskPanel.ui"
|
self.ui = Paths.modulePath() + "/shipHydrostatics/TaskPanel.ui"
|
||||||
self.ship = None
|
self.ship = None
|
||||||
|
|
||||||
def accept(self):
|
def accept(self):
|
||||||
if not self.ship:
|
if not self.ship:
|
||||||
return False
|
return False
|
||||||
self.save()
|
self.save()
|
||||||
draft = self.form.minDraft.value()
|
draft = self.form.minDraft.value()
|
||||||
drafts = [draft]
|
drafts = [draft]
|
||||||
dDraft = (self.form.maxDraft.value() - self.form.minDraft.value())/(self.form.nDraft.value()-1)
|
dDraft = (self.form.maxDraft.value() - self.form.minDraft.value())/(self.form.nDraft.value()-1)
|
||||||
for i in range(1,self.form.nDraft.value()):
|
for i in range(1,self.form.nDraft.value()):
|
||||||
draft = draft + dDraft
|
draft = draft + dDraft
|
||||||
drafts.append(draft)
|
drafts.append(draft)
|
||||||
Plot.Plot(self.ship, self.form.trim.value(), drafts)
|
Plot.Plot(self.ship, self.form.trim.value(), drafts)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def reject(self):
|
def reject(self):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def clicked(self, index):
|
def clicked(self, index):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def open(self):
|
def open(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def needsFullSpace(self):
|
def needsFullSpace(self):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def isAllowedAlterSelection(self):
|
def isAllowedAlterSelection(self):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def isAllowedAlterView(self):
|
def isAllowedAlterView(self):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def isAllowedAlterDocument(self):
|
def isAllowedAlterDocument(self):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def helpRequested(self):
|
def helpRequested(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def setupUi(self):
|
def setupUi(self):
|
||||||
mw = self.getMainWindow()
|
mw = self.getMainWindow()
|
||||||
form = mw.findChild(QtGui.QWidget, "TaskPanel")
|
form = mw.findChild(QtGui.QWidget, "TaskPanel")
|
||||||
form.trim = form.findChild(QtGui.QDoubleSpinBox, "Trim")
|
form.trim = form.findChild(QtGui.QDoubleSpinBox, "Trim")
|
||||||
form.minDraft = form.findChild(QtGui.QDoubleSpinBox, "MinDraft")
|
form.minDraft = form.findChild(QtGui.QDoubleSpinBox, "MinDraft")
|
||||||
form.maxDraft = form.findChild(QtGui.QDoubleSpinBox, "MaxDraft")
|
form.maxDraft = form.findChild(QtGui.QDoubleSpinBox, "MaxDraft")
|
||||||
form.nDraft = form.findChild(QtGui.QSpinBox, "NDraft")
|
form.nDraft = form.findChild(QtGui.QSpinBox, "NDraft")
|
||||||
self.form = form
|
self.form = form
|
||||||
# Initial values
|
# Initial values
|
||||||
if self.initValues():
|
if self.initValues():
|
||||||
return True
|
return True
|
||||||
self.retranslateUi()
|
self.retranslateUi()
|
||||||
# Connect Signals and Slots
|
# Connect Signals and Slots
|
||||||
QtCore.QObject.connect(form.trim, QtCore.SIGNAL("valueChanged(double)"), self.onData)
|
QtCore.QObject.connect(form.trim, QtCore.SIGNAL("valueChanged(double)"), self.onData)
|
||||||
QtCore.QObject.connect(form.minDraft, QtCore.SIGNAL("valueChanged(double)"), self.onData)
|
QtCore.QObject.connect(form.minDraft, QtCore.SIGNAL("valueChanged(double)"), self.onData)
|
||||||
QtCore.QObject.connect(form.maxDraft, QtCore.SIGNAL("valueChanged(double)"), self.onData)
|
QtCore.QObject.connect(form.maxDraft, QtCore.SIGNAL("valueChanged(double)"), self.onData)
|
||||||
|
|
||||||
def getMainWindow(self):
|
def getMainWindow(self):
|
||||||
"returns the main window"
|
"returns the main window"
|
||||||
# using QtGui.qApp.activeWindow() isn't very reliable because if another
|
# using QtGui.qApp.activeWindow() isn't very reliable because if another
|
||||||
# widget than the mainwindow is active (e.g. a dialog) the wrong widget is
|
# widget than the mainwindow is active (e.g. a dialog) the wrong widget is
|
||||||
# returned
|
# returned
|
||||||
toplevel = QtGui.qApp.topLevelWidgets()
|
toplevel = QtGui.qApp.topLevelWidgets()
|
||||||
for i in toplevel:
|
for i in toplevel:
|
||||||
if i.metaObject().className() == "Gui::MainWindow":
|
if i.metaObject().className() == "Gui::MainWindow":
|
||||||
return i
|
return i
|
||||||
raise Exception("No main window found")
|
raise Exception("No main window found")
|
||||||
|
|
||||||
def initValues(self):
|
def initValues(self):
|
||||||
""" Set initial values for fields
|
""" Set initial values for fields
|
||||||
"""
|
"""
|
||||||
# Get objects
|
# Get objects
|
||||||
selObjs = Gui.Selection.getSelection()
|
selObjs = Gui.Selection.getSelection()
|
||||||
if not selObjs:
|
if not selObjs:
|
||||||
msg = Translator.translate("Ship instance must be selected (no object selected)\n")
|
msg = Translator.translate("Ship instance must be selected (no object selected)\n")
|
||||||
App.Console.PrintError(msg)
|
App.Console.PrintError(msg)
|
||||||
return True
|
return True
|
||||||
for i in range(0,len(selObjs)):
|
for i in range(0,len(selObjs)):
|
||||||
obj = selObjs[i]
|
obj = selObjs[i]
|
||||||
# Test if is a ship instance
|
# Test if is a ship instance
|
||||||
props = obj.PropertiesList
|
props = obj.PropertiesList
|
||||||
try:
|
try:
|
||||||
props.index("IsShip")
|
props.index("IsShip")
|
||||||
except ValueError:
|
except ValueError:
|
||||||
continue
|
continue
|
||||||
if obj.IsShip:
|
if obj.IsShip:
|
||||||
# Test if another ship already selected
|
# Test if another ship already selected
|
||||||
if self.ship:
|
if self.ship:
|
||||||
msg = Translator.translate("More than one ship selected (extra ship will be neglected)\n")
|
msg = Translator.translate("More than one ship selected (extra ship will be neglected)\n")
|
||||||
App.Console.PrintWarning(msg)
|
App.Console.PrintWarning(msg)
|
||||||
break
|
break
|
||||||
self.ship = obj
|
self.ship = obj
|
||||||
# Test if any valid ship was selected
|
# Test if any valid ship was selected
|
||||||
if not self.ship:
|
if not self.ship:
|
||||||
msg = Translator.translate("Ship instance must be selected (no valid ship found at selected objects)\n")
|
msg = Translator.translate("Ship instance must be selected (no valid ship found at selected objects)\n")
|
||||||
App.Console.PrintError(msg)
|
App.Console.PrintError(msg)
|
||||||
return True
|
return True
|
||||||
# Get bounds
|
# Get bounds
|
||||||
bbox = self.ship.Shape.BoundBox
|
bbox = self.ship.Shape.BoundBox
|
||||||
# Set trim
|
# Set trim
|
||||||
flag = True
|
flag = True
|
||||||
try:
|
try:
|
||||||
props.index("HydrostaticsTrim")
|
props.index("HydrostaticsTrim")
|
||||||
except ValueError:
|
except ValueError:
|
||||||
flag = False
|
flag = False
|
||||||
if flag:
|
if flag:
|
||||||
self.form.trim.setValue(self.ship.HydrostaticsTrim)
|
self.form.trim.setValue(self.ship.HydrostaticsTrim)
|
||||||
# Set drafts
|
# Set drafts
|
||||||
self.form.maxDraft.setValue(1.1*self.ship.Draft)
|
self.form.maxDraft.setValue(1.1*self.ship.Draft)
|
||||||
self.form.minDraft.setValue(0.9*self.ship.Draft)
|
self.form.minDraft.setValue(0.9*self.ship.Draft)
|
||||||
# Try to use saved values
|
# Try to use saved values
|
||||||
props = self.ship.PropertiesList
|
props = self.ship.PropertiesList
|
||||||
flag = True
|
flag = True
|
||||||
try:
|
try:
|
||||||
props.index("HydrostaticsMinDraft")
|
props.index("HydrostaticsMinDraft")
|
||||||
except ValueError:
|
except ValueError:
|
||||||
flag = False
|
flag = False
|
||||||
if flag:
|
if flag:
|
||||||
self.form.minDraft.setValue(self.ship.HydrostaticsMinDraft)
|
self.form.minDraft.setValue(self.ship.HydrostaticsMinDraft)
|
||||||
flag = True
|
flag = True
|
||||||
try:
|
try:
|
||||||
props.index("HydrostaticsMaxDraft")
|
props.index("HydrostaticsMaxDraft")
|
||||||
except ValueError:
|
except ValueError:
|
||||||
flag = False
|
flag = False
|
||||||
if flag:
|
if flag:
|
||||||
self.form.maxDraft.setValue(self.ship.HydrostaticsMaxDraft)
|
self.form.maxDraft.setValue(self.ship.HydrostaticsMaxDraft)
|
||||||
self.form.maxDraft.setMaximum(bbox.ZMax)
|
self.form.maxDraft.setMaximum(bbox.ZMax)
|
||||||
self.form.minDraft.setMinimum(bbox.ZMin)
|
self.form.minDraft.setMinimum(bbox.ZMin)
|
||||||
self.form.maxDraft.setMinimum(self.form.minDraft.value())
|
self.form.maxDraft.setMinimum(self.form.minDraft.value())
|
||||||
self.form.minDraft.setMaximum(self.form.maxDraft.value())
|
self.form.minDraft.setMaximum(self.form.maxDraft.value())
|
||||||
flag = True
|
flag = True
|
||||||
try:
|
try:
|
||||||
props.index("HydrostaticsNDraft")
|
props.index("HydrostaticsNDraft")
|
||||||
except ValueError:
|
except ValueError:
|
||||||
flag = False
|
flag = False
|
||||||
if flag:
|
if flag:
|
||||||
self.form.nDraft.setValue(self.ship.HydrostaticsNDraft)
|
self.form.nDraft.setValue(self.ship.HydrostaticsNDraft)
|
||||||
# Update GUI
|
# Update GUI
|
||||||
msg = Translator.translate("Ready to work\n")
|
msg = Translator.translate("Ready to work\n")
|
||||||
App.Console.PrintMessage(msg)
|
App.Console.PrintMessage(msg)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def retranslateUi(self):
|
def retranslateUi(self):
|
||||||
""" Set user interface locale strings.
|
""" Set user interface locale strings.
|
||||||
"""
|
"""
|
||||||
self.form.setWindowTitle(Translator.translate("Plot hydrostatics"))
|
self.form.setWindowTitle(Translator.translate("Plot hydrostatics"))
|
||||||
self.form.findChild(QtGui.QLabel, "TrimLabel").setText(Translator.translate("Trim"))
|
self.form.findChild(QtGui.QLabel, "TrimLabel").setText(Translator.translate("Trim"))
|
||||||
self.form.findChild(QtGui.QLabel, "MinDraftLabel").setText(Translator.translate("Minimum draft"))
|
self.form.findChild(QtGui.QLabel, "MinDraftLabel").setText(Translator.translate("Minimum draft"))
|
||||||
self.form.findChild(QtGui.QLabel, "MaxDraftLabel").setText(Translator.translate("Maximum draft"))
|
self.form.findChild(QtGui.QLabel, "MaxDraftLabel").setText(Translator.translate("Maximum draft"))
|
||||||
self.form.findChild(QtGui.QLabel, "NDraftLabel").setText(Translator.translate("Number of points"))
|
self.form.findChild(QtGui.QLabel, "NDraftLabel").setText(Translator.translate("Number of points"))
|
||||||
|
|
||||||
def onData(self, value):
|
def onData(self, value):
|
||||||
""" Method called when input data is changed.
|
""" Method called when input data is changed.
|
||||||
@param value Changed value.
|
@param value Changed value.
|
||||||
"""
|
"""
|
||||||
if not self.ship:
|
if not self.ship:
|
||||||
return
|
return
|
||||||
self.form.maxDraft.setMinimum(self.form.minDraft.value())
|
self.form.maxDraft.setMinimum(self.form.minDraft.value())
|
||||||
self.form.minDraft.setMaximum(self.form.maxDraft.value())
|
self.form.minDraft.setMaximum(self.form.maxDraft.value())
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
""" Saves data into ship instance.
|
""" Saves data into ship instance.
|
||||||
"""
|
"""
|
||||||
props = self.ship.PropertiesList
|
props = self.ship.PropertiesList
|
||||||
try:
|
try:
|
||||||
props.index("HydrostaticsTrim")
|
props.index("HydrostaticsTrim")
|
||||||
except ValueError:
|
except ValueError:
|
||||||
self.ship.addProperty("App::PropertyFloat","HydrostaticsTrim","Ship", str(Translator.translate("Hydrostatics trim selected [m]")))
|
self.ship.addProperty("App::PropertyFloat","HydrostaticsTrim","Ship", str(Translator.translate("Hydrostatics trim selected [m]")))
|
||||||
self.ship.HydrostaticsTrim = self.form.trim.value()
|
self.ship.HydrostaticsTrim = self.form.trim.value()
|
||||||
try:
|
try:
|
||||||
props.index("HydrostaticsMinDraft")
|
props.index("HydrostaticsMinDraft")
|
||||||
except ValueError:
|
except ValueError:
|
||||||
self.ship.addProperty("App::PropertyFloat","HydrostaticsMinDraft","Ship", str(Translator.translate("Hydrostatics minimum draft selected [m]")))
|
self.ship.addProperty("App::PropertyFloat","HydrostaticsMinDraft","Ship", str(Translator.translate("Hydrostatics minimum draft selected [m]")))
|
||||||
self.ship.HydrostaticsMinDraft = self.form.minDraft.value()
|
self.ship.HydrostaticsMinDraft = self.form.minDraft.value()
|
||||||
try:
|
try:
|
||||||
props.index("HydrostaticsMaxDraft")
|
props.index("HydrostaticsMaxDraft")
|
||||||
except ValueError:
|
except ValueError:
|
||||||
self.ship.addProperty("App::PropertyFloat","HydrostaticsMaxDraft","Ship", str(Translator.translate("Hydrostatics maximum draft selected [m]")))
|
self.ship.addProperty("App::PropertyFloat","HydrostaticsMaxDraft","Ship", str(Translator.translate("Hydrostatics maximum draft selected [m]")))
|
||||||
self.ship.HydrostaticsMaxDraft = self.form.maxDraft.value()
|
self.ship.HydrostaticsMaxDraft = self.form.maxDraft.value()
|
||||||
try:
|
try:
|
||||||
props.index("HydrostaticsNDraft")
|
props.index("HydrostaticsNDraft")
|
||||||
except ValueError:
|
except ValueError:
|
||||||
self.ship.addProperty("App::PropertyInteger","HydrostaticsNDraft","Ship", str(Translator.translate("Hydrostatics number of points selected [m]")))
|
self.ship.addProperty("App::PropertyInteger","HydrostaticsNDraft","Ship", str(Translator.translate("Hydrostatics number of points selected [m]")))
|
||||||
self.ship.HydrostaticsNDraft = self.form.nDraft.value()
|
self.ship.HydrostaticsNDraft = self.form.nDraft.value()
|
||||||
|
|
||||||
def createTask():
|
def createTask():
|
||||||
panel = TaskPanel()
|
panel = TaskPanel()
|
||||||
Gui.Control.showDialog(panel)
|
Gui.Control.showDialog(panel)
|
||||||
if panel.setupUi():
|
if panel.setupUi():
|
||||||
Gui.Control.closeDialog(panel)
|
Gui.Control.closeDialog(panel)
|
||||||
return None
|
return None
|
||||||
return panel
|
return panel
|
||||||
|
|
|
@ -51,7 +51,7 @@ def Plot(scale, sections, shape):
|
||||||
x0 = xMid - 0.5*xTot
|
x0 = xMid - 0.5*xTot
|
||||||
y0 = 297.0 - yMid - 0.5*yTot # 297 = A3_width
|
y0 = 297.0 - yMid - 0.5*yTot # 297 = A3_width
|
||||||
# Get border
|
# Get border
|
||||||
edges = self.getEdges([shape])
|
edges = getEdges([shape])
|
||||||
border = edges[0]
|
border = edges[0]
|
||||||
for i in range(0,len(edges)):
|
for i in range(0,len(edges)):
|
||||||
border = border.oldFuse(edges[i]) # Only group objects, don't try to build more complex entities
|
border = border.oldFuse(edges[i]) # Only group objects, don't try to build more complex entities
|
||||||
|
@ -95,7 +95,7 @@ def Plot(scale, sections, shape):
|
||||||
FreeCAD.ActiveDocument.recompute()
|
FreeCAD.ActiveDocument.recompute()
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
def getEdges(self, objs=None):
|
def getEdges(objs=None):
|
||||||
""" Returns object edges (list of them)
|
""" Returns object edges (list of them)
|
||||||
@param objs Object to get the faces, none if selected
|
@param objs Object to get the faces, none if selected
|
||||||
object may used.
|
object may used.
|
||||||
|
|
|
@ -1,348 +1,348 @@
|
||||||
#***************************************************************************
|
#***************************************************************************
|
||||||
#* *
|
#* *
|
||||||
#* Copyright (c) 2011, 2012 *
|
#* Copyright (c) 2011, 2012 *
|
||||||
#* Jose Luis Cercos Pita <jlcercos@gmail.com> *
|
#* Jose Luis Cercos Pita <jlcercos@gmail.com> *
|
||||||
#* *
|
#* *
|
||||||
#* This program is free software; you can redistribute it and/or modify *
|
#* This program is free software; you can redistribute it and/or modify *
|
||||||
#* it under the terms of the GNU Lesser General Public License (LGPL) *
|
#* it under the terms of the GNU Lesser General Public License (LGPL) *
|
||||||
#* as published by the Free Software Foundation; either version 2 of *
|
#* as published by the Free Software Foundation; either version 2 of *
|
||||||
#* the License, or (at your option) any later version. *
|
#* the License, or (at your option) any later version. *
|
||||||
#* for detail see the LICENCE text file. *
|
#* for detail see the LICENCE text file. *
|
||||||
#* *
|
#* *
|
||||||
#* This program is distributed in the hope that it will be useful, *
|
#* This program is distributed in the hope that it will be useful, *
|
||||||
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
#* GNU Library General Public License for more details. *
|
#* GNU Library General Public License for more details. *
|
||||||
#* *
|
#* *
|
||||||
#* You should have received a copy of the GNU Library General Public *
|
#* You should have received a copy of the GNU Library General Public *
|
||||||
#* License along with this program; if not, write to the Free Software *
|
#* License along with this program; if not, write to the Free Software *
|
||||||
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
|
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
|
||||||
#* USA *
|
#* USA *
|
||||||
#* *
|
#* *
|
||||||
#***************************************************************************
|
#***************************************************************************
|
||||||
|
|
||||||
# FreeCAD modules
|
# FreeCAD modules
|
||||||
import FreeCAD as App
|
import FreeCAD as App
|
||||||
import FreeCADGui as Gui
|
import FreeCADGui as Gui
|
||||||
# Qt library
|
# Qt library
|
||||||
from PyQt4 import QtGui,QtCore
|
from PyQt4 import QtGui,QtCore
|
||||||
# Module
|
# Module
|
||||||
import Preview, Plot
|
import Preview, Plot
|
||||||
import Instance
|
import Instance
|
||||||
from shipUtils import Paths, Translator
|
from shipUtils import Paths, Translator
|
||||||
|
|
||||||
class TaskPanel:
|
class TaskPanel:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.ui = Paths.modulePath() + "/shipOutlineDraw/TaskPanel.ui"
|
self.ui = Paths.modulePath() + "/shipOutlineDraw/TaskPanel.ui"
|
||||||
self.ship = None
|
self.ship = None
|
||||||
self.skip = False
|
self.skip = False
|
||||||
self.LSections = []
|
self.LSections = []
|
||||||
self.BSections = []
|
self.BSections = []
|
||||||
self.TSections = []
|
self.TSections = []
|
||||||
self.obj = None
|
self.obj = None
|
||||||
self.preview = Preview.Preview()
|
self.preview = Preview.Preview()
|
||||||
|
|
||||||
def accept(self):
|
def accept(self):
|
||||||
self.saveSections()
|
self.saveSections()
|
||||||
self.obj = Plot.Plot(self.form.scale.value(), self.obj.Shape, self.ship.Shape)
|
self.obj = Plot.Plot(self.form.scale.value(), self.obj.Shape, self.ship.Shape)
|
||||||
self.preview.clean()
|
self.preview.clean()
|
||||||
self.obj.Label = 'OutlineDraw'
|
self.obj.Label = 'OutlineDraw'
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def reject(self):
|
def reject(self):
|
||||||
self.preview.clean()
|
self.preview.clean()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def clicked(self, index):
|
def clicked(self, index):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def open(self):
|
def open(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def needsFullSpace(self):
|
def needsFullSpace(self):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def isAllowedAlterSelection(self):
|
def isAllowedAlterSelection(self):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def isAllowedAlterView(self):
|
def isAllowedAlterView(self):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def isAllowedAlterDocument(self):
|
def isAllowedAlterDocument(self):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def helpRequested(self):
|
def helpRequested(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def setupUi(self):
|
def setupUi(self):
|
||||||
mw = self.getMainWindow()
|
mw = self.getMainWindow()
|
||||||
form = mw.findChild(QtGui.QWidget, "TaskPanel")
|
form = mw.findChild(QtGui.QWidget, "TaskPanel")
|
||||||
form.sections = form.findChild(QtGui.QTableWidget, "Sections")
|
form.sections = form.findChild(QtGui.QTableWidget, "Sections")
|
||||||
try:
|
try:
|
||||||
form.sections.setInputMethodHints(QtCore.Qt.ImhFormattedNumbersOnly)
|
form.sections.setInputMethodHints(QtCore.Qt.ImhFormattedNumbersOnly)
|
||||||
except:
|
except:
|
||||||
msg = Translator.translate("QtCore.Qt.ImhFormattedNumbersOnly not supported, will not used.\n")
|
msg = Translator.translate("QtCore.Qt.ImhFormattedNumbersOnly not supported, will not used.\n")
|
||||||
App.Console.PrintWarning(msg)
|
App.Console.PrintWarning(msg)
|
||||||
form.sectionType = form.findChild(QtGui.QComboBox, "SectionType")
|
form.sectionType = form.findChild(QtGui.QComboBox, "SectionType")
|
||||||
form.deleteButton = form.findChild(QtGui.QPushButton, "DeleteButton")
|
form.deleteButton = form.findChild(QtGui.QPushButton, "DeleteButton")
|
||||||
form.nSections = form.findChild(QtGui.QSpinBox, "NSections")
|
form.nSections = form.findChild(QtGui.QSpinBox, "NSections")
|
||||||
form.createButton = form.findChild(QtGui.QPushButton, "CreateButton")
|
form.createButton = form.findChild(QtGui.QPushButton, "CreateButton")
|
||||||
form.scale = form.findChild(QtGui.QSpinBox, "Scale")
|
form.scale = form.findChild(QtGui.QSpinBox, "Scale")
|
||||||
self.form = form
|
self.form = form
|
||||||
# Initial values
|
# Initial values
|
||||||
if self.initValues():
|
if self.initValues():
|
||||||
return True
|
return True
|
||||||
self.retranslateUi()
|
self.retranslateUi()
|
||||||
self.obj = self.preview.update(self.ship.Length, self.ship.Beam, self.ship.Draft, self.LSections,self.BSections,self.TSections, self.ship.Shape)
|
self.obj = self.preview.update(self.ship.Length, self.ship.Beam, self.ship.Draft, self.LSections,self.BSections,self.TSections, self.ship.Shape)
|
||||||
# Connect Signals and Slots
|
# Connect Signals and Slots
|
||||||
QtCore.QObject.connect(form.sectionType,QtCore.SIGNAL("activated(QString)"),self.onSectionType)
|
QtCore.QObject.connect(form.sectionType,QtCore.SIGNAL("activated(QString)"),self.onSectionType)
|
||||||
QtCore.QObject.connect(form.sections,QtCore.SIGNAL("cellChanged(int,int)"),self.onTableItem);
|
QtCore.QObject.connect(form.sections,QtCore.SIGNAL("cellChanged(int,int)"),self.onTableItem);
|
||||||
QtCore.QObject.connect(form.deleteButton,QtCore.SIGNAL("pressed()"),self.onDeleteButton)
|
QtCore.QObject.connect(form.deleteButton,QtCore.SIGNAL("pressed()"),self.onDeleteButton)
|
||||||
QtCore.QObject.connect(form.createButton,QtCore.SIGNAL("pressed()"),self.onCreateButton)
|
QtCore.QObject.connect(form.createButton,QtCore.SIGNAL("pressed()"),self.onCreateButton)
|
||||||
|
|
||||||
def getMainWindow(self):
|
def getMainWindow(self):
|
||||||
"returns the main window"
|
"returns the main window"
|
||||||
# using QtGui.qApp.activeWindow() isn't very reliable because if another
|
# using QtGui.qApp.activeWindow() isn't very reliable because if another
|
||||||
# widget than the mainwindow is active (e.g. a dialog) the wrong widget is
|
# widget than the mainwindow is active (e.g. a dialog) the wrong widget is
|
||||||
# returned
|
# returned
|
||||||
toplevel = QtGui.qApp.topLevelWidgets()
|
toplevel = QtGui.qApp.topLevelWidgets()
|
||||||
for i in toplevel:
|
for i in toplevel:
|
||||||
if i.metaObject().className() == "Gui::MainWindow":
|
if i.metaObject().className() == "Gui::MainWindow":
|
||||||
return i
|
return i
|
||||||
raise Exception("No main window found")
|
raise Exception("No main window found")
|
||||||
|
|
||||||
def initValues(self):
|
def initValues(self):
|
||||||
""" Set initial values for fields
|
""" Set initial values for fields
|
||||||
"""
|
"""
|
||||||
# Get selected objects
|
# Get selected objects
|
||||||
selObjs = Gui.Selection.getSelection()
|
selObjs = Gui.Selection.getSelection()
|
||||||
if not selObjs:
|
if not selObjs:
|
||||||
msg = Translator.translate("Ship instance must be selected (no object selected)\n")
|
msg = Translator.translate("Ship instance must be selected (no object selected)\n")
|
||||||
App.Console.PrintError(msg)
|
App.Console.PrintError(msg)
|
||||||
return True
|
return True
|
||||||
for i in range(0,len(selObjs)):
|
for i in range(0,len(selObjs)):
|
||||||
obj = selObjs[i]
|
obj = selObjs[i]
|
||||||
# Test if is a ship instance
|
# Test if is a ship instance
|
||||||
props = obj.PropertiesList
|
props = obj.PropertiesList
|
||||||
try:
|
try:
|
||||||
props.index("IsShip")
|
props.index("IsShip")
|
||||||
except ValueError:
|
except ValueError:
|
||||||
continue
|
continue
|
||||||
if obj.IsShip:
|
if obj.IsShip:
|
||||||
# Test if another ship already selected
|
# Test if another ship already selected
|
||||||
if self.ship:
|
if self.ship:
|
||||||
msg = Translator.translate("More than one ship selected (extra ship will be neglected)\n")
|
msg = Translator.translate("More than one ship selected (extra ship will be neglected)\n")
|
||||||
App.Console.PrintWarning(msg)
|
App.Console.PrintWarning(msg)
|
||||||
break
|
break
|
||||||
self.ship = obj
|
self.ship = obj
|
||||||
# Test if any valid ship was selected
|
# Test if any valid ship was selected
|
||||||
if not self.ship:
|
if not self.ship:
|
||||||
msg = Translator.translate("Ship instance must be selected (no valid ship found at selected objects)\n")
|
msg = Translator.translate("Ship instance must be selected (no valid ship found at selected objects)\n")
|
||||||
App.Console.PrintError(msg)
|
App.Console.PrintError(msg)
|
||||||
return True
|
return True
|
||||||
# Load sections (if exist)
|
# Load sections (if exist)
|
||||||
self.loadSections()
|
self.loadSections()
|
||||||
msg = Translator.translate("Ready to work\n")
|
msg = Translator.translate("Ready to work\n")
|
||||||
App.Console.PrintMessage(msg)
|
App.Console.PrintMessage(msg)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def retranslateUi(self):
|
def retranslateUi(self):
|
||||||
""" Set user interface locale strings.
|
""" Set user interface locale strings.
|
||||||
"""
|
"""
|
||||||
self.form.setWindowTitle(Translator.translate("Outline draw"))
|
self.form.setWindowTitle(Translator.translate("Outline draw"))
|
||||||
self.form.findChild(QtGui.QGroupBox, "AutoCreateBox").setTitle(Translator.translate("Auto create"))
|
self.form.findChild(QtGui.QGroupBox, "AutoCreateBox").setTitle(Translator.translate("Auto create"))
|
||||||
self.form.findChild(QtGui.QGroupBox, "ScaleBox").setTitle(Translator.translate("Scale"))
|
self.form.findChild(QtGui.QGroupBox, "ScaleBox").setTitle(Translator.translate("Scale"))
|
||||||
self.form.findChild(QtGui.QPushButton, "DeleteButton").setText(Translator.translate("Delete all sections"))
|
self.form.findChild(QtGui.QPushButton, "DeleteButton").setText(Translator.translate("Delete all sections"))
|
||||||
self.form.findChild(QtGui.QPushButton, "CreateButton").setText(Translator.translate("Create sections"))
|
self.form.findChild(QtGui.QPushButton, "CreateButton").setText(Translator.translate("Create sections"))
|
||||||
self.form.findChild(QtGui.QComboBox, "SectionType").setItemText(0, Translator.translate("Transversal"))
|
self.form.findChild(QtGui.QComboBox, "SectionType").setItemText(0, Translator.translate("Transversal"))
|
||||||
self.form.findChild(QtGui.QComboBox, "SectionType").setItemText(1, Translator.translate("Longitudinal"))
|
self.form.findChild(QtGui.QComboBox, "SectionType").setItemText(1, Translator.translate("Longitudinal"))
|
||||||
self.form.findChild(QtGui.QComboBox, "SectionType").setItemText(2, Translator.translate("Water lines"))
|
self.form.findChild(QtGui.QComboBox, "SectionType").setItemText(2, Translator.translate("Water lines"))
|
||||||
|
|
||||||
def onSectionType(self):
|
def onSectionType(self):
|
||||||
""" Function called when the section type is changed.
|
""" Function called when the section type is changed.
|
||||||
"""
|
"""
|
||||||
# Search section type
|
# Search section type
|
||||||
ID = self.form.sectionType.currentIndex()
|
ID = self.form.sectionType.currentIndex()
|
||||||
self.setSectionType(ID)
|
self.setSectionType(ID)
|
||||||
|
|
||||||
def setSectionType(self, ID):
|
def setSectionType(self, ID):
|
||||||
""" Function that set the type section related table.
|
""" Function that set the type section related table.
|
||||||
@param ID Id of the section to set: \n
|
@param ID Id of the section to set: \n
|
||||||
0 = Transversal sections \n
|
0 = Transversal sections \n
|
||||||
1 = Longitudinal sections \n
|
1 = Longitudinal sections \n
|
||||||
2 = Water lines
|
2 = Water lines
|
||||||
"""
|
"""
|
||||||
SectionList = []
|
SectionList = []
|
||||||
if ID == 0:
|
if ID == 0:
|
||||||
SectionList = self.LSections[:]
|
SectionList = self.LSections[:]
|
||||||
elif ID == 1:
|
elif ID == 1:
|
||||||
SectionList = self.BSections[:]
|
SectionList = self.BSections[:]
|
||||||
elif ID == 2:
|
elif ID == 2:
|
||||||
SectionList = self.TSections[:]
|
SectionList = self.TSections[:]
|
||||||
nRow = len(SectionList)
|
nRow = len(SectionList)
|
||||||
self.form.sections.clearContents()
|
self.form.sections.clearContents()
|
||||||
self.form.sections.setRowCount(nRow+1)
|
self.form.sections.setRowCount(nRow+1)
|
||||||
if not nRow:
|
if not nRow:
|
||||||
self.obj = self.preview.update(self.ship.Length, self.ship.Beam, self.ship.Draft, self.LSections,self.BSections,self.TSections, self.ship.Shape)
|
self.obj = self.preview.update(self.ship.Length, self.ship.Beam, self.ship.Draft, self.LSections,self.BSections,self.TSections, self.ship.Shape)
|
||||||
return
|
return
|
||||||
self.skip = True # Avoid recursive call to OnItem
|
self.skip = True # Avoid recursive call to OnItem
|
||||||
for i in range(0,nRow):
|
for i in range(0,nRow):
|
||||||
if i == nRow-1:
|
if i == nRow-1:
|
||||||
self.skip = False
|
self.skip = False
|
||||||
string = '%f' % (SectionList[i])
|
string = '%f' % (SectionList[i])
|
||||||
item = QtGui.QTableWidgetItem(string)
|
item = QtGui.QTableWidgetItem(string)
|
||||||
self.form.sections.setItem(i,0,item)
|
self.form.sections.setItem(i,0,item)
|
||||||
|
|
||||||
def onTableItem(self, row, column):
|
def onTableItem(self, row, column):
|
||||||
""" Function called when an item of table is changed.
|
""" Function called when an item of table is changed.
|
||||||
@param row Changed item row
|
@param row Changed item row
|
||||||
@param column Changed item column
|
@param column Changed item column
|
||||||
"""
|
"""
|
||||||
if self.skip:
|
if self.skip:
|
||||||
return
|
return
|
||||||
# Ensure that exist one empty item at least
|
# Ensure that exist one empty item at least
|
||||||
nRow = self.form.sections.rowCount()
|
nRow = self.form.sections.rowCount()
|
||||||
item = self.form.sections.item(nRow-1,0)
|
item = self.form.sections.item(nRow-1,0)
|
||||||
if item :
|
if item :
|
||||||
if(item.text() != ''):
|
if(item.text() != ''):
|
||||||
self.form.sections.setRowCount(nRow+1)
|
self.form.sections.setRowCount(nRow+1)
|
||||||
# Ensure that new item is a number
|
# Ensure that new item is a number
|
||||||
ID = self.form.sectionType.currentIndex()
|
ID = self.form.sectionType.currentIndex()
|
||||||
if ID == 0:
|
if ID == 0:
|
||||||
SectionList = self.LSections[:]
|
SectionList = self.LSections[:]
|
||||||
elif ID == 1:
|
elif ID == 1:
|
||||||
SectionList = self.BSections[:]
|
SectionList = self.BSections[:]
|
||||||
elif ID == 2:
|
elif ID == 2:
|
||||||
SectionList = self.TSections[:]
|
SectionList = self.TSections[:]
|
||||||
item = self.form.sections.item(row,column)
|
item = self.form.sections.item(row,column)
|
||||||
(number,flag) = item.text().toFloat()
|
(number,flag) = item.text().toFloat()
|
||||||
if not flag:
|
if not flag:
|
||||||
if len(SectionList) > nRow-1:
|
if len(SectionList) > nRow-1:
|
||||||
number = SectionList[nRow-1]
|
number = SectionList[nRow-1]
|
||||||
else:
|
else:
|
||||||
number = 0.0
|
number = 0.0
|
||||||
string = '%f' % (number)
|
string = '%f' % (number)
|
||||||
item.setText(string)
|
item.setText(string)
|
||||||
# Regenerate the list
|
# Regenerate the list
|
||||||
SectionList = []
|
SectionList = []
|
||||||
for i in range(0,nRow):
|
for i in range(0,nRow):
|
||||||
item = self.form.sections.item(i,0)
|
item = self.form.sections.item(i,0)
|
||||||
if item:
|
if item:
|
||||||
(number,flag) = item.text().toFloat()
|
(number,flag) = item.text().toFloat()
|
||||||
SectionList.append(number)
|
SectionList.append(number)
|
||||||
# Paste it into the class list
|
# Paste it into the class list
|
||||||
ID = self.form.sectionType.currentIndex()
|
ID = self.form.sectionType.currentIndex()
|
||||||
if ID == 0:
|
if ID == 0:
|
||||||
self.LSections = SectionList[:]
|
self.LSections = SectionList[:]
|
||||||
elif ID == 1:
|
elif ID == 1:
|
||||||
self.BSections = SectionList[:]
|
self.BSections = SectionList[:]
|
||||||
elif ID == 2:
|
elif ID == 2:
|
||||||
self.TSections = SectionList[:]
|
self.TSections = SectionList[:]
|
||||||
self.obj = self.preview.update(self.ship.Length, self.ship.Beam, self.ship.Draft, self.LSections,self.BSections,self.TSections, self.ship.Shape)
|
self.obj = self.preview.update(self.ship.Length, self.ship.Beam, self.ship.Draft, self.LSections,self.BSections,self.TSections, self.ship.Shape)
|
||||||
|
|
||||||
def onDeleteButton(self):
|
def onDeleteButton(self):
|
||||||
""" Function called when the delete button is pressed.
|
""" Function called when the delete button is pressed.
|
||||||
All sections mustt be erased
|
All sections mustt be erased
|
||||||
"""
|
"""
|
||||||
self.form.sections.clearContents()
|
self.form.sections.clearContents()
|
||||||
self.form.sections.setRowCount(1)
|
self.form.sections.setRowCount(1)
|
||||||
# Clear active list
|
# Clear active list
|
||||||
ID = self.form.sectionType.currentIndex()
|
ID = self.form.sectionType.currentIndex()
|
||||||
if ID == 0:
|
if ID == 0:
|
||||||
self.LSections = []
|
self.LSections = []
|
||||||
elif ID == 1:
|
elif ID == 1:
|
||||||
self.BSections = []
|
self.BSections = []
|
||||||
elif ID == 2:
|
elif ID == 2:
|
||||||
self.TSections = []
|
self.TSections = []
|
||||||
self.setSectionType(ID)
|
self.setSectionType(ID)
|
||||||
|
|
||||||
def onCreateButton(self):
|
def onCreateButton(self):
|
||||||
""" Function called when create button is pressed.
|
""" Function called when create button is pressed.
|
||||||
Several sections must be added to list
|
Several sections must be added to list
|
||||||
"""
|
"""
|
||||||
# Recolect data
|
# Recolect data
|
||||||
nSections = self.form.nSections.value()
|
nSections = self.form.nSections.value()
|
||||||
SectionList = []
|
SectionList = []
|
||||||
L = 0.0
|
L = 0.0
|
||||||
ID = self.form.sectionType.currentIndex()
|
ID = self.form.sectionType.currentIndex()
|
||||||
if ID == 0:
|
if ID == 0:
|
||||||
L = self.ship.Length
|
L = self.ship.Length
|
||||||
d = L / (nSections-1) # Distance between sections
|
d = L / (nSections-1) # Distance between sections
|
||||||
start = - L/2.0 # Ship must have 0.0 at coordinates origin
|
start = - L/2.0 # Ship must have 0.0 at coordinates origin
|
||||||
elif ID == 1:
|
elif ID == 1:
|
||||||
L = -0.5*self.ship.Beam # Ship must be in y<0.0
|
L = -0.5*self.ship.Beam # Ship must be in y<0.0
|
||||||
d = L / (nSections+1.0) # Distance between sections
|
d = L / (nSections+1.0) # Distance between sections
|
||||||
start = d
|
start = d
|
||||||
elif ID == 2:
|
elif ID == 2:
|
||||||
L = self.ship.Draft
|
L = self.ship.Draft
|
||||||
d = L / (nSections) # Distance between sections
|
d = L / (nSections) # Distance between sections
|
||||||
start = d
|
start = d
|
||||||
# Calculate sections
|
# Calculate sections
|
||||||
for i in range(0,nSections):
|
for i in range(0,nSections):
|
||||||
sec = i*d + start
|
sec = i*d + start
|
||||||
SectionList.append(sec)
|
SectionList.append(sec)
|
||||||
# Paste into class table
|
# Paste into class table
|
||||||
if ID == 0:
|
if ID == 0:
|
||||||
self.LSections = SectionList[:]
|
self.LSections = SectionList[:]
|
||||||
elif ID == 1:
|
elif ID == 1:
|
||||||
self.BSections = SectionList[:]
|
self.BSections = SectionList[:]
|
||||||
elif ID == 2:
|
elif ID == 2:
|
||||||
self.TSections = SectionList[:]
|
self.TSections = SectionList[:]
|
||||||
# Print the table
|
# Print the table
|
||||||
self.setSectionType(ID)
|
self.setSectionType(ID)
|
||||||
|
|
||||||
def loadSections(self):
|
def loadSections(self):
|
||||||
""" Loads from ship object previously selected sections.
|
""" Loads from ship object previously selected sections.
|
||||||
"""
|
"""
|
||||||
# Load sections
|
# Load sections
|
||||||
props = self.ship.PropertiesList
|
props = self.ship.PropertiesList
|
||||||
flag=True
|
flag=True
|
||||||
try:
|
try:
|
||||||
props.index("LSections")
|
props.index("LSections")
|
||||||
except ValueError:
|
except ValueError:
|
||||||
flag=False
|
flag=False
|
||||||
if flag:
|
if flag:
|
||||||
self.LSections = self.ship.LSections[:]
|
self.LSections = self.ship.LSections[:]
|
||||||
self.BSections = self.ship.BSections[:]
|
self.BSections = self.ship.BSections[:]
|
||||||
self.TSections = self.ship.TSections[:]
|
self.TSections = self.ship.TSections[:]
|
||||||
# Load scale too
|
# Load scale too
|
||||||
flag=True
|
flag=True
|
||||||
try:
|
try:
|
||||||
props.index("PlotScale")
|
props.index("PlotScale")
|
||||||
except ValueError:
|
except ValueError:
|
||||||
flag=False
|
flag=False
|
||||||
if flag:
|
if flag:
|
||||||
self.form.scale.setValue(self.ship.PlotScale)
|
self.form.scale.setValue(self.ship.PlotScale)
|
||||||
# Set UI
|
# Set UI
|
||||||
self.setSectionType(self.form.sectionType.currentIndex())
|
self.setSectionType(self.form.sectionType.currentIndex())
|
||||||
|
|
||||||
def saveSections(self):
|
def saveSections(self):
|
||||||
""" Save selected sections into ship object.
|
""" Save selected sections into ship object.
|
||||||
"""
|
"""
|
||||||
# Test if previous section have been created
|
# Test if previous section have been created
|
||||||
props = self.ship.PropertiesList
|
props = self.ship.PropertiesList
|
||||||
try:
|
try:
|
||||||
props.index("LSections")
|
props.index("LSections")
|
||||||
except ValueError:
|
except ValueError:
|
||||||
# Create new sections list
|
# Create new sections list
|
||||||
self.ship.addProperty("App::PropertyFloatList","LSections","Ship", str(Translator.translate("Transversal sections position [m]"))).LSections=[]
|
self.ship.addProperty("App::PropertyFloatList","LSections","Ship", str(Translator.translate("Transversal sections position [m]"))).LSections=[]
|
||||||
self.ship.addProperty("App::PropertyFloatList","BSections","Ship", str(Translator.translate("Longitudinal sections position [m]"))).BSections=[]
|
self.ship.addProperty("App::PropertyFloatList","BSections","Ship", str(Translator.translate("Longitudinal sections position [m]"))).BSections=[]
|
||||||
self.ship.addProperty("App::PropertyFloatList","TSections","Ship", str(Translator.translate("Water lines position [m]"))).TSections=[]
|
self.ship.addProperty("App::PropertyFloatList","TSections","Ship", str(Translator.translate("Water lines position [m]"))).TSections=[]
|
||||||
# Save sections
|
# Save sections
|
||||||
self.ship.LSections = self.LSections[:]
|
self.ship.LSections = self.LSections[:]
|
||||||
self.ship.BSections = self.BSections[:]
|
self.ship.BSections = self.BSections[:]
|
||||||
self.ship.TSections = self.TSections[:]
|
self.ship.TSections = self.TSections[:]
|
||||||
# Save also scale
|
# Save also scale
|
||||||
try:
|
try:
|
||||||
props.index("PlotScale")
|
props.index("PlotScale")
|
||||||
except ValueError:
|
except ValueError:
|
||||||
self.ship.addProperty("App::PropertyInteger","PlotScale","Ship", str(Translator.translate("Plot scale (1:scale format)"))).PlotScale=250
|
self.ship.addProperty("App::PropertyInteger","PlotScale","Ship", str(Translator.translate("Plot scale (1:scale format)"))).PlotScale=250
|
||||||
self.ship.PlotScale = self.form.scale.value()
|
self.ship.PlotScale = self.form.scale.value()
|
||||||
|
|
||||||
def createTask():
|
def createTask():
|
||||||
panel = TaskPanel()
|
panel = TaskPanel()
|
||||||
Gui.Control.showDialog(panel)
|
Gui.Control.showDialog(panel)
|
||||||
if panel.setupUi():
|
if panel.setupUi():
|
||||||
Gui.Control.closeDialog(panel)
|
Gui.Control.closeDialog(panel)
|
||||||
return None
|
return None
|
||||||
return panel
|
return panel
|
||||||
|
|
Loading…
Reference in New Issue
Block a user