Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.eclipse.set.feature.siteplan.transform.SiteplanTransformator;
import org.eclipse.set.model.siteplan.Siteplan;
import org.eclipse.set.utils.FileWebBrowser;
import org.eclipse.set.utils.ToolboxConfiguration;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;

Expand Down Expand Up @@ -105,6 +106,17 @@ private void serveConfiguration(final Response response)
final String json = new ObjectMapper().writerWithDefaultPrettyPrinter()
.writeValueAsString(new SiteplanConfiguration("siteplan")); //$NON-NLS-1$
response.setResponseData(json);
if (ToolboxConfiguration.isDevelopmentMode()) {
try {
final Path path = Paths.get("configuration.json");
Files.writeString(path, json);
System.out.println(
"Exported currently loaded configuration.json to "
+ path.toAbsolutePath());
} catch (final IOException e) {
// don't care for now. It is just development mode stuff
}
}
}

private void serveSiteplan(final Response response)
Expand All @@ -131,6 +143,16 @@ private void serveSiteplan(final Response response)
.writeValueAsString(siteplan);
response.setMimeType("application/json;charset=UTF-8"); //$NON-NLS-1$
response.setResponseData(json);
if (ToolboxConfiguration.isDevelopmentMode()) {
try {
final Path path = Paths.get("siteplan.json");
Files.writeString(path, json);
System.out.println("Exported currently loaded siteplan.json to "
+ path.toAbsolutePath());
} catch (final IOException e) {
// don't care for now. It is just development mode stuff
}
}
}

@Override
Expand Down
62 changes: 26 additions & 36 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 @@ -221,7 +219,7 @@ export default class FeatureService extends Vue {
]
.map(state => featureClass.getFeatures(state))
.flat()
.map(feature => featureClass.setFeatureColor(feature))
.map(feature => featureClass.setFeatureColor(feature, SiteplanColorValue.COLOR_UNCHANGED_PLANNING))
case TableType.FINAL:
return [
model.commonState,
Expand All @@ -230,40 +228,32 @@ export default class FeatureService extends Vue {
]
.map(state => featureClass.getFeatures(state))
.flat()
.map(feature => featureClass.setFeatureColor(feature))
.map(feature => featureClass.setFeatureColor(feature, SiteplanColorValue.COLOR_UNCHANGED_PLANNING))
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, SiteplanColorValue.COLOR_UNCHANGED_PLANNING)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mariusheine here shouldn't set color to COLOR_UNCHANGED_PLANNING, because when the elemete isn't planing object then it should be grau. See LageplanFeature #getRegionColor()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TruongQuangSB But then it is probably also wrong to set the color to UNCHANGED_PLANNING in initial and final state, isn't it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mariusheine yes, in initial and final state shouldn't set color to UNCAHNGED_PLANNING

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
6 changes: 6 additions & 0 deletions web/siteplan/src/feature/LageplanFeature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,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
8 changes: 7 additions & 1 deletion web/siteplan/src/feature/SignalFeature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,13 @@ export default class SignalFeature extends LageplanFeature<SignalMount> {

setFeatureColor (feature: Feature<Geometry>, color?: number[], partID?: string): Feature<Geometry> {
if (color) {
super.setFeatureColor(feature, color, partID)
if (partID) {
super.setFeatureColor(feature, color, partID)
} else {
Object.values(SignalPart).forEach(part => {
super.setFeatureColor(feature, color, part)
})
}
} else {
Object.values(SignalPart).forEach(part => {
this.setFeatureRegionColor(feature, part)
Expand Down
8 changes: 7 additions & 1 deletion web/siteplan/src/feature/TrackSwitchFeature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,13 @@ export default class TrackSwitchFeature extends LageplanFeature<TrackSwitch> {

setFeatureColor (feature: Feature<Geometry>, color?: number[], id?: string): Feature<Geometry> {
if (color) {
super.setFeatureColor(feature, color, id)
if (id) {
super.setFeatureColor(feature, color, id)
} else {
Object.values(TrackSwitchPart).forEach(part => {
this.setFeatureColor(feature, color, part)
})
}
} else {
Object.values(TrackSwitchPart).forEach(part => {
this.setFeatureRegionColor(feature, part)
Expand Down
10 changes: 9 additions & 1 deletion web/siteplan/src/util/SVG/Draw/SvgDraw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ export default class SvgDraw {
centerText: boolean,
fontSize: number,
rotate?: number,
centerVertical?: boolean
centerVertical?: boolean,
applyColor?: boolean
): Element {
const labelsvg = document.createElement('text')
if (!label) {
Expand All @@ -94,6 +95,12 @@ export default class SvgDraw {
labelsvg.setAttribute('id', 'label')
labelsvg.setAttribute('font-size', fontSize.toString())
labelsvg.setAttribute('font-family', 'siteplanfont')
if (label.color && applyColor) {
const rgbColorString = `rgb(${label.color[0]}, ${label.color[1]}, ${label.color[2]})`
labelsvg.setAttribute('fill', rgbColorString)
labelsvg.setAttribute('stroke', rgbColorString)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mariusheine i think, we don't need set label color here. We already use svg filter for set svg color (see SvgColorService).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TruongQuangSB Yeah but it somehow was not applied for the signal km marker

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mariusheine the reason is the Label not contain ObjectColor. Because of this can't find the objectColor property in SvgService #getSVGStyle line 94. You can change the propery color in Label to objectColors with type ObjectColor. It will be work

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TruongQuangSB This did not worked totally, because the SvgService tried to get the objectColors from the drawData (which was the attachedSignals[0] of the signalMount). So I had to set the correct drawData (the signalMount in this case) and it worked nicely.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mariusheine the drawData isn't only attachedSignals[0], it is contain attachedSignals[0], featureType, label. But it ist fine, when you change to signalMount, By SingalRouteMarker doesn't matter attachedSignals[0] or signalMount


labelsvg.setAttribute('stroke-width', '0.2')
labelsvg.setAttribute('style', 'writing-mode: vertical-rl;')
const textAnchor = this.getTextAnchor(centerText, label)
Expand Down Expand Up @@ -255,6 +262,7 @@ export default class SvgDraw {
true,
13,
90,
true,
true
))
return new SvgElement('RouteMarker', svg, [], null, [])
Expand Down
Loading