Skip to content

Commit 0211adb

Browse files
committed
update draw and class name of rhino scene objects
1 parent 09688c7 commit 0211adb

27 files changed

+258
-342
lines changed

docs/api/compas_rhino.scene.rst

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,29 @@ Classes
1919
:toctree: generated/
2020
:nosignatures:
2121

22-
BoxObject
23-
BrepObject
24-
CapsuleObject
25-
CircleObject
26-
ConeObject
27-
CurveObject
28-
CylinderObject
29-
EllipseObject
30-
FrameObject
31-
LineObject
32-
MeshObject
33-
GraphObject
34-
PlaneObject
35-
PointObject
36-
PolygonObject
37-
PolyhedronObject
38-
PolylineObject
22+
RhinoBoxObject
23+
RhinoBrepObject
24+
RhinoCapsuleObject
25+
RhinoCircleObject
26+
RhinoConeObject
27+
RhinoCurveObject
28+
RhinoCylinderObject
29+
RhinoEllipseObject
30+
RhinoFrameObject
31+
RhinoLineObject
32+
RhinoMeshObject
33+
RhinoGraphObject
34+
RhinoPlaneObject
35+
RhinoPointObject
36+
RhinoPolygonObject
37+
RhinoPolyhedronObject
38+
RhinoPolylineObject
3939
RhinoSceneObject
40-
SphereObject
41-
SurfaceObject
42-
TorusObject
43-
VectorObject
44-
VolMeshObject
40+
RhinoSphereObject
41+
RhinoSurfaceObject
42+
RhinoTorusObject
43+
RhinoVectorObject
44+
RhinoVolMeshObject
4545

4646

4747

src/compas/scene/sceneobject.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ class SceneObject(object):
4545
The transformation of the scene object in world coordinates.
4646
color : :class:`compas.colors.Color`
4747
The color of the object.
48+
contrastcolor : :class:`compas.colors.Color`, readon-only
49+
The contrastcolor wrt to the color.
50+
This is a 50% darket or lighter version of the color, depending on whether the color is light or dark.
4851
opacity : float
4952
The opacity of the object.
5053
show : bool

src/compas_rhino/scene/__init__.py

Lines changed: 66 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,13 @@
1717
from compas.geometry import Polygon
1818
from compas.geometry import Polyline
1919
from compas.geometry import Vector
20-
2120
from compas.geometry import Box
2221
from compas.geometry import Capsule
2322
from compas.geometry import Cone
2423
from compas.geometry import Cylinder
2524
from compas.geometry import Polyhedron
2625
from compas.geometry import Sphere
2726
from compas.geometry import Torus
28-
2927
from compas.geometry import Curve
3028
from compas.geometry import Surface
3129
from compas.geometry import Brep
@@ -37,31 +35,28 @@
3735
import compas_rhino
3836

3937
from .sceneobject import RhinoSceneObject
40-
from .circleobject import CircleObject
41-
from .ellipseobject import EllipseObject
42-
from .frameobject import FrameObject
43-
from .lineobject import LineObject
44-
from .planeobject import PlaneObject
45-
from .pointobject import PointObject
46-
from .polygonobject import PolygonObject
47-
from .polylineobject import PolylineObject
48-
from .vectorobject import VectorObject
49-
50-
from .boxobject import BoxObject
51-
from .capsuleobject import CapsuleObject
52-
from .coneobject import ConeObject
53-
from .cylinderobject import CylinderObject
54-
from .polyhedronobject import PolyhedronObject
55-
from .sphereobject import SphereObject
56-
from .torusobject import TorusObject
57-
58-
from .meshobject import MeshObject
59-
from .graphobject import GraphObject
60-
from .volmeshobject import VolMeshObject
61-
62-
from .curveobject import CurveObject
63-
from .surfaceobject import SurfaceObject
64-
from .brepobject import BrepObject
38+
from .circleobject import RhinoCircleObject
39+
from .ellipseobject import RhinoEllipseObject
40+
from .frameobject import RhinoFrameObject
41+
from .lineobject import RhinoLineObject
42+
from .planeobject import RhinoPlaneObject
43+
from .pointobject import RhinoPointObject
44+
from .polygonobject import RhinoPolygonObject
45+
from .polylineobject import RhinoPolylineObject
46+
from .vectorobject import RhinoVectorObject
47+
from .boxobject import RhinoBoxObject
48+
from .brepobject import RhinoBrepObject
49+
from .capsuleobject import RhinoCapsuleObject
50+
from .coneobject import RhinoConeObject
51+
from .cylinderobject import RhinoCylinderObject
52+
from .polyhedronobject import RhinoPolyhedronObject
53+
from .sphereobject import RhinoSphereObject
54+
from .torusobject import RhinoTorusObject
55+
from .meshobject import RhinoMeshObject
56+
from .graphobject import RhinoGraphObject
57+
from .volmeshobject import RhinoVolMeshObject
58+
from .curveobject import RhinoCurveObject
59+
from .surfaceobject import RhinoSurfaceObject
6560

