示例#1
0
BOOL CColorCell::HitTest(CPoint point)
{
	if (m_bAtFirstType)
	{
		CRgn rgn;
		rgn.CreatePolygonRgn(m_Points, 6, ALTERNATE);
		return rgn.PtInRegion(point);
	}
	else
	{
		CRgn rgn;
		rgn.CreateRectRgn(m_rcPosition.left, m_rcPosition.top, m_rcPosition.right, m_rcPosition.bottom);
		return rgn.PtInRegion(point);
	}
}
/*
Description:
  Selects point cloud points using a 2D selection region.
Parameters:
  view     - [in]  The view in which the selection region was defined.
  cloud    - [in]  The point cloud to test.
  points3d - [in]  The 2D (screen) points that define the selection region.
  indices  - [out] The indices of the points in the point cloud
                   that lie inside of the selection region.
Returns:
  The number of indices added to the output array.
*/
static int RhRegionSelectPointCloudPoints(
    CRhinoView* view,
    const ON_PointCloud& cloud,
    ON_SimpleArray<CPoint>& points2d,
    ON_SimpleArray<int>& indices
)
{
    if( 0 == view )
        return 0;

    const int index_count = indices.Count();

    CRgn rgn;
    if( rgn.CreatePolygonRgn(points2d.Array(), points2d.Count(), WINDING) )
    {
        ON_Xform w2s;
        view->ActiveViewport().VP().GetXform( ON::world_cs, ON::screen_cs, w2s );

        int i;
        ON_3dPoint point;

        for( i = 0; i < cloud.m_P.Count(); i++ )
        {
            point = cloud.m_P[i];
            point.Transform( w2s );
            if( rgn.PtInRegion((int)point.x, (int)point.y) )
                indices.Append( i );
        }
    }

    return indices.Count() - index_count;
}
示例#3
0
BOOL CTyBase::PointRgn(float x, float y, int Numble, PointStruct *PointList, float blc)
{
	CRgn rgn; 
	int x1,y1,i;
	CPoint bbcc[MAXPOINTNUM];
	
	if(Numble < 3) 
		return 0;//如果点的数目<3即不是一个区域返回不成功标志

	ASSERT(Numble <= MAXPOINTNUM);

	//将点的坐标转变成屏幕坐标
	x1 = (int)(x/blc);
	y1 = (int)(y/blc);

	//将封闭区域各点的坐标转成屏幕坐标
	for(i = 0;i < Numble;i++)
	{
		bbcc[i].x = (int)((PointList[i].x)/blc);
		bbcc[i].y = (int)((PointList[i].y)/blc);
	}

	rgn.CreatePolygonRgn(bbcc,Numble,1);//初试化一个多边形区域
	i = (rgn.PtInRegion(x1,y1)!=0);		//如果在区域内j=1,否则j=0;
	rgn.DeleteObject();					        //删除定义的rgn对象

	return i;
}
示例#4
0
bool ASSISTANT::Oval::ContainsPoint(Gdiplus::PointF &ptMouse)
{
   if (!visible)
      return false; 

   CRect rcObject;
   GetBoundingBox(rcObject);

   CRgn rgnElliptic;

   double dMaxDistance = (double)lineWidth / 2 + 0.5;
   BOOL bRet = TRUE;
   if (IsFilled())
   {
      CRgn rgnElliptic;
      bRet = rgnElliptic.CreateEllipticRgnIndirect(rcObject);
      
      if (!bRet)
         return false;
      if (rgnElliptic.PtInRegion((int)ptMouse.X, (int)ptMouse.Y))
         return true;
      
   }
   else
   {
      CRect rcOutside = rcObject;
      rcOutside.InflateRect(dMaxDistance, dMaxDistance, dMaxDistance, dMaxDistance);
      bRet = rgnElliptic.CreateEllipticRgnIndirect(rcOutside);
      if (!bRet)
         return false;

      CRgn rgnElliptic2;
      CRect rcInside = rcObject;
      rcInside.DeflateRect(dMaxDistance, dMaxDistance, dMaxDistance, dMaxDistance);
      bRet = rgnElliptic2.CreateEllipticRgnIndirect(rcInside);
      if (!bRet)
         return false;

      rgnElliptic.CombineRgn(&rgnElliptic, &rgnElliptic2, RGN_DIFF);
      if (rgnElliptic.PtInRegion((int)ptMouse.X, (int)ptMouse.Y))
         return true;

   }

   return false;
}
示例#5
0
文件: GLine.cpp 项目: SeoGB/exam
//--------------------------------------------------------------------------
// 선택 지점의 좌표 포인트 반환
//--------------------------------------------------------------------------
int GLine::FindSelectPoint(CPoint pt) {
	
	int tempThick = (GObject::m_nsThickness > 4 ? GObject::m_nsThickness : 5); // 기본 크기는 5 
	
	CRgn rgn;
	CPoint tempPt = GObject::m_sStartPoint;
	rgn.CreateEllipticRgn(tempPt.x - tempThick, tempPt.y - tempThick, tempPt.x + tempThick, tempPt.y + tempThick); // 리전 생성

	// 시작점이 Rgn 안에 있으며 시작점이 선택
	if(rgn.PtInRegion(pt) == TRUE) {
		return 0;
	}

	tempPt = GObject::m_sEndPoint;
	rgn.DeleteObject();
	rgn.CreateEllipticRgn(tempPt.x - tempThick, tempPt.y - tempThick, tempPt.x + tempThick, tempPt.y + tempThick); // 리전 생성

	// 끝점이 선택된 경우
	if(rgn.PtInRegion(pt) == TRUE) {
		return 4;
	}
	return -1;
}
示例#6
0
文件: MyRect.cpp 项目: xuwenbo/KR_Ph2
BOOL CMyRect::IsSelected(CPoint point)
{
    CRgn rgn;

    rgn.CreateRectRgn(m_ptBegin.x, m_ptBegin.y,
                      m_ptEnd.x, m_ptEnd.y);

    if (rgn.PtInRegion(point))
    {
        return TRUE;
    }

    return FALSE;
}
示例#7
0
// Returns which group (if any) the sent point lies within in this series.
int MyGraphSeries::HitTest(const CPoint& pt, int searchStart = 0) const
{
	VALIDATE;

	for (int nGroup = searchStart; nGroup < m_oaRegions.GetSize(); ++nGroup) {
		CRgn* prgnData = m_oaRegions.GetAt(nGroup);
		ASSERT_NULL_OR_POINTER(prgnData, CRgn);

		if (prgnData  &&  prgnData->PtInRegion(pt)) {
			return nGroup;
		}
	}

	return -1;
}
示例#8
0
int CNaviWnd::MouseTest(int x, int y)
{
	int res=0;
	CRect rect;
	CRgn rgn;
	for(int i=1;i<5;i++)
	{
		rect.SetRect(2+(i-1)*17,2,2+i*17,18);
		rgn.CreateRectRgnIndirect(&rect);
		if(rgn.PtInRegion(x,y))
			res=i;
		rgn.DeleteObject();
	}
	rect.SetRect(180,8,195,18);
	rgn.CreateRectRgnIndirect(&rect);
		if(rgn.PtInRegion(x,y))
			res=5;
	rect.SetRect(178,20,1985,40);
	rgn.DeleteObject();
	rgn.CreateRectRgnIndirect(&rect);
		if(rgn.PtInRegion(x,y))
			res=6;
	return res;
}
示例#9
0
文件: Line.cpp 项目: Hi10086/CR22-2
BOOL CLine::IsSelect(CPoint pt)
{
  CRgn rgn;
  CPoint Points[4];
  Points[0].x = m_ptBegin.x;
  Points[0].y = m_ptBegin.y - 5;
  Points[1].x = m_ptBegin.x;
  Points[1].y = m_ptBegin.y + 5;
  Points[2].x = m_ptEnd.x;
  Points[2].y = m_ptEnd.y + 5;
  Points[3].x = m_ptEnd.x;
  Points[3].y = m_ptEnd.y - 5;

  rgn.CreatePolygonRgn(Points, 4, ALTERNATE);
  
  return rgn.PtInRegion(pt);
}
示例#10
0
long CEllipse::HitTest(long x, long y)
{
	if(m_locked){
			return TK_NONE;
	}
	if(m_lStatus!=ST_NOMAL) return TK_NONE;

	CRect rtTemp;
	POINT pt;
	pt.x=x;
	pt.y=y;

	rtTemp.SetRect(m_lx1-DELTA,m_ly1-DELTA,m_lx1+DELTA,m_ly1+DELTA);
	if(rtTemp.PtInRect(pt)) return TK_LT;

	rtTemp.SetRect(m_lx1-DELTA,m_ly2-DELTA,m_lx1+DELTA,m_ly2+DELTA);
	if(rtTemp.PtInRect(pt)) return TK_LB;
	
	rtTemp.SetRect(m_lx2-DELTA,m_ly1-DELTA,m_lx2+DELTA,m_ly1+DELTA);
	if(rtTemp.PtInRect(pt)) return TK_RT;

	rtTemp.SetRect(m_lx2-DELTA,m_ly2-DELTA,m_lx2+DELTA,m_ly2+DELTA);
	if(rtTemp.PtInRect(pt)) return TK_RB;

	rtTemp.SetRect((m_lx1+m_lx2)/2-DELTA,m_ly1-DELTA,(m_lx1+m_lx2)/2+DELTA,m_ly1+DELTA);
	if(rtTemp.PtInRect(pt)) return TK_TM;

	rtTemp.SetRect((m_lx1+m_lx2)/2-DELTA,m_ly2-DELTA,(m_lx1+m_lx2)/2+DELTA,m_ly2+DELTA);
	if(rtTemp.PtInRect(pt)) return TK_BM;

	rtTemp.SetRect(m_lx1-DELTA,(m_ly1+m_ly2)/2-DELTA,m_lx1+DELTA,(m_ly1+m_ly2)/2+DELTA);
	if(rtTemp.PtInRect(pt)) return TK_LM;

	rtTemp.SetRect(m_lx2-DELTA,(m_ly1+m_ly2)/2-DELTA,m_lx2+DELTA,(m_ly1+m_ly2)/2+DELTA);
	if(rtTemp.PtInRect(pt)) return TK_RM;

	CRgn rgnTmp;
	if(rgnTmp.CreateEllipticRgn(m_lx1,m_ly1,m_lx2,m_ly2)){
		if(rgnTmp.PtInRegion(pt)) return TK_MOV;
	}

	return TK_NONE;
}
示例#11
0
long CLine::HitTest(long x, long y)
{
    if(!m_DnyAttr.m_Linked) return TK_NONE;

    CRect rtTemp;
    POINT pt;
    pt.x=x;
    pt.y=y;

    POINT ptTmp[4];
    if((m_lx1-m_lx2)*(m_ly1-m_ly2)>=0) {
        ptTmp[0].x=m_lx1-DELTA;
        ptTmp[0].y=m_ly1+DELTA;
        ptTmp[1].x=m_lx1+DELTA;
        ptTmp[1].y=m_ly1-DELTA;
        ptTmp[2].x=m_lx2+DELTA;
        ptTmp[2].y=m_ly2-DELTA;
        ptTmp[3].x=m_lx2-DELTA;
        ptTmp[3].y=m_ly2+DELTA;
    } else {
        ptTmp[0].x=m_lx1+DELTA;
        ptTmp[0].y=m_ly1+DELTA;
        ptTmp[1].x=m_lx1-DELTA;
        ptTmp[1].y=m_ly1-DELTA;
        ptTmp[2].x=m_lx2-DELTA;
        ptTmp[2].y=m_ly2-DELTA;
        ptTmp[3].x=m_lx2+DELTA;
        ptTmp[3].y=m_ly2+DELTA;
    }
    CRgn rgnTmp;
    if(rgnTmp.CreatePolygonRgn(ptTmp,4,ALTERNATE)) {
        if(rgnTmp.PtInRegion(pt)) return TK_PUSH;
    }

    return TK_NONE;
}
示例#12
0
long CArc::HitTest(long x, long y)
{
	if(m_locked){
			return TK_NONE;
	}
	if(m_lStatus!=ST_NOMAL) return TK_NONE;

	CRect rtTemp;
	POINT pt;
	pt.x=x;
	pt.y=y;

	rtTemp.SetRect(m_lx1-DELTA,m_ly1-DELTA,m_lx1+DELTA,m_ly1+DELTA);
	if(rtTemp.PtInRect(pt)) return TK_LT;

	rtTemp.SetRect(m_lx1-DELTA,m_ly2-DELTA,m_lx1+DELTA,m_ly2+DELTA);
	if(rtTemp.PtInRect(pt)) return TK_LB;
	
	rtTemp.SetRect(m_lx2-DELTA,m_ly1-DELTA,m_lx2+DELTA,m_ly1+DELTA);
	if(rtTemp.PtInRect(pt)) return TK_RT;

	rtTemp.SetRect(m_lx2-DELTA,m_ly2-DELTA,m_lx2+DELTA,m_ly2+DELTA);
	if(rtTemp.PtInRect(pt)) return TK_RB;

	rtTemp.SetRect((m_lx1+m_lx2)/2-DELTA,m_ly1-DELTA,(m_lx1+m_lx2)/2+DELTA,m_ly1+DELTA);
	if(rtTemp.PtInRect(pt)) return TK_TM;

	rtTemp.SetRect((m_lx1+m_lx2)/2-DELTA,m_ly2-DELTA,(m_lx1+m_lx2)/2+DELTA,m_ly2+DELTA);
	if(rtTemp.PtInRect(pt)) return TK_BM;

	rtTemp.SetRect(m_lx1-DELTA,(m_ly1+m_ly2)/2-DELTA,m_lx1+DELTA,(m_ly1+m_ly2)/2+DELTA);
	if(rtTemp.PtInRect(pt)) return TK_LM;

	rtTemp.SetRect(m_lx2-DELTA,(m_ly1+m_ly2)/2-DELTA,m_lx2+DELTA,(m_ly1+m_ly2)/2+DELTA);
	if(rtTemp.PtInRect(pt)) return TK_RM;

	rtTemp.SetRect(m_lx3-DELTA,m_ly3-DELTA,m_lx3+DELTA,m_ly3+DELTA);
	if(rtTemp.PtInRect(pt)) return TK_SP;
	
	rtTemp.SetRect(m_lx4-DELTA,m_ly4-DELTA,m_lx4+DELTA,m_ly4+DELTA);
	if(rtTemp.PtInRect(pt)) return TK_EP;
	
	long x1,y1,x2,y2;
	if(m_lx1<=m_lx2){
		x1=m_lx1;
		x2=m_lx2;
	}else{
		x1=m_lx2;
		x2=m_lx1;
	}
	if(m_ly1<m_ly2){
		y1=m_ly1;
		y2=m_ly2;
	}else{
		y1=m_ly2;
		y2=m_ly1;
	}
	CRgn rgnTmp;
    if(rgnTmp.CreateEllipticRgn(x1-DELTA,y1-DELTA,x2+DELTA,y2+DELTA)){
	    if(!rgnTmp.PtInRegion(pt)) return TK_NONE;
	    x1=x1+DELTA;
	    y1=y1+DELTA;
	    x2=x2-DELTA;
	    y2=y2-DELTA;
	    if(x1<x2 && y1<y2){
		    CRgn rgnTmp;
            if(rgnTmp.CreateEllipticRgn(x1,y1,x2,y2)){
		        if(rgnTmp.PtInRegion(pt)) return TK_NONE;
            }else{
                return TK_NONE;
            }
	    }
	    double dx=(double)x-((double)m_lx1+(double)m_lx2)/2;
	    double dy=-(double)y+((double)m_ly1+(double)m_ly2)/2;
	    double dxs=(double)m_lx3-((double)m_lx1+(double)m_lx2)/2;
	    double dys=-(double)m_ly3+((double)m_ly1+(double)m_ly2)/2;
	    double dxe=(double)m_lx4-((double)m_lx1+(double)m_lx2)/2;
	    double dye=-(double)m_ly4+((double)m_ly1+(double)m_ly2)/2;
	    double sa=GetAngle(dxs,dys);
	    double ea=GetAngle(dxe,dye);
	    double pa=GetAngle(dx,dy);

	    if(SPE(sa,pa,ea)) return TK_MOV;
    }
	return TK_NONE;
}
示例#13
0
	BOOL		HitTest(CPoint pt)			{ return m_rgn.PtInRegion(pt); }
