最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

dm script - Arrow annotation coordinates become incorrect when added to a annotation group - Stack Overflow

programmeradmin0浏览0评论

I'm experiencing an issue with arrow annotations in my ImageDisplay component. When I create arrow annotations sequentially, the arrow coordinates are correct. However, if I first create an annotation group and then add arrow annotations to this group, the arrow coordinates become incorrect. It appears that the marker group's coordinate system might not match the coordinate system used by ImageDisplay.

What I've Tried:

  1. Generating arrow markers one by one works as expected.
Image img := RealImage("RImg",4,256,256)
img.ShowImage()
ImageDisplay img_disp = img.ImageGetImageDisplay(0)
ImageDocument img_doc = img.ImageGetOrCreateImageDocument()

Number radius = 50
Number cx = 128
Number cy = 128
Number flag = 1
for (Number count = 0 ; count < 4 ; count++)
{
    Number phi = count * 2 * Pi()/ 4
    Number px = round(cx+radius*Cos(phi))
    Number py = round(cy+radius*Sin(phi))
    Component arrow = NewArrowAnnotation(cy, cx, py, px)
    img_disp.ComponentAddChildAtEnd(arrow)
}
  1. Creating a marker group first and then adding arrow markers leads to mixed-up coordinates.
Image img := RealImage("RImg",4,256,256)
img.ShowImage()
ImageDisplay img_disp = img.ImageGetImageDisplay(0)
ImageDocument img_doc = img.ImageGetOrCreateImageDocument()
Component arrows = NewGroupAnnotation()

Number radius = 50
Number cx = 128
Number cy = 128
for (Number count = 0 ; count < 4 ; count++)
{
    Number phi = count * 2 * Pi()/ 4
    Number px = round(cx+radius*Cos(phi))
    Number py = round(cy+radius*Sin(phi))
    Result(py + ", " + px + "\n")
    Component arrow = NewArrowAnnotation(cy, cx, py, px)
    arrows.ComponentAddChildAtEnd(arrow)
}

img_disp.ComponentAddChildAtEnd(arrows)

Questions:

  1. What could cause the coordinate discrepancy between the marker group and the ImageDisplay?
  2. How can I ensure that the marker group uses the same coordinate system as ImageDisplay when adding arrow markers?

I'm experiencing an issue with arrow annotations in my ImageDisplay component. When I create arrow annotations sequentially, the arrow coordinates are correct. However, if I first create an annotation group and then add arrow annotations to this group, the arrow coordinates become incorrect. It appears that the marker group's coordinate system might not match the coordinate system used by ImageDisplay.

What I've Tried:

  1. Generating arrow markers one by one works as expected.
Image img := RealImage("RImg",4,256,256)
img.ShowImage()
ImageDisplay img_disp = img.ImageGetImageDisplay(0)
ImageDocument img_doc = img.ImageGetOrCreateImageDocument()

Number radius = 50
Number cx = 128
Number cy = 128
Number flag = 1
for (Number count = 0 ; count < 4 ; count++)
{
    Number phi = count * 2 * Pi()/ 4
    Number px = round(cx+radius*Cos(phi))
    Number py = round(cy+radius*Sin(phi))
    Component arrow = NewArrowAnnotation(cy, cx, py, px)
    img_disp.ComponentAddChildAtEnd(arrow)
}
  1. Creating a marker group first and then adding arrow markers leads to mixed-up coordinates.
Image img := RealImage("RImg",4,256,256)
img.ShowImage()
ImageDisplay img_disp = img.ImageGetImageDisplay(0)
ImageDocument img_doc = img.ImageGetOrCreateImageDocument()
Component arrows = NewGroupAnnotation()

Number radius = 50
Number cx = 128
Number cy = 128
for (Number count = 0 ; count < 4 ; count++)
{
    Number phi = count * 2 * Pi()/ 4
    Number px = round(cx+radius*Cos(phi))
    Number py = round(cy+radius*Sin(phi))
    Result(py + ", " + px + "\n")
    Component arrow = NewArrowAnnotation(cy, cx, py, px)
    arrows.ComponentAddChildAtEnd(arrow)
}

img_disp.ComponentAddChildAtEnd(arrows)

Questions:

  1. What could cause the coordinate discrepancy between the marker group and the ImageDisplay?
  2. How can I ensure that the marker group uses the same coordinate system as ImageDisplay when adding arrow markers?
Share Improve this question asked Mar 4 at 13:58 ChenZXChenZX 3372 silver badges11 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

The details of how coordinate systems are inherited by child Components of various types are very unclear to me and I have not found any place in the DM documentation that fully spells this out. Perhaps someone else can point us to a clearer explanation.

However, it does seem to be clear that group annotations do not have a well-defined coordinate system of their own and thus adding new (previously unplaced) annotations to a group often does not yield the desired result. The better approach seems to be to first place new annotations on the desired ImageDisplay and then add such placed annotations to a group in order to achieved the desired association of daughter Components, as follows:

Number imgW = 256
Number imgH = 256
Image img := RealImage("RImg",4,imgW,imgH)
img.ShowImage()
ImageDisplay img_disp = img.ImageGetImageDisplay(0)
ImageDocument img_doc = img.ImageGetOrCreateImageDocument()
Component arrows = NewGroupAnnotation()
img_disp.ComponentAddChildAtEnd(arrows)

Number radius = 50
Number cx = imgW/2
Number cy = imgH/2
for (Number count = 0 ; count < 4 ; count++)
{
    Number phi = count * 2 * Pi()/ 4
    Number px = round(cx+radius*Cos(phi))
    Number py = round(cy+radius*Sin(phi))
    Component arrow = NewArrowAnnotation(cy, cx, py, px)
    img_disp.ComponentAddChildAtEnd(arrow)
    arrows.ComponentAddChildAtEnd(arrow)
}

TagGroup properties = NewTagGroup()
arrows.ComponentExternalizeProperties(properties)
properties.TagGroupOpenBrowserWindow(0)
发布评论

评论列表(0)

  1. 暂无评论