1 |
# Copyright (c) 2001, 2002 by Intevation GmbH |
# Copyright (c) 2001, 2002, 2003 by Intevation GmbH |
2 |
# Authors: |
# Authors: |
3 |
# Bernhard Herzog <[email protected]> |
# Bernhard Herzog <[email protected]> |
4 |
# |
# |
15 |
FIELDTYPE_STRING |
FIELDTYPE_STRING |
16 |
import view |
import view |
17 |
from dialogs import NonModalDialog |
from dialogs import NonModalDialog |
18 |
from messages import SELECTED_SHAPE |
from messages import SHAPES_SELECTED |
19 |
|
|
20 |
wx_value_type_map = {FIELDTYPE_INT: wxGRID_VALUE_NUMBER, |
wx_value_type_map = {FIELDTYPE_INT: wxGRID_VALUE_NUMBER, |
21 |
FIELDTYPE_DOUBLE: wxGRID_VALUE_FLOAT, |
FIELDTYPE_DOUBLE: wxGRID_VALUE_FLOAT, |
159 |
|
|
160 |
"""Frame that displays a Thuban table in a grid view""" |
"""Frame that displays a Thuban table in a grid view""" |
161 |
|
|
162 |
def __init__(self, parent, interactor, name, title, table): |
def __init__(self, parent, name, title, table): |
163 |
NonModalDialog.__init__(self, parent, interactor, name, title) |
NonModalDialog.__init__(self, parent, name, title) |
164 |
self.table = table |
self.table = table |
165 |
self.grid = self.make_grid(self.table) |
self.grid = self.make_grid(self.table) |
166 |
|
|
181 |
selected object in a map. |
selected object in a map. |
182 |
""" |
""" |
183 |
|
|
184 |
def __init__(self, parent, interactor, name, title, layer, table): |
def __init__(self, parent, name, title, layer, table): |
185 |
TableFrame.__init__(self, parent, interactor, name, title, table) |
TableFrame.__init__(self, parent, name, title, table) |
186 |
self.layer = layer |
self.layer = layer |
187 |
self.grid.Subscribe(ROW_SELECTED, self.row_selected) |
self.grid.Subscribe(ROW_SELECTED, self.row_selected) |
188 |
self.interactor.Subscribe(SELECTED_SHAPE, self.select_shape) |
self.parent.Subscribe(SHAPES_SELECTED, self.select_shape) |
189 |
|
|
190 |
def make_grid(self, table): |
def make_grid(self, table): |
191 |
"""Override the derived method to return a LayerTableGrid. |
"""Override the derived method to return a LayerTableGrid. |
193 |
return LayerTableGrid(self, table) |
return LayerTableGrid(self, table) |
194 |
|
|
195 |
def OnClose(self, event): |
def OnClose(self, event): |
196 |
self.interactor.Unsubscribe(SELECTED_SHAPE, self.select_shape) |
self.parent.Unsubscribe(SHAPES_SELECTED, self.select_shape) |
197 |
TableFrame.OnClose(self, event) |
TableFrame.OnClose(self, event) |
198 |
|
|
199 |
def select_shape(self, layer, shape): |
def select_shape(self, layer, shapes): |
200 |
|
"""Subscribed to the SHAPES_SELECTED message. |
201 |
|
|
202 |
|
If shapes contains exactly one shape id, select that shape in |
203 |
|
the grid. Otherwise deselect all. |
204 |
|
""" |
205 |
|
if len(shapes): |
206 |
|
shape = shapes[0] |
207 |
|
else: |
208 |
|
shape = None |
209 |
self.grid.select_shape(layer, shape) |
self.grid.select_shape(layer, shape) |
210 |
|
|
211 |
def row_selected(self, row): |
def row_selected(self, row): |
212 |
if self.layer is not None: |
if self.layer is not None: |
213 |
self.interactor.SelectLayerAndShape(self.layer, row) |
self.parent.SelectShapes(self.layer, [row]) |