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
bd9177cd
Commit
bd9177cd
authored
6 years ago
by
David Sehnal
Browse files
Options
Downloads
Patches
Plain Diff
Param definition areEqual induced by the params shape
parent
1ea3672c
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-math/linear-algebra/3d/vec2.ts
+4
-0
4 additions, 0 deletions
src/mol-math/linear-algebra/3d/vec2.ts
src/mol-util/param-definition.ts
+47
-3
47 additions, 3 deletions
src/mol-util/param-definition.ts
with
51 additions
and
3 deletions
src/mol-math/linear-algebra/3d/vec2.ts
+
4
−
0
View file @
bd9177cd
...
...
@@ -152,6 +152,10 @@ namespace Vec2 {
out
[
1
]
=
1.0
/
a
[
1
];
return
out
;
}
export
function
areEqual
(
a
:
Vec2
,
b
:
Vec2
)
{
return
a
[
0
]
===
b
[
0
]
&&
a
[
1
]
===
b
[
1
];
}
}
export
default
Vec2
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/mol-util/param-definition.ts
+
47
−
3
View file @
bd9177cd
...
...
@@ -6,8 +6,8 @@
*/
import
{
Color
as
ColorData
}
from
'
./color
'
;
import
{
shallowClone
}
from
'
mol-util
'
;
import
{
Vec2
}
from
'
mol-math/linear-algebra
'
;
import
{
shallowClone
,
shallowEqual
}
from
'
mol-util
'
;
import
{
Vec2
,
Vec3
}
from
'
mol-math/linear-algebra
'
;
import
{
camelCaseToWords
}
from
'
./string
'
;
export
namespace
ParamDefinition
{
...
...
@@ -104,7 +104,8 @@ export namespace ParamDefinition {
return
{
type
:
'
group
'
,
defaultValue
:
getDefaultValues
(
params
)
as
any
,
params
};
}
export
interface
Mapped
<
T
>
extends
Base
<
{
name
:
string
,
params
:
T
}
>
{
export
interface
NamedParams
<
T
=
any
>
{
name
:
string
,
params
:
T
}
export
interface
Mapped
<
T
>
extends
Base
<
NamedParams
<
T
>>
{
type
:
'
mapped
'
,
select
:
Select
<
string
>
,
map
(
name
:
string
):
Any
...
...
@@ -159,4 +160,47 @@ export namespace ParamDefinition {
// TODO
return
void
0
;
}
export
function
areEqual
(
params
:
Params
,
a
:
any
,
b
:
any
):
boolean
{
if
(
a
===
b
)
return
true
;
if
(
!
a
)
return
!
b
;
if
(
!
b
)
return
!
a
;
if
(
typeof
a
!==
'
object
'
||
typeof
b
!==
'
object
'
)
return
false
;
for
(
const
k
of
Object
.
keys
(
params
))
{
if
(
!
isParamEqual
(
params
[
k
],
a
[
k
],
b
[
k
]))
return
false
;
}
return
true
;
}
function
isParamEqual
(
p
:
Any
,
a
:
any
,
b
:
any
):
boolean
{
if
(
a
===
b
)
return
true
;
if
(
!
a
)
return
!
b
;
if
(
!
b
)
return
!
a
;
if
(
p
.
type
===
'
group
'
)
{
return
areEqual
(
p
.
params
,
a
,
b
);
}
else
if
(
p
.
type
===
'
mapped
'
)
{
const
u
=
a
as
NamedParams
,
v
=
b
as
NamedParams
;
if
(
!
u
)
return
!
v
;
if
(
!
u
||
!
v
)
return
false
;
if
(
u
.
name
!==
v
.
name
)
return
false
;
const
map
=
p
.
map
(
u
.
name
);
return
isParamEqual
(
map
,
u
.
params
,
v
.
params
);
}
else
if
(
p
.
type
===
'
interval
'
)
{
return
a
[
0
]
===
b
[
0
]
&&
a
[
1
]
===
b
[
1
];
}
else
if
(
p
.
type
===
'
line-graph
'
)
{
const
u
=
a
as
LineGraph
[
'
defaultValue
'
],
v
=
b
as
LineGraph
[
'
defaultValue
'
];
if
(
u
.
length
!==
v
.
length
)
return
false
;
for
(
let
i
=
0
,
_i
=
u
.
length
;
i
<
_i
;
i
++
)
{
if
(
!
Vec2
.
areEqual
(
u
[
i
],
v
[
i
]))
return
false
;
}
return
true
;
}
else
if
(
typeof
a
===
'
object
'
&&
typeof
b
===
'
object
'
)
{
return
shallowEqual
(
a
,
b
);
}
// a === b was checked at the top.
return
false
;
}
}
\ 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