📄 fmwndvr.cpp
字号:
} return RxFMWnd3DOutline::OnSetCursor(pWnd, nHitTest, message);}void RxFMWndVR::OnLButtonDown(UINT nFlags, CPoint point) { SetCapture(); m_ptOld = point; m_ptDown = point; int nTBCurMode = RxGetFrameMain()->GetTBCurMode(); switch(nTBCurMode) { case BTN_MEASURE_DISTANCE: SetDistanceFrom(point); break; case BTN_MEASURE_AREA: SetAreaCenter(point); break; case BTN_3DMPR_BASIC : { m_iMPRHitTest = theFMDocVR.MPR_HitTest(&point); if(m_iMPRHitTest != HT_3DMPR_NONE && m_iMPRHitTest != theFMDocVR.MPR_Get_Selected()) { theFMDocVR.MPR_Set_Selected(m_iMPRHitTest); RedrawWnd(FALSE); UpdateMPRWindow(); } break; } } RxFMWnd3DOutline::OnLButtonDown(nFlags, point);}BOOL RxFMWndVR::SetDistanceFrom(CPoint point){ int x=0, y=0, z=0; BOOL bFindPoint = FALSE; if(m_nSeries == RXSERIES_REF) { bFindPoint = m_pVRRefAgent->Get3DPoint(m_ptDown.x, m_ptDown.y, x, y, z); } else if(m_nSeries == RXSERIES_FLT) { bFindPoint = m_pVRFltAgent->Get3DPoint(m_ptDown.x, m_ptDown.y, x, y, z); } else { bFindPoint = FALSE; } RxLine *element=new RxLine; element->nType = LINE; element->fMeasurement = 0; element->bValid = bFindPoint; element->iFrom[0] = x; element->iFrom[1] = y; element->iFrom[2] = z; element->iTo[0] = element->iTo[1] = element->iTo[2] = -1; element->ptFrom = point; element->ptTo = point; m_lMeasure.AddTail(element); return TRUE;}BOOL RxFMWndVR::SetAreaCenter(CPoint point){ int x=0, y=0, z=0; BOOL bFindPoint = FALSE; if(m_nSeries == RXSERIES_REF) { bFindPoint = m_pVRRefAgent->Get3DPoint(m_ptDown.x, m_ptDown.y, x, y, z); } else if(m_nSeries == RXSERIES_FLT) { bFindPoint = m_pVRFltAgent->Get3DPoint(m_ptDown.x, m_ptDown.y, x, y, z); } else { bFindPoint = FALSE; }/* CString str; str.Format(_T("x=%d, y=%d, z=%d"), x,y,z); AfxMessageBox(str);*/ RxArea *element=new RxArea; element->nType = AREA; element->fMeasurement = 0; element->a = 0; element->b = 0; element->x = x; element->y = y; element->z = z; element->bValid = bFindPoint; m_lMeasure.AddTail(element); return bFindPoint;}BOOL RxFMWndVR::AnnotateMeasureDistance(CPoint point){ RxLine *pElement = (RxLine *)m_lMeasure.GetTail(); int x=0, y=0, z=0; BOOL bFindPoint = FALSE; // get 3d hit point if(m_nSeries == RXSERIES_REF) { bFindPoint = m_pVRRefAgent->Get3DPoint(point.x, point.y, x, y, z); } else if(m_nSeries == RXSERIES_FLT) { bFindPoint = m_pVRFltAgent->Get3DPoint(point.x, point.y, x, y, z); } if(pElement->bValid && bFindPoint) { pElement->iTo[0] = x; pElement->iTo[1] = y; pElement->iTo[2] = z; pElement->MakeDistance(); } else { delete pElement; m_lMeasure.RemoveTail(); } return TRUE;}BOOL RxFMWndVR::AnnotateMeasureArea(CPoint point){ RxArea *pElement = (RxArea *)m_lMeasure.GetTail(); if(!pElement->bValid) { delete pElement; m_lMeasure.RemoveTail(); } else { const double pi=3.1415926536; pElement->fMeasurement = fabs(pElement->a * pElement->b * pi); } return TRUE;}BOOL RxFMWndVR::AnnotateMeasureVolume(CPoint point){ CPoint offset = point - m_ptDown; if(offset.x*offset.x + offset.y*offset.y >= 3) return FALSE; int x=0, y=0, z=0; int nVoxelNum=-1; double fUnitVoxel=0, fVolume=0; if(m_nSeries == RXSERIES_REF) { if(m_pVRRefAgent->Get3DPoint(m_ptDown.x, m_ptDown.y, x, y, z)) { if(z==0) z++; nVoxelNum = m_pVRRefAgent->Growing3D(x,y,z); fUnitVoxel = RxGetVolumeData(RXSERIES_REF)->GetVoxelVolume(); fVolume = fUnitVoxel*nVoxelNum; } } else if(m_nSeries == RXSERIES_FLT) { if(m_pVRFltAgent->Get3DPoint(m_ptDown.x, m_ptDown.y, x, y, z)) { if(z==0) z++; nVoxelNum = m_pVRFltAgent->Growing3D(x,y,z); fUnitVoxel = RxGetVolumeData(RXSERIES_FLT)->GetVoxelVolume(); fVolume = fUnitVoxel*nVoxelNum; } } if(fVolume == 0) return FALSE; RxVolume *element=new RxVolume; element->nType = VOLUME; element->fMeasurement = fVolume; element->x = x; element->y = y; element->z = z; m_lMeasure.AddTail(element); return TRUE;}void RxFMWndVR::SetNeedRecalVolume(){ m_bNeedRecalVolume = TRUE;}BOOL RxFMWndVR::ReCalMeasureVolume(BOOL bNeedRecal){ if(!(m_bNeedRecalVolume || bNeedRecal)) return TRUE; m_bNeedRecalVolume = FALSE; POSITION pos = m_lMeasure.GetHeadPosition(); int size=m_lMeasure.GetCount(); while(pos != NULL) { RxMeasurement *pElement = (RxMeasurement *)m_lMeasure.GetNext(pos); if(pElement->nType != VOLUME) continue; RxVolume *pVolume = (RxVolume*)pElement; double fVolume = 0; int nVoxelNum=0; double fUnitVoxel=0; if(m_nSeries == RXSERIES_REF) { if(m_pVRRefAgent->IsInsideInCrop(pVolume->x, pVolume->y, pVolume->z)) { nVoxelNum = m_pVRRefAgent->Growing3D(pVolume->x, pVolume->y, pVolume->z); fUnitVoxel = RxGetVolumeData(RXSERIES_REF)->GetVoxelVolume(); fVolume = fUnitVoxel*nVoxelNum; } } else if(m_nSeries == RXSERIES_FLT) { if(m_pVRFltAgent->IsInsideInCrop(pVolume->x, pVolume->y, pVolume->z)) { nVoxelNum = m_pVRFltAgent->Growing3D(pVolume->x, pVolume->y, pVolume->z); fUnitVoxel = RxGetVolumeData(RXSERIES_FLT)->GetVoxelVolume(); fVolume = fUnitVoxel*nVoxelNum; } } pElement->fMeasurement = fVolume; } return TRUE;}BOOL RxFMWndVR::ClearAnnotationList(){ POSITION pos = m_lMeasure.GetHeadPosition(); while(pos != NULL) { RxMeasurement *pElement = (RxMeasurement *)m_lMeasure.GetNext(pos); if(pElement->nType == VOLUME) { RxVolume *pVolume = (RxVolume *)pElement; delete pVolume; } else if(pElement->nType == AREA) { RxArea *pArea = (RxArea *)pElement; delete pArea; } else if(pElement->nType == LINE) { RxLine *pLine = (RxLine *)pElement; delete pLine; } } m_lMeasure.RemoveAll(); return TRUE;}void RxFMWndVR::OnLButtonUp(UINT nFlags, CPoint point) { if(GetCapture() == this) { int nMeasureState = RxGetFrameMain()->GetTBCurMode(); BOOL bMeasureSuccess = FALSE; switch(nMeasureState) { case BTN_MEASURE_DISTANCE : bMeasureSuccess = AnnotateMeasureDistance(point); break; case BTN_MEASURE_AREA : bMeasureSuccess = AnnotateMeasureArea(point); break; case BTN_MEASURE_VOLUME : bMeasureSuccess = AnnotateMeasureVolume(point); if(!bMeasureSuccess) { CString str; str.Format(_T("Render time=%d"),m_pVRRefInfo->m_iElapsedTime); AfxMessageBox(str); } break;/* CString0 str; str.Format(_T("x=%d, y=%d, z=%d, %fcc"), x,y,z, fVolume); AfxMessageBox(str);*/ } ReleaseCapture(); if(nMeasureState) RedrawWnd(FALSE); } RxFMWnd3DOutline::OnLButtonUp(nFlags, point);}void RxFMWndVR::OnRButtonDown(UINT nFlags, CPoint point) { SetCursor(AfxGetApp()->LoadCursor(IDC_CURSOR_ROTATE)); SetCapture(); m_ptOld = point; RxFMWnd3DOutline::OnRButtonDown(nFlags, point);}void RxFMWndVR::OnRButtonUp(UINT nFlags, CPoint point) { if(GetCapture() == this) ReleaseCapture(); RxFMWnd3DOutline::OnRButtonUp(nFlags, point);}void RxFMWndVR::OnMouseMove(UINT nFlags, CPoint point) { if(GetCapture() != this) { RxFMWnd3DOutline::OnMouseMove(nFlags, point); // invlalid魄沥/ return; } CPoint ptDiff = point - m_ptOld; CPoint ptDn2Mv = point - m_ptDown; if(ptDiff.x == 0 && ptDiff.y == 0) { RxFMWnd3DOutline::OnMouseMove(nFlags, point); return; } int nTBCurMode = RxGetFrameMain()->GetTBCurMode(); if(nFlags & MK_LBUTTON) { switch(nTBCurMode) { case BTN_MEASURE_DISTANCE: { RxLine *pElement = (RxLine *)m_lMeasure.GetTail(); if(pElement->bValid) { pElement->ptTo = point; RedrawWnd(FALSE); } } break; case BTN_MEASURE_AREA: { RxArea *pElement = (RxArea *)m_lMeasure.GetTail(); if(pElement->bValid) { double fVoxelLength = (m_nSeries == RXSERIES_REF) ? RxGetVolumeData(RXSERIES_REF)->GetVoxelLength() : RxGetVolumeData(RXSERIES_FLT)->GetVoxelLength(); pElement->a = ptDn2Mv.x * fVoxelLength * 100 / theFMDocVR.m_iVRZoomFactor; pElement->b = ptDn2Mv.y * fVoxelLength * 100 / theFMDocVR.m_iVRZoomFactor; RedrawWnd(FALSE); } } break; case BTN_PAN : m_ptPan += ptDiff; RedrawWnd(TRUE); break; case BTN_ZOOM : { int iCurZoomFactor = theFMDocVR.m_iVRZoomFactor; int iOldZoomFactor = iCurZoomFactor; iCurZoomFactor -= ptDiff.y; iCurZoomFactor = __min(300, __max(iCurZoomFactor, 50)); double zoomRatio = double(iCurZoomFactor) / double(iOldZoomFactor); m_ptPan.x = int(zoomRatio * m_ptPan.x + 0.5); m_ptPan.y = int(zoomRatio * m_ptPan.y + 0.5); theFMDocVR.m_iVRZoomFactor = iCurZoomFactor; RxGetFrameBottom()->SetZoomFactor(iCurZoomFactor); RedrawWnd(TRUE); break; } case BTN_3DMPR_BASIC : { if(m_iMPRHitTest == HT_3DMPR_NONE) break; _3DMPR_INFO *stPtrMPR = theFMDocVR.MPR_Get_Struct(); if(stPtrMPR->iSelected == HT_3DMPR_HORIZONTAL) { stPtrMPR->ptCenter.y += ptDiff.y; RedrawWnd(FALSE); UpdateMPRWindow(); } else if(stPtrMPR->iSelected == HT_3DMPR_VERTICAL) { stPtrMPR->ptCenter.x += ptDiff.x; RedrawWnd(FALSE); UpdateMPRWindow(); } else if(stPtrMPR->iSelected == HT_3DMPR_CIRCLE) { stPtrMPR->ptCenterSlant.x += ptDiff.x; stPtrMPR->ptCenterSlant.y += ptDiff.y; RedrawWnd(FALSE); UpdateMPRWindow(); } else if(stPtrMPR->iSelected == HT_3DMPR_SLANT) { double dDistance = sqrt((ptDiff.x * ptDiff.x) + (ptDiff.y * ptDiff.y)); CPoint Vector1, Vector2; double dCosine, dDir; Vector1.x = m_ptOld.x - stPtrMPR->ptCenterSlant.x; Vector1.y = m_ptOld.y - stPtrMPR->ptCenterSlant.y; Vector2.x = point.x - stPtrMPR->ptCenterSlant.x; Vector2.y = point.y - stPtrMPR->ptCenterSlant.y; dCosine = (Vector1.x*Vector2.x + Vector1.y*Vector2.y) / (sqrt((double)(Vector1.x*Vector1.x + Vector1.y*Vector1.y))* sqrt((double)(Vector2.x*Vector2.x + Vector2.y*Vector2.y))); dDir = (double)(Vector1.x * Vector2.y - Vector1.y * Vector2.x); if(dDir <= 0) stPtrMPR->iCircleAngle += ROUNDOFF(acos(dCosine)*180/M_PI); else stPtrMPR->iCircleAngle -= ROUNDOFF(acos(dCosine)*180/M_PI); if(stPtrMPR->iCircleAngle < 0) stPtrMPR->iCircleAngle += 360; stPtrMPR->iCircleAngle %= 360; RedrawWnd(FALSE); UpdateMPRWindow(); } break; } } } else if(nFlags & MK_RBUTTON) { if(PerformRotateByOffset(ptDiff)) RedrawWnd(TRUE); if(nTBCurMode == BTN_3DMPR_BASIC) UpdateMPRWindow(); } m_ptOld = point; RxFMWnd3DOutline::OnMouseMove(nFlags, point);}BOOL RxFMWndVR::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt) { double zDegree = -zDelta/120.; m_mxRotation.Rotate(2, zDegree); // Z_AXIS RedrawWnd(TRUE); return RxFMWnd3DOutline::OnMouseWheel(nFlags, zDelta, pt);}////////////////////////////////////////////// 2. message handlers from frame bottomvoid RxFMWndVR::OnChangedZoomFactor(NMHDR* pNMHDR, LRESULT* pResult){ NMED_INT *pNMED = (NMED_INT *)pNMHDR; theFMDocVR.m_iVRZoomFactor = pNMED->nEdit; RedrawWnd(TRUE); *pResult = 0;}////////////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -