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
6059b0b9
Commit
6059b0b9
authored
6 years ago
by
Alexander Rose
Browse files
Options
Downloads
Patches
Plain Diff
add ValueCell.updateIfChanged
parent
99d2b1d4
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/mol-geo/representation/structure/spacefill.ts
+5
-13
5 additions, 13 deletions
src/mol-geo/representation/structure/spacefill.ts
src/mol-util/index.ts
+4
-4
4 additions, 4 deletions
src/mol-util/index.ts
src/mol-util/value-cell.ts
+6
-0
6 additions, 0 deletions
src/mol-util/value-cell.ts
with
15 additions
and
17 deletions
src/mol-geo/representation/structure/spacefill.ts
+
5
−
13
View file @
6059b0b9
...
...
@@ -161,19 +161,11 @@ export default function Spacefill(): UnitsRepresentation<SpacefillProps> {
createColors
(
currentGroup
,
vertexMap
,
newProps
.
colorTheme
,
spheres
.
values
)
}
// TODO handle in a generic way
if
(
spheres
.
values
.
uAlpha
.
ref
.
value
!==
newProps
.
alpha
)
{
ValueCell
.
update
(
spheres
.
values
.
uAlpha
,
newProps
.
alpha
)
}
if
(
spheres
.
values
.
dDoubleSided
.
ref
.
value
!==
newProps
.
doubleSided
)
{
ValueCell
.
update
(
spheres
.
values
.
dDoubleSided
,
newProps
.
doubleSided
)
}
if
(
spheres
.
values
.
dFlipSided
.
ref
.
value
!==
newProps
.
flipSided
)
{
ValueCell
.
update
(
spheres
.
values
.
dFlipSided
,
newProps
.
flipSided
)
}
if
(
spheres
.
values
.
dFlatShaded
.
ref
.
value
!==
newProps
.
flatShaded
)
{
ValueCell
.
update
(
spheres
.
values
.
dFlatShaded
,
newProps
.
flatShaded
)
}
ValueCell
.
updateIfChanged
(
spheres
.
values
.
uAlpha
,
newProps
.
alpha
)
ValueCell
.
updateIfChanged
(
spheres
.
values
.
dDoubleSided
,
newProps
.
doubleSided
)
ValueCell
.
updateIfChanged
(
spheres
.
values
.
dFlipSided
,
newProps
.
flipSided
)
ValueCell
.
updateIfChanged
(
spheres
.
values
.
dFlatShaded
,
newProps
.
flatShaded
)
spheres
.
state
.
visible
=
newProps
.
visible
spheres
.
state
.
depthMask
=
newProps
.
depthMask
...
...
This diff is collapsed.
Click to expand it.
src/mol-util/index.ts
+
4
−
4
View file @
6059b0b9
...
...
@@ -30,6 +30,8 @@ export function arrayEqual<T>(arr1: T[], arr2: T[]) {
return
true
}
const
hasOwnProperty
=
Object
.
prototype
.
hasOwnProperty
;
export
function
deepEqual
(
a
:
any
,
b
:
any
)
{
// from https://github.com/epoberezkin/fast-deep-equal MIT
if
(
a
===
b
)
return
true
;
...
...
@@ -62,7 +64,7 @@ export function deepEqual(a: any, b: any) {
if
(
regexpA
!==
regexpB
)
return
false
for
(
let
i
=
0
;
i
<
keys
.
length
;
i
++
)
{
if
(
!
Object
.
prototype
.
hasOwnProperty
.
call
(
b
,
keys
[
i
]))
return
false
if
(
!
hasOwnProperty
.
call
(
b
,
keys
[
i
]))
return
false
}
for
(
let
i
=
0
;
i
<
keys
.
length
;
i
++
)
{
...
...
@@ -75,8 +77,6 @@ export function deepEqual(a: any, b: any) {
return
false
}
const
hasOwnProperty
=
Object
.
prototype
.
hasOwnProperty
;
export
function
shallowEqual
<
T
>
(
a
:
T
,
b
:
T
)
{
if
(
!
a
)
{
if
(
!
b
)
return
true
;
...
...
@@ -170,7 +170,7 @@ function _shallowMerge<T>(source: T) {
return
ret
;
}
export
const
merge
:
(
<
T
>
(
source
:
T
,
...
rest
:
Partial
<
T
>
[])
=>
T
)
=
_shallowMerge
;
export
const
merge
:
(
<
T
>
(
source
:
T
,
...
rest
:
Partial
<
T
>
[])
=>
T
)
=
_shallowMerge
;
function
padTime
(
n
:
number
)
{
return
(
n
<
10
?
'
0
'
:
''
)
+
n
}
export
function
formatTime
(
d
:
Date
)
{
...
...
This diff is collapsed.
Click to expand it.
src/mol-util/value-cell.ts
+
6
−
0
View file @
6059b0b9
...
...
@@ -2,6 +2,7 @@
* Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author David Sehnal <david.sehnal@gmail.com>
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
import
{
idFactory
}
from
'
./id-factory
'
...
...
@@ -55,6 +56,11 @@ namespace ValueCell {
export
function
set
<
T
,
D
>
(
cell
:
ValueCell
<
T
,
D
>
,
box
:
ValueBox
<
T
,
D
>
):
ValueCell
<
T
,
D
>
{
return
ValueRef
.
set
(
cell
,
box
);
}
/** Updates the cell if the value is has changed, comparing by reference */
export
function
updateIfChanged
<
T
,
D
>
(
cell
:
ValueCell
<
T
,
D
>
,
value
:
T
):
ValueCell
<
T
,
D
>
{
return
cell
.
ref
.
value
!==
value
?
update
(
cell
,
value
)
:
cell
}
}
export
{
ValueRef
,
ValueBox
,
ValueCell
};
\ No newline at end of file
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