示例#1
0
        void LoadFileThreadProc()
        {
            BinaryReader filehandle = new BinaryReader(new FileStream(Path.Combine(this.App.AppDataPath, "MODEL.FIL"), FileMode.Open, FileAccess.Read), Encoding.Default);

            SetProgressBarMaxValue(100);
            string strModelName = string.Empty;
            //string stgLabel = string.Empty;
            string stgLabelLast = string.Empty;

            while ((filehandle.BaseStream.Position < filehandle.BaseStream.Length) && (bKeepLoadFileThreadRunning == true))
            {
                CLabtype lab = CLabtype.FromStream(filehandle);
                if (lab.attr == CLabtype.Type.Model)
                {
                    strModelName = ((CModType)lab.Tag).Name.ToLower().Trim();
                }
                else if (lab.attr == CLabtype.Type.String)
                {
                    stgLabelLast = ((CStgType)lab.Tag).label.ToLower().Trim();
                }
                else
                {
                    if (strModelName == "animation" && stgLabelLast.IndexOf('#') == -1)
                    {
                        List <CLabtype> listlbs = null;
                        if (hashLabels.ContainsKey(stgLabelLast) == false)
                        {
                            listlbs = new List <CLabtype>();
                            hashLabels.Add(stgLabelLast, listlbs);
                        }
                        else
                        {
                            listlbs = (List <CLabtype>)hashLabels[stgLabelLast];
                        }
                        listlbs.Add(lab);
                    }
                }

                int iCurProgressInPercent = (int)(((double)filehandle.BaseStream.Position / (double)filehandle.BaseStream.Length) * 100.00);
                SetProgressBarValue(iCurProgressInPercent);
                System.Threading.Thread.Sleep(0);
            }

            if (hashLabels.Count == 0)
            {
                MessageBox.Show("Model 'ANIMATION' is not found in model file"
                                , HeadsFunctions1.Properties.Resources.ST_ERROR_MSGBOX_CAPTION
                                , System.Windows.Forms.MessageBoxButtons.OK
                                , System.Windows.Forms.MessageBoxIcon.Error);

                this.CloseFrom();
            }
            else
            {
                this.SetProgressBarValue(100);
                this.ShowPlayerCtrls(true);

                this.ShowFirstItem();

                this.App.ZoomExtents();

                this.EnableCtrl(this.buttonStop_, false);
            }
            bKeepLoadFileThreadRunning = false;
        }
示例#2
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();
            }
        }