哪个多切片线图的切片被选中?

huangapple go评论56阅读模式
英文:

which slice of a multi-slice lineplot is selected?

问题

从脚本方面来看,有一个命令可以选择多切片线图中的一个切片,即通过鼠标在图例中点击它。但我找不到一个命令可以让我确定当前选择了哪个切片。imgdsp.ImageDisplayGetSliceSelected() 在输出窗口中只显示 "无匹配",我在 "F1" 下的帮助中也没有成功找到相关信息。我还尝试了 ImageDisplayGetDisplayedLayers(),但它始终返回0。

如何确定多切片线图中当前选择了哪个切片?

英文:

Given a multi-slice lineplot, one of the slices can be selected by clicking it in the legend with the mouse. From the scripting side, there is a command to imgdsp.ImageDisplaySetSliceSelected(). But I can't find a command that lets me determine which slice is currently selected. imgdsp.ImageDisplayGetSliceSelected() shows only 'No match' in the output window and I was not successful looking through the help under 'F1'. I also tried ImageDisplayGetDisplayedLayers() but it returned 0 always.

How can I determine which slice is currently selected in a multi-slice lineplot?

答案1

得分: 2

事实上,您可以在LinePlot显示中选择多个切片,而不仅仅是一个,只需在单击时按住 CTRL 键进行多重选择。

您正在寻找的命令是:

Boolean ImageDisplayIsSliceSelected( ImageDisplay id, ScriptObject slice_id )

其使用示例如下:

imageDocument  doc = NewImageDocument("SliceTest")
imageDisplay disp = doc.ImageDocumentAddImageDisplay( RealImage(""),4,100)=icol, "best" )
disp.LinePlotImageDisplaySetLegendShown(1)
disp.ImageDisplayAddImage(RealImage(""),4,100)=icol**2/iwidth,"Second")
disp.ImageDisplayAddImage(RealImage(""),4,100)=icol**3/iwidth**2,"Third")
disp.ImageDisplayAddImage(RealImage(""),4,100)=icol**4/iwidth**3,"Fourth")

disp.ImageDisplaySetSliceSelected( disp.ImageDisplayGetSliceIDByIndex(2), 1 )
doc.ImageDocumentShow()
ClearResults()
Result("当前切片选择状态:\n")
For( number i=0; i<disp.ImageDisplayCountSlices(); i++){
    Result("切片 #"+i+": '"+disp.ImageDisplayGetSliceLabelByIndex(i)+"'")
    object sliceID = disp.ImageDisplayGetSliceIDByIndex(i)
    Result("\t: 已选择:"+disp.ImageDisplayIsSliceSelected(sliceID,""))
    Result("\n")
}

但我进一步鼓励您查看F1帮助文档中的示例脚本,链接如下:

哪个多切片线图的切片被选中?

英文:

As a matter of fact, one can have multiple slices selected in LinePlot display, not just one, just hold CTRL while clicking for multi-select.

The command you're looking for is:<br>Boolean ImageDisplayIsSliceSelected( ImageDisplay id, ScriptObject slice_id )

And an example of its use is:

imageDocument  doc = NewImageDocument(&quot;SliceTest&quot;)
imageDisplay disp = doc.ImageDocumentAddImageDisplay( RealImage(&quot;&quot;,4,100)=icol, &quot;best&quot; )
disp.LinePlotImageDisplaySetLegendShown(1)
disp.ImageDisplayAddImage(RealImage(&quot;&quot;,4,100)=icol**2/iwidth,&quot;Second&quot;)
disp.ImageDisplayAddImage(RealImage(&quot;&quot;,4,100)=icol**3/iwidth**2,&quot;Third&quot;)
disp.ImageDisplayAddImage(RealImage(&quot;&quot;,4,100)=icol**4/iwidth**3,&quot;Fourth&quot;)

disp.ImageDisplaySetSliceSelected( disp.ImageDisplayGetSliceIDByIndex(2), 1 )
doc.ImageDocumentShow()
ClearResults()
Result(&quot;Current slice selection states:\n&quot;)
For( number i=0; i&lt;disp.ImageDisplayCountSlices(); i++){
	Result(&quot;Slice #&quot;+i+&quot;: &#39;&quot;+disp.ImageDisplayGetSliceLabelByIndex(i)+&quot;&#39;&quot;)
	object sliceID = disp.ImageDisplayGetSliceIDByIndex(i)
	Result(&quot;\t: Selected:&quot;+disp.ImageDisplayIsSliceSelected(sliceID,&quot;&quot;))
	Result(&quot;\n&quot;)
}

But I would further encourage you to look at the example scripts of the F1 help documentation here:

哪个多切片线图的切片被选中?

huangapple
  • 本文由 发表于 2023年5月28日 09:07:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/76349591.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定