📄 presetwindowing.cpp
字号:
// PresetWindowing.cpp: implementation of the RxPresetWindowing class.////////////////////////////////////////////////////////////////////////#include "stdafx.h"#include "fusion.h"#include "PresetWindowing.h"#include "DlgPresetWindowing.h"//////////////////////////////////////////////////////////////////////// Construction/Destruction//////////////////////////////////////////////////////////////////////RxPresetWindowing::RxPresetWindowing(){ m_nModality = 1; m_ArrayWindowing.SetSize(0, 5);}RxPresetWindowing::~RxPresetWindowing(){ RemoveAllPresetWindowing();}void RxPresetWindowing::CreatePresetWindowingFile(UINT nModality){ int iCount; _PRESET_WINDOWING *pPresetWindowing; if(nModality == 0) // MR Default preset { iCount = 12; pPresetWindowing = new _PRESET_WINDOWING[iCount]; _tcscpy(pPresetWindowing[0].strTitle, _T("Abdomen T1")); pPresetWindowing[0].iLevel = 165; pPresetWindowing[0].iWidth = 200; pPresetWindowing[0].iHotKey = 0; _tcscpy(pPresetWindowing[1].strTitle, _T("Abdomen T2")); pPresetWindowing[1].iLevel = 112; pPresetWindowing[1].iWidth = 266; pPresetWindowing[1].iHotKey = 1; _tcscpy(pPresetWindowing[2].strTitle, _T("Chest T1 Sag")); pPresetWindowing[2].iLevel = 168; pPresetWindowing[2].iWidth = 230; pPresetWindowing[2].iHotKey = 2; _tcscpy(pPresetWindowing[3].strTitle, _T("Chest T2 Sag")); pPresetWindowing[3].iLevel = 129; pPresetWindowing[3].iWidth = 290; pPresetWindowing[3].iHotKey = 3; _tcscpy(pPresetWindowing[4].strTitle, _T("Head T1Axi")); pPresetWindowing[4].iLevel = 400; pPresetWindowing[4].iWidth = 858; pPresetWindowing[4].iHotKey = 4; _tcscpy(pPresetWindowing[5].strTitle, _T("Head T1Cor")); pPresetWindowing[5].iLevel = 776; pPresetWindowing[5].iWidth = 880; pPresetWindowing[5].iHotKey = 5; _tcscpy(pPresetWindowing[6].strTitle, _T("Head T2Axi")); pPresetWindowing[6].iLevel = 279; pPresetWindowing[6].iWidth = 948; pPresetWindowing[6].iHotKey = 6; _tcscpy(pPresetWindowing[7].strTitle, _T("Neck T1Sag")); pPresetWindowing[7].iLevel = 274; pPresetWindowing[7].iWidth = 442; pPresetWindowing[7].iHotKey = 7; _tcscpy(pPresetWindowing[8].strTitle, _T("Neck T2Sag")); pPresetWindowing[8].iLevel = 62; pPresetWindowing[8].iWidth = 152; pPresetWindowing[8].iHotKey = 8; _tcscpy(pPresetWindowing[9].strTitle, _T("Spine T1Sag")); pPresetWindowing[9].iLevel = 69; pPresetWindowing[9].iWidth = 168; pPresetWindowing[9].iHotKey = 9; _tcscpy(pPresetWindowing[10].strTitle, _T("Spine T2 Sag")); pPresetWindowing[10].iLevel = 316; pPresetWindowing[10].iWidth = 1264; pPresetWindowing[10].iHotKey = 10; _tcscpy(pPresetWindowing[11].strTitle, _T("T1")); pPresetWindowing[11].iLevel = 210; pPresetWindowing[11].iWidth = 1000; pPresetWindowing[11].iHotKey = 11; } else if(nModality == 1) // CT Default preset { iCount = 17; pPresetWindowing = new _PRESET_WINDOWING[iCount]; _tcscpy(pPresetWindowing[0].strTitle, _T("Airway")); pPresetWindowing[0].iLevel = -500; pPresetWindowing[0].iWidth = 1500; pPresetWindowing[0].iHotKey = 0; _tcscpy(pPresetWindowing[1].strTitle, _T("Angio MPR")); pPresetWindowing[1].iLevel = 80; pPresetWindowing[1].iWidth = 700; pPresetWindowing[1].iHotKey = 1; _tcscpy(pPresetWindowing[2].strTitle, _T("Angio Stent")); pPresetWindowing[2].iLevel = 40; pPresetWindowing[2].iWidth = 1200; pPresetWindowing[2].iHotKey = 2; _tcscpy(pPresetWindowing[3].strTitle, _T("Bone")); pPresetWindowing[3].iLevel = 250; pPresetWindowing[3].iWidth = 1200; pPresetWindowing[3].iHotKey = 3; _tcscpy(pPresetWindowing[4].strTitle, _T("Brain")); pPresetWindowing[4].iLevel = 30; pPresetWindowing[4].iWidth = 80; pPresetWindowing[4].iHotKey = 4; _tcscpy(pPresetWindowing[5].strTitle, _T("Facial")); pPresetWindowing[5].iLevel = 50; pPresetWindowing[5].iWidth = 350; pPresetWindowing[5].iHotKey = 5; _tcscpy(pPresetWindowing[6].strTitle, _T("Kidney")); pPresetWindowing[6].iLevel = 70; pPresetWindowing[6].iWidth = 50; pPresetWindowing[6].iHotKey = 6; _tcscpy(pPresetWindowing[7].strTitle, _T("Liver")); pPresetWindowing[7].iLevel = 70; pPresetWindowing[7].iWidth = 170; pPresetWindowing[7].iHotKey = 7; _tcscpy(pPresetWindowing[8].strTitle, _T("Lung")); pPresetWindowing[8].iLevel = -650; pPresetWindowing[8].iWidth = 1300; pPresetWindowing[8].iHotKey = 8; _tcscpy(pPresetWindowing[9].strTitle, _T("Mediastinum")); pPresetWindowing[9].iLevel = 20; pPresetWindowing[9].iWidth = 400; pPresetWindowing[9].iHotKey = 9; _tcscpy(pPresetWindowing[10].strTitle, _T("MinIP")); pPresetWindowing[10].iLevel = -650; pPresetWindowing[10].iWidth = 1600; pPresetWindowing[10].iHotKey = 10; _tcscpy(pPresetWindowing[11].strTitle, _T("MIP")); pPresetWindowing[11].iLevel = 250; pPresetWindowing[11].iWidth = 600; pPresetWindowing[11].iHotKey = 11; _tcscpy(pPresetWindowing[12].strTitle, _T("Neck")); pPresetWindowing[12].iLevel = 20; pPresetWindowing[12].iWidth = 400; pPresetWindowing[12].iHotKey = 12; _tcscpy(pPresetWindowing[13].strTitle, _T("OMU")); pPresetWindowing[13].iLevel = 0; pPresetWindowing[13].iWidth = 2000; pPresetWindowing[13].iHotKey = -1; _tcscpy(pPresetWindowing[14].strTitle, _T("Pelvis")); pPresetWindowing[14].iLevel = -20; pPresetWindowing[14].iWidth = 450; pPresetWindowing[14].iHotKey = -1; _tcscpy(pPresetWindowing[15].strTitle, _T("Stomach")); pPresetWindowing[15].iLevel = 70; pPresetWindowing[15].iWidth = 400; pPresetWindowing[15].iHotKey = -1; _tcscpy(pPresetWindowing[16].strTitle, _T("Temporal")); pPresetWindowing[16].iLevel = 200; pPresetWindowing[16].iWidth = 4000; pPresetWindowing[16].iHotKey = -1; } CFile file; if(file.Open(m_strFileName, CFile::modeCreate|CFile::modeReadWrite)) { file.Write(pPresetWindowing, sizeof(_PRESET_WINDOWING) * iCount); file.Close(); } delete []pPresetWindowing;}void RxPresetWindowing::ReadPresetWindowingFile(UINT nModality, LPCTSTR lpszFileName){ RemoveAllPresetWindowing(); m_strFileName = lpszFileName; CFile file; // 蜡瓤己 八荤饶 利钦窍瘤 臼阑版快 颇老阑 积己茄促. if(file.Open(m_strFileName, CFile::modeRead)) { int nFileLength = file.GetLength(); file.Close(); if(nFileLength == 0 || nFileLength % sizeof(_PRESET_WINDOWING) != 0) CreatePresetWindowingFile(nModality); } else CreatePresetWindowingFile(nModality); file.Open(m_strFileName, CFile::modeRead); int iFileLength = file.GetLength(); int iSizeStruct = sizeof(_PRESET_WINDOWING); _PRESET_WINDOWING stPresetWindowing; for(int i = 0; i < iFileLength; i += iSizeStruct) { file.Seek(i, 0); file.Read(&stPresetWindowing, iSizeStruct); AddPresetWindowing(&stPresetWindowing); } file.Close();}void RxPresetWindowing::WritePresetWindowingFile(){ CFile file; file.Open(m_strFileName, CFile::modeCreate|CFile::modeReadWrite); int iCount = m_ArrayWindowing.GetSize(); _PRESET_WINDOWING_PTR stpPresetWindowing; int iSizeStruct = sizeof(_PRESET_WINDOWING); for(int i = 0; i < iCount; i++) { stpPresetWindowing = (_PRESET_WINDOWING_PTR)m_ArrayWindowing.GetAt(i); file.Seek(i * iSizeStruct, 0); file.Write(stpPresetWindowing, iSizeStruct); } file.Close();}int RxPresetWindowing::AddPresetWindowing(_PRESET_WINDOWING_PTR stpPresetWindowing){ return AddPresetWindowing(stpPresetWindowing->strTitle, stpPresetWindowing->iLevel, stpPresetWindowing->iWidth, stpPresetWindowing->iHotKey);}int RxPresetWindowing::AddPresetWindowing(LPCTSTR lpszName, int iLevel, int iWidth, int iHotKey){ _PRESET_WINDOWING_PTR stpPresetWindowing = new _PRESET_WINDOWING; _tcscpy(stpPresetWindowing->strTitle, lpszName); stpPresetWindowing->iLevel = iLevel; stpPresetWindowing->iWidth = iWidth; stpPresetWindowing->iHotKey = iHotKey; int iArrayCount = m_ArrayWindowing.GetSize(); if(iArrayCount == 0) m_ArrayWindowing.Add(stpPresetWindowing); else { _PRESET_WINDOWING_PTR stpCmpPresetWindowing; for(int i = 0; i <= iArrayCount; i++) { if(i == iArrayCount) m_ArrayWindowing.Add(stpPresetWindowing); else { stpCmpPresetWindowing = (_PRESET_WINDOWING_PTR)m_ArrayWindowing.GetAt(i); if(_tcsicmp(stpPresetWindowing->strTitle, stpCmpPresetWindowing->strTitle) < 0) { m_ArrayWindowing.InsertAt(i, stpPresetWindowing); return i; } } } } return iArrayCount;}_PRESET_WINDOWING_PTR RxPresetWindowing::GetPresetWindowing(UINT nIndex){ if(nIndex >= 0 && nIndex < (UINT)m_ArrayWindowing.GetSize()) return (_PRESET_WINDOWING_PTR)m_ArrayWindowing.GetAt(nIndex); else return NULL;}int RxPresetWindowing::GetPresetWindowingByHotKey(int iHotKey){ int iArrayCount = m_ArrayWindowing.GetSize(); _PRESET_WINDOWING_PTR stpPresetWindowing; for(int i = 0; i < iArrayCount; i++) { stpPresetWindowing = (_PRESET_WINDOWING_PTR)m_ArrayWindowing.GetAt(i); if(stpPresetWindowing->iHotKey == iHotKey) return i; } return -1;}int RxPresetWindowing::GetPresetWindowingCount(){ return m_ArrayWindowing.GetSize();}void RxPresetWindowing::RemovePresetWindowing(UINT nIndex){ if(nIndex >= 0 && nIndex < (UINT)m_ArrayWindowing.GetSize()) { _PRESET_WINDOWING_PTR stpPresetWindowing = (_PRESET_WINDOWING_PTR)m_ArrayWindowing.GetAt(nIndex); delete stpPresetWindowing; m_ArrayWindowing.RemoveAt(nIndex); }}void RxPresetWindowing::RemoveAllPresetWindowing(){ UINT nCount = m_ArrayWindowing.GetSize(); _PRESET_WINDOWING_PTR stpPresetWindowing; for(UINT i = 0; i < nCount; i++) { stpPresetWindowing = (_PRESET_WINDOWING_PTR)m_ArrayWindowing.GetAt(i); delete stpPresetWindowing; } m_ArrayWindowing.RemoveAll();}void RxPresetWindowing::ShowPresetWindowDialog(int iLevel, int iWidth){ RxDlgPresetWindowing dlg; if(m_nModality == 0) dlg.SetPresetWindowing(this, 0, 4095, iLevel, iWidth); else if(m_nModality == 1) dlg.SetPresetWindowing(this, -1024, 3071, iLevel, iWidth); dlg.DoModal(); WritePresetWindowingFile();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -