Ver Fonte

seperated camera and repr focus more; always do camera focus with primary-alt

Alexander Rose há 4 anos atrás
pai
commit
19016b6730

+ 3 - 2
src/mol-plugin-ui/structure/focus.tsx

@@ -187,11 +187,12 @@ export class StructureFocusControls extends PluginUIComponent<{}, StructureFocus
         } else {
             this.plugin.managers.structure.focus.set(f);
         }
+        this.focusCamera();
     }
 
     toggleAction = () => this.setState({ showAction: !this.state.showAction })
 
-    focus = () => {
+    focusCamera = () => {
         const { current } = this.plugin.managers.structure.focus;
         if (current) this.plugin.managers.camera.focusLoci(current.loci);
     }
@@ -233,7 +234,7 @@ export class StructureFocusControls extends PluginUIComponent<{}, StructureFocus
 
         return <>
             <div className='msp-flex-row'>
-                <Button noOverflow onClick={this.focus} title={title} onMouseEnter={this.highlightCurrent} onMouseLeave={this.clearHighlights} disabled={this.isDisabled || !current}
+                <Button noOverflow onClick={this.focusCamera} title={title} onMouseEnter={this.highlightCurrent} onMouseLeave={this.clearHighlights} disabled={this.isDisabled || !current}
                     style={{ textAlignLast: current ? 'left' : void 0 }}>
                     {label}
                 </Button>

+ 4 - 10
src/mol-plugin/behavior/dynamic/camera.ts

@@ -11,7 +11,6 @@ import { PluginBehavior } from '../behavior';
 import { ButtonsType, ModifiersKeys } from '../../../mol-util/input/input-observer';
 import { Binding } from '../../../mol-util/binding';
 import { PluginCommands } from '../../commands';
-import { Structure, StructureElement, Bond } from '../../../mol-model/structure';
 
 const B = ButtonsType;
 const M = ModifiersKeys;
@@ -19,10 +18,11 @@ const Trigger = Binding.Trigger;
 
 const DefaultFocusLociBindings = {
     clickCenterFocus: Binding([
-        Trigger(B.Flag.Primary, M.create())
+        Trigger(B.Flag.Primary, M.create()),
+        Trigger(B.Flag.Primary, M.create({ alt: true }))
     ], 'Camera center and focus', 'Click element using ${triggers}'),
     clickCenterFocusSelectMode: Binding([
-        Trigger(B.Flag.Auxilary, M.create()),
+        Trigger(B.Flag.Secondary, M.create()),
         Trigger(B.Flag.Primary, M.create({ alt: true }))
     ], 'Camera center and focus', 'Click element using ${triggers}'),
 };
@@ -53,14 +53,8 @@ export const FocusLoci = PluginBehavior.create<FocusLociProps>({
                         return;
                     }
 
-                    // The focus is handled in structure-focus-representation
-                    // TODO: is there a better solution for structure-based loci?
-
                     const loci = Loci.normalize(current.loci, this.ctx.managers.interactivity.props.granularity);
-
-                    if (!Structure.isLoci(loci) && !StructureElement.Loci.is(loci) && !Bond.isLoci(loci)) {
-                        this.ctx.managers.camera.focusLoci(loci, this.params);
-                    }
+                    this.ctx.managers.camera.focusLoci(loci, this.params);
                 }
             });
         }

+ 5 - 4
src/mol-plugin/behavior/dynamic/representation.ts

@@ -15,7 +15,7 @@ import { StateSelection } from '../../../mol-state';
 import { ButtonsType, ModifiersKeys } from '../../../mol-util/input/input-observer';
 import { Binding } from '../../../mol-util/binding';
 import { ParamDefinition as PD } from '../../../mol-util/param-definition';
-import { EmptyLoci, Loci, isEmptyLoci } from '../../../mol-model/loci';
+import { EmptyLoci, Loci } from '../../../mol-model/loci';
 import { Structure, StructureElement, StructureProperties } from '../../../mol-model/structure';
 import { arrayMax } from '../../../mol-util/array';
 import { Representation } from '../../../mol-repr/representation';
@@ -243,9 +243,10 @@ export const FocusLoci = PluginBehavior.create<FocusLociProps>({
                             this.ctx.managers.structure.focus.setFromLoci(loci);
                         } else {
                             this.ctx.managers.structure.focus.addFromLoci(loci);
-                        }
-                        if (isEmptyLoci(loci)) {
-                            this.ctx.managers.camera.reset();
+
+                            // focus-add is not handled in camera behavior, doing it here
+                            const current = this.ctx.managers.structure.focus.current?.loci;
+                            if (current) this.ctx.managers.camera.focusLoci(current);
                         }
                     }
                     return;

+ 0 - 2
src/mol-plugin/behavior/dynamic/selection/structure-focus-representation.ts

@@ -142,8 +142,6 @@ export class StructureFocusRepresentationBehavior extends PluginBehavior.WithSub
         builder.to(refs[StructureFocusRepresentationTags.SurrSel]!).update(StateTransforms.Model.StructureSelectionFromExpression, old => ({ ...old, expression: surroundings, label: this.surrLabel }));
 
         await PluginCommands.State.Update(this.plugin, { state, tree: builder, options: { doNotLogTiming: true, doNotUpdateCurrent: true } });
-
-        this.plugin.managers.camera.focusLoci(loci);
     }
 
     register(ref: string): void {