Skip to content

Commit

Permalink
add arrow example
Browse files Browse the repository at this point in the history
  • Loading branch information
Licini committed Aug 15, 2024
1 parent a2dd871 commit f9ad50f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
21 changes: 21 additions & 0 deletions scripts/arrows.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

import compas
from compas.colors import Color
from compas.geometry import Vector
from compas_viewer.viewer import Viewer

viewer = Viewer()

N = 10
M = 10

for i in range(N):
for j in range(M):
viewer.scene.add(
Vector(0, 0, (i + j + 1) / 5),
anchor = [i, j, 0],
linecolor=Color(i / N, j / M, 0.0),
name=f"Arrow_{i}_{j}",
)

viewer.show()
2 changes: 1 addition & 1 deletion src/compas_viewer/components/color.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def __init__(
elif isinstance(default_color, ColorDict):
default_color = default_color.default
else:
raise ValueError("Invalid color type.")
raise ValueError("Invalid color type. : {}".format(type(default_color)))
default_color = QColor(*remap_rgb(default_color, to_range_one=False))

self.color_button = QPushButton(self)
Expand Down
2 changes: 1 addition & 1 deletion src/compas_viewer/components/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def set_layout(self, items: list[dict], obj: Any) -> None:
min_val: float = sub_item.get("min_val", None)
max_val: float = sub_item.get("max_val", None)

if attr and not hasattr(obj, attr):
if attr and getattr(obj, attr, None) is None:
# TODO: @Tsai, this needs to be handled at upper level.
continue

Expand Down

0 comments on commit f9ad50f

Please sign in to comment.