class mapWidget ( wifimap.view.AbstractmapWidget , gtk.Image ) :
- def __init__ ( self , config ) :
- wifimap.view.AbstractmapWidget.__init__( self , config )
+ def __init__ ( self , config , map_size=(800,480) ) :
+ wifimap.view.AbstractmapWidget.__init__( self , config , map_size )
gtk.Image.__init__(self)
def draw_paths( self ) :
+ center_x , center_y = self.win_x / 2 , self.win_y / 2
+
+ # To get the central pixel in the window center, we must shift to the tile origin
+ 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")
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
+
+ # To get the central pixel in the window center, we must shift to the tile origin
+ 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")
+
+ 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 * 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 )
+ db.close()
+
+ self.get_pixbuf().get_from_drawable( pixmap , pixmap.get_colormap() , 0, 0 , 0 , 0 , self.win_x, self.win_y )
+
if hildon :
else :
print "UNKNOWN",event.keyval
- def __init__(self):
+ def __init__( self , map_size=(800,480) ) :
self.connect("destroy", self.destroy)
self.connect("key-press-event", self.on_key_press)
- vbox = gtk.VBox(False, 0)
- self.add( vbox )
+ self.vbox = gtk.VBox(False, 0)
# To get explicit GDK_BUTTON_PRESS instead of paired GDK_LEAVE_NOTIFY & GDK_ENTER_NOTIFY
# self.add_events(gtk.gdk.BUTTON_MOTION_MASK | gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK | gtk.gdk.POINTER_MOTION_MASK)
self.connect('button_release_event', self.release_event)
#
self.config = wifimap.config.Configuration()
- self.map = mapWidget( self.config )
- vbox.pack_end( self.map , True , True , 5)
+ self.map = mapWidget( self.config , map_size )
+ self.vbox.pack_end( self.map , True , True , 5)
- self.create_menu( vbox )
-
- # and the window
- self.show_all()
-
- self.size_x , self.size_y = 800 , 480
+ self.size_x , self.size_y = map_size
self.click_x , self.click_y = None , None
def zoomdialog ( self , widget ) :
def __init__(self):
hildon.Window.__init__( self )
AbstractMapWindow.__init__(self)
+ self.add( self.vbox )
+ self.create_menu( self.vbox )
+ self.show_all()
def create_menu ( self , vbox ) :
def __init__(self):
gtk.Window.__init__( self , gtk.WINDOW_TOPLEVEL )
AbstractMapWindow.__init__(self)
+ self.add( self.vbox )
+ self.create_menu( self.vbox )
+ self.show_all()
+
self.resize( self.size_x , self.size_y)
def create_menu ( self , vbox ) :