comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Problem with COMMON block
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Problem with COMMON block [message #14798] Mon, 29 March 1999 00:00
Ivan Zimine is currently offline  Ivan Zimine
Messages: 40
Registered: February 1999
Member
Hi Tri,

I don't have much experience with COMMON blocks and in fact I never use
it in widget programs. Instead I use the top base uvalue to pass all the
data between event processing routines. For image data I use pointers. I
have changed a bit
your programs so you can see how that might work for you. I haven't
tried the code, hope it's ok.

ivan



;*********************************************************** ***
; procedure WindowLoadImage_event
;
; To manage all events of the WindowLoadImage
;*********************************************************** ***
pro WindowLoadImage_event, event
WIDGET_CONTROL, event.top, GET_UVALUE=info, /no_copy ; <- get info
WIDGET_CONTROL, event.id, GET_UVALUE = selected
; define a temporal type
CASE selected OF
'LoadStdImage': BEGIN
fname = info.StdImage.header.FileName;
;^^^^^^
fname = DIALOG_PICKFILE(FILE = fname, GROUP = event.top, $
;^^^^^^^^^
/READ, FILTER = '*.hdr', /MUST_EXIST)
; read your data
;if you need to display it use
;Wset, info.wind1 & TV, image
END
ENDCASE
WIDGET_CONTROL, event.top, SET_UVALUE=info, /no_copy ; <- store info
end

;*********************************************************** ***
; procedure WindowLoadImage
;
; the Window of LoadImage
;*********************************************************** ***
pro WindowLoadImage

StdImage = {IMAGESTRUCT, Header:{HEADERSTRUCT, FileName:BYTARR(128),
Dimension:0, $
X_Dim:0, Y_Dim:0, Z_Dim:0, $
X_Size:0., Y_Size:0., Z_Size:0.}, $
Data:PTR_NEW()}

MW_XSize = 800 ; it must be at least equal 3*img_DrawSize
MW_YSize = 650
LIWindow = WIDGET_BASE(XSIZE = MW_XSize, YSIZE = MW_YSize, $
TITLE='Load Images')
;****************
; Drawing windows
img_DrawSize = 256
img_XOffGap = (MW_XSize - 3 * img_DrawSize) / 4.0
img_YOffGap = 10
img_XOff = FIX(img_XOffGap)
img_YOff = img_XOffGap
StdImgDraw1 = WIDGET_DRAW(LIWindow, XSIZE = img_DrawSize, $
YSIZE=img_DrawSize, $
XOFFSET = img_XOff, YOFFSET =
img_YOff, $
FRAME = 3, COLORS = 256)
img_XOff = FIX(img_XOff + img_DrawSize + img_XOffGap)
StdImgDraw2 = WIDGET_DRAW(LIWindow, XSIZE = img_DrawSize, $
YSIZE=img_DrawSize, XOFFSET =
img_XOff,$ > YOFFSET = img_YOff,
FRAME = 3,COLORS = 256)
img_XOff = FIX(img_XOff + img_DrawSize + img_XOffGap)
StdImgDraw3 = WIDGET_DRAW(LIWindow, XSIZE = img_DrawSize, $
YSIZE=img_DrawSize, $
XOFFSET = img_XOff, YOFFSET =
img_YOff, $
FRAME = 3, COLORS = 256)
;****************
; Drawing buttons of range 1
img_XOff = FIX(img_XOffGap)
bt_YOff = img_YOffGap + img_DrawSize + 10
btSize = 60
btStdImgLoad = WIDGET_BUTTON(LIWindow, $
XOFFSET = img_XOff, YOFFSET = bt_YOff, XSIZE = btSize, $
VALUE = 'Load...', $
UVALUE = 'LoadStdImage')
;****************
; Drawing buttons of range 2
bt_YOff = MW_YSize - img_YOffGap - img_DrawSize - 30
btObjImgLoad = WIDGET_BUTTON(LIWindow, $
XOFFSET = img_XOff, YOFFSET = bt_YOff, XSIZE = btSize,
$
VALUE = 'Load...', $
UVALUE = 'LoadObjImage')

WIDGET_CONTROL, LIWindow, /REALIZE
; you might also need windows ID of your draw widgets
WIDGET_CONTROL,StdImgDraw1, GET_VALUE=wind1
WIDGET_CONTROL,StdImgDraw2, GET_VALUE=wind2
WIDGET_CONTROL,StdImgDraw3, GET_VALUE=wind3
info={wind1:wind1, wind2:wind2, wind3:wind3, StdImage:StdImage}
WIDGET_CONTROL, LIWindow, SET_UVALUE=infom, /no_copy

XMANAGER, 'WindowLoadImage', LIWindow
end

--
Ivan Zimine
Dpt. of Radiology (MRI), Geneva University Hospitals
email: ivan.zimine@physics.unige.ch
tel. : (+41 22) 372 70 70
Re: Problem with COMMON block [message #14799 is a reply to message #14798] Mon, 29 March 1999 00:00 Go to previous message
Quentin Errera is currently offline  Quentin Errera
Messages: 4
Registered: March 1999
Junior Member
In the routine "pro WindowLoadImage_event, event" complite the common
like this
COMMON SHAREIMAGE, StdImage, ObjImage
i.e. like it is define in "pro WindowLoadImage".

It should be work.

Reason is that idl will first compile "WindowLoadImage_event" before
"WindowLoadImage" and is finding an empty common.

Quentin.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: ENVI ROI -> ASCII
Next Topic: How to read variables from a simple .DBF file?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 17:38:23 PDT 2025

Total time taken to generate the page: 0.00568 seconds