提交 5bdd1b43 编写于 作者: V Vivian Lin 提交者: siyangy

Dreamview: implemented map element toggles in layer menu (#3083)

上级 15e90470
因为 它太大了无法显示 source diff 。你可以改为 查看blob
因为 它太大了无法显示 source diff 。你可以改为 查看blob
...@@ -47,6 +47,13 @@ const MenuIdOptionMapping = { ...@@ -47,6 +47,13 @@ const MenuIdOptionMapping = {
planningLine: 'showPlanning', planningLine: 'showPlanning',
positionLocalization: 'showPositionLocalization', positionLocalization: 'showPositionLocalization',
positionGps: 'showPositionGps', positionGps: 'showPositionGps',
mapCrosswalk: 'showMapCrosswalk',
mapClearArea: 'showMapClearArea',
mapJunction: 'showMapJunction',
mapLane: 'showMapLane',
mapRoad: 'showMapRoad',
mapSignal: 'showMapSignal',
mapStopSign: 'showMapStopSign',
}; };
@observer @observer
......
import * as THREE from "three"; import * as THREE from "three";
import {MAP_WS} from "store/websocket"; import STORE from "store";
import { MAP_WS } from "store/websocket";
import { import {
drawSegmentsFromPoints, drawSegmentsFromPoints,
...@@ -49,6 +50,7 @@ export default class Map { ...@@ -49,6 +50,7 @@ export default class Map {
this.laneHeading = {}; this.laneHeading = {};
this.overlapMap = {}; this.overlapMap = {};
this.initialized = false; this.initialized = false;
this.elementKindsDrawn = '';
} }
// The result will be the all the elements in current but not in data. // The result will be the all the elements in current but not in data.
...@@ -57,6 +59,10 @@ export default class Map { ...@@ -57,6 +59,10 @@ export default class Map {
let empty = true; let empty = true;
for (const kind in elementIds) { for (const kind in elementIds) {
if (!this.shouldDrawThisElementKind(kind)) {
continue;
}
result[kind] = []; result[kind] = [];
const newIds = elementIds[kind]; const newIds = elementIds[kind];
const oldData = data[kind]; const oldData = data[kind];
...@@ -381,14 +387,17 @@ export default class Map { ...@@ -381,14 +387,17 @@ export default class Map {
const newData = {}; const newData = {};
for (const kind in this.data) { for (const kind in this.data) {
const drawThisKind = this.shouldDrawThisElementKind(kind);
newData[kind] = []; newData[kind] = [];
const oldDataOfThisKind = this.data[kind]; const oldDataOfThisKind = this.data[kind];
const currentIds = elementIds[kind]; const currentIds = elementIds[kind];
oldDataOfThisKind.forEach(oldData => { oldDataOfThisKind.forEach(oldData => {
if (currentIds && currentIds.includes(oldData.id.id)) { if (drawThisKind && currentIds && currentIds.includes(oldData.id.id)) {
newData[kind].push(oldData); newData[kind].push(oldData);
} else { } else {
this.removeDrewObjects(oldData.drewObjects, scene); if (kind !== "overlap") {
this.removeDrewObjects(oldData.drewObjects, scene);
}
if (kind === 'lane') { if (kind === 'lane') {
delete this.laneHeading[oldData.id.id]; delete this.laneHeading[oldData.id.id];
} }
...@@ -472,10 +481,27 @@ export default class Map { ...@@ -472,10 +481,27 @@ export default class Map {
} }
} }
shouldDrawThisElementKind(kind) {
// Ex: mapping 'lane' to 'showMapLane' option
const optionName = `showMap${kind[0].toUpperCase()}${kind.slice(1)}`;
// NOTE: return true if the option is not found
return STORE.options[optionName] !== false;
}
updateIndex(hash, elementIds, scene) { updateIndex(hash, elementIds, scene) {
if (hash !== this.hash) { let newElementKindsDrawn = '';
for (const kind of Object.keys(elementIds).sort()) {
if (this.shouldDrawThisElementKind(kind)) {
newElementKindsDrawn += kind;
}
}
if (hash !== this.hash || this.elementKindsDrawn !== newElementKindsDrawn) {
this.hash = hash; this.hash = hash;
this.elementKindsDrawn = newElementKindsDrawn;
const diff = this.diffMapElements(elementIds, this.data); const diff = this.diffMapElements(elementIds, this.data);
this.removeExpiredElements(elementIds, scene);
if (!_.isEmpty(diff) || !this.initialized) { if (!_.isEmpty(diff) || !this.initialized) {
MAP_WS.requestMapData(diff); MAP_WS.requestMapData(diff);
this.initialized = true; this.initialized = true;
......
...@@ -68,5 +68,18 @@ export default [ ...@@ -68,5 +68,18 @@ export default [
positionLocalization: 'Localization', positionLocalization: 'Localization',
positionGps: 'GPS', positionGps: 'GPS',
} }
}, {
id: 'map',
title: 'Map',
type: 'checkbox',
data: {
mapCrosswalk: 'Crosswalk',
mapClearArea: 'Clear Area',
mapJunction: 'Junction',
mapLane: 'Lane',
mapRoad: 'Road',
mapSignal: 'Signal',
mapStopSign: 'Stop Sign',
}
}, },
]; ];
...@@ -74,6 +74,13 @@ options: ...@@ -74,6 +74,13 @@ options:
showPointCloud: false showPointCloud: false
showPositionGps: false showPositionGps: false
showPositionLocalization: true showPositionLocalization: true
showMapCrosswalk: true
showMapClearArea: true
showMapJunction: false
showMapLane: true
showMapRoad: false
showMapSignal: true
showMapStopSign: true
cameraAngle: Default cameraAngle: Default
debug: debug:
# Turn this on for monitor related debugging # Turn this on for monitor related debugging
......
...@@ -48,6 +48,13 @@ export default class Options { ...@@ -48,6 +48,13 @@ export default class Options {
@observable showPointCloud = PARAMETERS.options.defaults.showPointCloud; @observable showPointCloud = PARAMETERS.options.defaults.showPointCloud;
@observable showPositionGps = PARAMETERS.options.defaults.showPositionGps; @observable showPositionGps = PARAMETERS.options.defaults.showPositionGps;
@observable showPositionLocalization = PARAMETERS.options.defaults.showPositionLocalization; @observable showPositionLocalization = PARAMETERS.options.defaults.showPositionLocalization;
@observable showMapCrosswalk = PARAMETERS.options.defaults.showMapCrosswalk;
@observable showMapClearArea = PARAMETERS.options.defaults.showMapClearArea;
@observable showMapJunction = PARAMETERS.options.defaults.showMapJunction;
@observable showMapLane = PARAMETERS.options.defaults.showMapLane;
@observable showMapRoad = PARAMETERS.options.defaults.showMapRoad;
@observable showMapSignal = PARAMETERS.options.defaults.showMapSignal;
@observable showMapStopSign = PARAMETERS.options.defaults.showMapStopSign;
// Others // Others
@observable showPNCMonitor = PARAMETERS.options.defaults.showPNCMonitor; @observable showPNCMonitor = PARAMETERS.options.defaults.showPNCMonitor;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册