Skip to content

Commit

Permalink
Introduced double-click to expand and load shape
Browse files Browse the repository at this point in the history
  • Loading branch information
yorikvanhavre committed Mar 7, 2024
1 parent 7c5f72c commit b382938
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions ifc_viewproviders.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ def expandChildren(self, obj=None):
"""Creates children of this object"""

import ifc_tools # lazy import
from PySide import QtCore, QtGui

if not obj:
obj = self.Object
Expand All @@ -168,6 +169,19 @@ def expandChildren(self, obj=None):
obj, ifcfile, recursive=False, assemblies=True, expand=False
)
obj.Document.recompute()

# expand the item in the tree view
mw = FreeCADGui.getMainWindow()
tree = mw.findChild(QtGui.QDockWidget,"Model")
model = tree.findChild(QtGui.QWidget,"Model")
splitter = model.findChild(QtGui.QSplitter)
tree = splitter.children()[1].children()[0]
it = tree.findItems(obj.Label, QtCore.Qt.MatchRecursive, 0)
if it:
it[0].setExpanded(True)
for i in range(it[0].childCount()):
it[0].child(i).setExpanded(True)

return nc

def collapseChildren(self):
Expand Down Expand Up @@ -317,6 +331,35 @@ def createGroup(self):
ifc_tools.aggregate(group, self.Object)
self.Object.Document.recompute()

def doubleClicked(self, vobj):
"""Expands everything that needs to be expanded"""

import ifc_geometry # lazy import
import ifc_tools # lazy import
import ifc_psets # lazy import
import ifc_materials # lazy import
import ifc_layers # lazy import

# generic data loading
ifc_geometry.add_geom_properties(vobj.Object)
ifc_psets.show_psets(vobj.Object)
ifc_materials.show_material(vobj.Object)
ifc_layers.add_layers(vobj.Object)

# expand children
if self.hasChildren(vobj.Object):
self.expandChildren()
return True

# load shape
element = ifc_tools.get_ifc_element(vobj.Object)
if ifc_tools.has_representation(element):
if vobj.Object.ShapeMode != "Shape":
vobj.Object.ShapeMode = "Shape"
vobj.Object.Document.recompute()
return True
return None


class ifc_vp_document(ifc_vp_object):
"""View provider for the IFC document object"""
Expand Down

0 comments on commit b382938

Please sign in to comment.