Changeset 637 for trunk/py

Show
Ignore:
Timestamp:
07/26/08 08:52:19 (4 months ago)
Author:
asc
Message:

start using pwmarker

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/py/wscompose/pinwin.py

    r591 r637  
    233233             
    234234        # 
     235 
     236        for data in self.ctx['markers'] : 
     237            self.draw_shadow(img, data, bleed_x, bleed_y) 
    235238         
    236239        for data in self.ctx['markers'] : 
  • trunk/py/wscompose/plotting.py

    r593 r637  
    99 
    1010import wscompose 
    11 import wscompose.markers 
     11import wscompose.pwmarker 
    1212import string 
    1313import random 
     
    7575             
    7676            mrk = self.load_marker(w, h, a) 
    77  
    7877            pt = self.latlon_to_point(mrk_data['latitude'], mrk_data['longitude']) 
    7978             
     
    9190            x1 = mrk_data['x'] - int(mrk.x_offset) 
    9291            y1 = mrk_data['y'] - int(mrk.y_offset) 
    93              
    94             x2 = x1 + (w + mrk.padding
    95             y2 = y1 + (h + mrk.padding
     92 
     93            x2 = x1 + (w + (mrk.x_padding * 2)
     94            y2 = y1 + (h + (mrk.y_padding * 2)
    9695             
    9796            mrk_data['canvas'] = (x1, y1, x2, y2) 
     
    164163 
    165164        # print "does %s overlap %s" % (cur_label, test_label) 
     165        # print "current %s" % current 
    166166         
    167167        # first, ensure that some part of 'current' 
     
    232232             
    233233        for data in self.ctx['markers'] : 
     234            self.draw_shadow(img, data) 
     235 
     236        for data in self.ctx['markers'] : 
    234237            self.draw_marker(img, data) 
    235238 
     
    237240     
    238241    # ########################################################## 
    239          
    240     def draw_marker (self, img, mrk_data, bleed_x=0, bleed_y=0) : 
     242 
     243    def draw_shadow (self, img, mrk_data, bleed_x=0, bleed_y=0) : 
    241244 
    242245        w = mrk_data['width'] 
     
    245248         
    246249        mrk = self.load_marker(w, h, a) 
    247                                          
     250         
    248251        loc = ModestMaps.Geo.Location(mrk_data['latitude'], mrk_data['longitude']) 
    249252        pt = self.ctx['map'].locationPoint(loc)             
     
    257260        my = mrk_data['y'] - int(mrk.y_offset) 
    258261 
    259         # note the +2 which is necessary once we  
    260         # paste the pinwin/alpha with an offset 
    261         # of (1,1) - see also : markers.py 
    262          
    263         dx = mx + mrk.x_padding + 2 
    264         dy = my + mrk.y_padding + 2 
     262        dx = mx + mrk.x_padding 
     263        dy = my + mrk.y_padding 
    265264 
    266265        # 
    267266 
    268         img.paste(mrk.fh(), (mx, my), mrk.fh()) 
     267        shadow = mrk.fh('shadow') 
     268        img.paste(shadow, (mx, my), shadow) 
    269269         
    270270        mrk_data['x_fill'] = dx 
    271271        mrk_data['y_fill'] = dy         
     272 
     273    # ########################################################## 
     274     
     275    def draw_marker (self, img, mrk_data, bleed_x=0, bleed_y=0) : 
     276 
     277        w = mrk_data['width'] 
     278        h = mrk_data['height'] 
     279        a = mrk_data['adjust_cone_height'] 
     280         
     281        mrk = self.load_marker(w, h, a) 
     282         
     283        loc = ModestMaps.Geo.Location(mrk_data['latitude'], mrk_data['longitude']) 
     284        pt = self.ctx['map'].locationPoint(loc)             
     285 
     286        # 
     287         
     288        mrk_data['x'] = int(pt.x) + bleed_x 
     289        mrk_data['y'] = int(pt.y) + bleed_y 
     290 
     291        mx = mrk_data['x'] - int(mrk.x_offset) 
     292        my = mrk_data['y'] - int(mrk.y_offset) 
     293         
     294        dx = mx + mrk.x_padding 
     295        dy = my + mrk.y_padding 
     296 
     297        # 
     298 
     299        pinwin = mrk.fh('pinwin') 
     300        img.paste(pinwin, (mx, my), pinwin) 
     301         
     302        mrk_data['x_fill'] = dx 
     303        mrk_data['y_fill'] = dy         
     304 
    272305            
    273306    # ########################################################## 
     
    291324 
    292325        key = "%s-%s-%s" % (w, h, a) 
    293  
     326         
    294327        if not self.__markers__.has_key(key) : 
    295             self.__markers__[key] = wscompose.markers.pinwin(w, h, a) 
    296  
     328            mrk = wscompose.pwmarker.PinwinMarker(w, h, a) 
     329            mrk.draw() 
     330             
     331            self.__markers__[key] = mrk 
     332             
    297333        return self.__markers__[key] 
    298334