[GRASS-SVN] r42059 - grass-addons/gui/wxpython/data_catalog
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Apr 29 14:49:29 EDT 2010
Author: epifanio
Date: 2010-04-29 14:49:28 -0400 (Thu, 29 Apr 2010)
New Revision: 42059
Added:
grass-addons/gui/wxpython/data_catalog/conf.xml
grass-addons/gui/wxpython/data_catalog/tcp4ossim.py
Modified:
grass-addons/gui/wxpython/data_catalog/LayerTree.py
grass-addons/gui/wxpython/data_catalog/catalog.py
grass-addons/gui/wxpython/data_catalog/mapdisplay.py
Log:
Work on code to connetc datacatalog with ossimplanet
Modified: grass-addons/gui/wxpython/data_catalog/LayerTree.py
===================================================================
--- grass-addons/gui/wxpython/data_catalog/LayerTree.py 2010-04-29 13:12:42 UTC (rev 42058)
+++ grass-addons/gui/wxpython/data_catalog/LayerTree.py 2010-04-29 18:49:28 UTC (rev 42059)
@@ -55,6 +55,7 @@
self.ID_COPY = wx.NewId()
self.ID_DEL = wx.NewId()
self.ID_OSSIM = wx.NewId()
+ self.ID_OSSIM2 = wx.NewId()
self.ID_INFO = wx.NewId()
self.ID_REPORT = wx.NewId()
@@ -93,6 +94,7 @@
self.Bind(wx.EVT_MENU,self.OnRename,id=self.ID_REN)
self.Bind(wx.EVT_MENU,self.OnDelete,id=self.ID_DEL)
self.Bind(wx.EVT_MENU,self.OnOssim,id=self.ID_OSSIM)
+ self.Bind(wx.EVT_MENU,self.OnOssim2,id=self.ID_OSSIM2)
self.Bind(wx.EVT_MENU,self.OnInfo,id=self.ID_INFO)
self.Bind(wx.EVT_MENU,self.OnReport,id=self.ID_REPORT)
@@ -289,7 +291,8 @@
mnuCopy = self.popupmenu.Append(self.ID_COPY,'&Copy\tCtrl+C')
mnuRename = self.popupmenu.Append(self.ID_REN,'&Rename\tCtrl-R')
mnuDel = self.popupmenu.Append(self.ID_DEL,'&Delete\tDEL')
- mnuOssim = self.popupmenu.Append(self.ID_OSSIM,'&send to OssimPlanet')
+ mnuOssim = self.popupmenu.Append(self.ID_OSSIM,'&Send to OssimPlanet')
+ mnuOssim = self.popupmenu.Append(self.ID_OSSIM2,'&Remove from OssimPlanet')
mnuInfo = self.popupmenu.Append(self.ID_INFO,'&Info')
mnuReport = self.popupmenu.Append(self.ID_REPORT,'&Report')
self.PopupMenu(self.popupmenu)
@@ -415,6 +418,25 @@
current = OssimPlanet(cmdflag)
current.start()
+
+ def OnOssim2( self,event ):
+ """
+ Performs grass command for deleting a map
+ """
+ item = self.GetSelection()
+
+ parent =self.GetItemParent(item)
+ if self.GetItemText(parent) == "Raster Map" :
+ cmdflag = 'r.planet.py -r map=' + str(self.GetItemText(item))
+ elif self.GetItemText(parent) == "Vector Map" :
+ cmdflag = 'v.planet.py -r map=' + str(self.GetItemText(item))
+
+ if cmdflag:
+
+ #command = ["r.planet.py", cmdflag]
+ #gcmd.CommandThread(command,stdout=None,stderr=None).run()
+ current = OssimPlanet(cmdflag)
+ current.start()
def OnDisplay(self, event):
Modified: grass-addons/gui/wxpython/data_catalog/catalog.py
===================================================================
--- grass-addons/gui/wxpython/data_catalog/catalog.py 2010-04-29 13:12:42 UTC (rev 42058)
+++ grass-addons/gui/wxpython/data_catalog/catalog.py 2010-04-29 18:49:28 UTC (rev 42059)
@@ -187,8 +187,8 @@
#setting splitter window
self.cmbPanel = wx.Panel(self,name="cmbpanel")
-
+
self.maptree = None
self.pg_panel = None
self.cb_loclist = []
@@ -197,8 +197,17 @@
#creating controls
self.mInfo = wx.TextCtrl(self.cmbPanel, wx.ID_ANY, style = wx.TE_READONLY,size=(300,30))
+ #
+ # start radiobutton to activate - deactivate the mouse actions to send position to ossimplanet
+ #
+ self.options = ['on', 'off']
+ self.radiobox = wx.RadioBox(self.cmbPanel, wx.ID_ANY, "", pos=(100, 0), choices=self.options, style=wx.HORIZONTAL)
+ self.radiobox.SetSelection(1)
+ #
+ #
#self.chkInfo = wx.CheckBox(self.cmbPanel, wx.ID_ANY,"display Info", wx.DefaultPosition, wx.DefaultSize)
self.treeExpand = wx.CheckBox(self.cmbPanel, wx.ID_ANY,"Expand All", wx.DefaultPosition, wx.DefaultSize)
+ #self.treeExpand2 = wx.CheckBox(self.cmbPanel, wx.ID_ANY,"Expand All 2", wx.DefaultPosition, wx.DefaultSize)
self.cmbLocation = wx.ComboBox(self.cmbPanel, value = "Select Location",size=wx.DefaultSize, choices=self.loclist)
self.cmbMapset = wx.ComboBox(self.cmbPanel, value = "Select Mapset", size=wx.DefaultSize)
#self.tree = wx.TreeCtrl(self.pLeft, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TR_HIDE_ROOT|wx.TR_HAS_BUTTONS|wx.TR_EDIT_LABELS)
@@ -2047,6 +2056,7 @@
self.cmbSizer.Add(self.cmbLocation)
self.cmbSizer.Add(self.cmbMapset)
self.cmbSizer.Add(self.mInfo)
+ self.cmbSizer.Add(self.radiobox)
#splitter window sizers
self.mSizer.Add(self.cmbPanel,flag=wx.EXPAND)
#self.mSizer.Add(self.win, 1, wx.EXPAND)
Added: grass-addons/gui/wxpython/data_catalog/conf.xml
===================================================================
--- grass-addons/gui/wxpython/data_catalog/conf.xml (rev 0)
+++ grass-addons/gui/wxpython/data_catalog/conf.xml 2010-04-29 18:49:28 UTC (rev 42059)
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+ <PlanetSashaSettings>
+ <tcp>
+ <host>localhost</host>
+ <dport>8000</dport>
+ <pport>7000</pport>
+ </tcp>
+ </PlanetSashaSettings>
\ No newline at end of file
Modified: grass-addons/gui/wxpython/data_catalog/mapdisplay.py
===================================================================
--- grass-addons/gui/wxpython/data_catalog/mapdisplay.py 2010-04-29 13:12:42 UTC (rev 42058)
+++ grass-addons/gui/wxpython/data_catalog/mapdisplay.py 2010-04-29 18:49:28 UTC (rev 42059)
@@ -32,6 +32,7 @@
import tempfile
import copy
import time
+from tcp4ossim import zoomto
@@ -1162,7 +1163,6 @@
self.Zoom(begin, end, zoomtype)
# redraw map
- self.flag=True
self.UpdateMap()
### self.OnPaint(None)
@@ -2082,7 +2082,7 @@
self.ZoomHistory(self.Map.region['n'], self.Map.region['s'],
self.Map.region['e'], self.Map.region['w'])
- self.flag = True
+
self.UpdateMap()
self.parent.StatusbarUpdate()
@@ -2096,9 +2096,7 @@
self.ZoomHistory(self.Map.region['n'], self.Map.region['s'],
self.Map.region['e'], self.Map.region['w'])
-
-
- self.flag=True
+
self.UpdateMap()
self.parent.StatusbarUpdate()
@@ -2436,6 +2434,9 @@
self.MapWindow = self.MapWindow2D
self.MapWindow.Bind(wx.EVT_MOTION, self.OnMotion)
self.MapWindow.Bind(wx.EVT_LEFT_DOWN, self.OnClick)
+ self.MapWindow.Bind(wx.EVT_RADIOBOX, self.printsomething)
+ # test for right click mouse event
+ #self.MapWindow.Bind(wx.EVT_RIGHT_DOWN, self.OnClick3)
self.MapWindow.SetCursor(self.cursors["default"])
# used by Nviz (3D display mode)
self.MapWindow3D = None
@@ -2498,10 +2499,6 @@
self.viewInfo = True #to display v/r.info on mapdisplay
self.gisdbase = self.gisrc['GISDBASE']
- self.current_zoom = 100
- self.zoom_step = 10
-
-
parent1 = self.GetParent()
rightpanel = parent1.GetParent()
@@ -2539,17 +2536,48 @@
#r.rightSizer.Add(self.maptree)
+
def OnClick(self,event):
x, y = self.MapWindow.Pixel2Cell(event.GetPosition())
- if self.MapWindow.mouse['use'] == "zoom":
- self.current_zoom = self.current_zoom + self.zoom_step
- self.frame.mInfo.SetValue(str(x) + ' , ' + str(y)+ ' , ' + str(self.current_zoom) + '%')
+ out = subprocess.Popen(['m.proj', '-o'], stdout=subprocess.PIPE, stdin=subprocess.PIPE).communicate("%s %s" % (x,y))[0]
+ f = out.replace("'"," ").replace('d',' ').replace('"',' ').replace('\n','').split('\t')
+ lon = f[0].split(' ')
+ lat = f[1].split(' ')[:-1]
+ if lat[-1] == 'N':
+ signlat = 1
+ if lat[-1] == 'S':
+ signlat = -1
+ if lon[-1] == 'E':
+ signlon = 1
+ if lon[-1] == 'W':
+ signlon = -1
+ lat = (float(lat[0]) + (float(lat[1]) / 60) + float(lat[2]) / 3600) * float(signlat)
+ lon = (float(lon[0]) + (float(lon[1]) / 60) + float(lon[2]) / 3600) * float(signlon)
+ self.frame.mInfo.SetValue(str(lat) + ' , ' + str(lon))
+ zoomto(str(lon),str(lat),15000)
+ event.Skip()
+
- #print self.current_zoom
+ def OnClick2(self,event):
+ x, y = self.MapWindow.Pixel2Cell(event.GetPosition())
+ self.frame.mInfo.SetValue(str(x) + ' , ' + str(y))
+ event.Skip()
+
+ # test for right click mouse event
+ def OnClick3(self,event):
+ x, y = self.MapWindow.Pixel2Cell(event.GetPosition())
+ self.frame.mInfo.SetValue(str(x) + ' , ' + str(y))
+ event.Skip()
+ # test for radiobox
+ def printsomething(self,event):
+ stringa = 'ffffff'
+ self.frame.mInfo.SetValue(str(stringa))
+ print stringa
event.Skip()
+
def read_gisrc(self):
"""
@@ -2949,9 +2977,6 @@
Zoom in the map.
Set mouse cursor, zoombox attributes, and zoom direction
"""
-
- self.zoom_step = 10
-
if self.toolbars['map']:
self.toolbars['map'].OnTool(event)
self.toolbars['map'].action['desc'] = ''
@@ -2969,9 +2994,6 @@
Zoom out the map.
Set mouse cursor, zoombox attributes, and zoom direction
"""
-
- self.zoom_step = -10
-
if self.toolbars['map']:
self.toolbars['map'].OnTool(event)
self.toolbars['map'].action['desc'] = ''
@@ -3017,7 +3039,6 @@
"""
self.Map.getRegion()
self.Map.getResolution()
- self.flag=True
self.UpdateMap()
# event.Skip()
Added: grass-addons/gui/wxpython/data_catalog/tcp4ossim.py
===================================================================
--- grass-addons/gui/wxpython/data_catalog/tcp4ossim.py (rev 0)
+++ grass-addons/gui/wxpython/data_catalog/tcp4ossim.py 2010-04-29 18:49:28 UTC (rev 42059)
@@ -0,0 +1,91 @@
+#!/usr/bin/env python
+import socket
+from xml.dom import minidom
+import os
+import sys
+
+apppath = os.path.abspath(os.path.dirname(sys.argv[0]))
+configfile = '%s/conf.xml' % (apppath)
+
+def parseTCPconf():
+ xmldoc = minidom.parse(configfile)
+ tcpconf = {}
+ planetsashaconf = xmldoc.firstChild
+ if planetsashaconf.childNodes[1].childNodes[1].firstChild is not None:
+ tcpconf['tcpHost'] = planetsashaconf.childNodes[1].childNodes[1].firstChild.data
+ else :
+ print 'tcpHost not found'
+ tcpconf['tcpHost'] = 'None'
+
+ if planetsashaconf.childNodes[1].childNodes[3].firstChild is not None:
+ tcpconf['tcpDport'] = planetsashaconf.childNodes[1].childNodes[3].firstChild.data
+ else :
+ print 'tcpDport not found'
+ tcpconf['tcpDport'] = 'None'
+
+ if planetsashaconf.childNodes[1].childNodes[5].firstChild is not None:
+ tcpconf['tcpPport'] = planetsashaconf.childNodes[1].childNodes[5].firstChild.data
+ else :
+ print 'tcpPport not found'
+ tcpconf['tcpPport'] = 'None'
+
+ return tcpconf
+
+
+def setparamconnection():
+ try :
+ conf = parseTCPconf()
+ host = conf['tcpHost']
+ nav = conf['tcpPport']
+ data = conf['tcpDport']
+ return host, nav, data
+ except :
+ print 'Use preference Panel to set preference'
+
+
+def addfile(output):
+ host = setparamconnection()[0]
+ dport = setparamconnection()[2]
+ ossim_data_xml = "<Add target=':idolbridge'><Image groupType='groundTexture'><filename>%s</filename> <id>%s</id><name>%s</name></Image></Add>" % (output,output,output)
+ ossimdata = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ ossimdata.connect((host, int(dport)))
+ try :
+ ossimdata.send(ossim_data_xml)
+ ossimdata.close()
+ except :
+ print "Connection error"
+
+
+def zoomto(lon,lat,distance):
+ host = setparamconnection()[0]
+ pport = setparamconnection()[1]
+ ossim_zoom_xml = '<Set target=":navigator" vref="wgs84"><Camera><longitude>%s</longitude><latitude>%s</latitude><altitude>%s</altitude><heading>0</heading><pitch>0</pitch><roll>0</roll><altitudeMode>absolute</altitudeMode><range>%s</range></Camera></Set>' % (lon, lat, distance, distance)
+ ossimposition = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ try :
+ ossimposition.connect((host, int(pport)))
+ ossimposition.send(ossim_zoom_xml)
+ ossimposition.close()
+ except :
+ print "Connection error"
+
+
+def removefile(output):
+ host = setparamconnection()[0]
+ dport = setparamconnection()[2]
+ ossimdata = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ ossimdata.connect((host, int(dport)))
+ ossim_data_xml = "<Remove target=':idolbridge' id='%s' />" % (output)
+ try :
+ ossimdata.send(ossim_data_xml)
+ ossimdata.close()
+ except :
+ print 'Connection error'
+
+
+def addzoom(output,lon,lat,distance):
+ addfile(output)
+ zoomto(lon,lat,distance)
+
+
+#addzoom('/Users/sasha/Desktop/rgb.tif',-81.0009,29.0009,15000)
+#removefile('/data/florida/Brevard.tif','localhost',8000)
More information about the grass-commit
mailing list