31 |
from Thuban.UI.dock import DockPanel |
from Thuban.UI.dock import DockPanel |
32 |
from Thuban.UI.scalebar import ScaleBar |
from Thuban.UI.scalebar import ScaleBar |
33 |
|
|
34 |
|
from Thuban.UI.menu import Menu |
35 |
|
|
36 |
from Thuban.Lib.connector import ConnectorError |
from Thuban.Lib.connector import ConnectorError |
37 |
|
|
38 |
ID_LEGEND_TOP = 4001 |
ID_LEGEND_TOP = 4001 |
44 |
ID_LEGEND_SHOWLAYER = 4007 |
ID_LEGEND_SHOWLAYER = 4007 |
45 |
ID_LEGEND_HIDELAYER = 4008 |
ID_LEGEND_HIDELAYER = 4008 |
46 |
|
|
|
ID_POPUP_TOP = 4501 |
|
|
ID_POPUP_UP = 4502 |
|
|
ID_POPUP_DOWN = 4503 |
|
|
ID_POPUP_BOTTOM = 4504 |
|
|
ID_POPUP_PROPS = 4506 |
|
|
ID_POPUP_VISIBLE = 4507 |
|
|
ID_POPUP_PROJ = 4509 |
|
|
|
|
47 |
BMP_SIZE_W = 15 |
BMP_SIZE_W = 15 |
48 |
BMP_SIZE_H = 15 |
BMP_SIZE_H = 15 |
49 |
|
|
55 |
HIDE_BMP = "hide_layer" |
HIDE_BMP = "hide_layer" |
56 |
PROPS_BMP = "layer_properties" |
PROPS_BMP = "layer_properties" |
57 |
|
|
|
|
|
58 |
class LegendPanel(DockPanel): |
class LegendPanel(DockPanel): |
59 |
|
|
60 |
def __init__(self, parent, map, mainWindow): |
def __init__(self, parent, map, mainWindow): |
109 |
EVT_TOOL(self, ID_LEGEND_SHOWLAYER, self._OnShowLayer) |
EVT_TOOL(self, ID_LEGEND_SHOWLAYER, self._OnShowLayer) |
110 |
EVT_TOOL(self, ID_LEGEND_HIDELAYER, self._OnHideLayer) |
EVT_TOOL(self, ID_LEGEND_HIDELAYER, self._OnHideLayer) |
111 |
|
|
|
EVT_MENU(self, ID_POPUP_PROPS, self._OnProperties) |
|
|
EVT_MENU(self, ID_POPUP_TOP, self._OnMoveTop) |
|
|
EVT_MENU(self, ID_POPUP_UP, self._OnMoveUp) |
|
|
EVT_MENU(self, ID_POPUP_DOWN, self._OnMoveDown) |
|
|
EVT_MENU(self, ID_POPUP_BOTTOM, self._OnMoveBottom) |
|
|
EVT_MENU(self, ID_POPUP_VISIBLE, self._OnToggleVisibility) |
|
|
EVT_MENU(self, ID_POPUP_PROJ, self._OnProjection) |
|
|
|
|
112 |
self.tree = LegendTree(self, ID_LEGEND_TREE, map, mainWindow) |
self.tree = LegendTree(self, ID_LEGEND_TREE, map, mainWindow) |
113 |
|
|
114 |
panelBox.Add(self.tree, 1, wxGROW, 0) |
panelBox.Add(self.tree, 1, wxGROW, 0) |
189 |
def _OnProjection(self, event): |
def _OnProjection(self, event): |
190 |
self.tree.LayerProjection() |
self.tree.LayerProjection() |
191 |
|
|
192 |
|
def _OnRemoveLayer(self, event): |
193 |
|
self.mainWindow.RemoveLayer() |
194 |
|
|
195 |
|
def _OnShowTable(self, event): |
196 |
|
self.mainWindow.LayerShowTable() |
197 |
|
|
198 |
def __EnableButtons(self, on): |
def __EnableButtons(self, on): |
199 |
self.toolBar.EnableTool(ID_LEGEND_TOP, on) |
self.toolBar.EnableTool(ID_LEGEND_TOP, on) |
200 |
self.toolBar.EnableTool(ID_LEGEND_RAISE, on) |
self.toolBar.EnableTool(ID_LEGEND_RAISE, on) |
249 |
|
|
250 |
self.SetMap(map) |
self.SetMap(map) |
251 |
|
|
252 |
|
def _OnRightClick(self, event): |
253 |
|
"""Select item and pop up a context menu""" |
254 |
|
|
255 |
|
# The pop up menu is related to the legend tree, so we have direct |
256 |
|
# access on the tree items. The events issued by the menu are handled |
257 |
|
# by the legend panel, since most of the handlers are already |
258 |
|
# implemented there. |
259 |
|
|
260 |
|
# Update item selection to the right click |
261 |
|
item = event.GetItem() |
262 |
|
self.SelectItem(item) |
263 |
|
|
264 |
|
# Define the menu |
265 |
|
popup_menu = Menu("PopUp", "", |
266 |
|
[ "layer_visibility", |
267 |
|
None, |
268 |
|
"layer_properties", |
269 |
|
"layer_projection", |
270 |
|
"layer_remove", |
271 |
|
"layer_show_table", |
272 |
|
None, |
273 |
|
"layer_to_top", |
274 |
|
"layer_raise", |
275 |
|
"layer_lower", |
276 |
|
"layer_to_bottom" |
277 |
|
]) |
278 |
|
|
279 |
|
# Display the menu |
280 |
|
pos = event.GetPoint() |
281 |
|
shift = self.ClientToScreen((0,0)) |
282 |
|
self.PopupMenu(self.mainWindow.build_menu(popup_menu), pos) |
283 |
|
|
284 |
def find_layer(self, layer): |
def find_layer(self, layer): |
285 |
"""Return the tree item for the layer""" |
"""Return the tree item for the layer""" |
286 |
root = self.GetRootItem() |
root = self.GetRootItem() |
448 |
event.Veto() |
event.Veto() |
449 |
self.preventExpandCollapse = False |
self.preventExpandCollapse = False |
450 |
|
|
|
def _OnRightClick(self, event): |
|
|
"""Select item and pop up a context menu""" |
|
|
|
|
|
# The pop up menu is related to the legend tree, so we have direct |
|
|
# access on the tree items. The events issued by the menu are handled |
|
|
# by the legend panel, since most of the handlers are already |
|
|
# implemented there. |
|
|
|
|
|
# Update item selection to the right click |
|
|
item = event.GetItem() |
|
|
self.SelectItem(item) |
|
|
|
|
|
# Create the menu |
|
|
menu = wxMenu("", 0) |
|
|
|
|
|
# The "Visible" item is a special ... |
|
|
menuitem = wxMenuItem(menu, ID_POPUP_VISIBLE, _("Visible"), |
|
|
"", wxITEM_CHECK) |
|
|
menu.AppendItem(menuitem) |
|
|
layer, group = self.GetSelectedHierarchy() |
|
|
menuitem.Check(layer.Visible()) |
|
|
|
|
|
menu.AppendSeparator() |
|
|
menu.Append(ID_POPUP_PROPS, _("Properties")) |
|
|
menu.Append(ID_POPUP_PROJ, _("Projection")) |
|
|
menu.AppendSeparator() |
|
|
menu.Append(ID_POPUP_TOP, _("Top")) |
|
|
menu.Append(ID_POPUP_UP, _("Up")) |
|
|
menu.Append(ID_POPUP_DOWN, _("Down")) |
|
|
menu.Append(ID_POPUP_BOTTOM, _("Bottom")) |
|
|
|
|
|
# Display the menu |
|
|
pos = event.GetPoint() |
|
|
shift = self.ClientToScreen((0,0)) |
|
|
self.PopupMenu(menu, pos) |
|
|
|
|
451 |
def _OnItemActivated(self, event): |
def _OnItemActivated(self, event): |
452 |
# The following looks strange but is need under Windows to |
# The following looks strange but is need under Windows to |
453 |
# raise the Properties on double-click: The tree control |
# raise the Properties on double-click: The tree control |