Parent Directory
|
Revision Log
Implement multiple selected shapes * Thuban/UI/selection.py: New module with a class to represent the selection. * Thuban/UI/messages.py (SELECTED_TABLE, SELECTED_MAP): Remove these unused messages * Thuban/UI/application.py (ThubanApplication.OnInit) (ThubanApplication.OnExit, ThubanApplication.SetSession): The interactor is gone now. (ThubanApplication.CreateMainWindow): There is no interactor anymore so we pass None as the interactor argument for now for compatibility. * Thuban/UI/view.py (MapCanvas.delegated_messages) (MapCanvas.Subscribe, MapCanvas.Unsubscribe): In Subscribe and Unsubscribe, delegate messages according to the delegated_messages class variable. (MapCanvas.__getattr__, MapCanvas.delegated_methods): Get some attributes from instance variables as described with the delegated_methods class variable. (MapCanvas.__init__): New instance variable selection holding the current selection (MapCanvas.do_redraw): Deal with multiple selected shapes. Simply pass them on to the renderer (MapCanvas.SetMap): Clear the selection when a different map is selected. (MapCanvas.shape_selected): Simple force a complete redraw. The selection class now takes care of only issueing SHAPES_SELECTED messages when the set of selected shapes actually does change. (MapCanvas.SelectShapeAt): The selection is now managed in self.selection * Thuban/UI/mainwindow.py (MainWindow.delegated_messages) (MainWindow.Subscribe, MainWindow.Unsubscribe): In Subscribe and Unsubscribe, delegate messages according to the delegated_messages class variable. (MainWindow.delegated_methods, MainWindow.__getattr__): Get some attributes from instance variables as described with the delegated_methods class variable. (MainWindow.__init__): The interactor as ivar is gone. The parameter is still there for compatibility. The selection messages now come from the canvas. (MainWindow.current_layer, MainWindow.has_selected_layer): Delegate to the the canvas. (MainWindow.LayerShowTable, MainWindow.Classify) (MainWindow.identify_view_on_demand): The dialogs don't need the interactor parameter anymore. * Thuban/UI/tableview.py (TableFrame.__init__) (LayerTableFrame.__init__, LayerTableFrame.OnClose) (LayerTableFrame.row_selected): The interactor is gone. It's job from the dialog's point of view is now done by the mainwindow, i.e. the parent. Subscribe to SHAPES_SELECTED instead of SELECTED_SHAPE * Thuban/UI/dialogs.py (NonModalDialog.__init__): The interactor is gone. It's job from the dialog's point of view is now done by the mainwindow, i.e. the parent. * Thuban/UI/classifier.py (Classifier.__init__): The interactor is gone. It's job from the dialog's point of view is now done by the mainwindow, i.e. the parent. * Thuban/UI/tree.py (SessionTreeView.__init__): The interactor is gone. It's job from the dialog's point of view is now done by the mainwindow, i.e. the parent. (SessionTreeCtrl.__init__): New parameter mainwindow which is stored as self.mainwindow. The mainwindow is need so that the tree can still subscribe to the selection messages. (SessionTreeCtrl.__init__, SessionTreeCtrl.unsubscribe_all) (SessionTreeCtrl.update_tree, SessionTreeCtrl.OnSelChanged): The selection is now accessible through the mainwindow. Subscribe to SHAPES_SELECTED instead of SELECTED_SHAPE * Thuban/UI/identifyview.py (IdentifyView.__init__): Use the SHAPES_SELECTED message now. (IdentifyView.selected_shape): Now subscribed to SHAPES_SELECTED, so deal with multiple shapes (IdentifyView.__init__, IdentifyView.OnClose): The interactor is gone. It's job from the dialog's point of view is now done by the mainwindow, i.e. the parent. * Thuban/UI/renderer.py (ScreenRenderer.RenderMap): Rename the selected_shape parameter and ivar to selected_shapes. It's now a list of shape ids. (MapRenderer.draw_label_layer): Deal with multiple selected shapes. Rearrange the code a bit so that the setup and shape type distinctions are only executed once.
1 | # Copyright (c) 2001, 2002, 2003 by Intevation GmbH |
2 | # Authors: |
3 | # Bernhard Herzog <[email protected]> |
4 | # |
5 | # This program is free software under the GPL (>=v2) |
6 | # Read the file COPYING coming with Thuban for details. |
7 | |
8 | __version__ = "$Revision$" |
9 | |
10 | from wxPython.wx import * |
11 | from wxPython.grid import * |
12 | |
13 | from Thuban import _ |
14 | |
15 | from dialogs import NonModalDialog |
16 | from controls import RecordListCtrl, RecordGridCtrl |
17 | from messages import SHAPES_SELECTED |
18 | |
19 | class IdentifyListCtrl(RecordListCtrl): |
20 | |
21 | def selected_shape(self, layer, shape): |
22 | if layer is not None: |
23 | table = layer.shapetable |
24 | else: |
25 | table = None |
26 | self.fill_list(table, shape) |
27 | |
28 | class IdentifyGridCtrl(RecordGridCtrl): |
29 | |
30 | def selected_shape(self, layer, shape): |
31 | if layer is not None: |
32 | table = layer.shapetable |
33 | else: |
34 | table = None |
35 | self.SetTableRecord(table, shape) |
36 | |
37 | class IdentifyView(NonModalDialog): |
38 | |
39 | def __init__(self, parent, name): |
40 | NonModalDialog.__init__(self, parent, name, _("Identify Shape")) |
41 | parent.Subscribe(SHAPES_SELECTED, self.selected_shape) |
42 | |
43 | panel = wxPanel(self, -1, style = wxWANTS_CHARS) |
44 | #self.list = IdentifyListCtrl(panel, -1) |
45 | self.list = IdentifyGridCtrl(panel) |
46 | |
47 | sizer = wxBoxSizer(wxVERTICAL) |
48 | sizer.Add(self.list, 1, wx.wxEXPAND| wx.wxALL, 0) |
49 | |
50 | self.SetSize(wxSize(300,200)) |
51 | panel.SetAutoLayout(true) |
52 | panel.SetSizer(sizer) |
53 | sizer.Fit(panel) |
54 | |
55 | def OnClose(self, event): |
56 | self.parent.Unsubscribe(SHAPES_SELECTED, self.selected_shape) |
57 | NonModalDialog.OnClose(self, event) |
58 | |
59 | def selected_shape(self, layer, shapes): |
60 | """Subscribed to the SHAPES_SELECTED messages. |
61 | |
62 | If exatly one shape is selected, pass that shape id to the |
63 | list's selected_shape method. Otherwise pass None as the shape |
64 | id. |
65 | """ |
66 | if len(shapes) == 1: |
67 | shape = shapes[0] |
68 | else: |
69 | shape = None |
70 | self.list.selected_shape(layer, shape) |
Name | Value |
---|---|
svn:eol-style | native |
svn:keywords | Author Date Id Revision |
[email protected] | ViewVC Help |
Powered by ViewVC 1.1.26 |