Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Knowledge Space WP Plugin
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
Service Desk
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
alg
Knowledge Space WP Plugin
Commits
ec305005
Commit
ec305005
authored
2 years ago
by
Matthias Konitzny
Browse files
Options
Downloads
Patches
Plain Diff
Dynamically changing the node rendering based on node selection.
parent
ff3d18a0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!3
Master into new editor
Pipeline
#56807
passed
2 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/display/display.tsx
+5
-1
5 additions, 1 deletion
src/display/display.tsx
src/display/renderer.tsx
+68
-6
68 additions, 6 deletions
src/display/renderer.tsx
with
73 additions
and
7 deletions
src/display/display.tsx
+
5
−
1
View file @
ec305005
...
...
@@ -128,7 +128,10 @@ class Display extends React.Component<
node
=
{
this
.
state
.
currentNode
}
nodeColors
=
{
this
.
state
.
graph
.
nodeColors
}
height
=
{
this
.
state
.
nodeActive
?
this
.
state
.
height
:
0
}
onClose
=
{
this
.
handleNodeClose
}
onClose
=
{
()
=>
{
this
.
handleNodeClose
();
this
.
rendererRef
.
current
.
deselectNode
();
}
}
nodeClickedCallback
=
{
this
.
handleNodeChangeRequest
}
></
NodeInfoBar
>
)
}
...
...
@@ -148,6 +151,7 @@ class Display extends React.Component<
width
=
{
this
.
state
.
width
}
height
=
{
this
.
state
.
height
}
onNodeClicked
=
{
this
.
handleNodeClicked
}
onNodeDeselected
=
{
this
.
handleNodeClose
}
/>
)
}
</
div
>
...
...
This diff is collapsed.
Click to expand it.
src/display/renderer.tsx
+
68
−
6
View file @
ec305005
...
...
@@ -9,7 +9,7 @@ import { Line2, LineGeometry, LineMaterial } from "three-fatline";
import
React
from
"
react
"
;
import
PropTypes
,
{
InferType
}
from
"
prop-types
"
;
import
SpriteText
from
"
three-spritetext
"
;
import
{
Object3D
}
from
"
three
"
;
import
{
Object3D
,
Sprite
}
from
"
three
"
;
import
Graph
,
{
Coordinate
,
LinkData
,
NodeData
}
from
"
./graph
"
;
export
interface
GraphNode
extends
NodeData
{
...
...
@@ -42,16 +42,18 @@ export class GraphRenderer extends React.PureComponent<
>
{
props
:
InferType
<
typeof
GraphRenderer
.
propTypes
>
;
state
:
InferType
<
typeof
GraphRenderer
.
stateTypes
>
;
forceGraph
:
React
.
RefObject
<
any
>
;
// using typeof ForceGraph3d produces an error here...
highlightedNodes
:
Set
<
GraphNode
>
;
highlightedLinks
:
Set
<
GraphLink
>
;
hoverNode
:
GraphNode
;
private
forceGraph
:
React
.
RefObject
<
any
>
;
// using typeof ForceGraph3d produces an error here...
private
highlightedNodes
:
Set
<
GraphNode
>
;
private
highlightedLinks
:
Set
<
GraphLink
>
;
private
hoverNode
:
GraphNode
;
private
node3dObjects
:
Map
<
string
,
THREE
.
Group
>
;
static
propTypes
=
{
graph
:
PropTypes
.
instanceOf
(
Graph
).
isRequired
,
width
:
PropTypes
.
number
.
isRequired
,
height
:
PropTypes
.
number
.
isRequired
,
onNodeClicked
:
PropTypes
.
func
,
onNodeDeselected
:
PropTypes
.
func
,
isFullscreen
:
PropTypes
.
bool
,
};
...
...
@@ -62,6 +64,7 @@ export class GraphRenderer extends React.PureComponent<
this
.
highlightedNodes
=
new
Set
();
this
.
highlightedLinks
=
new
Set
();
this
.
node3dObjects
=
new
Map
<
string
,
THREE
.
Group
>
();
this
.
hoverNode
=
null
;
this
.
forceGraph
=
React
.
createRef
();
}
...
...
@@ -122,7 +125,7 @@ export class GraphRenderer extends React.PureComponent<
sprite
.
scale
.
set
(...
Config
.
NODE_SIZE
);
group
.
add
(
sprite
);
this
.
node3dObjects
.
set
(
node
.
id
,
group
);
return
group
;
}
...
...
@@ -156,6 +159,7 @@ export class GraphRenderer extends React.PureComponent<
const
line
=
new
Line2
(
geometry
,
material
);
line
.
computeLineDistances
();
line
.
scale
.
set
(
1
,
1
,
1
);
return
line
;
}
...
...
@@ -223,11 +227,68 @@ export class GraphRenderer extends React.PureComponent<
});
}
deselectNode
()
{
this
.
node3dObjects
.
forEach
((
nodeObj
)
=>
this
.
makeNodeVisible
(
nodeObj
));
for
(
const
l
of
this
.
props
.
graph
.
links
)
{
l
.
__lineObj
.
material
.
opacity
=
1.0
;
}
if
(
this
.
props
.
onNodeDeselected
!==
undefined
)
{
this
.
props
.
onNodeDeselected
();
}
}
displayNodeSelection
(
node
:
GraphNode
)
{
// Set all nodes to a grayed out state
this
.
node3dObjects
.
forEach
((
nodeObj
)
=>
{
this
.
makeNodeInvisible
(
nodeObj
);
});
// Reset neighbors
for
(
const
neighbor
of
node
.
neighbors
)
{
const
neighborObj
=
this
.
node3dObjects
.
get
(
neighbor
.
id
);
this
.
makeNodeVisible
(
neighborObj
);
}
// Set all links to a grayed out state
for
(
const
l
of
this
.
props
.
graph
.
links
)
{
l
.
__lineObj
.
material
.
opacity
=
0.15
;
}
// Reset for current connections
for
(
const
l
of
node
.
links
)
{
const
lObj
=
l
as
GraphLink
;
lObj
.
__lineObj
.
material
.
opacity
=
1.0
;
}
// Reset for current node
const
nodeObj
=
this
.
node3dObjects
.
get
(
node
.
id
);
this
.
makeNodeVisible
(
nodeObj
);
}
private
makeNodeInvisible
(
nodeObjectGroup
:
THREE
.
Group
)
{
const
text
=
nodeObjectGroup
.
children
[
0
]
as
SpriteText
;
text
.
material
.
opacity
=
0.0
;
const
circle
=
nodeObjectGroup
.
children
[
1
]
as
Sprite
;
circle
.
material
.
opacity
=
0.5
;
}
private
makeNodeVisible
(
nodeObjectGroup
:
THREE
.
Group
)
{
const
text
=
nodeObjectGroup
.
children
[
0
]
as
SpriteText
;
text
.
material
.
opacity
=
0.85
;
const
circle
=
nodeObjectGroup
.
children
[
1
]
as
Sprite
;
circle
.
material
.
opacity
=
1.0
;
}
onNodeClick
(
node
:
GraphNode
)
{
this
.
focusOnNode
(
node
);
if
(
MODE
===
"
default
"
&&
this
.
props
.
onNodeClicked
)
{
this
.
props
.
onNodeClicked
(
node
);
}
this
.
displayNodeSelection
(
node
);
}
onNodeDragEnd
(
node
:
GraphNode
,
translate
:
Coordinate
)
{
...
...
@@ -306,6 +367,7 @@ export class GraphRenderer extends React.PureComponent<
nodeThreeObject
=
{
(
node
:
GraphNode
)
=>
this
.
drawNode
(
node
)
}
linkThreeObject
=
{
(
link
:
LinkData
)
=>
this
.
drawLink
(
link
)
}
onNodeClick
=
{
(
node
:
GraphNode
)
=>
this
.
onNodeClick
(
node
)
}
onBackgroundClick
=
{
()
=>
this
.
deselectNode
()
}
//d3AlphaDecay={0.1}
warmupTicks
=
{
150
}
cooldownTime
=
{
1000
}
// TODO: Do we want the simulation to unfreeze on node drag?
...
...
This diff is collapsed.
Click to expand it.
Matthias Konitzny
@konitzny
mentioned in issue
#19 (closed)
·
2 years ago
mentioned in issue
#19 (closed)
mentioned in issue #19
Toggle commit list
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