Merge branch 'main' of ssh://892887cvmk08.aicp.io:24928/orisys-tech/orisys-app
This commit is contained in:
@@ -251,6 +251,9 @@ class FrameView:
|
||||
theme=theme,
|
||||
draw_style=draw_style,
|
||||
depth_range=span,
|
||||
depth_threshold=float(
|
||||
getattr(self.depth_display_settings(), "depth_threshold", 0.0)
|
||||
),
|
||||
canvas_bgr=hex_to_bgr(color(theme, "arrow_canvas", "#0B1830")),
|
||||
domain_mask=boundary,
|
||||
# A frame read from a stored analysis result says which policy its *recovered*
|
||||
|
||||
@@ -164,6 +164,7 @@ uniform sampler2D u_valid;
|
||||
uniform vec2 u_inv_domain_size;
|
||||
uniform float u_lower;
|
||||
uniform float u_upper;
|
||||
uniform float u_depth_threshold;
|
||||
uniform vec4 u_invalid_color;
|
||||
|
||||
out vec4 frag_color;
|
||||
@@ -181,7 +182,11 @@ void main() {
|
||||
return;
|
||||
}
|
||||
float span = max(u_upper - u_lower, 1e-12);
|
||||
float t = clamp((texture(u_field, texel).r - u_lower) / span, 0.0, 1.0);
|
||||
float value = texture(u_field, texel).r;
|
||||
float t = clamp((value - u_lower) / span, 0.0, 1.0);
|
||||
if (u_depth_threshold > 0.0 && value < u_depth_threshold) {
|
||||
t = 0.0;
|
||||
}
|
||||
frag_color = vec4(texture(u_lut, vec2(t, 0.5)).rgb, 1.0);
|
||||
}
|
||||
"""
|
||||
@@ -717,6 +722,7 @@ class GLRenderer:
|
||||
#: Range of the valid samples of the field currently uploaded, for the
|
||||
#: automatic colour scale. ``None`` until a frame carries valid data.
|
||||
self._scalar_range: tuple[float, float] | None = None
|
||||
self._field_quantity = ""
|
||||
#: The 2D canvas's latched depth ``(lo, hi)``, when the window has one.
|
||||
#: Depth automatic colouring uses this so both legends name one interval.
|
||||
self._shared_depth_scale: tuple[float, float] | None = None
|
||||
@@ -771,6 +777,7 @@ class GLRenderer:
|
||||
# longer on screen: keeping it made the first automatic draw of the new scene use
|
||||
# the previous scene's bounds.
|
||||
self._scalar_range = None
|
||||
self._field_quantity = ""
|
||||
self._last_scale = None
|
||||
self._last_scale_mode = ""
|
||||
uvs = np.asarray(assets.binding.uvs, dtype=np.float32)
|
||||
@@ -847,6 +854,7 @@ class GLRenderer:
|
||||
previous=self._scalar_range,
|
||||
shared_depth_scale=self._shared_depth_scale,
|
||||
)
|
||||
self._field_quantity = str(getattr(field.descriptor, "quantity", ""))
|
||||
self._upload_overlays(frame)
|
||||
|
||||
def _upload_field_textures(self, field: Any) -> None:
|
||||
@@ -1070,6 +1078,13 @@ class GLRenderer:
|
||||
if part.role == "sensing":
|
||||
_set_float(GL, locations.get("u_lower"), lower)
|
||||
_set_float(GL, locations.get("u_upper"), upper)
|
||||
_set_float(
|
||||
GL,
|
||||
locations.get("u_depth_threshold"),
|
||||
settings.depth_threshold
|
||||
if self._field_quantity == "depth_response"
|
||||
else 0.0,
|
||||
)
|
||||
_set_vec4(GL, locations.get("u_invalid_color"), INVALID_COLOR)
|
||||
self._bind_field_textures(GL, locations)
|
||||
else:
|
||||
@@ -1203,6 +1218,7 @@ class GLRenderer:
|
||||
self._initialized = False
|
||||
self._estimated_gpu_bytes = 0
|
||||
self._scalar_range = None
|
||||
self._field_quantity = ""
|
||||
self._last_scale = None
|
||||
self._last_scale_mode = ""
|
||||
self._paint_calls = 0
|
||||
@@ -1339,7 +1355,8 @@ def _compile_program(GL: Any, profile: Profile, name: str) -> int:
|
||||
def _uniform_locations(GL: Any, program: int) -> dict[str, int]:
|
||||
names = (
|
||||
"u_view", "u_projection", "u_lower", "u_upper",
|
||||
"u_invalid_color", "u_lut", "u_field", "u_valid", "u_inv_domain_size",
|
||||
"u_invalid_color", "u_depth_threshold", "u_lut", "u_field",
|
||||
"u_valid", "u_inv_domain_size",
|
||||
"u_light_direction", "u_base_color",
|
||||
)
|
||||
out: dict[str, int] = {}
|
||||
|
||||
@@ -265,6 +265,16 @@ class ThreeDPanel(QFrame):
|
||||
self.flow_threshold_spin.valueChanged.connect(self._emit_settings)
|
||||
form.addRow(self.flow_threshold_label, self.flow_threshold_spin)
|
||||
|
||||
self.depth_threshold_label = QLabel()
|
||||
self.depth_threshold_spin = QDoubleSpinBox()
|
||||
self.depth_threshold_spin.setRange(0.0, 1000.0)
|
||||
self.depth_threshold_spin.setDecimals(4)
|
||||
self.depth_threshold_spin.setSingleStep(0.005)
|
||||
self.depth_threshold_spin.setValue(0.0)
|
||||
self.depth_threshold_spin.setMaximumWidth(SPIN_WIDTH)
|
||||
self.depth_threshold_spin.valueChanged.connect(self._emit_settings)
|
||||
form.addRow(self.depth_threshold_label, self.depth_threshold_spin)
|
||||
|
||||
self.scale_label = QLabel()
|
||||
self.scale_combo = QComboBox()
|
||||
self.scale_combo.addItem("fixed", "fixed")
|
||||
@@ -701,6 +711,7 @@ class ThreeDPanel(QFrame):
|
||||
self.flow_arrows_check,
|
||||
self.contact_arrow_check,
|
||||
self.flow_threshold_spin,
|
||||
self.depth_threshold_spin,
|
||||
self.scale_combo,
|
||||
self.fps_combo,
|
||||
self.reset_button,
|
||||
@@ -735,6 +746,7 @@ class ThreeDPanel(QFrame):
|
||||
self.flow_arrows_check.setChecked(bool(settings.flow_arrows_enabled))
|
||||
self.contact_arrow_check.setChecked(bool(settings.contact_arrow_enabled))
|
||||
self.flow_threshold_spin.setValue(float(settings.flow_on_px))
|
||||
self.depth_threshold_spin.setValue(float(settings.depth_threshold))
|
||||
self._flow_grid_spacing = max(1, int(settings.flow_grid_spacing))
|
||||
self._max_arrows = max(1, int(settings.max_arrows))
|
||||
self.depth_adaptive_check.setChecked(bool(settings.depth_scale_adaptive))
|
||||
@@ -791,6 +803,7 @@ class ThreeDPanel(QFrame):
|
||||
flow_grid_spacing=int(self._flow_grid_spacing),
|
||||
max_arrows=int(self._max_arrows),
|
||||
depth_scale_adaptive=bool(self.depth_adaptive_check.isChecked()),
|
||||
depth_threshold=float(self.depth_threshold_spin.value()),
|
||||
)
|
||||
|
||||
# ------------------------------------------------------------------ signals
|
||||
@@ -863,6 +876,9 @@ class ThreeDPanel(QFrame):
|
||||
self.flow_threshold_label.setText(t("scene3d.flow_threshold"))
|
||||
self.flow_threshold_label.setToolTip(t("scene3d.flow_threshold_tip"))
|
||||
self.flow_threshold_spin.setToolTip(t("scene3d.flow_threshold_tip"))
|
||||
self.depth_threshold_label.setText(t("scene3d.depth_threshold"))
|
||||
self.depth_threshold_label.setToolTip(t("scene3d.depth_threshold_tip"))
|
||||
self.depth_threshold_spin.setToolTip(t("scene3d.depth_threshold_tip"))
|
||||
self.scale_label.setText(t("scene3d.scale"))
|
||||
self.range_label.setText(t("scene3d.scale_range"))
|
||||
self.range_label.setToolTip(t("scene3d.scale_range_tip"))
|
||||
|
||||
@@ -89,6 +89,7 @@ def settings_to_prefs(settings: DisplaySettings) -> dict[str, Any]:
|
||||
"flow_grid_spacing": int(settings.flow_grid_spacing),
|
||||
"max_arrows": int(settings.max_arrows),
|
||||
"depth_scale_adaptive": bool(settings.depth_scale_adaptive),
|
||||
"depth_threshold": float(settings.depth_threshold),
|
||||
}
|
||||
if scale is not None:
|
||||
block["color_scale"] = {
|
||||
@@ -171,4 +172,5 @@ def settings_from_prefs(
|
||||
flow_grid_spacing=spacing,
|
||||
max_arrows=max_arrows,
|
||||
depth_scale_adaptive=_flag(raw.get("depth_scale_adaptive"), False),
|
||||
depth_threshold=min(max(_number(raw.get("depth_threshold"), 0.0), 0.0), 1000.0),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user