示例#1
0
        private void FillLabel(string strModelName)
        {
            List <string>   listLabels    = new List <string>();
            List <ClSTtype> listmodeldata = new List <ClSTtype>();

            ViewerUtils.ReadModelLstFile(m_strpathlistfile, ref listmodeldata);

            foreach (ClSTtype data in listmodeldata)
            {
                if (data.strMod1.Trim() == strModelName.Trim())
                {
                    listLabels.Add(data.strStg);
                }
            }
            this.lbStringLebels_.Items.Clear();
            foreach (string strLabel in listLabels)
            {
                if (strLabel.Trim() != "")
                {
                    if (this.lbStringLebels_.Items.Contains(strLabel) == false)
                    {
                        this.lbStringLebels_.Items.Add(strLabel);
                    }
                }
            }
        }
示例#2
0
 public void ToStream(System.IO.BinaryWriter bw)
 {
     bw.Write(this.Code);
     bw.Write(this.AcceptCode);
     bw.Write(ViewerUtils.ConvertStringToByteArray(this.ModelName, 30));
     bw.Write(ViewerUtils.ConvertStringToByteArray(this.StringName, 20));
 }
示例#3
0
        private void FillModels()
        {
            List <string>   listmodels    = new List <string>();
            List <ClSTtype> listmodeldata = new List <ClSTtype>();

            ViewerUtils.ReadModelLstFile(m_strpathlistfile, ref listmodeldata);

            foreach (ClSTtype data in listmodeldata)
            {
                if (listmodels.Contains(data.strMod1) == false)
                {
                    listmodels.Add(data.strMod1);
                }
            }
            foreach (string strModel in listmodels)
            {
                if (this.cbModelName_.Items.Contains(strModel) == false)
                {
                    this.cbModelName_.Items.Add(strModel);
                }
            }

            if (this.cbModelName_.Items.Count > 0)
            {
                this.cbModelName_.SelectedIndex = 0;
            }
        }
示例#4
0
        //const double r9 = 57.29577951;
        public bool WriteHIPFile(string strPath, CHalFile filedata)
        {
            bool         bSuccess = false;
            BinaryWriter bw       = new BinaryWriter(new FileStream(strPath, FileMode.Create), Encoding.Default);

            if (bw != null)
            {
                short sTotalHips = (short)filedata.ListHip.Count;
                bw.Write(filedata.Code);                                                  //Line code
                bw.Write(filedata.AcceptCode);                                            //Accept code
                bw.Write(ViewerUtils.ConvertStringToByteArray(filedata.ModelName, 30));   //Model name
                bw.Write(ViewerUtils.ConvertStringToByteArray(filedata.StringLevel, 20)); //String level

                bw.Write(sTotalHips);                                                     //Total HIPs
                bw.Write(filedata.StartChainage);                                         //Start Chain
                bw.Write(filedata.ChainageInterval);                                      //Chainage Interval

                for (short iIndex = 0; iIndex < sTotalHips; iIndex++)
                {
                    CHHipData hhipObj = filedata.ListHip[iIndex];

                    short sTotalHIP = (short)(iIndex + 1);
                    bw.Write(sTotalHIP);//Hip no
                    bw.Write(hhipObj.xvalue);
                    bw.Write(hhipObj.yvalue);
                    bw.Write(hhipObj.radius);
                    bw.Write(hhipObj.leadtrans);
                    bw.Write(hhipObj.trailtrans);
                }
                bw.Close();
                bSuccess = true;
            }
            return(bSuccess);
        }
示例#5
0
        void SaveAndFinish()
        {
            CHalignElementUtil.SaveHalign(this.m_app.AppDataPath);

            // delete halign.tmp
            ViewerUtils.DeleteFileIfExists(System.IO.Path.Combine(this.m_app.AppDataPath, "halign.tmp"));
            ViewerUtils.RenameFile(System.IO.Path.Combine(this.m_app.AppDataPath, "~halign.fil"), "~*halign.fil");
        }
示例#6
0
        private void btnFinish__Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;

            CValignUtil.SaveValign(this.app.AppDataPath);

            ViewerUtils.DeleteFileIfExists(Path.Combine(this.app.AppDataPath, "VALIGN.TMP"));
            this.Close();
        }
示例#7
0
        public string StringName; //[20];

        public static FirstLine FromStream(System.IO.BinaryReader br)
        {
            FirstLine data = new FirstLine();

            data.Code       = br.ReadInt16();
            data.AcceptCode = br.ReadInt16();
            data.ModelName  = ViewerUtils.ConvertCharArrayToString(br.ReadBytes(30));
            data.StringName = ViewerUtils.ConvertCharArrayToString(br.ReadBytes(20));

            return(data);
        }
示例#8
0
        private void btnOk__Click(object sender, EventArgs e)
        {
            if (ValidateData())
            {
                CBox boundbox = this.hdapp.ActiveDocument.BoundingBox;
                if (boundbox != null)
                {
                    //Delete the existing
                    //ViewerUtils.DeleteEntitiesByLabel(this.hdapp.ActiveDocument, HeadsUtils.Constants.LABEL_DETAILS, false);

                    HeadsUtils.Detail Det = new Detail();
                    double            z   = 0.0;
                    Det.XMin       = boundbox.TopLeft.X;
                    Det.YMin       = boundbox.TopLeft.Y;
                    z              = boundbox.TopLeft.Z;
                    Det.ModelName  = this.SelectedModelName;
                    Det.StringName = this.SelectedStringLabel;
                    Det.TextSize   = this.tbTextSize_.Value;
                    Det.Rotation   = 0;
                    //For Halign Details1 to Details2
                    //For Valign Details2 to Details1
                    //string strFileName = (this.IsValign == false) ? "DETAILS1.TMP" : "DETAILS2.TMP";
                    string       PathName = Path.Combine(this.hdapp.AppDataPath, "DETAILS1.TMP");
                    BinaryWriter bw       = new BinaryWriter(new FileStream(PathName, FileMode.Create), Encoding.Default);
                    Det.ToStream(bw);
                    bw.Close();

                    string strDetailsOutFile = Path.Combine(this.hdapp.AppDataPath, "DETAILS2.TMP");
                    ViewerUtils.DeleteFileIfExists(strDetailsOutFile);

                    if (this.IsValign == false)
                    {
                        CDetailsHalignUtil util = new CDetailsHalignUtil();
                        util.Funcmain(this.hdapp.AppDataPath);
                    }
                    else
                    {
                        CDetailsValignUtil util = new CDetailsValignUtil();
                        util.Funcmain(this.hdapp.AppDataPath, this.hdapp.ActiveDocument.ConfigParam);
                    }

                    if (File.Exists(strDetailsOutFile))
                    {
                        DrawingUtil.DrawDrg(this.hdapp, strDetailsOutFile, HeadsUtils.Constants.LABEL_DETAILS, true);
                        this.hdapp.ActiveDocument.RefreshDocument();
                    }
                }

                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }
示例#9
0
        private void btnOk__Click(object sender, EventArgs e)
        {
            if (this.ValidateData())
            {
                //string PathName;
                Grid Grd = new Grid();
                //CCfgtype cfg;

                CBox box = this.headsApp.ActiveDocument.BoundingBox;
                if (box != null)
                {
                    //Delete Existing
                    ViewerUtils.DeleteEntitiesByLabel(this.headsApp.ActiveDocument, HeadsUtils.Constants.LABEL_GRID, false);

                    double[] xy = new double[] { box.BottomRight.X, box.BottomRight.Y, box.TopLeft.X, box.TopLeft.Y };

                    Grd.ModelName  = "$$$$$$$$";
                    Grd.StringName = "****";
                    Grd.MinX       = xy[0];
                    Grd.MinY       = xy[1];
                    Grd.MaxX       = xy[2];
                    Grd.MaxY       = xy[3];

                    Grd.XInterval = this.tbXInterval_.Value;
                    Grd.YInterval = this.tbYInterval_.Value;
                    Grd.Rotation  = 0;
                    Grd.TextSize  = this.tbTextSize_.Value;

                    string FileName = Path.Combine(this.headsApp.AppDataPath, "GRID1.TMP");

                    BinaryWriter bw = new BinaryWriter(new FileStream(FileName, FileMode.Create), Encoding.Default);
                    Grd.ToStream(bw);
                    bw.Close();

                    FileName = Path.Combine(this.headsApp.AppDataPath, "GRID2.TMP");

                    ViewerUtils.DeleteFileIfExists(FileName);

                    CCoordinatesUtil util = new CCoordinatesUtil();
                    util.Funcmain(this.headsApp.AppDataPath);

                    DrawingUtil.DrawChainage(this.headsApp, FileName, HeadsUtils.Constants.LABEL_GRID, true);

                    this.headsApp.ActiveDocument.RefreshDocument();
                }
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }
示例#10
0
        public bool ReadModelsFromFile()
        {
            string filePath = fPath;
            bool   success  = false;

            if (File.Exists(filePath))
            {
                filePath = Path.GetDirectoryName(filePath);
            }
            BinaryReader br;
            long         len = 1;

            filePath = Path.Combine(filePath, "model.lst");
            //LstModel.Clear();

            if (File.Exists(filePath) == false)
            {
                return(false);
            }

            br = new BinaryReader(new FileStream(filePath, FileMode.Open, FileAccess.Read), Encoding.Default);
            try
            {
                LstModel = new List <CModel>();
                len      = br.BaseStream.Length;
                CModel cm;
                while (br.BaseStream.Position < len)
                {
                    cm            = new CModel();
                    cm.ModelName  = ViewerUtils.ConvertCharArrayToString(br.ReadBytes(30));
                    cm.StringName = ViewerUtils.ConvertCharArrayToString(br.ReadBytes(20));

                    if (cm.ModelName != "")
                    {
                        LstModel.Add(cm);
                    }
                }
                success = true;
            }
            catch (Exception exx)
            {
                success = false;
            }
            finally
            {
                br.Close();
            }
            return(success);
        }
示例#11
0
        void ApplyValign()
        {
            if (this.ValidateData())
            {
                this.app.ActiveDocument.ConfigParam.XMetric = 1;
                this.app.ActiveDocument.ConfigParam.YMetric = 10;
                CCfgtype cfg = new CCfgtype();
                this.app.ActiveDocument.ConfigParam.CopyTo(cfg);

                IHdEntity entity = this.app.ActiveDocument.GetObjectById(this.LastAppliedPolyLineID);
                if (entity != null)
                {
                    entity.Erase();
                }

                //Erase the selected polyline on screen
                //this is because user may modify the X, Y
                //co-ordinates using this dialog
                entity = this.app.ActiveDocument.GetObjectById(this.MainPolyLineID);
                if (entity != null)
                {
                    entity.Erase();
                }

                List <VVIP>     listParams = GetParamData();
                List <CPoint3D> polypts    = new List <CPoint3D>();

                foreach (VVIP vdata in listParams)
                {
                    polypts.Add(new CPoint3D(vdata.chainx * cfg.XMetric, vdata.chainy * cfg.YMetric, 0));
                }

                this.MainPolyLineID = this.app.ActiveDocument.DrawPolyline3D(polypts).ObjectID;

                this.WriteDataFile();

                ViewerUtils.DeleteFileIfExists(Path.Combine(this.app.AppDataPath, "VAL2.TMP"));

                CValignUtil util = new CValignUtil();
                if (util.Funcmain(this.app.AppDataPath))
                {
                    DrawingUtil.DrawData(this.app, Path.Combine(this.app.AppDataPath, "VAL2.TMP"), "PVR", true);
                }

                this.app.ActiveDocument.RefreshDocument();
            }
        }
示例#12
0
        private void btnOk__Click(object sender, EventArgs e)
        {
            if (ValidateData())
            {
                CBox boundbox = this.hdapp.ActiveDocument.BoundingBox;
                if (boundbox != null)
                {
                    //Delete the existing
                    //ViewerUtils.DeleteEntitiesByLabel(this.hdapp.ActiveDocument, HeadsUtils.Constants.LABEL_CHAINAGE, false);

                    //CCfgtype cfg = this.hdapp.ConfigParam;
                    HeadsUtils.Chainage Chng = new HeadsUtils.Chainage();
                    double z = 0.0;
                    Chng.XMin             = boundbox.TopLeft.X;
                    Chng.YMin             = boundbox.TopLeft.Y;
                    z                     = boundbox.TopLeft.Z;
                    Chng.ModelName        = this.SelectedModelName;
                    Chng.StringName       = this.SelectedStringLabel;
                    Chng.TextSize         = this.tbTextSize_.Value;
                    Chng.ChainageInterval = this.tbChainageInterval_.Value;
                    Chng.Rotation         = 0;

                    BinaryWriter bw = new BinaryWriter(new FileStream(Path.Combine(this.hdapp.AppDataPath, "CHAIN1.TMP"), FileMode.Create), Encoding.Default);
                    bw.Write(ViewerUtils.ConvertStringToByteArray(Chng.ModelName, 30));
                    bw.Write(ViewerUtils.ConvertStringToByteArray(Chng.StringName, 20));
                    bw.Write(Chng.XMin);
                    bw.Write(Chng.YMin);
                    bw.Write(Chng.ChainageInterval);
                    bw.Write(Chng.TextSize);
                    bw.Write(Chng.Rotation);
                    bw.Close();

                    ViewerUtils.DeleteFileIfExists(Path.Combine(this.hdapp.AppDataPath, "CHAIN2.TMP"));

                    CChainageUtil util = new CChainageUtil();
                    util.Funcmain(this.hdapp.AppDataPath);

                    DrawingUtil.DrawChainage(this.hdapp, Path.Combine(this.hdapp.AppDataPath, "CHAIN2.TMP"), "CHAIN", true);

                    this.hdapp.ActiveDocument.RefreshDocument();
                }

                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }
示例#13
0
        private void btnApply__Click(object sender, EventArgs e)
        {
            WriteDataToFileOFF();

            if (File.Exists(Path.Combine(this.app.AppDataPath, "OFF1.TMP")) == true)
            {
                ViewerUtils.DeleteFileIfExists(Path.Combine(this.app.AppDataPath, "OFF2.TMP"));

                COffsetUtil util = new COffsetUtil();
                util.Funcmain(this.app.AppDataPath);

                if (File.Exists(Path.Combine(this.app.AppDataPath, "OFF2.TMP")))
                {
                    DrawingUtil.DrawData(this.app, Path.Combine(this.app.AppDataPath, "OFF2.TMP"), "PVR", true);
                    this.app.ActiveDocument.RefreshDocument();
                }
            }
        }
示例#14
0
        public void AcceptLayout(IHeadsApplication app)
        {
            if (this.LastAppliedLayout != null && this.LastAppliedLayoutID != 0)
            {
                IHdEntity entity = app.ActiveDocument.GetObjectById(this.LastAppliedLayoutID);
                if (entity != null && entity.EntityName == "POLYLINE3D")
                {
                    IHdPolyline3D polyline = (IHdPolyline3D)entity;
                    CPoint3D[]    cords    = polyline.Coordinates;
                    CPoint3D      pt1      = null;
                    CPoint3D      pt2      = null;

                    if (cords.Length > 7)
                    {
                        pt1 = cords[0];
                        pt2 = cords[1];
                        this.LastAppliedLayout.angle = ViewerUtils.GetAngle(pt1, pt2, false);
                        pt1 = cords[5];
                        this.LastAppliedLayout.startX = pt1.X;
                        this.LastAppliedLayout.startY = pt1.Y;

                        StreamWriter sw      = new StreamWriter(Path.Combine(app.AppDataPath, "Layout.fil"), true);
                        string       strTemp = string.Format("{0:f3} {1:f3} {2:f3} {3:f3} {4:f3} {5:f3} {6:f3} {7:f3} {8:f3} {9:f3} "
                                                             , this.LastAppliedLayout.startX
                                                             , this.LastAppliedLayout.startY
                                                             , this.LastAppliedLayout.angle
                                                             , this.LastAppliedLayout.sheetWidth
                                                             , this.LastAppliedLayout.sheetLength
                                                             , this.LastAppliedLayout.layOutScale
                                                             , this.LastAppliedLayout.bottomM
                                                             , this.LastAppliedLayout.rightM
                                                             , this.LastAppliedLayout.topM
                                                             , this.LastAppliedLayout.leftM);
                        sw.WriteLine(strTemp);
                        sw.Close();
                    }
                }

                //this.LastAppliedLayout = null;
                this.LastAppliedLayoutID = 0;
            }
        }
示例#15
0
        private void ShowDetails(bool bShow)
        {
            string strHipLabel = HeadsUtils.Constants.LABEL_DETAILS + ":HIP";

            ViewerUtils.DeleteEntitiesByLabel(this.m_app.ActiveDocument, strHipLabel, true);
            if (bShow)
            {
                double dTextHeight = 5.0;
                double dZVal       = 5.0;
                double dYPos       = 0;
                double dXPos       = 0;
                for (int iCnt = 0; iCnt < this.dtParams.Rows.Count; iCnt++)
                {
                    CHHipData hipdata = this.GetRow(iCnt);

                    dYPos = hipdata.yvalue - (dTextHeight * 1.5);
                    dXPos = hipdata.xvalue + 2.5;

                    string   strLine = "IP# " + iCnt.ToString();
                    CPoint3D pt      = new CPoint3D(dXPos, dYPos, dZVal);
                    IHdText  textObj = this.m_app.ActiveDocument.DrawText(pt, strLine, dTextHeight);
                    textObj.Label = strHipLabel;

                    dYPos = dYPos - (dTextHeight * 1.5);

                    strLine       = "X : " + hipdata.xvalue.ToString("0.000");
                    pt            = new CPoint3D(dXPos, dYPos, dZVal);
                    textObj       = this.m_app.ActiveDocument.DrawText(pt, strLine, dTextHeight);
                    textObj.Label = strHipLabel;

                    dYPos = dYPos - (dTextHeight * 1.5);

                    strLine       = "Y : " + hipdata.yvalue.ToString("0.000");
                    pt            = new CPoint3D(dXPos, dYPos, dZVal);
                    textObj       = this.m_app.ActiveDocument.DrawText(pt, strLine, dTextHeight);
                    textObj.Label = strHipLabel;
                }
            }

            this.m_app.ActiveDocument.RefreshDocument();
        }
示例#16
0
        void Cancel()
        {
            int loop = nTotED;

            while (loop > 0)
            {
                loop--;
                IHdEntity entity = this.m_app.ActiveDocument.GetObjectById(carED[loop].npLineID);
                if (entity != null)
                {
                    entity.Erase();
                }
            }
            // delete halign.tmp
            ViewerUtils.DeleteFileIfExists(Path.Combine(this.m_app.AppDataPath, "halign.tmp"));
            if (System.IO.File.Exists(Path.Combine(this.m_app.AppDataPath, "~halign.fil")))
            {
                // delete truncated halign.fil
                ViewerUtils.DeleteFileIfExists(Path.Combine(this.m_app.AppDataPath, "halign.fil"));

                ViewerUtils.RenameFile(Path.Combine(this.m_app.AppDataPath, "~halign.fil"), "halign.fil");
            }
        }
示例#17
0
        void read_input()
        {
            //IN_flag = 0;

            pathfile = Path.Combine(path, "chain1.tmp");

            if (File.Exists(pathfile) == false)
            {
                textstring = "File %s not found..." + pathfile;
                error_msg();
            }
            else
            {
                HeadsUtils.Chainage chain = new HeadsUtils.Chainage();

                fp1 = new BinaryReader(new FileStream(pathfile, FileMode.Open, FileAccess.Read), Encoding.Default);

                chain.ModelName        = ViewerUtils.ConvertCharArrayToString(fp1.ReadBytes(30));
                chain.StringName       = ViewerUtils.ConvertCharArrayToString(fp1.ReadBytes(20));
                chain.XMin             = fp1.ReadDouble();
                chain.YMin             = fp1.ReadDouble();
                chain.ChainageInterval = fp1.ReadDouble();
                chain.TextSize         = fp1.ReadDouble();
                chain.Rotation         = fp1.ReadDouble();

                model  = chain.ModelName;
                stglbl = chain.StringName;

                inc      = chain.ChainageInterval;
                textsize = chain.TextSize;
                rotn     = chain.Rotation;
                XMIN     = chain.XMin;
                YMIN     = chain.YMin;

                fp1.Close();
            }
        }
示例#18
0
        public bool ReadHIPFile(string strPath, out CHalFile filedata)
        {
            bool bSuccess = false;

            filedata = new CHalFile();
            BinaryReader br = new BinaryReader(new FileStream(strPath, FileMode.Open, FileAccess.Read), Encoding.Default);

            if (br != null)
            {
                filedata.Code        = br.ReadInt16();                                         //Line code
                filedata.AcceptCode  = br.ReadInt16();                                         //Accept code
                filedata.ModelName   = ViewerUtils.ConvertCharArrayToString(br.ReadBytes(30)); //Model name
                filedata.StringLevel = ViewerUtils.ConvertCharArrayToString(br.ReadBytes(20)); //String level

                short sTotalHIP = br.ReadInt16();                                              //Total HIPs
                filedata.StartChainage    = br.ReadDouble();                                   //Start Chain
                filedata.ChainageInterval = br.ReadDouble();                                   //Chainage Interval

                for (short sCnt = 0; sCnt < sTotalHIP; sCnt++)
                {
                    CHHipData hhipObj = new CHHipData();
                    short     iHipNo  = br.ReadInt16();
                    hhipObj.xvalue     = br.ReadDouble();
                    hhipObj.yvalue     = br.ReadDouble();
                    hhipObj.radius     = br.ReadDouble();
                    hhipObj.leadtrans  = br.ReadDouble();
                    hhipObj.trailtrans = br.ReadDouble();

                    filedata.ListHip.Add(hhipObj);
                }

                br.Close();
                bSuccess = true;
            }
            return(bSuccess);
        }
示例#19
0
        private void FormHipMethod_FormClosed(object sender, FormClosedEventArgs e)
        {
            string strHalignTmpFilePath = Path.Combine(this.m_app.AppDataPath, "halign.tmp");

            ViewerUtils.DeleteFileIfExists(strHalignTmpFilePath);
        }
示例#20
0
        private void ApplyHIP()
        {
            this.m_app.ActiveDocument.ConfigParam.XMetric = 1;
            this.m_app.ActiveDocument.ConfigParam.YMetric = 1;

            //Delete existing hip line
            IHdEntity entity = this.m_app.ActiveDocument.GetObjectById(this.m_iLastAppliedPolyLine);

            if (entity != null)
            {
                entity.Erase();
            }

            //Erase the selected polyline on screen
            //this is because user may modify the X, Y
            //co-ordinates using this dialog
            entity = this.m_app.ActiveDocument.GetObjectById(this.m_iMainPolyLine);
            if (entity != null)
            {
                List <CHHipData> listLinedata = new List <CHHipData>();
                GetPolylineDetails((IHdPolyline3D)entity, ref listLinedata);
                int temCount = this.dtParams.Rows.Count;
                for (int iCnt = 0; iCnt < temCount; iCnt++)
                {
                    CHHipData hdata = listLinedata[iCnt];

                    this.dtParams.Rows[iCnt][FormHipMethod.ColNameXValue] = hdata.xvalue;
                    this.dtParams.Rows[iCnt][FormHipMethod.ColNameYValue] = hdata.yvalue;
                }
                UpdateDeltaValue();

                entity.Erase();
            }
            //Redraw the polyline
            List <CPoint3D> listPt = new List <CPoint3D>();

            for (int iCnt = 0; iCnt < this.dtParams.Rows.Count; iCnt++)
            {
                CHHipData data = this.GetRow(iCnt);
                listPt.Add(new CPoint3D(data.xvalue, data.yvalue, 0));
            }
            this.m_iMainPolyLine = this.m_app.ActiveDocument.DrawPolyline3D(listPt).ObjectID;


            //Refresh the document
            this.m_app.ActiveDocument.RefreshDocument();


            List <CHHipData> listHips = new List <CHHipData>();

            for (int iCnt = 0; iCnt < this.dtParams.Rows.Count; iCnt++)
            {
                listHips.Add(this.GetRow(iCnt));
            }

            CHalFile filedata = new CHalFile();

            filedata.Code             = 1;
            filedata.AcceptCode       = 0;
            filedata.ModelName        = this.txtModelName_.Text.Trim();
            filedata.StringLevel      = this.txtStringlabel_.Text.Trim();
            filedata.StartChainage    = this.txtStartInterval_.Value;
            filedata.ChainageInterval = this.txtChainageInterval_.Value;
            filedata.ListHip          = listHips;

            string         strHipFilePath = Path.Combine(m_app.AppDataPath, "HAL1.tmp");
            CHalignHipUtil util           = new CHalignHipUtil();

            if (util.WriteHIPFile(strHipFilePath, filedata))
            {
                //Delete HAL2.TEMP
                string strHAL2TmpPath = Path.Combine(m_app.AppDataPath, "HAL2.tmp");
                ViewerUtils.DeleteFileIfExists(strHAL2TmpPath);

                //try
                {
                    if (util.FuncMain(this.m_app.AppDataPath) == true)
                    {
                        this.m_iLastAppliedPolyLine = DrawingUtil.DrawData(this.m_app, strHAL2TmpPath, "PVR", true);
                        this.m_app.ActiveDocument.RefreshDocument();

                        //this.m_app.ZoomExtents();
                    }
                }
                //catch (Exception ex)
                //{
                //    MessageBox.Show(this, ex.ToString(), "ERROR!"
                //        , MessageBoxButtons.OK
                //        , MessageBoxIcon.Error);
                //    System.Diagnostics.Trace.Write(ex.ToString());
                //}
            }
            else
            {
                MessageBox.Show(this
                                , "Failed to generate HIP file"
                                , Resources.ST_ERROR_MSGBOX_CAPTION
                                , MessageBoxButtons.OK
                                , MessageBoxIcon.Error);
            }

            this.ShowDetails(checkBoxShowDetails_.Checked);
        }
示例#21
0
        public void FuncMainPostOff(string argv, string strRefMod, string strRefStr, string strOffMod, string strOffStr)
        {
            path = argv;

            this.m_RefMod = strRefMod;
            this.m_RefStr = strRefStr;
            this.m_OffMod = strOffMod;
            this.m_OffStr = strOffStr;

            pathfile        = Path.Combine(path, "MODEL.FIL");
            listmodelfilOld = new List <CLabtype>();
            listmodelfilNew = new List <CLabtype>();
            ViewerUtils.ReadModelFilFile(pathfile, ref listmodelfilOld);

            pathfile = Path.Combine(path, "OFFSET.FIL");
            if (File.Exists(pathfile) == false)
            {
                return;
            }

            fp2 = new StreamReader(pathfile);
            fp4 = new StreamWriter(Path.Combine(path, "OFFSETS.REP"), true);

            fp5 = new StreamWriter(Path.Combine(path, "OFFDAT.FIL"), true);



            header();

            write_input_rep();

            fp4.WriteLine("");

            //int fp1Pos = 0;

            while (fp2.EndOfStream == false)                      /* Input file */
            {
                string   strCurfp2Line = fp2.ReadLine();
                string[] tok           = strCurfp2Line.Split(new char[] { '\t' });
                str1 = tok[0];

                opnum = short.Parse(str1);

                if (opnum == 401)
                {
                    str1   = tok[1];
                    refmod = tok[2];
                    str2   = tok[3];
                    refstr = tok[4];
                    offind = 0;

                    chndiff      = 0;
                    last_chndiff = 0;
                    chn1         = 0;
                    //rewind(fp1);
                }
                else if (opnum == 402)
                {
                    type   = 1;
                    str1   = tok[1];
                    offmod = tok[2];
                    str2   = tok[3];
                    offstr = tok[4];

                    str1 = tok[5];
                    ch1  = double.Parse(tok[6]);
                    str2 = tok[7];
                    ch2  = double.Parse(tok[8]);

                    str1 = tok[9];
                    ho1  = double.Parse(tok[10]);
                    str2 = tok[11];
                    ho2  = double.Parse(tok[12]);

                    str1 = tok[13];
                    vo1  = double.Parse(tok[14]);
                    str2 = tok[15];
                    vo2  = double.Parse(tok[16]);

                    //fscanf(fp2,"%s %s %s %s",str1, offmod, str2, offstr);
                    //fscanf(fp2,"%s %lf %s %lf",str1, &ch1, str2, &ch2);
                    //fscanf(fp2,"%s %lf %s %lf",str1, &ho1, str2, &ho2);
                    //fscanf(fp2,"%s %lf %s %lf",str1, &vo1, str2, &vo2);

                    //rec=0;
                    //rewind(fp1);
                    if (last_offstr != offstr)
                    {
                        offind = 0;
                    }

                    /*
                     * buffer.Format("CREATING OFFSET STRING TYPE 1");
                     */
                    try
                    {
                        StreamWriter tmpFile = new StreamWriter(Path.Combine(path, "SCROLL.TMP"), true);
                        tmpFile.WriteLine("CREATING OFFSET STRING TYPE 1");
                        tmpFile.Close();
                    }
                    catch
                    {
                        msgstr = "Failed to write display file";
                        error_msg();
                        return;
                    }

                    fp4.Write(string.Format("\n  MODEL = {0}  REFERENCE-STRING LABEL = {1}\n", refmod, refstr));
                    fp4.Write(string.Format("\n  MODEL = {0}  OFFSET-STRING LABEL = {1}\n\n", offmod, offstr));
                    fp4.Write("  CHAINAGE(M)     X (M)             Y(M)            Z(M)   H-OFF(M)  V-OFF(M)\n\n");

                    //fprintf(fp4,"\n  MODEL = %s  REFERENCE-STRING LABEL = %s\n", refmod, refstr);
                    //fprintf(fp4,"\n  MODEL = %s  OFFSET-STRING LABEL = %s\n\n", offmod, offstr);
                    //fprintf(fp4, "  CHAINAGE(M)     X (M)             Y(M)            Z(M)   H-OFF(M)  V-OFF(M)\n\n");

                    fp5.Write(string.Format("{0} {1} {2} {3} CH1 {4:f3} CH2 {5:f3} HO1 {6:f3} HO2 {7:f3} VO1 {8:f3} VO2 {9:f3}\n", refmod, refstr, offmod, offstr, ch1, ch2, ho1, ho2, vo1, vo2));
                    //fprintf(fp5,"%s %s %s %s CH1 %.3f CH2 %.3f HO1 %.3f HO2 %.3f VO1 %.3f VO2 %.3f\n", refmod, refstr, offmod, offstr, ch1, ch2, ho1, ho2, vo1, vo2);

                    reference_string();

                    //if(find != 1 && label != 999)
                    //{
                    //    //fprintf(fp1,"999\n");
                    //}
                }
                else if (opnum == 403)
                {
                    type   = 2;
                    str1   = tok[1];
                    offmod = tok[2];
                    str2   = tok[3];
                    offstr = tok[4];

                    str1 = tok[5];
                    ch1  = double.Parse(tok[6]);
                    str2 = tok[7];
                    ch2  = double.Parse(tok[8]);

                    str1 = tok[9];
                    ho1  = double.Parse(tok[10]);
                    str2 = tok[11];
                    ho2  = double.Parse(tok[12]);

                    str1 = tok[13];
                    se1  = double.Parse(tok[14]);
                    str2 = tok[15];
                    se2  = double.Parse(tok[16]);


                    //fscanf(fp2,"%s %s %s %s",str1, offmod, str2, offstr);
                    //fscanf(fp2,"%s %lf %s %lf",str1, &ch1, str2, &ch2);
                    //fscanf(fp2,"%s %lf %s %lf",str1, &ho1, str2, &ho2);
                    //fscanf(fp2,"%s %lf %s %lf",str1, &se1, str2, &se2);

                    //rec=0;
                    //rewind(fp1);
                    if (last_offstr != offstr)
                    {
                        offind = 0;
                    }

                    try
                    {
                        StreamWriter tmpFile = new StreamWriter(Path.Combine(path, "SCROLL.TMP"), true);
                        tmpFile.WriteLine("CREATING OFFSET STRING TYPE 2");
                        tmpFile.Close();
                    }
                    catch
                    {
                        msgstr = "Failed to write display file";
                        error_msg();
                        return;
                    }


                    fp4.Write(string.Format("\n  MODEL = {0}  REFERENCE-STRING LABEL = {1}\n", refmod, refstr));
                    fp4.Write(string.Format("\n  MODEL = {0}  OFFSET-STRING LABEL = {1}\n", offmod, offstr));
                    fp4.Write("  CHAINAGE(M)     X (M)             Y(M)            Z(M)   H-OFF(M)  V-OFF(M)\n\n");

                    //fprintf(fp4,"\n  MODEL = %s  REFERENCE-STRING LABEL = %s\n", refmod, refstr);
                    //fprintf(fp4,"\n  MODEL = %s  OFFSET-STRING LABEL = %s\n", offmod, offstr);
                    //fprintf(fp4, "  CHAINAGE(M)     X (M)             Y(M)            Z(M)   H-OFF(M)  V-OFF(M)\n\n");

                    vo1 = Math.Abs(ho1) * se1 / 100.0;
                    vo2 = Math.Abs(ho2) * se2 / 100.0;
                    fp5.Write(string.Format("{0} {1} {2} {3} CH1 {4:f3} CH2 {5:f3} HO1 {6:f3} HO2 {7:f3} VO1 {8:f3} VO2 {9:f3}\n"
                                            , refmod, refstr, offmod, offstr, ch1, ch2, ho1, ho2, vo1, vo2));
                    //fprintf(fp5,"%s %s %s %s CH1 %.3f CH2 %.3f HO1 %.3f HO2 %.3f VO1 %.3f VO2 %.3f\n", refmod, refstr, offmod, offstr, ch1, ch2, ho1, ho2, vo1, vo2);

                    reference_string();

                    //if(find != 1 && label != 999)
                    //{
                    //    //fprintf(fp1,"999\n");
                    //}
                }
                else if (opnum == 404)
                {
                    type = 3;

                    str1   = tok[1];
                    offmod = tok[2];
                    str2   = tok[3];
                    offstr = tok[4];

                    str1 = tok[5];
                    ch1  = double.Parse(tok[6]);
                    str2 = tok[7];
                    ch2  = double.Parse(tok[8]);

                    str1 = tok[9];
                    se1  = double.Parse(tok[10]);
                    str2 = tok[11];
                    se2  = double.Parse(tok[12]);

                    //fscanf(fp2,"%s %s %s %s",str1, submod, str2, substr);
                    //fscanf(fp2,"%s %lf %s %lf",str1, &ch1, str2, &ch2);
                    //fscanf(fp2,"%s %lf %s %lf",str1, &se1, str2, &se2);

                    //rec = 0;
                    //rewind(fp1);
                    if (last_substr != substr)
                    {
                        offind = 0;
                    }

                    try
                    {
                        StreamWriter tmpFile = new StreamWriter(Path.Combine(path, "SCROLL.TMP"), true);
                        tmpFile.WriteLine("CREATING OFFSET STRING TYPE 3");
                        tmpFile.Close();
                    }
                    catch
                    {
                        msgstr = "Failed to write display file";
                        error_msg();
                        return;
                    }

                    fp4.Write(string.Format("\n  MODEL = {0}  REFERENCE-STRING LABEL = {1}\n", refmod, refstr));
                    fp4.Write(string.Format("\n  MODEL = {0}  OFFSET-STRING LABEL = {1}\n", submod, substr));
                    fp4.Write("  CHAINAGE(M)     CHAINAGE(M)      X (M)             Y(M)            Z(M)   H-OFF(M)  V-OFF(M)\n");
                    fp4.Write("  REF. STR.       SUB. STR.\n\n");

                    //fprintf(fp4,"\n  MODEL = %s  REFERENCE-STRING LABEL = %s\n", refmod, refstr);
                    //fprintf(fp4,"\n  MODEL = %s  OFFSET-STRING LABEL = %s\n", submod, substr);
                    //fprintf(fp4, "  CHAINAGE(M)     CHAINAGE(M)      X (M)             Y(M)            Z(M)   H-OFF(M)  V-OFF(M)\n");
                    //fprintf(fp4, "  REF. STR.       SUB. STR.\n\n");

                    ok2 = 0;
                    //hit = 0;
                    ss_found = 0;

                    vo1 = Math.Abs(ho1) * se1 / 100.0;
                    vo2 = Math.Abs(ho2) * se2 / 100.0;
                    fp5.Write(string.Format("{0} {1} {2} {3} CH1 {4:f3} CH2 {5:f3} HO1 {6:f3} HO2 {7:f3} VO1 {8:f3} VO2 {9:f3}\n", refmod, refstr, offmod, offstr, ch1, ch2, ho1, ho2, vo1, vo2));
                    //fprintf(fp5,"%s %s %s %s CH1 %.3f CH2 %.3f HO1 %.3f HO2 %.3f VO1 %.3f VO2 %.3f\n", refmod, refstr, offmod, offstr, ch1, ch2, ho1, ho2, vo1, vo2);


                    reference_string();

                    if (ss_found == 0)
                    {
                        fp4.Write(string.Format("Master Sub-String {0} {1} not found in {2}...!!!"
                                                , submod, substr, Path.Combine(path, "MODEL.FIL")));
                        msgstr = string.Format("Master Sub-String {0} {1} not found in {2}...!!!", submod, substr, Path.Combine(path, "MODEL.FIL"));
                        System.Windows.Forms.MessageBox.Show(msgstr, HeadsUtils.Constants.ProductName);
                        break;
                    }

                    if (find != 1 && label != CLabtype.Type.EndCode)
                    {
                        CLabtype lab = new CLabtype();
                        lab.attr = CLabtype.Type.EndCode;
                        listmodelfilOld.Add(lab);
                    }

                    last_submod = submod;
                    last_substr = substr;

                    //fclose(fp5);
                }
                else
                {
                    break;
                }

                last_offmod = offmod;
                last_offstr = offstr;
            }  /* while feof */

            footer();

            listmodelfilOld.AddRange(listmodelfilNew);
            ViewerUtils.WriteModelFilFile(Path.Combine(path, "MODEL.FIL"), listmodelfilOld);

            //fclose(fp1);
            fp2.Close();
            fp4.Close();
            fp5.Close();

            System.Windows.Forms.MessageBox.Show("Design Report is written in file OFFSETS.REP", HeadsUtils.Constants.ProductName);
        }
示例#22
0
        public static void DrawChainage(IHeadsApplication app, string szFileName, string sType, bool bEngFunc)
        {
            // 11/09/01
            Eldtype    eld     = new Eldtype();
            Linetype   line    = new Linetype();
            Boxtype    box     = new Boxtype();
            Circletype circle1 = new Circletype();
            Arctype    arc     = new Arctype();
            TEXTtype   text    = new TEXTtype();
            CCfgtype   cfg     = new CCfgtype();


            BinaryReader fhandle;                               //int fhandle;
            double       LWidthDbl = 0;                         //'/l->line
            double       BWidthDbl;                             //'/b->box
            double       AWidthDbl;                             //'/ a->text
            double       CWidthDbl;                             //'/c->circle
            //double						RotAngle = 0;

            //IHdPolyline3D		pLine;    // no plines req d deb
            //CvdSelection	MySelSet; // renentry d deb 11/09/01
            //CVdView						*drawing = NULL;	//frmDrawing drawing;
            //DrgReturn					Retval;
            //int							i = 0;
            CCfgtype tempcfg = new CCfgtype();
            long     NumPts  = 0;


            //if(!bEngFunc)
            //{
            //    CDocument* pDocument = theApp.m_pDocTemplate->CreateNewDocument();

            //    BOOL bAutoDelete = pDocument->m_bAutoDelete;
            //    pDocument->m_bAutoDelete = FALSE;   // don't destroy if something goes wrong
            //    CFrameWnd* pFrame = theApp.m_pDocTemplate->CreateNewFrame(pDocument, NULL);
            //    pDocument->m_bAutoDelete = bAutoDelete;

            //    pDocument->SetPathName(szFileName);
            //    theApp.m_pDocTemplate->InitialUpdateFrame(pFrame, pDocument, TRUE);
            //}

            //drawing = (CVdView*)GetCurrentView();

            if (File.Exists(szFileName) == false)
            {
                return;
            }
            fhandle = new BinaryReader(new FileStream(szFileName, FileMode.Open), Encoding.Default);

            //	if(bEngFunc)
            cfg = app.ActiveDocument.ConfigParam;

            while (fhandle.BaseStream.Position < fhandle.BaseStream.Length)
            {
                eld.Code = fhandle.ReadInt16();

                if (eld.Code == 99)
                {
                    if (sType == "PVR" && (!bEngFunc))
                    {
                        cfg = CCfgtype.FromStream(fhandle);
                        app.ActiveDocument.ConfigParam = cfg;
                    }
                    else
                    {
                        tempcfg = CCfgtype.FromStream(fhandle);
                    }
                    //RotAngle = 0;
                    NumPts = 0;
                }
                else if (eld.Code == 1) // line
                {
                    line = Linetype.FromStream(fhandle);

                    XlateNmat(ref line.x1, ref line.y1, cfg.XMetric, cfg.YMetric);
                    XlateNmat(ref line.x2, ref line.y2, cfg.XMetric, cfg.YMetric);


                    LWidthDbl = (double)(line.width);                   //Convert to double
                    NumPts    = NumPts + 1;

                    if (line.scatt == 1)
                    {
                        IHdLine Entity = app.ActiveDocument.DrawLine(new CPoint3D(line.x1, line.y1, line.z1), new CPoint3D(line.x2, line.y2, line.z2));

                        if (Entity != null)
                        {
                            if (!bEngFunc)
                            {
                                string layerName = line.layer;
                                DrawingUtil.SetLayerToEntity(bEngFunc, Entity, app.ActiveDocument, layerName);

                                //Entity.SetPenStyle(line.style);
                                //Entity.SetPenWidth(LWidthDbl);
                            }
                        }

                        Entity.Label = sType;
                    }
                }
                else if (eld.Code == 2)
                {
                    box = Boxtype.FromStream(fhandle);

                    box.style = (short)(box.style - 1);

                    XlateNmat(ref box.x1, ref box.y1, cfg.XMetric, cfg.YMetric);
                    XlateNmat(ref box.x2, ref box.y2, cfg.XMetric, cfg.YMetric);

                    BWidthDbl = (double)(box.Width);

                    if (box.scatt == 1)
                    {
                        IHdPolyline3D polyRect = DrawingUtil.DrawRect(app.ActiveDocument
                                                                      , new CPoint3D(box.x1, box.y1, 0)
                                                                      , new CPoint3D(box.x2, box.y2, 0));

                        DrawingUtil.SetLayerToEntity(bEngFunc, polyRect, app.ActiveDocument, box.Layer);

                        polyRect.Label = sType;
                    }
                }
                else if (eld.Code == 3)
                {
                    circle1 = Circletype.FromStream(fhandle);

                    circle1.style = (short)(circle1.style - 1);
                    XlateNmat(ref circle1.xc, ref circle1.yc, cfg.XMetric, cfg.YMetric);

                    CWidthDbl = (double)(circle1.Width);

                    if (circle1.scatt == 1)
                    {
                        IHdEllipse hdellipse = app.ActiveDocument.DrawEllipse(new CPoint3D(circle1.xc, circle1.yc, 0), circle1.Radius);
                        DrawingUtil.SetLayerToEntity(bEngFunc, hdellipse, app.ActiveDocument, circle1.Layer);

                        hdellipse.Label = sType;
                    }
                }
                else if (eld.Code == 4)
                {
                    arc = Arctype.FromStream(fhandle);

                    arc.style = (short)(arc.style - 1);

                    XlateNmat(ref arc.xc, ref arc.yc, cfg.XMetric, cfg.YMetric);
                    XlateNmat(ref arc.xs, ref arc.ys, cfg.XMetric, cfg.YMetric);
                    XlateNmat(ref arc.xe, ref arc.ye, cfg.XMetric, cfg.YMetric);

                    AWidthDbl = (double)(arc.Width);

                    if (arc.scatt != 0)
                    {
                        IHdArc hdarc = DrawingUtil.DrawArc(app.ActiveDocument, arc.xs, arc.ys, arc.xe, arc.ye, arc.xc, arc.yc, arc.Radius);
                        DrawingUtil.SetLayerToEntity(bEngFunc, hdarc, app.ActiveDocument, arc.Layer);

                        hdarc.Label = sType;
                    }
                }
                else if (eld.Code == 9)
                {
                    text = TEXTtype.FromStream(fhandle);

                    text.style = (short)(text.style - 1);

                    XlateNmat(ref text.x1, ref text.y1, cfg.XMetric, cfg.YMetric);

                    if (text.scatt != 0)
                    {
                        IHdText hdtext = app.ActiveDocument.DrawText(new CPoint3D(text.x1, text.y1, 0), text.text, text.Size);
                        DrawingUtil.SetLayerToEntity(bEngFunc, hdtext, app.ActiveDocument, text.Layer);

                        hdtext.Rotate(new CPoint3D(text.x1, text.y1, 0), ViewerUtils.DegreeToRadian(text.rotn));
                        hdtext.Label = sType;
                        //DrawText(bEngFunc, text.text, text.x1, text.y1, text.Size, text.Color, text.style, text.Label, text.Layer, text.rotn, sType);
                    }
                }
            }

            fhandle.Close();
        }
示例#23
0
        public static void ImportFromDRG(IHeadsApplication app, string strPath, string sType, bool bEngFunc)
        {
            app.ActiveDocument.DisableUndoRecording(true);

            CCfgtype     cfg     = app.ActiveDocument.ConfigParam;
            Linetype     line    = null;
            Circletype   circle1 = null;
            TEXTtype     text    = null;
            Arctype      arc     = null;
            BinaryReader br      = new BinaryReader(new FileStream(strPath, FileMode.Open, FileAccess.Read), Encoding.Default);
            Eldtype      eld     = new Eldtype();

            while (br.BaseStream.Position < br.BaseStream.Length)
            {
                eld.Code = br.ReadInt16();
                if (GetDrgEleType(eld.Code) == DrgEleType.CONFIG)
                {
                    if (sType == "PVR" && (!bEngFunc))
                    {
                        cfg = CCfgtype.FromStream(br);
                        app.ActiveDocument.ConfigParam = cfg;
                    }
                    else
                    {
                        CCfgtype tempcfg = CCfgtype.FromStream(br);
                    }
                }
                else if (GetDrgEleType(eld.Code) == DrgEleType.LINE)
                {
                    line = Linetype.FromStream(br);


                    XlateNmat(ref line.x1, ref line.y1, cfg.XMetric, cfg.YMetric);
                    XlateNmat(ref line.x2, ref line.y2, cfg.XMetric, cfg.YMetric);

                    //LWidthDbl = (double)(line.Width);			//Convert result into double :::why?
                    //NumPts = NumPts + 1;
                    if (line.scatt == 1)
                    {
                        line.style = (short)(line.style - 1);
                        IHdLine aLine = app.ActiveDocument.DrawLine(line.StartPoint, line.EndPoint);
                        aLine.ColorIndex = line.color;
                        SetLayerToEntity(bEngFunc, aLine, app.ActiveDocument, line.layer);
                    }//end if(line.scatt == 1)
                }
                else if (GetDrgEleType(eld.Code) == DrgEleType.ELLIPSE)
                {
                    circle1 = Circletype.FromStream(br);

                    circle1.style = (short)(circle1.style - 1);
                    //			circle1.Color = HeadsToVDraw(circle1.Color);
                    XlateNmat(ref circle1.xc, ref circle1.yc, cfg.XMetric, cfg.YMetric);

                    //CWidthDbl = (double)(circle1.Width);

                    if (circle1.scatt == 1)
                    {
                        IHdEllipse ellipse = app.ActiveDocument.DrawEllipse(new CPoint3D(circle1.xc, circle1.yc, 0), circle1.Radius);
                        //DrawCircle(bEngFunc, circle1.xc, circle1.yc, circle1.Radius, circle1.Color, circle1.style, CWidthDbl, circle1.Label, circle1.Layer, RotAngle, sType);

                        SetLayerToEntity(bEngFunc, ellipse, app.ActiveDocument, circle1.Layer);

                        ellipse.Label      = circle1.Label;
                        ellipse.ColorIndex = circle1.color;
                    }
                }
                else if (GetDrgEleType(eld.Code) == DrgEleType.ARC)
                {
                    arc = Arctype.FromStream(br);

                    arc.style = (short)(arc.style - 1);
                    //			arc.Color = HeadsToVDraw(arc.Color);
                    XlateNmat(ref arc.xc, ref arc.yc, cfg.XMetric, cfg.YMetric);
                    XlateNmat(ref arc.xs, ref arc.ys, cfg.XMetric, cfg.YMetric);
                    XlateNmat(ref arc.xe, ref arc.ye, cfg.XMetric, cfg.YMetric);

                    //AWidthDbl = (double)(arc.Width);
                    if (arc.scatt == 1)
                    {
                        IHdArc hdarc = DrawArc(app.ActiveDocument, arc.xs, arc.ys, arc.xe, arc.ye, arc.xc, arc.yc, arc.Radius);
                        SetLayerToEntity(bEngFunc, hdarc, app.ActiveDocument, arc.Layer);

                        hdarc.Label      = arc.Label;
                        hdarc.ColorIndex = arc.Color;
                    }
                }
                else if (GetDrgEleType(eld.Code) == DrgEleType.TEXT)
                {
                    text = TEXTtype.FromStream(br);

                    text.style = (short)(text.style - 1);

                    XlateNmat(ref text.x1, ref text.y1, cfg.XMetric, cfg.YMetric);

                    if (text.scatt != 0)
                    {
                        IHdText hdtext = app.ActiveDocument.DrawText(new CPoint3D(text.x1, text.y1, 0), text.text, text.Size);
                        DrawingUtil.SetLayerToEntity(bEngFunc, hdtext, app.ActiveDocument, text.Layer);
                        hdtext.Label = text.Label;
                        hdtext.Rotate(new CPoint3D(text.x1, text.y1, 0), ViewerUtils.DegreeToRadian(text.rotn));
                        hdtext.ColorIndex = text.Color;
                    }
                }
            }
            br.Close();

            app.ActiveDocument.DisableUndoRecording(false);
            app.ZoomExtents();
        }
示例#24
0
 public void DeleteCoordinates(IHeadsApplication app)
 {
     ViewerUtils.DeleteEntitiesByLabel(app.ActiveDocument, HeadsUtils.Constants.LABEL_GRID, false);
     app.ActiveDocument.RefreshDocument();
 }
示例#25
0
 public void DeleteDetails(IHeadsApplication app)
 {
     ViewerUtils.DeleteEntitiesByLabel(app.ActiveDocument, HeadsUtils.Constants.LABEL_DETAILS, false);
     app.ActiveDocument.RefreshDocument();
 }
示例#26
0
 public void DeleteLSecGrid(IHeadsApplication app)
 {
     ViewerUtils.DeleteEntitiesByLabel(app.ActiveDocument, HeadsUtils.Constants.LABEL_GRID + ":LSec", true);
     app.ActiveDocument.RefreshDocument();
 }
示例#27
0
        private bool hip_method()
        {
            bool bSuccess = true;

            fp1 = new BinaryReader(new FileStream(Path.Combine(this.m_strWorkingDirPath, "HAL1.tmp"), FileMode.Open, FileAccess.Read), Encoding.Default);

            CHalFile filedata = new CHalFile();

            filedata.Code        = fp1.ReadInt16();                                         //Line code
            filedata.AcceptCode  = fp1.ReadInt16();                                         //Accept code
            filedata.ModelName   = ViewerUtils.ConvertCharArrayToString(fp1.ReadBytes(30)); //Model name
            filedata.StringLevel = ViewerUtils.ConvertCharArrayToString(fp1.ReadBytes(20)); //String level
            short sTotalHIP = fp1.ReadInt16();                                              //Total HIPs

            filedata.StartChainage    = fp1.ReadDouble();                                   //Start Chain
            filedata.ChainageInterval = fp1.ReadDouble();                                   //Chainage Interval



            modnam = filedata.ModelName;
            stglbl = filedata.StringLevel;
            hips   = sTotalHIP;
            chn1   = filedata.StartChainage;
            inc    = filedata.ChainageInterval;
            ptsc   = 0;
            pts    = 0;

            fpm = new StreamWriter(Path.Combine(this.m_strWorkingDirPath, "ERRORMESSAGES.TXT"), true);
            fpm.WriteLine();
            fpm.WriteLine("    *************************************************");
            fpm.WriteLine("    Program [HEADS:Design:HALIGNMENT] was run on : " + DateTime.Now.ToString());

            for (ip = 0; ip < hips - 2; ip++)
            {
                hip_input();

                bearings();

                deflection();

                tangent_points();

                if (error_flag != 0)
                {
                    break;
                }

                if (lt1 > 0)
                {
                    elno++;
                    eltype = 1;
                    //chn1 = chn1;
                    hipx = x2;
                    hipy = y2;
                    l    = lt1;

                    if (ip == 0)
                    {
                        xs = x1;
                        ys = y1;
                    }
                    else
                    {
                        xs = xe;
                        ys = ye;
                    }
                    b1 = B1;

                    element();
                }

                if (ls1 > 0)
                {
                    elno++;
                    eltype = 2;
                    chn1   = chn2;
                    hipx   = x2;
                    hipy   = y2;
                    l      = ls1;
                    xs     = xe; ys = ye;
                    b1     = b2;

                    element();
                }


                if (lc > 0)
                {
                    elno++;
                    eltype = 3;
                    chn1   = chn2;
                    hipx   = x2;
                    hipy   = y2;
                    l      = lc;
                    xs     = xe; ys = ye;
                    b1     = b2;

                    element();
                }

                if (ls2 > 0)
                {
                    elno++;
                    eltype = 4;
                    chn1   = chn2;
                    hipx   = x2;
                    hipy   = y2;
                    l      = ls2;
                    xs     = xe; ys = ye;
                    b1     = b2;

                    element();
                }

                x1 = xe; y1 = ye;
                xm = x2; ym = y2;
                x2 = x3; y2 = y3;

                rad  = last_rad;
                ls1  = last_ls1;
                ls2  = last_ls2;
                turn = last_turn;

                chn1 = chn2;
                B1   = b2;
            }

            if (error_flag == 0)
            {
                if (lt2 > 0)
                {
                    elno++;
                    eltype = 1;
                    chn1   = chn2;
                    hipx   = xm;
                    hipy   = ym;
                    l      = lt2;
                    xs     = xe; ys = ye;
                    b1     = B2;

                    element();
                }
            }


            fpm.WriteLine("    *************************************************");
            fpm.Close();
            fp1.Close();

            if (error_flag == 1)
            {
                System.Windows.Forms.MessageBox.Show("Check the file ERRORMESSAGES.TXT for all the details", HeadsUtils.Constants.ProductName);
                bSuccess = false;
            }
            else
            {
                bSuccess = true;
            }

            return(bSuccess);
        }
示例#28
0
        void ApplyData()
        {
            if (this.txtModelName_.Text.Trim() == "" || this.txtStringlabel_.Text.Trim() == "")
            {
                MessageBox.Show("Input Model Name and String Level"
                                , Resources.ST_ERROR_MSGBOX_CAPTION
                                , System.Windows.Forms.MessageBoxButtons.OK
                                , System.Windows.Forms.MessageBoxIcon.Information);

                return;
            }
            else
            {
                if (this.txtModelName_.ReadOnly == false)
                {
                    string     strHalignFilFilePath = System.IO.Path.Combine(this.m_app.AppDataPath, "HALIGN.FIL");
                    CHIPInfo[] infoarr = CHalignHipUtil.ReadHaligns(strHalignFilFilePath);
                    foreach (CHIPInfo info in infoarr)
                    {
                        if (info.ModelName.Trim().ToLower() == this.txtModelName_.Text.Trim().ToLower() &&
                            info.StringLabel.Trim().ToLower() == this.txtStringlabel_.Text.Trim().ToLower())
                        {
                            MessageBox.Show("Model Name and String Level already exists\nPlease specify unique Model Name and String Level"
                                            , Resources.ST_ERROR_MSGBOX_CAPTION
                                            , System.Windows.Forms.MessageBoxButtons.OK
                                            , System.Windows.Forms.MessageBoxIcon.Information);

                            return;
                        }
                    }
                }
            }

            this.Cursor = System.Windows.Forms.Cursors.WaitCursor;
            this.btnSaveFinish_.Enabled = false;

            ViewerUtils.DeleteFileIfExists(System.IO.Path.Combine(this.m_app.AppDataPath, "halign.tmp"));

            int loop = nTotED;

            while (loop > 0)
            {
                loop--;
                //Delete existing hip line
                IHdEntity entity = this.m_app.ActiveDocument.GetObjectById(carED[loop].npLineID);
                if (entity != null)
                {
                    entity.Erase();
                }
            }
            CHalignElementUtil code = new CHalignElementUtil();

            for (loop = 0; loop < ElementNo - 1; loop++)
            {
                ViewerUtils.DeleteFileIfExists(System.IO.Path.Combine(this.m_app.AppDataPath, "HAL2.TMP"));

                code.Funcmain(this.m_app.AppDataPath, 2, 1, this.txtModelName_.Text, this.txtStringlabel_.Text
                              , (short)carED[loop].nElementNo, (short)carED[loop].nType, carED[loop].dStartChain
                              , carED[loop].dChainInterval, carED[loop].dXvalue, carED[loop].dYvalue
                              , carED[loop].dBearings, carED[loop].dLength, carED[loop].dRadius);
                this.m_iLastAppliedPolyLine = DrawingUtil.DrawData(this.m_app, System.IO.Path.Combine(this.m_app.AppDataPath, "HAL2.TMP"), "ELE", true);
                carED[loop].npLineID        = this.m_iLastAppliedPolyLine;
            } //end for

            ViewerUtils.DeleteFileIfExists(Path.Combine(this.m_app.AppDataPath, "HAL2.TMP"));

            //writes hal2.tmp, appends halign.tmp
            code.Funcmain(this.m_app.AppDataPath, 2, 1, this.txtModelName_.Text, this.txtStringlabel_.Text
                          , (short)ElementNo, this.SelectedElementType, this.txtStartInterval_.Value
                          , this.txtChainageInterval_.Value, this.txtXVal_.Value, this.txtYVal_.Value
                          , this.txtWCBearings_.Value, this.txtLength_.Value, this.txtRadius_.Value);

            this.m_iLastAppliedPolyLine = DrawingUtil.DrawData(this.m_app, Path.Combine(this.m_app.AppDataPath, "HAL2.TMP"), "ELE", true);

            GetDlgED((ElementNo - 1), (int)this.SelectedElementType, this.m_iLastAppliedPolyLine);
            nTotED = ElementNo;

            //	AcceptCode = 1;
            ElementNo                     = ElementNo + 1;
            this.StartEleNo               = ElementNo;
            this.txtXVal_.Value           = code.xe;
            this.txtYVal_.Value           = code.ye;
            this.txtWCBearings_.Value     = code.b2;
            this.txtStartInterval_.Value += this.txtLength_.Value;
            this.TotalEleDrawn            = nTotED;

            lastED.dXvalue        = code.xe;
            lastED.dYvalue        = code.ye;
            lastED.dBearings      = code.b2;
            lastED.dChainInterval = this.txtChainageInterval_.Value;
            lastED.dStartChain    = this.txtStartInterval_.Value;
            lastED.nType          = (int)this.SelectedElementType;
            lastED.dLength        = this.txtLength_.Value;
            lastED.dRadius        = this.txtRadius_.Value;
            lastED.nElementNo     = ElementNo;

            this.m_app.ActiveDocument.RefreshDocument();
            this.btnSaveFinish_.Enabled = true;
            this.Cursor = System.Windows.Forms.Cursors.Default;
        }
示例#29
0
 public void DeleteChainage(IHeadsApplication app)
 {
     ViewerUtils.DeleteEntitiesByLabel(app.ActiveDocument, HeadsUtils.Constants.LABEL_CHAINAGE, false);
     app.ActiveDocument.RefreshDocument();
 }
示例#30
0
        void FillFromExistingData(CHIPInfo info)
        {
            if (info.IsHipData == false)
            {
                ViewerUtils.DeleteFileIfExists(System.IO.Path.Combine(this.m_app.AppDataPath, "halign.tmp"));

                int nidxED = 0;

                this.txtModelName_.Text   = info.ModelName;
                this.txtStringlabel_.Text = info.StringLabel;
                for (int iCnt = 0; iCnt < info.DataList.Count; iCnt++)
                {
                    CHalignFilData fildata = info.DataList[iCnt];
                    if (carED[nidxED] == null)
                    {
                        carED[nidxED] = new CElementData();
                    }
                    carED[nidxED].dBearings      = fildata.dB1;
                    carED[nidxED].dChainInterval = 10;
                    carED[nidxED].dLength        = fildata.dEllength;
                    if (fildata.iTurn == 1)
                    {
                        fildata.dRadius = -1 * fildata.dRadius;
                    }
                    carED[nidxED].dRadius     = fildata.dRadius;
                    carED[nidxED].dStartChain = fildata.dStartchn;
                    carED[nidxED].dXvalue     = fildata.dStartx;
                    carED[nidxED].dYvalue     = fildata.dStarty;
                    carED[nidxED].nElementNo  = nidxED + 1;
                    carED[nidxED].nType       = fildata.iEltype;

                    CHalignElementUtil code = new CHalignElementUtil();

                    code.Funcmain(this.m_app.AppDataPath, 2, 1, info.ModelName, info.StringLabel
                                  , (short)(nidxED + 1), fildata.iEltype, fildata.dStartchn
                                  , 10.0, fildata.dStartx, fildata.dStarty, fildata.dB1
                                  , fildata.dEllength, fildata.dRadius);

                    carED[nidxED].npLineID = DrawingUtil.DrawData(this.m_app, System.IO.Path.Combine(this.m_app.AppDataPath, "HAL2.TMP"), "ELE", true);

                    nidxED++;

                    this.SelectedElementType        = fildata.iEltype;
                    this.txtChainageInterval_.Value = 10.0;
                    this.txtLength_.Value           = fildata.dEllength;
                    this.txtModelName_.Text         = fildata.sMod;
                    this.txtRadius_.Value           = fildata.dRadius;
                    this.txtStartInterval_.Value    = fildata.dEndchn;
                    this.txtStringlabel_.Text       = fildata.sString;
                    this.txtWCBearings_.Value       = fildata.dB2;
                    this.txtXVal_.Value             = fildata.dEndx;
                    this.txtYVal_.Value             = fildata.dEndy;
                    this.StartEleNo = nidxED + 1;
                    ElementNo       = nidxED + 1;
                    nTotED          = ElementNo - 1;
                    TotalEleDrawn   = nidxED;

                    lastED.dStartChain    = this.txtStartInterval_.Value;
                    lastED.dChainInterval = this.txtChainageInterval_.Value;
                    lastED.dXvalue        = this.txtXVal_.Value;
                    lastED.dYvalue        = this.txtYVal_.Value;
                    lastED.nType          = this.SelectedElementType;
                    lastED.dBearings      = this.txtWCBearings_.Value;
                    lastED.dLength        = this.txtLength_.Value;
                    lastED.dRadius        = this.txtRadius_.Value;
                    lastED.nElementNo     = this.StartEleNo;
                }
                this.m_app.ActiveDocument.RefreshDocument();
                this.m_app.ZoomExtents();
                //ViewerUtils.DeleteFileIfExists(this.m_app.AppDataPath + @"\~halign.fil");
            }
        }