Ejemplo n.º 1
0
        bubble(int numSides)
        {
            ObjectId idWO  = ObjectId.Null;             //wipeout
            ObjectId idSM  = ObjectId.Null;             //symbol
            ObjectId idTX  = ObjectId.Null;             //text
            ObjectId idLDR = ObjectId.Null;             //leader

            Object osMode = SnapMode.getOSnap();

            SnapMode.setOSnap(0);

            double  angleView = -(double)Application.GetSystemVariable("VIEWTWIST");
            Point3d pnt3d     = Pub.pnt3dO;
            Point3d pnt3dEnd  = Pub.pnt3dO;

            Handle                   hTarget     = "0000".stringToHandle();
            string                   layerTarget = "";
            ObjectIdCollection       idsLDR      = new ObjectIdCollection();
            FullSubentityPath        path        = new FullSubentityPath();
            List <FullSubentityPath> paths       = new List <FullSubentityPath>();
            int scale = Misc.getCurrAnnoScale();

            bool   canLdr = false;
            string result = bubTxt;

            try
            {
                do
                {
                    Entity ent = Ldr.getFirstLdrPoint(out pnt3d, out canLdr, out hTarget, out layerTarget, out path);
                    if (ent == null)
                    {
                        break;
                    }
                    Color color = Misc.getColorByLayer();
                    idLDR = JigSplineLeader_BB.jigSplineLeader(pnt3d, 0.09, "BUBBLE", color);

                    if (idLDR == ObjectId.Null)
                    {
                        break;
                    }

                    paths.Add(path);
                    pnt3dEnd = idLDR.getLastVertex();

                    Ldr.setLdrXData(pnt3dEnd, idLDR, idSM);

                    idsLDR.Add(idLDR);

                    bool cancel = false;

                    if (idsLDR.Count == 1)
                    {
                        if (numSides == 0)
                        {
                            cancel = UserInput.getUserInput(result, "\nEnter Callout Number: ", out result);
                            if (cancel || result == string.Empty)
                            {
                                return;
                            }
                            bubTxt = result;
                            idTX   = Txt.addMText(result, pnt3dEnd, angleView, 0.8, 0.09, AttachmentPoint.MiddleCenter, "Annotative", "BUBBLE", color, Pub.JUSTIFYCENTER);
                        }
                        else
                        {
                            cancel = UserInput.getUserInput(result, "\nEnter Callout Number", out result);
                            if (cancel || result == string.Empty)
                            {
                                return;
                            }
                            bubTxt = result;
                            idSM   = Draw.addSymbolAndWipeout(pnt3dEnd, angleView, out idWO, Pub.radius, numSides, true);
                            idSM.moveToTop();
                            idSM.moveBelow(new ObjectIdCollection {
                                idWO
                            });
                            idTX = Txt.addMText(result, pnt3dEnd, angleView, 0.0, 0.09, AttachmentPoint.MiddleCenter, "Annotative", "BUBBLE", color, Pub.JUSTIFYCENTER);
                        }
                    }
                }while (!canLdr);
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " Draw2.cs: line: 91");
            }
            finally
            {
                Application.SetSystemVariable("OSMODE", osMode);
                xRef.unHighlightNestedEntity(paths);
            }

            if (idTX.IsValid)
            {
                addXData(idSM, scale, idTX, idsLDR, idWO, numSides, hTarget, layerTarget);
            }
        }
