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

📄 chapter10volumerender1.pro

📁 IDL可视化分析与应用的源代码
💻 PRO
📖 第 1 页 / 共 5 页
字号:
            QUALITY=([0,(*pState).render_quality])[(*pState).auto_render]

        end
;
;   Hide or show the solid plane object.
;
    'SOLIDPLANE' : begin
        j = Chapter10VolumeRender1ToggleState(event.id)
        (*pState).rOtherObjectArray[1]->SetProperty, HIDE=1-j
        Chapter10VolumeRender1Draw, *pState, $
            QUALITY=([0,(*pState).render_quality])[(*pState).auto_render]
        end   ; of SOLIDPLANE
;
;   Show or hide the axis object.
;
    'AXES' : begin
        j = Chapter10VolumeRender1ToggleState(event.id)
        (*pState).rOtherObjectArray[7]->SetProperty,HIDE=1-j
        Chapter10VolumeRender1Draw, *pState, $
            QUALITY=([0,(*pState).render_quality])[(*pState).auto_render]
        end
;
;   Show or hide the 3D cursor object.

    'CURSOR' : begin
        j = Chapter10VolumeRender1ToggleState(event.id)
        (*pState).rOtherObjectArray[2]->SetProperty,HIDE=1-j
        Chapter10VolumeRender1Draw, *pState, $
            QUALITY=([0,(*pState).render_quality])[(*pState).auto_render]
        end
;
;   Set the user-indicated render step.
;
    'XSTEP' : begin
        (*pState).rVolumeArray[0]->GetProperty, RENDER_STEP=render_step
        render_step[0] = event.value + 1
        for i = 0, N_ELEMENTS((*pState).rVolumeArray)-1 do begin
            (*pState).rVolumeArray[i]->SetProperty, RENDER_STEP=render_step
            end

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

        end

    'YSTEP' : begin
        (*pState).rVolumeArray[0]->GetProperty, RENDER_STEP=render_step
        render_step[1] = event.value + 1
        for i = 0, N_ELEMENTS((*pState).rVolumeArray)-1 do begin
            (*pState).rVolumeArray[i]->SetProperty, RENDER_STEP=render_step
            end

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

        end

    'ZSTEP' : begin
        (*pState).rVolumeArray[0]->GetProperty, RENDER_STEP=render_step
        render_step[2] = event.value + 1
        for i = 0, N_ELEMENTS((*pState).rVolumeArray)-1 do begin
            (*pState).rVolumeArray[i]->SetProperty, RENDER_STEP=render_step
            end

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

        end
;
;   Set the user-indicated render quality.
;
    'QUALITY' : begin
        (*pState).render_quality = event.value + 1

        for i=0,N_ELEMENTS((*pState).rVolumeArray)-1 do begin
            (*pState).rVolumeArray[i]->SetProperty, INTERP=event.value
            end

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

        end
;
;   Handle events that occur in the drawing area.
;
    'DRAW': begin
        if (event.type eq 4) then begin ; Expose.
            Chapter10VolumeRender1Refresh, *pState
            endif

        if (event.type eq 0) then $
            if (event.press eq 1) AND ((*pState).lmb_scale eq 1) then $
                event.press = 2     ; virtual button 2 event.
;
;       Rotation updates.
;
        if (*pState).rModelArray[0]->Update(event) $
        or (*pState).rModelArray[1]->Update(event) then begin
            Chapter10VolumeRender1Draw, *pState, QUALITY=0
            end
;
;       Mouse button press.
;
        if (event.type eq 0) then begin
            case event.press of
                2 : begin
;
;                   Middle mouse-button.  Scale the objects.
;
                    xy = ([event.x, event.y] - (*pState).center)
                    r= TOTAL(xy^2) ; distance from center of unit circle
                    (*pState).sc[1] = SQRT(r)
                    (*pState).sc[2] = 1.0
                    end
                4 : begin
;
;                   Right mouse-button
;
                    (*pState).rWindow->GetProperty, QUALITY=current_quality
                    if (current_quality ge 1) then begin
