Пример #1
0
        public virtual void StartPlacement(Intergraph.GTechnology.API.IGTPlacementTechniqueHelper PTHelper, Intergraph.GTechnology.API.IGTKeyObject KeyObject, Intergraph.GTechnology.API.IGTKeyObjects KeyObjectCollection)
        {
            try
            {
                m_PTHelper = PTHelper;
                IGTKeyObject  m_KeyObject           = KeyObject;
                IGTKeyObjects m_KeyObjectCollection = KeyObjectCollection;

                if (bSilent)
                {
                    m_PTHelper.StatusBarPromptsEnabled = false;
                    m_PTHelper.StartPlacement(m_KeyObject, m_KeyObjectCollection);
                    // End Placement
                    m_PTHelper.EndPlacement();
                }
                else
                {
                    m_PTHelper.StatusBarPromptsEnabled = true;
                    m_PTHelper.StartPlacement(m_KeyObject, m_KeyObjectCollection);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error in Isolation Scenario PlacementTechnic Interface \n" + ex.Message, "G /Technology", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #2
0
        public virtual void StartPlacement(IGTPlacementTechniqueHelper PTHelper, IGTKeyObject KeyObject, IGTKeyObjects KeyObjectCollection)
        {
            try
            {
                m_PTHelper = PTHelper;
                IGTKeyObject  m_KeyObject           = KeyObject;
                IGTKeyObjects m_KeyObjectCollection = KeyObjectCollection;

                if (bSilent)
                {
                    // Disable construction aids and status bar prompts for silent placement techinque.
                    m_PTHelper.ConstructionAidsEnabled        = GTConstructionAidsEnabledConstants.gtptConstructionAidsNone;
                    m_PTHelper.ConstructionAidDynamicsEnabled = false;
                    m_PTHelper.StatusBarPromptsEnabled        = false;
                    m_PTHelper.StartPlacement(m_KeyObject, m_KeyObjectCollection);

                    // End Placement
                    m_PTHelper.EndPlacement();
                }
                else
                {
                    m_PTHelper.StatusBarPromptsEnabled = true;
                    m_PTHelper.StartPlacement(m_KeyObject, m_KeyObjectCollection);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error in Isolation Scenario PlacementTechnic Interface \n" + ex.Message, "G /Technology", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public void PlacePrimarySwitchGear(IGTDDCKeyObject selectedObject)
        {
            //Reading the arguments
            IGTPolygonGeometry oCPLGeom = null;
            double             XOffset  = short.Parse(m_ActiveGraphicComponent.Arguments.GetArgument(0).ToString());
            double             YOffset  = short.Parse(m_ActiveGraphicComponent.Arguments.GetArgument(1).ToString());

            if (selectedObject.Geometry.Type == "OrientedPointGeometry")
            {
                IGTOrientedPointGeometry iPointGeom = (IGTOrientedPointGeometry)selectedObject.Geometry;
                oCPLGeom = GetPolyGeom(iPointGeom.Origin, XOffset, YOffset);
                RotateGeom(iPointGeom, ref oCPLGeom);
            }
            else if (selectedObject.Geometry.Type == "PolygonGeometry") //GTGeometryTypeConstants.gtgtPolygonGeometry
            {
                IGTPolygonGeometry iPolygonGeom = (IGTPolygonGeometry)selectedObject.Geometry;
                // We do not know what is the first placement point. So we will loop through all the points and grab one point from two identical points
                // because First and Last point would be same
                // TODO  Is there any better way ? To confirm..

                var dupPoint = from p in iPolygonGeom.Points group p by p.X into g where g.Count() > 1 select g.ToString();

                IGTPoint duplicated = iPolygonGeom.Points.First(p => dupPoint.Contains(p.X.ToString()));

                oCPLGeom = GetPolyGeom(duplicated, XOffset, YOffset);
                RotateGeom(iPolygonGeom, ref oCPLGeom);
            }
            if (oCPLGeom != null)
            {
                m_PTHelper.SetGeometry(oCPLGeom);
                m_PTHelper.EndPlacement();
                this.AssemblyCopyToModel(oCPLGeom);
            }
        }
Пример #4
0
        public void PlacePrimarySwitchGear(IGTDDCKeyObject selectedObject)
        {
            //Reading the arguments
            IGTPolygonGeometry oCPLGeom = null;
            double             XOffset  = short.Parse(m_ActiveGraphicComponent.Arguments.GetArgument(0).ToString());
            double             YOffset  = short.Parse(m_ActiveGraphicComponent.Arguments.GetArgument(1).ToString());

            if (selectedObject.Geometry.Type == "OrientedPointGeometry")
            {
                IGTOrientedPointGeometry iPointGeom = (IGTOrientedPointGeometry)selectedObject.Geometry;
                oCPLGeom = GetPolyGeom(iPointGeom.Origin, XOffset, YOffset);
                RotateGeom(iPointGeom, ref oCPLGeom);
            }
            else
            {
                // oCPLGeom = GetPolyGeom(selectedObject.Geometry.FirstPoint, Length, Width, XOffset, YOffset);
            }
            if (oCPLGeom != null)
            {
                m_PTHelper.SetGeometry(oCPLGeom);
                m_PTHelper.EndPlacement();
                this.AssemblyCopyToModel(oCPLGeom);
            }
        }
Пример #5
0
        private void PlacePrimarySwitchGear(IGTDDCKeyObject selectedObject)
        {
            try
            {
                //Reading the arguments
                IGTPolygonGeometry oCPLGeom = null;
                double             XOffset  = short.Parse(m_ActiveGraphicComponent.Arguments.GetArgument(0).ToString());
                double             YOffset  = short.Parse(m_ActiveGraphicComponent.Arguments.GetArgument(1).ToString());
                if (selectedObject.Geometry.Type == GTGeometryTypeConstants.gtgtOrientedPointGeometry)
                {
                    IGTOrientedPointGeometry iPointGeom = (IGTOrientedPointGeometry)selectedObject.Geometry;
                    //oCPLGeom = GetPolyGeom(iPointGeom.Origin, XOffset, YOffset);
                    oCPLGeom = GetPolyGeom(iPointGeom.Origin, 0, 0);
                    RotateGeom(iPointGeom, ref oCPLGeom);
                }
                else if (selectedObject.Geometry.Type == GTGeometryTypeConstants.gtgtPolygonGeometry)
                {
                    IGTPolygonGeometry iPolygonGeom  = (IGTPolygonGeometry)selectedObject.Geometry;
                    List <Point2D>     polygonPoints = new List <Point2D>();
                    foreach (IGTPoint point in iPolygonGeom.Points)
                    {
                        polygonPoints.Add(new Point2D {
                            x = point.X, y = point.Y
                        });
                    }

                    //Calulate approx minimum length for sides of polygon
                    double sideLength1 = 0.0;
                    double sideLength2 = 0.0;
                    double sideLength3 = 0.0;
                    double length      = 0.0;
                    if (polygonPoints.Count > 3)
                    {
                        sideLength1 = Math.Abs(polygonPoints[0].y - polygonPoints[0].x);
                        sideLength2 = Math.Abs(polygonPoints[1].y - polygonPoints[1].x);
                        sideLength3 = Math.Abs(polygonPoints[2].y - polygonPoints[2].x);
                        length      = Math.Min(sideLength1, sideLength2);
                        length      = Math.Min(length, sideLength3);
                    }



                    int     vertexCount = iPolygonGeom.Points.Count - 1;
                    Point2D centroid    = Compute2DPolygonCentroid(polygonPoints, vertexCount);

                    m_CentriodPoint   = GTClassFactory.Create <IGTPoint>();
                    m_CentriodPoint.X = centroid.x;
                    m_CentriodPoint.Y = centroid.y;
                    m_CentriodPoint.Z = 0.0;

                    //oCPLGeom = GetPolyGeom(m_CentriodPoint, XOffset, YOffset);
                    oCPLGeom = GetPolyGeom(m_CentriodPoint, 0, 0, length);
                    RotateGeom(iPolygonGeom, ref oCPLGeom);
                }
                if (oCPLGeom != null)
                {
                    m_PTHelper.SetGeometry(oCPLGeom);
                    m_PTHelper.EndPlacement();
                    this.AssemblyCopyToModel(oCPLGeom);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #6
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();
            }
        }