option to pass settings to pyqt4 app

This commit is contained in:
Thomas Krijnen
2016-05-03 11:05:46 +02:00
parent 04acfe1169
commit fefa8a0563
@@ -100,7 +100,7 @@ class application(QtGui.QApplication):
if len(decompositions): if len(decompositions):
return decompositions[0].RelatingObject return decompositions[0].RelatingObject
def load_file(self, f): def load_file(self, f, **kwargs):
products = list(f.by_type("IfcProduct")) + list(f.by_type("IfcProject")) products = list(f.by_type("IfcProduct")) + list(f.by_type("IfcProject"))
parents = list(map(self.parent, products)) parents = list(map(self.parent, products))
items = {} items = {}
@@ -131,7 +131,7 @@ class application(QtGui.QApplication):
ATTRIBUTES = ['Name'] ATTRIBUTES = ['Name']
def load_file(self, f): def load_file(self, f, **kwargs):
products = list(f.by_type("IfcProduct")) products = list(f.by_type("IfcProduct"))
types = set(map(lambda i: i.is_a(), products)) types = set(map(lambda i: i.is_a(), products))
items = {} items = {}
@@ -192,10 +192,11 @@ class application(QtGui.QApplication):
self.InitDriver() self.InitDriver()
self._display.Select = self.HandleSelection self._display.Select = self.HandleSelection
def load_file(self, f): def load_file(self, f, setting=None):
s = settings() if setting is None:
s.set(s.USE_PYTHON_OPENCASCADE, True) setting = settings()
setting.set(setting.USE_PYTHON_OPENCASCADE, True)
v = self._display v = self._display
@@ -213,7 +214,7 @@ class application(QtGui.QApplication):
for p in f.by_type("IfcProduct"): for p in f.by_type("IfcProduct"):
if terminate[0]: break if terminate[0]: break
if p.Representation is None: continue if p.Representation is None: continue
shape = create_shape(s, p) shape = create_shape(setting, p)
ais = display_shape(shape, viewer_handle=v) ais = display_shape(shape, viewer_handle=v)
ais.GetObject().SetSelectionPriority(self.counter) ais.GetObject().SetSelectionPriority(self.counter)
self.ais_to_product[self.counter] = p self.ais_to_product[self.counter] = p
@@ -311,7 +312,7 @@ class application(QtGui.QApplication):
c.select(inst) c.select(inst)
return handler return handler
def __init__(self): def __init__(self, settings=None):
QtGui.QApplication.__init__(self, sys.argv) QtGui.QApplication.__init__(self, sys.argv)
self.window = application.window() self.window = application.window()
self.tree = application.decomposition_treeview() self.tree = application.decomposition_treeview()
@@ -341,6 +342,8 @@ class application(QtGui.QApplication):
t.instanceVisibilityChanged.connect(functools.partial(self.change_visibility, t)) t.instanceVisibilityChanged.connect(functools.partial(self.change_visibility, t))
t.instanceDisplayModeChanged.connect(functools.partial(self.change_displaymode, t)) t.instanceDisplayModeChanged.connect(functools.partial(self.change_displaymode, t))
self.settings = settings
def change_visibility(self, tree, inst, flag): def change_visibility(self, tree, inst, flag):
insts = tree.get_children(inst) insts = tree.get_children(inst)
self.canvas.toggle_visibility(insts, flag) self.canvas.toggle_visibility(insts, flag)
@@ -367,4 +370,4 @@ class application(QtGui.QApplication):
f = ifcopenshell.open(fn) f = ifcopenshell.open(fn)
self.files[fn] = f self.files[fn] = f
for c in self.components: for c in self.components:
c.load_file(f) c.load_file(f, setting=self.settings)