Skip to content
This repository has been archived by the owner on Jul 29, 2019. It is now read-only.

Selection box #4242

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
Open

Selection box #4242

wants to merge 11 commits into from

Conversation

softwareCobbler
Copy link

This implements a "selectionBox" feature in Network's interaction module. With this option enabled, the user can press CTRL and left click and then drag a box around the canvas. Let go and it selects the nodes and/or edges within the box (there are option flags the user can set to have it select nodes / edges).
Open to feedback!
This was briefly discussed in #4233.
Thanks!
sbox

@softwareCobbler
Copy link
Author

Quick video example of feature

@jgorene
Copy link

jgorene commented Feb 4, 2019

A priori, I didn't encounter any bugs at least after a few tests.
Subject to further testing, this seems ready to be implemented at the latest on v4.22.
Good work !

@softwareCobbler
Copy link
Author

softwareCobbler commented Feb 5, 2019

considering the line width option - since CanvasRenderingContext2D.lineWidth is in coordinate space, I'm not certain how to provide a sane default. The value the user provides will change in apparent thickness as the zoom scale changes. Recalculating upon camera scale changes is the obvious solution, but I don't know quite what units the user expects to see.
Should a value of 1.0 always be 1 screen pixel? Or 1% of the total canvas area?

@jgorene
Copy link

jgorene commented Feb 5, 2019

@softwareCobbler Indeed and it's already very good like that, no problem 😌
I still have a lot to learn and it will take me a little more time to properly analyze the new option , anyway.

@mojoaxel Just by the way and nothing to do with this new interaction option but it seems that "zoomSpeed" option is obsolete... but maybe I missed something?

@softwareCobbler
Copy link
Author

Got the lineWidth option up and running for this:

  • It is a value in screen pixels, the canvas zoom should not affect the pixel count.
  • lineWidth is kept greater than or equal to zero (negative values are forced to 0), and while the user can pass in real numbers, the passed-in values are rounded down to the nearest integer.
  • a zero value means we draw no border, and just fill in the appropriate fillRect
  • canvas bounds clamping has been adjusted to deal with different sized lineWidth's

@@ -541,6 +541,7 @@ ItemSet.prototype.show = function() {

/**
* Activates the popup timer to show the given popup after a fixed time.
* @param {any} popup
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cherry-picked this into #4256 to provide a more logical separation of concern (it's a bit out of place in this PR)

@mojoaxel mojoaxel self-assigned this Feb 8, 2019
@mojoaxel mojoaxel added this to the Minor Release v4.22 milestone Feb 8, 2019
This reverts commit f2bec3e (ref
almende/vis PR #4256
@mojoaxel mojoaxel self-requested a review February 19, 2019 21:01
@mojoaxel
Copy link
Member

@softwareCobbler Please consider moving this pull-request over to vis-network! Also we are always looking for people that might be interesting in helping maintaining 😉

@softwareCobbler
Copy link
Author

softwareCobbler commented Jul 23, 2019 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants