Skip to content

Commit

Permalink
wxGUI: Save current Single-Window layout to a workspace file (#2768)
Browse files Browse the repository at this point in the history
  • Loading branch information
lindakarlovska committed Feb 28, 2023
1 parent 78243ae commit 1aa5bc0
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 2 deletions.
40 changes: 40 additions & 0 deletions gui/wxpython/core/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ def __init__(self, tree):
"cwd": None,
} # current working directory

#
# layout
#
self.layout = {
"panes": None,
"notebook": None,
}

#
#
# list of mapdisplays
#
Expand Down Expand Up @@ -128,6 +137,18 @@ def __processFile(self):
if cwdPath:
self.layerManager["cwd"] = cwdPath

#
# layout
#
layout = self.root.find("layout")
if layout:
self.layout["panes"] = self.__filterValue(
self.__getNodeText(layout, "panes")
)
self.layout["notebook"] = self.__filterValue(
self.__getNodeText(layout, "notebook")
)

#
# displays
#
Expand Down Expand Up @@ -898,6 +919,25 @@ def __init__(self, lmgr, file):
self.indent -= 4
file.write("%s</layer_manager>\n" % (" " * self.indent))

# layout
if UserSettings.Get(group="appearance", key="singleWindow", subkey="enabled"):
layout_panes = self.lmgr.GetAuiManager().SavePerspective()
layout_notebook = self.lmgr.GetAuiNotebook().SavePerspective()
file.write("{indent}<layout>\n".format(indent=" " * self.indent))
self.indent += 4
file.write(
"{indent}<panes>{layout}</panes>\n".format(
indent=" " * self.indent, layout=layout_panes
)
)
file.write(
"{indent}<notebook>{layout}</notebook>\n".format(
indent=" " * self.indent, layout=layout_notebook
)
)
self.indent -= 4
file.write("{indent}</layout>\n".format(indent=" " * self.indent))

# list of displays
for page in range(0, self.lmgr.GetLayerNotebook().GetPageCount()):
dispName = self.lmgr.GetLayerNotebook().GetPageText(page)
Expand Down
9 changes: 9 additions & 0 deletions gui/wxpython/lmgr/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,15 @@ def Load(self, filename):
self.lmgr.nvizUpdateSettings()
mapdisplay[i].toolbars["map"].combo.SetSelection(1)

#
# load layout
#
if UserSettings.Get(group="appearance", key="singleWindow", subkey="enabled"):
if gxwXml.layout["panes"]:
self.lmgr.GetAuiManager().LoadPerspective(gxwXml.layout["panes"])
if gxwXml.layout["notebook"]:
self.lmgr.GetAuiNotebook().LoadPerspective(gxwXml.layout["notebook"])

self.workspaceFile = filename
self.AddFileToHistory()
return True
Expand Down
16 changes: 14 additions & 2 deletions gui/wxpython/main_window/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,20 @@ def RunDisplayCmd(self, command):
lcmd=command,
)

def GetAuiManager(self):
"""Get aui manager
:return: aui manager instance
"""
return self._auimgr

def GetAuiNotebook(self):
"""Get aui notebook
:return: aui notebook instance
"""
return self.mapnotebook

def GetLayerNotebook(self):
"""Get Layers Notebook"""
return self.notebookLayers
Expand Down Expand Up @@ -1948,8 +1962,6 @@ def _onMapDisplayFocus(self, notebookLayerPage):
# moved from mapdisp/frame.py
# TODO: why it is called 3 times when getting focus?
# and one times when loosing focus?
if self.workspace_manager.loadingWorkspace:
return
pgnum = self.notebookLayers.GetPageIndex(notebookLayerPage)
if pgnum > -1:
self.notebookLayers.SetSelection(pgnum)
Expand Down

0 comments on commit 1aa5bc0

Please sign in to comment.