本文整理匯總了C#中Sledge.Editor.Documents.Document.Snap方法的典型用法代碼示例。如果您正苦於以下問題:C# Document.Snap方法的具體用法?C# Document.Snap怎麽用?C# Document.Snap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Sledge.Editor.Documents.Document
的用法示例。
在下文中一共展示了Document.Snap方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: GetTransformationMatrix
public override Matrix4? GetTransformationMatrix(Viewport2D viewport, ViewportEvent e, BaseBoxTool.BoxState state, Document doc)
{
var shearUpDown = state.Handle == BaseBoxTool.ResizeHandle.Left || state.Handle == BaseBoxTool.ResizeHandle.Right;
var shearTopRight = state.Handle == BaseBoxTool.ResizeHandle.Top || state.Handle == BaseBoxTool.ResizeHandle.Right;
var nsmd = viewport.ScreenToWorld(e.X, viewport.Height - e.Y) - state.MoveStart;
var mouseDiff = SnapIfNeeded(nsmd, doc);
if (KeyboardState.Shift)
{
mouseDiff = doc.Snap(nsmd, doc.Map.GridSpacing / 2);
}
var relative = viewport.Flatten(state.PreTransformBoxEnd - state.PreTransformBoxStart);
var shearOrigin = (shearTopRight) ? state.PreTransformBoxStart : state.PreTransformBoxEnd;
var shearAmount = new Coordinate(mouseDiff.X / relative.Y, mouseDiff.Y / relative.X, 0);
if (!shearTopRight) shearAmount *= -1;
var shearMatrix = Matrix4.Identity;
var sax = (float)shearAmount.X;
var say = (float)shearAmount.Y;
switch (viewport.Direction)
{
case Viewport2D.ViewDirection.Top:
if (shearUpDown) shearMatrix.M12 = say;
else shearMatrix.M21 = sax;
break;
case Viewport2D.ViewDirection.Front:
if (shearUpDown) shearMatrix.M23 = say;
else shearMatrix.M32 = sax;
break;
case Viewport2D.ViewDirection.Side:
if (shearUpDown) shearMatrix.M13 = say;
else shearMatrix.M31 = sax;
break;
}
var stran = Matrix4.CreateTranslation((float)-shearOrigin.X, (float)-shearOrigin.Y, (float)-shearOrigin.Z);
var shear = Matrix4.Mult(stran, shearMatrix);
return Matrix4.Mult(shear, Matrix4.Invert(stran));
}
示例2: SnapIfNeeded
protected static Coordinate SnapIfNeeded(Coordinate c, Document doc)
{
return doc.Snap(c);
}