21 |
from dialogs import NonModalNonParentDialog |
from dialogs import NonModalNonParentDialog |
22 |
|
|
23 |
from messages import SHAPES_SELECTED, SESSION_REPLACED |
from messages import SHAPES_SELECTED, SESSION_REPLACED |
24 |
from Thuban.Model.messages import TABLE_REMOVED |
from Thuban.Model.messages import TABLE_REMOVED, MAP_LAYERS_REMOVED |
25 |
|
|
26 |
wx_value_type_map = {FIELDTYPE_INT: wxGRID_VALUE_NUMBER, |
wx_value_type_map = {FIELDTYPE_INT: wxGRID_VALUE_NUMBER, |
27 |
FIELDTYPE_DOUBLE: wxGRID_VALUE_FLOAT, |
FIELDTYPE_DOUBLE: wxGRID_VALUE_FLOAT, |
496 |
self.layer = layer |
self.layer = layer |
497 |
self.grid.Subscribe(ROW_SELECTED, self.rows_selected) |
self.grid.Subscribe(ROW_SELECTED, self.rows_selected) |
498 |
self.parent.Subscribe(SHAPES_SELECTED, self.select_shapes) |
self.parent.Subscribe(SHAPES_SELECTED, self.select_shapes) |
499 |
|
self.map = self.parent.Map() |
500 |
|
self.map.Subscribe(MAP_LAYERS_REMOVED, self.map_layers_removed) |
501 |
|
|
502 |
# if there is already a selection present, update the grid |
# if there is already a selection present, update the grid |
503 |
# accordingly |
# accordingly |
520 |
"""Override the derived method to first unsubscribed.""" |
"""Override the derived method to first unsubscribed.""" |
521 |
self.parent.Unsubscribe(SHAPES_SELECTED, self.select_shapes) |
self.parent.Unsubscribe(SHAPES_SELECTED, self.select_shapes) |
522 |
self.grid.Unsubscribe(ROW_SELECTED, self.rows_selected) |
self.grid.Unsubscribe(ROW_SELECTED, self.rows_selected) |
523 |
|
self.map.Unsubscribe(MAP_LAYERS_REMOVED, self.map_layers_removed) |
524 |
QueryTableFrame.OnClose(self, event) |
QueryTableFrame.OnClose(self, event) |
525 |
|
|
526 |
def select_shapes(self, layer, shapes): |
def select_shapes(self, layer, shapes): |
537 |
""" |
""" |
538 |
if self.layer is not None: |
if self.layer is not None: |
539 |
self.parent.SelectShapes(self.layer, rows) |
self.parent.SelectShapes(self.layer, rows) |
540 |
|
|
541 |
|
def map_layers_removed(self, *args): |
542 |
|
"""Receiver for the map's MAP_LAYERS_REMOVED message |
543 |
|
|
544 |
|
Close the dialog if the layer whose table we're showing is not |
545 |
|
in the map anymore. |
546 |
|
""" |
547 |
|
if self.layer not in self.map.Layers(): |
548 |
|
self.Close() |
549 |
|
|