mirror of https://gitlab.com/pamhyr/pamhyr2
Compare commits
No commits in common. "78ba7b70b46dcd3c19048a198ff5791a6118d480" and "d922436ada65947ecd4b250e1bbe17e104ecd5c1" have entirely different histories.
78ba7b70b4
...
d922436ada
|
|
@ -214,7 +214,7 @@ class InternalMeshing(AMeshingTool):
|
|||
ratio = (alpha[j0] - beta[j0-1]) \
|
||||
/ (beta[j0] - beta[j0-1])
|
||||
if ratio < 0.0:
|
||||
logger.warning(f"ratio négatif {ratio}")
|
||||
print(f"ratio négatif {ratio}")
|
||||
# on double le point a gauche
|
||||
p = sect2.point(start2+j0-1).copy()
|
||||
sect2.insert_point(start2+j0-1, p)
|
||||
|
|
|
|||
|
|
@ -304,10 +304,8 @@ class BoundaryConditionAdisTS(SQLSubModel):
|
|||
|
||||
if pol_id not in pid_pol:
|
||||
# ⚠️ cas important : probablement déjà migré
|
||||
logger.warning(
|
||||
f"pol_id {pol_id} not in pid_pol " +
|
||||
"→ probably already migrated"
|
||||
)
|
||||
print(f"[WARN] pol_id {pol_id} not in pid_pol " +
|
||||
f"→ probably already migrated")
|
||||
continue
|
||||
|
||||
execute(
|
||||
|
|
|
|||
|
|
@ -338,13 +338,6 @@ class PointXYZ(Point):
|
|||
self._z = float(value)
|
||||
self.modified()
|
||||
|
||||
def shift(self, x, y, z):
|
||||
self.x += x
|
||||
self.y += y
|
||||
self.z += z
|
||||
|
||||
self.modified()
|
||||
|
||||
def get_coordinate(self):
|
||||
return (self._x, self._y, self._z)
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ from typing import List
|
|||
from functools import reduce
|
||||
from dataclasses import dataclass
|
||||
|
||||
from tools import trace, timer, flatten
|
||||
from tools import timer, flatten
|
||||
from shapely import geometry
|
||||
|
||||
from Model.Tools.PamhyrDB import SQLSubModel
|
||||
|
|
@ -396,6 +396,7 @@ class ProfileXYZ(Profile, SQLSubModel):
|
|||
|
||||
for point in self._points:
|
||||
p = point.copy()
|
||||
print(p)
|
||||
new_p._points.append(p)
|
||||
|
||||
new_p.modified()
|
||||
|
|
@ -1073,10 +1074,16 @@ class ProfileXYZ(Profile, SQLSubModel):
|
|||
|
||||
def shift(self, x, y, z):
|
||||
for p in self._points:
|
||||
p.shift(x, y, z)
|
||||
p.x = p.x + x
|
||||
p.y = p.y + y
|
||||
p.z = p.z + z
|
||||
|
||||
self.modified()
|
||||
|
||||
def modified(self):
|
||||
self.tab_up_to_date = False
|
||||
self.station_up_to_date = False
|
||||
|
||||
def add_npoints(self, npoints):
|
||||
# add npoints in a profile
|
||||
for k in range(npoints):
|
||||
|
|
|
|||
|
|
@ -52,11 +52,6 @@ class Reach(SQLSubModel):
|
|||
self._guidelines_is_valid = False
|
||||
self._guidelines = {}
|
||||
|
||||
super(Reach, self).__init__(
|
||||
id=parent.pamhyr_id,
|
||||
status=status,
|
||||
)
|
||||
|
||||
@property
|
||||
def pamhyr_id(self):
|
||||
return self._parent.pamhyr_id
|
||||
|
|
@ -65,10 +60,6 @@ class Reach(SQLSubModel):
|
|||
def _pamhyr_id(self):
|
||||
return self._parent.pamhyr_id
|
||||
|
||||
@_pamhyr_id.setter
|
||||
def _pamhyr_id(self, id):
|
||||
return
|
||||
|
||||
@classmethod
|
||||
def _db_create(cls, execute):
|
||||
return cls._create_submodel(execute)
|
||||
|
|
@ -211,6 +202,7 @@ class Reach(SQLSubModel):
|
|||
else:
|
||||
gi = self.get_global_profil_index(index)
|
||||
profile.num = gi
|
||||
print(f"gi = {gi}")
|
||||
self._profiles.insert(gi, profile)
|
||||
|
||||
self.modified()
|
||||
|
|
|
|||
|
|
@ -183,6 +183,7 @@ class BasicHS(SQLSubModel):
|
|||
bhs._data = BHSValue._db_load(
|
||||
execute, data
|
||||
)
|
||||
print(f"{bhs_pid} : {deleted}")
|
||||
if deleted:
|
||||
bhs.set_as_deleted()
|
||||
|
||||
|
|
|
|||
|
|
@ -588,6 +588,8 @@ class InitialConditions(SQLSubModel):
|
|||
for data in self._data:
|
||||
data_height[data["rk"].rk] = data["height"]
|
||||
|
||||
print(data_height)
|
||||
|
||||
incline = self._reach.reach.get_incline_median_mean()
|
||||
logger.debug(f"incline = {incline}")
|
||||
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ class OutputRKAdists(SQLSubModel):
|
|||
"output_rk_adists(pamhyr_id, deleted, " +
|
||||
"reach, rk, title, scenario) " +
|
||||
"VALUES (" +
|
||||
f"{self.id}, {self._db_format(self.is_deleted())}, " +
|
||||
f"{self.id}, {self._db_format(self.is_deleted())}" +
|
||||
f"{self._reach}, {self._rk}, " +
|
||||
f"'{self._db_format(self._title)}', " +
|
||||
f"{self._status.scenario_id}" +
|
||||
|
|
|
|||
|
|
@ -263,6 +263,8 @@ class Reservoir(SQLSubModel):
|
|||
cls._db_update_to_0_2_0_set_node_pid(execute, table, nodes)
|
||||
Scenario.update_db_add_scenario(execute, table)
|
||||
|
||||
print(execute(f"SELECT * FROM {table}"))
|
||||
|
||||
cls._db_create(execute, ext="_tmp")
|
||||
execute(
|
||||
f"INSERT INTO {table}_tmp " +
|
||||
|
|
|
|||
|
|
@ -16,8 +16,6 @@
|
|||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from functools import reduce
|
||||
|
||||
from tools import logger_exception
|
||||
|
||||
from Model.Tools.PamhyrDict import PamhyrModelDict
|
||||
|
|
@ -80,12 +78,3 @@ class Scenarios(PamhyrModelDict):
|
|||
|
||||
self._dict[key].set_as_deleted()
|
||||
self._status.modified()
|
||||
|
||||
def is_leaf(self, scenario):
|
||||
return not reduce(
|
||||
lambda acc, s: (
|
||||
acc or (not s.is_deleted() and s.parent is scenario)
|
||||
),
|
||||
self._dict.values(),
|
||||
False
|
||||
)
|
||||
|
|
|
|||
|
|
@ -26,8 +26,6 @@ from functools import reduce
|
|||
from SQL import SQL
|
||||
from Model.Except import NotImplementedMethodeError
|
||||
|
||||
from tools import trace
|
||||
|
||||
from Model.Tools.PamhyrID import PamhyrID
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
|
@ -50,9 +48,11 @@ class SQLModel(SQL):
|
|||
self._cur = self._db.cursor()
|
||||
|
||||
if is_new:
|
||||
logger.info("Create database")
|
||||
self._create() # Create db
|
||||
# self._save() # Save
|
||||
else:
|
||||
logger.info("Update database")
|
||||
self._update() # Update db scheme if necessary
|
||||
# self._load() # Load data
|
||||
|
||||
|
|
@ -313,10 +313,8 @@ class SQLSubModel(PamhyrID):
|
|||
|
||||
if node_id not in nodes:
|
||||
# ⚠️ cas important : probablement déjà migré
|
||||
logger.warning(
|
||||
f"node_id {node_id} not in nodes " +
|
||||
"→ probably already migrated"
|
||||
)
|
||||
print(f"[WARN] node_id {node_id} not in nodes " +
|
||||
f"→ probably already migrated")
|
||||
continue
|
||||
|
||||
execute(
|
||||
|
|
|
|||
|
|
@ -426,6 +426,7 @@ class Rubar3(CommandLineSolver):
|
|||
coeff = coeff_min
|
||||
else:
|
||||
for s in lst:
|
||||
print(s.begin_rk, s.end_rk)
|
||||
if (rk >= s.begin_rk and rk <= s.end_rk or
|
||||
rk <= s.begin_rk and rk >= s.end_rk):
|
||||
coeff = s.begin_strickler # TODO: inerpolate
|
||||
|
|
@ -472,6 +473,7 @@ class Rubar3(CommandLineSolver):
|
|||
last = profiles[-1]
|
||||
|
||||
if first not in data or last not in data:
|
||||
print(data)
|
||||
logger.error(
|
||||
"Study initial condition is not fully defined"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -251,6 +251,7 @@ class GeometryReachTableModel(PamhyrTableModel):
|
|||
self.layoutChanged.emit()
|
||||
|
||||
def meshing(self, mesher, data, tableView):
|
||||
|
||||
new_profiles = mesher.meshing(
|
||||
self._data,
|
||||
**data
|
||||
|
|
@ -286,6 +287,7 @@ class GeometryReachTableModel(PamhyrTableModel):
|
|||
self.layoutChanged.emit()
|
||||
|
||||
def purge(self, np_purge):
|
||||
|
||||
self._undo.push(
|
||||
PurgeCommand(
|
||||
self._data, np_purge
|
||||
|
|
@ -294,6 +296,7 @@ class GeometryReachTableModel(PamhyrTableModel):
|
|||
self.layoutChanged.emit()
|
||||
|
||||
def shift(self, rows, dx, dy, dz):
|
||||
|
||||
self._undo.push(
|
||||
ShiftCommand(
|
||||
self._data, rows, dx, dy, dz
|
||||
|
|
@ -302,6 +305,7 @@ class GeometryReachTableModel(PamhyrTableModel):
|
|||
self.layoutChanged.emit()
|
||||
|
||||
def change_reach(self, new_reach, parent):
|
||||
|
||||
self._undo.push(
|
||||
ChangeReachCommand(
|
||||
new_reach,
|
||||
|
|
|
|||
|
|
@ -411,13 +411,13 @@ class ShiftCommand(QUndoCommand):
|
|||
def undo(self):
|
||||
for i in self._rows:
|
||||
profile = self._reach.profiles[i]
|
||||
profile.shift(
|
||||
self._reach.profiles[i].shift(
|
||||
-self._dx, -self._dy, -self._dz
|
||||
)
|
||||
|
||||
def redo(self):
|
||||
for i in self._rows:
|
||||
profile = self._reach.profiles[i]
|
||||
profile.shift(
|
||||
self._reach.profiles[i].shift(
|
||||
self._dx, self._dy, self._dz
|
||||
)
|
||||
|
|
|
|||
|
|
@ -925,11 +925,9 @@ class GraphWidget(QGraphicsView):
|
|||
self.scale(scaleFactor, scaleFactor)
|
||||
|
||||
def mousePressEvent(self, event):
|
||||
if self._only_display:
|
||||
if self._only_display or self.graph._status.is_read_only():
|
||||
return
|
||||
|
||||
locked = self.graph._status.is_read_only()
|
||||
|
||||
pos = self.mapToScene(event.pos())
|
||||
self.clicked = True
|
||||
|
||||
|
|
@ -938,6 +936,9 @@ class GraphWidget(QGraphicsView):
|
|||
super(GraphWidget, self).mousePressEvent(event)
|
||||
return
|
||||
|
||||
if self.graph._status.is_read_only():
|
||||
return
|
||||
|
||||
# Move item and select edge item
|
||||
if self._state == "move":
|
||||
self._selected_new_edge_src_node = None
|
||||
|
|
@ -947,15 +948,13 @@ class GraphWidget(QGraphicsView):
|
|||
edge = items[0]
|
||||
if edge:
|
||||
self.set_current_edge(edge)
|
||||
if not locked:
|
||||
if items and type(items[0]) is NodeItem:
|
||||
elif items and type(items[0]) is NodeItem:
|
||||
self._mouse_origin_x = pos.x()
|
||||
self._mouse_origin_y = pos.y()
|
||||
self._current_moved_node = items[0]
|
||||
|
||||
if not locked:
|
||||
# Add nodes and edges
|
||||
if self._state == "add":
|
||||
elif self._state == "add":
|
||||
items = self.items(event.pos())
|
||||
nodes = list(filter(lambda i: type(i) is NodeItem, items))
|
||||
if not nodes:
|
||||
|
|
@ -989,12 +988,10 @@ class GraphWidget(QGraphicsView):
|
|||
def mouseReleaseEvent(self, event):
|
||||
self.clicked = False
|
||||
|
||||
if self._only_display:
|
||||
if self._only_display or self.graph._status.is_read_only():
|
||||
return
|
||||
|
||||
locked = self.graph._status.is_read_only()
|
||||
|
||||
if not locked and self._state == "move":
|
||||
if self._state == "move":
|
||||
if self._current_moved_node is not None:
|
||||
pos = self.mapToScene(event.pos())
|
||||
self._undo.push(
|
||||
|
|
@ -1010,8 +1007,10 @@ class GraphWidget(QGraphicsView):
|
|||
super(GraphWidget, self).mouseReleaseEvent(event)
|
||||
|
||||
def mouseMoveEvent(self, event):
|
||||
if self.graph._status.is_read_only():
|
||||
return
|
||||
|
||||
pos = self.mapToScene(event.pos())
|
||||
locked = self.graph._status.is_read_only()
|
||||
|
||||
# Selecte item on the fly
|
||||
items = self.items(event.pos())
|
||||
|
|
|
|||
|
|
@ -57,8 +57,6 @@ class DefaultMenu(AbstractMenu):
|
|||
class ScenarioMenu(AbstractMenu):
|
||||
def run(self):
|
||||
item = self._items[0]
|
||||
scenarios = item.graph._study.scenarios
|
||||
|
||||
current_scenario = item.graph._study.status.scenario.id
|
||||
|
||||
select = self._menu.addAction(self._trad["menu_select_scenario"])
|
||||
|
|
@ -66,9 +64,7 @@ class ScenarioMenu(AbstractMenu):
|
|||
delete = None
|
||||
|
||||
if item.scenario.id != 0:
|
||||
if scenarios.is_leaf(item.scenario):
|
||||
delete = self._menu.addAction(self._trad["menu_del_scenario"])
|
||||
|
||||
if item.scenario.id == current_scenario:
|
||||
duplicate = self._menu.addAction(
|
||||
self._trad["menu_dup_scenario"]
|
||||
|
|
|
|||
|
|
@ -470,16 +470,9 @@ class GraphWidget(QGraphicsView):
|
|||
self.changeScenario.emit(self.sender())
|
||||
|
||||
def new_scenario(self, pos):
|
||||
must_save = self.dialog_save()
|
||||
if must_save == "Cancel":
|
||||
return
|
||||
|
||||
def fn():
|
||||
self._close_other_window()
|
||||
|
||||
if must_save == "Save":
|
||||
self._study.save()
|
||||
|
||||
self._undo.push(
|
||||
AddScenariosCommand(
|
||||
self._study,
|
||||
|
|
@ -507,16 +500,9 @@ class GraphWidget(QGraphicsView):
|
|||
self.changeScenario.emit(self.sender())
|
||||
|
||||
def duplicate_scenario(self, item):
|
||||
must_save = self.dialog_save()
|
||||
if must_save == "Cancel":
|
||||
return
|
||||
|
||||
def fn():
|
||||
self._close_other_window()
|
||||
|
||||
if must_save == "Save":
|
||||
self._study.save()
|
||||
|
||||
# self._study.save()
|
||||
self._undo.push(
|
||||
DuplicateScenariosCommand(
|
||||
self._study,
|
||||
|
|
|
|||
Loading…
Reference in New Issue