⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 histogram.cpp

📁 3D reconstruction, medical image processing from colons, using intel image processing for based clas
💻 CPP
📖 第 1 页 / 共 4 页
字号:
							// boundary check by position							if(pOTFPolygon->nPointPoX[2] < pOTFPolygon->nPointPoX[1])								pOTFPolygon->nPointPoX[2] = pOTFPolygon->nPointPoX[1];							if(pOTFPolygon->nPointPoX[2] > pOTFPolygon->nPointPoX[3])								pOTFPolygon->nPointPoX[2] = pOTFPolygon->nPointPoX[3];							UpdateSpectrum();							RedrawWnd();							SendMessageToOwner(OTF_POS_CHANGED);						}					}					else if(nHitTest == HGHT_OTF_POINT4)					{						int		nOldPiX = pOTFPolygon->nPointPiX[3];						// boundary check by pixel						pOTFPolygon->nPointPiX[3] = msg.pt.x+nDiff1;						if(pOTFPolygon->nPointPiX[3] >= m_szWindow.cx)							pOTFPolygon->nPointPiX[3] = m_szWindow.cx;						else if(pOTFPolygon->nPointPiX[3] <= pOTFPolygon->nPointPiX[2])							pOTFPolygon->nPointPiX[3] = pOTFPolygon->nPointPiX[2];						if(nOldPiX != pOTFPolygon->nPointPiX[3])						{							// pixel to position							pOTFPolygon->nPointPoX[3] = PiToPoH(pOTFPolygon->nPointPiX[3],																m_stScroll.nPoMin, m_stScroll.nPoMax);							// boundary check by position							if(pOTFPolygon->nPointPoX[3] < pOTFPolygon->nPointPoX[2])								pOTFPolygon->nPointPoX[3] = pOTFPolygon->nPointPoX[2];							UpdateSpectrum();							RedrawWnd();							SendMessageToOwner(OTF_POS_CHANGED);						}					}					else if(nHitTest == HGHT_OTF_LINE1)					{						int		nOldPiX = pOTFPolygon->nPointPiX[0];						pOTFPolygon->nPointPiX[0] = msg.pt.x+nDiff1;						pOTFPolygon->nPointPiX[1] = pOTFPolygon->nPointPiX[0]+nDiff2;						if(pOTFPolygon->nPointPiX[0] <= 0)						{							pOTFPolygon->nPointPiX[0] = 0;							pOTFPolygon->nPointPiX[1] = pOTFPolygon->nPointPiX[0]+nDiff2;						}						else if(pOTFPolygon->nPointPiX[1] >= pOTFPolygon->nPointPiX[2])						{							pOTFPolygon->nPointPiX[1] = pOTFPolygon->nPointPiX[2];							pOTFPolygon->nPointPiX[0] = pOTFPolygon->nPointPiX[1]-nDiff2;						}						if(nOldPiX != pOTFPolygon->nPointPiX[0])						{							pOTFPolygon->nPointPoX[0] = PiToPoH(pOTFPolygon->nPointPiX[0],																m_stScroll.nPoMin, m_stScroll.nPoMax);							pOTFPolygon->nPointPoX[1] = PiToPoH(pOTFPolygon->nPointPiX[1],																m_stScroll.nPoMin, m_stScroll.nPoMax);							UpdateSpectrum();							RedrawWnd();							SendMessageToOwner(OTF_POS_CHANGED);						}					}					else if(nHitTest == HGHT_OTF_LINE2)					{						int		nOldPiY = pOTFPolygon->nPointPiY[1];						pOTFPolygon->nPointPiY[1] = msg.pt.y+nDiff1;						if(pOTFPolygon->nPointPiY[1] <= nTop)							pOTFPolygon->nPointPiY[1] = nTop;						else if(pOTFPolygon->nPointPiY[1] >= nBottom)							pOTFPolygon->nPointPiY[1] = nBottom;						if(nOldPiY != pOTFPolygon->nPointPiY[1])						{							pOTFPolygon->nPointPiY[2] = pOTFPolygon->nPointPiY[1];							pOTFPolygon->fOpacityPo   = PiToPoO(pOTFPolygon->nPointPiY[1]);							UpdateSpectrum();							RedrawWnd();							SendMessageToOwner(OTF_POS_CHANGED);						}					}					else if(nHitTest == HGHT_OTF_LINE3)					{						int		nOldPiX = pOTFPolygon->nPointPiX[2];						pOTFPolygon->nPointPiX[2] = msg.pt.x+nDiff1;						pOTFPolygon->nPointPiX[3] = pOTFPolygon->nPointPiX[2]+nDiff2;						if(pOTFPolygon->nPointPiX[2] <= pOTFPolygon->nPointPiX[1])						{							pOTFPolygon->nPointPiX[2] = pOTFPolygon->nPointPiX[1];							pOTFPolygon->nPointPiX[3] = pOTFPolygon->nPointPiX[2]+nDiff2;						}						else if(pOTFPolygon->nPointPiX[3] >= m_szWindow.cx)						{							pOTFPolygon->nPointPiX[3] = m_szWindow.cx;							pOTFPolygon->nPointPiX[2] = pOTFPolygon->nPointPiX[3]-nDiff2;						}						if(nOldPiX != pOTFPolygon->nPointPiX[2])						{							pOTFPolygon->nPointPoX[2] = PiToPoH(pOTFPolygon->nPointPiX[2],																m_stScroll.nPoMin, m_stScroll.nPoMax);							pOTFPolygon->nPointPoX[3] = PiToPoH(pOTFPolygon->nPointPiX[3],																m_stScroll.nPoMin, m_stScroll.nPoMax);							UpdateSpectrum();							RedrawWnd();							SendMessageToOwner(OTF_POS_CHANGED);						}					}					else if(nHitTest == HGHT_OTF_POLYGON)					{						int		nOldPiX = pOTFPolygon->nPointPiX[0];						pOTFPolygon->nPointPiX[0] = msg.pt.x+nDiff1;						pOTFPolygon->nPointPiX[1] = pOTFPolygon->nPointPiX[0]+nDiff2;						pOTFPolygon->nPointPiX[2] = pOTFPolygon->nPointPiX[0]+nDiff3;						pOTFPolygon->nPointPiX[3] = pOTFPolygon->nPointPiX[0]+nDiff4;						if(pOTFPolygon->nPointPiX[0] <= 0)						{							pOTFPolygon->nPointPiX[0] = 0;							pOTFPolygon->nPointPiX[1] = pOTFPolygon->nPointPiX[0]+nDiff2;							pOTFPolygon->nPointPiX[2] = pOTFPolygon->nPointPiX[0]+nDiff3;							pOTFPolygon->nPointPiX[3] = pOTFPolygon->nPointPiX[0]+nDiff4;						}						else if(pOTFPolygon->nPointPiX[3] >= m_szWindow.cx)						{							pOTFPolygon->nPointPiX[0] = m_szWindow.cx-nDiff4;							pOTFPolygon->nPointPiX[1] = pOTFPolygon->nPointPiX[0]+nDiff2;							pOTFPolygon->nPointPiX[2] = pOTFPolygon->nPointPiX[0]+nDiff3;							pOTFPolygon->nPointPiX[3] = pOTFPolygon->nPointPiX[0]+nDiff4;						}						if(nOldPiX != pOTFPolygon->nPointPiX[2])						{							pOTFPolygon->nPointPoX[0] = PiToPoH(pOTFPolygon->nPointPiX[0],																m_stScroll.nPoMin, m_stScroll.nPoMax);							pOTFPolygon->nPointPoX[1] = PiToPoH(pOTFPolygon->nPointPiX[1],																m_stScroll.nPoMin, m_stScroll.nPoMax);							pOTFPolygon->nPointPoX[2] = PiToPoH(pOTFPolygon->nPointPiX[2],																m_stScroll.nPoMin, m_stScroll.nPoMax);							pOTFPolygon->nPointPoX[3] = PiToPoH(pOTFPolygon->nPointPiX[3],																m_stScroll.nPoMin, m_stScroll.nPoMax);							UpdateSpectrum();							RedrawWnd();							SendMessageToOwner(OTF_POS_CHANGED);						}					}				}				break;			case WM_LBUTTONUP :				goto EndLButtonDown;			default :	// just dispatch rest of the messages				DispatchMessage(&msg);				break;		}	}EndLButtonDown :	ReleaseCapture();}void RxHistogram::OnLButtonDblClk(UINT nFlags, CPoint point) {	int		nIndex		= -1;	int		nHitTest	= HitTest(point, &nIndex);	if(HGHT_OTF_POINT1 <= nHitTest && nHitTest <= HGHT_OTF_POLYGON)	{		// 急琶等 OTF啊 厚劝己拳 登绢乐促搁 劝己拳 矫挪促.		if(nIndex != m_nActiveOTF)		{			m_nActiveOTF = nIndex;			RedrawWnd();		}		// 泅犁狼 OTF狼 祸惑阑 函版茄促.		if(nIndex > -1)		{			int				nPoint;			CColorDialog	dlgColor;			_OTF_POLYGON	*pOTFPolygon = (_OTF_POLYGON *)m_ArrayOTFPolygon.GetAt(nIndex);			dlgColor.m_cc.Flags |= CC_RGBINIT|CC_ANYCOLOR|CC_FULLOPEN;			switch(nHitTest)			{				case HGHT_OTF_POINT1 :				case HGHT_OTF_POINT2 :				case HGHT_OTF_POINT3 :				case HGHT_OTF_POINT4 :					nPoint = nHitTest - HGHT_OTF_POINT1;					dlgColor.m_cc.rgbResult = pOTFPolygon->crPoint[nPoint];					if(dlgColor.DoModal() == IDOK)					{						pOTFPolygon->crPoint[nPoint] = dlgColor.GetColor();						UpdateSpectrum();						RedrawWnd();						SendMessageToOwner(OTF_COLOR_CHANGED);					}					break;				case HGHT_OTF_LINE1 :				case HGHT_OTF_LINE2 :				case HGHT_OTF_LINE3 :					nPoint = nHitTest - HGHT_OTF_LINE1;					if(pOTFPolygon->crPoint[nPoint] == pOTFPolygon->crPoint[nPoint+1])						dlgColor.m_cc.rgbResult = pOTFPolygon->crPoint[nPoint];					if(dlgColor.DoModal() == IDOK)					{						pOTFPolygon->crPoint[nPoint]   = dlgColor.GetColor();						pOTFPolygon->crPoint[nPoint+1] = dlgColor.GetColor();						UpdateSpectrum();						RedrawWnd();						SendMessageToOwner(OTF_COLOR_CHANGED);					}					break;				case HGHT_OTF_POLYGON :					nPoint = 0;					if(pOTFPolygon->crPoint[nPoint] == pOTFPolygon->crPoint[nPoint+1] &&						pOTFPolygon->crPoint[nPoint] == pOTFPolygon->crPoint[nPoint+2] &&						pOTFPolygon->crPoint[nPoint] == pOTFPolygon->crPoint[nPoint+3])						dlgColor.m_cc.rgbResult = pOTFPolygon->crPoint[nPoint];					if(dlgColor.DoModal() == IDOK)					{						pOTFPolygon->crPoint[nPoint]   = dlgColor.GetColor();						pOTFPolygon->crPoint[nPoint+1] = dlgColor.GetColor();						pOTFPolygon->crPoint[nPoint+2] = dlgColor.GetColor();						pOTFPolygon->crPoint[nPoint+3] = dlgColor.GetColor();						UpdateSpectrum();						RedrawWnd();						SendMessageToOwner(OTF_COLOR_CHANGED);					}					break;			}		}	}		CWnd::OnLButtonDblClk(nFlags, point);}void RxHistogram::OnRButtonUp(UINT nFlags, CPoint point) {	int		nIndex		= -1;	int		nHitTest	= HitTest(point, &nIndex);	if(HGHT_OTF_POINT1 <= nHitTest && nHitTest <= HGHT_OTF_POLYGON)	{		// 急琶等 OTF啊 厚劝己拳 登绢乐促搁 劝己拳 矫挪促.		if(nIndex != m_nActiveOTF)			m_nActiveOTF = nIndex;		// 泅犁狼 OTF狼 祸惑阑 函版茄促.		if(nIndex > -1)		{			_OTF_POLYGON	*pOTFPolygon = (_OTF_POLYGON *)m_ArrayOTFPolygon.GetAt(nIndex);			pOTFPolygon->bEnable = !pOTFPolygon->bEnable;		}		UpdateSpectrum();		RedrawWnd();		SendMessageToOwner(OTF_COLOR_CHANGED);	}		CWnd::OnRButtonUp(nFlags, point);}int  RxHistogram::HitTest(CPoint point, int *pOTFIndex){	// 胶农费官 康开 眉农	if(point.y <= HGSZ_SCROLL)	{		if((m_stScroll.nPiMin+HGSZ_HITTEST < point.x) && (point.x < m_stScroll.nPiMax-HGSZ_HITTEST))			return HGHT_SCROLL_CENTER;		else if((m_stScroll.nPiMin-HGSZ_HITTEST < point.x) && (point.x <= m_stScroll.nPiMin+HGSZ_HITTEST))			return HGHT_SCROLL_LEFT;		else if((m_stScroll.nPiMax-HGSZ_HITTEST <= point.x) && (point.x < m_stScroll.nPiMax+HGSZ_HITTEST))			return HGHT_SCROLL_RIGHT;	}	// OTF 康开 眉农	else if(point.y >= (HGSZ_SCROLL+HGSZ_SCROLL_MARGIN) &&				point.y <= (m_szWindow.cy))	{		int		nOTFCount = m_ArrayOTFPolygon.GetSize();		if(nOTFCount <= 0)		return -1;		_OTF_POLYGON	*pOTFPolygon;		int				i,j,k;		// first check Active OTF, and then check Inactive OTF		// point hit test		for(i = nOTFCount; i >= 0; i--)		{			if(i == nOTFCount)			j = m_nActiveOTF;			else						j = i;			if(i == m_nActiveOTF)		continue;			pOTFPolygon = (_OTF_POLYGON *)m_ArrayOTFPolygon.GetAt(j);			for(k = 0; k < 4; k++)			{				if(point.x <= pOTFPolygon->nPointPiX[k]+HGSZ_HITTEST &&					point.x >= pOTFPolygon->nPointPiX[k]-HGSZ_HITTEST &&					point.y <= pOTFPolygon->nPointPiY[k]+HGSZ_HITTEST && 					point.y >= pOTFPolygon->nPointPiY[k]-HGSZ_HITTEST)				{					if(pOTFIndex != NULL)			*pOTFIndex = j;					return (HGHT_OTF_POINT1 + k);				}			}		}		// line test		float	fSlope;		int		nOnLineX, nOnLineY;		for(i = nOTFCount; i >= 0; i--)		{			if(i == nOTFCount)			j = m_nActiveOTF;			else						j = i;			if(i == m_nActiveOTF)		continue;			pOTFPolygon = (_OTF_POLYGON *)m_ArrayOTFPolygon.GetAt(j);			for(k = 0; k < 3; k++)			{				if (pOTFPolygon->nPointPiX[k] != pOTFPolygon->nPointPiX[k+1])				{					fSlope = (float)(pOTFPolygon->nPointPiY[k+1] - pOTFPolygon->nPointPiY[k]) /								(float)(pOTFPolygon->nPointPiX[k+1] - pOTFPolygon->nPointPiX[k]);					if(fabs(fSlope) <= 1.0f)					{						if(pOTFPolygon->nPointPiX[k] < point.x && point.x < pOTFPolygon->nPointPiX[k+1])						{							nOnLineY = (int)(fSlope*(point.x-pOTFPolygon->nPointPiX[k])+pOTFPolygon->nPointPiY[k]);							if(point.y <= nOnLineY+HGSZ_HITTEST && point.y >= nOnLineY-HGSZ_HITTEST)							{								if(pOTFIndex != NULL)			*pOTFIndex = j;								return (HGHT_OTF_LINE1 + k);							}						}					}					else					{						if(min(pOTFPolygon->nPointPiY[k], pOTFPolygon->nPointPiY[k+1]) < point.y &&								point.y < max(pOTFPolygon->nPointPiY[k], pOTFPolygon->nPointPiY[k+1]))						{							nOnLineX = (int)((1.0f/fSlope)*(point.y-pOTFPolygon->nPointPiY[k])+pOTFPolygon->nPointPiX[k]);														if(point.x <= nOnLineX+HGSZ_HITTEST && point.x >= nOnLineX-HGSZ_HITTEST)							{								if(pOTFIndex != NULL)			*pOTFIndex = j;								return (HGHT_OTF_LINE1 + k);							}						}					}				}				else				{					if(point.x > pOTFPolygon->nPointPiX[k]-HGSZ_HITTEST &&						point.x < pOTFPolygon->nPointPiX[k]+HGSZ_HITTEST &&						min(pOTFPolygon->nPointPiY[k], pOTFPolygon->nPointPiY[k+1]) < point.y &&						point.y < max(pOTFPolygon->nPointPiY[k], pOTFPolygon->nPointPiY[k+1]))					{							if(pOTFIndex != NULL)			*pOTFIndex = j;							return (HGHT_OTF_LINE1 + k);					}				}			}		}		// inside polygon test		for(i = nOTFCount; i >= 0; i--)		{			BOOL	bInStatus[3] = { FALSE, FALSE, FALSE };			if(i == nOTFCount)			j = m_nActiveOTF;			else						j = i;			if(i == m_nActiveOTF)		continue;			pOTFPolygon = (_OTF_POLYGON *)m_ArrayOTFPolygon.GetAt(j);			if(pOTFPolygon->nPointPiX[0] < point.x && point.x < pOTFPolygon->nPointPiX[3])			{				for(k = 0; k < 3; k++)				{					if(pOTFPolygon->nPointPiX[k] != pOTFPolygon->nPointPiX[k+1])					{						fSlope = (float)(pOTFPolygon->nPointPiY[k+1] - pOTFPolygon->nPointPiY[k]) /									(float)(pOTFPolygon->nPointPiX[k+1] - pOTFPolygon->nPointPiX[k]);						if(point.y > fSlope * (point.x - pOTFPolygon->nPointPiX[k]) + pOTFPolygon->nPointPiY[k])							bInStatus[k] = TRUE;					}					else					{	//荐流栏肺 登绢 乐绰 荤急						if (k == 0 && point.x > pOTFPolygon->nPointPiX[k])							bInStatus[k] = TRUE;						else if(k == 1 && point.y > pOTFPolygon->nPointPiY[1])							bInStatus[k] = TRUE;						else if(k == 2 && point.x < pOTFPolygon->nPointPiX[k])							bInStatus[k] = TRUE;					}				}			}			if(bInStatus[0] && bInStatus[1] && bInStatus[2])			{				if(pOTFIndex != NULL)			*pOTFIndex = j;				return HGHT_OTF_POLYGON;			}		}	}	return -1;}///////////////////////////////////////////////////////////////////////////////	structure management functionsvoid RxHistogram::SetScroll(_SCROLL *pScroll, BOOL bRedraw){	m_stScroll.nMinSize		= pScroll->nMinSize;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -