英文:
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("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("Current slice selection states:\n")
For( number i=0; i<disp.ImageDisplayCountSlices(); i++){
Result("Slice #"+i+": '"+disp.ImageDisplayGetSliceLabelByIndex(i)+"'")
object sliceID = disp.ImageDisplayGetSliceIDByIndex(i)
Result("\t: Selected:"+disp.ImageDisplayIsSliceSelected(sliceID,""))
Result("\n")
}
But I would further encourage you to look at the example scripts of the F1 help documentation here:
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论