1 |
bh |
535 |
# Copyright (c) 2001, 2002, 2003 by Intevation GmbH |
2 |
bh |
6 |
# Authors: |
3 |
|
|
# Bernhard Herzog <[email protected]> |
4 |
frank |
1138 |
# Frank Koormann <[email protected]> |
5 |
bh |
6 |
# |
6 |
|
|
# This program is free software under the GPL (>=v2) |
7 |
|
|
# Read the file COPYING coming with Thuban for details. |
8 |
|
|
|
9 |
|
|
__version__ = "$Revision$" |
10 |
|
|
|
11 |
|
|
from wxPython.wx import * |
12 |
|
|
from wxPython.grid import * |
13 |
|
|
|
14 |
jan |
374 |
from Thuban import _ |
15 |
|
|
|
16 |
bh |
29 |
from dialogs import NonModalDialog |
17 |
bh |
80 |
from controls import RecordListCtrl, RecordGridCtrl |
18 |
bh |
535 |
from messages import SHAPES_SELECTED |
19 |
bh |
6 |
|
20 |
bh |
51 |
class IdentifyListCtrl(RecordListCtrl): |
21 |
bh |
6 |
|
22 |
|
|
def selected_shape(self, layer, shape): |
23 |
bh |
66 |
if layer is not None: |
24 |
bh |
1219 |
table = layer.ShapeStore().Table() |
25 |
bh |
66 |
else: |
26 |
|
|
table = None |
27 |
|
|
self.fill_list(table, shape) |
28 |
bh |
6 |
|
29 |
bh |
80 |
class IdentifyGridCtrl(RecordGridCtrl): |
30 |
bh |
6 |
|
31 |
bh |
80 |
def selected_shape(self, layer, shape): |
32 |
|
|
if layer is not None: |
33 |
bh |
1219 |
table = layer.ShapeStore().Table() |
34 |
bh |
80 |
else: |
35 |
|
|
table = None |
36 |
|
|
self.SetTableRecord(table, shape) |
37 |
|
|
|
38 |
bh |
29 |
class IdentifyView(NonModalDialog): |
39 |
bh |
6 |
|
40 |
jan |
1706 |
ID_STOP = 100 |
41 |
|
|
|
42 |
bh |
535 |
def __init__(self, parent, name): |
43 |
|
|
NonModalDialog.__init__(self, parent, name, _("Identify Shape")) |
44 |
|
|
parent.Subscribe(SHAPES_SELECTED, self.selected_shape) |
45 |
|
|
|
46 |
frank |
1138 |
top_box = wxBoxSizer(wxVERTICAL) |
47 |
frank |
1131 |
#self.list = IdentifyGridCtrl(panel) |
48 |
frank |
1138 |
self.list = IdentifyListCtrl(self, -1) |
49 |
|
|
self.list.SetSize(wxSize(305,200)) |
50 |
|
|
top_box.Add(self.list, 1, wxEXPAND|wxALL, 4) |
51 |
bh |
6 |
|
52 |
frank |
1138 |
box = wxBoxSizer(wxHORIZONTAL) |
53 |
jan |
1706 |
box.Add(wxButton(self, wxID_CLOSE, _("Close Window")), 0, wxALL, 4) |
54 |
|
|
box.Add(wxButton(self, self.ID_STOP, _("Stop Identify Mode")), |
55 |
|
|
0, wxALL, 4) |
56 |
frank |
1138 |
top_box.Add(box, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 4) |
57 |
bh |
535 |
|
58 |
frank |
1138 |
EVT_BUTTON(self, wxID_CLOSE, self.OnClose) |
59 |
jan |
1706 |
EVT_BUTTON(self, self.ID_STOP, self.OnStop) |
60 |
bh |
29 |
|
61 |
frank |
1138 |
self.SetAutoLayout(True) |
62 |
|
|
self.SetSizer(top_box) |
63 |
|
|
top_box.Fit(self) |
64 |
|
|
top_box.SetSizeHints(self) |
65 |
|
|
|
66 |
bh |
1194 |
# Make sure to reflect the current selection. |
67 |
|
|
self.selected_shape(parent.SelectedLayer(), parent.SelectedShapes()) |
68 |
|
|
|
69 |
bh |
29 |
def OnClose(self, event): |
70 |
bh |
535 |
self.parent.Unsubscribe(SHAPES_SELECTED, self.selected_shape) |
71 |
bh |
29 |
NonModalDialog.OnClose(self, event) |
72 |
|
|
|
73 |
jan |
1706 |
def OnStop(self, event): |
74 |
|
|
self.parent.Unsubscribe(SHAPES_SELECTED, self.selected_shape) |
75 |
|
|
self.parent.canvas.SelectTool(None) |
76 |
|
|
NonModalDialog.OnClose(self, event) |
77 |
|
|
|
78 |
bh |
535 |
def selected_shape(self, layer, shapes): |
79 |
|
|
"""Subscribed to the SHAPES_SELECTED messages. |
80 |
|
|
|
81 |
|
|
If exatly one shape is selected, pass that shape id to the |
82 |
|
|
list's selected_shape method. Otherwise pass None as the shape |
83 |
|
|
id. |
84 |
|
|
""" |
85 |
|
|
if len(shapes) == 1: |
86 |
|
|
shape = shapes[0] |
87 |
|
|
else: |
88 |
|
|
shape = None |
89 |
bh |
29 |
self.list.selected_shape(layer, shape) |