def __init__(self): # ------------------------- UI Initialization ------------------------- super().__init__() self.ui = Ui_MainWindow() self.ui.setupUi(self) self.setWindowState(Qt.WindowMaximized) self.setWindowTitle('Metacontrol - untitled.mtc') maintab = self.ui.tabMainWidget # disable the tabs maintab.setTabEnabled(self._DOETAB_IDX, False) maintab.setTabEnabled(self._METAMODELTAB_IDX, False) maintab.setTabEnabled(self._OPTTAB_IDX, False) maintab.setTabEnabled(self._HESSIANTAB_IDX, False) maintab.setTabEnabled(self._SOCTAB_IDX, False) # ------------------------ Internal variables ------------------------- self.application_database = DataStorage() # ----------------------- Load the tabs widgets ----------------------- self.tab_loadsim = LoadSimTab(self.application_database, parent_tab=self.ui.simulationTab) self.tab_doe = DoeTab(self.application_database, parent_tab=self.ui.samplingTab) self.tab_metamodel = MetamodelTab(self.application_database, parent_tab=self.ui.metamodelTab) self.tab_optimization = OptimizationTab( self.application_database, parent_tab=self.ui.optimizationTab) self.tab_reducedspace = ReducedSpaceTab( self.application_database, parent_tab=self.ui.reducedspaceTab) self.tab_hessianext = HessianExtractionTab( self.application_database, parent_tab=self.ui.hessianextractionTab) self.tab_soc = SocTab(self.application_database, parent_tab=self.ui.socTab) # ------------------------ Actions connections ------------------------ self.ui.actionOpen.triggered.connect(self.open_file) self.ui.actionSave.triggered.connect(self.save_file) self.ui.actionSave_As.triggered.connect(self.save_file_as) # --------------------------- Signals/Slots --------------------------- # sampling tab enabled self.application_database.sampling_enabled.connect( self.on_sampling_enabled) # metamodel tab enabled self.application_database.metamodel_enabled.connect( self.on_metamodel_enabled) # optimization tab enabled self.application_database.metamodel_enabled.connect( self.on_optimization_enabled) # hessian tab enabled self.application_database.hessian_enabled.connect( self.on_hessianextraction_enabled) # soc tab enabled self.application_database.soc_enabled.connect(self.on_soc_enabled)
def doetab_mock(): # doetab and sampling assistant DOE_TAB_MOCK_DS = DataStorage() DOE_TAB_MOCK_DS.load(MTC_FOLDER_PATH / 'doetab_sampling_assistant.mtc') DOE_TAB_MOCK_DS.simulation_file = str(ASPEN_BKP_FILE_PATH) return DOE_TAB_MOCK_DS
def redspace_mock(): # reduced space tab REDSPACE_TAB_MOCK_DS = DataStorage() REDSPACE_TAB_MOCK_DS.load(MTC_FOLDER_PATH / "reducedspacetab.mtc") REDSPACE_TAB_MOCK_DS.simulation_file = str(ASPEN_BKP_FILE_PATH) return REDSPACE_TAB_MOCK_DS
def lhssettings_mock(): # lhs settings dialog _mtc_lhs_settings = {'n_samples': 50, 'n_iter': 10, 'inc_vertices': False} LHSSETTINGS_MOCK_DS = DataStorage() LHSSETTINGS_MOCK_DS.doe_lhs_settings = _mtc_lhs_settings return LHSSETTINGS_MOCK_DS
def loadsim_mock(): # loasim and sampling(doe) tabs LOADSIM_SAMPLING_MOCK_DS = DataStorage() LOADSIM_SAMPLING_MOCK_DS.load(MTC_FOLDER_PATH / 'loadsimtab.mtc') LOADSIM_SAMPLING_MOCK_DS.simulation_file = str(ASPEN_BKP_FILE_PATH) return LOADSIM_SAMPLING_MOCK_DS
def indirect_mock(): # C3 splitter column - indirect control INDIRECT_MOC_DS = DataStorage() INDIRECT_MOC_DS.load(MTC_FOLDER_PATH / "indirect control - c3 splitter.mtc") return INDIRECT_MOC_DS
def soc_mock(): # soc tab SOC_TAB_MOC_DS = DataStorage() SOC_TAB_MOC_DS.load(MTC_FOLDER_PATH / "soctab.mtc") SOC_TAB_MOC_DS.simulation_file = str(ASPEN_BKP_FILE_PATH) return SOC_TAB_MOC_DS
def hessian_mock(): # hessian extraction tab HESSIAN_TAB_MOCK_DS = DataStorage() HESSIAN_TAB_MOCK_DS.load(MTC_FOLDER_PATH / "hessianextractiontab.mtc") HESSIAN_TAB_MOCK_DS.simulation_file = str(ASPEN_BKP_FILE_PATH) return HESSIAN_TAB_MOCK_DS
def main(): ds = DataStorage()
class MainWindow(QMainWindow): _DOETAB_IDX = 1 _METAMODELTAB_IDX = 2 _OPTTAB_IDX = 3 _REDSPACETAB_IDX = 4 _HESSIANTAB_IDX = 5 _SOCTAB_IDX = 6 def __init__(self): # ------------------------- UI Initialization ------------------------- super().__init__() self.ui = Ui_MainWindow() self.ui.setupUi(self) self.setWindowState(Qt.WindowMaximized) self.setWindowTitle('Metacontrol - untitled.mtc') maintab = self.ui.tabMainWidget # disable the tabs maintab.setTabEnabled(self._DOETAB_IDX, False) maintab.setTabEnabled(self._METAMODELTAB_IDX, False) maintab.setTabEnabled(self._OPTTAB_IDX, False) maintab.setTabEnabled(self._HESSIANTAB_IDX, False) maintab.setTabEnabled(self._SOCTAB_IDX, False) # ------------------------ Internal variables ------------------------- self.application_database = DataStorage() # ----------------------- Load the tabs widgets ----------------------- self.tab_loadsim = LoadSimTab(self.application_database, parent_tab=self.ui.simulationTab) self.tab_doe = DoeTab(self.application_database, parent_tab=self.ui.samplingTab) self.tab_metamodel = MetamodelTab(self.application_database, parent_tab=self.ui.metamodelTab) self.tab_optimization = OptimizationTab( self.application_database, parent_tab=self.ui.optimizationTab) self.tab_reducedspace = ReducedSpaceTab( self.application_database, parent_tab=self.ui.reducedspaceTab) self.tab_hessianext = HessianExtractionTab( self.application_database, parent_tab=self.ui.hessianextractionTab) self.tab_soc = SocTab(self.application_database, parent_tab=self.ui.socTab) # ------------------------ Actions connections ------------------------ self.ui.actionOpen.triggered.connect(self.open_file) self.ui.actionSave.triggered.connect(self.save_file) self.ui.actionSave_As.triggered.connect(self.save_file_as) # --------------------------- Signals/Slots --------------------------- # sampling tab enabled self.application_database.sampling_enabled.connect( self.on_sampling_enabled) # metamodel tab enabled self.application_database.metamodel_enabled.connect( self.on_metamodel_enabled) # optimization tab enabled self.application_database.metamodel_enabled.connect( self.on_optimization_enabled) # hessian tab enabled self.application_database.hessian_enabled.connect( self.on_hessianextraction_enabled) # soc tab enabled self.application_database.soc_enabled.connect(self.on_soc_enabled) def open_file(self): """Prompts the user to select which .mtc file to open. """ homedir = pathlib.Path().home() mtc_filename, _ = \ QFileDialog.getOpenFileName(self, "Select the .mtc file to open.", str(homedir), "Metacontrol files (*.mtc)") if mtc_filename != "": # the user provided a valid file (did not canceled the dialog). self.application_database.load(mtc_filename) # update the window title self.setWindowTitle("Metacontrol - " + mtc_filename) def save_file(self): """Saves the current application configuration as is. If it is a new file prompts the user to select the location and name of the .mtc file. """ current_mtc_name = self.windowTitle().split('Metacontrol - ')[1] if pathlib.Path(current_mtc_name).is_file(): # file exists, save it self.application_database.save(current_mtc_name) else: # new file, prompt the user self.save_file_as() def save_file_as(self): """Prompts the user to select location and name of the .mtc file to save. """ dialog_title = "Select the name and where to save the .mtc file" filetype = "Metacontrol files (*.mtc)" homedir = pathlib.Path().home() mtc_filepath, _ = QFileDialog.getSaveFileName(self, dialog_title, str(homedir), filetype) if mtc_filepath != '': # change the window title self.setWindowTitle("Metacontrol - " + mtc_filepath) # save the file self.application_database.save(mtc_filepath) def on_sampling_enabled(self, is_enabled): self.ui.tabMainWidget.setTabEnabled(self._DOETAB_IDX, is_enabled) def on_metamodel_enabled(self, is_enabled): self.ui.tabMainWidget.setTabEnabled(self._METAMODELTAB_IDX, is_enabled) def on_optimization_enabled(self, is_enabled): self.ui.tabMainWidget.setTabEnabled(self._OPTTAB_IDX, is_enabled) def on_hessianextraction_enabled(self, is_enabled): self.ui.tabMainWidget.setTabEnabled(self._HESSIANTAB_IDX, is_enabled) def on_soc_enabled(self, is_enabled): self.ui.tabMainWidget.setTabEnabled(self._SOCTAB_IDX, is_enabled)
if current_txt != 'Select header': if self.mode == 'original': self.app_data.doe_csv_settings['convergence_index'] = \ current_txt else: self.app_data.reduced_doe_csv_settings['convergence_index'] = \ current_txt self.ui.buttonBox.setEnabled(True) else: self.ui.buttonBox.setEnabled(False) if __name__ == "__main__": import sys from gui.calls.base import my_exception_hook app = QApplication(sys.argv) header_list = ['case', 'status', 'rr', 'df', 'd', 'xb', 'b', 'qr', 'l', 'v', 'f', 'xd'] ds = DataStorage() w = ConvergenceSelectorDialog(headers_list=header_list, application_data=ds) w.show() sys.excepthook = my_exception_hook sys.exit(app.exec_())