def addShowCaseInfo(self): self.addTab("Case Info") case_widget = HelpedWidget("Select case", "init/select_case_for_info") model = AllCasesModel() self.combo = QComboBox() self.combo.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLength) self.combo.setMinimumContentsLength(20) self.combo.setModel(model) self.combo.currentIndexChanged.connect(self.showInfoForCase) case_widget.addWidget(self.combo) case_widget.addStretch() self.addRow(case_widget) area_widget = HelpedWidget("Case info", "init/selected_case_info") self.text_area = QTextEdit() self.text_area.setReadOnly(True) self.text_area.setMinimumHeight(300) area_widget.addWidget(self.text_area) area_widget.addStretch() self.addRow(area_widget) choice = CaseSelectorModel().getCurrentChoice() self.combo.setCurrentIndex(model.indexOf(choice))
def __init__(self): QWidget.__init__(self) self.setMinimumWidth(500) self.setMinimumHeight(200) self.__dynamic = False self.setWindowTitle("Load results manually") self.activateWindow() layout = QFormLayout() current_case = CaseSelectorModel().getCurrentChoice() run_path_text = QTextEdit() run_path_text.setText(self.readCurrentRunPath()) run_path_text.setDisabled(True) run_path_text.setFixedHeight(80) layout.addRow("Load data from current run path: ", run_path_text) self.__case_model = AllCasesModel() self.__case_combo = QComboBox() self.__case_combo.setSizeAdjustPolicy( QComboBox.AdjustToMinimumContentsLength) self.__case_combo.setMinimumContentsLength(20) self.__case_combo.setModel(self.__case_model) self.__case_combo.setCurrentIndex( self.__case_model.indexOf(current_case)) layout.addRow("Load into case:", self.__case_combo) self.__active_realizations_model = LoadResultsRealizationsModel( EnsembleSizeModel().getValue()) self.__active_realizations_field = StringBox( self.__active_realizations_model, "Realizations to load", "load_results_manually/Realizations") self.__active_realizations_field.setValidator(RangeStringArgument()) layout.addRow(self.__active_realizations_field.getLabel(), self.__active_realizations_field) self.__iterations_count = LoadResultsModel().getIterationCount() self._iterations_model = LoadResultsIterationsModel( self.__iterations_count) self._iterations_field = StringBox(self._iterations_model, "Iteration to load", "load_results_manually/iterations") self._iterations_field.setValidator(IntegerArgument()) layout.addRow(self._iterations_field.getLabel(), self._iterations_field) self.setLayout(layout)
def __init__(self): QWidget.__init__(self) self.setMinimumWidth(500) self.setMinimumHeight(200) self.__dynamic = False self.setWindowTitle("Load results manually") self.activateWindow() layout = QFormLayout() current_case = CaseSelectorModel().getCurrentChoice() run_path_text = QTextEdit() run_path_text.setText(self.readCurrentRunPath()) run_path_text.setDisabled(True) run_path_text.setFixedHeight(80) layout.addRow("Load data from current run path: ",run_path_text) self.__case_model = AllCasesModel() self.__case_combo = QComboBox() self.__case_combo.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLength) self.__case_combo.setMinimumContentsLength(20) self.__case_combo.setModel(self.__case_model) self.__case_combo.setCurrentIndex(self.__case_model.indexOf(current_case)) layout.addRow("Load into case:",self.__case_combo) self.__active_realizations_model = LoadResultsRealizationsModel(EnsembleSizeModel().getValue()) self.__active_realizations_field = StringBox(self.__active_realizations_model, "Realizations to load", "load_results_manually/Realizations") self.__active_realizations_field.setValidator(RangeStringArgument()) layout.addRow(self.__active_realizations_field.getLabel(), self.__active_realizations_field) self.__iterations_count = LoadResultsModel().getIterationCount() self._iterations_model = LoadResultsIterationsModel(self.__iterations_count) self._iterations_field = StringBox(self._iterations_model, "Iteration to load", "load_results_manually/iterations") self._iterations_field.setValidator(IntegerArgument()) layout.addRow(self._iterations_field.getLabel(), self._iterations_field) self.setLayout(layout)
def __init__(self, parent=None): QWidget.__init__(self, parent) self.setMinimumWidth(500) self.setMinimumHeight(200) self.__dynamic = False self.setWindowTitle("Export data") self.activateWindow() layout = QFormLayout() current_case = CaseSelectorModel().getCurrentChoice() self.__case_model = AllCasesModel() self.__case_combo = QComboBox() self.__case_combo.setSizeAdjustPolicy( QComboBox.AdjustToMinimumContentsLength) self.__case_combo.setMinimumContentsLength(20) self.__case_combo.setModel(self.__case_model) self.__case_combo.setCurrentIndex( self.__case_model.indexOf(current_case)) layout.addRow("Select case:", self.__case_combo) self.__export_keyword_model = ExportKeywordModel() self.__kw_model = self.__export_keyword_model.getKeyWords() self.__keywords = QComboBox() self.__keywords.addItems(self.__kw_model) layout.addRow("Select keyword:", self.__keywords) self.__active_realizations_model = ExportRealizationsModel( EnsembleSizeModel().getValue()) self.__active_realizations_field = StringBox( self.__active_realizations_model, "Active realizations", "config/simulation/active_realizations") self.__active_realizations_field.setValidator(RangeStringArgument()) self.__active_realizations_field.validationChanged.connect( self.validateExportDialog) layout.addRow(self.__active_realizations_field.getLabel(), self.__active_realizations_field) file_name_button = QToolButton() file_name_button.setText("Browse") file_name_button.clicked.connect(self.selectFileDirectory) self.__defaultPath = QDir.currentPath() + "/export" self.__file_name = QLineEdit() self.__file_name.setEnabled(False) self.__file_name.setText(self.__defaultPath) self.__file_name.textChanged.connect(self.validateExportDialog) self.__file_name.setMinimumWidth(250) file_name_layout = QHBoxLayout() file_name_layout.addWidget(self.__file_name) file_name_layout.addWidget(file_name_button) layout.addRow("Select directory to save files to:", file_name_layout) self.__gen_kw_file_types = ["Parameter list", "Template based"] self.__field_kw_file_types = ["Eclipse GRDECL", "RMS roff"] self.__gen_data_file_types = ["Gen data"] self.__file_type_model = self.__field_kw_file_types self.__file_type_combo = QComboBox() self.__file_type_combo.setSizeAdjustPolicy(QComboBox.AdjustToContents) self.__file_type_combo.addItems(self.__file_type_model) layout.addRow("Select file format:", self.__file_type_combo) self.__report_step = QLineEdit() layout.addRow("Report step:", self.__report_step) self.__gen_data_report_step_model = [] self.__gen_data_report_step = QComboBox() layout.addRow("Report step:", self.__gen_data_report_step) self.setLayout(layout) self.__keywords.currentIndexChanged.connect(self.keywordSelected) self.keywordSelected()
class ExportPanel(QWidget): updateExportButton = pyqtSignal(str, bool) runExport = pyqtSignal(dict) def __init__(self, parent=None): QWidget.__init__(self, parent) self.setMinimumWidth(500) self.setMinimumHeight(200) self.__dynamic = False self.setWindowTitle("Export data") self.activateWindow() layout = QFormLayout() current_case = CaseSelectorModel().getCurrentChoice() self.__case_model = AllCasesModel() self.__case_combo = QComboBox() self.__case_combo.setSizeAdjustPolicy( QComboBox.AdjustToMinimumContentsLength) self.__case_combo.setMinimumContentsLength(20) self.__case_combo.setModel(self.__case_model) self.__case_combo.setCurrentIndex( self.__case_model.indexOf(current_case)) layout.addRow("Select case:", self.__case_combo) self.__export_keyword_model = ExportKeywordModel() self.__kw_model = self.__export_keyword_model.getKeyWords() self.__keywords = QComboBox() self.__keywords.addItems(self.__kw_model) layout.addRow("Select keyword:", self.__keywords) self.__active_realizations_model = ExportRealizationsModel( EnsembleSizeModel().getValue()) self.__active_realizations_field = StringBox( self.__active_realizations_model, "Active realizations", "config/simulation/active_realizations") self.__active_realizations_field.setValidator(RangeStringArgument()) self.__active_realizations_field.validationChanged.connect( self.validateExportDialog) layout.addRow(self.__active_realizations_field.getLabel(), self.__active_realizations_field) file_name_button = QToolButton() file_name_button.setText("Browse") file_name_button.clicked.connect(self.selectFileDirectory) self.__defaultPath = QDir.currentPath() + "/export" self.__file_name = QLineEdit() self.__file_name.setEnabled(False) self.__file_name.setText(self.__defaultPath) self.__file_name.textChanged.connect(self.validateExportDialog) self.__file_name.setMinimumWidth(250) file_name_layout = QHBoxLayout() file_name_layout.addWidget(self.__file_name) file_name_layout.addWidget(file_name_button) layout.addRow("Select directory to save files to:", file_name_layout) self.__gen_kw_file_types = ["Parameter list", "Template based"] self.__field_kw_file_types = ["Eclipse GRDECL", "RMS roff"] self.__gen_data_file_types = ["Gen data"] self.__file_type_model = self.__field_kw_file_types self.__file_type_combo = QComboBox() self.__file_type_combo.setSizeAdjustPolicy(QComboBox.AdjustToContents) self.__file_type_combo.addItems(self.__file_type_model) layout.addRow("Select file format:", self.__file_type_combo) self.__report_step = QLineEdit() layout.addRow("Report step:", self.__report_step) self.__gen_data_report_step_model = [] self.__gen_data_report_step = QComboBox() layout.addRow("Report step:", self.__gen_data_report_step) self.setLayout(layout) self.__keywords.currentIndexChanged.connect(self.keywordSelected) self.keywordSelected() def selectFileDirectory(self): directory = QFileDialog().getExistingDirectory( self, "Directory", self.__file_name.text(), QFileDialog.ShowDirsOnly) if str(directory).__len__() > 0: self.__file_name.setText(str(directory)) def updateFileExportType(self, keyword): self.__file_type_combo.clear() if self.__export_keyword_model.isGenKw(keyword): self.__file_type_model = self.__gen_kw_file_types elif self.__export_keyword_model.isGenParamKw(keyword): self.__file_type_model = self.__gen_data_file_types elif self.__export_keyword_model.isGenDataKw(keyword): self.__file_type_model = self.__gen_data_file_types else: self.__file_type_model = self.__field_kw_file_types self.__file_type_combo.addItems(self.__file_type_model) def export(self): keyword = self.__kw_model[self.__keywords.currentIndex()] report_step = self.getReportStep(keyword) all_cases = self.__case_model.getAllItems() selected_case = all_cases[self.__case_combo.currentIndex()] path = self.__file_name.text() iactive = self.__active_realizations_model.getActiveRealizationsMask() file_type_key = self.__file_type_model[ self.__file_type_combo.currentIndex()] values = { "keyword": keyword, "report_step": report_step, "iactive": iactive, "file_type_key": file_type_key, "path": path, "selected_case": selected_case } self.runExport.emit(values) def getReportStep(self, key): report_step = 0 if self.__dynamic: report_step = self.__report_step.text() if self.__export_keyword_model.isGenParamKw(key): return report_step if self.__export_keyword_model.isGenDataKw(key): report_step = self.__gen_data_report_step_model[ self.__gen_data_report_step.currentIndex()] return report_step def keywordSelected(self): key = self.__kw_model[self.__keywords.currentIndex()] self.updateFileExportType(key) self.__dynamic = False if self.__export_keyword_model.isFieldKw(key): self.__dynamic = self.__export_keyword_model.isDynamicField(key) self.__report_step.setVisible(self.__dynamic) self.layout().labelForField(self.__report_step).setVisible( self.__dynamic) self.__gen_data_report_step.setVisible( self.__export_keyword_model.isGenDataKw(key)) self.layout().labelForField(self.__gen_data_report_step).setVisible( self.__export_keyword_model.isGenDataKw(key)) if self.__export_keyword_model.isGenDataKw(key): data = self.__export_keyword_model.getGenDataReportSteps(key) self.__gen_data_report_step_model = data self.__gen_data_report_step.clear() self.__gen_data_report_step.addItems( self.__gen_data_report_step_model) def setSelectedCase(self, selected_case): self.__case_combo.setCurrentIndex( self.__case_model.indexOf(selected_case)) def validateExportDialog(self): validRealizations = False if self.__active_realizations_field.isValid(): validRealizations = True path = str(self.__file_name.text()) validPath = len(path) > 0 if validRealizations and validPath: self.updateExportButton.emit("export", True) else: self.updateExportButton.emit("export", False)
def __init__(self, parent=None): QWidget.__init__(self, parent) self.setMinimumWidth(500) self.setMinimumHeight(200) self.__dynamic = False self.setWindowTitle("Export data") self.activateWindow() layout = QFormLayout() current_case = CaseSelectorModel().getCurrentChoice() self.__case_model = AllCasesModel() self.__case_combo = QComboBox() self.__case_combo.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLength) self.__case_combo.setMinimumContentsLength(20) self.__case_combo.setModel(self.__case_model) self.__case_combo.setCurrentIndex(self.__case_model.indexOf(current_case)) layout.addRow("Select case:",self.__case_combo) self.__export_keyword_model = ExportKeywordModel() self.__kw_model = self.__export_keyword_model.getKeyWords() self.__keywords = QComboBox() self.__keywords.addItems(self.__kw_model) layout.addRow("Select keyword:",self.__keywords) self.__active_realizations_model = ExportRealizationsModel(EnsembleSizeModel().getValue()) self.__active_realizations_field = StringBox(self.__active_realizations_model, "Active realizations", "config/simulation/active_realizations") self.__active_realizations_field.setValidator(RangeStringArgument()) self.__active_realizations_field.validationChanged.connect(self.validateExportDialog) layout.addRow(self.__active_realizations_field.getLabel(), self.__active_realizations_field) file_name_button= QToolButton() file_name_button.setText("Browse") file_name_button.clicked.connect(self.selectFileDirectory) self.__defaultPath = QDir.currentPath()+"/export" self.__file_name = QLineEdit() self.__file_name.setEnabled(False) self.__file_name.setText(self.__defaultPath) self.__file_name.textChanged.connect(self.validateExportDialog) self.__file_name.setMinimumWidth(250) file_name_layout = QHBoxLayout() file_name_layout.addWidget(self.__file_name) file_name_layout.addWidget(file_name_button) layout.addRow("Select directory to save files to:", file_name_layout) self.__gen_kw_file_types = ["Parameter list", "Template based"] self.__field_kw_file_types = ["Eclipse GRDECL", "RMS roff"] self.__gen_data_file_types = ["Gen data"] self.__file_type_model = self.__field_kw_file_types self.__file_type_combo = QComboBox() self.__file_type_combo.setSizeAdjustPolicy(QComboBox.AdjustToContents) self.__file_type_combo.addItems(self.__file_type_model) layout.addRow("Select file format:",self.__file_type_combo) self.__report_step = QLineEdit() layout.addRow("Report step:", self.__report_step) self.__gen_data_report_step_model=[] self.__gen_data_report_step = QComboBox() layout.addRow("Report step:", self.__gen_data_report_step) self.setLayout(layout) self.__keywords.currentIndexChanged.connect(self.keywordSelected) self.keywordSelected()
class ExportPanel(QWidget): updateExportButton = pyqtSignal(str, bool) runExport = pyqtSignal(dict) def __init__(self, parent=None): QWidget.__init__(self, parent) self.setMinimumWidth(500) self.setMinimumHeight(200) self.__dynamic = False self.setWindowTitle("Export data") self.activateWindow() layout = QFormLayout() current_case = CaseSelectorModel().getCurrentChoice() self.__case_model = AllCasesModel() self.__case_combo = QComboBox() self.__case_combo.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLength) self.__case_combo.setMinimumContentsLength(20) self.__case_combo.setModel(self.__case_model) self.__case_combo.setCurrentIndex(self.__case_model.indexOf(current_case)) layout.addRow("Select case:",self.__case_combo) self.__export_keyword_model = ExportKeywordModel() self.__kw_model = self.__export_keyword_model.getKeyWords() self.__keywords = QComboBox() self.__keywords.addItems(self.__kw_model) layout.addRow("Select keyword:",self.__keywords) self.__active_realizations_model = ExportRealizationsModel(EnsembleSizeModel().getValue()) self.__active_realizations_field = StringBox(self.__active_realizations_model, "Active realizations", "config/simulation/active_realizations") self.__active_realizations_field.setValidator(RangeStringArgument()) self.__active_realizations_field.validationChanged.connect(self.validateExportDialog) layout.addRow(self.__active_realizations_field.getLabel(), self.__active_realizations_field) file_name_button= QToolButton() file_name_button.setText("Browse") file_name_button.clicked.connect(self.selectFileDirectory) self.__defaultPath = QDir.currentPath()+"/export" self.__file_name = QLineEdit() self.__file_name.setEnabled(False) self.__file_name.setText(self.__defaultPath) self.__file_name.textChanged.connect(self.validateExportDialog) self.__file_name.setMinimumWidth(250) file_name_layout = QHBoxLayout() file_name_layout.addWidget(self.__file_name) file_name_layout.addWidget(file_name_button) layout.addRow("Select directory to save files to:", file_name_layout) self.__gen_kw_file_types = ["Parameter list", "Template based"] self.__field_kw_file_types = ["Eclipse GRDECL", "RMS roff"] self.__gen_data_file_types = ["Gen data"] self.__file_type_model = self.__field_kw_file_types self.__file_type_combo = QComboBox() self.__file_type_combo.setSizeAdjustPolicy(QComboBox.AdjustToContents) self.__file_type_combo.addItems(self.__file_type_model) layout.addRow("Select file format:",self.__file_type_combo) self.__report_step = QLineEdit() layout.addRow("Report step:", self.__report_step) self.__gen_data_report_step_model=[] self.__gen_data_report_step = QComboBox() layout.addRow("Report step:", self.__gen_data_report_step) self.setLayout(layout) self.__keywords.currentIndexChanged.connect(self.keywordSelected) self.keywordSelected() def selectFileDirectory(self): directory = QFileDialog().getExistingDirectory(self, "Directory", self.__file_name.text(), QFileDialog.ShowDirsOnly) if str(directory).__len__() > 0: self.__file_name.setText(str(directory)) def updateFileExportType(self, keyword): self.__file_type_combo.clear() if self.__export_keyword_model.isGenKw(keyword): self.__file_type_model = self.__gen_kw_file_types elif self.__export_keyword_model.isGenParamKw(keyword): self.__file_type_model = self.__gen_data_file_types elif self.__export_keyword_model.isGenDataKw(keyword): self.__file_type_model = self.__gen_data_file_types else: self.__file_type_model = self.__field_kw_file_types self.__file_type_combo.addItems(self.__file_type_model) def export(self): keyword = self.__kw_model[self.__keywords.currentIndex()] report_step = self.getReportStep(keyword) all_cases = self.__case_model.getAllItems() selected_case = all_cases[self.__case_combo.currentIndex()] path = self.__file_name.text() iactive = self.__active_realizations_model.getActiveRealizationsMask() file_type_key = self.__file_type_model[self.__file_type_combo.currentIndex()] values = {"keyword":keyword, "report_step":report_step, "iactive":iactive,"file_type_key":file_type_key, "path":path , "selected_case" : selected_case} self.runExport.emit(values) def getReportStep(self, key): report_step = 0 if self.__dynamic: report_step = self.__report_step.text() if self.__export_keyword_model.isGenParamKw(key): return report_step if self.__export_keyword_model.isGenDataKw(key): report_step = self.__gen_data_report_step_model[self.__gen_data_report_step.currentIndex()] return report_step def keywordSelected(self): key = self.__kw_model[self.__keywords.currentIndex()] self.updateFileExportType(key) self.__dynamic = False if self.__export_keyword_model.isFieldKw(key): self.__dynamic = self.__export_keyword_model.isDynamicField(key) self.__report_step.setVisible(self.__dynamic) self.layout().labelForField(self.__report_step).setVisible(self.__dynamic) self.__gen_data_report_step.setVisible(self.__export_keyword_model.isGenDataKw(key)) self.layout().labelForField(self.__gen_data_report_step).setVisible(self.__export_keyword_model.isGenDataKw(key)) if self.__export_keyword_model.isGenDataKw(key): data = self.__export_keyword_model.getGenDataReportSteps(key) self.__gen_data_report_step_model = data self.__gen_data_report_step.clear() self.__gen_data_report_step.addItems(self.__gen_data_report_step_model) def setSelectedCase(self, selected_case): self.__case_combo.setCurrentIndex(self.__case_model.indexOf(selected_case)) def validateExportDialog(self): validRealizations = False if self.__active_realizations_field.isValid(): validRealizations = True path = str(self.__file_name.text()) validPath = len(path) > 0 if validRealizations and validPath: self.updateExportButton.emit("export", True) else: self.updateExportButton.emit("export", False)