⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chapter10volumerender1.pro

📁 IDL可视化分析与应用的源代码
💻 PRO
📖 第 1 页 / 共 5 页
字号:
                (*pState).lmb_scale = 0
                (*pState).axis = 2
                (*pState).rModelArray[0]->SetProperty, AXIS=2, /CONSTRAIN
                (*pState).rModelArray[1]->SetProperty, AXIS=2, /CONSTRAIN
                WIDGET_CONTROL, (*pState).wLMBMode, SET_DROPLIST_SELECT=3
                end
            'R': begin
                (*pState).lmb_scale = 0
                (*pState).axis = 0
                (*pState).rModelArray[0]->SetProperty, AXIS=0, CONSTRAIN=2
                (*pState).rModelArray[1]->SetProperty, AXIS=0, CONSTRAIN=2
                WIDGET_CONTROL, (*pState).wLMBMode, SET_DROPLIST_SELECT=4
                end
            'G': begin
                (*pState).lmb_scale = 0
                (*pState).axis = 1
                (*pState).rModelArray[0]->SetProperty, AXIS=1, CONSTRAIN=2
                (*pState).rModelArray[1]->SetProperty, AXIS=1, CONSTRAIN=2
                WIDGET_CONTROL, (*pState).wLMBMode, SET_DROPLIST_SELECT=5
                end
            'B': begin
                (*pState).lmb_scale = 0
                (*pState).axis = 2
                (*pState).rModelArray[0]->SetProperty, AXIS=2, CONSTRAIN=2
                (*pState).rModelArray[1]->SetProperty, AXIS=2, CONSTRAIN=2
                WIDGET_CONTROL, (*pState).wLMBMode, SET_DROPLIST_SELECT=6
                end
            'S': begin
                (*pState).lmb_scale = 1
                WIDGET_CONTROL, (*pState).wLMBMode, SET_DROPLIST_SELECT=7
                end
            else:
            endcase
        (*pState).rModelArray[0]->GetProperty, CONSTRAIN=constrain
        if constrain eq 2 and STRUPCASE(event.ch) ne 'S' then begin
            if Chapter10VolumeRender1ToggleState((*pState).wAxesButton) eq 0 then $
                void = Chapter10VolumeRender1ToggleState((*pState).wAxesButton) $
            else begin
                (*pState).rOtherObjectArray[7]->SetProperty, HIDE=0
                Chapter10VolumeRender1Draw, *pState, $
                    QUALITY= $
                        ([0,(*pState).render_quality])[(*pState).auto_render]
                end
            end
        end
    'LMBMODE' : begin ; Left Mouse-Button Mode.
        case event.index of
            0: begin ; unconstrained rotation
                (*pState).lmb_scale = 0
                (*pState).axis = 3
                (*pState).rModelArray[0]->SetProperty, CONSTRAIN=0
                (*pState).rModelArray[1]->SetProperty, CONSTRAIN=0
                end
            1: begin
                (*pState).lmb_scale = 0
                (*pState).axis = 0
                (*pState).rModelArray[0]->SetProperty, AXIS=0, /CONSTRAIN
                (*pState).rModelArray[1]->SetProperty, AXIS=0, /CONSTRAIN
                (*pState).screen_rotate = 1
                end
            2: begin
                (*pState).lmb_scale = 0
                (*pState).axis = 1
                (*pState).rModelArray[0]->SetProperty, AXIS=1, /CONSTRAIN
                (*pState).rModelArray[1]->SetProperty, AXIS=1, /CONSTRAIN
                end
            3: begin
                (*pState).lmb_scale = 0
                (*pState).axis = 2
                (*pState).rModelArray[0]->SetProperty, AXIS=2, /CONSTRAIN
                (*pState).rModelArray[1]->SetProperty, AXIS=2, /CONSTRAIN
                end
            4: begin
                (*pState).lmb_scale = 0
                (*pState).axis = 0
                (*pState).rModelArray[0]->SetProperty, AXIS=0, CONSTRAIN=2
                (*pState).rModelArray[1]->SetProperty, AXIS=0, CONSTRAIN=2
                end
            5: begin
                (*pState).lmb_scale = 0
                (*pState).axis = 1
                (*pState).rModelArray[0]->SetProperty, AXIS=1, CONSTRAIN=2
                (*pState).rModelArray[1]->SetProperty, AXIS=1, CONSTRAIN=2
                end
            6: begin
                (*pState).lmb_scale = 0
                (*pState).axis = 2
                (*pState).rModelArray[0]->SetProperty, AXIS=2, CONSTRAIN=2
                (*pState).rModelArray[1]->SetProperty, AXIS=2, CONSTRAIN=2
                end
            7: begin
                (*pState).lmb_scale = 1
                end
            else:
            endcase
        (*pState).rModelArray[0]->GetProperty, CONSTRAIN=constrain
        if constrain eq 2 and event.index ne 7 then begin
            if Chapter10VolumeRender1ToggleState((*pState).wAxesButton) eq 0 then $
                void = Chapter10VolumeRender1ToggleState((*pState).wAxesButton) $
            else begin
                (*pState).rOtherObjectArray[7]->SetProperty, HIDE=0
                Chapter10VolumeRender1Draw, *pState, $
                    QUALITY= $
                        ([0,(*pState).render_quality])[(*pState).auto_render]
                end
            end
        end
    'CUTTING_PLANE' : begin
        for i=0,N_ELEMENTS((*pState).rVolumeArray)-1 do begin
            (*pState).rVolumeArray[i]->GetProperty, YRANGE=yrange
            (*pState).rVolumeArray[i]->SetProperty, $
                CUTTING_PLANE=[0,1,0, -(event.value / 100.) * yrange[1]]
            end

        Chapter10VolumeRender1Draw, *pState, $
            QUALITY=([0,(*pState).render_quality])[(*pState).auto_render]
        end
    'PET_COLOR' : begin
        Chapter10VolumeRender1SetTable,             $
            (*pState).rVolumeArray[(*pState).cur],  $
            0,                          $
            (*pState).pet_color_files[event.index], $
            MULTI_VOL=1

        white_name = demo_filepath( $
            'white_pet.pal', $; file that contains uniform, pure white.
            SUBDIR=['examples','demo','demodata'] $
            )

        if STRPOS((*pState).pet_color_files[event.index], white_name) $
        eq 0 then $
            (*pState).pet_is_white = 1b $
        else $
            (*pState).pet_is_white = 0b

        if (*pState).pet_is_white and (*pState).pet_is_solid then $
