Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node coordinates #19

Open
kalliopeargentina opened this issue Feb 1, 2014 · 2 comments
Open

Node coordinates #19

kalliopeargentina opened this issue Feb 1, 2014 · 2 comments

Comments

@kalliopeargentina
Copy link

Hi, I've been experimenting with your program (awesome by the way) and added some features I needed for my app for personal use (i added some display filters and touch gestures). I was thinking of adding a feature to add nodes and edges (ie: adding a node where I click with the mouse or tap). If this is likekly to happen I would need to understand how do you map position from the gexf coordinates to the canvas. I see that you use a function called calcCoord but I am not understanding how it works. could you provide some pointers or general ideas so I can understand this? what i would try to make is an inverse function so i can get the gexf coordinates from the mouse position.

By the way if you are curious about my app here is a link (its in spanish):

http://www.kalliope.com.ar/gexf-js-master/index.html

And an article explaining it (sadly also in spanish only):

http://vikingobjj.blogspot.com.ar/2014/01/war-inside-my-head.html

@raphv
Copy link
Owner

raphv commented Feb 12, 2014

Hello,

There is a function called nodeFromPos that looks up nodes at the mouse position.

I know the code for that part is a bit complicated and tends to mix french and english and that the words I use to describe coordinate properties may be improper.

The coordinates are transformed 3 times to convert node positions from the Gexf file to screen positions:

1 - First, when the GEXF file is loaded, the coordinates are normalised, that gives the coords.base property https://github.com/raphv/gexf-js/blob/master/js/gexfjs.js#L442
2 - Then, when the scale is changed, the coordinates are recalculated to what I call coords.actual https://github.com/raphv/gexf-js/blob/master/js/gexfjs.js#L611
3 - Finally, and only if the lens mode is activated, the node positions that are under the lens are transformed again to coords.real https://github.com/raphv/gexf-js/blob/master/js/gexfjs.js#L663

I hope this helps,

Regards,

Raphael

@kalliopeargentina
Copy link
Author

Thanks! I'll let you know how it goes

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

No branches or pull requests

2 participants