Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Molstar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michal Malý
Molstar
Commits
78cc0d96
Commit
78cc0d96
authored
3 years ago
by
Michal Malý
Browse files
Options
Downloads
Patches
Plain Diff
Show the order of locis to be used for measurements in 3D view
parent
7f39cf0f
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/mol-plugin-state/manager/structure/measurement.ts
+45
-1
45 additions, 1 deletion
src/mol-plugin-state/manager/structure/measurement.ts
src/mol-plugin-ui/structure/measurements.tsx
+28
-1
28 additions, 1 deletion
src/mol-plugin-ui/structure/measurements.tsx
with
73 additions
and
2 deletions
src/mol-plugin-state/manager/structure/measurement.ts
+
45
−
1
View file @
78cc0d96
...
...
@@ -17,10 +17,12 @@ import { ParamDefinition as PD } from '../../../mol-util/param-definition';
import
{
MeasurementRepresentationCommonTextParams
,
LociLabelTextParams
}
from
'
../../../mol-repr/shape/loci/common
'
;
import
{
LineParams
}
from
'
../../../mol-repr/structure/representation/line
'
;
import
{
Expression
}
from
'
../../../mol-script/language/expression
'
;
import
{
Color
}
from
'
../../../mol-util/color
'
;
export
{
StructureMeasurementManager
};
export
const
MeasurementGroupTag
=
'
measurement-group
'
;
export
const
MeasurementOrderLabelTag
=
'
measurement-order-label
'
;
export
type
StructureMeasurementCell
=
StateObjectCell
<
PluginStateObject
.
Shape
.
Representation3D
,
StateTransform
<
StateTransformer
<
PluginStateObject
.
Molecule
.
Structure
.
Selections
,
PluginStateObject
.
Shape
.
Representation3D
,
any
>>>
...
...
@@ -281,6 +283,41 @@ class StructureMeasurementManager extends StatefulPluginComponent<StructureMeasu
await
PluginCommands
.
State
.
Update
(
this
.
plugin
,
{
state
,
tree
:
update
,
options
:
{
doNotLogTiming
:
true
}
});
}
async
addOrderLabels
(
locis
:
StructureElement
.
Loci
[])
{
const
update
=
this
.
getGroup
();
const
current
=
this
.
plugin
.
state
.
data
.
select
(
StateSelection
.
Generators
.
ofType
(
PluginStateObject
.
Molecule
.
Structure
.
Selections
).
withTag
(
MeasurementOrderLabelTag
));
for
(
const
obj
of
current
)
update
.
delete
(
obj
);
let
order
=
1
;
for
(
const
loci
of
locis
)
{
const
cell
=
this
.
plugin
.
helpers
.
substructureParent
.
get
(
loci
.
structure
);
if
(
!
cell
)
continue
;
const
dependsOn
=
[
cell
.
transform
.
ref
];
update
.
apply
(
StateTransforms
.
Model
.
MultiStructureSelectionFromExpression
,
{
selections
:
[
{
key
:
'
a
'
,
ref
:
cell
.
transform
.
ref
,
expression
:
StructureElement
.
Loci
.
toExpression
(
loci
)
},
],
isTransitive
:
true
,
label
:
'
Order
'
},
{
dependsOn
,
tags
:
MeasurementOrderLabelTag
})
.
apply
(
StateTransforms
.
Representation
.
StructureSelectionsLabel3D
,
{
textColor
:
Color
.
fromRgb
(
255
,
255
,
255
),
borderColor
:
Color
.
fromRgb
(
0
,
0
,
0
),
borderWidth
:
0.5
,
textSize
:
0.33
,
customText
:
`
${
order
++
}
`
},
{
tags
:
MeasurementOrderLabelTag
});
}
const
state
=
this
.
plugin
.
state
.
data
;
await
PluginCommands
.
State
.
Update
(
this
.
plugin
,
{
state
,
tree
:
update
,
options
:
{
doNotLogTiming
:
true
}
});
}
private
_empty
:
any
[]
=
[];
private
getTransforms
<
T
extends
StateTransformer
<
A
,
B
,
any
>
,
A
extends
PluginStateObject
.
Molecule
.
Structure
.
Selections
,
B
extends
StateObject
>
(
transformer
:
T
)
{
const
state
=
this
.
plugin
.
state
.
data
;
...
...
@@ -291,8 +328,15 @@ class StructureMeasurementManager extends StatefulPluginComponent<StructureMeasu
}
private
sync
()
{
const
labels
=
[];
for
(
const
cell
of
this
.
getTransforms
(
StateTransforms
.
Representation
.
StructureSelectionsLabel3D
)
as
StructureMeasurementCell
[])
{
const
tags
=
(
cell
.
obj
as
any
)[
'
tags
'
]
as
string
[];
if
(
!
tags
||
!
tags
.
includes
(
MeasurementOrderLabelTag
))
labels
.
push
(
cell
);
}
const
updated
=
this
.
updateState
({
labels
:
this
.
getTransforms
(
StateTransforms
.
Representation
.
StructureSelectionsLabel3D
)
,
labels
,
distances
:
this
.
getTransforms
(
StateTransforms
.
Representation
.
StructureSelectionsDistance3D
),
angles
:
this
.
getTransforms
(
StateTransforms
.
Representation
.
StructureSelectionsAngle3D
),
dihedrals
:
this
.
getTransforms
(
StateTransforms
.
Representation
.
StructureSelectionsDihedral3D
),
...
...
This diff is collapsed.
Click to expand it.
src/mol-plugin-ui/structure/measurements.tsx
+
28
−
1
View file @
78cc0d96
...
...
@@ -62,7 +62,6 @@ export class MeasurementList extends PurePluginUIComponent {
render
()
{
const
measurements
=
this
.
plugin
.
managers
.
structure
.
measurement
.
state
;
return
<
div
style
=
{
{
marginTop
:
'
6px
'
}
}
>
{
this
.
renderGroup
(
measurements
.
labels
,
'
Labels
'
)
}
{
this
.
renderGroup
(
measurements
.
distances
,
'
Distances
'
)
}
...
...
@@ -80,6 +79,7 @@ export class MeasurementControls extends PurePluginUIComponent<{}, { isBusy: boo
componentDidMount
()
{
this
.
subscribe
(
this
.
selection
.
events
.
additionsHistoryUpdated
,
()
=>
{
this
.
forceUpdate
();
this
.
updateOrderLabels
();
});
this
.
subscribe
(
this
.
plugin
.
behaviors
.
state
.
isBusy
,
v
=>
{
...
...
@@ -87,6 +87,33 @@ export class MeasurementControls extends PurePluginUIComponent<{}, { isBusy: boo
});
}
componentWillUnmount
()
{
this
.
clearOrderLabels
();
super
.
componentWillUnmount
();
}
componentDidUpdate
(
prevProps
:
{},
prevState
:
{
isBusy
:
boolean
,
action
?:
'
add
'
|
'
options
'
})
{
if
(
this
.
state
.
action
!==
prevState
.
action
)
this
.
updateOrderLabels
();
}
clearOrderLabels
()
{
this
.
plugin
.
managers
.
structure
.
measurement
.
addOrderLabels
([]);
}
updateOrderLabels
()
{
if
(
this
.
state
.
action
!==
'
add
'
)
{
this
.
clearOrderLabels
();
return
;
}
const
locis
=
[];
const
history
=
this
.
selection
.
additionsHistory
;
for
(
let
idx
=
0
;
idx
<
history
.
length
&&
idx
<
4
;
idx
++
)
locis
.
push
(
history
[
idx
].
loci
);
this
.
plugin
.
managers
.
structure
.
measurement
.
addOrderLabels
(
locis
);
}
get
selection
()
{
return
this
.
plugin
.
managers
.
structure
.
selection
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment