//-----------------------------------------------------------------------------
// Purpose: Handles left mouse button down events in the 2D view.
// Input  : Per CWnd::OnLButtonDown.
// Output : Returns true if the message was handled, false if not.
//-----------------------------------------------------------------------------
bool Cordon3D::OnLMouseDown2D(CMapView2D *pView, UINT nFlags, const Vector2D &vPoint)
{
	Tool3D::OnLMouseDown2D(pView, nFlags, vPoint);

	Vector vecWorld;
	pView->ClientToWorld(vecWorld, vPoint);

	unsigned int uConstraints = GetConstraints( nFlags );

	if ( HitTest(pView, vPoint, true) )
	{
		StartTranslation( pView, vPoint, m_LastHitTestHandle );
	}
	else
	{
		// getvisiblepoint fills in any coord that's still set to COORD_NOTINIT:
		vecWorld[pView->axThird] = COORD_NOTINIT;
		m_pDocument->GetBestVisiblePoint(vecWorld);

		// snap starting position to grid
		if ( uConstraints & constrainSnap )
			m_pDocument->Snap(vecWorld,uConstraints);
		
		StartNew( pView, vPoint, vecWorld, Vector(0,0,0) );
	}

	return true;
}
Esempio n. 2
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : *vecStart - 
//			*mins - 
//			*maxs - 
//-----------------------------------------------------------------------------
void Box3D::StartNew( CMapView *pView, const Vector2D &vPoint, const Vector &vecStart, const Vector &vecSize )
{
	//Setup our info
	m_TranslateMode	= modeScale;
	m_TranslateHandle = Vector( 1, 1, 1 );
	bmins = vecStart;
	bmaxs = vecStart+vecSize;
	NormalizeBox( bmins, bmaxs );

	StartTranslation( pView, vPoint, Vector( 1, 1, 1 )  );

	m_bPreventOverlap = false;
	m_bEmpty = false;
}
//-----------------------------------------------------------------------------
// Purpose: Handles left mouse button down events in the 2D view.
// Input  : Per CWnd::OnLButtonDown.
// Output : Returns true if the message was handled, false if not.
//-----------------------------------------------------------------------------
bool Clipper3D::OnLMouseDown2D(CMapView2D *pView, UINT nFlags, CPoint point)
{
	CMapDoc *pDoc = pView->GetDocument();
	CMapWorld *pWorld = pDoc->GetMapWorld();

	m_ptLDownClient = point;
	m_bLButtonDown = true;

	pView->SetCapture();

	//
	// Convert to some odd coordinate space that the base tools code uses.
	//
  	CPoint ptScreen = point;
	ptScreen.x += pView->GetScrollPos(SB_HORZ);
	ptScreen.y += pView->GetScrollPos(SB_VERT);
	
	//
	// Convert point to world coords.
	//
	pView->ClientToWorld(point);

	Vector ptOrg( COORD_NOTINIT, COORD_NOTINIT, COORD_NOTINIT );
	ptOrg[axHorz] = point.x;
	ptOrg[axVert] = point.y;

	// getvisiblepoint fills in any coord that's still set to COORD_NOTINIT:
	pDoc->GetBestVisiblePoint(ptOrg);

	// snap starting position to grid
	if (!(GetAsyncKeyState(VK_MENU) & 0x8000))
	{
		pDoc->Snap(ptOrg);
	}
	
	BOOL bStarting = FALSE;

	// if the tool is not empty, and shift is not held down (to
	//  start a new camera), don't do anything.
	if(!IsEmpty())
	{
		if(!StartTranslation(ptScreen))
		{
			if (nFlags & MK_SHIFT)
			{
				SetEmpty();
				bStarting = TRUE;
			}
			else
			{
				goto _DoNothing;
			}
		}
	}
	else
	{
		bStarting = TRUE;
	}

	SetClipObjects(pDoc->Selection_GetList());

	if (bStarting)
	{
		StartNew(ptOrg);
		pView->SetUpdateFlag(CMapView2D::updTool);
	}

_DoNothing:

	return true;
}