示例#1
0
        decimal pDoY(int i)
        {
            decimal y_ = 0m;

            int yRef = pGetRef(i, PatternElement.properties_i.yPosRef);

            // We have a relative positioning situation.
            // Note that this could be cascading so we need to walk the stack

            if (yRef >= 0)
            {
                int sRef = pGetPatternElement(i).getInt(PatternElement.properties_i.yPosSubShapeRef);

                int sPosRef = pGetPatternElement(i).getInt(PatternElement.properties_i.yPosSubShapeRefPos);

                bool refFlipped = pGetPatternElement(yRef).getInt(PatternElement.properties_i.flipV) == 1;

                y_ += pGetPatternElement(yRef).getDecimal(PatternElement.properties_decimal.yPos);

                // In the case of an array shape type for the reference, we may still have subshape relative references. To check this, we need to query for an array. If we don't have an array, we're good.
                // Then we also need to query whether the subshape reference is a higher value than the number of subshapes in the shape; the 'array' subshape reference is last in the list.
                bool doY = !pGetPatternElement(yRef).isYArray() || (pGetPatternElement(yRef).isYArray() && (sRef < pGetPatternElement(yRef).getSubShapeCount()));

                int aYRef = yRef;

                // Is the array reference a relative array?
                if (pGetPatternElement(yRef).getInt(PatternElement.properties_i.arrayRef) != 0)
                {
                    aYRef = pGetPatternElement(yRef).getInt(PatternElement.properties_i.arrayRef) - 1;

                    int PSSR = pGetPatternElement(i).getInt(PatternElement.properties_i.yPosSubShapeRef);
                    int PSSC = pGetPatternElement(yRef).getSubShapeCount();
                    if (PSSR == PSSC)
                    {
                        doY = false;
                    }
                }

                if (doY)
                {
                    y_ += pGetPatternElement(yRef).getDecimal(PatternElement.properties_decimal.verOffset, 0);
                    if (sRef == 1)
                    {
                        y_ += pGetPatternElement(yRef).getDecimal(PatternElement.properties_decimal.verOffset, 1);
                    }
                    if (sRef == 2)
                    {
                        y_ += pGetPatternElement(yRef).getDecimal(PatternElement.properties_decimal.verLength, 0);
                        y_ -= pGetPatternElement(yRef).getDecimal(PatternElement.properties_decimal.verLength, 2);
                        y_ -= pGetPatternElement(yRef).getDecimal(PatternElement.properties_decimal.verOffset, 2);
                    }
                }

                // Process the side case.
                if ((!refFlipped && (sPosRef == (int)CommonVars.subShapeVerLocs.T)) || (refFlipped && (sPosRef == (int)CommonVars.subShapeVerLocs.B)))
                {
                    if (doY)
                    {
                        switch (sRef)
                        {
                            case 0:
                                y_ += pGetPatternElement(yRef).getDecimal(PatternElement.properties_decimal.verLength, 0);
                                break;
                            case 1:
                                y_ += pGetPatternElement(yRef).getDecimal(PatternElement.properties_decimal.verLength, 1);
                                break;
                            case 2:
                                y_ += pGetPatternElement(yRef).getDecimal(PatternElement.properties_decimal.verLength, 2);
                                break;
                        }
                    }
                    else
                    {
                        y_ += Convert.ToDecimal(pBBDimension(bbDims.height, aYRef));
                    }
                }

                if (sPosRef == (int)CommonVars.subShapeVerLocs.M)
                {
                    if (doY)
                    {
                        switch (sRef)
                        {
                            case 0:
                                y_ += pGetPatternElement(yRef).getDecimal(PatternElement.properties_decimal.verLength, 0) / 2;
                                break;
                            case 1:
                                y_ += pGetPatternElement(yRef).getDecimal(PatternElement.properties_decimal.verLength, 1) / 2;
                                break;
                            case 2:
                                y_ += pGetPatternElement(yRef).getDecimal(PatternElement.properties_decimal.verLength, 2) / 2;
                                break;
                        }
                    }
                    else
                    {
                        y_ += Convert.ToDecimal(pBBDimension(bbDims.height, aYRef)) / 2;
                    }
                }

                // Is the reference flipped? If so, we need to flip our value to get the correct result
                if (refFlipped)
                {
                    ShapeLibrary t = new ShapeLibrary(pGetPatternElement(yRef));
                    GeoLibPointF pivot = t.getPivotPoint();

                    bool alignX = pGetPatternElement(yRef).getInt(PatternElement.properties_i.alignX) == 1;
                    bool alignY = pGetPatternElement(yRef).getInt(PatternElement.properties_i.alignY) == 1;
                    y_ = Convert.ToDecimal(GeoWrangler.flip(false, true, alignX, alignY, pivot, new[] { new GeoLibPointF(0, Convert.ToDouble(y_)) })[0].Y);
                }

                if (doY)
                {
                    switch (sRef)
                    {
                        case 0:
                            y_ += pGetPatternElement(i).getDecimal(PatternElement.properties_decimal.verOffset, 0);
                            break;
                        case 1:
                            y_ += pGetPatternElement(i).getDecimal(PatternElement.properties_decimal.verOffset, 1);
                            break;
                        case 2:
                            break;
                    }
                }

                // yRef = pGetRef(yRef, PatternElement.properties_i.yPosRef);
            }

            return y_;

        }