Ejemplo n.º 2
0
        addLdrText(string nameCmd, string nameApp, ObjectId idLdr, List <ObjectId> idsCgPnts, string top = "", string bot = "", string bot2 = "",
                   double deltaZ = 0.0, double xFactor = 0.8, bool useBackgroundFill = false, List <Point3d> pnts3dX = null)
        {
            string resultTop  = top.ToUpper();
            string resultBot  = bot.ToUpper();
            string resultBot2 = bot2.ToUpper();

            Point3d pnt3dTop = Pub.pnt3dO;
            Point3d pnt3dBot = Pub.pnt3dO;

            Point3d pnt3dLdrMid = Pub.pnt3dO;
            Point3d pnt3dLdrIns = Pub.pnt3dO;       //text insertion point on Ldr before offset
            Point3d pnt3dLdrEnd = Pub.pnt3dO;

            Point3d pnt3d1 = Pub.pnt3dO;
            Point3d pnt3d2 = Pub.pnt3dO;

            ObjectId idTxTop  = ObjectId.Null; //text
            ObjectId idTxBot  = ObjectId.Null;
            ObjectId idTxBot2 = ObjectId.Null;

            double         angle     = 0.0;
            double         scale     = Misc.getCurrAnnoScale();
            double         gapTop    = 0.09;
            double         gapBot    = 0.09;
            List <Point3d> pnts3dLdr = new List <Point3d>();

            int n = 0;
            //Application.ShowAlertDialog(idLDR.IsErased.ToString() + idLDR.IsEffectivelyErased.ToString() + idLDR.ToString());
            PromptStatus ps = PromptStatus.Cancel;

            if (nameCmd == "cmdFFD")
            {
                pnt3d1 = UserInput.getPoint("Pick Insertion Point for Label: ", out ps, osMode: 0);
                //Line line = LdrText_JigLine.jigLine(pnt3d1);
                //angle = line.Angle;
                //line.ObjectId.delete();
                angle = (double)Application.GetSystemVariable("VIEWTWIST");
            }
            else
            {
                if (idLdr.IsEffectivelyErased || idLdr.IsErased)
                {
                    return;
                }

                pnts3dLdr   = idLdr.getCoordinates3dList();
                n           = pnts3dLdr.Count;
                angle       = pnts3dLdr[n - 2].getDirection(pnts3dLdr[n - 1]); //angle opposite direction arrow is pointing for GS or direction of 2nd segment of leader if 3 points
                pnt3dLdrEnd = pnts3dLdr[n - 1];
            }

            double angleTx = 0;

            AttachmentPoint apTop;
            AttachmentPoint apBot;
            string          justifyTop = string.Empty;
            string          justifyBot = string.Empty;

            bool left_justify = Base_Tools45.Math.left_Justify(angle);

            if (left_justify)
            {
                apTop      = AttachmentPoint.BottomLeft;
                apBot      = AttachmentPoint.TopLeft;
                angleTx    = angle + pi;
                justifyTop = Pub.JUSTIFYLEFT;
                justifyBot = Pub.JUSTIFYLEFT;
            }
            else
            {
                apTop      = AttachmentPoint.BottomRight;
                apBot      = AttachmentPoint.TopRight;
                angleTx    = angle;
                justifyTop = Pub.JUSTIFYRIGHT;
                justifyBot = Pub.JUSTIFYRIGHT;
            }

            if (cmdsGS.Contains(nameCmd))
            { // overrides for GS commands
                apTop      = AttachmentPoint.BottomCenter;
                justifyTop = Pub.JUSTIFYCENTER;
            }

            if (nameCmd == "cmdFFD")
            {
                apTop      = AttachmentPoint.MiddleCenter;
                justifyTop = Pub.JUSTIFYCENTER;
            }

            if (nameCmd == "cmdDEP")
            {
                justifyTop = Pub.JUSTIFYCENTER;
            }
            if (bot.Length < 4)
            {
                justifyBot = Pub.JUSTIFYCENTER;
            }

            double widthTop = 0;
            double widthBot = 0;
            double station  = 0.0;
            double offset   = 0.0;

            Txt.setAnnoStyle();

            Color color = Misc.getColorByLayer();

            switch (nameCmd)
            {
            case "cmdFFD":
                string txtTop = string.Format("{0}{1}{2}", resultTop, @"\P", resultBot);
                idTxTop = Txt.addMText(txtTop, pnt3d1, angleTx, 0.0, 0.50, apTop, "Annotative", "GRADES", color, justifyTop, AnnotativeStates.True, 0.8, true, backgroundFill: useBackgroundFill);
                station = 0.0;
                offset  = 0.0;
                return;

            case "cmdGS3":
                pnt3dLdrMid = idLdr.getBegPnt().getMidPoint2d(idLdr.getEndPnt());
                pnt3dLdrIns = pnt3dLdrMid.traverse(angle, (0.09 * scale / 2.4));
                if (left_justify)
                {
                    pnt3dTop = pnt3dLdrIns.traverse(angle - pi / 2, (gapTop * scale / 5));
                }
                else
                {
                    pnt3dLdrIns = pnt3dLdrMid.traverse(angle, (0.09 * scale / 2.4));
                    pnt3dTop    = pnt3dLdrIns.traverse(angle + pi / 2, (gapTop * scale / 5));
                }
                idTxTop = Txt.addMText(top, pnt3dTop, angleTx, 0.0, 0.085, apTop, "Annotative", "GRADES", color, justifyTop, AnnotativeStates.True, 0.7, backgroundFill: useBackgroundFill);
                Geom.getStaOff(idsCgPnts, pnt3dLdrIns, ref station, ref offset);
                pnts3dLdr = new List <Point3d> {
                    idLdr.getBegPnt(),
                        idLdr.getEndPnt(),
                        pnt3dLdrIns
                };
                break;

            case "cmdGS":
            case "cmdGS0":
            case "cmdGSE":
            case "cmdGSS":
            case "cmdGSX":
            case "cmdSL":
            case "cmdSS":
                if (nameCmd == "cmdGSX")
                {
                    gapTop = 0.01;
                }
                else
                {
                    gapTop = 0.09;
                }
                pnt3dLdrMid = idLdr.getBegPnt().getMidPoint2d(idLdr.getEndPnt());
                pnt3dLdrIns = pnt3dLdrMid.traverse(angle, (0.09 * scale / 2.4));
                if (left_justify)
                {
                    pnt3dTop = pnt3dLdrIns.traverse(angle - pi / 2, (gapTop * scale / 4));
                }
                else
                {
                    pnt3dTop = pnt3dLdrIns.traverse(angle + pi / 2, (gapTop * scale / 4));
                }
                idTxTop = Txt.addMText(top, pnt3dTop, angleTx, 0.0, 0.09, apTop, "Annotative", "GRADES", color, justifyTop, backgroundFill: useBackgroundFill);

                Geom.getStaOff(idsCgPnts, pnt3dLdrIns, ref station, ref offset);
                pnts3dLdr = new List <Point3d> {
                    idLdr.getBegPnt(),
                        idLdr.getEndPnt(),
                        pnt3dLdrIns                //pnt3dM - on ldr opposite text insertion point
                };
                break;

            default:
                idTxTop  = Txt.addMText(resultTop, pnt3dLdrEnd, angleTx, 0.0, 0.09, apTop, "Annotative", "GRADES", color, justifyTop, backgroundFill: useBackgroundFill);
                widthTop = idTxTop.getMTextWidth();
                if (resultBot != string.Empty)
                {
                    idTxBot = Txt.addMText(resultBot, pnt3dLdrEnd, angleTx, 0.0, 0.09, apBot, "Annotative", "GRADES", color, justifyBot, backgroundFill: useBackgroundFill);
                }
                if (resultBot2 != string.Empty)
                {
                    pnt3dBot = pnt3dLdrEnd.traverse(angleTx - pi / 2, (.14 * scale));
                    idTxBot2 = Txt.addMText(resultBot2, pnt3dBot, angleTx, 0.0, 0.09, apBot, "Annotative", "GRADES", color, justifyBot, backgroundFill: useBackgroundFill);
                }
                station = 0.0;
                offset  = 0.0;
                break;
            }
            if (resultBot == string.Empty || nameCmd == "cmdFFD")
            {
                widthBot = 0;
            }
            else
            {
                widthBot = idTxBot.getMTextWidth();
            }

            double width = 0;

            if (widthBot > widthTop)
            {
                width = widthBot;
            }
            else
            {
                width = widthTop;
            }

            //Adjust callout leader length
            if (!cmdsGS.Contains(nameCmd))
            {
                if (nameCmd == "cmdFLX" || nameCmd == "cmdGX")
                {
                    gapTop = 0.01;
                    gapBot = 0.08;
                }
                else
                {
                    gapTop = 0.09;
                    gapBot = 0.09;
                }

                Point3d pnt3dLdrEndAdj = pnts3dLdr[n - 2].traverse(angle, width);  //reseting leader endpoint based on text width

                idLdr.adjLdrEndPnt(pnt3dLdrEndAdj);
                pnts3dLdr = idLdr.getCoordinates3dList();

                if (left_justify)
                {
                    pnt3dTop = pnt3dLdrEndAdj.traverse(angle - pi / 2, gapTop * scale / 4);
                    pnt3dBot = pnt3dLdrEndAdj.traverse(angle + pi / 2, gapBot * scale / 4);
                }
                else
                {
                    pnt3dTop = pnt3dLdrEndAdj.traverse(angle + pi / 2, gapTop * scale / 4);
                    pnt3dBot = pnt3dLdrEndAdj.traverse(angle - pi / 2, gapBot * scale / 4);
                }

                idTxTop.adjMTextXYandAngle(pnt3dTop, angleTx, width);
                if (idTxBot != ObjectId.Null)
                {
                    idTxBot.adjMTextXYandAngle(pnt3dBot, angleTx, width);
                }
                if (idTxBot2 != ObjectId.Null)
                {
                    if (left_justify)
                    {
                        pnt3dBot = pnt3dLdrEndAdj.traverse(angle + pi / 2, 0.14 * scale);
                    }
                    else
                    {
                        pnt3dBot = pnt3dLdrEndAdj.traverse(angle - pi / 2, 0.14 * scale);
                    }

                    idTxBot2.adjMTextXYandAngle(pnt3dBot, angleTx, width);
                }
            }

            idLdr.moveToTop();

            //Add XData
            if (nameCmd != "cmdRDR" && nameCmd != "cmdSW")
            {
                if (idTxTop.IsValid)
                {
                    addXDataLnks(nameApp, nameCmd, idLdr, idTxTop, idTxBot, idTxBot2, pnt3dTop, scale, deltaZ, pnts3dLdr, idsCgPnts, station, offset, pnts3dX);
                }
                else
                {
                    return;
                }
                //addMTextIdToAppDict(nameApp, idTxTop);
            }
        }