2 |
# Authors: |
# Authors: |
3 |
# Jan-Oliver Wagner <[email protected]> |
# Jan-Oliver Wagner <[email protected]> |
4 |
# Bernhard Herzog <[email protected]> |
# Bernhard Herzog <[email protected]> |
5 |
|
# Frank Koormann <[email protected]> |
6 |
# |
# |
7 |
# This program is free software under the GPL (>=v2) |
# This program is free software under the GPL (>=v2) |
8 |
# Read the file COPYING coming with Thuban for details. |
# Read the file COPYING coming with Thuban for details. |
13 |
|
|
14 |
__version__ = "$Revision$" |
__version__ = "$Revision$" |
15 |
|
|
16 |
__ThubanVersion__ = "0.2" #"$THUBAN_0_2$" |
__ThubanVersion__ = "0.8" #"$THUBAN_0_2$" |
17 |
#__BuildDate__ = "$Date$" |
#__BuildDate__ = "$Date$" |
18 |
|
|
19 |
import os |
import os |
20 |
|
import copy |
21 |
|
|
22 |
from wxPython.wx import * |
from wxPython.wx import * |
23 |
|
from wxPython.wx import __version__ as wxPython_version |
24 |
|
|
25 |
import Thuban |
import Thuban |
26 |
|
import Thuban.version |
27 |
|
|
28 |
from Thuban import _ |
from Thuban import _ |
29 |
from Thuban.Model.session import create_empty_session |
from Thuban.Model.session import create_empty_session |
30 |
from Thuban.Model.layer import Layer |
from Thuban.Model.layer import Layer, RasterLayer |
31 |
from Thuban.Model.color import Color |
from Thuban.Model.postgisdb import PostGISShapeStore |
32 |
from Thuban.Model.proj import Projection |
# XXX: replace this by |
33 |
|
# from wxPython.lib.dialogs import wxMultipleChoiceDialog |
34 |
|
# when Thuban does not support wxPython 2.4.0 any more. |
35 |
|
from Thuban.UI.multiplechoicedialog import wxMultipleChoiceDialog |
36 |
|
|
37 |
import view |
import view |
38 |
import tree |
import tree |
|
import proj4dialog |
|
39 |
import tableview, identifyview |
import tableview, identifyview |
40 |
import classifier |
from Thuban.UI.classifier import Classifier |
41 |
|
import legend |
42 |
from menu import Menu |
from menu import Menu |
43 |
|
|
44 |
from context import Context |
from context import Context |
45 |
from command import registry, Command, ToolCommand |
from command import registry, Command, ToolCommand |
46 |
from messages import LAYER_SELECTED, SHAPES_SELECTED, VIEW_POSITION |
from messages import LAYER_SELECTED, SHAPES_SELECTED, VIEW_POSITION, \ |
47 |
|
MAP_REPLACED |
48 |
|
from about import About |
49 |
|
|
50 |
|
from Thuban.UI.dock import DockFrame |
51 |
|
from Thuban.UI.join import JoinDialog |
52 |
|
from Thuban.UI.dbdialog import DBFrame, ChooseDBTableDialog |
53 |
|
import resource |
54 |
|
import Thuban.Model.resource |
55 |
|
|
56 |
# the directory where the toolbar icons are stored |
import projdialog |
|
bitmapdir = os.path.join(Thuban.__path__[0], os.pardir, "Resources", "Bitmaps") |
|
|
bitmapext = ".xpm" |
|
57 |
|
|
58 |
|
|
59 |
class MainWindow(wxFrame): |
class MainWindow(DockFrame): |
60 |
|
|
61 |
# Some messages that can be subscribed/unsubscribed directly through |
# Some messages that can be subscribed/unsubscribed directly through |
62 |
# the MapCanvas come in fact from other objects. This is a map to |
# the MapCanvas come in fact from other objects. This is a map to |
64 |
# actually come from. This delegation is implemented in the |
# actually come from. This delegation is implemented in the |
65 |
# Subscribe and unsubscribed methods |
# Subscribe and unsubscribed methods |
66 |
delegated_messages = {LAYER_SELECTED: "canvas", |
delegated_messages = {LAYER_SELECTED: "canvas", |
67 |
SHAPES_SELECTED: "canvas"} |
SHAPES_SELECTED: "canvas", |
68 |
|
MAP_REPLACED: "canvas"} |
69 |
|
|
70 |
# Methods delegated to some instance variables. The delegation is |
# Methods delegated to some instance variables. The delegation is |
71 |
# implemented in the __getattr__ method. |
# implemented in the __getattr__ method. |
72 |
delegated_methods = {"SelectLayer": "canvas", |
delegated_methods = {"SelectLayer": "canvas", |
73 |
"SelectShapes": "canvas", |
"SelectShapes": "canvas", |
74 |
|
"SelectedLayer": "canvas", |
75 |
|
"SelectedShapes": "canvas", |
76 |
} |
} |
77 |
|
|
78 |
def __init__(self, parent, ID, title, application, interactor, |
def __init__(self, parent, ID, title, application, interactor, |
79 |
initial_message = None, size = wxSize(-1, -1)): |
initial_message = None, size = wxSize(-1, -1)): |
80 |
wxFrame.__init__(self, parent, ID, title, wxDefaultPosition, size) |
DockFrame.__init__(self, parent, ID, title, wxDefaultPosition, size) |
81 |
|
#wxFrame.__init__(self, parent, ID, title, wxDefaultPosition, size) |
82 |
|
|
83 |
self.application = application |
self.application = application |
84 |
|
|
98 |
# call Realize to make sure that the tools appear. |
# call Realize to make sure that the tools appear. |
99 |
toolbar.Realize() |
toolbar.Realize() |
100 |
|
|
101 |
|
|
102 |
# Create the map canvas |
# Create the map canvas |
103 |
canvas = view.MapCanvas(self, -1) |
canvas = view.MapCanvas(self, -1) |
104 |
canvas.Subscribe(VIEW_POSITION, self.view_position_changed) |
canvas.Subscribe(VIEW_POSITION, self.view_position_changed) |
105 |
canvas.Subscribe(SHAPES_SELECTED, self.identify_view_on_demand) |
canvas.Subscribe(SHAPES_SELECTED, self.identify_view_on_demand) |
106 |
self.canvas = canvas |
self.canvas = canvas |
107 |
|
|
108 |
|
self.SetMainWindow(self.canvas) |
109 |
|
|
110 |
|
self.SetAutoLayout(True) |
111 |
|
|
112 |
self.init_dialogs() |
self.init_dialogs() |
113 |
|
|
114 |
|
self.ShowLegend() |
115 |
|
|
116 |
EVT_CLOSE(self, self.OnClose) |
EVT_CLOSE(self, self.OnClose) |
117 |
|
|
118 |
def Subscribe(self, channel, *args): |
def Subscribe(self, channel, *args): |
255 |
command = registry.Command(name) |
command = registry.Command(name) |
256 |
if command is not None: |
if command is not None: |
257 |
ID = self.get_id(name) |
ID = self.get_id(name) |
258 |
filename = os.path.join(bitmapdir, command.Icon()) + bitmapext |
bitmap = resource.GetBitmapResource(command.Icon(), |
259 |
bitmap = wxBitmap(filename, wxBITMAP_TYPE_XPM) |
wxBITMAP_TYPE_XPM) |
260 |
toolbar.AddTool(ID, bitmap, |
toolbar.AddTool(ID, bitmap, |
261 |
shortHelpString = command.HelpText(), |
shortHelpString = command.HelpText(), |
262 |
isToggle = command.IsCheckCommand()) |
isToggle = command.IsCheckCommand()) |
366 |
result = wxID_NO |
result = wxID_NO |
367 |
return result |
return result |
368 |
|
|
|
def prepare_new_session(self): |
|
|
for d in self.dialogs.values(): |
|
|
if not isinstance(d, tree.SessionTreeView): |
|
|
d.Close() |
|
|
|
|
369 |
def NewSession(self): |
def NewSession(self): |
370 |
self.save_modified_session() |
if self.save_modified_session() != wxID_CANCEL: |
371 |
self.prepare_new_session() |
self.application.SetSession(create_empty_session()) |
|
self.application.SetSession(create_empty_session()) |
|
372 |
|
|
373 |
def OpenSession(self): |
def OpenSession(self): |
374 |
self.save_modified_session() |
if self.save_modified_session() != wxID_CANCEL: |
375 |
dlg = wxFileDialog(self, _("Open Session"), ".", "", "*.thuban", wxOPEN) |
dlg = wxFileDialog(self, _("Open Session"), ".", "", |
376 |
if dlg.ShowModal() == wxID_OK: |
"Thuban Session File (*.thuban)|*.thuban", |
377 |
self.prepare_new_session() |
wxOPEN) |
378 |
self.application.OpenSession(dlg.GetPath()) |
if dlg.ShowModal() == wxID_OK: |
379 |
dlg.Destroy() |
self.application.OpenSession(dlg.GetPath()) |
380 |
|
dlg.Destroy() |
381 |
|
|
382 |
def SaveSession(self): |
def SaveSession(self): |
383 |
if self.application.session.filename == None: |
if self.application.session.filename == None: |
387 |
|
|
388 |
def SaveSessionAs(self): |
def SaveSessionAs(self): |
389 |
dlg = wxFileDialog(self, _("Save Session As"), ".", "", |
dlg = wxFileDialog(self, _("Save Session As"), ".", "", |
390 |
"*.thuban", wxOPEN) |
"Thuban Session File (*.thuban)|*.thuban", |
391 |
|
wxSAVE|wxOVERWRITE_PROMPT) |
392 |
if dlg.ShowModal() == wxID_OK: |
if dlg.ShowModal() == wxID_OK: |
393 |
self.application.session.SetFilename(dlg.GetPath()) |
self.application.session.SetFilename(dlg.GetPath()) |
394 |
self.application.SaveSession() |
self.application.SaveSession() |
395 |
dlg.Destroy() |
dlg.Destroy() |
396 |
|
|
397 |
def Exit(self): |
def Exit(self): |
398 |
self.Close(false) |
self.Close(False) |
399 |
|
|
400 |
def OnClose(self, event): |
def OnClose(self, event): |
401 |
result = self.save_modified_session(can_veto = event.CanVeto()) |
result = self.save_modified_session(can_veto = event.CanVeto()) |
406 |
# wx's destroy event, but that isn't implemented for wxGTK |
# wx's destroy event, but that isn't implemented for wxGTK |
407 |
# yet. |
# yet. |
408 |
self.canvas.Unsubscribe(VIEW_POSITION, self.view_position_changed) |
self.canvas.Unsubscribe(VIEW_POSITION, self.view_position_changed) |
409 |
|
DockFrame.OnClose(self, event) |
410 |
|
for dlg in self.dialogs.values(): |
411 |
|
dlg.Destroy() |
412 |
|
self.canvas.Destroy() |
413 |
self.Destroy() |
self.Destroy() |
414 |
|
|
415 |
def SetMap(self, map): |
def SetMap(self, map): |
416 |
self.canvas.SetMap(map) |
self.canvas.SetMap(map) |
417 |
|
self.__SetTitle(map.Title()) |
418 |
|
|
419 |
|
dialog = self.FindRegisteredDock("legend") |
420 |
|
if dialog is not None: |
421 |
|
dialog.GetPanel().SetMap(self.Map()) |
422 |
|
|
423 |
def Map(self): |
def Map(self): |
424 |
"""Return the map displayed by this mainwindow""" |
"""Return the map displayed by this mainwindow""" |
425 |
|
|
426 |
return self.canvas.Map() |
return self.canvas.Map() |
427 |
|
|
428 |
def ShowSessionTree(self): |
def ToggleSessionTree(self): |
429 |
|
"""If the session tree is shown close it otherwise create a new tree""" |
430 |
name = "session_tree" |
name = "session_tree" |
431 |
dialog = self.get_open_dialog(name) |
dialog = self.get_open_dialog(name) |
432 |
if dialog is None: |
if dialog is None: |
434 |
self.add_dialog(name, dialog) |
self.add_dialog(name, dialog) |
435 |
dialog.Show(True) |
dialog.Show(True) |
436 |
else: |
else: |
437 |
# FIXME: bring dialog to front here |
dialog.Close() |
|
pass |
|
438 |
|
|
439 |
|
def SessionTreeShown(self): |
440 |
|
"""Return true iff the session tree is currently shown""" |
441 |
|
return self.get_open_dialog("session_tree") is not None |
442 |
|
|
443 |
def About(self): |
def About(self): |
444 |
self.RunMessageBox(_("About"), |
dlg = About(self) |
445 |
_("Thuban v%s\n" |
dlg.ShowModal() |
446 |
#"Build Date: %s\n" |
dlg.Destroy() |
447 |
"\n" |
|
448 |
"Thuban is a program for\n" |
def DatabaseManagement(self): |
449 |
"exploring geographic data.\n" |
name = "dbmanagement" |
450 |
"Copyright (C) 2001-2003 Intevation GmbH.\n" |
dialog = self.get_open_dialog(name) |
451 |
"Thuban is licensed under the GNU GPL" |
if dialog is None: |
452 |
% __ThubanVersion__), #__BuildDate__)), |
map = self.canvas.Map() |
453 |
wxOK | wxICON_INFORMATION) |
dialog = DBFrame(self, name, self.application.Session()) |
454 |
|
self.add_dialog(name, dialog) |
455 |
|
dialog.Show() |
456 |
|
dialog.Raise() |
457 |
|
|
458 |
def AddLayer(self): |
def AddLayer(self): |
459 |
dlg = wxFileDialog(self, _("Select a data file"), ".", "", "*.*", |
dlg = wxFileDialog(self, _("Select one or more data files"), ".", "", |
460 |
|
_("Shapefiles (*.shp)") + "|*.shp|" + |
461 |
|
_("All Files (*.*)") + "|*.*", |
462 |
|
wxOPEN | wxMULTIPLE) |
463 |
|
if dlg.ShowModal() == wxID_OK: |
464 |
|
filenames = dlg.GetPaths() |
465 |
|
for filename in filenames: |
466 |
|
title = os.path.splitext(os.path.basename(filename))[0] |
467 |
|
map = self.canvas.Map() |
468 |
|
has_layers = map.HasLayers() |
469 |
|
try: |
470 |
|
store = self.application.Session().OpenShapefile(filename) |
471 |
|
except IOError: |
472 |
|
# the layer couldn't be opened |
473 |
|
self.RunMessageBox(_("Add Layer"), |
474 |
|
_("Can't open the file '%s'.")%filename) |
475 |
|
else: |
476 |
|
layer = Layer(title, store) |
477 |
|
map.AddLayer(layer) |
478 |
|
if not has_layers: |
479 |
|
# if we're adding a layer to an empty map, fit the |
480 |
|
# new map to the window |
481 |
|
self.canvas.FitMapToWindow() |
482 |
|
dlg.Destroy() |
483 |
|
|
484 |
|
def AddRasterLayer(self): |
485 |
|
dlg = wxFileDialog(self, _("Select an image file"), ".", "", "*.*", |
486 |
wxOPEN) |
wxOPEN) |
487 |
if dlg.ShowModal() == wxID_OK: |
if dlg.ShowModal() == wxID_OK: |
488 |
filename = dlg.GetPath() |
filename = dlg.GetPath() |
489 |
title = os.path.splitext(os.path.basename(filename))[0] |
title = os.path.splitext(os.path.basename(filename))[0] |
|
layer = Layer(title, filename) |
|
490 |
map = self.canvas.Map() |
map = self.canvas.Map() |
491 |
has_layers = map.HasLayers() |
has_layers = map.HasLayers() |
492 |
try: |
try: |
493 |
map.AddLayer(layer) |
layer = RasterLayer(title, filename) |
494 |
except IOError: |
except IOError: |
495 |
# the layer couldn't be opened |
# the layer couldn't be opened |
496 |
self.RunMessageBox(_("Add Layer"), |
self.RunMessageBox(_("Add Image Layer"), |
497 |
_("Can't open the file '%s'.") % filename) |
_("Can't open the file '%s'.") % filename) |
498 |
else: |
else: |
499 |
|
map.AddLayer(layer) |
500 |
if not has_layers: |
if not has_layers: |
501 |
# if we're adding a layer to an empty map, fit the |
# if we're adding a layer to an empty map, fit the |
502 |
# new map to the window |
# new map to the window |
503 |
self.canvas.FitMapToWindow() |
self.canvas.FitMapToWindow() |
504 |
dlg.Destroy() |
dlg.Destroy() |
505 |
|
|
506 |
|
def AddDBLayer(self): |
507 |
|
"""Add a layer read from a database""" |
508 |
|
session = self.application.Session() |
509 |
|
dlg = ChooseDBTableDialog(self.application.Session(), self,-1, "") |
510 |
|
|
511 |
|
if dlg.ShowModal() == wxID_OK: |
512 |
|
dbconn, dbtable = dlg.GetTable() |
513 |
|
try: |
514 |
|
title = str(dbtable) |
515 |
|
|
516 |
|
# Chose the correct Interface for the database type |
517 |
|
store = PostGISShapeStore(dbconn, dbtable) |
518 |
|
session.AddShapeStore(store) |
519 |
|
layer = Layer(title, store) |
520 |
|
except: |
521 |
|
# Some error occured while initializing the layer |
522 |
|
self.RunMessageBox(_("Add Layer from database"), |
523 |
|
_("Can't open the database table '%s'") |
524 |
|
% dbtable) |
525 |
|
|
526 |
|
map = self.canvas.Map() |
527 |
|
|
528 |
|
has_layers = map.HasLayers() |
529 |
|
map.AddLayer(layer) |
530 |
|
if not has_layers: |
531 |
|
self.canvas.FitMapToWindow() |
532 |
|
|
533 |
|
dlg.Destroy() |
534 |
|
|
535 |
def RemoveLayer(self): |
def RemoveLayer(self): |
536 |
layer = self.current_layer() |
layer = self.current_layer() |
537 |
if layer is not None: |
if layer is not None: |
540 |
def CanRemoveLayer(self): |
def CanRemoveLayer(self): |
541 |
"""Return true if the currently selected layer can be deleted. |
"""Return true if the currently selected layer can be deleted. |
542 |
|
|
543 |
If no layer is selected return false. |
If no layer is selected return False. |
544 |
|
|
545 |
The return value of this method determines whether the remove |
The return value of this method determines whether the remove |
546 |
layer command is sensitive in menu. |
layer command is sensitive in menu. |
548 |
layer = self.current_layer() |
layer = self.current_layer() |
549 |
if layer is not None: |
if layer is not None: |
550 |
return self.canvas.Map().CanRemoveLayer(layer) |
return self.canvas.Map().CanRemoveLayer(layer) |
551 |
return 0 |
return False |
552 |
|
|
553 |
def RaiseLayer(self): |
def RaiseLayer(self): |
554 |
layer = self.current_layer() |
layer = self.current_layer() |
571 |
"""Return true if a layer is currently selected""" |
"""Return true if a layer is currently selected""" |
572 |
return self.canvas.HasSelectedLayer() |
return self.canvas.HasSelectedLayer() |
573 |
|
|
574 |
def choose_color(self): |
def has_selected_shapes(self): |
575 |
"""Run the color selection dialog and return the selected color. |
"""Return true if a shape is currently selected""" |
576 |
|
return self.canvas.HasSelectedShapes() |
577 |
|
|
578 |
If the user cancels, return None. |
def HideLayer(self): |
|
""" |
|
|
dlg = wxColourDialog(self) |
|
|
color = None |
|
|
if dlg.ShowModal() == wxID_OK: |
|
|
data = dlg.GetColourData() |
|
|
wxc = data.GetColour() |
|
|
color = Color(wxc.Red() / 255.0, |
|
|
wxc.Green() / 255.0, |
|
|
wxc.Blue() / 255.0) |
|
|
dlg.Destroy() |
|
|
return color |
|
|
|
|
|
def LayerFillColor(self): |
|
|
layer = self.current_layer() |
|
|
if layer is not None: |
|
|
color = self.choose_color() |
|
|
if color is not None: |
|
|
layer.GetClassification().SetDefaultFill(color) |
|
|
|
|
|
def LayerTransparentFill(self): |
|
579 |
layer = self.current_layer() |
layer = self.current_layer() |
580 |
if layer is not None: |
if layer is not None: |
581 |
layer.GetClassification().SetDefaultFill(Color.None) |
layer.SetVisible(0) |
582 |
|
|
583 |
def LayerOutlineColor(self): |
def ShowLayer(self): |
584 |
layer = self.current_layer() |
layer = self.current_layer() |
585 |
if layer is not None: |
if layer is not None: |
586 |
color = self.choose_color() |
layer.SetVisible(1) |
|
if color is not None: |
|
|
layer.GetClassification().SetDefaultLineColor(color) |
|
587 |
|
|
588 |
def LayerNoOutline(self): |
def DuplicateLayer(self): |
589 |
|
"""Ceate a new layer above the selected layer with the same shapestore |
590 |
|
""" |
591 |
layer = self.current_layer() |
layer = self.current_layer() |
592 |
if layer is not None: |
if layer is not None and hasattr(layer, "ShapeStore"): |
593 |
layer.GetClassification().SetDefaultLineColor(Color.None) |
new_layer = Layer(_("Copy of `%s'") % layer.Title(), |
594 |
|
layer.ShapeStore(), |
595 |
|
projection = layer.GetProjection()) |
596 |
|
new_classification = copy.deepcopy(layer.GetClassification()) |
597 |
|
new_layer.SetClassification(new_classification) |
598 |
|
self.Map().AddLayer(new_layer) |
599 |
|
|
600 |
def HideLayer(self): |
def CanDuplicateLayer(self): |
601 |
|
"""Return whether the DuplicateLayer method can create a duplicate""" |
602 |
layer = self.current_layer() |
layer = self.current_layer() |
603 |
if layer is not None: |
return layer is not None and hasattr(layer, "ShapeStore") |
|
layer.SetVisible(0) |
|
|
|
|
|
def ShowLayer(self): |
|
|
layer = self.current_layer() |
|
|
if layer is not None: |
|
|
layer.SetVisible(1) |
|
604 |
|
|
605 |
def LayerShowTable(self): |
def LayerShowTable(self): |
606 |
layer = self.current_layer() |
layer = self.current_layer() |
607 |
if layer is not None: |
if layer is not None: |
608 |
table = layer.table |
table = layer.ShapeStore().Table() |
609 |
name = "table_view" + str(id(table)) |
name = "table_view" + str(id(table)) |
610 |
dialog = self.get_open_dialog(name) |
dialog = self.get_open_dialog(name) |
611 |
if dialog is None: |
if dialog is None: |
612 |
dialog = tableview.LayerTableFrame(self, name, |
dialog = tableview.LayerTableFrame(self, name, |
613 |
_("Table: %s") % layer.Title(), |
_("Layer Table: %s") % layer.Title(), |
614 |
layer, table) |
layer, table) |
615 |
self.add_dialog(name, dialog) |
self.add_dialog(name, dialog) |
616 |
dialog.Show(true) |
dialog.Show(True) |
617 |
else: |
else: |
618 |
# FIXME: bring dialog to front here |
# FIXME: bring dialog to front here |
619 |
pass |
pass |
620 |
|
|
621 |
def Projection(self): |
def MapProjection(self): |
622 |
map = self.canvas.Map() |
|
623 |
proj = map.projection |
name = "map_projection" |
624 |
if proj is None: |
dialog = self.get_open_dialog(name) |
625 |
proj4Dlg = proj4dialog.Proj4Dialog(NULL, None, map.BoundingBox()) |
|
626 |
else: |
if dialog is None: |
627 |
proj4Dlg = proj4dialog.Proj4Dialog(NULL, map.projection.params, |
map = self.canvas.Map() |
628 |
map.BoundingBox()) |
dialog = projdialog.ProjFrame(self, name, |
629 |
if proj4Dlg.ShowModal() == wxID_OK: |
_("Map Projection: %s") % map.Title(), map) |
630 |
params = proj4Dlg.GetParams() |
self.add_dialog(name, dialog) |
631 |
if params is not None: |
dialog.Show() |
632 |
proj = Projection(params) |
dialog.Raise() |
633 |
else: |
|
634 |
proj = None |
def LayerProjection(self): |
|
map.SetProjection(proj) |
|
|
proj4Dlg.Destroy() |
|
635 |
|
|
636 |
def Classify(self): |
layer = self.current_layer() |
637 |
|
|
638 |
|
name = "layer_projection" + str(id(layer)) |
639 |
|
dialog = self.get_open_dialog(name) |
640 |
|
|
641 |
|
if dialog is None: |
642 |
|
map = self.canvas.Map() |
643 |
|
dialog = projdialog.ProjFrame(self, name, |
644 |
|
_("Layer Projection: %s") % layer.Title(), layer) |
645 |
|
self.add_dialog(name, dialog) |
646 |
|
dialog.Show() |
647 |
|
dialog.Raise() |
648 |
|
|
649 |
|
def LayerEditProperties(self): |
650 |
|
|
651 |
# |
# |
652 |
# the menu option for this should only be available if there |
# the menu option for this should only be available if there |
655 |
# |
# |
656 |
|
|
657 |
layer = self.current_layer() |
layer = self.current_layer() |
658 |
name = "classifier" + str(id(layer)) |
self.OpenLayerProperties(layer) |
659 |
|
|
660 |
|
def OpenLayerProperties(self, layer, group = None): |
661 |
|
name = "layer_properties" + str(id(layer)) |
662 |
dialog = self.get_open_dialog(name) |
dialog = self.get_open_dialog(name) |
663 |
|
|
664 |
if dialog is None: |
if dialog is None: |
665 |
dialog = classifier.Classifier(self, name, self.current_layer()) |
dialog = Classifier(self, name, self.Map(), layer, group) |
666 |
self.add_dialog(name, dialog) |
self.add_dialog(name, dialog) |
667 |
dialog.Show() |
dialog.Show() |
668 |
|
dialog.Raise() |
669 |
|
|
670 |
|
def LayerJoinTable(self): |
671 |
|
layer = self.canvas.SelectedLayer() |
672 |
|
if layer is not None: |
673 |
|
dlg = JoinDialog(self, _("Join Layer with Table"), |
674 |
|
self.application.session, |
675 |
|
layer = layer) |
676 |
|
dlg.ShowModal() |
677 |
|
|
678 |
|
def LayerUnjoinTable(self): |
679 |
|
layer = self.canvas.SelectedLayer() |
680 |
|
if layer is not None: |
681 |
|
orig_store = layer.ShapeStore().OrigShapeStore() |
682 |
|
if orig_store: |
683 |
|
layer.SetShapeStore(orig_store) |
684 |
|
|
685 |
|
def ShowLegend(self): |
686 |
|
if not self.LegendShown(): |
687 |
|
self.ToggleLegend() |
688 |
|
|
689 |
|
def ToggleLegend(self): |
690 |
|
"""Show the legend if it's not shown otherwise hide it again""" |
691 |
|
name = "legend" |
692 |
|
dialog = self.FindRegisteredDock(name) |
693 |
|
|
694 |
|
if dialog is None: |
695 |
|
dialog = self.CreateDock(name, -1, _("Legend"), wxLAYOUT_LEFT) |
696 |
|
legend.LegendPanel(dialog, None, self) |
697 |
|
dialog.Dock() |
698 |
|
dialog.GetPanel().SetMap(self.Map()) |
699 |
|
dialog.Show() |
700 |
|
else: |
701 |
|
dialog.Show(not dialog.IsShown()) |
702 |
|
|
703 |
|
def LegendShown(self): |
704 |
|
"""Return true iff the legend is currently open""" |
705 |
|
dialog = self.FindRegisteredDock("legend") |
706 |
|
return dialog is not None and dialog.IsShown() |
707 |
|
|
708 |
|
def TableOpen(self): |
709 |
|
dlg = wxFileDialog(self, _("Open Table"), ".", "", |
710 |
|
_("DBF Files (*.dbf)") + "|*.dbf|" + |
711 |
|
#_("CSV Files (*.csv)") + "|*.csv|" + |
712 |
|
_("All Files (*.*)") + "|*.*", |
713 |
|
wxOPEN) |
714 |
|
if dlg.ShowModal() == wxID_OK: |
715 |
|
filename = dlg.GetPath() |
716 |
|
dlg.Destroy() |
717 |
|
try: |
718 |
|
table = self.application.session.OpenTableFile(filename) |
719 |
|
except IOError: |
720 |
|
# the layer couldn't be opened |
721 |
|
self.RunMessageBox(_("Open Table"), |
722 |
|
_("Can't open the file '%s'.") % filename) |
723 |
|
else: |
724 |
|
self.ShowTableView(table) |
725 |
|
|
726 |
|
def TableClose(self): |
727 |
|
tables = self.application.session.UnreferencedTables() |
728 |
|
|
729 |
|
lst = [(t.Title(), t) for t in tables] |
730 |
|
lst.sort() |
731 |
|
titles = [i[0] for i in lst] |
732 |
|
dlg = wxMultipleChoiceDialog(self, _("Pick the tables to close:"), |
733 |
|
_("Close Table"), titles, |
734 |
|
size = (400, 300), |
735 |
|
style = wxDEFAULT_DIALOG_STYLE | |
736 |
|
wxRESIZE_BORDER) |
737 |
|
if dlg.ShowModal() == wxID_OK: |
738 |
|
for i in dlg.GetValue(): |
739 |
|
self.application.session.RemoveTable(lst[i][1]) |
740 |
|
|
741 |
|
|
742 |
|
def TableShow(self): |
743 |
|
"""Offer a multi-selection dialog for tables to be displayed |
744 |
|
|
745 |
|
The windows for the selected tables are opened or brought to |
746 |
|
the front. |
747 |
|
""" |
748 |
|
tables = self.application.session.Tables() |
749 |
|
|
750 |
|
lst = [(t.Title(), t) for t in tables] |
751 |
|
lst.sort() |
752 |
|
titles = [i[0] for i in lst] |
753 |
|
dlg = wxMultipleChoiceDialog(self, _("Pick the table to show:"), |
754 |
|
_("Show Table"), titles, |
755 |
|
size = (400,300), |
756 |
|
style = wxDEFAULT_DIALOG_STYLE | |
757 |
|
wxRESIZE_BORDER) |
758 |
|
if (dlg.ShowModal() == wxID_OK): |
759 |
|
for i in dlg.GetValue(): |
760 |
|
# XXX: if the table belongs to a layer, open a |
761 |
|
# LayerTableFrame instead of QueryTableFrame |
762 |
|
self.ShowTableView(lst[i][1]) |
763 |
|
|
764 |
|
def TableJoin(self): |
765 |
|
dlg = JoinDialog(self, _("Join Tables"), self.application.session) |
766 |
|
dlg.ShowModal() |
767 |
|
|
768 |
|
def ShowTableView(self, table): |
769 |
|
"""Open a table view for the table and optionally""" |
770 |
|
name = "table_view%d" % id(table) |
771 |
|
dialog = self.get_open_dialog(name) |
772 |
|
if dialog is None: |
773 |
|
dialog = tableview.QueryTableFrame(self, name, |
774 |
|
_("Table: %s") % table.Title(), |
775 |
|
table) |
776 |
|
self.add_dialog(name, dialog) |
777 |
|
dialog.Show(True) |
778 |
|
dialog.Raise() |
779 |
|
|
780 |
|
def TableRename(self): |
781 |
|
"""Let the user rename a table""" |
782 |
|
|
783 |
|
# First, let the user select a table |
784 |
|
tables = self.application.session.Tables() |
785 |
|
lst = [(t.Title(), t) for t in tables] |
786 |
|
lst.sort() |
787 |
|
titles = [i[0] for i in lst] |
788 |
|
dlg = wxMultipleChoiceDialog(self, _("Pick the table to rename:"), |
789 |
|
_("Rename Table"), titles, |
790 |
|
size = (400,300), |
791 |
|
style = wxDEFAULT_DIALOG_STYLE | |
792 |
|
wxRESIZE_BORDER) |
793 |
|
if (dlg.ShowModal() == wxID_OK): |
794 |
|
to_rename = [lst[i][1] for i in dlg.GetValue()] |
795 |
|
dlg.Destroy() |
796 |
|
else: |
797 |
|
to_rename = [] |
798 |
|
|
799 |
|
# Second, let the user rename the layers |
800 |
|
for table in to_rename: |
801 |
|
dlg = wxTextEntryDialog(self, "Table Title: ", "Rename Table", |
802 |
|
table.Title()) |
803 |
|
try: |
804 |
|
if dlg.ShowModal() == wxID_OK: |
805 |
|
title = dlg.GetValue() |
806 |
|
if title != "": |
807 |
|
table.SetTitle(title) |
808 |
|
|
809 |
|
# Make sure the session is marked as modified. |
810 |
|
# FIXME: This should be handled automatically, |
811 |
|
# but that requires more changes to the tables |
812 |
|
# than I have time for currently. |
813 |
|
self.application.session.changed() |
814 |
|
finally: |
815 |
|
dlg.Destroy() |
816 |
|
|
817 |
|
|
818 |
def ZoomInTool(self): |
def ZoomInTool(self): |
819 |
self.canvas.ZoomInTool() |
self.canvas.ZoomInTool() |
834 |
def FullExtent(self): |
def FullExtent(self): |
835 |
self.canvas.FitMapToWindow() |
self.canvas.FitMapToWindow() |
836 |
|
|
837 |
|
def FullLayerExtent(self): |
838 |
|
self.canvas.FitLayerToWindow(self.current_layer()) |
839 |
|
|
840 |
|
def FullSelectionExtent(self): |
841 |
|
self.canvas.FitSelectedToWindow() |
842 |
|
|
843 |
|
def ExportMap(self): |
844 |
|
self.canvas.Export() |
845 |
|
|
846 |
def PrintMap(self): |
def PrintMap(self): |
847 |
self.canvas.Print() |
self.canvas.Print() |
848 |
|
|
849 |
|
def RenameMap(self): |
850 |
|
dlg = wxTextEntryDialog(self, "Map Title: ", "Rename Map", |
851 |
|
self.Map().Title()) |
852 |
|
if dlg.ShowModal() == wxID_OK: |
853 |
|
title = dlg.GetValue() |
854 |
|
if title != "": |
855 |
|
self.Map().SetTitle(title) |
856 |
|
self.__SetTitle(title) |
857 |
|
|
858 |
|
dlg.Destroy() |
859 |
|
|
860 |
|
def RenameLayer(self): |
861 |
|
"""Let the user rename the currently selected layer""" |
862 |
|
layer = self.current_layer() |
863 |
|
if layer is not None: |
864 |
|
dlg = wxTextEntryDialog(self, "Layer Title: ", "Rename Layer", |
865 |
|
layer.Title()) |
866 |
|
try: |
867 |
|
if dlg.ShowModal() == wxID_OK: |
868 |
|
title = dlg.GetValue() |
869 |
|
if title != "": |
870 |
|
layer.SetTitle(title) |
871 |
|
finally: |
872 |
|
dlg.Destroy() |
873 |
|
|
874 |
def identify_view_on_demand(self, layer, shapes): |
def identify_view_on_demand(self, layer, shapes): |
875 |
|
"""Subscribed to the canvas' SHAPES_SELECTED message |
876 |
|
|
877 |
|
If the current tool is the identify tool, at least one shape is |
878 |
|
selected and the identify dialog is not shown, show the dialog. |
879 |
|
""" |
880 |
|
# If the selection has become empty we don't need to do |
881 |
|
# anything. Otherwise it could happen that the dialog was popped |
882 |
|
# up when the selection became empty, e.g. when a new selection |
883 |
|
# is opened while the identify tool is active and dialog had |
884 |
|
# been closed |
885 |
|
if not shapes: |
886 |
|
return |
887 |
|
|
888 |
name = "identify_view" |
name = "identify_view" |
889 |
if self.canvas.CurrentTool() == "IdentifyTool": |
if self.canvas.CurrentTool() == "IdentifyTool": |
890 |
if not self.dialog_open(name): |
if not self.dialog_open(name): |
891 |
dialog = identifyview.IdentifyView(self, name) |
dialog = identifyview.IdentifyView(self, name) |
892 |
self.add_dialog(name, dialog) |
self.add_dialog(name, dialog) |
893 |
dialog.Show(true) |
dialog.Show(True) |
894 |
else: |
else: |
895 |
# FIXME: bring dialog to front? |
# FIXME: bring dialog to front? |
896 |
pass |
pass |
897 |
|
|
898 |
|
def __SetTitle(self, title): |
899 |
|
self.SetTitle("Thuban - " + title) |
900 |
|
|
901 |
# |
# |
902 |
# Define all the commands available in the main window |
# Define all the commands available in the main window |
903 |
# |
# |
909 |
apply(getattr(context.mainwindow, methodname), args) |
apply(getattr(context.mainwindow, methodname), args) |
910 |
|
|
911 |
def _method_command(name, title, method, helptext = "", |
def _method_command(name, title, method, helptext = "", |
912 |
icon = "", sensitive = None): |
icon = "", sensitive = None, checked = None): |
913 |
"""Add a command implemented by a method of the mainwindow object""" |
"""Add a command implemented by a method of the mainwindow object""" |
914 |
registry.Add(Command(name, title, call_method, args=(method,), |
registry.Add(Command(name, title, call_method, args=(method,), |
915 |
helptext = helptext, icon = icon, |
helptext = helptext, icon = icon, |
916 |
sensitive = sensitive)) |
sensitive = sensitive, checked = checked)) |
917 |
|
|
918 |
def make_check_current_tool(toolname): |
def make_check_current_tool(toolname): |
919 |
"""Return a function that tests if the currently active tool is toolname |
"""Return a function that tests if the currently active tool is toolname |
938 |
"""Return true if a layer is selected in the context""" |
"""Return true if a layer is selected in the context""" |
939 |
return context.mainwindow.has_selected_layer() |
return context.mainwindow.has_selected_layer() |
940 |
|
|
941 |
|
def _has_selected_shapes(context): |
942 |
|
"""Return true if a layer is selected in the context""" |
943 |
|
return context.mainwindow.has_selected_shapes() |
944 |
|
|
945 |
def _can_remove_layer(context): |
def _can_remove_layer(context): |
946 |
return context.mainwindow.CanRemoveLayer() |
return context.mainwindow.CanRemoveLayer() |
947 |
|
|
948 |
def _has_tree_window_shown(context): |
def _has_tree_window_shown(context): |
949 |
"""Return true if the tree window is shown""" |
"""Return true if the tree window is shown""" |
950 |
return context.mainwindow.get_open_dialog("session_tree") is None |
return context.mainwindow.SessionTreeShown() |
951 |
|
|
952 |
def _has_visible_map(context): |
def _has_visible_map(context): |
953 |
"""Return true iff theres a visible map in the mainwindow. |
"""Return true iff theres a visible map in the mainwindow. |
960 |
return 1 |
return 1 |
961 |
return 0 |
return 0 |
962 |
|
|
963 |
|
def _has_legend_shown(context): |
964 |
|
"""Return true if the legend window is shown""" |
965 |
|
return context.mainwindow.LegendShown() |
966 |
|
|
967 |
|
def _has_gdal_support(context): |
968 |
|
"""Return True if the GDAL is available""" |
969 |
|
return Thuban.Model.resource.has_gdal_support() |
970 |
|
|
971 |
|
def _has_dbconnections(context): |
972 |
|
"""Return whether the the session has database connections""" |
973 |
|
return context.session.HasDBConnections() |
974 |
|
|
975 |
# File menu |
# File menu |
976 |
_method_command("new_session", _("&New Session"), "NewSession") |
_method_command("new_session", _("&New Session"), "NewSession", |
977 |
_method_command("open_session", _("&Open Session"), "OpenSession") |
helptext = _("Start a new session")) |
978 |
_method_command("save_session", _("&Save Session"), "SaveSession") |
_method_command("open_session", _("&Open Session..."), "OpenSession", |
979 |
_method_command("save_session_as", _("Save Session &As"), "SaveSessionAs") |
helptext = _("Open a session file")) |
980 |
_method_command("show_session_tree", _("Show Session &Tree"), "ShowSessionTree", |
_method_command("save_session", _("&Save Session"), "SaveSession", |
981 |
sensitive = _has_tree_window_shown) |
helptext =_("Save this session to the file it was opened from")) |
982 |
_method_command("exit", _("E&xit"), "Exit") |
_method_command("save_session_as", _("Save Session &As..."), "SaveSessionAs", |
983 |
|
helptext = _("Save this session to a new file")) |
984 |
|
_method_command("toggle_session_tree", _("Session &Tree"), "ToggleSessionTree", |
985 |
|
checked = _has_tree_window_shown, |
986 |
|
helptext = _("Toggle on/off the session tree analysis window")) |
987 |
|
_method_command("toggle_legend", _("Legend"), "ToggleLegend", |
988 |
|
checked = _has_legend_shown, |
989 |
|
helptext = _("Toggle Legend on/off")) |
990 |
|
_method_command("database_management", _("&Database Connections..."), |
991 |
|
"DatabaseManagement") |
992 |
|
_method_command("exit", _("E&xit"), "Exit", |
993 |
|
helptext = _("Finish working with Thuban")) |
994 |
|
|
995 |
# Help menu |
# Help menu |
996 |
_method_command("help_about", _("&About"), "About") |
_method_command("help_about", _("&About..."), "About", |
997 |
|
helptext = _("Info about Thuban authors, version and modules")) |
998 |
|
|
999 |
|
|
1000 |
# Map menu |
# Map menu |
1001 |
_method_command("map_projection", _("Pro&jection"), "Projection") |
_method_command("map_projection", _("Pro&jection..."), "MapProjection", |
1002 |
|
helptext = _("Set or change the map projection")) |
1003 |
|
|
1004 |
_tool_command("map_zoom_in_tool", _("&Zoom in"), "ZoomInTool", "ZoomInTool", |
_tool_command("map_zoom_in_tool", _("&Zoom in"), "ZoomInTool", "ZoomInTool", |
1005 |
helptext = _("Switch to map-mode 'zoom-in'"), icon = "zoom_in", |
helptext = _("Switch to map-mode 'zoom-in'"), icon = "zoom_in", |
1018 |
helptext = _("Add/Remove labels"), icon = "label", |
helptext = _("Add/Remove labels"), icon = "label", |
1019 |
sensitive = _has_visible_map) |
sensitive = _has_visible_map) |
1020 |
_method_command("map_full_extent", _("&Full extent"), "FullExtent", |
_method_command("map_full_extent", _("&Full extent"), "FullExtent", |
1021 |
helptext = _("Full Extent"), icon = "fullextent", |
helptext = _("Zoom to the full map extent"), icon = "fullextent", |
1022 |
sensitive = _has_visible_map) |
sensitive = _has_visible_map) |
1023 |
|
_method_command("layer_full_extent", _("&Full layer extent"), "FullLayerExtent", |
1024 |
|
helptext = _("Zoom to the full layer extent"), |
1025 |
|
icon = "fulllayerextent", sensitive = _has_selected_layer) |
1026 |
|
_method_command("selected_full_extent", _("&Full selection extent"), |
1027 |
|
"FullSelectionExtent", |
1028 |
|
helptext = _("Zoom to the full selection extent"), |
1029 |
|
icon = "fullselextent", sensitive = _has_selected_shapes) |
1030 |
|
_method_command("map_export", _("E&xport"), "ExportMap", |
1031 |
|
helptext = _("Export the map to file")) |
1032 |
_method_command("map_print", _("Prin&t"), "PrintMap", |
_method_command("map_print", _("Prin&t"), "PrintMap", |
1033 |
helptext = _("Print the map")) |
helptext = _("Print the map")) |
1034 |
|
_method_command("map_rename", _("&Rename..."), "RenameMap", |
1035 |
# Layer menu |
helptext = _("Rename the map")) |
1036 |
_method_command("layer_add", _("&Add Layer"), "AddLayer", |
_method_command("layer_add", _("&Add Layer..."), "AddLayer", |
1037 |
helptext = _("Add a new layer to active map")) |
helptext = _("Add a new layer to the map")) |
1038 |
|
_method_command("rasterlayer_add", _("&Add Image Layer..."), "AddRasterLayer", |
1039 |
|
helptext = _("Add a new image layer to the map"), |
1040 |
|
sensitive = _has_gdal_support) |
1041 |
|
_method_command("layer_add_db", _("Add &Database Layer..."), "AddDBLayer", |
1042 |
|
helptext = _("Add a new database layer to active map"), |
1043 |
|
sensitive = _has_dbconnections) |
1044 |
_method_command("layer_remove", _("&Remove Layer"), "RemoveLayer", |
_method_command("layer_remove", _("&Remove Layer"), "RemoveLayer", |
1045 |
helptext = _("Remove selected layer(s)"), |
helptext = _("Remove selected layer"), |
1046 |
sensitive = _can_remove_layer) |
sensitive = _can_remove_layer) |
1047 |
_method_command("layer_fill_color", _("&Fill Color"), "LayerFillColor", |
|
1048 |
helptext = _("Set the fill color of selected layer(s)"), |
# Layer menu |
1049 |
sensitive = _has_selected_layer) |
_method_command("layer_projection", _("Pro&jection..."), "LayerProjection", |
1050 |
_method_command("layer_transparent_fill", _("&Transparent Fill"), |
sensitive = _has_selected_layer, |
1051 |
"LayerTransparentFill", |
helptext = _("Specify projection for selected layer")) |
1052 |
helptext = _("Do not fill the selected layer(s)"), |
_method_command("layer_duplicate", _("&Duplicate"), "DuplicateLayer", |
1053 |
sensitive = _has_selected_layer) |
helptext = _("Duplicate selected layer"), |
1054 |
_method_command("layer_outline_color", _("&Outline Color"), "LayerOutlineColor", |
sensitive = lambda context: context.mainwindow.CanDuplicateLayer()) |
1055 |
helptext = _("Set the outline color of selected layer(s)"), |
_method_command("layer_rename", _("Re&name ..."), "RenameLayer", |
1056 |
sensitive = _has_selected_layer) |
helptext = _("Rename selected layer"), |
|
_method_command("layer_no_outline", _("&No Outline"), "LayerNoOutline", |
|
|
helptext= _("Do not draw the outline of the selected layer(s)"), |
|
1057 |
sensitive = _has_selected_layer) |
sensitive = _has_selected_layer) |
1058 |
_method_command("layer_raise", _("&Raise"), "RaiseLayer", |
_method_command("layer_raise", _("&Raise"), "RaiseLayer", |
1059 |
helptext = _("Raise selected layer(s)"), |
helptext = _("Raise selected layer"), |
1060 |
sensitive = _has_selected_layer) |
sensitive = _has_selected_layer) |
1061 |
_method_command("layer_lower", _("&Lower"), "LowerLayer", |
_method_command("layer_lower", _("&Lower"), "LowerLayer", |
1062 |
helptext = _("Lower selected layer(s)"), |
helptext = _("Lower selected layer"), |
1063 |
sensitive = _has_selected_layer) |
sensitive = _has_selected_layer) |
1064 |
_method_command("layer_show", _("&Show"), "ShowLayer", |
_method_command("layer_show", _("&Show"), "ShowLayer", |
1065 |
helptext = _("Make selected layer(s) visible"), |
helptext = _("Make selected layer visible"), |
1066 |
sensitive = _has_selected_layer) |
sensitive = _has_selected_layer) |
1067 |
_method_command("layer_hide", _("&Hide"), "HideLayer", |
_method_command("layer_hide", _("&Hide"), "HideLayer", |
1068 |
helptext = _("Make selected layer(s) unvisible"), |
helptext = _("Make selected layer unvisible"), |
1069 |
sensitive = _has_selected_layer) |
sensitive = _has_selected_layer) |
1070 |
_method_command("layer_show_table", _("Show Ta&ble"), "LayerShowTable", |
_method_command("layer_show_table", _("Show Ta&ble"), "LayerShowTable", |
1071 |
helptext = _("Show the selected layer's table"), |
helptext = _("Show the selected layer's table"), |
1072 |
sensitive = _has_selected_layer) |
sensitive = _has_selected_layer) |
1073 |
|
_method_command("layer_properties", _("&Properties..."), "LayerEditProperties", |
1074 |
|
sensitive = _has_selected_layer, |
1075 |
|
helptext = _("Edit the properties of the selected layer")) |
1076 |
|
_method_command("layer_jointable", _("&Join Table..."), "LayerJoinTable", |
1077 |
|
sensitive = _has_selected_layer, |
1078 |
|
helptext = _("Join and attach a table to the selected layer")) |
1079 |
|
|
1080 |
_method_command("layer_classifier", _("Classify"), "Classify", |
def _can_unjoin(context): |
1081 |
sensitive = _has_selected_layer) |
"""Return whether the Layer/Unjoin command can be executed. |
1082 |
|
|
1083 |
# the menu structure |
This is the case if a layer is selected and that layer has a |
1084 |
main_menu = Menu("<main>", "<main>", |
shapestore that has an original shapestore. |
1085 |
[Menu("file", _("&File"), |
""" |
1086 |
["new_session", "open_session", None, |
layer = context.mainwindow.SelectedLayer() |
1087 |
"save_session", "save_session_as", None, |
if layer is None: |
1088 |
"show_session_tree", None, |
return 0 |
1089 |
"exit"]), |
getstore = getattr(layer, "ShapeStore", None) |
1090 |
Menu("map", _("&Map"), |
if getstore is not None: |
1091 |
["layer_add", "layer_remove", |
return getstore().OrigShapeStore() is not None |
1092 |
|
else: |
1093 |
|
return 0 |
1094 |
|
_method_command("layer_unjointable", _("&Unjoin Table..."), "LayerUnjoinTable", |
1095 |
|
sensitive = _can_unjoin, |
1096 |
|
helptext = _("Undo the last join operation")) |
1097 |
|
|
1098 |
|
|
1099 |
|
def _has_tables(context): |
1100 |
|
return bool(context.session.Tables()) |
1101 |
|
|
1102 |
|
# Table menu |
1103 |
|
_method_command("table_open", _("&Open..."), "TableOpen", |
1104 |
|
helptext = _("Open a DBF-table from a file")) |
1105 |
|
_method_command("table_close", _("&Close..."), "TableClose", |
1106 |
|
sensitive = lambda context: bool(context.session.UnreferencedTables()), |
1107 |
|
helptext = _("Close one or more tables from a list")) |
1108 |
|
_method_command("table_rename", _("&Rename..."), "TableRename", |
1109 |
|
sensitive = _has_tables, |
1110 |
|
helptext = _("Rename one or more tables")) |
1111 |
|
_method_command("table_show", _("&Show..."), "TableShow", |
1112 |
|
sensitive = _has_tables, |
1113 |
|
helptext = _("Show one or more tables in a dialog")) |
1114 |
|
_method_command("table_join", _("&Join..."), "TableJoin", |
1115 |
|
sensitive = _has_tables, |
1116 |
|
helptext = _("Join two tables creating a new one")) |
1117 |
|
|
1118 |
|
# Export only under Windows ... |
1119 |
|
map_menu = ["layer_add", "layer_add_db", "rasterlayer_add", "layer_remove", |
1120 |
None, |
None, |
1121 |
|
"map_rename", |
1122 |
"map_projection", |
"map_projection", |
1123 |
None, |
None, |
1124 |
"map_zoom_in_tool", "map_zoom_out_tool", |
"map_zoom_in_tool", "map_zoom_out_tool", |
1125 |
"map_pan_tool", "map_identify_tool", "map_label_tool", |
"map_pan_tool", |
|
None, |
|
1126 |
"map_full_extent", |
"map_full_extent", |
1127 |
|
"layer_full_extent", |
1128 |
|
"selected_full_extent", |
1129 |
|
None, |
1130 |
|
"map_identify_tool", "map_label_tool", |
1131 |
None, |
None, |
1132 |
"map_print"]), |
"toggle_legend", |
1133 |
|
None] |
1134 |
|
if wxPlatform == '__WXMSW__': |
1135 |
|
map_menu.append("map_export") |
1136 |
|
map_menu.append("map_print") |
1137 |
|
|
1138 |
|
# the menu structure |
1139 |
|
main_menu = Menu("<main>", "<main>", |
1140 |
|
[Menu("file", _("&File"), |
1141 |
|
["new_session", "open_session", None, |
1142 |
|
"save_session", "save_session_as", None, |
1143 |
|
"database_management", None, |
1144 |
|
"toggle_session_tree", None, |
1145 |
|
"exit"]), |
1146 |
|
Menu("map", _("&Map"), map_menu), |
1147 |
Menu("layer", _("&Layer"), |
Menu("layer", _("&Layer"), |
1148 |
["layer_fill_color", "layer_transparent_fill", |
["layer_rename", "layer_duplicate", |
|
"layer_outline_color", "layer_no_outline", |
|
1149 |
None, |
None, |
1150 |
"layer_raise", "layer_lower", |
"layer_raise", "layer_lower", |
1151 |
None, |
None, |
1152 |
"layer_show", "layer_hide", |
"layer_show", "layer_hide", |
1153 |
None, |
None, |
1154 |
|
"layer_projection", |
1155 |
|
None, |
1156 |
"layer_show_table", |
"layer_show_table", |
1157 |
|
"layer_jointable", |
1158 |
|
"layer_unjointable", |
1159 |
None, |
None, |
1160 |
"layer_classifier"]), |
"layer_properties"]), |
1161 |
|
Menu("table", _("&Table"), |
1162 |
|
["table_open", "table_close", "table_rename", |
1163 |
|
None, |
1164 |
|
"table_show", |
1165 |
|
None, |
1166 |
|
"table_join"]), |
1167 |
Menu("help", _("&Help"), |
Menu("help", _("&Help"), |
1168 |
["help_about"])]) |
["help_about"])]) |
1169 |
|
|
1171 |
|
|
1172 |
main_toolbar = Menu("<toolbar>", "<toolbar>", |
main_toolbar = Menu("<toolbar>", "<toolbar>", |
1173 |
["map_zoom_in_tool", "map_zoom_out_tool", "map_pan_tool", |
["map_zoom_in_tool", "map_zoom_out_tool", "map_pan_tool", |
1174 |
"map_full_extent", None, |
"map_full_extent", |
1175 |
|
"layer_full_extent", |
1176 |
|
"selected_full_extent", |
1177 |
|
None, |
1178 |
"map_identify_tool", "map_label_tool"]) |
"map_identify_tool", "map_label_tool"]) |
1179 |
|
|