private void UpdateBasicInformationGroup(PipeInfo pipeInfo) { // Pipe No. m_labelPipeId.Text = string.Format(Resources.IDS_PIPE_ID_IMMSERING, pipeInfo.PipeId); // Data time m_labelDateTime.Text = pipeInfo.Time.ToString(); }
private void UpdateAngleInformationGroup(PipeInfo pipeInfo) { // Angle1 const string strAngleFormat = "{0:0.###}"; m_Angle1.Text = string.Format(strAngleFormat, pipeInfo.RollInclineAngle); m_MaxAngle1.Text = string.Format(strAngleFormat, pipeInfo.MaxAbsRoll); // Angle 2 m_Angle2.Text = string.Format(strAngleFormat, pipeInfo.PitchInclineAngle); m_MaxAngle2.Text = string.Format(strAngleFormat, pipeInfo.MaxAbsPitch); }
/// <summary> /// This function is used to be called outside to refresh the data shown in the UI /// </summary> public void UpdateData(PipeInfo pipeInfo) { // Basic information UpdateBasicInformationGroup(pipeInfo); // GPS information UpdateGPSInformationGroup(pipeInfo); // Angle information UpdateAngleInformationGroup(pipeInfo); // Connection Point pair information UpdateConnectionPointPairGroup(pipeInfo); }
//public static bool CalcaulateConnection(PipeInfo currentPipeInfo, out IList<CPipeConnectionPointPair> connectionPointPair) //{ // // Construct the connection pair list // connectionPointPair = new List<CPipeConnectionPointPair>(); // if (null == currentPipeInfo) return false; // // Assert valid // int iPipeIndex = currentPipeInfo.PipeId; // int iPipeTotalCount = IApp.theApp.DataModel.PipeModels.Count; // if (iPipeIndex <= 0 || iPipeIndex > iPipeTotalCount) return false; // Something goes wrong // CPipeModel currentPipeModel = IApp.theApp.DataModel.PipeModels[iPipeIndex - 1]; // if (null == currentPipeModel) return false; // // Get current pipe transformation // //vtk.vtkTransform transform = currentPipeInfo.Matrix.ToVTKTransformation(); // vtk.vtkTransform transform = currentPipeModel.GetPipeTransformByPipeInfo(currentPipeInfo); // //Random ro = new Random(); // //transform.Translate(ro.NextDouble() * -20000, ro.NextDouble() * -5000, ro.NextDouble() * -14000); // //transform.Update(); // // How to calculate the start and end connection point. // if (iPipeIndex == 1) // First pipe // { // // For the first pipe, then the previous start point is its start point // foreach (CPipeConnectionPointPair pair in currentPipeModel.ConnectionPointPairList) // { // CPipeConnectionPointPair newPair = new CPipeConnectionPointPair(); // newPair.Name = pair.Name; // // If the pipe is first pipe, we should use its start connection point to be the previous end connection point. // newPair.StartConnectionPoint = pair.StartConnectionPoint; // // The end point should be the pipe model's current start connection point // double[] ptTransformed = new double[3]; // transform.TransformPoint(pair.StartConnectionPoint.Point, ptTransformed); // newPair.EndConnectionPoint = new CPoint3D(ptTransformed); // connectionPointPair.Add(newPair); // } // } // else if (iPipeIndex > 1) // { // bool bUpdatePreviousPipeConnectionPoints = ApplicationOptions.Instance().UpdateConnectionPointPositionByLastTransform; // CPipeModel previousPipeModel = IApp.theApp.DataModel.PipeModels[iPipeIndex - 2]; // foreach (CPipeConnectionPointPair pair in currentPipeModel.ConnectionPointPairList) // { // CPipeConnectionPointPair newPair = new CPipeConnectionPointPair(); // newPair.Name = pair.Name; // // For none first pipe, we should take care if the first pipe is not placed as the position of the modeling one. // double[] lastPipeStartConnectionPoint = null; // if (bUpdatePreviousPipeConnectionPoints && previousPipeModel.FinalTransform != null) // { // lastPipeStartConnectionPoint = previousPipeModel.FinalTransform.TransformDoublePoint(pair.StartConnectionPoint.Point); // } // else // { // lastPipeStartConnectionPoint = pair.StartConnectionPoint.Point; // } // // If the pipe is first pipe, we should use its start connection point to be the previous end connection point. // newPair.StartConnectionPoint = new CPoint3D(lastPipeStartConnectionPoint); // // The end point should be the pipe model's current start connection point // double[] ptTransformed = new double[3]; // transform.TransformPoint(pair.StartConnectionPoint.Point, ptTransformed); // newPair.EndConnectionPoint = new CPoint3D(ptTransformed); // connectionPointPair.Add(newPair); // } // } // return true; //} public static bool CalcaulateConnection(PipeInfo currentPipeInfo, out IList<CPipeConnectionPointPair> connectionPointPair) { // Construct the connection pair list connectionPointPair = new List<CPipeConnectionPointPair>(); if (null == currentPipeInfo) return false; // Assert valid int iPipeIndex = currentPipeInfo.PipeId; int iPipeTotalCount = IApp.theApp.DataModel.PipeModels.Count; if (iPipeIndex <= 0 || iPipeIndex > iPipeTotalCount) return false; // Something goes wrong CPipeModel currentPipeModel = IApp.theApp.DataModel.PipeModels[iPipeIndex - 1]; if (null == currentPipeModel) return false; // Get current pipe transformation //vtk.vtkTransform transform = currentPipeInfo.Matrix.ToVTKTransformation(); vtk.vtkTransform transform = currentPipeModel.GetPipeTransformByPipeInfo(currentPipeInfo); //Random ro = new Random(); //transform.Translate(ro.NextDouble() * -20000, ro.NextDouble() * -5000, ro.NextDouble() * -14000); //transform.Update(); // How to calculate the start and end connection point. if (iPipeIndex == 1) // First pipe { // For the first pipe, then the previous start point is its start point foreach (CPipeConnectionPointPairEx pair in currentPipeModel.ConnectionPointPairList) { CPipeConnectionPointPair newPair = new CPipeConnectionPointPair(); newPair.Name = pair.Name; // If the pipe is first pipe, ingore the ConnectionPositionEnum for the StartConnectionPoint newPair.StartConnectionPoint = pair.StartConnectionPoint; // The end point should be the pipe model's current start connection point if (pair.EndPositionEnum == ConnectionPositionEnum.kStaticPosition) { newPair.EndConnectionPoint = pair.EndConnectionPoint; } else if (pair.EndPositionEnum == ConnectionPositionEnum.kOnThisPipe) { double[] ptTransformed = new double[3]; transform.TransformPoint(pair.EndConnectionPoint.Point, ptTransformed); newPair.EndConnectionPoint = new CPoint3D(ptTransformed); } else if (pair.EndPositionEnum == ConnectionPositionEnum.kOnPreviousPipe) { newPair.EndConnectionPoint = pair.EndConnectionPoint; } connectionPointPair.Add(newPair); } } else if (iPipeIndex > 1) { bool bUpdatePreviousPipeConnectionPoints = ApplicationOptions.Instance().UpdateConnectionPointPositionByLastTransform; CPipeModel previousPipeModel = IApp.theApp.DataModel.PipeModels[iPipeIndex - 2]; foreach (CPipeConnectionPointPairEx pair in currentPipeModel.ConnectionPointPairList) { CPipeConnectionPointPair newPair = new CPipeConnectionPointPair(); newPair.Name = pair.Name; // For none first pipe, we should take care if the first pipe is not placed as the position of the modeling one. double[] lastPipeStartConnectionPoint = pair.StartConnectionPoint.Point; double[] lastPipeStartConnectionPointTransformed = null; if (bUpdatePreviousPipeConnectionPoints && previousPipeModel.FinalTransform != null) { lastPipeStartConnectionPointTransformed = previousPipeModel.FinalTransform.TransformDoublePoint(pair.StartConnectionPoint.Point); } else { lastPipeStartConnectionPointTransformed = pair.StartConnectionPoint.Point; } // If the pipe is first pipe, we should use its start connection point to be the previous end connection point. if (pair.StartPositionEnum == ConnectionPositionEnum.kStaticPosition) { newPair.StartConnectionPoint = new CPoint3D(lastPipeStartConnectionPoint); } else if (pair.StartPositionEnum == ConnectionPositionEnum.kOnPreviousPipe) { newPair.StartConnectionPoint = new CPoint3D(lastPipeStartConnectionPointTransformed); } else if (pair.StartPositionEnum == ConnectionPositionEnum.kOnThisPipe) { double[] ptTransformed = new double[3]; transform.TransformPoint(pair.StartConnectionPoint.Point, ptTransformed); newPair.StartConnectionPoint = new CPoint3D(ptTransformed); } // The end point should be the pipe model's current start connection point if (pair.EndPositionEnum == ConnectionPositionEnum.kStaticPosition) { newPair.EndConnectionPoint = pair.EndConnectionPoint; } else if (pair.EndPositionEnum == ConnectionPositionEnum.kOnThisPipe) { double[] ptTransformed = new double[3]; transform.TransformPoint(pair.EndConnectionPoint.Point, ptTransformed); newPair.EndConnectionPoint = new CPoint3D(ptTransformed); } else if (pair.EndPositionEnum == ConnectionPositionEnum.kOnPreviousPipe) { newPair.EndConnectionPoint = new CPoint3D(lastPipeStartConnectionPointTransformed); } connectionPointPair.Add(newPair); } } return true; }
protected virtual void SetMaxAngle(PipeInfo pipeInfo) { if (pipeInfo == null) return; double maxAbsRoll; double maxAbsPitch; QueryMaxAngle(pipeInfo, out maxAbsRoll, out maxAbsPitch); pipeInfo.MaxAbsRoll = maxAbsRoll; pipeInfo.MaxAbsPitch = maxAbsPitch; }
/// <summary> /// /// </summary> /// <param name="pipeInfo"></param> protected override void SetMaxAngle(PipeInfo pipeInfo) { if (pipeInfo == null) return; if (pipeInfo.PipeId > m_currentPipeId) { m_maxAbsRoll = pipeInfo.RollInclineAngle; m_maxAbsPitch = pipeInfo.PitchInclineAngle; } else if (pipeInfo.PipeId == m_currentPipeId) { if (Math.Abs(pipeInfo.RollInclineAngle) > m_maxAbsRoll) m_maxAbsRoll = pipeInfo.RollInclineAngle; if (Math.Abs(pipeInfo.PitchInclineAngle) > m_maxAbsPitch) m_maxAbsPitch = pipeInfo.PitchInclineAngle; } pipeInfo.MaxAbsRoll = m_maxAbsRoll; pipeInfo.MaxAbsPitch = m_maxAbsPitch; }
protected PipeInfo ExtractPipeInfo(List<GPSRecord> lstGPSRecords, InclineRecord inclineRcd, out int lastGPSMeasureId) { for (int idx = lstGPSRecords.Count - 1; idx >= 0; idx++) { // find first matching GPS Record if (inclineRcd.PipeId == lstGPSRecords[idx].PipeId && (inclineRcd.MeasureTime - lstGPSRecords[idx].MeasureTime).Duration() <= m_inclineGPSMeasureTimeTolerance) { for (int jdx = idx - 1; jdx >= 0; jdx++) { // find send matching GPS Record if (inclineRcd.PipeId == lstGPSRecords[jdx].PipeId && lstGPSRecords[idx].ProjectPointId != lstGPSRecords[jdx].ProjectPointId && (lstGPSRecords[idx].MeasureTime - lstGPSRecords[jdx].MeasureTime).Duration() <= m_GPSMeasureTimeTolerance) { GPSRecord gpsPrjPt1 = (lstGPSRecords[idx].ProjectPointId < lstGPSRecords[jdx].ProjectPointId) ? lstGPSRecords[idx] : lstGPSRecords[jdx]; GPSRecord gpsPrjPt2 = (lstGPSRecords[idx].ProjectPointId < lstGPSRecords[jdx].ProjectPointId) ? lstGPSRecords[jdx] : lstGPSRecords[idx]; PipeInfo pipeInfo = new PipeInfo(inclineRcd.PipeId, gpsPrjPt1.Location, gpsPrjPt2.Location, inclineRcd.Alpha, inclineRcd.Beta, inclineRcd.MeasureTime); lastGPSMeasureId = lstGPSRecords[idx].MeasureId; return pipeInfo; } } } } lastGPSMeasureId = 0; return null; }
private PipeInfo ToPipeInfo(SqlDataReader sqlDataReader) { PipeInfo pipeInfo = null; if (sqlDataReader.Read() && sqlDataReader.FieldCount > 11) { pipeInfo = new PipeInfo((int)(sqlDataReader.GetDecimal(0)), (int)(sqlDataReader.GetDecimal(10)), (int)(sqlDataReader.GetDecimal(11))); pipeInfo.Time = sqlDataReader.GetDateTime(1); const double mToMm = 1000.0; // negate z component to convert to right-hand coordinate system pipeInfo.StartPoint = new Point3D((double)(sqlDataReader.GetDecimal(2)) * mToMm, (double)(sqlDataReader.GetDecimal(3)) * mToMm, -(double)(sqlDataReader.GetDecimal(4)) * mToMm); pipeInfo.EndPoint = new Point3D((double)(sqlDataReader.GetDecimal(5)) * mToMm, (double)(sqlDataReader.GetDecimal(6)) * mToMm, -(double)(sqlDataReader.GetDecimal(7)) * mToMm); pipeInfo.PitchInclineAngle = (double)(sqlDataReader.GetDecimal(8)); pipeInfo.RollInclineAngle = (double)(sqlDataReader.GetDecimal(9)); } return pipeInfo; }
protected void QueryMaxAngle(PipeInfo pipeInfo, out double maxAbsRoll, out double maxAbsPitch) { maxAbsRoll = 0.0; maxAbsPitch = 0.0; if (pipeInfo == null) return; string strInclineSql = String.Format(@"SELECT MAX(ABS(Angle1)) AS MaxAlpha, MAX(ABS(Angle2)) AS MaxBeta FROM InclineMeasure WHERE PipeID='{0}' AND MeasureID <='{1}'", pipeInfo.PipeId, pipeInfo.InclineMeasureId); lock (m_dbConn) { // read Incline records using (SqlCommand sqlCmd = new SqlCommand(strInclineSql, m_dbConn)) { using (SqlDataReader sqlDataReader = sqlCmd.ExecuteReader()) { if (sqlDataReader.Read()) { maxAbsRoll = (double)(sqlDataReader.GetDecimal(0)); maxAbsPitch = (double)(sqlDataReader.GetDecimal(1)); } } } } }
private void UpdateConnectionPointPairGroup(PipeInfo pipeInfo) { // Update the connection indicator IList<CPipeConnectionPointPair> connectionPointPairList = null; if (CPipeConnetionUtility.CalcaulateConnection(IApp.theApp.DataDriven.CurrentData, out connectionPointPairList)) { cStatisticDataBindingSource.DataSource = connectionPointPairList; } }
private void UpdateGPSInformationGroup(PipeInfo pipeInfo) { // GPS 1 const string strCoordFormat = "{0,15:0,0.000}"; string strStartPoint; strStartPoint = string.Concat("(", string.Format(strCoordFormat, pipeInfo.StartDisplayPoint.X * IApp.theApp.DataModel.GPSUnitToMeter), " ,", string.Format(strCoordFormat, pipeInfo.StartDisplayPoint.Y * IApp.theApp.DataModel.GPSUnitToMeter), " ,", string.Format(strCoordFormat, pipeInfo.StartDisplayPoint.Z * IApp.theApp.DataModel.GPSUnitToMeter), ")"); m_GPS1Detail.Text = strStartPoint; // GPS 2 string strEndPoint; strEndPoint = string.Concat("(", string.Format(strCoordFormat, pipeInfo.EndDisplayPoint.X * IApp.theApp.DataModel.GPSUnitToMeter), " ,", string.Format(strCoordFormat, pipeInfo.EndDisplayPoint.Y * IApp.theApp.DataModel.GPSUnitToMeter), " ,", string.Format(strCoordFormat, pipeInfo.EndDisplayPoint.Z * IApp.theApp.DataModel.GPSUnitToMeter), ")"); m_GPS2Detail.Text = strEndPoint; }
private void DriveModel(PipeInfo pipeInfo) { IApp.theApp.DataDriven.DriveModel(pipeInfo); // Update the dialog if (IApp.theApp.DataDriven.CurrentData != null) { if (m_immersingInformationForm != null) { m_immersingInformationForm.UpdateData(IApp.theApp.DataDriven.CurrentData); } // Update the connection indicator IList<CPipeConnectionPointPair> connectionPointPairList = null; if (CPipeConnetionUtility.CalcaulateConnection(IApp.theApp.DataDriven.CurrentData, out connectionPointPairList)) { CPipeConnectionIndicator pipeConnectionIndicator = IApp.theApp.PipeConnectionIndicator; if (pipeConnectionIndicator != null) { pipeConnectionIndicator.SetPoints(connectionPointPairList); pipeConnectionIndicator.Impl.UpatePoints(); } } // Update the Text Display // Show it only in debug mode if (ApplicationOptions.Instance().AppOptions.DebugMode) { CStatisticData statisticData = new CStatisticData(); statisticData.ConnectionPointPairList = connectionPointPairList; IApp.theApp.StatisticTextDisplayer.DisplayText(statisticData.ToTextString()); // Make sure we make the StatisticTextDisplayerAdditional appeal after the StatisticTextDisplayer IApp.theApp.StatisticTextDisplayerAdditional.DisplayText(statisticData.ToDataString()); //// Update the WarningTextDisplayer //CAngleWarningData angleWarningData = new CAngleWarningData(); //IApp.theApp.WarningTextDisplayer.DisplayText(angleWarningData.ToString()); } } // Update Angle warning UpdateAngleWarning(); // Render the scene IApp.theApp.RenderScene(); }
private void dataQuery_DataArrivedCallback(PipeInfo queryResult) { // A message is arrived, we need to sync this to drive the model // This must happen during observer mode. // Must in monitor mode if (IApp.theApp.ObserverModeManager.ActiveModeType != ObserverMode.ObserverMode.eMonitorMode) return; if (IApp.theApp.vtkControl.InvokeRequired) { dataQuery_DataArrivedCallback_Invoke d = new dataQuery_DataArrivedCallback_Invoke(dataQuery_DataArrivedCallback); this.Invoke(d, new object[] { queryResult }); } else { DriveModel(queryResult); } }
private void UpdateAnimationLabelTextByPipeInfo(PipeInfo pipeInfo) { // Pipe info must be not null DateTime dateTime = DateTime.Now; // Get the current pipe info try { dateTime = pipeInfo.Time; UpdateAnimationLabelTextByDateTime(dateTime, true); } catch (Exception ex) { string errMsg = ex.Message + "\n" + ex.StackTrace; vtk.vtkOutputWindow.GetInstance().DisplayErrorText(errMsg); } }