6661

6762
@plugin(category="drawing-utils", pluggable_name="clear", requires=["Rhino"])
@@ -76,53 +71,53 @@ def after_draw_rhino(drawn_objects):
7671

7772
@plugin(category="factories", requires=["Rhino"])
7873
def register_scene_objects():
79-
register(Circle, CircleObject, context="Rhino")
80-
register(Ellipse, EllipseObject, context="Rhino")
81-
register(Frame, FrameObject, context="Rhino")
82-
register(Line, LineObject, context="Rhino")
83-
register(Plane, PlaneObject, context="Rhino")
84-
register(Point, PointObject, context="Rhino")
85-
register(Polygon, PolygonObject, context="Rhino")
86-
register(Polyline, PolylineObject, context="Rhino")
87-
register(Vector, VectorObject, context="Rhino")
88-
register(Box, BoxObject, context="Rhino")
89-
register(Capsule, CapsuleObject, context="Rhino")
90-
register(Cone, ConeObject, context="Rhino")
91-
register(Cylinder, CylinderObject, context="Rhino")
92-
register(Polyhedron, PolyhedronObject, context="Rhino")
93-
register(Sphere, SphereObject, context="Rhino")
94-
register(Torus, TorusObject, context="Rhino")
95-
register(Mesh, MeshObject, context="Rhino")
96-
register(Graph, GraphObject, context="Rhino")
97-
register(VolMesh, VolMeshObject, context="Rhino")
98-
register(Curve, CurveObject, context="Rhino")
99-
register(Surface, SurfaceObject, context="Rhino")
100-
register(Brep, BrepObject, context="Rhino")
74+
register(Circle, RhinoCircleObject, context="Rhino")
75+
register(Ellipse, RhinoEllipseObject, context="Rhino")
76+
register(Frame, RhinoFrameObject, context="Rhino")
77+
register(Line, RhinoLineObject, context="Rhino")
78+
register(Plane, RhinoPlaneObject, context="Rhino")
79+
register(Point, RhinoPointObject, context="Rhino")
80+
register(Polygon, RhinoPolygonObject, context="Rhino")
81+
register(Polyline, RhinoPolylineObject, context="Rhino")
82+
register(Vector, RhinoVectorObject, context="Rhino")
83+
register(Box, RhinoBoxObject, context="Rhino")
84+
register(Capsule, RhinoCapsuleObject, context="Rhino")
85+
register(Cone, RhinoConeObject, context="Rhino")
86+
register(Cylinder, RhinoCylinderObject, context="Rhino")
87+
register(Polyhedron, RhinoPolyhedronObject, context="Rhino")
88+
register(Sphere, RhinoSphereObject, context="Rhino")
89+
register(Torus, RhinoTorusObject, context="Rhino")
90+
register(Mesh, RhinoMeshObject, context="Rhino")
91+
register(Graph, RhinoGraphObject, context="Rhino")
92+
register(VolMesh, RhinoVolMeshObject, context="Rhino")
93+
register(Curve, RhinoCurveObject, context="Rhino")
94+
register(Surface, RhinoSurfaceObject, context="Rhino")
95+
register(Brep, RhinoBrepObject, context="Rhino")
10196
print("Rhino SceneObjects registered.")
10297

10398

