📄 fmwndvr.cpp
字号:
ptFrom = pLine->ptFrom; ptTo = pLine->ptTo; } else { RxVect4D vecFrom(pLine->iFrom[0], pLine->iFrom[1], pLine->iFrom[2]); RxVect4D vecTo(pLine->iTo[0], pLine->iTo[1], pLine->iTo[2]); RxVect4D vecImageFrom = mxView * vecFrom; RxVect4D vecImageTo = mxView * vecTo; ptFrom.x = ROUNDOFF(vecImageFrom.m[0]); ptFrom.y = ROUNDOFF(vecImageFrom.m[1]); ptTo.x = ROUNDOFF(vecImageTo.m[0]); ptTo.y = ROUNDOFF(vecImageTo.m[1]); } CPen linePen(PS_SOLID, 2, pElement->color); CPen *pOldPen = (CPen *)pDC->SelectObject(&linePen); pDC->MoveTo(ptFrom); pDC->LineTo(ptTo); pDC->SelectObject(pOldPen); linePen.DeleteObject(); if(pLine->fMeasurement) { str.Format(_T("%2.2f"),pLine->fMeasurement); CPoint ptCenter = ptFrom + ptTo; ptCenter.x /= 2; ptCenter.y /= 2; pDC->TextOut(ptCenter.x+iOffsetX, ptCenter.y+iOffsetY, str); pDC->MoveTo(ptCenter); pDC->LineTo(ptCenter+pElement->ptTextOffset); } } pen.DeleteObject(); } pDC->SelectObject(OldPen); Pen.DeleteObject(); pDC->SelectObject(pOldBrush); brush.DeleteObject();}void RxFMWndVR::DrawOnePlane(CDC *pDC, RxVect4D vtPt1, RxVect4D vtPt2, RxVect4D vtPt3, RxVect4D vtPt4){ pDC->MoveTo(ROUNDOFF(vtPt1[0]), ROUNDOFF(vtPt1[1])); pDC->LineTo(ROUNDOFF(vtPt2[0]), ROUNDOFF(vtPt2[1])); pDC->LineTo(ROUNDOFF(vtPt3[0]), ROUNDOFF(vtPt3[1])); pDC->LineTo(ROUNDOFF(vtPt4[0]), ROUNDOFF(vtPt4[1])); pDC->LineTo(ROUNDOFF(vtPt1[0]), ROUNDOFF(vtPt1[1]));}void RxFMWndVR::DrawBoundingBoxWhole(CDC *pDC) { CPen pen, *pOldPen; pen.CreatePen(PS_DOT, 1, RGB(127,127,127)); pOldPen = pDC->SelectObject(&pen); //BEGIN::快急 visible planes阑 弊妨霖促. if(m_abPlaneVisible[PLANE_ZMIN]) // Z-Min 乞搁捞 visible DrawOnePlane(pDC, m_aptApex[0], m_aptApex[1], m_aptApex[2], m_aptApex[3]); if(m_abPlaneVisible[PLANE_ZMAX]) // Z-Max 乞搁捞 visible DrawOnePlane(pDC, m_aptApex[4], m_aptApex[5], m_aptApex[6], m_aptApex[7]); if(m_abPlaneVisible[PLANE_XMAX]) // X-Max 乞搁捞 visible DrawOnePlane(pDC, m_aptApex[1], m_aptApex[5], m_aptApex[6], m_aptApex[2]); if(m_abPlaneVisible[PLANE_XMIN]) // X-Min 乞搁捞 visible DrawOnePlane(pDC, m_aptApex[0], m_aptApex[4], m_aptApex[7], m_aptApex[3]); if(m_abPlaneVisible[PLANE_YMIN]) // Y-Min 乞搁捞 visible DrawOnePlane(pDC, m_aptApex[0], m_aptApex[1], m_aptApex[5], m_aptApex[4]); if(m_abPlaneVisible[PLANE_YMAX]) // Y-Max 乞搁捞 visible DrawOnePlane(pDC, m_aptApex[3], m_aptApex[2], m_aptApex[6], m_aptApex[7]); //END::快急 visible planes阑 弊妨霖促. pDC->SelectObject(pOldPen); pen.DeleteObject();}void RxFMWndVR::DrawBoundingBoxCrop(CDC *pDC){ CPen pen, *pOldPen; pen.CreatePen(PS_SOLID, 2, RGB(255,170,255)); pOldPen = pDC->SelectObject(&pen); //BEGIN::快急 visible planes阑 弊妨霖促. if(m_abPlaneVisible[PLANE_ZMIN]) // Z-Min 乞搁捞 visible DrawOnePlane(pDC, m_aptApexCrop[0], m_aptApexCrop[1], m_aptApexCrop[2], m_aptApexCrop[3]); if(m_abPlaneVisible[PLANE_ZMAX]) // Z-Max 乞搁捞 visible DrawOnePlane(pDC, m_aptApexCrop[4], m_aptApexCrop[5], m_aptApexCrop[6], m_aptApexCrop[7]); if(m_abPlaneVisible[PLANE_XMAX]) // X-Max 乞搁捞 visible DrawOnePlane(pDC, m_aptApexCrop[1], m_aptApexCrop[5], m_aptApexCrop[6], m_aptApexCrop[2]); if(m_abPlaneVisible[PLANE_XMIN]) // X-Min 乞搁捞 visible DrawOnePlane(pDC, m_aptApexCrop[0], m_aptApexCrop[4], m_aptApexCrop[7], m_aptApexCrop[3]); if(m_abPlaneVisible[PLANE_YMIN]) // Y-Min 乞搁捞 visible DrawOnePlane(pDC, m_aptApexCrop[0], m_aptApexCrop[1], m_aptApexCrop[5], m_aptApexCrop[4]); if(m_abPlaneVisible[PLANE_YMAX]) // Y-Max 乞搁捞 visible DrawOnePlane(pDC, m_aptApexCrop[3], m_aptApexCrop[2], m_aptApexCrop[6], m_aptApexCrop[7]); //END::快急 visible planes阑 弊妨霖促. pDC->SelectObject(pOldPen); pen.DeleteObject();}void RxFMWndVR::DrawMPRLine(CDC *pDC){ COLORREF crSelect = RGB(220,254,129); COLORREF crNormal = RGB( 0,255, 0); COLORREF crSphere = RGB(220,254,129); _3DMPR_INFO *pStMPR = theFMDocVR.MPR_Get_Struct(); // Horizontal line CPen pen, *pOldPen; if(pStMPR->iSelected == HT_3DMPR_HORIZONTAL) pen.CreatePen(PS_SOLID, 2, crSelect); else pen.CreatePen(PS_SOLID, 1, crNormal); pOldPen = pDC->SelectObject(&pen); pDC->MoveTo( 0, pStMPR->ptCenter.y); pDC->LineTo(m_szWindow.cx, pStMPR->ptCenter.y); pDC->SelectObject(pOldPen); pen.DeleteObject(); // Vertical line if(pStMPR->iSelected == HT_3DMPR_VERTICAL) pen.CreatePen(PS_SOLID, 2, crSelect); else pen.CreatePen(PS_SOLID, 1, crNormal); pOldPen = pDC->SelectObject(&pen); pDC->MoveTo(pStMPR->ptCenter.x, 0); pDC->LineTo(pStMPR->ptCenter.x, m_szWindow.cy); pDC->SelectObject(pOldPen); pen.DeleteObject(); // Slant line CPoint ptStart, ptEnd; if(pStMPR->iSelected == HT_3DMPR_SLANT || pStMPR->iSelected == HT_3DMPR_CIRCLE) pen.CreatePen(PS_SOLID, 2, crSelect); else pen.CreatePen(PS_SOLID, 1, crNormal); pOldPen = pDC->SelectObject(&pen); theFMDocVR.MPR_GetSlantPoint(&ptStart, &ptEnd, m_szWindow); pDC->MoveTo(ptStart); pDC->LineTo(ptEnd); pDC->SelectObject(pOldPen); pen.DeleteObject(); // Center circle if(pStMPR->iSelected == HT_3DMPR_CIRCLE) pen.CreatePen(PS_SOLID, 2, crSphere); else pen.CreatePen(PS_SOLID, 1, crNormal); pOldPen = pDC->SelectObject(&pen); CRect rcTemp; rcTemp.left = pStMPR->ptCenterSlant.x - MPR_CIRCLE_RADIUS; rcTemp.top = pStMPR->ptCenterSlant.y + MPR_CIRCLE_RADIUS; rcTemp.right = pStMPR->ptCenterSlant.x + MPR_CIRCLE_RADIUS; rcTemp.bottom = pStMPR->ptCenterSlant.y - MPR_CIRCLE_RADIUS; ptStart.x = pStMPR->ptCenterSlant.x - MPR_CIRCLE_RADIUS; ptStart.y = pStMPR->ptCenterSlant.y; ptEnd.x = pStMPR->ptCenterSlant.x - MPR_CIRCLE_RADIUS; ptEnd.y = pStMPR->ptCenterSlant.y; pDC->Arc(rcTemp, ptStart, ptEnd); pDC->SelectObject(pOldPen); pen.DeleteObject();}void RxFMWndVR::DrawOrientationCube(CDC *pDC){ // Orientation cube狼 viewing matrix int iOriCubeMargin = 10; double dOriCubeSize = 40.; double dOriCubeSizeHalf = dOriCubeSize / 2.; RxMatrix4D mxOriCube; mxOriCube.LoadIdentity(); mxOriCube.Translate(dOriCubeSize, m_szWindow.cy - dOriCubeSize, dOriCubeSizeHalf); RxMatrix4D mxOriCubeCenterScale; mxOriCubeCenterScale.LoadIdentity(); mxOriCubeCenterScale.Translate(-dOriCubeSizeHalf, -dOriCubeSizeHalf, -dOriCubeSizeHalf); mxOriCube = mxOriCube * m_mxRotation * mxOriCubeCenterScale; RxVect4D aptOriCubeApex[8]; aptOriCubeApex[0] = mxOriCube * RxVect4D( 0, 0, 0, 1); aptOriCubeApex[1] = mxOriCube * RxVect4D(dOriCubeSize, 0, 0, 1); aptOriCubeApex[2] = mxOriCube * RxVect4D(dOriCubeSize, dOriCubeSize, 0, 1); aptOriCubeApex[3] = mxOriCube * RxVect4D( 0, dOriCubeSize, 0, 1); aptOriCubeApex[4] = mxOriCube * RxVect4D( 0, 0, dOriCubeSize, 1); aptOriCubeApex[5] = mxOriCube * RxVect4D(dOriCubeSize, 0, dOriCubeSize, 1); aptOriCubeApex[6] = mxOriCube * RxVect4D(dOriCubeSize, dOriCubeSize, dOriCubeSize, 1); aptOriCubeApex[7] = mxOriCube * RxVect4D( 0, dOriCubeSize, dOriCubeSize, 1); int nSavedDC = pDC->SaveDC(); pDC->SetBkMode(TRANSPARENT); pDC->SetTextAlign(TA_CENTER|TA_LEFT); pDC->SetTextColor(RGB(195,195,255)); CPen pen, *pOldPen; pen.CreatePen(PS_SOLID, 1, RGB(255,205,205)); pOldPen = pDC->SelectObject(&pen); RxVect4D resV; // 吝埃俊 Text免仿秦 林绰 谅钎 蔼 //BEGIN::快急 visible planes阑 弊妨霖促. if(m_abPlaneVisible[PLANE_ZMIN]) // Z-Min 乞搁捞 visible { DrawOnePlane(pDC, aptOriCubeApex[0], aptOriCubeApex[1], aptOriCubeApex[2], aptOriCubeApex[3]); resV = mxOriCube * RxVect4D(dOriCubeSizeHalf, dOriCubeSizeHalf, -iOriCubeMargin, 1); pDC->TextOut((int)resV[0], (int)resV[1]-10, _T("F")); } if(m_abPlaneVisible[PLANE_ZMAX]) // Z-Max 乞搁捞 visible { DrawOnePlane(pDC, aptOriCubeApex[4], aptOriCubeApex[5], aptOriCubeApex[6], aptOriCubeApex[7]); resV = mxOriCube * RxVect4D(dOriCubeSizeHalf, dOriCubeSizeHalf, dOriCubeSize + iOriCubeMargin, 1); pDC->TextOut((int)resV[0], (int)resV[1]-10, _T("H")); } if(m_abPlaneVisible[PLANE_XMAX]) // X-Max 乞搁捞 visible { DrawOnePlane(pDC, aptOriCubeApex[1], aptOriCubeApex[5], aptOriCubeApex[6], aptOriCubeApex[2]); resV = mxOriCube * RxVect4D(dOriCubeSize + iOriCubeMargin, dOriCubeSizeHalf, dOriCubeSizeHalf, 1); pDC->TextOut((int)resV[0], (int)resV[1]-10, _T("R")); } if(m_abPlaneVisible[PLANE_XMIN]) // X-Min 乞搁捞 visible { DrawOnePlane(pDC, aptOriCubeApex[0], aptOriCubeApex[4], aptOriCubeApex[7], aptOriCubeApex[3]); resV = mxOriCube * RxVect4D(-iOriCubeMargin, dOriCubeSizeHalf, dOriCubeSizeHalf, 1); pDC->TextOut((int)resV[0], (int)resV[1]-10, _T("L")); } if(m_abPlaneVisible[PLANE_YMIN]) // Y-Min 乞搁捞 visible { DrawOnePlane(pDC, aptOriCubeApex[0], aptOriCubeApex[1], aptOriCubeApex[5], aptOriCubeApex[4]); resV = mxOriCube * RxVect4D(dOriCubeSizeHalf, -iOriCubeMargin, dOriCubeSizeHalf, 1); pDC->TextOut((int)resV[0], (int)resV[1]-10, _T("A")); } if(m_abPlaneVisible[PLANE_YMAX]) // Y-Max 乞搁捞 visible { DrawOnePlane(pDC, aptOriCubeApex[3], aptOriCubeApex[2], aptOriCubeApex[6], aptOriCubeApex[7]); resV = mxOriCube * RxVect4D(dOriCubeSizeHalf, dOriCubeSize + iOriCubeMargin, dOriCubeSizeHalf, 1); pDC->TextOut((int)resV[0], (int)resV[1]-10, _T("P")); } //END::快急 visible planes阑 弊妨霖促. pDC->SelectObject(pOldPen); pen.DeleteObject(); pDC->RestoreDC(nSavedDC);}#define COLOR_SCALEBAR RGB(0,135,195)#define SIZE_SCALEBAR_GRID_GAP 10 // mm 窜困#define SIZE_SCALEBAR_GRID 6#define POS_SCALEBAR_LEFT_MARGIN 5#define CNT_HALF_SCALEBAR_GRID_NO 2.5void RxFMWndVR::DrawScaleBar(CDC *pDC){ double fScaling = 100. / (double)(theFMDocVR.m_iVRZoomFactor); if(m_nSeries == RXSERIES_FLT) fScaling *= (double)(RxGetVolumeData(RXSERIES_FLT)->m_fPixelSpace); else fScaling *= (double)(RxGetVolumeData(RXSERIES_REF)->m_fPixelSpace); double fPixelCnt = (double)SIZE_SCALEBAR_GRID_GAP/fScaling; int sx = POS_SCALEBAR_LEFT_MARGIN; int sy = m_szWindow.cy / 2; CPen Pen(PS_SOLID, 2, COLOR_SCALEBAR); CPen *OldPen = (CPen *)pDC->SelectObject(&Pen); pDC->MoveTo(sx, (int)(sy - (int)(fPixelCnt * CNT_HALF_SCALEBAR_GRID_NO))); pDC->LineTo(sx, (int)(sy + (int)(fPixelCnt * CNT_HALF_SCALEBAR_GRID_NO))-1); double fDy = fPixelCnt / 2; for(int i = 0; i < 3; i++) { pDC->MoveTo(sx-1, sy - (int)(fDy + fPixelCnt * i + .5)); pDC->LineTo(sx+SIZE_SCALEBAR_GRID, sy - (int)(fDy + fPixelCnt * i + .5)); pDC->MoveTo(sx-1, sy + (int)(fDy + fPixelCnt * i + .5)); pDC->LineTo(sx+SIZE_SCALEBAR_GRID, sy + (int)(fDy + fPixelCnt * i + .5)); } pDC->SelectObject(OldPen); Pen.DeleteObject();}void RxFMWndVR::DrawPatientInfo(CDC *pDC){ RxDicomObject *pDicomInfo = RxGetVolumeData(m_nSeries)->m_pDicomInfo; int nSavedDC = pDC->SaveDC(); CFont font, *pOldFont; font.CreateFont(-14, 0, 0, 0, FW_NORMAL, FALSE, 0, 0, DEFAULT_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, _T("Arial")); pOldFont = pDC->SelectObject(&font); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(RGB(255,255,255)); int itype, iVal; CString strText; POINT ptText; CSize szText; ptText.x = 5; ptText.y = 5; // top-left pDicomInfo->GetDicomInfo(DI_PATIENTNAME, &strText, &itype); pDC->TextOut(ptText.x, ptText.y, strText); pDicomInfo->GetDicomInfo(DI_PATIENTID, &strText, &itype); szText = pDC->GetTextExtent(strText); pDC->TextOut(ptText.x, ptText.y + szText.cy, strText); // top-right ptText.x = m_szWindow.cx - 10; pDicomInfo->GetDicomInfo(DI_EXAMDATE, &strText, &itype); szText = pDC->GetTextExtent(strText); pDC->TextOut(ptText.x - szText.cx, ptText.y, strText); pDicomInfo->GetDicomInfo(DI_DEVICENAME, &strText, &itype); szText = pDC->GetTextExtent(strText); pDC->TextOut(ptText.x - szText.cx, ptText.y + szText.cy, strText); pDicomInfo->GetDicomInfo(DI_SERIESNO, &iVal, &itype); strText.Format(_T("Ser %d"), iVal); szText = pDC->GetTextExtent(strText); pDC->TextOut(ptText.x - szText.cx, ptText.y + (szText.cy*2), strText); pDC->SelectObject(pOldFont); font.DeleteObject(); pDC->RestoreDC(nSavedDC);}// transformation outputvoid RxFMWndVR::DrawTransOutput(CDC *pDC){ if(!m_bOutputTransform) return; CRect rcClient; GetClientRect(rcClient); CString strText; strText.Format(_T("Shift: %5.3f,%5.3f,%5.3f "), m_pTransform->xmove,m_pTransform->ymove,m_pTransform->zmove); CRect rcText; rcText.SetRect(rcClient.left,rcClient.Height()-60,rcClient.right,rcClient.Height()-40); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(RGB(150,150,150)); pDC->DrawText(strText,rcText,DT_SINGLELINE|DT_VCENTER|DT_RIGHT); strText.Format(_T("Scaling: %5.3f,%5.3f,%5.3f "), m_pTransform->xscale,m_pTransform->yscale,m_pTransform->zscale); rcText.SetRect(rcClient.left,rcClient.Height()-20,rcClient.right,rcClient.Height()-40); pDC->DrawText(strText,rcText,DT_SINGLELINE|DT_VCENTER|DT_RIGHT); strText.Format(_T("Rotating: %5.3f,%5.3f,%5.3f "), m_pTransform->xrot,m_pTransform->yrot,m_pTransform->zrot); rcText.SetRect(rcClient.left,rcClient.Height()-0,rcClient.right,rcClient.Height()-20); pDC->DrawText(strText,rcText,DT_SINGLELINE|DT_VCENTER|DT_RIGHT);}void RxFMWndVR::OnSize(UINT nType, int cx, int cy) { RxFMWnd3DOutline::OnSize(nType, cx, cy); // TODO: Add your message handler code here if(cx == 0 || cy == 0) // 0,0捞搁 公矫 return; m_szWindow.cx = cx; m_szWindow.cy = cy; // update size buttons at caption int nFrame3DFMatrix = RxGetFrameMain()->Frame3DF_GetMatrix(); if(nFrame3DFMatrix == FRAME_MATRIX_12) { SetBtnVisible(IDFM_LOCAL_BTN_MIN, FALSE, FALSE); SetBtnVisible(IDFM_LOCAL_BTN_MAX, TRUE, TRUE); } else if(nFrame3DFMatrix == FRAME_MATRIX_32) { SetBtnVisible(IDFM_LOCAL_BTN_MAX, FALSE, FALSE); SetBtnVisible(IDFM_LOCAL_BTN_MIN, TRUE, TRUE); } int nTBCurMode = RxGetFrameMain()->GetTBCurMode(); if(nTBCurMode == BTN_3DMPR_BASIC) { theFMDocVR.MPR_Initialize(m_szWindow); UpdateMPRWindow(); } m_bNeedToRender = TRUE;}BOOL RxFMWndVR::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) { if(pWnd->GetSafeHwnd() == GetSafeHwnd() && nHitTest == HTCLIENT) { int nTBCurMode = RxGetFrameMain()->GetTBCurMode(); if(nTBCurMode == BTN_PAN) { SetCursor(AfxGetApp()->LoadCursor(IDC_CURSOR_PAN)); return TRUE; } else if(nTBCurMode == BTN_ZOOM) { SetCursor(AfxGetApp()->LoadCursor(IDC_CURSOR_ZOOM)); return TRUE; } else if(nTBCurMode == BTN_CROP) { SetCursor(AfxGetApp()->LoadCursor(IDC_CURSOR_CROP)); return TRUE; } else if(nTBCurMode == BTN_WINDOWING) { SetCursor(AfxGetApp()->LoadCursor(IDC_CURSOR_WINDOWING)); return TRUE; } else if(nTBCurMode == BTN_3DMPR_BASIC) { POINT point; GetCursorPos(&point); ScreenToClient(&point); int nHitTest = theFMDocVR.MPR_HitTest(&point); if(nHitTest == HT_3DMPR_NONE) { SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); return TRUE; } else { SetCursor(AfxGetApp()->LoadStandardCursor(MAKEINTRESOURCE(32649))); return TRUE; } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -