annotate clients/editor/plugins/layertool.py @ 182:bcc93e17f978

- added new plugin to FIFedit (Layertool) FEATURES: - layers now can be toogled visible / invisible - tool also allows layer selection (better workflow IMO) - just click on the layer name - demo screencapture can be found here: http://zero-projekt.net/files/screencaptures/1280x_zero_fifedit_layertool.ogg Please let me know if this plugin causes any trouble for you.
author chewie@33b003aa-7bff-0310-803a-e67f0ece8222
date Wed, 11 Feb 2009 19:27:18 +0000
parents
children 5f5f8ca6db93
rev   line source
182
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
1 #!/usr/bin/env python
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
2 # coding: utf-8
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
3 # ###################################################
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
4 # Copyright (C) 2008 The Zero-Projekt team
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
5 # http://zero-projekt.net
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
6 # info@zero-projekt.net
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
7 # This file is part of Zero "Was vom Morgen blieb"
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
8 #
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
9 # The Zero-Projekt codebase is free software; you can redistribute it and/or modify
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
10 # it under the terms of the GNU General Public License as published by
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
11 # the Free Software Foundation; either version 2 of the License, or
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
12 # (at your option) any later version.
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
13 #
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
14 # This program is distributed in the hope that it will be useful,
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
17 # GNU General Public License for more details.
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
18 #
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
19 # You should have received a copy of the GNU General Public License
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
20 # along with this program; if not, write to the
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
21 # Free Software Foundation, Inc.,
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
22 # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
23 # ###################################################
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
24
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
25 """ an advanced layer tool for FIFedit """
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
26
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
27 import fife
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
28 import plugin
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
29 import pychan
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
30 import pychan.widgets as widgets
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
31 from pychan.tools import callbackWithArguments as cbwa
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
32
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
33 import settings as Settings
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
34
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
35 class LayerTool(plugin.Plugin):
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
36 """ The B{LayerTool} is an advanced method to view
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
37 and change layer informations.
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
38
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
39 While the original FIFedit tool only allows to select
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
40 layers, this one will provide the following functionality:
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
41
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
42 - toggle layer visibility
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
43 - select layer
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
44 - list layers
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
45
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
46 The plugin has to register itself in the mapeditor module
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
47 to get actual content when a new map is loaded.
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
48 """
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
49 def __init__(self, engine, mapedit):
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
50 # Fifedit plugin data
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
51 self.menu_items = { 'LayerTool' : self.toggle }
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
52 self._mapedit = mapedit
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
53 self.data = False
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
54
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
55 # "register" at mapeditor module
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
56 self._mapedit.layertool = self
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
57
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
58 self.subwrappers = []
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
59 self.__create_gui()
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
60
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
61 def __create_gui(self):
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
62 """ create the basic gui container """
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
63 self.container = pychan.loadXML('gui/layertool.xml')
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
64 self.wrapper = self.container.findChild(name="layers_wrapper")
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
65
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
66 def _adjust_position(self):
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
67 """ adjusts the position of the container - we don't want to
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
68 let the window appear at the center of the screen.
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
69 (new default position: left, beneath the tools window)
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
70 """
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
71 self.container.position = (10, 200)
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
72
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
73 def clear(self):
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
74 """ remove all subwrappers """
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
75 if self.subwrappers is []: return
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
76
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
77 for subwrapper in self.subwrappers:
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
78 self.wrapper.removeChild(subwrapper)
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
79
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
80 self.subwrappers = []
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
81
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
82 def update(self):
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
83 """ dump new layer informations into the wrapper
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
84
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
85 We group one ToggleButton and one Lable into a HBox, the main wrapper
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
86 itself is a VBox and we also capture both the Button and the Label to listen
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
87 for mouse actions
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
88 """
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
89 layers = self._mapedit._map.getLayers()
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
90
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
91 self.clear()
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
92
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
93 for layer in layers:
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
94 layerid = layer.getId()
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
95 subwrapper = pychan.widgets.HBox()
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
96
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
97 visibility_widget = pychan.widgets.ToggleButton(up_image="icons/is_visible.png",down_image="icons/quit.png")
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
98 visibility_widget.name = "toggle_" + layerid
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
99 visibility_widget.capture(self.toggle_layer_visibility,"mousePressed")
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
100
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
101 layer_name_widget = pychan.widgets.Label()
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
102 layer_name_widget.text = layerid
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
103 layer_name_widget.name = "select_" + layerid
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
104 layer_name_widget.capture(self.select_active_layer,"mousePressed")
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
105
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
106 subwrapper.addChild(visibility_widget)
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
107 subwrapper.addChild(layer_name_widget)
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
108
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
109 self.wrapper.addChild(subwrapper)
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
110 self.subwrappers.append(subwrapper)
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
111
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
112 self.container.adaptLayout()
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
113 self.data = True
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
114
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
115 def toggle(self):
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
116 """ toggle visibility of the main gui container """
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
117 if self.container.isVisible():
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
118 self.container.hide()
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
119 else:
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
120 self.container.show()
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
121 self._adjust_position()
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
122
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
123 def toggle_layer_visibility(self, event, widget):
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
124 """ callback for ToggleButtons
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
125
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
126 @type event: object
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
127 @param event: pychan mouse event
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
128 @type widget: object
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
129 @param widget: the pychan widget where the event occurs, transports the layer id in it's name
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
130 """
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
131 if not self.data: return
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
132
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
133 layerid = widget.name[7:]
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
134
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
135 layer = self._mapedit._map.getLayer(layerid)
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
136 if layer.areInstancesVisible():
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
137 layer.setInstancesVisible(False)
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
138 else:
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
139 layer.setInstancesVisible(True)
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
140
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
141
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
142 def select_active_layer(self, event, widget):
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
143 """ callback for Labels
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
144
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
145 We hand the layerid over to the mapeditor module to select a
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
146 new active layer
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
147
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
148 @type event: object
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
149 @param event: pychan mouse event
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
150 @type widget: object
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
151 @param widget: the pychan widget where the event occurs, transports the layer id in it's name
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
152 """
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
153 if not self.data: return
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
154
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
155 layerid = widget.name[7:]
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
156 self._mapedit._editLayer(layerid)