11<template >
22<div class =" structure-panel" >
33 <StructureViewerTooltip attach =" .structure-panel" />
4- <div class =" structure-wrapper" ref =" structurepanel" >
4+ <div class =" structure-wrapper" ref =" structurepanel" @mouseleave = " clearTimer " @mousedown = " isMouseDown = true " @mouseup = " isMouseDown = false " >
55 <StructureViewerToolbar
66 :isFullscreen =" isFullscreen"
77 :isSpinning =" isSpinning"
1616 style =" position : absolute ; bottom : 8px ;"
1717 />
1818 <div class =" structure-viewer" ref =" viewport" ></div >
19+ <div ref =" previewTooltip"
20+ v-show =" previewIndex >= 0"
21+ style =" position : absolute ;
22+ bottom : 48px ;
23+ left : 8px ;
24+ padding : 8px ;
25+ font-size : 12px ;
26+ background-color : rgba (0 , 0 , 0 , 0.4 );
27+ color : white
28+ "
29+ v-html =" refRes"
30+ >
31+ </div >
1932 </div >
2033</div >
2134</template >
@@ -25,7 +38,7 @@ import StructureViewerTooltip from './StructureViewerTooltip.vue';
2538import StructureViewerToolbar from ' ./StructureViewerToolbar.vue' ;
2639import StructureViewerMixin from ' ./StructureViewerMixin.vue' ;
2740import { tmalign , parse as parseTMOutput , parseMatrix as parseTMMatrix } from ' tmalign-wasm' ;
28- import { mockPDB , makeSubPDB , makeMatrix4 , getResidueIndices } from ' ./Utilities.js' ;
41+ import { mockPDB , makeSubPDB , makeMatrix4 , getResidueIndices , oneToThree } from ' ./Utilities.js' ;
2942import { download , PdbWriter , Matrix4 , Quaternion , Vector3 , concatStructures , ColormakerRegistry , Selection } from ' ngl' ;
3043import { pulchra } from ' pulchra-wasm' ;
3144
@@ -142,6 +155,9 @@ export default {
142155 ticking: false ,
143156 hoverTimer: null ,
144157 pendingColumn: - 1 ,
158+ registeredColumn: - 1 ,
159+ isMouseDown: false ,
160+ previewIndex: - 1 ,
145161 }),
146162 props: {
147163 entries: { type: Array , required: true },
@@ -169,6 +185,7 @@ export default {
169185 this .stage .setParameters ({
170186 hoverTimeout: 100 ,
171187 })
188+
172189 this .stage .signals .clicked .add ((pickingProxy ) => {
173190 if (! pickingProxy) {
174191 // this.selectedColumn = -1;
@@ -206,7 +223,7 @@ export default {
206223 });
207224
208225 this .stage .signals .hovered .add ((pickingProxy ) => {
209- if (! pickingProxy || ! pickingProxy .atom ) {
226+ if (this . isMouseDown || ! pickingProxy || ! pickingProxy .atom ) {
210227 this .clearTimer ()
211228 return ;
212229 }
@@ -222,7 +239,7 @@ export default {
222239 if (! this .ticking ) {
223240 this .ticking = true
224241 window .requestAnimationFrame (() => {
225- this .togglePreview ()
242+ this .togglePreview (index )
226243 this .ticking = false
227244 })
228245 }
@@ -490,6 +507,7 @@ ENDMDL
490507 })
491508 );
492509 this .updateMask ();
510+ this .clearTimer ()
493511 },
494512 async updateMask () {
495513 this .stage .eachRepresentation ((repr ) => {
@@ -585,24 +603,29 @@ ENDMDL
585603 let sele = String (resIdx + 1 - range) + " -" + (resIdx - 1 + range)
586604 comp .autoView (sele, 200 )
587605 },
588- setTimer (idx ) {
606+ setTimer (idx , structIdx ) {
607+ this .registeredColumn = idx;
589608 this .hoverTimer = setTimeout (() => {
590- console . log (idx, " fired " )
609+ this . previewIndex = structIdx
591610 this .$emit (' changePreview' , idx, true )
592- }, 1000 )
611+ this .registeredColumn = - 1
612+ }, 900 )
593613 },
594614 clearTimer () {
595615 if (this .hoverTimer ) {
596616 clearTimeout (this .hoverTimer )
597617 this .hoverTimer = null
598618 }
619+ this .previewIndex = - 1
599620 this .$emit (' changePreview' , - 1 , true )
600621 },
601- togglePreview () {
602- if (this .previewColumn == this .pendingColumn ) return
622+ togglePreview (index ) {
623+ if (this .previewColumn == this .pendingColumn
624+ || this .pendingColumn == this .registeredColumn
625+ ) return
603626
604627 this .clearTimer ()
605- this .setTimer (this .pendingColumn )
628+ this .setTimer (this .pendingColumn , index )
606629 },
607630 },
608631 watch: {
@@ -640,6 +663,21 @@ ENDMDL
640663 highLightColor () {
641664 return 0xe31986
642665 },
666+ refRes () {
667+ if (this .previewColumn < 0
668+ || this .previewIndex < 0 ) return " "
669+
670+ const targetObj = this .entries [this .previewIndex ]
671+ const name = targetObj .name ? .length > 12
672+ ? targetObj .name .slice (0 , 9 ) + ' ...'
673+ : targetObj .name
674+ const targetSeq = targetObj .aa
675+ const AA = oneToThree[targetSeq[this .previewColumn ]]
676+ const formatted = AA .charAt (0 ) + AA .toLowerCase ().slice (1 , 3 )
677+ const resNo = getResidueIndex (targetSeq, this .previewColumn ) + 1
678+ return ' <span>' + name + ' : </span><strong>'
679+ + formatted + String (resNo) + ' </strong>'
680+ },
643681 },
644682}
645683< / script>
0 commit comments