mirror of https://gitlab.com/pamhyr/pamhyr2
MainWindow: Add solver selection dialog and prepare other solver run window.
parent
314ae4d249
commit
9d4e51bf22
|
|
@ -4,6 +4,8 @@ import os
|
||||||
import subprocess
|
import subprocess
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
|
from Model.Except import NotImplementedMethodeError
|
||||||
|
|
||||||
class STATUS(Enum):
|
class STATUS(Enum):
|
||||||
STOPED = 0
|
STOPED = 0
|
||||||
RUNNING = 1
|
RUNNING = 1
|
||||||
|
|
@ -53,6 +55,13 @@ class AbstractSolver(object):
|
||||||
|
|
||||||
return lst
|
return lst
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def checker(cls):
|
||||||
|
lst = [
|
||||||
|
]
|
||||||
|
|
||||||
|
return lst
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
return self._name
|
return self._name
|
||||||
|
|
|
||||||
|
|
@ -329,6 +329,19 @@ class ASubWindowFeatures(object):
|
||||||
"""
|
"""
|
||||||
self.find(QComboBox, name).addItem(item)
|
self.find(QComboBox, name).addItem(item)
|
||||||
|
|
||||||
|
def combobox_add_items(self, name:str, items:str):
|
||||||
|
"""Add item in combo box
|
||||||
|
|
||||||
|
Args:
|
||||||
|
name: The combo box component name
|
||||||
|
item: The item to add
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Nothing
|
||||||
|
"""
|
||||||
|
for item in items:
|
||||||
|
self.find(QComboBox, name).addItem(item)
|
||||||
|
|
||||||
def set_combobox_text(self, name:str, item:str):
|
def set_combobox_text(self, name:str, item:str):
|
||||||
"""Set current text of combo box
|
"""Set current text of combo box
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ class ConfigureWindow(ASubWindow, ListedSubWindow):
|
||||||
table = self.find(QTableView, "tableView_solver")
|
table = self.find(QTableView, "tableView_solver")
|
||||||
self.solver_table_model = SolverTableModel(
|
self.solver_table_model = SolverTableModel(
|
||||||
headers = ["name", "type", "description"],
|
headers = ["name", "type", "description"],
|
||||||
rows = conf.solvers.copy()
|
rows = conf.solvers
|
||||||
)
|
)
|
||||||
table.setModel(self.solver_table_model)
|
table.setModel(self.solver_table_model)
|
||||||
table.setSelectionBehavior(QAbstractItemView.SelectRows)
|
table.setSelectionBehavior(QAbstractItemView.SelectRows)
|
||||||
|
|
|
||||||
|
|
@ -377,9 +377,11 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||||
def run_solver(self):
|
def run_solver(self):
|
||||||
run = SelectSolverWindow(
|
run = SelectSolverWindow(
|
||||||
study = self.model,
|
study = self.model,
|
||||||
|
config = self.conf,
|
||||||
parent = self
|
parent = self
|
||||||
)
|
)
|
||||||
run.show()
|
if run.exec():
|
||||||
|
solver = run.solver
|
||||||
|
|
||||||
# TODO: Delete me !
|
# TODO: Delete me !
|
||||||
###############
|
###############
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,68 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from tools import trace, timer
|
||||||
|
|
||||||
|
from View.ASubWindow import ASubWindow
|
||||||
|
from View.ListedSubWindow import ListedSubWindow
|
||||||
|
|
||||||
|
from PyQt5.QtGui import (
|
||||||
|
QKeySequence,
|
||||||
|
)
|
||||||
|
|
||||||
|
from PyQt5.QtCore import (
|
||||||
|
Qt, QVariant, QAbstractTableModel,
|
||||||
|
QCoreApplication, QModelIndex, pyqtSlot,
|
||||||
|
QRect,
|
||||||
|
)
|
||||||
|
|
||||||
|
from PyQt5.QtWidgets import (
|
||||||
|
QDialogButtonBox, QPushButton, QLineEdit,
|
||||||
|
QFileDialog, QTableView, QAbstractItemView,
|
||||||
|
QUndoStack, QShortcut, QAction, QItemDelegate,
|
||||||
|
QComboBox, QVBoxLayout, QHeaderView, QTabWidget,
|
||||||
|
)
|
||||||
|
|
||||||
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
|
class SelectSolverWindow(ASubWindow, ListedSubWindow):
|
||||||
|
def __init__(self, title="Select solver",
|
||||||
|
study=None, config=None,
|
||||||
|
parent=None):
|
||||||
|
self._title = title
|
||||||
|
|
||||||
|
self._study = study
|
||||||
|
self._config = config
|
||||||
|
self._solver = None
|
||||||
|
|
||||||
|
super(SelectSolverWindow, self).__init__(
|
||||||
|
name=self._title, ui="SelectSolver", parent=parent
|
||||||
|
)
|
||||||
|
self.ui.setWindowTitle(self._title)
|
||||||
|
|
||||||
|
self.setup_combobox()
|
||||||
|
self.setup_connections()
|
||||||
|
|
||||||
|
def setup_combobox(self):
|
||||||
|
solvers = self._config.solvers
|
||||||
|
solvers_name = list(map(lambda s: s.name, solvers))
|
||||||
|
|
||||||
|
self.combobox_add_items("comboBox", solvers_name)
|
||||||
|
|
||||||
|
def setup_connections(self):
|
||||||
|
self.find(QPushButton, "pushButton_run").clicked.connect(self.accept)
|
||||||
|
self.find(QPushButton, "pushButton_cancel").clicked.connect(self.reject)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def solver(self):
|
||||||
|
return self._solver
|
||||||
|
|
||||||
|
def accept(self):
|
||||||
|
solver_name = self.get_combobox_text("comboBox")
|
||||||
|
self._solver = next(
|
||||||
|
filter(
|
||||||
|
lambda s: s.name == solver_name,
|
||||||
|
self._config.solvers
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
super(SelectSolverWindow, self).accept()
|
||||||
|
|
@ -0,0 +1,78 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>MainWindow</class>
|
||||||
|
<widget class="QMainWindow" name="MainWindow">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>640</width>
|
||||||
|
<height>480</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>MainWindow</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="centralwidget">
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QListView" name="listView"/>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QProgressBar" name="progressBar">
|
||||||
|
<property name="value">
|
||||||
|
<number>24</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::Retry</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QStatusBar" name="statusbar"/>
|
||||||
|
<widget class="QToolBar" name="toolBar">
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>toolBar</string>
|
||||||
|
</property>
|
||||||
|
<attribute name="toolBarArea">
|
||||||
|
<enum>TopToolBarArea</enum>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="toolBarBreak">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
|
<addaction name="action_retry"/>
|
||||||
|
<addaction name="action_cancel"/>
|
||||||
|
</widget>
|
||||||
|
<action name="action_retry">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset>
|
||||||
|
<normaloff>ressources/gtk-ok.png</normaloff>ressources/gtk-ok.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Retry</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Retry check</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="action_cancel">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset>
|
||||||
|
<normaloff>ressources/gtk-stop.png</normaloff>ressources/gtk-stop.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Cancel</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
|
|
@ -0,0 +1,62 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>Dialog</class>
|
||||||
|
<widget class="QDialog" name="Dialog">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>320</width>
|
||||||
|
<height>80</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Dialog</string>
|
||||||
|
</property>
|
||||||
|
<property name="locale">
|
||||||
|
<locale language="English" country="Europe"/>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QComboBox" name="comboBox"/>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pushButton_cancel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Cancel</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pushButton_run">
|
||||||
|
<property name="text">
|
||||||
|
<string>Run</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset>
|
||||||
|
<normaloff>ressources/player_play.png</normaloff>ressources/player_play.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
|
|
@ -0,0 +1,78 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>MainWindow</class>
|
||||||
|
<widget class="QMainWindow" name="MainWindow">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>640</width>
|
||||||
|
<height>480</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>MainWindow</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="centralwidget">
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QTextEdit" name="textEdit"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QMenuBar" name="menubar">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>640</width>
|
||||||
|
<height>22</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QStatusBar" name="statusbar"/>
|
||||||
|
<widget class="QToolBar" name="toolBar">
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>toolBar</string>
|
||||||
|
</property>
|
||||||
|
<attribute name="toolBarArea">
|
||||||
|
<enum>TopToolBarArea</enum>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="toolBarBreak">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
|
<addaction name="action_start"/>
|
||||||
|
<addaction name="action_pause"/>
|
||||||
|
<addaction name="action_stop"/>
|
||||||
|
</widget>
|
||||||
|
<action name="action_stop">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset>
|
||||||
|
<normaloff>ressources/gtk-stop.png</normaloff>ressources/gtk-stop.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Stop</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="action_start">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset>
|
||||||
|
<normaloff>ressources/player_play.png</normaloff>ressources/player_play.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Start</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="action_pause">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset>
|
||||||
|
<normaloff>ressources/player_pause.png</normaloff>ressources/player_pause.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Pause</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
|
|
@ -16,8 +16,9 @@ class Config(object):
|
||||||
self.set_default_value()
|
self.set_default_value()
|
||||||
|
|
||||||
def set_default_value(self):
|
def set_default_value(self):
|
||||||
|
print('toto')
|
||||||
# Solvers
|
# Solvers
|
||||||
self.solvers = []
|
self._solvers = []
|
||||||
|
|
||||||
# Meshing tool
|
# Meshing tool
|
||||||
self.meshing_tool = ""
|
self.meshing_tool = ""
|
||||||
|
|
@ -40,7 +41,7 @@ class Config(object):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def filename(cls):
|
def filename(cls):
|
||||||
return os.path.expanduser('~user') + config_dir + config_file
|
return os.path.expanduser('~') + config_dir + config_file
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def languages(cls):
|
def languages(cls):
|
||||||
|
|
@ -50,6 +51,14 @@ class Config(object):
|
||||||
"French": "fr",
|
"French": "fr",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@property
|
||||||
|
def solvers(self):
|
||||||
|
return self._solvers.copy()
|
||||||
|
|
||||||
|
@solvers.setter
|
||||||
|
def solvers(self, solvers):
|
||||||
|
self._solvers = solvers
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
os.makedirs(os.path.dirname(self.filename), exist_ok=True)
|
os.makedirs(os.path.dirname(self.filename), exist_ok=True)
|
||||||
with open(self.filename, 'wb') as out_file:
|
with open(self.filename, 'wb') as out_file:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue