geography : add preferences for animation in geoperson.

svn: r17406
This commit is contained in:
Serge Noiraud 2011-05-04 19:02:08 +00:00
parent 75d144e6b5
commit 299bef1c74
3 changed files with 82 additions and 18 deletions

View File

@ -29,6 +29,8 @@
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gen.ggettext import gettext as _ from gen.ggettext import gettext as _
import gen.lib import gen.lib
import os
import const
import osmgpsmap import osmgpsmap
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -36,6 +38,7 @@ import osmgpsmap
# Constants # Constants
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
GEOGRAPHY_PATH = os.path.join(const.HOME_DIR, "maps")
ICONS = { ICONS = {
gen.lib.EventType.BIRTH : 'gramps-geo-birth', gen.lib.EventType.BIRTH : 'gramps-geo-birth',

View File

@ -68,13 +68,6 @@ from config import config
from gui.editors import EditPlace, EditEvent, EditFamily, EditPerson from gui.editors import EditPlace, EditEvent, EditFamily, EditPerson
from gui.selectors.selectplace import SelectPlace from gui.selectors.selectplace import SelectPlace
#-------------------------------------------------------------------------
#
# Constants
#
#-------------------------------------------------------------------------
GEOGRAPHY_PATH = os.path.join(const.HOME_DIR, "maps")
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Functions # Functions
@ -692,7 +685,7 @@ class GeoGraphyView(osmGpsMap, NavigationView):
""" """
The function which is used to create the configuration window. The function which is used to create the configuration window.
""" """
return [self.map_options] return [self.map_options, self.specific_options]
def config_zoom_and_position(self, client, cnxn_id, entry, data): def config_zoom_and_position(self, client, cnxn_id, entry, data):
""" """
@ -717,6 +710,18 @@ class GeoGraphyView(osmGpsMap, NavigationView):
self.set_crosshair(config.get("geography.show_cross")) self.set_crosshair(config.get("geography.show_cross"))
pass pass
def specific_options(self, configdialog):
"""
Add specific entry to the preference menu.
Must be done in the associated view.
"""
table = gtk.Table(2, 2)
table.set_border_width(12)
table.set_col_spacings(6)
table.set_row_spacings(6)
configdialog.add_text(table, _('Nothing for this view.'), 1)
return _('Specific parameters'), table
def map_options(self, configdialog): def map_options(self, configdialog):
""" """
Function that builds the widget in the configuration dialog Function that builds the widget in the configuration dialog

View File

@ -67,6 +67,7 @@ from gui.selectors.selectplace import SelectPlace
from Filters.SideBar import PersonSidebarFilter from Filters.SideBar import PersonSidebarFilter
from gui.views.navigationview import NavigationView from gui.views.navigationview import NavigationView
import Bookmarks import Bookmarks
import constants
from Utils import navigation_label from Utils import navigation_label
from maps.geography import GeoGraphyView from maps.geography import GeoGraphyView
@ -114,6 +115,28 @@ class GeoPerson(GeoGraphyView):
""" """
The view used to render person map. The view used to render person map.
""" """
CONFIGSETTINGS = (
('geography.path', constants.GEOGRAPHY_PATH),
('geography.zoom', 10),
('geography.show_cross', True),
('geography.lock', False),
('geography.center-lat', 0.0),
('geography.center-lon', 0.0),
#('geography.gps_mode', GPS_DISABLED),
#('geography.gps_update_rate', float(1.0)),
#('geography.max_gps_zoom', 16),
#('geography.gps_increment', GPS_INCREMENT),
('geography.map_service', constants.OPENSTREETMAP),
# specific to geoperson :
('geography.steps', 20),
('geography.maximum_lon_lat', 30),
('geography.speed', 100),
)
def __init__(self, pdata, dbstate, uistate, nav_group=0): def __init__(self, pdata, dbstate, uistate, nav_group=0):
GeoGraphyView.__init__(self, _("Person places map"), GeoGraphyView.__init__(self, _("Person places map"),
@ -212,9 +235,10 @@ class GeoPerson(GeoGraphyView):
self.osm.gps_add(startlat, startlon, heading) self.osm.gps_add(startlat, startlon, heading)
endlat = float(marks[ni][3]) endlat = float(marks[ni][3])
endlon = float(marks[ni][4]) endlon = float(marks[ni][4])
max_lon_lat = float(self._config.get("geography.maximum_lon_lat")) / 10
if stepyear < 9000: if stepyear < 9000:
if (( abs(float(endlat) - float(startlat)) > 3.0 ) or if (( abs(float(endlat) - float(startlat)) > max_lon_lat ) or
( abs(float(endlon) - float(startlon)) > 3.0 )): ( abs(float(endlon) - float(startlon)) > max_lon_lat )):
self.large_move = True self.large_move = True
stepyear = 9000 stepyear = 9000
else: else:
@ -227,18 +251,16 @@ class GeoPerson(GeoGraphyView):
if years < 1: if years < 1:
years = 1 years = 1
if stepyear > 8999: if stepyear > 8999:
latstep = ( endlat - startlat ) / 30 latstep = ( endlat - startlat ) / self._config.get("geography.steps")
lonstep = ( endlon - startlon ) / 30 lonstep = ( endlon - startlon ) / self._config.get("geography.steps")
startlat += ( latstep * (stepyear - 8999) ) startlat += ( latstep * (stepyear - 8999) )
startlon += ( lonstep * (stepyear - 8999) ) startlon += ( lonstep * (stepyear - 8999) )
print "shift : ", latstep, lonstep
else: else:
latstep = ( endlat - startlat ) / years latstep = ( endlat - startlat ) / years
lonstep = ( endlon - startlon ) / years lonstep = ( endlon - startlon ) / years
stepyear = 1 if stepyear < 1 else stepyear stepyear = 1 if stepyear < 1 else stepyear
startlat += ( latstep * stepyear ) startlat += ( latstep * stepyear )
startlon += ( lonstep * stepyear ) startlon += ( lonstep * stepyear )
print "position : ", startlat, startlon, stepyear
self.osm.gps_add(startlat, startlon, heading) self.osm.gps_add(startlat, startlon, heading)
stepyear += 1 stepyear += 1
difflat = round(( startlat - endlat ) if startlat > endlat else \ difflat = round(( startlat - endlat ) if startlat > endlat else \
@ -249,13 +271,14 @@ class GeoPerson(GeoGraphyView):
i += 1 i += 1
self.large_move = False self.large_move = False
stepyear = 1 stepyear = 1
# 100ms => 1s per 10 years. # if geography.speed = 100 => 100ms => 1s per 10 years.
# For a 100 years person, it takes 10 secondes. # For a 100 years person, it takes 10 secondes.
# if large_move, one step is the difflat or difflon / 30 # if large_move, one step is the difflat or difflon / geography.steps
# in this case, stepyear is >= 9000 # in this case, stepyear is >= 9000
# large move means longitude or latitude differences greater than 3.0 # large move means longitude or latitude differences greater than geography.maximum_lon_lat
# degrees. # degrees.
glib.timeout_add(100, self.animate, menu, marks, i, stepyear) glib.timeout_add(self._config.get("geography.speed"), self.animate,
menu, marks, i, stepyear)
return False return False
def _createmap(self,obj): def _createmap(self,obj):
@ -454,3 +477,36 @@ class GeoPerson(GeoGraphyView):
""" """
return (("Person Filter Gramplet",), return (("Person Filter Gramplet",),
()) ())
def specific_options(self, configdialog):
"""
Add specific entry to the preference menu.
Must be done in the associated view.
"""
table = gtk.Table(2, 2)
table.set_border_width(12)
table.set_col_spacings(6)
table.set_row_spacings(6)
configdialog.add_text(table,
_('Animation speed in milliseconds (big value means slower)'),
1)
self.config_size_slider = configdialog.add_slider(table,
"",
2, 'geography.speed',
(100, 1000))
configdialog.add_text(table,
_('How many steps between two markers when we are on large move ?'),
3)
self.config_size_slider = configdialog.add_slider(table,
"",
4, 'geography.steps',
(10, 100))
configdialog.add_text(table,
_('The minimum latitude/longitude to select large move.\n'
'The value is in tenth of degree.'),
5)
self.config_size_slider = configdialog.add_slider(table,
"",
6, 'geography.maximum_lon_lat',
(5, 50))
return _('The animation parameters'), table