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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michal Malý
Molstar
Commits
03067ca6
Commit
03067ca6
authored
5 years ago
by
Alexander Rose
Browse files
Options
Downloads
Patches
Plain Diff
wip, structure tools quality option
parent
a69f1337
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/mol-plugin/ui/structure/representation.tsx
+14
-6
14 additions, 6 deletions
src/mol-plugin/ui/structure/representation.tsx
src/mol-plugin/util/structure-representation-helper.ts
+40
-19
40 additions, 19 deletions
src/mol-plugin/util/structure-representation-helper.ts
with
54 additions
and
25 deletions
src/mol-plugin/ui/structure/representation.tsx
+
14
−
6
View file @
03067ca6
...
...
@@ -12,6 +12,7 @@ import { ColorOptions, ParameterControls } from '../controls/parameters';
import
{
Color
}
from
'
../../../mol-util/color
'
;
import
{
ButtonSelect
,
Options
}
from
'
../controls/common
'
import
{
ParamDefinition
as
PD
}
from
'
../../../mol-util/param-definition
'
;
import
{
VisualQuality
,
VisualQualityOptions
}
from
'
../../../mol-geo/geometry/base
'
;
abstract
class
BaseStructureRepresentationControls
extends
PluginUIComponent
{
onChange
=
(
value
:
string
)
=>
{
...
...
@@ -94,23 +95,30 @@ export class StructureRepresentationControls extends PluginUIComponent {
}
onChange
=
async
(
p
:
{
param
:
PD
.
Base
<
any
>
,
name
:
string
,
value
:
any
})
=>
{
if
(
p
.
name
===
'
showHydrogens
'
)
{
await
this
.
plugin
.
helpers
.
structureRepresentation
.
setIgnoreHydrogens
(
!
p
.
value
)
if
(
p
.
name
===
'
options
'
)
{
await
this
.
plugin
.
helpers
.
structureRepresentation
.
setIgnoreHydrogens
(
!
p
.
value
.
showHydrogens
)
await
this
.
plugin
.
helpers
.
structureRepresentation
.
setQuality
(
p
.
value
.
visualQuality
)
this
.
forceUpdate
()
}
this
.
forceUpdate
()
}
get
params
()
{
const
values
=
this
.
values
const
{
options
}
=
this
.
values
return
{
showHydrogens
:
PD
.
Boolean
(
values
.
showHydrogens
)
options
:
PD
.
Group
({
showHydrogens
:
PD
.
Boolean
(
options
.
showHydrogens
),
visualQuality
:
PD
.
Select
<
VisualQuality
>
(
options
.
visualQuality
,
VisualQualityOptions
),
},
{
isExpanded
:
true
})
}
}
get
values
()
{
const
{
structureRepresentation
:
rep
}
=
this
.
plugin
.
helpers
return
{
showHydrogens
:
!
rep
.
ignoreHydrogens
options
:
{
showHydrogens
:
!
rep
.
ignoreHydrogens
,
visualQuality
:
rep
.
quality
,
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/mol-plugin/util/structure-representation-helper.ts
+
40
−
19
View file @
03067ca6
...
...
@@ -6,7 +6,7 @@
import
{
PluginStateObject
as
PSO
}
from
'
../../mol-plugin/state/objects
'
;
import
{
StateTransforms
}
from
'
../../mol-plugin/state/transforms
'
;
import
{
StateTransformer
,
StateSelection
,
StateObjectCell
,
StateTransform
}
from
'
../../mol-state
'
;
import
{
StateTransformer
,
StateSelection
,
StateObjectCell
,
StateTransform
,
StateBuilder
}
from
'
../../mol-state
'
;
import
{
StructureElement
,
Structure
,
StructureSelection
,
QueryContext
}
from
'
../../mol-model/structure
'
;
import
{
PluginContext
}
from
'
../context
'
;
import
{
StructureRepresentation3DHelpers
}
from
'
../state/transforms/representation
'
;
...
...
@@ -14,8 +14,10 @@ import Expression from '../../mol-script/language/expression';
import
{
compile
}
from
'
../../mol-script/runtime/query/compiler
'
;
import
{
StructureSelectionQueries
as
Q
}
from
'
../util/structure-selection-helper
'
;
import
{
MolScriptBuilder
as
MS
}
from
'
../../mol-script/language/builder
'
;
import
{
VisualQuality
}
from
'
../../mol-geo/geometry/base
'
;
type
StructureTransform
=
StateObjectCell
<
PSO
.
Molecule
.
Structure
,
StateTransform
<
StateTransformer
<
any
,
PSO
.
Molecule
.
Structure
,
any
>>>
type
RepresentationTransform
=
StateObjectCell
<
PSO
.
Molecule
.
Structure
.
Representation3D
,
StateTransform
<
StateTransformer
<
any
,
PSO
.
Molecule
.
Structure
.
Representation3D
,
any
>>>
const
RepresentationManagerTag
=
'
representation-controls
'
export
function
getRepresentationManagerTag
(
type
:
string
)
{
...
...
@@ -65,9 +67,10 @@ export class StructureRepresentationHelper {
}
else
{
const
combinedLoci
=
getCombinedLoci
(
modifier
,
loci
,
StructureElement
.
Loci
(
s
,
[]))
const
params
=
StructureRepresentation3DHelpers
.
getDefaultParams
(
this
.
plugin
,
type
as
any
,
s
)
if
(
params
.
type
.
params
.
ignoreHydrogens
!==
undefined
)
{
params
.
type
.
params
.
ignoreHydrogens
=
this
.
_ignoreHydrogens
}
const
p
=
params
.
type
.
params
if
(
p
.
ignoreHydrogens
!==
undefined
)
p
.
ignoreHydrogens
=
this
.
_ignoreHydrogens
if
(
p
.
quality
!==
undefined
)
p
.
quality
=
this
.
_quality
update
.
to
(
structure
.
transform
.
ref
)
.
apply
(
...
...
@@ -119,34 +122,52 @@ export class StructureRepresentationHelper {
await
this
.
plugin
.
runTask
(
state
.
updateTree
(
update
,
{
doNotUpdateCurrent
:
true
}))
}
private
_ignoreHydrogens
=
false
get
ignoreHydrogens
()
{
return
this
.
_ignoreHydrogens
}
async
setIgnoreHydrogens
(
ignoreHydrogens
:
boolean
)
{
if
(
ignoreHydrogens
===
this
.
_ignoreHydrogens
)
return
async
eachRepresentation
(
callback
:
(
repr
:
RepresentationTransform
,
update
:
StateBuilder
.
Root
)
=>
void
)
{
const
{
registry
}
=
this
.
plugin
.
structureRepresentation
const
state
=
this
.
plugin
.
state
.
dataState
;
const
update
=
state
.
build
()
const
structures
=
state
.
select
(
StateSelection
.
Generators
.
rootsOfType
(
PSO
.
Molecule
.
Structure
))
for
(
const
structure
of
structures
)
{
for
(
let
i
=
0
,
il
=
registry
.
types
.
length
;
i
<
il
;
++
i
)
{
const
type
=
registry
.
types
[
i
][
0
]
const
repr
=
this
.
getRepresentation
(
structure
.
transform
.
ref
,
type
)
if
(
repr
&&
repr
.
params
&&
repr
.
params
.
values
.
type
.
params
.
ignoreHydrogens
!==
undefined
)
{
const
{
name
,
params
}
=
repr
.
params
.
values
.
type
update
.
to
(
repr
.
transform
.
ref
).
update
(
StateTransforms
.
Representation
.
StructureRepresentation3D
,
props
=>
({
...
props
,
type
:
{
name
,
params
:
{
...
params
,
ignoreHydrogens
}}})
)
}
const
repr
=
this
.
getRepresentation
(
structure
.
transform
.
ref
,
registry
.
types
[
i
][
0
])
if
(
repr
)
callback
(
repr
,
update
)
}
}
await
this
.
plugin
.
runTask
(
state
.
updateTree
(
update
,
{
doNotUpdateCurrent
:
true
}))
}
private
_ignoreHydrogens
=
false
get
ignoreHydrogens
()
{
return
this
.
_ignoreHydrogens
}
async
setIgnoreHydrogens
(
ignoreHydrogens
:
boolean
)
{
if
(
ignoreHydrogens
===
this
.
_ignoreHydrogens
)
return
await
this
.
eachRepresentation
((
repr
,
update
)
=>
{
if
(
repr
.
params
&&
repr
.
params
.
values
.
type
.
params
.
ignoreHydrogens
!==
undefined
)
{
const
{
name
,
params
}
=
repr
.
params
.
values
.
type
update
.
to
(
repr
.
transform
.
ref
).
update
(
StateTransforms
.
Representation
.
StructureRepresentation3D
,
props
=>
({
...
props
,
type
:
{
name
,
params
:
{
...
params
,
ignoreHydrogens
}}})
)
}
})
this
.
_ignoreHydrogens
=
ignoreHydrogens
}
private
_quality
=
'
auto
'
as
VisualQuality
get
quality
()
{
return
this
.
_quality
}
async
setQuality
(
quality
:
VisualQuality
)
{
if
(
quality
===
this
.
_quality
)
return
await
this
.
eachRepresentation
((
repr
,
update
)
=>
{
if
(
repr
.
params
&&
repr
.
params
.
values
.
type
.
params
.
quality
!==
undefined
)
{
const
{
name
,
params
}
=
repr
.
params
.
values
.
type
update
.
to
(
repr
.
transform
.
ref
).
update
(
StateTransforms
.
Representation
.
StructureRepresentation3D
,
props
=>
({
...
props
,
type
:
{
name
,
params
:
{
...
params
,
quality
}}})
)
}
})
this
.
_quality
=
quality
}
async
preset
()
{
// TODO generalize and make configurable
await
this
.
clear
()
...
...
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