Geography : animation preference parameters.

svn: r17504
This commit is contained in:
Serge Noiraud 2011-05-15 17:39:17 +00:00
parent c60e7422b3
commit 9268cc0319
3 changed files with 100 additions and 15 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

@ -69,13 +69,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
@ -717,7 +710,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):
""" """
@ -742,6 +735,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"),
@ -208,9 +231,18 @@ class GeoPerson(GeoGraphyView):
heading = 1 heading = 1
if index == 0 and stepyear == 0: if index == 0 and stepyear == 0:
self.remove_all_gps() self.remove_all_gps()
self.large_move = False
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 (( abs(float(endlat) - float(startlat)) > max_lon_lat ) or
( abs(float(endlon) - float(startlon)) > max_lon_lat )):
self.large_move = True
stepyear = 9000
else:
self.large_move = False
# year format = YYYYMMDD ( for sort ) # year format = YYYYMMDD ( for sort )
startyear = str(marks[i][6])[0:4] startyear = str(marks[i][6])[0:4]
endyear = str(marks[ni][6])[0:4] endyear = str(marks[ni][6])[0:4]
@ -218,11 +250,17 @@ class GeoPerson(GeoGraphyView):
years = int(endyear) - int(startyear) years = int(endyear) - int(startyear)
if years < 1: if years < 1:
years = 1 years = 1
latstep = ( endlat - startlat ) / years if stepyear > 8999:
lonstep = ( endlon - startlon ) / years latstep = ( endlat - startlat ) / self._config.get("geography.steps")
stepyear = 1 if stepyear < 1 else stepyear lonstep = ( endlon - startlon ) / self._config.get("geography.steps")
startlat += ( latstep * stepyear ) startlat += ( latstep * (stepyear - 8999) )
startlon += ( lonstep * stepyear ) startlon += ( lonstep * (stepyear - 8999) )
else:
latstep = ( endlat - startlat ) / years
lonstep = ( endlon - startlon ) / years
stepyear = 1 if stepyear < 1 else stepyear
startlat += ( latstep * stepyear )
startlon += ( lonstep * 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 \
@ -231,10 +269,16 @@ class GeoPerson(GeoGraphyView):
( endlon - startlon ), 8) ( endlon - startlon ), 8)
if ( difflat == 0.0 and difflon == 0.0 ): if ( difflat == 0.0 and difflon == 0.0 ):
i += 1 i += 1
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.
glib.timeout_add(100, self.animate, menu, marks, i, stepyear) # if large_move, one step is the difflat or difflon / geography.steps
# in this case, stepyear is >= 9000
# large move means longitude or latitude differences greater than geography.maximum_lon_lat
# degrees.
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):
@ -446,3 +490,36 @@ class GeoPerson(GeoGraphyView):
""" """
return (("Person Filter",), return (("Person Filter",),
()) ())
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