Ejemplo n.º 1
0
    def refresh_widgets(self):
        """
        Check through mainframe what the state of the application is
        and reset widgets. For exampe enable/disable widgets
        dependent on the availability of data. 
        """
        print 'MapmatchingWxGui.refresh_widgets', self._is_needs_refresh
        scenario = self.get_scenario()
        is_refresh = False
        if self._scenario != scenario:
            del self._scenario
            del self._mapmatching
            del self._results
            del self._matchprocess
            self._scenario = scenario
            self._mapmatching = scenario.demand.add_demandobject(
                ident='mapmatching', DemandClass=mapmatching.Mapmatching)

            # with this configuration, results can point to mapmatching data
            # but not to data within results structure
            # results does not save mapmatching and vice versa
            self._results = mapmatching.Matchresults(
                'matchresults',
                self._mapmatching,
            )
            self._matchprocess = None
            #self._mapmatching =  mapmatching.Mapmatching('mapmatching', scenario)
            is_refresh = True

        if is_refresh | self._is_needs_refresh:
            self._is_needs_refresh = False
            # print '  is_refresh',is_refresh,self._is_needs_refresh
            neteditor = self.get_neteditor()
            #canvas = self.get_canvas()
            drawing = self.get_drawing()  # canvas.get_drawing()

            # add or refresh facility drawing
            drawing.set_element('gpspointsdraws',
                                GpsPointsDrawings,
                                self._mapmatching.points,
                                layer=150)

            drawing.set_element('gpsroutesdraws',
                                GpsRoutesDrawings,
                                self._results.tripresults.get_routes(),
                                layer=149)

            # neteditor.get_toolbox().add_toolclass(AddZoneTool)# will check if tool is already there
            # neteditor.get_toolbox().add_toolclass(AddFacilityTool)
            neteditor.draw()

        self._canvas = self.get_canvas()
    def refresh_widgets(self):
        """
        Check through mainframe what the state of the application is
        and reset widgets. For exampe enable/disable widgets
        dependent on the availability of data. 
        """
        print 'MapmatchingWxGui.refresh_widgets'
        scenario = self.get_scenario()
        is_refresh = False
        if self._demand != scenario.demand:
            del self._demand
            del self._mapmatching
            self._demand = scenario.demand
            self._mapmatching = self._demand.add_demandobject(
                ident='mapmatching', DemandClass=mapmatching.Mapmatching)

            # if (self._results is None) & (self._mapmatching is not None):
            del self._results
            self._results = mapmatching.Matchresults(ident=ident_results,
                                                     parent=self._mapmatching)
            is_refresh = True

        if is_refresh | self._is_needs_refresh:
            self._is_needs_refresh = False
            print '  is_refresh', is_refresh, self._is_needs_refresh
            neteditor = self.get_neteditor()
            #canvas = self.get_canvas()
            drawing = self.get_drawing()  # canvas.get_drawing()

            # add or refresh facility drawing
            drawing.set_element('gpspointsdraws',
                                GpsPointsDrawings,
                                self._mapmatching.points,
                                layer=150)

            drawing.set_element('gpsroutesdraws',
                                GpsRoutesDrawings,
                                self._mapmatching.trips.get_routes(),
                                layer=149)

            # neteditor.get_toolbox().add_toolclass(AddZoneTool)# will check if tool is already there
            # neteditor.get_toolbox().add_toolclass(AddFacilityTool)
            neteditor.draw()

        self._canvas = self.get_canvas()