Article | 60001353 |
Type | HowTo |
Product | Engine |
Version | 6 |
Date Added | 3/16/2011 |
Submitted by | Adam White |
Keywords |
Ability to turn of the "circle" and change the way view rotation is done in View3D "VROT"
It can be done by overriden the vdKeyDown event of VectorDrawBaseControl
example:
(Suppose that we have a form with a vdFramedControl added in the form control collection)
In the following example
1.when the user press the left or right arrow key by holding the Alt key, the view is rotated arrond the Y axis of active View .
2.when the user press the up or down arrow key by holding the Alt key, the view is rotated arrond the X axis of active View .
3.when the user press the left or right arrow key by holding the Control key, the view is rotated arrond the Z axis of active View .
private void Form1_Load(object sender, EventArgs e)
{
vdFramedControl.BaseControl.vdKeyDown += new VectorDraw.Professional.Control.KeyDownEventHandler(BaseControl_vdKeyDown);
}
void BaseControl_vdKeyDown(KeyEventArgs e, ref bool cancel)
{
BaseAction action = doc.ActiveLayOut.OverAllActiveAction;
if(action == null) return;
Matrix curmat = new Matrix( action.Render.CurrentMatrix);
bool done = false;
if (e.Alt && e.KeyCode == Keys.Left)
{
curmat.RotateYMatrix(Globals.VD_PI_OVER_180 * 10 * 1.0d);
done = true;
}
else if (e.Alt && e.KeyCode == Keys.Right)
{
curmat.RotateYMatrix(Globals.VD_PI_OVER_180 * 10 * -1.0d);
done = true;
}
else if (e.Alt && e.KeyCode == Keys.Up)
{
curmat.RotateXMatrix(Globals.VD_PI_OVER_180 * 10 * 1.0d);
done = true;
}
else if (e.Alt && e.KeyCode == Keys.Down)
{
curmat.RotateXMatrix(Globals.VD_PI_OVER_180 * 10 * -1.0d);
done = true;
}
else if (e.Control && e.KeyCode == Keys.Left)
{
curmat.RotateZMatrix(Globals.VD_PI_OVER_180 * 10 * -1.0d);
done = true;
}
else if (e.Control && e.KeyCode == Keys.Right)
{
curmat.RotateZMatrix(Globals.VD_PI_OVER_180 * 10 * 1.0d);
done = true;
}
if (!done) return;
action.Render.CurrentMatrix = curmat;
doc.Redraw(true);
cancel = true;
}