Changeset 892
- Timestamp:
- 12/20/2012 06:00:27 PM (11 years ago)
- Location:
- SHX/trunk/SeismicHandler
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
SHX/trunk/SeismicHandler/basics/messages.py
r887 r892 13 13 import time 14 14 from SeismicHandler.utils.pubsub import pub 15 from SeismicHandler.basics.tools import AttributeBlock 15 16 16 17 # shortcut … … 156 157 """ 157 158 styles = get_runtime("styles") 159 block = block.upper() 158 160 159 if item is None: 160 styles[block.upper()] = value 161 if block in styles.keys(): 162 if item is None: 163 styles[block] = value 164 else: 165 styles[block.upper()][item.upper()] = value 166 set_runtime("styles", styles) 161 167 else: 162 styles[block.upper()][item.upper()] = value 163 set_runtime("styles", styles) 168 # build attribute block 169 attribs = get_runtime("attrib") 170 kwargs = {item: value} 171 a = attribs.get(block, AttributeBlock(**kwargs)) 172 attribs[block.upper()] = a 173 set_runtime("attrib", attribs) 164 174 165 175 def get_style(block, item=None): … … 169 179 styles = get_runtime("styles") 170 180 181 if block.upper() not in styles.keys(): 182 styles = get_runtime("attrib") 183 171 184 if item is None: 172 185 return styles[block.upper()] -
SHX/trunk/SeismicHandler/basics/tools.py
r891 r892 30 30 31 31 32 class Attrib(object): 32 class AttributeBlock(object): 33 lstyles = ["Solid", "ShortDash", "LongDash", "DotDash", "Dot"] 33 34 def __init__(self, **kwargs): 34 35 """ 35 36 Style attribute class. Used in command "FCT SETSTYLE" 36 37 """ 37 self.lstyles = ["Solid", "ShortDash", "LongDash", "DotDash", "Dot"]38 39 38 attrib = AttribDict() 40 39 # set defaults 41 attrib.char height = 840 attrib.charsize = 0.012 42 41 attrib.color = [0, 0, 0] 43 42 attrib.font = "default" … … 47 46 # override with new values 48 47 for k in kwargs: 49 k = k.lower()50 if k not in attrib:48 kl = k.lower() 49 if kl not in attrib.keys(): 51 50 raise NameError("invalid style attribute") 52 51 53 52 v = kwargs[k] 54 if v.is _integer():53 if v.isdigit(): 55 54 v = int(v) 56 elif v.isnumeric(): 57 v = float(v) 58 attrib[k] = v 55 else: 56 try: 57 v = float(v) 58 except: 59 pass 60 attrib[kl] = v 59 61 60 62 self.style = attrib -
SHX/trunk/SeismicHandler/config/runtime.py
r887 r892 105 105 # styles 106 106 "RUNTIME:styles": { 107 "TITLE": {}, 108 "TRCINFO": {}, 109 "TIMEAXIS": {}, 110 "MARK": {}, 111 "ZEROTRCSTYLE": {}, 112 "PM": {}, 113 "MARGINS": [0, 0, 0, 0], 107 "MARGINS": [0.1, 0.1, 0.4, 0.15], 114 108 }, 109 # attribute blocks 110 "RUNTIME:attrib": {} 115 111 }) 116 112 -
SHX/trunk/SeismicHandler/modules/parse.py
r781 r892 639 639 "TOTTRCS": "_internalvars", 640 640 "STATUS": "_internalvars", 641 "TITLESTYLE": "TITLE",642 "TRCINFOSTYLE": "TRCINFO",643 "TIMEAXISSTYLE": "TIMEAXIS",644 "MARKSTYLE": "MARK",645 "ZEROTRCSTYLE": "ZEROTRCSTYLE",646 "PMSTYLE": "PM",641 "TITLESTYLE": '8', 642 "TRCINFOSTYLE": '9', 643 "TIMEAXISSTYLE": '7', 644 "MARKSTYLE": '6', 645 "ZEROTRCSTYLE": '8', 646 "PMSTYLE": '5', 647 647 648 648 # XXX todo -
SHX/trunk/SeismicHandler/modules/wx_.py
r890 r892 18 18 # width of station info 19 19 STATION_INFO = 85 20 # margin at end of trace21 MARGIN = 1520 # margins (top, right, bottom, left) 21 MARGINS = [10, 10, 10, 10] 22 22 # space for time-scale 23 23 TIMESCALE = 40 … … 61 61 self.phasename = "P" 62 62 self.space = None 63 self.interactive = "t ime_trace"63 self.interactive = "trace_time" 64 64 65 65 self._setup() … … 344 344 # horizontal 345 345 if self.traceOrder in [0, 1]: 346 pixel_width = self.width - STATION_INFO - MARGIN 346 pixel_width = self.width - STATION_INFO - MARGINS[1] - MARGINS[3] 347 347 # vertical 348 348 elif self.traceOrder in [2, 3]: 349 pixel_width = self.height - STATION_INFO - MARGIN 349 pixel_width = self.height - STATION_INFO - MARGINS[0] - MARGINS[2] 350 350 351 351 # horizontal plotting 352 352 if self.traceOrder in [0, 1]: 353 timepos -= STATION_INFO + MARGIN[1] 354 # vertical plotting 355 elif self.traceOrder == 2: 356 if self.relativeAxis: 357 timepos -= length + MARGINS[0] 358 else: 359 timepos -= pixel_width + MARGINS[0] 360 timepos *= -1 361 elif self.traceOrder == 3: 353 362 timepos -= STATION_INFO 363 364 if self.timewindow[1] is None: 365 duration = self.relend - self.relstart 366 start = self.relstart 367 else: 368 duration = self.timewindow[1] - self.timewindow[0] 369 start = self.timewindow[0] 370 371 t = timepos * duration / pixel_width + start 372 373 return t 374 375 376 def ScreenToTraceAndTime(self, x, y): 377 """ 378 Returns trace instance and time code derived from cursor 379 position inside graphical panel. 380 """ 381 x, y = self.CalcUnscrolledPosition((x,y)) 382 # horizontal display 383 if self.traceOrder in [0, 1]: 384 tracepos, timepos = y, x 385 # vertical display 386 elif self.traceOrder in [2, 3]: 387 tracepos, timepos = x, y 388 389 # get trace under cursor 390 trace = None 391 theight = self.traceheight // 2 392 for t in self.traces: 393 if tracepos >= t.shx.midpoint - theight and \ 394 tracepos <= t.shx.midpoint + theight: 395 trace = t 396 break 397 398 # get time code 399 if trace and self.relativeAxis: 400 start = trace.stats.starttime 401 end = trace.stats.endtime 402 pixel_width = trace.shx.PlotPixels 403 # only needed for vertical plotting 404 length = self.height - STATION_INFO - MARGINS[0] - MARGINS[2] 405 else: 406 # global time axis 407 start = self.start 408 end = self.end 409 # horizontal 410 if self.traceOrder in [0, 1]: 411 pixel_width = self.width - STATION_INFO - MARGINS[1] - MARGINS[3] 412 # vertical 413 elif self.traceOrder in [2, 3]: 414 pixel_width = self.height - STATION_INFO - MARGINS[0] - MARGINS[2] 415 416 duration = end - start 417 timestamp = None 418 419 # horizontal plotting 420 if self.traceOrder in [0, 1]: 421 timepos -= STATION_INFO + MARGINS[3] 354 422 # vertical plotting 355 423 elif self.traceOrder == 2: … … 362 430 timepos -= STATION_INFO 363 431 364 if self.timewindow[1] is None:365 duration = self.relend - self.relstart366 start = self.relstart367 else:368 duration = self.timewindow[1] - self.timewindow[0]369 start = self.timewindow[0]370 371 t = timepos * duration / pixel_width + start372 373 return t374 375 376 def ScreenToTraceAndTime(self, x, y):377 """378 Returns trace instance and time code derived from cursor379 position inside graphical panel.380 """381 x, y = self.CalcUnscrolledPosition((x,y))382 # horizontal display383 if self.traceOrder in [0, 1]:384 tracepos, timepos = y, x385 # vertical display386 elif self.traceOrder in [2, 3]:387 tracepos, timepos = x, y388 389 # get trace under cursor390 trace = None391 theight = self.traceheight // 2392 for t in self.traces:393 if tracepos >= t.shx.midpoint - theight and \394 tracepos <= t.shx.midpoint + theight:395 trace = t396 break397 398 # get time code399 if trace and self.relativeAxis:400 start = trace.stats.starttime401 end = trace.stats.endtime402 pixel_width = trace.shx.PlotPixels403 # only needed for vertical plotting404 length = self.height - STATION_INFO - MARGIN405 else:406 # global time axis407 start = self.start408 end = self.end409 # horizontal410 if self.traceOrder in [0, 1]:411 pixel_width = self.width - STATION_INFO - MARGIN412 # vertical413 elif self.traceOrder in [2, 3]:414 pixel_width = self.height - STATION_INFO - MARGIN415 416 duration = end - start417 timestamp = None418 419 # horizontal plotting420 if self.traceOrder in [0, 1]:421 timepos -= STATION_INFO422 # vertical plotting423 elif self.traceOrder == 2:424 if self.relativeAxis:425 timepos -= length + MARGIN426 else:427 timepos -= pixel_width + MARGIN428 timepos *= -1429 elif self.traceOrder == 3:430 timepos -= STATION_INFO431 432 432 t = timepos * duration / pixel_width 433 433 timestamp = start + t … … 459 459 # horizontal 460 460 if self.traceOrder in [0, 1]: 461 pixel_width = self.width - STATION_INFO - MARGIN 461 pixel_width = self.width - STATION_INFO - MARGINS[1] - MARGINS[3] 462 462 # vertical 463 463 elif self.traceOrder in [2, 3]: 464 pixel_width = self.height - STATION_INFO - MARGIN 464 pixel_width = self.height - STATION_INFO - MARGINS[0] - MARGINS[2] 465 465 466 466 # relative position inside trace window … … 469 469 # horizontal 470 470 if self.traceOrder in [0, 1]: 471 x, y = self.CalcScrolledPosition( 472 (relpos + STATION_INFO, trace.shx.midpoint)) 471 x, y = self.CalcScrolledPosition(( 472 relpos + STATION_INFO + MARGINS[1] + MARGINS[3], 473 trace.shx.midpoint 474 )) 473 475 # vertical 474 476 elif self.traceOrder == 2: … … 636 638 if self.traceOrder in [0, 1]: 637 639 if numTraces: 638 theight = (height - TIMESCALE ) // numTraces640 theight = (height - TIMESCALE - MARGINS[0] - MARGINS[2]) // numTraces 639 641 else: 640 642 theight = height - TIMESCALE 641 pltwidth = width - STATION_INFO - MARGIN 643 pltwidth = width - STATION_INFO - MARGINS[1] - MARGINS[3] 642 644 elif self.traceOrder in [2, 3]: 643 645 if numTraces: 644 theight = (width - TIMESCALE ) // numTraces646 theight = (width - TIMESCALE - MARGINS[1] - MARGINS[3]) // numTraces 645 647 theight = width - TIMESCALE 646 pltwidth = height - STATION_INFO - MARGIN 648 pltwidth = height - STATION_INFO - MARGINS[0] - MARGINS[2] 647 649 else: 648 650 raise ValueError("unknown trace order %d" % self.traceorder) … … 733 735 # copy trace picture to canvas 734 736 if self.traceOrder in [0, 1]: 735 canvas.Blit(plotoffset + STATION_INFO, i * theight, pltwidth, 736 theight, buffer, 0, 0, wx.AND) 737 canvas.Blit( 738 plotoffset + STATION_INFO + MARGINS[3], 739 i * theight + MARGINS[0], 740 pltwidth, 741 theight, 742 buffer, 743 0, 744 0, 745 wx.AND 746 ) 737 747 elif self.traceOrder == 2: 738 748 canvas.Blit(i * theight, -plotoffset + MARGIN, theight, … … 754 764 # helper lines for debugging 755 765 w, h, _, _ = canvas.GetFullTextExtent(txt) 756 t.shx.midpoint = tmp = i * theight + theight//2 766 t.shx.midpoint = tmp = i * theight + theight//2 + MARGINS[0] 757 767 if self.traceOrder in [0, 1]: 758 canvas.DrawText(txt, 5 , tmp - h // 2)759 canvas.DrawLine(STATION_INFO , tmp, width - MARGIN, tmp)768 canvas.DrawText(txt, 5 + MARGINS[3], tmp - h // 2) 769 canvas.DrawLine(STATION_INFO + MARGINS[3], tmp, width - MARGINS[1], tmp) 760 770 # canvas.SetPen(wx.Pen('Red', 1, wx.LONG_DASH)) 761 771 # canvas.DrawLine(STATION_INFO, tmp + theight // 2, … … 790 800 if self.traceOrder in [0, 1]: 791 801 PARTS = 5. # axis split into X parts 792 length = width - MARGIN - STATION_INFO # pixel length of time axis793 fixpos = height - TIMESCALE + 10# here: y coordinate794 varpos_start = STATION_INFO # here: x start802 length = width - MARGINS[1] - MARGINS[3] - STATION_INFO # pixel length of time axis 803 fixpos = height - TIMESCALE - MARGINS[2] # here: y coordinate 804 varpos_start = STATION_INFO + MARGINS[3] # here: x start 795 805 elif self.traceOrder in [2, 3]: 796 806 PARTS = 4.
Note: See TracChangeset
for help on using the changeset viewer.