/// <summary> /// Method to create Work Label geometry /// </summary> /// <param name="wpGeometry"> WorkPoint geometry</param> /// <param name="tTVfeature"> Tree trimming feature </param> /// <param name="cid">cid</param> private void CreateWorkLabelGeometry(IGTOrientedPointGeometry wpGeometry, IGTKeyObject tTVfeature, short cid) { try { IGTTextPointGeometry iGtTxtPointGeometry = GTClassFactory.Create <IGTTextPointGeometry>(); IGTPoint textPoint = GTClassFactory.Create <IGTPoint>(); textPoint.X = wpGeometry.Origin.X + Convert.ToDouble(m_Arguments.GetArgument(0)); textPoint.Y = wpGeometry.Origin.Y + Convert.ToDouble(m_Arguments.GetArgument(1)); textPoint.Z = 0; iGtTxtPointGeometry.Origin = textPoint; IGTComponent igtComponent = tTVfeature.Components.GetComponent(19006); if (igtComponent.Recordset.RecordCount != 0) { igtComponent.Recordset.MoveLast(); } igtComponent.Recordset.AddNew("G3E_FID", tTVfeature.FID); igtComponent.Recordset.Fields["G3E_FNO"].Value = 190; igtComponent.Recordset.Fields["G3E_CNO"].Value = 19006; igtComponent.Recordset.Fields["G3E_CID"].Value = cid; igtComponent.Geometry = iGtTxtPointGeometry; igtComponent.Recordset.Update(System.Type.Missing, System.Type.Missing); } catch (Exception) { throw; } }
/// <summary> /// Method to create work point feature /// </summary> /// <returns>Work point feature IGTKeyObject</returns> public IGTKeyObject CreateWorkPointFeature() { try { IGTKeyObject workPointFeature = m_dataContext.NewFeature(191); IGTComponents workPointComponents = workPointFeature.Components; int wpOffsetX = 0; int wpOffsetY = 0; GetWorkPointOffset(ref wpOffsetX, ref wpOffsetY); foreach (IGTComponent component in workPointComponents) { Recordset tempRs = component.Recordset; if (tempRs != null) { if (tempRs.RecordCount > 0) { if (component.CNO == 19102) // Work point symbol { IGTOrientedPointGeometry orientedPtGeometry = GTClassFactory.Create <IGTOrientedPointGeometry>(); IGTPoint point = GTClassFactory.Create <IGTPoint>(); point.X = m_locationX - wpOffsetX; point.Y = m_locationY - wpOffsetY; orientedPtGeometry.Origin = point; component.Geometry = orientedPtGeometry; } if (component.CNO == 19103) // Work point Label { IGTTextPointGeometry gTTextPointGeometry = GTClassFactory.Create <IGTTextPointGeometry>(); IGTPoint gTPoint = GTClassFactory.Create <IGTPoint>(); gTPoint.X = m_locationX - wpOffsetX; gTPoint.Y = m_locationY - wpOffsetY; gTTextPointGeometry.Origin = gTPoint; gTTextPointGeometry.Alignment = GTAlignmentConstants.gtalBottomCenter; component.Geometry = gTTextPointGeometry; component.Recordset.Update(); } } } } // Leader Line should end at a point 70% of the way toward the structure from center of the Work Point. m_locationX = m_locationX - wpOffsetX * .3; m_locationY = m_locationY - wpOffsetY * .3; CreateLeaderLine(workPointFeature, m_locationX, m_locationY); return(workPointFeature); } catch (Exception) { throw; } }
public void SynchronizeWPCuLabel(IGTKeyObject p_WPKeyObject) { try { int wpOffsetX = 0; int wpOffsetY = 0; GetWorkPointOffset(ref wpOffsetX, ref wpOffsetY); double Owner_X = m_locationX; double Owner_Y = m_locationY; IGTComponent CuLabelcomponent = p_WPKeyObject.Components.GetComponent(19105); if (CuLabelcomponent.Recordset.RecordCount == 0) { CuLabelcomponent.Recordset.AddNew(); CuLabelcomponent.Recordset.Fields["G3E_FID"].Value = p_WPKeyObject.FID; CuLabelcomponent.Recordset.Fields["G3E_FNO"].Value = 191; CuLabelcomponent.Recordset.Fields["G3E_CNO"].Value = 19105; IGTTextPointGeometry gTTextPointGeometry = GTClassFactory.Create <IGTTextPointGeometry>(); IGTPoint gTPoint = GTClassFactory.Create <IGTPoint>(); gTPoint.X = m_locationX - wpOffsetX * (1.6); gTPoint.Y = Owner_Y - wpOffsetY * (1.3); gTTextPointGeometry.Origin = gTPoint; gTTextPointGeometry.Alignment = GTAlignmentConstants.gtalTopLeft; CuLabelcomponent.Geometry = gTTextPointGeometry; CuLabelcomponent.Recordset.Update(); } } catch (Exception) { throw; } }
public bool GeneratePlot(string strPlot, string strCity, string strDivision) { IGTNamedPlot gTNewNamedPlot = GTClassFactory.Create <IGTNamedPlot>(); IGTPlotFrame gTNewPlotFrame = GTClassFactory.Create <IGTPlotFrame>(); IGTPlotWindow gTPlotWindow = GTClassFactory.Create <IGTPlotWindow>(); IGTPlotMap gtNewPlotMap = GTClassFactory.Create <IGTPlotMap>(); IGTPlotRedlines gTPlotRedlines = null; //Recordset rs = null; object objectValue = null; string strNewPlotName = ""; try { if (!IsPlotNameExist(strPlot)) { strNewPlotName = strPlot; if (m_gTNamedPlot != null && !string.IsNullOrEmpty(strNewPlotName)) { gTNewNamedPlot = m_gTNamedPlot.CopyPlot(strNewPlotName); gTPlotWindow = m_gTApplication.NewPlotWindow(gTNewNamedPlot); gTPlotWindow.BackColor = System.Drawing.Color.White; gTPlotWindow.Caption = gTPlotWindow.NamedPlot.Name; if (!String.IsNullOrEmpty(m_gTNamedPlot.FieldsQuery)) { gTPlotWindow.NamedPlot.FieldsQuery = m_gTNamedPlot.FieldsQuery; } //rs = gTDataContext.OpenRecordset(gTPlotWindow.NamedPlot.FieldsQuery, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, // (int)ADODB.CommandTypeEnum.adCmdText, gTDataContext.ActiveJob); gTPlotRedlines = gTPlotWindow.NamedPlot.GetRedlines(GTPlotRedlineCollectionConstants.gtprcTextOnly); foreach (IGTPlotRedline prl in gTPlotRedlines) { IGTTextPointGeometry gTTextPointGeometry = (IGTTextPointGeometry)prl.Geometry.Copy(); if (prl.AutomaticTextSource == GTPlotAutomaticTextSourceConstants.gtpatPlotByQuery) { string currentVal = String.IsNullOrEmpty(gTTextPointGeometry.Text) ? " " : gTTextPointGeometry.Text; if (prl.AutomaticTextField.ToString() == "WR") { objectValue = m_gTApplication.DataContext.ActiveJob; } else if (prl.AutomaticTextField.ToString() == "StreetLightESILocation") { string esiLocations = ""; foreach (string esiL in m_SelectedEsiLocations) { if (!string.IsNullOrEmpty(esiLocations)) { esiLocations = esiLocations + ",'" + esiL + "'"; } else { esiLocations = "'" + esiL + "'"; } } objectValue = esiLocations; } else if (prl.AutomaticTextField.ToString() == "CountofStreetLightsinselectset") { objectValue = m_SelectedEsiLocations.Length + " Street Lights"; } else if (prl.AutomaticTextField.ToString() == "Subdivision") { objectValue = strDivision; } else if (prl.AutomaticTextField.ToString() == "City") { objectValue = strCity; } gTTextPointGeometry.Text = (objectValue == null) ? " " : objectValue.ToString(); prl.Geometry = gTTextPointGeometry; } } foreach (IGTPlotFrame plf in gTNewNamedPlot.Frames) { if (plf.Type == GTPlotFrameTypeConstants.gtpftMap) { gTNewPlotFrame = plf; } } if (gTNewPlotFrame != null) { gtNewPlotMap = gTNewPlotFrame.PlotMap; gTNewPlotFrame.Activate(); gTNewPlotFrame.PlotMap.FitSelectedObjects(1.2); gTNewPlotFrame.Deactivate(); m_gTApplication.RefreshWindows(); return(true); } } } else { MessageBox.Show("Plot name already exists in workspace. Please enter a different plot name", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); return(false); } } catch { throw; } return(false); }
/// <summary> /// Method to apply offset to removal feature / old feature /// </summary> /// <param name="sqlString"></param> /// <returns></returns> private void ApplyOffSetToGraphicComponents(short featureFNO, int featureFID) { IGTPoint point = null; try { IGTKeyObject feature = m_iGtApplication.DataContext.OpenFeature(featureFNO, featureFID); IGTComponents allComponents = feature.Components; feature.Components.GetComponent(1).Recordset.MoveFirst(); string sStructureID = Convert.ToString(feature.Components.GetComponent(1).Recordset.Fields["STRUCTURE_ID"].Value); foreach (IGTComponent component in allComponents) { if (!IsGraphicGeoComp(component.CNO)) { continue; } if (component.Geometry == null) { continue; } switch (component.Geometry.Type) { case GTGeometryTypeConstants.gtgtOrientedPointGeometry: IGTOrientedPointGeometry orientedPtGeometry = GTClassFactory.Create <IGTOrientedPointGeometry>(); point = GTClassFactory.Create <IGTPoint>(); point.X = component.Geometry.FirstPoint.X + m_offSetX; point.Y = component.Geometry.FirstPoint.Y + m_offSetY; orientedPtGeometry.Origin = point; orientedPtGeometry.Orientation = ((IGTOrientedPointGeometry)component.Geometry).Orientation; component.Geometry = orientedPtGeometry; break; case GTGeometryTypeConstants.gtgtTextPointGeometry: IGTTextPointGeometry textPtGeometry = GTClassFactory.Create <IGTTextPointGeometry>(); point = GTClassFactory.Create <IGTPoint>(); point.X = component.Geometry.FirstPoint.X + m_offSetX; point.Y = component.Geometry.FirstPoint.Y + m_offSetY; textPtGeometry.Origin = point; textPtGeometry.Normal = ((IGTOrientedPointGeometry)component.Geometry).Orientation; component.Geometry = textPtGeometry; break; case GTGeometryTypeConstants.gtgtPolylineGeometry: IGTPolylineGeometry newFtPlineGeo = GTClassFactory.Create <IGTPolylineGeometry>(); for (int k = 0; k <= component.Geometry.KeypointCount - 1; k++) { point = GTClassFactory.Create <IGTPoint>(); point.X = component.Geometry.GetKeypointPosition(k).X + m_offSetX; point.Y = component.Geometry.GetKeypointPosition(k).Y + m_offSetY; newFtPlineGeo.Points.Add(point); } component.Geometry = newFtPlineGeo; break; case GTGeometryTypeConstants.gtgtCompositePolylineGeometry: IGTCompositePolylineGeometry newFtCpline = GTClassFactory.Create <IGTCompositePolylineGeometry>(); IGTPolylineGeometry polylineGeometrytemp = GTClassFactory.Create <IGTPolylineGeometry>(); foreach (IGTGeometry subgeom in (IGTCompositePolylineGeometry)component.Geometry) { switch (subgeom.Type) { case GTGeometryTypeConstants.gtgtPointGeometry: case GTGeometryTypeConstants.gtgtOrientedPointGeometry: point.X = component.Geometry.FirstPoint.X + m_offSetX; point.Y = component.Geometry.FirstPoint.Y + m_offSetY; polylineGeometrytemp.Points.Add(point); break; case GTGeometryTypeConstants.gtgtLineGeometry: point.X = component.Geometry.FirstPoint.X + m_offSetX; point.Y = component.Geometry.FirstPoint.Y + m_offSetY; polylineGeometrytemp.Points.Add(point); point.X = component.Geometry.LastPoint.X + m_offSetX; point.Y = component.Geometry.LastPoint.Y + m_offSetY; polylineGeometrytemp.Points.Add(point); break; case GTGeometryTypeConstants.gtgtPolylineGeometry: for (int k = 0; k < subgeom.KeypointCount; k++) { point.X = component.Geometry.FirstPoint.X + m_offSetX; point.Y = component.Geometry.FirstPoint.Y + m_offSetY; polylineGeometrytemp.Points.Add(point); } break; } } break; default: break; } } feature.Components.GetComponent(1).Recordset.Fields["STRUCTURE_ID"].Value = sStructureID; //Reset the Structure ID to original value. The update is needed as Set Structure Locaiton FI changed the original Structure ID UpdateAssociatedWorkPointsStructureId(feature.FNO, feature.FID, sStructureID); //Update all the WP associated with the feature } catch (Exception) { throw; } }
/// <summary> /// Method to create a Plot window with given template and exports the plot window to create a PDF. /// </summary> /// <param name="p_template">Specified plot template using which need to create a new named plot </param> /// <param name="p_newTreeTrimmingfeature">Current placed feature</param> private void CreatePlotWindowAndPlotPDF(IGTNamedPlot p_template, IGTKeyObject p_newTreeTrimmingfeature) { Recordset oPlotRS = null; IGTPlotRedlines oRLs = null; IGTPlotFrame gTPlotFrame = GTClassFactory.Create <IGTPlotFrame>(); IGTPlotMap gtPlotMap = GTClassFactory.Create <IGTPlotMap>(); IGTNamedPlot namedPlot = GTClassFactory.Create <IGTNamedPlot>(); IGTPlotWindow gTPlotWindow = GTClassFactory.Create <IGTPlotWindow>(); string plotName = null; object autoVal = null; try { plotName = GetPlotName(); namedPlot = p_template.CopyPlot(plotName); gTPlotWindow = m_oGTApplication.NewPlotWindow(namedPlot); gTPlotWindow.BackColor = System.Drawing.Color.White; gTPlotWindow.Caption = gTPlotWindow.NamedPlot.Name; foreach (IGTPlotFrame apf in namedPlot.Frames) { if (apf.Type == GTPlotFrameTypeConstants.gtpftMap) { gTPlotFrame = apf; } } if (gTPlotFrame != null) { gtPlotMap = gTPlotFrame.PlotMap; if (!String.IsNullOrEmpty(p_template.FieldsQuery)) { gTPlotWindow.NamedPlot.FieldsQuery = p_template.FieldsQuery; } else { gTPlotWindow.NamedPlot.FieldsQuery = "Select WR_NBR,G3E_IDENTIFIER,DESIGNER_UID,G3E_DATECREATED,WR_CREW_HQ_C from g3e_job where g3e_identifier='" + m_oGTApplication.DataContext.ActiveJob + "'"; } oPlotRS = m_oGTApplication.DataContext.OpenRecordset(gTPlotWindow.NamedPlot.FieldsQuery, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, (int)ADODB.CommandTypeEnum.adCmdText); oRLs = gTPlotWindow.NamedPlot.GetRedlines(GTPlotRedlineCollectionConstants.gtprcTextOnly); foreach (IGTPlotRedline oRL in oRLs) { IGTTextPointGeometry oTPG = (IGTTextPointGeometry)oRL.Geometry.Copy(); if (oRL.AutomaticTextSource == GTPlotAutomaticTextSourceConstants.gtpatPlotByQuery) { if (oRL.AutomaticTextField.ToString() == "WR Number") { autoVal = oPlotRS.Fields["WR_NBR"].Value; } else if (oRL.AutomaticTextField.ToString() == "WR Name") { autoVal = oPlotRS.Fields["G3E_IDENTIFIER"].Value; } else if (oRL.AutomaticTextField.ToString() == "Designer Name") { autoVal = oPlotRS.Fields["DESIGNER_UID"].Value; } else if (oRL.AutomaticTextField.ToString() == "Date") { autoVal = oPlotRS.Fields["G3E_DATECREATED"].Value; } else if (oRL.AutomaticTextField.ToString() == "Crew HQ") { autoVal = oPlotRS.Fields["WR_CREW_HQ_C"].Value; } oTPG.Text = (autoVal == null) ? " " : autoVal.ToString(); oRL.Geometry = oTPG; } } gTPlotFrame.Activate(); gTPlotFrame.PlotMap.ZoomArea(p_newTreeTrimmingfeature.Components.GetComponent(19002).Geometry.Range); ZoomToExtents(gTPlotFrame, p_newTreeTrimmingfeature.Components.GetComponent(19002).Geometry.Range, 1.2); gTPlotFrame.ClipGeometry = WorldToPaper(gtPlotMap, (IGTPolygonGeometry)p_newTreeTrimmingfeature.Components.GetComponent(19002).Geometry); gTPlotFrame.IsClipped = true; gTPlotFrame.Deactivate(); m_oGTApplication.RefreshWindows(); m_oPlotPDFName = plotName.Replace('/', '_').Replace('\\', '_').Replace(' ', '_'); ExportToPDF(Path.GetTempPath(), m_oPlotPDFName, false, gTPlotWindow); } } catch { throw; } finally { oPlotRS = null; } }