📄 chapter10volumerender1.pro
字号:
wAxesButton = WIDGET_BUTTON(wOptionButton, $
VALUE='Axis Lines (off)', UVALUE='AXES', $
UNAME='Chapter10VolumeRender1:axes')
wCursorButton = WIDGET_BUTTON(wOptionButton, $
VALUE='3D Cursor (off)', UVALUE='CURSOR', $
UNAME='Chapter10VolumeRender1:cursor')
;
;Create the menu bar item help that contains the about button
;
wHelpButton = WIDGET_BUTTON(barBase, VALUE='About', /HELP, /MENU)
wAboutButton = WIDGET_BUTTON(wHelpButton, $
VALUE='About volumes', UVALUE='ABOUT')
;
subBase = WIDGET_BASE(wBase, COLUMN=2)
wLeftbase = WIDGET_BASE(subBase, /COLUMN)
wVolBGroup = CW_BGROUP(wLeftBase, /COLUMN, $
['Dual Volume PET MRI','Electron Probability Density'], $
/EXCLUSIVE, /NO_REL, FRAME=0, UVALUE='VOLSEL', IDS=vol_buttonID)
WIDGET_CONTROL, wVolBgroup, SET_UNAME='Chapter10VolumeRender1:wVolBGroup'
wRenderButton = WIDGET_BUTTON(wLeftBase, $
VALUE="Render", UVALUE='RENDER', UNAME='Chapter10VolumeRender1:render')
wNonExclusiveBase = WIDGET_BASE(wLeftBase, /NONEXCLUSIVE)
wAutoRenderButton = WIDGET_BUTTON(wNonExclusiveBase, $
VALUE="Auto-Render", UVALUE='AUTORENDER', $
UNAME='Chapter10VolumeRender1:autorender')
wLightButton = WIDGET_BUTTON(wNonExclusiveBase, $
VALUE="Gradient Shading", UVALUE='LIGHTING', $
UNAME='Chapter10VolumeRender1:gradient_shade')
pet_color = Chapter10VolumeRender1TableNames('*_pet.pal', pet_color_files)
mri_color = Chapter10VolumeRender1TableNames('*_mri.pal', mri_color_files)
iron_color = Chapter10VolumeRender1TableNames('*_hipiph.pal', iron_color_files)
pet_opacity = Chapter10VolumeRender1TableNames('*_pet.opa', pet_opacity_files)
mri_opacity = Chapter10VolumeRender1TableNames('*_mri.opa', mri_opacity_files)
iron_opacity = Chapter10VolumeRender1TableNames('*_hipiph.opa', iron_opacity_files)
indx = SORT(pet_color)
pet_color = pet_color[indx]
pet_color_files = pet_color_files[indx]
indx = SORT(mri_color)
mri_color = mri_color[indx]
mri_color_files = mri_color_files[indx]
indx = SORT(iron_color)
iron_color = iron_color[indx]
iron_color_files = iron_color_files[indx]
indx = SORT(pet_opacity)
pet_opacity = pet_opacity[indx]
pet_opacity_files = pet_opacity_files[indx]
indx = SORT(mri_opacity)
mri_opacity = mri_opacity[indx]
mri_opacity_files = mri_opacity_files[indx]
indx = SORT(iron_opacity) & indx = SHIFT(indx, -1)
iron_opacity = iron_opacity[indx]
iron_opacity_files = iron_opacity_files[indx]
wStackerBase = WIDGET_BASE(wLeftBase)
wBrainTablesBase = WIDGET_BASE(wStackerBase, /COLUMN)
wPetColor = WIDGET_DROPLIST(wBrainTablesBase, $
VALUE=pet_color, $
TITLE='PET Colors', $
UVALUE='PET_COLOR', $
UNAME='Chapter10VolumeRender1:pet_color')
wPetOpacity = WIDGET_DROPLIST(wBrainTablesBase, $
VALUE=pet_opacity, $
TITLE='PET Opacities', $
UVALUE='PET_OPACITY', $
UNAME='Chapter10VolumeRender1:pet_opacity')
wIronTablesBase = WIDGET_BASE(wStackerBase, /COLUMN)
wIronColor = WIDGET_DROPLIST(wIronTablesBase, $
VALUE=iron_color, $
TITLE='Colors', $
UVALUE='IRON_COLOR', $
UNAME='Chapter10VolumeRender1:iron_color')
wIronOpacity = WIDGET_DROPLIST(wIronTablesBase, $
VALUE=iron_opacity, $
TITLE='Opacities', $
UVALUE='IRON_OPACITY', $
UNAME='Chapter10VolumeRender1:iron_opacity')
WIDGET_CONTROL, wIronTablesBase, MAP=0
wQuality = CW_BGROUP(wLeftBase, $
['medium (faster)', 'high'], $
LABEL_TOP='Rendering Quality:', $
/EXCLUSIVE, $
UVALUE='QUALITY', $
/NO_RELEASE, $
/FRAME)
WIDGET_CONTROL, wQuality, SET_UNAME='Chapter10VolumeRender1:quality_radio'
void = WIDGET_LABEL(wLeftBase, $
VALUE='Left Mouse-Button Action:', $
/ALIGN_LEFT)
wLMBMode = WIDGET_DROPLIST(wLeftBase, $ ; left mouse-button mode
VALUE=["Rotate Unconstrained", $
"Rotate about Screen X", $
"Rotate about Screen Y", $
"Rotate about Screen Z", $
"Rotate about Data X (Red)", $
"Rotate about Data Y (Green)", $
"Rotate about Data Z (Blue)", $
"Scale"], $
UVALUE='LMBMODE', $
UNAME='Chapter10VolumeRender1:mouse_mode', $
/ALIGN_LEFT)
wCuttingSlider = WIDGET_SLIDER(wLeftBase, $
TITLE='Cutting Plane %', $
UVALUE='CUTTING_PLANE', $
UNAME='Chapter10VolumeRender1:cutting_plane')
wRightbase = WIDGET_BASE(subBase)
;
; Use IDL's software renderer because it is fast at
; rendering volumes.
;
renderer=1
;
wDraw = WIDGET_DRAW(wRightBase, $
GRAPHICS_LEVEL=2, $
XSIZE=xdim, $
YSIZE=ydim, $
/BUTTON_EVENTS, $
UVALUE='DRAW', $
RETAIN=0, $
/EXPOSE_EVENTS, $
UNAME='Chapter10VolumeRender1:draw', $
RENDERER=renderer)
wHotKeyReceptor = WIDGET_TEXT(wRightBase, $
/ALL_EVENTS, $
UVALUE='HOTKEY', $
UNAME='Chapter10VolumeRender1:hotkey')
;
;Create the status line label.
;
wStatusBase = WIDGET_BASE(wBase, MAP=0, /ROW)
;
WIDGET_CONTROL, wBase, /REALIZE
WIDGET_CONTROL, /HOURGLASS
appTLB = wBase ; Returns the top level base to the APPTLB keyword.
sText = demo_getTips(demo_filepath('volrendr.tip', $
SUBDIR=['examples','demo', 'demotext']), $
wBase, $
wStatusBase)
WIDGET_CONTROL, wBase, /CLEAR_EVENTS
WIDGET_CONTROL, wBase, SENSITIVE=0
WIDGET_CONTROL, wStartMes, /SHOW
;
;Grab a refernce to the drawable.
;
WIDGET_CONTROL, wDraw, GET_VALUE=rWindow
;
;Compute viewplane rectangle to nicely fit our volumes.
;
zoom = sqrt(2) ; Nicety. (Length of unit-cube face diagonal.)
myview = [-.5, -.5, 1, 1] * zoom
;
;Grow viewplane rectangle to match wDraw's aspect ratio.
;
aspect = FLOAT(xdim)/FLOAT(ydim)
if (aspect gt 1) then begin
myview[0] = myview[0] - ((aspect-1.0)*myview[2])/2.0
myview[2] = myview[2] * aspect
end $
else begin
myview[1] = myview[1] - (((1.0/aspect)-1.0)*myview[3])/2.0
myview[3] = myview[3] / aspect
end
rView->SetProperty, $
VIEWPLANE_RECT=myview, $
PROJECTION=1, $
EYE=2.0, $
ZCLIP=[1.0,-1.0], $
COLOR=[0,0,0]
;
;Create a transparent view that is just like our established view.
;(Used for screen refreshes.)
;
rTransparentView = OBJ_NEW('IDLgrView', $
VIEWPLANE_RECT=myview, $
PROJECTION=1, $
EYE=2.0, $
ZCLIP=[1.0,-1.0], $
COLOR=[0,0,0], $
/TRANSPARENT $
)
;
if not keyword_set(record_to_filename) then $
record_to_filename = ''
;
;Save the state of our application.
;
pState = PTR_NEW({ $
center: [xdim, ydim] / 2., $ ; Center of drawing area.
radius: ydim / 2, $ ; Sphere radius (1/2 of draw area height)
axis: 3b, $ ; constrict Trackball rotations. 0=x,1=y,2=z,3=no.
btndown: 0b, $ ; which mouse button is pressed.
pt0: FLTARR(3), $ ; Position point 0
pt1: FLTARR(3), $ ; Position point 1
sc: FLTARR(3), $ ; Scaling factor for x, y, z directions
wDraw: wDraw, $ ; Widget draw ID
wHotKeyReceptor: wHotKeyReceptor, $
wLMBMode: wLMBMode, $
wRenderButton: wRenderButton, $
wAutoRenderButton: wAutoRenderButton, $
wLightButton: wLightButton, $
wWireBoxButton: wWireBoxButton, $
wAxesButton: wAxesButton, $
wCursorButton: wCursorButton, $
rModelArray: rModelArray, $ ; Model array
cur: 0, $ ; Current object shown (0=brain, 1=cloud)
rVolumeArray: rVolumeArray, $ ; Volume object references
rOtherObjectArray: rOtherObjectArray, $ ; Other object references
rScaleToys: rScaleToys, $
rScaleVolumes: rScaleVolumes, $
rPartialBox: rPartialBox, $
rRedSpoke: rRedSpoke, $
rGreenSpoke: rGreenSpoke, $
rBlueSpoke: rBlueSpoke, $
rView: rView, $ ; View object reference
font24: font24, $
rWindow: rWindow, $ ; Window object reference
rTransparentView: rTransparentView, $
rToysModel: rModelArray[0], $ ; Trinkets.
sText: sText, $ ; Text structure for tips
jpos: jack, $ ; Axes position
ColorTable: colorTable, $ ; Color table to restore
rText: rText, $ ; Text object refence
rFont: rFont, $ ; Font object refence
wBase: wBase, $ ; top level base
wBrainTablesBase: wBrainTablesBase, $
wIronTablesBase: wIronTablesBase, $
wCuttingSlider: wCuttingSlider, $
pet_color_files: pet_color_files, $
mri_color_files: mri_color_files, $
pet_opacity_files: pet_opacity_files, $
mri_opacity_files: mri_opacity_files, $
iron_color_files: iron_color_files, $
iron_opacity_files: iron_opacity_files, $
lmb_scale: 0, $ ; Left mouse button scaling mode: 0=not on, 1=on
suppress_draws: 1b, $ ; 1=yes, 0=no
auto_render:0, $ ; 1=yes, 0=no
screen_rotate:1b, $ ; 1=rotations are with respect to screen axes.
an_instance_exists: 0b, $
render_quality: 1, $ ; 1 ('medium') or 2 ('high')
pet_is_solid: 0b, $ ; boolean
pet_is_white: 0b, $ ; boolean
cursor_stale: 0B, $ ; 3D cursor up to date in graphic?
record_to_filename: record_to_filename, $
wVolBGroup: wVolBGroup, $
wQuality: wQuality, $
debug: keyword_set(debug), $
groupBase: groupBase $; Base of Group Leader
})
WIDGET_CONTROL, wBase, SET_UVALUE=pState
;
rModelArray[3]->Remove, rText
;
;Set MRI color and opacity.
;
Chapter10VolumeRender1SetTable, rVolumeArray[0], 0, mri_color_files[0]
Chapter10VolumeRender1SetTable, rVolumeArray[0], 1, mri_opacity_files[0]
;
;Manually send a sequence of clicks to initialize the application.
;
vol_select_event = { $
id: wVolBGroup, $
top: wBase, $
handler: 0L, $
select: 1, $
value: 0 $
}
Chapter10VolumeRender1Event, vol_select_event
WIDGET_CONTROL, wQuality, SET_VALUE=0
event = { $
id: wQuality, $
top: wBase, $
handler: 0L, $
select: 1, $
value: 0 $
}
Chapter10VolumeRender1Event, event
WIDGET_CONTROL, wPetColor, SET_DROPLIST_SELECT=1
event = {WIDGET_DROPLIST, $
id: wPetColor, $
top: wBase, $
handler: 0L, $
index: 1L $
}
Chapter10VolumeRender1Event, event
WIDGET_CONTROL, wPetOpacity, SET_DROPLIST_SELECT=0
event.index = 0L
event.id = wPetOpacity
Chapter10VolumeRender1Event, event
vol_select_event.value = 1
Chapter10VolumeRender1Event, vol_select_event
WIDGET_CONTROL, wIronColor, SET_DROPLIST_SELECT=1
event.id = wIronColor
event.index = 1
Chapter10VolumeRender1Event, event
WIDGET_CONTROL, wIronOpacity, SET_DROPLIST_SELECT=([0,2])[initial_volume]
event.id = wIronOpacity
event.index = ([0, 2])[initial_volume]
Chapter10VolumeRender1Event, event
WIDGET_CONTROL, wCuttingSlider, SET_VALUE=20
event = {WIDGET_SLIDER, $
id: wCuttingSlider, $
top: wBase, $
handler: 0L, $
value: 20L, $
drag:0 $
}
Chapter10VolumeRender1Event, event
Chapter10VolumeRender1Event, { $
id: wAxesButton, $
top: wBase, $
handler: 0L $
}
(*pState).suppress_draws = 0
WIDGET_CONTROL, wVolBGroup, SET_VALUE=initial_volume
vol_select_event.value = initial_volume
Chapter10VolumeRender1Event, vol_select_event
void = demo_startmes('Rendering volume data...', UPDATE=wStartMes)
event.id = wRenderButton
Chapter10VolumeRender1Event, event
;
;Now we are ready to handle user events.
;
WIDGET_CONTROL, wStartMes, /DESTROY
if XREGISTERED('demo_tour') eq 0 then $
WIDGET_CONTROL, wHotKeyReceptor, /INPUT_FOCUS
XMANAGER, 'Chapter10VolumeRender1', wBase, $
Event_Handler='Chapter10VolumeRender1Event', $
CLEANUP='Chapter10VolumeRender1Cleanup', $
/NO_BLOCK
WIDGET_CONTROL, wBase, SENSITIVE=1
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -