void CServerDoc::CalcBounding(CDC* pDC, CServerNode* pNodeStart, CPoint ptStart, CSize& sizeMax) { ASSERT_VALID(pNodeStart); // select correct font for the document CFont font; CFont* pOldFont = SelectDocFont(pDC, font); // calculate the bounding rect pNodeStart->CalcBounding(pDC, ptStart, sizeMax); // restore state of the dc if (pOldFont != NULL) pDC->SelectObject(pOldFont); }
int CServerDoc::DrawTree(CDC* pDC, CPoint ptStart, CServerNode* pNodeSel, CServerNode* pRoot) { if (pRoot == NULL) pRoot = m_pRoot; // select correct font for the document CFont font; CFont* pOldFont = SelectDocFont(pDC, font); if (pOldFont == NULL) return -1; // draw the hierachy list int iResult = pRoot->DrawTree(pDC, ptStart, pNodeSel); // restore state of the dc pDC->SelectObject(pOldFont); return iResult; }
void CGelView::DrawGel(CDC* pDC, CRect rcBounds) { char tBuff[128]; CBrush bBrush; bBrush.CreateSolidBrush( RGB(255,255,255) ); pDC->FillRect( &rcBounds, &bBrush ); pDC->SetBkColor( RGB(255,255,255) ); CSize docSize = GetGelSize(); double ypi = pDC->GetDeviceCaps(LOGPIXELSY); double xpi = pDC->GetDeviceCaps(LOGPIXELSX); int x = (int)((double)docSize.cx/100.0 * xpi); int y = (int)((double)docSize.cy/100.0 * ypi); int xoff = rcBounds.TopLeft().x; int yoff = rcBounds.TopLeft().y; int YSpace = (int)(ypi / 24.0); int XSpace = (int)(xpi / 24.0); // Lets draw graph always ... // CFont fontTmp; CFont* pOldFont = SelectDocFont(pDC, fontTmp, 900); CPen nPen( PS_SOLID, m_LineWidth, RGB(0,0,0) ); CPen* oPen = pDC->SelectObject(&nPen); CSize fontSize = pDC->GetTextExtent( "X", 1 ); int NamesHeight = 0; POSITION gPos = m_listGel.GetHeadPosition(); while ( gPos != NULL ) { SGel *pSGel = (SGel *)m_listGel.GetNext(gPos); CString strName = pSGel->Sequence->GetTitle(); strName = strName.Left(10); CSize fontSize = pDC->GetTextExtent( strName, strName.GetLength() ); int iHeight = fontSize.cx; if ( iHeight > NamesHeight ) NamesHeight = iHeight; } // int xborder = (int)((double)x * .05); _snprintf( tBuff, 127, "%d", m_MaxY ); // = "1.0"; CSize tstrsz; tstrsz = pDC->GetTextExtent( tBuff, strlen(tBuff) ); int xborder = tstrsz.cx + XSpace; int yborder = (int)(xpi / 24.0); yborder += m_LineWidth; pDC->MoveTo(xoff + (xborder), yoff + (NamesHeight + YSpace - m_LineWidth) ); pDC->LineTo(xoff + (xborder),yoff + (y - yborder)); pDC->LineTo(xoff + (x - XSpace),yoff + (y - yborder)); pDC->LineTo(xoff + (x - XSpace),yoff + ( NamesHeight + YSpace - m_LineWidth )); pDC->LineTo(xoff + (xborder ),yoff + (NamesHeight + YSpace - m_LineWidth )); int GraphWidth = (x - XSpace) - xborder; int drl = 1; while ( drl < m_MinY ) { if ( drl * 10 > m_MinY ) break; drl = drl * 10; } double YRange = m_MaxY - (double)drl + 1; double dblYMult = (double)y - (yborder + NamesHeight + YSpace); if ( m_listGel.GetCount() != 0 ) { int GelCount = m_listGel.GetCount(); int dWidth = GraphWidth - ( GelCount * m_LineWidth * 2 ); int BandWidth = dWidth / GelCount; int Band = 0; gPos = m_listGel.GetHeadPosition(); while ( gPos != NULL ) { SGel *pSGel = (SGel *)m_listGel.GetNext(gPos); CString strName = pSGel->Sequence->GetTitle(); strName = strName.Left(10); double dblXVal = (Band * BandWidth) + (Band * m_LineWidth * 2) - (m_LineWidth * 2); pDC->ExtTextOut( 1 + xoff + ((int)dblXVal + xborder) + ( BandWidth / 2 ) - ( fontSize.cx / 2 ), yoff + (NamesHeight + YSpace - m_LineWidth - 2), ETO_CLIPPED, CRect ( xoff, yoff, xoff + x, yoff + y ), strName, strName.GetLength(), NULL ); Band++; int wdrl = drl; int inc = drl; while ( wdrl < m_MaxY ) { double dblYVal = 1.0 - (log (double( wdrl - drl + 1)) / log(YRange)); dblYVal *= dblYMult; int tyloc = yoff + (NamesHeight + YSpace + (int)dblYVal - 1); pDC->MoveTo( 1 + xoff + ((int)dblXVal + BandWidth + xborder + m_LineWidth+ m_LineWidth), tyloc); pDC->LineTo( 1 + xoff + ((int)dblXVal + BandWidth + xborder + m_LineWidth+ m_LineWidth + m_LineWidth), tyloc); pDC->LineTo( 1 + xoff + ((int)dblXVal + BandWidth + xborder + m_LineWidth+ m_LineWidth), tyloc); wdrl += inc; if ( wdrl == inc * 10 ) { inc = inc * 10; } } } pDC->SelectObject( pOldFont ); fontTmp.DeleteObject(); pOldFont = SelectDocFont(pDC, fontTmp, 0); int yinc = ((y - yborder) - (NamesHeight + YSpace ))/4; pDC->MoveTo(xoff + (xborder),yoff + ( NamesHeight + YSpace )); pDC->LineTo(xoff + (xborder - XSpace),yoff + ( NamesHeight + YSpace )); pDC->LineTo(xoff + (xborder),yoff + ( NamesHeight + YSpace )); _snprintf( tBuff, 127, "%d", m_MaxY ); // = "1.0"; CSize tstrsz; tstrsz = pDC->GetTextExtent( tBuff, strlen(tBuff) ); // pDC->LPtoDP( &tstrsz ); pDC->ExtTextOut( xoff + (xborder - XSpace - tstrsz.cx), yoff + (NamesHeight + YSpace) - tstrsz.cy, ETO_CLIPPED, CRect ( xoff, yoff, xoff + x, yoff + y ), tBuff, strlen(tBuff), NULL ); int wdrl = drl; int inc = drl; while ( wdrl < m_MaxY ) { double dblYVal = 1.0 - (log (double( wdrl - drl + 1)) / log(YRange)); dblYVal *= dblYMult; int tyloc = yoff + (NamesHeight + YSpace + (int)dblYVal - 1); pDC->MoveTo(xoff + (xborder),tyloc); pDC->LineTo(xoff + (xborder - XSpace),tyloc); pDC->LineTo(xoff + (xborder),tyloc); if ( wdrl == inc || wdrl == inc *5 ) { pDC->MoveTo(xoff + (xborder),tyloc); pDC->LineTo(xoff + (xborder - XSpace),tyloc); pDC->LineTo(xoff + (xborder),tyloc); _snprintf( tBuff, 127, "%d", wdrl ); // = ".75"; tstrsz = pDC->GetTextExtent( tBuff, strlen(tBuff) ); pDC->ExtTextOut( xoff + (xborder - XSpace - tstrsz.cx), tyloc -(tstrsz.cy/2), ETO_CLIPPED, CRect ( xoff, tyloc-(tstrsz.cy/2), xoff + x, (tyloc -(tstrsz.cy/2)) + y ), tBuff, strlen(tBuff), NULL ); } wdrl += inc; if ( wdrl == inc * 10 ) { inc = inc * 10; } } // For assumed Y Scale = 0 - 1.0 // Create a red pen. pDC->SelectObject( oPen ); nPen.DeleteObject(); nPen.CreatePen( PS_SOLID, m_LineWidth, RGB(255,0,0) ); oPen = pDC->SelectObject(&nPen); Band = 0; gPos = m_listGel.GetHeadPosition(); while ( gPos != NULL ) { SGel *pSGel = (SGel *)m_listGel.GetNext(gPos); double dblXVal = (Band * BandWidth) + (Band * m_LineWidth * 2); int FragCount = pSGel->arrGelLoc.GetSize(); for ( int i=0; i < FragCount; ++i ) { double ss = pSGel->arrGelLoc[i] / 100000000.0; double dblYVal = 1.0 - (log( (ss * YRange) - drl + 1) / log(YRange)); dblYVal *= dblYMult; pDC->MoveTo( 1 + xoff + ((int)dblXVal + xborder), yoff + (NamesHeight + YSpace + (int)dblYVal - 1) ); pDC->LineTo( 1 + xoff + ((int)dblXVal + BandWidth + xborder) - (m_LineWidth * 2), yoff + (NamesHeight + YSpace + (int)dblYVal - 1) ); pDC->LineTo( 1 + xoff + ((int)dblXVal + xborder), yoff + (NamesHeight + YSpace + (int)dblYVal - 1) ); } Band++; } } pDC->SelectObject( oPen ); nPen.DeleteObject(); pDC->SelectObject( pOldFont ); fontTmp.DeleteObject(); }