Skip to content

Commit

Permalink
wxGUI: startup screen code removed, instead the idea of demolocation …
Browse files Browse the repository at this point in the history
…is implemented.
  • Loading branch information
lindakladivova committed Feb 24, 2021
1 parent f252615 commit 80ec058
Show file tree
Hide file tree
Showing 8 changed files with 199 additions and 1,128 deletions.
2 changes: 1 addition & 1 deletion gui/wxpython/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ SRCFILES := $(wildcard icons/*.py scripts/*.py xml/*) \
mapswipe/*.py modules/*.py nviz/*.py psmap/*.py rdigit/*.py \
rlisetup/*.py startup/*.py timeline/*.py vdigit/*.py \
vnet/*.py web_services/*.py wxplot/*.py iscatt/*.py tplot/*.py photo2image/*.py image2target/*.py) \
gis_set.py gis_set_error.py wxgui.py README
wxgui.py README

DSTFILES := $(patsubst %,$(DSTDIR)/%,$(SRCFILES)) \
$(patsubst %.py,$(DSTDIR)/%.pyc,$(filter %.py,$(SRCFILES)))
Expand Down
35 changes: 33 additions & 2 deletions gui/wxpython/datacatalog/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@
from datacatalog.infomanager import DataCatalogInfoManager
from gui_core.wrap import Menu
from gui_core.forms import GUI
from grass.script import gisenv

from grass.pydispatch.signal import Signal

from grass.grassdb.checks import is_current_mapset_in_demolocation
from startup.guiutils import read_gisrc


class DataCatalog(wx.Panel):
Expand Down Expand Up @@ -65,9 +67,23 @@ def __init__(self, parent, giface=None, id=wx.ID_ANY,
# some layout
self._layout()

# show data structure infobar for first-time user with proper layout
# show infobar if applicable
if is_current_mapset_in_demolocation():
wx.CallLater(2000, self.showDataStructureInfo)
grassrc = read_gisrc()
if grassrc['REASON'] == "invalid":
if (grassrc['UNUSED_GISDBASE'] == os.getcwd() and
grassrc['UNUSED_LOCATION_NAME'] == "<UNKNOWN>" and
grassrc['UNUSED_MAPSET'] == "<UNKNOWN>"):
# show data structure infobar for first-time user
wx.CallLater(2000, self.showDataStructureInfo)
else:
wx.CallLater(2000, self.showBasicDemolocationInfo)
elif "owned by different user" in grassrc['REASON']:
# show basic info
wx.CallLater(2000, self.showBasicDemolocationInfo)
elif grassrc['REASON'] == "locked":
# show info allowing to switch to locked mapset
wx.CallLater(2000, self.showLockedMapsetInfo)

def _layout(self):
"""Do layout"""
Expand All @@ -85,6 +101,12 @@ def _layout(self):
def showDataStructureInfo(self):
self.infoManager.ShowDataStructureInfo(self.OnCreateLocation)

def showLockedMapsetInfo(self):
self.infoManager.ShowLockedMapsetInfo(self.OnSwitchMapset)

def showBasicDemolocationInfo(self):
self.infoManager.ShowBasicDemolocationInfo()

def showImportDataInfo(self):
self.infoManager.ShowImportDataInfo(self.OnImportOgrLayers, self.OnImportGdalLayers)

Expand Down Expand Up @@ -135,6 +157,15 @@ def OnDownloadLocation(self, event):
db_node, loc_node, mapset_node = self.tree.GetCurrentDbLocationMapsetNode()
self.tree.DownloadLocation(db_node)

def OnSwitchMapset(self, event):
"""Switch to given mapset"""
grassrc = read_gisrc()
grassdb=grassrc['UNUSED_GISDBASE']
location=grassrc['UNUSED_LOCATION_NAME']
mapset=grassrc['UNUSED_MAPSET']
self.tree.SwitchMapset(grassdb, location, mapset)
event.Skip()

def OnImportGdalLayers(self, event):
"""Convert multiple GDAL layers to GRASS raster map layers"""
from modules.import_export import GdalImportDialog
Expand Down
32 changes: 31 additions & 1 deletion gui/wxpython/datacatalog/infomanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import wx

from grass.script import gisenv

from startup.guiutils import read_gisrc

class DataCatalogInfoManager:
"""Manager for all things related to info bar in Data Catalog"""
Expand Down Expand Up @@ -58,5 +58,35 @@ def ShowImportDataInfo(self, OnImportOgrLayersHandler, OnImportGdalLayersHandler
).format(loc=gisenv()['LOCATION_NAME'])
self.infoBar.ShowMessage(message, wx.ICON_INFORMATION, buttons)

def ShowLockedMapsetInfo(self, OnSwitchMapsetHandler):
"""Show info when last used mapset is locked"""
grassrc = read_gisrc()
buttons = [("Switch to last used mapset", OnSwitchMapsetHandler)]
message = _(
"Last used mapset in path '{lastdb}/{lastloc}/{lastmapset}' is locked."
"GRASS GIS has started in the default Location {loc} which uses "
"WGS 84 (EPSG:4326). To continue, set usable mapset through Data "
"Catalog below, or remove .gislock and switch to last usable mapset."
).format(lastdb=grassrc['UNUSED_GISDBASE'],
lastloc=grassrc['UNUSED_LOCATION_NAME'],
lastmapset=grassrc['UNUSED_MAPSET'],
loc=gisenv()['LOCATION_NAME'])
self.infoBar.ShowMessage(message, wx.ICON_INFORMATION, buttons)

def ShowBasicDemolocationInfo(self):
"""Show info when last used mapset is invalid or owned by different user"""
grassrc = read_gisrc()
message = _(
"Last used mapset in path '{lastdb}/{lastloc}/{lastmapset}' is {reason}."
"GRASS GIS has started in the default Location {loc} which uses "
"WGS 84 (EPSG:4326). To continue, find or create usable mapset through "
"Data catalog below."
).format(lastdb=grassrc['UNUSED_GISDBASE'],
lastmapset=grassrc['UNUSED_MAPSET'],
lastloc=grassrc['UNUSED_LOCATION_NAME'],
reason=grassrc['REASON'],
loc=gisenv()['LOCATION_NAME'])
self.infoBar.ShowMessage(message, wx.ICON_INFORMATION)

def _onLearnMore(self, event):
self._giface.Help(entry="grass_database")
Loading

0 comments on commit 80ec058

Please sign in to comment.