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
29e659fc
Commit
29e659fc
authored
3 years ago
by
Maximilian Giller
Browse files
Options
Downloads
Patches
Plain Diff
Working on clean box-select implementation
parent
afdc8632
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#52769
passed
3 years ago
Stage: test
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
editor/js/tools/collecttool.js
+13
-33
13 additions, 33 deletions
editor/js/tools/collecttool.js
with
13 additions
and
33 deletions
editor/js/tools/collecttool.js
+
13
−
33
View file @
29e659fc
...
...
@@ -5,16 +5,25 @@ import { CollectMenu, COLLECTION_KEY } from "./menus/collectmenu";
import
*
as
Graph
from
"
../graph
"
;
import
jquery
from
"
jquery
"
;
/**
* Only one instance of this should exist, since box-select has to work on a global scale.
*/
var
collectToolInstance
=
undefined
;
// Used for box select
export
default
class
CollectTool
extends
Tool
{
constructor
(
key
)
{
super
(
"
Collect
"
,
"
collect
"
,
key
,
new
CollectMenu
());
this
.
setupBoxSelect
();
if
(
collectToolInstance
===
undefined
)
{
collectToolInstance
=
this
;
}
}
onBoxSelect
(
left
,
bottom
,
top
,
right
)
{
// Filter out selected nodes
const
hitNodes
=
[];
const
tl
=
renderer
.
screen2GraphCoords
(
left
,
top
);
const
br
=
renderer
.
screen2GraphCoords
(
right
,
bottom
);
const
hitNodes
=
[];
graph
.
data
[
Graph
.
GRAPH_NODES
].
forEach
((
node
)
=>
{
if
(
tl
.
x
<
node
.
x
&&
...
...
@@ -25,15 +34,14 @@ export default class CollectTool extends Tool {
hitNodes
.
push
(
node
);
}
});
// run code to select your nodes here
// return selectGraphObjects(hitNodes);
console
.
log
(
hitNodes
);
// Add to selected items
if
(
state
.
itemsContext
!==
CONTEXT
.
node
)
{
state
.
clearSelectedItems
();
state
.
itemsContext
=
CONTEXT
.
node
;
}
state
.
addSelectedItems
(
hitNodes
);
this
.
menu
.
value
(
COLLECTION_KEY
,
state
.
selectedItems
);
}
onNodeClick
(
node
)
{
...
...
@@ -169,34 +177,6 @@ export default class CollectTool extends Tool {
bottom
=
e
.
offsetY
;
}
this
.
boxSelect
.
remove
();
// this.onBoxSelect(left, bottom, top, right);
const
tl
=
renderer
.
screen2GraphCoords
(
left
,
top
);
const
br
=
renderer
.
screen2GraphCoords
(
right
,
bottom
);
const
hitNodes
=
[];
graph
.
data
[
Graph
.
GRAPH_NODES
].
forEach
((
node
)
=>
{
if
(
tl
.
x
<
node
.
x
&&
node
.
x
<
br
.
x
&&
br
.
y
>
node
.
y
&&
node
.
y
>
tl
.
y
)
{
hitNodes
.
push
(
node
);
}
});
// run code to select your nodes here
// return selectGraphObjects(hitNodes);
console
.
log
(
hitNodes
);
if
(
state
.
itemsContext
!==
CONTEXT
.
node
)
{
state
.
clearSelectedItems
();
state
.
itemsContext
=
CONTEXT
.
node
;
}
state
.
addSelectedItems
(
hitNodes
);
// TODO Should be shown in menu
// this.menu.value(COLLECTION_KEY, state.selectedItems);
collectToolInstance
.
onBoxSelect
(
left
,
bottom
,
top
,
right
);
}
}
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