in src/component/tag/TagCreator.ts [44:136]
constructor(component: Component<TagConfiguration>, navigator: Navigator) {
this._component = component;
this._navigator = navigator;
this._tagOperation$ = new Subject<CreateTagOperation>();
this._createPoints$ = new Subject<number[]>();
this._createPolygon$ = new Subject<number[]>();
this._createRect$ = new Subject<number[]>();
this._delete$ = new Subject<void>();
this._tag$ = this._tagOperation$.pipe(
scan(
(tag: CreateTag<Geometry>, operation: CreateTagOperation): CreateTag<Geometry> => {
return operation(tag);
},
null),
share());
this._replayedTag$ = this._tag$.pipe(
publishReplay(1),
refCount());
this._replayedTag$.subscribe();
this._createPoints$.pipe(
withLatestFrom(
this._component.configuration$,
this._navigator.stateService.currentTransform$),
map(
([coord, conf, transform]: [number[], TagConfiguration, Transform]): CreateTagOperation => {
return (): CreateTag<Geometry> => {
const geometry: PointsGeometry = new PointsGeometry([
[coord[0], coord[1]],
[coord[0], coord[1]],
]);
return new ExtremePointCreateTag(
geometry,
{
color: conf.createColor,
indicateCompleter: conf.indicatePointsCompleter,
},
transform);
};
}))
.subscribe(this._tagOperation$);
this._createRect$.pipe(
withLatestFrom(
this._component.configuration$,
this._navigator.stateService.currentTransform$),
map(
([coord, conf, transform]: [number[], TagConfiguration, Transform]): CreateTagOperation => {
return (): CreateTag<Geometry> => {
const geometry: RectGeometry = new RectGeometry([
coord[0],
coord[1],
coord[0],
coord[1],
]);
return new OutlineCreateTag(geometry, { color: conf.createColor }, transform);
};
}))
.subscribe(this._tagOperation$);
this._createPolygon$.pipe(
withLatestFrom(
this._component.configuration$,
this._navigator.stateService.currentTransform$),
map(
([coord, conf, transform]: [number[], TagConfiguration, Transform]): CreateTagOperation => {
return (): CreateTag<Geometry> => {
const geometry: PolygonGeometry = new PolygonGeometry([
[coord[0], coord[1]],
[coord[0], coord[1]],
[coord[0], coord[1]],
]);
return new OutlineCreateTag(geometry, { color: conf.createColor }, transform);
};
}))
.subscribe(this._tagOperation$);
this._delete$.pipe(
map(
(): CreateTagOperation => {
return (): CreateTag<Geometry> => {
return null;
};
}))
.subscribe(this._tagOperation$);
}