Ejemplo n.º 1
0
        public void ScaleAt(float scaleX, float scaleY, Vex.Point center)
        {
            scaleX = (Math.Abs(scaleX) < .01) ? .01f : scaleX;
            scaleY = (Math.Abs(scaleY) < .01) ? .01f : scaleY;

            Matrix tm = TransformMatrix.Clone();

            tm.Translate(-TransformMatrix.OffsetX, -TransformMatrix.OffsetY, MatrixOrder.Append);
            Matrix itm = tm.Clone();

            itm.Invert();

            foreach (uint id in list)
            {
                DesignInstance inst = instanceManager[id];

                using (Matrix ms = inst.GetMatrix().SysMatrix())
                {
                    ms.Translate(-center.X, -center.Y, MatrixOrder.Append);
                    ms.Multiply(itm, MatrixOrder.Append);
                    ms.Scale(scaleX, scaleY, MatrixOrder.Append);
                    ms.Multiply(tm, MatrixOrder.Append);
                    ms.Translate(center.X, center.Y, MatrixOrder.Append);

                    inst.SetMatrix(ms.VexMatrix());
                }
            }
            tm.Dispose();
            itm.Dispose();

            transformMatrix.ScaleAt(scaleX, scaleY, center.SysPointF());
            isDirty = true;
            MainForm.CurrentStage.InvalidateTransformedSelection();
        }
Ejemplo n.º 2
0
        public void ResetTransform()
        {
            if (transformMatrix != null)
            {
                transformMatrix.Dispose();
            }

            if (list.Count == 1)
            {
                DesignInstance di = instanceManager[list[0]];
                transformMatrix     = di.GetMatrix().SysMatrix();
                center              = di.RotationCenter;
                untransformedBounds = di.Definition.StrokeBounds;//.TranslatedRectangle(-di.Location.X, -di.Location.Y);
            }
            else
            {
                transformMatrix = new Matrix();
                transformMatrix.Translate(StrokeBounds.Left, StrokeBounds.Top, MatrixOrder.Append);
                center = StrokeBounds.LocalCenter;
                //center = StrokeBounds.LocalCenter.Translate(StrokeBounds.Point);
                untransformedBounds = StrokeBounds.TranslatedRectangle(-StrokeBounds.Left, -StrokeBounds.Top);
            }

            isTransformDirty = false;
        }
Ejemplo n.º 3
0
        private void TranslateElement(uint id, float newBoundsLeft, float newBoundsTop)
        {
            DesignInstance inst = instanceManager[id];

            using (Matrix mr = inst.GetMatrix().SysMatrix())
            {
                mr.Translate(newBoundsLeft - inst.StrokeBounds.Left, newBoundsTop - inst.StrokeBounds.Top, MatrixOrder.Append);
                inst.SetMatrix(mr.VexMatrix());
            }

            isDirty = true;
        }
Ejemplo n.º 4
0
        public void DrawTranslated(Graphics g, uint id, float newLocX, float newLocY)
        {
            Matrix m = g.Transform;

            DesignInstance inst = instanceManager[id];

            using (Matrix mr = inst.GetMatrix().SysMatrix())
            {
                mr.Translate(newLocX - inst.Location.X, newLocY - inst.Location.Y, MatrixOrder.Append);
                mr.Multiply(m, MatrixOrder.Append);
                g.Transform = mr;
                inst.DrawOutlineIntoRaw(g, 0, 0);
            }

            g.Transform = m;
        }
Ejemplo n.º 5
0
        public void RotateAt(float angle, Vex.Point center)
        {
            foreach (uint id in list)
            {
                DesignInstance inst = instanceManager[id];
                using (Matrix mr = inst.GetMatrix().SysMatrix())
                {
                    mr.RotateAt(angle, center.SysPointF(), MatrixOrder.Append);
                    inst.SetMatrix(mr.VexMatrix());
                }
            }

            transformMatrix.RotateAt(angle, center.SysPointF(), MatrixOrder.Append);
            isDirty = true;
            MainForm.CurrentStage.InvalidateTransformedSelection();
        }
Ejemplo n.º 6
0
        public void DrawRotated(Graphics g, float angle, Vex.Point center)
        {
            Matrix m = g.Transform;

            foreach (uint id in list)
            {
                DesignInstance inst = instanceManager[id];
                using (Matrix mr = inst.GetMatrix().SysMatrix())
                {
                    mr.RotateAt(angle, center.SysPointF(), MatrixOrder.Append);
                    mr.Multiply(m, MatrixOrder.Append);
                    g.Transform = mr;
                    inst.DrawOutlineIntoRaw(g, 0, 0);
                }
            }
            g.Transform = m;
        }
Ejemplo n.º 7
0
        public void GetFullMatrix(out Matrix m)
        {
            if (stage.InstanceManager.Contains(ParentInstanceId))
            {
                DesignInstance parent = stage.InstanceManager[ParentInstanceId];
                m = parent.GetMatrix().SysMatrix();
                m.Invert();
            }
            else
            {
                m = new SysMatrix();
            }

            using (Matrix lm = instance.GetTransformAtTime(0).Matrix.SysMatrix())
            {
                lm.Invert();
                m.Multiply(lm, MatrixOrder.Append);
            }
        }
Ejemplo n.º 8
0
        public void DrawScaled(Graphics g, float scaleX, float scaleY, Vex.Point center)
        {
            Matrix m = g.Transform;

            scaleX = (Math.Abs(scaleX) < .01) ? .01f : scaleX;
            scaleY = (Math.Abs(scaleY) < .01) ? .01f : scaleY;

            Matrix tm = TransformMatrix.Clone();

            tm.Translate(-TransformMatrix.OffsetX, -TransformMatrix.OffsetY, MatrixOrder.Append);
            Matrix itm = tm.Clone();

            itm.Invert();

            foreach (uint id in list)
            {
                DesignInstance inst = instanceManager[id];

                using (Matrix ms = inst.GetMatrix().SysMatrix())
                {
                    ms.Translate(-center.X, -center.Y, MatrixOrder.Append);
                    ms.Multiply(itm, MatrixOrder.Append);
                    ms.Scale(scaleX, scaleY, MatrixOrder.Append);
                    ms.Multiply(tm, MatrixOrder.Append);
                    ms.Translate(center.X, center.Y, MatrixOrder.Append);

                    ms.Multiply(m, MatrixOrder.Append);
                    g.Transform = ms;
                    inst.DrawOutlineIntoRaw(g, 0, 0);
                }
            }

            tm.Dispose();
            itm.Dispose();

            g.Transform = m;
        }