Beispiel #1
0
bool RotateViewMouseProc::NormalStart(HWND hwnd, int point, int flag, const IPoint2& screenPt )
{
	DbgAssert(!mStarted);

	Interface10* ip = GetCOREInterface10();
	ip->SetActiveViewport(hwnd);
		
	ViewExp& viewExp = ip->GetViewExp(hwnd);		
	if (viewExp.IsAlive())
		mViewport = reinterpret_cast<ViewExp10*>(viewExp.Execute(ViewExp::kEXECUTE_GET_VIEWEXP_10));
	if (NULL == mViewport)
		return false;
	
	SetCursor(mCursor);
	
	mViewport->UndoBegin();

	mViewport->GetAffineTM(mOldViewportMatrix);
	mOldScreenPt  = screenPt;

	mStarted = true;
	ip->RedrawViews(ip->GetTime(), REDRAW_BEGIN); 

	return mStarted;
}
void BaseLimitCtrl::SetValue(TimeValue in_t, void *in_val, int in_commit, GetSetMethod in_method)
{
	if(GetLocked()==false)
	{
		if (IsEnabled()) {
			if (in_method == CTRL_RELATIVE)
				GetTypedValueAbsolute(in_t, in_val);
			ClampTypedValue(in_t, in_val);
		}

		// Check if we have a controller assigned.  If so, SetValue on it, if it's not locked!
		Control *limitedCtrl = GetLimitedControl();
		if (limitedCtrl) {
			limitedCtrl->SetValue(in_t, in_val, in_commit, IsEnabled()? CTRL_ABSOLUTE: in_method);
		}
		else {
			// If in AutoKey or SetKey mode, ParamBlock::SetValue() and ParamBlock2::SetValue()
			// create a default controller (an fcurve) and then set key on that   
			// controller.  So if there is no limited controller, I'll do the same:
			// create one, and set key on it.
			if (GetSetKeyMode() || (Animating() && GetCOREInterface10()->GetAutoKeyDefaultKeyOn() && (in_t!=0) && (in_t!=GetCOREInterface10()->GetAutoKeyDefaultKeyTime()))) {
				// Create the proper default controller according to type
				Control *newLimitedCtrl = GetDefaultControlForDataType();
				if (newLimitedCtrl) {
					void* ptrVal = CreateTempValue();
					GetStaticValue(ptrVal, in_method);

					SetLimitedControl(newLimitedCtrl);
					if (GetSetKeyMode()) {
						ISetKey *skey = (ISetKey *)newLimitedCtrl->GetInterface(I_SETKEYCONTROL);
						if (skey)
							skey->SetCurrentValue(ptrVal);
						newLimitedCtrl->SetValue(in_t, in_val);
					}
					else {
						newLimitedCtrl->SetValue(TimeValue(GetCOREInterface10()->GetAutoKeyDefaultKeyTime()), ptrVal);
						newLimitedCtrl->SetValue(in_t, in_val);
					}
					DeleteTempValue(ptrVal);
				}
			}

			// Set the limit controller static value
			SetStaticValue(in_val, CTRL_ABSOLUTE);
		}
	}
}
Beispiel #3
0
void RotateViewCommandMode::ExitMode() 
{ 
	// Restore mouse cursor
	SetCursor(mOldCursor);
	ShowCursor(TRUE);
	DestroyCursor(mCursor);
	mCursor = NULL;
	proc.SetCursor(mCursor);

	// Remove command mode name from status panel
	Interface10* ip = GetCOREInterface10();
	ip->PopPrompt();
}
Beispiel #4
0
void RotateViewCommandMode::EnterMode() 
{ 
	// Load and set mouse cursor
	if (NULL == mCursor)
	{
		mCursor = LoadCursor(hInstance, MAKEINTRESOURCE(IDC_ROTATE_CURSOR));
		mOldCursor = SetCursor(mCursor);
		ShowCursor(TRUE);
	}
	proc.SetCursor(mCursor);

	// Display command mode name on status panel
	Interface10* ip = GetCOREInterface10();
	ip->PushPrompt(GetString(IDS_ROTATE_MODE));
}
Beispiel #5
0
void RotateViewMouseProc::Idle()
{
	if (mStarted)
	{
		if (mViewport)
		{
			SetCursor(mCursor);
			ShowCursor(TRUE);

			mViewport->Invalidate();
			Interface10* ip = GetCOREInterface10();
			ip->RedrawViews(ip->GetTime(), VP_END_SEQUENCE);

			mViewport->UndoAccept();

			mViewport = NULL;				
		}
		mStarted = false;
	}
}
Beispiel #6
0
bool RotateViewMouseProc::OnMouseAbort(HWND hwnd, int point, int flag, const IPoint2& screenPt )
{
	DbgAssert(mStarted);
	if ( ! mViewport || ! mViewport->IsAlive() )
	{
		DbgAssert(!_T("mViewport is not valid!"));
		return false;
	}

	mViewport->SetAffineTM(mOldViewportMatrix);
	mViewport->Invalidate();			

	Interface10* ip = GetCOREInterface10();
	ip->RedrawViews(ip->GetTime(), REDRAW_END); 

	mViewport = NULL;
	mStarted = false;

	return mStarted;
}
Beispiel #7
0
bool RotateViewMouseProc::OnMouseMove(HWND hwnd, int point, int flag, const IPoint2& screenPt )
{
	DbgAssert(mStarted);
	if ( ! mViewport || ! mViewport->IsAlive() )
	{
		DbgAssert(!_T("Viewport is not valid!"));
		return false;
	}
	
	SetCursor(mCursor);

	IPoint2 mCurScreenPt = screenPt;
	if (abs(screenPt.y - mOldScreenPt.y) > abs(screenPt.x - mOldScreenPt.x))
		// Constrain in X
		mCurScreenPt.x = mOldScreenPt.x;
	else
		// Constrain in Y
		mCurScreenPt.y = mOldScreenPt.y;
	
	// find out the user is moving the mouse in which direction
	IPoint2 delta = mCurScreenPt - mOldScreenPt;

	Point3 center;
	Matrix3 svmat;
	mViewport->GetAffineTM(svmat);

	if(mViewport->GetViewType() == VIEW_PERSP_USER)
		center = Point3(0.0f, 0.0f, -mViewport->GetFocalDist()) - svmat.GetTrans();
	else
		center = svmat.GetTrans();//mViewport->getOffset();

	float angle = (flag & MOUSE_CTRL) ? 10.0f : 1.0f;	

	if (delta.x < 0) // Going left
	{
		if (flag & MOUSE_SHIFT) 
			mViewport->Rotate( RotateZMatrix(  DegToRad(angle) ), center );
		else
			mViewport->Rotate( Inverse(svmat) * RotateZMatrix(  DegToRad(angle) ) * svmat, center );
	}
	else if (delta.x > 0) // Going Right
	{
		if (flag & MOUSE_SHIFT) 
			mViewport->Rotate( RotateZMatrix( -DegToRad(angle) ), center );
		else
			mViewport->Rotate( Inverse(svmat) * RotateZMatrix( -DegToRad(angle) ) * svmat, center );
	}
	else if (delta.y < 0) // going Up
	{
		mViewport->Rotate( RotateXMatrix(  DegToRad(angle) ), center );
	}
	else // Going down
	{
		mViewport->Rotate( RotateXMatrix( -DegToRad(angle) ), center );
	}

	mViewport->Invalidate();			
	Interface10* ip = GetCOREInterface10();
	ip->RedrawViews(ip->GetTime(), REDRAW_INTERACTIVE); 

	mOldScreenPt = screenPt;			

	return mStarted;
}