示例#1
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);
        }
示例#2
0
        private void btnInsert__Click(object sender, EventArgs e)
        {
            //EnableHipParamButtons(false);
            if (this.dataGridParams_.SelectedRows.Count == 1)
            {
                int       iIndex   = this.dataGridParams_.SelectedRows[0].Index;
                CHHipData hhipdata = new CHHipData();
                if (iIndex == 0 || iIndex == (this.dtParams.Rows.Count - 1))
                {
                    hhipdata.radius = 0;
                }
                else
                {
                    hhipdata.radius = (double)this.dtParams.Rows[iIndex][ColNameRadius];
                }
                FormHipEdit formhipedit = new FormHipEdit(hhipdata, Resources.ST_HIP_INSERT);
                formhipedit.Owner = this;
                if (formhipedit.ShowDialog() == DialogResult.OK)
                {
                    DataRow row = dtParams.NewRow();
                    row[ColNameIndex]      = 0;
                    row[ColNameXValue]     = formhipedit.HipData.xvalue;
                    row[ColNameYValue]     = formhipedit.HipData.yvalue;
                    row[ColNameDeviation]  = formhipedit.HipData.delta;
                    row[ColNameRadius]     = formhipedit.HipData.radius;
                    row[ColNameLeadTrans]  = formhipedit.HipData.leadtrans;
                    row[ColNameTrailTrans] = formhipedit.HipData.trailtrans;

                    this.dtParams.Rows.InsertAt(row, iIndex);

                    this.UpdateIndexValue();
                    this.UpdateDeltaValue();
                }
            }
        }
示例#3
0
        CHHipData GetRow(int iIndex)
        {
            CHHipData data = new CHHipData();

            data.xvalue     = (double)this.dtParams.Rows[iIndex][FormHipMethod.ColNameXValue];
            data.yvalue     = (double)this.dtParams.Rows[iIndex][FormHipMethod.ColNameYValue];
            data.delta      = (double)this.dtParams.Rows[iIndex][FormHipMethod.ColNameDeviation];
            data.radius     = (double)this.dtParams.Rows[iIndex][FormHipMethod.ColNameRadius];
            data.leadtrans  = (double)this.dtParams.Rows[iIndex][FormHipMethod.ColNameLeadTrans];
            data.trailtrans = (double)this.dtParams.Rows[iIndex][FormHipMethod.ColNameTrailTrans];
            return(data);
        }
示例#4
0
        public FormHipEdit(CHHipData hhip, string strCaption)
        {
            InitializeComponent();
            //set the data
            this.txtXValue_.Value     = hhip.xvalue;
            this.txtYValue_.Value     = hhip.yvalue;
            this.txtRadius_.Value     = hhip.radius;
            this.txtLeadTrans_.Value  = hhip.leadtrans;
            this.txtTrailTrans_.Value = hhip.trailtrans;

            this.Text = strCaption;

            this.dInitialRadiusValue = hhip.radius;
        }
示例#5
0
        void AddRow(CHHipData data)
        {
            int rows = dtParams.Rows.Count;

            DataRow row = dtParams.NewRow();

            row[ColNameIndex]      = rows;
            row[ColNameXValue]     = data.xvalue;
            row[ColNameYValue]     = data.yvalue;
            row[ColNameDeviation]  = data.delta;
            row[ColNameRadius]     = data.radius;
            row[ColNameLeadTrans]  = data.leadtrans;
            row[ColNameTrailTrans] = data.trailtrans;

            dtParams.Rows.Add(row);
        }
示例#6
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();
        }
示例#7
0
        private int GetPolylineDetails(IHdPolyline3D polyline, ref List <CHHipData> listHhip)
        {
            int iPolyLineObjID = 0;

            listHhip.Clear();
            if (polyline != null)
            {
                //Store the main source polyline
                iPolyLineObjID = polyline.ObjectID;

                CPoint3D[] ptCords = polyline.Coordinates;
                for (int iIndex = 0; iIndex < ptCords.Length; iIndex++)
                {
                    CHHipData hhipObj = new CHHipData();
                    hhipObj.xvalue = ptCords[iIndex].X;
                    hhipObj.yvalue = ptCords[iIndex].Y;
                    listHhip.Add(hhipObj);
                }
            }

            return(iPolyLineObjID);
        }
示例#8
0
        private void btnEdit__Click(object sender, EventArgs e)
        {
            //EnableHipParamButtons(false);
            if (this.dataGridParams_.SelectedRows.Count == 1)
            {
                int         iIndex      = this.dataGridParams_.SelectedRows[0].Index;
                CHHipData   hhipdata    = this.GetRow(iIndex);
                FormHipEdit formhipedit = new FormHipEdit(hhipdata, Resources.ST_HIP_EDIT);
                formhipedit.Owner = this;
                if (formhipedit.ShowDialog() == DialogResult.OK)
                {
                    DataRow row = this.dtParams.Rows[iIndex];

                    row[ColNameXValue]     = formhipedit.HipData.xvalue;
                    row[ColNameYValue]     = formhipedit.HipData.yvalue;
                    row[ColNameDeviation]  = formhipedit.HipData.delta;
                    row[ColNameRadius]     = formhipedit.HipData.radius;
                    row[ColNameLeadTrans]  = formhipedit.HipData.leadtrans;
                    row[ColNameTrailTrans] = formhipedit.HipData.trailtrans;
                    this.UpdateDeltaValue();
                }
            }
        }
示例#9
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);
        }
示例#10
0
        private void hip_input()
        {
            CHHipData hhipObj   = null;
            short     sHipNoRaw = 0;
            short     hipno;

            if (ip == 0)
            {
                hhipObj            = new CHHipData();
                sHipNoRaw          = fp1.ReadInt16();
                hhipObj.xvalue     = fp1.ReadDouble();
                hhipObj.yvalue     = fp1.ReadDouble();
                hhipObj.radius     = fp1.ReadDouble();
                hhipObj.leadtrans  = fp1.ReadDouble();
                hhipObj.trailtrans = fp1.ReadDouble();

                hipno = sHipNoRaw;
                x1    = hhipObj.xvalue;
                y1    = hhipObj.yvalue;
                rad   = hhipObj.radius;
                ls1   = hhipObj.leadtrans;
                ls2   = hhipObj.trailtrans;

                hhipObj            = new CHHipData();
                sHipNoRaw          = fp1.ReadInt16();
                hhipObj.xvalue     = fp1.ReadDouble();
                hhipObj.yvalue     = fp1.ReadDouble();
                hhipObj.radius     = fp1.ReadDouble();
                hhipObj.leadtrans  = fp1.ReadDouble();
                hhipObj.trailtrans = fp1.ReadDouble();

                hipno = sHipNoRaw;
                x2    = hhipObj.xvalue;
                y2    = hhipObj.yvalue;
                rad   = hhipObj.radius;
                ls1   = hhipObj.leadtrans;
                ls2   = hhipObj.trailtrans;

                if (rad < 0)
                {
                    rad  = 0.0 - rad;
                    turn = 1;
                }
                else
                {
                    turn = 2;
                }
            }

            hhipObj            = new CHHipData();
            sHipNoRaw          = fp1.ReadInt16();
            hhipObj.xvalue     = fp1.ReadDouble();
            hhipObj.yvalue     = fp1.ReadDouble();
            hhipObj.radius     = fp1.ReadDouble();
            hhipObj.leadtrans  = fp1.ReadDouble();
            hhipObj.trailtrans = fp1.ReadDouble();

            hipno    = sHipNoRaw;
            x3       = hhipObj.xvalue;
            y3       = hhipObj.yvalue;
            last_rad = hhipObj.radius;
            last_ls1 = hhipObj.leadtrans;
            last_ls2 = hhipObj.trailtrans;

            if (last_rad < 0)
            {
                last_rad  = 0.0 - last_rad;
                last_turn = 1;
            }
            else
            {
                last_turn = 2;
            }
        }
示例#11
0
        public static List <CHHipData> GenerateHIPData(CHIPInfo hipinfo)
        {
            List <CHHipData> listHhip   = null;
            int            ln           = 0;
            int            iLine        = 0;
            int            iHipArrIndex = 0;
            double         nSign        = 0;
            CHalignFilData filData      = null;

            CHHipData[] hipArr = new CHHipData[hipinfo.DataList.Count];

            for (int i = 0; i < hipinfo.DataList.Count; i++)
            {
                hipArr[i] = new CHHipData();
            }

            ln++;
            filData = hipinfo.DataList[iLine]; iLine++;
            nSign   = (filData.iTurn == 1) ? -1 : 1;

            hipArr[iHipArrIndex].xvalue     = filData.dStartx;
            hipArr[iHipArrIndex].yvalue     = filData.dStarty;
            hipArr[iHipArrIndex].delta      = filData.dDeviation * nSign;
            hipArr[iHipArrIndex].radius     = 0.0;
            hipArr[iHipArrIndex].leadtrans  = 0.0;
            hipArr[iHipArrIndex].trailtrans = 0.0;

            double dLastHIPx = filData.dHipx;
            double dLastHIPy = filData.dHipy;

            while (ln < (hipinfo.DataList.Count - 1))
            {
                ln++;
                filData = hipinfo.DataList[iLine]; iLine++;

                if (ln == 2)
                {
                    if (filData.iEltype != 1)
                    {
                        iHipArrIndex++;

                        nSign = (filData.iTurn == 1) ? -1 : 1;

                        hipArr[iHipArrIndex].xvalue     = filData.dHipx;
                        hipArr[iHipArrIndex].yvalue     = filData.dHipy;
                        hipArr[iHipArrIndex].delta      = filData.dDeviation * nSign;
                        hipArr[iHipArrIndex].radius     = 0.0;
                        hipArr[iHipArrIndex].leadtrans  = 0.0;
                        hipArr[iHipArrIndex].trailtrans = 0.0;
                    }
                }

                if ((Math.Abs(dLastHIPx - filData.dHipx) < 0.00001) && (Math.Abs(dLastHIPy - filData.dHipy) < 0.00001))
                {
                    // same HIP set
                    if (filData.iEltype == 2) // lead transition
                    {
                        hipArr[iHipArrIndex].leadtrans = filData.dEllength;
                    }
                    else if (filData.iEltype == 3) // circular transition
                    {
                        hipArr[iHipArrIndex].radius = filData.dRadius * nSign;
                    }
                    else if (filData.iEltype == 4) // trail transition
                    {
                        hipArr[iHipArrIndex].trailtrans = filData.dEllength;
                    }
                    else
                    {
                        //Error
                        return(listHhip);
                    }
                }
                else
                {
                    // next HIP set
                    iHipArrIndex++;

                    nSign = (filData.iTurn == 1) ? -1 : 1;

                    hipArr[iHipArrIndex].xvalue     = filData.dHipx;
                    hipArr[iHipArrIndex].yvalue     = filData.dHipy;
                    hipArr[iHipArrIndex].delta      = filData.dDeviation * nSign;
                    hipArr[iHipArrIndex].radius     = 0.0;
                    hipArr[iHipArrIndex].leadtrans  = 0.0;
                    hipArr[iHipArrIndex].trailtrans = 0.0;

                    dLastHIPx = filData.dHipx;
                    dLastHIPy = filData.dHipy;
                }
            }

            iHipArrIndex++;
            filData = hipinfo.DataList[iLine]; iLine++;
            ln++;
            nSign = (filData.iTurn == 1) ? -1 : 1;
            hipArr[iHipArrIndex].xvalue     = filData.dEndx;
            hipArr[iHipArrIndex].yvalue     = filData.dEndy;
            hipArr[iHipArrIndex].delta      = filData.dDeviation * nSign;
            hipArr[iHipArrIndex].radius     = 0.0;
            hipArr[iHipArrIndex].leadtrans  = 0.0;
            hipArr[iHipArrIndex].trailtrans = 0.0;

            listHhip = new List <CHHipData>();
            for (int ii = 0; ii < (iHipArrIndex + 1); ii++)
            {
                listHhip.Add(hipArr[ii]);
            }

            return(listHhip);
        }
示例#12
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);
        }