示例#1
0
        public static IHdPolyline3D DrawPolyline3DDx(IHeadsDocument doc, bool bEngFunc, CLinetype linetype)
        {
            List <CPoint3D> ptList = new List <CPoint3D>();

            ptList.Add(linetype.StartPoint);
            ptList.Add(linetype.EndPoint);

            IHdPolyline3D polyline = doc.DrawPolyline3D(ptList);

            DrawingUtil.SetLayerToEntity(bEngFunc, polyline, doc, linetype.Layer);
            polyline.Lineweight = eHEADS_LWEIGHT.LnWt000;
            polyline.Label      = linetype.Label;

            return(polyline);
        }
示例#2
0
        void ShowItemEntities(List <CLabtype> entities, string strModelName, string stgLabel)
        {
            int           NumPts   = 0;
            CPoint3D      ptStart  = new CPoint3D();
            CPoint3D      ptEnd    = new CPoint3D();
            CPoint3D      ptLast   = new CPoint3D();
            CTXTtype      txt      = new CTXTtype();
            CLinetype     uline    = new CLinetype();
            IHdPolyline3D polyline = null;
            string        str1     = "";

            IHdPoint aPoint = null;
            CPTStype pts    = new CPTStype();

            this.App.ActiveDocument.ConfigParam.XMetric = 1.0;
            this.App.ActiveDocument.ConfigParam.YMetric = 1.0;

            CCfgtype cfg = this.App.ActiveDocument.ConfigParam;

            eHEADS_COLOR entitycolor = (stgLabel.StartsWith("member")) ? FormLoadDeflection.MemberColor : FormLoadDeflection.LoadColor;

            double dTextHeight = (this.App.ActiveDocument.ActiveTextHeight > 0) ? this.App.ActiveDocument.ActiveTextHeight : 1.0;

            for (int iIndex = 0; iIndex < entities.Count; iIndex++)
            {
                CLabtype labtype = entities[iIndex];

                if (labtype.attr == CLabtype.Type.Point)
                {
                    pts = (CPTStype)labtype.Tag;

                    ptEnd = new CPoint3D(pts.mx * cfg.XMetric, pts.my * cfg.YMetric, pts.mz);
                    NumPts++;

                    ptStart = ptLast;
                    ptLast  = ptEnd;

                    uline.StartPoint = new CPoint3D(ptStart);
                    uline.EndPoint   = new CPoint3D(ptEnd);

                    str1 = stgLabel;

                    if (NumPts == 1)
                    {
                        aPoint = this.App.ActiveDocument.DrawPoint(ptEnd);

                        aPoint.color = entitycolor;
                    }
                    else if (NumPts == 2)
                    {
                        uline.Layer  = this.App.ActiveDocument.GetActiveLayer().Name;
                        uline.elatt  = 1;
                        uline.laatt  = 1;
                        uline.Label  = strModelName;
                        uline.Label += ":";
                        uline.Label += stgLabel;
                        uline.scatt  = 1;

                        polyline = DrawingUtil.DrawPolyline3DDx(this.App.ActiveDocument, true, uline);

                        polyline.color = entitycolor;

                        aPoint.Erase();
                    }
                    else if (NumPts > 2)
                    {
                        polyline.AppendVertex(ptEnd);
                    }
                }
                else if (labtype.attr == CLabtype.Type.Text)
                {
                    txt = (CTXTtype)labtype.Tag;

                    ptEnd = new CPoint3D(txt.tx * cfg.XMetric, txt.ty * cfg.YMetric, txt.tz);
                    str1  = txt.tg;
                    IHdText textobj = this.App.ActiveDocument.DrawText(ptEnd, str1, dTextHeight);
                    textobj.color = entitycolor;
                    aPoint        = this.App.ActiveDocument.DrawPoint(ptEnd);
                    aPoint.color  = entitycolor;
                }
                else if (labtype.attr == CLabtype.Type.EndCode)
                {
                    NumPts = 0;
                }
            }
            this.App.ActiveDocument.RefreshDocument(true);
        }
示例#3
0
        private void ExecDrawString(BinaryReader br)
        {
            bool bIsModel = false;
            bool bIsLabel = false;

            CPoint3D ptStart      = new CPoint3D();
            CPoint3D ptEnd        = new CPoint3D();
            CPoint3D ptLast       = new CPoint3D();
            CPoint3D ptFirst3dFac = new CPoint3D();
            string   strSeleModel = GetSelectedModelName();

            CTXTtype        txt          = new CTXTtype();
            CLinetype       uline        = new CLinetype();
            string          strModelName = "";
            int             NumPts       = 0;
            string          str1         = "";
            string          stgLabel     = "";
            IHdPoint        aPoint       = null;
            IHdPolyline3D   polyline     = null;
            CPTStype        pts          = new CPTStype();
            List <CPoint3D> pFArray      = new List <CPoint3D>();

            this.m_app.ActiveDocument.ConfigParam.XMetric = 1.0;
            this.m_app.ActiveDocument.ConfigParam.YMetric = 1.0;

            CCfgtype cfg = this.m_app.ActiveDocument.ConfigParam;

            int iSelectedLineType = this.GetSelectedLineType();

            double dTextHeight = (this.m_app.ActiveDocument.ActiveTextHeight > 0) ? this.m_app.ActiveDocument.ActiveTextHeight : 1.0;


            string strFilePath = m_strpathfilfile;
            //if (File.Exists(strFilePath))
            {
                //BinaryReader br = new BinaryReader(new FileStream(strFilePath, FileMode.Open, FileAccess.Read), Encoding.Default);

                //set the progress bar max value
                SetProgressBarMaxValue(100);

                while (br.BaseStream.Position < br.BaseStream.Length)
                {
                    CLabtype labtype = CLabtype.FromStream(br);

                    if (labtype.attr == CLabtype.Type.Model) // Model Name
                    {
                        NumPts       = 0;
                        strModelName = ((CModType)labtype.Tag).Name;
                        bIsModel     = (strModelName == strSeleModel) ? true : false;
                    }
                    else if (labtype.attr == CLabtype.Type.String)// String Label
                    {
                        stgLabel = ((CStgType)labtype.Tag).label;
                        if (bIsModel)
                        {
                            bIsLabel = this.lbStringLebels_.CheckedItems.Contains(stgLabel);
                        }
                    }
                    else if (labtype.attr == CLabtype.Type.Point)
                    {
                        pts = (CPTStype)labtype.Tag;

                        ptEnd = new CPoint3D(pts.mx * cfg.XMetric, pts.my * cfg.YMetric, pts.mz);
                        NumPts++;

                        ptStart = ptLast;
                        ptLast  = ptEnd;

                        if (bIsModel && bIsLabel)
                        {
                            uline.StartPoint = new CPoint3D(ptStart);
                            uline.EndPoint   = new CPoint3D(ptEnd);

                            str1 = stgLabel;
                            if (str1.ToUpper().StartsWith("P") == true)
                            {
                                if (str1.ToUpper().StartsWith("P0") == true)
                                {
                                    txt.Point = ptEnd;
                                    //double[] res = ptEnd.GetCordArr();

                                    txt.tr = 0.0;

                                    str1 = ptEnd.Z.ToString("0.000");
                                    this.m_app.ActiveDocument.DrawText(new CPoint3D(ptEnd.X, ptEnd.Y, dTextHeight), str1, dTextHeight);

                                    this.m_app.ActiveDocument.DrawLine(new CPoint3D(ptEnd.X - 0.5, ptEnd.Y, ptEnd.Z), new CPoint3D(ptEnd.X + 0.5, ptEnd.Y, ptEnd.Z));
                                    this.m_app.ActiveDocument.DrawLine(new CPoint3D(ptEnd.X, ptEnd.Y - 0.5, ptEnd.Z), new CPoint3D(ptEnd.X, ptEnd.Y + 0.5, ptEnd.Z));
                                }
                                else
                                {
                                    txt.Point = ptEnd;
                                    txt.tr    = 0.0;
                                    double[] res = ptEnd.GetCordArr();

                                    this.m_app.ActiveDocument.DrawText(new CPoint3D(ptEnd.X, ptEnd.Y, dTextHeight), str1, dTextHeight);

                                    this.m_app.ActiveDocument.DrawLine(new CPoint3D(ptEnd.X - 0.5, ptEnd.Y, ptEnd.Z), new CPoint3D(ptEnd.X + 0.5, ptEnd.Y, ptEnd.Z));
                                    this.m_app.ActiveDocument.DrawLine(new CPoint3D(ptEnd.X, ptEnd.Y - 0.5, ptEnd.Z), new CPoint3D(ptEnd.X, ptEnd.Y + 0.5, ptEnd.Z));
                                }
                            }
                            else
                            {
                                if (NumPts == 1)
                                {
                                    aPoint = this.m_app.ActiveDocument.DrawPoint(ptEnd);
                                    if (iSelectedLineType == 4)
                                    {
                                        aPoint.Erase();
                                        ptFirst3dFac = new CPoint3D(ptEnd);
                                        pFArray.Add(ptEnd);
                                    }
                                }
                                else if (NumPts == 2)
                                {
                                    uline.Layer  = this.m_app.ActiveDocument.GetActiveLayer().Name;
                                    uline.elatt  = 1;
                                    uline.laatt  = 1;
                                    uline.Label  = strModelName;
                                    uline.Label += ":";
                                    uline.Label += stgLabel;
                                    uline.scatt  = 1;

                                    if (iSelectedLineType == 1)
                                    {
                                        polyline = DrawingUtil.DrawPolyline3DDx(this.m_app.ActiveDocument, true, uline);
                                    }
                                    else if (iSelectedLineType == 2)
                                    {
                                        polyline = DrawingUtil.DrawPolyline3DDx(this.m_app.ActiveDocument, true, uline);
                                    }
                                    else if (iSelectedLineType == 3)
                                    {
                                        aPoint = this.m_app.ActiveDocument.DrawPoint(ptEnd);
                                    }
                                    else if (iSelectedLineType == 4)
                                    {
                                        pFArray.Add(ptEnd);
                                    }

                                    aPoint.Erase();
                                }
                                else if (NumPts > 2)
                                {
                                    if (iSelectedLineType == 1)
                                    {
                                        polyline.AppendVertex(ptEnd);
                                    }
                                    else if (iSelectedLineType == 2)
                                    {
                                        polyline = DrawingUtil.DrawPolyline3DDx(this.m_app.ActiveDocument, true, uline);
                                    }
                                    else if (iSelectedLineType == 3)
                                    {
                                        aPoint = this.m_app.ActiveDocument.DrawPoint(ptEnd);
                                    }
                                    else if (iSelectedLineType == 4)
                                    {
                                        pFArray.Add(ptEnd);
                                    }
                                }
                            }
                        }
                    }
                    else if (labtype.attr == CLabtype.Type.Text)
                    {
                        txt = (CTXTtype)labtype.Tag;

                        ptEnd = new CPoint3D(txt.tx * cfg.XMetric, txt.ty * cfg.YMetric, txt.tz);
                        if (bIsLabel && bIsModel)
                        {
                            str1 = txt.tg;
                            //Display an Elevation
                            //TO DO:
                            this.m_app.ActiveDocument.DrawText(ptEnd, str1, dTextHeight);
                            aPoint = this.m_app.ActiveDocument.DrawPoint(ptEnd);
                        }
                    }
                    else if (labtype.attr == CLabtype.Type.EndCode)
                    {
                        if ((iSelectedLineType == 4) && (bIsLabel && bIsModel))
                        {
                            if ((System.Math.Abs(ptEnd.X - ptFirst3dFac.X) > 0.00001) || (System.Math.Abs(ptEnd.Y - ptFirst3dFac.Y) > 0.00001))
                            {
                                if (NumPts < 4)
                                {
                                    pFArray.Add(ptFirst3dFac);   //close the face
                                }
                            }

                            if (pFArray.Count > 3)
                            {
                                IHd3DFace face3d = this.m_app.ActiveDocument.Draw3DFace(pFArray[0], pFArray[1], pFArray[2], pFArray[3]);
                                face3d.Update();
                            }
                            pFArray.Clear();
                        }
                        NumPts = 0;
                    }
                    int iCurProgressInPercent = (int)(((double)br.BaseStream.Position / (double)br.BaseStream.Length) * 100.00);

                    SetProgressBarValue(iCurProgressInPercent);
                    Thread.Sleep(0);
                }
                //br.Close();
            }
        }