base.py 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  1. """!
  2. @package wxplot.base
  3. @brief Base classes for iinteractive plotting using PyPlot
  4. Classes:
  5. - base::PlotIcons
  6. - base::BasePlotFrame
  7. (C) 2011 by the GRASS Development Team
  8. This program is free software under the GNU General Public License
  9. (>=v2). Read the file COPYING that comes with GRASS for details.
  10. @author Michael Barton, Arizona State University
  11. """
  12. import os
  13. import sys
  14. import wx
  15. import wx.lib.plot as plot
  16. from core.globalvar import ETCICONDIR
  17. from core.settings import UserSettings
  18. from wxplot.dialogs import TextDialog, OptDialog
  19. from core.render import Map
  20. from icons.icon import MetaIcon
  21. from gui_core.toolbars import BaseIcons
  22. import grass.script as grass
  23. PlotIcons = {
  24. 'draw' : MetaIcon(img = 'show',
  25. label = _('Draw/re-draw plot')),
  26. 'transect' : MetaIcon(img = 'layer-raster-profile',
  27. label = _('Draw transect in map display window to profile')),
  28. 'options' : MetaIcon(img = 'settings',
  29. label = _('Plot options')),
  30. 'statistics' : MetaIcon(img = 'check',
  31. label = _('Plot statistics')),
  32. 'save' : MetaIcon(img = 'save',
  33. label = _('Save profile data to CSV file')),
  34. 'quit' : BaseIcons['quit'].SetLabel(_('Quit plot tool')),
  35. }
  36. class BasePlotFrame(wx.Frame):
  37. """!Abstract PyPlot display frame class"""
  38. def __init__(self, parent = None, id = wx.ID_ANY, size = wx.Size(700, 400),
  39. style = wx.DEFAULT_FRAME_STYLE, rasterList = [], **kwargs):
  40. wx.Frame.__init__(self, parent, id, size = size, style = style, **kwargs)
  41. self.parent = parent # MapFrame for a plot type
  42. self.mapwin = self.parent.MapWindow
  43. self.Map = Map() # instance of render.Map to be associated with display
  44. self.rasterList = rasterList #list of rasters to plot
  45. self.raster = {} # dictionary of raster maps and their plotting parameters
  46. self.plottype = ''
  47. self.linestyledict = { 'solid' : wx.SOLID,
  48. 'dot' : wx.DOT,
  49. 'long-dash' : wx.LONG_DASH,
  50. 'short-dash' : wx.SHORT_DASH,
  51. 'dot-dash' : wx.DOT_DASH }
  52. self.ptfilldict = { 'transparent' : wx.TRANSPARENT,
  53. 'solid' : wx.SOLID }
  54. #
  55. # Icon
  56. #
  57. self.SetIcon(wx.Icon(os.path.join(ETCICONDIR, 'grass.ico'), wx.BITMAP_TYPE_ICO))
  58. #
  59. # Add statusbar
  60. #
  61. self.statusbar = self.CreateStatusBar(number = 2, style = 0)
  62. self.statusbar.SetStatusWidths([-2, -1])
  63. #
  64. # Define canvas and settings
  65. #
  66. #
  67. self.client = plot.PlotCanvas(self)
  68. #define the function for drawing pointLabels
  69. self.client.SetPointLabelFunc(self.DrawPointLabel)
  70. # Create mouse event for showing cursor coords in status bar
  71. self.client.canvas.Bind(wx.EVT_LEFT_DOWN, self.OnMouseLeftDown)
  72. # Show closest point when enabled
  73. self.client.canvas.Bind(wx.EVT_MOTION, self.OnMotion)
  74. self.plotlist = [] # list of things to plot
  75. self.plot = None # plot draw object
  76. self.ptitle = "" # title of window
  77. self.xlabel = "" # default X-axis label
  78. self.ylabel = "" # default Y-axis label
  79. #
  80. # Bind various events
  81. #
  82. self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
  83. self.CentreOnScreen()
  84. self._createColorDict()
  85. def _createColorDict(self):
  86. """!Create color dictionary to return wx.Color tuples
  87. for assigning colors to images in imagery groups"""
  88. self.colorDict = {}
  89. for clr in grass.named_colors.iterkeys():
  90. if clr == 'white' or clr == 'black': continue
  91. r = grass.named_colors[clr][0] * 255
  92. g = grass.named_colors[clr][1] * 255
  93. b = grass.named_colors[clr][2] * 255
  94. self.colorDict[clr] = (r,g,b,255)
  95. def InitPlotOpts(self, plottype):
  96. """!Initialize options for entire plot
  97. """
  98. ## change get more saved values for initialization
  99. self.plottype = plottype # histogram, profile, or scatter
  100. self.properties = {} # plot properties
  101. self.properties['font'] = {}
  102. self.properties['font']['prop'] = UserSettings.Get(group = self.plottype, key = 'font')
  103. self.properties['font']['wxfont'] = wx.Font(11, wx.FONTFAMILY_SWISS,
  104. wx.FONTSTYLE_NORMAL,
  105. wx.FONTWEIGHT_NORMAL)
  106. self.properties['raster'] = {}
  107. self.properties['raster'] = UserSettings.Get(group = self.plottype, key = 'raster')
  108. colstr = str(self.properties['raster']['pcolor'])
  109. self.properties['raster']['pcolor'] = tuple(int(colval) for colval in colstr.strip('()').split(','))
  110. if self.plottype == 'profile':
  111. self.properties['marker'] = UserSettings.Get(group = self.plottype, key = 'marker')
  112. # changing color string to tuple for markers/points
  113. colstr = str(self.properties['marker']['color'])
  114. self.properties['marker']['color'] = tuple(int(colval) for colval in colstr.strip('()').split(','))
  115. self.properties['grid'] = UserSettings.Get(group = self.plottype, key = 'grid')
  116. colstr = str(self.properties['grid']['color']) # changing color string to tuple
  117. self.properties['grid']['color'] = tuple(int(colval) for colval in colstr.strip('()').split(','))
  118. self.properties['x-axis'] = {}
  119. self.properties['x-axis']['prop'] = UserSettings.Get(group = self.plottype, key = 'x-axis')
  120. self.properties['x-axis']['axis'] = None
  121. self.properties['y-axis'] = {}
  122. self.properties['y-axis']['prop'] = UserSettings.Get(group = self.plottype, key = 'y-axis')
  123. self.properties['y-axis']['axis'] = None
  124. self.properties['legend'] = UserSettings.Get(group = self.plottype, key = 'legend')
  125. self.zoom = False # zooming disabled
  126. self.drag = False # draging disabled
  127. self.client.SetShowScrollbars(True) # vertical and horizontal scrollbars
  128. # x and y axis set to normal (non-log)
  129. self.client.setLogScale((False, False))
  130. if self.properties['x-axis']['prop']['type']:
  131. self.client.SetXSpec(self.properties['x-axis']['prop']['type'])
  132. else:
  133. self.client.SetXSpec('auto')
  134. if self.properties['y-axis']['prop']['type']:
  135. self.client.SetYSpec(self.properties['y-axis']['prop']['type'])
  136. else:
  137. self.client.SetYSpec('auto')
  138. def InitRasterOpts(self, rasterList, plottype):
  139. """!Initialize or update raster dictionary for plotting
  140. """
  141. rdict = {} # initialize a dictionary
  142. # self.properties['raster'] = {}
  143. self.properties['raster'] = UserSettings.Get(group = self.plottype, key = 'raster')
  144. for r in rasterList:
  145. idx = rasterList.index(r)
  146. try:
  147. ret = grass.raster_info(r)
  148. except:
  149. continue
  150. # if r.info cannot parse map, skip it
  151. self.raster[r] = self.properties['raster'] # some default settings
  152. rdict[r] = {} # initialize sub-dictionaries for each raster in the list
  153. rdict[r]['units'] = ''
  154. if ret['units'] not in ('(none)', '"none"', '', None):
  155. rdict[r]['units'] = ret['units']
  156. rdict[r]['plegend'] = r.split('@')[0]
  157. rdict[r]['datalist'] = [] # list of cell value,frequency pairs for plotting histogram
  158. rdict[r]['pline'] = None
  159. rdict[r]['datatype'] = ret['datatype']
  160. ## change init with saved values
  161. #
  162. #initialize with saved values
  163. #
  164. if self.properties['raster']['pwidth'] != None:
  165. rdict[r]['pwidth'] = self.properties['raster']['pwidth']
  166. else:
  167. rdict[r]['pwidth'] = 1
  168. if self.properties['raster']['pstyle'] != None and \
  169. self.properties['raster']['pstyle'] != '':
  170. rdict[r]['pstyle'] = self.properties['raster']['pstyle']
  171. else:
  172. rdict[r]['pstyle'] = 'solid'
  173. if idx <= len(self.colorList):
  174. if idx == 0:
  175. # use saved color for first plot
  176. if self.properties['raster']['pcolor'] != None:
  177. rdict[r]['pcolor'] = self.properties['raster']['pcolor']
  178. else:
  179. rdict[r]['pcolor'] = self.colorDict[self.colorList[idx]]
  180. else:
  181. rdict[r]['pcolor'] = self.colorDict[self.colorList[idx]]
  182. else:
  183. r = randint(0, 255)
  184. b = randint(0, 255)
  185. g = randint(0, 255)
  186. rdict[r]['pcolor'] = ((r,g,b,255))
  187. return rdict
  188. def InitRasterPairs(self, rasterList, plottype):
  189. """!Initialize or update raster dictionary with raster pairs for
  190. bivariate scatterplots
  191. """
  192. if len(rasterList) == 0: return
  193. ## change to init with saved values
  194. rdict = {} # initialize a dictionary
  195. for rpair in rasterList:
  196. idx = rasterList.index(rpair)
  197. try:
  198. ret0 = grass.raster_info(rpair[0])
  199. ret1 = grass.raster_info(rpair[1])
  200. except:
  201. continue
  202. # if r.info cannot parse map, skip it
  203. self.raster[rpair] = UserSettings.Get(group = plottype, key = 'rasters') # some default settings
  204. rdict[rpair] = {} # initialize sub-dictionaries for each raster in the list
  205. rdict[rpair][0] = {}
  206. rdict[rpair][1] = {}
  207. rdict[rpair][0]['units'] = ''
  208. rdict[rpair][1]['units'] = ''
  209. if ret0['units'] not in ('(none)', '"none"', '', None):
  210. rdict[rpair][0]['units'] = ret0['units']
  211. if ret1['units'] not in ('(none)', '"none"', '', None):
  212. rdict[rpair][1]['units'] = ret1['units']
  213. rdict[rpair]['plegend'] = rpair[0].split('@')[0] + ' vs ' + rpair[1].split('@')[0]
  214. rdict[rpair]['datalist'] = [] # list of cell value,frequency pairs for plotting histogram
  215. rdict[rpair][0]['datatype'] = ret0['datatype']
  216. rdict[rpair][1]['datatype'] = ret1['datatype']
  217. #
  218. #initialize with saved values
  219. #
  220. if self.properties['raster']['ptype'] != None and \
  221. self.properties['raster']['ptype'] != '':
  222. rdict[rpair]['ptype'] = self.properties['raster']['ptype']
  223. else:
  224. rdict[rpair]['ptype'] = 'dot'
  225. if self.properties['raster']['psize'] != None:
  226. rdict[rpair]['psize'] = self.properties['raster']['psize']
  227. else:
  228. rdict[rpair]['psize'] = 1
  229. if self.properties['raster']['pfill'] != None and \
  230. self.properties['raster']['pfill'] != '':
  231. rdict[rpair]['pfill'] = self.properties['raster']['pfill']
  232. else:
  233. rdict[rpair]['pfill'] = 'solid'
  234. if idx <= len(self.colorList):
  235. rdict[rpair]['pcolor'] = self.colorDict[self.colorList[idx]]
  236. else:
  237. r = randint(0, 255)
  238. b = randint(0, 255)
  239. g = randint(0, 255)
  240. rdict[rpair]['pcolor'] = ((r,g,b,255))
  241. return rdict
  242. def SetGraphStyle(self):
  243. """!Set plot and text options
  244. """
  245. self.client.SetFont(self.properties['font']['wxfont'])
  246. self.client.SetFontSizeTitle(self.properties['font']['prop']['titleSize'])
  247. self.client.SetFontSizeAxis(self.properties['font']['prop']['axisSize'])
  248. self.client.SetEnableZoom(self.zoom)
  249. self.client.SetEnableDrag(self.drag)
  250. ## change - changed order so that grid settings go last and axis go first
  251. #
  252. # axis settings
  253. #
  254. if self.properties['x-axis']['prop']['type'] == 'custom':
  255. self.client.SetXSpec('min')
  256. else:
  257. self.client.SetXSpec(self.properties['x-axis']['prop']['type'])
  258. if self.properties['y-axis']['prop']['type'] == 'custom':
  259. self.client.SetYSpec('min')
  260. else:
  261. self.client.SetYSpec(self.properties['y-axis']['prop'])
  262. if self.properties['x-axis']['prop']['type'] == 'custom' and \
  263. self.properties['x-axis']['prop']['min'] < self.properties['x-axis']['prop']['max']:
  264. self.properties['x-axis']['axis'] = (self.properties['x-axis']['prop']['min'],
  265. self.properties['x-axis']['prop']['max'])
  266. else:
  267. self.properties['x-axis']['axis'] = None
  268. if self.properties['y-axis']['prop']['type'] == 'custom' and \
  269. self.properties['y-axis']['prop']['min'] < self.properties['y-axis']['prop']['max']:
  270. self.properties['y-axis']['axis'] = (self.properties['y-axis']['prop']['min'],
  271. self.properties['y-axis']['prop']['max'])
  272. else:
  273. self.properties['y-axis']['axis'] = None
  274. if self.properties['x-axis']['prop']['log'] == True:
  275. self.properties['x-axis']['axis'] = None
  276. self.client.SetXSpec('min')
  277. if self.properties['y-axis']['prop']['log'] == True:
  278. self.properties['y-axis']['axis'] = None
  279. self.client.SetYSpec('min')
  280. self.client.setLogScale((self.properties['x-axis']['prop']['log'],
  281. self.properties['y-axis']['prop']['log']))
  282. #
  283. # grid settings
  284. #
  285. self.client.SetEnableGrid(self.properties['grid']['enabled'])
  286. self.client.SetGridColour(wx.Color(self.properties['grid']['color'][0],
  287. self.properties['grid']['color'][1],
  288. self.properties['grid']['color'][2],
  289. 255))
  290. #
  291. # legend settings
  292. #
  293. self.client.SetFontSizeLegend(self.properties['font']['prop']['legendSize'])
  294. self.client.SetEnableLegend(self.properties['legend']['enabled'])
  295. def DrawPlot(self, plotlist):
  296. """!Draw line and point plot from list plot elements.
  297. """
  298. self.plot = plot.PlotGraphics(plotlist,
  299. self.ptitle,
  300. self.xlabel,
  301. self.ylabel)
  302. if self.properties['x-axis']['prop']['type'] == 'custom':
  303. self.client.SetXSpec('min')
  304. else:
  305. self.client.SetXSpec(self.properties['x-axis']['prop']['type'])
  306. if self.properties['y-axis']['prop']['type'] == 'custom':
  307. self.client.SetYSpec('min')
  308. else:
  309. self.client.SetYSpec(self.properties['y-axis']['prop']['type'])
  310. self.client.Draw(self.plot, self.properties['x-axis']['axis'],
  311. self.properties['y-axis']['axis'])
  312. def DrawPointLabel(self, dc, mDataDict):
  313. """!This is the fuction that defines how the pointLabels are
  314. plotted dc - DC that will be passed mDataDict - Dictionary
  315. of data that you want to use for the pointLabel
  316. As an example I have decided I want a box at the curve
  317. point with some text information about the curve plotted
  318. below. Any wxDC method can be used.
  319. """
  320. dc.SetPen(wx.Pen(wx.BLACK))
  321. dc.SetBrush(wx.Brush( wx.BLACK, wx.SOLID ) )
  322. sx, sy = mDataDict["scaledXY"] #scaled x,y of closest point
  323. dc.DrawRectangle( sx-5,sy-5, 10, 10) #10by10 square centered on point
  324. px,py = mDataDict["pointXY"]
  325. cNum = mDataDict["curveNum"]
  326. pntIn = mDataDict["pIndex"]
  327. legend = mDataDict["legend"]
  328. #make a string to display
  329. s = "Crv# %i, '%s', Pt. (%.2f,%.2f), PtInd %i" %(cNum, legend, px, py, pntIn)
  330. dc.DrawText(s, sx , sy+1)
  331. def OnZoom(self, event):
  332. """!Enable zooming and disable dragging
  333. """
  334. self.zoom = True
  335. self.drag = False
  336. self.client.SetEnableZoom(self.zoom)
  337. self.client.SetEnableDrag(self.drag)
  338. def OnDrag(self, event):
  339. """!Enable dragging and disable zooming
  340. """
  341. self.zoom = False
  342. self.drag = True
  343. self.client.SetEnableDrag(self.drag)
  344. self.client.SetEnableZoom(self.zoom)
  345. def OnRedraw(self, event):
  346. """!Redraw the plot window. Unzoom to original size
  347. """
  348. self.client.Reset()
  349. self.client.Redraw()
  350. def OnErase(self, event):
  351. """!Erase the plot window
  352. """
  353. self.client.Clear()
  354. self.mapwin.ClearLines(self.mapwin.pdc)
  355. self.mapwin.ClearLines(self.mapwin.pdcTmp)
  356. self.mapwin.polycoords = []
  357. self.mapwin.Refresh()
  358. def SaveToFile(self, event):
  359. """!Save plot to graphics file
  360. """
  361. self.client.SaveFile()
  362. def OnMouseLeftDown(self,event):
  363. self.SetStatusText(_("Left Mouse Down at Point:") + \
  364. " (%.4f, %.4f)" % self.client._getXY(event))
  365. event.Skip() # allows plotCanvas OnMouseLeftDown to be called
  366. def OnMotion(self, event):
  367. """!Indicate when mouse is outside the plot area
  368. """
  369. if self.client.OnLeave(event): print 'out of area'
  370. #show closest point (when enbled)
  371. if self.client.GetEnablePointLabel() == True:
  372. #make up dict with info for the pointLabel
  373. #I've decided to mark the closest point on the closest curve
  374. dlst = self.client.GetClosetPoint( self.client._getXY(event), pointScaled = True)
  375. if dlst != []: #returns [] if none
  376. curveNum, legend, pIndex, pointXY, scaledXY, distance = dlst
  377. #make up dictionary to pass to my user function (see DrawPointLabel)
  378. mDataDict = {"curveNum":curveNum, "legend":legend, "pIndex":pIndex,\
  379. "pointXY":pointXY, "scaledXY":scaledXY}
  380. #pass dict to update the pointLabel
  381. self.client.UpdatePointLabel(mDataDict)
  382. event.Skip() #go to next handler
  383. def PlotOptionsMenu(self, event):
  384. """!Popup menu for plot and text options
  385. """
  386. point = wx.GetMousePosition()
  387. popt = wx.Menu()
  388. # Add items to the menu
  389. settext = wx.MenuItem(popt, wx.ID_ANY, _('Text settings'))
  390. popt.AppendItem(settext)
  391. self.Bind(wx.EVT_MENU, self.PlotText, settext)
  392. setgrid = wx.MenuItem(popt, wx.ID_ANY, _('Plot settings'))
  393. popt.AppendItem(setgrid)
  394. self.Bind(wx.EVT_MENU, self.PlotOptions, setgrid)
  395. # Popup the menu. If an item is selected then its handler
  396. # will be called before PopupMenu returns.
  397. self.PopupMenu(popt)
  398. popt.Destroy()
  399. def NotFunctional(self):
  400. """!Creates a 'not functional' message dialog
  401. """
  402. dlg = wx.MessageDialog(parent = self,
  403. message = _('This feature is not yet functional'),
  404. caption = _('Under Construction'),
  405. style = wx.OK | wx.ICON_INFORMATION)
  406. dlg.ShowModal()
  407. dlg.Destroy()
  408. def OnPlotText(self, dlg):
  409. """!Custom text settings for histogram plot.
  410. """
  411. self.ptitle = dlg.ptitle
  412. self.xlabel = dlg.xlabel
  413. self.ylabel = dlg.ylabel
  414. ## change these are redundant and can cause problems
  415. # dlg.UpdateSettings()
  416. self.client.SetFont(self.properties['font']['wxfont'])
  417. self.client.SetFontSizeTitle(self.properties['font']['prop']['titleSize'])
  418. self.client.SetFontSizeAxis(self.properties['font']['prop']['axisSize'])
  419. if self.plot:
  420. self.plot.setTitle(dlg.ptitle)
  421. self.plot.setXLabel(dlg.xlabel)
  422. self.plot.setYLabel(dlg.ylabel)
  423. # dlg.OnSave()
  424. self.OnRedraw(event = None)
  425. def PlotText(self, event):
  426. """!Set custom text values for profile title and axis labels.
  427. """
  428. dlg = TextDialog(parent = self, id = wx.ID_ANY,
  429. plottype = self.plottype,
  430. title = _('Histogram text settings'))
  431. ## change to work correctly
  432. btnval = dlg.ShowModal()
  433. if btnval == wx.ID_SAVE or btnval == wx.ID_OK or btnval == wx.ID_CANCEL:
  434. # self.OnPlotText(dlg)
  435. dlg.Destroy()
  436. def PlotOptions(self, event):
  437. """!Set various profile options, including: line width, color,
  438. style; marker size, color, fill, and style; grid and legend
  439. options. Calls OptDialog class.
  440. """
  441. dlg = OptDialog(parent = self, id = wx.ID_ANY,
  442. plottype = self.plottype,
  443. title = _('Plot settings'))
  444. btnval = dlg.ShowModal()
  445. ## change buttons to be like text options
  446. if btnval == wx.ID_SAVE or btnval == wx.ID_OK or btnval == wx.ID_CANCEL:
  447. ## change these are redundant and can cause problems
  448. # dlg.UpdateSettings()
  449. # self.SetGraphStyle()
  450. dlg.Destroy()
  451. def PrintMenu(self, event):
  452. """!Print options and output menu
  453. """
  454. point = wx.GetMousePosition()
  455. printmenu = wx.Menu()
  456. for title, handler in ((_("Page setup"), self.OnPageSetup),
  457. (_("Print preview"), self.OnPrintPreview),
  458. (_("Print display"), self.OnDoPrint)):
  459. item = wx.MenuItem(printmenu, wx.ID_ANY, title)
  460. printmenu.AppendItem(item)
  461. self.Bind(wx.EVT_MENU, handler, item)
  462. # Popup the menu. If an item is selected then its handler
  463. # will be called before PopupMenu returns.
  464. self.PopupMenu(printmenu)
  465. printmenu.Destroy()
  466. def OnPageSetup(self, event):
  467. self.client.PageSetup()
  468. def OnPrintPreview(self, event):
  469. self.client.PrintPreview()
  470. def OnDoPrint(self, event):
  471. self.client.Printout()
  472. def OnQuit(self, event):
  473. self.Close(True)
  474. def OnCloseWindow(self, event):
  475. """!Close plot window and clean up
  476. """
  477. try:
  478. self.mapwin.ClearLines()
  479. self.mapwin.mouse['begin'] = self.mapwin.mouse['end'] = (0.0, 0.0)
  480. self.mapwin.mouse['use'] = 'pointer'
  481. self.mapwin.mouse['box'] = 'point'
  482. self.mapwin.polycoords = []
  483. self.mapwin.UpdateMap(render = False, renderVector = False)
  484. except:
  485. pass
  486. self.mapwin.SetCursor(self.Parent.cursors["default"])
  487. self.Destroy()