d.rast.edit.py 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715
  1. #!/usr/bin/env python
  2. ############################################################################
  3. #
  4. # MODULE: d.rast.edit
  5. # AUTHOR(S): Glynn Clements <glynn@gclements.plus.com>
  6. # COPYRIGHT: (C) 2007,2008 Glynn Clements
  7. #
  8. # This program is free software; you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation; either version 2 of the License, or
  11. # (at your option) any later version.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU General Public License for more details.
  17. #
  18. #############################################################################/
  19. #%Module
  20. #% description: Interactively edit cell values in a raster map.
  21. #% keywords: display, raster
  22. #%End
  23. #%Option
  24. #% key: input
  25. #% type: string
  26. #% required: yes
  27. #% multiple: no
  28. #% key_desc: name
  29. #% description: Name of input raster map
  30. #% gisprompt: old,cell,raster
  31. #%End
  32. #%Option
  33. #% key: output
  34. #% type: string
  35. #% required: yes
  36. #% multiple: no
  37. #% key_desc: name
  38. #% description: Name for output raster map
  39. #% gisprompt: new,cell,raster
  40. #%End
  41. #%Option
  42. #% key: aspect
  43. #% type: string
  44. #% required: no
  45. #% multiple: no
  46. #% key_desc: name
  47. #% description: Name of aspect raster map
  48. #% gisprompt: old,cell,raster
  49. #%End
  50. #%Option
  51. #% key: width
  52. #% type: integer
  53. #% required: no
  54. #% multiple: no
  55. #% description: Width of display canvas
  56. #% answer: 640
  57. #%End
  58. #%Option
  59. #% key: height
  60. #% type: integer
  61. #% required: no
  62. #% multiple: no
  63. #% description: Height of display canvas
  64. #% answer: 480
  65. #%End
  66. #%Option
  67. #% key: size
  68. #% type: integer
  69. #% required: no
  70. #% multiple: no
  71. #% description: Minimum size of each cell
  72. #% answer: 12
  73. #%End
  74. #%Option
  75. #% key: rows
  76. #% type: integer
  77. #% required: no
  78. #% multiple: no
  79. #% description: Maximum number of rows to load
  80. #% answer: 100
  81. #%End
  82. #%Option
  83. #% key: cols
  84. #% type: integer
  85. #% required: no
  86. #% multiple: no
  87. #% description: Maximum number of columns to load
  88. #% answer: 100
  89. #%End
  90. import wxversion
  91. wxversion.select(['2.8','2.6'])
  92. #wxversion.select(['2.6','2.8'])
  93. import wx
  94. import sys
  95. import math
  96. import atexit
  97. import grass
  98. wind_keys = {
  99. 'north': ('n', float),
  100. 'south': ('s', float),
  101. 'east': ('e', float),
  102. 'west': ('w', float),
  103. 'nsres': ('nsres', float),
  104. 'ewres': ('ewres', float),
  105. 'rows': ('rows', int),
  106. 'cols': ('cols', int),
  107. }
  108. gray12_bits = '\x00\x00\x22\x22\x00\x00\x88\x88\x00\x00\x22\x22\x00\x00\x88\x88\x00\x00\x22\x22\x00\x00\x88\x88\x00\x00\x22\x22\x00\x00\x88\x88'
  109. def run(cmd, **kwargs):
  110. grass.run_command(cmd, quiet = True, **kwargs)
  111. class OverviewCanvas(wx.ScrolledWindow):
  112. def __init__(self, app, parent):
  113. wx.ScrolledWindow.__init__(self, parent)
  114. self.app = app
  115. self.width = app.total['cols']
  116. self.height = app.total['rows']
  117. self.SetVirtualSize((self.width, self.height))
  118. self.SetScrollRate(1, 1)
  119. self.Bind(wx.EVT_LEFT_DOWN, self.OnMouse)
  120. self.Bind(wx.EVT_MOTION, self.OnMouse)
  121. self.Bind(wx.EVT_LEFT_UP, self.OnMouse)
  122. self.Bind(wx.EVT_PAINT, self.OnPaint)
  123. run('r.out.ppm', input = app.inmap, output = app.tempfile)
  124. self.image = wx.BitmapFromImage(wx.Image(app.tempfile))
  125. grass.try_remove(app.tempfile)
  126. app.force_window()
  127. def OnPaint(self, ev):
  128. x0 = self.app.origin_x
  129. y0 = self.app.origin_y
  130. dx = self.app.cols
  131. dy = self.app.rows
  132. dc = wx.PaintDC(self)
  133. self.DoPrepareDC(dc)
  134. src = wx.MemoryDC()
  135. src.SelectObjectAsSource(self.image)
  136. dc.Blit(0, 0, self.width, self.height, src, 0, 0)
  137. src.SelectObjectAsSource(wx.NullBitmap)
  138. dc.SetPen(wx.Pen('red', style = wx.LONG_DASH))
  139. dc.SetBrush(wx.Brush('black', style = wx.TRANSPARENT))
  140. dc.DrawRectangle(x0, y0, dx, dy)
  141. dc.SetBrush(wx.NullBrush)
  142. dc.SetPen(wx.NullPen)
  143. def OnMouse(self, ev):
  144. if ev.Moving():
  145. return
  146. x = ev.GetX()
  147. y = ev.GetY()
  148. (x, y) = self.CalcUnscrolledPosition(x, y)
  149. self.set_window(x, y)
  150. if ev.ButtonUp():
  151. self.app.change_window()
  152. def set_window(self, x, y):
  153. self.app.origin_x = x - app.cols / 2
  154. self.app.origin_y = y - app.rows / 2
  155. self.app.force_window()
  156. self.Refresh()
  157. class OverviewWindow(wx.Frame):
  158. def __init__(self, app):
  159. wx.Frame.__init__(self, None, title = "d.rast.edit overview (%s)" % app.inmap)
  160. self.app = app
  161. self.canvas = OverviewCanvas(app, parent = self)
  162. self.Bind(wx.EVT_CLOSE, self.OnClose)
  163. def OnClose(self, ev):
  164. self.app.finalize()
  165. class Canvas(wx.ScrolledWindow):
  166. def __init__(self, app, parent):
  167. wx.ScrolledWindow.__init__(self, parent)
  168. self.app = app
  169. self.size = app.size
  170. w = app.cols * self.size
  171. h = app.rows * self.size
  172. self.SetVirtualSize((w, h))
  173. self.SetVirtualSizeHints(50, 50)
  174. self.SetScrollRate(1, 1)
  175. self.Bind(wx.EVT_LEFT_DOWN, self.OnMouse)
  176. self.Bind(wx.EVT_RIGHT_DOWN, self.OnMouse)
  177. self.Bind(wx.EVT_MOTION, self.OnMouse)
  178. self.Bind(wx.EVT_PAINT, self.OnPaint2)
  179. self.row = 0
  180. self.col = 0
  181. self.gray12 = wx.BitmapFromBits(gray12_bits, 16, 16)
  182. def OnMouse(self, ev):
  183. oldrow = self.row
  184. oldcol = self.col
  185. x = ev.GetX()
  186. y = ev.GetY()
  187. (x, y) = self.CalcUnscrolledPosition(x, y)
  188. col = x / self.size
  189. row = y / self.size
  190. self.row = row
  191. self.col = col
  192. if ev.Moving():
  193. self.refresh_cell(oldrow, oldcol)
  194. self.refresh_cell(row, col)
  195. elif ev.ButtonDown(wx.MOUSE_BTN_LEFT):
  196. self.cell_set()
  197. elif ev.ButtonDown(wx.MOUSE_BTN_RIGHT):
  198. self.cell_get()
  199. def paint_cell(self, dc, r, c):
  200. if r < 0 or r >= self.app.rows or c < 0 or c >= self.app.cols:
  201. return
  202. val = self.app.values[r][c]
  203. if val == None:
  204. fill = 'black'
  205. stipple = self.gray12
  206. else:
  207. fill = self.app.get_color(val)
  208. stipple = None
  209. if r == self.row and c == self.col:
  210. outline = 'red'
  211. elif self.app.changed[r][c]:
  212. outline = 'white'
  213. else:
  214. outline = 'black'
  215. dc.SetPen(wx.Pen(outline))
  216. if stipple:
  217. brush = wx.Brush(fill, style = wx.STIPPLE)
  218. brush.SetStipple(stipple)
  219. else:
  220. brush = wx.Brush(fill, style = wx.SOLID)
  221. x0 = c * self.size + 1
  222. x1 = x0 + self.size - 1
  223. y0 = r * self.size + 1
  224. y1 = y0 + self.size - 1
  225. dc.SetBrush(brush)
  226. dc.DrawRectangle(x0, y0, x1 - x0, y1 - y0)
  227. dc.SetPen(wx.NullPen)
  228. dc.SetBrush(wx.NullBrush)
  229. if not self.app.angles:
  230. return
  231. if self.app.angles[r][c] == '*':
  232. return
  233. cx = (x0 + x1) / 2
  234. cy = (y0 + y1) / 2
  235. a = math.radians(float(self.app.angles[r][c]))
  236. dx = math.cos(a) * self.size / 2
  237. dy = -math.sin(a) * self.size / 2
  238. x0 = cx - dx
  239. y0 = cy - dy
  240. x1 = cx + dx
  241. y1 = cy + dy
  242. dx, dy = x1 - x0, y1 - y0
  243. px, py = -dy, dx
  244. r,g,b = wx.NamedColor(fill)
  245. if r + g + b > 384:
  246. line = 'black'
  247. else:
  248. line = 'white'
  249. dc.SetPen(wx.Pen(line))
  250. dc.DrawLine(x0, y0, x1, y1)
  251. dc.DrawLine(x1, y1, x1 + px/6 - dx/3, y1 + py/6 - dy/3)
  252. dc.DrawLine(x1, y1, x1 - px/6 - dx/3, y1 - py/6 - dy/3)
  253. dc.SetPen(wx.NullPen)
  254. def paint_rect(self, dc, x, y, w, h):
  255. c0 = (x + 0) / self.size
  256. c1 = (x + w + 1) / self.size
  257. r0 = (y + 0) / self.size
  258. r1 = (y + h + 1) / self.size
  259. for r in range(r0, r1 + 1):
  260. for c in range(c0, c1 + 1):
  261. self.paint_cell(dc, r, c)
  262. def OnPaint(self, ev):
  263. dc = wx.PaintDC(self)
  264. self.DoPrepareDC(dc)
  265. for r in range(self.app.rows):
  266. for c in range(self.app.cols):
  267. self.paint_cell(dc, r, c)
  268. def OnPaint2(self, ev):
  269. dc = wx.PaintDC(self)
  270. self.DoPrepareDC(dc)
  271. it = wx.RegionIterator(self.GetUpdateRegion())
  272. while it.HaveRects():
  273. x = it.GetX()
  274. y = it.GetY()
  275. w = it.GetW()
  276. h = it.GetH()
  277. (x, y) = self.CalcUnscrolledPosition(x, y)
  278. self.paint_rect(dc, x, y, w, h)
  279. it.Next()
  280. def cell_enter(self):
  281. if not self.row or not self.col:
  282. return
  283. self.app.update_status(self.row, self.col)
  284. def cell_leave(self):
  285. self.app.clear_status()
  286. def cell_get(self):
  287. self.app.brush = self.app.values[self.row][self.col]
  288. self.app.frame.brush_update()
  289. def cell_set(self):
  290. self.app.values[self.row][self.col] = self.app.brush
  291. self.app.changed[self.row][self.col] = True
  292. self.refresh_cell(self.row, self.col)
  293. def refresh_cell(self, row, col):
  294. x = col * self.size
  295. y = row * self.size
  296. (x, y) = self.CalcScrolledPosition(x, y)
  297. self.RefreshRect((x, y, self.size, self.size))
  298. class ColorPanel(wx.Panel):
  299. def __init__(self, **kwargs):
  300. wx.Panel.__init__(self, **kwargs)
  301. self.SetBackgroundStyle(wx.BG_STYLE_COLOUR)
  302. self.stipple = wx.BitmapFromBits(gray12_bits, 16, 16)
  303. self.null_bg = True
  304. self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnErase)
  305. def OnErase(self, ev):
  306. self.ClearBackground()
  307. if not self.null_bg:
  308. return
  309. dc = ev.GetDC()
  310. if not dc:
  311. dc = wx.ClientDC(self)
  312. brush = wx.Brush('black', style = wx.STIPPLE)
  313. brush.SetStipple(self.stipple)
  314. dc.SetBackground(brush)
  315. dc.Clear()
  316. dc.SetBackground(wx.NullBrush)
  317. def SetNullBackgroundColour(self):
  318. wx.Panel.SetBackgroundColour(self, 'gray')
  319. self.null_bg = True
  320. def SetBackgroundColour(self, color):
  321. wx.Panel.SetBackgroundColour(self, color)
  322. self.null_bg = False
  323. class MainWindow(wx.Frame):
  324. def __init__(self, app):
  325. wx.Frame.__init__(self, None, title = "d.rast.edit (%s)" % app.inmap)
  326. self.app = app
  327. self.Bind(wx.EVT_CLOSE, self.OnClose)
  328. filemenu = wx.Menu()
  329. filemenu.Append(wx.ID_SAVE, "&Save", "Save changes")
  330. filemenu.Append(wx.ID_EXIT, "E&xit", "Terminate the program")
  331. menubar = wx.MenuBar()
  332. menubar.Append(filemenu, "&File")
  333. self.SetMenuBar(menubar)
  334. wx.EVT_MENU(self, wx.ID_SAVE, self.OnSave)
  335. wx.EVT_MENU(self, wx.ID_EXIT, self.OnExit)
  336. sizer = wx.BoxSizer(orient = wx.VERTICAL)
  337. self.canvas = Canvas(app, parent = self)
  338. si = sizer.Add(self.canvas, proportion = 1, flag = wx.EXPAND)
  339. tools = wx.BoxSizer(wx.HORIZONTAL)
  340. l = wx.StaticText(parent = self, label = 'New Value:')
  341. tools.Add(l, flag = wx.ALIGN_CENTER_VERTICAL)
  342. tools.AddSpacer(5)
  343. self.newval = wx.TextCtrl(parent = self, style = wx.TE_PROCESS_ENTER)
  344. tools.Add(self.newval, flag = wx.ALIGN_CENTER_VERTICAL)
  345. l = wx.StaticText(parent = self, label = 'Color:')
  346. tools.Add(l, flag = wx.ALIGN_CENTER_VERTICAL)
  347. tools.AddSpacer(5)
  348. self.color = ColorPanel(parent = self, size = (30,5))
  349. tools.Add(self.color, flag = wx.ALIGN_CENTER_VERTICAL | wx.EXPAND)
  350. self.Bind(wx.EVT_TEXT_ENTER, self.OnReturn, source = self.newval)
  351. sizer.AddSizer(tools, proportion = 0, flag = wx.EXPAND)
  352. self.SetSizerAndFit(sizer)
  353. self.SetSize((app.width, app.height))
  354. self.status = self.CreateStatusBar(6)
  355. self.brush_update()
  356. def OnSave(self, ev):
  357. self.app.save_map()
  358. def OnExit(self, ev):
  359. self.Close(True)
  360. def OnClose(self, ev):
  361. self.app.finalize()
  362. def OnReturn(self, ev):
  363. self.app.brush = self.newval.GetValue()
  364. if self.app.brush != '*' and self.app.brush.strip('0123456789') != '':
  365. self.app.brush = '*'
  366. self.brush_update()
  367. def update_status(self):
  368. for i, key in enumerate(['row', 'col', 'x', 'y', 'value', 'aspect']):
  369. s = "%s%s: %s" % (key[0].upper(), key[1:], self.app.status[key])
  370. self.status.SetStatusText(s, i)
  371. def clear_status(self):
  372. for key in self.status:
  373. self.status[key] = ''
  374. def brush_update(self):
  375. self.newval.ChangeValue(self.app.brush)
  376. if self.app.brush == '*':
  377. self.color.SetNullBackgroundColour()
  378. else:
  379. self.color.SetBackgroundColour(self.app.get_color(self.app.brush))
  380. self.color.Refresh()
  381. class Application(wx.App):
  382. def __init__(self, options):
  383. self.options = options
  384. wx.App.__init__(self)
  385. def initialize(self):
  386. grass.use_temp_region()
  387. run('g.region', rast = self.inmap)
  388. reg = grass.region()
  389. for k, f in wind_keys.values():
  390. self.total[k] = (f)(reg[k])
  391. if self.cols > self.total['cols']:
  392. self.cols = self.total['cols']
  393. if self.rows > self.total['rows']:
  394. self.rows = self.total['rows']
  395. tempbase = grass.tempfile()
  396. grass.try_remove(tempbase)
  397. self.tempfile = tempbase + '.ppm'
  398. self.tempmap = 'tmp.d.rast.edit'
  399. atexit.register(self.cleanup)
  400. run('g.copy', rast = (self.inmap, self.outmap), overwrite = True)
  401. run('r.colors', map = self.outmap, rast = self.inmap)
  402. def cleanup(self):
  403. grass.try_remove(self.tempfile)
  404. run('g.remove', rast = self.tempmap)
  405. def finalize(self):
  406. self.save_map()
  407. sys.exit(0)
  408. def save_map(self):
  409. p = grass.feed_command('r.in.ascii', input = '-', output = self.tempmap, quiet = True, overwrite = True)
  410. outf = p.stdin
  411. outf.write("north: %f\n" % self.wind['n'])
  412. outf.write("south: %f\n" % self.wind['s'])
  413. outf.write("east: %f\n" % self.wind['e'])
  414. outf.write("west: %f\n" % self.wind['w'])
  415. outf.write("rows: %d\n" % self.wind['rows'])
  416. outf.write("cols: %d\n" % self.wind['cols'])
  417. outf.write("null: *\n")
  418. for row in range(self.wind['rows']):
  419. for col in range(self.wind['cols']):
  420. if col > 0:
  421. outf.write(" ")
  422. val = self.values[row][col]
  423. if val and self.changed[row][col]:
  424. outf.write("%s" % val)
  425. else:
  426. outf.write('*')
  427. outf.write("\n")
  428. outf.close()
  429. p.wait()
  430. run('g.region', rast = self.inmap)
  431. run('r.patch', input = (self.tempmap, self.outmap), output = self.outmap, overwrite = True)
  432. run('r.colors', map = self.outmap, rast = self.inmap)
  433. run('g.remove', rast = self.tempmap)
  434. def read_header(self, infile):
  435. wind = {}
  436. for i in range(6):
  437. line = infile.readline().rstrip('\r\n')
  438. f = line.split(':')
  439. key = f[0]
  440. val = f[1].strip()
  441. (k, f) = wind_keys[key]
  442. wind[k] = (f)(val)
  443. return wind
  444. def read_data(self, infile):
  445. values = []
  446. for row in range(self.wind['rows']):
  447. line = infile.readline().rstrip('\r\n')
  448. values.append(line.split())
  449. return values
  450. def load_map(self):
  451. run('g.region', **self.wind)
  452. p = grass.pipe_command('r.out.ascii', input = self.inmap, quiet = True)
  453. self.wind = self.read_header(p.stdout)
  454. self.values = self.read_data(p.stdout)
  455. self.changed = [[False for c in row] for row in self.values]
  456. p.wait()
  457. self.clear_changes()
  458. run('r.out.ppm', input = self.inmap, output = self.tempfile)
  459. colorimg = wx.Image(self.tempfile)
  460. grass.try_remove(self.tempfile)
  461. for row in range(self.wind['rows']):
  462. for col in range(self.wind['cols']):
  463. val = self.values[row][col]
  464. if val in self.colors:
  465. continue
  466. r = colorimg.GetRed(col, row)
  467. g = colorimg.GetGreen(col, row)
  468. b = colorimg.GetBlue(col, row)
  469. color = "#%02x%02x%02x" % (r, g, b)
  470. self.colors[val] = color
  471. colorimg.Destroy()
  472. def load_aspect(self):
  473. if not self.aspect:
  474. return
  475. p = grass.pipe_command('r.out.ascii', input = self.aspect, quiet = True)
  476. self.read_header(p.stdout)
  477. self.angles = self.read_data(p.stdout)
  478. p.wait()
  479. def clear_changes(self):
  480. for row in range(self.wind['rows']):
  481. for col in range(self.wind['cols']):
  482. self.changed[row][col] = 0
  483. def update_window(self):
  484. x0 = self.origin_x
  485. y0 = self.origin_y
  486. x1 = x0 + self.cols
  487. y1 = y0 + self.rows
  488. self.wind['n'] = self.total['n'] - y0 * self.total['nsres']
  489. self.wind['s'] = self.total['n'] - y1 * self.total['nsres']
  490. self.wind['w'] = self.total['w'] + x0 * self.total['ewres']
  491. self.wind['e'] = self.total['w'] + x1 * self.total['ewres']
  492. self.wind['rows'] = self.rows
  493. self.wind['cols'] = self.cols
  494. def change_window(self):
  495. self.save_map()
  496. self.update_window()
  497. self.load_map()
  498. self.load_aspect()
  499. self.refresh_canvas()
  500. def force_window(self):
  501. if self.origin_x < 0:
  502. self.origin_x = 0
  503. if self.origin_x > self.total['cols'] - self.cols:
  504. self.origin_x = self.total['cols'] - self.cols
  505. if self.origin_y < 0:
  506. self.origin_y = 0
  507. if self.origin_y > self.total['rows'] - self.rows:
  508. self.origin_y = self.total['rows'] - self.rows
  509. def update_status(self, row, col):
  510. self.status['row'] = row
  511. self.status['col'] = col
  512. self.status['x'] = self.wind['e'] + (col + 0.5) * (self.wind['e'] - self.wind['w']) / self.wind['cols']
  513. self.status['y'] = self.wind['n'] - (row + 0.5) * (self.wind['n'] - self.wind['s']) / self.wind['rows']
  514. self.status['value'] = self.values[row][col]
  515. if self.angles:
  516. self.status['aspect'] = self.angles[row][col]
  517. def force_color(val):
  518. run('g.region', rows = 1, cols = 1)
  519. run('r.mapcalc', expression = "%s = %d" % (self.tempmap, val))
  520. run('r.colors', map = self.tempmap, rast = self.inmap)
  521. run('r.out.ppm', input = self.tempmap, out = self.tempfile)
  522. run('g.remove', rast = self.tempmap)
  523. tempimg = wx.Image(self.tempfile)
  524. grass.try_remove(self.tempfile)
  525. rgb = tempimg.get(0, 0)
  526. color = "#%02x%02x%02x" % rgb
  527. self.colors[val] = color
  528. tempimg.delete()
  529. def get_color(self, val):
  530. if val not in self.colors:
  531. try:
  532. self.force_color(val)
  533. except:
  534. self.colors[val] = "#ffffff"
  535. return self.colors[val]
  536. def refresh_canvas(self):
  537. self.frame.canvas.Refresh()
  538. def make_ui(self):
  539. self.frame = MainWindow(self)
  540. self.SetTopWindow(self.frame)
  541. self.frame.Show()
  542. self.overview = OverviewWindow(self)
  543. self.overview.Show()
  544. def OnInit(self):
  545. self.outmap = self.options['output']
  546. self.inmap = self.options['input']
  547. self.aspect = self.options['aspect']
  548. self.width = int(self.options['width'])
  549. self.height = int(self.options['height'])
  550. self.size = int(self.options['size'])
  551. self.rows = int(self.options['rows'])
  552. self.cols = int(self.options['cols'])
  553. self.status = {
  554. 'row': '',
  555. 'col': '',
  556. 'x': '',
  557. 'y': '',
  558. 'value': '',
  559. 'aspect': ''
  560. }
  561. self.values = None
  562. self.changed = None
  563. self.angles = None
  564. self.colors = {}
  565. self.brush = '*'
  566. self.origin_x = 0
  567. self.origin_y = 0
  568. self.wind = {}
  569. self.total = {}
  570. self.initialize()
  571. self.update_window()
  572. self.make_ui()
  573. self.load_map()
  574. self.load_aspect()
  575. self.refresh_canvas()
  576. return True
  577. if __name__ == "__main__":
  578. options, flags = grass.parser()
  579. app = Application(options)
  580. app.MainLoop()