Skip to content
Snippets Groups Projects
Commit 0bc83f47 authored by Alexander Rose's avatar Alexander Rose
Browse files

moved Loci.areEqual

parent bf5908e2
No related branches found
No related tags found
No related merge requests found
...@@ -43,7 +43,12 @@ export function createDataLoci(data: any, tag: string, indices: OrderedSet<numbe ...@@ -43,7 +43,12 @@ export function createDataLoci(data: any, tag: string, indices: OrderedSet<numbe
return { kind: 'data-loci', data, tag, indices } return { kind: 'data-loci', data, tag, indices }
} }
export function areLociEqual(lociA: Loci, lociB: Loci) { export { Loci }
type Loci = StructureElement.Loci | Structure.Loci | Link.Loci | EveryLoci | EmptyLoci | DataLoci | Shape.Loci
namespace Loci {
export function areEqual(lociA: Loci, lociB: Loci) {
if (isEveryLoci(lociA) && isEveryLoci(lociB)) return true if (isEveryLoci(lociA) && isEveryLoci(lociB)) return true
if (isEmptyLoci(lociA) && isEmptyLoci(lociB)) return true if (isEmptyLoci(lociA) && isEmptyLoci(lociB)) return true
if (isDataLoci(lociA) && isDataLoci(lociB)) { if (isDataLoci(lociA) && isDataLoci(lociB)) {
...@@ -64,13 +69,6 @@ export function areLociEqual(lociA: Loci, lociB: Loci) { ...@@ -64,13 +69,6 @@ export function areLociEqual(lociA: Loci, lociB: Loci) {
return false return false
} }
export { Loci }
type Loci = StructureElement.Loci | Structure.Loci | Link.Loci | EveryLoci | EmptyLoci | DataLoci | Shape.Loci
namespace Loci {
const sphereHelper = new CentroidHelper(), tempPos = Vec3.zero(); const sphereHelper = new CentroidHelper(), tempPos = Vec3.zero();
export function getBoundingSphere(loci: Loci): Sphere3D | undefined { export function getBoundingSphere(loci: Loci): Sphere3D | undefined {
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
*/ */
import { PluginBehavior } from '../behavior'; import { PluginBehavior } from '../behavior';
import { EmptyLoci, Loci, areLociEqual } from 'mol-model/loci'; import { EmptyLoci, Loci } from 'mol-model/loci';
import { MarkerAction } from 'mol-geo/geometry/marker-data'; import { MarkerAction } from 'mol-geo/geometry/marker-data';
import { labelFirst } from 'mol-theme/label'; import { labelFirst } from 'mol-theme/label';
import { PluginContext } from 'mol-plugin/context'; import { PluginContext } from 'mol-plugin/context';
...@@ -18,7 +18,7 @@ export const HighlightLoci = PluginBehavior.create({ ...@@ -18,7 +18,7 @@ export const HighlightLoci = PluginBehavior.create({
this.subscribeObservable(this.ctx.behaviors.canvas.highlightLoci, current => { this.subscribeObservable(this.ctx.behaviors.canvas.highlightLoci, current => {
if (!this.ctx.canvas3d) return; if (!this.ctx.canvas3d) return;
if (current.repr !== prevRepr || !areLociEqual(current.loci, prevLoci)) { if (current.repr !== prevRepr || !Loci.areEqual(current.loci, prevLoci)) {
this.ctx.canvas3d.mark(prevLoci, MarkerAction.RemoveHighlight, prevRepr); this.ctx.canvas3d.mark(prevLoci, MarkerAction.RemoveHighlight, prevRepr);
this.ctx.canvas3d.mark(current.loci, MarkerAction.Highlight, current.repr); this.ctx.canvas3d.mark(current.loci, MarkerAction.Highlight, current.repr);
prevLoci = current.loci; prevLoci = current.loci;
...@@ -37,7 +37,7 @@ export const SelectLoci = PluginBehavior.create({ ...@@ -37,7 +37,7 @@ export const SelectLoci = PluginBehavior.create({
let prevLoci: Loci = EmptyLoci, prevRepr: any = void 0; let prevLoci: Loci = EmptyLoci, prevRepr: any = void 0;
this.subscribeObservable(this.ctx.behaviors.canvas.selectLoci, current => { this.subscribeObservable(this.ctx.behaviors.canvas.selectLoci, current => {
if (!this.ctx.canvas3d) return; if (!this.ctx.canvas3d) return;
if (current.repr !== prevRepr || !areLociEqual(current.loci, prevLoci)) { if (current.repr !== prevRepr || !Loci.areEqual(current.loci, prevLoci)) {
this.ctx.canvas3d.mark(prevLoci, MarkerAction.Deselect, prevRepr); this.ctx.canvas3d.mark(prevLoci, MarkerAction.Deselect, prevRepr);
this.ctx.canvas3d.mark(current.loci, MarkerAction.Select, current.repr); this.ctx.canvas3d.mark(current.loci, MarkerAction.Select, current.repr);
prevLoci = current.loci; prevLoci = current.loci;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
import { PluginContext } from '../context'; import { PluginContext } from '../context';
import { PickingId } from 'mol-geo/geometry/picking'; import { PickingId } from 'mol-geo/geometry/picking';
import { EmptyLoci, Loci, areLociEqual } from 'mol-model/loci'; import { EmptyLoci, Loci } from 'mol-model/loci';
import { Representation } from 'mol-repr/representation'; import { Representation } from 'mol-repr/representation';
export class Canvas3dIdentifyHelper { export class Canvas3dIdentifyHelper {
...@@ -45,7 +45,7 @@ export class Canvas3dIdentifyHelper { ...@@ -45,7 +45,7 @@ export class Canvas3dIdentifyHelper {
} }
const loci = this.ctx.canvas3d.getLoci(this.id); const loci = this.ctx.canvas3d.getLoci(this.id);
if (loci.repr !== this.prevLoci.repr || !areLociEqual(loci.loci, this.prevLoci.loci)) { if (loci.repr !== this.prevLoci.repr || !Loci.areEqual(loci.loci, this.prevLoci.loci)) {
this.ctx.behaviors.canvas.highlightLoci.next(loci); this.ctx.behaviors.canvas.highlightLoci.next(loci);
this.prevLoci = loci; this.prevLoci = loci;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment