05 May 2016 10:57 PM |
|
Dear all,
I am trying to use object graphic in my GUI development. According the documentation, I should be able to created an IGLgrWindow by WIDGET_WINDOW, and then displaying graphics objects on it. Therefore I tried to display IDLgrPlot in this way it always gives me a blank window only. I put the code below, anyone can see any problems in this code please let me know:
PRO PLOTTEST
BASE = WIDGET_BASE(/ROW, TITLE= 'TEST OBJECT GRAPHICS', XSIZE=800, YSIZE=600)
DRAW1 = WIDGET_WINDOW(BASE, XSIZE=800, YSIZE=600, retain=2)
WIDGET_CONTROL, DRAW1, /REALIZE
WIDGET_CONTROL, DRAW1, GET_VALUE=OWINDOW1
RVAL = (GVAL = (BVAL = REVERSE(INDGEN(256))))
MYPALETTE = OBJ_NEW('IDLGRPALETTE', RVAL, GVAL, BVAL)
OWINDOW1->SETPROPERTY, PALETTE=MYPALETTE
MYVIEW = OBJ_NEW('IDLGRVIEW')
MYMODEL = OBJ_NEW('IDLGRMODEL')
MYVIEW->ADD, MYMODEL
X = (FINDGEN(21) / 10.0 - 1.0) * 10.0
Y = [3.0, -2.0, 0.5, 4.5, 3.0, 9.5, 9.0, 4.0, 1.0, -8.0, -6.5, -7.0, -2.0, 5.0, -1.0, -2.0, -6.0, 3.0, 5.5, 2.5, -3.0]
MYPLOT1 = OBJ_NEW('IDLGRPLOT', X, Y, COLOR=[255, 0, 0])
MYMODEL->ADD, MYPLOT1
OWINDOW1->DRAW, MYVIEW
END
|
|
|
|
Deleted User New Member
Posts:81  
06 May 2016 06:35 PM |
|
Dear Huang Su,
I think you just need to position and size the viewplane rectangle correctly to allow viewing of your plot's data space, for example:
MYVIEW = OBJ_NEW('IDLGRVIEW', VIEWPLANE_RECT=[-15,-15,30,30])
I hope this can be helpful.
-Jim
|
|
|
|
Deleted User New Member
Posts:32  
06 May 2016 09:38 PM |
|
Hi Jim,
Thanks for your hint, but still not working, the plot is not displayed.
However, if I put two breakpoints at the last two lines in debugging, I can see the plot displayed and then disappeared. It looks like some sort of events triggered a repaint function washed away the plot.
By the way, I am using Linux Debian distro and X-Window.
Thanks for any helps.
Regards,
Su
|
|
|
|
Deleted User New Member
Posts:32  
08 May 2016 09:52 PM |
|
Well, I think I am getting close to...don't know where:) To illustrate the problem, I put a 'WAIT, 3' statement after the DRAW instruction, like the code below, then I saw the plot shown up 3 seconds, and then disappeared. Can someone enlighten me how to deal with it?
PRO PLOTTEST
base = WIDGET_BASE(/ROW, TITLE= 'TEST OBJECT GRAPHICS', XSIZE=800, YSIZE=600)
draw1 = WIDGET_WINDOW(base, XSIZE=800, YSIZE=600, retain=2, GRAPHICS_LEVEL=2)
WIDGET_CONTROL, draw1, /REALIZE
WIDGET_CONTROL, draw1, GET_VALUE=owindow1
view1 = OBJ_NEW('IDLgrView', VIEWPLANE_RECT=[-15,-15,30,30])
mymodel = OBJ_NEW('IDLgrModel')
x = FINDGEN(20)-10
y = SIN(x)*10
myplot = OBJ_NEW('IDLgrPlot', x, y, COLOR=[255, 0, 0])
mymodel->ADD, myplot
view1->ADD, mymodel
owindow1->DRAW, view1
WAIT, 3
END
|
|
|
|
Deleted User New Member
Posts:32  
13 Jun 2016 08:32 PM |
|
I am still stuck here, no progress at all. Someone can help me on this? The plot is displayed only when I use WAIT to suspend the program, when WAIT finished, the plot disappear.
Platform: IDL 8.4.1, Linux Debian
PRO PLOTTEST
x = FINDGEN(20)-10
y = SIN(x)*10
base = WIDGET_BASE(/ROW, TITLE= 'TEST', XSIZE=800, YSIZE=600)
draw1 = WIDGET_WINDOW(base, XSIZE=800, YSIZE=600, GRAPHICS_LEVEL=2)
WIDGET_CONTROL, base, /REALIZE
WIDGET_CONTROL, draw1, GET_VALUE=owindow1
view1 = OBJ_NEW('IDLgrView', VIEWPLANE_RECT=[-15,-15,30,30])
model1 = OBJ_NEW('IDLgrModel')
plot1 = OBJ_NEW('IDLgrPlot', x, y, COLOR=[255, 0, 0])
model1->ADD, plot1
view1->ADD, model1
owindow1->DRAW, view1
WAIT, 3
END
|
|
|
|
Deleted User Basic Member
Posts:143  
14 Jun 2016 09:46 AM |
|
This is a little confusing, but WIDGET_WINDOW should only be used for Function Graphics (such as the PLOT and IMAGE functions). If you are using Object Graphics, you should use WIDGET_DRAW with the GRAPHICS_LEVEL property set to 2.
WIDGET_WINDOW = Function Graphics
WIDGET_DRAW (graphics_level 1) = Direct Graphics
WIDGET_DRAW(graphcs_level 2) = Object Graphics
If you change your code to use WIDGET_DRAW instead or WIDGET_WINDOW, it works without issue:
PRO dj_forum_huangsu_plottest
x = FINDGEN(20)-10
y = SIN(x)*10
base = WIDGET_BASE(/ROW, TITLE= 'TEST', XSIZE=800, YSIZE=600)
draw1 = widget_draw(base, xsize=800, ysize=600, graphics_level=2)
;draw1 = WIDGET_WINDOW(base, XSIZE=800, YSIZE=600, GRAPHICS_LEVEL=2)
WIDGET_CONTROL, base, /REALIZE
WIDGET_CONTROL, draw1, GET_VALUE=owindow1
view1 = OBJ_NEW('IDLgrView', VIEWPLANE_RECT=[-15,-15,30,30])
model1 = OBJ_NEW('IDLgrModel')
plot1 = OBJ_NEW('IDLgrPlot', x, y, COLOR=[255, 0, 0])
model1->ADD, plot1
view1->ADD, model1
owindow1->DRAW, view1
WAIT, 3
end
David Starbuck
Harris GS
|
|
|
|
Deleted User New Member
Posts:32  
14 Jun 2016 11:48 PM |
|
Thanks for David's enlightenment.
|
|
|
|