BOOL CDrawing::DrawElement(CDC* pDC, OgdcElemPoint3D* pElemPoint3D, BOOL bSelected) { OGDCASSERT(!OGDCIS0(m_dCoordRatio) && !m_rcClient.IsRectEmpty()); OgdcPoint3D* pPoint3Ds = &pElemPoint3D->m_point; OgdcPoint2D pnt; pnt.x = pPoint3Ds->x; pnt.y = pPoint3Ds->y; CPoint* pPoints = NULL; if(!GeoToDevice(&pnt, 1, pPoints)) { return FALSE; } CPen* pPen = pDC->GetCurrentPen(); COLORREF color = RGB(0,0,0); if(pPen != NULL) { LOGPEN logPen; pPen->GetLogPen(&logPen); color = logPen.lopnColor; } CBrush brush(color); CBrush* pOldBrush = pDC->SelectObject(&brush); int nRadius = m_curStyle.m_nMarkerSize / 2; pDC->Ellipse(CRect(pPoints[0].x-nRadius, pPoints[0].y-nRadius, pPoints[0].x+nRadius, pPoints[0].y+nRadius)); pDC->SelectObject(pOldBrush); delete[] pPoints; pPoints = NULL; return TRUE; }
//////////////////////////////////////////////////////////////////////////////// // // FUNCTION: DrawArrow // // DESCRIPTION: Draws drop down arrow, we could use DrawFrameControl - a bit too // messy // // NOTES: // // MAINTENANCE: // Name: Date: Version: Notes: // NT ALMOND 210100 1.0 Origin // //////////////////////////////////////////////////////////////////////////////// void CCoolBtn::DrawArrow(CDC* pDC,CPoint ArrowTip) { CPoint ptDest; CPen* pPen = pDC->GetCurrentPen(); LOGPEN logPen; pPen->GetLogPen(&logPen); pDC->SetPixel(ArrowTip, logPen.lopnColor); ArrowTip -= CPoint(1,1); pDC->MoveTo(ArrowTip); ptDest = ArrowTip; ptDest += CPoint(3,0); pDC->LineTo(ptDest); ArrowTip -= CPoint(1,1); pDC->MoveTo(ArrowTip); ptDest = ArrowTip; ptDest += CPoint(5,0); pDC->LineTo(ptDest); ArrowTip -= CPoint(1,1); pDC->MoveTo(ArrowTip); ptDest = ArrowTip; ptDest += CPoint(7,0); pDC->LineTo(ptDest); }
BOOL CDrawing::DrawElement(CDC* pDC, OgdcElemMultiPoint* pElemMultiPoint, BOOL bSelected) { OGDCASSERT(!OGDCIS0(m_dCoordRatio) && !m_rcClient.IsRectEmpty()); OgdcPoint2D* pPoint2Ds = pElemMultiPoint->m_points.GetData(); CPoint* pPoints = NULL; if(!GeoToDevice(pPoint2Ds, pElemMultiPoint->m_points.GetSize(), pPoints)) { return FALSE; } CPen* pPen = pDC->GetCurrentPen(); COLORREF color = RGB(0,0,0); if(pPen != NULL) { LOGPEN logPen; pPen->GetLogPen(&logPen); color = logPen.lopnColor; } CBrush brush(color); CBrush* pOldBrush = pDC->SelectObject(&brush); for(int i=0; i<pElemMultiPoint->m_points.GetSize(); i++) { pDC->Ellipse(CRect(pPoints[i].x-3, pPoints[i].y-3, pPoints[i].x+3, pPoints[i].y+3)); } pDC->SelectObject(pOldBrush); delete[] pPoints; pPoints = NULL; return TRUE; }
//============================================================================= void CXButtonXP::DrawArrow(CDC *pDC, const CRect& rect, BOOL bIsPressed, BOOL bIsThemed, BOOL bIsDisabled) //============================================================================= { CPen pen; CPen* penOld = NULL; if (bIsDisabled) { pen.CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DSHADOW)); penOld = pDC->SelectObject(&pen); } CPoint ptTip, ptDest; ptTip.x = rect.right - MENUBTN_WIDTH / 2; ptTip.y = (rect.bottom + rect.top) / 2 + 1; if (!bIsThemed && bIsPressed) ptTip.Offset(1, 1); CPen* pPen = pDC->GetCurrentPen(); LOGPEN logPen; pPen->GetLogPen(&logPen); pDC->SetPixel(ptTip, logPen.lopnColor); ptTip -= CPoint(1,1); pDC->MoveTo(ptTip); ptDest = ptTip; ptDest += CPoint(3,0); pDC->LineTo(ptDest); ptTip -= CPoint(1,1); pDC->MoveTo(ptTip); ptDest = ptTip; ptDest += CPoint(5,0); pDC->LineTo(ptDest); ptTip -= CPoint(1,1); pDC->MoveTo(ptTip); ptDest = ptTip; ptDest += CPoint(7,0); pDC->LineTo(ptDest); if (penOld) pDC->SelectObject(penOld); }
void CWell::Serialize(CArchive& ar) { // identification string CString strID; if (ar.IsStoring()) { strID.Format("Mod3D_Well %d", m_nVersion); ar << strID; ar << m_nVersion; CMyObject::Serialize(ar); ar << m_nID; ar << m_strName << m_strLocation << m_strDescription; // position ar << m_x << m_y << m_z; // data ar << m_nFormat; m_strData.Serialize(ar); m_data.Serialize(ar); //drawing ar << m_nChanZ << m_nChanWidth; ar << m_dRadiusProf; ar << m_dRadiusLog; ar << m_dRadiusLog3D; ar << m_bSolidLog3D; ar << m_nWellWidth; ar << m_nWellWidth3D; ar << m_nDravTag; ar << m_nSamplingLog; ar << m_nSamplingRing; ar << m_dLogPieStart; ar << m_dLogPieEnd; // lithology m_welLit.Serialize(ar); m_showChannel.Serialize(ar); // pens int nPens = m_penArray.GetSize(); ar << nPens; for(int i=0; i<nPens; i++) { CPen* pPen; pPen = &m_penArray.GetAt(i); LOGPEN lp; pPen->GetLogPen(&lp); // serialize it ar << lp.lopnColor; ar << lp.lopnStyle; ar << lp.lopnWidth.x; ar << lp.lopnWidth.y; } } else { // loading code ar >> strID; ar >> m_nVersion; CMyObject::Serialize(ar); if( m_nVersion < 20031215) { SerializeOld(ar); return; } ar >> m_nID; ar >> m_strName >> m_strLocation >> m_strDescription; // position ar >> m_x >> m_y >> m_z; // data ar >> m_nFormat; m_strData.Serialize(ar); m_data.Serialize(ar); //drawing ar >> m_nChanZ >> m_nChanWidth; ar >> m_dRadiusProf; ar >> m_dRadiusLog; ar >> m_dRadiusLog3D; ar >> m_bSolidLog3D; ar >> m_nWellWidth; ar >> m_nWellWidth3D; ar >> m_nDravTag; ar >> m_nSamplingLog; ar >> m_nSamplingRing; ar >> m_dLogPieStart; ar >> m_dLogPieEnd; // lithology m_welLit.Serialize(ar); m_showChannel.Serialize(ar); int nPens; ar >> nPens; m_penArray.SetSize(nPens); for(int i=0; i<nPens; i++) { LOGPEN lp; ar >> lp.lopnColor; ar >> lp.lopnStyle; ar >> lp.lopnWidth.x; ar >> lp.lopnWidth.y; m_penArray[i].CreatePenIndirect( &lp ); } //m_penArray.SetSize(m_nFormat); //for(int i=0; i<m_penArray.GetSize(); i++) { // m_penArray[i].CreatePen( PS_SOLID, 0, RGB(160,160,160) ); //} } }
void CWell::DrawGL(void) { if( m_data.IsEmpty() || !m_bVisible ) return; int n; int lit; int ipl; double* wd; WELLIT* wl; n = m_data.GetSize(); wd = m_data.GetData(); BOOL bLighht = glIsEnabled(GL_LIGHTING); glDisable(GL_LIGHTING); if(m_bSolidLog3D) glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); else { glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); } for(int i=m_nFormat*3, ip=m_nFormat*2; i<n; i += m_nFormat, ip += m_nFormat) { lit = (int) wd[i+m_nFormat-1]; wl = &m_welLit.GetAt(lit); glColor3d(wl->rd, wl->gd, wl->bd); glLineWidth( 5 ); glBegin(GL_LINES); glVertex3d( wd[ip+0], wd[ip+2], -wd[ip+1]); glVertex3d( wd[i+0], wd[i+2], -wd[i+1]); glEnd(); // Draw current layer glLineWidth(1.0f); if( (i % m_nSamplingLog) == 0) { for(int j=4; j<m_nFormat-1; j++) { if(m_showChannel[j] == TRUE) { ipl = i - m_nFormat*m_nSamplingLog; if(ipl < m_nFormat*2) ipl = m_nFormat*2; double u=m_dLogPieStart*PI/180.0; double dU = 2*PI/m_nSamplingRing; //glColor3f(1.0f, 0.0f, 0.0f); CPen* pPen = &m_penArray.GetAt(j); LOGPEN lp; double clr[3]; pPen->GetLogPen(&lp); clr[0] = GetRValue(lp.lopnColor)/255.0; clr[1] = GetGValue(lp.lopnColor)/255.0; clr[2] = GetBValue(lp.lopnColor)/255.0; glColor3dv(clr); while (u<(m_dLogPieEnd*PI/180.0)) { double P00[3],P01[3],P10[3],P11[3]; double dRadip, dRadi; dRadi = m_dRadiusLog3D * (wd[i+j] - wd[0+j])/(wd[m_nFormat+j] - wd[0+j]); dRadip = m_dRadiusLog3D * (wd[ipl+j] - wd[0+j])/(wd[m_nFormat+j] - wd[0+j]); P00[0] = wd[ipl+0] + cos(u)*(dRadip); P00[1] = wd[ipl+2]; P00[2] = -wd[ipl+1] + sin(u)*(dRadip); P01[0] = wd[ipl+0] + cos(u+dU)*(dRadip); P01[1] = wd[ipl+2]; P01[2] = -wd[ipl+1] + sin(u+dU)*(dRadip); P11[0] = wd[i+0] + cos(u+dU)*(dRadi); P11[1] = wd[i+2]; P11[2] = -wd[i+1] + sin(u+dU)*(dRadi); P10[0] = wd[i+0] + cos(u)*(dRadi); P10[1] = wd[i+2]; P10[2] = -wd[i+1] + sin(u)*(dRadi); glBegin(GL_QUADS); glVertex3dv(P00); glVertex3dv(P01); glVertex3dv(P11); glVertex3dv(P10); glEnd(); u+=dU; }; } } } } if(bLighht) glEnable(GL_LIGHTING); else glDisable(GL_LIGHTING); }
BOOL CDrawing::DrawElement(CDC* pDC, OgdcElemText* pElemText, BOOL bSelected) { OGDCASSERT(!OGDCIS0(m_dCoordRatio) && !m_rcClient.IsRectEmpty()); long nFontHeight = 10, nFontWidth = 5; OgdcTextStyle textStyle = pElemText->m_textStyle; if(textStyle.m_bFixedSize) { nFontHeight = OGDCROUND(textStyle.m_dHeight*3); if(nFontHeight == 0) { return TRUE; } nFontWidth = OGDCROUND(textStyle.m_dWidth*3); } else { nFontHeight = OGDCROUND(textStyle.m_dHeight/m_dCoordRatio); if(nFontHeight == 0) { return TRUE; } nFontWidth = OGDCROUND(textStyle.m_dWidth/m_dCoordRatio); } int nOldBkMode = 0; if( textStyle.m_bBackOpaque ) { nOldBkMode = pDC->SetBkMode(OPAQUE); } else { nOldBkMode = pDC->SetBkMode(TRANSPARENT); } CString strFontName = textStyle.m_strFaceName; strFontName.TrimLeft(); strFontName.TrimRight(); LOGFONT stFont; memset(&stFont,0,sizeof(LOGFONT)); stFont.lfWeight=FW_NORMAL; stFont.lfItalic = textStyle.m_bItalic; stFont.lfEscapement = OGDCROUND(textStyle.m_dAngle*10); stFont.lfOutPrecision = OUT_TT_PRECIS; stFont.lfClipPrecision = CLIP_LH_ANGLES; stFont.lfQuality = DRAFT_QUALITY;// PROOF_QUALITY; stFont.lfPitchAndFamily = TMPF_TRUETYPE|FF_SCRIPT; if(textStyle.m_bBold) { stFont.lfWeight = 700;//设置为粗体 } else { stFont.lfWeight = 0;//400 } if(textStyle.m_bUnderline) stFont.lfUnderline = TRUE;//设置为下画线 else stFont.lfUnderline = FALSE; if(textStyle.m_bStrikeOut) stFont.lfStrikeOut = TRUE;//设置为删除线 else stFont.lfStrikeOut = FALSE; stFont.lfHeight = nFontHeight; stFont.lfWidth = nFontWidth; strcpy(stFont.lfFaceName,strFontName); COLORREF color = textStyle.m_clrFore; if(bSelected) { CPen* pPen = pDC->GetCurrentPen(); if(pPen != NULL) { LOGPEN logPen; pPen->GetLogPen(&logPen); color = logPen.lopnColor; } } COLORREF corForeOld = pDC->SetTextColor(color); COLORREF corBackOld = pDC->SetBkColor(textStyle.m_clrBack); for(int i=0; i<pElemText->m_strTexts.GetSize(); i++) { stFont.lfEscapement = OGDCROUND(pElemText->m_angles[i]*10); CString strText = pElemText->m_strTexts[i]; OgdcPoint2D pnt2D = pElemText->m_points[i]; CPoint pntAnchor; CPoint* pPoints = NULL; GeoToDevice(&pnt2D, 1, pPoints); pntAnchor = pPoints[0]; delete[] pPoints; pPoints = NULL; CFont fontCurrent; fontCurrent.CreateFontIndirect(&stFont); CFont *pOldFont = pDC->SelectObject(&fontCurrent); pDC->TextOut(pntAnchor.x, pntAnchor.y, strText); pDC->SelectObject(pOldFont); } pDC->SetTextColor(corForeOld); pDC->SetBkColor(corBackOld); return TRUE; }