diff --git a/src/Solver/ASolver.py b/src/Solver/ASolver.py index 310e2772ed31564487ff5ccaaf6456fa4ad208b5..830d296e32be39625ba45fbff9e6065090392112 100644 --- a/src/Solver/ASolver.py +++ b/src/Solver/ASolver.py @@ -4,6 +4,8 @@ import os import subprocess from enum import Enum +from Model.Except import NotImplementedMethodeError + class STATUS(Enum): STOPED = 0 RUNNING = 1 @@ -53,6 +55,13 @@ class AbstractSolver(object): return lst + @classmethod + def checker(cls): + lst = [ + ] + + return lst + @property def name(self): return self._name diff --git a/src/View/ASubWindow.py b/src/View/ASubWindow.py index 6091c6de13c081001e5dddcc103a3a53f7570fe1..5bf0940ca66d07f3c12b5537dae6d74f5e4a487c 100644 --- a/src/View/ASubWindow.py +++ b/src/View/ASubWindow.py @@ -329,6 +329,19 @@ class ASubWindowFeatures(object): """ 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): """Set current text of combo box diff --git a/src/View/Configure/Window.py b/src/View/Configure/Window.py index 43ee4528d0103a09b801a9321b89916570711773..c0c1b104b306e500b4742b35df6bfb3c61780d2f 100644 --- a/src/View/Configure/Window.py +++ b/src/View/Configure/Window.py @@ -92,7 +92,7 @@ class ConfigureWindow(ASubWindow, ListedSubWindow): table = self.find(QTableView, "tableView_solver") self.solver_table_model = SolverTableModel( headers = ["name", "type", "description"], - rows = conf.solvers.copy() + rows = conf.solvers ) table.setModel(self.solver_table_model) table.setSelectionBehavior(QAbstractItemView.SelectRows) diff --git a/src/View/MainWindow.py b/src/View/MainWindow.py index 3f0b5adc3b0dc07d28eb8c7370fdfaca442b90fc..bc79d2fb97e7321deb0361adc23406aeddfd8ac8 100644 --- a/src/View/MainWindow.py +++ b/src/View/MainWindow.py @@ -377,9 +377,11 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): def run_solver(self): run = SelectSolverWindow( study = self.model, + config = self.conf, parent = self ) - run.show() + if run.exec(): + solver = run.solver # TODO: Delete me ! ############### diff --git a/src/View/RunSolver/Window.py b/src/View/RunSolver/Window.py new file mode 100644 index 0000000000000000000000000000000000000000..024e0d96019002d9480495cedb61e4864de4434f --- /dev/null +++ b/src/View/RunSolver/Window.py @@ -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() diff --git a/src/View/ui/CheckList.ui b/src/View/ui/CheckList.ui new file mode 100644 index 0000000000000000000000000000000000000000..79589e5e3e4c6ec18e7378e321b7bf76ca376a32 --- /dev/null +++ b/src/View/ui/CheckList.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="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> diff --git a/src/View/ui/SelectSolver.ui b/src/View/ui/SelectSolver.ui new file mode 100644 index 0000000000000000000000000000000000000000..c621bdd43fc93de8cbdb9d009bd77ae5736f7745 --- /dev/null +++ b/src/View/ui/SelectSolver.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> diff --git a/src/View/ui/SolverLog.ui b/src/View/ui/SolverLog.ui new file mode 100644 index 0000000000000000000000000000000000000000..c236fb51f31fb9d41364473bfa306e6d73a93876 --- /dev/null +++ b/src/View/ui/SolverLog.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> diff --git a/src/config.py b/src/config.py index 028adbdac4e705298908f2c3b508eb2c60e38349..60550351bcc4c5f0f241f5ea69e4b6a3debb49b2 100644 --- a/src/config.py +++ b/src/config.py @@ -16,8 +16,9 @@ class Config(object): self.set_default_value() def set_default_value(self): + print('toto') # Solvers - self.solvers = [] + self._solvers = [] # Meshing tool self.meshing_tool = "" @@ -40,7 +41,7 @@ class Config(object): @classmethod def filename(cls): - return os.path.expanduser('~user') + config_dir + config_file + return os.path.expanduser('~') + config_dir + config_file @classmethod def languages(cls): @@ -50,6 +51,14 @@ class Config(object): "French": "fr", } + @property + def solvers(self): + return self._solvers.copy() + + @solvers.setter + def solvers(self, solvers): + self._solvers = solvers + def save(self): os.makedirs(os.path.dirname(self.filename), exist_ok=True) with open(self.filename, 'wb') as out_file: