Path: blob/main/tools/contributed/sumopy/coremodules/demand/wxgui.py
169689 views
# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo1# Copyright (C) 2016-2025 German Aerospace Center (DLR) and others.2# SUMOPy module3# Copyright (C) 2012-2021 University of Bologna - DICAM4# This program and the accompanying materials are made available under the5# terms of the Eclipse Public License 2.0 which is available at6# https://www.eclipse.org/legal/epl-2.0/7# This Source Code may also be made available under the following Secondary8# Licenses when the conditions for such availability set forth in the Eclipse9# Public License 2.0 are satisfied: GNU General Public License, version 210# or later which is available at11# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html12# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later1314# @file wxgui.py15# @author Joerg Schweizer16# @date 20121718import os19import wx20import numpy as np2122from agilepy.lib_wx.modulegui import ModuleGui23from agilepy.lib_wx.ogleditor import *24from agilepy.lib_base.processes import Process25from agilepy.lib_wx.processdialog import ProcessDialog2627from coremodules.network import routing28from coremodules.scenario.scenario import load_scenario2930import demand31import turnflows32import origin_to_destination_wxgui as odgui33import turnflows_wxgui as turnflowsgui34import virtualpop_wxgui as virtualpopgui35import detectorflows_wxgui as detectorflowsgui36import publictransportservices_wxgui as pt373839class TripDrawings(Polygons):40def __init__(self, facilities, parent, **kwargs):4142Polygons.__init__(self, 'facilitydraws', parent,43name='Facility drawings',44linewidth=1,45detectwidth=3.0,46**kwargs)4748self.delete('vertices')4950self.add(cm.AttrConf('color_facility_default', np.array([0.921875, 0.78125, 0.4375, 1.0], np.float32),51groupnames=['options'],52perm='wr',53metatype='color',54name='Default color',55info='Default facility color.',56))5758self.set_facilities(facilities)5960def get_netelement(self):61return self._facilities6263def get_vertices_array(self):64return self._facilities.shapes.value[self._inds_map]6566def set_facilities(self, facilities):67# print '\nset_facilities',facilities.get_ids()68self._facilities = facilities69if len(self) > 0:70self.del_rows(self.get_ids())7172ids = self._facilities.get_ids()73self._inds_map = self._facilities.get_inds(ids)74self.add_rows(ids=ids)75self.update()7677def update(self, is_update=True):78# assumes that arrsy structure did not change79# print 'FacilityDrawings.update'80n = len(self)81self.colors.value[:] = np.ones((n, 4), np.float32)*self.color_facility_default.value82self.colors_highl.value[:] = self._get_colors_highl(self.colors.value)8384landusetypes = self._facilities.get_landusetypes()85ids_landusetype = self._facilities.ids_landusetype.value86for id_landusetype in landusetypes.get_ids():87#inds = np.flatnonzero(ids_landusetype == id_landusetype)88#color = landusetypes.colors[id_landusetype]89#self.colors.value[self._inds_map[inds]] = color90self.colors.value[self._inds_map[np.flatnonzero(91ids_landusetype == id_landusetype)]] = landusetypes.colors[id_landusetype]9293if is_update:94self._update_vertexvbo()95self._update_colorvbo()969798class RouteDrawings(Polygons):99def __init__(self, zones, parent, **kwargs):100101Polygons.__init__(self, 'zonedraws', parent,102name='Transport assignment zone drawings',103linewidth=4,104detectwidth=5.0,105**kwargs)106107self.delete('vertices')108109self.add(cm.AttrConf('color_default', np.array([0.3, 0.9, 0.5, 0.8], dtype=np.float32),110groupnames=['options'],111perm='wr',112metatype='color',113name='Default color',114info='Default facility color.',115))116117self.set_netelement(zones)118119def get_netelement(self):120return self._zones121122def get_vertices_array(self):123if self._is_not_synched:124self._inds_map = self._zones.get_inds(self._zones.get_ids())125self._is_not_synched = False126return self._zones.shapes.value[self._inds_map]127128def set_netelement(self, zones):129# print '\nset_facilities',facilities.get_ids()130self._zones = zones131if len(self) > 0:132self.del_rows(self.get_ids())133134ids = self._zones.get_ids()135#self._inds_map = self._zones.get_inds(ids)136self.add_rows(ids=ids)137138# plugins to keep grapgics syncronized with netelements139zones.shapes.plugin.add_event(cm.EVTADDITEM, self.on_add_element)140zones.plugin.add_event(cm.EVTDELITEM, self.on_del_element)141142self._id_target = -1143self.update()144145def update(self, is_update=True):146# assumes that arrsy structure did not change147# print 'FacilityDrawings.update'148n = len(self)149self.colors.value[:] = np.ones((n, 4), np.float32)*self.color_default.value150self.colors_highl.value[:] = self._get_colors_highl(self.colors.value)151152if is_update:153self.update_internal()154155def update_internal(self):156# print 'update_internal'157# print ' len(self),len(self._zones)',len(self),len(self._zones)158self._is_not_synched = True159self._update_vertexvbo()160self._update_colorvbo()161162def make_zone(self, shape, color):163# print 'make_zone shape',shape,type(shape)164return self._zones.make(shape=shape)165166def on_add_element(self, shapes, ids):167# print 'on_add_element',shapes.attrname,ids168if shapes == self._zones.shapes:169self._id_target = ids[0]170self.add_row(_id=self._id_target,171colors=self.color_default.value,172colors_highl=self._get_colors_highl(self.color_default.value)173)174#self._inds_map = self._zones.get_inds(self._zones.get_ids())175# self._update_vertexvbo()176# self._update_colorvbo()177178def begin_animation(self, id_target):179# print 'ZoneDrawings.begin_animation zones.shapes=\n',id_target,self._id_target, self._zones.shapes[id_target]180if self._id_target == -1:181self._id_target = id_target182self._drawobj_anim = self.parent.get_drawobj_by_ident(self._ident_drawobj_anim)183self.id_anim = self._drawobj_anim.add_drawobj(self._zones.shapes[self._id_target],184self.color_anim.value,185)186# print 'begin_animation',self.ident,_id,self._drawobj_anim187return True188189def end_animation(self, is_del_last_vert=False):190# print 'ZoneDrawings.end_animation',self.ident,self._id_target,self.id_anim191192# print ' verices =',self._drawobj_anim.vertices[self.id_anim]193# print ' self._drawobj_anim.vertices[self.id_anim]=',self._drawobj_anim.vertices[self.id_anim]194shape = self._drawobj_anim.vertices[self.id_anim]195self._zones.shapes[self._id_target] = shape196self._zones.coords[self._id_target] = self._zones.get_coords_from_shape(shape)197198self.del_animation()199# print ' self.get_vertices_array()=\n',self.get_vertices_array()200# self._drawobj_anim.del_drawobj(self.id_anim)201self.update_internal()202#self._inds_map = self._zones.get_inds(self._zones.get_ids())203# self._update_vertexvbo()204# self._update_colorvbo()205return True206207def del_elem(self, id_zone):208"""209Deletes an element from network and then in on canvas210through callback on_del_element211"""212# print 'del_elem'213# print ' len(self),len(self._zones)',len(self),len(self._zones)214215self._zones.del_element(id_zone)216217def on_del_element(self, shapes, ids):218"""219callback from netelement220"""221# print 'on_del_element',shapes.attrname,ids,self._id_target222# print ' len(self),len(self._zones)',len(self),len(self._zones)223# print ' verices =',self._drawobj_anim.vertices[self.id_anim]224self._is_not_synched = True225self.del_drawobj(ids[0])226# print ' len(self),len(self._zones)',len(self),len(self._zones)227# wx.CallAfter(self.update_internal)228# self.update_internal()229# print ' after CallAfter'230# print ' len(self),len(self._zones)',len(self),len(self._zones)231return True232233def del_animation(self, is_del_main=False):234# print 'end_animation',self.ident,_id,self._drawobj_anim235self._drawobj_anim.del_drawobj(self.id_anim)236self._drawobj_anim = None237238if is_del_main:239# self.del_drawobj(self._id_target)240# delete first element from net, which will241# call back on_del_netelement where the main drawobj is deleted242self.del_elem(self._id_target)243244self._id_target = -1245self.id_anim = -1246return True247248249class WxGui(turnflowsgui.TurnflowWxGuiMixin,250odgui.OdFlowsWxGuiMixin,251virtualpopgui.VirtualpopWxGuiMixin,252detectorflowsgui.DetectorflowsWxGuiMixin,253pt.PublicTransportWxGuiMixin,254ModuleGui):255256"""Contains functions that communicate between the widgets of the main wx gui257and the functions of the plugin.258"""259260def __init__(self, ident):261self._demand = None262self._init_common(ident, priority=1000,263icondirpath=os.path.join(os.path.dirname(__file__), 'images'))264265def get_module(self):266return self._demand267268def get_scenario(self):269return self._mainframe.get_modulegui('coremodules.scenario').get_scenario()270271def get_neteditor(self):272return self._mainframe.get_modulegui('coremodules.network').get_neteditor()273274def init_widgets(self, mainframe):275"""276Set mainframe and initialize widgets to various places.277"""278self._mainframe = mainframe279#self._neteditor = mainframe.add_view("Network", Neteditor)280281# mainframe.browse_obj(self._module)282self.make_menu()283self.make_toolbar()284285def refresh_widgets(self):286"""287Check through mainframe what the state of the application is288and reset widgets. For exampe enable/disable widgets289dependent on the availability of data.290"""291scenario = self.get_scenario()292# print 'demand refresh_widgets',scenario.net293is_refresh = False294if self._demand != scenario.demand:295del self._demand296self._demand = scenario.demand297is_refresh = True298# self.get_neteditor().get_toolbox().add_toolclass(AddZoneTool)299# print ' odintervals',self._demand.odintervals#,self.odintervals.times_start300# print ' ',dir(self._demand.odintervals)301302elif self._demand.is_modified():303is_refresh = True304305self.refresh_odflow(is_refresh)306self.refresh_turnflow(is_refresh)307self.refresh_pt(is_refresh)308309def make_menu(self):310# print 'make_menu'311menubar = self._mainframe.menubar312menubar.append_menu('demand')313314menubar.append_item('demand/browse',315self.on_browse_obj, # common function in modulegui316info='View and browse demand in object panel.',317bitmap=self.get_agileicon('icon_browse_24px.png'), # ,318)319# ----------------------------------------------------------------------320menubar.append_menu('demand/vehicles',321bitmap=self.get_icon("vehicle_24px.png"),322)323324menubar.append_item('demand/vehicles/clear vehicle types',325self.on_clear_vtypes,326info='Remove all vehicle types .',327bitmap=wx.ArtProvider.GetBitmap(wx.ART_DELETE, wx.ART_MENU),328)329330menubar.append_item('demand/vehicles/import vehicle types from xml...',331self.on_import_vtypes_xml,332info='Import vehicle types from xml file',333bitmap=self.get_agileicon("Document_Import_24px.png"),334)335menubar.append_item('demand/vehicles/export vehicle types from xml...',336self.on_export_vtypes,337bitmap=self.get_agileicon("Document_Export_24px.png"),338)339menubar.append_item('demand/vehicles/load defaults',340self.on_load_vtypes_defaults,341info='Load default vehicle types, removing all existing vehicle types.',342#bitmap = self.get_icon("route3_24px.png"),343)344345# ----------------------------------------------------------------------346self.add_menu_odflows(menubar)347# ----------------------------------------------------------------------348self.add_menu_turnflow(menubar)349# ----------------------------------------------------------------------350self.add_menu_detectorflow(menubar)351# ----------------------------------------------------------------------352self.add_menu_pt(menubar)353# ----------------------------------------------------------------------354355menubar.append_menu('demand/trips and routes',356bitmap=self.get_icon("trip3_24px.png"),357)358359menubar.append_item('demand/trips and routes/quickroute with fastest path',360self.on_route,361bitmap=self.get_icon("route3_24px.png"),362)363# menubar.append_item( 'demand/trips and routes/trips to routes with fastest path, del. disconnected',364# self.on_route_del_disconnected,365# bitmap = self.get_icon("route3_24px.png"),366# )367368menubar.append_item('demand/trips and routes/duarouter fastest route',369self.on_duaroute,370bitmap=self.get_icon("route3_24px.png"),371)372373menubar.append_item('demand/trips and routes/duarouter stochastic assignment...',374self.on_duaroute_stochastic,375bitmap=self.get_icon("route3_24px.png"),376)377378# menubar.append_item( 'demand/trips and routes/trips to routes with congested net ...',379# self.on_route_congested,380# bitmap = self.get_icon("route3_24px.png"),381# )382383menubar.append_item('demand/trips and routes/generate taxi trips...',384self.on_generate_taxitrips,385)386387menubar.append_item('demand/trips and routes/export trips to SUMO xml...',388self.on_export_sumotrips,389info='Export all trips to SUMO XML format.',390bitmap=self.get_agileicon("Document_Export_24px.png"),391)392393# menubar.append_item( 'demand/trips and routes/export routes to SUMO xml...',394# self.on_export_sumoroutes,395# info='Export all trips to SUMO XML format.',396# bitmap = self.get_agileicon("Document_Export_24px.png"),397# )398399menubar.append_item('demand/trips and routes/import trips from SUMO xml...',400self.on_import_trips_xml,401bitmap=self.get_agileicon("Document_Import_24px.png"),402)403404menubar.append_item('demand/trips and routes/import trips with routes from SUMO xml...',405self.on_import_triproutes_xml,406bitmap=self.get_agileicon("Document_Import_24px.png"),407)408409menubar.append_item('demand/trips and routes/import and overwrite routes to existing trips from SUMO xml...',410self.on_import_routes_overwrite_xml,411bitmap=self.get_agileicon("Document_Import_24px.png"),412)413414menubar.append_item('demand/trips and routes/import and add routes to existing trips from SUMO xml...',415self.on_import_routes_alternative_xml,416bitmap=self.get_agileicon("Document_Import_24px.png"),417)418419menubar.append_item('demand/trips and routes/import trips from scenario...',420self.on_import_trips_from_scenario,421info='Import trips from another scenario',422## bitmap = self.get_agileicon("Document_Import_24px.png"),423)424425menubar.append_item('demand/trips and routes/clear all trips and routes',426self.on_clear_trips,427info='Clear all trips with respective routes.',428bitmap=wx.ArtProvider.GetBitmap(wx.ART_DELETE, wx.ART_MENU),429)430431menubar.append_item('demand/trips and routes/clear all routes',432self.on_clear_routes,433info='Clear all routes, trips will remain.',434bitmap=wx.ArtProvider.GetBitmap(wx.ART_DELETE, wx.ART_MENU),435)436437menubar.append_item('demand/trips and routes/clear alternative routes',438self.on_clear_route_alternatves,439info='Clear alternative routes, only current route will remain.',440bitmap=wx.ArtProvider.GetBitmap(wx.ART_DELETE, wx.ART_MENU),441)442# ----------------------------------------------------------------------443444self.add_menu_virtualpop(menubar)445446# ----------------------------------------------------------------------447menubar.append_item('demand/export all routes to SUMO xml...',448self.on_export_all_sumoroutes,449info='Export all routes available in the demand database to SUMO XML format.',450bitmap=self.get_agileicon("Document_Export_24px.png"),451)452453menubar.append_item('demand/update all routes from SUMO xml...',454self.on_update_all_sumoroutes,455info='Update all routes available in the demand database from SUMO XML format. Note that no new routes are going to be imported.',456bitmap=self.get_agileicon("Document_Import_24px.png"),457)458# (self._menuitem_draw_route, id_item,) = menubar.append_item(459## 'plugins/traces/draw selected route in network',460# self.on_renew_objectbrowser,461## info='Enable visualization of routes in network tab. Double-click on trace in table.',462# check=True)463# self._menuitem_draw_route.Check(False)464##465# (self._menuitem_plot_route, id_item,) = menubar.append_item(466## 'plugins/traces/add plot selected route',467# self.on_renew_objectbrowser,468## info='Enable adding of routes to graphics in trace tab. Double-click on trace in table.',469# check=True)470# self._menuitem_plot_route.Check(False)471472def on_clear_vtypes(self, event=None):473self._demand.vtypes.clear_vtypes()474self._mainframe.browse_obj(self._demand.vtypes)475#if event: event.Skip()476477def on_load_vtypes_defaults(self, event=None):478self._demand.vtypes.clear_vtypes()479self._demand.vtypes.eprofiles.get_value().add_profiles_default()480self._demand.vtypes.add_vtypes_default()481self._mainframe.browse_obj(self._demand.vtypes)482#if event: event.Skip()483484def on_clear_trips(self, event=None):485self._demand.trips.clear_trips()486self._mainframe.browse_obj(self._demand.trips)487488def on_clear_routes(self, event=None):489self._demand.trips.clear_routes()490self._mainframe.browse_obj(self._demand.trips)491492def on_clear_route_alternatves(self, event=None):493self._demand.trips.clear_route_alternatves()494self._mainframe.browse_obj(self._demand.trips)495496def on_route(self, event=None):497"""Generates routes from current trip info. Uses a python implementation of a fastest path router.498"""499# self._demand.trips.clear_routes()500self._demand.trips.route(is_set_current=True)501self._mainframe.browse_obj(self._demand.trips)502503# def on_route_del_disconnected(self, event=None):504# """Generates routes from current trip info and deletes disconnected trips. Uses a python implementation of a fastest path router.505# """506# #self._demand.trips.clear_routes()507# self._demand.trips.route(is_del_disconnected = True)508# self._mainframe.browse_obj(self._demand.trips)509510def on_duaroute(self, event=None):511"""Fastest route traffic assignment with duarouter.512"""513# self._demand.trips.clear_routes()514self._demand.trips.duaroute(is_export_net=True, is_export_trips=True)515self._mainframe.browse_obj(self._demand.trips)516517def on_generate_taxitrips(self, event=None):518"""Stochastic traffic assignment with duarouter.519"""520521obj = demand.TaxiGenerator(self._demand,522logger=self._mainframe.get_logger())523524dlg = ProcessDialog(self._mainframe, obj)525526dlg.CenterOnScreen()527528# this does not return until the dialog is closed.529val = dlg.ShowModal()530# print ' val,val == wx.ID_OK',val,wx.ID_OK,wx.ID_CANCEL,val == wx.ID_CANCEL531# print ' status =',dlg.get_status()532533if dlg.get_status() == 'success':534dlg.apply()535dlg.Destroy()536537self._mainframe.browse_obj(self._demand.trips)538539def on_duaroute_stochastic(self, event=None):540"""Stochastic traffic assignment with duarouter.541"""542# self._demand.trips.clear_routes()543544obj = routing.DuaRouter(self.get_scenario().net,545trips=self._demand.trips,546logger=self._mainframe.get_logger())547548dlg = ProcessDialog(self._mainframe, obj)549550dlg.CenterOnScreen()551552# this does not return until the dialog is closed.553val = dlg.ShowModal()554# print ' val,val == wx.ID_OK',val,wx.ID_OK,wx.ID_CANCEL,val == wx.ID_CANCEL555# print ' status =',dlg.get_status()556557if dlg.get_status() == 'success':558dlg.apply()559dlg.Destroy()560561self._mainframe.browse_obj(self._demand.trips)562563# this should update all widgets for the new scenario!!564# print 'call self._mainframe.refresh_moduleguis()'565# self._mainframe.refresh_moduleguis()566567def on_import_vtypes_xml(self, event=None):568"""Select xml file and import new vehicle types.569"""570filepath = self._demand.trips.get_routefilepath()571# defaultFile = = os.path.dirname(filepath)572dirpath = os.path.dirname(filepath)573wildcards_all = 'XML files (*.xml)|*.xml|All files (*.*)|*.*'574dlg = wx.FileDialog(None, message='Import vtypes from SUMO xml',575defaultDir=dirpath,576# defaultFile = =# defaultFile = ,577wildcard=wildcards_all, style=wx.SAVE | wx.CHANGE_DIR)578if dlg.ShowModal() == wx.ID_OK:579filepath = dlg.GetPath()580581else:582return583584self._demand.vtypes.import_xml(filepath)585self._mainframe.browse_obj(self._demand.vtypes)586587def on_import_trips_xml(self, event=None):588"""Select xml file and import new trips.589New trips with associated routes will generated.590"""591filepath = self._demand.trips.get_routefilepath()592# defaultFile = = os.path.dirname(filepath)593dirpath = os.path.dirname(filepath)594wildcards_all = 'XML trip files (*.trip.xml)|*.trip.xml|All files (*.*)|*.*'595dlg = wx.FileDialog(None, message='Import trips and routes from SUMO xml',596defaultDir=dirpath,597# defaultFile = =# defaultFile = ,598wildcard=wildcards_all, style=wx.SAVE | wx.CHANGE_DIR)599if dlg.ShowModal() == wx.ID_OK:600filepath = dlg.GetPath()601602else:603return604605self._demand.trips.import_trips_xml(filepath, is_clear_trips=False,606is_generate_ids=True)607self._mainframe.browse_obj(self._demand.trips)608609def on_import_triproutes_xml(self, event=None):610"""Select xml file and import trips and routes.611New trips with associated routes will generated.612"""613filepath = self._demand.trips.get_routefilepath()614# defaultFile = = os.path.dirname(filepath)615dirpath = os.path.dirname(filepath)616wildcards_all = 'XML route files (*.rou.xml)|*.rou.xml|All files (*.*)|*.*'617dlg = wx.FileDialog(None, message='Import trips and routes from SUMO xml',618defaultDir=dirpath,619# defaultFile = =# defaultFile = ,620wildcard=wildcards_all, style=wx.SAVE | wx.CHANGE_DIR)621if dlg.ShowModal() == wx.ID_OK:622filepath = dlg.GetPath()623624else:625return626627self._demand.trips.import_routes_xml(filepath, is_clear_trips=False,628is_generate_ids=True,629is_add=False)630self._mainframe.browse_obj(self._demand.trips)631632def on_import_routes_overwrite_xml(self, event=None):633"""Select xml file and import routes.634Overwrite current routes of existing trips.635"""636filepath = self._demand.trips.get_routefilepath()637# defaultFile = = os.path.dirname(filepath)638dirpath = os.path.dirname(filepath)639wildcards_all = 'XML route files (*.rou.xml)|*.rou.xml|All files (*.*)|*.*'640dlg = wx.FileDialog(None, message='Import trips and routes from SUMO xml',641defaultDir=dirpath,642# defaultFile = =# defaultFile = ,643wildcard=wildcards_all, style=wx.OPEN | wx.CHANGE_DIR644)645646if dlg.ShowModal() == wx.ID_OK:647filepath = dlg.GetPath()648649else:650return651652self._demand.trips.import_routes_xml(filepath, is_clear_trips=False,653is_overwrite_only=True,654is_generate_ids=False,655is_add=False)656self._mainframe.browse_obj(self._demand.trips)657658def on_import_routes_alternative_xml(self, event=None):659"""Select xml file and import routes.660Add routes as alternative of existing trips.661"""662filepath = self._demand.trips.get_routefilepath()663# defaultFile = = os.path.dirname(filepath)664dirpath = os.path.dirname(filepath)665wildcards_all = 'XML route files (*.rou.xml)|*.rou.xml|All files (*.*)|*.*'666dlg = wx.FileDialog(None, message='Import trips and routes from SUMO xml',667defaultDir=dirpath,668# defaultFile = =# defaultFile = ,669wildcard=wildcards_all, style=wx.OPEN | wx.CHANGE_DIR670)671672if dlg.ShowModal() == wx.ID_OK:673filepath = dlg.GetPath()674675else:676return677678self._demand.trips.import_routes_xml(filepath, is_clear_trips=False,679is_generate_ids=False,680is_add=True)681self._mainframe.browse_obj(self._demand.trips)682683def on_import_trips_from_scenario(self, event=None):684"""Select xml file and import new vehicle types.685"""686filepath = self.get_scenario().get_rootfilepath()687# defaultFile = = os.path.dirname(filepath)688dirpath = os.path.dirname(filepath)689wildcards_all = "All files (*.*)|*.*"690wildcards_obj = "Python binary files (*.obj)|*.obj"691wildcards = wildcards_obj+"|"+wildcards_all692dlg = wx.FileDialog(693self._mainframe, message="Open scenario file",694defaultDir=dirpath,695# # defaultFile = = filepath+'.obj',696wildcard=wildcards,697style=wx.OPEN | wx.CHANGE_DIR698)699if dlg.ShowModal() == wx.ID_OK:700filepath = dlg.GetPath()701702else:703return704scenario2 = load_scenario(filepath, logger=None)705self._demand.trips.import_trips_from_scenario(scenario2)706self._mainframe.browse_obj(self._demand.trips)707708def on_export_sumotrips(self, event=None):709# print 'on_export_sumotrips'710filepath = self._demand.trips.get_tripfilepath()711# defaultFile = = os.path.dirname(filepath)712dirpath = os.path.dirname(filepath)713wildcards_all = '*.*|XML trip files (*.trip.xml)|*.trip.xml|All files (*.*)'714dlg = wx.FileDialog(None, message='Write trips to SUMO xml',715defaultDir=dirpath,716# defaultFile = =# defaultFile = ,717wildcard=wildcards_all, style=wx.SAVE | wx.CHANGE_DIR)718if dlg.ShowModal() == wx.ID_OK:719filepath = dlg.GetPath()720721else:722return723724self._demand.trips.export_trips_xml(filepath)725726def on_export_vtypes(self, event=None):727"""728Write vtypes to SUMO xml729"""730# print 'on_export_vtypes'731filepath = self._demand.trips.get_tripfilepath()732# defaultFile = = os.path.dirname(filepath)733dirpath = os.path.dirname(filepath)734wildcards_all = '*.*|XML vtype files (*.vtype.xml)|*.vtype.xml|All files (*.*)'735dlg = wx.FileDialog(None, message='Write vtypes to SUMO xml',736defaultDir=dirpath,737# defaultFile = =# defaultFile = ,738wildcard=wildcards_all, style=wx.SAVE | wx.CHANGE_DIR)739if dlg.ShowModal() == wx.ID_OK:740filepath = dlg.GetPath()741742else:743return744745self._demand.vtypes.export_xml(filepath)746747# def on_export_sumoroutes(self, event = None):748# #print 'on_export_sumotrips'749# filepath = self._demand.trips.get_routefilepath()750# # defaultFile = = os.path.basename(filepath)751# dirpath = os.path.dirname(filepath)752# wildcards_all = 'XML route files (*rou.xml)|*rou.xml|All files (*.*)|*.*'753# dlg = wx.FileDialog(None, message='Write routes to SUMO xml',754# defaultDir=dirpath,755# # defaultFile = =# defaultFile = ,756# wildcard=wildcards_all, style=wx.SAVE | wx.CHANGE_DIR)757# if dlg.ShowModal() == wx.ID_OK:758# filepath = dlg.GetPath()759#760# else:761# return762#763# self._demand.trips.export_routes_xml(filepath)764765def on_export_all_sumoroutes(self, event=None):766# print 'on_export_sumotrips'767filepath = self._demand.get_routefilepath()768# defaultFile = = os.path.basename(filepath)769dirpath = os.path.dirname(filepath)770wildcards_all = 'XML route files (*rou.xml)|*rou.xml|All files (*.*)|*.*'771dlg = wx.FileDialog(None, message='Write all routes to SUMO xml',772defaultDir=dirpath,773# defaultFile = =# defaultFile = ,774wildcard=wildcards_all, style=wx.SAVE | wx.CHANGE_DIR)775if dlg.ShowModal() == wx.ID_OK:776filepath = dlg.GetPath()777778else:779return780781self._demand.export_routes_xml(filepath)782783def on_update_all_sumoroutes(self, event=None):784# print 'on_export_sumotrips'785filepath = self._demand.get_routefilepath()786# defaultFile = = os.path.basename(filepath)787dirpath = os.path.dirname(filepath)788wildcards_all = 'XML route files (*rou.xml)|*rou.xml|All files (*.*)|*.*'789dlg = wx.FileDialog(None, message='Update all routes from SUMO xml',790defaultDir=dirpath,791# defaultFile = =# defaultFile = ,792wildcard=wildcards_all, style=wx.OPEN | wx.CHANGE_DIR)793if dlg.ShowModal() == wx.ID_OK:794filepath = dlg.GetPath()795796else:797return798799self._demand.import_routes_xml(filepath)800801802