Creating a trailing line with three.js - three.js

This is very similar to what I want.
Except I'd like the user to see a trailing line after first click. So when the user first clicks starting position is fixed and a line is created where the end point would be the current mouse location. Similarly to MS Paint line drawing functionality.
So when I move mouse to the right I want to see the line change.
Maybe some examples or pointers how to implement it?

For future reference, first initiate a two point line
var geometry = new THREE.Geometry();
geometry.vertices.push(point);
geometry.vertices.push(point);
var line = new THREE.Line(geometry, new THREE.LineBasicMaterial({}));
Then on mousemove replace the last vertice with latest mouse position.
line.geometry.vertices[last_point] = new_point;

Related

Make new dlg windows mouse position or somewhere specific

I'm a beginner, I'm trying to match the new created dlg windows to match the position of my mouse or at least somewhere specific, can anyone help?
var dlg = new Window("dialog",[100,495,300,540]);
Tried but look like this is not working.
If you are after a window that's 220 x 45 then I think you want:
var dialog = new Window("dialog");
dialog.text = "Dialog";
dialog.preferredSize.width = 200;
dialog.preferredSize.height = 45;
dialog.show();
Position the window - I'm not so sure about that. A few versions ago any dialog or windows were default to the top left. And you had to use var win = new Window(dlg,'My dialog window'); win.center(); to put them in the centre. It may be possible to position them at exact cooridinates.
However...
Two things that will make your life much easier is the Photoshop scriptUI guide
and Joonas Pääkkö's ScriptUI Dialog Builder. The latter will do a lot of teh heavy lifting for you. You're welcome.

PySide moving one window to the screen location of another window

I would like to get the screen location of one window, and then take those coordinates and move another window to that location. Thanks.
Just for the position, you can get the position of the first window:
pos = self.first.pos().toTuple()
and move the second one there:
self.second.move(*pos)
You can do the same with its size:
size = self.first.size().toTuple()
self.second.resize(*size)

New LineLayer won't appear unless map zoomed in/out

I have some routes in my code, and user can choose which one they wanna see on their map. For example, there are route X and route Y. Then user is seeing route Y and tap a button to see route X. Route Y is hidden and route X is shown.
Now here's my code to show route X (same for route Y, except different properties)
FeatureCollection featureCollection = BaseFeatureCollection.FromJson
("{\"type\":\"FeatureCollection\",\"features\":" +
"[{\"type\":\"Feature\",\"geometry\":{\"type\":\"LineString\"" +
",\"coordinates\":[" + stringCoordinates + "]},\"properties\":{}}]}");
GeoJsonSource geoJsonSource = new GeoJsonSource("route", featureCollection);
_mapboxMap.AddSource(geoJsonSource);
_lineLayerX = new LineLayer("linelayerred", "route");
_lineLayerX.SetProperties(
PropertyFactory.LineWidth(new Java.Lang.Float(8.0f)),
PropertyFactory.LinePattern("routex")
);
if (isShowRouteX) {
_mapboxMap.AddLayer(_lineLayerX);
}
Then when I wan't to hide and show another route
_mapboxMap.RemoveLayer(_lineLayerX);
_mapboxMap.AddLayer(_lineLayerY);
Code simplified, but basically that's all I do, and it does shows the route.
Now, the first time I add LineLayer, it would be shown immediately on map, I don't need to zoom in or out. But if new LineLayer added (after removing the old one), changes won't appear unless map is zoomed in or out, as if I have to do that to trigger redraw. Not even panning map to any direction would make new line appear. RemoveLayer executed flawlessly though.
I've even tried _mapView.Invalidate(), still doesn't work. What should I add so that user won't need to zoom in/out to see new LayerLine?
Also, I know that PropertyFactory has Visibility and it should/might work better for my problem, yet it doesn't work, especially Property.None. And not sure if it's still on topic in this questions, so I won't go further into it.
Finally found it, apparently I lacked this line
_mapboxMap.RemoveSource(geoJsonSource);
I put it on
_mapboxMap.RemoveLayer(_lineLayerX);
_mapboxMap.RemoveSource(geoJsonSource);
_mapboxMap.AddLayer(_lineLayerY);
and now the new line appears without the needs to zoom in or out.

mouse pointer to a position up in selenium

I have a requirement to move my mouse pointer based on a value in x-axis, such that tooltip will be shown. I am not sure how to do the same in selenium. I have seen the movetoelement, keysup. But i assume they are not the correct ones for my action.
Is there a way in selenium to do this.
Thanks in advance!!!!]2
You can use Action class in selenium and move to a element position. As you are aware of your x-axis, first move your pointer to that position in x axis and then in a loop call the movetoelement of action object with (0, iterating values) till you get your preferred tool tip. This can be fine tuned if you think this grid is going to appear in the center of the screen.

Any way to trigger a callback function while hovering over a point in Matlab?

I am using a while loop and within that I add ginput in MATLAB to capture the positions of mouse. I check every time if the returned position is within some area so I will plot some curve on the current figure. But the problem is, by using ginput, I have to press enter before the positions are returned. Is that any way to capture the mouse event such that when the current cursor hover over some points, a callback function will be triggered? Thanks.
Since you already have a figure you're using, you could set the listening property for the figure:
set(gcf,'WindowButtonMotionFcn', #mouseMoveListener);
But now you have to create a function called 'mouseMoveListener' (if you want to name it something else, change the words after the # sign to whatever name you want, and make sure the actual event function is named that too).
Within your function mouseMoveListener you can now get the mouse coordinates:
MousePos = get(mainAxis,'CurrentPoint');
Which tells the current point of the mouse with respect to the axes coordinates. From there, you can have whatever if statement check that the position is where you want it and perform whatever tasks you want based on that information.

Resources