mirror of https://gitlab.com/pamhyr/pamhyr2
geometry, results, configure: Some fixes.
parent
acfb876da0
commit
5b2ee80329
|
|
@ -62,6 +62,12 @@ class AbstractModelChecker(object):
|
|||
|
||||
# Abstract function
|
||||
|
||||
def _run(self, study):
|
||||
from Model.Study import Study
|
||||
|
||||
thread_study = Study.open(study._filename)
|
||||
self.run(thread_study)
|
||||
|
||||
def run(self, study):
|
||||
"""Run checker function
|
||||
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ class ProfileXYZ(Profile, SQLSubModel):
|
|||
)
|
||||
|
||||
data["profile"] = new
|
||||
new._points = PointXYZ._sql_load(execute, data)
|
||||
new._points = PointXYZ._sql_load(execute, data.copy())
|
||||
|
||||
yield ind, new
|
||||
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ class Reach(SQLSubModel):
|
|||
data = {}
|
||||
|
||||
ind = 0
|
||||
for profile in self._profiles:
|
||||
for profile in self.profiles:
|
||||
data["ind"] = ind
|
||||
profile._sql_save(execute, data)
|
||||
ind += 1
|
||||
|
|
@ -136,7 +136,7 @@ class Reach(SQLSubModel):
|
|||
def get_profiles_from_kp(self, kp):
|
||||
return list(
|
||||
filter(
|
||||
lambda p: p.kp == kp, self._profiles
|
||||
lambda p: p.kp == kp, self.profiles
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -72,4 +72,6 @@ class StricklersList(PamhyrModelList):
|
|||
key = f,
|
||||
reverse = reverse,
|
||||
)
|
||||
self._status.modified()
|
||||
|
||||
if self._status is not None:
|
||||
self._status.modified()
|
||||
|
|
|
|||
|
|
@ -71,7 +71,8 @@ class PamhyrModelList(SQLSubModel):
|
|||
|
||||
def set(self, row, new):
|
||||
self._lst[row] = new
|
||||
self._status.modified()
|
||||
if self._status is not None:
|
||||
self._status.modified()
|
||||
|
||||
def new(self, index):
|
||||
"""Create new elements and add it to list
|
||||
|
|
@ -86,12 +87,16 @@ class PamhyrModelList(SQLSubModel):
|
|||
|
||||
def insert(self, index, new):
|
||||
self._lst.insert(index, new)
|
||||
self._status.modified()
|
||||
|
||||
if self._status is not None:
|
||||
self._status.modified()
|
||||
|
||||
def delete(self, lst):
|
||||
for el in lst:
|
||||
self._lst.remove(el)
|
||||
self._status.modified()
|
||||
|
||||
if self._status is not None:
|
||||
self._status.modified()
|
||||
|
||||
def delete_i(self, indexes):
|
||||
lst = list(
|
||||
|
|
@ -107,7 +112,9 @@ class PamhyrModelList(SQLSubModel):
|
|||
|
||||
def sort(self, reverse=False, key=None):
|
||||
self._lst.sort(reverse=reverse, key=key)
|
||||
self._status.modified()
|
||||
|
||||
if self._status is not None:
|
||||
self._status.modified()
|
||||
|
||||
def move_up(self, index):
|
||||
if index < len(self._lst):
|
||||
|
|
@ -115,7 +122,9 @@ class PamhyrModelList(SQLSubModel):
|
|||
|
||||
l = self._lst
|
||||
l[index], l[next] = l[next], l[index]
|
||||
self._status.modified()
|
||||
|
||||
if self._status is not None:
|
||||
self._status.modified()
|
||||
|
||||
def move_down(self, index):
|
||||
if index >= 0:
|
||||
|
|
@ -123,7 +132,9 @@ class PamhyrModelList(SQLSubModel):
|
|||
|
||||
l = self._lst
|
||||
l[index], l[prev] = l[prev], l[index]
|
||||
self._status.modified()
|
||||
|
||||
if self._status is not None:
|
||||
self._status.modified()
|
||||
|
||||
|
||||
class PamhyrModelListWithTab(SQLSubModel):
|
||||
|
|
|
|||
|
|
@ -42,6 +42,6 @@ class Worker(QObject):
|
|||
self.signalStatus.emit(checker.name)
|
||||
|
||||
# Run checker
|
||||
checker.run(self._study)
|
||||
checker._run(self._study)
|
||||
|
||||
self.signalStatus.emit("progress")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
# Translate.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from PyQt5.QtCore import QCoreApplication
|
||||
|
||||
from View.Tools.PamhyrTranslate import PamhyrTranslate
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
class ConfigureTranslate(PamhyrTranslate):
|
||||
def __init__(self):
|
||||
super(ConfigureTranslate, self).__init__()
|
||||
|
||||
self._sub_dict["table_headers"] = {
|
||||
"name": _translate("Configure", "Name"),
|
||||
"type": _translate("Configure", "Type"),
|
||||
"description": _translate("Configure", "Description"),
|
||||
}
|
||||
|
|
@ -22,11 +22,13 @@ from copy import deepcopy
|
|||
|
||||
from config import Config
|
||||
from View.Tools.PamhyrWindow import PamhyrDialog
|
||||
from View.Tools.PamhyrTable import PamhyrTableModel
|
||||
|
||||
from View.Stricklers.Table import TableModel
|
||||
from View.Stricklers.translate import *
|
||||
from View.Stricklers.translate import StricklersTranslate
|
||||
from View.Stricklers.UndoCommand import *
|
||||
|
||||
from View.Configure.Translate import ConfigureTranslate
|
||||
from View.Configure.Solver.Window import ConfigureSolverWindow
|
||||
|
||||
from PyQt5.QtGui import (
|
||||
|
|
@ -47,50 +49,28 @@ from Solver.Solvers import solver_long_name
|
|||
|
||||
logger = logging.getLogger()
|
||||
|
||||
class SolverTableModel(QAbstractTableModel):
|
||||
def __init__(self, headers=[], rows=[]):
|
||||
super(QAbstractTableModel, self).__init__()
|
||||
self.rows = rows
|
||||
self.headers = headers
|
||||
|
||||
def rowCount(self, parent):
|
||||
return len(self.rows)
|
||||
|
||||
def columnCount(self, parent):
|
||||
return len(self.headers)
|
||||
|
||||
class SolverTableModel(PamhyrTableModel):
|
||||
def data(self, index, role):
|
||||
if role != Qt.ItemDataRole.DisplayRole:
|
||||
return QVariant()
|
||||
|
||||
ret = self.rows[index.row()][self.headers[index.column()]]
|
||||
ret = self._data[index.row()][self._headers[index.column()]]
|
||||
|
||||
if self.headers[index.column()] == "type":
|
||||
if self._headers[index.column()] == "type":
|
||||
ret = solver_long_name[ret]
|
||||
|
||||
return ret
|
||||
|
||||
def headerData(self, section, orientation, role):
|
||||
if (role == Qt.ItemDataRole.DisplayRole and
|
||||
orientation == Qt.Orientation.Horizontal):
|
||||
return self.headers[section].capitalize()
|
||||
|
||||
if (role == Qt.ItemDataRole.DisplayRole and
|
||||
orientation == Qt.Orientation.Vertical):
|
||||
return section + 1 # Start at 1
|
||||
|
||||
return QVariant()
|
||||
|
||||
def removeRow(self, index):
|
||||
del self.rows[index.row()]
|
||||
del self._data[index.row()]
|
||||
self.layoutChanged.emit()
|
||||
|
||||
def add_solver(self, solver):
|
||||
self.rows.append(solver)
|
||||
self._data.append(solver)
|
||||
self.layoutChanged.emit()
|
||||
|
||||
def change_solver(self, solver, index):
|
||||
self.rows[index.row()] = solver
|
||||
self._data[index.row()] = solver
|
||||
self.layoutChanged.emit()
|
||||
|
||||
|
||||
|
|
@ -105,10 +85,13 @@ class ConfigureWindow(PamhyrDialog):
|
|||
super(ConfigureWindow, self).__init__(
|
||||
title = self._pamhyr_name,
|
||||
config = config,
|
||||
trad = ConfigureTranslate(),
|
||||
options = [],
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self._trad_stricklers = StricklersTranslate()
|
||||
|
||||
self.setup_custom_sc()
|
||||
self.setup_solver()
|
||||
self.setup_stricklers()
|
||||
|
|
@ -118,26 +101,21 @@ class ConfigureWindow(PamhyrDialog):
|
|||
def setup_solver(self):
|
||||
table = self.find(QTableView, "tableView_solver")
|
||||
self.solver_table_model = SolverTableModel(
|
||||
headers = ["name", "type", "description"],
|
||||
rows = self._config.solvers
|
||||
table_view = table,
|
||||
table_headers = self._trad.get_dict("table_headers"),
|
||||
data = self._config.solvers
|
||||
)
|
||||
table.setModel(self.solver_table_model)
|
||||
table.setSelectionBehavior(QAbstractItemView.SelectRows)
|
||||
table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
|
||||
table.setAlternatingRowColors(True)
|
||||
table.resizeColumnsToContents()
|
||||
|
||||
def setup_stricklers(self):
|
||||
table = self.find(QTableView, f"tableView_stricklers")
|
||||
self._stricklers = deepcopy(self._config.stricklers)
|
||||
self._stricklers_table = TableModel(
|
||||
table_view = table,
|
||||
table_headers = self._trad_stricklers.get_dict("table_headers"),
|
||||
editable_headers = ["name", "comment", "minor", "medium"],
|
||||
data = self._stricklers,
|
||||
undo = self._undo_stack,
|
||||
)
|
||||
table.setModel(self._stricklers_table)
|
||||
table.setSelectionBehavior(QAbstractItemView.SelectRows)
|
||||
table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
|
||||
table.setAlternatingRowColors(True)
|
||||
|
||||
def setup_data(self):
|
||||
# Meshing_Tool
|
||||
|
|
@ -197,7 +175,7 @@ class ConfigureWindow(PamhyrDialog):
|
|||
|
||||
def accept(self):
|
||||
# Solvers
|
||||
self._config.solvers = self.solver_table_model.rows.copy()
|
||||
self._config.solvers = self.solver_table_model._data.copy()
|
||||
|
||||
# Meshing_Tool
|
||||
self._config.meshing_tool = self.get_line_edit_text("lineEdit_meshing_tool")
|
||||
|
|
@ -232,6 +210,7 @@ class ConfigureWindow(PamhyrDialog):
|
|||
self.close()
|
||||
|
||||
# Debug
|
||||
|
||||
def set_debug(self):
|
||||
self._config.debug = not self._config.debug
|
||||
logger.info(f"Debug mode set : {self._config.debug}")
|
||||
|
|
@ -243,7 +222,7 @@ class ConfigureWindow(PamhyrDialog):
|
|||
indexes = self.find(QTableView, "tableView_solver").selectionModel().selectedRows()
|
||||
for index in indexes:
|
||||
self.edit_solver = ConfigureSolverWindow(
|
||||
data=self.solver_table_model.rows[index.row()],
|
||||
data=self.solver_table_model._data[index.row()],
|
||||
config=self._config,
|
||||
parent=self
|
||||
)
|
||||
|
|
|
|||
|
|
@ -110,6 +110,8 @@ class PamhyrTableModel(QAbstractTableModel):
|
|||
self._table_view.setSelectionBehavior(QAbstractItemView.SelectRows)
|
||||
self._table_view.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
|
||||
self._table_view.setAlternatingRowColors(True)
|
||||
self._table_view.resizeColumnsToContents()
|
||||
|
||||
|
||||
def flags(self, index):
|
||||
column = index.column()
|
||||
|
|
|
|||
Loading…
Reference in New Issue