;
;                       Pick a voxel point.
;
                        j = (*pState).rVolumeArray[(*pState).cur]->pickvoxel( $
                            (*pState).rWindow, $
                            (*pState).rView,[event.x, event.y] $
                            )
                        k = -1

                        if (j[0] NE -1) then begin
                            if (*pState).cur eq 0 then $; Get PET volume
                                (*pState).rVolumeArray[0]->GetProperty, $
                                    DATA1=dd, /NO_COPY $
                            else $
                                (*pState).rVolumeArray[ $
                                    (*pState).cur]->GetProperty, $
                                        DATA0=dd, /NO_COPY
                            k = dd[j[0],j[1],j[2]]
                            if (*pState).cur eq 0 then $; Set PET volume
                                (*pState).rVolumeArray[0]->SetProperty, $
                                        DATA1=dd, /NO_COPY $
                            else $
                                (*pState).rVolumeArray[ $
                                    (*pState).cur]->SetProperty, $
                                        DATA0=dd, /NO_COPY
                            end
;
;                       Display the point coordinates and its value.
;
                        str = string(   $
                            j[0],       $
                            j[1],       $
                            j[2],       $
                            k,          $
                            FORMAT='("X=",I3.3,",Y=",I3.3,",Z=",I3.3,' $
                                  +'",Value=",I3.3)' $
                            )
                        demo_putTips, (*pState), str, 10
                        end
                    end
                else:
                endcase
            (*pState).btndown = event.press
            WIDGET_CONTROL,(*pState).wDraw, /DRAW_MOTION
            endif
;
;       Mouse-button motion.
;
        if event.type eq 2 then begin
            case (*pState).btndown of
                4: begin ; Right mouse-button.
                    (*pState).rWindow->GetProperty, QUALITY=current_quality
                    if current_quality ge 1 then begin
                        j = (*pState).rVolumeArray[(*pState).cur]->pickvoxel( $
                                (*pState).rWindow, $
                                (*pState).rView,[event.x,event.y] $
                                )
                        k= -1

                        if (j[0] NE -1) then begin
                            if (*pState).cur eq 0 then $ ; Get PET volume
                                (*pState).rVolumeArray[0]->GetProperty, $
                                    DATA1=dd, /NO_COPY $
                            else $
                                (*pState).rVolumeArray[ $
                                    (*pState).cur]->GetProperty, $
                                        DATA0=dd, /NO_COPY
                            k = dd[j[0],j[1],j[2]]
                            if (*pState).cur eq 0 then $ ; Set PET volume
                                (*pState).rVolumeArray[0]->SetProperty, $
                                        DATA1=dd, /NO_COPY $
                            else $
                                (*pState).rVolumeArray[ $
                                    (*pState).cur]->SetProperty, $
                                        DATA0=dd, /NO_COPY
                            end
;
;                       Display the voxel location and value.
;
                        str = string(   $
                            j[0],       $
                            j[1],       $
                            j[2],       $
                            k,          $
                            FORMAT='("X=",I3.3,",Y=",I3.3,",Z=",I3.3,' $
                                  +'",Value=",I3.3)' $
                            )
                        demo_putTips, (*pState), str, 10
                        end
                    end
                2: begin
                    xy = ([event.x,event.y] - (*pState).center)
                    r = total(xy^2) ; distance from center of unit circle
                    (*pState).sc[2] = (SQRT(r) $
                                    / (*pState).sc[1]) $
                                    / (*pState).sc[2]
                    (*pState).rScaleToys->Scale, $
                        (*pState).sc[2], $
                        (*pState).sc[2], $
                        (*pState).sc[2]
                    (*pState).rScaleVolumes->Scale, $
                        (*pState).sc[2], $
                        (*pState).sc[2], $
                        (*pState).sc[2]
                    (*pState).rModelArray[0]->GetProperty, $
                        RADIUS=radius
                    (*pState).rModelArray[0]->SetProperty, $
                        RADIUS=radius*(*pState).sc[2]
                    (*pState).rModelArray[1]->SetProperty, $
                        RADIUS=radius*(*pState).sc[2]
                    (*pState).sc[2] = (SQRT(r)/(*pState).sc[1])
                    Chapter10VolumeRender1Draw, *pState, QUALITY=0
                    end
                else:
                endcase
            end
;
;       Mouse-button release.
;
        if (event.type eq 1) then begin
            case (*pState).btndown of
                2: begin
                    (*pState).sc[0] = (*pState).sc[2] * (*pState).sc[0]
                    end
                4: begin
                    (*pState).rWindow->GetProperty, QUALITY=current_quality
                    if current_quality ge 1 then begin
                        j = (*pState).rVolumeArray[(*pState).cur]->pickvoxel( $
                            (*pState).rWindow, $
                            (*pState).rView,[event.x,event.y] $
                            )
                        k = -1

                        if (j[0] NE -1) then begin
                            if (*pState).cur eq 0 then $ ; Get PET volume
                                (*pState).rVolumeArray[0]->GetProperty, $
                                    DATA1=dd, /NO_COPY $
                            else $
                                (*pState).rVolumeArray[ $
                                    (*pState).cur]->GetProperty, $
                                        DATA0=dd, /NO_COPY
                            k = dd[j[0],j[1],j[2]]
                            if (*pState).cur eq 0 then $ ; Set PET volume
                                (*pState).rVolumeArray[0]->SetProperty, $
                                        DATA1=dd, /NO_COPY $
                            else $
                                (*pState).rVolumeArray[ $
                                    (*pState).cur]->SetProperty, $
                                        DATA0=dd, /NO_COPY
;
;                           Get the volume's coordinate transform.
;
                            (*pState).rVolumeArray[ $
                                (*pState).cur]->GetProperty, $
                                        XCOORD_CONV=x_conv, $
                                        YCOORD_CONV=y_conv, $
                                        ZCOORD_CONV=z_conv
;
;                           Convert to normal coordinates.
;
                            jack = FLTARR(3)
                            jack[0] = x_conv[1]*j[0] + x_conv[0]
                            jack[1] = y_conv[1]*j[1] + y_conv[0]
                            jack[2] = z_conv[1]*j[2] + z_conv[0]
;
;                           Apply the difference.
;
                            (*pState).rOtherObjectArray[6]->Translate, $
                                jack[0]-(*pState).jpos[0], $
                                jack[1]-(*pState).jpos[1], $
                                jack[2]-(*pState).jpos[2]
;
;                           Store the new location.
;
                            (*pState).jpos = jack
;
                            (*pState).cursor_stale = 1b ; Until it is drawn.
                            (*pState).rOtherObjectArray[2]->GetProperty, $
                                HIDE=hide
                            if (hide eq 0) and ((*pState).auto_render eq 1) $
                            then $
                                Chapter10VolumeRender1Draw, *pState, $
                                    QUALITY=(*pState).render_quality
                            end
;
;                       Display the voxel location and value numerically.
;
                        str = string(   $
                            j[0],       $
                            j[1],       $
                            j[2],       $
                            k,          $
                            FORMAT='("X=",I3.3,",Y=",I3.3,",Z=",I3.3,' $
                                  +'",Value=",I3.3)' $
                            )
                        demo_putTips, (*pState), str, 10
                        end
                    end
                else:
                endcase

            if (*pState).auto_render then begin
                (*pState).rWindow->GetProperty, QUALITY=current_quality
                if current_quality ne (*pState).render_quality then $
                    Chapter10VolumeRender1Draw, *pState, QUALITY=(*pState).render_quality
                end

            (*pState).btndown = 0
            WIDGET_CONTROL, (*pState).wDraw, DRAW_MOTION=0

            endif

        end   ;of DRAW
;
;   Quit this application.
;
    'QUIT' : begin
        WIDGET_CONTROL, event.top, /DESTROY
        RETURN
        end   ; of QUIT

    'ABOUT' : begin
;
        ONLINE_HELP, $
           book=demo_filepath("Chapter10VolumeRender1.pdf", $
                   SUBDIR=['examples','demo','demohelp']), $
                   /FULL_PATH

        RETURN
        end   ; of ABOUT

    else:
    endcase

if XREGISTERED('demo_tour') eq 0 then $
    WIDGET_CONTROL, (*pState).wHotKeyReceptor, /INPUT_FOCUS

end
;
;----------------------------------------------------------------------------
;
;  Purpose:  Destroy the top objects and restore the previous
;         color table.

⌨️ 快捷键说明

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