diff --git a/main/astrodatagui/AstrodataGUI.py b/main/astrodatagui/AstrodataGUI.py index e0f071d..471cee4 100644 --- a/main/astrodatagui/AstrodataGUI.py +++ b/main/astrodatagui/AstrodataGUI.py @@ -9,6 +9,8 @@ import numpy as np from .db.StarsDB import StarDB from .ui.NewStarDialog import NewStarDialog +from .CalcAllFlaresThread import CalcAllFlaresThread + DEFAULT_DB = "stars.db" class AstrodataGUI(QtWidgets.QMainWindow): @@ -61,6 +63,8 @@ class AstrodataGUI(QtWidgets.QMainWindow): self.loadDB() self.updateStarList() + self.calcAllFlaresThread = None + def setupCustomSimbadQueries(self): self.simbad = Simbad() self.simbad.add_votable_fields("sptype") @@ -344,22 +348,31 @@ class AstrodataGUI(QtWidgets.QMainWindow): view = self.comboPlotPeriodogramView.currentText() self.flaredetectorPreview.setPeriodogramState(periodogramEnabled, method, view) - def btCountAllFlaresClicked(self): - allStarsDictList = [] + def btCountAllFlaresClickedDone(self, allFlaresDictList): + print(allFlaresDictList) + self.calcAllFlaresThread = None - for starName in self.starDB.getAllStars(): - sequences = self.starDB.getStarSequences(starName) - infos = self.starDB.getStarInfos(starName) - for sourceSeq in sequences: - source = sourceSeq["Source"] - seq = sourceSeq["Sequence"] - filePath = self.starDB.getFilePath(starName, source, seq) - allStarsDictList.append({"StarName": starName, - "SpType": infos["SpType"], - "RotVel": infos["RotVel"], - "RotVelUnit": infos["RotVelUnit"], - "Distance": infos["Distance"], - "DistanceUnit": infos["DistanceUnit"], - "Source": source, - "Sequence": seq, - "FilePath": filePath}) + def btCountAllFlaresClicked(self): + if(self.calcAllFlaresThread is None): + allStarsDictList = [] + + for starName in self.starDB.getAllStars(): + sequences = self.starDB.getStarSequences(starName) + infos = self.starDB.getStarInfos(starName) + for sourceSeq in sequences: + source = sourceSeq["Source"] + seq = sourceSeq["Sequence"] + filePath = self.starDB.getFilePath(starName, source, seq) + allStarsDictList.append({"StarName": starName, + "SpType": infos["SpType"], + "RotVel": infos["RotVel"], + "RotVelUnit": infos["RotVelUnit"], + "Distance": infos["Distance"], + "DistanceUnit": infos["DistanceUnit"], + "Source": source, + "Sequence": seq, + "FilePath": filePath}) + + self.calcAllFlaresThread = CalcAllFlaresThread(allStarsDictList) + self.calcAllFlaresThread.finished.connect(self.btCountAllFlaresClickedDone) + self.calcAllFlaresThread.start() \ No newline at end of file