diff --git a/example/raytrace/example_RayTraceOutput.py b/example/raytrace/example_RayTraceOutput.py index fa4ca862c..71b0a1de0 100644 --- a/example/raytrace/example_RayTraceOutput.py +++ b/example/raytrace/example_RayTraceOutput.py @@ -639,14 +639,14 @@ def fn_5w1(x, y): def _draw_helper(view: View3d) -> None: sf1.draw(view, solar_field_style) trace.draw(view, trace_control) - aimpoint_xyz.draw_point(view, style=rcps.marker(color='tab:orange')) + aimpoint_xyz.draw_points(view, style=rcps.marker(color='tab:orange')) # debug heliostat_origin = sf1.heliostats[0].self_to_global_tranformation.apply(Pxyz.origin()) pointing_vector = st.tracking_surface_normal_xyz( heliostat_origin, aimpoint_xyz, lln.NSTTF_ORIGIN, when_ymdhmsz ) - Vxyz.merge([heliostat_origin, heliostat_origin + pointing_vector * 10]).draw_list(view) + Vxyz.merge([heliostat_origin, heliostat_origin + pointing_vector * 10]).draw_line(view) # debug self.show_save_and_check_figure(fig_record) @@ -770,7 +770,7 @@ def example_partial_field_trace(self) -> None: trace = rt.trace_scene(scene, Resolution.center(), verbose=False) trace.draw(view, RenderControlRayTrace(RenderControlLightPath(15, 200))) - aimpoint_xyz.draw_point(view, rcps.RenderControlPointSeq(color='orange', marker='.')) + aimpoint_xyz.draw_points(view, rcps.RenderControlPointSeq(color='orange', marker='.')) self.show_save_and_check_figure(fig_record) diff --git a/example/solarfield/example_SolarFieldOutput.py b/example/solarfield/example_SolarFieldOutput.py index 1a611b946..551c88f63 100644 --- a/example/solarfield/example_SolarFieldOutput.py +++ b/example/solarfield/example_SolarFieldOutput.py @@ -503,7 +503,7 @@ def example_solar_field_h_outlines(self) -> None: code_tag=self.code_tag, ) solar_field.draw(fig_record.view, solar_field_style) - aimpoint_xyz.draw_list(fig_record.view, style=rcps.marker(color='tab:orange'), label='aimpoint_xyz') + aimpoint_xyz.draw_line(fig_record.view, style=rcps.marker(color='tab:orange'), label='aimpoint_xyz') # Output. self.show_save_and_check_figure(fig_record) @@ -763,7 +763,7 @@ def example_heliostat_vector_field(self) -> None: comments=comments, code_tag=self.code_tag, ) - aimpoint_xyz.draw_point(fig_record.view, style=rcps.marker(color='tab:orange'), labels='aimpoint_xyz') + aimpoint_xyz.draw_points(fig_record.view, style=rcps.marker(color='tab:orange'), labels='aimpoint_xyz') solar_field.draw(fig_record.view, solar_field_style) self.show_save_and_check_figure(fig_record) @@ -781,7 +781,7 @@ def example_heliostat_vector_field(self) -> None: comments=comments, code_tag=self.code_tag, ) - aimpoint_xyz.draw_point(fig_record.view, style=rcps.marker(color='tab:orange'), labels='aimpoint_xyz') + aimpoint_xyz.draw_points(fig_record.view, style=rcps.marker(color='tab:orange'), labels='aimpoint_xyz') solar_field.draw(fig_record.view, solar_field_style) self.show_save_and_check_figure(fig_record) @@ -799,7 +799,7 @@ def example_heliostat_vector_field(self) -> None: comments=comments, code_tag=self.code_tag, ) - aimpoint_xyz.draw_point(fig_record.view, style=rcps.marker(color='tab:orange'), labels='aimpoint_xyz') + aimpoint_xyz.draw_points(fig_record.view, style=rcps.marker(color='tab:orange'), labels='aimpoint_xyz') solar_field.draw(fig_record.view, solar_field_style) self.show_save_and_check_figure(fig_record) @@ -817,7 +817,7 @@ def example_heliostat_vector_field(self) -> None: comments=comments, code_tag=self.code_tag, ) - aimpoint_xyz.draw_point(fig_record.view, style=rcps.marker(color='tab:orange'), labels='aimpoint_xyz') + aimpoint_xyz.draw_points(fig_record.view, style=rcps.marker(color='tab:orange'), labels='aimpoint_xyz') solar_field.draw(fig_record.view, solar_field_style) self.show_save_and_check_figure(fig_record) @@ -868,7 +868,7 @@ def example_dense_vector_field(self) -> None: code_tag=self.code_tag, ) solar_field.draw(fig_record.view, solar_field_style) - aimpoint_xyz.draw_point(fig_record.view, style=rcps.marker(color='tab:orange'), labels='aimpoint_xyz') + aimpoint_xyz.draw_points(fig_record.view, style=rcps.marker(color='tab:orange'), labels='aimpoint_xyz') # Draw dense vector field. grid_xy = solar_field.heliostat_field_regular_grid_xy(40, 20) diff --git a/opencsp/common/lib/csp/Facet.py b/opencsp/common/lib/csp/Facet.py index 942cee32f..a6e044b11 100644 --- a/opencsp/common/lib/csp/Facet.py +++ b/opencsp/common/lib/csp/Facet.py @@ -158,7 +158,7 @@ def draw(self, view: View3d, facet_style: RenderControlFacet = None, transform: # Centroid. if facet_style.draw_centroid: - Pxyz(origin).draw_point(view, style=facet_style.centroid_style) + origin.draw_points(view, style=facet_style.centroid_style) # Outline. if facet_style.draw_outline: @@ -169,15 +169,15 @@ def draw(self, view: View3d, facet_style: RenderControlFacet = None, transform: # view.draw_xyz_list(corners, close=True, style=facet_style.outline_style) left, right, bottom, top = self.axis_aligned_bounding_box border = Pxyz([[left, left, right, right], [top, bottom, bottom, top], [0, 0, 0, 0]]) - transform.apply(border).draw_list(view, close=True, style=facet_style.outline_style) + transform.apply(border).draw_line(view, close=True, style=facet_style.outline_style) # Surface normal. if facet_style.draw_surface_normal: # Construct ray. surface_normal_ray = transform.apply(UP * facet_style.surface_normal_length) # Draw ray and its base. - Pxyz(origin).draw_point(view, style=facet_style.surface_normal_base_style) - Vxyz.merge([origin, surface_normal_ray]).draw_list(view, style=facet_style.surface_normal_style) + origin.draw_points(view, style=facet_style.surface_normal_base_style) + Vxyz.merge([origin, surface_normal_ray]).draw_line(view, style=facet_style.surface_normal_style) # # Surface normal drawn at corners. # # (Not the surface normal at the corner. Facet curvature is not shown.) diff --git a/opencsp/common/lib/csp/FacetEnsemble.py b/opencsp/common/lib/csp/FacetEnsemble.py index 3d91aa4f0..17eabb5f2 100644 --- a/opencsp/common/lib/csp/FacetEnsemble.py +++ b/opencsp/common/lib/csp/FacetEnsemble.py @@ -182,17 +182,17 @@ def draw( # origin of the facet ensemble if facet_ensemble_style.draw_centroid: - Pxyz(origin).draw_point(view) + origin.draw_points(view) # pointing vector of the facet ensemble if facet_ensemble_style.draw_normal_vector: - Vxyz.merge([origin, normal_vector]).draw_list(view, style=facet_ensemble_style.normal_vector_style) + Vxyz.merge([origin, normal_vector]).draw_line(view, style=facet_ensemble_style.normal_vector_style) if facet_ensemble_style.draw_outline: left, right, top, bottom = self.axis_aligned_bounding_box corners = Pxyz([[left, left, right, right], [top, bottom, bottom, top], [0, 0, 0, 0]]) corners_moved = transform.apply(corners) - corners_moved.draw_list(view, close=True, style=facet_ensemble_style.outline_style) + corners_moved.draw_line(view, close=True, style=facet_ensemble_style.outline_style) # debug function def set_facet_transform_list(self, transformations: list[TransformXYZ]): diff --git a/opencsp/common/lib/csp/HeliostatAbstract.py b/opencsp/common/lib/csp/HeliostatAbstract.py index 781fbc50f..147278fd8 100644 --- a/opencsp/common/lib/csp/HeliostatAbstract.py +++ b/opencsp/common/lib/csp/HeliostatAbstract.py @@ -309,7 +309,7 @@ def draw(self, view: View3d, heliostat_style: RenderControlHeliostat = None, tra # Centroid. if heliostat_style.draw_centroid: - Pxyz(origin).draw_point(view, style=heliostat_style.centroid_style) + origin.draw_points(view, style=heliostat_style.centroid_style) # # Outline. # if heliostat_style.draw_outline: @@ -339,7 +339,7 @@ def draw(self, view: View3d, heliostat_style: RenderControlHeliostat = None, tra if heliostat_style.post != 0: DOWN = Vxyz([0, 0, -heliostat_style.post]) direction = transform.apply(DOWN) - Vxyz.merge([origin + DOWN, origin]).draw_list(view) + Vxyz.merge([origin + DOWN, origin]).draw_line(view) # Name. if heliostat_style.draw_name: diff --git a/opencsp/common/lib/csp/MirrorAbstract.py b/opencsp/common/lib/csp/MirrorAbstract.py index a2b9647fe..1c029c3a6 100644 --- a/opencsp/common/lib/csp/MirrorAbstract.py +++ b/opencsp/common/lib/csp/MirrorAbstract.py @@ -307,7 +307,7 @@ def draw( # Draw surface boundary if mirror_style.point_styles is not None: mirror_style.point_styles.markersize = 0 - edge_values_lifted.draw_list(view, style=mirror_style.point_styles) + edge_values_lifted.draw_line(view, style=mirror_style.point_styles) # Draw surface normals if mirror_style.surface_normals: diff --git a/opencsp/common/lib/csp/MirrorPoint.py b/opencsp/common/lib/csp/MirrorPoint.py index a3f66dc73..f4656f98e 100644 --- a/opencsp/common/lib/csp/MirrorPoint.py +++ b/opencsp/common/lib/csp/MirrorPoint.py @@ -176,7 +176,7 @@ def draw(self, view: View3d, mirror_style: RenderControlMirror, transform: Trans p_space = self.location_in_space(domain) # Draw sample points - p_space.draw_point(view, style=mirror_style.point_styles) + p_space.draw_points(view, style=mirror_style.point_styles) # Calculate z height of boundary to draw (lowest z value) min_val = min(self.surface_displacement_at(domain)) @@ -189,7 +189,7 @@ def draw(self, view: View3d, mirror_style: RenderControlMirror, transform: Trans if mirror_style.point_styles is not None: edge_style = mirror_style.point_styles edge_style.markersize = 0 - edge_values_lifted.draw_list(view, style=edge_style) + edge_values_lifted.draw_line(view, style=edge_style) # Draw surface normals if mirror_style.surface_normals: diff --git a/opencsp/common/lib/csp/SolarField.py b/opencsp/common/lib/csp/SolarField.py index 6c28cb13a..bcf464856 100644 --- a/opencsp/common/lib/csp/SolarField.py +++ b/opencsp/common/lib/csp/SolarField.py @@ -318,7 +318,7 @@ def draw( # Draw Origin if solar_field_style.draw_origin: - Pxyz(origin).draw_point(view) + origin.draw_points(view) # Heliostats. if solar_field_style.draw_heliostats: diff --git a/opencsp/common/lib/geometry/Intersection.py b/opencsp/common/lib/geometry/Intersection.py index ee6041b0a..2870c3a48 100644 --- a/opencsp/common/lib/geometry/Intersection.py +++ b/opencsp/common/lib/geometry/Intersection.py @@ -284,9 +284,9 @@ def _Pxy_to_flux_map(points: Pxy, bins: int, resolution_type: str = "pixelX") -> def draw(self, view: View3d, style: RenderControlPointSeq = None): if style is None: style = RenderControlPointSeq() - self.intersection_points.draw_point(view, style) + self.intersection_points.draw_points(view, style) def draw_subset(self, view: View3d, count: int, points_style: RenderControlPointSeq = None): for i in np.floor(np.linspace(0, len(self.intersection_points) - 1, count)): p = Pxyz(self.intersection_points[int(i)]) - p.draw_point(view) + p.draw_points(view) diff --git a/opencsp/common/lib/geometry/Pxyz.py b/opencsp/common/lib/geometry/Pxyz.py index c647954d3..3aa72ae2f 100644 --- a/opencsp/common/lib/geometry/Pxyz.py +++ b/opencsp/common/lib/geometry/Pxyz.py @@ -23,19 +23,3 @@ def as_Vxyz(self): @classmethod def empty(cls): return Pxyz([[], [], []]) - - def draw_point( - self, - figure: rcfr.RenderControlFigureRecord | v3d.View3d, - style: rcps.RenderControlPointSeq = None, - labels: list[str] = None, - ): - """Calls figure.draw_xyz(p) for all points in this instance, and with - the default arguments in place for any None's.""" - if style is None: - style = rcps.default(markersize=2) - if labels is None: - labels = [None] * len(self) - view = figure if isinstance(figure, v3d.View3d) else figure.view - for x, y, z, label in zip(self.x, self.y, self.z, labels): - view.draw_xyz((x, y, z), style, label) diff --git a/opencsp/common/lib/geometry/Vxyz.py b/opencsp/common/lib/geometry/Vxyz.py index d50da7767..16b90f25f 100644 --- a/opencsp/common/lib/geometry/Vxyz.py +++ b/opencsp/common/lib/geometry/Vxyz.py @@ -498,14 +498,18 @@ def origin(cls): # zs.append(func(x, y)) # return cls([xs, ys, zs]) - def draw_list( + def draw_line( self, figure: rcfr.RenderControlFigureRecord | v3d.View3d, close: bool = None, style: rcps.RenderControlPointSeq = None, label: str = None, ) -> None: - """Calls figure.draw_xyz_list(self.data.T) with the default arguments in place for any None's.""" + """ + Calls figure.draw_xyz_list(self.data.T) to draw all xyz points in a + single series. Uses the default arguments for draw_xyz_list in place of + any None's. + """ kwargs = dict() for key, val in [('close', close), ('style', style), ('label', label)]: if val is not None: @@ -513,3 +517,19 @@ def draw_list( view = figure if isinstance(figure, v3d.View3d) else figure.view view.draw_xyz_list(self.data.T, **kwargs) + + def draw_points( + self, + figure: rcfr.RenderControlFigureRecord | v3d.View3d, + style: rcps.RenderControlPointSeq = None, + labels: list[str] = None, + ): + """ + Calls figure.draw_xyz(p) to draw all xyz points in this instance + individually. Uses the default arguments in place for any None's. + """ + if labels is None: + labels = [None] * len(self) + view = figure if isinstance(figure, v3d.View3d) else figure.view + for x, y, z, label in zip(self.x, self.y, self.z, labels): + view.draw_xyz((x, y, z), style, label) diff --git a/opencsp/common/lib/render/View3d.py b/opencsp/common/lib/render/View3d.py index 039963cd9..b079514c6 100644 --- a/opencsp/common/lib/render/View3d.py +++ b/opencsp/common/lib/render/View3d.py @@ -653,13 +653,24 @@ def draw_xyz_list( style: rcps.RenderControlPointSeq = None, label: str = None, ) -> None: - """Draw lines or closed polygons. + """ + Draw lines or closed polygons. Parameters ---------- - input_xyz_list: List of xyz three vectors (eg [[0,0,0], [1,1,1]]) - close: Draw as a closed polygon (ignored if input_xyz_list < 3 points)""" - + input_xyz_list : Iterable[tuple[float, float, float]] + List of xyz three vectors (eg [[0,0,0], [1,1,1]]). The vectors must + be indexable, such as with input_xyz_list[0][0]. + close : bool, optional + True to draw as a closed polygon (ignored if input_xyz_list < 3 + points), or False to draw as given. By default False. + style : rcps.RenderControlPointSeq, optional + The style with which to render, or None for + RenderControlPointSeq.default(). By default None. + label : str, optional + The label to assign to this plot to be used in the legend, or None + for no label. By default None. + """ if style == None: style = rcps.default() diff --git a/opencsp/common/lib/test/test_FluxMaps.py b/opencsp/common/lib/test/test_FluxMaps.py index 543ff00a9..a2fe6cd9c 100644 --- a/opencsp/common/lib/test/test_FluxMaps.py +++ b/opencsp/common/lib/test/test_FluxMaps.py @@ -175,9 +175,9 @@ def square(z: float): mirror.draw(fig_record.view, mirror_style) trace_style = rcrt.init_current_lengths(current_len=6) trace.draw(fig_record.view, trace_style) - square(4).draw_list(fig_record.view, close=True, style=rcps.RenderControlPointSeq(color='b', marker=',')) - square(5).draw_list(fig_record.view, close=True, style=rcps.RenderControlPointSeq(color='g', marker=',')) - square(6).draw_list(fig_record.view, close=True, style=rcps.RenderControlPointSeq(color='r', marker=',')) + square(4).draw_line(fig_record.view, close=True, style=rcps.RenderControlPointSeq(color='b', marker=',')) + square(5).draw_line(fig_record.view, close=True, style=rcps.RenderControlPointSeq(color='g', marker=',')) + square(6).draw_line(fig_record.view, close=True, style=rcps.RenderControlPointSeq(color='r', marker=',')) self.show_save_and_check_figure(fig_record) # Draw z=4 diff --git a/opencsp/common/lib/test/test_RayTraceOutput.py b/opencsp/common/lib/test/test_RayTraceOutput.py index cbaa06c36..241de57cf 100644 --- a/opencsp/common/lib/test/test_RayTraceOutput.py +++ b/opencsp/common/lib/test/test_RayTraceOutput.py @@ -442,14 +442,14 @@ def fn_5w1(x, y): def _draw_helper(view: View3d) -> None: sf1.draw(view, solar_field_style) trace.draw(view, trace_control) - aimpoint_xyz.draw_point(view, style=rcps.marker(color='tab:orange')) + aimpoint_xyz.draw_points(view, style=rcps.marker(color='tab:orange')) # debug heliostat_origin = sf1.heliostats[0].self_to_global_tranformation.apply(Pxyz.origin()) pointing_vector = st.tracking_surface_normal_xyz( heliostat_origin, aimpoint_xyz, lln.NSTTF_ORIGIN, when_ymdhmsz ) - Vxyz.merge([heliostat_origin, heliostat_origin + pointing_vector * 10]).draw_list(view) + Vxyz.merge([heliostat_origin, heliostat_origin + pointing_vector * 10]).draw_line(view) # debug self.show_save_and_check_figure(fig_record) @@ -573,7 +573,7 @@ def test_partial_field_trace(self) -> None: trace = rt.trace_scene(scene, Resolution.center(), verbose=False) trace.draw(view, RenderControlRayTrace(RenderControlLightPath(15, 200))) - aimpoint_xyz.draw_point(view, rcps.RenderControlPointSeq(color='orange', marker='.')) + aimpoint_xyz.draw_points(view, rcps.RenderControlPointSeq(color='orange', marker='.')) self.show_save_and_check_figure(fig_record) diff --git a/opencsp/common/lib/test/test_SolarFieldOutput.py b/opencsp/common/lib/test/test_SolarFieldOutput.py index 5373b1cbb..6fc5948d1 100644 --- a/opencsp/common/lib/test/test_SolarFieldOutput.py +++ b/opencsp/common/lib/test/test_SolarFieldOutput.py @@ -503,7 +503,7 @@ def old_solar_field_h_outlines(self) -> None: code_tag=self.code_tag, ) solar_field.draw(fig_record.view, solar_field_style) - aimpoint_xyz.draw_list(fig_record.view, style=rcps.marker(color='tab:orange'), label='aimpoint_xyz') + aimpoint_xyz.draw_line(fig_record.view, style=rcps.marker(color='tab:orange'), label='aimpoint_xyz') # Output. self.show_save_and_check_figure(fig_record) @@ -779,7 +779,7 @@ def test_heliostat_vector_field(self) -> None: comments=comments, code_tag=self.code_tag, ) - aimpoint_xyz.draw_point(fig_record.view, style=rcps.marker(color='tab:orange'), labels='aimpoint_xyz') + aimpoint_xyz.draw_points(fig_record.view, style=rcps.marker(color='tab:orange'), labels='aimpoint_xyz') solar_field.draw(fig_record.view, solar_field_style) self.show_save_and_check_figure(fig_record) @@ -838,7 +838,7 @@ def test_dense_vector_field(self) -> None: code_tag=self.code_tag, ) solar_field.draw(fig_record.view, solar_field_style) - aimpoint_xyz.draw_point(fig_record.view, style=rcps.marker(color='tab:orange'), labels='aimpoint_xyz') + aimpoint_xyz.draw_points(fig_record.view, style=rcps.marker(color='tab:orange'), labels='aimpoint_xyz') # Draw dense vector field. grid_xy = solar_field.heliostat_field_regular_grid_xy(40, 20)