annotate clients/editor/plugins/LayerTool.py @ 359:ad5818097cd6

* Some cleanups for Editor class to match new coding standards * Minor cleanups in imports
author cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
date Sat, 26 Sep 2009 10:38:24 +0000
parents 8f64a9d1e7ab
children 598547404022
rev   line source
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
1 # -*- coding: utf-8 -*-
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
2
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
3 # ####################################################################
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
4 # Copyright (C) 2005-2009 by the FIFE team
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
5 # http://www.fifengine.de
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
6 # This file is part of FIFE.
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
7 #
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
8 # FIFE is free software; you can redistribute it and/or
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
9 # modify it under the terms of the GNU Lesser General Public
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
10 # License as published by the Free Software Foundation; either
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
11 # version 2.1 of the License, or (at your option) any later version.
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
12 #
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
13 # This library is distributed in the hope that it will be useful,
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
16 # Lesser General Public License for more details.
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
17 #
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
18 # You should have received a copy of the GNU Lesser General Public
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
19 # License along with this library; if not, write to the
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
20 # Free Software Foundation, Inc.,
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
22 # ####################################################################
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
23
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
24 """ A layer tool for FIFedit """
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
25
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
26 import fife
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
27 import pychan
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
28 import pychan.widgets as widgets
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
29 from pychan.tools import callbackWithArguments as cbwa
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
30
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
31 import scripts.plugin as plugin
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
32 import scripts.editor
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
33 from scripts.events import *
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
34 from scripts.gui.action import Action
343
8e71629c4c43 Several changes to layer, camera and map dialogs:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 340
diff changeset
35 from scripts.gui.layerdialog import LayerDialog
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
36
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
37 class LayerTool(plugin.Plugin):
322
3853f8659598 - small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 321
diff changeset
38 """ The B{LayerTool} allows to select and show / hide layers of a loaded
3853f8659598 - small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 321
diff changeset
39 map as well as creating new layers or edit layer properties
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
40 """
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
41
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
42 # default should be pychan default, highlight can be choosen (format: r,g,b)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
43 DEFAULT_BACKGROUND_COLOR = pychan.internal.DEFAULT_STYLE['default']['base_color']
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
44 HIGHLIGHT_BACKGROUND_COLOR = pychan.internal.DEFAULT_STYLE['default']['selection_color']
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
45
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
46 # the dynamicly created widgets have the name scheme prefix + layerid
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
47 LABEL_NAME_PREFIX = "select_"
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
48
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
49 def __init__(self):
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
50 # Editor instance
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
51 self._editor = None
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
52
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
53 # Plugin variables
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
54 self._enabled = False
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
55
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
56 # Current mapview
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
57 self._mapview = None
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
58
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
59 # Toolbar button to display LayerTool
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
60 self._action_show = None
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
61
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
62 # GUI
319
62ec3b530cc6 * Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 316
diff changeset
63 self._layer_wizard = None
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
64 self._container = None
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
65 self._wrapper = None
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
66 self._remove_layer_button = None
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
67 self._create_layer_button = None
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
68 self._edit_layer_button = None
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
69
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
70 #--- Plugin functions ---#
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
71 def enable(self):
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
72 """ Enable plugin """
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
73 if self._enabled is True:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
74 return
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
75
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
76 # Fifedit plugin data
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
77 self._editor = scripts.editor.getEditor()
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
78 self._action_show = Action(u"LayerTool", checkable=True)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
79 scripts.gui.action.activated.connect(self.toggle, sender=self._action_show)
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 358
diff changeset
80 self._editor._tools_menu.addAction(self._action_show)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
81
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
82 self._createGui()
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
83
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
84 self.toggle()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
85
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
86 events.postMapShown.connect(self.update)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
87
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
88 def disable(self):
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
89 """ Disable plugin """
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
90 if self._enabled is False:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
91 return
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
92 self._container.setDocked(False)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
93 self._container.hide()
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
94
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
95 events.postMapShown.disconnect(self.update)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
96
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 358
diff changeset
97 self._editor._tools_menu.removeAction(self._action_show)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
98
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
99 def isEnabled(self):
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
100 """ Returns True if plugin is enabled """
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
101 return self._enabled;
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
102
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
103 def getName(self):
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
104 """ Return plugin name """
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
105 return u"Layertool"
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
106
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
107 #--- End plugin functions ---#
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
108 def showLayerWizard(self):
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
109 """ Show layer wizard """
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
110 if not self._mapview: return
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
111
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
112 if self._layer_wizard: self._layer_wizard._widget.hide()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
113 self._layer_wizard = LayerDialog(self._editor.getEngine(), self._mapview.getMap(), callback=self._layerCreated)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
114
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
115 def showEditDialog(self):
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
116 """ Show layerdialog for active layer """
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
117 if not self._mapview: return
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
118 layer = self.getActiveLayer()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
119 if not layer: return
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
120
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
121 if self._layer_wizard: self._layer_wizard._widget.hide()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
122 self._layer_wizard = LayerDialog(self._editor.getEngine(), self._mapview.getMap(), layer=layer, callback=cbwa(self.update, self._mapview))
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
123
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
124 def clear(self):
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
125 """ Remove all subwrappers """
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
126 self._wrapper.removeAllChildren()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
127
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
128 def update(self, mapview):
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
129 """ Update layertool with information from mapview
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
130
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
131 We group one ToggleButton and one Label into a HBox, the main wrapper
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
132 itself is a VBox and we also capture both the Button and the Label to listen
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
133 for mouse actions
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
134
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
135 @type event: object
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
136 @param event: pychan mouse event
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
137 """
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
138 layers = []
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
139 self._mapview = mapview
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
140 if self._mapview is not None:
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
141 layers = self._mapview.getMap().getLayers()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
142
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
143 self.clear()
323
b64ce990abb1 LayerTool:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 322
diff changeset
144
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
145 if len(layers) <= 0:
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
146 if not self._mapview:
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
147 layerid = "No map is open"
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
148 else:
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
149 layerid = "No layers"
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
150 subwrapper = pychan.widgets.HBox()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
151
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
152 layerLabel = pychan.widgets.Label()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
153 layerLabel.text = unicode(layerid)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
154 layerLabel.name = LayerTool.LABEL_NAME_PREFIX + layerid
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
155 subwrapper.addChild(layerLabel)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
156
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
157 self._wrapper.addChild(subwrapper)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
158
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
159 active_layer = self.getActiveLayer()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
160 if active_layer:
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
161 active_layer = active_layer.getId()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
162 for layer in reversed(layers):
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
163 layerid = layer.getId()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
164 subwrapper = pychan.widgets.HBox()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
165
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
166 toggleVisibleButton = pychan.widgets.ToggleButton(hexpand=0, up_image="gui/icons/is_visible.png", down_image="gui/icons/is_visible.png", hover_image="gui/icons/is_visible.png")
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
167 toggleVisibleButton.name = "toggle_" + layerid
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
168 if layer.areInstancesVisible():
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
169 toggleVisibleButton.toggled = True
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
170 toggleVisibleButton.capture(self.toggleLayerVisibility)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
171
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
172 layerLabel = pychan.widgets.Label()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
173 layerLabel.text = unicode(layerid)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
174 layerLabel.name = LayerTool.LABEL_NAME_PREFIX + layerid
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
175 layerLabel.capture(self.selectLayer,"mousePressed")
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
176
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
177 if active_layer == layerid:
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
178 layerLabel.background_color = LayerTool.HIGHLIGHT_BACKGROUND_COLOR
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
179 layerLabel.foreground_color = LayerTool.HIGHLIGHT_BACKGROUND_COLOR
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
180 layerLabel.base_color = LayerTool.HIGHLIGHT_BACKGROUND_COLOR
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
181
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
182 subwrapper.addChild(toggleVisibleButton)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
183 subwrapper.addChild(layerLabel)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
184
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
185 self._wrapper.addChild(subwrapper)
323
b64ce990abb1 LayerTool:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 322
diff changeset
186
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
187 self._container.adaptLayout()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
188
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
189 def toggleLayerVisibility(self, event, widget):
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
190 """ Callback for ToggleButtons
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
191
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
192 Toggle the chosen layer visible / invisible. If the active layer is hidden,
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
193 it will be deselected.
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
194
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
195 @type event: object
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
196 @param event: pychan mouse event
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
197 @type widget: object
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
198 @param widget: the pychan widget where the event occurs, transports the layer id in it's name
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
199 """
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
200
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
201 layerid = widget.name[len(LayerTool.LABEL_NAME_PREFIX):]
323
b64ce990abb1 LayerTool:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 322
diff changeset
202
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
203 layer = self._mapview.getMap().getLayer(layerid)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
204 active_layer = self.getActiveLayer()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
205 if active_layer:
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
206 active_layer = active_layer.getId()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
207
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
208 if layer.areInstancesVisible():
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
209 layer.setInstancesVisible(False)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
210 else:
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
211 layer.setInstancesVisible(True)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
212
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
213 if active_layer == layerid:
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
214 self.resetSelection()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
215
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
216 def getActiveLayer(self):
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
217 """ Returns the active layer """
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
218 if self._mapview:
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
219 return self._mapview.getController()._layer
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
220
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
221 def selectLayer(self, event, widget=None, layerid=None):
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
222 """ Callback for Labels
323
b64ce990abb1 LayerTool:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 322
diff changeset
223
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
224 We hand the layerid over to the mapeditor module to select a
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
225 new active layer
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
226
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
227 Additionally, we mark the active layer widget (changing base color) and reseting the previous one
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
228
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
229 @type event: object
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
230 @param event: pychan mouse event
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
231 @type widget: object
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
232 @param widget: the pychan widget where the event occurs, transports the layer id in it's name
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
233 @type layerid: string
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
234 @param layerid: the layer id
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
235 """
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
236
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
237 if not widget and not layerid:
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
238 print "No layer ID or widget passed to LayerTool.selectLayer"
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
239 return
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
240
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
241 if widget is not None:
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
242 layerid = widget.name[len(LayerTool.LABEL_NAME_PREFIX):]
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
243
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
244 self.resetSelection()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
245
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
246 widget.background_color = LayerTool.HIGHLIGHT_BACKGROUND_COLOR
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
247 widget.foreground_color = LayerTool.HIGHLIGHT_BACKGROUND_COLOR
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
248 widget.base_color = LayerTool.HIGHLIGHT_BACKGROUND_COLOR
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
249
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
250 self._mapview.getController().selectLayer(layerid)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
251
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
252 def resetSelection(self):
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
253 """ Deselects selected layer """
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
254 previous_active_layer = self.getActiveLayer()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
255 if previous_active_layer is not None:
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
256 previous_layer_id = previous_active_layer.getId()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
257 previous_active_widget = self._container.findChild(name=LayerTool.LABEL_NAME_PREFIX + previous_layer_id)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
258 previous_active_widget.background_color = LayerTool.DEFAULT_BACKGROUND_COLOR
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
259 previous_active_widget.foreground_color = LayerTool.DEFAULT_BACKGROUND_COLOR
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
260 previous_active_widget.base_color = LayerTool.DEFAULT_BACKGROUND_COLOR
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
261 previous_active_widget.text = unicode(previous_layer_id)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
262
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
263 self._mapview.getController().selectLayer(None)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
264
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
265
319
62ec3b530cc6 * Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 316
diff changeset
266 def removeSelectedLayer(self):
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
267 """ Deletes the selected layer """
319
62ec3b530cc6 * Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 316
diff changeset
268 if not self._mapview: return
62ec3b530cc6 * Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 316
diff changeset
269
321
7ddec4ce99b3 Fixed a crash when removing the layer which the editor camera uses
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 319
diff changeset
270 if self._mapview.getMap().getNumLayers() <= 1:
7ddec4ce99b3 Fixed a crash when removing the layer which the editor camera uses
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 319
diff changeset
271 print "Can't remove the last layer"
7ddec4ce99b3 Fixed a crash when removing the layer which the editor camera uses
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 319
diff changeset
272 return
7ddec4ce99b3 Fixed a crash when removing the layer which the editor camera uses
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 319
diff changeset
273
319
62ec3b530cc6 * Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 316
diff changeset
274 layer = self.getActiveLayer()
62ec3b530cc6 * Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 316
diff changeset
275 if not layer: return
62ec3b530cc6 * Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 316
diff changeset
276
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
277 self.resetSelection()
319
62ec3b530cc6 * Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 316
diff changeset
278
321
7ddec4ce99b3 Fixed a crash when removing the layer which the editor camera uses
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 319
diff changeset
279 map = self._mapview.getMap()
7ddec4ce99b3 Fixed a crash when removing the layer which the editor camera uses
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 319
diff changeset
280
7ddec4ce99b3 Fixed a crash when removing the layer which the editor camera uses
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 319
diff changeset
281 # FIFE will crash if we try to delete the layer which is in use by a camera
7ddec4ce99b3 Fixed a crash when removing the layer which the editor camera uses
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 319
diff changeset
282 # so we will set the camera to another layer instead
7ddec4ce99b3 Fixed a crash when removing the layer which the editor camera uses
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 319
diff changeset
283 for cam in self._editor.getEngine().getView().getCameras():
322
3853f8659598 - small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 321
diff changeset
284 if cam.getLocationRef().getMap().getId() != map.getId():
3853f8659598 - small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 321
diff changeset
285 continue
3853f8659598 - small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 321
diff changeset
286
3853f8659598 - small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 321
diff changeset
287 if cam.getLocation().getLayer().getId() != layer.getId():
3853f8659598 - small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 321
diff changeset
288 continue
3853f8659598 - small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 321
diff changeset
289
3853f8659598 - small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 321
diff changeset
290 for l in map.getLayers():
3853f8659598 - small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 321
diff changeset
291 if l.getId() == layer.getId():
3853f8659598 - small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 321
diff changeset
292 continue
3853f8659598 - small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 321
diff changeset
293
3853f8659598 - small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 321
diff changeset
294 cam.getLocationRef().setLayer(l)
3853f8659598 - small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 321
diff changeset
295 break
321
7ddec4ce99b3 Fixed a crash when removing the layer which the editor camera uses
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 319
diff changeset
296
319
62ec3b530cc6 * Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 316
diff changeset
297 map.deleteLayer(layer)
62ec3b530cc6 * Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 316
diff changeset
298 self.update(self._mapview)
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
299
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
300 def toggle(self):
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
301 """ Toggles the layertool visible / invisible and sets
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
302 dock status
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
303 """
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
304 if self._container.isVisible() or self._container.isDocked():
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
305 self._container.setDocked(False)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
306 self._container.hide()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
307
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
308 self._action_show.setChecked(False)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
309 else:
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
310 self._container.show()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
311 self._action_show.setChecked(True)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
312 self._adjustPosition()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
313
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
314 def _createGui(self):
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
315 """ Create the basic gui container """
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
316 self._container = pychan.loadXML('gui/layertool.xml')
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
317 self._wrapper = self._container.findChild(name="layers_wrapper")
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
318 self._remove_layer_button = self._container.findChild(name="remove_layer_button")
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
319 self._create_layer_button = self._container.findChild(name="add_layer_button")
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
320 self._edit_layer_button = self._container.findChild(name="edit_layer_button")
319
62ec3b530cc6 * Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 316
diff changeset
321
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
322 self._remove_layer_button.capture(self.removeSelectedLayer)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
323 self._remove_layer_button.capture(cbwa(self._editor.getStatusBar().showTooltip, self._remove_layer_button.helptext), 'mouseEntered')
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
324 self._remove_layer_button.capture(self._editor.getStatusBar().hideTooltip, 'mouseExited')
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
325
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
326 self._create_layer_button.capture(self.showLayerWizard)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
327 self._create_layer_button.capture(cbwa(self._editor.getStatusBar().showTooltip, self._create_layer_button.helptext), 'mouseEntered')
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
328 self._create_layer_button.capture(self._editor.getStatusBar().hideTooltip, 'mouseExited')
323
b64ce990abb1 LayerTool:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 322
diff changeset
329
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
330 self._edit_layer_button.capture(self.showEditDialog)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
331 self._edit_layer_button.capture(cbwa(self._editor.getStatusBar().showTooltip, self._edit_layer_button.helptext), 'mouseEntered')
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
332 self._edit_layer_button.capture(self._editor.getStatusBar().hideTooltip, 'mouseExited')
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
333
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
334 self.update(None)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
335
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
336 def _adjustPosition(self):
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
337 """ Adjusts the position of the container - we don't want to
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
338 let the window appear at the center of the screen.
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
339 (new default position: left, beneath the tools window)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
340 """
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
341 self._container.position = (50, 200)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
342
323
b64ce990abb1 LayerTool:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 322
diff changeset
343 def _layerCreated(self, layer):
b64ce990abb1 LayerTool:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 322
diff changeset
344 self.update(self._mapview)
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
345 self.selectLayer(None, self._wrapper.findChild(name=LayerTool.LABEL_NAME_PREFIX + layer.getId()))
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
346
319
62ec3b530cc6 * Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 316
diff changeset
347
62ec3b530cc6 * Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 316
diff changeset
348