10499
__all__ = [
105100
"RhinoSceneObject",
106-
"CircleObject",
107-
"EllipseObject",
108-
"FrameObject",
109-
"LineObject",
110-
"PlaneObject",
111-
"PointObject",
112-
"PolygonObject",
113-
"PolylineObject",
114-
"VectorObject",
115-
"BoxObject",
116-
"CapsuleObject",
117-
"ConeObject",
118-
"CylinderObject",
119-
"PolyhedronObject",
120-
"SphereObject",
121-
"TorusObject",
122-
"MeshObject",
123-
"GraphObject",
124-
"VolMeshObject",
125-
"CurveObject",
126-
"SurfaceObject",
127-
"BrepObject",
101+
"RhinoCircleObject",
102+
"RhinoEllipseObject",
103+
"RhinoFrameObject",
104+
"RhinoLineObject",
105+
"RhinoPlaneObject",
106+
"RhinoPointObject",
107+
"RhinoPolygonObject",
108+
"RhinoPolylineObject",
109+
"RhinoVectorObject",
110+
"RhinoBoxObject",
111+
"RhinoCapsuleObject",
112+
"RhinoConeObject",
113+
"RhinoCylinderObject",
114+
"RhinoPolyhedronObject",
115+
"RhinoSphereObject",
116+
"RhinoTorusObject",
117+
"RhinoMeshObject",
118+
"RhinoGraphObject",
119+
"RhinoVolMeshObject",
120+
"RhinoCurveObject",
121+
"RhinoSurfaceObject",
122+
"RhinoBrepObject",
128123
]

src/compas_rhino/scene/boxobject.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
from compas_rhino.conversions import box_to_rhino
99
from compas_rhino.conversions import transformation_to_rhino
1010
from .sceneobject import RhinoSceneObject
11-
from .helpers import attributes
1211

1312

14-
class BoxObject(RhinoSceneObject, GeometryObject):
13+
class RhinoBoxObject(RhinoSceneObject, GeometryObject):
1514
"""Scene object for drawing box shapes.
1615
1716
Parameters
@@ -24,7 +23,7 @@ class BoxObject(RhinoSceneObject, GeometryObject):
2423
"""
2524

2625
def __init__(self, box, **kwargs):
27-
super(BoxObject, self).__init__(geometry=box, **kwargs)
26+
super(RhinoBoxObject, self).__init__(geometry=box, **kwargs)
2827
self.box = box
2928

