parameters: (self)
docstring: Open the IFC editor dialog box.
  
          This is the method that runs as a callback when the Edit IFC properties
          button is selected by the user.
  
          Defines the editor's structure, fill it with data, add a callback for
          the buttons and other interactions, and show it.
docstring_summary: Open the IFC editor dialog box.
docstring_tokens: Open the IFC editor dialog box .
function: def editIfcProperties(self):
          """Open the IFC editor dialog box.
  
          This is the method that runs as a callback when the Edit IFC properties
          button is selected by the user.
  
          Defines the editor's structure, fill it with data, add a callback for
          the buttons and other interactions, and show it.
          """
  
          if hasattr(self,"ifcEditor"):
              if self.ifcEditor:
                  self.ifcEditor.hide()
              del self.ifcEditor
          if not self.obj:
              return
          if not hasattr(self.obj,"IfcProperties"):
              return
          if not isinstance(self.obj.IfcProperties,dict):
              return
          import Arch_rc, csv, os, ArchIFCSchema
  
          # get presets
          self.ptypes = list(ArchIFCSchema.IfcTypes.keys())
          self.plabels = [''.join(map(lambda x: x if x.islower() else " "+x, t[3:]))[1:] for t in self.ptypes]
          self.psetdefs = {}
          psetspath = os.path.join(FreeCAD.getResourceDir(),"Mod","Arch","Presets","pset_definitions.csv")
          if os.path.exists(psetspath):
              with open(psetspath, "r") as csvfile:
                  reader = csv.reader(csvfile, delimiter=';')
                  for row in reader:
                      self.psetdefs[row[0]] = row[1:]
          self.psetkeys = [''.join(map(lambda x: x if x.islower() else " "+x, t[5:]))[1:] for t in self.psetdefs.keys()]
          self.psetkeys.sort()
          self.ifcEditor = FreeCADGui.PySideUic.loadUi(":/ui/DialogIfcProperties.ui")
  
          # center the dialog over FreeCAD window
          mw = FreeCADGui.getMainWindow()
          self.ifcEditor.move(mw.frameGeometry().topLeft() + mw.rect().center() - self.ifcEditor.rect().center())
          self.ifcModel = QtGui.QStandardItemModel()
          self.ifcEditor.treeProperties.setModel(self.ifcModel)
          #self.ifcEditor.treeProperties.setDragDropMode(QtGui.QAbstractItemView.InternalMove)
          self.ifcEditor.treeProperties.setUniformRowHeights(True)
          self.ifcEditor.treeProperties.setItemDelegate(IfcEditorDelegate(dialog=self,ptypes=self.ptypes,plabels=self.plabels))
          self.ifcModel.setHorizontalHeaderLabels([QtGui.QApplication.translate("Arch", "Property", None),
                                                   QtGui.QApplication.translate("Arch", "Type", None),
                                                   QtGui.QApplication.translate("Arch", "Value", None)])
  
          # set combos
          self.ifcEditor.comboProperty.addItems([QtGui.QApplication.translate("Arch", "Add property...", None)]+self.plabels)
          self.ifcEditor.comboPset.addItems([QtGui.QApplication.translate("Arch", "Add property set...", None),
                                             QtGui.QApplication.translate("Arch", "New...", None)]+self.psetkeys)
  
          # set UUID
          if "IfcUID" in self.obj.IfcData:
              self.ifcEditor.labelUUID.setText(self.obj.IfcData["IfcUID"])
  
          # fill the tree
          psets = {}
          for pname,value in self.obj.IfcProperties.items():
              # properties in IfcProperties dict are stored as "key":"pset;;type;;value" or "key":"type;;value"
              value = value.split(";;")
              if len(value) == 3:
                  pset = value[0]
                  ptype = value[1]
                  pvalue = value[2]
              elif len(value) == 2:
                  pset = "Default property set"
                  ptype = value[0]
                  pvalue = value[1]
              else:
                  continue
              plabel = ptype
              if ptype in self.ptypes:
                  plabel = self.plabels[self.ptypes.index(ptype)]
              psets.setdefault(pset,[]).append([pname,plabel,pvalue])
          for pset,plists in psets.items():
              top = QtGui.QStandardItem(pset)
              top.setDragEnabled(False)
              top.setToolTip("PropertySet")
              self.ifcModel.appendRow([top,QtGui.QStandardItem(),QtGui.QStandardItem()])
              for plist in plists:
                  it1 = QtGui.QStandardItem(plist[0])
                  it1.setDropEnabled(False)
                  it2 = QtGui.QStandardItem(plist[1])
                  it2.setDropEnabled(False)
                  it3 = QtGui.QStandardItem(plist[2])
                  it3.setDropEnabled(False)
                  top.appendRow([it1,it2,it3])
              top.sortChildren(0)
  
          # span top levels
          idx = self.ifcModel.invisibleRootItem().index()
          for i in range(self.ifcModel.rowCount()):
              if self.ifcModel.item(i,0).hasChildren():
                  self.ifcEditor.treeProperties.setFirstColumnSpanned(i, idx, True)
          self.ifcEditor.treeProperties.expandAll()
  
          # Add callbacks
          QtCore.QObject.connect(self.ifcEditor.buttonBox, QtCore.SIGNAL("accepted()"), self.acceptIfcProperties)
          QtCore.QObject.connect(self.ifcEditor.comboProperty, QtCore.SIGNAL("currentIndexChanged(int)"), self.addIfcProperty)
          QtCore.QObject.connect(self.ifcEditor.comboPset, QtCore.SIGNAL("currentIndexChanged(int)"), self.addIfcPset)
          QtCore.QObject.connect(self.ifcEditor.buttonDelete, QtCore.SIGNAL("clicked()"), self.removeIfcProperty)
          self.ifcEditor.treeProperties.setSortingEnabled(True)
  
          # set checkboxes
          if "FlagForceBrep" in self.obj.IfcData:
              self.ifcEditor.checkBrep.setChecked(self.obj.IfcData["FlagForceBrep"] == "True")
          if "FlagParametric" in self.obj.IfcData:
              self.ifcEditor.checkParametric.setChecked(self.obj.IfcData["FlagParametric"] == "True")
          self.ifcEditor.show()
