Compare commits

..

2 commits

Author SHA1 Message Date
Morgan 'ARR\!' Allen
b191a28a0a add save_keys functionality to BaseViewProvider (mixin?) and fixed icon loading 2025-07-10 12:11:46 -07:00
Morgan 'ARR\!' Allen
417a7065de small cleanup of README 2025-07-10 12:11:12 -07:00
3 changed files with 24 additions and 14 deletions

View file

@ -6,6 +6,7 @@ KiCAD 9 API Workbench
## What works
* Create board
* Bidirectional syncing
* Add Vias
* Add footprint pads
* Import footprint 3d models
@ -19,14 +20,11 @@ KiCAD 9 API Workbench
## In Progress / To be ported
### Tracks
Tracks can be loaded and drawn as simple `LineSegment` but more work is needed to draw properly 'widthed', and particularly whilte trying to eliminate overlapping lines.
Tracks can be loaded and drawn as simple `LineSegment` but more work is needed to draw properly 'widthed', and particularly while trying to eliminate overlapping lines.
### More Pad Shapes
Only rectangle get drawn right now, would like to figure out how to get Sketcher to do the heavy lifting
### Sync to KiCAD
In theory this code is mostly working but there seems to be an [issue in kicad-python](https://gitlab.com/kicad/code/kicad-python/-/issues/34)
## Plans
### Add more board features

View file

@ -17,9 +17,7 @@ class BaseObject:
self.sync_from()
def execute(self, feature):
# TODO this might not be the right move
print(self, 'BaseObject.execute')
#self.onDocumentRestored(feature)
pass
def get_api(self):
p = self.feature

View file

@ -9,6 +9,8 @@ class BaseViewProvider:
TYPE = None
EXTENSIONS = []
save_keys = []
def __init__(self, viewprovider):
self.viewprovider = viewprovider
self.feature = viewprovider.Object.Proxy.feature
@ -16,6 +18,7 @@ class BaseViewProvider:
self.icon = ''
if self.ICON:
print('>', settings.ICONPATH, self.ICON, os.path.join(settings.ICONPATH, self.ICON))
self.icon = os.path.join(settings.ICONPATH, self.ICON)
viewprovider.Proxy = self
@ -36,6 +39,7 @@ class BaseViewProvider:
Gui.Selection.clearSelection()
def getIcon(self):
print(self.icon)
return self.icon
def getDisplayModes(self,obj):
@ -46,11 +50,21 @@ class BaseViewProvider:
'''Return the name of the default display mode. It must be defined in getDisplayModes.'''
return 'Standard'
def __getstate__(self):
return {
'icon': self.icon
}
def dumps(self):
data = [ getattr(self, 'icon') ]
def __setstate__(self, props):
for prop in props:
setattr(self, prop, props[prop])
if len(self.save_keys) > 0:
for key in self.save_keys:
try:
data.append(getattr(self, key))
except Exception as e:
#XXX logging
print(e)
return tuple(data)
def loads(self, state):
self.icon = state[0]
for idx, key in enumerate(self.save_keys):
setattr(self, key, state[idx + 1])