Skip to content

Commit

Permalink
r.in.pdal: info.cpp also needs PDALCPPFLAGS (OSGeo#1768)
Browse files Browse the repository at this point in the history
  • Loading branch information
a0x8o committed Aug 23, 2024
1 parent 8c3ec54 commit 4bce14c
Show file tree
Hide file tree
Showing 4 changed files with 183 additions and 11 deletions.
4 changes: 4 additions & 0 deletions doc/notebooks/jupyter_integration.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,12 @@
"outputs": [],
"source": [
"# Demonstration of GrassRenderer for non-interactive map display\n",
<<<<<<< HEAD
"\n",
"r = gj.GrassRenderer(height=540, filename = \"streams_maps.png\")\n",
=======
"r = gj.GrassRenderer(height=540)\n",
>>>>>>> 523219d6d4 (r.in.pdal: info.cpp also needs PDALCPPFLAGS (#1768))
"\n",
"r.run(\"d.rast\", map=\"elevation\")\n",
"r.run(\"d.vect\", map=\"streams\")\n",
Expand Down
135 changes: 130 additions & 5 deletions gui/wxpython/main_window/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,14 @@
from lmgr.statusbar import SbMain
from lmgr.workspace import WorkspaceManager
from lmgr.pyshell import PyShellWindow
<<<<<<< HEAD
from lmgr.giface import LayerManagerGrassInterface
=======
from lmgr.giface import (
LayerManagerGrassInterface,
LayerManagerGrassInterfaceForMapDisplay,
)
>>>>>>> 523219d6d4 (r.in.pdal: info.cpp also needs PDALCPPFLAGS (#1768))
from mapdisp.frame import MapPanel
from datacatalog.catalog import DataCatalog
from history.browser import HistoryBrowser
Expand Down Expand Up @@ -199,8 +206,8 @@ def show_menu_errors(messages):
)
=======
size = wx.Display().GetGeometry().GetSize()
self.PANE_BEST_SIZE = tuple(t / 5 for t in size)
self.PANE_MIN_SIZE = tuple(t / 10 for t in size)
self.PANE_BEST_SIZE = tuple(t / 3 for t in size)
self.PANE_MIN_SIZE = tuple(t / 7 for t in size)
# create widgets and build panes
self.CreateMenuBar()
Expand Down Expand Up @@ -354,6 +361,7 @@ def IsPaneShown(self, name):
return self._auimgr.GetPane(name).IsShown()
return False
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
def SetStatusText(self, *args):
Expand All @@ -369,6 +377,24 @@ def _createMainNotebook(self):
>>>>>>> 4fcbd3f967 (Add Binder badge/button to readme (#1628))
=======
>>>>>>> 5871ca876b (wxGUI/Single-Window GUI: arrangement of basic widgets (#1621))
=======
def _createMapNotebook(self):
"""Create Map Display notebook"""
# create the notebook off-window to avoid flicker
client_size = self.GetClientSize()
notebook_style = (
aui.AUI_NB_DEFAULT_STYLE | aui.AUI_NB_TAB_EXTERNAL_MOVE | wx.NO_BORDER
)
self.mapnotebook = aui.AuiNotebook(
self,
-1,
wx.Point(client_size.x, client_size.y),
wx.Size(430, 200),
agwStyle=notebook_style,
)
self.mapnotebook.SetArtProvider(aui.AuiDefaultTabArt())
>>>>>>> 523219d6d4 (r.in.pdal: info.cpp also needs PDALCPPFLAGS (#1768))
def _createDataCatalog(self, parent):
"""Initialize Data Catalog widget"""
self.datacatalog = DataCatalog(parent=parent, giface=self._giface)
Expand Down Expand Up @@ -458,6 +484,9 @@ def _createPythonShell(self, parent):
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> 523219d6d4 (r.in.pdal: info.cpp also needs PDALCPPFLAGS (#1768))
def OnNewDisplay(self, event=None):
"""Create new layer tree and map display window instance"""
self.NewDisplay()
Expand All @@ -477,6 +506,7 @@ def NewDisplay(self, name=None, show=True):
self.pg_panel = wx.Panel(
self.notebookLayers, id=wx.ID_ANY, style=wx.BORDER_NONE
)
<<<<<<< HEAD
# create display toolbar
dmgrToolbar = DisplayPanelToolbar(guiparent=self.pg_panel, parent=self)

Expand All @@ -496,16 +526,44 @@ def CreateNewMapDisplay(giface, layertree):
mapdisplay = MapPanel(
parent=self.mainnotebook,
giface=giface,
=======
self.notebookLayers.AddPage(page=self.pg_panel, text=name, select=True)
self.currentPage = self.notebookLayers.GetCurrentPage()
self.currentPageNum = self.notebookLayers.GetSelection()

def CreateNewMapDisplay(layertree):
"""Callback function which creates a new Map Display window
:param layertree: layer tree object
:return: reference to mapdisplay instance
"""
# create instance of Map Display interface
self._gifaceForDisplay = LayerManagerGrassInterfaceForMapDisplay(
self._giface, layertree
)

# create Map Display
mapdisplay = MapPanel(
parent=self.mapnotebook,
giface=self._gifaceForDisplay,
>>>>>>> 523219d6d4 (r.in.pdal: info.cpp also needs PDALCPPFLAGS (#1768))
id=wx.ID_ANY,
tree=layertree,
lmgr=self,
Map=layertree.Map,
<<<<<<< HEAD
dockable=True,
=======
>>>>>>> 523219d6d4 (r.in.pdal: info.cpp also needs PDALCPPFLAGS (#1768))
title=name,
size=globalvar.MAP_WINDOW_SIZE,
)
# add map display panel to notebook and make it current
<<<<<<< HEAD
self.mainnotebook.AddPage(mapdisplay, name)
=======
self.mapnotebook.AddPage(mapdisplay, name)
self.mapnotebook.SetSelection(self.currentPageNum)
>>>>>>> 523219d6d4 (r.in.pdal: info.cpp also needs PDALCPPFLAGS (#1768))

# set map display properties
self._setUpMapDisplay(mapdisplay)
Expand Down Expand Up @@ -534,14 +592,20 @@ def CreateNewMapDisplay(giface, layertree):

# layout for controls
cb_boxsizer = wx.BoxSizer(wx.VERTICAL)
<<<<<<< HEAD
cb_boxsizer.Add(dmgrToolbar, proportion=0, flag=wx.EXPAND)
=======
>>>>>>> 523219d6d4 (r.in.pdal: info.cpp also needs PDALCPPFLAGS (#1768))
cb_boxsizer.Add(self.GetLayerTree(), proportion=1, flag=wx.EXPAND, border=1)
self.currentPage.SetSizer(cb_boxsizer)
cb_boxsizer.Fit(self.GetLayerTree())
self.currentPage.Layout()
self.GetLayerTree().Layout()
<<<<<<< HEAD
# Repaint Layers pane map display toolbar widget on the wxMac
self._repaintLayersPaneMapDisplayToolbar()
=======
>>>>>>> 523219d6d4 (r.in.pdal: info.cpp also needs PDALCPPFLAGS (#1768))

self.displayIndex += 1

Expand All @@ -552,6 +616,7 @@ def _setUpMapDisplay(self, mapdisplay):
page = self.currentPage
def CanCloseDisplay(askIfSaveWorkspace):
<<<<<<< HEAD
"""Callback to check if user wants to close display. Map
Display index can be different from index in Display tab.

Expand All @@ -566,10 +631,16 @@ def CanCloseDisplay(askIfSaveWorkspace):
pgnum_dict["layers"] = self.notebookLayers.GetPageIndex(page)
pgnum_dict["mainnotebook"] = self.mainnotebook.GetPageIndex(mapdisplay)
name = self.notebookLayers.GetPageText(pgnum_dict["layers"])
=======
"""Callback to check if user wants to close display"""
pgnum = self.notebookLayers.GetPageIndex(page)
name = self.notebookLayers.GetPageText(pgnum)
>>>>>>> 523219d6d4 (r.in.pdal: info.cpp also needs PDALCPPFLAGS (#1768))
caption = _("Close Map Display {}").format(name)
if not askIfSaveWorkspace or (
askIfSaveWorkspace and self.workspace_manager.CanClosePage(caption)
):
<<<<<<< HEAD
return pgnum_dict
return None
Expand All @@ -578,6 +649,17 @@ def CanCloseDisplay(askIfSaveWorkspace):
# bind various events
mapdisplay.onFocus.connect(
lambda page=self.currentPage: self._onMapDisplayFocus(page),
=======
return pgnum
return None
mapdisplay.canCloseDisplayCallback = CanCloseDisplay
# bind various events
mapdisplay.Bind(
wx.EVT_ACTIVATE,
lambda event, page=self.currentPage: self._onMapDisplayFocus(page),
>>>>>>> 523219d6d4 (r.in.pdal: info.cpp also needs PDALCPPFLAGS (#1768))
)
mapdisplay.starting3dMode.connect(
Expand All @@ -587,6 +669,10 @@ def CanCloseDisplay(askIfSaveWorkspace):
)
mapdisplay.starting3dMode.connect(self.AddNvizTools)
mapdisplay.ending3dMode.connect(self.RemoveNvizTools)
<<<<<<< HEAD
=======
mapdisplay.closingDisplay.connect(self._closePageNoEvent)
>>>>>>> 523219d6d4 (r.in.pdal: info.cpp also needs PDALCPPFLAGS (#1768))
# set default properties
mapdisplay.SetProperties(
Expand All @@ -606,6 +692,7 @@ def CanCloseDisplay(askIfSaveWorkspace):
group="display", key="showCompExtent", subkey="enabled"
),
)
<<<<<<< HEAD
def BuildPanes(self):
"""Build panes - toolbars as well as panels"""
Expand Down Expand Up @@ -870,17 +957,19 @@ def _createMapDisplay(self, parent):
"""Set up Map Display"""
# blank panel for testing
self.mapdisplay = wx.Panel(parent=parent)
=======
>>>>>>> 523219d6d4 (r.in.pdal: info.cpp also needs PDALCPPFLAGS (#1768))
def BuildPanes(self):
"""Build panes - toolbars as well as panels"""
# initialize all main widgets
self._createMapNotebook()
self._createDataCatalog(parent=self)
self._createDisplay(parent=self)
self._createSearchModule(parent=self)
self._createConsole(parent=self)
self._createPythonShell(parent=self)
self._createMapDisplay(parent=self)
self.toolbars = {
"workspace": LMWorkspaceToolbar(parent=self),
"tools": LMToolsToolbar(parent=self),
Expand Down Expand Up @@ -922,8 +1011,8 @@ def BuildPanes(self):
)
self._auimgr.AddPane(
self.mapdisplay,
aui.AuiPaneInfo().Name("map display").CenterPane().PaneBorder(True),
self.mapnotebook,
aui.AuiPaneInfo().Name("map display content").CenterPane().PaneBorder(True),
)
self._auimgr.AddPane(
Expand Down Expand Up @@ -1105,6 +1194,12 @@ def AddNvizTools(self, firstTime):
.MinimizeButton(True)
.MaximizeButton(True),
)
<<<<<<< HEAD
=======

self._auimgr.GetPane("nviz").Show()
self._auimgr.Update()
>>>>>>> 523219d6d4 (r.in.pdal: info.cpp also needs PDALCPPFLAGS (#1768))

self._auimgr.GetPane("nviz").Show()
self._auimgr.Update()
Expand Down Expand Up @@ -1284,9 +1379,16 @@ def OnCBPageChanged(self, event):
Also change active map notebook tab."""
self.currentPage = self.notebookLayers.GetCurrentPage()
self.currentPageNum = self.notebookLayers.GetSelection()
<<<<<<< HEAD
if hasattr(self.currentPage, "maptree") and self.mainnotebook.GetCurrentPage():
self.mainnotebook.SetSelectionToMainPage(self.GetMapDisplay())
=======
try:
self.mapnotebook.SetSelection(self.GetMapDisplayIndex())
except Exception:
pass
>>>>>>> 523219d6d4 (r.in.pdal: info.cpp also needs PDALCPPFLAGS (#1768))
event.Skip()
Expand Down Expand Up @@ -1316,18 +1418,32 @@ def OnCBPageClosing(self, event):

maptree = self.notebookLayers.GetPage(event.GetSelection()).maptree
maptree.GetMapDisplay().CleanUp()
<<<<<<< HEAD
self.mainnotebook.DeleteMainPage(self.GetMapDisplay())
=======
self.mapnotebook.DeletePage(self.GetMapDisplayIndex())
>>>>>>> 523219d6d4 (r.in.pdal: info.cpp also needs PDALCPPFLAGS (#1768))
maptree.Close(True)

self.currentPage = None

event.Skip()

<<<<<<< HEAD
def _renamePageNoEvent(self, pgnum_dict, is_docked, text):
if is_docked:
self.mainnotebook.SetMainPageText(
self.mainnotebook.GetPage(pgnum_dict["mainnotebook"]), text
)
=======
def _closePageNoEvent(self, page_index):
"""Close page and destroy map display without
generating notebook page closing event"""
self.notebookLayers.Unbind(FN.EVT_FLATNOTEBOOK_PAGE_CLOSING)
self.notebookLayers.DeletePage(page_index)
self.notebookLayers.Bind(FN.EVT_FLATNOTEBOOK_PAGE_CLOSING, self.OnCBPageClosing)
self.mapnotebook.DeletePage(page_index)
>>>>>>> 523219d6d4 (r.in.pdal: info.cpp also needs PDALCPPFLAGS (#1768))
def _closePageNoEvent(self, pgnum_dict, is_docked):
"""If map display is docked, close page and destroy map display without
Expand Down Expand Up @@ -1543,6 +1659,11 @@ def GetAllMapDisplays(self):
"""Get all (open) map displays"""
return self.GetMapDisplay(onlyCurrent=False)
def GetMapDisplayIndex(self):
"""Get the index of the currently active map display tab.
Can be different than index of related layertree."""
return self.mapnotebook.GetPageIndex(self.GetMapDisplay())
def GetLogWindow(self):
"""Gets console for command output and messages"""
return self._gconsole
Expand Down Expand Up @@ -2043,7 +2164,11 @@ def OnRenameDisplay(self, event):
if dlg.ShowModal() == wx.ID_OK:
name = dlg.GetValue()
self.notebookLayers.SetPageText(page=self.currentPageNum, text=name)
<<<<<<< HEAD
self.mainnotebook.SetMainPageText(page=self.GetMapDisplay(), text=name)
=======
self.mapnotebook.SetPageText(page_idx=self.GetMapDisplayIndex(), text=name)
>>>>>>> 523219d6d4 (r.in.pdal: info.cpp also needs PDALCPPFLAGS (#1768))
dlg.Destroy()
def OnRasterRules(self, event):
Expand Down
Loading

0 comments on commit 4bce14c

Please sign in to comment.