Пример #1
0
        public OoxTransform(OoxTransform outer, OoxTransform inner)
        {
            // Get the Bounding box of the most inner transformation
            _x  = inner.X;
            _y  = inner.Y;
            _cx = inner.CX;
            _cy = inner.CY;
            // Now combine all transformations (5.7.4, "Render a simple shape inside a group hierarchy", steps 1, 2, 3)
            _rot    = Normalize(outer._rot + inner._rot);
            _flipH  = outer._flipH * inner._flipH;
            _flipV  = outer._flipV * inner._flipV;
            _scaleX = outer._scaleX * inner._scaleX;
            _scaleY = outer._scaleY * inner._scaleY;
            TransformationMatrix m = outer._transform * inner._transform;   // Note : the center should be invariant by inner._transform...
            // Calculate the coordinates of the new Center (5.7.4, "Render a simple shape inside a group hierarchy", step 4)
            PointCoordinates originalCenter = new PointCoordinates(_x + _cx / 2.0, _y + _cy / 2.0);
            PointCoordinates newCenter      = m.Transform(originalCenter);
            // Now calculate the target "Bounding box"
            double newCx = _cx * _scaleX;
            double newCy = _cy * _scaleY;
            double newX  = newCenter.X - newCx / 2.0;
            double newY  = newCenter.Y - newCy / 2.0;

            // And finally compute the transformation matrix...
            CreateMatrix(_x, _y, _cx, _cy, newX, newY, newCx, newCy, _rot, _flipH, _flipV);
        }
Пример #2
0
        public static OoxTransform CreateLine(long xmlX, long xmlY, long xmlCx, long xmlCy, long xmlRot, long xmlFlipH, long xmlFlipV)
        {
            OoxTransform tmp = new OoxTransform(xmlX, xmlY, xmlCx, xmlCy, xmlRot, xmlFlipH, xmlFlipV);
            double       x1, y1;

            tmp.Transform(tmp._x, tmp._y, out x1, out y1);
            double x2, y2;

            tmp.Transform(tmp._x + tmp._cx, tmp._y + tmp._cy, out x2, out y2);
            long newX1    = (long)(x1 * 360000.0);
            long newY1    = (long)(y1 * 360000.0);
            long newX2    = ((long)(x2 * 360000.0));
            long newY2    = ((long)(y2 * 360000.0));
            long newFlipH = 1;
            long newFlipV = 1;

            if (newX1 > newX2)
            {
                long tmpX = newX2;
                newX2    = newX1;
                newX1    = tmpX;
                newFlipH = -1;
            }
            if (newY1 > newY2)
            {
                long tmpY = newY2;
                newY2    = newY1;
                newY1    = tmpY;
                newFlipV = -1;
            }
            return(new OoxTransform(newX1, newY1, newX2 - newX1, newY2 - newY1, 0, newFlipH, newFlipV));
        }