Skip to content

Commit bc375c8

Browse files
authored
Merge pull request #420 from SebGue/TreeEdit
[NF] Generic Object Editor
2 parents 2842345 + 481f488 commit bc375c8

File tree

31 files changed

+1841
-136
lines changed

31 files changed

+1841
-136
lines changed

pyleecan/Classes/Class_Dict.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6813,21 +6813,21 @@
68136813
"path": "pyleecan/Generator/ClassesRef/Material/ModelBH.csv",
68146814
"properties": [
68156815
{
6816-
"desc": "Max value of H for extrapolation",
6816+
"desc": "Max value of B for extrapolation",
68176817
"max": "",
68186818
"min": "",
68196819
"name": "Bmax",
68206820
"type": "float",
6821-
"unit": "-",
6821+
"unit": "T",
68226822
"value": 2.31
68236823
},
68246824
{
6825-
"desc": "Max value of B for extrapolation",
6825+
"desc": "Max value of H for extrapolation",
68266826
"max": "",
68276827
"min": "",
68286828
"name": "Hmax",
68296829
"type": "float",
6830-
"unit": "-",
6830+
"unit": "A/m",
68316831
"value": null
68326832
},
68336833
{
@@ -6836,7 +6836,7 @@
68366836
"min": "",
68376837
"name": "delta",
68386838
"type": "float",
6839-
"unit": "-",
6839+
"unit": "A/m",
68406840
"value": 100
68416841
}
68426842
]

pyleecan/Classes/ModelBH.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def _set_Bmax(self, value):
179179
Bmax = property(
180180
fget=_get_Bmax,
181181
fset=_set_Bmax,
182-
doc=u"""Max value of H for extrapolation
182+
doc=u"""Max value of B for extrapolation
183183
184184
:Type: float
185185
""",
@@ -197,7 +197,7 @@ def _set_Hmax(self, value):
197197
Hmax = property(
198198
fget=_get_Hmax,
199199
fset=_set_Hmax,
200-
doc=u"""Max value of B for extrapolation
200+
doc=u"""Max value of H for extrapolation
201201
202202
:Type: float
203203
""",

pyleecan/Classes/_ClassInfo.py

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
from json import load as jload
2+
from os.path import join, split
3+
4+
5+
class ClassInfo:
6+
def __init__(self):
7+
self.class_dict = self.__init_dict__()
8+
9+
def __init_dict__(self):
10+
"""Method to get a dict on the pyleecan classes, i.e. class name, description,
11+
properties, methods, etc.
12+
13+
Returns
14+
-------
15+
class_dict : dict
16+
dict of class information
17+
"""
18+
# load the class dict
19+
path = split(__file__)[0]
20+
with open(join(path, "Class_Dict.json")) as fp:
21+
class_dict = jload(fp)
22+
23+
# create inheritance information
24+
for cls_name in class_dict.keys():
25+
mother_name = class_dict[cls_name]["mother"]
26+
inherit = []
27+
while mother_name:
28+
inherit.append(mother_name)
29+
mother_name = class_dict[mother_name]["mother"]
30+
31+
class_dict[cls_name]["inherit"] = inherit
32+
33+
# from pprint import pprint
34+
# pprint(sorted([ClassInfo().get_prop_types()]))
35+
36+
# complete properties and methods on each class
37+
for cls_dict in class_dict.values():
38+
prop_names = [prop["name"] for prop in cls_dict["properties"]]
39+
for mother in cls_dict["inherit"]:
40+
mother_props = class_dict[mother]["properties"]
41+
for mother_prop in mother_props:
42+
if not mother_prop["name"] in prop_names:
43+
cls_dict["properties"].append(mother_prop)
44+
45+
# update property names
46+
prop_names = [prop["name"] for prop in cls_dict["properties"]]
47+
48+
# convert properties to dict
49+
cls_dict["prop_dict"] = dict()
50+
for prop in cls_dict["properties"]:
51+
cls_dict["prop_dict"][prop["name"]] = prop
52+
53+
return class_dict
54+
55+
def get_dict(self):
56+
return self.class_dict
57+
58+
def get_prop_types(self):
59+
"""Get a set of all defined property types of all classes."""
60+
type_set = set()
61+
62+
for cls in self.class_dict.values():
63+
for prop in cls["prop_dict"].values():
64+
type_set.add(prop["type"])
65+
66+
return type_set
67+
68+
def get_base_classes(self):
69+
"""Get the base classes, i.e. classes that have no mother class."""
70+
bases = set()
71+
for key, item in self.class_dict.items():
72+
if not item["mother"]:
73+
bases.add(key)
74+
75+
bases = sorted(list(bases))
76+
77+
return bases
78+
79+
def get_mothers(self, cls_name, stop=""):
80+
"""Get a ordered list of the mothers of a class."""
81+
mothers = []
82+
if stop not in self.class_dict:
83+
stop = ""
84+
if cls_name in self.class_dict:
85+
mother = self.class_dict[cls_name]["mother"]
86+
while mother and cls_name != stop:
87+
mothers.append(mother)
88+
cls_name = mother
89+
mother = self.class_dict[mother]["mother"]
90+
91+
return mothers

pyleecan/GUI/Dialog/DMachineSetup/SMHoleMag/PHoleMUD/PHoleMUD.ui

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
</property>
2828
<layout class="QHBoxLayout" name="horizontalLayout">
2929
<item>
30-
<widget class="MPLCanvas2" name="w_viewer" native="true"/>
30+
<widget class="MPLCanvas" name="w_viewer" native="true"/>
3131
</item>
3232
<item>
3333
<widget class="QScrollArea" name="scrollArea">
@@ -162,7 +162,7 @@
162162
<container>1</container>
163163
</customwidget>
164164
<customwidget>
165-
<class>MPLCanvas2</class>
165+
<class>MPLCanvas</class>
166166
<extends>QWidget</extends>
167167
<header>......GUI.Tools.MPLCanvas</header>
168168
<container>1</container>

pyleecan/GUI/Dialog/DMachineSetup/SMHoleMag/PHoleMUD/Ui_PHoleMUD.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from PySide2.QtWidgets import *
1111

1212
from ......GUI.Tools.WPathSelector.WPathSelectorV import WPathSelectorV
13-
from ......GUI.Tools.MPLCanvas import MPLCanvas2
13+
from ......GUI.Tools.MPLCanvas import MPLCanvas
1414
from ......GUI.Dialog.DMatLib.WMatSelect.WMatSelect import WMatSelect
1515

1616
from pyleecan.GUI.Resources import pyleecan_rc
@@ -25,7 +25,7 @@ def setupUi(self, PHoleMUD):
2525
PHoleMUD.setMaximumSize(QSize(16777215, 16777215))
2626
self.horizontalLayout = QHBoxLayout(PHoleMUD)
2727
self.horizontalLayout.setObjectName(u"horizontalLayout")
28-
self.w_viewer = MPLCanvas2(PHoleMUD)
28+
self.w_viewer = MPLCanvas(PHoleMUD)
2929
self.w_viewer.setObjectName(u"w_viewer")
3030

3131
self.horizontalLayout.addWidget(self.w_viewer)

pyleecan/GUI/Dialog/DMachineSetup/SPreview/SPreview.ui

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<item>
2424
<layout class="QHBoxLayout" name="horizontalLayout_2">
2525
<item>
26-
<widget class="MPLCanvas2" name="w_plot" native="true">
26+
<widget class="MPLCanvas" name="w_plot" native="true">
2727
<property name="sizePolicy">
2828
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
2929
<horstretch>0</horstretch>
@@ -90,7 +90,7 @@
9090
<container>1</container>
9191
</customwidget>
9292
<customwidget>
93-
<class>MPLCanvas2</class>
93+
<class>MPLCanvas</class>
9494
<extends>QWidget</extends>
9595
<header>.....GUI.Tools.MPLCanvas.h</header>
9696
<container>1</container>

pyleecan/GUI/Dialog/DMachineSetup/SPreview/Ui_SPreview.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from .....GUI.Dialog.DMachineSetup.SPreview.WMachineTable.WMachineTable import (
1313
WMachineTable,
1414
)
15-
from .....GUI.Tools.MPLCanvas import MPLCanvas2
15+
from .....GUI.Tools.MPLCanvas import MPLCanvas
1616

1717
from pyleecan.GUI.Resources import pyleecan_rc
1818

@@ -27,7 +27,7 @@ def setupUi(self, SPreview):
2727
self.verticalLayout.setObjectName(u"verticalLayout")
2828
self.horizontalLayout_2 = QHBoxLayout()
2929
self.horizontalLayout_2.setObjectName(u"horizontalLayout_2")
30-
self.w_plot = MPLCanvas2(SPreview)
30+
self.w_plot = MPLCanvas(SPreview)
3131
self.w_plot.setObjectName(u"w_plot")
3232
sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
3333
sizePolicy.setHorizontalStretch(0)

pyleecan/GUI/Dialog/DMachineSetup/SWSlot/PWSlotUD/PWSlotUD.ui

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
</property>
2828
<layout class="QHBoxLayout" name="horizontalLayout">
2929
<item>
30-
<widget class="MPLCanvas2" name="w_viewer" native="true"/>
30+
<widget class="MPLCanvas" name="w_viewer" native="true"/>
3131
</item>
3232
<item>
3333
<widget class="QScrollArea" name="scrollArea">
@@ -109,7 +109,7 @@
109109
<container>1</container>
110110
</customwidget>
111111
<customwidget>
112-
<class>MPLCanvas2</class>
112+
<class>MPLCanvas</class>
113113
<extends>QWidget</extends>
114114
<header>......GUI.Tools.MPLCanvas</header>
115115
<container>1</container>

pyleecan/GUI/Dialog/DMachineSetup/SWSlot/PWSlotUD/Ui_PWSlotUD.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
from ......GUI.Dialog.DMachineSetup.SWSlot.WWSlotOut.WWSlotOut import WWSlotOut
1313
from ......GUI.Tools.WPathSelector.WPathSelectorV import WPathSelectorV
14-
from ......GUI.Tools.MPLCanvas import MPLCanvas2
14+
from ......GUI.Tools.MPLCanvas import MPLCanvas
1515

1616
from pyleecan.GUI.Resources import pyleecan_rc
1717

@@ -25,7 +25,7 @@ def setupUi(self, PWSlotUD):
2525
PWSlotUD.setMaximumSize(QSize(16777215, 16777215))
2626
self.horizontalLayout = QHBoxLayout(PWSlotUD)
2727
self.horizontalLayout.setObjectName(u"horizontalLayout")
28-
self.w_viewer = MPLCanvas2(PWSlotUD)
28+
self.w_viewer = MPLCanvas(PWSlotUD)
2929
self.w_viewer.setObjectName(u"w_viewer")
3030

3131
self.horizontalLayout.addWidget(self.w_viewer)

pyleecan/GUI/Dialog/DMachineSetup/SWinding/SWinding.ui

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<item>
2424
<layout class="QHBoxLayout" name="horizontalLayout_8">
2525
<item>
26-
<widget class="MPLCanvas2" name="w_viewer" native="true">
26+
<widget class="MPLCanvas" name="w_viewer" native="true">
2727
<property name="minimumSize">
2828
<size>
2929
<width>250</width>
@@ -446,7 +446,7 @@
446446
</widget>
447447
<customwidgets>
448448
<customwidget>
449-
<class>MPLCanvas2</class>
449+
<class>MPLCanvas</class>
450450
<extends>QWidget</extends>
451451
<header>.....GUI.Tools.MPLCanvas</header>
452452
<container>1</container>

0 commit comments

Comments
 (0)