// LeftPaneWnd.cpp : implementation file // #include "stdafx.h" #include "Overlay.h" #include "LeftPaneWnd.h" #include "MainFrm.h" #include "RightPaneWnd.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif extern COverlayApp theApp; ///////////////////////////////////////////////////////////////////////////// // CLeftPaneWnd IMPLEMENT_DYNCREATE(CLeftPaneWnd, CFormView) CLeftPaneWnd::CLeftPaneWnd() : CFormView(CLeftPaneWnd::IDD) { //{{AFX_DATA_INIT(CLeftPaneWnd) //}}AFX_DATA_INIT } CLeftPaneWnd::~CLeftPaneWnd() { } BEGIN_MESSAGE_MAP(CLeftPaneWnd, CFormView) //{{AFX_MSG_MAP(CLeftPaneWnd) ON_WM_ERASEBKGND() //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CLeftPaneWnd drawing void CLeftPaneWnd::DoDataExchange(CDataExchange* pDX) { CFormView::DoDataExchange(pDX); //{{AFX_DATA_MAP(CLeftPaneWnd) DDX_Control(pDX, IDC_LEADRASIMGLISTCTRL1, m_ImageListControl); //}}AFX_DATA_MAP } void CLeftPaneWnd::OnDraw(CDC* pDC) { CDocument* pDoc = GetDocument(); // TODO: add draw code here } ///////////////////////////////////////////////////////////////////////////// // CLeftPaneWnd diagnostics #ifdef _DEBUG void CLeftPaneWnd::AssertValid() const { CFormView::AssertValid(); } void CLeftPaneWnd::Dump(CDumpContext& dc) const { CFormView::Dump(dc); } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CLeftPaneWnd message handlers BOOL CLeftPaneWnd::LoadOverlays() { int nRet; char szItemText [20]; CMainFrame* pFrame = (CMainFrame*) AfxGetApp()->GetMainWnd(); CRightPaneWnd* pRightPane = (CRightPaneWnd*)pFrame->m_wndSplitter.GetPane(0, 1); nRet = theApp.m_pLEADDicomDS->FindFirstElement(TAG_PIXEL_DATA, TRUE); m_ImageListControl.Clear(); if (nRet == DICOM_SUCCESS) { nRet = theApp.m_pLEADDicomDS->GetBitmapValue(0, 0, ORDER_BGR, DICOM_GETIMAGE_AUTO_LOAD_OVERLAYS | DICOM_GETIMAGE_AUTO_APPLY_MODALITY_LUT | DICOM_GETIMAGE_AUTO_APPLY_VOI_LUT); if (nRet != DICOM_SUCCESS) { MessageBox ("Error retrieving image from pixel data element.", "Error", MB_OK|MB_ICONERROR); return FALSE; } theApp.m_pRasterTmp->PutBitmap(theApp.m_pLEADDicomDS->GetBitmap () ); pFrame->m_uCount = theApp.m_pRasterProcess->GetOverlayCount(theApp.m_pRasterTmp, 0); if (pFrame->m_uCount < 1) { MessageBox ("No overlays found in this file.", "Error", MB_OK|MB_ICONERROR); return FALSE; } m_ImageListControl.SetItemWidth(145); m_ImageListControl.SetItemHeight(145); // Load all overlays for (int i = 0; i < (int)pFrame->m_uCount; i++) { theApp.m_pRasterProcess->GetOverlayBitmap(theApp.m_pRasterTmp, i ,theApp.m_pRaster, OVERLAY_COPY); // Make the overlay preview looks clearer theApp.m_pRasterProcess->Invert(theApp.m_pRaster); theApp.m_pRasterProcess->Size(theApp.m_pRaster,140, 140, RESIZE_FAVORBLACK); theApp.m_pRasterProcess->Invert(theApp.m_pRaster); sprintf (szItemText, "Overlay %d", i); m_ImageListControl.Insert(theApp.m_pRaster->GetBitmap(), szItemText, i); m_ImageListControl.EnsureVisible(m_ImageListControl.GetCount()-1); } pRightPane->m_RasterView.GetRaster().SetBitmap(theApp.m_pRasterTmp->GetBitmap()); m_ImageListControl.SetScrollStyle(0); m_ImageListControl.SetAllowSelection(1); m_ImageListControl.SetSelectionStyle(1); m_ImageListControl.Item(0).SetSelected(TRUE); } else { MessageBox(TEXT("No Modules in this data set."), TEXT("Error"), MB_OK|MB_ICONERROR); return FALSE; } return TRUE; } void CLeftPaneWnd::OverlaysShowOverlay(BOOL bShow, int nSelItemIndex, BOOL bView) { UINT uFlags = OVERLAYATTRIBUTES_FLAGS | OVERLAYATTRIBUTES_ORIGIN; UINT uAttFlags; CMainFrame* pFrame = (CMainFrame*) AfxGetApp()->GetMainWnd(); if(bView) theApp.m_pRasterProcess->GetOverlayAttributes(pFrame->m_pRightPaneWnd->m_RasterView.GetRaster() , nSelItemIndex, uFlags); else theApp.m_pRasterProcess->GetOverlayAttributes (theApp.m_pRasterTmp, nSelItemIndex, uFlags); uAttFlags = theApp.m_pRasterProcess->OverlayAttributes->Flags; if (bShow) uAttFlags |= OVERLAY_AUTOPAINT; else uAttFlags &= ~OVERLAY_AUTOPAINT; theApp.m_pRasterProcess->OverlayAttributes->Flags = uAttFlags; if(bView) theApp.m_pRasterProcess->SetOverlayAttributes (pFrame->m_pRightPaneWnd->m_RasterView.GetRaster() , nSelItemIndex, uFlags); else theApp.m_pRasterProcess->SetOverlayAttributes (theApp.m_pRasterTmp, nSelItemIndex, uFlags); pFrame->m_pRightPaneWnd->m_RasterView.ForceRepaint(); } BEGIN_EVENTSINK_MAP(CLeftPaneWnd, CFormView) //{{AFX_EVENTSINK_MAP(CLeftPaneWnd) ON_EVENT(CLeftPaneWnd, IDC_LEADRASIMGLISTCTRL1, 1 /* ItemSelected */, OnItemSelectedLeadrasimglistctrl1, VTS_I4) //}}AFX_EVENTSINK_MAP END_EVENTSINK_MAP() void CLeftPaneWnd::OnItemSelectedLeadrasimglistctrl1(long nIndex) { int nRet; CMainFrame* pFrame = (CMainFrame*) AfxGetApp()->GetMainWnd(); pFrame->m_nSelItemIndex = nIndex; // See if the OVERLAY_AUTOPAINT is on or off to update the "Show Overlay" menu item nRet = theApp.m_pRasterProcess->GetOverlayAttributes(pFrame->m_pRightPaneWnd->m_RasterView.GetRaster(), (short)nIndex, OVERLAYATTRIBUTES_FLAGS | OVERLAYATTRIBUTES_ORIGIN); if (theApp.m_pRasterProcess->OverlayAttributes->Flags & OVERLAY_AUTOPAINT ) theApp.m_bShowOverlay = TRUE ; else theApp.m_bShowOverlay = FALSE; }