mirror of https://gitlab.com/pamhyr/pamhyr2
doc: dev: Update documentation.
parent
ec91a8b63f
commit
145c301eed
|
|
@ -1,5 +1,5 @@
|
||||||
# documentation.org -- Pamhyr developers documentation
|
# documentation.org -- Pamhyr developers documentation
|
||||||
# Copyright (C) 2023 INRAE
|
# Copyright (C) 2023-2024 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|
@ -538,44 +538,44 @@ generic value from optional parameters, for examples:
|
||||||
#+NAME: window
|
#+NAME: window
|
||||||
#+CAPTION: Example of Pamhyr2 window
|
#+CAPTION: Example of Pamhyr2 window
|
||||||
#+begin_src python :python python3 :results output :noweb yes
|
#+begin_src python :python python3 :results output :noweb yes
|
||||||
from View.Tools.PamhyrWindow import PamhyrWindow
|
from View.Tools.PamhyrWindow import PamhyrWindow
|
||||||
from View.My.Translate import MyTranslate
|
from View.My.Translate import MyTranslate
|
||||||
from View.My.Table import MyTableModel
|
from View.My.Table import MyTableModel
|
||||||
|
|
||||||
class MyWindow(PamhyrWindow):
|
class MyWindow(PamhyrWindow):
|
||||||
_pamhyr_ui = "MyUI"
|
_pamhyr_ui = "MyUI"
|
||||||
_pamhyr_name = "My window"
|
_pamhyr_name = "My window"
|
||||||
|
|
||||||
def __init__(self, my_data=None,
|
def __init__(self, study=None, config=None,
|
||||||
study=None, config=None,
|
my_data=None,
|
||||||
parent=None):
|
parent=None):
|
||||||
self._my_data = my_data
|
self._my_data = my_data
|
||||||
|
|
||||||
super(MyWindow, self).__init__(
|
super(MyWindow, self).__init__(
|
||||||
# Window title
|
# Window title
|
||||||
title = self._pamhyr_name + " - " + study.name,
|
title = self._pamhyr_name + " - " + study.name,
|
||||||
# Window standard data
|
# Window standard data
|
||||||
study = study, config = config,
|
study = study, config = config,
|
||||||
trad = MyTranslate(),
|
trad = MyTranslate(),
|
||||||
parent = parent,
|
parent = parent,
|
||||||
# Activate undo/redo and copy/paste shortcut
|
# Activate undo/redo and copy/paste shortcut
|
||||||
options = ["undo", "copy"]
|
options = ["undo", "copy"]
|
||||||
)
|
)
|
||||||
|
|
||||||
# Add custom data to hash window computation
|
# Add custom data to hash window computation
|
||||||
self._hash_data.append(self._my_data)
|
self._hash_data.append(self._my_data)
|
||||||
|
|
||||||
# Setup custom window components
|
# Setup custom window components
|
||||||
self.setup_table()
|
self.setup_table()
|
||||||
self.setup_connections()
|
self.setup_connections()
|
||||||
|
|
||||||
def setup_table(self):
|
def setup_table(self):
|
||||||
# Init table(s)...
|
# Init table(s)...
|
||||||
|
|
||||||
def setup_connections(self):
|
def setup_connections(self):
|
||||||
# Init action connection(s)...
|
# Init action connection(s)...
|
||||||
|
|
||||||
# ...
|
# ...
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
Typically we called method =setup_*=, the method to initialize some
|
Typically we called method =setup_*=, the method to initialize some
|
||||||
|
|
@ -661,11 +661,13 @@ creation, this stack is accessible at =self._undo_stack=.
|
||||||
|
|
||||||
*** Plot
|
*** Plot
|
||||||
|
|
||||||
To define a new plot you can create a class who inherit to APlot. The
|
To define a new plot you can create a class who inherit to
|
||||||
creator need threee argument:
|
PamhyrPlot. The creator need at leaste five argument:
|
||||||
- A =canvas= of type =MplCanvas=
|
- A =canvas= of type =MplCanvas=
|
||||||
|
- A (optional) =trad= of type =PamhyrTranslate=
|
||||||
- A =data= used in =draw= and =update= to create and update the plot
|
- A =data= used in =draw= and =update= to create and update the plot
|
||||||
- A optional =toolbar= of type =PamhyrToolbar=
|
- A optional =toolbar= of type =PamhyrToolbar=
|
||||||
|
- A =parent= window
|
||||||
This class must implement two method =draw= and =update=, the first
|
This class must implement two method =draw= and =update=, the first
|
||||||
method to draw the plot from scratch, the second to update the plot if
|
method to draw the plot from scratch, the second to update the plot if
|
||||||
data has changed.
|
data has changed.
|
||||||
|
|
@ -673,19 +675,36 @@ data has changed.
|
||||||
#+begin_src python :python python3 :results output :noweb yes
|
#+begin_src python :python python3 :results output :noweb yes
|
||||||
from View.Tools.PamhyrPlot import PamhyrPlot
|
from View.Tools.PamhyrPlot import PamhyrPlot
|
||||||
|
|
||||||
class MyPlot(APlot):
|
class MyPlot(PamhyrPlot):
|
||||||
def __init__(self, canvas=None, data=None, toolbar=None):
|
def __init__(self, canvas=None, trad=None, toolbar=None
|
||||||
|
data=None, parent=None):
|
||||||
super(MyPlot, self).__init__(
|
super(MyPlot, self).__init__(
|
||||||
canvas=canvas,
|
canvas=canvas,
|
||||||
|
trad=trad,
|
||||||
data=data,
|
data=data,
|
||||||
toolbar=toolbar
|
toolbar=toolbar,
|
||||||
|
parent=parent
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.label_x = self._trad["x"]
|
||||||
|
self.label_y = self._trad["y"]
|
||||||
|
|
||||||
|
# Optional configuration
|
||||||
|
self._isometric_axis = False
|
||||||
|
|
||||||
|
self._auto_relim_update = True
|
||||||
|
self._autoscale_update = True
|
||||||
|
|
||||||
def draw(self):
|
def draw(self):
|
||||||
# Draw function code...
|
# Draw function code...
|
||||||
|
|
||||||
def update(self, ind = None):
|
def update(self):
|
||||||
# Update function code...
|
# Update function code...
|
||||||
|
|
||||||
|
def clear(self):
|
||||||
|
# Clear plot values...
|
||||||
|
|
||||||
|
# ...
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
** Solver
|
** Solver
|
||||||
|
|
@ -745,7 +764,7 @@ execute a code on distant computer, for example, over ssh.
|
||||||
style=dashed;
|
style=dashed;
|
||||||
subgraph cluster021 {
|
subgraph cluster021 {
|
||||||
label="Solver Classes";
|
label="Solver Classes";
|
||||||
classSolverM7[label="Mage7", fillcolor=6];
|
//classSolverM7[label="Mage7", fillcolor=6];
|
||||||
classSolverM8[label="Mage8", fillcolor=6];
|
classSolverM8[label="Mage8", fillcolor=6];
|
||||||
classSolverR[label="RubarBE", fillcolor=6];
|
classSolverR[label="RubarBE", fillcolor=6];
|
||||||
}
|
}
|
||||||
|
|
@ -828,7 +847,7 @@ solver and get results:
|
||||||
- (2.1) The solver read the input file(s)
|
- (2.1) The solver read the input file(s)
|
||||||
- (2.2) The solver compute results and write it to solver output
|
- (2.2) The solver compute results and write it to solver output
|
||||||
file(s)
|
file(s)
|
||||||
- (3) Pamhyr2 create a Reuslts
|
- (3) Pamhyr2 create a =Results= object
|
||||||
- (3.1) The Pamhyr2 solver class read solver output file(s) and
|
- (3.1) The Pamhyr2 solver class read solver output file(s) and
|
||||||
complete Results with readed data
|
complete Results with readed data
|
||||||
|
|
||||||
|
|
@ -958,8 +977,16 @@ different methods:
|
||||||
|
|
||||||
** Unit tests
|
** Unit tests
|
||||||
|
|
||||||
The unit tests is actually not implemented in Pamhyr2, it is a *work
|
A very small part of Pamhyr2 has unit test. This part is limited to the Model.
|
||||||
in progress*.
|
|
||||||
|
#+begin_src shell
|
||||||
|
python3 -m venv test
|
||||||
|
. test test/bin/activate
|
||||||
|
pip3 install -U -r ./full-requirements.txt
|
||||||
|
|
||||||
|
cd src/
|
||||||
|
python3 -Walways -m unittest discovert -v -t .
|
||||||
|
#+end_src
|
||||||
|
|
||||||
** The debug mode
|
** The debug mode
|
||||||
|
|
||||||
|
|
@ -970,14 +997,14 @@ line:
|
||||||
./Pamhyr2 debug
|
./Pamhyr2 debug
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
This mode add some log and add two action in main window menu:
|
This mode add some log and add two action in main window menu: "About
|
||||||
"About/Debug" open a window with Python Repl in current Python
|
> Debug" open a window with Python Repl in current Python
|
||||||
environement, and "About/Debug SQLite" who open the application
|
environement, and "About > Debug SQLite" who open the application
|
||||||
SQLiteBrowser (if installed) on current Study to explore the study
|
SQLiteBrowser (if installed) on current Study to explore the study
|
||||||
data base file.
|
data base file.
|
||||||
|
|
||||||
#+NAME: debug-repl
|
#+NAME: debug-repl
|
||||||
#+ATTR_LATEX: :width 12cm
|
#+ATTR_LATEX: :width 14cm
|
||||||
#+CAPTION: Pamhyr2 debug Python REPL
|
#+CAPTION: Pamhyr2 debug Python REPL
|
||||||
[[./images/python-debug-repl.png]]
|
[[./images/python-debug-repl.png]]
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 51 KiB |
Loading…
Reference in New Issue