[英]How to turn off default Mouse Event Handlers in ILNumerics PlotCube?
我正在使用ILNumerics數學庫創建一些2D圖。 為了顯示數據,我使用ILPlotCube類。 我想為MouseDoubleClick事件關閉EventHandler的默認行為,因為我想實現自己的行為。 那可能嗎?
這里是一些更多的上下文:
用於MouseDoubleClick事件的ILPlotCube的默認事件處理程序會將視圖重置為默認值。 通常,此方法效果很好,但是x和y值非常小似乎存在問題。 當我添加具有非常小的y值的linePlot時,圖的限制會自動設置為YMax = 0.525和YMin = -0.525。 不幸的是,這不是我想要的。 因此,我在添加linePlot之后自行設置值,並且該圖看起來完全像我想要的那樣。 很好...但是:如果我雙擊場景,它將再次使用默認(0.525)值。 面團! 這就是為什么我想關閉或覆蓋此行為。
有任何想法嗎?
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;
}
謝謝,
蒂姆
ILNumerics中的所有節點都提供對公用鼠標處理程序的訪問,您可以使用它們提供自己的邏輯-或僅禁用現有的單個處理程序。 在您的情況下,您可以覆蓋繪圖多維數據集的雙擊處理程序:
// ....
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;
ILNumerics中的鼠標處理程序實際上非常靈活和強大。 請參閱此處的文檔: http : //ilnumerics.net/mouse-events.html
@Edit:根據您的情況, ILPlotCube.AutoScaleOnAdd屬性也可能很有趣。 它確定是否在將新圖添加到圖多維數據集中后是否重新計算圖多維數據集限制。 您可能會發現false
更方便。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.