void CFFTDisp::OnMouseMove(UINT nFlags, CPoint point) { // 找到主框架 CMainFrame* pFrame = NULL; pFrame = (CMainFrame*)(AfxGetApp()->m_pMainWnd); if ( pFrame != NULL ) { if ( pFrame->m_bZoomOut ) { ::SetCursor( pFrame->m_hCursorOut ); } else if ( pFrame->m_bZoomIn ) { ::SetCursor( pFrame->m_hCursorIn ); } else { ::SetCursor( ::LoadCursor( NULL, IDC_ARROW ) ); } } // 记录移动坐标 m_ptMove = point; CSingleLock slDataBuf( &m_csFftDataBuf ); slDataBuf.Lock(); DrawCurve(); slDataBuf.Unlock(); CWnd::OnMouseMove(nFlags, point); }
void COscillogram::DrawPrint(CDC *dc, CRect *dRect) { int oldmode = dc->SetMapMode(MM_LOMETRIC); //获得网格矩形 m_GridRect.top = dRect->top - CS_MARGIN; m_GridRect.left = dRect->left + CS_MARGIN; m_GridRect.bottom = dRect->bottom + CS_MARGIN; m_GridRect.right = dRect->right - CS_MARGIN; //计算标题矩形 m_CaptionRect.top = dRect->top; m_CaptionRect.left = dRect->left; m_CaptionRect.bottom = m_GridRect.top ; m_CaptionRect.right = dRect->right; //计算步长宽度 m_xSpan = (float)m_GridRect.Width() / (m_xCount-1); m_ySpan = (float)m_GridRect.Height() / (m_yCount-1); //绘画工作 DrawCaption(dc); DrawGrid(dc); for(int i=0;i<GetCurveCount();i++) DrawCurve(dc,GetCurve(i)); dc->SetMapMode(oldmode); }
ULong Curve::movepoint (ULong code) { static ULong iPckedPnt = 0; static Bool lock = FALSE; if (code == WM_LBUTTONDOWN) if (_Editor.pCurrView->GetNearestPoint (this, _Editor.MousePos, iPckedPnt)) lock = TRUE; if (code == WM_LBUTTONUP) lock = FALSE; if (lock) { FP x,y; _Editor.pCurrView->GetWorldPos (_Editor.MousePos, x, y); UnDrawCurve (_Editor.pCurrView); CurveData[iPckedPnt].index = x; CurveData[iPckedPnt].value = y; DrawCurve (_Editor.pCurrView); } return lock; }
// generate the cylinder, it's made by a stack of circles void GenerateSurface() { GenerateCurve(); glNewList(CYLINDER, GL_COMPILE); for (int i = 0; i < CIRCLENUM; i++) { DrawCurve(i/4.0f); } glEndList(); }
void EggAvatar::DrawHair(IFTImage* pImage, UINT32 color) { // For each hair for (int i = 0; i < NumberOfHairs; ++i) { int firstPoint = HairFirstPoint + i * PointPerSingleHair; DrawCurve(pImage, firstPoint, PointPerSingleHair, false, color); } }
void COscillogram::DrawOscillogram(CDC *dc) { int oldmode = dc->SetMapMode(MM_LOMETRIC); SetOscillogramRect(dc); DrawCaption(dc); DrawGrid(dc); for(int i=0;i<GetCurveCount();i++) DrawCurve(dc,GetCurve(i)); dc->SetMapMode(oldmode); }
void CFFTDisp::ZoomRestore() { m_nBeginPos = 0; // m_dwDot = MAX_DEPTH/2; m_dwDot = MAX_DEPTH; m_dMaxGap = m_dOrgSampFreq / 2; m_dGap = m_dMaxGap / MAX_AXIS_VALUE; m_nRatio = 1; CSingleLock slDataBuf( &m_csFftDataBuf ); slDataBuf.Lock(); DrawCurve(); slDataBuf.Unlock(); }
void COscillogram::AddCurveValue(int nIndex ,float val,BOOL state) { CPointValue * temp; if(GetCurve(nIndex)) temp = &GetCurve(nIndex)->ptVal; else return ; CClientDC dc(this); dc.SetBkMode(TRANSPARENT); int oldMode = dc.SetMapMode(MM_LOMETRIC); SetOscillogramRect(&dc); DrawCurve(&dc,GetCurve(nIndex)); temp->SetValue(val,state); temp->MoveNext(); DrawCurve(&dc,GetCurve(nIndex)); dc.SetMapMode(oldMode); }
void CCurveButton::DrawItem(LPDRAWITEMSTRUCT lpDIS) { CDC * pDC = GetDC(); if( NULL == pDC ) return; CRect rectClient; GetClientRect( &rectClient ); pDC->FillSolidRect( rectClient, AfxGetProfile().GetColor(CColorClass::clrGraphBK) ); int scrollpos = GetScrollPos32( SB_HORZ ); DrawCurve( pDC, rectClient, scrollpos ); }
ULong Curve::addpoint (ULong code) { static ULong iPckedPnt = 0; if (code == WM_LBUTTONUP) { if (_Editor.pCurrView->GetNearestPoint (this, _Editor.MousePos, iPckedPnt)) { UnDrawCurve (_Editor.pCurrView); PCURVE pCurve = this; PCURVEPNT pNewPnts = new CURVEPNT [pCurve->cPoints + 1]; ULong n; for (n=0; n<=iPckedPnt; n++) { pNewPnts[n].index = pCurve->CurveData[n].index; pNewPnts[n].value = pCurve->CurveData[n].value; } pNewPnts[n].index = (pCurve->CurveData[n-1].index + pCurve->CurveData[n].index) / 2; pNewPnts[n].value = (pCurve->CurveData[n-1].value + pCurve->CurveData[n].value) / 2; for (; n<pCurve->cPoints; n++) { pNewPnts[n+1].index = pCurve->CurveData[n].index; pNewPnts[n+1].value = pCurve->CurveData[n].value; } pCurve->cPoints++; delete pCurve->CurveData; pCurve->CurveData = pNewPnts; DrawGrads (_Editor.pCurrView); DrawCurve (_Editor.pCurrView); } } return iPckedPnt; }
ULong Curve::deletepoint (ULong code) { static ULong iPckedPnt = 0; if (code == WM_LBUTTONUP) { if (_Editor.pCurrView->GetNearestPoint (this, _Editor.MousePos, iPckedPnt)) { UnDrawCurve (_Editor.pCurrView); PCURVE pCurve = this; PCURVEPNT pNewPnts = new CURVEPNT [pCurve->cPoints - 1]; ULong n,m; for (n=0, m=0; m<pCurve->cPoints; n++, m++) { if (m == iPckedPnt) { if ((m+1) == pCurve->cPoints) break; else m++; } pNewPnts[n].index = pCurve->CurveData[m].index; pNewPnts[n].value = pCurve->CurveData[m].value; } pCurve->cPoints--; delete pCurve->CurveData; pCurve->CurveData = pNewPnts; DrawGrads (_Editor.pCurrView); DrawCurve (_Editor.pCurrView); } } return iPckedPnt; }
// 表格绘制. void DataGrids::DrawGrids(HDC _hdc) { // 绘制x/y的箭头. WideString xStr = "电压(V)"; WideString yStr = "时间(S)"; m_stGrp = new Gdiplus::Graphics(_hdc); m_stGrp->SetSmoothingMode(Gdiplus::SmoothingModeHighQuality); /*FontFamily fontFamily(L"楷体_GB2312"); Font font(&fontFamily, 30, FontStyleRegular, UnitPixel); */ Gdiplus::SolidBrush solidBrush(Gdiplus::Color(255, 0, 0, 255)); Gdiplus::Pen p(Gdiplus::Color(255, 0, 0, 0),1); Gdiplus::AdjustableArrowCap cap(8,4,true); Gdiplus::Font font(L"楷体",12); Gdiplus::SolidBrush s( Gdiplus::Color(255, 0, 0, 0)); #define X(_x) UserX((_x)+xAxisOffset) #define Y(_y) UserY((_y)+yAxisOffset) // 刻度线.Y轴. p.SetColor(Gdiplus::Color(255, 0, 0, 255)); for(int i = 0; i * yMarkSpace < m_iHeight-yMarkSpace-8;i++) { m_stGrp->DrawLine(&p,X(0),Y(0+i*yMarkSpace),X(yMarkHeight+(((i%5)==0)?yMarkHeight:0)),Y(0+i*yMarkSpace)); } for(int i = 0; i * yMarkSpace < m_iWidth-xMarkSpace-8;i++) { m_stGrp->DrawLine(&p,X(i*xMarkSpace),Y(0),X(i*xMarkSpace),Y(xMarkHeight+((i%5)==0?xMarkHeight:0))); } p.SetColor(Gdiplus::Color(255, 0, 0, 0)); // Draw X,Y axises. p.SetCustomEndCap(&cap); m_stGrp->DrawLine(&p,X(0),Y(0),X(0),Y(m_iHeight)); // Draw Y axis m_stGrp->DrawLine(&p,X(0),Y(0),X(m_iWidth),Y(0)); // Draw X axis m_stGrp->DrawString(xStr.c_bstr(),xStr.Length(),&font,Gdiplus::PointF(30,10),&s); m_stGrp->DrawString(yStr.c_bstr(),yStr.Length(),&font,Gdiplus::PointF(m_iWidth-80,m_iHeight-50),&s); #undef X(_x) #undef Y(_y) DrawCurve(); delete m_stGrp; }
void QGraph::DrawGraph(QPainter &painter) { static QColor color; painter.save(); // Paint background // QBrush bg(m_BkColor); // painter.setBackground(bg); // Draw Border if(m_bBorder) color = m_BorderColor; else color = m_BkColor; QPen BorderPen(color); BorderPen.setStyle(GetStyle(m_BorderStyle)); BorderPen.setWidth(m_BorderWidth); painter.setPen(BorderPen); painter.fillRect(m_rCltRect, m_BkColor); painter.drawRect(m_rCltRect); Init(); painter.setClipRect(m_rCltRect); painter.setBackgroundMode(Qt::TransparentMode); if(m_bXMinGrid) DrawXMinGrid(painter); if(m_bYMinGrid) DrawYMinGrid(painter); if(m_bXMajGrid) DrawXMajGrid(painter); if(m_bYMajGrid) DrawYMajGrid(painter); DrawAxes(painter); DrawXTicks(painter); DrawYTicks(painter); for (int nc=0; nc < m_oaCurves.size(); nc++) DrawCurve(nc,painter); DrawTitles(painter); painter.setClipping(false); painter.restore(); }
void CFFTDisp::ZoomOut() { // 根据右击位置,计算对应的点(坐标间隔最小为1,所以点数不能太少) if ( m_ptRightClick.x > FFT_LEFT_MARGIN && m_dwDot > 20 ) { // 计算开始位置 DWORD dwNewDot = m_dwDot / 2; DWORD dwMousePoint = ( m_ptRightClick.x - FFT_LEFT_MARGIN ) * m_dwDot / m_dwPicWidth + m_nBeginPos; // 显示区域 [dwMousePoint - dwNewDot / 2, dwMousePoint + dwNewDot / 2] m_nBeginPos = dwMousePoint - dwNewDot / 2; // 修改最大间隔 m_dMaxGap = m_dMaxGap / 2; CString strMsg = "1.00"; CSize szText = m_dcPlot.GetTextExtent( strMsg ); int nAxisPointNum = m_dwPicWidth / (szText.cx * 2); if ( nAxisPointNum > MAX_AXIS_VALUE ) { nAxisPointNum = MAX_AXIS_VALUE; } if ( nAxisPointNum < 1 ) { nAxisPointNum = 1; } double dGap = m_dMaxGap / nAxisPointNum; m_dGap = FindNearFloatValue( dGap ); // 重新计算最大间隔和最大点数 m_dMaxGap = m_dGap * nAxisPointNum; m_dwDot = m_dMaxGap * MAX_DEPTH / m_dOrgSampFreq; CSingleLock slDataBuf( &m_csFftDataBuf ); slDataBuf.Lock(); DrawCurve(); slDataBuf.Unlock(); } if ( m_dwDot <= 20 ) { //SendMessage( ID_MENU_ZOOM_RESTORE ); ZoomRestore(); } }
BOOL EggAvatar::DrawImage(IFTImage* pImage) { // Initialize internal points to mean shape plus animation units LatLonEye(false); LatLonEye(true); LatLonEyeBrow(false); LatLonEyeBrow(true); LatLonMouth(); LatLonNose(); LatLonHair(); // Apply yaw to the feature points LatLonYaw(); // Convert to XYZ, apply pitch, roll, draw circle, scale and translate LatLonToXYZ(); PitchXYZ(); RollXYZ(); bool wasFacing = m_FacingUser; if (m_FacingUser && !CanTrackPupil()) { m_FacingUser = false; } PupilXYZ(false); PupilXYZ(true); m_FacingUser = wasFacing; CircleXYZ(); ScaleXYZ(); TranslateXYZ(); // Draw the components UINT32 white=0xFFFFFFFF; DrawCurve(pImage, RightEyeFirstPoint, NumberEyePoints, true, white); DrawCurve(pImage, LeftEyeFirstPoint, NumberEyePoints, true, white); DrawCurve(pImage, RightEyebrowFirstPoint, NumberEyebrowPoints, false, white); DrawCurve(pImage, LeftEyebrowFirstPoint, NumberEyebrowPoints, false, white); DrawCurve(pImage, MouthFirstPoint, NumberMouthPoints, true, white); DrawCurve(pImage, NoseFirstPoint, NumberNosePoints, false, white); DrawHair(pImage, white); DrawCurve(pImage, CircleFirstPoint, NumberCirclePoints, true, white); DrawPupil(pImage, true, white); DrawPupil(pImage, false, white); return TRUE; }
void CFFTDisp::OnSize(UINT nType, int cx, int cy) { CWnd::OnSize(nType, cx, cy); // TODO: Add your message handler code here GetClientRect(m_rectPlot); m_nClientHeight = m_rectPlot.Height(); m_nClientWidth = m_rectPlot.Width(); m_dwPicWidth = (m_nClientWidth - FFT_LEFT_MARGIN * 2) / FFT_NUM_HORZ * FFT_NUM_HORZ; // 显示点数与视图大小一致 //m_dwDot = (m_nClientWidth - FFT_LEFT_MARGIN * 2) / FFT_NUM_HORZ * FFT_NUM_HORZ; if ( cx > 0 && cy > 0 ) { // 图像大小发生变化时,修改背景DC和图像DC的大小 InvalidateCtrl(); // 重画图像 //DrawSpectrum(); CSingleLock slDataBuf( &m_csFftDataBuf ); slDataBuf.Lock(); DrawCurve(); slDataBuf.Unlock(); } }
ULong Curve::DuplicateCl (ULong code) { UnDrawCurve (_Editor.pCurrView); PCURVE pCurve = this; ULong n; for (n=0; n<pCurve->cPoints; n++) { if (pCurve->CurveData[n].index > 180) break; } if (n < 2) return FALSE; if (n < pCurve->cPoints) { // remove points from n onwards (including n) // and duplicate & rotate through 180 PCURVEPNT pNewPnts = new CURVEPNT [n << 1]; // copy wanted points into new array ULong m; for (m = 0; m<(n << 1); m++) { if (m < n) { pNewPnts[m].index = pCurve->CurveData[m].index; pNewPnts[m].value = pCurve->CurveData[m].value; } if (m >= n) { pNewPnts[m].index = 360 - pCurve->CurveData[(n<<1)-(m+1)].index; pNewPnts[m].value = - pCurve->CurveData[(n<<1)-(m+1)].value; } } pCurve->cPoints = n<<1; delete pCurve->CurveData; pCurve->CurveData = pNewPnts; } DrawGrads (_Editor.pCurrView); DrawCurve (_Editor.pCurrView); return TRUE; // ******** static ULong iPckedPnt = 0; if (code == WM_LBUTTONUP) { if (_Editor.pCurrView->GetNearestPoint (this, _Editor.MousePos, iPckedPnt)) { PCURVE pCurve = this; PCURVEPNT pNewPnts = new CURVEPNT [pCurve->cPoints - 1]; ULong n,m; for (n=0, m=0; m<pCurve->cPoints; n++, m++) { if (m == iPckedPnt) { if ((m+1) == pCurve->cPoints) break; else m++; } pNewPnts[n].index = pCurve->CurveData[m].index; pNewPnts[n].value = pCurve->CurveData[m].value; } pCurve->cPoints--; delete pCurve->CurveData; pCurve->CurveData = pNewPnts; } } return iPckedPnt; }