Skip to content

Commit

Permalink
Merge pull request #420 from SebGue/TreeEdit
Browse files Browse the repository at this point in the history
[NF] Generic Object Editor
  • Loading branch information
BonneelP authored Sep 24, 2021
2 parents 2842345 + 481f488 commit bc375c8
Show file tree
Hide file tree
Showing 31 changed files with 1,841 additions and 136 deletions.
10 changes: 5 additions & 5 deletions pyleecan/Classes/Class_Dict.json
Original file line number Diff line number Diff line change
Expand Up @@ -6813,21 +6813,21 @@
"path": "pyleecan/Generator/ClassesRef/Material/ModelBH.csv",
"properties": [
{
"desc": "Max value of H for extrapolation",
"desc": "Max value of B for extrapolation",
"max": "",
"min": "",
"name": "Bmax",
"type": "float",
"unit": "-",
"unit": "T",
"value": 2.31
},
{
"desc": "Max value of B for extrapolation",
"desc": "Max value of H for extrapolation",
"max": "",
"min": "",
"name": "Hmax",
"type": "float",
"unit": "-",
"unit": "A/m",
"value": null
},
{
Expand All @@ -6836,7 +6836,7 @@
"min": "",
"name": "delta",
"type": "float",
"unit": "-",
"unit": "A/m",
"value": 100
}
]
Expand Down
4 changes: 2 additions & 2 deletions pyleecan/Classes/ModelBH.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def _set_Bmax(self, value):
Bmax = property(
fget=_get_Bmax,
fset=_set_Bmax,
doc=u"""Max value of H for extrapolation
doc=u"""Max value of B for extrapolation
:Type: float
""",
Expand All @@ -197,7 +197,7 @@ def _set_Hmax(self, value):
Hmax = property(
fget=_get_Hmax,
fset=_set_Hmax,
doc=u"""Max value of B for extrapolation
doc=u"""Max value of H for extrapolation
:Type: float
""",
Expand Down
91 changes: 91 additions & 0 deletions pyleecan/Classes/_ClassInfo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
from json import load as jload
from os.path import join, split


class ClassInfo:
def __init__(self):
self.class_dict = self.__init_dict__()

def __init_dict__(self):
"""Method to get a dict on the pyleecan classes, i.e. class name, description,
properties, methods, etc.
Returns
-------
class_dict : dict
dict of class information
"""
# load the class dict
path = split(__file__)[0]
with open(join(path, "Class_Dict.json")) as fp:
class_dict = jload(fp)

# create inheritance information
for cls_name in class_dict.keys():
mother_name = class_dict[cls_name]["mother"]
inherit = []
while mother_name:
inherit.append(mother_name)
mother_name = class_dict[mother_name]["mother"]

class_dict[cls_name]["inherit"] = inherit

# from pprint import pprint
# pprint(sorted([ClassInfo().get_prop_types()]))

# complete properties and methods on each class
for cls_dict in class_dict.values():
prop_names = [prop["name"] for prop in cls_dict["properties"]]
for mother in cls_dict["inherit"]:
mother_props = class_dict[mother]["properties"]
for mother_prop in mother_props:
if not mother_prop["name"] in prop_names:
cls_dict["properties"].append(mother_prop)

# update property names
prop_names = [prop["name"] for prop in cls_dict["properties"]]

# convert properties to dict
cls_dict["prop_dict"] = dict()
for prop in cls_dict["properties"]:
cls_dict["prop_dict"][prop["name"]] = prop

return class_dict

def get_dict(self):
return self.class_dict

def get_prop_types(self):
"""Get a set of all defined property types of all classes."""
type_set = set()

for cls in self.class_dict.values():
for prop in cls["prop_dict"].values():
type_set.add(prop["type"])

return type_set

def get_base_classes(self):
"""Get the base classes, i.e. classes that have no mother class."""
bases = set()
for key, item in self.class_dict.items():
if not item["mother"]:
bases.add(key)

bases = sorted(list(bases))

return bases

def get_mothers(self, cls_name, stop=""):
"""Get a ordered list of the mothers of a class."""
mothers = []
if stop not in self.class_dict:
stop = ""
if cls_name in self.class_dict:
mother = self.class_dict[cls_name]["mother"]
while mother and cls_name != stop:
mothers.append(mother)
cls_name = mother
mother = self.class_dict[mother]["mother"]

return mothers
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="MPLCanvas2" name="w_viewer" native="true"/>
<widget class="MPLCanvas" name="w_viewer" native="true"/>
</item>
<item>
<widget class="QScrollArea" name="scrollArea">
Expand Down Expand Up @@ -162,7 +162,7 @@
<container>1</container>
</customwidget>
<customwidget>
<class>MPLCanvas2</class>
<class>MPLCanvas</class>
<extends>QWidget</extends>
<header>......GUI.Tools.MPLCanvas</header>
<container>1</container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from PySide2.QtWidgets import *

from ......GUI.Tools.WPathSelector.WPathSelectorV import WPathSelectorV
from ......GUI.Tools.MPLCanvas import MPLCanvas2
from ......GUI.Tools.MPLCanvas import MPLCanvas
from ......GUI.Dialog.DMatLib.WMatSelect.WMatSelect import WMatSelect

from pyleecan.GUI.Resources import pyleecan_rc
Expand All @@ -25,7 +25,7 @@ def setupUi(self, PHoleMUD):
PHoleMUD.setMaximumSize(QSize(16777215, 16777215))
self.horizontalLayout = QHBoxLayout(PHoleMUD)
self.horizontalLayout.setObjectName(u"horizontalLayout")
self.w_viewer = MPLCanvas2(PHoleMUD)
self.w_viewer = MPLCanvas(PHoleMUD)
self.w_viewer.setObjectName(u"w_viewer")

self.horizontalLayout.addWidget(self.w_viewer)
Expand Down
4 changes: 2 additions & 2 deletions pyleecan/GUI/Dialog/DMachineSetup/SPreview/SPreview.ui
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="MPLCanvas2" name="w_plot" native="true">
<widget class="MPLCanvas" name="w_plot" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
Expand Down Expand Up @@ -90,7 +90,7 @@
<container>1</container>
</customwidget>
<customwidget>
<class>MPLCanvas2</class>
<class>MPLCanvas</class>
<extends>QWidget</extends>
<header>.....GUI.Tools.MPLCanvas.h</header>
<container>1</container>
Expand Down
4 changes: 2 additions & 2 deletions pyleecan/GUI/Dialog/DMachineSetup/SPreview/Ui_SPreview.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from .....GUI.Dialog.DMachineSetup.SPreview.WMachineTable.WMachineTable import (
WMachineTable,
)
from .....GUI.Tools.MPLCanvas import MPLCanvas2
from .....GUI.Tools.MPLCanvas import MPLCanvas

from pyleecan.GUI.Resources import pyleecan_rc

Expand All @@ -27,7 +27,7 @@ def setupUi(self, SPreview):
self.verticalLayout.setObjectName(u"verticalLayout")
self.horizontalLayout_2 = QHBoxLayout()
self.horizontalLayout_2.setObjectName(u"horizontalLayout_2")
self.w_plot = MPLCanvas2(SPreview)
self.w_plot = MPLCanvas(SPreview)
self.w_plot.setObjectName(u"w_plot")
sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
Expand Down
4 changes: 2 additions & 2 deletions pyleecan/GUI/Dialog/DMachineSetup/SWSlot/PWSlotUD/PWSlotUD.ui
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="MPLCanvas2" name="w_viewer" native="true"/>
<widget class="MPLCanvas" name="w_viewer" native="true"/>
</item>
<item>
<widget class="QScrollArea" name="scrollArea">
Expand Down Expand Up @@ -109,7 +109,7 @@
<container>1</container>
</customwidget>
<customwidget>
<class>MPLCanvas2</class>
<class>MPLCanvas</class>
<extends>QWidget</extends>
<header>......GUI.Tools.MPLCanvas</header>
<container>1</container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from ......GUI.Dialog.DMachineSetup.SWSlot.WWSlotOut.WWSlotOut import WWSlotOut
from ......GUI.Tools.WPathSelector.WPathSelectorV import WPathSelectorV
from ......GUI.Tools.MPLCanvas import MPLCanvas2
from ......GUI.Tools.MPLCanvas import MPLCanvas

from pyleecan.GUI.Resources import pyleecan_rc

Expand All @@ -25,7 +25,7 @@ def setupUi(self, PWSlotUD):
PWSlotUD.setMaximumSize(QSize(16777215, 16777215))
self.horizontalLayout = QHBoxLayout(PWSlotUD)
self.horizontalLayout.setObjectName(u"horizontalLayout")
self.w_viewer = MPLCanvas2(PWSlotUD)
self.w_viewer = MPLCanvas(PWSlotUD)
self.w_viewer.setObjectName(u"w_viewer")

self.horizontalLayout.addWidget(self.w_viewer)
Expand Down
4 changes: 2 additions & 2 deletions pyleecan/GUI/Dialog/DMachineSetup/SWinding/SWinding.ui
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="MPLCanvas2" name="w_viewer" native="true">
<widget class="MPLCanvas" name="w_viewer" native="true">
<property name="minimumSize">
<size>
<width>250</width>
Expand Down Expand Up @@ -446,7 +446,7 @@
</widget>
<customwidgets>
<customwidget>
<class>MPLCanvas2</class>
<class>MPLCanvas</class>
<extends>QWidget</extends>
<header>.....GUI.Tools.MPLCanvas</header>
<container>1</container>
Expand Down
4 changes: 2 additions & 2 deletions pyleecan/GUI/Dialog/DMachineSetup/SWinding/Ui_SWinding.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from PySide2.QtGui import *
from PySide2.QtWidgets import *

from .....GUI.Tools.MPLCanvas import MPLCanvas2
from .....GUI.Tools.MPLCanvas import MPLCanvas

from pyleecan.GUI.Resources import pyleecan_rc

Expand All @@ -24,7 +24,7 @@ def setupUi(self, SWinding):
self.verticalLayout_4.setObjectName(u"verticalLayout_4")
self.horizontalLayout_8 = QHBoxLayout()
self.horizontalLayout_8.setObjectName(u"horizontalLayout_8")
self.w_viewer = MPLCanvas2(SWinding)
self.w_viewer = MPLCanvas(SWinding)
self.w_viewer.setObjectName(u"w_viewer")
self.w_viewer.setMinimumSize(QSize(250, 0))

Expand Down
2 changes: 1 addition & 1 deletion pyleecan/GUI/Dxf/DXF_Hole.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from ...Classes.SurfLine import SurfLine
from ...GUI.Dxf.dxf_to_pyleecan_list import dxf_to_pyleecan_list
from ...GUI.Resources import pixmap_dict
from ...GUI.Tools.MPLCanvas import MPLCanvas2
from ...GUI.Tools.MPLCanvas import MPLCanvas
from ...GUI.Tools.FloatEdit import FloatEdit
from ...GUI import gui_option
from ...loggers import GUI_LOG_NAME
Expand Down
2 changes: 1 addition & 1 deletion pyleecan/GUI/Dxf/DXF_Slot.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from ...definitions import config_dict
from ...GUI.Dxf.dxf_to_pyleecan_list import dxf_to_pyleecan_list
from ...GUI.Resources import pixmap_dict
from ...GUI.Tools.MPLCanvas import MPLCanvas2
from ...GUI.Tools.MPLCanvas import MPLCanvas
from ...loggers import GUI_LOG_NAME
from .Ui_DXF_Slot import Ui_DXF_Slot
from ...Functions.init_fig import init_fig
Expand Down
Loading

0 comments on commit bc375c8

Please sign in to comment.