15 |
|
|
16 |
from Thuban.Model.layer import Layer |
from Thuban.Model.layer import Layer |
17 |
from Thuban.Model.map import Map |
from Thuban.Model.map import Map |
|
from Thuban.Model.messages import * |
|
18 |
from Thuban.Model.classification import ClassGroup |
from Thuban.Model.classification import ClassGroup |
19 |
|
|
20 |
from Thuban.UI.messages import * |
from Thuban.Model.messages import \ |
21 |
|
MAP_STACKING_CHANGED, MAP_LAYERS_ADDED, MAP_LAYERS_REMOVED, LAYER_CHANGED,\ |
22 |
|
LAYER_VISIBILITY_CHANGED, TITLE_CHANGED |
23 |
|
|
24 |
|
from Thuban.UI.messages import SCALE_CHANGED |
25 |
|
|
26 |
from Thuban.UI.classifier import ClassDataPreviewer |
from Thuban.UI.classifier import ClassDataPreviewer |
27 |
from Thuban.UI.dock import DockPanel |
from Thuban.UI.dock import DockPanel |
28 |
|
from Thuban.UI.scalebar import ScaleBar |
29 |
|
|
30 |
from Thuban.Lib.connector import ConnectorError |
from Thuban.Lib.connector import ConnectorError |
31 |
|
|
94 |
|
|
95 |
panelBox.Add(self.tree, 1, wxGROW, 0) |
panelBox.Add(self.tree, 1, wxGROW, 0) |
96 |
|
|
97 |
|
self.scalebarbitmap = ScaleBarBitmap(self, map, mainWindow) |
98 |
|
panelBox.Add(self.scalebarbitmap, 0, wxGROW, 0) |
99 |
|
|
100 |
self.SetAutoLayout(True) |
self.SetAutoLayout(True) |
101 |
self.SetSizer(panelBox) |
self.SetSizer(panelBox) |
102 |
panelBox.SetSizeHints(self) |
panelBox.SetSizeHints(self) |
116 |
|
|
117 |
def SetMap(self, map): |
def SetMap(self, map): |
118 |
self.tree.SetMap(map) |
self.tree.SetMap(map) |
119 |
|
self.scalebarbitmap.SetCanvas(self.mainWindow.canvas) |
120 |
|
|
121 |
def DoOnSelChanged(self, layer, group): |
def DoOnSelChanged(self, layer, group): |
122 |
|
|
225 |
#self._OnMsgMapsChanged) |
#self._OnMsgMapsChanged) |
226 |
self.__FillTree(self.map) |
self.__FillTree(self.map) |
227 |
|
|
|
|
|
228 |
def MoveCurrentItemUp(self): |
def MoveCurrentItemUp(self): |
229 |
layer, group = self.GetSelectedHierarchy() |
layer, group = self.GetSelectedHierarchy() |
230 |
|
|
254 |
else: |
else: |
255 |
return wxTreeCtrl.OnCompareItems(self, item1, item2) |
return wxTreeCtrl.OnCompareItems(self, item1, item2) |
256 |
|
|
|
|
|
257 |
def DoOnShowLayer(self): |
def DoOnShowLayer(self): |
258 |
#self.__ShowHideLayer(True) |
#self.__ShowHideLayer(True) |
259 |
layer, group = self.GetSelectedHierarchy() |
layer, group = self.GetSelectedHierarchy() |
458 |
self.__SetVisibilityStyle(visible, id) |
self.__SetVisibilityStyle(visible, id) |
459 |
id, cookie = self.GetNextChild(parent, cookie) |
id, cookie = self.GetNextChild(parent, cookie) |
460 |
|
|
461 |
|
class ScaleBarBitmap(wxBoxSizer): |
462 |
|
|
463 |
|
def __init__(self, parent, map, mainWindow): |
464 |
|
# While the width is fixed, get the height _now_. |
465 |
|
dc = wxMemoryDC() |
466 |
|
textwidth, textheight = dc.GetTextExtent("%d"%0) |
467 |
|
self.width = 200 |
468 |
|
self.height = textheight + 3*2 + 8 |
469 |
|
|
470 |
|
wxBoxSizer.__init__(self, wxVERTICAL) |
471 |
|
bmp=wxEmptyBitmap(self.width, self.height) |
472 |
|
self.scalebarBitmap = wxStaticBitmap(parent, -1, bmp) |
473 |
|
self.Add(self.scalebarBitmap, 0, wxALIGN_CENTER|wxLEFT|wxTOP|wxRIGHT, 1) |
474 |
|
|
475 |
|
self.mainWindow = mainWindow |
476 |
|
self.parent = parent |
477 |
|
self.canvas = None |
478 |
|
self.SetCanvas(self.mainWindow.canvas) |
479 |
|
|
480 |
|
def SetCanvas(self, canvas): |
481 |
|
sub_list = [(SCALE_CHANGED, self._OnMsgScaleChanged)] |
482 |
|
|
483 |
|
if self.canvas is not None: |
484 |
|
for msg, func in sub_list: self.canvas.Unsubscribe(msg, func) |
485 |
|
|
486 |
|
self.canvas = canvas |
487 |
|
self.scalebar = ScaleBar(canvas.map) |
488 |
|
|
489 |
|
if self.canvas is not None: |
490 |
|
for msg, func in sub_list: self.canvas.Subscribe(msg, func) |
491 |
|
self.__SetScale(self.canvas.scale) |
492 |
|
|
493 |
|
def _OnMsgScaleChanged(self, scale): |
494 |
|
self.__SetScale(scale) |
495 |
|
|
496 |
|
def __SetScale(self, scale): |
497 |
|
bmp = wxEmptyBitmap(self.width, self.height) |
498 |
|
dc = wxMemoryDC() |
499 |
|
dc.SelectObject(bmp) |
500 |
|
dc.Clear() |
501 |
|
|
502 |
|
self.scalebar.DrawScalebar(scale, dc) |
503 |
|
|
504 |
|
self.scalebarBitmap.SetBitmap(bmp) |
505 |
|
|