def refreshGuiWithCurrentTime(self, currentTimePosition, sender=None): """update the gui when time has changed by refreshing/repainting the layers and changing the time showing in dateTimeEditCurrentTime and horizontalTimeSlider""" # setting the gui elements should not fire the event for # timeChanged, since they were changed to be in sync with the rest of the system on # purpose, no need to sync the system again self.setPropagateGuiChanges(False) if currentTimePosition is None: self.setPropagateGuiChanges(True) return time_util.updateUi(self.guiControl.getTimeWidget(), currentTimePosition) timeval = datetime_to_epoch(currentTimePosition) timeExtents = self.getTimeLayerManager().getProjectTimeExtents() try: pct = (timeval - datetime_to_epoch(timeExtents[0])) * 1.0 / ( datetime_to_epoch(timeExtents[1]) - datetime_to_epoch(timeExtents[0])) sliderVal = self.guiControl.dock.horizontalTimeSlider.minimum( ) + int(pct * (self.guiControl.dock.horizontalTimeSlider.maximum() - self.guiControl.dock.horizontalTimeSlider.minimum())) self.guiControl.dock.horizontalTimeSlider.setValue(sliderVal) self.guiControl.repaintRasters() self.guiControl.repaintJoined() self.guiControl.repaintVectors() self.guiControl.refreshMapCanvas() except Exception, e: error(e)
def refreshGuiWithCurrentTime(self,currentTimePosition,sender=None): """update the gui when time has changed by refreshing/repainting the layers and changing the time showing in dateTimeEditCurrentTime and horizontalTimeSlider""" # setting the gui elements should not fire the event for # timeChanged, since they were changed to be in sync with the rest of the system on # purpose, no need to sync the system again self.setPropagateGuiChanges(False) if currentTimePosition is None: self.setPropagateGuiChanges(True) return time_util.updateUi(self.guiControl.getTimeWidget(), currentTimePosition) timeval = datetime_to_epoch(currentTimePosition) timeExtents = self.getTimeLayerManager().getProjectTimeExtents() try: pct = (timeval - datetime_to_epoch(timeExtents[0]))*1.0 / (datetime_to_epoch( timeExtents[1]) - datetime_to_epoch(timeExtents[0])) sliderVal = self.guiControl.dock.horizontalTimeSlider.minimum() + int(pct * ( self.guiControl.dock.horizontalTimeSlider.maximum() - self.guiControl.dock.horizontalTimeSlider.minimum())) self.guiControl.dock.horizontalTimeSlider.setValue(sliderVal) self.guiControl.repaintRasters() self.guiControl.repaintJoined() self.guiControl.repaintVectors() self.guiControl.refreshMapCanvas() except Exception,e: error(e)