Changeset 2172
- Timestamp:
- 12/18/07 00:41:59 (8 months ago)
- Files:
-
- gaphas/trunk/gaphas/quadtree.py (modified) (2 diffs)
- gaphas/trunk/gaphas/tool.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
gaphas/trunk/gaphas/quadtree.py
r1926 r2172 2 2 Quadtree 3 3 ======== 4 From Wikipedia, the free encyclopedia5 4 6 5 A quadtree is a tree data structure in which each internal node has up to four … … 17 16 * The tree directory follows the spatial decomposition of the Quadtree 18 17 18 (From Wikipedia, the free encyclopedia) 19 19 """ 20 20 gaphas/trunk/gaphas/tool.py
r2137 r2172 190 190 191 191 def append(self, tool): 192 """ 193 Append a tool to the chain. Self is returned. 194 """ 192 195 self._tools.append(tool) 196 return self 193 197 194 198 def prepend(self, tool): 199 """ 200 Prepend a tool to the chain. Self is returned. 201 """ 195 202 self._tools.insert(0, tool) 203 return self 204 205 def swap(self, old_tool_class, new_tool): 206 """ 207 Swap one tool for another. Note that the first argument is the tool's 208 class (type), not an instance. 209 210 >>> chain = ToolChain().append(HoverTool()).append(RubberbandTool()) 211 >>> chain._tools # doctest: +ELLIPSIS 212 [<gaphas.tool.HoverTool object at 0x...>, <gaphas.tool.RubberbandTool object at 0x...>] 213 >>> chain.swap(HoverTool, ItemTool()) # doctest: +ELLIPSIS 214 <gaphas.tool.ToolChain object at 0x...> 215 216 Now the HoverTool has been substituted for the ItemTool: 217 218 >>> chain._tools # doctest: +ELLIPSIS 219 [<gaphas.tool.ItemTool object at 0x...>, <gaphas.tool.RubberbandTool object at 0x...>] 220 """ 221 tools = self._tools 222 for i in xrange(len(tools)): 223 if type(tools[i]) is old_tool_class: 224 if self._grabbed_tool is tools[i]: 225 raise ValueError, 'Can\'t swap tools since %s is grabbed' % tools[i] 226 tools[i] = new_tool 227 break 228 return self 196 229 197 230 def grab(self, tool): … … 289 322 if view.hovered_item: 290 323 if view.hovered_item in view.selected_items and \ 291 event.state & gtk.gdk.CONTROL_MASK:324 event.state & gtk.gdk.CONTROL_MASK: 292 325 view.focused_item = None 293 326 view.unselect_item(view.hovered_item) … … 652 685 The default tool chain build from HoverTool, ItemTool and HandleTool. 653 686 """ 654 chain = ToolChain() 655 chain.append(HoverTool())656 chain.append(HandleTool())657 chain.append(ItemTool())658 chain.append(TextEditTool())659 chain.append(RubberbandTool())687 chain = ToolChain().\ 688 append(HoverTool()).\ 689 append(HandleTool()).\ 690 append(ItemTool()).\ 691 append(TextEditTool()).\ 692 append(RubberbandTool()) 660 693 return chain 661 694