;
;           We don't need to render the PET part of the dual volume.
;
            (*pState).rVolumeArray[(*pState).cur]->SetProperty, $
                VOLUME_SELECT=0 $
        else $
            (*pState).rVolumeArray[(*pState).cur]->SetProperty, $
                VOLUME_SELECT=1

        Chapter10VolumeRender1Draw, *pState, $
            QUALITY=([0,(*pState).render_quality])[(*pState).auto_render]
        end
    'PET_OPACITY' : begin
        Chapter10VolumeRender1SetTable,             $
            (*pState).rVolumeArray[(*pState).cur],  $
            1,                          $
            (*pState).pet_opacity_files[event.index], $
            MULTI_VOL=1

        solid_name = demo_filepath( $
            'solid_pet.opa', $ ; file that contains uniform solid values
            SUBDIR=['examples','demo','demodata'] $
            )

        if STRPOS((*pState).pet_opacity_files[event.index], solid_name) $
        eq 0 then $
            (*pState).pet_is_solid = 1b $
        else $
            (*pState).pet_is_solid = 0b

        if (*pState).pet_is_white and (*pState).pet_is_solid then $
;
;           We don't need to render the PET part of the dual volume.
;
            (*pState).rVolumeArray[(*pState).cur]->SetProperty, $
                VOLUME_SELECT=0 $
        else $
            (*pState).rVolumeArray[(*pState).cur]->SetProperty, $
                VOLUME_SELECT=1

        Chapter10VolumeRender1Draw, *pState, $
            QUALITY=([0,(*pState).render_quality])[(*pState).auto_render]
        end
    'MRI_COLOR' : begin
        Chapter10VolumeRender1SetTable,             $
            (*pState).rVolumeArray[(*pState).cur],  $
            0,                          $
            (*pState).mri_color_files[event.index]

        Chapter10VolumeRender1Draw, *pState, $
            QUALITY=([0,(*pState).render_quality])[(*pState).auto_render]
        end
    'MRI_OPACITY' : begin
        Chapter10VolumeRender1SetTable,             $
            (*pState).rVolumeArray[(*pState).cur],  $
            1,                          $
            (*pState).mri_opacity_files[event.index]

        Chapter10VolumeRender1Draw, *pState, $
            QUALITY=([0,(*pState).render_quality])[(*pState).auto_render]
        end
    'IRON_COLOR' : begin
        Chapter10VolumeRender1SetTable,             $
            (*pState).rVolumeArray[(*pState).cur],  $
            0,                          $
            (*pState).iron_color_files[event.index]

        Chapter10VolumeRender1Draw, *pState, $
            QUALITY=([0,(*pState).render_quality])[(*pState).auto_render]
        end
    'IRON_OPACITY' : begin
        Chapter10VolumeRender1SetTable,             $
            (*pState).rVolumeArray[(*pState).cur],  $
            1,                          $
            (*pState).iron_opacity_files[event.index]

        if STRPOS((*pState).iron_opacity_files[event.index], "shells") ne -1 $
        then begin
;
;           For nicety, turn on gradient shading.  It looks good with our
;           "shells" opacity.
;
            WIDGET_CONTROL, (*pState).wLightButton, /SET_BUTTON
            Chapter10VolumeRender1Event, { $
                id: (*pState).wLightButton, $
                top: event.top, $
                handler: 0L, $
                select: 1 $
                }
            end $
        else $
            Chapter10VolumeRender1Draw, *pState, $
                QUALITY=([0,(*pState).render_quality])[(*pState).auto_render]
        end
;
;   Render the image and display it.
;
    'RENDER' : begin
        Chapter10VolumeRender1Draw, *pState, QUALITY=(*pState).render_quality
        end
;
;   Set on or off the auto rendering property.
;
    'AUTORENDER' : begin
        (*pState).auto_render = event.select
        WIDGET_CONTROL, (*pState).wRenderButton, $
            SENSITIVE=([1, 0])[event.select]
        if (*pState).auto_render then begin
            (*pState).rWindow->GetProperty, QUALITY=current_quality

            (*pState).rOtherObjectArray[2]->GetProperty, $ ; 3D Cursor.
                HIDE=hide

            if ((hide eq 0) and (*pState).cursor_stale) $
            or (current_quality ne (*pState).render_quality) then $
                Chapter10VolumeRender1Draw, *pState, QUALITY=(*pState).render_quality
            end
        end   ; of AUTORENDER
;
;   Select a volume to display.
;
    'VOLSEL': begin
        (*pState).cur = event.value
;
;       Hide the annnotation text (all 3).
;
        for i=3,5 do (*pState).rOtherObjectArray[i]->SetProperty, HIDE=1

        case event.value of
;
;           Show the brain.
;
            0: begin
                (*pState).rVolumeArray[0]->SetProperty, HIDE=0
                (*pState).rVolumeArray[1]->SetProperty, HIDE=1
                (*pState).rOtherObjectArray[4]->SetProperty, HIDE=0

                if not (*pState).suppress_draws then begin
                    WIDGET_CONTROL, (*pState).wBrainTablesBase, MAP=1
                    WIDGET_CONTROL, (*pState).wIronTablesBase,  MAP=0
                    end

                Chapter10VolumeRender1Draw, *pState, $
                    QUALITY=$
                        ([0,(*pState).render_quality])[(*pState).auto_render]
                end
;
;           Show the Electron Cloud.
;
            1: begin
                (*pState).rVolumeArray[0]->SetProperty, HIDE=1
                (*pState).rVolumeArray[1]->SetProperty, HIDE=0
                (*pState).rOtherObjectArray[5]->SetProperty, HIDE=0

                if not (*pState).suppress_draws then begin
                    (*pState).suppress_draws = 1

                    WIDGET_CONTROL, (*pState).wBrainTablesBase, MAP=0
                    WIDGET_CONTROL, (*pState).wIronTablesBase,  MAP=1

                    WIDGET_CONTROL, (*pState).wCuttingSlider, SET_VALUE=0
                        Chapter10VolumeRender1Event, { $
                            id: (*pState).wCuttingSlider, $
                            top: event.top, $
                            handler: 0L, $
                            value: 0, $
                            drag: 0 $
                            }

;
;                   Show the wire box.  Looks nice.
;
                    if Chapter10VolumeRender1ToggleState((*pState).wWireBoxButton) eq 0 $
                    then $
                        void = Chapter10VolumeRender1ToggleState((*pState).wWireBoxButton)
                    (*pState).rOtherObjectArray[0]->SetProperty, HIDE=0
;
;                   If we are not under a data-centric rotation constraint,
;                   then hide the axes.  Looks nicer.
;
                    (*pState).rModelArray[1]->GetProperty, CONSTRAIN=constrain
                    if constrain ne 2 then begin
                        if Chapter10VolumeRender1ToggleState((*pState).wAxesButton) eq 1 $
                        then $
                            void=Chapter10VolumeRender1ToggleState((*pState).wAxesButton) $
                        else begin
                            (*pState).rOtherObjectArray[7]->SetProperty, HIDE=1
                            Chapter10VolumeRender1Draw, *pState, $
                                QUALITY= $
                                    ([0,(*pState).render_quality]) $
                                        [(*pState).auto_render]
                            end
                        end
;
                    (*pState).suppress_draws = 0
                    end

                Chapter10VolumeRender1Draw, *pState, $
                    QUALITY= $
                        ([0,(*pState).render_quality])[(*pState).auto_render]

                end

            endcase

        end   ; of VOLSEL
;
;   Turn on or off the lights.
;
    'LIGHTING': begin
        for i = 0, N_ELEMENTS((*pState).rVolumeArray)-1 do begin
            (*pState).rVolumeArray[i]->SetProperty, $
                LIGHTING_MODEL=event.select
            endfor

        Chapter10VolumeRender1Draw, *pState, $
            QUALITY=([0,(*pState).render_quality])[(*pState).auto_render]

        end   ; of LIGHTING
;
;   Hide or show the wire box object.
;
    'WIREBOX' : begin
        j = Chapter10VolumeRender1ToggleState(event.id)
        (*pState).rOtherObjectArray[0]->SetProperty, HIDE=1-j

        Chapter10VolumeRender1Draw, *pState, $

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -