Skip to content
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

move class-specific draw methods out of View3d and into Vxyz and Pxyz #154

2 changes: 1 addition & 1 deletion example/mirror/example_MirrorOutput.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ def example_solar_field(self) -> None:
# trace = rt.trace_scene(scene, Resolution.center())

# trace.draw(fig_record.view, rcrt.RenderControlRayTrace(light_path_control))
# fig_record.view.draw_single_Pxyz(aimpoint)
# aimpoint.draw_point(fig_record.view)

# Output.
self.show_save_and_check_figure(fig_record)
Expand Down
6 changes: 3 additions & 3 deletions example/raytrace/example_RayTraceOutput.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
view.draw_single_Pxyz(aimpoint_xyz, 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
)
view.draw_Vxyz(Vxyz.merge([heliostat_origin, heliostat_origin + pointing_vector * 10]))
Vxyz.merge([heliostat_origin, heliostat_origin + pointing_vector * 10]).draw_line(view)
# debug

self.show_save_and_check_figure(fig_record)
Expand Down Expand Up @@ -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)))

view.draw_single_Pxyz(aimpoint_xyz, rcps.RenderControlPointSeq(color='orange', marker='.'))
aimpoint_xyz.draw_points(view, rcps.RenderControlPointSeq(color='orange', marker='.'))

self.show_save_and_check_figure(fig_record)

Expand Down
12 changes: 6 additions & 6 deletions example/solarfield/example_SolarFieldOutput.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
fig_record.view.draw_Vxyz(aimpoint_xyz, 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)
Expand Down Expand Up @@ -763,7 +763,7 @@ def example_heliostat_vector_field(self) -> None:
comments=comments,
code_tag=self.code_tag,
)
fig_record.view.draw_single_Pxyz(aimpoint_xyz, 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)

Expand All @@ -781,7 +781,7 @@ def example_heliostat_vector_field(self) -> None:
comments=comments,
code_tag=self.code_tag,
)
fig_record.view.draw_single_Pxyz(aimpoint_xyz, 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)

Expand All @@ -799,7 +799,7 @@ def example_heliostat_vector_field(self) -> None:
comments=comments,
code_tag=self.code_tag,
)
fig_record.view.draw_single_Pxyz(aimpoint_xyz, 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)

Expand All @@ -817,7 +817,7 @@ def example_heliostat_vector_field(self) -> None:
comments=comments,
code_tag=self.code_tag,
)
fig_record.view.draw_single_Pxyz(aimpoint_xyz, 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)

Expand Down Expand Up @@ -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)
fig_record.view.draw_single_Pxyz(aimpoint_xyz, 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)
Expand Down
8 changes: 4 additions & 4 deletions opencsp/common/lib/csp/Facet.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def draw(self, view: View3d, facet_style: RenderControlFacet = None, transform:

# Centroid.
if facet_style.draw_centroid:
view.draw_single_Pxyz(origin, style=facet_style.centroid_style)
origin.draw_points(view, style=facet_style.centroid_style)

# Outline.
if facet_style.draw_outline:
Expand All @@ -168,15 +168,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]])
view.draw_Vxyz(transform.apply(border), 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.
view.draw_single_Pxyz(origin, style=facet_style.surface_normal_base_style)
view.draw_Vxyz(Vxyz.merge([origin, surface_normal_ray]), 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.)
Expand Down
7 changes: 4 additions & 3 deletions opencsp/common/lib/csp/FacetEnsemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from opencsp.common.lib.geometry.Vxyz import Vxyz
from opencsp.common.lib.render.View3d import View3d
from opencsp.common.lib.render_control.RenderControlFacetEnsemble import RenderControlFacetEnsemble
import opencsp.common.lib.render_control.RenderControlPointSeq as rcps
import opencsp.common.lib.tool.log_tools as lt


Expand Down Expand Up @@ -177,17 +178,17 @@ def draw(

# origin of the facet ensemble
if facet_ensemble_style.draw_centroid:
view.draw_single_Pxyz(origin)
origin.draw_points(view, style=rcps.marker(markersize=1))

# pointing vector of the facet ensemble
if facet_ensemble_style.draw_normal_vector:
view.draw_Vxyz(Vxyz.merge([origin, normal_vector]), 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)
view.draw_Vxyz(corners_moved, close=True, style=facet_ensemble_style.outline_style)
corners_moved.draw_line(view, close=True, style=facet_ensemble_style.outline_style)

def set_facet_transform_list(self, transformations: list[TransformXYZ]):
"""
Expand Down
8 changes: 4 additions & 4 deletions opencsp/common/lib/csp/HeliostatAbstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def draw(self, view: View3d, heliostat_style: RenderControlHeliostat = None, tra

# Centroid.
if heliostat_style.draw_centroid:
view.draw_single_Pxyz(origin, style=heliostat_style.centroid_style)
origin.draw_points(view, style=heliostat_style.centroid_style)

# # Outline.
# if heliostat_style.draw_outline:
Expand All @@ -318,15 +318,15 @@ def draw(self, view: View3d, heliostat_style: RenderControlHeliostat = None, tra
# [top, bottom, bottom, top],
# [0, 0, 0, 0]])
# corners_moved = transform.apply(corners)
# view.draw_Vxyz(corners_moved, close=True, style=heliostat_style.outline_style)
# corners_moved.draw_list(view, close=True, style=heliostat_style.outline_style)

# # Surface normal.
# if heliostat_style.draw_surface_normal:
# # Construct ray.
# self.facet_ensemble.
# surface_normal_ray = transform.apply(UP * heliostat_style.corner_normal_length)
# # Draw ray and its base.
# view.draw_Vxyz(Vxyz.merge([origin, surface_normal_ray]),
# Vxyz.merge([origin, surface_normal_ray]).draw_list(view,
# close=False,
# style=heliostat_style.surface_normal_style)

Expand All @@ -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)
view.draw_Vxyz(Vxyz.merge([origin + DOWN, origin]))
Vxyz.merge([origin + DOWN, origin]).draw_line(view)

# Name.
if heliostat_style.draw_name:
Expand Down
2 changes: 1 addition & 1 deletion opencsp/common/lib/csp/MirrorAbstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ def draw(
# Draw surface boundary
if mirror_style.point_styles is not None:
mirror_style.point_styles.markersize = 0
view.draw_Vxyz(edge_values_lifted, style=mirror_style.point_styles)
edge_values_lifted.draw_line(view, style=mirror_style.point_styles)

# Draw surface normals
if mirror_style.surface_normals:
Expand Down
4 changes: 2 additions & 2 deletions opencsp/common/lib/csp/MirrorPoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def draw(self, view: View3d, mirror_style: RenderControlMirror, transform: Trans
p_space = self.location_in_space(domain)

# Draw sample points
view.draw_single_Pxyz(p_space, 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))
Expand All @@ -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
view.draw_Vxyz(edge_values_lifted, style=edge_style)
edge_values_lifted.draw_line(view, style=edge_style)

# Draw surface normals
if mirror_style.surface_normals:
Expand Down
2 changes: 1 addition & 1 deletion opencsp/common/lib/csp/SolarField.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ def draw(

# Draw Origin
if solar_field_style.draw_origin:
view.draw_single_Pxyz(origin)
origin.draw_points(view)

# Heliostats.
if solar_field_style.draw_heliostats:
Expand Down
5 changes: 3 additions & 2 deletions opencsp/common/lib/geometry/Intersection.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +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()
view.draw_single_Pxyz(self.intersection_points, 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)):
view.draw_single_Pxyz(self.intersection_points[int(i)])
p = Pxyz(self.intersection_points[int(i)])
p.draw_points(view)
3 changes: 3 additions & 0 deletions opencsp/common/lib/geometry/Pxyz.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from opencsp.common.lib.geometry.Vxyz import Vxyz
import opencsp.common.lib.render.View3d as v3d
import opencsp.common.lib.render_control.RenderControlFigureRecord as rcfr
import opencsp.common.lib.render_control.RenderControlPointSeq as rcps


class Pxyz(Vxyz):
Expand Down
Loading