Renamed PropertyContainer to PropertyBag, PropertyContainer already is a thing.

This commit is contained in:
Markus Lampert
2020-12-22 11:31:43 -08:00
parent ad6d463e36
commit 6f4df10d4a
9 changed files with 63 additions and 53 deletions

View File

@@ -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

View File

@@ -121,7 +121,7 @@
<file>panels/PageOpVcarveEdit.ui</file>
<file>panels/PathEdit.ui</file>
<file>panels/PointEdit.ui</file>
<file>panels/PropertyContainer.ui</file>
<file>panels/PropertyBag.ui</file>
<file>panels/PropertyCreate.ui</file>
<file>panels/SetupGlobal.ui</file>
<file>panels/SetupOp.ui</file>

View File

@@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
<string>Property Bag</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
@@ -52,6 +52,11 @@
</item>
</layout>
</widget>
<tabstops>
<tabstop>table</tabstop>
<tabstop>add</tabstop>
<tabstop>remove</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
<string>Create Property</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
@@ -22,7 +22,11 @@
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="propertyName"/>
<widget class="QLineEdit" name="propertyName">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Name of property.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_4">
@@ -48,6 +52,9 @@
</property>
<item>
<widget class="QComboBox" name="propertyGroup">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The category group the property belongs to.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="editable">
<bool>true</bool>
</property>
@@ -64,17 +71,24 @@
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="propertyType"/>
<widget class="QComboBox" name="propertyType">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The type of the property value.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Info</string>
<string>ToolTip</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QTextEdit" name="propertyInfo">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;ToolTip to be displayed when user hovers mouse over property.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="tabChangesFocus">
<bool>true</bool>
</property>
@@ -97,6 +111,9 @@
</property>
<item>
<widget class="QCheckBox" name="createAnother">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Check if you want to create several properties in a batch.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Create another</string>
</property>
@@ -122,6 +139,7 @@
<tabstop>propertyGroup</tabstop>
<tabstop>propertyType</tabstop>
<tabstop>propertyInfo</tabstop>
<tabstop>createAnother</tabstop>
</tabstops>
<resources/>
<connections>

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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")

View File

@@ -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)