self.composeMap()
self.show()
-class simpleMapWidget ( AbstractmapWidget , gtk.Image ) :
+class simpleMapWidget ( AbstractmapWidget , gtk.DrawingArea ) :
def __init__ ( self , config , map_size=(800,480) ) :
AbstractmapWidget.__init__( self , config , map_size )
- gtk.Image.__init__(self)
+ gtk.DrawingArea.__init__(self)
+ self.set_size_request(map_size[0] , map_size[1])
- p = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, self.win_x, self.win_y)
- self.set_from_pixbuf(p)
-
+ self.connect("expose-event", self.expose)
+
+ def expose(self, area, event):
self.composeMap()
+ # FIXME : The two below could slow the displaying
+ self.draw_paths()
+ self.plot_APs()
def composeMap( self ) :
center_x , center_y = self.win_x / 2 , self.win_y / 2
center_x -= self.refpix_x
center_y -= self.refpix_y
+ gc = self.style.fg_gc[gtk.STATE_NORMAL]
+
# Ranges should be long enough as to fill the screen
# Maybe they should be decided based on self.win_x, self.win_y
for i in range(-3,4) :
size_y = self.win_y - dest_y
if ( size_x > 0 and size_y > 0 ) and ( init_x < self.tile_size and init_y < self.tile_size ) :
- pixbuf.copy_area( init_x, init_y, size_x, size_y, self.get_pixbuf(), dest_x , dest_y )
+ self.window.draw_pixbuf( gc, pixbuf, init_x, init_y, dest_x, dest_y, size_x, size_y )
del(pixbuf)
- self.draw_paths()
- self.plot_APs()
-
def draw_paths( self ) :
center_x , center_y = self.win_x / 2 , self.win_y / 2
center_x -= self.refpix_x
center_y -= self.refpix_y
- pixmap,mask = self.get_pixbuf().render_pixmap_and_mask()
- red = pixmap.new_gc()
- red.foreground = pixmap.get_colormap().alloc_color("red")
- green = pixmap.new_gc()
- green.foreground = pixmap.get_colormap().alloc_color("green")
- blue = pixmap.new_gc()
- blue.foreground = pixmap.get_colormap().alloc_color("blue")
+ red = self.window.new_gc()
+ red.foreground = self.get_colormap().alloc_color("red")
filename = "data/wiscan_gui.info.old"
fd = open( filename )
values = line.split()
if values[1] == "FIX" :
dest_x , dest_y = self.gps2pix( ( float(values[5]) , float(values[6]) ) , ( center_x , center_y ) )
- pixmap.draw_rectangle(blue, True , dest_x , dest_y , 3 , 3 )
+ self.window.draw_rectangle(red, True , dest_x , dest_y , 3 , 3 )
fd.close()
- self.get_pixbuf().get_from_drawable( pixmap , pixmap.get_colormap() , 0, 0 , 0 , 0 , self.win_x, self.win_y )
-
def plot_APs( self ) :
center_x , center_y = self.win_x / 2 , self.win_y / 2
center_x -= self.refpix_x
center_y -= self.refpix_y
- pixmap,mask = self.get_pixbuf().render_pixmap_and_mask()
- blue = pixmap.new_gc()
- blue.foreground = pixmap.get_colormap().alloc_color("blue")
+ blue = self.window.new_gc()
+ blue.foreground = self.get_colormap().alloc_color("blue")
db = wifimap.db.database( os.path.join( self.conf.homedir , self.conf.dbname ) )
db.open()
for ap in db.db.execute( "SELECT * FROM ap where lat/n>%f and lat/n<%f and lon/n>%f and lon/n<%f" % ( lat - 0.003 , lat + 0.003 , lon - 0.007 , lon + 0.007 ) ) :
if ap[3] > 1 :
dest_x , dest_y = self.gps2pix( ( ap[4]/ap[3] , ap[5]/ap[3] ) , ( center_x , center_y ) )
- pixmap.draw_rectangle(blue, True , dest_x , dest_y , 3 , 3 )
+ self.window.draw_rectangle(blue, True , dest_x , dest_y , 3 , 3 )
db.close()
- self.get_pixbuf().get_from_drawable( pixmap , pixmap.get_colormap() , 0, 0 , 0 , 0 , self.win_x, self.win_y )
-
class mapWidget ( simpleMapWidget , interactiveMapWidget ) :
pass
+