Failed to fetch fork details. Try again later.
-
Delaigue Olivier authored60219b28
Forked from
HYCAR-Hydro / airGR
Source project has a limited visibility.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# Node.py -- Pamhyr
# Copyright (C) 2023-2024 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 Model.Network.Point import Point
class Node(object):
_id_cnt = 0
def __init__(self, id: int, name: str,
x: float = 0.0, y: float = 0.0,
status=None):
super(Node, self).__init__()
self._status = status
if id == -1:
type(self)._id_cnt += 1
self.id = type(self)._id_cnt
else:
self.id = id
self._name = name
self.pos = Point(x, y)
def __getitem__(self, key):
ret = None
if key == "name":
ret = self._name
elif key == "id":
ret = self.id
elif key == "pos":
ret = f"({self.pos.x},{self.pos.y})"
return ret
def __setitem__(self, key, value):
if key == "name":
self._name = value
elif key == "id":
self.id = value
self._status.modified()
@property
def name(self):
if self._name == "":
return f"N{self.id}"
return self._name
@property
def x(self):
return self.pos.x
@property
def y(self):
return self.pos.y
def setPos(self, x, y):
self.pos.x = x
self.pos.y = y
self._status.modified()