From 8214f0f9417fb4ee14409095b2c85e9b71b2474a Mon Sep 17 00:00:00 2001
From: David Sehnal <david.sehnal@gmail.com>
Date: Wed, 13 Mar 2019 11:16:48 +0100
Subject: [PATCH] mol-plugin: UI tweak, remove dynamic density on "double
 click"

---
 .../dynamic/volume-streaming/behavior.ts      | 24 ++++++++++++++++++-
 src/mol-plugin/skin/base/components/temp.scss |  6 ++++-
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/src/mol-plugin/behavior/dynamic/volume-streaming/behavior.ts b/src/mol-plugin/behavior/dynamic/volume-streaming/behavior.ts
index 2ad87f7ff..e7b357d9b 100644
--- a/src/mol-plugin/behavior/dynamic/volume-streaming/behavior.ts
+++ b/src/mol-plugin/behavior/dynamic/volume-streaming/behavior.ts
@@ -22,6 +22,7 @@ import { VolumeServerHeader, VolumeServerInfo } from './model';
 import { ButtonsType } from 'mol-util/input/input-observer';
 import { PluginCommands } from 'mol-plugin/command';
 import { StateSelection } from 'mol-state';
+import { Representation } from 'mol-repr/representation';
 
 export class VolumeStreaming extends PluginStateObject.CreateBehavior<VolumeStreaming.Behavior>({ name: 'Volume Streaming' }) { }
 
@@ -172,7 +173,21 @@ export namespace VolumeStreaming {
         }
 
         register(ref: string): void {
-            // this.ref = ref;
+            let lastLoci: Representation.Loci = Representation.Loci.Empty;
+
+            this.subscribeObservable(this.plugin.events.state.object.removed, o => {
+                if (!PluginStateObject.Molecule.Structure.is(o.obj) || lastLoci.loci.kind !== 'element-loci') return;
+                if (lastLoci.loci.structure === o.obj.data) {
+                    lastLoci = Representation.Loci.Empty;
+                }
+            });
+
+            this.subscribeObservable(this.plugin.events.state.object.updated, o => {
+                if (!PluginStateObject.Molecule.Structure.is(o.oldObj) || lastLoci.loci.kind !== 'element-loci') return;
+                if (lastLoci.loci.structure === o.oldObj.data) {
+                    lastLoci = Representation.Loci.Empty;
+                }
+            });
 
             this.subscribeObservable(this.plugin.behaviors.canvas3d.click, ({ current, buttons, modifiers }) => {
                 if (buttons !== ButtonsType.Flag.Secondary || this.params.view.name !== 'selection-box') return;
@@ -193,6 +208,13 @@ export namespace VolumeStreaming {
                 const root = this.getStructureRoot(ref);
                 if (!root || !root.obj || root.obj !== parent.obj) return;
 
+                if (Representation.Loci.areEqual(lastLoci, current)) {
+                    lastLoci = Representation.Loci.Empty;
+                    this.updateDynamicBox(ref, Box3D.empty());
+                    return;
+                }
+                lastLoci = current;
+
                 const loci = StructureElement.Loci.extendToWholeResidues(current.loci);
                 const box = StructureElement.Loci.getBoundary(loci).box;
                 this.updateDynamicBox(ref, box);
diff --git a/src/mol-plugin/skin/base/components/temp.scss b/src/mol-plugin/skin/base/components/temp.scss
index 8913fd5d3..9d20d320f 100644
--- a/src/mol-plugin/skin/base/components/temp.scss
+++ b/src/mol-plugin/skin/base/components/temp.scss
@@ -180,11 +180,15 @@
         line-height: $row-height;
         float: left;
         margin-right: $control-spacing;
-        background-color: $msp-form-control-background;
+
+        > button {
+            background-color: $msp-form-control-background;
+        }
 
         > select {
             display: inline-block;
             width: 200px;
+            margin-right: $control-spacing;
         }
     }
 
-- 
GitLab