Browse Source

wxGUI/datacatalog: add convenient functions to context menu

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@71186 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová 7 years ago
parent
commit
05e989f63d
1 changed files with 38 additions and 1 deletions
  1. 38 1
      gui/wxpython/datacatalog/tree.py

+ 38 - 1
gui/wxpython/datacatalog/tree.py

@@ -842,6 +842,34 @@ class DataCatalogTree(LocationMapTree):
             self.changeLocation.emit(mapset=self.selected_mapset.label, location=self.selected_location.label)
             self.changeLocation.emit(mapset=self.selected_mapset.label, location=self.selected_location.label)
         self.ExpandCurrentMapset()
         self.ExpandCurrentMapset()
 
 
+    def OnMetadata(self, event):
+        """Show metadata of any raster/vector/3draster"""
+        def done(event):
+            gscript.try_remove(gisrc)
+
+        if self.selected_type.label == 'raster':
+            cmd = ['r.info']
+        elif self.selected_type.label == 'vector':
+            cmd = ['v.info']
+        elif self.selected_type.label == 'raster_3d':
+            cmd = ['r3.info']
+        cmd.append('map=%s@%s' % (self.selected_layer.label, self.selected_mapset.label))
+
+        gisrc, env = gscript.create_environment(
+            gisenv()['GISDBASE'],
+            self.selected_location.label, self.selected_mapset.label)
+        # print output to command log area
+        # temp gisrc file must be deleted onDone
+        self._giface.RunCmd(cmd, env=env, onDone=done)
+
+    def OnCopyName(self, event):
+        """Copy layer name to clipboard"""
+        if wx.TheClipboard.Open():
+            do = wx.TextDataObject()
+            do.SetText('%s@%s' % (self.selected_layer.label, self.selected_mapset.label))
+            wx.TheClipboard.SetData(do)
+            wx.TheClipboard.Close()
+
     def Filter(self, text):
     def Filter(self, text):
         """Filter tree based on name and type."""
         """Filter tree based on name and type."""
         text = text.strip()
         text = text.strip()
@@ -905,6 +933,10 @@ class DataCatalogTree(LocationMapTree):
         menu.AppendItem(item)
         menu.AppendItem(item)
         self.Bind(wx.EVT_MENU, self.OnCopyMap, item)
         self.Bind(wx.EVT_MENU, self.OnCopyMap, item)
 
 
+        item = wx.MenuItem(menu, wx.NewId(), _("Copy &name"))
+        menu.AppendItem(item)
+        self.Bind(wx.EVT_MENU, self.OnCopyName, item)
+
         item = wx.MenuItem(menu, wx.NewId(), _("&Paste"))
         item = wx.MenuItem(menu, wx.NewId(), _("&Paste"))
         menu.AppendItem(item)
         menu.AppendItem(item)
         self.Bind(wx.EVT_MENU, self.OnPasteMap, item)
         self.Bind(wx.EVT_MENU, self.OnPasteMap, item)
@@ -921,13 +953,18 @@ class DataCatalogTree(LocationMapTree):
         self.Bind(wx.EVT_MENU, self.OnRenameMap, item)
         self.Bind(wx.EVT_MENU, self.OnRenameMap, item)
         item.Enable(currentMapset)
         item.Enable(currentMapset)
 
 
+        menu.AppendSeparator()
+
         if not isinstance(self._giface, StandaloneGrassInterface) and \
         if not isinstance(self._giface, StandaloneGrassInterface) and \
            self.selected_location.label == genv['LOCATION_NAME']:
            self.selected_location.label == genv['LOCATION_NAME']:
-            menu.AppendSeparator()
             item = wx.MenuItem(menu, wx.NewId(), _("&Display layer"))
             item = wx.MenuItem(menu, wx.NewId(), _("&Display layer"))
             menu.AppendItem(item)
             menu.AppendItem(item)
             self.Bind(wx.EVT_MENU, self.OnDisplayLayer, item)
             self.Bind(wx.EVT_MENU, self.OnDisplayLayer, item)
 
 
+        item = wx.MenuItem(menu, wx.NewId(), _("Show &metadata"))
+        menu.AppendItem(item)
+        self.Bind(wx.EVT_MENU, self.OnMetadata, item)
+
         self.PopupMenu(menu)
         self.PopupMenu(menu)
         menu.Destroy()
         menu.Destroy()