Skip to content

Commit

Permalink
last tools - ii2t, ip2i - adapted, now it is ready for testing (closi…
Browse files Browse the repository at this point in the history
…ng events need to correct)
  • Loading branch information
lindakladivova committed Jul 28, 2021
1 parent 1c73d43 commit 0a3a569
Show file tree
Hide file tree
Showing 5 changed files with 250 additions and 165 deletions.
2 changes: 1 addition & 1 deletion gui/wxpython/gcp/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2024,7 +2024,7 @@ def OnQuit(self, event):

self.Destroy()

#event.Skip()
# event.Skip()

def OnGROrder(self, event):
"""
Expand Down
78 changes: 63 additions & 15 deletions gui/wxpython/image2target/ii2t_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
- manager::LocationPage
- manager::GroupPage
- manager::DispMapPage
- manager::GCP
- manager::GCPPanel
- manager::GCPDisplay
- manager::GCPList
- manager::VectGroup
- manager::EditGCP
Expand Down Expand Up @@ -57,9 +58,10 @@
from core.render import Map
from gui_core.gselect import Select, LocationSelect, MapsetSelect
from gui_core.dialogs import GroupDialog
from gui_core.mapdisp import FrameMixin
from core.gcmd import RunCommand, GMessage, GError, GWarning
from core.settings import UserSettings
from gcp.mapdisplay import MapFrame
from gcp.mapdisplay import MapPanel
from core.giface import Notification
from gui_core.wrap import (
SpinCtrl,
Expand Down Expand Up @@ -296,22 +298,30 @@ def __init__(self, parent, giface):
#
# start GCP Manager
#
self.gcpmgr = GCP(
self.parent,
# create superior Map Display frame
mapframe = wx.Frame(
parent=None,
id=wx.ID_ANY,
size=globalvar.MAP_WINDOW_SIZE,
style=wx.DEFAULT_FRAME_STYLE,
title=name,
)
gcpmgr = GCPDisplay(
parent=mapframe,
giface=self._giface,
grwiz=self,
size=globalvar.MAP_WINDOW_SIZE,
toolbars=["gcpdisp"],
id=wx.ID_ANY,
Map=self.SrcMap,
lmgr=self.parent,
title=name,
)

# load GCPs
self.gcpmgr.InitMapDisplay()
self.gcpmgr.CenterOnScreen()
self.gcpmgr.Show()
gcpmgr.InitMapDisplay()
gcpmgr.CenterOnScreen()
gcpmgr.Show()
# need to update AUI here for wingrass
self.gcpmgr._mgr.Update()
gcpmgr._mgr.Update()
else:
self.Cleanup()

Expand Down Expand Up @@ -990,7 +1000,7 @@ def OnEnterPage(self, event=None):
wx.FindWindowById(wx.ID_FORWARD).Enable(True)


class GCP(MapFrame, ColumnSorterMixin):
class GCPPanel(MapPanel, ColumnSorterMixin):
"""
Manages ground control points for georectifying. Calculates RMS statistics.
Calls i.ortho.rectify or v.rectify to georectify map.
Expand Down Expand Up @@ -1018,7 +1028,7 @@ def __init__(
self.show_target = True

# wx.Frame.__init__(self, parent, id, title, size = size, name = "GCPFrame")
MapFrame.__init__(
MapPanel.__init__(
self,
parent=parent,
giface=self._giface,
Expand Down Expand Up @@ -1209,7 +1219,6 @@ def __init__(
self.Bind(wx.EVT_ACTIVATE, self.OnFocus)
self.Bind(wx.EVT_SIZE, self.OnSize)
self.Bind(wx.EVT_IDLE, self.OnIdle)
self.Bind(wx.EVT_CLOSE, self.OnQuit)

self.SetSettings()

Expand Down Expand Up @@ -1701,7 +1710,7 @@ def ReloadGCPs(self, event):
targetMapWin.UpdateMap(render=False, renderVector=False)

def OnFocus(self, event):
# TODO: it is here just to remove old or obsolate beavior of base class gcp/MapFrame?
# TODO: it is here just to remove old or obsolate beavior of base class gcp/MapPanel?
# self.grwiz.SwitchEnv('source')
pass

Expand Down Expand Up @@ -2291,7 +2300,7 @@ def OnSize(self, event):
"""Adjust Map Windows after GCP Map Display has been resized"""
# re-render image on idle
self.resize = grass.clock()
super(MapFrame, self).OnSize(event)
super(MapPanel, self).OnSize(event)

def OnIdle(self, event):
"""GCP Map Display resized, adjust Map Windows"""
Expand All @@ -2314,6 +2323,45 @@ def OnIdle(self, event):
pass


class GCPDisplay(FrameMixin, GCPPanel):
"""Map Display used for Multi-Window layout"""

def __init__(self, parent, giface, grwiz, id, lmgr, Map, title, **kwargs):

# init map panel
GCPPanel.__init__(
self,
parent=parent,
giface=giface,
grwiz=grwiz,
id=id,
lmgr=lmgr,
Map=Map,
title=title,
**kwargs,
)
# set system icon
parent.iconsize = (16, 16)
parent.SetIcon(
wx.Icon(
os.path.join(globalvar.ICONDIR, "grass_map.ico"), wx.BITMAP_TYPE_ICO
)
)

# bind to frame
parent.Bind(wx.EVT_CLOSE, self.OnQuit)

# extend shortcuts and create frame accelerator table
self.shortcuts_table.append((self.OnFullScreen, wx.ACCEL_NORMAL, wx.WXK_F11))
self._initShortcuts()

# add Map Display panel to Map Display frame
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self, proportion=1, flag=wx.EXPAND)
parent.SetSizer(sizer)
parent.Layout()


class GCPList(ListCtrl, CheckListCtrlMixin, ListCtrlAutoWidthMixin):
def __init__(
self,
Expand Down
124 changes: 61 additions & 63 deletions gui/wxpython/image2target/ii2t_mapdisplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
for various display management functions, one for manipulating GCPs.
Classes:
- mapdisplay::MapFrame
- mapdisplay::MapPanel
(C) 2006-2011 by the GRASS Development Team
Expand All @@ -27,7 +27,7 @@
from mapdisp.gprint import PrintOptions
from core.gcmd import GMessage
from gui_core.dialogs import GetImageHandlers, ImageSizeDialog
from gui_core.mapdisp import SingleMapFrame
from gui_core.mapdisp import SingleMapPanel
from gui_core.wrap import Menu
from mapwin.buffered import BufferedMapWindow
from mapwin.base import MapWindowProperties
Expand All @@ -39,8 +39,8 @@
cmdfilename = None


class MapFrame(SingleMapFrame):
"""Main frame for map display window. Drawing takes place in
class MapPanel(SingleMapPanel):
"""Main panel for map display window. Drawing takes place in
child double buffered drawing window.
"""

Expand All @@ -63,10 +63,10 @@ def __init__(
:param toolbars: array of activated toolbars, e.g. ['map', 'digit']
:param map: instance of render.Map
:param auimgs: AUI manager
:param kwargs: wx.Frame attribures
:param kwargs: wx.Panel attribures
"""

SingleMapFrame.__init__(
SingleMapPanel.__init__(
self,
parent=parent,
giface=giface,
Expand Down Expand Up @@ -101,7 +101,7 @@ def __init__(
#

# items for choice
self.statusbarItems = [
statusbarItems = [
sb.SbCoordinates,
sb.SbRegionExtent,
sb.SbCompRegionExtent,
Expand All @@ -115,20 +115,7 @@ def __init__(
]

# create statusbar and its manager
statusbar = self.CreateStatusBar(number=4, style=0)
statusbar.SetStatusWidths([-5, -2, -1, -1])
self.statusbarManager = sb.SbManager(mapframe=self, statusbar=statusbar)

# fill statusbar manager
self.statusbarManager.AddStatusbarItemsByClass(
self.statusbarItems, mapframe=self, statusbar=statusbar
)
self.statusbarManager.AddStatusbarItem(
sb.SbMask(self, statusbar=statusbar, position=2)
)
self.statusbarManager.AddStatusbarItem(
sb.SbRender(self, statusbar=statusbar, position=3)
)
self.statusbar = self.CreateStatusbar(statusbarItems)

self.statusbarManager.SetMode(8) # goto GCP

Expand Down Expand Up @@ -190,44 +177,7 @@ def __init__(
# self.SrcMapWindow.SetSize((300, 300))
# self.TgtMapWindow.SetSize((300, 300))
self.list.SetSize((100, 150))
self._mgr.AddPane(
self.list,
wx.aui.AuiPaneInfo()
.Name("gcplist")
.Caption(_("GCP List"))
.LeftDockable(False)
.RightDockable(False)
.PinButton()
.FloatingSize((600, 200))
.CloseButton(False)
.DestroyOnClose(True)
.Top()
.Layer(1)
.MinSize((200, 100)),
)
self._mgr.AddPane(
self.SrcMapWindow,
wx.aui.AuiPaneInfo()
.Name("source")
.Caption(_("Source Display"))
.Dockable(False)
.CloseButton(False)
.DestroyOnClose(True)
.Floatable(False)
.Centre(),
)
self._mgr.AddPane(
self.TgtMapWindow,
wx.aui.AuiPaneInfo()
.Name("target")
.Caption(_("Target Display"))
.Dockable(False)
.CloseButton(False)
.DestroyOnClose(True)
.Floatable(False)
.Right()
.Layer(0),
)
self._addPanes()

srcwidth, srcheight = self.SrcMapWindow.GetSize()
tgtwidth, tgtheight = self.TgtMapWindow.GetSize()
Expand Down Expand Up @@ -275,7 +225,7 @@ def __init__(
self.statusbarManager.Update()

def _setUpMapWindow(self, mapWindow):
# TODO: almost the same implementation as for MapFrameBase (only names differ)
# TODO: almost the same implementation as for MapPanelBase (only names differ)
# enable or disable zoom history tool
mapWindow.zoomHistoryAvailable.connect(
lambda: self.GetMapToolbar().Enable("zoomback", enable=True)
Expand All @@ -297,7 +247,10 @@ def AddToolbar(self, name):
"""
# default toolbar
if name == "map":
self.toolbars["map"] = MapToolbar(self, self._toolSwitcher, self._giface)
if "map" not in self.toolbars:
self.toolbars["map"] = MapToolbar(
self, self._toolSwitcher, self._giface
)

self._mgr.AddPane(
self.toolbars["map"],
Expand All @@ -317,7 +270,8 @@ def AddToolbar(self, name):

# GCP display
elif name == "gcpdisp":
self.toolbars["gcpdisp"] = GCPDisplayToolbar(self, self._toolSwitcher)
if "gcpdisp" not in self.toolbars:
self.toolbars["gcpdisp"] = GCPDisplayToolbar(self, self._toolSwitcher)

self._mgr.AddPane(
self.toolbars["gcpdisp"],
Expand All @@ -337,7 +291,8 @@ def AddToolbar(self, name):
if not self.show_target:
self.toolbars["gcpdisp"].Enable("zoommenu", enable=False)

self.toolbars["gcpman"] = GCPManToolbar(self)
if "gcpman" not in self.toolbars:
self.toolbars["gcpman"] = GCPManToolbar(self)

self._mgr.AddPane(
self.toolbars["gcpman"],
Expand All @@ -357,6 +312,49 @@ def AddToolbar(self, name):

self._mgr.Update()

def _addPanes(self):
"""Add mapwindows, toolbars and statusbar to aui manager"""
self._mgr.AddPane(
self.list,
wx.aui.AuiPaneInfo()
.Name("gcplist")
.Caption(_("GCP List"))
.LeftDockable(False)
.RightDockable(False)
.PinButton()
.FloatingSize((600, 200))
.CloseButton(False)
.DestroyOnClose(True)
.Top()
.Layer(1)
.MinSize((200, 100)),
)
self._mgr.AddPane(
self.SrcMapWindow,
wx.aui.AuiPaneInfo()
.Name("source")
.Caption(_("Source Display"))
.Dockable(False)
.CloseButton(False)
.DestroyOnClose(True)
.Floatable(False)
.Centre(),
)
self._mgr.AddPane(
self.TgtMapWindow,
wx.aui.AuiPaneInfo()
.Name("target")
.Caption(_("Target Display"))
.Dockable(False)
.CloseButton(False)
.DestroyOnClose(True)
.Floatable(False)
.Right()
.Layer(0),
)
# statusbar
self.AddStatusbarPane()

def OnUpdateProgress(self, event):
"""
Update progress bar info
Expand Down
Loading

0 comments on commit 0a3a569

Please sign in to comment.