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.center()
+ 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 center( self ) :
center_x , center_y = self.win_x / 2 , self.win_y / 2
return center_x , center_y
- def plot( self , pixmap , coords , colorname , radius=3 ) :
+ def plot( self , coords , colorname , radius=3 ) :
center_x , center_y = self.center()
- gc = pixmap.new_gc()
- gc.foreground = pixmap.get_colormap().alloc_color( colorname )
+ gc = self.window.new_gc()
+ gc.foreground = self.get_colormap().alloc_color( colorname )
dest_x , dest_y = self.gps2pix( coords , ( center_x , center_y ) )
- pixmap.draw_rectangle(gc, True , dest_x , dest_y , radius , radius )
+ self.window.draw_rectangle(gc, True , dest_x , dest_y , radius , radius )
def draw_paths( self ) :
- pixmap,mask = self.get_pixbuf().render_pixmap_and_mask()
-
filename = "/tmp/wiscan_gui.info"
fd = open( filename )
for line in fd.readlines() :
values = line.split()
if values[1] == "FIX" :
- self.plot( pixmap , ( float(values[5]) , float(values[6]) ) , "red" )
+ self.plot( ( float(values[5]) , float(values[6]) ) , "red" )
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 ) :
- pixmap,mask = self.get_pixbuf().render_pixmap_and_mask()
-
db = wifimap.db.database( os.path.join( self.conf.homedir , self.conf.dbname ) )
db.open()
# NOTE : Intervals for query are just educated guesses to fit in window
lat , lon = self.conf.lat , self.conf.lon
for ap in db.db.execute( "SELECT lat,lon FROM ap" ) :
- self.plot( pixmap , ( ap[0] , ap[1] ) , "blue" )
+ self.plot( ( ap[0] , ap[1] ) , "blue" )
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