mirror of https://gitlab.com/pamhyr/pamhyr2
BC: Edit: Add plot (not finish).
parent
d49091a469
commit
2f0b5b2e31
|
|
@ -27,10 +27,12 @@ from View.BoundaryCondition.BCUndoCommand import (
|
||||||
AddCommand, DelCommand, SortCommand,
|
AddCommand, DelCommand, SortCommand,
|
||||||
MoveCommand, PasteCommand, DuplicateCommand,
|
MoveCommand, PasteCommand, DuplicateCommand,
|
||||||
)
|
)
|
||||||
|
|
||||||
from Model.BoundaryCondition.BoundaryConditionTypes import (
|
from Model.BoundaryCondition.BoundaryConditionTypes import (
|
||||||
NotDefined, PonctualContribution,
|
NotDefined, PonctualContribution,
|
||||||
TimeOverZ, TimeOverDebit, ZOverDebit
|
TimeOverZ, TimeOverDebit, ZOverDebit
|
||||||
)
|
)
|
||||||
|
|
||||||
from View.BoundaryCondition.translate import long_types
|
from View.BoundaryCondition.translate import long_types
|
||||||
from View.BoundaryCondition.Edit.Window import EditBoundaryConditionWindow
|
from View.BoundaryCondition.Edit.Window import EditBoundaryConditionWindow
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,67 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from tools import timer, trace
|
||||||
|
from View.Plot.APlot import APlot
|
||||||
|
|
||||||
|
from PyQt5.QtCore import (
|
||||||
|
QCoreApplication
|
||||||
|
)
|
||||||
|
|
||||||
|
from View.BoundaryCondition.Edit.translate import *
|
||||||
|
|
||||||
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
|
class Plot(APlot):
|
||||||
|
def __init__(self, canvas=None, data=None, toolbar=None):
|
||||||
|
super(Plot, self).__init__(
|
||||||
|
canvas=canvas,
|
||||||
|
data=data,
|
||||||
|
toolbar=toolbar
|
||||||
|
)
|
||||||
|
|
||||||
|
@timer
|
||||||
|
def draw(self):
|
||||||
|
self.canvas.axes.cla()
|
||||||
|
self.canvas.axes.grid(color='grey', linestyle='--', linewidth=0.5)
|
||||||
|
|
||||||
|
if len(self.data) == 0:
|
||||||
|
self._init = False
|
||||||
|
return
|
||||||
|
|
||||||
|
# Plot data
|
||||||
|
x = list(map(lambda v: v[0], self.data.data))
|
||||||
|
y = list(map(lambda v: v[1], self.data.data))
|
||||||
|
self._line, = self.canvas.axes.plot(
|
||||||
|
x, y,
|
||||||
|
color='r', lw=1.,
|
||||||
|
markersize=5, marker='+',
|
||||||
|
picker=30
|
||||||
|
)
|
||||||
|
|
||||||
|
# Plot label
|
||||||
|
header = self.data.header
|
||||||
|
self.canvas.axes.set_xlabel(
|
||||||
|
table_headers[header[0]], color='black', fontsize=10
|
||||||
|
)
|
||||||
|
self.canvas.axes.set_ylabel(
|
||||||
|
table_headers[header[1]], color='black', fontsize=10
|
||||||
|
)
|
||||||
|
|
||||||
|
self.canvas.figure.tight_layout()
|
||||||
|
self.canvas.figure.canvas.draw_idle()
|
||||||
|
self.toolbar.update()
|
||||||
|
|
||||||
|
self._init = True
|
||||||
|
|
||||||
|
@timer
|
||||||
|
def update(self, ind=None):
|
||||||
|
if self._init == False:
|
||||||
|
self.draw()
|
||||||
|
return
|
||||||
|
|
||||||
|
# if ind is not None:
|
||||||
|
|
||||||
|
# else:
|
||||||
|
|
||||||
|
self.canvas.figure.tight_layout()
|
||||||
|
self.canvas.figure.canvas.draw_idle()
|
||||||
|
|
@ -15,24 +15,19 @@ from PyQt5.QtWidgets import (
|
||||||
QTableView, QAbstractItemView,
|
QTableView, QAbstractItemView,
|
||||||
)
|
)
|
||||||
|
|
||||||
from View.BoundaryCondition.Edit.UndoCommand import (
|
|
||||||
SetDataCommand, AddCommand, DelCommand,
|
|
||||||
SortCommand, MoveCommand, PasteCommand,
|
|
||||||
DuplicateCommand,
|
|
||||||
)
|
|
||||||
|
|
||||||
from Model.BoundaryCondition.BoundaryConditionTypes import (
|
from Model.BoundaryCondition.BoundaryConditionTypes import (
|
||||||
NotDefined, PonctualContribution,
|
NotDefined, PonctualContribution,
|
||||||
TimeOverZ, TimeOverDebit, ZOverDebit
|
TimeOverZ, TimeOverDebit, ZOverDebit
|
||||||
)
|
)
|
||||||
|
|
||||||
_translate = QCoreApplication.translate
|
from View.BoundaryCondition.Edit.UndoCommand import (
|
||||||
|
SetDataCommand, AddCommand, DelCommand,
|
||||||
|
SortCommand, MoveCommand, PasteCommand,
|
||||||
|
DuplicateCommand,
|
||||||
|
)
|
||||||
|
from View.BoundaryCondition.Edit.translate import *
|
||||||
|
|
||||||
table_headers = {
|
_translate = QCoreApplication.translate
|
||||||
"time": _translate("BoundaryCondition", "Time"),
|
|
||||||
"debit": _translate("BoundaryCondition", "Debit"),
|
|
||||||
"z": _translate("BoundaryCondition", "Z (m)")
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class TableModel(QAbstractTableModel):
|
class TableModel(QAbstractTableModel):
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ class SortCommand(QUndoCommand):
|
||||||
|
|
||||||
def redo(self):
|
def redo(self):
|
||||||
self._data.sort(
|
self._data.sort(
|
||||||
reverse=self._reverse,
|
_reverse=self._reverse,
|
||||||
key=lambda x: x.name
|
key=lambda x: x.name
|
||||||
)
|
)
|
||||||
if self._indexes is None:
|
if self._indexes is None:
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,11 @@ from PyQt5.QtWidgets import (
|
||||||
QUndoStack, QShortcut, QAction, QItemDelegate,
|
QUndoStack, QShortcut, QAction, QItemDelegate,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from View.Plot.MplCanvas import MplCanvas
|
||||||
|
|
||||||
from View.BoundaryCondition.translate import long_types
|
from View.BoundaryCondition.translate import long_types
|
||||||
from View.BoundaryCondition.Edit.Table import TableModel
|
from View.BoundaryCondition.Edit.Table import TableModel
|
||||||
|
from View.BoundaryCondition.Edit.Plot import Plot
|
||||||
|
|
||||||
_translate = QCoreApplication.translate
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
|
|
@ -34,6 +37,7 @@ class EditBoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
|
||||||
self.setup_window()
|
self.setup_window()
|
||||||
self.setup_sc()
|
self.setup_sc()
|
||||||
self.setup_table()
|
self.setup_table()
|
||||||
|
self.setup_plot()
|
||||||
self.setup_connections()
|
self.setup_connections()
|
||||||
|
|
||||||
def setup_window(self):
|
def setup_window(self):
|
||||||
|
|
@ -67,6 +71,18 @@ class EditBoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
|
||||||
table.setSelectionBehavior(QAbstractItemView.SelectRows)
|
table.setSelectionBehavior(QAbstractItemView.SelectRows)
|
||||||
table.setAlternatingRowColors(True)
|
table.setAlternatingRowColors(True)
|
||||||
|
|
||||||
|
def setup_plot(self):
|
||||||
|
self.canvas = MplCanvas(width=5, height=4, dpi=100)
|
||||||
|
self.canvas.setObjectName("canvas")
|
||||||
|
self.verticalLayout.addWidget(self.canvas)
|
||||||
|
|
||||||
|
self.plot = Plot(
|
||||||
|
canvas = self.canvas,
|
||||||
|
data = self._data,
|
||||||
|
)
|
||||||
|
self.plot.draw()
|
||||||
|
|
||||||
|
|
||||||
def setup_connections(self):
|
def setup_connections(self):
|
||||||
self.find(QAction, "action_add").triggered.connect(self.add)
|
self.find(QAction, "action_add").triggered.connect(self.add)
|
||||||
self.find(QAction, "action_del").triggered.connect(self.delete)
|
self.find(QAction, "action_del").triggered.connect(self.delete)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from PyQt5.QtCore import QCoreApplication
|
||||||
|
|
||||||
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
|
table_headers = {
|
||||||
|
"time": _translate("BoundaryCondition", "Time"),
|
||||||
|
"debit": _translate("BoundaryCondition", "Debit"),
|
||||||
|
"z": _translate("BoundaryCondition", "Z (m)")
|
||||||
|
}
|
||||||
|
|
@ -24,6 +24,16 @@
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralwidget">
|
<widget class="QWidget" name="centralwidget">
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
|
<property name="currentIndex">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="tab">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Liquid</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QSplitter" name="splitter">
|
<widget class="QSplitter" name="splitter">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
|
@ -43,6 +53,20 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QWidget" name="tab_2">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Solid</string>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="tab_3">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Suspension</string>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
<widget class="QMenuBar" name="menubar">
|
<widget class="QMenuBar" name="menubar">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue