Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
frama-c
Commits
ae868325
Commit
ae868325
authored
4 years ago
by
Valentin Perrelle
Browse files
Options
Downloads
Patches
Plain Diff
[ivette] Dive: improves selection logic
parent
b3b5f826
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ivette/src/frama-c/dive/Dive.tsx
+36
-48
36 additions, 48 deletions
ivette/src/frama-c/dive/Dive.tsx
with
36 additions
and
48 deletions
ivette/src/frama-c/dive/Dive.tsx
+
36
−
48
View file @
ae868325
...
...
@@ -103,7 +103,7 @@ class Dive {
const
data
=
ele
.
data
();
const
commands
=
[{
content
:
renderToString
(
ctxmenu
.
explore
),
select
:
()
=>
this
.
explore
(
ele
),
select
:
()
=>
{
this
.
explore
(
ele
)
;
}
,
enabled
:
true
,
}];
if
(
data
.
kind
===
'
composite
'
)
{
...
...
@@ -414,13 +414,13 @@ class Dive {
async
add
(
marker
:
string
)
{
const
node
=
await
this
.
exec
(
API
.
add
,
marker
);
if
(
node
)
this
.
s
elect
Node
(
node
);
this
.
updateNodeS
elect
ion
(
node
);
}
explore
(
node
:
Cytoscape
.
NodeSingular
)
:
void
{
async
explore
(
node
:
Cytoscape
.
NodeSingular
)
{
const
id
=
parseInt
(
node
.
id
(),
10
);
if
(
id
)
this
.
exec
(
API
.
explore
,
id
);
await
this
.
exec
(
API
.
explore
,
id
);
}
show
(
node
:
Cytoscape
.
NodeSingular
):
void
{
...
...
@@ -435,12 +435,12 @@ class Dive {
this
.
exec
(
API
.
hide
,
id
);
}
clickNode
(
node
:
Cytoscape
.
NodeSingular
)
:
void
{
this
.
s
elect
Node
(
node
);
this
.
explore
(
node
);
async
clickNode
(
node
:
Cytoscape
.
NodeSingular
)
{
this
.
updateNodeS
elect
ion
(
node
);
await
this
.
explore
(
node
);
const
writes
=
node
.
data
()?.
writes
;
if
(
writes
)
if
(
writes
&&
writes
.
length
)
this
.
onSelect
?.(
writes
);
/* Cytoscape automatically selects the node clicked, and unselects all other
...
...
@@ -449,18 +449,21 @@ class Dive {
node
.
unselectify
();
}
selectLocation
(
location
:
States
.
Location
)
{
const
selectNode
=
this
.
cy
.
$
(
'
node:selected
'
);
const
writes
=
selectNode
?.
data
()?.
writes
;
if
(
location
.
marker
&&
!
_
.
some
(
writes
,
location
))
{
this
.
add
(
location
.
marker
);
}
else
{
this
.
selectNode
(
selectNode
);
// Update selection
selectLocation
(
location
:
States
.
Location
,
doExplore
:
boolean
)
{
if
(
location
!==
this
.
selectedLocation
)
{
this
.
selectedLocation
=
location
;
const
selectNode
=
this
.
cy
.
$
(
'
node:selected
'
);
const
writes
=
selectNode
?.
data
()?.
writes
;
if
(
doExplore
&&
location
.
marker
&&
!
_
.
some
(
writes
,
location
))
{
this
.
add
(
location
.
marker
);
}
else
{
this
.
updateNodeSelection
(
selectNode
);
}
}
}
s
elect
Node
(
node
:
Cytoscape
.
NodeSingular
):
void
{
updateNodeS
elect
ion
(
node
:
Cytoscape
.
NodeSingular
):
void
{
const
hasOrigin
=
(
ele
:
Cytoscape
.
NodeSingular
)
=>
(
_
.
some
(
ele
.
data
().
origins
,
this
.
selectedLocation
)
);
...
...
@@ -468,7 +471,11 @@ class Dive {
select
(
node
);
const
edges
=
node
.
incomers
(
'
edge
'
);
edges
.
unselect
();
edges
.
filter
(
hasOrigin
).
select
();
const
relevantEdges
=
edges
.
filter
(
hasOrigin
);
if
(
relevantEdges
.
empty
())
edges
.
select
();
else
relevantEdges
.
select
();
}
}
...
...
@@ -495,40 +502,21 @@ const GraphView = () => {
dive
.
mode
=
selectionMode
===
'
follow
'
?
'
explore
'
:
'
overview
'
;
},
[
dive
,
selectionMode
]);
/* When clicking on a node, select its writes locations as a multiple
selection. If these locations were already selected, select the next
location in the multiple selection. */
useEffect
(()
=>
{
/* When clicking on a node, select its writes locations as a multiple
selection. If these locations were already selected, select the next
location in the multiple selection. */
dive
.
onSelect
=
(
locations
)
=>
{
if
(
updateSelection
)
{
if
(
_
.
isEqual
(
locations
,
selection
?.
multiple
?.
allSelections
))
{
updateSelection
(
'
MULTIPLE_CYCLE
'
);
}
else
{
updateSelection
({
locations
,
index
:
0
,
});
}
}
if
(
_
.
isEqual
(
locations
,
selection
?.
multiple
?.
allSelections
))
updateSelection
(
'
MULTIPLE_CYCLE
'
);
else
updateSelection
({
locations
,
index
:
0
});
};
},
[
dive
,
selection
,
updateSelection
]);
useEffect
(()
=>
{
const
index
=
selection
?.
multiple
?.
index
;
const
allSelections
=
selection
?.
multiple
?.
allSelections
;
if
(
allSelections
&&
0
<=
index
&&
index
<
allSelections
.
length
)
{
const
selected
=
allSelections
[
index
];
dive
.
selectedLocation
=
selected
;
}
},
[
dive
,
selection
]);
// Updates the graph according to the selected marker.
useEffect
(()
=>
{
if
(
!
lock
&&
selection
?.
current
)
{
dive
.
selectLocation
(
selection
?.
current
);
}
},
[
dive
,
lock
,
selection
,
selectionMode
]);
// Updates the graph according to the selected marker.
if
(
selection
?.
current
)
dive
.
selectLocation
(
selection
?.
current
,
!
lock
);
},
[
dive
,
lock
,
selection
,
updateSelection
]);
// Layout selection
const
selectLayout
=
(
layout
?:
string
)
=>
{
...
...
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