def outlineView_willDisplayCell_forTableColumn_item_(self, ov, cell, tc, item): _layer = Globals.unwrap(item) if _layer.isVisible(): _color = NSColor.blackColor() else: _color = NSColor.lightGrayColor() cell.setTextColor_(_color)
def ClearLayer_(self, sender): _layer = Globals.unwrap(sender.representedObject()) if not isinstance(_layer, PythonCAD.Generic.layer.Layer): raise TypeError, "Invalid Layer: " + ` _layer ` _layer.clear() _doc = self.document() _doc.getDA().setNeedsDisplay_(True)
def ClearLayer_(self, sender): _layer = Globals.unwrap(sender.representedObject()) if not isinstance(_layer, PythonCAD.Generic.layer.Layer): raise TypeError, "Invalid Layer: " + `_layer` _layer.clear() _doc = self.document() _doc.getDA().setNeedsDisplay_(True)
def outlineView_willDisplayCell_forTableColumn_item_( self, ov, cell, tc, item): _layer = Globals.unwrap(item) if _layer.isVisible(): _color = NSColor.blackColor() else: _color = NSColor.lightGrayColor() cell.setTextColor_(_color)
def outlineView_numberOfChildrenOfItem_(self, outlineView, item): """ NSOutlineViewDataSource method for layer view outlineView_numberOfChildrenOfItem_(outlineView, item) """ _item = Globals.unwrap(item) if _item is None: return 1 # Top Layer item is first item in layer list return len(_item.getSublayers())
def outlineView_isItemExpandable_(self, outlineView, item): """ NSOutlineViewDataSource method for layer view outlineView_isItemExpandable_(outlineView, item) """ _item = Globals.unwrap(item) if _item is None: return True # Top Layer item is always displayed return _item.hasSublayers()
def outlineViewSelectionDidChange_(self, note): _ov = note.object() _index = _ov.selectedRow() if -1 != _index: _item = _ov.itemAtRow_(_index) _layer = Globals.unwrap(_item) _doc = self.document() _doc.getImage().setActiveLayer(_layer) _doc.getDA().setNeedsDisplay_(True)
def outlineView_child_ofItem_(self, outlineView, itemIndex, item): """ NSOutlineViewDataSource method for layer view outlineView_child_ofItem_(outlineView, itemIndex, item) """ _item = Globals.unwrap(item) if _item is None: return Globals.wrap(self.document().getImage().getTopLayer()) _children = _item.getSublayers() return Globals.wrap(_children[itemIndex])
def outlineView_objectValueForTableColumn_byItem_(self, ov, tc, item): """ NSOutlineViewDataSource method for layer view outlineView_objectValueForTableColumn_byItem_(outlineView, tableColumn, item) """ if tc.identifier() != Globals.LayerColumnName: return None _item = Globals.unwrap(item) if _item is None: _item = self.document().getImage().getTopLayer() return _item.getName()
def outlineView_setObjectValue_forTableColumn_byItem_(self, ov, val, tc, item): """ NSOutlineViewDataSource method for layer view outlineView_setObjectValue_forTableColumn_byItem_(outlineView, value, tableColumn, item) """ if tc.identifier() != Globals.LayerColumnName: return _layer = Globals.unwrap(item) if not isinstance(_layer, PythonCAD.Generic.layer.Layer): raise TypeError, "Invalid active Layer: " + `_layer` _layer.setName(val)
def outlineView_setObjectValue_forTableColumn_byItem_( self, ov, val, tc, item): """ NSOutlineViewDataSource method for layer view outlineView_setObjectValue_forTableColumn_byItem_(outlineView, value, tableColumn, item) """ if tc.identifier() != Globals.LayerColumnName: return _layer = Globals.unwrap(item) if not isinstance(_layer, PythonCAD.Generic.layer.Layer): raise TypeError, "Invalid active Layer: " + ` _layer ` _layer.setName(val)
def ShowChildLayers_(self, sender): _layer = Globals.unwrap(sender.representedObject()) if not isinstance(_layer, PythonCAD.Generic.layer.Layer): raise TypeError, "Invalid Layer: " + `_layer` _children = _layer.getSublayers() while(len(_children)): _child = _children.pop() _child.show() if _child.hasSublayers(): _children = _children + _child.getSublayers() _doc = self.document() _doc.getDA().setNeedsDisplay_(True) _doc.getOutlineView().setNeedsDisplay_(True)
def ShowChildLayers_(self, sender): _layer = Globals.unwrap(sender.representedObject()) if not isinstance(_layer, PythonCAD.Generic.layer.Layer): raise TypeError, "Invalid Layer: " + ` _layer ` _children = _layer.getSublayers() while (len(_children)): _child = _children.pop() _child.show() if _child.hasSublayers(): _children = _children + _child.getSublayers() _doc = self.document() _doc.getDA().setNeedsDisplay_(True) _doc.getOutlineView().setNeedsDisplay_(True)
def menuForEvent_(self, event): _point = self.convertPoint_fromView_(event.locationInWindow(), None) _index = self.rowAtPoint_(_point) if -1 == _index: return None if not self.isRowSelected_(_index): self.selectRow_byExtendingSelection_(_index, False) _item = self.itemAtRow_(_index) _layer = Globals.unwrap(_item) if not isinstance(_layer, PythonCAD.Generic.layer.Layer): raise TypeError, "Invalid Layer: " + `_layer` _menu = NSMenu.alloc().initWithTitle_("Context") _menuItem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_("Rename", "EditLayerName:", "") _menu.addItem_(_menuItem) if _layer.isVisible(): _menuItem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_("Hide", "HideLayer:", "") else: _menuItem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_("Show", "ShowLayer:", "") _menuItem.setRepresentedObject_(_item) _menu.addItem_(_menuItem) _menuItem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_("Add Child Layer", "AddChildLayer:", "") _menuItem.setRepresentedObject_(_item) _menu.addItem_(_menuItem) _menuItem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_("Clear", "ClearLayer:", "") _menuItem.setRepresentedObject_(_item) _menu.addItem_(_menuItem) if _layer.hasChildren(): _menuItem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_("Hide Children", "HideChildLayers:", "") _menuItem.setRepresentedObject_(_item) _menu.insertItem_atIndex_(_menuItem, 3) _menuItem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_("Show Children", "ShowChildLayers:", "") _menuItem.setRepresentedObject_(_item) _menu.insertItem_atIndex_(_menuItem, 4) elif _layer.getParentLayer() is not None: _menuItem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_("Delete", "DeleteLayer:", "") _menuItem.setRepresentedObject_(_item) _menu.addItem_(_menuItem) return _menu
def DeleteLayer_(self, sender): _layer = Globals.unwrap(sender.representedObject()) if not isinstance(_layer, PythonCAD.Generic.layer.Layer): raise TypeError, "Invalid Layer: " + `_layer` _doc = self.document() _doc.delLayer(_layer)
def DeleteLayer_(self, sender): _layer = Globals.unwrap(sender.representedObject()) if not isinstance(_layer, PythonCAD.Generic.layer.Layer): raise TypeError, "Invalid Layer: " + ` _layer ` _doc = self.document() _doc.delLayer(_layer)