From barton at grass.itc.it Wed Aug 1 08:06:49 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Wed Aug 1 08:06:54 2007 Subject: [grass-addons] r988 - trunk/grassaddons/gui Message-ID: <200708010606.l7166nuP004276@grass.itc.it> Author: barton Date: 2007-08-01 08:06:25 +0200 (Wed, 01 Aug 2007) New Revision: 988 Modified: trunk/grassaddons/gui/location_wizard.py Log: Setting region extents disabled. Will be moved to intro screen button. Added location variable (if new location creation successful) for use in intro panel. Modified: trunk/grassaddons/gui/location_wizard.py =================================================================== --- trunk/grassaddons/gui/location_wizard.py 2007-07-30 17:59:30 UTC (rev 987) +++ trunk/grassaddons/gui/location_wizard.py 2007-08-01 06:06:25 UTC (rev 988) @@ -240,10 +240,10 @@ wx.MessageBox('You must select a coordinate system') event.Veto() - if coordsys == "xy": - self.parent.bboxpage.cstate.Enable(False) - else: - self.parent.bboxpage.cstate.Enable(True) +# if coordsys == "xy": +# self.parent.bboxpage.cstate.Enable(False) +# else: +# self.parent.bboxpage.cstate.Enable(True) def SetVal(self,event): global coordsys @@ -954,7 +954,7 @@ self.GetNext().SetPrev(self) def OnText(self, event): - self.epsgcode = self.GetString() + self.epsgcode = event.GetString() def OnDoSearch(self,event): str = self.searchb.GetValue() @@ -1673,7 +1673,7 @@ self.projpage = ProjectionsPage(self.wizard, self) self.projtypepage = ProjTypePage(self.wizard,self) self.epsgpage = EPSGPage(self.wizard, self) - self.bboxpage = BBoxPage(self.wizard, self) +# self.bboxpage = BBoxPage(self.wizard, self) self.filepage = GeoreferencedFilePage(self.wizard, self) self.datumpage = DatumPage(self.wizard, self) self.ellipsepage = EllipsePage(self.wizard, self) @@ -1686,35 +1686,37 @@ self.startpage.SetNext(self.csystemspage) self.csystemspage.SetPrev(self.startpage) - self.csystemspage.SetNext(self.bboxpage) + self.csystemspage.SetNext(self.sumpage) self.projtypepage.SetPrev(self.projpage) self.projtypepage.SetNext(self.datumpage) self.datumpage.SetPrev(self.projtypepage) - self.datumpage.SetNext(self.bboxpage) + self.datumpage.SetNext(self.sumpage) self.ellipsepage.SetPrev(self.projtypepage) - self.ellipsepage.SetNext(self.bboxpage) + self.ellipsepage.SetNext(self.sumpage) self.projpage.SetPrev(self.csystemspage) - self.projpage.SetNext(self.projtypepage) + self.projpage.SetNext(self.sumpage) self.epsgpage.SetPrev(self.csystemspage) - self.epsgpage.SetNext(self.bboxpage) + self.epsgpage.SetNext(self.sumpage) self.filepage.SetPrev(self.csystemspage) - self.filepage.SetNext(self.bboxpage) + self.filepage.SetNext(self.sumpage) self.custompage.SetPrev(self.csystemspage) - self.custompage.SetNext(self.bboxpage) + self.custompage.SetNext(self.sumpage) - self.bboxpage.SetPrev(self.csystemspage) - self.bboxpage.SetNext(self.sumpage) +# self.bboxpage.SetPrev(self.csystemspage) +# self.bboxpage.SetNext(self.sumpage) - self.sumpage.SetPrev(self.bboxpage) +# self.sumpage.SetPrev(self.bboxpage) +# + self.wizard.FitToPage(self.datumpage) - self.wizard.FitToPage(self.bboxpage) + self.location = None #New location created success = False @@ -1722,12 +1724,13 @@ success = self.onWizFinished() if success == True: wx.MessageBox("New location created.") + self.location = self.startpage.location else: wx.MessageBox("Unable to create new location.") else: wx.MessageBox("Location wizard canceled. New location not created.") - self.wizard.Destroy() +# self.wizard.Destroy() def onWizFinished(self): database = self.startpage.grassdatabase @@ -1852,6 +1855,7 @@ def CustomCreate(self): proj4string = self.custompage.proj4string + location = self.startpage.location dlg = wx.MessageDialog(self.wizard, "New location '%s' will be created using PROJ.4 string: %s" % (location,proj4string), From barton at grass.itc.it Wed Aug 1 08:08:25 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Wed Aug 1 08:08:30 2007 Subject: [grass-addons] r989 - trunk/grassaddons/gui Message-ID: <200708010608.l7168P8A004296@grass.itc.it> Author: barton Date: 2007-08-01 08:07:35 +0200 (Wed, 01 Aug 2007) New Revision: 989 Modified: trunk/grassaddons/gui/gis_set.py Log: When new location created in wizard, it is automatically selected along with the new PERMANENT mapset. EPSG and Georeferenced file classes removed from gis_set.py because they are now in location wizard. Modified: trunk/grassaddons/gui/gis_set.py =================================================================== --- trunk/grassaddons/gui/gis_set.py 2007-08-01 06:06:25 UTC (rev 988) +++ trunk/grassaddons/gui/gis_set.py 2007-08-01 06:07:35 UTC (rev 989) @@ -24,371 +24,6 @@ return grassrc -class EpsgCode(wx.Frame): - def __init__(self, parent, id, title, ): - wx.Frame.__init__(self,parent, id , title, size=(50,600)) - - self.parent = parent - - # sizers - self.vsizer= wx.BoxSizer(wx.VERTICAL) - self.sizer = wx.FlexGridSizer(5,4,5,5) - - # labels - self.lname= wx.StaticText(self, -1, "Name of new Location: ", - style=wx.ALIGN_RIGHT) - self.lfile= wx.StaticText(self, -1, "Path to the EPSG-codes file: ", - style=wx.ALIGN_RIGHT) - self.lcode= wx.StaticText(self, -1, "EPSG code: ", - style=wx.ALIGN_RIGHT) - self.lsearch= wx.StaticText(self, -1, "Search in code description: ", - style=wx.ALIGN_RIGHT) - - # text input - self.tname = wx.TextCtrl(self,-1, "newLocation", size=(200,20)) - epsgdir = os.path.join(os.environ["GRASS_PROJSHARE"], 'epsg') - self.tfile = wx.TextCtrl(self,-1, epsgdir, size=(200,20)) - - self.tcode = wx.TextCtrl(self,-1, "", size=(200,20)) - - # buttons - self.bbrowse = wx.Button(self, -1, "Browse ...", size=(100,-1)) - self.bbcodes = wx.Button(self, -1, "Browse Codes") - self.bcancel = wx.Button(self, -1, "Cancel", size=(100,-1)) - self.bcreate = wx.Button(self, -1, "Create", size=(100,-1)) - - # empty panels - self.epanel1 = wx.Panel(self,-1) - self.epanel2 = wx.Panel(self,-1) - self.epanel3 = wx.Panel(self,-1) - self.epanel4 = wx.Panel(self,-1) - - # search box - self.searchb = wx.SearchCtrl(self, size=(200,-1), style=wx.TE_PROCESS_ENTER) - - # table - self.tablewidth=600 - self.epsgs = wx.ListCtrl(self, id=wx.ID_ANY, - size=(750,200), - style=wx.LC_REPORT| - wx.LC_HRULES| - wx.EXPAND) - self.epsgs.InsertColumn(0, 'EPSG', wx.LIST_FORMAT_CENTRE) - self.epsgs.InsertColumn(1, 'Description', wx.LIST_FORMAT_LEFT) - self.epsgs.InsertColumn(2, 'Parameters', wx.LIST_FORMAT_LEFT) - self.epsgs.SetColumnWidth(0, 50) - self.epsgs.SetColumnWidth(1, 300) - self.epsgs.SetColumnWidth(2, 400) - - # layout - self.sizer.Add(self.lname, 0, wx.ALIGN_RIGHT | - wx.ALIGN_CENTER_VERTICAL | - wx.TOP, 10) - self.sizer.Add(self.tname, 0, wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.TOP, 10) - self.sizer.Add(self.epanel1, 0, wx.ALIGN_LEFT, 1) - self.sizer.Add(self.epanel2, 0, wx.ALIGN_LEFT, 1) - - self.sizer.Add(self.lfile, 0 , wx.ALIGN_RIGHT | - wx.ALIGN_CENTER_VERTICAL | - wx.TOP, 5) - self.sizer.Add(self.tfile, 0 , wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.TOP, 5) - self.sizer.Add(self.bbrowse, 0 , wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.TOP|wx.LEFT, 5) - self.sizer.Add(self.epanel3, 0, wx.ALIGN_LEFT, 1) - - self.sizer.Add(self.lcode, 0, wx.ALIGN_RIGHT | - wx.ALIGN_CENTER_VERTICAL | - wx.TOP, 5) - self.sizer.Add(self.tcode, 0, wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.TOP, 5) - self.sizer.Add(self.bcreate, 0 , wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.TOP|wx.LEFT, 5) - self.sizer.Add(self.bcancel, 0 , wx.ALIGN_RIGHT | - wx.ALIGN_CENTER_VERTICAL | - wx.TOP|wx.RIGHT, 5) - - self.sizer.Add(self.lsearch, 0, wx.ALIGN_RIGHT | - wx.ALIGN_CENTER_VERTICAL | - wx.TOP|wx.BOTTOM, 5) - self.sizer.Add(self.searchb, 0, wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.TOP|wx.BOTTOM, 5) - self.sizer.Add(self.bbcodes, 0 , wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.TOP|wx.LEFT|wx.BOTTOM, 5) - self.sizer.Add(self.epanel4, 0, wx.ALIGN_LEFT, 1) - - self.vsizer.Add(self.sizer,0, wx.ADJUST_MINSIZE, 1) - self.vsizer.Add(self.epsgs, wx.ALIGN_LEFT|wx.EXPAND, 0) - - self.SetAutoLayout(True) - self.SetSizer(self.vsizer) - self.vsizer.Fit(self) - self.vsizer.SetSizeHints(self) - self.Layout() - - # events - wx.EVT_BUTTON(self, self.bbrowse.GetId(), self.OnBrowse) - wx.EVT_BUTTON(self, self.bcancel.GetId(), self.OnCancel) - wx.EVT_BUTTON(self, self.bcreate.GetId(), self.OnCreate) - wx.EVT_BUTTON(self, self.bbcodes.GetId(), self.OnBrowseCodes) - self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemSelected, self.epsgs) - self.searchb.Bind(wx.EVT_TEXT_ENTER, self.OnDoSearch, self.searchb) - - def OnDoSearch(self,event): - str = self.searchb.GetValue() - listItem = self.epsgs.GetColumn(1) - - for i in range(self.epsgs.GetItemCount()): - listItem = self.epsgs.GetItem(i,1) - if listItem.GetText().find(str) > -1: - epsgcode = self.epsgs.GetItem(i, 0) - self.tcode.SetValue(epsgcode.GetText()) - break - - self.OnBrowseCodes(None,str) - - - def OnBrowse(self, event): - - dlg = wx.FileDialog(self, "Locate EPSG codes file:", - "/", "", "*.*", wx.OPEN) - if dlg.ShowModal() == wx.ID_OK: - path = dlg.GetPath() - self.tfile.SetValue(path) - dlg.Destroy() - - def OnCancel(self, event): - self.Destroy() - - def OnItemSelected(self,event): - item = event.GetItem() - self.tcode.SetValue(str(item.GetText())) - - - def OnBrowseCodes(self,event,search=None): - try: - self.epsgs.DeleteAllItems() - f = open(self.tfile.GetValue(),"r") - i=1 - j = 0 - descr = None - code = None - params = "" - #self.epsgs.ClearAll() - for line in f.readlines(): - line = line.strip() - if line.find("#") == 0: - descr = line[1:].strip() - elif line.find("<") == 0: - code = line.split(" ")[0] - for par in line.split(" ")[1:]: - params += par + " " - code = code[1:-1] - if code == None: code = 'no code' - if descr == None: descr = 'no description' - if params == None: params = 'no parameters' - if i%2 == 0: - if search and descr.lower().find(search.lower()) > -1 or\ - not search: - index = self.epsgs.InsertStringItem(j, code) - self.epsgs.SetStringItem(index, 1, descr) - self.epsgs.SetStringItem(index, 2, params) - j += 1 - # reset - descr = None; code = None; params = "" -# if i%2 == 0: -# self.epsgs.SetItemBackgroundColour(i, "grey") - i += 1 - f.close() - self.epsgs.SetColumnWidth(1, wx.LIST_AUTOSIZE) - self.epsgs.SetColumnWidth(2, wx.LIST_AUTOSIZE) - self.SendSizeEvent() - except StandardError, e: - dlg = wx.MessageDialog(self, "Could not read EPGS codes: %s " - % e,"Can not read file", wx.OK|wx.ICON_INFORMATION) - dlg.ShowModal() - dlg.Destroy() - - def OnChange(self,event): - self.item = event.GetItem() - - def OnCreate(self, event): - if not self.tcode.GetValue(): - dlg = wx.MessageDialog(self, "Could not create new location: EPSG Code value missing", - "Can not create location", wx.OK|wx.ICON_INFORMATION) - dlg.ShowModal() - dlg.Destroy() - return - - number = -1 - try: - code = self.tcode.GetValue() - except: - dlg = wx.MessageDialog(self, "Could not create new location: '%s' is not a valid EPSG code" % code, - "Can not create location", wx.OK|wx.ICON_INFORMATION) - dlg.ShowModal() - dlg.Destroy() - return - - if os.path.isdir(os.path.join(self.parent.gisdbase,self.tname.GetValue())): - dlg = wx.MessageDialog(self, "Could not create new location: %s already exists" - % os.path.join(self.parent.gisdbase,self.tname.GetValue()),"Can not create location", wx.OK|wx.ICON_INFORMATION) - dlg.ShowModal() - dlg.Destroy() - return - - # creating location - # all credit to Michael Barton and his file_option.tcl and - # Markus Neteler - try: - dtoptions = os.popen3(" g.proj epsg=%s datumtrans=-1" % (code))[1].read() - if dtoptions != None: - # open a dialog to select datum transform number - dtoptions = 'Select the number of a datum transformation to use: \n'+dtoptions - dlg = wx.TextEntryDialog(self, dtoptions) - dlg.SetValue('1') - - if dlg.ShowModal() == wx.ID_OK: - dtrans = dlg.GetValue() - - dlg.Destroy() - - cmd = os.system("g.proj -c epsg=%s location=%s datumtrans=%s" % (code, self.tname.GetValue(), dtrans)) - else: - os.system("g.proj -c epsg=%s location=%s datumtrans=1" % (code, self.tname.GetValue())) - - self.Destroy() - self.parent.OnSetDatabase(None) - - except StandardError, e: - dlg = wx.MessageDialog(self, "Could not create new location: %s " - % str(e),"Can not create location", wx.OK|wx.ICON_INFORMATION) - dlg.ShowModal() - dlg.Destroy() - return - - def OnDoubleClick(self, event): - print self.epsgs.GetValue() - pass - - -class GeoreferencedFile(wx.Frame): - def __init__(self, parent, id, title, ): - wx.Frame.__init__(self,parent, id , title) - - self.parent = parent - - self.sizer = wx.FlexGridSizer(3,3,5,5) - - self.lname= wx.StaticText(self, -1, "Name of new Location: ", - style=wx.ALIGN_RIGHT) - - self.lfile= wx.StaticText(self, -1, "Georeferenced file: ", - style=wx.ALIGN_RIGHT) - - self.tname = wx.TextCtrl(self,-1, "newLocation", size=(200,20)) - self.tfile = wx.TextCtrl(self,-1, "", size=(200,20)) - - self.bbrowse = wx.Button(self, -1, "Browse ...", size=(100,-1)) - self.bcancel = wx.Button(self, -1, "Cancel", size=(100,-1)) - self.bcreate = wx.Button(self, -1, "Create", size=(100,-1)) - - self.gpanel1 = wx.Panel(self,-1) - self.gpanel2 = wx.Panel(self,-1) - - self.sizer.Add(self.lname, 0, wx.ALIGN_RIGHT | - wx.ALIGN_CENTRE_VERTICAL | - wx.TOP|wx.LEFT , 10) - self.sizer.Add(self.tname, 0, wx.ALIGN_LEFT | - wx.ALIGN_CENTRE_VERTICAL | - wx.TOP , 10) - self.sizer.Add(self.gpanel1, 0, wx.ALIGN_LEFT | - wx.ALIGN_CENTRE, 5) - - self.sizer.Add(self.lfile, 0 , wx.ALIGN_RIGHT | - wx.ALIGN_CENTRE_VERTICAL | - wx.TOP , 5) - self.sizer.Add(self.tfile, 0 , wx.ALIGN_LEFT | - wx.ALIGN_CENTRE_VERTICAL | - wx.TOP , 5) - self.sizer.Add(self.bbrowse, 0 , wx.ALIGN_CENTER, 10) - - self.sizer.Add(self.bcreate, 0 , wx.ALIGN_CENTER | - wx.ALL, 10) - self.sizer.Add(self.gpanel2, 0 , wx.ALIGN_CENTER | - wx.ALL, 10) - - self.sizer.Add(self.bcancel, 0 , wx.ALIGN_CENTER | - wx.ALL, 10) - - self.SetAutoLayout(True) - self.SetSizer(self.sizer) - self.sizer.Fit(self) - self.sizer.SetSizeHints(self) - self.Layout() - - - wx.EVT_BUTTON(self, self.bbrowse.GetId(), self.OnBrowse) - wx.EVT_BUTTON(self, self.bcancel.GetId(), self.OnCancel) - wx.EVT_BUTTON(self, self.bcreate.GetId(), self.OnCreate) - - def OnBrowse(self, event): - - dlg = wx.FileDialog(self, "Choose a georeferenced file:", os.getcwd(), "", "*.*", wx.OPEN) - if dlg.ShowModal() == wx.ID_OK: - path = dlg.GetPath() - self.tfile.SetValue(path) - dlg.Destroy() - - def OnCancel(self, event): - self.Destroy() - - def OnCreate(self, event): - if not os.path.isfile(self.tfile.GetValue()): - dlg = wx.MessageDialog(self, "Could not create new location: %s not file" - % self.tfile.GetValue(),"Can not create location", wx.OK|wx.ICON_INFORMATION) - dlg.ShowModal() - dlg.Destroy() - return - - if not self.tname.GetValue(): - dlg = wx.MessageDialog(self, "Could not create new location: name not set", - "Can not create location", wx.OK|wx.ICON_INFORMATION) - dlg.ShowModal() - dlg.Destroy() - return - - if os.path.isdir(os.path.join(self.parent.gisdbase,self.tname.GetValue())): - dlg = wx.MessageDialog(self, "Could not create new location: %s exists" - % os.path.join(self.parent.gisdbase,self.tname.GetValue()),"Can not create location", wx.OK|wx.ICON_INFORMATION) - dlg.ShowModal() - dlg.Destroy() - return - - # creating location - # all credit to Michael Barton and his file_option.tcl and - # Markus Neteler - try: - # FIXME: this does not need to work on windows - os.system("g.proj -c georef=%s location=%s >&2" % (self.tfile.GetValue(), self.tname.GetValue())) - - self.parent.OnSetDatabase(None) - self.Destroy() - - except StandardError, e: - dlg = wx.MessageDialog(self, "Could not create new location: %s " - % str(e),"Can not create location", wx.OK|wx.ICON_INFORMATION) - dlg.ShowModal() - dlg.Destroy() - class GRASSStartup(wx.Frame): def __init__(self, *args, **kwds): kwds["style"] = wx.DEFAULT_FRAME_STYLE @@ -612,10 +247,14 @@ def OnWizard(self,event): import location_wizard reload(location_wizard) - gWizard = location_wizard.GWizard(self, self.tgisdbase.GetValue()) - self.OnSetDatabase(event) + gWizard = location_wizard.GWizard(self, self.tgisdbase.GetValue()) + if gWizard.location != None: + self.OnSetDatabase(event) + self.UpdateMapsets(os.path.join( + self.gisbase,gWizard.location)) + self.lblocations.SetSelection(self.listOfLocations.index(gWizard.location)) + self.lbmapsets.SetSelection(0) - def UpdateLocations(self,dbase): self.listOfLocations = [] @@ -733,7 +372,6 @@ event.Skip() - class StartUp(wx.App): def OnInit(self): wx.InitAllImageHandlers() From barton at grass.itc.it Wed Aug 1 08:34:27 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Wed Aug 1 08:34:32 2007 Subject: [grass-addons] r990 - trunk/grassaddons/gui Message-ID: <200708010634.l716YRRW004413@grass.itc.it> Author: barton Date: 2007-08-01 08:34:12 +0200 (Wed, 01 Aug 2007) New Revision: 990 Modified: trunk/grassaddons/gui/gis_set.py Log: Initial layout and code for new region setting frame. Modified: trunk/grassaddons/gui/gis_set.py =================================================================== --- trunk/grassaddons/gui/gis_set.py 2007-08-01 06:07:35 UTC (rev 989) +++ trunk/grassaddons/gui/gis_set.py 2007-08-01 06:34:12 UTC (rev 990) @@ -6,8 +6,8 @@ import os import glob import shutil +import wx.lib.rcsizer as rcs - def read_grassrc(): """ Read variables from $HOME/.grassrc6 file @@ -61,6 +61,7 @@ self.lmapset = wx.StaticText(self, -1, "Accessible Mapsets\n(directories of GIS files)", style=wx.ALIGN_CENTRE) self.lcreate = wx.StaticText(self, -1, "Create new mapset\nin selected location", style=wx.ALIGN_CENTRE) self.ldefine = wx.StaticText(self, -1, "Define new location...", style=wx.ALIGN_CENTRE) + self.lregion = wx.StaticText(self, -1, "Define default region...", style=wx.ALIGN_CENTRE) # buttons buttonsize1 = (150,-1) @@ -75,6 +76,7 @@ # self.bgeoreferenced = wx.Button(self, -1, "Georeferenced file", size=buttonsize1) # self.bepsg = wx.Button(self, -1, "EPSG codes", size=buttonsize1) self.bwizard = wx.Button(self, -1, "Location wizard", size=buttonsize1) + self.bregion = wx.Button(self, -1, "Define region", size=buttonsize1) # textinputs @@ -99,24 +101,16 @@ self.__do_layout() # events -# wx.EVT_BUTTON(self, self.bbrowse.GetId(), self.OnBrowse) self.bbrowse.Bind(wx.EVT_BUTTON, self.OnBrowse) -# wx.EVT_BUTTON(self, self.bstart.GetId(), self.OnStart) self.bstart.Bind(wx.EVT_BUTTON, self.OnStart) -# wx.EVT_BUTTON(self, self.bexit.GetId(), self.OnExit) self.bexit.Bind(wx.EVT_BUTTON, self.OnExit) -# wx.EVT_BUTTON(self, self.bhelp.GetId(), self.OnHelp) self.bhelp.Bind(wx.EVT_BUTTON, self.OnHelp) -# wx.EVT_BUTTON(self, self.bmapset.GetId(), self.OnCreateMapset) self.bmapset.Bind(wx.EVT_BUTTON, self.OnCreateMapset) -# wx.EVT_BUTTON(self, self.bgeoreferenced.GetId(), self.OnGeoreferenced) -# wx.EVT_BUTTON(self, self.bepsg.GetId(), self.OnEpsg) self.bwizard.Bind(wx.EVT_BUTTON, self.OnWizard) + self.bregion.Bind(wx.EVT_BUTTON, self.OnRegion) self.lblocations.Bind(wx.EVT_LISTBOX, self.OnSelectLocation) self.lbmapsets.Bind(wx.EVT_LISTBOX, self.OnSelectMapset) -# wx.EVT_KEY_DOWN(self.tgisdbase, self.OnKeyPressedInDbase) self.Bind(wx.EVT_KEY_DOWN, self.OnKeyPressedInDbase, self.tgisdbase) -# wx.EVT_KEY_DOWN(self.tnewmapset, self.OnKeyPressedInMapset) self.Bind(wx.EVT_KEY_DOWN, self.OnKeyPressedInMapset, self.tnewmapset) self.Bind(wx.EVT_CLOSE, self.onCloseWindow) @@ -173,9 +167,9 @@ mapset_sizer.Add(self.tnewmapset, 0, label_style|wx.BOTTOM, 5) mapset_sizer.Add(self.bmapset, 0, label_style|wx.BOTTOM, 10) mapset_sizer.Add(self.ldefine, 0, label_style|wx.RIGHT|wx.LEFT, 5) -# mapset_sizer.Add(self.bgeoreferenced, 0, label_style|wx.TOP, 5) -# mapset_sizer.Add(self.bepsg, 0, label_style|wx.TOP, 5) mapset_sizer.Add(self.bwizard, 0, label_style|wx.TOP, 5) + mapset_sizer.Add(self.lregion, 0, label_style|wx.TOP|wx.RIGHT|wx.LEFT, 5) + mapset_sizer.Add(self.bregion, 0, label_style|wx.TOP, 5) mapset_sizer.Add((5,0)) grid_sizer.Add(self.llocation, 0,label_style|wx.ALL, 5) @@ -255,6 +249,9 @@ self.lblocations.SetSelection(self.listOfLocations.index(gWizard.location)) self.lbmapsets.SetSelection(0) + def OnRegion(self,event): + RegionDef(self) + def UpdateLocations(self,dbase): self.listOfLocations = [] @@ -344,15 +341,6 @@ #self.bmapset.Enable(True) event.Skip() - def OnGeoreferenced(self,event): - NewLocation = GeoreferencedFile(self, -1, "Define new Location") - NewLocation.Show() - - def OnEpsg(self,event): - NewLocation = EpsgCode(self, -1, "Define new Location") - NewLocation.Show() - - def OnStart(self, event): print "g.gisenv set=GISDBASE='%s';" % self.tgisdbase.GetValue() print "g.gisenv set=LOCATION_NAME='%s';" % self.listOfLocations[self.lblocations.GetSelection()] @@ -371,7 +359,424 @@ print "exit" event.Skip() +class RegionDef(wx.Frame): + """ + Page for setting default region extents and resolution + """ + def __init__(self,parent,id=wx.ID_ANY, title="Set default region values"): + wx.Frame.__init__(self, parent, id, title, size=(300,300)) + + self.parent = parent + # inputs + self.ttop = self.MakeTextCtrl("1", size=(150, -1)) + self.tbottom = self.MakeTextCtrl("0", size=(150, -1)) + self.tleft = self.MakeTextCtrl("0", size=(150, -1)) + self.tright = self.MakeTextCtrl("1", size=(150, -1)) + self.tres = self.MakeTextCtrl("1", size=(150, -1)) + + self.tgdal = self.MakeTextCtrl("", size=(250, -1)) + self.tdsn = self.MakeTextCtrl("", size=(250, -1)) + # list of layers + self.layers = [] + self.llayers = wx.ComboBox(self, -1, + choices=self.layers, + size=(250,-1), + style=wx.CB_DROPDOWN) + + # labels + self.lmessage = wx.StaticText(self,-1, "", size=(300,50)) + + # buttons + self.bbrowsegdal = self.MakeButton("Browse...", size=(150,-1)) + self.bbrowseogr = self.MakeButton("Browse...", size=(150,-1)) + self.bgetlayers = self.MakeButton("Get Layers", size=(150,-1)) + self.bset = self.MakeButton("Set coordinates", size=(150,-1)) + + # list of states + self.states = [] + self.coords = [] + try: + f = open(os.path.join(os.getenv("GISBASE"),"etc","wx","states.txt"),"r") + for line in f.readlines(): + if line[0] == "#": + continue + state,coord = line.split(";") + coord = coord.replace(","," ") + self.states.append(state) + self.coords.append(coord.split()) + f.close() + except: + pass + # NOTE: ComboCtcl should come here, but nobody knows, how to + # implement it + # self.stateslist = wx.ListCtrl(self, + # style=wx.LC_LIST|wx.LC_SINGLE_SEL|wx.SIMPLE_BORDER) + # self.cstate = wx.combo.ComboCtrl(self, -1, pos=(50, 170), size=(150, -1), + # style=wx.CB_READONLY) + + self.cstate = wx.ComboBox(self, -1, + size=(250,-1), + choices=self.states, + style=wx.CB_DROPDOWN) + + # layout + self.sizer = rcs.RowColSizer() +# tmpsizer = wx.BoxSizer(wx.VERTICAL) +# +# tmpsizer.Add(self.title, 0, wx.ALIGN_CENTRE|wx.ALL, 5) +# tmpsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND|wx.ALL, 0) +# tmpsizer.Add(self.sizer, wx.EXPAND) +# +# self.SetSizer(tmpsizer) + self.SetSizer(self.sizer) + self.SetAutoLayout(True) + + + + self.sizer.Add(self.MakeRLabel("North"), 0, + wx.ALIGN_CENTER_HORIZONTAL | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 0, row=1,col=2) + self.sizer.Add(self.ttop, 0, + wx.ALIGN_CENTER_HORIZONTAL | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=2,col=2) + + self.sizer.Add(self.MakeRLabel("West"), 0, + wx.ALIGN_RIGHT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 0, row=3,col=0) + self.sizer.Add(self.tleft, 0, + wx.ALIGN_RIGHT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=3,col=1) + + self.sizer.Add(self.tright, 0, + wx.ALIGN_CENTER_HORIZONTAL | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=3,col=3) + self.sizer.Add(self.MakeRLabel("East"), 0, + wx.ALIGN_LEFT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 0, row=3,col=4) + + self.sizer.Add(self.tbottom, 0, + wx.ALIGN_CENTER_HORIZONTAL | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=4,col=2) + self.sizer.Add(self.MakeRLabel("South"), 0, + wx.ALIGN_CENTER_HORIZONTAL | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 0, row=5,col=2) + + self.sizer.Add(self.MakeRLabel("Initial resolution"), 0, + wx.ALIGN_RIGHT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=6,col=1) + self.sizer.Add(self.tres, 0, + wx.ALIGN_CENTER_HORIZONTAL | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=6,col=2) + self.sizer.Add(self.bset, 0, + wx.ALIGN_LEFT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=6, col=3 ) + + self.sizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND|wx.ALL, 0, row=7, col=0, colspan=6) + + self.sizer.Add(self.MakeRLabel("Match extents of georeferenced raster map or image"), 3, + wx.ALIGN_LEFT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=8,col=0, colspan=3) + + self.sizer.Add(self.MakeRLabel("File:"), 0, + wx.ALIGN_RIGHT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=9,col=0, colspan=1) + self.sizer.Add(self.tgdal, 0, + wx.ALIGN_LEFT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=9,col=1, colspan=2) + self.sizer.Add(self.bbrowsegdal, 0, + wx.ALIGN_LEFT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=9,col=3) + + self.sizer.Add(wx.StaticLine(self, -1), 0, + wx.EXPAND|wx.ALL, 0, + row=10, col=0, colspan=6) + + self.sizer.Add(self.MakeRLabel("Match extents of georeferenced vector map"), 0, + wx.ALIGN_LEFT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=11,col=0, colspan=3 ) + + self.sizer.Add(self.MakeRLabel("Data source/directory:"), 0, + wx.ALIGN_RIGHT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=12,col=0, colspan=1) + self.sizer.Add(self.tdsn, 0, + wx.ALIGN_LEFT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=12, col=1, colspan=2) + self.sizer.Add(self.bbrowseogr, 0, + wx.ALIGN_LEFT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=12, col=3) + + self.sizer.Add(self.MakeRLabel("Layer/file:"), 0, + wx.ALIGN_RIGHT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=13,col=0, colspan=1) + self.sizer.Add(self.llayers, 0, + wx.ALIGN_LEFT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=13,col=1, colspan=2) + self.sizer.Add(self.bgetlayers, 0, + wx.ALIGN_LEFT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=13,col=3) + + self.sizer.Add(wx.StaticLine(self, -1), 0, + wx.EXPAND|wx.ALL | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, + row=14, col=0, colspan=6) + self.sizer.Add(self.MakeRLabel("Match extents of selected country"), 0, + wx.ALIGN_LEFT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=15,col=0, colspan=3) + self.sizer.Add(self.cstate, 0, + wx.ALIGN_LEFT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=16,col=1, colspan=2) + + self.sizer.Add(self.lmessage, 0, + wx.ALIGN_LEFT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, + row=17,col=1, colspan=3) + + self.Bind(wx.EVT_COMBOBOX, self.OnItemSelected, self.cstate) + self.Bind(wx.EVT_TEXT, self.OnStateText, self.cstate) + self.Bind(wx.EVT_BUTTON, self.OnSetButton, self.bset) + self.Bind(wx.EVT_BUTTON, self.OnBrowseGdal, self.bbrowsegdal) + self.Bind(wx.EVT_BUTTON, self.OnBrowseOGR, self.bbrowseogr) + self.Bind(wx.EVT_BUTTON, self.OnGetOGRLayers, self.bgetlayers) + + def MakeRLabel(self, text=""): + """Make right-aligned label""" + try: + if text[-1] != " ": + text += " " + except: + pass + return wx.StaticText(self, -1, text, style=wx.ALIGN_RIGHT) + + def MakeLLabel(self, text=""): + """Make left-aligned label""" + try: + if text[-1] != " ": + text += " " + except: + pass + return wx.StaticText(self, -1, text, style=wx.ALIGN_LEFT) + + def MakeTextCtrl(self,text='', size=(100,-1)): + """Generic text control""" + return wx.TextCtrl(self,-1, text, size=size) + + def MakeButton(self,text, size=(75,25)): + """Generic button""" + return wx.Button(self, -1, text, + style=wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, + size=size) + + def OnBrowseGdal(self, event): + dlg = wx.FileDialog(self, "Choose a raster file:", os.getcwd(), "", "*.*", wx.OPEN) + path = "" + if dlg.ShowModal() == wx.ID_OK: + path = dlg.GetPath() + self.tgdal.SetValue(path) + dlg.Destroy() + + self.OnSetButton() + + def OnBrowseOGR(self, event): + dlg = wx.FileDialog(self, "Choose a data source name:", os.getcwd(), "", "*.*", wx.OPEN) + path = "" + if dlg.ShowModal() == wx.ID_OK: + path = dlg.GetPath() + self.tdsn.SetValue(path) + dlg.Destroy() + self.OnGetOGRLayers(None) + + def OnSetButton(self,event=None): + if self.tgdal.GetValue(): + self.__setGDAL() + if self.tdsn.GetValue() and self.llayers.GetSelection()>-1: + self.__setOGR() + elif self.cstate.GetSelection() > -1: + sys.stderr.write("##############"+str(self.cstate.GetSelection())+"\n") + self.OnItemSelected(None) + + def OnGetOGRLayers(self, event): + path = self.tdsn.GetValue() + line = "" + + sys.stderr.write(path+"####\n") + self.layers = [] + self.llayers.Clear() + cmd = os.popen("ogrinfo -so %s\n" % (path)) + line = cmd.readline() + # 1: cr (Polygon) + rex = re.compile("^(\d+):\s+(.+)\s+\(.*\)") + while 1: + if not line or line == "": + break + try: + sys.stderr.write("#####"+line+"####\n") + number, name = rex.findall(line)[0] + self.layers.append(name) + except: + pass + line = cmd.readline() + self.llayers.AppendItems(self.layers) + #sys.stderr.write(str( self.layers)+"\n") + #self.sizer.Remove(self.llayers) + #self.llayers = wx.ComboBox(self, -1, choices=self.layers, size=(100,-1), + # style=wx.CB_DROPDOWN) + #self.sizer.Add(self.llayers, 0, wx.ALIGN_CENTER_VERTICAL, row=12,col=3) + #self.sizer.ShowItems(True) + self.OnSetButton() + pass + + def __setOGR(self): + layer = self.layers[self.llayers.GetSelection()] + path = self.tdsn.GetValue() + number="-?\d+\.\d+" + line = "" + + #test values + self.ttop.SetValue(500) + self.tleft.SetValue(500) + + #Extent: (-146.976217, -55.985484) - (72.774632, 80.594358) + rex = re.compile("\((%s),\s*(%s)\)\s*-\s*\((%s),\s*(%s)\)" %(number, number, number, number)) + cmd = os.popen("ogrinfo -so %s %s" % (path ,layer)) + line = cmd.readline() + while 1: + if not line or line == "": + break + sys.stderr.write(line+"\n") + if line.find("Extent")>-1: + sys.stderr.write(line[0]+"#####\n") + x1,y1,x2,y2 = rex.findall(line)[0] + self.tbottom.SetValue(y1) + self.tleft.SetValue(x1) + self.ttop.SetValue(y2) + self.tright.SetValue(x2) + break + line = cmd.readline() + return + + def __setGDAL(self): + path = self.tgdal.GetValue() + line = "" + number="-?\d+\.\d+" + + #test values + self.ttop.SetValue(500) + self.tleft.SetValue(500) + + # Upper Left ( 0.0, 0.0) + rex=re.compile("\(\s*(%s)\s*,\s*(%s)\)" % (number, number)) + obj = os.popen("gdalinfo %s | grep \"Upper\|Lower\"" % path) + + line = obj.readline() + while 1: + sys.stderr.write(line+"\n") + if not line: + break + if line.find("Upper Left")>-1: + x,y = rex.findall(line)[0] + self.ttop.SetValue(y) + self.tleft.SetValue(x) + if line.find("Lower Right")>-1: + x,y = rex.findall(line)[0] + self.tbottom.SetValue(y) + self.tright.SetValue(x) + line = obj.readline() + return + + def OnStateText(self,event): + item = self.llayers.FindString(event.GetString()) + self.llayers.SetSelection(item) + self.llayers.SetValue(self.llayers.GetStringSelection()) + pass + #.log.WriteText('EvtTextEnter: %s' % event.GetString()) + #sys.stderr.write(event.GetString()+"\n") + #text=event.GetString().lower() + #for idx in range(len(self.states)): + # if self.states[idx].lower() == text: + # self.cstate.Select(idx) + # break + + def OnPageChange(self, event): + self.GetNext().FillVars() + self.GetNext().SetPrev(self) + + global north + north = self.ttop.GetValue() + global south + south = self.tbottom.GetValue() + global east + east = self.tright.GetValue() + global west + west = self.tleft.GetValue() + global resolution + resolution = self.tres.GetValue() + + def OnItemSelected(self, event): + item = self.cstate.GetSelection() + w,s,e,n = self.coords[item] + # 4 + # 1 3 + # 2 + + if self.parent.csystemspage.cs == "latlong": + pass + if self.parent.csystemspage.cs == "xy": + pass + else: + if self.parent.csystemspage.cs == "epsg": + to="+init=epsg:%d" % (int(self.parent.epsgpage.tcode.GetValue())) + elif self.parent.csystemspage.cs == "proj": + to="+proj=%s" % (self.parent.projpage.tproj.GetValue()) + elif self.parent.csystemspage.cs == "utm": + to="+proj=utm" + else: + sys.stderr.write(self.parent.csystemspage.cs+"\n") + + try: + sin, sout = os.popen2("cs2cs +proj=latlong +datum=WGS84 +to %s" % (to)) + sin.write("%s %s\n" % (w,s)) + sin.write("%s %s\n" % (e,n)) + sin.close() + w,s,t = sout.readline().split() + e,n,t = sout.readline().split() + self.lmessage.SetLabel("") + except: + n = s = w = e="NULL" + self.lmessage.SetLabel("Unable to calculate country extends:\n cs2cs +proj=latlong +datum=WGS84 +to %s"% to) + + self.ttop.SetValue( str(n) ) + self.tbottom.SetValue( str(s) ) + self.tright.SetValue( str(e) ) + self.tleft.SetValue( str(w) ) + + class StartUp(wx.App): def OnInit(self): wx.InitAllImageHandlers() From barton at grass.itc.it Wed Aug 1 18:01:24 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Wed Aug 1 18:01:26 2007 Subject: [grass-addons] r991 - trunk/grassaddons/gui Message-ID: <200708011601.l71G1OCk014952@grass.itc.it> Author: barton Date: 2007-08-01 18:01:12 +0200 (Wed, 01 Aug 2007) New Revision: 991 Modified: trunk/grassaddons/gui/gis_set.py Log: Basic layout for default region setting done. Note that I've deactivated functions that require external programs that do not come with GRASS and may not be present on all systems. Modified: trunk/grassaddons/gui/gis_set.py =================================================================== --- trunk/grassaddons/gui/gis_set.py 2007-08-01 06:34:12 UTC (rev 990) +++ trunk/grassaddons/gui/gis_set.py 2007-08-01 16:01:12 UTC (rev 991) @@ -250,7 +250,8 @@ self.lbmapsets.SetSelection(0) def OnRegion(self,event): - RegionDef(self) + defineRegion = RegionDef(self) + defineRegion.Show() def UpdateLocations(self,dbase): @@ -365,7 +366,7 @@ """ def __init__(self,parent,id=wx.ID_ANY, title="Set default region values"): - wx.Frame.__init__(self, parent, id, title, size=(300,300)) + wx.Frame.__init__(self, parent, id, title, size=(650,300)) self.parent = parent # inputs @@ -375,23 +376,24 @@ self.tright = self.MakeTextCtrl("1", size=(150, -1)) self.tres = self.MakeTextCtrl("1", size=(150, -1)) - self.tgdal = self.MakeTextCtrl("", size=(250, -1)) - self.tdsn = self.MakeTextCtrl("", size=(250, -1)) +# self.tgdal = self.MakeTextCtrl("", size=(250, -1)) +# self.tdsn = self.MakeTextCtrl("", size=(250, -1)) # list of layers self.layers = [] - self.llayers = wx.ComboBox(self, -1, - choices=self.layers, - size=(250,-1), - style=wx.CB_DROPDOWN) +# self.llayers = wx.ComboBox(self, -1, +# choices=self.layers, +# size=(250,-1), +# style=wx.CB_DROPDOWN) # labels self.lmessage = wx.StaticText(self,-1, "", size=(300,50)) # buttons - self.bbrowsegdal = self.MakeButton("Browse...", size=(150,-1)) - self.bbrowseogr = self.MakeButton("Browse...", size=(150,-1)) - self.bgetlayers = self.MakeButton("Get Layers", size=(150,-1)) +# self.bbrowsegdal = self.MakeButton("Browse...", size=(150,-1)) +# self.bbrowseogr = self.MakeButton("Browse...", size=(150,-1)) +# self.bgetlayers = self.MakeButton("Get Layers", size=(150,-1)) self.bset = self.MakeButton("Set coordinates", size=(150,-1)) + self.bcancel = self.MakeButton("Cancel", size=(150,-1)) # list of states self.states = [] @@ -415,10 +417,10 @@ # self.cstate = wx.combo.ComboCtrl(self, -1, pos=(50, 170), size=(150, -1), # style=wx.CB_READONLY) - self.cstate = wx.ComboBox(self, -1, - size=(250,-1), - choices=self.states, - style=wx.CB_DROPDOWN) +# self.cstate = wx.ComboBox(self, -1, +# size=(250,-1), +# choices=self.states, +# style=wx.CB_DROPDOWN) # layout self.sizer = rcs.RowColSizer() @@ -429,11 +431,12 @@ # tmpsizer.Add(self.sizer, wx.EXPAND) # # self.SetSizer(tmpsizer) - self.SetSizer(self.sizer) - self.SetAutoLayout(True) + self.sizer.Add(self.MakeLLabel("Region extents and resolution:"), 3, + wx.ALIGN_RIGHT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 10, row=0,col=0, colspan=2) - self.sizer.Add(self.MakeRLabel("North"), 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL | @@ -470,7 +473,7 @@ wx.ALIGN_CENTER_VERTICAL | wx.ALL, 0, row=5,col=2) - self.sizer.Add(self.MakeRLabel("Initial resolution"), 0, + self.sizer.Add(self.MakeRLabel("Resolution"), 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5, row=6,col=1) @@ -478,92 +481,103 @@ wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5, row=6,col=2) - self.sizer.Add(self.bset, 0, - wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=6, col=3 ) self.sizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND|wx.ALL, 0, row=7, col=0, colspan=6) - self.sizer.Add(self.MakeRLabel("Match extents of georeferenced raster map or image"), 3, + self.sizer.Add(self.bset, 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=8,col=0, colspan=3) + wx.ALL, 5, row=8, col=3 ) - self.sizer.Add(self.MakeRLabel("File:"), 0, - wx.ALIGN_RIGHT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=9,col=0, colspan=1) - self.sizer.Add(self.tgdal, 0, + self.sizer.Add(self.bcancel, 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=9,col=1, colspan=2) - self.sizer.Add(self.bbrowsegdal, 0, - wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=9,col=3) + wx.ALL, 5, row=8, col=1 ) - self.sizer.Add(wx.StaticLine(self, -1), 0, - wx.EXPAND|wx.ALL, 0, - row=10, col=0, colspan=6) +# self.sizer.Add(self.MakeRLabel("Match extents of georeferenced raster map or image"), 3, +# wx.ALIGN_LEFT | +# wx.ALIGN_CENTER_VERTICAL | +# wx.ALL, 5, row=8,col=0, colspan=3) +# +# self.sizer.Add(self.MakeRLabel("File:"), 0, +# wx.ALIGN_RIGHT | +# wx.ALIGN_CENTER_VERTICAL | +# wx.ALL, 5, row=9,col=0, colspan=1) +# self.sizer.Add(self.tgdal, 0, +# wx.ALIGN_LEFT | +# wx.ALIGN_CENTER_VERTICAL | +# wx.ALL, 5, row=9,col=1, colspan=2) +# self.sizer.Add(self.bbrowsegdal, 0, +# wx.ALIGN_LEFT | +# wx.ALIGN_CENTER_VERTICAL | +# wx.ALL, 5, row=9,col=3) +# +# self.sizer.Add(wx.StaticLine(self, -1), 0, +# wx.EXPAND|wx.ALL, 0, +# row=10, col=0, colspan=6) +# +# self.sizer.Add(self.MakeRLabel("Match extents of georeferenced vector map"), 0, +# wx.ALIGN_LEFT | +# wx.ALIGN_CENTER_VERTICAL | +# wx.ALL, 5, row=11,col=0, colspan=3 ) +# +# self.sizer.Add(self.MakeRLabel("Data source/directory:"), 0, +# wx.ALIGN_RIGHT | +# wx.ALIGN_CENTER_VERTICAL | +# wx.ALL, 5, row=12,col=0, colspan=1) +# self.sizer.Add(self.tdsn, 0, +# wx.ALIGN_LEFT | +# wx.ALIGN_CENTER_VERTICAL | +# wx.ALL, 5, row=12, col=1, colspan=2) +# self.sizer.Add(self.bbrowseogr, 0, +# wx.ALIGN_LEFT | +# wx.ALIGN_CENTER_VERTICAL | +# wx.ALL, 5, row=12, col=3) +# +# self.sizer.Add(self.MakeRLabel("Layer/file:"), 0, +# wx.ALIGN_RIGHT | +# wx.ALIGN_CENTER_VERTICAL | +# wx.ALL, 5, row=13,col=0, colspan=1) +# self.sizer.Add(self.llayers, 0, +# wx.ALIGN_LEFT | +# wx.ALIGN_CENTER_VERTICAL | +# wx.ALL, 5, row=13,col=1, colspan=2) +# self.sizer.Add(self.bgetlayers, 0, +# wx.ALIGN_LEFT | +# wx.ALIGN_CENTER_VERTICAL | +# wx.ALL, 5, row=13,col=3) +# +# self.sizer.Add(wx.StaticLine(self, -1), 0, +# wx.EXPAND|wx.ALL | +# wx.ALIGN_CENTER_VERTICAL | +# wx.ALL, 5, +# row=14, col=0, colspan=6) +# self.sizer.Add(self.MakeRLabel("Match extents of selected country"), 0, +# wx.ALIGN_LEFT | +# wx.ALIGN_CENTER_VERTICAL | +# wx.ALL, 5, row=15,col=0, colspan=3) +# self.sizer.Add(self.cstate, 0, +# wx.ALIGN_LEFT | +# wx.ALIGN_CENTER_VERTICAL | +# wx.ALL, 5, row=16,col=1, colspan=2) +# +# self.sizer.Add(self.lmessage, 0, +# wx.ALIGN_LEFT | +# wx.ALIGN_CENTER_VERTICAL | +# wx.ALL, 5, +# row=17,col=1, colspan=3) - self.sizer.Add(self.MakeRLabel("Match extents of georeferenced vector map"), 0, - wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=11,col=0, colspan=3 ) + self.SetSizer(self.sizer) + self.SetAutoLayout(True) + self.Layout() - self.sizer.Add(self.MakeRLabel("Data source/directory:"), 0, - wx.ALIGN_RIGHT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=12,col=0, colspan=1) - self.sizer.Add(self.tdsn, 0, - wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=12, col=1, colspan=2) - self.sizer.Add(self.bbrowseogr, 0, - wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=12, col=3) - - self.sizer.Add(self.MakeRLabel("Layer/file:"), 0, - wx.ALIGN_RIGHT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=13,col=0, colspan=1) - self.sizer.Add(self.llayers, 0, - wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=13,col=1, colspan=2) - self.sizer.Add(self.bgetlayers, 0, - wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=13,col=3) - - self.sizer.Add(wx.StaticLine(self, -1), 0, - wx.EXPAND|wx.ALL | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, - row=14, col=0, colspan=6) - self.sizer.Add(self.MakeRLabel("Match extents of selected country"), 0, - wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=15,col=0, colspan=3) - self.sizer.Add(self.cstate, 0, - wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=16,col=1, colspan=2) - - self.sizer.Add(self.lmessage, 0, - wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, - row=17,col=1, colspan=3) - - self.Bind(wx.EVT_COMBOBOX, self.OnItemSelected, self.cstate) - self.Bind(wx.EVT_TEXT, self.OnStateText, self.cstate) +# self.Bind(wx.EVT_COMBOBOX, self.OnItemSelected, self.cstate) +# self.Bind(wx.EVT_TEXT, self.OnStateText, self.cstate) self.Bind(wx.EVT_BUTTON, self.OnSetButton, self.bset) - self.Bind(wx.EVT_BUTTON, self.OnBrowseGdal, self.bbrowsegdal) - self.Bind(wx.EVT_BUTTON, self.OnBrowseOGR, self.bbrowseogr) - self.Bind(wx.EVT_BUTTON, self.OnGetOGRLayers, self.bgetlayers) + self.Bind(wx.EVT_BUTTON, self.OnCancel, self.bcancel) +# self.Bind(wx.EVT_BUTTON, self.OnBrowseGdal, self.bbrowsegdal) +# self.Bind(wx.EVT_BUTTON, self.OnBrowseOGR, self.bbrowseogr) +# self.Bind(wx.EVT_BUTTON, self.OnGetOGRLayers, self.bgetlayers) def MakeRLabel(self, text=""): """Make right-aligned label""" @@ -621,6 +635,9 @@ sys.stderr.write("##############"+str(self.cstate.GetSelection())+"\n") self.OnItemSelected(None) + def OnCancel(self, event): + self.Destroy() + def OnGetOGRLayers(self, event): path = self.tdsn.GetValue() line = "" From bundala at grass.itc.it Wed Aug 1 20:42:13 2007 From: bundala at grass.itc.it (bundala@grass.itc.it) Date: Wed Aug 1 20:42:16 2007 Subject: [grass-addons] r992 - trunk/grassaddons/v.generalize Message-ID: <200708011842.l71IgD9c019992@grass.itc.it> Author: bundala Date: 2007-08-01 20:42:10 +0200 (Wed, 01 Aug 2007) New Revision: 992 Modified: trunk/grassaddons/v.generalize/description.html trunk/grassaddons/v.generalize/main.c Log: Added and documented r flag-remove small areas and lines Modified: trunk/grassaddons/v.generalize/description.html =================================================================== --- trunk/grassaddons/v.generalize/description.html 2007-08-01 16:01:12 UTC (rev 991) +++ trunk/grassaddons/v.generalize/description.html 2007-08-01 18:42:10 UTC (rev 992) @@ -34,17 +34,12 @@
  • Vertex Reduction
  • Reumann-Witkam Algorithm
  • - Different algorithms require different parameters, but all the algorithms have one parameter in common. It is threshold parameter. In general, the degree -of simplification increases with the increasing value of threshold. +of simplification increases with the increasing value of threshold.
    +The following happens if r flag is presented. If some line is simplified and hence becomes shorter than threshold then it is removed. Also, if type contains area and a simplification algorithm is selected, the areas of area less than threshold are also removed. @@ -96,7 +91,7 @@ The following smoothing algorithms are implemented in v.generalize

    @@ -166,12 +166,12 @@ closer than threshold appart.

  • -alfa, beta - These parameters define the rigidity of lines. For greater -values of alfa, beta (>=1), the algorithm better preserves the original +alpha, beta - These parameters define the rigidity of lines. For greater +values of alpha, beta (>=1), the algorithm better preserves the original shape of the lines. On the other hand, the lines may not -be move enough. If the values of alfa, beta are too small (<=0.001) +be move enough. If the values of alpha, beta are too small (<=0.001) then the lines are moved sufficiently, but the geometry and topology of lines can -be destroyed. Probably, the best way to find the good values of alfa, beta +be destroyed. Probably, the best way to find the good values of alpha, beta is by trial and error.
  • Modified: trunk/grassaddons/v.generalize/displacement.c =================================================================== --- trunk/grassaddons/v.generalize/displacement.c 2007-08-06 17:32:05 UTC (rev 1011) +++ trunk/grassaddons/v.generalize/displacement.c 2007-08-06 18:54:32 UTC (rev 1012) @@ -25,10 +25,13 @@ #include "matrix.h" /* snakes method modified for displacement. - * Function returns somthing */ + * Function returns somthing. This function affects only the + * lines specified in varray (or all lines if varray is null). + Other lines are copied */ int snakes_displacement(struct Map_info *In, struct Map_info *Out, - double threshold, double alfa, double beta, double gama, - double delta, int iterations, VARRAY * varray) + double threshold, double alpha, double beta, + double gama, double delta, int iterations, + VARRAY * varray) { int n_points; @@ -156,8 +159,8 @@ matrix_mult_scalar(0.0, &k); - double a = 2.0 * alfa + 6.0 * beta; - double b = -alfa - 4.0 * beta; + double a = 2.0 * alpha + 6.0 * beta; + double b = -alpha - 4.0 * beta; double c = beta; /* build matrix */ @@ -209,7 +212,7 @@ continue; cx = dx.a[point_index[i]][0]; cy = dy.a[point_index[i]][0]; - f = sqrt(cx * cx + cy * cy) * alfa; + f = sqrt(cx * cx + cy * cy) * alpha; f /= threshold2; fx.a[point_index[i]][0] -= cx * f; fy.a[point_index[i]][0] -= cy * f; Modified: trunk/grassaddons/v.generalize/main.c =================================================================== --- trunk/grassaddons/v.generalize/main.c 2007-08-06 17:32:05 UTC (rev 1011) +++ trunk/grassaddons/v.generalize/main.c 2007-08-06 18:54:32 UTC (rev 1012) @@ -22,6 +22,7 @@ #include #include #include "misc.h" +#include "operators.h" #define DOUGLAS 0 #define LANG 1 @@ -42,18 +43,18 @@ struct Map_info In, Out; static struct line_pnts *Points; struct line_cats *Cats; - int i, type, cat, iter; + int i, type, iter; char *mapset; struct GModule *module; /* GRASS module for parsing arguments */ struct Option *map_in, *map_out, *thresh_opt, *method_opt, *look_ahead_opt; - struct Option *iterations_opt, *cat_opt, *alfa_opt, *beta_opt, *type_opt; + struct Option *iterations_opt, *cat_opt, *alpha_opt, *beta_opt, *type_opt; struct Option *field_opt, *where_opt, *reduction_opt, *slide_opt; struct Option *angle_thresh_opt, *degree_thresh_opt, *closeness_thresh_opt; struct Option *betweeness_thresh_opt; struct Flag *ca_flag, *rs_flag; int with_z; int total_input, total_output; /* Number of points in the input/output map respectively */ - double thresh, alfa, beta, reduction, slide, angle_thresh; + double thresh, alpha, beta, reduction, slide, angle_thresh; double degree_thresh, closeness_thresh, betweeness_thresh; int method; int look_ahead, iterations; @@ -176,12 +177,12 @@ betweeness_thresh_opt->description = _("Betweeness threshold in network generalization"); - alfa_opt = G_define_option(); - alfa_opt->key = "alfa"; - alfa_opt->type = TYPE_DOUBLE; - alfa_opt->required = YES; - alfa_opt->answer = "1.0"; - alfa_opt->description = _("Snakes alfa parameter"); + alpha_opt = G_define_option(); + alpha_opt->key = "alpha"; + alpha_opt->type = TYPE_DOUBLE; + alpha_opt->required = YES; + alpha_opt->answer = "1.0"; + alpha_opt->description = _("Snakes alpha parameter"); beta_opt = G_define_option(); beta_opt->key = "beta"; @@ -216,7 +217,7 @@ thresh = atof(thresh_opt->answer); look_ahead = atoi(look_ahead_opt->answer); - alfa = atof(alfa_opt->answer); + alpha = atof(alpha_opt->answer); beta = atof(beta_opt->answer); reduction = atof(reduction_opt->answer); iterations = atoi(iterations_opt->answer); @@ -338,7 +339,7 @@ total_input = total_output = 0; if (method == DISPLACEMENT) { - snakes_displacement(&In, &Out, thresh, alfa, beta, 1.0, 10.0, + snakes_displacement(&In, &Out, thresh, alpha, beta, 1.0, 10.0, iterations, varray); }; @@ -399,7 +400,7 @@ hermite(Points, thresh, angle_thresh, with_z); break; case SNAKES: - snakes(Points, alfa, beta, with_z); + snakes(Points, alpha, beta, with_z); break; }; }; Modified: trunk/grassaddons/v.generalize/misc.c =================================================================== --- trunk/grassaddons/v.generalize/misc.c 2007-08-06 17:32:05 UTC (rev 1011) +++ trunk/grassaddons/v.generalize/misc.c 2007-08-06 18:54:32 UTC (rev 1012) @@ -77,7 +77,7 @@ * implementing set! */ int copy_tables_by_cats(struct Map_info *In, struct Map_info *Out) { - /* this is the (mostly) code from v.extract, it should be move to + /* this is the (mostly) code from v.extract, it should be moved to * some vector library (probably) */ int nlines, line, nfields; @@ -87,7 +87,6 @@ struct line_pnts *Points; int **ocats, *nocats, *fields; int i; - int ret; /* Collect list of output cats */ Points = Vect_new_line_struct(); Added: trunk/grassaddons/v.generalize/operators.h =================================================================== --- trunk/grassaddons/v.generalize/operators.h (rev 0) +++ trunk/grassaddons/v.generalize/operators.h 2007-08-06 18:54:32 UTC (rev 1012) @@ -0,0 +1,32 @@ +/* This file contains the declarations of all generalization operators + * implemented in this v.generalize */ + +/* simplification.c */ +int douglas_peucker(struct line_pnts *Points, double thresh, int with_z); +int lang(struct line_pnts *Points, double thresh, int look_ahead, int with_z); +int vertex_reduction(struct line_pnts *Points, double eps, int with_z); +int reumann_witkam(struct line_pnts *Points, double thresh, int with_z); +int douglas_peucker_reduction(struct line_pnts *Points, double thresh, + double reduction, int with_z); + +/* smoothing.c */ +int boyle(struct line_pnts *Points, int look_ahead, int with_z); +int sliding_averaging(struct line_pnts *Points, double slide, int look_ahead, + int with_z); +int distance_weighting(struct line_pnts *Points, double slide, int look_ahead, + int with_z); +int chaiken(struct line_pnts *Points, double thresh, int with_z); +int hermite(struct line_pnts *Points, double step, double angle_thresh, + int with_z); +int snakes(struct line_pnts *Points, double alpha, double beta, int with_z); + +/* network.c */ +int graph_generalization(struct Map_info *In, struct Map_info *Out, + double degree_thresh, double closeness_thresh, + double betweeness_thresh); + +/* displacement.c */ +int snakes_displacement(struct Map_info *In, struct Map_info *Out, + double threshold, double alpha, double beta, + double gama, double delta, int iterations, + VARRAY * varray); Property changes on: trunk/grassaddons/v.generalize/operators.h ___________________________________________________________________ Name: svn:executable + * Modified: trunk/grassaddons/v.generalize/pq.c =================================================================== --- trunk/grassaddons/v.generalize/pq.c 2007-08-06 17:32:05 UTC (rev 1011) +++ trunk/grassaddons/v.generalize/pq.c 2007-08-06 18:54:32 UTC (rev 1012) @@ -81,7 +81,7 @@ if (right < n && bh->key[right] > bh->key[greater]) greater = right; - if (greater = i) + if (greater == i) break; td = bh->key[i]; Modified: trunk/grassaddons/v.generalize/simplification.c =================================================================== --- trunk/grassaddons/v.generalize/simplification.c 2007-08-06 17:32:05 UTC (rev 1011) +++ trunk/grassaddons/v.generalize/simplification.c 2007-08-06 18:54:32 UTC (rev 1012) @@ -23,6 +23,7 @@ #include #include "point.h" #include "pq.h" +#include "misc.h" int douglas_peucker(struct line_pnts *Points, double thresh, int with_z) { @@ -37,7 +38,7 @@ if (!index) { G_fatal_error(_("Out of memory")); - G_fre(stack); + G_free(stack); return Points->n_points; }; @@ -225,8 +226,8 @@ { int seg1, seg2; int i, count; - POINT x0, x1, x2, sub, diff, prev, dir; - double subd, diffd, sp, dist, prevd, dird, b, t, sgn; + POINT x0, x1, x2, sub, diff; + double subd, diffd, sp, dist; int n; n = Points->n_points; @@ -257,21 +258,6 @@ * all variables which do not change for each line-point calculation */ if (dist > thresh) { - /* - * pointassign(Points, i - 1, with_z, &prev); - * prevd = pointdist2(prev); - * pointsubtract(x0, prev, &dir); - * dird = pointdist2(dir); - * b = 2 * pointdot(prev, dir); - * - * t = (-b + sqrt(b * b - 4 * prevd * dird)) / (2 * dird); - * - * x0.x = prev.x + t * dir.x; - * x0.y = prev.y + t * dir.y; - * x0.z = prev.z + t * dir.z; - * - */ - point_assign(Points, i - 1, with_z, &x1); point_assign(Points, i, with_z, &x2); point_subtract(x2, x1, &sub); @@ -331,6 +317,7 @@ }; int indices; + indices = 0; /* preserve first and last point */ sel[0] = sel[n - 1] = 1; Modified: trunk/grassaddons/v.generalize/smoothing.c =================================================================== --- trunk/grassaddons/v.generalize/smoothing.c 2007-08-06 17:32:05 UTC (rev 1011) +++ trunk/grassaddons/v.generalize/smoothing.c 2007-08-06 18:54:32 UTC (rev 1012) @@ -200,7 +200,7 @@ int n, i; POINT_LIST head, *cur; - POINT p0, p1, p2, m1, m2, tmp; + POINT p0, p1, p2, m1, tmp; n = Points->n_points; @@ -380,13 +380,13 @@ * returns the number of points in the output line. This is * always equal to the number of points in the original line * - * alfa, beta are 2 parameters which change the behaviour of the algorithm + * alpha, beta are 2 parameters which change the behaviour of the algorithm * * TODO: Add parameter iterations, so the runnining time is O(N^3 * log iterations) * instead of O(N^3 * itearations). Probably not needed, for many iterations, * the result is almost straight line */ -int snakes(struct line_pnts *Points, double alfa, double beta, int with_z) +int snakes(struct line_pnts *Points, double alpha, double beta, int with_z) { MATRIX g, ginv, xcoord, ycoord, zcoord, xout, yout, zout; @@ -436,8 +436,8 @@ /* calculate the matrix */ - double a = 2.0 * alfa + 6.0 * beta; - double b = -alfa - 4.0 * beta; + double a = 2.0 * alpha + 6.0 * beta; + double b = -alpha - 4.0 * beta; double c = beta; double val[5] = { c, b, a, b, c }; From barton at grass.itc.it Tue Aug 7 08:02:44 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Tue Aug 7 08:02:46 2007 Subject: [grass-addons] r1013 - trunk/grassaddons/gui Message-ID: <200708070602.l7762iVJ014132@grass.itc.it> Author: barton Date: 2007-08-07 08:02:38 +0200 (Tue, 07 Aug 2007) New Revision: 1013 Removed: trunk/grassaddons/gui/Init.sh Log: Outdated version of init.sh no longer needed Deleted: trunk/grassaddons/gui/Init.sh =================================================================== --- trunk/grassaddons/gui/Init.sh 2007-08-06 18:54:32 UTC (rev 1012) +++ trunk/grassaddons/gui/Init.sh 2007-08-07 06:02:38 UTC (rev 1013) @@ -1,958 +0,0 @@ -#!/bin/sh -############################################################################# -# -# $Id: init.sh,v 1.104 2007/02/12 06:31:54 hamish Exp $ -# -# MODULE: GRASS Initialization -# AUTHOR(S): Original author unknown - probably CERL -# Andreas Lange - Germany - andreas.lange@rhein-main.de -# Huidae Cho - Korea - grass4u@gmail.com -# Justin Hickey - Thailand - jhickey@hpcc.nectec.or.th -# Markus Neteler - Germany/Italy - neteler@itc.it -# PURPOSE: The source file for this shell script is in -# src/general/init/init.sh. It sets up some environment -# variables and the lock file. It also parses any remaining -# command line options for setting the GISDBASE, LOCATION, and/or -# MAPSET. Finally it starts GRASS with the appropriate user -# interface and cleans up after it is finished. -# COPYRIGHT: (C) 2000 by the GRASS Development Team -# -# This program is free software under the GNU General Public -# License (>=v2). Read the file COPYING that comes with GRASS -# for details. -# -############################################################################# - -trap "echo 'User break!' ; exit" 2 3 15 - -# Set the GRASS_PERL variable -GRASS_PERL=/usr/bin/perl -export GRASS_PERL - -# GRASS_SH is normally just for Windows when not started from a bourne -# shell. But when starting from Init.sh is still needed for Tcl/Tk. -GRASS_SH=/bin/sh -export GRASS_SH - -# Set GRASS version number for R interface etc (must be an env_var for MS-Windows) -GRASS_VERSION="6.3.cvs" -export GRASS_VERSION - -# Get the command name -CMD_NAME=grass63 - -# Get the system name -SYSTEM=`uname -s` -case $SYSTEM in -MINGW*) - MINGW=1 - ;; -CYGWIN*) - CYGWIN=1 - ;; -esac - - -# Go through the command line options -for i in "$@" ; do - - # Use a case to check the command line options - case "$i" in - - # Check if the user asked for the version - -v|--version) - cat "$GISBASE/etc/license" - exit - ;; - - # Check if the user asked for help - help|-h|-help|--help) - echo "Usage:" - echo " $CMD_NAME [-h | -help | --help] [-text | -gui] [[[/]/]]" - echo - echo "Flags:" - echo " -h or -help or --help print this help message" - echo " -text use text based interface and set as default" - echo " -gui (or -tcltk) use Tcl/Tk based graphical user interface" - echo " and set as default" - echo " -oldgui use the old GUI interface and set as default" - echo - echo "Parameters:" - echo " GISDBASE initial database (path to GIS data)" - echo " LOCATION_NAME initial location" - echo " MAPSET initial mapset" - echo - echo " GISDBASE/LOCATION_NAME/MAPSET fully qualified initial mapset directory" - echo - echo "Environment variables relevant for startup:" - echo " GRASS_GUI select GUI (text, gis.m, d.m, wx)" # wx - echo " GRASS_TCLSH set tclsh shell name to override 'tclsh'" - echo " GRASS_WISH set wish shell name to override 'wish'" - echo " GRASS_HTML_BROWSER set html web browser for help pages" - echo " GRASS_ADDON_PATH set additional path(s) to local GRASS modules" - echo " GRASS_BATCH_JOB shell script to be processed as batch job" - echo " GRASS_PYTHON set python shell name to override 'python'" - exit - ;; - - # Check if the -text flag was given - -text) - GRASS_GUI="text" - shift - ;; - - # Check if the -tcltk flag was given - # change -gui to wxpython as needed - -gui | -tcltk) - GRASS_GUI="tcltk" - shift - ;; - - # Check if the -oldgui flag was given - -oldgui) - GRASS_GUI="d.m" - shift - ;; - - # Check if the -wx flag was given - -wx) - GRASS_GUI="wx" - shift - ;; - esac -done - -# Set the GIS_LOCK variable to current process id -GIS_LOCK=$$ -export GIS_LOCK - -# Set the global grassrc file -GISRCRC="$HOME/.grassrc6" - -# Set the session grassrc file -if [ "$MINGW" ] ; then - PWD=`pwd -W` - USER="$USERNAME" - if [ ! "$USER" ] ; then - USER="user_name" - fi - if [ ! -f "$GISBASE/etc/monitorcap" ] ; then - # create an empty monitorcap - touch "$GISBASE/etc/monitorcap" - fi -else - PWD=`pwd` - USER="`whoami`" -fi - -## use TMPDIR if it exists, otherwise /tmp -#tmp=${TMPDIR-/tmp} -#tmp="$tmp/grass6-$USER-$GIS_LOCK" -tmp=/tmp/grass6-$USER-$GIS_LOCK -(umask 077 && mkdir "$tmp") || { - echo "Cannot create temporary directory! Exiting." 1>&2 - exit 1 -} -GISRC="$tmp/gisrc" -export GISRC - -# remove invalid GISRC file to avoid disturbing error messages: -cat "$GISRCRC" 2>/dev/null| grep UNKNOWN >/dev/null -if [ $? -eq 0 ] ; then - rm -f "$GISRCRC" -fi - -# Copy the global grassrc file to the session grassrc file -if [ -f "$GISRCRC" ] ; then - cp "$GISRCRC" "$GISRC" - if [ $? -eq 1 ] ; then - echo "Cannot copy '$GISRCRC' to '$GISRC'" - exit - fi -fi - -# Copy global grassrc file to session grassrc - -# At this point the GRASS user interface variable has been set from the -# command line, been set from an external environment variable, or is -# not set. So we check if it is not set -if [ ! "$GRASS_GUI" ] ; then - - # Check for a reference to the GRASS user interface in the grassrc file - if [ -f "$GISRC" ] ; then - GRASS_GUI=`awk '/GRASS_GUI/ {print $2}' "$GISRC"` - fi - - # Set the GRASS user interface to the default if needed - currently tcltk - if [ ! "$GRASS_GUI" ] ; then - GRASS_GUI="tcltk" - fi -else - if [ "$GRASS_GUI" = "gui" ] ; then - # change to wxpython as needed - GRASS_GUI="tcltk" - fi - -fi - -# Set PATH to GRASS bin, ETC to GRASS etc -ETC="$GISBASE/etc" - -if [ "$LC_ALL" ] ; then - LCL=`echo "$LC_ALL" | sed 's/\(..\)\(.*\)/\1/'` -elif [ "$LC_MESSAGES" ] ; then - LCL=`echo "$LC_MESSAGES" | sed 's/\(..\)\(.*\)/\1/'` -else - LCL=`echo "$LANG" | sed 's/\(..\)\(.*\)/\1/'` -fi - -if [ -n "$GRASS_ADDON_PATH" ] ; then - PATH="$GISBASE/bin:$GISBASE/scripts:$GRASS_ADDON_PATH:$PATH" -else - PATH="$GISBASE/bin:$GISBASE/scripts:$PATH" -fi -export PATH - -# Set LD_LIBRARY_PATH to find GRASS shared libraries -if [ ! "$DYLD_LIBRARY_PATH" ] ; then - DYLD_LIBRARY_PATH="$GISBASE/lib" -else - DYLD_LIBRARY_PATH="$GISBASE/lib:$DYLD_LIBRARY_PATH" -fi -export DYLD_LIBRARY_PATH -# Additional copy of variable to use with grass-run.sh -GRASS_LD_LIBRARY_PATH="$DYLD_LIBRARY_PATH" -export GRASS_LD_LIBRARY_PATH - -# Set some environment variables if they are not set -if [ ! "$GRASS_PAGER" ] ; then - if [ -x /bin/more ] || [ -x /usr/bin/more ] ; then - GRASS_PAGER=more - elif [ -x /bin/less ] || [ -x /usr/bin/less ] ; then - GRASS_PAGER=less - elif [ "$MINGW" ] ; then - GRASS_PAGER=more - else - GRASS_PAGER=cat - fi - export GRASS_PAGER -fi - - -# Set up tcltk and wish environment -# with options for aqua tcltk with Mac OSX - - -if [ ! "$GRASS_TCLSH" ] ; then - if [ "$HOSTTYPE" = "macintosh" ] ; then - if [ -d "/usr/local/grasslib" ]; then - GRASS_TCLSH=/usr/local/grasslib/bin/tclsh - else - GRASS_TCLSH=tclsh - fi - else - GRASS_TCLSH=tclsh - fi - export GRASS_TCLSH -fi - - -#WISH_OS=`echo 'puts $tcl_platform(platform) ; exit 0' | wish` - -if [ ! "$GRASS_WISH" ] ; then - if [ "$HOSTTYPE" = "macintosh" ] ; then - if [ "$osxaqua" ] ; then - if [ -d "/usr/local/grasslib/bin/Grass.app" ] ; then - GRASS_WISH=/usr/local/grasslib/bin/Grass.app/Contents/MacOS/Grass - else - GRASS_WISH=/usr/bin/wish - fi - export osxaqua - elif [ -d "/usr/local/grasslib" ] ; then - GRASS_WISH=/usr/local/grasslib/bin/wish - else - #force X11 tcl on Mac without grasslib directory: - GRASS_WISH=/usr/bin/wish - fi - else - GRASS_WISH=wish - fi -fi -export GRASS_WISH - -if [ ! "$GRASS_PYTHON" ] ; then - GRASS_PYTHON=python -fi -export GRASS_PYTHON - - -if [ ! "$GRASS_HTML_BROWSER" ] ; then - for i in `echo "$PATH" | sed 's/^:/.:/ - s/::/:.:/g - s/:$/:./ - s/:/ /g'` - do - if [ -f "$i/htmlview" ] ; then - GRASS_HTML_BROWSER=htmlview - break - elif [ -f "$i/konqueror" ] ; then - GRASS_HTML_BROWSER=konqueror - break - elif [ -f "$i/mozilla" ] ; then - GRASS_HTML_BROWSER=mozilla - break - elif [ -f "$i/mozilla-firefox" ] ; then - GRASS_HTML_BROWSER=mozilla-firefox - break - elif [ -f "$i/opera" ] ; then - GRASS_HTML_BROWSER=opera - break - elif [ -f "$i/netscape" ] ; then - GRASS_HTML_BROWSER=netscape - break - elif [ "$HOSTTYPE" = "macintosh" -o "$HOSTTYPE" = "powermac" -o "$HOSTTYPE" = "powerpc" ] ; then - GRASS_HTML_BROWSER=open - break - elif [ "$HOSTTYPE" = "arm" ] ; then - GRASS_HTML_BROWSER=dillo - break - elif [ "$HOSTTYPE" = "arm" ] ; then - GRASS_HTML_BROWSER=dillo2 - break - elif [ "$MINGW" -o "$CYGWIN" ] ; then - iexplore="$SYSTEMDRIVE/Program Files/Internet Explorer/iexplore.exe" - if [ -f "$iexplore" ] ; then - GRASS_HTML_BROWSER=$iexplore - else - GRASS_HTML_BROWSER="iexplore" - fi - break - fi - done -fi -if [ ! "$GRASS_HTML_BROWSER" ] ; then - echo "Searching for web browser, but neither konqueror, nor mozilla, opera, netscape found." - # so we set konqueror, though, to make lib/gis/parser.c happy: - GRASS_HTML_BROWSER=konqueror -fi -export GRASS_HTML_BROWSER - -#predefine monitor size for certain architectures -if [ "$HOSTTYPE" = "arm" ] ; then - #small monitor on ARM (iPAQ, zaurus... etc) - GRASS_HEIGHT=320 - GRASS_WIDTH=240 - export GRASS_HEIGHT GRASS_WIDTH -fi - - -if [ ! "$GRASS_GNUPLOT" ] ; then - GRASS_GNUPLOT="gnuplot -persist" - export GRASS_GNUPLOT -fi - -if [ ! "$GRASS_PROJSHARE" ] ; then - GRASS_PROJSHARE=/usr/local/share/proj - export GRASS_PROJSHARE -fi - -# First time user - GISRC is defined in the GRASS script -if [ ! -f "$GISRC" ] ; then - - if [ ! -f "$GISBASE/locale/$LCL/etc/grass_intro" ] ; then - cat "$ETC/grass_intro" - else - cat "$GISBASE/locale/$LCL/etc/grass_intro" - fi - - echo - echo "Hit RETURN to continue" - read ans - - #for convenience, define pwd as GISDBASE: - echo "GISDBASE: $PWD" > "$GISRC" - echo 'LOCATION_NAME: ' >> "$GISRC" - echo 'MAPSET: ' >> "$GISRC" - - # This is a hack for not having a good initial gui - should be removed - # with next version of initialization gui - #GRASS_GUI="text" - -else - echo "Cleaning up temporary files....." - ("$ETC/clean_temp" > /dev/null &) -fi - - -echo "Starting GRASS ..." - -# Check if we are running X windows by checking the DISPLAY variable -if [ "$DISPLAY" -o "$MINGW" ] ; then - - # Check if python is working properly - if [ "$GRASS_GUI" = "wx" ]; then - echo 'variable=True' | "$GRASS_PYTHON" >/dev/null 2>&1 - fi - # Check if we need to find wish - if [ "$GRASS_GUI" = "tcltk" ] || \ - [ "$GRASS_GUI" = "gis.m" ] || \ - [ "$GRASS_GUI" = "d.m" ] ; then - - # Check if wish is working properly - echo 'exit 0' | "$GRASS_WISH" >/dev/null 2>&1 - fi - - # ok - if [ "$?" = 0 ] ; then - # Set the tcltkgrass base directory - TCLTKGRASSBASE="$ETC" - # Set the wxpython base directory - WXPYTHONGRASSBASE="$ETC/wx" - else - - # Wish was not found - switch to text interface mode - echo - echo "WARNING: The wish command does not work as expected!" - echo "Please check your GRASS_WISH environment variable." - echo "Use the -help option for details." - echo "Switching to text based interface mode." - echo - echo "Hit RETURN to continue." - read ans - - GRASS_GUI="text" - fi -else - - # Display a message if a graphical interface was expected - if [ "$GRASS_GUI" != "text" ] ; then - # Set the interface mode to text - echo - echo "WARNING: It appears that the X Windows system is not active." - echo "A graphical based user interface is not supported." - echo "Switching to text based interface mode." - echo - echo "Hit RETURN to continue" - read ans - - GRASS_GUI="text" - fi -fi - -# Save the user interface variable in the grassrc file - choose a temporary -# file name that should not match another file -if [ -f "$GISRC" ] ; then - awk '$1 !~ /GRASS_GUI/ {print}' "$GISRC" > "$GISRC.$$" - echo "GRASS_GUI: $GRASS_GUI" >> "$GISRC.$$" - mv -f "$GISRC.$$" "$GISRC" -fi - -# Parsing argument to get LOCATION -if [ ! "$1" ] ; then - - # Try interactive startup - LOCATION= -else - - # Try non-interactive startup - L= - - if [ "$1" = "-" ] ; then - - if [ "$LOCATION" ] ; then - L="$LOCATION" - fi - else - L="$1" - fi - - if [ "$L" ] ; then - if [ "$L" = "." ] ; then - L=$PWD - elif [ `echo "$L" | cut -c 1` != "/" ] ; then - L="$PWD/$L" - fi - - MAPSET=`basename "$L"` - L=`dirname "$L"` - - if [ "$L" != "." ] ; then - LOCATION_NAME=`basename "$L"` - L=`dirname "$L"` - - if [ "$L" != "." ] ; then - GISDBASE="$L" - fi - fi - fi - - #strip off white space from LOCATION_NAME and MAPSET: only supported for $GISDBASE - MAPSET=`echo $MAPSET | sed 's+ ++g'` - LOCATION_NAME=`echo $LOCATION_NAME | sed 's+ ++g'` - - if [ "$GISDBASE" -a "$LOCATION_NAME" -a "$MAPSET" ] ; then - LOCATION="$GISDBASE/$LOCATION_NAME/$MAPSET" - - if [ ! -r "$LOCATION/WIND" ] ; then - if [ "$LOCATION_NAME" = "PERMANENT" ] ; then - echo "$LOCATION: Not a valid GRASS location" - exit 1 - else - # the user wants to create mapset on the fly - if [ ! -f "$GISDBASE/$LOCATION_NAME/PERMANENT/WIND" ] ; then - echo "The LOCATION \"$LOCATION_NAME\" does not exist. Please create first" - exit 1 - else - mkdir -p "$LOCATION" - cp "$GISDBASE/$LOCATION_NAME/PERMANENT/WIND" "$LOCATION/WIND" - echo "Missing WIND file fixed" - fi - fi - fi - - if [ -s "$GISRC" ] ; then - sed -e "s|^GISDBASE:.*$|GISDBASE: $GISDBASE|; \ - s|^LOCATION_NAME:.*$|LOCATION_NAME: $LOCATION_NAME|; \ - s|^MAPSET:.*$|MAPSET: $MAPSET|" "$GISRC" > "$GISRC.$$" - - if [ $? -eq 0 ] ; then - mv -f "$GISRC.$$" "$GISRC" - else - rm -f "$GISRC.$$" - echo "Failed to create new $GISRC" - LOCATION= - fi - else - echo "GISDBASE: $GISDBASE" > "$GISRC" - echo "LOCATION_NAME: $LOCATION_NAME" >> "$GISRC" - echo "MAPSET: $MAPSET" >> "$GISRC" - fi - else - echo "GISDBASE, LOCATION_NAME and MAPSET variables not set properly." - echo "Interactive startup needed." - exit - fi -fi - -# User selects LOCATION and MAPSET if not set -if [ ! "$LOCATION" ] ; then - - case "$GRASS_GUI" in - - # Check for text interface - text) - "$ETC/set_data" - - case $? in - 0) ;; - *) - # Check for an invalid GISRC file - if [ -f "$GISRC" ] ; then - VALUE=`grep "GISDBASE" "$GISRC"` - if [ "$VALUE" = "" ] ; then - echo "Invalid resource file, removing $GISRC" - rm -f "$GISRC" - fi - fi - - exit - ;; - esac - ;; - - # Check for tcltk interface - tcltk | gis.m | d.m | wx) - - if [ "$GRASS_GUI" = "tcltk" ] || \ - [ "$GRASS_GUI" = "gis.m" ] || \ - [ "$GRASS_GUI" = "d.m" ] ; then - - #"$GRASS_WISH" -file "$TCLTKGRASSBASE/gis_set.tcl" - #exit - eval `"$GRASS_WISH" -file "$TCLTKGRASSBASE/gis_set.tcl"` - thetest=$? - #0: failure - #1: successfully read environment - - ########################################################################### - # at the moment when the EPSG facility is used, the eval returns "1" - # whereas everything should be ok, therefore til that problem is not solved - # the return is forced to be ok ("0") - if [ "$EPSGSCRIPT" = "yes" ] ; then - thetest=0 - fi - ############################################################################ - else - #"$GRASS_PYTHON" "$WXPYTHONGRASSBASE/gis_set.py" - #exit - eval `"$GRASS_PYTHON" "$WXPYTHONGRASSBASE/gis_set.py"` - thetest=$? - fi - - - case $thetest in - 1) - - # The gis_set.tcl script printed an error message so wait - # for user to read it - echo "Error in Tcl/Tk startup. If necessary, please" - echo "report this error to the GRASS developers." - echo "Switching to text mode now." - echo "Hit RETURN to continue..." - read ans - - GRASS_GUI="text" - - if [ -f "$GISRC" ] ; then - awk '$1 !~ /GRASS_GUI/ {print}' "$GISRC" > "$GISRC.$$" - echo "GRASS_GUI: $GRASS_GUI" >> "$GISRC.$$" - mv -f "$GISRC.$$" "$GISRC" - fi - - "$ETC/set_data" - - case $? in - 0) ;; - *) - # Check for an invalid GISRC file - if [ -f "$GISRC" ] ; then - VALUE=`grep "GISDBASE" "$GISRC"` - if [ "$VALUE" = "" ] ; then - echo "Invalid resource file, removing $GISRC" - rm -f "$GISRC" - fi - fi - - exit - ;; - esac - ;; - - 0) - # These checks should not be necessary with real init stuff - if [ "$LOCATION_NAME" = "##NONE##" ] ; then - "$ETC/set_data" - if [ $? != 0 ]; then - echo "GISDBASE: $OLD_DB" > "$GISRC" - echo "LOCATION_NAME: $OLD_LOC" >> "$GISRC" - echo "MAPSET: $OLD_MAP" >> "$GISRC" - exit - fi - fi - - if [ "$LOCATION_NAME" = "##ERROR##" ] ; then - echo "The selected location is not a valid GRASS location" - exit - fi - - ;; - - *) - echo "ERROR: Invalid return code from gis_set.tcl." - echo "Please advise GRASS developers of this error." - ;; - esac - - ;; - - - *) - # Shouldn't need this but you never know - echo "ERROR: Invalid user interface specified - $GRASS_GUI." - echo "Use the -help option to select a valid interface." - exit - ;; - esac -fi - -GISDBASE=`g.gisenv GISDBASE` -LOCATION_NAME=`g.gisenv LOCATION_NAME` -MAPSET=`g.gisenv MAPSET` - -LOCATION="${GISDBASE?}/${LOCATION_NAME?}/${MAPSET?}" - -# Check for concurrent use -lockfile="$LOCATION/.gislock" -"$ETC/lock" "$lockfile" $$ -case $? in - 0) ;; - 1) - echo "$USER is currently running GRASS in selected mapset (file $lockfile found). Concurrent use not allowed." - rm -rf "$tmp" # remove session files from tmpdir - exit 1 ;; - *) - echo Unable to properly access "$lockfile" - echo Please notify system personel. - exit 1 ;; -esac - -trap "" 2 3 15 - -# cygwin has many problems with the shell setup -# below, so i hardcoded everything here. -if [ "$CYGWIN" ] ; then - sh="cygwin" - shellname="GNU Bash (Cygwin)" - export SHELL=/usr/bin/bash.exe - export OSTYPE=cygwin -else - sh=`basename "$SHELL"` - case "$sh" in - ksh) shellname="Korn Shell";; - csh) shellname="C Shell" ;; - tcsh) shellname="TC Shell" ;; - bash) shellname="Bash Shell" ;; - sh) shellname="Bourne Shell";; - *) shellname=shell;; - esac -fi - -# check for SHELL -if [ ! -x "$SHELL" ] ; then - echo "ERROR: The SHELL variable is not set" 1>&2 - rm -f "$lockfile" - rm -rf "$tmp" # remove session files from tmpdir - exit 1 -fi - -# hack to process batch jobs: -if [ -n "$GRASS_BATCH_JOB" ] ; then - # defined, but ... - if [ ! -f "$GRASS_BATCH_JOB" ] ; then - # wrong file - echo "Job file '$GRASS_BATCH_JOB' has been defined in the 'GRASS_BATCH_JOB' variable but not found. Exiting." - echo "Use 'unset GRASS_BATCH_JOB' to disable batch job processing." - exit 1 - else - # right file, but ... - if [ ! -x "$GRASS_BATCH_JOB" ] ; then - echo "Please change file permission to 'executable' for '$GRASS_BATCH_JOB'" - exit 1 - else - echo "Executing '$GRASS_BATCH_JOB' ..." - GRASS_GUI="text" - SHELL="$GRASS_BATCH_JOB" - fi - fi -fi - -# Start the chosen GUI but ignore text -echo "GRASS GUI should be $GRASS_GUI" -case "$GRASS_GUI" in - - # Check for tcltk interface - tcltk | gis.m ) - if [ "$osxaqua" ] ; then - "$GISBASE/scripts/gis.m" | sh & - else - "$GISBASE/scripts/gis.m" - fi - ;; - d.m) - if [ "$osxaqua" ] ; then - "$GISBASE/scripts/d.m" | sh & - else - "$GISBASE/scripts/d.m" - fi - ;; - - wx) - # comming soon, see ^ - "$GISBASE/scripts/wxgrass" & - ;; - - # Ignore others - *) - ;; -esac - -# Display the version and license info -if [ "$MINGW" ] ; then - : -# TODO: uncomment when PDCurses works. -# cls -else - if [ -z "$GRASS_BATCH_JOB" ] ; then - echo "" - #tput clear - fi -fi - -if [ -f "$GISBASE/locale/$LCL/etc/welcome" ] ; then - cat "$GISBASE/locale/$LCL/etc/welcome" -else - cat "$ETC/welcome" -fi - -echo "GRASS homepage: http://grass.itc.it/" -echo "This version running thru: $shellname ($SHELL)" -echo "Help is available with the command: g.manual -i" -echo "See the licence terms with: g.version -c" - -if [ "$GRASS_GUI" = "text" ] ; then - echo "Start the graphical user interface with: gis.m" -else - echo "If required, restart the graphical user interface with: wxgrass &" -fi - -echo "When ready to quit enter: exit" - -case "$sh" in - -csh|tcsh) - USERHOME="$HOME" # save original home - HOME="$LOCATION" - export HOME - cshrc="$HOME/.cshrc" - tcshrc="$HOME/.tcshrc" - rm -f "$cshrc" "$tcshrc" - echo "set home = $USERHOME" > "$cshrc" - echo "set history = 500 savehist = 500 noclobber ignoreeof" >> "$cshrc" - echo "set histfile = $HOME/.history" >> "$cshrc" - - echo "set prompt = '\\" >> "$cshrc" - echo "Mapset <${MAPSET}> in Location <${LOCATION_NAME}> \\" >> "$cshrc" - echo "GRASS 6.3.cvs > '" >> "$cshrc" - echo 'set BOGUS=``;unset BOGUS' >> "$cshrc" - - if [ -r "$USERHOME/.grass.cshrc" ] - then - cat "$USERHOME/.grass.cshrc" >> "$cshrc" - fi - - if [ -r "$USERHOME/.cshrc" ] - then - grep '^ *set *mail *= *' "$USERHOME/.cshrc" >> "$cshrc" - fi - - if [ -r "$USERHOME/.tcshrc" ] - then - grep '^ *set *mail *= *' "$USERHOME/.tcshrc" >> "$cshrc" - fi - - if [ -r "$USERHOME/.login" ] - then - grep '^ *set *mail *= *' "$USERHOME/.login" >> "$cshrc" - fi - - echo "set path = ( $PATH ) " | sed 's/:/ /g' >> "$cshrc" - - cp "$cshrc" "$tcshrc" - "$ETC/run" "$SHELL" - EXIT_VAL=$? - - HOME="$USERHOME" - export HOME - ;; - -bash|msh) - USERHOME="$HOME" # save original home - HOME="$LOCATION" # save .bashrc in $LOCATION - export HOME - bashrc="$HOME/.bashrc" - rm -f "$bashrc" - echo "test -z $PROFILEREAD && . /etc/profile" > "$bashrc" - echo "test -r ~/.alias && . ~/.alias" >> "$bashrc" - echo "umask 022" >> "$bashrc" - echo "PS1='GRASS 6.3.cvs ($LOCATION_NAME):\w > '" >> "$bashrc" - echo "PROMPT_COMMAND=$GISBASE/etc/prompt.sh" >> "$bashrc" - - if [ -r "$USERHOME/.grass.bashrc" ] - then - cat "$USERHOME/.grass.bashrc" >> "$bashrc" - fi - - echo "export PATH=\"$PATH\"" >> "$bashrc" - echo "export HOME=\"$USERHOME\"" >> "$bashrc" # restore user home path - - "$ETC/run" "$SHELL" - EXIT_VAL=$? - - HOME="$USERHOME" - export HOME - ;; - -cygwin) - USERHOME="$HOME" # save original home - HOME="$LOCATION" # save .bashrc in $LOCATION - export HOME - bashrc="$HOME/.bashrc" - rm -f "$bashrc" - # this does not work on cygwin for unknown reasons - # echo "test -z $PROFILEREAD && . /etc/profile" > "$bashrc" - echo "test -r ~/.alias && . ~/.alias" >> "$bashrc" - echo "umask 022" >> "$bashrc" - echo "PS1='GRASS 6.3.cvs ($LOCATION_NAME):\w > '" >> "$bashrc" - - if [ -r "$USERHOME/.grass.bashrc" ] - then - cat "$USERHOME/.grass.bashrc" >> "$bashrc" - fi - - echo "export PATH=\"$PATH\"" >> "$bashrc" - echo "export HOME=\"$USERHOME\"" >> "$bashrc" # restore user home path - - "$ETC/run" "$SHELL" - EXIT_VAL=$? - - HOME="$USERHOME" - export HOME - ;; - -*) - - PS1="GRASS $GRASS_VERSION ($LOCATION_NAME):\w > " - export PS1 - - if [ "$MINGW" ] ; then - # "$ETC/run" doesn't work at all??? - "$SHELL" - rm -rf "$LOCATION/.tmp"/* # remove gis.m session files from .tmp - else - "$ETC/run" "$SHELL" - EXIT_VAL=$? - fi - ;; -esac - -trap 2 3 15 - -# GRASS session finished -if [ "$MINGW" ] ; then - : -# TODO: uncomment when PDCurses works. -# cls -else - if [ -z "$GRASS_BATCH_JOB" ] ; then - echo "" - #tput clear - fi -fi - -echo "Closing monitors....." -for MON in `d.mon -L | grep running | grep -v "not running" | sed 's/ .*//'` -do - echo d.mon stop=$MON - d.mon stop=$MON -done - -echo "Cleaning up temporary files....." - -"$ETC/clean_temp" > /dev/null -rm -f "$lockfile" - -# Save GISRC -cp "$GISRC" "$GISRCRC" -rm -rf "$tmp" # remove session files from tmpdir - -echo "done" -echo -echo -echo -echo "Goodbye from GRASS GIS" -echo -if [ -x "$GRASS_BATCH_JOB" ] ; then - echo "Batch job '$GRASS_BATCH_JOB' (defined in GRASS_BATCH_JOB variable) was executed." - exit $EXIT_VAL -fi - From barton at grass.itc.it Wed Aug 8 09:31:28 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Wed Aug 8 09:31:32 2007 Subject: [grass-addons] r1014 - trunk/grassaddons/gui/gui_modules Message-ID: <200708080731.l787VSDa002661@grass.itc.it> Author: barton Date: 2007-08-08 09:31:16 +0200 (Wed, 08 Aug 2007) New Revision: 1014 Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py Log: Minor fix to include all raster map types Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py =================================================================== --- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-08-07 06:02:38 UTC (rev 1013) +++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-08-08 07:31:16 UTC (rev 1014) @@ -498,7 +498,6 @@ except: return - # render vector map layer which is edited digitToolbar = self.parent.digittoolbar if digitToolbar and \ @@ -508,7 +507,6 @@ # draw map self.imgVectorMap = self.parent.digit.driver.DrawMap() - self.Draw(self.pdc, self.img, drawid=id) # draw map image background if self.imgVectorMap: self.Draw(self.pdc, self.imgVectorMap, drawid=100) # draw vector map image @@ -1250,7 +1248,7 @@ (layer.name, layer.type)) # selected layer must be a valid map - if layer.type in ('raster', 'rgb', 'his'): + if layer.type in ('raster', 'rgb', 'his', 'shaded', 'arrow'): cmdVec = ["r.info", "-g", "map=%s" % layer.name] elif layer.type in ('vector', 'thememap', 'themechart'): cmdVec = ["v.info", "-g", "map=%s" % layer.name] From barton at grass.itc.it Wed Aug 8 09:32:43 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Wed Aug 8 09:32:46 2007 Subject: [grass-addons] r1015 - trunk/grassaddons/gui/gui_modules Message-ID: <200708080732.l787WhuJ002681@grass.itc.it> Author: barton Date: 2007-08-08 09:32:31 +0200 (Wed, 08 Aug 2007) New Revision: 1015 Modified: trunk/grassaddons/gui/gui_modules/render.py Log: Improved handling of zooming, but still could be improved. Modified: trunk/grassaddons/gui/gui_modules/render.py =================================================================== --- trunk/grassaddons/gui/gui_modules/render.py 2007-08-08 07:31:16 UTC (rev 1014) +++ trunk/grassaddons/gui/gui_modules/render.py 2007-08-08 07:32:31 UTC (rev 1015) @@ -324,42 +324,35 @@ Also adjusts extents when zooming so that zoomed map is centered in display. """ - if self.width > self.height and \ - self.region["w"] - self.region["e"] > \ - self.region['n'] - self.region['s']: + mapwidth = abs(self.region["e"] - self.region["w"]) + mapheight = abs(self.region['n'] - self.region['s']) + if self.width/self.height > \ + mapwidth/mapheight: + # changing e-w region - self.region["ewres"] = self.region["nsres"] = \ - (self.region['n'] - self.region['s']) / self.height + res = mapheight / self.height - center = self.region['w'] + \ - (self.region['e'] - self.region['w']) / 2 + center = self.region['w'] + mapwidth / 2 - self.region['w'] = center - self.width / 2 * \ - self.region["nsres"] + self.region['w'] = center - self.width / 2 * res - self.region['e'] = center + self.width / 2 * \ - self.region["nsres"] + self.region['e'] = center + self.width / 2 * res - self.region['rows'] = self.width - self.region['cols'] = self.height - else: + # changing n-s region - self.region["ewres"] = self.region["nsres"] = \ - (self.region['e'] - self.region['w']) / self.width + res = mapwidth / self.width - center = self.region['s'] + \ - (self.region['n'] - self.region['s']) / 2 + center = self.region['s'] + mapheight / 2 - self.region['s'] = center - self.height / 2 * \ - self.region["ewres"] + self.region['s'] = center - self.height / 2 * res - self.region['n'] = center + self.height / 2 * \ - self.region["ewres"] + self.region['n'] = center + self.height / 2 * res - self.region['rows'] = self.width - self.region['cols'] = self.height + self.region["ewres"] = self.region["nsres"] = res + self.region['rows'] = self.width + self.region['cols'] = self.height Debug.msg (3, "Map.__adjustRegion(): %s" % self.region) From maldacker at grass.itc.it Wed Aug 8 13:59:04 2007 From: maldacker at grass.itc.it (maldacker@grass.itc.it) Date: Wed Aug 8 13:59:07 2007 Subject: [grass-addons] r1016 - trunk/grassaddons/v.path.obstacles Message-ID: <200708081159.l78Bx4gL005903@grass.itc.it> Author: maldacker Date: 2007-08-08 13:58:55 +0200 (Wed, 08 Aug 2007) New Revision: 1016 Modified: trunk/grassaddons/v.path.obstacles/data_structures.c trunk/grassaddons/v.path.obstacles/data_structures.h trunk/grassaddons/v.path.obstacles/geometry.c trunk/grassaddons/v.path.obstacles/main.c trunk/grassaddons/v.path.obstacles/visibility.c trunk/grassaddons/v.path.obstacles/visibility.h Log: added parameters to add points before and after computing the graph Modified: trunk/grassaddons/v.path.obstacles/data_structures.c =================================================================== --- trunk/grassaddons/v.path.obstacles/data_structures.c 2007-08-08 07:32:31 UTC (rev 1015) +++ trunk/grassaddons/v.path.obstacles/data_structures.c 2007-08-08 11:58:55 UTC (rev 1016) @@ -44,7 +44,7 @@ void init_stack(int size) { stack_index = -1; - stack = ( struct Point * ) G_malloc( size * sizeof( struct Point ) ); + stack = G_malloc( size * sizeof( struct Point ) ); } /** compare the points along the x axis Modified: trunk/grassaddons/v.path.obstacles/data_structures.h =================================================================== --- trunk/grassaddons/v.path.obstacles/data_structures.h 2007-08-08 07:32:31 UTC (rev 1015) +++ trunk/grassaddons/v.path.obstacles/data_structures.h 2007-08-08 11:58:55 UTC (rev 1016) @@ -15,7 +15,9 @@ #ifndef DATA_STRUCTURES_H #define DATA_STRUCTURES_H - #include "rotation_tree.h" +#include +#include +#include "rotation_tree.h" struct Point * pop(); struct Point * top(); @@ -23,8 +25,8 @@ int empty_stack(); void init_stack(); -static int stack_index; -static struct Point ** stack; +static int stack_index = 0; +static struct Point ** stack = NULL; int cmp_points(struct Point * v1, struct Point* v2); void quickSort( struct Point a[], int l, int r); Modified: trunk/grassaddons/v.path.obstacles/geometry.c =================================================================== --- trunk/grassaddons/v.path.obstacles/geometry.c 2007-08-08 07:32:31 UTC (rev 1015) +++ trunk/grassaddons/v.path.obstacles/geometry.c 2007-08-08 11:58:55 UTC (rev 1016) @@ -35,7 +35,6 @@ int left_turn( struct Point * p1, struct Point * p2, struct Point * p3 ) { double a, b, c, d; - double r; if ( p3->y == PORT_DOUBLE_MAX) { Modified: trunk/grassaddons/v.path.obstacles/main.c =================================================================== --- trunk/grassaddons/v.path.obstacles/main.c 2007-08-08 07:32:31 UTC (rev 1015) +++ trunk/grassaddons/v.path.obstacles/main.c 2007-08-08 11:58:55 UTC (rev 1016) @@ -18,41 +18,53 @@ #include #include #include "visibility.h" +#include "proto.h" -void load_lines( struct Map_info * map, struct Point ** points, int * num_points, struct Line ** lines, int * num_lines ); -void count( struct Map_info * map, int * num_points, int * num_lines); -void process_point( struct line_pnts * sites, struct Point ** points, int * index_point, int cat); -void process_line( struct line_pnts * sites, struct Point ** points, int * index_point, struct Line ** lines, int * index_line, int cat); -void process_boundary( struct line_pnts * sites, struct Point ** points, int * index_point, struct Line ** lines, int * index_line, int cat); +/** TODO: need to check if vis and input have same set of vertices */ int main( int argc, char* argv[]) { - struct Map_info in, out; + struct Map_info in, out, vis; struct GModule *module; /* GRASS module for parsing arguments */ struct Option *input, *output; /* The input map */ + struct Option *coor, *ovis; char*mapset; struct Point * points; struct Line * lines; int num_points, num_lines; + int n; - /* initialize GIS environment */ - G_gisinit(argv[0]); /* reads grass env, stores program name to G_program_name() */ + /* initialize GIS environment */ + G_gisinit(argv[0]); /* reads grass env, stores program name to G_program_name() */ - /* initialize module */ - module = G_define_module(); - module->keywords = _("vector, path, visibility"); - module->description = _("Shortest path in free vector space"); + /* initialize module */ + module = G_define_module(); + module->keywords = _("vector, path, visibility"); + module->description = _("Visibility graph construction"); /* define the arguments needed */ input = G_define_standard_option(G_OPT_V_INPUT); output = G_define_standard_option(G_OPT_V_OUTPUT); + coor = G_define_option() ; + coor->key = "coordinate" ; + coor->key_desc = "x,y" ; + coor->type = TYPE_STRING ; + coor->required = NO ; + coor->multiple = YES ; + coor->description = _("One or more coordinates") ; + ovis = G_define_option(); + ovis->key = "vis"; + ovis->type = TYPE_STRING; + ovis->required = NO; + ovis->description = "Add points after computing the vis graph"; + /* options and flags parser */ - if (G_parser(argc, argv)) + if (G_parser(argc, argv)) exit(EXIT_FAILURE); Vect_check_input_output_name ( input->answer, output->answer, GV_FATAL_EXIT ); @@ -67,20 +79,47 @@ if(Vect_open_old(&in, input->answer, mapset) < 1) /* opens the map */ G_fatal_error(_("Could not open input")); - if (Vect_open_new(&out, output->answer, WITHOUT_Z) < 0) + if ( ovis->answer != NULL ) { - Vect_close(&in); - G_fatal_error(_("Could not open output")); - } + mapset = G_find_vector2( ovis->answer, NULL ); + + if( Vect_open_old(&vis, ovis->answer, mapset) < 1 ) + G_fatal_error("Could not open vis"); + + if(Vect_copy( ovis->answer, mapset, output->answer, NULL) < 0 ) + G_fatal_error("Could not copy map"); + + mapset = G_find_vector2( output->answer, NULL ); + + if( Vect_open_old(&out, output->answer, mapset) < 1 ) + G_fatal_error("Could not open vis"); + } + else + { + if (Vect_open_new(&out, output->answer, WITHOUT_Z) < 0) + { + Vect_close(&in); + G_fatal_error(_("Could not open output")); + } + } - + if (G_projection () == PROJECTION_LL) G_warning("We are in LL projection"); load_lines( &in, &points, &num_points, &lines, &num_lines); - construct_visibility( points, num_points, lines, num_lines, &out ); + + if ( coor->answers != NULL ) + n = add_points( coor->answers, &points, &num_points); + + G_message("We have %d new points", n ); + if ( ovis->answer == NULL ) + construct_visibility( points, num_points, lines, num_lines, &out ); + else + visibility_points( points, num_points, lines, num_lines, &out, n ); + G_free(points); G_free(lines); @@ -90,6 +129,51 @@ exit(EXIT_SUCCESS); } + +/** add points to the visibility graph +*/ +int add_points( char ** coor, struct Point ** points, int * index_point ) +{ + int i, n; + double x, y; + + /* first count how many points we are going to add */ + n = 0; i = 0; + while ( coor[i] != NULL ) + { + n++; + i+=2; + } + + /* resizing points acordingly */ + *points = G_realloc( *points, (*index_point+n)*sizeof( struct Point ) ); + + + /* and defining the points */ + for ( i=0 ; coor[i] != NULL ; i+=2 ) + { + G_scan_easting ( coor[i] , &x , G_projection() ); + G_scan_northing ( coor[i+1] , &y , G_projection() ); + + (*points)[*index_point].x = x; + (*points)[*index_point].y = y; + (*points)[*index_point].cat = -1; + + (*points)[*index_point].line1 = NULL; + (*points)[*index_point].line2 = NULL; + + (*points)[*index_point].left_brother = NULL; + (*points)[*index_point].right_brother = NULL; + (*points)[*index_point].father = NULL; + (*points)[*index_point].rightmost_son = NULL; + + (*index_point)++; + + } + + return n; +} + /** counts the number of individual segments ( boundaries and lines ) and vertices */ void count( struct Map_info * map, int * num_points, int * num_lines) @@ -142,7 +226,6 @@ int index_line = 0; int index_point = 0; struct line_pnts* sites; - int i; struct line_cats* cats; int cat = 0; int type; Modified: trunk/grassaddons/v.path.obstacles/visibility.c =================================================================== --- trunk/grassaddons/v.path.obstacles/visibility.c 2007-08-08 07:32:31 UTC (rev 1015) +++ trunk/grassaddons/v.path.obstacles/visibility.c 2007-08-08 11:58:55 UTC (rev 1016) @@ -170,7 +170,7 @@ /** the algorithm that computes the visibility graph */ -int construct_visibility ( struct Point * points, int num_points, struct Line * lines, int num_lines, struct Map_info * out ) +void construct_visibility ( struct Point * points, int num_points, struct Line * lines, int num_lines, struct Map_info * out ) { struct Point * p, * p_r, * q, * z; struct Point * p_infinity,* p_ninfinity; @@ -262,3 +262,37 @@ } +void visibility_points( struct Point * points, int num_points, struct Line * lines, int num_lines, struct Map_info * out, int n ) +{ + + int i,j,k; + + double x1,y1,z1,x2,y2,z2; + + /* loop through the points to add */ + for ( i = 0 ; i < n ; i++ ) + { + /* loop through the other points */ + for ( j = 0 ; j < num_points - n ; j++ ) + { + + /* loop trhough the lines */ + for ( k = 0 ; k < num_lines ; k++ ) + { + if ( segment1( &points[j] ) == &lines[k] || segment2( &points[j] ) == &lines[k] ) + continue; + if ( Vect_segment_intersection (points[num_points-i-1].x, points[num_points-i-1].y, 0, points[j].x, points[j].y, 0, lines[k].p1->x, lines[k].p1->y, 0, lines[k].p2->x, lines[k].p2->y, 0, &x1, &y1, &z1, &x2, &y2, &z2, 0) != 0) + break; + } + + G_message("Here k is %d",k); + if ( k == num_lines ) + { + G_message("Reporting %f,%f and %f,%f", points[j].x, points[j].y, points[num_points-1-i].x, points[num_points-1-i].y); + report( &points[num_points-i-1], &points[j], out ); + } + } + } + +} + Modified: trunk/grassaddons/v.path.obstacles/visibility.h =================================================================== --- trunk/grassaddons/v.path.obstacles/visibility.h 2007-08-08 07:32:31 UTC (rev 1015) +++ trunk/grassaddons/v.path.obstacles/visibility.h 2007-08-08 11:58:55 UTC (rev 1016) @@ -26,14 +26,14 @@ #include "rotation_tree.h" -int construct_visibility( struct Point * points, int num_points, struct Line * lines, int num_lines, struct Map_info* out ); +void construct_visibility( struct Point * points, int num_points, struct Line * lines, int num_lines, struct Map_info* out ); void handle( struct Point* p, struct Point* q, struct Map_info * out ); void report( struct Point * p, struct Point * q, struct Map_info * out ); void init_vis( struct Point * points, int num_points, struct Line * lines, int num_lines ); +void visibility_points( struct Point * points, int num_points, struct Line * lines, int num_lines, struct Map_info * out, int n ); - #endif From barton at grass.itc.it Wed Aug 8 17:12:09 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Wed Aug 8 17:12:11 2007 Subject: [grass-addons] r1017 - trunk/grassaddons/gui/gui_modules Message-ID: <200708081512.l78FC9rP007420@grass.itc.it> Author: barton Date: 2007-08-08 17:11:57 +0200 (Wed, 08 Aug 2007) New Revision: 1017 Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py Log: Restored default arrow cursor Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py =================================================================== --- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-08-08 11:58:55 UTC (rev 1016) +++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-08-08 15:11:57 UTC (rev 1017) @@ -1452,7 +1452,7 @@ self.cursors = { # default: cross # "default" : wx.StockCursor(wx.CURSOR_DEFAULT), - "default" : wx.StockCursor(wx.CURSOR_CROSS), + "default" : wx.StockCursor(wx.CURSOR_ARROW), "cross" : wx.StockCursor(wx.CURSOR_CROSS), "hand" : wx.StockCursor(wx.CURSOR_HAND), "pencil" : wx.StockCursor(wx.CURSOR_PENCIL), From bundala at grass.itc.it Wed Aug 8 21:02:16 2007 From: bundala at grass.itc.it (bundala@grass.itc.it) Date: Wed Aug 8 21:02:17 2007 Subject: [grass-addons] r1018 - trunk/grassaddons/v.generalize Message-ID: <200708081902.l78J2GoO011044@grass.itc.it> Author: bundala Date: 2007-08-08 21:02:13 +0200 (Wed, 08 Aug 2007) New Revision: 1018 Modified: trunk/grassaddons/v.generalize/displacement.c trunk/grassaddons/v.generalize/matrix.c Log: added percent messages in displacement Modified: trunk/grassaddons/v.generalize/displacement.c =================================================================== --- trunk/grassaddons/v.generalize/displacement.c 2007-08-08 15:11:57 UTC (rev 1017) +++ trunk/grassaddons/v.generalize/displacement.c 2007-08-08 19:02:13 UTC (rev 1018) @@ -74,9 +74,12 @@ /* read points * TODO: some better/faster method for determining whether two points are the same */ + G_percent_reset(); + G_message(_("Reading data...")); index = 0; pindex = 0; for (i = 1; i <= n_lines; i++) { + G_percent(i, n_lines, 1); type = Vect_read_line(In, Points, NULL, i); if (type != GV_LINE || (varray && !varray->c[i])) continue; @@ -105,7 +108,6 @@ }; }; - threshold2 = threshold * threshold; /*select only the points which need to be displace */ for (i = 0; i < index; i++) { @@ -146,7 +148,7 @@ point_index[i] = tmp_index[point_index[i]]; pindex = selected; - printf("%d\n", pindex); + G_debug(3, "Number of conflicting points: %d", pindex); /* initialize matrices */ matrix_init(pindex, pindex, &k); Modified: trunk/grassaddons/v.generalize/matrix.c =================================================================== --- trunk/grassaddons/v.generalize/matrix.c 2007-08-08 15:11:57 UTC (rev 1017) +++ trunk/grassaddons/v.generalize/matrix.c 2007-08-08 19:02:13 UTC (rev 1018) @@ -26,7 +26,7 @@ res->rows = rows; res->cols = cols; - res->a = (double **)G_malloc(rows * sizeof(double *)); + res->a = (double **)G_calloc(rows, sizeof(double *)); if (res->a == NULL) return 0; From barton at grass.itc.it Thu Aug 9 08:24:15 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Thu Aug 9 08:24:17 2007 Subject: [grass-addons] r1019 - trunk/grassaddons/gui/gui_modules Message-ID: <200708090624.l796OFgh022450@grass.itc.it> Author: barton Date: 2007-08-09 08:24:04 +0200 (Thu, 09 Aug 2007) New Revision: 1019 Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py trunk/grassaddons/gui/gui_modules/render.py Log: Fixed display rendering so that map or zoomed area always fits in window. Rendering seems faster too. Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py =================================================================== --- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-08-08 19:02:13 UTC (rev 1018) +++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-08-09 06:24:04 UTC (rev 1019) @@ -1234,7 +1234,9 @@ Set display extents to match selected raster or vector map. """ + zoomreg = {} + # find selected map if not self.tree.GetSelection(): return @@ -1249,29 +1251,28 @@ # selected layer must be a valid map if layer.type in ('raster', 'rgb', 'his', 'shaded', 'arrow'): - cmdVec = ["r.info", "-g", "map=%s" % layer.name] + cmdlist = ["g.region", "-ugp", "rast=%s" % layer.name] elif layer.type in ('vector', 'thememap', 'themechart'): - cmdVec = ["v.info", "-g", "map=%s" % layer.name] + cmdlist = ["g.region", "-ugp", "vect=%s" % layer.name] else: return - p = cmd.Command(cmdVec) + # get map extents using g.region and update display + p = cmd.Command(cmdlist) - output = p.module_stdout.read().split('\n') - for oline in output: - extent = oline.split('=') - if extent[0] == 'north': - self.Map.region['n'] = float(extent[1]) - elif extent[0] == 'south': - self.Map.region['s'] = float(extent[1]) - elif extent[0] == 'east': - self.Map.region['e'] = float(extent[1]) - elif extent[0] == 'west': - self.Map.region['w'] = float(extent[1]) + if p.returncode == 0: + output = p.module_stdout.read().split('\n') + for line in output: + line = line.strip() + if '=' in line: key,val = line.split('=') + zoomreg[key] = float(val) + self.Map.region['n'] = zoomreg['n'] + self.Map.region['s'] = zoomreg['s'] + self.Map.region['e'] = zoomreg['e'] + self.Map.region['w'] = zoomreg['w'] + self.ZoomHistory(self.Map.region['n'],self.Map.region['s'],self.Map.region['e'],self.Map.region['w']) + self.UpdateMap() - self.ZoomHistory(self.Map.region['n'],self.Map.region['s'],self.Map.region['e'],self.Map.region['w']) - self.UpdateMap() - def ZoomToWind(self, event): """ Set display geometry to match computational Modified: trunk/grassaddons/gui/gui_modules/render.py =================================================================== --- trunk/grassaddons/gui/gui_modules/render.py 2007-08-08 19:02:13 UTC (rev 1018) +++ trunk/grassaddons/gui/gui_modules/render.py 2007-08-09 06:24:04 UTC (rev 1019) @@ -102,7 +102,7 @@ # # prepare command for each layer # - layertypes = ['raster','rgb','his','shaded','rastarrow','vector','thememap','themechart',\ + layertypes = ['raster','rgb','his','shaded','rastarrow','rastnum','vector','thememap','themechart',\ 'grid','geodesic','rhumb','labels','command','overlay'] if self.type in layertypes: self.__renderLayer() @@ -202,8 +202,8 @@ self.wind = {} # WIND settings self.region = {} # region settings - self.width = 300 # map width - self.height = 400 # map height + self.width = 640.0 # map width + self.height = 480.0 # map height self.layers = [] # stack of available layer self.overlays = [] # stack of available overlays @@ -235,6 +235,7 @@ """ Reads current region settings from g.region command """ + print "in initregion" # # setting region @@ -265,36 +266,37 @@ value = value.strip() self.wind[key] = value - self.__adjustRegion() - windfile.close() - - # # setting resolution # + self.SetRegion() + + # self.region['ewres'] = self.region['nsres'] = abs(float(self.region['e']) # - float(self.region['w']))/self.width - def __initMonSize(self): - """ - Reads current GRASS monitor dimensions from env or - use the default values [640x480] - """ +# I don't think that this method is used anymore (Michael 8/6/2007 +# def __initMonSize(self): +# """ +# Reads current GRASS monitor dimensions from env or +# use the default values [640x480] +# """ +# print 'in initmonsize' +# +# try: +# self.width = int (os.getenv("GRASS_WIDTH")) +# except: +# self.width = 640 +# +# try: +# self.height = int(os.getenv("GRASS_HEIGHT")) +# +# except: +# self.height = 480 - try: - self.width = int (os.getenv("GRASS_WIDTH")) - except: - self.width = 640 - try: - self.height = int(os.getenv("GRASS_HEIGHT")) - - except: - self.height = 480 - - def __initEnv(self): """ Stores environment variables to self.env variable @@ -320,42 +322,59 @@ Maintains constant display resolution, not related to computational region. Do NOT use the display resolution to set computational resolution. Set computational resolution through g.region. - - Also adjusts extents when zooming so that zoomed map is centered - in display. """ + + self.width = float(self.width) + self.height = float(self.height) mapwidth = abs(self.region["e"] - self.region["w"]) mapheight = abs(self.region['n'] - self.region['s']) - if self.width/self.height > \ - mapwidth/mapheight: + self.region["nsres"] = mapheight / self.height + self.region["ewres"] = mapwidth / self.width + self.region['rows'] = round(mapheight/self.region["nsres"]) + self.region['cols'] = round(mapwidth/self.region["ewres"]) - # changing e-w region - res = mapheight / self.height + Debug.msg (3, "Map.__adjustRegion(): %s" % self.region) - center = self.region['w'] + mapwidth / 2 + return self.region - self.region['w'] = center - self.width / 2 * res + def alignResolution(self): + """ + Sets display extents to even multiple of + current resolution in WIND file from SW corner. + This must be done manually as using the -a flag + can produce incorrect extents. - self.region['e'] = center + self.width / 2 * res + Used for saving current display settings to WIND file + """ - else: + # new values to use for saving to region file + new = {} +# windreg = {} + n = s = e = w = 0.0 + nwres = ewres = 0.0 - # changing n-s region - res = mapwidth / self.width + # Get current values for region and display +# windreg = self.GetRegion() + nsres = self.GetRegion()['nsres'] + ewres = self.GetRegion()['ewres'] - center = self.region['s'] + mapheight / 2 + n = float(self.region['n']) + s = float(self.region['s']) + e = float(self.region['e']) + w = float(self.region['w']) - self.region['s'] = center - self.height / 2 * res + # Calculate rows, columns, and extents + new['rows'] = math.fabs(round((n-s)/nsres)) + new['cols'] = math.fabs(round((e-w)/ewres)) - self.region['n'] = center + self.height / 2 * res + # Calculate new extents + new['s'] = nsres * round(s/nsres) + new['w'] = ewres * round(w/ewres) + new['n'] = new['s'] + (new['rows'] * nsres) + new['e'] = new['w'] + (new['cols'] * ewres) + return new - self.region["ewres"] = self.region["nsres"] = res - self.region['rows'] = self.width - self.region['cols'] = self.height - - Debug.msg (3, "Map.__adjustRegion(): %s" % self.region) - def GetRegion(self): """ Returns dictionary with output from g.region -gp @@ -363,6 +382,7 @@ Example: {"n":"4928010", "s":"4913700", "w":"589980",...} """ + print "in getregion" region = {} @@ -381,6 +401,7 @@ os.environ["GRASS_REGION"] = tmpreg Debug.msg (3, "Map.GetRegion(): %s" % region) + return region def SetRegion(self): @@ -392,15 +413,18 @@ string usable for GRASS_REGION variable or None """ + print "in setregion" + grass_region = "" - self.__adjustRegion() - newextents = self.alignResolution() - self.region['n'] = newextents['n'] - self.region['s'] = newextents['s'] - self.region['e'] = newextents['e'] - self.region['w'] = newextents['w'] + self.region = self.__adjustRegion() +# newextents = self.alignResolution() +# self.region['n'] = newextents['n'] +# self.region['s'] = newextents['s'] +# self.region['e'] = newextents['e'] +# self.region['w'] = newextents['w'] + try: for key in self.wind.keys(): if key == 'north': @@ -439,6 +463,7 @@ grass_region += key + ": " + self.wind[key] + "; " Debug.msg (4, "Map.SetRegion(): %s" % grass_region) + return grass_region except: @@ -468,41 +493,6 @@ else: return - def alignResolution(self): - """ - Sets display extents to even multiple of - current resolution in WIND file from SW corner. - This must be done manually as using the -a flag - can produce incorrect extents. - """ - - # new values to use for saving to region file - new = {} -# windreg = {} - n = s = e = w = 0.0 - nwres = ewres = 0.0 - - # Get current values for region and display - windreg = self.GetRegion() - nsres = windreg['nsres'] - ewres = windreg['ewres'] - - n = float(self.region['n']) - s = float(self.region['s']) - e = float(self.region['e']) - w = float(self.region['w']) - - # Calculate rows, columns, and extents - new['rows'] = math.fabs(round((n-s)/nsres)) - new['cols'] = math.fabs(round((e-w)/ewres)) - - # Calculate new extents - new['s'] = nsres * round(s/nsres) - new['w'] = ewres * round(w/ewres) - new['n'] = new['s'] + (new['rows'] * nsres) - new['e'] = new['w'] + (new['cols'] * ewres) - return new - def GetListOfLayers(self, l_type=None, l_mapset=None, l_active=None, l_hidden=None): """ Returns list of layers (including overlays [l_type='overlay'] of @@ -918,8 +908,8 @@ os.system("g.region -d") map = Map() - map.width = 300 - map.height = 400 + map.width = 640 + map.height = 480 map.AddLayer(item=None, type="raster", name="elevation.dem", command = "d.rast elevation.dem@PERMANENT catlist=1000-1500 -i", l_opacity=.7) From barton at grass.itc.it Fri Aug 10 07:16:04 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Fri Aug 10 07:16:08 2007 Subject: [grass-addons] r1020 - trunk/grassaddons/gui Message-ID: <200708100516.l7A5G4Ix014103@grass.itc.it> Author: barton Date: 2007-08-10 07:15:56 +0200 (Fri, 10 Aug 2007) New Revision: 1020 Modified: trunk/grassaddons/gui/README Log: Remove reference to special init.sh (use cvs version now) and added more places to get wxPython and Python. (Thought I'd committed this several days ago). Modified: trunk/grassaddons/gui/README =================================================================== --- trunk/grassaddons/gui/README 2007-08-09 06:24:04 UTC (rev 1019) +++ trunk/grassaddons/gui/README 2007-08-10 05:15:56 UTC (rev 1020) @@ -6,18 +6,26 @@ --------------------------------------------------------------------- Requirements: - Python >=2.4 and wxPython 2.8.1.1 + Python >=2.4 and wxPython >=2.8.1.1 Get wxPython 2.8.x packages from: + * Source: : http://www.wxpython.org/download.php * Debian: http://www.bitpim.org/developer.html -> "Install wxPython" - * Fedora: + * Fedora: http://www.wxpython.org/download.php * Mandriva 2007.0: http://mpa.itc.it/markus/wxpython_rpms/ * Mandriva 2007.1 (spring): available from main/backports (see http://club.mandriva.com/xwiki/bin/view/Downloads/MirrorFinder2 ) - * MS-Windows: - * SuSe: + Also http://www.wxpython.org/download.php + * MS-Windows: http://www.wxpython.org/download.php + * OS X: http://www.wxpython.org/download.php + * SuSe: * Ubuntu: deb http://wxpython.wxcommunity.com/apt/ubuntu/dapper / deb http://wxpython.wxcommunity.com/apt/ubuntu/feisty / + + Get Python from: + * Python.org for Source, MS-Windows, OS X: http://www.python.org/download/ + * ActiveStates for AIX, HP-UX, Linux (x86), Linux 64-bit (x86_64 AMD64), Mac OS X, + Solaris (SPARC), Windows: http://www.activestate.com/store/download.aspx?prdGUID=b08b04e0-6872-4d9d-a722-7a0c2dea2758 --------------------------------------------------------------------- How to start: @@ -49,25 +57,17 @@ 2 - STARTUP WITH GRASS INITIALIZATION If you want to start the wxgrass GUI automatically when you start -GRASS, replace your $GRASS/etc/init.sh with the one that accompanies -wxgrass. Rename your original init.sh to avoid overwriting it. +GRASS, edit your .grassrc6 file to replace... -Edit your .grassrc6 file to replace... - GRASS_GUI: tcktk (or whatever you have here) ...with... GRASS_GUI: wx -***NOTE*** -You may need to edit init.sh to match your settings for LD_DISPLAY - - 3 - STARTUP FROM GRASS TERMINAL -Do not use the wxgrass init.sh. Simply type wxgrass& from the GRASS -terminal to start the GUI using the wxgrass script. +Simply type wxgrass& from the GRASS terminal to start the GUI using the wxgrass script. 4 - CLI Display scripts @@ -124,7 +124,7 @@ This enables all debug messages (GRASS modules + GUI). GUI debug messages starts with 'GUI', e.g. - GUI D1/1: MapFrame.__init__() + GUI D1/1: MapFrame.__init__() If you want to enable *only* GUI debug messages set DEBUG variable to 'GUI:level', e.g. @@ -133,8 +133,8 @@ 6 - ICON THEMES Currently only two icon themes are available: - * default (based on TCL/TK GUI prototype) - * Silk + * default (based on TCL/TK GUI prototype) + * Silk To enable 'Silk' icon theme set environment variable: From bundala at grass.itc.it Fri Aug 10 14:36:31 2007 From: bundala at grass.itc.it (bundala@grass.itc.it) Date: Fri Aug 10 14:36:32 2007 Subject: [grass-addons] r1021 - trunk/grassaddons/v.generalize Message-ID: <200708101236.l7ACaVnZ019710@grass.itc.it> Author: bundala Date: 2007-08-10 14:36:27 +0200 (Fri, 10 Aug 2007) New Revision: 1021 Modified: trunk/grassaddons/v.generalize/description.html trunk/grassaddons/v.generalize/main.c Log: added: remove small lines/areas (code+man page) Modified: trunk/grassaddons/v.generalize/description.html =================================================================== --- trunk/grassaddons/v.generalize/description.html 2007-08-10 05:15:56 UTC (rev 1020) +++ trunk/grassaddons/v.generalize/description.html 2007-08-10 12:36:27 UTC (rev 1021) @@ -36,6 +36,7 @@
  • Lang Algorithm
  • Vertex Reduction
  • Reumann-Witkam Algorithm
  • +
  • Remove Small Lines/Areas
  • Different algorithms require different parameters, but all the algorithms have @@ -66,7 +67,9 @@ process on the remaining points.
  • Reuman-Witkam - Input parameters: input, threshold. This algorithm quite reasonably preserves the global characteristics of the lines. For more information - check http://www.ifp.uni-stuttgart.de/lehre/vorlesungen/GIS1/Lernmodule/Lg/LG_de_6.html(german)
  • + check http://www.ifp.uni-stuttgart.de/lehre/vorlesungen/GIS1/Lernmodule/Lg/LG_de_6.html(german) +
  • Remove Small Lines/Areas - removes the lines (strictly) shorter than threshold and areas of area (strictly)less than threshold. + Other lines/areas/boundaries are left unchanged. Input parameters: input, threshold

    Modified: trunk/grassaddons/v.generalize/main.c =================================================================== --- trunk/grassaddons/v.generalize/main.c 2007-08-10 05:15:56 UTC (rev 1020) +++ trunk/grassaddons/v.generalize/main.c 2007-08-10 12:36:27 UTC (rev 1021) @@ -35,6 +35,7 @@ #define SNAKES 8 #define DOUGLAS_REDUCTION 9 #define SLIDING_AVERAGING 10 +#define REMOVE_SMALL 11 #define NETWORK 100 #define DISPLACEMENT 101 @@ -91,13 +92,14 @@ method_opt->required = YES; method_opt->multiple = NO; method_opt->options = - "douglas,douglas_reduction,lang,reduction,reumann,boyle,sliding_averaging,distance_weighting,chaiken,hermite,snakes,network,displacement"; + "douglas,douglas_reduction,lang,reduction,reumann,remove_small,boyle,sliding_averaging,distance_weighting,chaiken,hermite,snakes,network,displacement"; method_opt->answer = "douglas"; method_opt->descriptions = _("douglas;Douglas-Peucker Algorithm;" "douglas_reduction;Douglas-Peucker Algorithm with reduction parameter;" "lang;Lang Simplification Algorithm;" "reduction;Vertex Reduction Algorithm eliminates points close to each other;" "reumann;Reumann-Witkam Algorithm;" + "remove_small;Removes lines shorter than threshold and areas of area less than threshold;" "boyle;Boyle's Forward-Looking Algorithm;" "sliding_averaging;McMaster's Sliding Averaging Algorithm;" "distance_weighting;McMaster's Distance-Weighting Algorithm;" @@ -258,6 +260,11 @@ method = NETWORK; else if (strcmp(s, "displacement") == 0) method = DISPLACEMENT; + else if (strcmp(s, "remove_small") == 0) { + method = REMOVE_SMALL; + /* switch -r flag on */ + rs_flag->answer = 1; + } else { G_fatal_error(_("Unknown method")); exit(EXIT_FAILURE); @@ -271,6 +278,7 @@ case LANG: case VERTEX_REDUCTION: case REUMANN: + case REMOVE_SMALL: simplification = 1; break; default: From barton at grass.itc.it Sat Aug 11 00:17:05 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Sat Aug 11 00:17:07 2007 Subject: [grass-addons] r1022 - trunk/grassaddons/gui/gui_modules Message-ID: <200708102217.l7AMH55W024860@grass.itc.it> Author: barton Date: 2007-08-11 00:16:58 +0200 (Sat, 11 Aug 2007) New Revision: 1022 Modified: trunk/grassaddons/gui/gui_modules/render.py Log: Remove debugging code. Modified: trunk/grassaddons/gui/gui_modules/render.py =================================================================== --- trunk/grassaddons/gui/gui_modules/render.py 2007-08-10 12:36:27 UTC (rev 1021) +++ trunk/grassaddons/gui/gui_modules/render.py 2007-08-10 22:16:58 UTC (rev 1022) @@ -413,8 +413,6 @@ string usable for GRASS_REGION variable or None """ - print "in setregion" - grass_region = "" self.region = self.__adjustRegion() From bundala at grass.itc.it Tue Aug 14 00:20:21 2007 From: bundala at grass.itc.it (bundala@grass.itc.it) Date: Tue Aug 14 00:20:24 2007 Subject: [grass-addons] r1023 - trunk/grassaddons/v.generalize Message-ID: <200708132220.l7DMKLG7010324@grass.itc.it> Author: bundala Date: 2007-08-14 00:20:17 +0200 (Tue, 14 Aug 2007) New Revision: 1023 Modified: trunk/grassaddons/v.generalize/main.c Log: fixed: bug in displacement Modified: trunk/grassaddons/v.generalize/main.c =================================================================== --- trunk/grassaddons/v.generalize/main.c 2007-08-10 22:16:58 UTC (rev 1022) +++ trunk/grassaddons/v.generalize/main.c 2007-08-13 22:20:17 UTC (rev 1023) @@ -258,8 +258,11 @@ method = SLIDING_AVERAGING; else if (strcmp(s, "network") == 0) method = NETWORK; - else if (strcmp(s, "displacement") == 0) + else if (strcmp(s, "displacement") == 0) { method = DISPLACEMENT; + /* we can displace only the lines */ + mask_type = GV_LINE; + } else if (strcmp(s, "remove_small") == 0) { method = REMOVE_SMALL; /* switch -r flag on */ From neteler at grass.itc.it Tue Aug 14 10:37:46 2007 From: neteler at grass.itc.it (neteler@grass.itc.it) Date: Tue Aug 14 10:37:49 2007 Subject: [grass-addons] r1024 - trunk/grassaddons/gui Message-ID: <200708140837.l7E8bkx3018368@grass.itc.it> Author: neteler Date: 2007-08-14 10:37:46 +0200 (Tue, 14 Aug 2007) New Revision: 1024 Modified: trunk/grassaddons/gui/README Log: new Fedora RPMs from Brad Modified: trunk/grassaddons/gui/README =================================================================== --- trunk/grassaddons/gui/README 2007-08-13 22:20:17 UTC (rev 1023) +++ trunk/grassaddons/gui/README 2007-08-14 08:37:46 UTC (rev 1024) @@ -12,7 +12,8 @@ * Source: : http://www.wxpython.org/download.php * Debian: http://www.bitpim.org/developer.html -> "Install wxPython" * Fedora: http://www.wxpython.org/download.php - * Mandriva 2007.0: http://mpa.itc.it/markus/wxpython_rpms/ + http://mpa.itc.it/markus/wxpython_rpms/fedora/ + * Mandriva 2007.0: http://mpa.itc.it/markus/wxpython_rpms/mandriva2007.0/ * Mandriva 2007.1 (spring): available from main/backports (see http://club.mandriva.com/xwiki/bin/view/Downloads/MirrorFinder2 ) Also http://www.wxpython.org/download.php From barton at grass.itc.it Thu Aug 16 07:45:25 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Thu Aug 16 07:45:26 2007 Subject: [grass-addons] r1025 - trunk/grassaddons/gui/gui_modules Message-ID: <200708160545.l7G5jPX3017099@grass.itc.it> Author: barton Date: 2007-08-16 07:45:16 +0200 (Thu, 16 Aug 2007) New Revision: 1025 Modified: trunk/grassaddons/gui/gui_modules/render.py Log: removed more temporary debugging code Modified: trunk/grassaddons/gui/gui_modules/render.py =================================================================== --- trunk/grassaddons/gui/gui_modules/render.py 2007-08-14 08:37:46 UTC (rev 1024) +++ trunk/grassaddons/gui/gui_modules/render.py 2007-08-16 05:45:16 UTC (rev 1025) @@ -235,7 +235,6 @@ """ Reads current region settings from g.region command """ - print "in initregion" # # setting region @@ -382,7 +381,6 @@ Example: {"n":"4928010", "s":"4913700", "w":"589980",...} """ - print "in getregion" region = {} @@ -404,13 +402,15 @@ return region - def SetRegion(self): + def SetRegion(self, windres=False): """ Render string for GRASS_REGION env. variable, so that the images will be rendered from desired zoom level. Returns: string usable for GRASS_REGION variable or None + If windres set to True, uses resolution from WIND file rather than display + (for modules that require set resolution like d.rast.num) """ grass_region = "" From landa at grass.itc.it Thu Aug 16 09:50:01 2007 From: landa at grass.itc.it (landa@grass.itc.it) Date: Thu Aug 16 09:50:03 2007 Subject: [grass-addons] r1026 - trunk/grassaddons/gui Message-ID: <200708160750.l7G7o1C7018147@grass.itc.it> Author: landa Date: 2007-08-16 09:49:42 +0200 (Thu, 16 Aug 2007) New Revision: 1026 Modified: trunk/grassaddons/gui/README Log: Debian GNU/Linux installation notes updated Modified: trunk/grassaddons/gui/README =================================================================== --- trunk/grassaddons/gui/README 2007-08-16 05:45:16 UTC (rev 1025) +++ trunk/grassaddons/gui/README 2007-08-16 07:49:42 UTC (rev 1026) @@ -1,7 +1,8 @@ GRASS graphical user interface ============================== -AUTHORS: Jachym, Michael, MartinL +AUTHORS: Michael Barton, Jachym Cepicky, Martin Landa + $LastChangedDate$ --------------------------------------------------------------------- @@ -9,8 +10,10 @@ Python >=2.4 and wxPython >=2.8.1.1 Get wxPython 2.8.x packages from: - * Source: : http://www.wxpython.org/download.php - * Debian: http://www.bitpim.org/developer.html -> "Install wxPython" + * Source: http://www.wxpython.org/download.php + * Debian GNU/Linux: http://wiki.wxpython.org/InstallingOnUbuntuOrDebian + [ deb http://apt.wxwidgets.org/ etch-wx main ] + http://www.bitpim.org/developer.html -> "Install wxPython" * Fedora: http://www.wxpython.org/download.php http://mpa.itc.it/markus/wxpython_rpms/fedora/ * Mandriva 2007.0: http://mpa.itc.it/markus/wxpython_rpms/mandriva2007.0/ From barton at grass.itc.it Thu Aug 16 18:15:01 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Thu Aug 16 18:15:03 2007 Subject: [grass-addons] r1027 - trunk/grassaddons/gui/gui_modules Message-ID: <200708161615.l7GGF138024776@grass.itc.it> Author: barton Date: 2007-08-16 18:14:52 +0200 (Thu, 16 Aug 2007) New Revision: 1027 Modified: trunk/grassaddons/gui/gui_modules/render.py Log: Code cleanup. Classes changed to new style for Python 2.4+ Modified: trunk/grassaddons/gui/gui_modules/render.py =================================================================== --- trunk/grassaddons/gui/gui_modules/render.py 2007-08-16 07:49:42 UTC (rev 1026) +++ trunk/grassaddons/gui/gui_modules/render.py 2007-08-16 16:14:52 UTC (rev 1027) @@ -22,7 +22,7 @@ import cmd from debug import Debug as Debug -class MapLayer: +class MapLayer(object): """ This class serves for storing map layers to be displayed @@ -166,7 +166,7 @@ else: return int (self.opacity * 100) -class Map: +class Map(object): """ This class serves for rendering of output images. @@ -489,7 +489,7 @@ projinfo['proj'] = "xy" return projinfo else: - return + return None def GetListOfLayers(self, l_type=None, l_mapset=None, l_active=None, l_hidden=None): """ From barton at grass.itc.it Thu Aug 16 18:16:36 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Thu Aug 16 18:16:38 2007 Subject: [grass-addons] r1028 - trunk/grassaddons/gui/gui_modules Message-ID: <200708161616.l7GGGaWk024797@grass.itc.it> Author: barton Date: 2007-08-16 18:16:28 +0200 (Thu, 16 Aug 2007) New Revision: 1028 Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py Log: Barscale and legend overlay code improved. Overlay layers not added until user selects overlay from menubar. Barscale (north arrow only) and legend now work in latlon locations. Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py =================================================================== --- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-08-16 16:14:52 UTC (rev 1027) +++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-08-16 16:16:28 UTC (rev 1028) @@ -1494,12 +1494,6 @@ for i in range(len(map_frame_statusbar_fields)): self.statusbar.SetStatusText(map_frame_statusbar_fields[i], i) - - # d.barscale overlay added to rendering overlay list - self.Map.AddOverlay(0, type='overlay', command=['d.barscale'], l_active=False, l_render=False) - # d.barscale overlay added to rendering overlay list as placeholder for d.legend - self.Map.AddOverlay(1, type='overlay', command=['d.barscale'], l_active=False, l_render=False) - # # Init map display # @@ -2087,29 +2081,18 @@ ovltype = id = 0 # index for overlay layer in render - if ovltype not in self.Map.ovlookup: - self.Map.AddOverlay(ovltype, type='overlay', command='d.barscale', l_active=False, l_render=False) - if ovltype in self.params: params = self.params[ovltype] else: params = '' - # get overlay images (overlay must be active) - if not self.Map.ovlookup[ovltype].active: - self.Map.ovlookup[ovltype].active = True - self.Map.Render(force=True) + # If location is latlon, only display north arrow (scale won't work) +# proj = self.projinfo['proj'] +# if proj == 'll': +# barcmd = 'd.barscale -n' +# else: +# barcmd = 'd.barscale' - ovldict = self.MapWindow.GetOverlay() - - if id not in ovldict: - return - - img = ovldict[id] - - if id not in self.ovlcoords: - self.ovlcoords[id] = [10,10] - # decoration overlay control dialog dlg = DecDialog(self, wx.ID_ANY, _('Scale and North arrow'), size=(350, 200), style=wx.DEFAULT_DIALOG_STYLE, @@ -2122,16 +2105,34 @@ dlg.CenterOnScreen() +# if ovltype not in self.Map.ovlookup: +# self.Map.AddOverlay(ovltype, type='overlay', command=['d.barscale'], l_active=False, l_render=False) + + # if OK button pressed in decoration control dialog if dlg.ShowModal() == wx.ID_OK: if self.ovlchk[id] == True: + # get overlay images (overlay must be active) + if not self.Map.ovlookup[ovltype].active: + self.Map.ovlookup[ovltype].active = True + self.Map.Render(force=True) + + ovldict = self.MapWindow.GetOverlay() + + if id not in ovldict: + self.MapWindow.UpdateMap() + return + + img = ovldict[id] + + if id not in self.ovlcoords: + self.ovlcoords[id] = [10,10] + self.MapWindow.Draw(self.MapWindow.pdc, drawid=id, img=img, pdctype='image', coords=self.ovlcoords[id]) - # update the map canvas self.MapWindow.UpdateMap() - dlg.Destroy() # close properties dialog if open @@ -2146,29 +2147,11 @@ """ ovltype = id = 1 # index for overlay layer in render - if ovltype not in self.Map.ovlookup: - self.Map.AddOverlay(ovltype, type='overlay', command='d.barscale', l_active=False, l_render=False) - if ovltype in self.params: params = self.params[ovltype] else: params = '' - # get overlay images (overlay must be active) - if not self.Map.ovlookup[ovltype].active: - self.Map.ovlookup[ovltype].active = True - self.Map.Render(force=True) - - ovldict = self.MapWindow.GetOverlay() - - if id not in ovldict: - return - - img = ovldict[id] - - if id not in self.ovlcoords: - self.ovlcoords[id] = [10,10] - # Decoration overlay control dialog dlg = DecDialog(self, wx.ID_ANY, 'Legend', size=(350, 200), style=wx.DEFAULT_DIALOG_STYLE, @@ -2184,10 +2167,27 @@ # If OK button pressed in decoration control dialog val = dlg.ShowModal() if val == wx.ID_OK: + if self.ovlchk[id] == True: + # get overlay images (overlay must be active) + if not self.Map.ovlookup[ovltype].active: + self.Map.ovlookup[ovltype].active = True + self.Map.Render(force=True) + + ovldict = self.MapWindow.GetOverlay() + + if id not in ovldict: + self.MapWindow.UpdateMap() + return + + img = ovldict[id] + + if id not in self.ovlcoords: + self.ovlcoords[id] = [10,10] + self.MapWindow.Draw(self.MapWindow.pdc, drawid=id, - img=img, pdctype='image', - coords=self.ovlcoords[id]) + img=img, pdctype='image', + coords=self.ovlcoords[id]) self.MapWindow.UpdateMap() dlg.Destroy() @@ -2234,10 +2234,13 @@ # delete object if if it has no text if maptext == '': - self.MapWindow.pdc.ClearId(id) - self.MapWindow.pdc.RemoveId(id) - del self.MapWindow.textdict[id] - del self.ovlcoords[id] + try: + self.MapWindow.pdc.ClearId(id) + self.MapWindow.pdc.RemoveId(id) + del self.MapWindow.textdict[id] + del self.ovlcoords[id] + except: + pass return self.MapWindow.pdc.ClearId(id) @@ -2310,6 +2313,9 @@ self.ovlchk = self.parent.MapWindow.ovlchk self.params = params #previously set decoration options to pass back to options dialog + if self.ovltype not in self.parent.Map.ovlookup: + self.parent.Map.AddOverlay(self.ovltype, type='overlay', command=[self.ovlcmd], l_active=False, l_render=False) + #self.MakeModal(True) sizer = wx.BoxSizer(wx.VERTICAL) @@ -2364,6 +2370,7 @@ """ Sets option for decoration map overlays """ + # display properties dialog (modal mode) menuform.GUI().ParseCommand(self.ovlcmd, gmpath, completed=(self.parent.GetOptData, self.ovltype, self.params), From barton at grass.itc.it Thu Aug 16 19:18:55 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Thu Aug 16 19:18:57 2007 Subject: [grass-addons] r1029 - trunk/grassaddons/gui Message-ID: <200708161718.l7GHItro025368@grass.itc.it> Author: barton Date: 2007-08-16 19:18:47 +0200 (Thu, 16 Aug 2007) New Revision: 1029 Modified: trunk/grassaddons/gui/wxgrass Log: Updated wxgrass startup script so that it runs non-modally Modified: trunk/grassaddons/gui/wxgrass =================================================================== --- trunk/grassaddons/gui/wxgrass 2007-08-16 16:16:28 UTC (rev 1028) +++ trunk/grassaddons/gui/wxgrass 2007-08-16 17:18:47 UTC (rev 1029) @@ -5,12 +5,12 @@ exit 1 fi -SYSTEM=`uname -s` +#SYSTEM=`uname -s` -if [ "$SYSTEM" = "Darwin" ] ; then - pythonw "$GISBASE/etc/wx/wxgui.py" -name wxgui_py -else - python "$GISBASE/etc/wx/wxgui.py" -name wxgui_py -fi +#if [ "$SYSTEM" = "Darwin" ] ; then +# pythonw "$GISBASE/etc/wx/wxgui.py" -name wxgui_py +#else + python "$GISBASE/etc/wx/wxgui.py" -name wxgui_py & +#fi exit 0 From bundala at grass.itc.it Fri Aug 17 00:01:12 2007 From: bundala at grass.itc.it (bundala@grass.itc.it) Date: Fri Aug 17 00:01:14 2007 Subject: [grass-addons] r1030 - trunk/grassaddons/v.generalize Message-ID: <200708162201.l7GM1CRA027822@grass.itc.it> Author: bundala Date: 2007-08-17 00:01:10 +0200 (Fri, 17 Aug 2007) New Revision: 1030 Modified: trunk/grassaddons/v.generalize/smoothing.c Log: fixed bug in distance_weighting Modified: trunk/grassaddons/v.generalize/smoothing.c =================================================================== --- trunk/grassaddons/v.generalize/smoothing.c 2007-08-16 17:18:47 UTC (rev 1029) +++ trunk/grassaddons/v.generalize/smoothing.c 2007-08-16 22:01:10 UTC (rev 1030) @@ -134,7 +134,7 @@ int with_z) { POINT p, c, s, tmp; - int n, i, next, half, j; + int n, i, half, j; double dists, d; POINT *res; @@ -153,7 +153,6 @@ point_assign(Points, 0, with_z, &res[0]); - next = 1; half = look_ahead / 2; for (i = half; i + half < n; i++) { @@ -178,14 +177,13 @@ }; point_scalar(s, slide / dists, &tmp); point_scalar(c, (double)1.0 - slide, &s); - point_add(s, tmp, &res[next]); - next++; + point_add(s, tmp, &res[i]); }; for (i = half; i + half < n; i++) { - Points->x[i] = res[i - half].x; - Points->y[i] = res[i - half].y; - Points->z[i] = res[i - half].z; + Points->x[i] = res[i].x; + Points->y[i] = res[i].y; + Points->z[i] = res[i].z; }; G_free(res); From landa at grass.itc.it Fri Aug 17 10:44:57 2007 From: landa at grass.itc.it (landa@grass.itc.it) Date: Fri Aug 17 10:44:59 2007 Subject: [grass-addons] r1031 - in trunk/grassaddons/gui: . display_driver Message-ID: <200708170844.l7H8ivBB002882@grass.itc.it> Author: landa Date: 2007-08-17 10:43:28 +0200 (Fri, 17 Aug 2007) New Revision: 1031 Added: trunk/grassaddons/gui/display_driver/ trunk/grassaddons/gui/display_driver/Makefile trunk/grassaddons/gui/display_driver/Makefile.in trunk/grassaddons/gui/display_driver/driver.cc trunk/grassaddons/gui/display_driver/driver.h trunk/grassaddons/gui/display_driver/driver.i Log: Experimental C++ wxWidgets display driver for digitization tool. The beta version of digitization tool is still unfinished, now disabled for user. Added: trunk/grassaddons/gui/display_driver/Makefile =================================================================== --- trunk/grassaddons/gui/display_driver/Makefile (rev 0) +++ trunk/grassaddons/gui/display_driver/Makefile 2007-08-17 08:43:28 UTC (rev 1031) @@ -0,0 +1,34 @@ +PYTHONVERSION=2.4 + +MODULE_TOPDIR = ../../.. + +include $(MODULE_TOPDIR)/include/Make/Lib.make +include $(MODULE_TOPDIR)/include/Make/Doxygen.make + +SWIG=swig + +CFLAGS=-c -fpic -I/usr/include/python$(PYTHONVERSION) -I./ -I$(ARCH_DISTDIR)/include `wx-config --cxxflags` + +LDFLAGS=-shared -L$(ARCH_LIBDIR) -lgrass_vect -lgrass_gis `wx-config --libs` + +default: grass6_wxdriver.so + +clean: + -rm -f *.o *.so grass6_wxdriver_wrap.cxx grass6_wxdriver.py grass6_wxdriver.i grass6_wxdriver.pyc + +grass6_wxdriver.i: + cat ./driver.i > grass6_wxdriver.i + echo "/* auto-generate swig typedef file (with some GRASS functions removed) */" >> grass6_wxdriver.i + cat ./driver.h >> grass6_wxdriver.i + +grass6_wxdriver_wrap.cxx: grass6_wxdriver.i + $(SWIG) -c++ -python -shadow $< + +grass6_wxdriver_wrap.o: grass6_wxdriver_wrap.cxx + $(CXX) $(CFLAGS) $(INCLUDE_DIRS) $< + +driver.o: driver.cc + $(CXX) $(CFLAGS) $(INCLUDE_DIRS) $< + +grass6_wxdriver.so: grass6_wxdriver_wrap.o driver.o + $(CXX) $(LDFLAGS) grass6_wxdriver_wrap.o driver.o -o _grass6_wxdriver.so Added: trunk/grassaddons/gui/display_driver/Makefile.in =================================================================== --- trunk/grassaddons/gui/display_driver/Makefile.in (rev 0) +++ trunk/grassaddons/gui/display_driver/Makefile.in 2007-08-17 08:43:28 UTC (rev 1031) @@ -0,0 +1,38 @@ +### DEFINITIONS + +PYTHONVERSION=@PYVERSION@ + +### END DEFINITIONS + +MODULE_TOPDIR = ../../.. + +include $(MODULE_TOPDIR)/include/Make/Lib.make +include $(MODULE_TOPDIR)/include/Make/Doxygen.make + +SWIG=swig + +CFLAGS=-c -fpic -I/usr/include/python$(PYTHONVERSION) -I./ -I$(ARCH_DISTDIR)/include `wx-config --cxxflags` + +LDFLAGS=-shared -L$(ARCH_LIBDIR) -lgrass_vect -lgrass_gis `wx-config --libs` + +default: grass6_wxdriver.so + +clean: + -rm -f *.o *.so grass6_wxdriver_wrap.cxx grass6_wxdriver.py grass6_wxdriver.i grass6_wxdriver.pyc + +grass6_wxdriver.i: + cat ./driver.i > grass6_wxdriver.i + echo "/* auto-generate swig typedef file (with some GRASS functions removed) */" >> grass6_wxdriver.i + cat ./driver.h >> grass6_wxdriver.i + +grass6_wxdriver_wrap.cxx: grass6_wxdriver.i + $(SWIG) -c++ -python -shadow $< + +grass6_wxdriver_wrap.o: grass6_wxdriver_wrap.cxx + $(CXX) $(CFLAGS) $(INCLUDE_DIRS) $< + +driver.o: driver.cc + $(CXX) $(CFLAGS) $(INCLUDE_DIRS) $< + +grass6_wxdriver.so: grass6_wxdriver_wrap.o driver.o + $(CXX) $(LDFLAGS) grass6_wxdriver_wrap.o driver.o -o _grass6_wxdriver.so Added: trunk/grassaddons/gui/display_driver/driver.cc =================================================================== --- trunk/grassaddons/gui/display_driver/driver.cc (rev 0) +++ trunk/grassaddons/gui/display_driver/driver.cc 2007-08-17 08:43:28 UTC (rev 1031) @@ -0,0 +1,400 @@ +/** + \file driver.cc + + \brief Experimental C++ wxWidgets display driver + + This driver is designed for wxPython GRASS GUI. + Displays vector map layers when Digitization tool is + activated. + + \author Martin Landa + + (C) 2007 by the GRASS Development Team + + This program is free software under the GNU General Public + License (>=v2). Read the file COPYING that comes with GRASS + for details. +*/ + +#include "driver.h" + +/** + \brief Initialize driver + + Allocate given structures. + + \param + + \return +*/ +DisplayDriver::DisplayDriver() +{ + G_gisinit(""); /* need by other GRASS functions */ + + mapInfo = NULL; + + points = Vect_new_line_struct(); + pointsScreen = new wxList(); + cats = Vect_new_cats_struct(); + +} + +/** + \brief Destroy driver + + Close the map, deallocate given structures. + + \param + + \return +*/ +DisplayDriver::~DisplayDriver() +{ + if (mapInfo) + CloseMap(); + + Vect_destroy_line_struct(points); + delete pointsScreen; + Vect_destroy_cats_struct(cats); +} + +/** + \brief Display content of the map in device + + \param[in,out] device wxDC object where to draw vector features + + \return number of displayed features + \return -1 on error + */ +int DisplayDriver::DrawMap(void *device) +{ + if (!mapInfo) + return -1; + + dc = (wxDC *) device; + + int nlines; + + nlines = Vect_get_num_lines(mapInfo); + + for (int line = 1; line <= nlines; line++) { + DrawLine(line); + } + + dc = NULL; + + return nlines; +} + +/** + \brief Display selected vector feature + + \param[in] id of the vector feature + + \return 1 on success + \return -1 on failure (vector feature is dead, etc.) +*/ +int DisplayDriver::DrawLine(int line) +{ + if (!dc || !Vect_line_alive (mapInfo, line)) + return -1; + + int type; // line type + int x, y, z; // screen coordinates + bool draw; // draw object ? + + type = Vect_read_line (mapInfo, points, cats, line); + pointsScreen->Clear(); + + //self.ids[line] = [] + for (int i = 0; i < points->n_points; i++) { + Cell2Pixel(points->x[i], points->y[i], points->z[i], + &x, &y, &z); + pointsScreen->Append((wxObject*) new wxPoint(x, y)); /* TODO: 3D */ + } + + // draw vector feature + if (type & GV_LINES) { + switch (type) { + case GV_LINE: + dc->SetPen(wxPen(settings.line.color, settings.lineWidth, wxSOLID)); + draw = settings.line.enabled; + break; + case GV_BOUNDARY: + int left, right; + Vect_get_line_areas(mapInfo, line, + &left, &right); + if (left == 0 && right == 0) { + dc->SetPen(wxPen(settings.boundaryNo.color, settings.lineWidth, wxSOLID)); + draw = settings.boundaryNo.enabled; + } + else if (left > 0 && right > 0) { + dc->SetPen(wxPen(settings.boundaryTwo.color, settings.lineWidth, wxSOLID)); + draw = settings.boundaryTwo.enabled; + } + else { + dc->SetPen(wxPen(settings.boundaryOne.color, settings.lineWidth, wxSOLID)); + draw = settings.boundaryOne.enabled; + } + break; + default: + draw = FALSE; + break; + } + + if (draw) { + dc->DrawLines(pointsScreen); + if (settings.vertex.enabled) { + dc->SetPen(wxPen(settings.vertex.color, settings.lineWidth, wxSOLID)); + DrawLineVerteces(); + } + DrawLineNodes(line); + } + } + else if (type & GV_POINTS) { + if (type == GV_POINT && settings.point.enabled) { + dc->SetPen(wxPen(settings.point.color, settings.lineWidth, wxSOLID)); + DrawCross((const wxPoint *) pointsScreen->GetFirst()->GetData()); + } + else if (type == GV_CENTROID) { + int cret = Vect_get_centroid_area(mapInfo, line); + if (cret > 0) { // -> area + draw = settings.centroidIn.enabled; + dc->SetPen(wxPen(settings.centroidIn.color, settings.lineWidth, wxSOLID)); + } + else if (cret == 0) { + draw = settings.centroidOut.enabled; + dc->SetPen(wxPen(settings.centroidOut.color, settings.lineWidth, wxSOLID)); + } + else { + draw = settings.centroidDup.enabled; + dc->SetPen(wxPen(settings.centroidDup.color, settings.lineWidth, wxSOLID)); + } + + if (draw) + DrawCross((const wxPoint *) pointsScreen->GetFirst()->GetData()); + } + } + + return 1; +} + +/** + \brief Display verteces of the line + + Except of first and last vertex, see DisplayNodes(). + + \param + + \return number of displayed verteces +*/ +int DisplayDriver::DrawLineVerteces() +{ + for (int i = 1; i < pointsScreen->GetCount() - 1; i++) { + DrawCross((const wxPoint*) pointsScreen->Item(i)->GetData()); + } + + return pointsScreen->GetCount() - 2; +} + +/** + \brief Display nodes of the line + + \param + + \return 1 +*/ +int DisplayDriver::DrawLineNodes(int line) +{ + int node; + double east, north, depth; + int x, y, z; + int nodes [2]; + + Vect_get_line_nodes(mapInfo, line, &(nodes[0]), &(nodes[1])); + + for (int i = 0; i < sizeof(nodes) / sizeof(int); i++) { + node = nodes[i]; + Vect_get_node_coor(mapInfo, node, + &east, &north, &depth); + + Cell2Pixel(east, north, depth, + &x, &y, &z); + + if (Vect_get_node_n_lines(mapInfo, node) == 1) + dc->SetPen(wxPen(settings.nodeOne.color, settings.lineWidth, wxSOLID)); + else + dc->SetPen(wxPen(settings.nodeTwo.color, settings.lineWidth, wxSOLID)); + + wxPoint point(x, y); + DrawCross(&point); + + //elf.ids[line].append(self.mapwindow.DrawCross(coords, size=5)) + } + + return 1; +} + + +/* + \brief Close vector map layer + + \param + + \return +*/ +void DisplayDriver::CloseMap() +{ + if (mapInfo) { + Vect_close(mapInfo); + G_free ((void *) mapInfo); + mapInfo = NULL; + } + + return; +} + +/** + \brief Open vector map layer + + \param[in] mapname name of vector map + \param[in] mapset name of mapset where the vector map layer is stored + + \return +*/ +void DisplayDriver::OpenMap(const char* mapname, const char *mapset) +{ + if (!mapInfo) + mapInfo = (struct Map_info *) G_malloc (sizeof (struct Map_info)); + +// define open level (level 2: topology) + Vect_set_open_level(2); + +// open existing map + Vect_open_old(mapInfo, (char*) mapname, (char *) mapset); + + return; +} + +/* + \brief Conversion from geographic coordinates (east, north) + to screen (x, y) + + \param[in] east,north,elev geographical coordinates + \param[out] x, y, z screen coordinates + + \return +*/ +void DisplayDriver::Cell2Pixel(double east, double north, double depth, + int *x, int *y, int *z) +{ + *x = int((east - region.west) / region.ew_res); + *y = int((region.north - north) / region.ns_res); + *z = 0; + + return; +} + +/** + \brief Set geographical region + + Needed for Cell2Pixel(). + + \param[in] north,south,east,west,ns_res,ew_res region settings + + \return +*/ +void DisplayDriver::SetRegion(double north, double south, double east, double west, + double ns_res, double ew_res) +{ + region.north = north; + region.south = south; + region.east = east; + region.west = west; + region.ns_res = ns_res; + region.ew_res = ew_res; + + return; +} + +/** + \brief Draw cross symbol of given size in device content + + Used for points, node, vertices + + \param[in] point coordinates of center + \param[in] size size of the cross symbol + + \return 1 on success + \return -1 on failure +*/ +int DisplayDriver::DrawCross(const wxPoint* point, int size) +{ + if (!dc || !point) + return -1; + + //self.lineid = wx.NewId() + dc->DrawLine(point->x - size, point->y, point->x + size, point->y); + dc->DrawLine(point->x, point->y - size, point->x, point->y + size); + + return 1; +} + +/* + \brief Set settings for displaying vector feature + + E.g. line width, color, ... + + \param[in] lineWidth,... settgings + + \return +*/ +void DisplayDriver::SetSettings(unsigned long highlight, + bool ePoint, unsigned long cPoint, /* enabled, color */ + bool eLine, unsigned long cLine, + bool eBoundaryNo, unsigned long cBoundaryNo, + bool eBoundaryOne, unsigned long cBoundaryOne, + bool eBoundaryTwo, unsigned long cBoundaryTwo, + bool eCentroidIn, unsigned long cCentroidIn, + bool eCentroidOut, unsigned long cCentroidOut, + bool eCentroidDup, unsigned long cCentroidDup, + bool eNodeOne, unsigned long cNodeOne, + bool eNodeTwo, unsigned long cNodeTwo, + bool eVertex, unsigned long cVertex, + int lineWidth) +{ + settings.highlight.Set(highlight); + + settings.point.enabled = ePoint; + settings.point.color.Set(cPoint); + + settings.line.enabled = eLine; + settings.line.color.Set(cLine); + + settings.boundaryNo.enabled = eBoundaryNo; + settings.boundaryNo.color.Set(cBoundaryNo); + settings.boundaryOne.enabled = eBoundaryOne; + settings.boundaryOne.color.Set(cBoundaryOne); + settings.boundaryTwo.enabled = eBoundaryTwo; + settings.boundaryTwo.color.Set(cBoundaryTwo); + + + settings.centroidIn.enabled = eCentroidIn; + settings.centroidIn.color.Set(cCentroidIn); + settings.centroidOut.enabled = eCentroidOut; + settings.centroidOut.color.Set(cCentroidOut); + settings.centroidDup.enabled = eCentroidDup; + settings.centroidDup.color.Set(cCentroidDup); + + settings.nodeOne.enabled = eNodeOne; + settings.nodeOne.color.Set(cNodeOne); + settings.nodeTwo.enabled = eNodeTwo; + settings.nodeTwo.color.Set(cNodeTwo); + + settings.vertex.enabled = eVertex; + settings.vertex.color.Set(cVertex); + + + settings.lineWidth = lineWidth; + +} Added: trunk/grassaddons/gui/display_driver/driver.h =================================================================== --- trunk/grassaddons/gui/display_driver/driver.h (rev 0) +++ trunk/grassaddons/gui/display_driver/driver.h 2007-08-17 08:43:28 UTC (rev 1031) @@ -0,0 +1,108 @@ +#include + +// For compilers that support precompilation, includes "wx.h". +#include + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +// Include your minimal set of headers here, or wx.h +#include +#endif + +#include +#include + +extern "C" { +#include +#include +} + +class DisplayDriver +{ + private: + wxDC *dc; /* device content */ + + struct Map_info *mapInfo; + struct line_pnts *points; // east, north, depth + wxList *pointsScreen; // x, y, z + struct line_cats *cats; + + struct _region { + double north; + double south; + double east; + double west; + double ns_res; + double ew_res; + } region; + + struct symbol { + bool enabled; + wxColor color; + }; + + struct _settings { + wxColor highlight; + + symbol point; + symbol line; + + symbol boundaryNo; + symbol boundaryOne; + symbol boundaryTwo; + + symbol centroidIn; + symbol centroidOut; + symbol centroidDup; + + symbol nodeOne; + symbol nodeTwo; + + symbol vertex; + + int lineWidth; // screen units + + } settings; + + void Cell2Pixel (double east, double north, double depth, + int *x, int *y, int *z); + + int DrawCross(const wxPoint *point, int size=5); + + int DrawLine(int line); + int DrawLineVerteces(); + int DrawLineNodes(int line); + + public: + /* constructor */ + DisplayDriver(); + /* destructor */ + ~DisplayDriver(); + + /* display */ + int DrawMap(void *device); + + /* general */ + void CloseMap(); + void OpenMap(const char *mapname, const char *mapset); + + /* set */ + void SetRegion(double north, double south, double east, double west, + double ns_res, double ew_res); + void SetSettings(unsigned long highlight, + bool ePoint, unsigned long cPoint, /* enabled, color */ + bool eLine, unsigned long cLine, + bool eBoundaryNo, unsigned long cBoundaryNo, + bool eBoundaryOne, unsigned long cBoundaryOne, + bool eBoundaryTwo, unsigned long cBoundaryTwo, + bool eCentroidIn, unsigned long cCentroidIn, + bool eCentroidOut, unsigned long cCentroidOut, + bool eCentroidDup, unsigned long cCentroidDup, + bool eNodeOne, unsigned long cNodeOne, + bool eNodeTwo, unsigned long cNodeTwo, + bool eVertex, unsigned long cVertex, + int lineWidth); +}; Added: trunk/grassaddons/gui/display_driver/driver.i =================================================================== --- trunk/grassaddons/gui/display_driver/driver.i (rev 0) +++ trunk/grassaddons/gui/display_driver/driver.i 2007-08-17 08:43:28 UTC (rev 1031) @@ -0,0 +1,10 @@ +/* File: driver.i */ + +%module grass6_wxdriver +%{ +#include +#include +#include +#include +#include "driver.h" +%} From landa at grass.itc.it Sat Aug 18 16:42:12 2007 From: landa at grass.itc.it (landa@grass.itc.it) Date: Sat Aug 18 16:42:17 2007 Subject: [grass-addons] r1032 - in trunk/grassaddons/gui: display_driver gui_modules Message-ID: <200708181442.l7IEgCsc005504@grass.itc.it> Author: landa Date: 2007-08-18 16:40:53 +0200 (Sat, 18 Aug 2007) New Revision: 1032 Added: trunk/grassaddons/gui/display_driver/pseudodc.cpp Modified: trunk/grassaddons/gui/display_driver/Makefile trunk/grassaddons/gui/display_driver/driver.cc trunk/grassaddons/gui/display_driver/driver.h trunk/grassaddons/gui/gui_modules/digit.py trunk/grassaddons/gui/gui_modules/mapdisp.py trunk/grassaddons/gui/gui_modules/render.py trunk/grassaddons/gui/gui_modules/toolbars.py trunk/grassaddons/gui/gui_modules/wxgui_utils.py Log: Digitization tool: Use wx.PseudoDC instead of wxDC. Temporary added pseudodc.cpp from wxPython src. Modified: trunk/grassaddons/gui/display_driver/Makefile =================================================================== --- trunk/grassaddons/gui/display_driver/Makefile 2007-08-17 08:43:28 UTC (rev 1031) +++ trunk/grassaddons/gui/display_driver/Makefile 2007-08-18 14:40:53 UTC (rev 1032) @@ -7,7 +7,7 @@ SWIG=swig -CFLAGS=-c -fpic -I/usr/include/python$(PYTHONVERSION) -I./ -I$(ARCH_DISTDIR)/include `wx-config --cxxflags` +CFLAGS=-c -fpic -I/usr/include/python$(PYTHONVERSION) -I./ -I$(ARCH_DISTDIR)/include `wx-config --cxxflags` LDFLAGS=-shared -L$(ARCH_LIBDIR) -lgrass_vect -lgrass_gis `wx-config --libs` @@ -30,5 +30,8 @@ driver.o: driver.cc $(CXX) $(CFLAGS) $(INCLUDE_DIRS) $< -grass6_wxdriver.so: grass6_wxdriver_wrap.o driver.o - $(CXX) $(LDFLAGS) grass6_wxdriver_wrap.o driver.o -o _grass6_wxdriver.so +pseudodc.o: pseudodc.cpp + $(CXX) $(CFLAGS) $(INCLUDE_DIRS) $< + +grass6_wxdriver.so: grass6_wxdriver_wrap.o driver.o pseudodc.o + $(CXX) $(LDFLAGS) grass6_wxdriver_wrap.o driver.o pseudodc.o -o _grass6_wxdriver.so Modified: trunk/grassaddons/gui/display_driver/driver.cc =================================================================== --- trunk/grassaddons/gui/display_driver/driver.cc 2007-08-17 08:43:28 UTC (rev 1031) +++ trunk/grassaddons/gui/display_driver/driver.cc 2007-08-18 14:40:53 UTC (rev 1032) @@ -32,6 +32,7 @@ G_gisinit(""); /* need by other GRASS functions */ mapInfo = NULL; + dcId = 1; points = Vect_new_line_struct(); pointsScreen = new wxList(); @@ -71,8 +72,11 @@ if (!mapInfo) return -1; - dc = (wxDC *) device; + dc = (wxPseudoDC *) device; + dcId = 1; + ids.clear(); + int nlines; nlines = Vect_get_num_lines(mapInfo); @@ -81,6 +85,8 @@ DrawLine(line); } + PrintIds(); + dc = NULL; return nlines; @@ -105,7 +111,6 @@ type = Vect_read_line (mapInfo, points, cats, line); pointsScreen->Clear(); - //self.ids[line] = [] for (int i = 0; i < points->n_points; i++) { Cell2Pixel(points->x[i], points->y[i], points->z[i], @@ -143,10 +148,21 @@ } if (draw) { - dc->DrawLines(pointsScreen); + //dc->DrawLines(pointsScreen); + for (int i = 0; i < pointsScreen->GetCount() - 1;) { + wxPoint *point_beg = (wxPoint *) pointsScreen->Item(i)->GetData(); + wxPoint *point_end = (wxPoint *) pointsScreen->Item(++i)->GetData(); + + ids[line].push_back(dcId); + dc->SetId(dcId++); + + dc->DrawLine(point_beg->x, point_beg->y, + point_end->x, point_end->y); + } + if (settings.vertex.enabled) { dc->SetPen(wxPen(settings.vertex.color, settings.lineWidth, wxSOLID)); - DrawLineVerteces(); + DrawLineVerteces(line); } DrawLineNodes(line); } @@ -154,7 +170,7 @@ else if (type & GV_POINTS) { if (type == GV_POINT && settings.point.enabled) { dc->SetPen(wxPen(settings.point.color, settings.lineWidth, wxSOLID)); - DrawCross((const wxPoint *) pointsScreen->GetFirst()->GetData()); + DrawCross(line, (const wxPoint *) pointsScreen->GetFirst()->GetData()); } else if (type == GV_CENTROID) { int cret = Vect_get_centroid_area(mapInfo, line); @@ -172,7 +188,7 @@ } if (draw) - DrawCross((const wxPoint *) pointsScreen->GetFirst()->GetData()); + DrawCross(line, (const wxPoint *) pointsScreen->GetFirst()->GetData()); } } @@ -188,10 +204,10 @@ \return number of displayed verteces */ -int DisplayDriver::DrawLineVerteces() +int DisplayDriver::DrawLineVerteces(int line) { for (int i = 1; i < pointsScreen->GetCount() - 1; i++) { - DrawCross((const wxPoint*) pointsScreen->Item(i)->GetData()); + DrawCross(line, (const wxPoint*) pointsScreen->Item(i)->GetData()); } return pointsScreen->GetCount() - 2; @@ -221,13 +237,13 @@ Cell2Pixel(east, north, depth, &x, &y, &z); - if (Vect_get_node_n_lines(mapInfo, node) == 1) + if (Vect_get_node_n_lines(mapInfo, node) == 1) dc->SetPen(wxPen(settings.nodeOne.color, settings.lineWidth, wxSOLID)); else dc->SetPen(wxPen(settings.nodeTwo.color, settings.lineWidth, wxSOLID)); wxPoint point(x, y); - DrawCross(&point); + DrawCross(line, &point); //elf.ids[line].append(self.mapwindow.DrawCross(coords, size=5)) } @@ -328,12 +344,14 @@ \return 1 on success \return -1 on failure */ -int DisplayDriver::DrawCross(const wxPoint* point, int size) +int DisplayDriver::DrawCross(int line, const wxPoint* point, int size) { if (!dc || !point) return -1; - //self.lineid = wx.NewId() + ids[line].push_back(dcId); + dc->SetId(dcId++); + dc->DrawLine(point->x - size, point->y, point->x + size, point->y); dc->DrawLine(point->x, point->y - size, point->x, point->y + size); @@ -398,3 +416,93 @@ settings.lineWidth = lineWidth; } + +/** + \brief Prints gId: dcIds + + Useful for debugging purposes. + + \param + + \return +*/ +void DisplayDriver::PrintIds() +{ + for (ids_map::const_iterator i = ids.begin(), e = ids.end(); + i != e; ++i) { + std::cout << i->first << ":"; + for(std::vector::const_iterator ii = i->second.begin(), ee = i->second.end(); + ii != ee; ++ii) { + std::cout << " " << *ii; + } + std::cout << std::endl; + } + return; +} + +/** + \brief Select vector features by given bounding box + + rect = ((x1, y1), (x2, y2)) + Number of selected features can be decreased by 'onlyType' + ('NULL' for all types) + + \param + + \return number of selected features + \return -1 on error +*/ +int DisplayDriver::SelectLinesByBox(double x1, double y1, double x2, double y2, + std::vector* ids) +{ + if (!mapInfo) + return -1; + + int type, line; + double dx, dy; + + struct ilist *list; + struct line_pnts *bbox; + + std::vector selected; + + type = -1; // all types + + list = Vect_new_list(); + bbox = Vect_new_line_struct(); + + dx = std::fabs(x2 - x1); + dy = std::fabs(y2 - y1); + + Vect_append_point(bbox, x1, y1, 0.0); + Vect_append_point(bbox, x2, y1, 0.0); + Vect_append_point(bbox, x2, y2, 0.0); + Vect_append_point(bbox, x1, y2, 0.0); + Vect_append_point(bbox, x1, y1, 0.0); + + Vect_select_lines_by_polygon(mapInfo, bbox, + 0, NULL, + type, list); + + for (int i = 0; i < list->n_values; i++) { + line = list->value[i]; + selected.push_back(line); + } + + // remove all duplicate ids + sort(selected.begin(), selected.end()); + selected.erase(unique(selected.begin(), selected.end()), selected.end()); + + Vect_destroy_line_struct(bbox); + Vect_destroy_list(list); + + for (std::vector::const_iterator i = selected.begin(), e = selected.end(); + i != e; ++i) + std::cout << *i << " "; + std::cout << std::endl; + + if (ids) + *ids = selected; + + return selected.size(); +} Modified: trunk/grassaddons/gui/display_driver/driver.h =================================================================== --- trunk/grassaddons/gui/display_driver/driver.h 2007-08-17 08:43:28 UTC (rev 1031) +++ trunk/grassaddons/gui/display_driver/driver.h 2007-08-18 14:40:53 UTC (rev 1032) @@ -1,4 +1,7 @@ -#include +#include // debug +#include +#include +#include // For compilers that support precompilation, includes "wx.h". #include @@ -15,6 +18,9 @@ #include #include +#include +#include + extern "C" { #include #include @@ -23,8 +29,13 @@ class DisplayDriver { private: - wxDC *dc; /* device content */ + wxPseudoDC *dc; // device content + long int dcId; // wxDC id starting + typedef std::map > ids_map; + + ids_map ids; + struct Map_info *mapInfo; struct line_pnts *points; // east, north, depth wxList *pointsScreen; // x, y, z @@ -70,12 +81,15 @@ void Cell2Pixel (double east, double north, double depth, int *x, int *y, int *z); - int DrawCross(const wxPoint *point, int size=5); + int DrawCross(int line, const wxPoint *point, int size=5); int DrawLine(int line); - int DrawLineVerteces(); + int DrawLineVerteces(int line); int DrawLineNodes(int line); + /* debug */ + void PrintIds(); + public: /* constructor */ DisplayDriver(); @@ -85,6 +99,10 @@ /* display */ int DrawMap(void *device); + /* select */ + int SelectLinesByBox(double x1, double y1, double x2, double y2, + std::vector* ids); + /* general */ void CloseMap(); void OpenMap(const char *mapname, const char *mapset); Added: trunk/grassaddons/gui/display_driver/pseudodc.cpp =================================================================== --- trunk/grassaddons/gui/display_driver/pseudodc.cpp (rev 0) +++ trunk/grassaddons/gui/display_driver/pseudodc.cpp 2007-08-18 14:40:53 UTC (rev 1032) @@ -0,0 +1,637 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: common/pseudodc.cpp +// Purpose: Implementation of the wxPseudoDC Class +// Author: Paul Lanier +// Modified by: +// Created: 05/25/06 +// RCS-ID: $Id: pseudodc.cpp 42187 2006-10-21 01:22:11Z RD $ +// Copyright: (c) wxWidgets team +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +// For compilers that support precompilation, includes "wx.h". +//include "wx/wxprec.h" + +#undef DEBUG +#include +#include "wx/wxPython/wxPython.h" +#include "wx/wxPython/pseudodc.h" + +// wxList based class definitions +#include +WX_DEFINE_LIST(pdcOpList); +WX_DEFINE_LIST(pdcObjectList); + +//---------------------------------------------------------------------------- +// Helper functions used for drawing greyed out versions of objects +//---------------------------------------------------------------------------- +wxColour &MakeColourGrey(const wxColour &c) +{ + static wxColour rval; + rval.Set(byte((230-c.Red())*0.7+c.Red()), + byte((230-c.Green())*0.7+c.Green()), + byte((230-c.Blue())*0.7+c.Blue())); + return rval; +} +wxBrush &GetGreyBrush(wxBrush &brush) +{ + static wxBrush b; + wxColour c; + b = brush; + c = MakeColourGrey(brush.GetColour()); + b.SetColour(c); + return b; +} + +wxPen &GetGreyPen(wxPen &pen) +{ + static wxPen p; + wxColour c; + p = pen; + c = MakeColourGrey(pen.GetColour()); + p.SetColour(c); + return p; +} + +void GreyOutImage(wxImage &img) +{ + unsigned char *data = img.GetData(); + unsigned char r,g,b; + unsigned char mr,mg,mb; + int i, tst; + int len = img.GetHeight()*img.GetWidth()*3; + if (img.HasMask()) + { + mr = img.GetMaskRed(); + mg = img.GetMaskGreen(); + mb = img.GetMaskBlue(); + } + tst=0; + for (i=0;iGetData()->DrawToDC(dc, m_greyedout); + node = node->GetNext(); + } +} + +// ---------------------------------------------------------------------------- +// Translate - translate all the operations by some dx,dy +// ---------------------------------------------------------------------------- +void pdcObject::Translate(wxCoord dx, wxCoord dy) +{ + pdcOpList::Node *node = m_oplist.GetFirst(); + while(node) + { + node->GetData()->Translate(dx,dy); + node = node->GetNext(); + } + if (m_bounded) + { + m_bounds.x += dx; + m_bounds.y += dy; + } +} + +// ---------------------------------------------------------------------------- +// SetGreyedOut - set the greyout member and cache grey versions of everything +// if greyout is true +// ---------------------------------------------------------------------------- +void pdcObject::SetGreyedOut(bool greyout) +{ + m_greyedout=greyout; + if (greyout) + { + pdcOpList::Node *node = m_oplist.GetFirst(); + pdcOp *obj; + while(node) + { + + obj = node->GetData(); + obj->CacheGrey(); + node = node->GetNext(); + } + } +} + +// ============================================================================ +// wxPseudoDC implementation +// ============================================================================ + +// ---------------------------------------------------------------------------- +// Destructor +// ---------------------------------------------------------------------------- +wxPseudoDC::~wxPseudoDC() +{ + // delete all the nodes in the list + RemoveAll(); + +} + +// ---------------------------------------------------------------------------- +// ClearAll - remove all nodes from list +// ---------------------------------------------------------------------------- +void wxPseudoDC::RemoveAll(void) +{ + m_objectlist.Clear(); + m_currId = -1; + m_lastObjNode = NULL; +} + +// ---------------------------------------------------------------------------- +// GetLen - return the number of operations in the current op list +// ---------------------------------------------------------------------------- +int wxPseudoDC::GetLen(void) +{ + pdcObjectList::Node *pt = m_objectlist.GetFirst(); + int len=0; + while (pt) + { + len += pt->GetData()->GetLen(); + pt = pt->GetNext(); + } + return len; +} + +// ---------------------------------------------------------------------------- +// FindObjNode - find and return an object node by id. If node doesn't exist +// and create is true then create one and return it. Otherwise +// return NULL. +// ---------------------------------------------------------------------------- +pdcObjectList::Node *wxPseudoDC::FindObjNode(int id, bool create) +{ + // see if last operation was for same id + if (m_lastObjNode && m_lastObjNode->GetData()->GetId() == id) + return m_lastObjNode; + // if not then search for it + pdcObjectList::Node *pt = m_objectlist.GetFirst(); + while (pt) + { + if (pt->GetData()->GetId() == id) + { + + // cache this node for future operations + m_lastObjNode = pt; + return pt; + } + pt = pt->GetNext(); + } + // if create then create and return a new node + if (create) + { + // cache this node for future operations + m_lastObjNode = m_objectlist.Append(new pdcObject(id)); + return m_lastObjNode; + } + // otherwise just return NULL + return NULL; +} + +// ---------------------------------------------------------------------------- +// AddToList - Add a node to the list at the end (preserve draw order) +// ---------------------------------------------------------------------------- +void wxPseudoDC::AddToList(pdcOp *newOp) +{ + pdcObjectList::Node *pt = FindObjNode(m_currId, true); + pt->GetData()->AddOp(newOp); +} + +// ---------------------------------------------------------------------------- +// ClearID - remove all the operations associated with a single ID +// ---------------------------------------------------------------------------- +void wxPseudoDC::ClearId(int id) +{ + pdcObjectList::Node *pt = FindObjNode(id); + if (pt) pt->GetData()->Clear(); +} + +// ---------------------------------------------------------------------------- +// RemoveID - Remove the object node (and all operations) associated with an id +// ---------------------------------------------------------------------------- +void wxPseudoDC::RemoveId(int id) +{ + pdcObjectList::Node *pt = FindObjNode(id); + if (pt) + { + if (m_lastObjNode == pt) + m_lastObjNode = NULL; + m_objectlist.DeleteNode(pt); + } +} + +// ---------------------------------------------------------------------------- +// SetIdBounds - Set the bounding rect for a given id +// ---------------------------------------------------------------------------- +void wxPseudoDC::SetIdBounds(int id, wxRect& rect) +{ + pdcObjectList::Node *pt = FindObjNode(id, true); + pt->GetData()->SetBounds(rect); +} + +// ---------------------------------------------------------------------------- +// GetIdBounds - Get the bounding rect for a given id +// ---------------------------------------------------------------------------- +void wxPseudoDC::GetIdBounds(int id, wxRect& rect) +{ + pdcObjectList::Node *pt = FindObjNode(id); + if (pt && pt->GetData()->IsBounded()) + rect = pt->GetData()->GetBounds(); + else + rect.x = rect.y = rect.width = rect.height = 0; +} + +// ---------------------------------------------------------------------------- +// TranslateId - Translate all the operations of a single id +// ---------------------------------------------------------------------------- +void wxPseudoDC::TranslateId(int id, wxCoord dx, wxCoord dy) +{ + pdcObjectList::Node *pt = FindObjNode(id); + if (pt) pt->GetData()->Translate(dx,dy); +} + +// ---------------------------------------------------------------------------- +// DrawIdToDC - Draw a specific id to the dc passed in +// ---------------------------------------------------------------------------- +void wxPseudoDC::DrawIdToDC(int id, wxDC *dc) +{ + pdcObjectList::Node *pt = FindObjNode(id); + if (pt) pt->GetData()->DrawToDC(dc); +} + +// ---------------------------------------------------------------------------- +// SetIdGreyedOut - Set the greyedout member of id +// ---------------------------------------------------------------------------- +void wxPseudoDC::SetIdGreyedOut(int id, bool greyout) +{ + pdcObjectList::Node *pt = FindObjNode(id); + if (pt) pt->GetData()->SetGreyedOut(greyout); +} + +// ---------------------------------------------------------------------------- +// GetIdGreyedOut - Get the greyedout member of id +// ---------------------------------------------------------------------------- +bool wxPseudoDC::GetIdGreyedOut(int id) +{ + pdcObjectList::Node *pt = FindObjNode(id); + if (pt) return pt->GetData()->GetGreyedOut(); + else return false; +} + +// ---------------------------------------------------------------------------- +// FindObjectsByBBox - Return a list of all the ids whose bounding boxes +// contain (x,y) +// ---------------------------------------------------------------------------- +PyObject *wxPseudoDC::FindObjectsByBBox(wxCoord x, wxCoord y) +{ + //wxPyBlock_t blocked = wxPyBeginBlockThreads(); + pdcObjectList::Node *pt = m_objectlist.GetFirst(); + pdcObject *obj; + PyObject* pyList = NULL; + pyList = PyList_New(0); + wxRect r; + while (pt) + { + obj = pt->GetData(); + r = obj->GetBounds(); + if (obj->IsBounded() && r.Contains(x,y)) + { + PyObject* pyObj = PyInt_FromLong((long)obj->GetId()); + PyList_Insert(pyList, 0, pyObj); + Py_DECREF(pyObj); + } + pt = pt->GetNext(); + } + //wxPyEndBlockThreads(blocked); + return pyList; +} + +// ---------------------------------------------------------------------------- +// FindObjects - Return a list of all the ids that draw to (x,y) +// ---------------------------------------------------------------------------- +PyObject *wxPseudoDC::FindObjects(wxCoord x, wxCoord y, + wxCoord radius, const wxColor& bg) +{ + //wxPyBlock_t blocked = wxPyBeginBlockThreads(); + pdcObjectList::Node *pt = m_objectlist.GetFirst(); + pdcObject *obj; + PyObject* pyList = NULL; + pyList = PyList_New(0); + wxBrush bgbrush(bg); + wxPen bgpen(bg); + // special case radius = 0 + if (radius == 0) + { + wxBitmap bmp(4,4,24); + wxMemoryDC memdc; + wxColor pix; + wxRect viewrect(x-2,y-2,4,4); + // setup the memdc for rendering + memdc.SelectObject(bmp); + memdc.SetBackground(bgbrush); + memdc.Clear(); + memdc.SetDeviceOrigin(2-x,2-y); + while (pt) + { + obj = pt->GetData(); + if (obj->IsBounded() && obj->GetBounds().Contains(x,y)) + { + // start clean + memdc.SetBrush(bgbrush); + memdc.SetPen(bgpen); + memdc.DrawRectangle(viewrect); + // draw the object + obj->DrawToDC(&memdc); + memdc.GetPixel(x,y,&pix); + // clear and update rgn2 + if (pix != bg) + { + PyObject* pyObj = PyInt_FromLong((long)obj->GetId()); + PyList_Insert(pyList, 0, pyObj); + Py_DECREF(pyObj); + } + } + pt = pt->GetNext(); + } + memdc.SelectObject(wxNullBitmap); + } + else + { + wxRect viewrect(x-radius,y-radius,2*radius,2*radius); + wxBitmap maskbmp(2*radius,2*radius,24); + wxMemoryDC maskdc; + // create bitmap with circle for masking + maskdc.SelectObject(maskbmp); + maskdc.SetBackground(*wxBLACK_BRUSH); + maskdc.Clear(); + maskdc.SetBrush(*wxWHITE_BRUSH); + maskdc.SetPen(*wxWHITE_PEN); + maskdc.DrawCircle(radius,radius,radius); + // now setup a memdc for rendering our object + wxBitmap bmp(2*radius,2*radius,24); + wxMemoryDC memdc; + memdc.SelectObject(bmp); + // set the origin so (x,y) is in the bmp center + memdc.SetDeviceOrigin(radius-x,radius-y); + // a region will be used to see if the result is empty + wxRegion rgn2; + while (pt) + { + obj = pt->GetData(); + if (obj->IsBounded() && viewrect.Intersects(obj->GetBounds())) + { + // start clean + //memdc.Clear(); + memdc.SetBrush(bgbrush); + memdc.SetPen(bgpen); + memdc.DrawRectangle(viewrect); + // draw the object + obj->DrawToDC(&memdc); + // remove background color + memdc.SetLogicalFunction(wxXOR); + memdc.SetBrush(bgbrush); + memdc.SetPen(bgpen); + memdc.DrawRectangle(viewrect); + memdc.SetLogicalFunction(wxCOPY); +#ifdef __WXMAC__ + // wxAND is not supported on wxMac, but it doesn't seem to + // hurt anything to use wxCOPY instead... + memdc.Blit(x-radius,y-radius,2*radius,2*radius,&maskdc,0,0,wxCOPY); +#else + // AND with circle bitmap + memdc.Blit(x-radius,y-radius,2*radius,2*radius,&maskdc,0,0,wxAND); +#endif + // clear and update rgn2 + memdc.SelectObject(wxNullBitmap); + rgn2.Clear(); + rgn2.Union(bmp, *wxBLACK); + //rgn2.Intersect(rgn); + memdc.SelectObject(bmp); + if (!rgn2.IsEmpty()) + { + PyObject* pyObj = PyInt_FromLong((long)obj->GetId()); + PyList_Insert(pyList, 0, pyObj); + Py_DECREF(pyObj); + } + } + pt = pt->GetNext(); + } + maskdc.SelectObject(wxNullBitmap); + memdc.SelectObject(wxNullBitmap); + } + //wxPyEndBlockThreads(blocked); + return pyList; +} + +// ---------------------------------------------------------------------------- +// DrawToDCClipped - play back the op list to the DC but clip any objects +// known to be not in rect. This is a coarse level of +// clipping to speed things up when lots of objects are off +// screen and doesn't affect the dc level clipping +// ---------------------------------------------------------------------------- +void wxPseudoDC::DrawToDCClipped(wxDC *dc, const wxRect& rect) +{ + pdcObjectList::Node *pt = m_objectlist.GetFirst(); + pdcObject *obj; + while (pt) + { + obj = pt->GetData(); + if (!obj->IsBounded() || rect.Intersects(obj->GetBounds())) + obj->DrawToDC(dc); + pt = pt->GetNext(); + } +} +void wxPseudoDC::DrawToDCClippedRgn(wxDC *dc, const wxRegion& region) +{ + pdcObjectList::Node *pt = m_objectlist.GetFirst(); + pdcObject *obj; + while (pt) + { + obj = pt->GetData(); + if (!obj->IsBounded() || + (region.Contains(obj->GetBounds()) != wxOutRegion)) + obj->DrawToDC(dc); + pt = pt->GetNext(); + } +} + +// ---------------------------------------------------------------------------- +// DrawToDC - play back the op list to the DC +// ---------------------------------------------------------------------------- +void wxPseudoDC::DrawToDC(wxDC *dc) +{ + pdcObjectList::Node *pt = m_objectlist.GetFirst(); + while (pt) + { + pt->GetData()->DrawToDC(dc); + pt = pt->GetNext(); + } +} Modified: trunk/grassaddons/gui/gui_modules/digit.py =================================================================== --- trunk/grassaddons/gui/gui_modules/digit.py 2007-08-17 08:43:28 UTC (rev 1031) +++ trunk/grassaddons/gui/gui_modules/digit.py 2007-08-18 14:40:53 UTC (rev 1032) @@ -55,6 +55,9 @@ "This only TEMPORARY solution (display driver based on SWIG-Python interface is EXTREMELY SLOW!\n" \ "Will be replaced by C/C++ display driver." else: + driverPath = os.path.join( os.getenv("GISBASE"), "etc","wx", "display_driver") + sys.path.append(driverPath) + from grass6_wxdriver import DisplayDriver try: driverPath = os.path.join( os.getenv("GISBASE"), "etc","wx", "display_driver") sys.path.append(driverPath) @@ -435,6 +438,7 @@ AbstractDisplayDriver.__init__(self, parent, mapwindow) # initialize wx display driver + self.display = DisplayDriver() try: self.display = DisplayDriver() except: @@ -450,26 +454,35 @@ else: self.display.CloseMap() - def DrawMap(self): - """Display content of the map in PseudoDC + def DrawMap(self, pdc): + """Draw vector map layer content Return wx.Image """ - bmp = wx.EmptyBitmap(self.mapwindow.Map.width, self.mapwindow.Map.height) - dc = wx.MemoryDC( bmp) - dc.Clear() - dc.SetBackgroundMode(wx.TRANSPARENT) - - nlines = self.display.DrawMap(dc) + + nlines = self.display.DrawMap(pdc) Debug.msg(3, "CDisplayDriver.DrawMap(): nlines=%d" % nlines) - return bmp.ConvertToImage() + return nlines + def SelectLinesByBox(self, rect, onlyType=None): + """Select vector features by given bounding box. + rect = ((x1, y1), (x2, y2)) + Number of selected features can be decreased by 'onlyType' + ('None' for no types) + """ + + nselected = self.display.SelectLinesByBox() + Debug.msg(4, "CDisplayDriver.SelectLinesByBox(): selected=%d" % \ + nselected) + def SetRegion(self, reg): """Set geographical region Needed for 'cell2pixel' conversion""" + Debug.msg(3, "CDisplayDriver.SetRegion(): %s" % reg) + self.display.SetRegion(reg['n'], reg['s'], reg['e'], Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py =================================================================== --- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-08-17 08:43:28 UTC (rev 1031) +++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-08-18 14:40:53 UTC (rev 1032) @@ -213,6 +213,9 @@ # create a PseudoDC for map decorations like scales and legends self.pdc = wx.PseudoDC() + # used for digitization tool + self.pdcVector = None + # will store an off screen empty bitmap for saving to file self._Buffer = '' @@ -365,9 +368,7 @@ def OnPaint(self, event): """ - Draw psuedo DC to buffered paint DC - - Additionaly draw also vector map which is edited + Draw PseudoDC to buffered paint DC """ dc = wx.BufferedPaintDC(self, self._Buffer) @@ -382,12 +383,15 @@ # create a clipping rect from our position and size # and update region - rgn = self.GetUpdateRegion() - r = rgn.GetBox() - dc.SetClippingRect(r) + rgn = self.GetUpdateRegion().GetBox() + dc.SetClippingRect(rgn) # draw to the dc using the calculated clipping rect - self.pdc.DrawToDCClipped(dc,r) + self.pdc.DrawToDCClipped(dc, rgn) + # draw vector map layer + if self.pdcVector: + self.pdcVector.DrawToDCClipped(dc, rgn) + def OnSize(self, event): """ Scale map image so that it is @@ -461,13 +465,14 @@ else: img = None - self.imagedict[img] = 99 # set image PeudoDC ID + self.imagedict[img] = 99 # set image PseudoDC ID + return img def UpdateMap(self, render=True, redraw=True, removeId=[]): """ - Updates the canvas anytime there is a change to the underlying images + Updates the canvas anytime there is a change to the underlaying images or to the geometry of the canvas. """ @@ -478,11 +483,11 @@ # render new map images self.Map.width, self.Map.height = self.GetClientSize() self.mapfile = self.Map.Render(force=True) - self.img = self.GetImage() + self.img = self.GetImage() # id=99 self.resize = False if not self.img or redraw == False: - return + return False # paint images to PseudoDC if len(removeId) > 0: @@ -496,20 +501,22 @@ try: id = self.imagedict[self.img] except: - return + return False - # render vector map layer which is edited + # draw background map image to PseudoDC + self.Draw(self.pdc, self.img, drawid=id) + + # render vector map layer digitToolbar = self.parent.digittoolbar if digitToolbar and \ digitToolbar.layerSelectedID != None: # set region self.parent.digit.driver.SetRegion(self.Map.region) # draw map - self.imgVectorMap = self.parent.digit.driver.DrawMap() + self.pdcVector = wx.PseudoDC() + self.parent.digit.driver.DrawMap(self.pdcVector) - self.Draw(self.pdc, self.img, drawid=id) # draw map image background - if self.imgVectorMap: - self.Draw(self.pdc, self.imgVectorMap, drawid=100) # draw vector map image + # overlay self.ovldict = self.GetOverlay() # list of decoration overlay images if self.ovldict != {}: # draw scale and legend overlays for id in self.ovldict: @@ -533,6 +540,8 @@ (self.Map.region["w"], self.Map.region["e"], self.Map.region["n"], self.Map.region["s"]), 0) + return True + def EraseMap(self): """ Erase the map display @@ -894,10 +903,14 @@ onlyType="line") else: # moveLine | deleteLine - self.moveIds = self.parent.digit.driver.SelectLinesByBox((self.Pixel2Cell(self.mouse['begin'][0], - self.mouse['begin'][1]), - self.Pixel2Cell(self.mouse['end'][0], - self.mouse['end'][1]))) + x1, y1 = self.Pixel2Cell(self.mouse['begin'][0], self.mouse['begin'][1]) + x2, y2 = self.Pixel2Cell(self.mouse['end'][0], self.mouse['end'][1]) + # PyDisplayDriver + # self.moveIds = self.parent.digit.driver.SelectLinesByBox((x1,y1), + # x2, y2))) + nselected = self.parent.digit.driver.SelectLinesByBox(x1, y1, x2, y2) + Debug.msg (3, "") + if len(self.moveIds) > 0: self.UpdateMap(render=False) if digitToolbar.action in ["moveLine", "moveVertex"]: Modified: trunk/grassaddons/gui/gui_modules/render.py =================================================================== --- trunk/grassaddons/gui/gui_modules/render.py 2007-08-17 08:43:28 UTC (rev 1031) +++ trunk/grassaddons/gui/gui_modules/render.py 2007-08-18 14:40:53 UTC (rev 1032) @@ -27,13 +27,13 @@ This class serves for storing map layers to be displayed Common layer attributes: - type - layer type (raster, vector, overlay, command) + type - layer type (raster, vector, overlay, command, etc.) name - layer name, e.g. map name ('elevation@PERMANENT') - cmd - GRASS command string + cmdlist - GRASS command (e.g. 'd.rast map=elevation@PERMANENT') active - layer is active, will be rendered only if True hidden - layer is hidden, won't be listed in GIS Manager if True - opacity - layer opacity [0-1] + opacity - layer opacity <0;1> mapfile - file name of rendered layer maskfile - mask name of rendered layer @@ -48,8 +48,10 @@ self.hidden = hidden self.opacity = opacity - Debug.msg (3, "MapLayer.__init__(): type=%s, cmd=%s, name=%s, active=%d, opacity=%d, hidden=%d" % - (self.type, self.GetCmd(string=True), self.name, self.active, self.opacity, self.hidden)) + Debug.msg (3, "MapLayer.__init__(): type=%s, cmd='%s', name=%s, " \ + "active=%d, opacity=%d, hidden=%d" % \ + (self.type, self.GetCmd(string=True), self.name, self.active, + self.opacity, self.hidden)) gtemp = utils.GetTempfile() self.maskfile = gtemp + ".pgm" @@ -59,7 +61,7 @@ self.mapfile = gtemp + ".ppm" def __del__(self): - Debug.msg (3, "MapLayer.__del__(): layer=%s, cmd=%s" % + Debug.msg (3, "MapLayer.__del__(): layer=%s, cmd='%s'" % (self.name, self.GetCmd(string=True))) def __renderLayer(self): @@ -747,7 +749,7 @@ """ layer.active = active - Debug.msg (3, "Map.ChangeLayerActive(): layer=%s, active=%d" % \ + Debug.msg (3, "Map.ChangeLayerActive(): name='%s' -> active=%d" % \ (layer.name, layer.active)) def ChangeLayerName (self, layer, name): Modified: trunk/grassaddons/gui/gui_modules/toolbars.py =================================================================== --- trunk/grassaddons/gui/gui_modules/toolbars.py 2007-08-17 08:43:28 UTC (rev 1031) +++ trunk/grassaddons/gui/gui_modules/toolbars.py 2007-08-18 14:40:53 UTC (rev 1032) @@ -1,7 +1,6 @@ """ MODULE: toolbar - CLASSES: * AbstractToolbar * MapToolbar @@ -162,19 +161,20 @@ def __init__(self, parent, map): self.mapcontent = map # Map class instance - self.parent = parent # + self.parent = parent # MapFrame # selected map to digitize - self.layerSelectedID = None + self.layerSelectedID = None self.layers = [] - # action (digitize new point, line, etc. + + # default action (digitize new point, line, etc.) self.action = "addLine" self.type = "point" self.addString = "" self.comboid = None - # create toolbar + # create toolbars (two rows) self.toolbar = [] numOfRows = 2 for row in range(0, numOfRows): @@ -256,29 +256,29 @@ self.OnDisplayAttr)) def OnAddPoint(self, event): - """Add point to the vector map layer""" - Debug.msg (4, "DigitToolbar.OnAddPoint()") + """Add point to the vector map Laier""" + Debug.msg (2, "DigitToolbar.OnAddPoint()") self.action = "addLine" self.type = "point" self.parent.MapWindow.mouse['box'] = 'point' def OnAddLine(self, event): """Add line to the vector map layer""" - Debug.msg (4, "DigitToolbar.OnAddLine()") + Debug.msg (2, "DigitToolbar.OnAddLine()") self.action = "addLine" self.type = "line" self.parent.MapWindow.mouse['box'] = 'line' def OnAddBoundary(self, event): """Add boundary to the vector map layer""" - Debug.msg (4, "DigitToolbar.OnAddBoundary()") + Debug.msg (2, "DigitToolbar.OnAddBoundary()") self.action = "addLine" self.type = "boundary" self.parent.MapWindow.mouse['box'] = 'line' def OnAddCentroid(self, event): """Add centroid to the vector map layer""" - Debug.msg (4, "DigitToolbar.OnAddCentroid()") + Debug.msg (2, "DigitToolbar.OnAddCentroid()") self.action = "addLine" self.type = "centroid" self.parent.MapWindow.mouse['box'] = 'point' @@ -297,24 +297,24 @@ self.parent.RemoveToolbar ("digit") def OnMoveVertex(self, event): - Debug.msg(4, "Digittoolbar.OnMoveVertex():") + Debug.msg(2, "Digittoolbar.OnMoveVertex():") self.action = "moveVertex" self.parent.MapWindow.mouse['box'] = 'point' def OnAddVertex(self, event): - Debug.msg(4, "Digittoolbar.OnAddVertex():") + Debug.msg(2, "Digittoolbar.OnAddVertex():") self.action = "addVertex" self.parent.MapWindow.mouse['box'] = 'point' def OnRemoveVertex(self, event): - Debug.msg(4, "Digittoolbar.OnRemoveVertex():") + Debug.msg(2, "Digittoolbar.OnRemoveVertex():") self.action = "removeVertex" self.parent.MapWindow.mouse['box'] = 'point' def OnSplitLine(self, event): - Debug.msg(4, "Digittoolbar.OnSplitLine():") + Debug.msg(2, "Digittoolbar.OnSplitLine():") self.action = "splitLine" self.parent.MapWindow.mouse['box'] = 'point' @@ -322,12 +322,12 @@ pass def OnMoveLine(self, event): - Debug.msg(4, "Digittoolbar.OnMoveLine():") + Debug.msg(2, "Digittoolbar.OnMoveLine():") self.action = "moveLine" self.parent.MapWindow.mouse['box'] = 'box' def OnDeleteLine(self, event): - Debug.msg(4, "Digittoolbar.OnDeleteLine():") + Debug.msg(2, "Digittoolbar.OnDeleteLine():") self.action = "deleteLine" self.parent.MapWindow.mouse['box'] = 'box' @@ -336,7 +336,7 @@ def OnDisplayAttr(self, event): self.action="displayAttributes" - Debug.msg(4, "Digittoolbar.OnDisplayAttr():") + Debug.msg(2, "Digittoolbar.OnDisplayAttr():") def OnCopyCats(self, event): pass @@ -363,7 +363,7 @@ def StartEditing (self, layerSelected): """ - Mark selected map layer as enabled for digitization + Start editing of selected vector map layer. Return True on success or False if layer cannot be edited """ @@ -386,15 +386,19 @@ # deactive layer self.mapcontent.ChangeLayerActive(mapLayer, False) - # draw map content - #self.driver.DrawMap() + # change cursor + self.parent.MapWindow.SetCursor(self.parent.cursors["cross"]) + + # create pseudoDC for drawing the map + self.parent.pdcVector = wx.PseudoDC() return True def StopEditing (self, layerSelected): """ - Unmark currently enabled map layer. + Stop editing of selected vector map layer. """ + if self.layers[self.layerSelectedID] == layerSelected: self.layerSelectedID = None Debug.msg (4, "DigitToolbar.StopEditing(): layer=%s" % \ @@ -406,6 +410,12 @@ self.parent.digit.SetMapName(None) + # change cursor + self.parent.MapWindow.SetCursor(self.parent.cursors["default"]) + + # destroy pseudodc + del self.parent.pdcVector + return True return False @@ -418,6 +428,9 @@ Optionaly also update toolbar """ + Debug.msg (4, "DigitToolbar.UpdateListOfLayers(): updateTool=%d" % \ + updateTool) + layerNameSelected = None if self.layerSelectedID != None: # name of currently selected layer layerNameSelected = self.layers[self.layerSelectedID].name @@ -438,15 +451,15 @@ # ugly ... if self.comboid: self.toolbar[0].DeleteToolByPos(0) - #self.combo.Destroy() self.combo = wx.ComboBox(self.toolbar[0], id=wx.ID_ANY, value=value, choices=layerNameList, size=(150, -1), style=wx.CB_READONLY) + self.comboid = self.toolbar[0].InsertControl(0, self.combo) + # additional bindings self.parent.Bind(wx.EVT_COMBOBOX, self.OnSelectMap, self.comboid) - self.comboid = self.toolbar[0].InsertControl(0, self.combo) self.toolbar[0].Realize() return layerNameList Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py =================================================================== --- trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-08-17 08:43:28 UTC (rev 1031) +++ trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-08-18 14:40:53 UTC (rev 1032) @@ -366,17 +366,20 @@ self.EditLabel(self.layer_selected) def AddLayer(self, ltype): - """Add layer, create MapLayer instance""" + """Add new item to the layer tree, create corresponding MapLayer instance. + Launch property dialog if needed (raster, vector, etc.)""" self.first = True checked = False params = {} # no initial options parameters + # deselect active item if self.layer_selected: self.SelectItem(self.layer_selected, select=False) Debug.msg (3, "LayerTree().AddLayer(): ltype=%s" % (ltype)) + if ltype == 'command': - # generic command layer + # generic command item ctrl = wx.TextCtrl(self, id=wx.ID_ANY, value='', pos=wx.DefaultPosition, size=(250,25), style=wx.TE_MULTILINE|wx.TE_WORDWRAP) @@ -384,16 +387,16 @@ ctrl.Bind(wx.EVT_TEXT_ENTER, self.OnCmdChanged) ctrl.Bind(wx.EVT_TEXT, self.OnCmdChanged) elif ltype == 'group': + # group item ctrl = None grouptext = 'Layer group:' + str(self.groupnode) self.groupnode += 1 checked = True else: - # all other layers + # all other items (raster, vector, ...) ctrl = wx.SpinCtrl(self, id=wx.ID_ANY, value="", pos=(30, 50), - style=wx.SP_ARROW_KEYS) - ctrl.SetRange(1,100) - ctrl.SetValue(100) + style=wx.SP_ARROW_KEYS, initial=100, min=0, max=100) + self.Bind(wx.EVT_SPINCTRL, self.OnOpacity, ctrl) # add layer to the layer tree @@ -488,37 +491,55 @@ ltype) if ltype == 'raster': - menuform.GUI().ParseCommand('d.rast', completed=(self.getOptData,layer,params), parentframe=self) + menuform.GUI().ParseCommand('d.rast', completed=(self.getOptData,layer,params), + parentframe=self) elif ltype == 'rgb': - menuform.GUI().ParseCommand('d.rgb', completed=(self.getOptData,layer,params), parentframe=self) + menuform.GUI().ParseCommand('d.rgb', completed=(self.getOptData,layer,params), + parentframe=self) elif ltype == 'his': - menuform.GUI().ParseCommand('d.his', completed=(self.getOptData,layer,params), parentframe=self) + menuform.GUI().ParseCommand('d.his', completed=(self.getOptData,layer,params), + parentframe=self) elif ltype == 'shaded': - menuform.GUI().ParseCommand('d.shadedmap', completed=(self.getOptData,layer,params), parentframe=self) + menuform.GUI().ParseCommand('d.shadedmap', completed=(self.getOptData,layer,params), + parentframe=self) elif ltype == 'rastarrow': - menuform.GUI().ParseCommand('d.rast.arrow', completed=(self.getOptData,layer,params), parentframe=self) + menuform.GUI().ParseCommand('d.rast.arrow', completed=(self.getOptData,layer,params), + parentframe=self) elif ltype == 'rastnum': - menuform.GUI().ParseCommand('d.rast.num', completed=(self.getOptData,layer,params), parentframe=self) + menuform.GUI().ParseCommand('d.rast.num', completed=(self.getOptData,layer,params), + parentframe=self) elif ltype == 'vector': - menuform.GUI().ParseCommand('d.vect', completed=(self.getOptData,layer,params), parentframe=self) + menuform.GUI().ParseCommand('d.vect', completed=(self.getOptData,layer,params), + parentframe=self) elif ltype == 'thememap': - menuform.GUI().ParseCommand('d.vect.thematic', completed=(self.getOptData,layer,params), parentframe=self) + menuform.GUI().ParseCommand('d.vect.thematic', + completed=(self.getOptData,layer,params), + parentframe=self) elif ltype == 'themechart': - menuform.GUI().ParseCommand('d.vect.chart', completed=(self.getOptData,layer,params), parentframe=self) + menuform.GUI().ParseCommand('d.vect.chart', + completed=(self.getOptData,layer,params), + parentframe=self) elif ltype == 'grid': - menuform.GUI().ParseCommand('d.grid', completed=(self.getOptData,layer,params), parentframe=self) + menuform.GUI().ParseCommand('d.grid', completed=(self.getOptData,layer,params), + parentframe=self) elif ltype == 'geodesic': - menuform.GUI().ParseCommand('d.geodesic', completed=(self.getOptData,layer,params), parentframe=self) + menuform.GUI().ParseCommand('d.geodesic', completed=(self.getOptData,layer,params), + parentframe=self) elif ltype == 'rhumb': - menuform.GUI().ParseCommand('d.rhumbline', completed=(self.getOptData,layer,params), parentframe=self) + menuform.GUI().ParseCommand('d.rhumbline', completed=(self.getOptData,layer,params), + parentframe=self) elif ltype == 'labels': - menuform.GUI().ParseCommand('d.labels', completed=(self.getOptData,layer,params), parentframe=self) + menuform.GUI().ParseCommand('d.labels', completed=(self.getOptData,layer,params), + parentframe=self) elif ltype == 'cmdlayer': pass elif ltype == 'group': pass def OnActivateLayer(self, event): + """Click on the layer item. + Launch property dialog, or expand/collapse group of items, etc.""" + layer = event.GetItem() self.layer_selected = layer @@ -531,7 +552,7 @@ self.Expand(layer) def OnDeleteLayer(self, event): - """Remove selected layer for the layer tree""" + """Remove selected layer item from the layer tree""" item = event.GetItem() @@ -554,6 +575,7 @@ self.layers.pop(item) def OnLayerChecked(self, event): + """Enable/disable given layer item""" item = event.GetItem() checked = item.IsChecked() layer = self.layers[item] @@ -677,8 +699,7 @@ newctrl = None else: newctrl = wx.SpinCtrl(self, id=wx.ID_ANY, value="", pos=(30, 50), - style=wx.SP_ARROW_KEYS) - newctrl.SetRange(1,100) + style=wx.SP_ARROW_KEYS, min=0, max=100) try: newctrl.SetValue(oldLayer.maplayer.GetOpacity()) except: From barton at grass.itc.it Sat Aug 18 23:31:11 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Sat Aug 18 23:31:12 2007 Subject: [grass-addons] r1033 - trunk/grassaddons/gui/gui_modules Message-ID: <200708182131.l7ILVBK4009060@grass.itc.it> Author: barton Date: 2007-08-18 23:31:03 +0200 (Sat, 18 Aug 2007) New Revision: 1033 Modified: trunk/grassaddons/gui/gui_modules/select.py Log: Added new dialog class to select.py. This lets the GIS element selection control be displayed in a dialog and launched from a button or other control. Useful for embedding in handler that sets location and mapset prior to calling selector (georectifying module) and so that map selection can be called from a toolbar button. Modified: trunk/grassaddons/gui/gui_modules/select.py =================================================================== --- trunk/grassaddons/gui/gui_modules/select.py 2007-08-18 14:40:53 UTC (rev 1032) +++ trunk/grassaddons/gui/gui_modules/select.py 2007-08-18 21:31:03 UTC (rev 1033) @@ -26,6 +26,45 @@ import cmd +class SelectDialog(wx.Dialog): + def __init__(self, parent, id=wx.ID_ANY, title='Select GIS element', + pos=wx.DefaultPosition, size=(-1,-1), type='cell', + style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER): + """ + A dialog box for the GIS element selector control so that it can be launched f + rom a button or other control. + """ + + wx.Dialog.__init__(self, parent, id, title, pos, size, style) + + self.selection = '' + + sizer = wx.BoxSizer(wx.VERTICAL) + + box = wx.BoxSizer(wx.HORIZONTAL) + self.selection = Select(self, id=wx.ID_ANY, size=(300,-1),type=type) + box.Add(self.selection, 0, wx.ALIGN_CENTER|wx.ALL, 5) + sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) + + line = wx.StaticLine(self, -1, size=(20,-1), style=wx.LI_HORIZONTAL) + sizer.Add(line, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP, 5) + + btnsizer = wx.StdDialogButtonSizer() + + btn = wx.Button(self, wx.ID_OK) + btn.SetDefault() + btnsizer.AddButton(btn) + + btn = wx.Button(self, wx.ID_CANCEL) + btnsizer.AddButton(btn) + btnsizer.Realize() + + sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) + + self.SetSizer(sizer) + sizer.Fit(self) + + class Select(wx.combo.ComboCtrl): def __init__(self, parent, id, size, type): """ From barton at grass.itc.it Sat Aug 18 23:33:10 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Sat Aug 18 23:33:12 2007 Subject: [grass-addons] r1034 - trunk/grassaddons/gui/gui_modules Message-ID: <200708182133.l7ILXAr5009114@grass.itc.it> Author: barton Date: 2007-08-18 23:33:02 +0200 (Sat, 18 Aug 2007) New Revision: 1034 Modified: trunk/grassaddons/gui/gui_modules/toolbars.py Log: Added toolbar for georectification display (subset of main display toolbar) Modified: trunk/grassaddons/gui/gui_modules/toolbars.py =================================================================== --- trunk/grassaddons/gui/gui_modules/toolbars.py 2007-08-18 21:31:03 UTC (rev 1033) +++ trunk/grassaddons/gui/gui_modules/toolbars.py 2007-08-18 21:33:02 UTC (rev 1034) @@ -154,6 +154,75 @@ if tool == "Digitize" and not self.mapdisplay.digittoolbar: self.mapdisplay.AddToolbar("digit") +class GRToolbar(AbstractToolbar): + """ + Georectify Display toolbar + """ + + def __init__(self, mapdisplay, map): + self.mapcontent = map + self.mapdisplay = mapdisplay + + self.toolbar = wx.ToolBar(parent=self.mapdisplay, id=wx.ID_ANY) + + # self.SetToolBar(self.toolbar) + tsize = (24, 24) + self.toolbar.SetToolBitmapSize(tsize) + + self.InitToolbar(self.mapdisplay, self.toolbar, self.ToolbarData()) + + # realize the toolbar + self.toolbar.Realize() + + def ToolbarData(self): + """Toolbar data""" + + self.displaymap = self.rendermap = self.erase = \ + self.pointer = self.query = self.pan = self.zoomin = self.zoomout = \ + self.zoomback = self.zoommenu = self.analyze = self.dec = self.savefile = self.printmap =None + + # tool, label, bitmap, kind, shortHelp, longHelp, handler + return ( + (self.displaymap, "displaymap", Icons["displaymap"].GetBitmap(), + wx.ITEM_NORMAL, Icons["displaymap"].GetLabel(), Icons["displaymap"].GetDesc(), + self.mapdisplay.ReDraw), + (self.rendermap, "rendermap", Icons["rendermap"].GetBitmap(), + wx.ITEM_NORMAL, Icons["rendermap"].GetLabel(), Icons["rendermap"].GetDesc(), + self.mapdisplay.ReRender), + (self.erase, "erase", Icons["erase"].GetBitmap(), + wx.ITEM_NORMAL, Icons["erase"].GetLabel(), Icons["erase"].GetDesc(), + self.mapdisplay.OnErase), + ("", "", "", "", "", "", ""), + (self.pointer, "pointer", Icons["pointer"].GetBitmap(), + wx.ITEM_RADIO, Icons["pointer"].GetLabel(), Icons["pointer"].GetDesc(), + self.mapdisplay.Pointer), + (self.pan, "pan", Icons["pan"].GetBitmap(), + wx.ITEM_RADIO, Icons["pan"].GetLabel(), Icons["pan"].GetDesc(), + self.mapdisplay.OnPan), + (self.zoomin, "zoom_in", Icons["zoom_in"].GetBitmap(), + wx.ITEM_RADIO, Icons["zoom_in"].GetLabel(), Icons["zoom_in"].GetDesc(), + self.mapdisplay.OnZoomIn), + (self.zoomout, "zoom_out", Icons["zoom_out"].GetBitmap(), + wx.ITEM_RADIO, Icons["zoom_out"].GetLabel(), Icons["zoom_out"].GetDesc(), + self.mapdisplay.OnZoomOut), + (self.zoomback, "zoom_back", Icons["zoom_back"].GetBitmap(), + wx.ITEM_NORMAL, Icons["zoom_back"].GetLabel(), Icons["zoom_back"].GetDesc(), + self.mapdisplay.OnZoomBack), + (self.zoommenu, "zoommenu", Icons["zoommenu"].GetBitmap(), + wx.ITEM_NORMAL, Icons["zoommenu"].GetLabel(), Icons["zoommenu"].GetDesc(), + self.mapdisplay.OnZoomMenu) + ) + + def OnSelect(self, event): + """ + Select / enable tool available in tools list + """ + tool = event.GetString() + + if tool == "Digitize" and not self.mapdisplay.digittoolbar: + self.mapdisplay.AddToolbar("digit") + + class DigitToolbar(AbstractToolbar): """ Toolbar for digitization @@ -268,7 +337,7 @@ self.action = "addLine" self.type = "line" self.parent.MapWindow.mouse['box'] = 'line' - + def OnAddBoundary(self, event): """Add boundary to the vector map layer""" Debug.msg (2, "DigitToolbar.OnAddBoundary()") @@ -292,7 +361,7 @@ self.StopEditing(self.layers[self.layerSelectedID]) except: pass - + # disable the toolbar self.parent.RemoveToolbar ("digit") @@ -317,7 +386,7 @@ Debug.msg(2, "Digittoolbar.OnSplitLine():") self.action = "splitLine" self.parent.MapWindow.mouse['box'] = 'point' - + def OnEditLine(self, event): pass @@ -325,7 +394,7 @@ Debug.msg(2, "Digittoolbar.OnMoveLine():") self.action = "moveLine" self.parent.MapWindow.mouse['box'] = 'box' - + def OnDeleteLine(self, event): Debug.msg(2, "Digittoolbar.OnDeleteLine():") self.action = "deleteLine" @@ -345,7 +414,7 @@ """Show settings dialog""" DigitSettingsDialog(parent=self.parent, title=_("Digitization settings"), style=wx.DEFAULT_DIALOG_STYLE).Show() - + def OnSelectMap (self, event): """ Select vector map layer for editing @@ -383,7 +452,7 @@ self.parent.digit.SetMapName(mapLayer.name) - # deactive layer + # deactive layer self.mapcontent.ChangeLayerActive(mapLayer, False) # change cursor @@ -391,7 +460,7 @@ # create pseudoDC for drawing the map self.parent.pdcVector = wx.PseudoDC() - + return True def StopEditing (self, layerSelected): @@ -404,12 +473,12 @@ Debug.msg (4, "DigitToolbar.StopEditing(): layer=%s" % \ (layerSelected.name)) self.combo.SetValue ('Select vector map') - + # re-active layer self.mapcontent.ChangeLayerActive(layerSelected, True) self.parent.digit.SetMapName(None) - + # change cursor self.parent.MapWindow.SetCursor(self.parent.cursors["default"]) @@ -419,7 +488,7 @@ return True return False - + def UpdateListOfLayers (self, updateTool=False): """ Update list of available vector map layers. From barton at grass.itc.it Sat Aug 18 23:41:20 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Sat Aug 18 23:41:22 2007 Subject: [grass-addons] r1035 - trunk/grassaddons/gui/gui_modules Message-ID: <200708182141.l7ILfKW2009134@grass.itc.it> Author: barton Date: 2007-08-18 23:41:11 +0200 (Sat, 18 Aug 2007) New Revision: 1035 Added: trunk/grassaddons/gui/gui_modules/georect.py Log: New georectify module. Only startup dialog working at present. Added: trunk/grassaddons/gui/gui_modules/georect.py =================================================================== --- trunk/grassaddons/gui/gui_modules/georect.py (rev 0) +++ trunk/grassaddons/gui/gui_modules/georect.py 2007-08-18 21:41:11 UTC (rev 1035) @@ -0,0 +1,225 @@ +""" +MODULE: georect.py + +CLASSES: + * Georectify + * GCP + * GRMap + +PURPOSE: Georectification module for GRASS GIS. Includes ground control + point management and interactive point and click GCP creation + +AUTHORS: The GRASS Development Team + Michael Barton + +COPYRIGHT: (C) 2006-2007 by the GRASS Development Team + This program is free software under the GNU General Public + License (>=v2). Read the file COPYING that comes with GRASS + for details. +""" + +# recheck once completed to see how many of these are still needed +import os +import sys +import time +import glob +import math +import tempfile +import shutil + +import wx +import wx.aui +import wx.lib.filebrowsebutton as filebrowse +from threading import Thread + +try: + import subprocess +except: + CompatPath = os.path.join( os.getenv("GISBASE"),"etc","wx") + sys.path.append(CompatPath) + from compat import subprocess + +gmpath = os.path.join( os.getenv("GISBASE"),"etc","wx","gui_modules" ) +sys.path.append(gmpath) +gmpath = os.path.join( os.getenv("GISBASE"),"etc","wx","icons" ) +sys.path.append(gmpath) + +import mapdisp +import render +import toolbars +import grassenv +import menuform +import select +import disp_print +import cmd +from debug import Debug as Debug +from icon import Icons as Icons + +import images +imagepath = images.__path__[0] +sys.path.append(imagepath) + +class Georectify(object): + """ + Init class for georectifying. Launches startup dialog + for setting georectifying parameters. + """ + def __init__(self,parent): + print 'in georectify start' + + self.parent = parent + + # launch the startup dialog + dlg = GeorectStart(self.parent) + + dlg.CenterOnScreen() + dlg.ShowModal() + + # If OK button pressed in decoration control dialog +# if dlg.ShowModal() == wx.ID_OK: +# # go on to GCP management +# pass + + + + + # starup dialog calls GCP which + + def StartUp(self): + pass + +class GeorectStart(wx.Dialog): + def __init__(self, parent, id=wx.ID_ANY, title=_('Set georectification parameters'), + pos=wx.DefaultPosition, size=(-1,-1), + style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER): + wx.Dialog.__init__(self, parent, id, title, pos, size, style) + + #set environmental variables + cmdlist = ['g.gisenv', 'get=GISDBASE'] + self.grassdatabase = cmd.Command(cmdlist).module_stdout.read().strip() + + cmdlist = ['g.gisenv', 'get=LOCATION_NAME'] + self.curr_location = cmd.Command(cmdlist).module_stdout.read().strip() + + cmdlist = ['g.gisenv', 'get=MAPSET'] + self.curr_mapset = cmd.Command(cmdlist).module_stdout.read().strip() + + self.StartDir = os.path.join(self.grassdatabase,self.curr_location) + self.xy_mapset = '' + self.xy_mapsetDir = '' + self.xy_group = '' + + #select display map (entry) + #start and cancel (buttons) + + sizer = wx.BoxSizer(wx.VERTICAL) + + box = wx.BoxSizer(wx.HORIZONTAL) + self.rb_maptype = wx.RadioBox(self, -1, "Map type to georectify", + wx.DefaultPosition, wx.DefaultSize, + ['raster','vector'], 2, wx.RA_SPECIFY_COLS) + box.Add(self.rb_maptype, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) + sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) + + box = wx.BoxSizer(wx.HORIZONTAL) + self.dbb_mapset = filebrowse.DirBrowseButton( + self, wx.ID_ANY, size=(450, -1), + labelText='Select mapset: ', + buttonText='Browse ...', + toolTip='Select mapset of maps to georeference', + dialogTitle='Mapsets', + startDirectory=self.StartDir, + changeCallback = self.On_dbb_mapset) + box.Add(self.dbb_mapset, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) + sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) + + box = wx.BoxSizer(wx.HORIZONTAL) + self.btn_mkgroup = wx.Button(self, wx.ID_ANY, "Make group ...") + box.Add(self.btn_mkgroup, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) + sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) + + box = wx.BoxSizer(wx.HORIZONTAL) + self.dbb_group = filebrowse.DirBrowseButton( + self, wx.ID_ANY, size=(450, -1), + labelText='Select group: ', + buttonText='Browse ...', + toolTip='Select group of maps to georeference', + dialogTitle='Groups', + startDirectory=os.path.join(self.xy_mapset,"group"), + changeCallback = self.On_dbb_group) + # Need to deactivate until xy_mapsetDir is set + box.Add(self.dbb_group, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) + sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) + + #Select the display map here...???? + #In TclTk, first switch to xy mapset; then select map + box = wx.BoxSizer(wx.HORIZONTAL) + self.btn_selmap = wx.Button(self, wx.ID_ANY, "Select map ...") + + box.Add(self.btn_selmap, 0, wx.ALIGN_CENTRE|wx.ALL, 5) + sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) + + line = wx.StaticLine(self, -1, size=(20,-1), style=wx.LI_HORIZONTAL) + sizer.Add(line, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP, 5) + + btnsizer = wx.StdDialogButtonSizer() + + btn = wx.Button(self, wx.ID_OK) + btn.SetDefault() + btnsizer.AddButton(btn) + + btn = wx.Button(self, wx.ID_CANCEL) + btnsizer.AddButton(btn) + btnsizer.Realize() + + sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) + + self.SetSizer(sizer) + sizer.Fit(self) + + self.Bind(wx.EVT_BUTTON, self.OnMkgroup, self.btn_mkgroup) + self.Bind(wx.EVT_BUTTON, self.OnSelectMap, self.btn_selmap) + + def On_dbb_mapset(self,event): + self.xy_mapsetDir = event.GetString() + # Disable group select if no mapset selected? + # need to split mapsetDir into xy_location and xy_mapset +# self.xy_mapsetDir = os.path.join(self.grassdatabase,self.location,self.mapset) + + print 'mapset =',self.mapset + + def On_dbb_group(self,event): + self.xy_group = event.GetString() + + print 'group =',self.xy_group + + def OnSelectMap(self,event): + dlg = select.SelectDialog(self,title="Select map",type='cell') + + if dlg.ShowModal() == wx.ID_OK: + self.xy_map = dlg.selection.GetValue() + + dlg.Destroy() + print 'selection =',self.xy_map + + + def OnMkgroup(self,event): + pass + + def SwitchToXY(self): + pass + + def SwitchBack(self): + pass + +class GCP(wx.Frame): + """ + Manages ground control points for georectifying. Calculates RMS statics. + Calls i.rectify or v.transform to georectify map. + """ + def __init__(self,parent,id=-1,title="Create & manage ground control points"): + wx.Frame.__init__(self, parent, id , title, size=(50,600)) + + # Button for adding new GCP + +# maybe we can use mapdisp classes to create the display??? \ No newline at end of file From barton at grass.itc.it Sat Aug 18 23:43:23 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Sat Aug 18 23:43:25 2007 Subject: [grass-addons] r1036 - trunk/grassaddons/gui/gui_modules Message-ID: <200708182143.l7ILhNLK009154@grass.itc.it> Author: barton Date: 2007-08-18 23:43:15 +0200 (Sat, 18 Aug 2007) New Revision: 1036 Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py Log: Added support for new georectify module. Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py =================================================================== --- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-08-18 21:41:11 UTC (rev 1035) +++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-08-18 21:43:15 UTC (rev 1036) @@ -1596,6 +1596,17 @@ BottomDockable(False).TopDockable(True). CloseButton(False).Layer(2)) + elif name == "georect": + self.grtoolbar = toolbars.GRToolbar(self, self.Map) + + self._mgr.AddPane(self.grtoolbar.toolbar, + wx.aui.AuiPaneInfo(). + Name("grtoolbar").Caption("Georectification Toolbar"). + ToolbarPane().Top(). + LeftDockable(False).RightDockable(False). + BottomDockable(False).TopDockable(True). + CloseButton(False).Layer(2)) + # change mouse to draw digitized line self.MapWindow.mouse['box'] = "point" self.MapWindow.zoomtype = 0 From barton at grass.itc.it Sat Aug 18 23:45:51 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Sat Aug 18 23:45:53 2007 Subject: [grass-addons] r1037 - trunk/grassaddons/gui/gui_modules Message-ID: <200708182145.l7ILjpb4009174@grass.itc.it> Author: barton Date: 2007-08-18 23:45:43 +0200 (Sat, 18 Aug 2007) New Revision: 1037 Modified: trunk/grassaddons/gui/gui_modules/menudata.py Log: Changing "Files" menu to "File" for better consistency with OS standards Modified: trunk/grassaddons/gui/gui_modules/menudata.py =================================================================== --- trunk/grassaddons/gui/gui_modules/menudata.py 2007-08-18 21:43:15 UTC (rev 1036) +++ trunk/grassaddons/gui/gui_modules/menudata.py 2007-08-18 21:45:43 UTC (rev 1037) @@ -24,7 +24,7 @@ Probably could be changed to XML or *.dtd file.''' def GetMenu(self): return [( - ("Files", ( + ("File", ( ("Import raster map", ( ("Multiple import formats using GDAL", "Import multiple formats using GDAL", "self.OnMenuCmd", "r.in.gdal"), ("","","", ""), From landa at grass.itc.it Mon Aug 20 12:44:37 2007 From: landa at grass.itc.it (landa@grass.itc.it) Date: Mon Aug 20 12:44:38 2007 Subject: [grass-addons] r1038 - trunk/grassaddons/gui/gui_modules Message-ID: <200708201044.l7KAib1G017348@grass.itc.it> Author: landa Date: 2007-08-20 12:44:37 +0200 (Mon, 20 Aug 2007) New Revision: 1038 Modified: trunk/grassaddons/gui/gui_modules/digit.py Log: cosmetics: redundant code removed Modified: trunk/grassaddons/gui/gui_modules/digit.py =================================================================== --- trunk/grassaddons/gui/gui_modules/digit.py 2007-08-18 21:45:43 UTC (rev 1037) +++ trunk/grassaddons/gui/gui_modules/digit.py 2007-08-20 10:44:37 UTC (rev 1038) @@ -55,9 +55,6 @@ "This only TEMPORARY solution (display driver based on SWIG-Python interface is EXTREMELY SLOW!\n" \ "Will be replaced by C/C++ display driver." else: - driverPath = os.path.join( os.getenv("GISBASE"), "etc","wx", "display_driver") - sys.path.append(driverPath) - from grass6_wxdriver import DisplayDriver try: driverPath = os.path.join( os.getenv("GISBASE"), "etc","wx", "display_driver") sys.path.append(driverPath) @@ -438,7 +435,6 @@ AbstractDisplayDriver.__init__(self, parent, mapwindow) # initialize wx display driver - self.display = DisplayDriver() try: self.display = DisplayDriver() except: From landa at grass.itc.it Mon Aug 20 13:00:44 2007 From: landa at grass.itc.it (landa@grass.itc.it) Date: Mon Aug 20 13:00:46 2007 Subject: [grass-addons] r1039 - in trunk/grassaddons/gui: display_driver gui_modules Message-ID: <200708201100.l7KB0i7Q017860@grass.itc.it> Author: landa Date: 2007-08-20 13:00:43 +0200 (Mon, 20 Aug 2007) New Revision: 1039 Modified: trunk/grassaddons/gui/display_driver/Makefile trunk/grassaddons/gui/display_driver/driver.cc trunk/grassaddons/gui/display_driver/driver.h trunk/grassaddons/gui/display_driver/driver.i trunk/grassaddons/gui/gui_modules/digit.py trunk/grassaddons/gui/gui_modules/mapdisp.py trunk/grassaddons/gui/gui_modules/toolbars.py Log: Minor updates of digitization tool Modified: trunk/grassaddons/gui/display_driver/Makefile =================================================================== --- trunk/grassaddons/gui/display_driver/Makefile 2007-08-20 10:44:37 UTC (rev 1038) +++ trunk/grassaddons/gui/display_driver/Makefile 2007-08-20 11:00:43 UTC (rev 1039) @@ -7,7 +7,7 @@ SWIG=swig -CFLAGS=-c -fpic -I/usr/include/python$(PYTHONVERSION) -I./ -I$(ARCH_DISTDIR)/include `wx-config --cxxflags` +CFLAGS=-c -fpic -I/usr/include/python$(PYTHONVERSION) -I./ -I$(ARCH_DISTDIR)/include `wx-config --cxxflags` `gdal-config --cflags` LDFLAGS=-shared -L$(ARCH_LIBDIR) -lgrass_vect -lgrass_gis `wx-config --libs` Modified: trunk/grassaddons/gui/display_driver/driver.cc =================================================================== --- trunk/grassaddons/gui/display_driver/driver.cc 2007-08-20 10:44:37 UTC (rev 1038) +++ trunk/grassaddons/gui/display_driver/driver.cc 2007-08-20 11:00:43 UTC (rev 1039) @@ -85,7 +85,9 @@ DrawLine(line); } +#ifdef DEBUG PrintIds(); +#endif dc = NULL; @@ -143,11 +145,16 @@ } break; default: - draw = FALSE; + draw = false; break; } if (draw) { + // highlight feature? + if (IsSelected(line)) { + dc->SetPen(wxPen(settings.highlight, settings.lineWidth, wxSOLID)); + } + //dc->DrawLines(pointsScreen); for (int i = 0; i < pointsScreen->GetCount() - 1;) { wxPoint *point_beg = (wxPoint *) pointsScreen->Item(i)->GetData(); @@ -170,7 +177,7 @@ else if (type & GV_POINTS) { if (type == GV_POINT && settings.point.enabled) { dc->SetPen(wxPen(settings.point.color, settings.lineWidth, wxSOLID)); - DrawCross(line, (const wxPoint *) pointsScreen->GetFirst()->GetData()); + draw = true; } else if (type == GV_CENTROID) { int cret = Vect_get_centroid_area(mapInfo, line); @@ -186,9 +193,16 @@ draw = settings.centroidDup.enabled; dc->SetPen(wxPen(settings.centroidDup.color, settings.lineWidth, wxSOLID)); } + } - if (draw) - DrawCross(line, (const wxPoint *) pointsScreen->GetFirst()->GetData()); + if (draw) { + // highlight feature? + if (IsSelected(line)) { + std::cout << line << " " << IsSelected(line) << std::endl; + dc->SetPen(wxPen(settings.highlight, settings.lineWidth, wxSOLID)); + } + + DrawCross(line, (const wxPoint *) pointsScreen->GetFirst()->GetData()); } } @@ -292,6 +306,27 @@ return; } +/** + \brief Close and open vector map layer + + Need for modification using v.edit + + \param + + \return +*/ +void DisplayDriver::ReOpenMap() +{ + // char* name = G_store(Vect_get_map_name(mapInfo)); ??? + char* name = G_store(mapInfo->name); + char* mapset = G_store(Vect_get_mapset(mapInfo)); + + Vect_close(mapInfo); + mapInfo = NULL; + + return OpenMap(name, mapset); +} + /* \brief Conversion from geographic coordinates (east, north) to screen (x, y) @@ -452,8 +487,7 @@ \return number of selected features \return -1 on error */ -int DisplayDriver::SelectLinesByBox(double x1, double y1, double x2, double y2, - std::vector* ids) +int DisplayDriver::SelectLinesByBox(double x1, double y1, double x2, double y2) { if (!mapInfo) return -1; @@ -464,8 +498,6 @@ struct ilist *list; struct line_pnts *bbox; - std::vector selected; - type = -1; // all types list = Vect_new_list(); @@ -496,13 +528,60 @@ Vect_destroy_line_struct(bbox); Vect_destroy_list(list); +#ifdef DEBUG for (std::vector::const_iterator i = selected.begin(), e = selected.end(); i != e; ++i) - std::cout << *i << " "; + std::cout << "selected:" << *i << " "; std::cout << std::endl; +#endif - if (ids) - *ids = selected; - return selected.size(); } + +/** + \brief Is vector feature selected? + + \param[in] line vector feature id + + \return if vector feature is selected return true + \return if not return false +*/ +bool DisplayDriver::IsSelected(int line) +{ + for(std::vector::const_iterator i = selected.begin(), e = selected.end(); + i != e; ++i) { + if (line == *i) + return true; + } + + return false; +} + +/** + \brief Unselect selected features by user + + Clear list of ids of selected vector features + + \param + + \return +*/ +void DisplayDriver::Unselect() +{ + selected.clear(); + + return; +} + +/** + \brief Return grass ids of selected vector features + + \param + + \return list of ids of selected vector features +*/ +std::vector DisplayDriver::GetSelected() +{ + return selected; +} + Modified: trunk/grassaddons/gui/display_driver/driver.h =================================================================== --- trunk/grassaddons/gui/display_driver/driver.h 2007-08-20 10:44:37 UTC (rev 1038) +++ trunk/grassaddons/gui/display_driver/driver.h 2007-08-20 11:00:43 UTC (rev 1039) @@ -26,16 +26,20 @@ #include } +#define DEBUG + class DisplayDriver { private: wxPseudoDC *dc; // device content long int dcId; // wxDC id starting - typedef std::map > ids_map; + typedef std::map > ids_map; - ids_map ids; + ids_map ids; // gId : {dcIds, ...} + std::vector selected; // list of selected features (gId) + struct Map_info *mapInfo; struct line_pnts *points; // east, north, depth wxList *pointsScreen; // x, y, z @@ -90,6 +94,9 @@ /* debug */ void PrintIds(); + /* select feature */ + bool IsSelected(int line); + public: /* constructor */ DisplayDriver(); @@ -100,12 +107,14 @@ int DrawMap(void *device); /* select */ - int SelectLinesByBox(double x1, double y1, double x2, double y2, - std::vector* ids); + int SelectLinesByBox(double x1, double y1, double x2, double y2); + void Unselect(); + std::vector GetSelected(); /* general */ void CloseMap(); void OpenMap(const char *mapname, const char *mapset); + void ReOpenMap(); /* set */ void SetRegion(double north, double south, double east, double west, Modified: trunk/grassaddons/gui/display_driver/driver.i =================================================================== --- trunk/grassaddons/gui/display_driver/driver.i 2007-08-20 10:44:37 UTC (rev 1038) +++ trunk/grassaddons/gui/display_driver/driver.i 2007-08-20 11:00:43 UTC (rev 1039) @@ -8,3 +8,8 @@ #include #include "driver.h" %} + +%include "std_vector.i" +namespace std { + %template(IntVector) vector; +} \ No newline at end of file Modified: trunk/grassaddons/gui/gui_modules/digit.py =================================================================== --- trunk/grassaddons/gui/gui_modules/digit.py 2007-08-20 10:44:37 UTC (rev 1038) +++ trunk/grassaddons/gui/gui_modules/digit.py 2007-08-20 11:00:43 UTC (rev 1039) @@ -91,7 +91,7 @@ self.settings["symbolCentroidDup"] = (True, (156, 62, 206, 255)) # violet self.settings["symbolNodeOne"] = (True, (255, 0, 0, 255)) # red self.settings["symbolNodeTwo"] = (True, (0, 86, 45, 255)) # dark green - self.settings["symbolVertex"] = (True, (255, 20, 147, 255)) # deep pink + self.settings["symbolVertex"] = (False, (255, 20, 147, 255)) # deep pink # display self.settings["lineWidth"] = (2, "screen pixels") @@ -243,23 +243,25 @@ def DeleteSelectedLines(self): """Delete selected vector features from the vector map""" - if not self.driver.selected: + selected = self.driver.GetSelected() + + if len(selected) <= 0: return False Debug.msg(4, "Digit.DeleteSelectedLines(): ids=%s" % \ - self.driver.selected) + selected) - ids = ",".join(["%d" % v for v in self.driver.selected]) - command = ["v.edit", "--q", - "map=%s" % self.map, - "tool=delete", - "ids=%s" % ids] + ids = ",".join(["%d" % v for v in selected]) + command = [ "v.edit", "--q", + "map=%s" % self.map, + "tool=delete", + "ids=%s" % ids] # run the command vedit = cmd.Command(cmd=command) # redraw map - #self.driver.ReDrawMap(self.map) + self.driver.display.ReOpenMap() return True @@ -386,47 +388,6 @@ return threshold - def SetPen(self, line, symbol): - """Set Pen for PseudoDC according vector feature status""" - - if line in self.selected: - symbol = "symbolHighlight" - - width = self.parent.settings["lineWidth"][0] - - if self.parent.settings[symbol][0] in [True, None]: - self.mapwindow.pen = self.mapwindow.polypen = wx.Pen(colour=self.parent.settings[symbol][1], - width=width, style=wx.SOLID) - else: - self.mapwindow.pen = self.mapwindow.polypen = None - - def SetSelected(self, pdcId): - """Set selected objects (their ids) in PseudoDC - - For deseleids=[] - """ - # reset - self.selected = [] - - for line in pdcId: - self.selected.append(line) - - Debug.msg(4, "DisplayDriver.SetSelected(): pdcId=%s, grassId=%s" % \ - (pdcId, self.selected)) - - def GetSelected(self, grassId=True): - """Get ids of selected objects in PseudoDC - - If grassId=True return GRASS line id otherwise PseudoDC id""" - if grassId: - return self.selected - else: - pdcId = [] - for line in self.selected: - for id in self.ids[line]: - pdcId.append(id) - return pdcId - class CDisplayDriver(AbstractDisplayDriver): """ Display driver using grass6_wxdriver module @@ -468,10 +429,25 @@ ('None' for no types) """ - nselected = self.display.SelectLinesByBox() + x1, y1 = rect[0] + x2, y2 = rect[1] + + nselected = self.display.SelectLinesByBox(x1, y1, x2, y2) Debug.msg(4, "CDisplayDriver.SelectLinesByBox(): selected=%d" % \ nselected) + + return nselected + + def GetSelected(self): + """Get ids (grass) of selected vector features""" + return self.display.GetSelected() + + def Unselect(self): + """Unselect selected vector features""" + + self.display.Unselect() + def SetRegion(self, reg): """Set geographical region @@ -494,7 +470,10 @@ if not self.display: return - self.display.SetSettings (0, + self.display.SetSettings (wx.Color(settings['symbolHighlight'][1][0], + settings['symbolHighlight'][1][1], + settings['symbolHighlight'][1][2], + 255).GetRGB(), settings['symbolPoint'][0], wx.Color(settings['symbolPoint'][1][0], settings['symbolPoint'][1][1], @@ -835,6 +814,47 @@ self.SetPen(line, "symbolPoint") self.ids[line].append(self.mapwindow.DrawCross(coords[0], size=5)) + def SetPen(self, line, symbol): + """Set Pen for PseudoDC according vector feature status""" + + if line in self.selected: + symbol = "symbolHighlight" + + width = self.parent.settings["lineWidth"][0] + + if self.parent.settings[symbol][0] in [True, None]: + self.mapwindow.pen = self.mapwindow.polypen = wx.Pen(colour=self.parent.settings[symbol][1], + width=width, style=wx.SOLID) + else: + self.mapwindow.pen = self.mapwindow.polypen = None + + def SetSelected(self, pdcId): + """Set selected objects (their ids) in PseudoDC + + For deseleids=[] + """ + # reset + self.selected = [] + + for line in pdcId: + self.selected.append(line) + + Debug.msg(4, "DisplayDriver.SetSelected(): pdcId=%s, grassId=%s" % \ + (pdcId, self.selected)) + + def GetSelected(self, grassId=True): + """Get ids of selected objects in PseudoDC + + If grassId=True return GRASS line id otherwise PseudoDC id""" + if grassId: + return self.selected + else: + pdcId = [] + for line in self.selected: + for id in self.ids[line]: + pdcId.append(id) + return pdcId + class DigitSettingsDialog(wx.Dialog): """ Standard settings dialog for digitization purposes Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py =================================================================== --- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-08-20 10:44:37 UTC (rev 1038) +++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-08-20 11:00:43 UTC (rev 1039) @@ -427,6 +427,7 @@ if self.resize: self.UpdateMap() + event.Skip() def SaveToFile(self, FileName, FileType): @@ -470,7 +471,7 @@ return img - def UpdateMap(self, render=True, redraw=True, removeId=[]): + def UpdateMap(self, render=True): """ Updates the canvas anytime there is a change to the underlaying images or to the geometry of the canvas. @@ -486,17 +487,11 @@ self.img = self.GetImage() # id=99 self.resize = False - if not self.img or redraw == False: + if not self.img: return False - # paint images to PseudoDC - if len(removeId) > 0: - for id in removeId: - self.pdc.ClearId(id) - self.pdc.RemoveId(id) - else: - self.pdc.Clear() - self.pdc.RemoveAll() + self.pdc.Clear() + self.pdc.RemoveAll() try: id = self.imagedict[self.img] @@ -874,7 +869,7 @@ self.Zoom(self.mouse['begin'], self.mouse['end'], self.zoomtype) # redraw map - self.UpdateMap(redraw=True) + self.UpdateMap() elif self.mouse["use"] == "query": # querying @@ -893,34 +888,39 @@ pass elif self.mouse["use"] == "pointer" and self.parent.digittoolbar: - # digitization + # digitization tool active digitToolbar = self.parent.digittoolbar self.mouse['end'] = event.GetPositionTuple()[:] if digitToolbar.action in ["deleteLine", "moveLine", "moveVertex"]: + nselected = 0 + driver = self.parent.digit.driver + # -> delete line || move line || move vertex if digitToolbar.action == "moveVertex": - self.moveIds = self.parent.digit.driver.SelectLinesByPoint(self.Pixel2Cell(self.mouse['begin'][0], + # -> move vertex (select by point) + self.moveIds = driver.SelectLinesByPoint(self.Pixel2Cell(self.mouse['begin'][0], self.mouse['begin'][1]), onlyType="line") - else: # moveLine | deleteLine + else: + # -> moveLine || deleteLine (select by box) x1, y1 = self.Pixel2Cell(self.mouse['begin'][0], self.mouse['begin'][1]) x2, y2 = self.Pixel2Cell(self.mouse['end'][0], self.mouse['end'][1]) - # PyDisplayDriver - # self.moveIds = self.parent.digit.driver.SelectLinesByBox((x1,y1), - # x2, y2))) - nselected = self.parent.digit.driver.SelectLinesByBox(x1, y1, x2, y2) - Debug.msg (3, "") + nselected = driver.SelectLinesByBox(((x1, y1), (x2, y2))) - if len(self.moveIds) > 0: + if nselected > 0: + # highlight selected features self.UpdateMap(render=False) if digitToolbar.action in ["moveLine", "moveVertex"]: - self.UpdateMap(render=False, redraw=False, removeId=self.moveIds) + # -> move line || move vertex + self.UpdateMap(render=False) # get pseudoDC id of objects which should be redrawn if digitToolbar.action == "moveLine": - self.moveIds = self.parent.digit.driver.GetSelected(grassId=False) + # -> move line + self.moveIds = driver.GetSelected(grassId=False) else: - self.moveIds = self.parent.digit.driver.GetSelectedVertex(self.Pixel2Cell(self.mouse['begin'][0], - self.mouse['begin'][1])) + # -> move vertex + self.moveIds = driver.GetSelectedVertex(self.Pixel2Cell(self.mouse['begin'][0], + self.mouse['begin'][1])) elif digitToolbar.action in ["splitLine", "addVertex", "removeVertex"]: self.parent.digit.driver.SelectLinesByPoint(self.Pixel2Cell(self.mouse['begin'][0], self.mouse['begin'][1]), onlyType="line") self.UpdateMap(render=False) @@ -1016,8 +1016,10 @@ digit = self.parent.digittoolbar if digit: + # digitization tool (confirm action) if digit.action == "addLine" and \ digit.type in ["line", "boundary"]: + # -> add new line / boundary try: map = digit.layers[digit.layerSelectedID].name except: @@ -1028,7 +1030,6 @@ dlg.Destroy() if map: - # add new line mapcoords = [] # xy -> EN for coord in self.polycoords: @@ -1062,6 +1063,7 @@ # clean up saved positions self.polycoords = [] elif digit.action == "deleteLine": + # -> delete selected vector features self.parent.digit.DeleteSelectedLines() elif digit.action in ["moveLine", "moveVertex"] and hasattr(self, "moveBegin"): # pixel -> cell @@ -1088,7 +1090,8 @@ elif digit.action == "removeVertex": self.parent.digit.RemoveVertex(self.Pixel2Cell(self.mouse['begin'][0], self.mouse['begin'][1])) - self.parent.digit.driver.SetSelected([]) + #self.parent.digit.driver.SetSelected([]) + self.parent.digit.driver.Unselect() self.UpdateMap(render=False) event.Skip() @@ -1104,9 +1107,11 @@ self.mouse['begin'] = self.polycoords[-1] self.ClearLines() self.DrawLines() - elif digit.action in ["deleteLine", "moveLine", "splitLine", "addVertex", "removeVertex", "moveVertex"]: + elif digit.action in ["deleteLine", "moveLine", "splitLine", + "addVertex", "removeVertex", "moveVertex"]: # unselected selected features - self.parent.digit.driver.SetSelected([]) + # self.parent.digit.driver.SetSelect([]) + self.parent.digit.driver.Unselect() if digit.action in ["moveLine", "moveVertex"] and hasattr(self, "moveBegin"): del self.moveBegin del self.moveCoords Modified: trunk/grassaddons/gui/gui_modules/toolbars.py =================================================================== --- trunk/grassaddons/gui/gui_modules/toolbars.py 2007-08-20 10:44:37 UTC (rev 1038) +++ trunk/grassaddons/gui/gui_modules/toolbars.py 2007-08-20 11:00:43 UTC (rev 1039) @@ -222,7 +222,6 @@ if tool == "Digitize" and not self.mapdisplay.digittoolbar: self.mapdisplay.AddToolbar("digit") - class DigitToolbar(AbstractToolbar): """ Toolbar for digitization @@ -337,7 +336,7 @@ self.action = "addLine" self.type = "line" self.parent.MapWindow.mouse['box'] = 'line' - + def OnAddBoundary(self, event): """Add boundary to the vector map layer""" Debug.msg (2, "DigitToolbar.OnAddBoundary()") @@ -361,7 +360,7 @@ self.StopEditing(self.layers[self.layerSelectedID]) except: pass - + # disable the toolbar self.parent.RemoveToolbar ("digit") @@ -386,7 +385,7 @@ Debug.msg(2, "Digittoolbar.OnSplitLine():") self.action = "splitLine" self.parent.MapWindow.mouse['box'] = 'point' - + def OnEditLine(self, event): pass @@ -394,7 +393,7 @@ Debug.msg(2, "Digittoolbar.OnMoveLine():") self.action = "moveLine" self.parent.MapWindow.mouse['box'] = 'box' - + def OnDeleteLine(self, event): Debug.msg(2, "Digittoolbar.OnDeleteLine():") self.action = "deleteLine" @@ -414,7 +413,7 @@ """Show settings dialog""" DigitSettingsDialog(parent=self.parent, title=_("Digitization settings"), style=wx.DEFAULT_DIALOG_STYLE).Show() - + def OnSelectMap (self, event): """ Select vector map layer for editing @@ -452,7 +451,7 @@ self.parent.digit.SetMapName(mapLayer.name) - # deactive layer + # deactive layer self.mapcontent.ChangeLayerActive(mapLayer, False) # change cursor @@ -460,7 +459,7 @@ # create pseudoDC for drawing the map self.parent.pdcVector = wx.PseudoDC() - + return True def StopEditing (self, layerSelected): @@ -473,22 +472,22 @@ Debug.msg (4, "DigitToolbar.StopEditing(): layer=%s" % \ (layerSelected.name)) self.combo.SetValue ('Select vector map') - + # re-active layer self.mapcontent.ChangeLayerActive(layerSelected, True) self.parent.digit.SetMapName(None) - + # change cursor self.parent.MapWindow.SetCursor(self.parent.cursors["default"]) - # destroy pseudodc - del self.parent.pdcVector + # disable pseudodc for vector map layer + self.parent.MapWindow.pdcVector = None return True return False - + def UpdateListOfLayers (self, updateTool=False): """ Update list of available vector map layers. From landa at grass.itc.it Mon Aug 20 13:39:50 2007 From: landa at grass.itc.it (landa@grass.itc.it) Date: Mon Aug 20 13:39:51 2007 Subject: [grass-addons] r1040 - trunk/grassaddons/gui/display_driver Message-ID: <200708201139.l7KBdoRL018094@grass.itc.it> Author: landa Date: 2007-08-20 13:39:50 +0200 (Mon, 20 Aug 2007) New Revision: 1040 Added: trunk/grassaddons/gui/display_driver/README Log: readme added Added: trunk/grassaddons/gui/display_driver/README =================================================================== --- trunk/grassaddons/gui/display_driver/README (rev 0) +++ trunk/grassaddons/gui/display_driver/README 2007-08-20 11:39:50 UTC (rev 1040) @@ -0,0 +1,4 @@ +Experimental C++ display driver for Digitization tool +===================================================== + +Under development ... *not* ready for testing! From neteler at grass.itc.it Mon Aug 20 15:19:24 2007 From: neteler at grass.itc.it (neteler@grass.itc.it) Date: Mon Aug 20 15:19:26 2007 Subject: [grass-addons] r1041 - in trunk/grassaddons/i.pr: doc i.pr_training include Message-ID: <200708201319.l7KDJOHR019228@grass.itc.it> Author: neteler Date: 2007-08-20 15:19:21 +0200 (Mon, 20 Aug 2007) New Revision: 1041 Modified: trunk/grassaddons/i.pr/doc/usage.tex trunk/grassaddons/i.pr/i.pr_training/main.c trunk/grassaddons/i.pr/i.pr_training/sites.c trunk/grassaddons/i.pr/include/global.h Log: updated GRASS 5 sites API to legacy GRASS 6 sites API Modified: trunk/grassaddons/i.pr/doc/usage.tex =================================================================== --- trunk/grassaddons/i.pr/doc/usage.tex 2007-08-20 11:39:50 UTC (rev 1040) +++ trunk/grassaddons/i.pr/doc/usage.tex 2007-08-20 13:19:21 UTC (rev 1041) @@ -56,7 +56,7 @@ \begin{verbatim} Usage: i.pr_training map=name[,name,...] [vis_map=name] training=name - [site_file=name] rows=value cols=value [class=value] + [vector=name] rows=value cols=value [class=value] Parameters: map Input raster maps (max 25) for extracting the training @@ -68,12 +68,12 @@ maps. If this file already exists, the new data will be appended to the end of the file. - site_file Name of the site file containing labelled location. + vector Name of the site file containing labelled location. Substitutes the interactive procedure of site selection. rows Number of rows (required odd) of the training samples. cols Number of columns (required odd) of the training samples. class Numerical label to be attached to the training examples. - Option not required with the site_file option. + Option not required with the vector option. \end{verbatim} \section{i.pr\_features} Modified: trunk/grassaddons/i.pr/i.pr_training/main.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_training/main.c 2007-08-20 11:39:50 UTC (rev 1040) +++ trunk/grassaddons/i.pr/i.pr_training/main.c 2007-08-20 13:19:21 UTC (rev 1041) @@ -79,10 +79,10 @@ opt4->description= "Name of the output file containing the training raster maps.\n\t\tIf this file already exists, the new data will be appended\n\t\tto the end of the file."; opt6 = G_define_option() ; - opt6->key = "site_file"; + opt6->key = "vector"; opt6->type = TYPE_STRING; opt6->required = NO; - opt6->description= "Name of the site file containing labelled location.\n\t\tSubstitutes the interactive procedure of site selection."; + opt6->description= "Name of the vector points map containing labelled location.\n\t\tSubstitutes the interactive procedure of point selection."; opt2 = G_define_option(); opt2->key = "rows"; @@ -100,7 +100,7 @@ opt5->key = "class"; opt5->type = TYPE_INTEGER; opt5->required = NO; - opt5->description= "Numerical label to be attached to the training examples.\n\t\tOption not required with the site_file option."; + opt5->description= "Numerical label to be attached to the training examples.\n\t\tOption not required with the vector option."; if (G_parser(argc, argv)) exit(1); Modified: trunk/grassaddons/i.pr/i.pr_training/sites.c =================================================================== --- trunk/grassaddons/i.pr/i.pr_training/sites.c 2007-08-20 11:39:50 UTC (rev 1040) +++ trunk/grassaddons/i.pr/i.pr_training/sites.c 2007-08-20 13:19:21 UTC (rev 1041) @@ -1,4 +1,5 @@ #include +#include #include "global.h" #include "globals.h" @@ -14,14 +15,14 @@ int dims=0,cat=0,strs=0,dbls=0; int code; - mapset = G_find_file ("site_lists", site_file, ""); + mapset = G_find_sites(site_file, ""); if (mapset == NULL){ - sprintf (msg, "read_points_from_file-> Can't find sites file <%s>", site_file); + sprintf (msg, "read_points_from_file-> Can't find vector points map <%s>", site_file); G_fatal_error (msg); } out = G_fopen_sites_old (site_file, mapset); if (out == NULL){ - sprintf (msg, "read_points_from_file-> Can't open sites file <%s>", site_file); + sprintf (msg, "read_points_from_file-> Can't open vector points map <%s>", site_file); G_fatal_error (msg); } if (G_site_describe (out, &dims, &cat, &strs, &dbls)!=0){ @@ -37,7 +38,7 @@ training->class[training->nexamples] = site->ccat; training->nexamples += 1; } - fclose(out); + G_sites_close(out); if(code != -1){ sprintf (msg, "read_points_from_file-> Error in G_site_get"); G_warning(msg); Modified: trunk/grassaddons/i.pr/include/global.h =================================================================== --- trunk/grassaddons/i.pr/include/global.h 2007-08-20 11:39:50 UTC (rev 1040) +++ trunk/grassaddons/i.pr/include/global.h 2007-08-20 13:19:21 UTC (rev 1041) @@ -1,5 +1,4 @@ #include -#include #include "func.h" #define PIG M_PI From bundala at grass.itc.it Mon Aug 20 18:37:15 2007 From: bundala at grass.itc.it (bundala@grass.itc.it) Date: Mon Aug 20 18:37:18 2007 Subject: [grass-addons] r1042 - in trunk/grassaddons/v.generalize: . tutorial Message-ID: <200708201637.l7KGbFN1021389@grass.itc.it> Author: bundala Date: 2007-08-20 18:36:06 +0200 (Mon, 20 Aug 2007) New Revision: 1042 Added: trunk/grassaddons/v.generalize/tutorial/ trunk/grassaddons/v.generalize/tutorial/grass_logo.png trunk/grassaddons/v.generalize/tutorial/grassdocs.css trunk/grassaddons/v.generalize/tutorial/tutorial.html trunk/grassaddons/v.generalize/tutorial/v.generalize.anim.gif trunk/grassaddons/v.generalize/tutorial/v.generalize.douglas.png trunk/grassaddons/v.generalize/tutorial/v.generalize.lang.png trunk/grassaddons/v.generalize/tutorial/v.generalize.net200.png trunk/grassaddons/v.generalize/tutorial/v.generalize.net50.png trunk/grassaddons/v.generalize/tutorial/v.generalize.pic1.png trunk/grassaddons/v.generalize/tutorial/v.generalize.pic10.png trunk/grassaddons/v.generalize/tutorial/v.generalize.pic11.png trunk/grassaddons/v.generalize/tutorial/v.generalize.pic12.png trunk/grassaddons/v.generalize/tutorial/v.generalize.pic13.png trunk/grassaddons/v.generalize/tutorial/v.generalize.pic14.png trunk/grassaddons/v.generalize/tutorial/v.generalize.pic15.png trunk/grassaddons/v.generalize/tutorial/v.generalize.pic16.png trunk/grassaddons/v.generalize/tutorial/v.generalize.pic2.png trunk/grassaddons/v.generalize/tutorial/v.generalize.pic3.png trunk/grassaddons/v.generalize/tutorial/v.generalize.pic4.png trunk/grassaddons/v.generalize/tutorial/v.generalize.pic5.png trunk/grassaddons/v.generalize/tutorial/v.generalize.pic6.png trunk/grassaddons/v.generalize/tutorial/v.generalize.pic7.png trunk/grassaddons/v.generalize/tutorial/v.generalize.pic8.png trunk/grassaddons/v.generalize/tutorial/v.generalize.pic9.png trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.douglas.png trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.lang.png trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.net200.png trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.net50.png trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic1.png trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic10.png trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic11.png trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic12.png trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic13.png trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic14.png trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic15.png trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic16.png trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic2.png trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic3.png trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic4.png trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic5.png trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic6.png trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic7.png trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic8.png trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic9.png trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.reduction.png trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.reumann.png trunk/grassaddons/v.generalize/tutorial/v.generalize.reduction.png trunk/grassaddons/v.generalize/tutorial/v.generalize.reumann.png Modified: trunk/grassaddons/v.generalize/description.html Log: added tutorial Modified: trunk/grassaddons/v.generalize/description.html =================================================================== --- trunk/grassaddons/v.generalize/description.html 2007-08-20 13:19:21 UTC (rev 1041) +++ trunk/grassaddons/v.generalize/description.html 2007-08-20 16:36:06 UTC (rev 1042) @@ -4,6 +4,9 @@ is module for generalization of GRASS vector maps. This module comprises a bunch of algortihms for line simplification, line smoothing, network generalization and displacemet. (New methods may be added later) +Also, this document contains only the descriptions of module and implemented +methods. For more examples and nice pictures, check +tutorial

    NOTES

    (Line) simplification is a process of reducing the compexity of vector features. @@ -69,7 +72,7 @@ reasonably preserves the global characteristics of the lines. For more information check http://www.ifp.uni-stuttgart.de/lehre/vorlesungen/GIS1/Lernmodule/Lg/LG_de_6.html(german)
  • Remove Small Lines/Areas - removes the lines (strictly) shorter than threshold and areas of area (strictly)less than threshold. - Other lines/areas/boundaries are left unchanged. Input parameters: input, threshold + Other lines/areas/boundaries are left unchanged. Input parameters: input, threshold

    @@ -200,20 +203,20 @@