1 |
# Copyright (c) 2001 by Intevation GmbH |
# Copyright (c) 2001, 2002 by Intevation GmbH |
2 |
# Authors: |
# Authors: |
3 |
# Bernhard Herzog <[email protected]> |
# Bernhard Herzog <[email protected]> |
4 |
# |
# |
9 |
|
|
10 |
from Thuban.Lib.connector import Publisher |
from Thuban.Lib.connector import Publisher |
11 |
|
|
12 |
from messages import MAPS_CHANGED, LAYERS_CHANGED, MAP_PROJECTION_CHANGED, \ |
from messages import MAPS_CHANGED, FILENAME_CHANGED, \ |
13 |
LAYER_LEGEND_CHANGED, FILENAME_CHANGED |
LAYERS_CHANGED, MAP_PROJECTION_CHANGED, \ |
14 |
|
LAYER_LEGEND_CHANGED, LAYER_PROJECTION_CHANGED, LAYER_VISIBILITY_CHANGED |
15 |
|
|
16 |
from base import TitledObject, Modifiable |
from base import TitledObject, Modifiable |
17 |
|
|
37 |
subscriptions easier. |
subscriptions easier. |
38 |
""" |
""" |
39 |
|
|
40 |
|
# message channels that have to be forwarded from maps contained in |
41 |
|
# the session. |
42 |
|
forwarded_channels = ( |
43 |
|
# map specific channels |
44 |
|
MAP_PROJECTION_CHANGED, |
45 |
|
LAYERS_CHANGED, |
46 |
|
|
47 |
|
# layer channels forwarded by the map |
48 |
|
LAYER_PROJECTION_CHANGED, |
49 |
|
LAYER_LEGEND_CHANGED, |
50 |
|
LAYER_VISIBILITY_CHANGED) |
51 |
|
|
52 |
def __init__(self, title): |
def __init__(self, title): |
53 |
TitledObject.__init__(self, title) |
TitledObject.__init__(self, title) |
54 |
Modifiable.__init__(self) |
Modifiable.__init__(self) |
68 |
|
|
69 |
def AddMap(self, map): |
def AddMap(self, map): |
70 |
self.maps.append(map) |
self.maps.append(map) |
71 |
for channel in (LAYERS_CHANGED, MAP_PROJECTION_CHANGED, |
for channel in self.forwarded_channels: |
|
LAYER_LEGEND_CHANGED): |
|
72 |
map.Subscribe(channel, self.forward, channel) |
map.Subscribe(channel, self.forward, channel) |
73 |
self.changed(MAPS_CHANGED) |
self.changed(MAPS_CHANGED) |
74 |
|
|
97 |
|
|
98 |
def UnsetModified(self): |
def UnsetModified(self): |
99 |
"""Unset the modified flag of the session and the maps""" |
"""Unset the modified flag of the session and the maps""" |
|
print "Session.UnsetModified: entry", self.modified |
|
100 |
Modifiable.UnsetModified(self) |
Modifiable.UnsetModified(self) |
101 |
for map in self.maps: |
for map in self.maps: |
102 |
map.UnsetModified() |
map.UnsetModified() |
|
print "Session.UnsetModified: exit", self.modified |
|
103 |
|
|
104 |
|
|
105 |
|
|
106 |
def create_empty_session(): |
def create_empty_session(): |
107 |
"""Return an empty session useful as a starting point""" |
"""Return an empty session useful as a starting point""" |
108 |
|
import os |
109 |
session = Session('unnamed session') |
session = Session('unnamed session') |
110 |
session.SetFilename('unnamed.session') |
session.SetFilename(None) |
111 |
session.AddMap(Map('unnamed map')) |
session.AddMap(Map('unnamed map')) |
112 |
|
session.UnsetModified() |
113 |
return session |
return session |