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
c9a3254b
Commit
c9a3254b
authored
3 years ago
by
Alexander Rose
Browse files
Options
Downloads
Patches
Plain Diff
fix partial marker average calculation
parent
bad6d030
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/mol-repr/visual.ts
+6
-5
6 additions, 5 deletions
src/mol-repr/visual.ts
src/mol-util/marker-action.ts
+20
-27
20 additions, 27 deletions
src/mol-util/marker-action.ts
with
26 additions
and
32 deletions
src/mol-repr/visual.ts
+
6
−
5
View file @
c9a3254b
...
...
@@ -76,6 +76,7 @@ namespace Visual {
const
{
tMarker
,
dMarkerType
,
uMarker
,
markerAverage
,
markerStatus
,
uGroupCount
,
instanceCount
}
=
renderObject
.
values
;
const
count
=
uGroupCount
.
ref
.
value
*
instanceCount
.
ref
.
value
;
const
{
array
}
=
tMarker
.
ref
.
value
;
const
currentStatus
=
markerStatus
.
ref
.
value
as
MarkerInfo
[
'
status
'
];
if
(
!
isEveryLoci
(
loci
))
{
let
intervalSize
=
0
;
...
...
@@ -90,9 +91,9 @@ namespace Visual {
let
average
=
-
1
;
let
status
:
MarkerInfo
[
'
status
'
]
=
-
1
;
if
(
isEveryLoci
(
loci
))
{
const
info
=
getMarkerInfo
(
action
,
markerStatus
.
ref
.
value
);
const
info
=
getMarkerInfo
(
action
,
currentStatus
);
if
(
info
.
status
!==
-
1
)
{
changed
=
markerStatus
.
ref
.
value
!==
info
.
status
;
changed
=
currentStatus
!==
info
.
status
;
if
(
changed
)
setMarkerValue
(
array
,
info
.
status
,
count
);
}
else
{
changed
=
applyMarkerAction
(
array
,
Interval
.
ofLength
(
count
),
action
);
...
...
@@ -102,13 +103,13 @@ namespace Visual {
}
else
{
changed
=
lociApply
(
loci
,
interval
=>
applyMarkerAction
(
array
,
interval
,
action
),
true
);
if
(
changed
)
{
average
=
getPartialMarkerAverage
(
action
,
markerStatus
.
ref
.
value
);
average
=
getPartialMarkerAverage
(
action
,
currentStatus
);
if
(
previous
&&
previous
.
status
!==
-
1
&&
average
===
-
1
&&
MarkerActions
.
isReverse
(
previous
.
action
,
action
)
&&
Loci
.
areEqual
(
loci
,
previous
.
loci
)
)
{
status
=
previous
.
status
;
average
=
status
===
0
?
0
:
1
;
average
=
status
===
0
?
0
:
0.5
;
}
}
}
...
...
@@ -120,7 +121,7 @@ namespace Visual {
if
(
previous
)
{
previous
.
action
=
action
;
previous
.
loci
=
loci
;
previous
.
status
=
markerStatus
.
ref
.
value
as
MarkerInfo
[
'
s
tatus
'
]
;
previous
.
status
=
currentS
tatus
;
}
ValueCell
.
updateIfChanged
(
uMarker
,
status
);
if
(
status
===
-
1
)
ValueCell
.
update
(
tMarker
,
tMarker
.
ref
.
value
);
...
...
This diff is collapsed.
Click to expand it.
src/mol-util/marker-action.ts
+
20
−
27
View file @
c9a3254b
...
...
@@ -153,7 +153,7 @@ export interface MarkerInfo {
status
:
0
|
1
|
2
|
3
|
-
1
}
export
function
getMarkerInfo
(
action
:
MarkerAction
,
currentStatus
:
number
):
MarkerInfo
{
export
function
getMarkerInfo
(
action
:
MarkerAction
,
currentStatus
:
MarkerInfo
[
'
status
'
]
):
MarkerInfo
{
let
average
:
MarkerInfo
[
'
average
'
]
=
-
1
;
let
status
:
MarkerInfo
[
'
status
'
]
=
-
1
;
switch
(
action
)
{
...
...
@@ -224,52 +224,45 @@ export function getMarkerInfo(action: MarkerAction, currentStatus: number): Mark
* Assumes the action is applied to a partial set that is
* neither the empty set nor the full set.
*/
export
function
getPartialMarkerAverage
(
action
:
MarkerAction
,
currentStatus
:
number
):
MarkerInfo
[
'
average
'
]
{
export
function
getPartialMarkerAverage
(
action
:
MarkerAction
,
currentStatus
:
MarkerInfo
[
'
status
'
]
)
{
switch
(
action
)
{
case
MarkerAction
.
Highlight
:
return
1
;
return
0.5
;
case
MarkerAction
.
RemoveHighlight
:
if
(
currentStatus
===
0
)
{
return
0
;
}
else
if
(
currentStatus
===
1
)
{
return
-
1
;
}
else
if
(
currentStatus
===
2
||
currentStatus
===
3
)
{
return
1
;
return
0.5
;
}
else
{
// 1 | -1
return
-
1
;
}
return
-
1
;
case
MarkerAction
.
Select
:
return
1
;
return
0.5
;
case
MarkerAction
.
Deselect
:
if
(
currentStatus
===
1
||
currentStatus
===
3
)
{
return
1
;
return
0.5
;
}
else
if
(
currentStatus
===
0
)
{
return
0
;
}
else
if
(
currentStatus
===
2
)
{
}
else
{
// 2 | -1
return
-
1
;
}
return
-
1
;
case
MarkerAction
.
Toggle
:
if
(
currentStatus
===
1
)
{
return
1
;
}
else
if
(
currentStatus
===
2
)
{
return
1
;
}
else
if
(
currentStatus
===
3
)
{
return
1
;
}
else
if
(
currentStatus
===
0
)
{
return
1
;
if
(
currentStatus
===
-
1
)
{
return
-
1
;
}
else
{
// 0 | 1 | 2 | 3
return
0.5
;
}
return
-
1
;
case
MarkerAction
.
Clear
:
if
(
currentStatus
===
1
)
{
return
1
;
}
else
if
(
currentStatus
===
2
)
{
return
1
;
}
else
if
(
currentStatus
===
3
)
{
return
1
;
if
(
currentStatus
===
-
1
)
{
return
-
1
;
}
else
if
(
currentStatus
===
0
)
{
return
0
;
}
else
{
// 1 | 2 | 3
return
0.5
;
}
case
MarkerAction
.
None
:
return
-
1
;
default
:
assertUnreachable
(
action
);
}
return
-
1
;
}
\ 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