Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 24 additions & 34 deletions web/siteplan/src/components/FeatureService.vue
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,13 @@ export default class FeatureService extends Vue {
unsubscribe: SubscribeOptions | undefined
map: Map = store.state.map
model: SiteplanModel | null = null
developmentOptions = false
svgService: SvgService = new SvgService(axios)
listFeature: ILageplanFeature[] = []
inLODView = false
collisionService = new CollisionService(this.map)

mounted (): void {
this.createLayers()
this.developmentOptions = Configuration.developmentMode()
this.loadModel()
store.subscribe((m, s) => {
if (m.type === 'setSheetCutCRS') {
Expand Down Expand Up @@ -232,38 +230,30 @@ export default class FeatureService extends Vue {
.flat()
.map(feature => featureClass.setFeatureColor(feature))
case TableType.DIFF:{
if (Configuration.developmentMode()) {
// Temporary demo: Only show red/yellow in development mode
const compareState = featureClass.compareChangedState(
model.changedInitialState,
model.changedFinalState
)
return [
featureClass
.getFeatures(model.commonState)
.map(feature => featureClass.setFeatureColor(feature)),
compareState,
featureClass
.getFeatures(model.finalState)
.map(feature =>
featureClass.setFeatureColor(
feature,
SiteplanColorValue.COLOR_ADDED
)),
featureClass
.getFeatures(model.initialState)
.map(feature =>
featureClass.setFeatureColor(
feature,
SiteplanColorValue.COLOR_REMOVED
))
].flat()
}

return [model.commonState, model.finalState, model.changedInitialState]
.map(state => featureClass.getFeatures(state))
.flat()
.map(feature => featureClass.setFeatureColor(feature))
const compareState = featureClass.compareChangedState(
model.changedInitialState,
model.changedFinalState
)
return [
featureClass
.getFeatures(model.commonState)
.map(feature => featureClass.setFeatureColor(feature)),
compareState,
featureClass
.getFeatures(model.finalState)
.map(feature =>
featureClass.setFeatureColor(
feature,
SiteplanColorValue.COLOR_ADDED
)),
featureClass
.getFeatures(model.initialState)
.map(feature =>
featureClass.setFeatureColor(
feature,
SiteplanColorValue.COLOR_REMOVED
))
].flat()
}
}
} catch (e) {
Expand Down
12 changes: 12 additions & 0 deletions web/siteplan/src/feature/LageplanFeature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,12 @@ export default abstract class LageplanFeature<T extends SiteplanObject> implemen
return final
}

resetFeatureColor (feature: Feature<Geometry>): Feature<Geometry> {
const object = getFeatureData(feature) as SiteplanObject
object.objectColors = []
return feature
}

// Default implementation
setFeatureColor (feature: Feature<Geometry>, color?: number[], partID?: string): Feature<Geometry> {
this.setObjectColor(
Expand Down Expand Up @@ -356,6 +362,12 @@ export default abstract class LageplanFeature<T extends SiteplanObject> implemen
const objColor = { id, color }
if (!object.objectColors) {
object.objectColors = [objColor]
return
}

const existingObjectColor = object.objectColors.find(objectColor => objectColor.id === id)
if (existingObjectColor) {
existingObjectColor.color = color
} else {
object.objectColors.push(objColor)
}
Expand Down
20 changes: 14 additions & 6 deletions web/siteplan/src/feature/SignalFeature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,36 +90,44 @@ export default class SignalFeature extends LageplanFeature<SignalMount> {
}

setFeatureColor (feature: Feature<Geometry>, color?: number[], partID?: string): Feature<Geometry> {
if (color) {
if (!color && !partID) {
this.resetFeatureColor(feature)
} else if (partID) {
super.setFeatureColor(feature, color, partID)
} else {
Object.values(SignalPart).forEach(part => {
this.setFeatureRegionColor(feature, part)
this.setFeatureRegionColor(feature, part, color)
})
}

return feature
}

protected setFeatureRegionColor (feature: Feature<Geometry>, objectPart?: string | undefined): Feature<Geometry> {
protected setFeatureRegionColor (
feature: Feature<Geometry>,
objectPart?: string | undefined,
color?: number[]
): Feature<Geometry> {
const signalModel = getFeatureData(feature) as SignalMount
// IMPROVE: Because at the moment Signal Additive doesn't have GUID,
// you can't set region color for this.
switch (objectPart) {
case SignalPart.Label:
case SignalPart.RouteMarker:
case SignalPart.Mast: {
this.setObjectColor(signalModel, objectPart, this.getRegionColor(feature))
this.setObjectColor(signalModel, objectPart, color ?? this.getRegionColor(feature))
break
}
case SignalPart.Schirm: {
if (signalModel.attachedSignals.length === 1) {
this.setObjectColor(
signalModel,
objectPart,
this.getRegionColor(feature, signalModel.attachedSignals[0].guid)
color ?? this.getRegionColor(feature, signalModel.attachedSignals[0].guid)
)
} else {
signalModel.attachedSignals.forEach(signal => {
const regionColor = this.getRegionColor(feature, signal.guid)
const regionColor = color ?? this.getRegionColor(feature, signal.guid)
this.setObjectColor(signalModel, `${objectPart}_${signal.guid}`, regionColor)
})
}
Expand Down
6 changes: 3 additions & 3 deletions web/siteplan/src/feature/SignalRouteMarkerFeature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default class SignalRouteMarkerFeature extends LageplanFeature<SignalMoun
const lineCoordinates = this.getLocationLineCoors(signalPos)
const lineFeature = createFeature(
FeatureType.SignalRouteMarker,
signalMount.attachedSignals[0],
signalMount,
new LineString([lineCoordinates[0], lineCoordinates[1]])
)
lineFeature.setStyle((_, resolution) => {
Expand All @@ -71,7 +71,7 @@ export default class SignalRouteMarkerFeature extends LageplanFeature<SignalMoun
// Add km text
const textFeature = createFeature(
FeatureType.SignalRouteMarker,
signalMount.attachedSignals[0],
signalMount,
new Point([signalPos.x, signalPos.y])
)

Expand All @@ -88,7 +88,7 @@ export default class SignalRouteMarkerFeature extends LageplanFeature<SignalMoun
updateLabelOrientation(label, labelRotation + 90, this.map)
updateLabelColor(label, getColor(signalMount, SignalPart.RouteMarker))
const style = this.svgService.getFeatureStyle(
signalMount.attachedSignals[0],
signalMount,
FeatureType.SignalRouteMarker,
label
)
Expand Down
9 changes: 5 additions & 4 deletions web/siteplan/src/model/Signal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*/
import { defaultSignalScreenObj, SignalScreen } from './SignalScreen'
import { checkInstance } from '@/util/ObjectExtension'
import { Label } from './Label'
import { defaultRouteLocationObj, RouteObject } from './RouteObject'
import { defaultPositionObj, Position } from './Position'
import { checkInstance } from '@/util/ObjectExtension'
import { defaultRouteLocationObj, RouteObject } from './RouteObject'
import { defaultSignalScreenObj, SignalScreen } from './SignalScreen'

export enum SignalRole
{
Expand Down Expand Up @@ -60,7 +60,8 @@ export enum SignalPart {
Schirm = 'schirm',
Mast = 'mast',
Additive = 'additive',
RouteMarker = 'marker'
RouteMarker = 'marker',
Label = 'label'
}

export interface Signal extends RouteObject
Expand Down
5 changes: 0 additions & 5 deletions web/siteplan/src/service/SvgColorService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ export default class SvgColorService {
}

private static shouldApplyColor (svg: Element, obj: ObjectColor) {
if (obj.id === 'label') {
this.applyColorByIds(svg, 'label', obj.color)
return false
}

return svg.querySelector('#' + obj.id) !== null
}

Expand Down
7 changes: 5 additions & 2 deletions web/siteplan/src/util/SVG/Draw/SvgDraw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import { Label } from '@/model/Label'
import { KMMarker } from '@/model/Route'
import { SignalPart } from '@/model/Signal'
import { ISvgElement, SvgElement } from '@/model/SvgElement'
import '@/util/ElementExtensions'
import { fromCenterPointAndMasure } from '@/util/ExtentExtension'
Expand Down Expand Up @@ -247,7 +248,7 @@ export default class SvgDraw {
static getRouteMarker (label: Label): ISvgElement {
const svg = SvgDraw.createSvgWithHead(this.SVG_KMMARKER_DRAWAREA_X, this.SVG_KMMARKER_DRAWAREA_Y)
// Add the label
svg.appendChild(SvgDraw.drawLabelAt(
const labelSvg = SvgDraw.drawLabelAt(
label,
this.SVG_KMMARKER_DRAWAREA_CENTER_X - 60,
this.SVG_KMMARKER_DRAWAREA_CENTER_Y + 8,
Expand All @@ -256,7 +257,9 @@ export default class SvgDraw {
13,
90,
true
))
)
labelSvg.setAttribute('id', SignalPart.RouteMarker)
svg.appendChild(labelSvg)
return new SvgElement('RouteMarker', svg, [], null, [])
}

Expand Down
Loading