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
2c88ace9
Commit
2c88ace9
authored
5 years ago
by
Alexander Rose
Browse files
Options
Downloads
Patches
Plain Diff
added number precision helpers, improved isovalue step calculation
parent
6eae95f9
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-plugin/ui/custom/volume.tsx
+3
-2
3 additions, 2 deletions
src/mol-plugin/ui/custom/volume.tsx
src/mol-repr/volume/isosurface.ts
+3
-2
3 additions, 2 deletions
src/mol-repr/volume/isosurface.ts
src/mol-util/number.ts
+17
-1
17 additions, 1 deletion
src/mol-util/number.ts
with
23 additions
and
5 deletions
src/mol-plugin/ui/custom/volume.tsx
+
3
−
2
View file @
2c88ace9
...
@@ -15,6 +15,7 @@ import { Slider } from '../controls/slider';
...
@@ -15,6 +15,7 @@ import { Slider } from '../controls/slider';
import
{
VolumeIsoValue
,
VolumeData
}
from
'
../../../mol-model/volume
'
;
import
{
VolumeIsoValue
,
VolumeData
}
from
'
../../../mol-model/volume
'
;
import
{
Vec3
}
from
'
../../../mol-math/linear-algebra
'
;
import
{
Vec3
}
from
'
../../../mol-math/linear-algebra
'
;
import
{
ColorNames
}
from
'
../../../mol-util/color/names
'
;
import
{
ColorNames
}
from
'
../../../mol-util/color/names
'
;
import
{
toPrecision
}
from
'
../../../mol-util/number
'
;
const
ChannelParams
=
{
const
ChannelParams
=
{
color
:
PD
.
Color
(
ColorNames
.
black
,
{
description
:
'
Display color of the volume.
'
}),
color
:
PD
.
Color
(
ColorNames
.
black
,
{
description
:
'
Display color of the volume.
'
}),
...
@@ -40,12 +41,12 @@ function Channel(props: {
...
@@ -40,12 +41,12 @@ function Channel(props: {
const
value
=
channel
.
isoValue
.
kind
===
'
relative
'
?
channel
.
isoValue
.
relativeValue
:
channel
.
isoValue
.
absoluteValue
;
const
value
=
channel
.
isoValue
.
kind
===
'
relative
'
?
channel
.
isoValue
.
relativeValue
:
channel
.
isoValue
.
absoluteValue
;
const
relMin
=
(
min
-
mean
)
/
sigma
;
const
relMin
=
(
min
-
mean
)
/
sigma
;
const
relMax
=
(
max
-
mean
)
/
sigma
;
const
relMax
=
(
max
-
mean
)
/
sigma
;
const
step
=
toPrecision
(
isRelative
?
Math
.
round
(((
max
-
min
)
/
sigma
))
/
100
:
sigma
/
100
,
2
)
return
<
ExpandableGroup
return
<
ExpandableGroup
label
=
{
props
.
label
+
(
props
.
isRelative
?
'
\
u03C3
'
:
''
)
}
label
=
{
props
.
label
+
(
props
.
isRelative
?
'
\
u03C3
'
:
''
)
}
colorStripe
=
{
channel
.
color
}
colorStripe
=
{
channel
.
color
}
pivot
=
{
<
Slider
value
=
{
value
}
min
=
{
isRelative
?
relMin
:
min
}
max
=
{
isRelative
?
relMax
:
max
}
pivot
=
{
<
Slider
value
=
{
value
}
min
=
{
isRelative
?
relMin
:
min
}
max
=
{
isRelative
?
relMax
:
max
}
step
=
{
step
}
step
=
{
isRelative
?
sigma
/
100
:
Math
.
round
(((
max
-
min
)
/
sigma
))
/
100
}
onChange
=
{
v
=>
props
.
changeIso
(
props
.
name
,
v
,
isRelative
)
}
disabled
=
{
props
.
params
.
isDisabled
}
onEnter
=
{
props
.
params
.
events
.
onEnter
}
/>
}
onChange
=
{
v
=>
props
.
changeIso
(
props
.
name
,
v
,
isRelative
)
}
disabled
=
{
props
.
params
.
isDisabled
}
onEnter
=
{
props
.
params
.
events
.
onEnter
}
/>
}
controls
=
{
<
ParameterControls
onChange
=
{
({
name
,
value
})
=>
props
.
changeParams
(
props
.
name
,
name
,
value
)
}
params
=
{
ChannelParams
}
values
=
{
channel
}
onEnter
=
{
props
.
params
.
events
.
onEnter
}
/>
}
controls
=
{
<
ParameterControls
onChange
=
{
({
name
,
value
})
=>
props
.
changeParams
(
props
.
name
,
name
,
value
)
}
params
=
{
ChannelParams
}
values
=
{
channel
}
onEnter
=
{
props
.
params
.
events
.
onEnter
}
/>
}
/>;
/>;
...
...
This diff is collapsed.
Click to expand it.
src/mol-repr/volume/isosurface.ts
+
3
−
2
View file @
2c88ace9
...
@@ -18,6 +18,7 @@ import { EmptyLoci } from '../../mol-model/loci';
...
@@ -18,6 +18,7 @@ import { EmptyLoci } from '../../mol-model/loci';
import
{
VisualUpdateState
}
from
'
../util
'
;
import
{
VisualUpdateState
}
from
'
../util
'
;
import
{
Lines
}
from
'
../../mol-geo/geometry/lines/lines
'
;
import
{
Lines
}
from
'
../../mol-geo/geometry/lines/lines
'
;
import
{
RepresentationContext
,
RepresentationParamsGetter
,
Representation
}
from
'
../representation
'
;
import
{
RepresentationContext
,
RepresentationParamsGetter
,
Representation
}
from
'
../representation
'
;
import
{
toPrecision
}
from
'
../../mol-util/number
'
;
const
defaultStats
:
VolumeData
[
'
dataStats
'
]
=
{
min
:
-
1
,
max
:
1
,
mean
:
0
,
sigma
:
0.1
};
const
defaultStats
:
VolumeData
[
'
dataStats
'
]
=
{
min
:
-
1
,
max
:
1
,
mean
:
0
,
sigma
:
0.1
};
export
function
createIsoValueParam
(
defaultValue
:
VolumeIsoValue
,
stats
?:
VolumeData
[
'
dataStats
'
])
{
export
function
createIsoValueParam
(
defaultValue
:
VolumeIsoValue
,
stats
?:
VolumeData
[
'
dataStats
'
])
{
...
@@ -43,12 +44,12 @@ export function createIsoValueParam(defaultValue: VolumeIsoValue, stats?: Volume
...
@@ -43,12 +44,12 @@ export function createIsoValueParam(defaultValue: VolumeIsoValue, stats?: Volume
'
absolute
'
:
PD
.
Converted
(
'
absolute
'
:
PD
.
Converted
(
(
v
:
VolumeIsoValue
)
=>
VolumeIsoValue
.
toAbsolute
(
v
,
VolumeData
.
One
.
dataStats
).
absoluteValue
,
(
v
:
VolumeIsoValue
)
=>
VolumeIsoValue
.
toAbsolute
(
v
,
VolumeData
.
One
.
dataStats
).
absoluteValue
,
(
v
:
number
)
=>
VolumeIsoValue
.
absolute
(
v
),
(
v
:
number
)
=>
VolumeIsoValue
.
absolute
(
v
),
PD
.
Numeric
(
mean
,
{
min
,
max
,
step
:
sigma
/
100
})
PD
.
Numeric
(
mean
,
{
min
,
max
,
step
:
toPrecision
(
sigma
/
100
,
2
)
})
),
),
'
relative
'
:
PD
.
Converted
(
'
relative
'
:
PD
.
Converted
(
(
v
:
VolumeIsoValue
)
=>
VolumeIsoValue
.
toRelative
(
v
,
VolumeData
.
One
.
dataStats
).
relativeValue
,
(
v
:
VolumeIsoValue
)
=>
VolumeIsoValue
.
toRelative
(
v
,
VolumeData
.
One
.
dataStats
).
relativeValue
,
(
v
:
number
)
=>
VolumeIsoValue
.
relative
(
v
),
(
v
:
number
)
=>
VolumeIsoValue
.
relative
(
v
),
PD
.
Numeric
(
Math
.
min
(
1
,
relMax
),
{
min
:
relMin
,
max
:
relMax
,
step
:
Math
.
round
(((
max
-
min
)
/
sigma
))
/
100
})
PD
.
Numeric
(
Math
.
min
(
1
,
relMax
),
{
min
:
relMin
,
max
:
relMax
,
step
:
toPrecision
(
Math
.
round
(((
max
-
min
)
/
sigma
))
/
100
,
2
)
})
)
)
},
},
(
v
:
VolumeIsoValue
)
=>
v
.
kind
===
'
absolute
'
?
'
absolute
'
:
'
relative
'
,
(
v
:
VolumeIsoValue
)
=>
v
.
kind
===
'
absolute
'
?
'
absolute
'
:
'
relative
'
,
...
...
This diff is collapsed.
Click to expand it.
src/mol-util/number.ts
+
17
−
1
View file @
2c88ace9
/**
/**
* Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2018
-2019
mol* contributors, licensed under MIT, See LICENSE file for more info.
*
*
* @author David Sehnal <david.sehnal@gmail.com>
* @author David Sehnal <david.sehnal@gmail.com>
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
*/
/**
/**
...
@@ -52,4 +53,19 @@ export function isInteger(s: string) {
...
@@ -52,4 +53,19 @@ export function isInteger(s: string) {
s
=
s
.
trim
()
s
=
s
.
trim
()
const
n
=
parseInt
(
s
,
10
)
const
n
=
parseInt
(
s
,
10
)
return
isNaN
(
n
)
?
false
:
n
.
toString
()
===
s
return
isNaN
(
n
)
?
false
:
n
.
toString
()
===
s
}
export
function
getPrecision
(
v
:
number
)
{
if
(
!
isFinite
(
v
))
return
0
let
e
=
1
let
p
=
0
while
(
Math
.
round
(
v
*
e
)
/
e
!==
v
)
{
e
*=
10
++
p
}
return
p
}
export
function
toPrecision
(
v
:
number
,
precision
:
number
)
{
return
parseFloat
(
v
.
toPrecision
(
precision
))
}
}
\ 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