Skip to content
Snippets Groups Projects
Commit 29f1f9d0 authored by Miłosz Grocholewski's avatar Miłosz Grocholewski
Browse files

feat(vector-map): disable elements background color when data overlays are visible

parent 9f466ff6
No related branches found
No related tags found
1 merge request!322feat(vector-map): disable elements background color when data overlays are visible
Showing
with 34 additions and 6 deletions
...@@ -74,6 +74,7 @@ export default function processModelElements( ...@@ -74,6 +74,7 @@ export default function processModelElements(
nameHorizontalAlign: element.nameHorizontalAlign as HorizontalAlign, nameHorizontalAlign: element.nameHorizontalAlign as HorizontalAlign,
text: element.name, text: element.name,
fontSize: element.fontSize, fontSize: element.fontSize,
overlaysVisible: Boolean(overlaysOrder.length),
pointToProjection, pointToProjection,
mapInstance, mapInstance,
vectorSource, vectorSource,
......
...@@ -40,6 +40,7 @@ export interface CompartmentProps { ...@@ -40,6 +40,7 @@ export interface CompartmentProps {
nameHorizontalAlign: HorizontalAlign; nameHorizontalAlign: HorizontalAlign;
fillColor: Color; fillColor: Color;
borderColor: Color; borderColor: Color;
overlaysVisible: boolean;
pointToProjection: UsePointToProjectionResult; pointToProjection: UsePointToProjectionResult;
mapInstance: MapInstance; mapInstance: MapInstance;
vectorSource: VectorSource; vectorSource: VectorSource;
...@@ -58,6 +59,8 @@ export default abstract class Compartment extends BaseMultiPolygon { ...@@ -58,6 +59,8 @@ export default abstract class Compartment extends BaseMultiPolygon {
thickness: number; thickness: number;
overlaysVisible: boolean;
constructor({ constructor({
id, id,
complexId, complexId,
...@@ -81,6 +84,7 @@ export default abstract class Compartment extends BaseMultiPolygon { ...@@ -81,6 +84,7 @@ export default abstract class Compartment extends BaseMultiPolygon {
nameHorizontalAlign, nameHorizontalAlign,
fillColor, fillColor,
borderColor, borderColor,
overlaysVisible,
pointToProjection, pointToProjection,
mapInstance, mapInstance,
vectorSource, vectorSource,
...@@ -116,6 +120,7 @@ export default abstract class Compartment extends BaseMultiPolygon { ...@@ -116,6 +120,7 @@ export default abstract class Compartment extends BaseMultiPolygon {
this.outerWidth = outerWidth; this.outerWidth = outerWidth;
this.innerWidth = innerWidth; this.innerWidth = innerWidth;
this.thickness = thickness; this.thickness = thickness;
this.overlaysVisible = overlaysVisible;
this.getCompartmentCoords(); this.getCompartmentCoords();
this.createPolygons(); this.createPolygons();
this.drawText(); this.drawText();
...@@ -142,7 +147,9 @@ export default abstract class Compartment extends BaseMultiPolygon { ...@@ -142,7 +147,9 @@ export default abstract class Compartment extends BaseMultiPolygon {
this.styles.push( this.styles.push(
new Style({ new Style({
geometry: framePolygon, geometry: framePolygon,
fill: getFill({ color: rgbToHex({ ...this.fillColor, alpha: 128 }) }), fill: this.overlaysVisible
? undefined
: getFill({ color: rgbToHex({ ...this.fillColor, alpha: 128 }) }),
zIndex: this.zIndex, zIndex: this.zIndex,
}), }),
); );
...@@ -154,7 +161,9 @@ export default abstract class Compartment extends BaseMultiPolygon { ...@@ -154,7 +161,9 @@ export default abstract class Compartment extends BaseMultiPolygon {
this.styles.push( this.styles.push(
new Style({ new Style({
geometry: outerPolygon, geometry: outerPolygon,
stroke: getStroke({ color: rgbToHex(this.borderColor), width: this.outerWidth }), stroke: this.overlaysVisible
? getStroke({ width: this.outerWidth })
: getStroke({ color: rgbToHex(this.borderColor), width: this.outerWidth }),
zIndex: this.zIndex, zIndex: this.zIndex,
}), }),
); );
...@@ -166,8 +175,12 @@ export default abstract class Compartment extends BaseMultiPolygon { ...@@ -166,8 +175,12 @@ export default abstract class Compartment extends BaseMultiPolygon {
this.styles.push( this.styles.push(
new Style({ new Style({
geometry: innerPolygon, geometry: innerPolygon,
stroke: getStroke({ color: rgbToHex(this.borderColor), width: this.innerWidth }), stroke: this.overlaysVisible
fill: getFill({ color: rgbToHex({ ...this.fillColor, alpha: 9 }) }), ? getStroke({ width: this.innerWidth })
: getStroke({ color: rgbToHex(this.borderColor), width: this.innerWidth }),
fill: this.overlaysVisible
? undefined
: getFill({ color: rgbToHex({ ...this.fillColor, alpha: 9 }) }),
zIndex: this.zIndex, zIndex: this.zIndex,
}), }),
); );
......
...@@ -65,6 +65,7 @@ describe('CompartmentCircle', () => { ...@@ -65,6 +65,7 @@ describe('CompartmentCircle', () => {
nameWidth: 40, nameWidth: 40,
nameVerticalAlign: 'MIDDLE', nameVerticalAlign: 'MIDDLE',
nameHorizontalAlign: 'CENTER', nameHorizontalAlign: 'CENTER',
overlaysVisible: false,
pointToProjection: jest.fn(), pointToProjection: jest.fn(),
mapInstance, mapInstance,
vectorSource: new VectorSource(), vectorSource: new VectorSource(),
......
...@@ -40,6 +40,7 @@ export type CompartmentCircleProps = { ...@@ -40,6 +40,7 @@ export type CompartmentCircleProps = {
nameWidth: number; nameWidth: number;
nameVerticalAlign?: VerticalAlign; nameVerticalAlign?: VerticalAlign;
nameHorizontalAlign?: HorizontalAlign; nameHorizontalAlign?: HorizontalAlign;
overlaysVisible: boolean;
pointToProjection: UsePointToProjectionResult; pointToProjection: UsePointToProjectionResult;
mapInstance: MapInstance; mapInstance: MapInstance;
vectorSource: VectorSource; vectorSource: VectorSource;
...@@ -71,6 +72,7 @@ export default class CompartmentCircle extends Compartment { ...@@ -71,6 +72,7 @@ export default class CompartmentCircle extends Compartment {
nameWidth, nameWidth,
nameVerticalAlign = 'MIDDLE', nameVerticalAlign = 'MIDDLE',
nameHorizontalAlign = 'CENTER', nameHorizontalAlign = 'CENTER',
overlaysVisible,
pointToProjection, pointToProjection,
mapInstance, mapInstance,
vectorSource, vectorSource,
...@@ -100,6 +102,7 @@ export default class CompartmentCircle extends Compartment { ...@@ -100,6 +102,7 @@ export default class CompartmentCircle extends Compartment {
nameHorizontalAlign, nameHorizontalAlign,
fillColor, fillColor,
borderColor, borderColor,
overlaysVisible,
pointToProjection, pointToProjection,
mapInstance, mapInstance,
vectorSource, vectorSource,
......
...@@ -63,6 +63,7 @@ describe('CompartmentPathway', () => { ...@@ -63,6 +63,7 @@ describe('CompartmentPathway', () => {
nameWidth: 40, nameWidth: 40,
nameVerticalAlign: 'MIDDLE', nameVerticalAlign: 'MIDDLE',
nameHorizontalAlign: 'CENTER', nameHorizontalAlign: 'CENTER',
overlaysVisible: false,
pointToProjection: jest.fn(() => [10, 10]), pointToProjection: jest.fn(() => [10, 10]),
mapInstance, mapInstance,
vectorSource: new VectorSource(), vectorSource: new VectorSource(),
......
...@@ -41,6 +41,7 @@ export type CompartmentPathwayProps = { ...@@ -41,6 +41,7 @@ export type CompartmentPathwayProps = {
nameWidth: number; nameWidth: number;
nameVerticalAlign?: VerticalAlign; nameVerticalAlign?: VerticalAlign;
nameHorizontalAlign?: HorizontalAlign; nameHorizontalAlign?: HorizontalAlign;
overlaysVisible: boolean;
pointToProjection: UsePointToProjectionResult; pointToProjection: UsePointToProjectionResult;
mapInstance: MapInstance; mapInstance: MapInstance;
vectorSource: VectorSource; vectorSource: VectorSource;
...@@ -51,6 +52,8 @@ export type CompartmentPathwayProps = { ...@@ -51,6 +52,8 @@ export type CompartmentPathwayProps = {
export default class CompartmentPathway extends BaseMultiPolygon { export default class CompartmentPathway extends BaseMultiPolygon {
outerWidth: number; outerWidth: number;
overlaysVisible: boolean;
constructor({ constructor({
id, id,
complexId, complexId,
...@@ -72,6 +75,7 @@ export default class CompartmentPathway extends BaseMultiPolygon { ...@@ -72,6 +75,7 @@ export default class CompartmentPathway extends BaseMultiPolygon {
nameWidth, nameWidth,
nameVerticalAlign = 'MIDDLE', nameVerticalAlign = 'MIDDLE',
nameHorizontalAlign = 'CENTER', nameHorizontalAlign = 'CENTER',
overlaysVisible,
pointToProjection, pointToProjection,
mapInstance, mapInstance,
vectorSource, vectorSource,
...@@ -105,6 +109,7 @@ export default class CompartmentPathway extends BaseMultiPolygon { ...@@ -105,6 +109,7 @@ export default class CompartmentPathway extends BaseMultiPolygon {
mapSize, mapSize,
}); });
this.outerWidth = outerWidth; this.outerWidth = outerWidth;
this.overlaysVisible = overlaysVisible;
this.createPolygons(); this.createPolygons();
this.drawText(); this.drawText();
this.drawMultiPolygonFeature(mapInstance); this.drawMultiPolygonFeature(mapInstance);
...@@ -131,7 +136,7 @@ export default class CompartmentPathway extends BaseMultiPolygon { ...@@ -131,7 +136,7 @@ export default class CompartmentPathway extends BaseMultiPolygon {
getStyle({ getStyle({
geometry: compartmentPolygon, geometry: compartmentPolygon,
borderColor: this.borderColor, borderColor: this.borderColor,
fillColor: { ...this.fillColor, alpha: 9 }, fillColor: this.overlaysVisible ? undefined : { ...this.fillColor, alpha: 9 },
lineWidth: this.outerWidth, lineWidth: this.outerWidth,
zIndex: this.zIndex, zIndex: this.zIndex,
}), }),
......
...@@ -63,6 +63,7 @@ describe('CompartmentSquare', () => { ...@@ -63,6 +63,7 @@ describe('CompartmentSquare', () => {
nameWidth: 40, nameWidth: 40,
nameVerticalAlign: 'MIDDLE', nameVerticalAlign: 'MIDDLE',
nameHorizontalAlign: 'CENTER', nameHorizontalAlign: 'CENTER',
overlaysVisible: false,
pointToProjection: jest.fn(), pointToProjection: jest.fn(),
mapInstance, mapInstance,
vectorSource: new VectorSource(), vectorSource: new VectorSource(),
......
...@@ -39,6 +39,7 @@ export type CompartmentSquareProps = { ...@@ -39,6 +39,7 @@ export type CompartmentSquareProps = {
nameWidth: number; nameWidth: number;
nameVerticalAlign?: VerticalAlign; nameVerticalAlign?: VerticalAlign;
nameHorizontalAlign?: HorizontalAlign; nameHorizontalAlign?: HorizontalAlign;
overlaysVisible: boolean;
pointToProjection: UsePointToProjectionResult; pointToProjection: UsePointToProjectionResult;
mapInstance: MapInstance; mapInstance: MapInstance;
vectorSource: VectorSource; vectorSource: VectorSource;
...@@ -70,6 +71,7 @@ export default class CompartmentSquare extends Compartment { ...@@ -70,6 +71,7 @@ export default class CompartmentSquare extends Compartment {
nameWidth, nameWidth,
nameVerticalAlign = 'MIDDLE', nameVerticalAlign = 'MIDDLE',
nameHorizontalAlign = 'CENTER', nameHorizontalAlign = 'CENTER',
overlaysVisible,
pointToProjection, pointToProjection,
mapInstance, mapInstance,
vectorSource, vectorSource,
...@@ -99,6 +101,7 @@ export default class CompartmentSquare extends Compartment { ...@@ -99,6 +101,7 @@ export default class CompartmentSquare extends Compartment {
nameHorizontalAlign, nameHorizontalAlign,
fillColor, fillColor,
borderColor, borderColor,
overlaysVisible,
pointToProjection, pointToProjection,
mapInstance, mapInstance,
vectorSource, vectorSource,
......
...@@ -299,7 +299,7 @@ export default class MapElement extends BaseMultiPolygon { ...@@ -299,7 +299,7 @@ export default class MapElement extends BaseMultiPolygon {
const elementStyle = getStyle({ const elementStyle = getStyle({
geometry: elementPolygon, geometry: elementPolygon,
borderColor: this.borderColor, borderColor: this.borderColor,
fillColor: this.overlays.length ? undefined : this.fillColor, fillColor: this.overlaysOrder.length ? undefined : this.fillColor,
lineWidth: this.lineWidth, lineWidth: this.lineWidth,
lineDash: this.lineDash, lineDash: this.lineDash,
zIndex: this.zIndex, zIndex: this.zIndex,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment