I'm using the ILNumerics Math Library to create some 2D Plots. To display the data I use the ILPlotCube Class. I would like to turn off the default behavior of the EventHandler for MouseDoubleClick events, because I would like to implement my own. Is that possible?
Here's some more context:
The default event handler of an ILPlotCube for MouseDoubleClick events resets the view to default values. Usually this works quite well, but there seems to be a problem with very small x- and y-values. When I add a linePlot with very small y-values the limits of the plots are automatically set to YMax=0.525 and YMin=-0.525. Unfortunately, that's not what I want. So, I set the values myself after adding the linePlot and the plot looks exactly how I'd like to have it. Great... but: if I double click on the scene it uses the default (0.525) values again. Dough! That's why I would like to turn off or overwrite this behavior.
Any ideas?
private void ilPanel1_Load(object sender, EventArgs e)
{
var scene = new ILScene();
//data with very small "y-values"
ILArray<float> line1 = new float[,] {
{0.0f, 1.0f, 2.0f },
{2.042166e-08f, 2.070141e-08f , 2.042166e-08f} };
var linePlot1 = new ILLinePlot(line1.T,
lineColor: Color.Blue,
lineWidth: 3,
markerStyle: MarkerStyle.Dot);
//Create Plot Cube
var plotCube = new ILPlotCube();
plotCube.Add(linePlot1);
//plotCube.Plots.Limits.YMax is now 0.525
//plotCube.Plots.Limits.YMin is now -0.525
//manually set the value
float maxY = 0.0f;
using (ILScope.Enter())
{
var aPos = linePlot1.Line.Positions.Storage["1;:"];
maxY = ILMath.max(aPos).FirstOrDefault();
}
plotCube.Plots.Limits.YMax = maxY;
plotCube.Plots.Limits.YMin = 0.0f;
var plot = scene.Add(plotCube);
ilPanel1.Scene = scene;
}
Thanks,
Tim
All nodes in ILNumerics provide access to the common mouse handlers which you can use to provide your own logic - or to simply disable existing individual handlers. In your case, you can override the double click handler for the plot cube:
// ....
plotCube.MouseDoubleClick += (_e, _a) => {
_a.Cancel = true;
};
// you may want disable zoom and pan as well?
plot.AllowZoom = false;
plot.AllowPan = false;
// continue with your code here...
ilPanel1.Scene = scene;
The mouse handlers in ILNumerics are actually very flexible and powerful. See the documentation here: http://ilnumerics.net/mouse-events.html
@Edit: for your situation, the ILPlotCube.AutoScaleOnAdd property might also be of interest. It determines, if the plot cube limits are to be recomputed once a new plot has been added to the plot cube. You might find false
more convenient.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.