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
02dd5f9d
Commit
02dd5f9d
authored
5 years ago
by
Alexander Rose
Browse files
Options
Downloads
Patches
Plain Diff
fix, set new source in StructureRepresentation3D.update
parent
3685c92b
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/mol-plugin/state/transforms/representation.ts
+67
-10
67 additions, 10 deletions
src/mol-plugin/state/transforms/representation.ts
with
67 additions
and
10 deletions
src/mol-plugin/state/transforms/representation.ts
+
67
−
10
View file @
02dd5f9d
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
* @author Alexander Rose <alexander.rose@weirdbyte.de>
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
*/
import
{
Structure
}
from
'
../../../mol-model/structure
'
;
import
{
Structure
,
StructureElement
}
from
'
../../../mol-model/structure
'
;
import
{
VolumeData
,
VolumeIsoValue
}
from
'
../../../mol-model/volume
'
;
import
{
VolumeData
,
VolumeIsoValue
}
from
'
../../../mol-model/volume
'
;
import
{
PluginContext
}
from
'
../../../mol-plugin/context
'
;
import
{
PluginContext
}
from
'
../../../mol-plugin/context
'
;
import
{
RepresentationProvider
}
from
'
../../../mol-repr/representation
'
;
import
{
RepresentationProvider
}
from
'
../../../mol-repr/representation
'
;
...
@@ -29,7 +29,7 @@ import { unwindStructureAssembly, explodeStructure } from '../animation/helpers'
...
@@ -29,7 +29,7 @@ import { unwindStructureAssembly, explodeStructure } from '../animation/helpers'
import
{
Color
}
from
'
../../../mol-util/color
'
;
import
{
Color
}
from
'
../../../mol-util/color
'
;
import
{
Overpaint
}
from
'
../../../mol-theme/overpaint
'
;
import
{
Overpaint
}
from
'
../../../mol-theme/overpaint
'
;
import
{
Transparency
}
from
'
../../../mol-theme/transparency
'
;
import
{
Transparency
}
from
'
../../../mol-theme/transparency
'
;
import
{
getStructureOverpaint
,
getStructureTransparency
}
from
'
./helpers
'
;
import
{
getStructureOverpaint
FromScript
,
getStructureOverpaintFromBundle
,
getStructureTransparency
}
from
'
./helpers
'
;
import
{
BaseGeometry
}
from
'
../../../mol-geo/geometry/base
'
;
import
{
BaseGeometry
}
from
'
../../../mol-geo/geometry/base
'
;
export
{
StructureRepresentation3D
}
export
{
StructureRepresentation3D
}
...
@@ -37,7 +37,8 @@ export { StructureRepresentation3DHelpers }
...
@@ -37,7 +37,8 @@ export { StructureRepresentation3DHelpers }
export
{
StructureLabels3D
}
export
{
StructureLabels3D
}
export
{
ExplodeStructureRepresentation3D
}
export
{
ExplodeStructureRepresentation3D
}
export
{
UnwindStructureAssemblyRepresentation3D
}
export
{
UnwindStructureAssemblyRepresentation3D
}
export
{
OverpaintStructureRepresentation3D
}
export
{
OverpaintStructureRepresentation3DFromScript
}
export
{
OverpaintStructureRepresentation3DFromBundle
}
export
{
TransparencyStructureRepresentation3D
}
export
{
TransparencyStructureRepresentation3D
}
export
{
VolumeRepresentation3D
}
export
{
VolumeRepresentation3D
}
...
@@ -191,6 +192,7 @@ const StructureRepresentation3D = PluginStateTransform.BuiltIn({
...
@@ -191,6 +192,7 @@ const StructureRepresentation3D = PluginStateTransform.BuiltIn({
const
props
=
{
...
b
.
data
.
repr
.
props
,
...
newParams
.
type
.
params
}
const
props
=
{
...
b
.
data
.
repr
.
props
,
...
newParams
.
type
.
params
}
b
.
data
.
repr
.
setTheme
(
createTheme
(
plugin
.
structureRepresentation
.
themeCtx
,
{
structure
:
a
.
data
},
newParams
));
b
.
data
.
repr
.
setTheme
(
createTheme
(
plugin
.
structureRepresentation
.
themeCtx
,
{
structure
:
a
.
data
},
newParams
));
await
b
.
data
.
repr
.
createOrUpdate
(
props
,
a
.
data
).
runInContext
(
ctx
);
await
b
.
data
.
repr
.
createOrUpdate
(
props
,
a
.
data
).
runInContext
(
ctx
);
b
.
data
.
source
=
a
return
StateTransformer
.
UpdateResult
.
Updated
;
return
StateTransformer
.
UpdateResult
.
Updated
;
});
});
},
},
...
@@ -324,9 +326,9 @@ const ExplodeStructureRepresentation3D = PluginStateTransform.BuiltIn({
...
@@ -324,9 +326,9 @@ const ExplodeStructureRepresentation3D = PluginStateTransform.BuiltIn({
}
}
});
});
type
OverpaintStructureRepresentation3D
=
typeof
OverpaintStructureRepresentation3D
type
OverpaintStructureRepresentation3D
FromScript
=
typeof
OverpaintStructureRepresentation3D
FromScript
const
OverpaintStructureRepresentation3D
=
PluginStateTransform
.
BuiltIn
({
const
OverpaintStructureRepresentation3D
FromScript
=
PluginStateTransform
.
BuiltIn
({
name
:
'
overpaint-structure-representation-3d
'
,
name
:
'
overpaint-structure-representation-3d
-from-script
'
,
display
:
'
Overpaint 3D Representation
'
,
display
:
'
Overpaint 3D Representation
'
,
from
:
SO
.
Molecule
.
Structure
.
Representation3D
,
from
:
SO
.
Molecule
.
Structure
.
Representation3D
,
to
:
SO
.
Molecule
.
Structure
.
Representation3DState
,
to
:
SO
.
Molecule
.
Structure
.
Representation3DState
,
...
@@ -350,7 +352,7 @@ const OverpaintStructureRepresentation3D = PluginStateTransform.BuiltIn({
...
@@ -350,7 +352,7 @@ const OverpaintStructureRepresentation3D = PluginStateTransform.BuiltIn({
},
},
apply
({
a
,
params
})
{
apply
({
a
,
params
})
{
const
structure
=
a
.
data
.
source
.
data
const
structure
=
a
.
data
.
source
.
data
const
overpaint
=
getStructureOverpaint
(
structure
,
params
.
layers
,
params
.
alpha
)
const
overpaint
=
getStructureOverpaint
FromScript
(
structure
,
params
.
layers
,
params
.
alpha
)
return
new
SO
.
Molecule
.
Structure
.
Representation3DState
({
return
new
SO
.
Molecule
.
Structure
.
Representation3DState
({
state
:
{
overpaint
},
state
:
{
overpaint
},
...
@@ -360,10 +362,65 @@ const OverpaintStructureRepresentation3D = PluginStateTransform.BuiltIn({
...
@@ -360,10 +362,65 @@ const OverpaintStructureRepresentation3D = PluginStateTransform.BuiltIn({
},
{
label
:
`Overpaint (
${
overpaint
.
layers
.
length
}
Layers)`
})
},
{
label
:
`Overpaint (
${
overpaint
.
layers
.
length
}
Layers)`
})
},
},
update
({
a
,
b
,
newParams
,
oldParams
})
{
update
({
a
,
b
,
newParams
,
oldParams
})
{
const
structure
=
b
.
data
.
info
as
Structure
const
oldStructure
=
b
.
data
.
info
as
Structure
if
(
a
.
data
.
source
.
data
!==
structure
)
return
StateTransformer
.
UpdateResult
.
Recreate
const
newStructure
=
a
.
data
.
source
.
data
if
(
newStructure
!==
oldStructure
)
return
StateTransformer
.
UpdateResult
.
Recreate
const
oldOverpaint
=
b
.
data
.
state
.
overpaint
!
const
newOverpaint
=
getStructureOverpaintFromScript
(
newStructure
,
newParams
.
layers
,
newParams
.
alpha
)
if
(
oldParams
.
alpha
===
newParams
.
alpha
&&
Overpaint
.
areEqual
(
oldOverpaint
,
newOverpaint
))
return
StateTransformer
.
UpdateResult
.
Unchanged
b
.
data
.
state
.
overpaint
=
newOverpaint
b
.
data
.
source
=
a
b
.
label
=
`Overpaint (
${
newOverpaint
.
layers
.
length
}
Layers)`
return
StateTransformer
.
UpdateResult
.
Updated
}
});
type
OverpaintStructureRepresentation3DFromBundle
=
typeof
OverpaintStructureRepresentation3DFromBundle
const
OverpaintStructureRepresentation3DFromBundle
=
PluginStateTransform
.
BuiltIn
({
name
:
'
overpaint-structure-representation-3d-from-bundle
'
,
display
:
'
Overpaint 3D Representation
'
,
from
:
SO
.
Molecule
.
Structure
.
Representation3D
,
to
:
SO
.
Molecule
.
Structure
.
Representation3DState
,
params
:
{
layers
:
PD
.
ObjectList
({
bundle
:
PD
.
Value
<
StructureElement
.
Bundle
>
(
StructureElement
.
Bundle
.
Empty
),
color
:
PD
.
Color
(
ColorNames
.
blueviolet
),
clear
:
PD
.
Boolean
(
false
)
},
e
=>
`
${
e
.
clear
?
'
Clear
'
:
Color
.
toRgbString
(
e
.
color
)}
`
,
{
defaultValue
:
[{
bundle
:
StructureElement
.
Bundle
.
Empty
,
color
:
ColorNames
.
blueviolet
,
clear
:
false
}],
isHidden
:
true
}),
alpha
:
PD
.
Numeric
(
1
,
{
min
:
0
,
max
:
1
,
step
:
0.01
},
{
label
:
'
Opacity
'
}),
}
})({
canAutoUpdate
()
{
return
true
;
},
apply
({
a
,
params
})
{
console
.
log
(
'
apply
'
,
{
a
,
params
})
const
structure
=
a
.
data
.
source
.
data
const
overpaint
=
getStructureOverpaintFromBundle
(
structure
,
params
.
layers
,
params
.
alpha
)
return
new
SO
.
Molecule
.
Structure
.
Representation3DState
({
state
:
{
overpaint
},
initialState
:
{
overpaint
:
Overpaint
.
Empty
},
info
:
structure
,
source
:
a
},
{
label
:
`Overpaint (
${
overpaint
.
layers
.
length
}
Layers)`
})
},
update
({
a
,
b
,
newParams
,
oldParams
})
{
console
.
log
(
'
update
'
,
{
a
,
b
,
newParams
,
oldParams
})
const
oldStructure
=
b
.
data
.
info
as
Structure
const
newStructure
=
a
.
data
.
source
.
data
console
.
log
()
if
(
newStructure
!==
oldStructure
)
return
StateTransformer
.
UpdateResult
.
Recreate
const
oldOverpaint
=
b
.
data
.
state
.
overpaint
!
const
oldOverpaint
=
b
.
data
.
state
.
overpaint
!
const
newOverpaint
=
getStructureOverpaint
(
s
tructure
,
newParams
.
layers
,
newParams
.
alpha
)
const
newOverpaint
=
getStructureOverpaint
FromBundle
(
newS
tructure
,
newParams
.
layers
,
newParams
.
alpha
)
if
(
oldParams
.
alpha
===
newParams
.
alpha
&&
Overpaint
.
areEqual
(
oldOverpaint
,
newOverpaint
))
return
StateTransformer
.
UpdateResult
.
Unchanged
if
(
oldParams
.
alpha
===
newParams
.
alpha
&&
Overpaint
.
areEqual
(
oldOverpaint
,
newOverpaint
))
return
StateTransformer
.
UpdateResult
.
Unchanged
b
.
data
.
state
.
overpaint
=
newOverpaint
b
.
data
.
state
.
overpaint
=
newOverpaint
...
...
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