Skip to content

Commit b911dc8

Browse files
committed
Merge branch 'main' into hashtree
2 parents 1a5a254 + 7b138a6 commit b911dc8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+545
-202
lines changed

.github/workflows/docs.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ on:
66
- main
77
tags:
88
- 'v*'
9-
pull_request:
10-
branches:
11-
- main
9+
pull_request_review:
10+
types: [submitted]
1211

1312
jobs:
1413
docs:
14+
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') || (github.event_name == 'pull_request_review' && github.event.review.state == 'approved')
1515
runs-on: ubuntu-latest
1616
steps:
1717
- uses: compas-dev/compas-actions.docs@v3

CHANGELOG.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,46 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## Unreleased
99

1010
### Added
11-
11+
* Added `viewerinstance` in `compas.scene.Scene` to support viewers context detection.
1212
* Added `compas_rhino8` as starting point for Rhino8 support.
13+
* Added `compas.scene.SceneObjectNode`.
14+
* Added `compas.scene.SceneTree`.
15+
* Added `compas.scene.SceneObject.node`.
16+
* Added `compas.scene.SceneObject.frame`.
17+
* Added `compas.scene.SceneObject.worldtransformation`.
18+
* Added `compas.scene.SceneObject.parent`.
19+
* Added `compas.scene.SceneObject.children`.
20+
* Added `compas.scene.SceneObject.add()`.
1321
* Added tutorial for `compas.datastructures.Tree`.
22+
* Added Serialisation capability to `compas.scene.Scene`.
23+
* Added `show` flag to `compas.scene.SceneObject`.
24+
* Added `show_points` flag to `compas.scene.GeometryObject`.
25+
* Added `show_lines` flag to `compas.scene.GeometryObject`.
26+
* Added `show_surfaces` flag to `compas.scene.GeometryObject`.
27+
* Added `show_vertices` flag to `compas.scene.MeshObject`.
28+
* Added `show_edges` flag to `compas.scene.MeshObject`.
29+
* Added `show_faces` flag to `compas.scene.MeshObject`.
30+
* Added `show_nodes` flag to `compas.scene.NetworkObject`.
31+
* Added `show_edges` flag to `compas.scene.NetworkObject`.
32+
* Added `show_vertices` flag to `compas.scene.VolMeshObject`.
33+
* Added `show_edges` flag to `compas.scene.VolMeshObject`.
34+
* Added `show_faces` flag to `compas.scene.VolMeshObject`.
35+
* Added `show_cells` flag to `compas.scene.VolMeshObject`.
1436
* Added `compas.datastructures.HashTree` and `compas.datastructures.HashNode`.
1537

1638
### Changed
1739

1840
* Changed the `__str__` of `compas.geometry.Point` and `compas.geometry.Vector` to use a limited number of decimals (determined by `Tolerance.PRECISION`). Note: `__repr__` will instead maintain full precision.
41+
* In pull requests, `docs` Workflow are now only triggered on review approval.
42+
* The `draw` implementations of `compas.scene.SceneObject` will now always use the `worldtransformation` of the `SceneObject`.
43+
* Fixed typo in name `Rhino.Geometry.MeshingParameters` in `compas_rhino.geometry.RhinoBrep.to_meshes()`.
44+
* Fixed `TypeErrorException` when serializing a `Mesh` which has been converted from Rhino.
45+
* Fixed color conversions in `compas_rhion.conversions.mesh_to_compas`.
1946

2047
### Removed
2148

2249
* Removed `compas_rhino.forms`. Forms will be moved to `compas_ui`.
2350

24-
2551
## [2.0.0-beta.1] 2023-12-20
2652

2753
### Added

docs/userguide/scene.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474

7575
x = 0
7676
y = 0
77-
for obj in scene.sceneobjects:
77+
for obj in scene.objects:
7878
obj.transformation = Translation.from_vector([x, y, 0])
7979
x += 5
8080
if x > 20:

src/compas/data/encoders.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def default(self, o):
151151
return None
152152

153153
if dotnet_support:
154-
if isinstance(o, System.Decimal):
154+
if isinstance(o, (System.Decimal, System.Double, System.Single)):
155155
return float(o)
156156

157157
return super(DataEncoder, self).default(o)

src/compas/scene/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
from .context import register
2424

2525
from .scene import Scene
26+
from .scene import SceneObjectNode
27+
from .scene import SceneTree
2628

2729
__all__ = [
2830
"SceneObjectNotRegisteredError",
@@ -33,6 +35,8 @@
3335
"GeometryObject",
3436
"VolMeshObject",
3537
"Scene",
38+
"SceneObjectNode",
39+
"SceneTree",
3640
"clear",
3741
"redraw",
3842
"register_scene_objects",

src/compas/scene/context.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
from compas.plugins import pluggable
1+
import inspect
2+
from collections import defaultdict
3+
4+
import compas
25
from compas.plugins import PluginValidator
6+
from compas.plugins import pluggable
7+
38
from .exceptions import NoSceneObjectContextError
49
from .exceptions import SceneObjectNotRegisteredError
5-
import inspect
6-
import compas
7-
from collections import defaultdict
810

911
ITEM_SCENEOBJECT = defaultdict(dict)
1012

@@ -62,15 +64,9 @@ def is_viewer_open():
6264
bool
6365
6466
"""
65-
# TODO: implement [without introducing compas_view2 as a dependency..?]
66-
# make the viewer app a singleton
67-
# check for the exitence of an instance of the singleton
68-
# if the instance exists, return True
69-
# in this case, the viewer is the current context
70-
# to do this without introducing compas_view2 as a dependency,
71-
# creating the singleton instance should modify a class attribute of the SceneObject
72-
# (or potentially a module level attribute of compas itself)
73-
return False
67+
from compas.scene import Scene
68+
69+
return Scene.viewerinstance is not None
7470

7571

7672
def _detect_current_context():

src/compas/scene/geometryobject.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ class GeometryObject(SceneObject):
2828
The size of the points.
2929
linewidth : float
3030
The width of the lines or curves.
31+
show_points : bool
32+
Flag for showing or hiding the points. Default is ``False``.
33+
show_lines : bool
34+
Flag for showing or hiding the lines or curves. Default is ``True``.
35+
show_surfaces : bool
36+
Flag for showing or hiding the surfaces. Default is ``True``.
3137
3238
"""
3339

@@ -43,3 +49,6 @@ def __init__(self, geometry, **kwargs):
4349
self.surfacecolor = kwargs.get("surfacecolor", self.color)
4450
self.pointsize = kwargs.get("pointsize", 1.0)
4551
self.linewidth = kwargs.get("linewidth", 1.0)
52+
self.show_points = kwargs.get("show_points", False)
53+
self.show_lines = kwargs.get("show_lines", True)
54+
self.show_surfaces = kwargs.get("show_surfaces", True)

src/compas/scene/meshobject.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ class MeshObject(SceneObject):
3232
Edge colors.
3333
facecolor : :class:`compas.colors.ColorDict`
3434
Face colors.
35+
vertexsize : float
36+
The size of the vertices. Default is ``1.0``.
37+
edgewidth : float
38+
The width of the edges. Default is ``1.0``.
39+
show_vertices : bool
40+
Flag for showing or hiding the vertices. Default is ``False``.
41+
show_edges : bool
42+
Flag for showing or hiding the edges. Default is ``True``.
43+
show_faces : bool
44+
Flag for showing or hiding the faces. Default is ``True``.
3545
3646
See Also
3747
--------
@@ -54,6 +64,9 @@ def __init__(self, mesh, **kwargs):
5464
self.facecolor = kwargs.get("facecolor", self.color)
5565
self.vertexsize = kwargs.get("vertexsize", 1.0)
5666
self.edgewidth = kwargs.get("edgewidth", 1.0)
67+
self.show_vertices = kwargs.get("show_vertices", False)
68+
self.show_edges = kwargs.get("show_edges", True)
69+
self.show_faces = kwargs.get("show_faces", True)
5770

5871
@property
5972
def mesh(self):
@@ -78,8 +91,7 @@ def transformation(self, transformation):
7891
def vertex_xyz(self):
7992
if self._vertex_xyz is None:
8093
points = self.mesh.vertices_attributes("xyz") # type: ignore
81-
if self.transformation:
82-
points = transform_points(points, self.transformation)
94+
points = transform_points(points, self.worldtransformation)
8395
self._vertex_xyz = dict(zip(self.mesh.vertices(), points)) # type: ignore
8496
return self._vertex_xyz
8597

src/compas/scene/networkobject.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,13 @@ class NetworkObject(SceneObject):
2929
edgecolor : :class:`compas.colors.ColorDict`
3030
Mapping between edges and colors.
3131
nodesize : float
32-
The size of the nodes.
32+
The size of the nodes. Default is ``1.0``.
3333
edgewidth : float
34-
The width of the edges.
34+
The width of the edges. Default is ``1.0``.
35+
show_nodes : bool
36+
Flag for showing or hiding the nodes. Default is ``True``.
37+
show_edges : bool
38+
Flag for showing or hiding the edges. Default is ``True``.
3539
3640
See Also
3741
--------
@@ -52,6 +56,8 @@ def __init__(self, network, **kwargs):
5256
self.edgecolor = kwargs.get("edgecolor", self.color)
5357
self.nodesize = kwargs.get("nodesize", 1.0)
5458
self.edgewidth = kwargs.get("edgewidth", 1.0)
59+
self.show_nodes = kwargs.get("show_nodes", True)
60+
self.show_edges = kwargs.get("show_edges", True)
5561

5662
@property
5763
def network(self):
@@ -76,8 +82,7 @@ def transformation(self, transformation):
7682
def node_xyz(self):
7783
if self._node_xyz is None:
7884
points = self.network.nodes_attributes("xyz") # type: ignore
79-
if self.transformation:
80-
points = transform_points(points, self.transformation)
85+
points = transform_points(points, self.worldtransformation)
8186
self._node_xyz = dict(zip(self.network.nodes(), points)) # type: ignore
8287
return self._node_xyz
8388

0 commit comments

Comments
 (0)