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
13fe0ea6
Commit
13fe0ea6
authored
6 years ago
by
Alexander Rose
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' into gl-lines
parents
532d26e0
ea356d1d
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/mol-state/state.ts
+27
-14
27 additions, 14 deletions
src/mol-state/state.ts
with
27 additions
and
14 deletions
src/mol-state/state.ts
+
27
−
14
View file @
13fe0ea6
...
@@ -224,7 +224,7 @@ async function update(ctx: UpdateContext) {
...
@@ -224,7 +224,7 @@ async function update(ctx: UpdateContext) {
}
}
if
(
hasCurrent
)
{
if
(
hasCurrent
)
{
const
newCurrent
=
findNewCurrent
(
ctx
.
oldTree
,
current
,
deletes
);
const
newCurrent
=
findNewCurrent
(
ctx
.
oldTree
,
current
,
deletes
,
ctx
.
cells
);
ctx
.
parent
.
setCurrent
(
newCurrent
);
ctx
.
parent
.
setCurrent
(
newCurrent
);
}
}
...
@@ -270,7 +270,7 @@ async function update(ctx: UpdateContext) {
...
@@ -270,7 +270,7 @@ async function update(ctx: UpdateContext) {
await
updateSubtree
(
ctx
,
root
);
await
updateSubtree
(
ctx
,
root
);
}
}
let
newCurrent
:
Transform
.
Ref
|
undefined
;
let
newCurrent
:
Transform
.
Ref
|
undefined
=
ctx
.
newCurrent
;
// Raise object updated events
// Raise object updated events
for
(
const
update
of
ctx
.
results
)
{
for
(
const
update
of
ctx
.
results
)
{
if
(
update
.
action
===
'
created
'
)
{
if
(
update
.
action
===
'
created
'
)
{
...
@@ -286,8 +286,19 @@ async function update(ctx: UpdateContext) {
...
@@ -286,8 +286,19 @@ async function update(ctx: UpdateContext) {
}
}
}
}
if
(
ctx
.
newCurrent
)
ctx
.
parent
.
setCurrent
(
ctx
.
newCurrent
);
if
(
newCurrent
)
ctx
.
parent
.
setCurrent
(
newCurrent
);
else
if
(
newCurrent
)
ctx
.
parent
.
setCurrent
(
newCurrent
);
else
{
// check if old current or its parent hasn't become null
const
current
=
ctx
.
parent
.
current
;
const
currentCell
=
ctx
.
cells
.
get
(
current
);
if
(
currentCell
&&
(
currentCell
.
obj
===
StateObject
.
Null
||
(
currentCell
.
status
===
'
error
'
&&
currentCell
.
errorText
===
ParentNullErrorText
)))
{
newCurrent
=
findNewCurrent
(
ctx
.
oldTree
,
current
,
[],
ctx
.
cells
);
ctx
.
parent
.
setCurrent
(
newCurrent
);
}
}
return
deletes
.
length
>
0
||
roots
.
length
>
0
||
ctx
.
changed
;
return
deletes
.
length
>
0
||
roots
.
length
>
0
||
ctx
.
changed
;
}
}
...
@@ -300,6 +311,7 @@ function findUpdateRoots(cells: Map<Transform.Ref, StateObjectCell>, tree: State
...
@@ -300,6 +311,7 @@ function findUpdateRoots(cells: Map<Transform.Ref, StateObjectCell>, tree: State
function
findUpdateRootsVisitor
(
n
:
Transform
,
_
:
any
,
s
:
{
roots
:
Ref
[],
cells
:
Map
<
Ref
,
StateObjectCell
>
})
{
function
findUpdateRootsVisitor
(
n
:
Transform
,
_
:
any
,
s
:
{
roots
:
Ref
[],
cells
:
Map
<
Ref
,
StateObjectCell
>
})
{
const
cell
=
s
.
cells
.
get
(
n
.
ref
);
const
cell
=
s
.
cells
.
get
(
n
.
ref
);
if
(
cell
&&
cell
.
obj
===
StateObject
.
Null
)
return
false
;
if
(
!
cell
||
cell
.
version
!==
n
.
version
||
cell
.
status
===
'
error
'
)
{
if
(
!
cell
||
cell
.
version
!==
n
.
version
||
cell
.
status
===
'
error
'
)
{
s
.
roots
.
push
(
n
.
ref
);
s
.
roots
.
push
(
n
.
ref
);
return
false
;
return
false
;
...
@@ -369,12 +381,12 @@ function initCells(ctx: UpdateContext, roots: Ref[]) {
...
@@ -369,12 +381,12 @@ function initCells(ctx: UpdateContext, roots: Ref[]) {
return
initCtx
.
added
;
return
initCtx
.
added
;
}
}
function
findNewCurrent
(
tree
:
StateTree
,
start
:
Ref
,
deletes
:
Ref
[])
{
function
findNewCurrent
(
tree
:
StateTree
,
start
:
Ref
,
deletes
:
Ref
[]
,
cells
:
Map
<
Ref
,
StateObjectCell
>
)
{
const
deleteSet
=
new
Set
(
deletes
);
const
deleteSet
=
new
Set
(
deletes
);
return
_findNewCurrent
(
tree
,
start
,
deleteSet
);
return
_findNewCurrent
(
tree
,
start
,
deleteSet
,
cells
);
}
}
function
_findNewCurrent
(
tree
:
StateTree
,
ref
:
Ref
,
deletes
:
Set
<
Ref
>
):
Ref
{
function
_findNewCurrent
(
tree
:
StateTree
,
ref
:
Ref
,
deletes
:
Set
<
Ref
>
,
cells
:
Map
<
Ref
,
StateObjectCell
>
):
Ref
{
if
(
ref
===
Transform
.
RootRef
)
return
ref
;
if
(
ref
===
Transform
.
RootRef
)
return
ref
;
const
node
=
tree
.
transforms
.
get
(
ref
)
!
;
const
node
=
tree
.
transforms
.
get
(
ref
)
!
;
...
@@ -387,6 +399,10 @@ function _findNewCurrent(tree: StateTree, ref: Ref, deletes: Set<Ref>): Ref {
...
@@ -387,6 +399,10 @@ function _findNewCurrent(tree: StateTree, ref: Ref, deletes: Set<Ref>): Ref {
if
(
s
.
done
)
break
;
if
(
s
.
done
)
break
;
if
(
deletes
.
has
(
s
.
value
))
continue
;
if
(
deletes
.
has
(
s
.
value
))
continue
;
const
cell
=
cells
.
get
(
s
.
value
);
if
(
!
cell
||
cell
.
status
===
'
error
'
||
cell
.
obj
===
StateObject
.
Null
)
{
continue
;
}
const
t
=
tree
.
transforms
.
get
(
s
.
value
);
const
t
=
tree
.
transforms
.
get
(
s
.
value
);
if
(
t
.
props
&&
t
.
props
.
isGhost
)
continue
;
if
(
t
.
props
&&
t
.
props
.
isGhost
)
continue
;
...
@@ -402,7 +418,7 @@ function _findNewCurrent(tree: StateTree, ref: Ref, deletes: Set<Ref>): Ref {
...
@@ -402,7 +418,7 @@ function _findNewCurrent(tree: StateTree, ref: Ref, deletes: Set<Ref>): Ref {
}
}
if
(
prevCandidate
)
return
prevCandidate
;
if
(
prevCandidate
)
return
prevCandidate
;
return
_findNewCurrent
(
tree
,
node
.
parent
,
deletes
);
return
_findNewCurrent
(
tree
,
node
.
parent
,
deletes
,
cells
);
}
}
/** Set status and error text of the cell. Remove all existing objects in the subtree. */
/** Set status and error text of the cell. Remove all existing objects in the subtree. */
...
@@ -440,6 +456,8 @@ type UpdateNodeResult =
...
@@ -440,6 +456,8 @@ type UpdateNodeResult =
|
{
ref
:
Ref
,
action
:
'
replaced
'
,
oldObj
?:
StateObject
,
obj
:
StateObject
}
|
{
ref
:
Ref
,
action
:
'
replaced
'
,
oldObj
?:
StateObject
,
obj
:
StateObject
}
|
{
action
:
'
none
'
}
|
{
action
:
'
none
'
}
const
ParentNullErrorText
=
'
Parent is null
'
;
async
function
updateSubtree
(
ctx
:
UpdateContext
,
root
:
Ref
)
{
async
function
updateSubtree
(
ctx
:
UpdateContext
,
root
:
Ref
)
{
setCellStatus
(
ctx
,
root
,
'
processing
'
);
setCellStatus
(
ctx
,
root
,
'
processing
'
);
...
@@ -463,11 +481,6 @@ async function updateSubtree(ctx: UpdateContext, root: Ref) {
...
@@ -463,11 +481,6 @@ async function updateSubtree(ctx: UpdateContext, root: Ref) {
isNull
=
update
.
obj
===
StateObject
.
Null
;
isNull
=
update
.
obj
===
StateObject
.
Null
;
ctx
.
parent
.
events
.
log
.
next
(
LogEntry
.
info
(
`Updated
${
update
.
obj
.
label
}
in
${
formatTimespan
(
time
)}
.`
));
ctx
.
parent
.
events
.
log
.
next
(
LogEntry
.
info
(
`Updated
${
update
.
obj
.
label
}
in
${
formatTimespan
(
time
)}
.`
));
}
}
if
(
isNull
&&
!
ctx
.
newCurrent
)
{
// TODO: is this ok?
ctx
.
newCurrent
=
findNewCurrent
(
ctx
.
tree
,
root
,
[
root
]);
}
}
catch
(
e
)
{
}
catch
(
e
)
{
ctx
.
changed
=
true
;
ctx
.
changed
=
true
;
if
(
!
ctx
.
hadError
)
ctx
.
newCurrent
=
root
;
if
(
!
ctx
.
hadError
)
ctx
.
newCurrent
=
root
;
...
@@ -479,7 +492,7 @@ async function updateSubtree(ctx: UpdateContext, root: Ref) {
...
@@ -479,7 +492,7 @@ async function updateSubtree(ctx: UpdateContext, root: Ref) {
while
(
true
)
{
while
(
true
)
{
const
next
=
children
.
next
();
const
next
=
children
.
next
();
if
(
next
.
done
)
return
;
if
(
next
.
done
)
return
;
if
(
isNull
)
doError
(
ctx
,
next
.
value
,
'
Parent
is null
'
,
true
);
if
(
isNull
)
doError
(
ctx
,
next
.
value
,
Parent
NullErrorText
,
true
);
else
await
updateSubtree
(
ctx
,
next
.
value
);
else
await
updateSubtree
(
ctx
,
next
.
value
);
}
}
}
}
...
...
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