示例#1
0
        public static IGTPoint RetrieveRelativePoint(IGTGraphicComponent relativeComponent)
        {
            //initialize
            IGTGeometry relativeGeometry = relativeComponent.Geometry;
            IGTPoint    relativePoint    = GTClassFactory.Create <IGTPoint>();

            relativePoint.X = ((IGTOrientedPointGeometry)relativeGeometry).Origin.X;
            relativePoint.Y = ((IGTOrientedPointGeometry)relativeGeometry).Origin.Y;
            relativePoint.Z = ((IGTOrientedPointGeometry)relativeGeometry).Origin.Z;
            return(relativePoint);
        }
示例#2
0
 public void Exitcommand()
 {
     if (m_gtApplication != null)
     {
         m_gtApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "");
         m_gtApplication = null;
     }
     if (m_PTHelper != null)
     {
         m_GComps = null;
         m_GComp  = null;
         m_PTHelper.StatusBarPromptsEnabled        = false;
         m_PTHelper.ConstructionAidsEnabled        = GTConstructionAidsEnabledConstants.gtptConstructionAidsNone;
         m_PTHelper.ConstructionAidDynamicsEnabled = false;
         m_PTHelper = null;
     }
 }
示例#3
0
        /// <summary>
        /// StartPlacement
        /// </summary>
        /// <param name="PTHelper"></param>
        /// <param name="KeyObject"></param>
        /// <param name="KeyObjectCollection"></param>
        /// <returns></returns>
        public override void StartPlacement(IGTPlacementTechniqueHelper PTHelper, IGTKeyObject KeyObject, IGTKeyObjects KeyObjectCollection)
        {
            try
            {
                m_PTHelper = PTHelper;
                IGTKeyObject        m_KeyObject = KeyObject;
                IGTPoint            m_gtOrigin;
                IGTGraphicComponent relativeComponent = GTClassFactory.Create <IGTGraphicComponent>();
                m_KeyObjectCollection = KeyObjectCollection;

                //get current Key object
                currentKeyObject = GetcurrentKeyObject(KeyObject.FNO);

                if (bSilent)
                {
                    m_gtApplication.BeginWaitCursor();

                    // Disable construction aids and status bar prompts for silent placement techinque.
                    m_PTHelper.ConstructionAidsEnabled        = GTConstructionAidsEnabledConstants.gtptConstructionAidsNone;
                    m_PTHelper.ConstructionAidDynamicsEnabled = false;
                    m_PTHelper.StatusBarPromptsEnabled        = true;
                    m_gtApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, currentKeyObject + " Point placement is in Progress......");

                    IGTComponents gtComponents = KeyObject.Components;
                    m_PTHelper.StartPlacement(KeyObject, KeyObjectCollection);

                    //Read arguments
                    ReadArgument();

                    //Find the relative component defined in the placement technique arguments.
                    if ((Convert.ToString(m_GComp.Arguments.GetArgument(0)) != "") && (m_GComps.Count > 0) && (m_GComp != null))
                    {
                        relativeComponent = AccessRelativeComponent.RetrieveRelativeComponent(Convert.ToString(m_GComp.Arguments.GetArgument(0)), m_GComps, m_GComp);
                        //get the origin
                        m_gtOrigin = GetOrigin(m_KeyObject, gtComponents, relativeComponent, xOffset, pointLocation);

                        if ((m_gtOrigin != null) && (relativeComponent != null))
                        {
                            //Set Attribute values
                            SetAttributeValues(gtComponents, m_KeyObject, relativeComponent);

                            //Create new point geometry aligned to the linear feature
                            IGTOrientedPointGeometry newPointGeometry = (IGTOrientedPointGeometry)PTHelper.CreateGeometry();
                            //newPointGeometry.Orientation = VectorByAngle(ang);
                            newPointGeometry.Origin = m_gtOrigin;
                            m_PTHelper.SetGeometry(newPointGeometry);
                            m_PTHelper.EndPlacement();
                        }
                        else
                        {
                            AbortPlacement();
                        }
                    }
                    else
                    {
                        if (pointLocation == "R")
                        {
                            MessageBox.Show("Error: Unable to place " + currentKeyObject + " Points", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        AbortPlacement();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: Unable to place " + currentKeyObject + " Points \n" + ex.Message, "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Error);
                AbortPlacement();
            }
            finally
            {
                m_KeyObjectCollection = null;
                m_GComps = null;
                m_GComp  = null;
                if (pointLocation == "R")
                {
                    m_gtApplication.EndWaitCursor();
                    m_gtApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Feature Placement Completed");
                    m_gtApplication.ActiveMapWindow.MousePointer = GTMousePointerConstants.gtmwmpNWArrow;
                    m_PTHelper.ConstructionAidsEnabled           = GTConstructionAidsEnabledConstants.gtptConstructionAidsNone;
                    m_PTHelper.ConstructionAidDynamicsEnabled    = false;
                }
                Exitcommand();
            }
        }
示例#4
0
        /// <summary>
        /// Get Origin point of point feature
        /// </summary>
        /// <param name="m_gtComponents"></param>
        /// <param name="gtRelativeComponent"></param>
        /// <param name="xOffset"></param>
        /// <param name="pointLocation"></param>
        /// <returns></returns>
        private IGTPoint GetOrigin(IGTKeyObject m_KeyObject, IGTComponents m_gtComponents, IGTGraphicComponent m_gtRelativeComponent, double xOffset, string pointLocation)
        {
            try
            {
                IGTPoint    m_gtOriginPoint  = null;
                IGTGeometry m_gtLineGeometry = GTClassFactory.Create <IGTGeometry>();
                m_gtApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, currentKeyObject + " Point placement is in Progress......");

                //Get Relative Component
                IGTKeyObject m_gtRelativePoint = m_gtApplication.DataContext.OpenFeature(m_gtRelativeComponent.FNO, m_gtRelativeComponent.FID);

                //get the related Linear features
                IGTKeyObjects m_gtRelativeLines = GetRelatedFeature(m_gtRelativePoint, iRNO, linearFNO);

                //get the related Linear features in case they are not connected to relativepoint
                if (m_gtRelativeLines.Count == 0)
                {
                    IGTKeyObjects m_gtBypasspt = GetRelatedFeature(m_gtRelativePoint, iRNO, m_KeyObject.FNO);
                    if (m_gtBypasspt.Count > 0)
                    {
                        m_gtRelativeLines = GetRelatedFeature(m_gtBypasspt[0], iRNO, linearFNO);
                    }
                }

                //Check if related line geometry is not null
                if (m_gtRelativeLines != null && m_gtRelativeLines.Count > 0)
                {
                    //Get node values
                    m_gtRelativeLines = GetNodeValues(m_gtRelativePoint, m_gtRelativeLines);
                    m_gtLineGeometry  = m_gtRelativeLines[0].Components.GetComponent(primaryCNO).Geometry;

                    //Get Line segment and its angle
                    m_gtLineGeometry = GetSegmentAndAngle(m_gtLineGeometry, m_gtRelativeComponent.Geometry.FirstPoint);

                    if (m_gtLineGeometry != null)
                    {
                        switch (pointLocation)
                        {
                        case "L":
                            //Get Left Origin Point
                            m_gtOriginPoint = GetLeftOriginPoint(m_gtComponents, m_gtRelativePoint, m_gtLineGeometry, m_gtRelativeLines);

                            break;

                        case "R":
                            //Get Right Origin Point
                            m_gtOriginPoint = GetRightOriginPoint(m_gtComponents, m_gtRelativePoint, m_gtLineGeometry);

                            break;

                        case "T":
                            //Get Top Origin Point
                            m_gtOriginPoint = GetTopOriginPoint(m_gtLineGeometry);

                            //establish the connectivity for Relative point with Linear feature
                            EstablishRelationship(m_gtRelativePoint, m_gtRelativeLines);
                            break;

                        default:
                            break;
                        }
                        if (m_gtOriginPoint == null)
                        {
                            m_gtOriginPoint = m_gtRelativeComponent.Geometry.FirstPoint;
                        }
                    }
                    else
                    {
                        if (pointLocation == "R")
                        {
                            MessageBox.Show("Error: Unable to place " + currentKeyObject + " Points as the linear feature is not selected properly", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
                return(m_gtOriginPoint);
            }
            catch
            {
                throw;
            }
        }
示例#5
0
        /// <summary>
        /// Get Origin
        /// </summary>
        /// <param name="m_gtComponents"></param>
        /// <param name="m_gtRelativeComponent"></param>
        /// <param name="xOffset"></param>
        /// <param name="pointLocation"></param>
        /// <returns></returns>
        private IGTPoint GetOrigin(IGTKeyObject KeyObject, IGTComponents m_gtComponents, IGTGraphicComponent m_gtRelativeComponent, double xOffset, string pointLocation)
        {
            try
            {
                IGTPoint m_gtOriginPoint = null;
                m_gtApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Isolation Point placement is in Progress......");

                //Get the related Point feature
                IGTKeyObject m_gtRelativePoint = m_gtApplication.DataContext.OpenFeature(m_gtRelativeComponent.FNO, m_gtRelativeComponent.FID);

                //get the related lines
                IGTKeyObjects m_gtRelativeLines = GetRelatedFeature(m_gtRelativePoint, iRNO, linearFNO);

                //get the related Linear features in case they are not connected to relativepoint
                if (m_gtRelativeLines.Count == 0)
                {
                    IGTKeyObjects m_gtBypasspt = GetRelatedFeature(m_gtRelativePoint, iRNO, KeyobjectFNO);
                    if (m_gtBypasspt.Count > 0)
                    {
                        m_gtRelativeLines = GetRelatedFeature(m_gtBypasspt[0], iRNO, linearFNO);
                    }
                }

                //Check if related line geometry is not null
                if (m_gtRelativeLines != null && m_gtRelativeLines.Count > 0)
                {
                    EstablishRelationship(m_gtRelativePoint, m_gtRelativeLines);

                    IGTGeometry m_gtLineGeometry = m_gtRelativeLines[0].Components.GetComponent(primaryCNO).Geometry;

                    if (m_gtLineGeometry != null)
                    {
                        //Get node values
                        GetNodeValues(m_gtRelativePoint, m_gtRelativeLines);

                        //create offset geoemtry
                        if ((m_rlnode2 != 0) && (m_rlnode2 == m_rpnode1))
                        {
                            IGTGeometry[] geoms = m_gtLineGeometry.CreateOffsetGeometries(xOffset);
                            m_gtOriginPoint = geoms[0].LastPoint;

                            //set the node value
                            m_gtComponents.GetComponent(ConnectivityCNO).Recordset.Fields["NODE_1_ID"].Value = m_rlnode2;
                            m_gtRelativePoint.Components.GetComponent(ConnectivityCNO).Recordset.Fields["NODE_1_ID"].Value = 0;
                            m_gtRelativePoint.Components.GetComponent(ConnectivityCNO).Recordset.Fields["NODE_2_ID"].Value = 0;
                            m_gtRelativePoint.Components.GetComponent(ConnectivityCNO).Recordset.Update();
                            m_gtComponents.GetComponent(ConnectivityCNO).Recordset.Update();

                            //set the node value
                            if (m_gtRelativePoint.FNO == transformerUGFNO)
                            {
                                if (m_gtRelativeLines.Count > 1)
                                {
                                    m_gtRelativeLines[1].Components.GetComponent(ConnectivityCNO).Recordset.Fields["NODE_1_ID"].Value = m_rlnode2;
                                    m_gtRelativeLines[1].Components.GetComponent(ConnectivityCNO).Recordset.Update();
                                }
                            }
                        }
                        else
                        {
                            IGTGeometry[] geoms = m_gtLineGeometry.CreateOffsetGeometries(xOffset);
                            m_gtOriginPoint = geoms[0].FirstPoint;

                            //set the node value
                            m_gtComponents.GetComponent(ConnectivityCNO).Recordset.Fields["NODE_1_ID"].Value = m_rlnode1;
                            m_gtRelativePoint.Components.GetComponent(ConnectivityCNO).Recordset.Fields["NODE_1_ID"].Value = 0;
                            m_gtRelativePoint.Components.GetComponent(ConnectivityCNO).Recordset.Fields["NODE_2_ID"].Value = 0;
                            m_gtRelativePoint.Components.GetComponent(ConnectivityCNO).Recordset.Update();
                            m_gtComponents.GetComponent(ConnectivityCNO).Recordset.Update();

                            //set the node value
                            if (m_gtRelativePoint.FNO == transformerUGFNO)
                            {
                                if (m_gtRelativeLines.Count > 1)
                                {
                                    m_gtRelativeLines[1].Components.GetComponent(ConnectivityCNO).Recordset.Fields["NODE_1_ID"].Value = m_rlnode1;
                                    m_gtRelativeLines[1].Components.GetComponent(ConnectivityCNO).Recordset.Update();
                                }
                            }
                        }
                    }
                    if (m_gtOriginPoint == null)
                    {
                        m_gtOriginPoint = m_gtRelativeComponent.Geometry.FirstPoint;
                    }
                }
                else
                {
                    if (pointLocation == "R")
                    {
                        MessageBox.Show("Error: Unable to place Isolation Points as the linear feature is not selected properly", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                return(m_gtOriginPoint);
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#6
0
        /// <summary>
        /// Set Attribute value
        /// </summary>
        /// <param name="m_gtComponents"></param>
        /// <param name="m_gtKeyObject"></param>
        /// <param name="m_gtRelativeComponent"></param>
        /// <returns></returns>
        protected void SetAttributeValues(IGTComponents m_gtComponents, IGTKeyObject m_gtKeyObject, IGTGraphicComponent m_gtRelativeComponent)
        {
            try
            {
                foreach (IGTComponent m_gtComponent in m_gtComponents)
                {
                    switch (m_gtComponent.CNO)
                    {
                    case VirtualPointCNO:
                        if (m_gtComponent.Recordset.RecordCount == 0)
                        {
                            m_gtComponent.Recordset.AddNew();
                            m_gtComponent.Recordset.Fields["G3E_FID"].Value = m_gtKeyObject.FID;
                            m_gtComponent.Recordset.Fields["G3E_FNO"].Value = m_gtKeyObject.FNO;
                            m_gtComponent.Recordset.Fields["G3E_CNO"].Value = m_gtComponent.CNO;
                            m_gtComponent.Recordset.Fields["G3E_CID"].Value = 1;
                        }
                        else
                        {
                            m_gtComponent.Recordset.MoveFirst();
                        }
                        break;

                    case ConnectivityCNO:
                        if (m_gtComponent.Recordset.RecordCount == 0)
                        {
                            m_gtComponent.Recordset.AddNew();
                            m_gtComponent.Recordset.Fields["G3E_FID"].Value         = m_gtKeyObject.FID;
                            m_gtComponent.Recordset.Fields["G3E_FNO"].Value         = m_gtKeyObject.FNO;
                            m_gtComponent.Recordset.Fields["G3E_CNO"].Value         = m_gtComponent.CNO;
                            m_gtComponent.Recordset.Fields["G3E_CID"].Value         = 1;
                            m_gtComponent.Recordset.Fields["STATUS_NORMAL_C"].Value = statusNormal;
                        }
                        else
                        {
                            m_gtComponent.Recordset.MoveFirst();
                            m_gtComponent.Recordset.Fields["STATUS_NORMAL_C"].Value = statusNormal;
                        }
                        break;

                    case VirtualAttributeCNO:
                        if (m_gtComponent.Recordset.RecordCount == 0)
                        {
                            m_gtComponent.Recordset.AddNew();
                            m_gtComponent.Recordset.Fields["G3E_FID"].Value        = m_gtKeyObject.FID;
                            m_gtComponent.Recordset.Fields["G3E_FNO"].Value        = m_gtKeyObject.FNO;
                            m_gtComponent.Recordset.Fields["G3E_CNO"].Value        = m_gtComponent.CNO;
                            m_gtComponent.Recordset.Fields["G3E_CID"].Value        = 1;
                            m_gtComponent.Recordset.Fields["ASSOCIATED_FID"].Value = m_gtRelativeComponent.FID;
                            m_gtComponent.Recordset.Fields["PERMANENT_YN"].Value   = "Y";
                        }
                        else
                        {
                            m_gtComponent.Recordset.MoveFirst();
                            m_gtComponent.Recordset.Fields["ASSOCIATED_FID"].Value = m_gtRelativeComponent.FID;
                            m_gtComponent.Recordset.Fields["PERMANENT_YN"].Value   = "Y";
                        }
                        break;

                    default:
                        break;
                    }
                }
            }
            catch
            {
                throw;
            }
        }
示例#7
0
        public static IGTGraphicComponent RetrieveRelativeComponent(string relativeComponentArgument, IGTGraphicComponents graphicComponents, IGTGraphicComponent graphicComponentBeingPlaced)
        {
            IGTGraphicComponent relativeComponent = null;

            char[] delimiterChars = { '/' };

            //Convert the placement technique argument that contains the relative component from
            //a variant to a string
            if (String.IsNullOrEmpty(relativeComponentArgument))
            {
                MessageBox.Show("Error: Unable to get relative component information. Possible cause: Relative component is not defined.", "G / Technology");
            }
            else
            {
                //Parse the relative component argument into 4 distinct key ids.  The format of the
                //argument is FNO/FIDX/CNO/Occurrence type.  To parse it, use the split function and the
                //"/" delimiter.  Split will return an array substrings
                string[] relativeComponentArgumentIDs = relativeComponentArgument.Split(delimiterChars);

                //Convert the substrings to integers and save as key ids for a later comparison.
                int FNO           = Convert.ToInt32(relativeComponentArgumentIDs[0]);
                int FID           = Convert.ToInt32(relativeComponentArgumentIDs[1]);
                int CNO           = Convert.ToInt32(relativeComponentArgumentIDs[2]);
                int occurenceType = Convert.ToInt32(relativeComponentArgumentIDs[3]);
                int lastCID       = -1;

                //Use the key ids saved above to find this relative component in the GraphicComponents
                //collection.
                foreach (IGTGraphicComponent graphicComponent in graphicComponents)
                {
                    //First look for a match on FNO, FeatureIndex, and CNO
                    if ((graphicComponent.FNO == FNO) &&
                        (graphicComponent.CNO == CNO))
                    {
                        //Now that we've found a match, find the specified occurrence type.  The
                        //occurrence type identifies which instance to use when multiple instances
                        //of a CNO exist.
                        switch (occurenceType)
                        {
                        case ALL_OCCTYPE:
                            //Not applicable for VBAStartLinearAtPointSPT
                            MessageBox.Show("Error in AccessRelativeComponent.RetrieveRelativeComponent: Occurrence type of 'All' not supported by this placement technique", "G / Technology");
                            break;

                        case LASTPLACED_OCCTYPE:
                            //This finds the occurrence with the greatest CID value.
                            if (graphicComponent.CID > lastCID)
                            {
                                //store last cid value
                                lastCID           = graphicComponent.CID;
                                relativeComponent = graphicComponent;
                            }
                            break;

                        case SAMEASACTIVE_OCCTYPE:
                            //This finds the occurrence with the same CID value as the CID of
                            //the component a technique is currently placing.
                            if (graphicComponent.CID == graphicComponentBeingPlaced.CID)
                            {
                                relativeComponent = graphicComponent;
                            }
                            break;

                        default:
                            relativeComponent = graphicComponent;
                            break;
                        }
                    }
                }
                if (relativeComponent == null)
                {
                    MessageBox.Show("Error in AccessRelativeComponent.RetrieveRelativeComponent: Failed to find the relative component " + relativeComponentArgument, "G/Technology");
                }
            }
            return(relativeComponent);
        }