diff --git a/src/Mod/Path/CMakeLists.txt b/src/Mod/Path/CMakeLists.txt index 28bc67fa96..8e25c23ef3 100644 --- a/src/Mod/Path/CMakeLists.txt +++ b/src/Mod/Path/CMakeLists.txt @@ -97,8 +97,8 @@ SET(PathScripts_SRCS PathScripts/PathProfileFacesGui.py PathScripts/PathProfileGui.py PathScripts/PathProperty.py - PathScripts/PathPropertyContainer.py - PathScripts/PathPropertyContainerGui.py + PathScripts/PathPropertyBag.py + PathScripts/PathPropertyBagGui.py PathScripts/PathPropertyEditor.py PathScripts/PathSanity.py PathScripts/PathSelection.py diff --git a/src/Mod/Path/Gui/Resources/Path.qrc b/src/Mod/Path/Gui/Resources/Path.qrc index 8300eb42ee..832f74f868 100644 --- a/src/Mod/Path/Gui/Resources/Path.qrc +++ b/src/Mod/Path/Gui/Resources/Path.qrc @@ -121,7 +121,7 @@ panels/PageOpVcarveEdit.ui panels/PathEdit.ui panels/PointEdit.ui - panels/PropertyContainer.ui + panels/PropertyBag.ui panels/PropertyCreate.ui panels/SetupGlobal.ui panels/SetupOp.ui diff --git a/src/Mod/Path/Gui/Resources/panels/PropertyContainer.ui b/src/Mod/Path/Gui/Resources/panels/PropertyBag.ui similarity index 91% rename from src/Mod/Path/Gui/Resources/panels/PropertyContainer.ui rename to src/Mod/Path/Gui/Resources/panels/PropertyBag.ui index 21df9f9cb5..9240477417 100644 --- a/src/Mod/Path/Gui/Resources/panels/PropertyContainer.ui +++ b/src/Mod/Path/Gui/Resources/panels/PropertyBag.ui @@ -11,7 +11,7 @@ - Form + Property Bag @@ -52,6 +52,11 @@ + + table + add + remove + diff --git a/src/Mod/Path/Gui/Resources/panels/PropertyCreate.ui b/src/Mod/Path/Gui/Resources/panels/PropertyCreate.ui index 13fe6cd1e9..28f62a039d 100644 --- a/src/Mod/Path/Gui/Resources/panels/PropertyCreate.ui +++ b/src/Mod/Path/Gui/Resources/panels/PropertyCreate.ui @@ -11,7 +11,7 @@ - Dialog + Create Property @@ -22,7 +22,11 @@ - + + + <html><head/><body><p>Name of property.</p></body></html> + + @@ -48,6 +52,9 @@ + + <html><head/><body><p>The category group the property belongs to.</p></body></html> + true @@ -64,17 +71,24 @@ - + + + <html><head/><body><p>The type of the property value.</p></body></html> + + - Info + ToolTip + + <html><head/><body><p>ToolTip to be displayed when user hovers mouse over property.</p></body></html> + true @@ -97,6 +111,9 @@ + + <html><head/><body><p>Check if you want to create several properties in a batch.</p></body></html> + Create another @@ -122,6 +139,7 @@ propertyGroup propertyType propertyInfo + createAnother diff --git a/src/Mod/Path/InitGui.py b/src/Mod/Path/InitGui.py index 8e9fb87c94..20e35d8590 100644 --- a/src/Mod/Path/InitGui.py +++ b/src/Mod/Path/InitGui.py @@ -155,8 +155,8 @@ class PathWorkbench (Workbench): self.appendMenu([QtCore.QT_TRANSLATE_NOOP("Path", "&Path")], extracmdlist) self.appendMenu([QtCore.QT_TRANSLATE_NOOP("Path", "&Path")], ["Separator"]) - self.appendMenu([QtCore.QT_TRANSLATE_NOOP("Path", "&Path"), QtCore.QT_TRANSLATE_NOOP("Path", "Tools")], - ["Path_PropertyContainer"]) + self.appendMenu([QtCore.QT_TRANSLATE_NOOP("Path", "&Path"), QtCore.QT_TRANSLATE_NOOP("Path", "Utils")], + ["Path_PropertyBag"]) self.dressupcmds = dressupcmdlist diff --git a/src/Mod/Path/PathScripts/PathGuiInit.py b/src/Mod/Path/PathScripts/PathGuiInit.py index 29f285d59a..405dcb4fcc 100644 --- a/src/Mod/Path/PathScripts/PathGuiInit.py +++ b/src/Mod/Path/PathScripts/PathGuiInit.py @@ -66,7 +66,7 @@ def Startup(): # from PathScripts import PathProfileEdgesGui # from PathScripts import PathProfileFacesGui from PathScripts import PathProfileGui - from PathScripts import PathPropertyContainerGui + from PathScripts import PathPropertyBagGui from PathScripts import PathSanity from PathScripts import PathSetupSheetGui from PathScripts import PathSimpleCopy diff --git a/src/Mod/Path/PathScripts/PathPropertyContainer.py b/src/Mod/Path/PathScripts/PathPropertyBag.py similarity index 94% rename from src/Mod/Path/PathScripts/PathPropertyContainer.py rename to src/Mod/Path/PathScripts/PathPropertyBag.py index baf033dfba..01455fa5be 100644 --- a/src/Mod/Path/PathScripts/PathPropertyContainer.py +++ b/src/Mod/Path/PathScripts/PathPropertyBag.py @@ -57,14 +57,14 @@ def getPropertyType(o): if type(o) == FreeCAD.Units.Quantity: return SupportedPropertyType[o.Unit.Type] -class PropertyContainer(object): +class PropertyBag(object): '''Property container object.''' CustomPropertyGroups = 'CustomPropertyGroups' CustomPropertyGroupDefault = 'User' def __init__(self, obj): - obj.addProperty('App::PropertyStringList', self.CustomPropertyGroups, 'Base', PySide.QtCore.QT_TRANSLATE_NOOP('PathPropertyContainer', 'List of custom property groups')) + obj.addProperty('App::PropertyStringList', self.CustomPropertyGroups, 'Base', PySide.QtCore.QT_TRANSLATE_NOOP('PathPropertyBag', 'List of custom property groups')) self.onDocumentRestored(obj) def __getstate__(self): @@ -93,17 +93,17 @@ class PropertyContainer(object): self.obj.CustomPropertyGroups = groups self.obj.addProperty(propertyType, name, group, desc) -def Create(name = 'PropertyContainer'): +def Create(name = 'PropertyBag'): obj = FreeCAD.ActiveDocument.addObject('App::FeaturePython', name) - obj.Proxy = PropertyContainer(obj) + obj.Proxy = PropertyBag(obj) return obj -def IsPropertyContainer(obj): +def IsPropertyBag(obj): '''Returns True if the supplied object is a property container (or its Proxy).''' - if type(obj) == PropertyContainer: + if type(obj) == PropertyBag: return True if hasattr(obj, 'Proxy'): - return IsPropertyContainer(obj.Proxy) + return IsPropertyBag(obj.Proxy) return False diff --git a/src/Mod/Path/PathScripts/PathPropertyContainerGui.py b/src/Mod/Path/PathScripts/PathPropertyBagGui.py similarity index 90% rename from src/Mod/Path/PathScripts/PathPropertyContainerGui.py rename to src/Mod/Path/PathScripts/PathPropertyBagGui.py index d12ee29466..bebdfcfca6 100644 --- a/src/Mod/Path/PathScripts/PathPropertyContainerGui.py +++ b/src/Mod/Path/PathScripts/PathPropertyBagGui.py @@ -25,16 +25,16 @@ import FreeCADGui import PathScripts.PathGui as PathGui import PathScripts.PathIconViewProvider as PathIconViewProvider import PathScripts.PathLog as PathLog -import PathScripts.PathPropertyContainer as PathPropertyContainer +import PathScripts.PathPropertyBag as PathPropertyBag import PathScripts.PathPropertyEditor as PathPropertyEditor import PathScripts.PathUtil as PathUtil from PySide import QtCore, QtGui -__title__ = "Property Container Editor" +__title__ = "Property Bag Editor" __author__ = "sliptonic (Brad Collette)" __url__ = "https://www.freecadweb.org" -__doc__ = "Task panel editor for a PropertyContainer" +__doc__ = "Task panel editor for a PropertyBag" PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule()) #PathLog.trackModule(PathLog.thisModule()) @@ -44,7 +44,7 @@ def translate(context, text, disambig=None): return QtCore.QCoreApplication.translate(context, text, disambig) class ViewProvider(object): - '''ViewProvider for a PropertyContainer. + '''ViewProvider for a PropertyBag. It's sole job is to provide an icon and invoke the TaskPanel on edit.''' def __init__(self, vobj, name): @@ -135,9 +135,9 @@ class PropertyCreate(object): if grp: self.form.propertyGroup.setCurrentText(grp) - for t in sorted(PathPropertyContainer.SupportedPropertyType): + for t in sorted(PathPropertyBag.SupportedPropertyType): self.form.propertyType.addItem(t) - if PathPropertyContainer.SupportedPropertyType[t] == typ: + if PathPropertyBag.SupportedPropertyType[t] == typ: typ = t if typ: self.form.propertyType.setCurrentText(typ) @@ -163,7 +163,7 @@ class PropertyCreate(object): def propertyGroup(self): return self.form.propertyGroup.currentText().strip() def propertyType(self): - return PathPropertyContainer.SupportedPropertyType[self.form.propertyType.currentText()].strip() + return PathPropertyBag.SupportedPropertyType[self.form.propertyType.currentText()].strip() def propertyInfo(self): return self.form.propertyInfo.toPlainText().strip() def createAnother(self): @@ -183,12 +183,12 @@ class TaskPanel(object): def __init__(self, vobj): self.obj = vobj.Object self.props = sorted(self.obj.Proxy.getCustomProperties()) - self.form = FreeCADGui.PySideUic.loadUi(":panels/PropertyContainer.ui") + self.form = FreeCADGui.PySideUic.loadUi(":panels/PropertyBag.ui") # initialized later self.delegate = None self.model = None - FreeCAD.ActiveDocument.openTransaction(translate("PathPropertyContainer", "Edit PropertyContainer")) + FreeCAD.ActiveDocument.openTransaction(translate("PathPropertyBag", "Edit PropertyBag")) def updateData(self, topLeft, bottomRight): if topLeft.column() == self.ColumnDesc: @@ -291,24 +291,24 @@ class TaskPanel(object): self.model.removeRow(row) -def Create(name = 'PropertyContainer'): - '''Create(name = 'PropertyContainer') ... creates a new setup sheet''' - FreeCAD.ActiveDocument.openTransaction(translate("PathPropertyContainer", "Create PropertyContainer")) - pcont = PathPropertyContainer.Create(name) +def Create(name = 'PropertyBag'): + '''Create(name = 'PropertyBag') ... creates a new setup sheet''' + FreeCAD.ActiveDocument.openTransaction(translate("PathPropertyBag", "Create PropertyBag")) + pcont = PathPropertyBag.Create(name) PathIconViewProvider.Attach(pcont.ViewObject, name) return pcont -PathIconViewProvider.RegisterViewProvider('PropertyContainer', ViewProvider) +PathIconViewProvider.RegisterViewProvider('PropertyBag', ViewProvider) -class PropertyContainerCreateCommand(object): +class PropertyBagCreateCommand(object): '''Command to create a property container object''' def __init__(self): pass def GetResources(self): - return {'MenuText': translate('PathPropertyContainer', 'Property Container'), - 'ToolTip': translate('PathPropertyContainer', 'Creates an object which can be used to store reference properties.')} + return {'MenuText': translate('PathPropertyBag', 'Property Bag'), + 'ToolTip': translate('PathPropertyBag', 'Creates an object which can be used to store reference properties.')} def IsActive(self): return not FreeCAD.ActiveDocument is None @@ -329,6 +329,6 @@ class PropertyContainerCreateCommand(object): body.Group = group if FreeCAD.GuiUp: - FreeCADGui.addCommand('Path_PropertyContainer', PropertyContainerCreateCommand()) + FreeCADGui.addCommand('Path_PropertyBag', PropertyBagCreateCommand()) -FreeCAD.Console.PrintLog("Loading PathPropertyContainerGui ... done\n") +FreeCAD.Console.PrintLog("Loading PathPropertyBagGui ... done\n") diff --git a/src/Mod/Path/PathScripts/PathToolBit.py b/src/Mod/Path/PathScripts/PathToolBit.py index 5e63902c34..ea6b84c499 100644 --- a/src/Mod/Path/PathScripts/PathToolBit.py +++ b/src/Mod/Path/PathScripts/PathToolBit.py @@ -24,7 +24,7 @@ import FreeCAD import PathScripts.PathGeom as PathGeom import PathScripts.PathLog as PathLog import PathScripts.PathPreferences as PathPreferences -import PathScripts.PathPropertyContainer as PathPropertyContainer +import PathScripts.PathPropertyBag as PathPropertyBag import PathScripts.PathSetupSheetOpPrototype as PathSetupSheetOpPrototype import PathScripts.PathUtil as PathUtil import PySide @@ -303,9 +303,6 @@ class ToolBit(object): self._deleteBitSetup(obj) bitBody = obj.Document.copyObject(doc.RootObjects[0], True) - for o in doc.RootObjects[0].Group: - PathLog.debug("..... {}: {}".format(o.Label, o.Name)) - if docOpened: FreeCAD.setActiveDocument(activeDoc.Name) FreeCAD.closeDocument(doc.Name) @@ -315,23 +312,13 @@ class ToolBit(object): PathLog.debug("bitBody.{} ({}): {}".format(bitBody.Label, bitBody.Name, type(bitBody))) - def isAttributes(o): - if not hasattr(o, 'Proxy'): - PathLog.debug(" {} has not Proxy ({})".format(o.Label, type(o))) - return False - if not hasattr(o.Proxy, 'getCustomProperties'): - PathLog.debug(" {}.Proxy has no getCustomProperties ({})".format(o.Label, type(o.Proxy))) - return False - PathLog.debug(" {} <-".format(o.Label)) - return True - propNames = [] - for attributes in [o for o in bitBody.Group if isAttributes(o)]: + for attributes in [o for o in bitBody.Group if PathPropertyBag.IsPropertyBag(o)]: PathLog.debug("Process properties from {}".format(attributes.Label)) for prop in attributes.Proxy.getCustomProperties(): # extract property parameters and values so it can be copied src = attributes.getPropertyByName(prop) - typ = PathPropertyContainer.getPropertyType(src) + typ = PathPropertyBag.getPropertyType(src) grp = attributes.getGroupOfProperty(prop) dsc = attributes.getDocumentationOfProperty(prop)