In the program added an IDLgrPolyLine and IDLgrROI object are drawn. The
results of the
program is that only the IDLgrPolyLine is drawn. Important is that
normalized coordinates are used,
otherwise both objects are correctly drawn.
What is wrong here?
I'll work with IDL5.3 on a PC.
Regards,
Erik
Function _Normalize, range, Position=position
scale = [((position[0]*range[1])-(position[1]*range[0])) / $
(range[1]-range[0]),
(position[1]-position[0])/(range[1]-range[0])]
return, scale
end
; Calculate the normalization vector of pixel coordinates to
normalized
; coordinates.
;
Pro Normalization, Region = region, Xs = xs, Ys = ys
pos = [-1.0, -1.0, 1.0, 1.0]
xs = _Normalize([0, region[0]], Position=[pos[0], pos[2]])
ys = _Normalize([0, region[1]], Position=[pos[1], pos[3]])
end
; Main
;
; With Object Graphics a IDLgrPolyLine and IDLgrROI is drawn.
; Use are normalized coordinates.
;
top_wid = Widget_Base(XSize = 500, YSize = 500)
draw_wid = Widget_Draw(top_wid, XSize = 500, YSize = 500,
Graphics_Level = 2)
Widget_Control, top_wid, /REALIZE;
Widget_Control, draw_wid, Get_Value = window
view = Obj_New('IDLgrView', Color = [0, 0, 0])
view->SetProperty, Location = [0, 0], Dimensions = [500, 500],
Viewplane_rect = [-1.0, -1.0, 2.0, 2.0]
model = Obj_New('IDLgrModel')
view->Add, model
; Calculate the normalization vectors for conversion
; of pixel coordinates to normalized units.
Normalization, Region = [500, 500], Xs = xs, Ys = ys
; The IDLgrPolyLine Object.
gfxPL = OBJ_New('IDLgrPolyLine', Color = [255, 0, 0])
model->Add, gfxPL
gfxPL->SetProperty, Data = [[200, 200, 0], [400, 400, 0]]
gfxPL->SetProperty, XCoord_Conv = xs, YCoord_Conv = ys
; The IDLgrROI Object.
gfxROI = OBJ_New('IDLgrROI', Color = [255, 255, 255])
model->Add, gfxROI
gfxROI->SetProperty, Data = [[50, 400, 0], [400, 50, 0]]
gfxROI->SetProperty, XCoord_Conv = xs, YCoord_Conv = ys
window->Draw, view
end
|