function_tokens: def editIfcProperties ( self ) : if hasattr ( self , "ifcEditor" ) : if self . ifcEditor : self . ifcEditor . hide ( ) del self . ifcEditor if not self . obj : return if not hasattr ( self . obj , "IfcProperties" ) : return if not isinstance ( self . obj . IfcProperties , dict ) : return import Arch_rc , csv , os , ArchIFCSchema # get presets self . ptypes = list ( ArchIFCSchema . IfcTypes . keys ( ) ) self . plabels = [ '' . join ( map ( lambda x : x if x . islower ( ) else " " + x , t [ 3 : ] ) ) [ 1 : ] for t in self . ptypes ] self . psetdefs = { } psetspath = os . path . join ( FreeCAD . getResourceDir ( ) , "Mod" , "Arch" , "Presets" , "pset_definitions.csv" ) if os . path . exists ( psetspath ) : with open ( psetspath , "r" ) as csvfile : reader = csv . reader ( csvfile , delimiter = ';' ) for row in reader : self . psetdefs [ row [ 0 ] ] = row [ 1 : ] self . psetkeys = [ '' . join ( map ( lambda x : x if x . islower ( ) else " " + x , t [ 5 : ] ) ) [ 1 : ] for t in self . psetdefs . keys ( ) ] self . psetkeys . sort ( ) self . ifcEditor = FreeCADGui . PySideUic . loadUi ( ":/ui/DialogIfcProperties.ui" ) # center the dialog over FreeCAD window mw = FreeCADGui . getMainWindow ( ) self . ifcEditor . move ( mw . frameGeometry ( ) . topLeft ( ) + mw . rect ( ) . center ( ) - self . ifcEditor . rect ( ) . center ( ) ) self . ifcModel = QtGui . QStandardItemModel ( ) self . ifcEditor . treeProperties . setModel ( self . ifcModel ) #self.ifcEditor.treeProperties.setDragDropMode(QtGui.QAbstractItemView.InternalMove) self . ifcEditor . treeProperties . setUniformRowHeights ( True ) self . ifcEditor . treeProperties . setItemDelegate ( IfcEditorDelegate ( dialog = self , ptypes = self . ptypes , plabels = self . plabels ) ) self . ifcModel . setHorizontalHeaderLabels ( [ QtGui . QApplication . translate ( "Arch" , "Property" , None ) , QtGui . QApplication . translate ( "Arch" , "Type" , None ) , QtGui . QApplication . translate ( "Arch" , "Value" , None ) ] ) # set combos self . ifcEditor . comboProperty . addItems ( [ QtGui . QApplication . translate ( "Arch" , "Add property..." , None ) ] + self . plabels ) self . ifcEditor . comboPset . addItems ( [ QtGui . QApplication . translate ( "Arch" , "Add property set..." , None ) , QtGui . QApplication . translate ( "Arch" , "New..." , None ) ] + self . psetkeys ) # set UUID if "IfcUID" in self . obj . IfcData : self . ifcEditor . labelUUID . setText ( self . obj . IfcData [ "IfcUID" ] ) # fill the tree psets = { } for pname , value in self . obj . IfcProperties . items ( ) : # properties in IfcProperties dict are stored as "key":"pset;;type;;value" or "key":"type;;value" value = value . split ( ";;" ) if len ( value ) == 3 : pset = value [ 0 ] ptype = value [ 1 ] pvalue = value [ 2 ] elif len ( value ) == 2 : pset = "Default property set" ptype = value [ 0 ] pvalue = value [ 1 ] else : continue plabel = ptype if ptype in self . ptypes : plabel = self . plabels [ self . ptypes . index ( ptype ) ] psets . setdefault ( pset , [ ] ) . append ( [ pname , plabel , pvalue ] ) for pset , plists in psets . items ( ) : top = QtGui . QStandardItem ( pset ) top . setDragEnabled ( False ) top . setToolTip ( "PropertySet" ) self . ifcModel . appendRow ( [ top , QtGui . QStandardItem ( ) , QtGui . QStandardItem ( ) ] ) for plist in plists : it1 = QtGui . QStandardItem ( plist [ 0 ] ) it1 . setDropEnabled ( False ) it2 = QtGui . QStandardItem ( plist [ 1 ] ) it2 . setDropEnabled ( False ) it3 = QtGui . QStandardItem ( plist [ 2 ] ) it3 . setDropEnabled ( False ) top . appendRow ( [ it1 , it2 , it3 ] ) top . sortChildren ( 0 ) # span top levels idx = self . ifcModel . invisibleRootItem ( ) . index ( ) for i in range ( self . ifcModel . rowCount ( ) ) : if self . ifcModel . item ( i , 0 ) . hasChildren ( ) : self . ifcEditor . treeProperties . setFirstColumnSpanned ( i , idx , True ) self . ifcEditor . treeProperties . expandAll ( ) # Add callbacks QtCore . QObject . connect ( self . ifcEditor . buttonBox , QtCore . SIGNAL ( "accepted()" ) , self . acceptIfcProperties ) QtCore . QObject . connect ( self . ifcEditor . comboProperty , QtCore . SIGNAL ( "currentIndexChanged(int)" ) , self . addIfcProperty ) QtCore . QObject . connect ( self . ifcEditor . comboPset , QtCore . SIGNAL ( "currentIndexChanged(int)" ) , self . addIfcPset ) QtCore . QObject . connect ( self . ifcEditor . buttonDelete , QtCore . SIGNAL ( "clicked()" ) , self . removeIfcProperty ) self . ifcEditor . treeProperties . setSortingEnabled ( True ) # set checkboxes if "FlagForceBrep" in self . obj . IfcData : self . ifcEditor . checkBrep . setChecked ( self . obj . IfcData [ "FlagForceBrep" ] == "True" ) if "FlagParametric" in self . obj . IfcData : self . ifcEditor . checkParametric . setChecked ( self . obj . IfcData [ "FlagParametric" ] == "True" ) self . ifcEditor . show ( )