示例#1
0
/*
*--------------------------------------------------------------------------------
*  成员函数名   :OnMouseMove
*  功能描述     :当鼠标在窗体移动消息
*  输入参数描述	:
*    UINT nType :  按键类型
*    CPoint point :当前鼠标坐标点的位置
*  返回变量说明 :
*  算法描述		:以矩形区中心点坐标为基点进行旋转
*  附加说明     :主要用于任意角度旋转图形时,得到旋转的角度
*--------------------------------------------------------------------------------
*/
void CFloatDibWnd::OnMouseMove(UINT nFlags, CPoint point) 
{
    //画一虚线框,当旋转图片时先只旋转这个框,当MouseUp时才正式旋转图形

	HDC hDC = ::GetDC(m_hParentWnd);
	switch (m_ChangeType)
	{
	case CT_ROTATE:
		{	    	
		double dblAngle;
		dblAngle = GetRotateAngle(PointToParentClient(m_ptLast));
		DrawRotateBorder(dblAngle);

		dblAngle = GetRotateAngle(PointToParentClient(point));
        DrawRotateBorder(dblAngle);
		SetCursor(AfxGetApp()->LoadCursor(IDC_CURROTATE));	
		
		break;
		}

	case CT_MOVE:
		break;

	case CT_RESIZE:
		// 调整大小	
		{
			CRect rcBorder = RectToParentClient(m_ptLast);
			DrawResizeBorder(rcBorder);				

			rcBorder = RectToParentClient(point);
			DrawResizeBorder(rcBorder);

			break;
		}

	default:
		break;
	}

	m_ptLast = point;
	CWnd::OnMouseMove(nFlags, point);
}
示例#2
0
/*
*--------------------------------------------------------------------------------
*  成员函数名   :OnLButtonUp
*  功能描述     :鼠标左键按起时的消息
*  输入参数描述	:
*    UINT nType:按键类型
*    CPoint point :当前鼠标坐标点的位置
*  返回变量说明 :
*  算法描述		:
*  附加说明     :用于取消左键按下的标志,并计算出要旋转的角度,画出旋转后的位图
*--------------------------------------------------------------------------------
*/
void CFloatDibWnd::OnLButtonUp(UINT nFlags, CPoint point) 
{       
	//结束形变操作
//	SetCursor(LoadCursor(NULL, IDC_ARROW));
	SetCursor(AfxGetApp()->LoadCursor(IDC_ARROW));
	switch (m_ChangeType)
	{
	case CT_ROTATE:
		{
		// 旋转窗口内的图像以原始图像为操作对象,此次旋转要加上最后的旋转角度
		double dblAngle = GetRotateAngle(PointToParentClient(point));

		// 旋转
		RotateAngle(dblAngle);

		UpdateWindow();
		break;
		}

	case CT_RESIZE:
		{
		// 缩放图像时实际上只是改变窗口大小,并不改变图像的实际尺寸
		// 改变图像及窗口大小
		CRect rect = RectToParentClient(point);
		::MoveWindow(GetSafeHwnd(), rect.left, rect.top, rect.Width(), rect.Height(), TRUE);
		break;
		}
	
	default:
		return;
	}
	m_ChangeType = CT_MOVE;

	::SendMessage(m_hParentWnd, WM_PAINT, 0, 0);
	InvalidateRect(NULL, TRUE);

	ReleaseCapture();

//	CWnd::OnLButtonUp(nFlags, point);
}
void VisitorLandsideBehavior::setDestination( const ARCVector3& p ,MobDir emWalk )
{
	//destination is equal to current location
	ASSERT(m_pPerson->getType().GetTypeIndex() != 0);
	
	//carrion that defines relative position should use own relative position
	PaxOnboardBaseBehavior* spCarrionBehavior = m_pPerson->getOnboardBehavior();
	//ASSERT(spCarrionBehavior);
	if (!m_pPerson->m_pGroupInfo->IsFollower())
	{
		PaxVisitor* pVisitor = (PaxVisitor*)m_pPerson;
		Passenger* pOwner = pVisitor->GetOwner();
		if (pOwner && pOwner->GetVisitorItemByType(pVisitor->getType().GetTypeIndex()))//does not separate with passenger
		{
			CGroupLeaderInfo* pGroupLeader = (CGroupLeaderInfo*)(m_pPerson->m_pGroupInfo);
			if (pGroupLeader->isInGroup())//separate with group
			{
				LandsideBaseBehavior* spOwnerBehavior = pOwner->getLandsideBehavior();
				ASSERT(spOwnerBehavior);
				ARCVector3 _OwnerPreLocation = spOwnerBehavior->location;
				ARCVector3 OwnerLocation = spOwnerBehavior->m_ptDestination;

				if (_OwnerPreLocation == OwnerLocation && spOwnerBehavior->getState() != EntryLandside)//can not calculate direction of passenger and current location
				{
					m_ptDestination = p;
					SetFollowerDestination(location,m_ptDestination,Person::m_pRotation);
					return;
				}

				ARCVector3 paxDirection(_OwnerPreLocation, OwnerLocation);
				ARCVector3 paxLogPoint = _OwnerPreLocation;

				Point ptDir(paxDirection[VX],paxDirection[VY],paxDirection[VZ]);
				Point ptCenter(paxLogPoint.n[VX],paxLogPoint.n[VY],paxLogPoint.n[VZ]);

				CNonPaxRelativePosSpec* pNonPaxRelPosSpec = pVisitor->GetTerminal()->GetNonPaxRelativePosSpec();
				ASSERT(pNonPaxRelPosSpec);
				CPoint2008 ptRelatePos;
				ARCVector4 rotation;
				bool bRes = pNonPaxRelPosSpec->GetNonPaxRelatePosition(ptRelatePos, rotation, pVisitor->getType().GetTypeIndex());
				if (bRes)
				{
					Point vectorLat( ptRelatePos.getX(),ptRelatePos.getY(), 0.0);
					double dAngle = GetRotateAngle(emWalk);
					Point dir(paxDirection.n[VX],paxDirection.n[VY],paxDirection.n[VZ]);
					Point ptRotate(paxLogPoint.n[VX],paxLogPoint.n[VY],paxLogPoint.n[VZ]);
					dir.rotate(dAngle);
					dir.Normalize();
					vectorLat.rotate(dir, ptRotate);
					ARCVector3 vectorPt;
					vectorPt.n[VX] = vectorLat.getX();
					vectorPt.n[VY] = vectorLat.getY();
					vectorPt.n[VZ] = paxLogPoint.n[VZ];
					setLocation(vectorPt);

					SetRelativePosition(ptDir,ptCenter,emWalk);
					return;
				}
			}	
		}
		m_ptDestination = p;
		SetFollowerDestination(location,m_ptDestination,Person::m_pRotation);
	}

	//separate with passenger or not in group
	m_ptDestination = p;
	
}
void VisitorLandsideBehavior::writeCurrentLogItem(PaxLandsideBehavior* pOwnerPax,Point _OwnerPreLocation, theVisitorLogNum logNum/* = secondLog*/,MobDir emWalk/* = FORWARD*/)
{
	ASSERT(firstLog == logNum || secondLog == logNum);

	if (pOwnerPax == NULL)
		return;

	Point OwnerLocation;
	OwnerLocation.init(pOwnerPax->getPoint().n[VX],pOwnerPax->getPoint().n[VY],pOwnerPax->getPoint().n[VZ]); 

	if( _OwnerPreLocation == OwnerLocation )return;



	// use vector(_OwnerPreLocation -> OwnerLocation) as passenger direction
	Point paxDirection(_OwnerPreLocation, OwnerLocation);
	Point paxLogPoint = (firstLog == logNum)?_OwnerPreLocation:OwnerLocation;

	CNonPaxRelativePosSpec* pNonPaxRelPosSpec = m_pPerson->GetTerminal()->GetNonPaxRelativePosSpec();
	ASSERT( NULL != pNonPaxRelPosSpec );
	CPoint2008 ptRelatePos;
	ARCVector4 rotation;
	bool bRes = pNonPaxRelPosSpec->GetNonPaxRelatePosition(ptRelatePos, rotation, m_pPerson->getType().GetTypeIndex());
	if (bRes)
	{
		Point vectorLat( ptRelatePos.getX(),ptRelatePos.getY(), 0.0);
		double dAngle = GetRotateAngle(emWalk);
		Point dir(paxDirection);
		dir.rotate(dAngle);
		dir.Normalize();
		vectorLat.rotate(dir, paxLogPoint);

		//	location = vectorLat;
		ARCVector3 vectorPt;
		vectorPt.n[VX] = vectorLat.getX();
		vectorPt.n[VY] = vectorLat.getY();
		vectorPt.n[VZ] = paxLogPoint.getZ();
		setLocation(vectorPt);
		SetRelativePosition(paxDirection,paxLogPoint,emWalk);
	}
	else
	{
		switch( m_pPerson->getType().GetTypeIndex() )
		{
		case 1:	//visitor  // left
			{
				Point vectorLat( paxDirection.perpendicular() );
				vectorLat.length(100.0);
				setLocation(paxLogPoint + vectorLat);
				setDestination(getPoint());
				break;
			}
		case 2:	//checked bag	//front
			{
				paxDirection.length(25.0);//( 150.0 );
				setDestination(paxLogPoint + paxDirection);
				setLocation(paxLogPoint + paxDirection);
				break;
			}
		case 3:	//hand bag	// left
			{
				Point vectorLat( paxDirection.perpendicular() );
				vectorLat.length(20.0);
				setLocation(paxLogPoint + vectorLat);
				setDestination(paxLogPoint + vectorLat);
				break;
			}
		case 4:	//carte		// front
			{
				paxDirection.length( 100.0 );
				setDestination(paxLogPoint + paxDirection);
				setLocation(paxLogPoint + paxDirection);
				break;
			}
		case 6: //dog		//right_front
			{
				Point vectorLat( paxDirection.perpendicular() );
				vectorLat.length(-100.0);
				setDestination(paxLogPoint + vectorLat);
				paxDirection.length( 100.0 );
				setDestination(paxDirection + getDest());
				setLocation(getDest());
				break;
			}
		default: //other visitor
			{
				paxDirection.length(25.0);//( 150.0 );
				setDestination(paxLogPoint + paxDirection);
				setLocation(getDest());
				break;
			}
		}	
		SetFollowerDestination( getPoint(), getDest(), Person::m_pRotation );
	}

}