/[thuban]/branches/WIP-pyshapelib-bramz/Thuban/UI/identifyview.py
ViewVC logotype

Annotation of /branches/WIP-pyshapelib-bramz/Thuban/UI/identifyview.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 535 - (hide annotations)
Fri Mar 14 20:42:18 2003 UTC (22 years ago) by bh
Original Path: trunk/thuban/Thuban/UI/identifyview.py
File MIME type: text/x-python
File size: 2047 byte(s)
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 bh 535 # Copyright (c) 2001, 2002, 2003 by Intevation GmbH
2 bh 6 # 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 jan 374 from Thuban import _
14    
15 bh 29 from dialogs import NonModalDialog
16 bh 80 from controls import RecordListCtrl, RecordGridCtrl
17 bh 535 from messages import SHAPES_SELECTED
18 bh 6
19 bh 51 class IdentifyListCtrl(RecordListCtrl):
20 bh 6
21     def selected_shape(self, layer, shape):
22 bh 66 if layer is not None:
23     table = layer.shapetable
24     else:
25     table = None
26     self.fill_list(table, shape)
27 bh 6
28 bh 80 class IdentifyGridCtrl(RecordGridCtrl):
29 bh 6
30 bh 80 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 bh 29 class IdentifyView(NonModalDialog):
38 bh 6
39 bh 535 def __init__(self, parent, name):
40     NonModalDialog.__init__(self, parent, name, _("Identify Shape"))
41     parent.Subscribe(SHAPES_SELECTED, self.selected_shape)
42    
43 bh 6 panel = wxPanel(self, -1, style = wxWANTS_CHARS)
44 bh 80 #self.list = IdentifyListCtrl(panel, -1)
45     self.list = IdentifyGridCtrl(panel)
46 bh 6
47     sizer = wxBoxSizer(wxVERTICAL)
48     sizer.Add(self.list, 1, wx.wxEXPAND| wx.wxALL, 0)
49 bh 535
50 frank 422 self.SetSize(wxSize(300,200))
51 bh 6 panel.SetAutoLayout(true)
52     panel.SetSizer(sizer)
53     sizer.Fit(panel)
54 bh 29
55     def OnClose(self, event):
56 bh 535 self.parent.Unsubscribe(SHAPES_SELECTED, self.selected_shape)
57 bh 29 NonModalDialog.OnClose(self, event)
58    
59 bh 535 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 bh 29 self.list.selected_shape(layer, shape)

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26