예제 #1
0
    def __init__(self,donnees_d_entree):
        self.donnees_d_entree = donnees_d_entree
        self.thread = QtCore.QThread()

        if donnees_d_entree['forcage_attribut_fichier_de_sortie']=="":
            if self.donnees_d_entree['pasdespace']==0:
                self.donnees_d_entree['pathshp'] =os.path.join(os.path.dirname(self.donnees_d_entree['pathselafin']),
                                                                                           os.path.basename(self.donnees_d_entree['pathselafin']).split('.')[0]
                                                                                           +"_points_t_"+str(int(self.donnees_d_entree['temps']))+str('.shp'))  
            else:
                self.donnees_d_entree['pathshp']=os.path.join(os.path.dirname(self.donnees_d_entree['pathselafin']),
                                                                                           os.path.basename(self.donnees_d_entree['pathselafin']).split('.')[0]
                                                                                           +"_points_"+str(int(self.donnees_d_entree['pasdespace']))
                                                                                           +"m_t_"+str(int(self.donnees_d_entree['temps']))+str('.shp'))  
        else:
                self.donnees_d_entree['pathshp']=os.path.join(os.path.dirname(self.donnees_d_entree['pathselafin']),
                                                                                           os.path.basename(self.donnees_d_entree['pathselafin']).split('.')[0]
                                                                                           +"_"+str(self.donnees_d_entree['forcage_attribut_fichier_de_sortie'])
                                                                                           +str('.shp'))

        if self.donnees_d_entree['fichier_point_avec_vecteur_vitesse']:
            self.donnees_d_entree['Parametre_vitesse_X'] = donnees_d_entree['Parametre_vitesse_X']
            self.donnees_d_entree['Parametre_vitesse_Y'] = donnees_d_entree['Parametre_vitesse_Y']
        else:
            self.donnees_d_entree['Parametre_vitesse_X'] = None
            self.donnees_d_entree['Parametre_vitesse_Y'] = None

        self.worker = ""
예제 #2
0
 def runModuleAsync(self, module):
     worker = ModuleRunWorker(module)
     thread = QtCore.QThread(self)
     worker.moveToThread(thread)
     worker.finished.connect(self.runModuleWorkerFinished)
     worker.error.connect(self.runModuleWorkerError)
     worker.status.connect(self.workerStatus)
     self.abort_signal.connect(worker.stop)
     thread.started.connect(worker.run)
     self.setWorkerRunning(True)
     thread.start()
     self.threads.append(thread)
     self.workers.append(worker)
예제 #3
0
 def validate_async(self):
     # print "val_async> ",
     if not self.currentlyvalidating and self.revalidate:
         # print "ok >",
         self.currentlyvalidating = True
         worker = ModuleValidateWorker(self)
         # start the worker in a new thread
         thread = QtCore.QThread()
         worker.moveToThread(thread)
         worker.error.connect(self.validateError)
         worker.finished.connect(self.validateFinished)
         thread.started.connect(worker.run)
         thread.start()
         self.validatethread = thread
         self.validateworker = worker
    def start(self, selafin, tool):
        # Launch worker
        self.thread = QtCore.QThread()
        self.worker = rasterize(selafin, tool)
        # self.graphtemp.points = qgspoints
        # self.worker = self.graphtemp

        self.worker.moveToThread(self.thread)
        self.thread.started.connect(self.worker.createRaster)
        self.worker.status.connect(self.writeOutput)
        self.worker.error.connect(self.raiseError)
        self.worker.finished.connect(self.workerFinished)
        self.worker.finished.connect(self.worker.deleteLater)
        self.thread.finished.connect(self.thread.deleteLater)
        self.worker.finished.connect(self.thread.quit)
        self.thread.start()
예제 #5
0
 def run_async(self, on_finish=None, on_error=None, status=None, abort_signal=None, run_now=True):
     worker = ModuleBaseRunWorker(self)
     thread = QtCore.QThread()
     worker.moveToThread(thread)
     if on_error:
         worker.error.connect(on_error)
     if on_finish:
         worker.finished.connect(on_finish)
     if status:
         worker.status.connect(status)
     if abort_signal:
         abort_signal.connect(worker.stop)
     worker.finished.connect(thread.quit)
     thread.started.connect(worker.run)
     if run_now:
         thread.start()
     return thread, worker
예제 #6
0
 def startWorker(self, module):
     #https://snorfalorpagus.net/blog/2013/12/07/multithreading-in-qgis-python-plugins/
     if self.workerrunning:
         return
     self.setWorkerRunning(True)
     worker = ModuleLoadWorker(module)
     module.setIcon(self.loadingIcon)
     self.moduleList.setEnabled(False)
     # start the worker in a new thread
     thread = QtCore.QThread(self)
     worker.moveToThread(thread)
     worker.finished.connect(self.workerFinished)
     worker.error.connect(self.workerError)
     thread.started.connect(worker.run)
     thread.start()
     self.thread = thread
     self.worker = worker
예제 #7
0
파일: QpalsWSM.py 프로젝트: zhixd83/qpals
    def exportWSM(self):
        self.WSMProj.outputFile = self.expPath.currentText()
        self.WSMProj.dX = self.dXSpin.value()
        self.WSMProj.dY = self.dYSpin.value()
        self.expBtn.setEnabled(False)

        worker = QpalsWSMExporter(self.WSMProj)
        thread = QtCore.QThread()
        worker.moveToThread(thread)
        worker.error.connect(self.sec_error)
        worker.finished.connect(self.saveWSM)
        worker.progress.connect(lambda p: self.progress2.setValue(p))
        worker.finished.connect(thread.quit)
        thread.started.connect(worker.run)
        thread.start()

        self.threads.append(thread)
        self.workers.append(worker)
예제 #8
0
 def start(self, selafin, graphtemptool,qgspoints ):
              
     #Launch worker
     self.thread = QtCore.QThread()
     self.worker = GraphTemp(selafin, graphtemptool, qgspoints, self.compare)
     #self.graphtemp.points = qgspoints
     #self.worker = self.graphtemp
     
     self.worker.moveToThread(self.thread)
     self.thread.started.connect(self.worker.createGraphTemp)
     self.worker.status.connect(self.writeOutput)
     self.worker.error.connect(self.writeError)
     self.worker.emitpoint.connect(self.emitPoint)
     self.worker.emitnum.connect(self.emitNum)
     self.worker.emitprogressbar.connect(self.updateProgressBar)
     self.worker.finished.connect(self.workerFinished)
     self.worker.finished.connect(self.worker.deleteLater)
     self.thread.finished.connect(self.thread.deleteLater)
     self.worker.finished.connect(self.thread.quit)
     self.thread.start()
예제 #9
0
    def __init__(self, donnees_d_entree):
        self.donnees_d_entree = donnees_d_entree
        self.thread = QtCore.QThread()

        if donnees_d_entree["forcage_attribut_fichier_de_sortie"] == "":
            if self.donnees_d_entree["pasdespace"] == 0:
                self.donnees_d_entree["pathshp"] = os.path.join(
                    os.path.dirname(self.donnees_d_entree["pathselafin"]),
                    os.path.basename(
                        self.donnees_d_entree["pathselafin"]).split(".")[0] +
                    "_points_t_" + str(int(self.donnees_d_entree["temps"])) +
                    str(".shp"),
                )
            else:
                self.donnees_d_entree["pathshp"] = os.path.join(
                    os.path.dirname(self.donnees_d_entree["pathselafin"]),
                    os.path.basename(
                        self.donnees_d_entree["pathselafin"]).split(".")[0] +
                    "_points_" +
                    str(int(self.donnees_d_entree["pasdespace"])) + "m_t_" +
                    str(int(self.donnees_d_entree["temps"])) + str(".shp"),
                )
        else:
            self.donnees_d_entree["pathshp"] = os.path.join(
                os.path.dirname(self.donnees_d_entree["pathselafin"]),
                os.path.basename(
                    self.donnees_d_entree["pathselafin"]).split(".")[0] + "_" +
                str(self.donnees_d_entree["forcage_attribut_fichier_de_sortie"]
                    ) + str(".shp"),
            )

        if self.donnees_d_entree["fichier_point_avec_vecteur_vitesse"]:
            self.donnees_d_entree["Parametre_vitesse_X"] = donnees_d_entree[
                "Parametre_vitesse_X"]
            self.donnees_d_entree["Parametre_vitesse_Y"] = donnees_d_entree[
                "Parametre_vitesse_Y"]
        else:
            self.donnees_d_entree["Parametre_vitesse_X"] = None
            self.donnees_d_entree["Parametre_vitesse_Y"] = None

        self.worker = ""
예제 #10
0
    def connect_init(self):
        # This connection is for the Notification system. It cannot be the previous one.
        # Indeed, the previous can only be manipulated by the QGIS layer system. If we need to
        # query the database with SQL request, a @Psycopg2 class is required.
        #
        # Important: The notify system is managed in another thread (a non-ui one). If the LISTEN system
        # is set into an UI thread, the UI will be slowed.
        self.conn = psycopg2.connect(dbname=self.database,
                                     user=self.username,
                                     password=self.password,
                                     host=self.host,
                                     port=self.port)
        # This option is required for the multi-threading.
        self.conn.set_isolation_level(
            psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT)

        # Init the notification worker
        self.worker = ListenerWorker(self.conn, self.notify_key)
        # Create the thread (a non-ui one)
        self.thread = QtCore.QThread(self.ui)

        # Initialize the notification system
        self.notify_init()
예제 #11
0
 def __init__(self):
     QtCore.QObject.__init__(self)
     self.thread = QtCore.QThread()
     self.worker = None
     self.processtype = 0