Skip to content

Commit aa6ae75

Browse files
Patrick Schustertobifalk
Patrick Schuster
authored andcommitted
ui: Add button to switch between label attributes
Signed-off-by: Tobias Falkenstein <[email protected]>
1 parent 3ed385c commit aa6ae75

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

ui/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cloe-ui",
3-
"version": "0.18.0-nightly-2021-11-10",
3+
"version": "0.18.0-nightly-2022-02-04",
44
"cloe-compatibility": "0.16",
55
"license": "Apache-2.0",
66
"private": true,

ui/src/components/rendering.jsx

+39-1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ class Rendering extends Component {
102102
objSensorsToRender: [this.defaultSensor.Object],
103103
laneSensorsToRender: [this.defaultSensor.Lane]
104104
};
105+
this.currentLabelIndex = 0;
106+
this.labelAttributes = [["id", "prob"], ["class", "type"], "transl"];
105107
}
106108

107109
render() {
@@ -158,6 +160,7 @@ class Rendering extends Component {
158160
() => this.setState({ renderLabels: !renderLabels }),
159161
renderLabels
160162
)}
163+
{this.renderLabelAttributes(renderLabels)}
161164
{this.renderToggleSwitch("Axes", () => this.toggleHelperAxes(), helperAxesVisible)}
162165
{this.renderToggleSwitch("Grid", () => this.toggleGrid(), gridVisible)}
163166
<div className={gridVisible ? "" : "d-none"}>
@@ -221,6 +224,29 @@ class Rendering extends Component {
221224
);
222225
};
223226

227+
renderLabelAttributes = (renderLabels) => {
228+
if (renderLabels) {
229+
return (
230+
<React.Fragment>
231+
<div
232+
className="menu-switch"
233+
onClick={() => this.switchLabelAttributes(this.currentLabelIndex++)}
234+
>
235+
<small className="mr-2 ml-2 mb-1">switch Attributes</small>
236+
</div>
237+
</React.Fragment>
238+
);
239+
} else {
240+
return <React.Fragment></React.Fragment>;
241+
}
242+
};
243+
244+
switchLabelAttributes = (index) => {
245+
if (index === this.labelAttributes.length - 1) {
246+
this.currentLabelIndex = 0;
247+
}
248+
};
249+
224250
renderSensorSelect = (sensorType, selectSensors) => {
225251
let colors;
226252
let defaultColors;
@@ -718,7 +744,19 @@ class Rendering extends Component {
718744
if (object.exist_prob !== undefined) {
719745
existProb = object.exist_prob;
720746
}
721-
return `ID: ${object.id} \n Prob.: ${existProb.toFixed(2)}`;
747+
let pose = object.pose || 0;
748+
let translation = pose.translation || 0;
749+
let transX = translation.x || 0;
750+
switch (this.currentLabelIndex) {
751+
case 0:
752+
return `ID: ${object.id} \n Prob.: ${existProb.toFixed(2)}`;
753+
case 1:
754+
return `Class: ${object.class} \n Type: ${object.type}`;
755+
case 2:
756+
return `Transl.: \n X: ${transX.toFixed(3) || translation}`;
757+
default:
758+
break;
759+
}
722760
};
723761

724762
createDefaultLabel = (text, color) => {

0 commit comments

Comments
 (0)