3029
def draw(self):
@@ -36,10 +35,9 @@ def draw(self):
3635
List of GUIDs of the objects created in Rhino.
3736
3837
"""
39-
attr = attributes(name=self.geometry.name, color=self.color, layer=self.layer)
38+
attr = self.compile_attributes()
4039
geometry = box_to_rhino(self.geometry)
41-
transformation = transformation_to_rhino(self.worldtransformation)
42-
geometry.Transform(transformation)
40+
geometry.Transform(transformation_to_rhino(self.worldtransformation))
4341

4442
self._guids = [sc.doc.Objects.AddBox(geometry, attr)]
4543
return self.guids

src/compas_rhino/scene/brepobject.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
from compas_rhino.conversions import transformation_to_rhino
99
from compas.scene import GeometryObject
1010
from .sceneobject import RhinoSceneObject
11-
from .helpers import attributes
1211

1312

14-
class BrepObject(RhinoSceneObject, GeometryObject):
13+
class RhinoBrepObject(RhinoSceneObject, GeometryObject):
1514
"""A scene object for drawing a RhinoBrep.
1615
1716
Parameters
@@ -22,7 +21,7 @@ class BrepObject(RhinoSceneObject, GeometryObject):
2221
"""
2322

2423
def __init__(self, brep, **kwargs):
25-
super(BrepObject, self).__init__(geometry=brep, **kwargs)
24+
super(RhinoBrepObject, self).__init__(geometry=brep, **kwargs)
2625

2726
def draw(self):
2827
"""Bakes the Brep into the current document
@@ -33,7 +32,7 @@ def draw(self):
3332
List of GUIDs of the objects created in Rhino.
3433
3534
"""
36-
attr = attributes(name=self.geometry.name, color=self.color, layer=self.layer)
35+
attr = self.compile_attributes()
3736
geometry = brep_to_rhino(self.geometry)
3837
geometry.Transform(transformation_to_rhino(self.worldtransformation))
3938

src/compas_rhino/scene/capsuleobject.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
from compas_rhino.conversions import capsule_to_rhino_brep
99
from compas_rhino.conversions import transformation_to_rhino
1010
from .sceneobject import RhinoSceneObject
11-
from .helpers import attributes
1211

1312

14-
class CapsuleObject(RhinoSceneObject, GeometryObject):
13+
class RhinoCapsuleObject(RhinoSceneObject, GeometryObject):
1514
"""Scene object for drawing capsule shapes.
1615
1716
Parameters
@@ -24,7 +23,7 @@ class CapsuleObject(RhinoSceneObject, GeometryObject):
2423
"""
2524

2625
def __init__(self, capsule, **kwargs):
27-
super(CapsuleObject, self).__init__(geometry=capsule, **kwargs)
26+
super(RhinoCapsuleObject, self).__init__(geometry=capsule, **kwargs)
2827

2928
def draw(self):
3029
"""Draw the capsule associated with the scene object.
@@ -35,7 +34,7 @@ def draw(self):
3534
The GUIDs of the objects created in Rhino.
3635
3736
"""
38-
attr = attributes(name=self.geometry.name, color=self.color, layer=self.layer)
37+
attr = self.compile_attributes()
3938
breps = capsule_to_rhino_brep(self.geometry)
4039
transformation = transformation_to_rhino(self.worldtransformation)
4140
for geometry in breps:

src/compas_rhino/scene/circleobject.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
from compas_rhino.conversions import circle_to_rhino
99
from compas_rhino.conversions import transformation_to_rhino
1010
from .sceneobject import RhinoSceneObject
11-
from .helpers import attributes
1211

1312

14-
class CircleObject(RhinoSceneObject, GeometryObject):
13+
class RhinoCircleObject(RhinoSceneObject, GeometryObject):
1514
"""Scene object for drawing circles.
1615
1716
Parameters
@@ -24,7 +23,7 @@ class CircleObject(RhinoSceneObject, GeometryObject):
2423
"""
2524

2625
def __init__(self, circle, **kwargs):
27-
super(CircleObject, self).__init__(geometry=circle, **kwargs)
26+
super(RhinoCircleObject, self).__init__(geometry=circle, **kwargs)
2827

2928
def draw(self):
3029
"""Draw the circle.
@@ -35,7 +34,7 @@ def draw(self):
3534
List of GUIDs of the objects created in Rhino.
3635
3736
"""
38-
attr = attributes(name=self.geometry.name, color=self.color, layer=self.layer)
37+
attr = self.compile_attributes()
3938
geometry = circle_to_rhino(self.geometry)
4039
geometry.Transform(transformation_to_rhino(self.worldtransformation))
4140

src/compas_rhino/scene/coneobject.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
from compas_rhino.conversions import cone_to_rhino_brep
99
from compas_rhino.conversions import transformation_to_rhino
1010
from .sceneobject import RhinoSceneObject
11-
from .helpers import attributes
1211

1312

14-
class ConeObject(RhinoSceneObject, GeometryObject):
13+
class RhinoConeObject(RhinoSceneObject, GeometryObject):
1514
"""Scene object for drawing cone shapes.
1615
1716
Parameters
@@ -24,7 +23,7 @@ class ConeObject(RhinoSceneObject, GeometryObject):
2423
"""
2524

2625
def __init__(self, cone, **kwargs):
27-
super(ConeObject, self).__init__(geometry=cone, **kwargs)
26+
super(RhinoConeObject, self).__init__(geometry=cone, **kwargs)
2827

2928
def draw(self):
3029
"""Draw the cone associated with the scene object.
@@ -35,7 +34,7 @@ def draw(self):
3534
The GUID of the object created in Rhino.
3635
3736
"""
38-
attr = attributes(name=self.geometry.name, color=self.color, layer=self.layer)
37+
attr = self.compile_attributes()
3938
geometry = cone_to_rhino_brep(self.geometry)
4039
geometry.Transform(transformation_to_rhino(self.worldtransformation))
4140

0 commit comments

Comments
 (0)