示例#2
0
        decimal pDoX(int i)
        {
            decimal x_ = 0m;

            int xRef = pGetRef(i, PatternElement.properties_i.xPosRef);

            // We have a relative positioning situation.
            // Note that this could be cascading so we need to walk the stack
            if (xRef >= 0)
            {
                int sRef = pGetPatternElement(i).getInt(PatternElement.properties_i.xPosSubShapeRef);

                int sPosRef = pGetPatternElement(i).getInt(PatternElement.properties_i.xPosSubShapeRefPos);

                bool refFlipped = pGetPatternElement(xRef).getInt(PatternElement.properties_i.flipH) == 1;
                x_ += pGetPatternElement(xRef).getDecimal(PatternElement.properties_decimal.xPos);

                // In the case of an array shape type for the reference, we may still have subshape relative references. To check this, we need to query for an array. If we don't have an array, we're good.
                // Then we also need to query whether the subshape reference is a higher value than the number of subshapes in the shape; the 'array' subshape reference is last in the list.
                bool doX = !pGetPatternElement(xRef).isXArray() || (pGetPatternElement(xRef).isXArray() && (sRef < pGetPatternElement(xRef).getSubShapeCount()));

                int aXRef = xRef;
                // Is the array reference a relative array?
                if (pGetPatternElement(xRef).getInt(PatternElement.properties_i.arrayRef) != 0)
                {
                    aXRef = pGetPatternElement(xRef).getInt(PatternElement.properties_i.arrayRef) - 1;

                    int PSSR = pGetPatternElement(i).getInt(PatternElement.properties_i.xPosSubShapeRef);
                    int PSSC = pGetPatternElement(xRef).getSubShapeCount();
                    if (PSSR == PSSC)
                    {
                        doX = false;
                    }
                }

                if (doX)
                {
                    if (sRef == 1)
                    {
                        x_ += pGetPatternElement(xRef).getDecimal(PatternElement.properties_decimal.horOffset, 0);
                        if (pGetPatternElement(xRef).getInt(PatternElement.properties_i.shapeIndex) != (int)CommonVars.shapeNames.Sshape)
                        {
                            if ((pGetPatternElement(xRef).getInt(PatternElement.properties_i.shapeIndex) != (int)CommonVars.shapeNames.Ushape) && (pGetPatternElement(xRef).getInt(PatternElement.properties_i.shapeIndex) != (int)CommonVars.shapeNames.Xshape))
                            {
                                x_ += pGetPatternElement(xRef).getDecimal(PatternElement.properties_decimal.horLength, 0);
                            }
                            else
                            {
                                x_ += pGetPatternElement(xRef).getDecimal(PatternElement.properties_decimal.horOffset, 1);
                            }
                        }
                    }
                    if (sRef == 2)
                    {
                        x_ += pGetPatternElement(xRef).getDecimal(PatternElement.properties_decimal.horOffset, 0);
                        x_ += pGetPatternElement(xRef).getDecimal(PatternElement.properties_decimal.horOffset, 2);
                    }
                }

                // Process the side case.
                if ((!refFlipped && (sPosRef == (int)CommonVars.subShapeHorLocs.R)) || (refFlipped && (sPosRef == (int)CommonVars.subShapeHorLocs.L)))
                {
                    if (doX)
                    {
                        switch (sRef)
                        {
                            case 0:
                                x_ += pGetPatternElement(xRef).getDecimal(PatternElement.properties_decimal.horLength, 0);
                                break;
                            case 1:
                                x_ += pGetPatternElement(xRef).getDecimal(PatternElement.properties_decimal.horLength, 1);
                                break;
                            case 2:
                                x_ += pGetPatternElement(xRef).getDecimal(PatternElement.properties_decimal.horLength, 2);
                                break;
                        }
                    }
                    else
                    {
                        x_ += Convert.ToDecimal(pBBDimension(bbDims.width, aXRef));
                    }
                }

                if (sPosRef == (int)CommonVars.subShapeHorLocs.M)
                {
                    if (doX)
                    {
                        switch (sRef)
                        {
                            case 0:
                                x_ += pGetPatternElement(xRef).getDecimal(PatternElement.properties_decimal.horLength, 0) / 2;
                                break;
                            case 1:
                                x_ += pGetPatternElement(xRef).getDecimal(PatternElement.properties_decimal.horLength, 1) / 2;
                                break;
                            case 2:
                                x_ += pGetPatternElement(xRef).getDecimal(PatternElement.properties_decimal.horLength, 2) / 2;
                                break;
                        }
                    }
                    else
                    {
                        x_ += Convert.ToDecimal(pBBDimension(bbDims.width, aXRef)) / 2;
                    }
                }

                // Is the reference flipped? If so, we need to flip our value to get the correct result
                if (refFlipped)
                {
                    ShapeLibrary t = new ShapeLibrary(pGetPatternElement(xRef));
                    GeoLibPointF pivot = t.getPivotPoint();

                    bool alignX = pGetPatternElement(xRef).getInt(PatternElement.properties_i.alignX) == 1;
                    bool alignY = pGetPatternElement(xRef).getInt(PatternElement.properties_i.alignY) == 1;
                    x_ = Convert.ToDecimal(GeoWrangler.flip(true, false, alignX, alignY, pivot, new[] { new GeoLibPointF(Convert.ToDouble(x_), 0) })[0].X);
                }

                if (doX)
                {
                    switch (sRef)
                    {
                        case 0:
                            x_ += pGetPatternElement(i).getDecimal(PatternElement.properties_decimal.horOffset, 0);
                            break;
                        case 1:
                            x_ += pGetPatternElement(i).getDecimal(PatternElement.properties_decimal.horOffset, 1);
                            break;
                        case 2:
                            x_ += pGetPatternElement(i).getDecimal(PatternElement.properties_decimal.horOffset, 2);
                            break;
                    }
                }

                // xRef = pGetRef(xRef, PatternElement.properties_i.xPosRef);
            }

            return x_;
        }