示例#14
0
void CSpiroView::OnLButtonDown(UINT nFlags, CPoint point) 
{
	if (m_bDrawingActive)
		return;

	if (m_bDroppingAnchor || m_bDroppingWheel)
	{
		ASSERT(!m_bDrawingDone);
		CWheel* pWheelDrop = NULL;
		CRing*	pRingDrop = NULL;
		CSpiroDoc* pDoc = GetDocument();
		ENSURE(pDoc != NULL);

		//convert the client coordinates to logical coordinates
		CDC* pDC = GetDC();
		ENSURE(pDC != NULL);
		OnPrepareDC(pDC);

		// Convert client coordinates to Logical coordinates
		CPoint pointScaled(point);
		pDC->DPtoLP(&pointScaled);
		point.x = pointScaled.x * m_nZoomDenom / m_nZoomNumer;  // undo scaling effects
		point.y = pointScaled.y * m_nZoomDenom / m_nZoomNumer;

		CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd();
		ENSURE(pFrame != NULL && pFrame->IsKindOf(RUNTIME_CLASS(CMainFrame)));

		if (m_bDroppingAnchor)
		{
			ASSERT(m_iPieceDropped >= 0 && m_iPieceDropped < TOTALRINGS);
			pRingDrop = new CRing(CRing::m_rgnRads[m_iPieceDropped] - RINGWIDTH,
				CRing::m_rgnRads[m_iPieceDropped],
				CRing::m_rgco[m_iPieceDropped], RGB(0, 0, 0));

			ENSURE(pRingDrop != NULL);  
			m_bDroppingAnchor = false;
			ENSURE(m_pAnchor == NULL);
			m_pAnchor = pRingDrop;
			m_pAnchor->SetPosition(point);
			m_dDataAnchorFirst = m_pAnchor->GetFigData();
		}
		else if (m_bDroppingWheel)
		{
			CBasePiece** ppPiece = (m_pAnchor == NULL? &m_pAnchor : &m_pWheel);
			ASSERT(m_iPieceDropped >= 0 && m_iPieceDropped < TOTALWHEELS);
			pWheelDrop = new CWheel(CWheel::m_rgnRads[m_iPieceDropped],
								CWheel::m_rgco[m_iPieceDropped],
								CWheel::m_rgcoPattern[m_iPieceDropped]);
								

			ENSURE(pWheelDrop != NULL);
			ENSURE(*ppPiece == NULL);
			*ppPiece = pWheelDrop;
			m_bDroppingWheel = false;
			(*ppPiece)->SetPosition(point);

			if (m_pWheel != NULL)
			{
				m_pWheel->SetWheelMode();

				// set the default pen location. pDC and zoom ration are dummies
				m_pWheel->SetPenLocation(this, pDC, CPoint(0, 0), 1, 1);

				ENSURE(m_pAnchor != NULL);

				CPoint ptContact;
				double dAngle;
				// Get contact position from the anchor and set wheel position
				// Decides if wheel is internal in case of being a ring
				m_pAnchor->GetContactPosition(pointScaled, m_nZoomNumer, 
										m_nZoomDenom, ptContact, dAngle);
			
				if (m_pWheel->GetPerimeter() >= m_pAnchor->GetPerimeter())
				{
					pointScaled.x = 0;
					pointScaled.y = 0;   // force the wheel out of the ring

					// get contact position again to make sure it's right
					m_pAnchor->GetContactPosition(pointScaled, m_nZoomNumer, 
											m_nZoomDenom, ptContact, dAngle);
				}

 				m_pWheel->SetPosition(ptContact, dAngle);
				m_dDataWheelFirst = m_pWheel->GetFigData();
				m_ptWheelPosFirst = m_pWheel->m_ptPos;
				PressButton(0);  // get the color settings for the new wheel
				CreateFigure();
			}

			m_iPieceDropped += TOTALRINGS + 1;
#ifdef _DEBUG
			int nID = pFrame->m_wndToolBarSpiro.GetItemID(m_iPieceDropped);
			ASSERT(nID >= ID_ENORMOUSWHEEL && nID <= ID_TINYWHEEL);
#endif
		}

		// uncheck the button used to select the piece in the toolbar
		UINT nButtonID = pFrame->m_wndToolBarSpiro.GetItemID(m_iPieceDropped);
		pFrame->m_wndToolBarSpiro.GetToolBarCtrl().CheckButton(nButtonID, FALSE);

		// invalidate the region holding the ring
		CRgn	rgn;  // region occupied by the piece
		(m_pWheel != NULL? m_pWheel : m_pAnchor)->GetDevPieceRgn(pDC,
									&rgn, m_nZoomNumer, m_nZoomDenom, false);

		InvalidateRgn(&rgn, FALSE);
		m_iPieceDropped = -1; // reset to keep control on values.
		ReleaseDC(pDC);
		return;
	}

	// check if the user wants to drag the pen position

	CDC* pDC = GetDC();
	ENSURE(pDC != NULL);
	OnPrepareDC(pDC);
	CPoint pointScaled(point);
	pDC->DPtoLP(&pointScaled);   // gets the logical coord point value with scale into account

	if (m_pWheel != NULL)
	{
		if (m_pWheel->HitTest(pDC, point, m_nZoomNumer, m_nZoomDenom) == HIT_PEN_LOCATION)  // start drag operation
		{
			MSG		msg;

			// if there is a WM_LBUTTONUP in the queue do not drag pencil location
			if (!::PeekMessage(&msg, m_hWnd, WM_LBUTTONUP, WM_LBUTTONUP, PM_NOREMOVE))
			{
				ClientToScreen(&point); // convert to screen coordinates
				CRect rectWindow;
				GetWindowRect(&rectWindow);
				point.x -= rectWindow.left;
				point.y -= rectWindow.top;  // point relative to windows corner

				CImageList& il = GetApp()->m_imageList;
				::ShowCursor(FALSE);
				il.BeginDrag(0, CPoint(0, 47));
				il.DragEnter(this, point);
				m_bMovingPencil = true;
				SetCapture();
			}
		}
	}

	for (;;) 
	{
		CRgn	rgn;
		MSG		msg;

		if (::PeekMessage(&msg, m_hWnd, WM_LBUTTONUP, WM_LBUTTONUP, PM_NOREMOVE))  // no drag is being requested
			break;

		if (m_pWheel != NULL)
		{
			m_pWheel->GetLogPieceRgn(&rgn, m_nZoomNumer, m_nZoomDenom);
			if (rgn.PtInRegion(pointScaled))  // clicked on wheel.  Don't do anything
				break;

			rgn.DeleteObject();
		}

		if (m_pAnchor != NULL)
		{
			m_pAnchor->GetLogPieceRgn(&rgn, m_nZoomNumer, m_nZoomDenom);
			if (rgn.PtInRegion(pointScaled))   // clicked on the anchor
				break;

			rgn.DeleteObject();
		}

		// find now if the user clicked on a Figure.  The current Figure cannot be dragged.  This is by design
		CSpiroDoc*	pDoc = GetDocument();
		INT_PTR		iPic;
		CFigure*	pFigure;
		CSpiroRect	rect;

		for (iPic = pDoc->m_arrPFigures.GetUpperBound(); iPic >= 0; iPic--)
		{
			pFigure = (CFigure*)pDoc->m_arrPFigures.GetAt(iPic);
			ENSURE(pFigure != NULL);
			pFigure->GetBoundingRect(&rect);
			rect.Scale(m_nZoomNumer, m_nZoomDenom);
			if (pointScaled.x < rect.left || pointScaled.x >= rect.right ||
					pointScaled.y > rect.top || pointScaled.y <= rect.bottom)
			{
				continue;
			}

			bool bCopy = (nFlags & MK_CONTROL) == MK_CONTROL;
			m_pFigureDrag = (bCopy? new CFigure(pFigure) : pFigure);

			if (!bCopy)
				pDoc->m_arrPFigures.RemoveAt(iPic);

			ENSURE(m_pILDragFigure == NULL);

			// First draw the Figure into a memery DC using an allocated bitmap
			CDC	dcMem;
			ENSURE(pDC != NULL);

			VERIFY(dcMem.CreateCompatibleDC(pDC));
			dcMem.SetMapMode(MM_SPIRO);
			dcMem.SetViewportOrg(0, 0);
			dcMem.SetWindowOrg(rect.left, rect.top);

			CSpiroRect	rectBitmap(rect);
			dcMem.LPtoDP(&rectBitmap);
			ASSERT(rectBitmap.left == 0 && rectBitmap.top == 0);

			int			nWidth = rectBitmap.right;
			int			nHeight = rectBitmap.bottom;

			CBitmap*	pbmOld = NULL;
			
			ASSERT(m_pBitmapDragFigure == NULL);
			m_pBitmapDragFigure = new CBitmap();
			m_pBitmapDragFigure->CreateCompatibleBitmap(pDC, nWidth, nHeight);
			pbmOld = dcMem.SelectObject(m_pBitmapDragFigure);

		//	dcMem.PatBlt(rect.left, rect.top, rect.Width(), rect.Height(), WHITENESS);
			CBrush	brush;
			brush.CreateStockObject(WHITE_BRUSH);
			dcMem.FillRect(&rect, &brush);
			m_pFigureDrag->Draw(&dcMem, m_nZoomNumer, m_nZoomDenom, NULL, &rect);
			dcMem.SelectObject(pbmOld);
			// Then create an imagelist and add the bitmap to it
			ASSERT(m_pILDragFigure == NULL);
			m_pILDragFigure = new CImageList();				
			VERIFY(m_pILDragFigure->Create(nWidth, nHeight, ILC_COLOR | ILC_MASK, 1, 1));
			VERIFY(m_pILDragFigure->Add(m_pBitmapDragFigure, RGB(255, 255, 255)) == 0);

			m_bStartDrag = true;  // Enter the drag on first mouse move

			//calculate the hot spot for the figure
			m_ptHotSpotDragFigure.x = pointScaled.x - rect.left;
			m_ptHotSpotDragFigure.y = pointScaled.y - rect.bottom;
			pDC->SetWindowOrg(0, rect.top - rect.bottom);
			pDC->SetViewportOrg(0, 0);
			pDC->LPtoDP(&m_ptHotSpotDragFigure);
			m_pILDragFigure->BeginDrag(0, m_ptHotSpotDragFigure);
			SetCapture();
			break;
		}

		break;
	}

	ReleaseDC(pDC);
	CScrollView::OnLButtonDown(nFlags, point);
}
示例#15
0
void MonitorManager::OnLButtonDown(UINT nFlags, CPoint point,CWnd* pRulerWnd)
{
	//m_pWndParent->SetCapture();
	CMonitorControler* current=NULL;
	CRgn *rgn;
	bool found=false,inselected=false;
	for(UINT i=0;(i<m_aMonitorsControler.size()) && (!found); ++i)
	{
		rgn=m_aMonitorsControler[i]->GetMyViewClientRgn();
		if(rgn->PtInRegion(point))
		{
			current = m_aMonitorsControler[i];
			m_pCurrentControler=current;
			m_bLButtonDown=true;
			m_ePos=RotateRect::POS_RECT;
			m_PointRectPrev=point;
			found=true;
		}
		else
		{
			rgn=m_aMonitorsControler[i]->GetMyViewHandleRgn();
			for(UINT j=0;(j<4) && (!found);++j)
			{
				if(rgn[j].PtInRegion(point))
				{
					current = m_aMonitorsControler[i];
					m_pCurrentControler=current;
					m_bLButtonDown=true;
					m_ePos=RotateRect::POS_HANDLE;
					m_PointHandlePrev=point;
					found=true;
				}
			}
		}
	}

	if(current != NULL)
	{
		std::vector<CMonitorControler*>::iterator it,pos;
		for(it= m_aSelectedControler.begin();it != m_aSelectedControler.end();++it)
		{
			if(current == *it)
			{
				inselected=true;
				pos=it;
			}
		}
		bool bCtrlDown=(GetKeyState(VK_CONTROL)<0)?true:false;
		if(bCtrlDown)
		{
			if(inselected)
			{
				current->SetActive(false);
				m_aSelectedControler.erase(pos);
			}
			else
			{
				current->SetActive(true);
				m_aSelectedControler.push_back(current);
			}
		}
		else
		{
			if(!inselected)
			{
				for(UINT i=0;i<m_aSelectedControler.size();++i)
				{
					m_aSelectedControler[i]->SetActive(false);
				}
				m_aSelectedControler.clear();
				current->SetActive(true);
				m_aSelectedControler.push_back(current);
			}	
		}
		((CRulerCtlWnd*)pRulerWnd)->DrawRulerCursor(current->GetMyViewCenter()->x+CRulerCtlWnd::VERTICAL_RULER_RIGHT,
			current->GetMyViewCenter()->y+CRulerCtlWnd::HORIZON_RULER_BOTTOM);
		SetMonitorText(current->GetMyMonitorInfo());
	}
	else
	{
		for(UINT i=0;i<m_aSelectedControler.size();++i)
		{
			m_aSelectedControler[i]->SetActive(false);
		}
		m_aSelectedControler.clear();
		SetMonitorText(_T("N/A"));
	}
}
示例#16
0
void CPredView::OnMouseMove(UINT nFlags, CPoint point)
{
	// TODO: Add your message handler code here and/or call default

	CScrollView::OnMouseMove(nFlags, point);
	int i;
	CClientDC dc(this);
	OnPrepareDC(&dc);
	POINT m_point;
	CFCCDoc* pDoc=(CFCCDoc*)GetDocument();
	m_point.x=point.x;
	m_point.y=point.y;
	dc.DPtoLP(&m_point);
	CRgn rgn;
	bHitCaption=false;
	for(i=0;i<nCol;i++)
	{
		
		if(wnd_navi.nCurPage<wnd_navi.nTotalPage || (wnd_navi.nCurPage-1)*nCol+i+1 <= (pDoc->list_CompoundTest.GetCount()-1)/nItemPage+1)
		{
			
			CPoint topleft(60+i*(80+widthCompoundName+widthYhat+widthClassName+widthID),30);
			CPoint bottomright(60+i*(80+widthCompoundName+widthYhat+widthClassName+widthID)+widthID,50);
			rgn.CreateRectRgn(topleft.x,topleft.y,bottomright.x,bottomright.y);
			if(rgn.PtInRegion(m_point))
			{
				//pDoc->MergeSort(SORT_BY_ID,SortAscend,pDoc->list_CompoundTest);
				bHitCaption=true;
			}
			rgn.DeleteObject();
			topleft.SetPoint(60+i*(80+widthCompoundName+widthYhat+widthClassName+widthID)+widthID+10,30);
			bottomright.SetPoint(60+i*(80+widthCompoundName+widthYhat+widthClassName+widthID)+widthID+widthCompoundName+10,50);
			rgn.CreateRectRgn(topleft.x,topleft.y,bottomright.x,bottomright.y);
			if(rgn.PtInRegion(m_point))
			{
				//pDoc->MergeSort(SORT_BY_NAME,SortAscend,pDoc->list_CompoundTest);
				bHitCaption=true;
			}
			rgn.DeleteObject();
			topleft.SetPoint(60+i*(80+widthCompoundName+widthYhat+widthClassName+widthID)+widthID+widthCompoundName+20,30);
			bottomright.SetPoint(60+i*(80+widthCompoundName+widthYhat+widthClassName+widthID)+widthID+widthCompoundName+widthClassName+widthYhat+30,50);
			rgn.CreateRectRgn(topleft.x,topleft.y,bottomright.x,bottomright.y);
			if(rgn.PtInRegion(m_point))
			{
				//pDoc->MergeSort(SORT_BY_VALUE,SortAscend,pDoc->list_CompoundTest);
				bHitCaption=true;
			}
			rgn.DeleteObject();
		}
	}
	if(bHitCaption)
	{
		if(bOldMouseInCaption==false && pDoc->list_CompoundTest.GetCount()>0)
		{
			if(SortAscend)
				::SetCursor(cursorAscend);
			else
				::SetCursor(cursorDescend);
			bOldMouseInCaption=true;
			//TRACE("hit caption change cursor\n");
		}
	}
	else
	{
		//if(bOldMouseInCaption==true)
		{
			::SetCursor(::LoadCursor(NULL,IDC_ARROW));
			bOldMouseInCaption=false;
			//TRACE("not hit caption change cursor\n");
		}
		
	}

	// TODO: Add your message handler code here
}
示例#17
0
void CPredView::OnLButtonDown(UINT nFlags, CPoint point)
{
	// TODO: Add your message handler code here and/or call default
	/*HCURSOR hCursor=AfxGetApp()->LoadCursorA(IDC_DESCEND);
	if(hCursor==NULL)
		TRACE("Invaidate cursor\n");
	SetCursor(hCursor);*/
	TRACE("%d\n",nFlags);
	CClientDC dc(this);
	OnPrepareDC(&dc);
	POINT m_point;
	CFCCDoc* pDoc=(CFCCDoc*)GetDocument();
	m_point.x=point.x;
	m_point.y=point.y;
	dc.DPtoLP(&m_point);
	CRgn rgn;
	int i,j;
	int selCol=-1;
	int selRow=-1;
	for(i=0;i<nCol;i++)
	{
		bool bHitCaption=false;
		if(wnd_navi.nCurPage<wnd_navi.nTotalPage || (wnd_navi.nCurPage-1)*nCol+i+1 <= (pDoc->list_CompoundTest.GetCount()-1)/nItemPage+1)
		{
			
			CPoint topleft(60+i*(80+widthCompoundName+widthYhat+widthClassName+widthID),30);
			CPoint bottomright(60+i*(80+widthCompoundName+widthYhat+widthClassName+widthID)+widthID,50);
			rgn.CreateRectRgn(topleft.x,topleft.y,bottomright.x,bottomright.y);
			if(rgn.PtInRegion(m_point))
			{
				pDoc->MergeSort(SORT_BY_ID,SortAscend,pDoc->list_CompoundTest);
				bHitCaption=true;
			}
			rgn.DeleteObject();
			topleft.SetPoint(60+i*(80+widthCompoundName+widthYhat+widthClassName+widthID)+widthID+10,30);
			bottomright.SetPoint(60+i*(80+widthCompoundName+widthYhat+widthClassName+widthID)+widthID+widthCompoundName+10,50);
			rgn.CreateRectRgn(topleft.x,topleft.y,bottomright.x,bottomright.y);
			if(rgn.PtInRegion(m_point))
			{
				pDoc->MergeSort(SORT_BY_NAME,SortAscend,pDoc->list_CompoundTest);
				bHitCaption=true;
			}
			rgn.DeleteObject();
			topleft.SetPoint(60+i*(80+widthCompoundName+widthYhat+widthClassName+widthID)+widthID+widthCompoundName+20,30);
			bottomright.SetPoint(60+i*(80+widthCompoundName+widthYhat+widthClassName+widthID)+widthID+widthCompoundName+widthClassName+widthYhat+30,50);
			rgn.CreateRectRgn(topleft.x,topleft.y,bottomright.x,bottomright.y);
			if(rgn.PtInRegion(m_point))
			{
				pDoc->MergeSort(SORT_BY_VALUE,SortAscend,pDoc->list_CompoundTest);
				bHitCaption=true;
			}
			rgn.DeleteObject();
		}
		if(bHitCaption)
		{
			TRACE("LButton down caption\n");
			Invalidate();
			UpdateWindow();
			SortAscend=1-SortAscend;
			if(SortAscend)
				::SetCursor(cursorAscend);
			else
				::SetCursor(cursorDescend);
			bOldMouseInCaption=true;
			
		}
		for(j=0;j<nItemPage;j++)
		{
			rgn.CreateRectRgn(50+i*(80+widthCompoundName+widthYhat+widthClassName+widthID),50+20*j,
				20+(i+1)*(80+widthCompoundName+widthYhat+widthClassName+widthID),50+20*(j+1));
			if(rgn.PtInRegion(m_point))
			{
				selCol=i;
				selRow=j;
			}
			rgn.DeleteObject();
		}
	}
	if(selCol>=0 && selRow>=0)
	{
		dlg.nIndex=(wnd_navi.nCurPage-1)*(nCol*nItemPage)+selCol*nItemPage+selRow+1;
		if(nFlags&MK_CONTROL)
			SendMessage(WM_FINDCOMPOUND,GOTOLINE,2);
		else
			SendMessage(WM_FINDCOMPOUND,GOTOLINE,1);
	}
	else
	{
		if(nFlags!=MK_CONTROL)
		{
			POSITION pos;
			pos=pDoc->list_CompoundTest.GetHeadPosition();
			while(pos)
			{
				pCompound=(CCompound*)pDoc->list_CompoundTest.GetNext(pos);
				((CCompound*)pCompound)->bSelect=false;
			}
		}
		Invalidate(0);
	}
	CScrollView::OnLButtonDown(nFlags, point);
}
示例#18
0
void
UVMapView::End()
{
    active = false;

    // get the model:
    if (!nmarks || !material || !material->tex_diffuse) return;

    // if not adding to selection:
    if (select_mode == SELECT_REPLACE) {
        Clear();
    }

    Bitmap*  bmp = material->tex_diffuse;
    int      w   = bmp->Width();
    int      h   = bmp->Height();

    double   cx  = window->Width()  / 2 + x_offset;
    double   cy  = window->Height() / 2 + y_offset;


    // if only one mark:
    if (nmarks < 2) {
        // find all selected verts:
        ListIter<Poly> iter = polys;
        while (++iter) {
            Poly*       p     = iter.value();
            VertexSet*  vset  = p->vertex_set;

            for (int i = 0; i < p->nverts; i++) {
                int    n1   = p->verts[i];
                double tu1  = vset->tu[n1];
                double tv1  = vset->tv[n1];

                int x1 = (int) (cx + zoom * w * (tu1-0.5));
                int y1 = (int) (cy + zoom * h * (tv1-0.5));

                int dx = abs(marks[0].x - x1);
                int dy = abs(marks[0].y - y1);

                if (dx < 4 && dy < 4) {
                    WORD  p_index = iter.index();
                    DWORD value   = (p_index << 16) | i;

                    if (select_mode == SELECT_REMOVE) {
                        for (auto svi = selverts.begin(); svi != selverts.end(); ++svi) {
                            if (*svi == value) {
                                selverts.erase(svi);
                            }
                        }
                    }
                    else {
                        bool contains = false;
                        for (auto svi = selverts.begin(); svi != selverts.end(); ++svi) {
                            if (*svi == value) {
                                contains = true;
                            }
                        }
                        if (!contains)
                            selverts.push_back(value);
                    }
                }
            }
        }
    }

    // otherwise, build a region:
    else {
        CRgn rgn;
        rgn.CreatePolygonRgn(marks, nmarks, WINDING);

        // find all selected verts:
        ListIter<Poly> iter = polys;
        while (++iter) {
            Poly*       p     = iter.value();
            VertexSet*  vset  = p->vertex_set;

            for (int i = 0; i < p->nverts; i++) {
                int    n1   = p->verts[i];
                double tu1  = vset->tu[n1];
                double tv1  = vset->tv[n1];

                int x1 = (int) (cx + zoom * w * (tu1-0.5));
                int y1 = (int) (cy + zoom * h * (tv1-0.5));

                CPoint p(x1,y1);

                if (rgn.PtInRegion(p)) {
                    WORD  p_index = iter.index();
                    DWORD value   = (p_index << 16) | i;

                    if (select_mode == SELECT_REMOVE) {
                        for (auto svi = selverts.begin(); svi != selverts.end(); ++svi) {
                            if (*svi == value)
                                selverts.erase(svi);
                        }
                    }
                    else {
                        bool contains = false;
                        for (auto svi = selverts.begin(); svi != selverts.end(); ++svi) {
                            if (*svi == value)
                                contains = true;
                        }
                        if (!contains)
                            selverts.push_back(value);
                    }
                }
            }
        }
    }

    nmarks = 0;
}