-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
item as kwarg #1353
item as kwarg #1353
Changes from 4 commits
42dcc41
d876e20
af635d7
6b12b2e
cdb7eae
afa6eef
0ac89d6
5f7dd1d
70f63f9
70df234
2ccb969
83db8e9
e13685e
0f051b0
34e0650
47a0f53
6f3c1c4
0c8826e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,17 +41,24 @@ class GeometryObject(SceneObject): | |
linecolor = ColorAttribute() | ||
surfacecolor = ColorAttribute() | ||
|
||
def __init__(self, geometry, **kwargs): | ||
super(GeometryObject, self).__init__(item=geometry, **kwargs) | ||
self.geometry = geometry | ||
self.pointcolor = kwargs.get("pointcolor", self.color) | ||
self.linecolor = kwargs.get("linecolor", self.color) | ||
self.surfacecolor = kwargs.get("surfacecolor", self.color) | ||
self.pointsize = kwargs.get("pointsize", 1.0) | ||
self.linewidth = kwargs.get("linewidth", 1.0) | ||
self.show_points = kwargs.get("show_points", False) | ||
self.show_lines = kwargs.get("show_lines", True) | ||
self.show_surfaces = kwargs.get("show_surfaces", True) | ||
def __init__(self, pointcolor=None, linecolor=None, surfacecolor=None, pointsize=1.0, linewidth=1.0, show_points=False, show_lines=True, show_surfaces=True, **kwargs): | ||
super(GeometryObject, self).__init__(**kwargs) | ||
self.pointcolor = pointcolor or self.color | ||
self.linecolor = linecolor or self.color | ||
self.surfacecolor = surfacecolor or self.color | ||
self.pointsize = pointsize | ||
self.linewidth = linewidth | ||
self.show_points = show_points | ||
self.show_lines = show_lines | ||
self.show_surfaces = show_surfaces | ||
|
||
@property | ||
def geometry(self): | ||
return self.item | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we need alias we create a property that points to |
||
|
||
@geometry.setter | ||
def geometry(self, geometry): | ||
self.item = geometry | ||
|
||
def draw(self): | ||
"""Draw the geometry. Implemented by child classes.""" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,11 +46,9 @@ class GraphObject(SceneObject): | |
nodecolor = ColorDictAttribute() | ||
edgecolor = ColorDictAttribute() | ||
|
||
def __init__(self, graph, **kwargs): | ||
super(GraphObject, self).__init__(item=graph, **kwargs) | ||
self._graph = None | ||
def __init__(self, **kwargs): | ||
Licini marked this conversation as resolved.
Show resolved
Hide resolved
|
||
super(GraphObject, self).__init__(**kwargs) | ||
self._node_xyz = None | ||
self.graph = graph | ||
self.nodecolor = kwargs.get("nodecolor", self.color) | ||
self.edgecolor = kwargs.get("edgecolor", self.color) | ||
self.nodesize = kwargs.get("nodesize", 1.0) | ||
|
@@ -60,13 +58,7 @@ def __init__(self, graph, **kwargs): | |
|
||
@property | ||
def graph(self): | ||
return self._graph | ||
|
||
@graph.setter | ||
def graph(self, graph): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These setters I removed for now, because |
||
self._graph = graph | ||
self._transformation = None | ||
self._node_xyz = None | ||
return self.item | ||
|
||
@property | ||
def transformation(self): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,17 +12,7 @@ | |
|
||
|
||
class RhinoBrepObject(RhinoSceneObject, GeometryObject): | ||
"""A scene object for drawing a RhinoBrep. | ||
|
||
Parameters | ||
---------- | ||
brep : :class:`compas_rhino.geometry.RhinoBrep` | ||
The Brep to draw. | ||
|
||
""" | ||
|
||
def __init__(self, brep, **kwargs): | ||
super(RhinoBrepObject, self).__init__(geometry=brep, **kwargs) | ||
"""A scene object for drawing a RhinoBrep.""" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In many cases the |
||
|
||
def draw(self): | ||
"""Bakes the Brep into the current document | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So after adjustment, any
__init__
of subclasses should only care about additional parameters that its parent classes do not have, the data item will be passed along automatically within**kwargs
and eventualy received by the root__init__
ofSceneObject