[Thuban-devel] Re: RfD: Support for layer specific resources
Martin Schulze
joey at infodrom.org
Thu Sep 30 18:06:40 CEST 2004
Bernhard Herzog wrote:
> > Having it in mainwindow doesn't work since that would introduce a
> > circular import chain. mainwindow is already importing the classifier,
> > so the classifier cannot import the mainwindow.
>
> mainwindow only imports classifier because it's referenced directly in
> the OpenLayerProperties method. That reference will go away, of course,
> since that's basically the point of the changes we're discussing here.
> So there's no need anymore for mainwindow to import classifier at all,
> and there would be no circular import.
Whoops, you are correct. Great. In that case, at least at the moment
there is no problem with having the definition in mainwindow.py. New
patch attached. Will commit tomorrow.
Regards,
Joey
--
This is GNU/Linux Country. On a quiet night, you can hear Windows reboot.
-------------- next part --------------
Index: Extensions/wms/properties.py
===================================================================
RCS file: /thubanrepository/thuban/Extensions/wms/properties.py,v
retrieving revision 1.1
diff -u -r1.1 properties.py
--- Extensions/wms/properties.py 15 Apr 2004 16:14:51 -0000 1.1
+++ Extensions/wms/properties.py 30 Sep 2004 16:03:44 -0000
@@ -72,7 +72,7 @@
Representation for the WMS properties dialog
"""
- def __init__(self, parent, name, layer):
+ def __init__(self, parent, name, layer, *args, **kw):
"""
Build the properties dialog
"""
Index: Extensions/wms/wms.py
===================================================================
RCS file: /thubanrepository/thuban/Extensions/wms/wms.py,v
retrieving revision 1.10
diff -u -r1.10 wms.py
--- Extensions/wms/wms.py 28 Sep 2004 19:54:50 -0000 1.10
+++ Extensions/wms/wms.py 30 Sep 2004 16:03:44 -0000
@@ -28,7 +28,7 @@
from Thuban.Model.proj import Projection
from Thuban.Model.extension import Extension
from Thuban.UI.command import registry, Command
-from Thuban.UI.mainwindow import main_menu
+from Thuban.UI.mainwindow import main_menu, layer_properties_dialogs
from Thuban import _
import Thuban.UI.baserenderer
from Thuban.UI.extensionregistry import ExtensionDesc, ext_registry
@@ -65,6 +65,8 @@
return ()
Thuban.UI.baserenderer.add_renderer_extension(WMSLayer, render_wms_layer)
+from properties import wmsProperties
+layer_properties_dialogs.add(WMSLayer, wmsProperties)
class SelectWMSServer(wxDialog):
Index: Thuban/UI/classifier.py
===================================================================
RCS file: /thubanrepository/thuban/Thuban/UI/classifier.py,v
retrieving revision 1.65
diff -u -r1.65 classifier.py
--- Thuban/UI/classifier.py 7 May 2004 20:20:43 -0000 1.65
+++ Thuban/UI/classifier.py 30 Sep 2004 16:03:45 -0000
@@ -685,7 +685,7 @@
FIELDTYPE_INT: _("Integer"),
FIELDTYPE_DOUBLE: _("Decimal")}
- def __init__(self, parent, name, map, layer, group = None):
+ def __init__(self, parent, name, layer, group = None):
"""Create a Properties/Classification dialog for a layer.
The layer is part of map. If group is not None, select that
group in the classification table.
@@ -697,7 +697,7 @@
self.parent.Subscribe(MAP_REPLACED, self.map_replaced)
self.layer = layer
- self.map = map
+ self.map = parent.Map()
self.map.Subscribe(MAP_LAYERS_REMOVED, self.map_layers_removed)
self.layer.Subscribe(LAYER_SHAPESTORE_REPLACED,
@@ -1510,3 +1510,7 @@
def _OnLeftDClick(self, event):
self.DoEdit()
+
+from Thuban.UI.mainwindow import layer_properties_dialogs
+layer_properties_dialogs.add(Layer, Classifier)
+layer_properties_dialogs.add(RasterLayer, Classifier)
Index: Thuban/UI/mainwindow.py
===================================================================
RCS file: /thubanrepository/thuban/Thuban/UI/mainwindow.py,v
retrieving revision 1.132
diff -u -r1.132 mainwindow.py
--- Thuban/UI/mainwindow.py 18 Apr 2004 20:37:01 -0000 1.132
+++ Thuban/UI/mainwindow.py 30 Sep 2004 16:03:46 -0000
@@ -35,7 +35,6 @@
import view
import tree
import tableview, identifyview
-from Thuban.UI.classifier import Classifier
import legend
from menu import Menu
@@ -53,6 +52,9 @@
import projdialog
+from Thuban.Lib.classmapper import ClassMapper
+
+layer_properties_dialogs = ClassMapper()
class MainWindow(DockFrame):
@@ -349,6 +351,23 @@
"""
self.SetStatusText(text)
+ def OpenOrRaiseDialog(self, name, dialog_class, *args, **kw):
+ """
+ Open or raise a dialog.
+
+ If a dialog with the denoted name does already exist it is
+ raised. Otherwise a new dialog, an instance of dialog_class,
+ is created, inserted into the main list and displayed.
+ """
+ dialog = self.get_open_dialog(name)
+
+ if dialog is None:
+ dialog = dialog_class(self, name, *args, **kw)
+ self.add_dialog(name, dialog)
+ dialog.Show(True)
+ else:
+ dialog.Raise()
+
def save_modified_session(self, can_veto = 1):
"""If the current session has been modified, ask the user
whether to save it and do so if requested. Return the outcome of
@@ -705,14 +724,18 @@
self.OpenLayerProperties(layer)
def OpenLayerProperties(self, layer, group = None):
- name = "layer_properties" + str(id(layer))
- dialog = self.get_open_dialog(name)
+ """
+ Open or raise the properties dialog.
- if dialog is None:
- dialog = Classifier(self, name, self.Map(), layer, group)
- self.add_dialog(name, dialog)
- dialog.Show()
- dialog.Raise()
+ This method opens or raises the properties dialog for the
+ currently selected layer if one is defined for this layer
+ type.
+ """
+ dialog_class = layer_properties_dialogs.get(layer)
+
+ if dialog_class is not None:
+ name = "layer_properties" + str(id(layer))
+ self.OpenOrRaiseDialog(name, dialog_class, layer, group = group)
def LayerJoinTable(self):
layer = self.canvas.SelectedLayer()
More information about the Thuban-devel
mailing list
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)