def removePathPreviews(self): """Remove recorded path previews from the map canvas""" for rb in self.previousPaths: self.canvas.scene().removeItem(rb) SourcePlugins.callMethodOnEach("clearMapCanvasItems", ()) self.previousPaths=[] self.canvas.refresh()
def terminateAndCleanup(self): """Stop gathering process.""" self.msleep(500) #fixes video crashing when stopped immediately after start; TODO: do it better SourcePlugins.callMethodOnEach("stopRecording", ()) self.controller.gpsDaemon.stopRecording() self.disconnect(self.controller.gpsDaemon, SIGNAL("newTrackPoint(PyQt_PyObject)"), self.onNewTrackPoint) self.alive=False
def initialize(self): """Initializes data gathering.""" self.outputDirectory=self.getDataDirectory() SourcePlugins.callMethodOnEach("startRecording", (self.outputDirectory,)) self.controller.gpsDaemon.startRecording(self.outputDirectory+"nmea.log", self.outputDirectory+"path.gpx") self.connect(self.controller.gpsDaemon, SIGNAL("newTrackPoint(PyQt_PyObject)"), self.onNewTrackPoint)
def run(self): """Main execution method, that periodically polls for data.""" self.stopMe=0 while (self.stopMe==0) and self.controller.gpsDaemon.ok(): QThread.msleep(50) SourcePlugins.callMethodOnEach("pollRecording", ()) #let the caller know we finished self.emit(SIGNAL("gathererEvent(PyQt_PyObject)"), ("recordingTerminated", self.stopMe))
def run(self): """Main execution method, that periodically polls for data.""" self.stopMe = 0 while (self.stopMe == 0) and self.controller.gpsDaemon.ok(): QThread.msleep(50) SourcePlugins.callMethodOnEach("pollRecording", ()) #let the caller know we finished self.emit(SIGNAL("gathererEvent(PyQt_PyObject)"), ("recordingTerminated", self.stopMe))
def terminateAndCleanup(self): """Stop gathering process.""" self.msleep( 500 ) #fixes video crashing when stopped immediately after start; TODO: do it better SourcePlugins.callMethodOnEach("stopRecording", ()) self.controller.gpsDaemon.stopRecording() self.disconnect(self.controller.gpsDaemon, SIGNAL("newTrackPoint(PyQt_PyObject)"), self.onNewTrackPoint) self.alive = False
def initialize(self): """Initializes data gathering.""" self.outputDirectory = self.getDataDirectory() SourcePlugins.callMethodOnEach("startRecording", (self.outputDirectory, )) self.controller.gpsDaemon.startRecording( self.outputDirectory + "nmea.log", self.outputDirectory + "path.gpx") self.connect(self.controller.gpsDaemon, SIGNAL("newTrackPoint(PyQt_PyObject)"), self.onNewTrackPoint)
def initGui(self): """ Initialize plugin's UI """ self.initLogging() self.recording=False self.loadPlugins() self.loadConfiguration() self.rubberBand=None self.lastPosition=None self.timer=None self.previousPaths=[] #previews of previously recorded paths self.gpsDaemon=GpsDaemon(self, self) self.canvas=self.iface.mapCanvas() self.gatherer=None self.dockWidget=None self.dockWidget_simple=None self.dockWidget=DockWidget(self) self.dockWidget_simple=DockWidget_simple(self) self.actionDockWidget=QAction("Show Gatherer dock widget",self.iface.mainWindow()) self.actionDockWidget.setCheckable(True) QObject.connect(self.actionDockWidget, SIGNAL("triggered()"), self.showHideDockWidget) self.iface.addPluginToMenu("Qgis-&mapper", self.actionDockWidget) QObject.connect(self.dockWidget, SIGNAL("visibilityChanged(bool)"), lambda : self.__dockwidgetVisibilityChanged(0)) QObject.connect(self.dockWidget_simple, SIGNAL("visibilityChanged(bool)"), lambda : self.__dockwidgetVisibilityChanged(1)) SourcePlugins.initializeUI(self.dockWidget.dataInputPlugins_tabWidget) self.curDockWidget=None self.showInterface(self.interface_simple) self.canvas=self.iface.mapCanvas() self.positionMarker=PositionMarker(self.canvas) self.connect(self.gpsDaemon, SIGNAL("newTrackPoint(PyQt_PyObject)"), self.gotNewTrackPoint)
def unload(self): """ Cleanup and unload the plugin """ self.canvas.scene().removeItem(self.positionMarker) self.positionMarker=None if self.recording: self.recordingStop() self.saveConfiguration() SourcePlugins.unloadPlugins() self.gpsDaemon.terminate() self.dockWidget.unload() self.showInterface(None) del self.dockWidget del self.dockWidget_simple self.iface.removePluginMenu("Qgis-&mapper",self.actionDockWidget) del self.actionDockWidget logging.debug("Plugin terminated.")
def loadPlugins(self): """Load all existing plugins""" SourcePlugins.loadPlugins(self)