private IGTPolygonGeometry GetPolyGeom(IGTPoint iPt, double xOffset, double yOffset)
        {
            IGTPolylineGeometry oPolyLineGeom = null;
            IGTPolygonGeometry  oGeom         = null;
            IGTPoint            oTmpPt;
            IGTPoint            oStartPt;
            IGTPoint            oMidPT;

            try
            {
                if (iPt == null)
                {
                    return(null);
                }
                oPolyLineGeom = GTClassFactory.Create <IGTPolylineGeometry>();
                oGeom         = GTClassFactory.Create <IGTPolygonGeometry>();
                oTmpPt        = GTClassFactory.Create <IGTPoint>();
                oMidPT        = GTClassFactory.Create <IGTPoint>();
                oStartPt      = GTClassFactory.Create <IGTPoint>();;


                oMidPT.X = iPt.X;
                oMidPT.Y = iPt.Y + 10.0;

                oStartPt.X = oMidPT.X + (-14);
                oStartPt.Y = oMidPT.Y;
                oPolyLineGeom.Points.Add(oStartPt);

                oTmpPt.X = oMidPT.X + 14;
                oTmpPt.Y = oMidPT.Y;
                oPolyLineGeom.Points.Add(oTmpPt);

                oTmpPt.X = oTmpPt.X;
                oTmpPt.Y = oTmpPt.Y + 28;
                oPolyLineGeom.Points.Add(oTmpPt);

                oTmpPt.X = oTmpPt.X - 28;
                oTmpPt.Y = oTmpPt.Y;
                oPolyLineGeom.Points.Add(oTmpPt);

                oPolyLineGeom.Points.Add(oStartPt);

                foreach (IGTPoint pt in oPolyLineGeom.Points)
                {
                    oGeom.Points.Add(pt);
                }

                return(oGeom);
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(oGeom);
            }

            finally
            {
            }
        }
Example #2
0
        private void AssemblyCopyToModel(IGTPolygonGeometry oGeometry)
        {
            int    ownerID = 0;
            int    lRecords;
            double dGeoOrientation = 0.0;

            try
            {
                frmAssmbly                  = new frmAssembly();
                frmAssmbly.Application      = m_GTApplication;
                frmAssmbly.FeatureFNO       = m_ActiveGraphicComponent.FNO;
                frmAssmbly.DetailIdentifier = m_ActiveMapWindow.DetailID;
                frmAssmbly.ShowDialog();
                if (frmAssmbly.FeatureIdentifier != 0)
                {
                    ownerID = GetOwnerIdentifier();
                    GetAssemblyPointsAndOrientation(oGeometry, ref dGeoOrientation);
                    ADODB.Recordset oRS = m_GTApplication.DataContext.Execute("{call OC_EXECUTE_DEEPCOPY(" + m_ActiveGraphicComponent.FNO.ToString() + " ," +
                                                                              frmAssmbly.FeatureIdentifier.ToString() + ", " +
                                                                              m_ActiveGraphicComponent.FNO.ToString() + ", " +
                                                                              m_ActiveGraphicComponent.CNO.ToString() + ", " +
                                                                              m_ActiveGraphicComponent.FID.ToString() + ", " +
                                                                              ownerID.ToString() + ", " + dGeoOrientation + ", " + m_ActiveMapWindow.DetailID + ")}", out lRecords, 1, new object[1]);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        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);
            }
        }
        /// <summary>
        /// Rotates input geometry relative to the reference geom
        /// </summary>
        /// <param name="ogeom"></param>
        /// <returns></returns>
        private void RotateGeom(IGTGeometry refGeom, ref IGTPolygonGeometry inpGeom)
        {
            double             dAngle     = 0;
            IGTPolygonGeometry oPolyGeom  = null;
            IGTMatrix          tmpTMatrix = null;
            IGTVector          transVec;

            try
            {
                if (refGeom == null || inpGeom == null)
                {
                    return;
                }
                if (refGeom.GetType().ToString() == "Intergraph.GTechnology.Private.GTOrientedPointGeometry")
                {
                    dAngle = AngleBetweenTwoPoints(((IGTOrientedPointGeometry)refGeom).Orientation);
                }
                else if (refGeom.GetType().ToString() == "Intergraph.GTechnology.Private.GTPolygonGeometry")
                {
                    oPolyGeom = (IGTPolygonGeometry)refGeom.Stroke();
                    dAngle    = AngleBetweenTwoPoints(oPolyGeom.Points[0], oPolyGeom.Points[1]);
                }
                transVec = GTClassFactory.Create <IGTVector>();

                if (inpGeom.GetType().ToString() == "Intergraph.GTechnology.Private.GTPolygonGeometry")
                {
                    oPolyGeom = (IGTPolygonGeometry)inpGeom.Stroke();

                    // move and rotate the geometry to the correct position
                    transVec.I = oPolyGeom.Points[0].X * -1;
                    transVec.J = oPolyGeom.Points[0].Y * -1;
                    transVec.K = oPolyGeom.Points[0].Z * -1;
                }

                tmpTMatrix = GTClassFactory.Create <IGTMatrix>();
                tmpTMatrix = TranslationTransform(transVec);
                inpGeom    = (IGTPolygonGeometry)inpGeom.Multiply(inpGeom, tmpTMatrix);

                // rotate the geometry to the angle of the
                tmpTMatrix = GTClassFactory.Create <IGTMatrix>();
                tmpTMatrix = RotateZTransform(dAngle, 'D');
                inpGeom    = (IGTPolygonGeometry)inpGeom.Multiply(inpGeom, tmpTMatrix);

                transVec   = transVec.NegateVector(transVec);
                tmpTMatrix = GTClassFactory.Create <IGTMatrix>();
                tmpTMatrix = TranslationTransform(transVec);
                inpGeom    = (IGTPolygonGeometry)inpGeom.Multiply(inpGeom, tmpTMatrix);
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            finally
            {
            }
        }
Example #5
0
        private void GetAssemblyPointsAndOrientation(IGTPolygonGeometry oGeometry, ref double dOrientation)
        {
            double pi            = 0.0;
            double dx            = 0.0;
            double dy            = 0.0;
            string sCoordinates1 = string.Empty;

            pi           = 4 * System.Math.Atan(1);
            dOrientation = 0;
            try
            {
                IGTPoint oPoint0 = oGeometry.Points[0];
                IGTPoint oPoint1 = oGeometry.Points[1];

                IGTPolygonGeometry oTemp = (IGTPolygonGeometry)(oGeometry);
                for (int i = 0; i < oTemp.Points.Count; i++)
                {
                    sCoordinates1 = string.Join(",", new string[] { sCoordinates1, oTemp.Points[i].X.ToString(), oTemp.Points[i].Y.ToString(),
                                                                    oTemp.Points[i].Z.ToString() });
                }

                sCoordinates1 = sCoordinates1.Remove(0, 1);
                int rAffected = 0;
                // Execute .NET stored procedure
                ADODB.Recordset oRS = m_GTApplication.DataContext.Execute("{call OC_INSERT_TEMP_PLR_COORD('" + sCoordinates1 + "')}",
                                                                          out rAffected, 1, new object[1]);


                // Calculate orientation
                dx = oPoint1.X - oPoint0.X;
                dy = oPoint1.Y - oPoint0.Y;
                if (dx == 0)
                {
                    if (dy >= 0)
                    {
                        dOrientation = pi / 2;
                    }
                    else
                    {
                        dOrientation = -(pi / 2);
                    }
                }
                else
                {
                    dOrientation = System.Math.Atan(dy / dx);
                    if (dx < 0)
                    {
                        dOrientation = dOrientation + pi;
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Example #6
0
        private void AssemblyCopyToModel(IGTPolygonGeometry oGeometry)
        {
            int      ownerID   = 0;
            IGTPoint firstPnt  = null;
            IGTPoint secondPnt = null;
            IGTPoint thirtPnt  = null;
            int      lRecords;
            double   dGeoOrientation = 0.0;

            try
            {
                frmAssmbly             = new frmAssembly();
                frmAssmbly.Application = m_GTApplication;
                frmAssmbly.FeatureFNO  = m_ActiveGraphicComponent.FNO;
                frmAssmbly.ShowDialog();
                if (frmAssmbly.FeatureIdentifier != 0)
                {
                    ownerID = GetOwnerIdentifier();
                    GetAssemblyPointsAndOrientation(oGeometry, ref firstPnt, ref secondPnt, ref thirtPnt, ref dGeoOrientation);
                    //string assemblyQuery = "BEGIN G3E_DeepCopy.CopyChildrenToModel(" + m_ActiveGraphicComponent.FNO.ToString() + " ," +
                    //                                                frmAssmbly.FeatureIdentifier.ToString() + ", " +
                    //                                                m_ActiveGraphicComponent.FNO.ToString() + ", " +
                    //                                                m_ActiveGraphicComponent.CNO.ToString() + ", " +
                    //                                                m_ActiveGraphicComponent.FID.ToString() + ", " +
                    //                                                ownerID.ToString() + ", '" +
                    //                                                firstPnt.X.ToString().Replace(",", ".") + "', '" +
                    //                                                firstPnt.Y.ToString().Replace(",", ".") + "', '" +
                    //                                                secondPnt.X.ToString().Replace(",", ".") + "', '" +
                    //                                                secondPnt.Y.ToString().Replace(",", ".") + "', '" +
                    //                                                thirtPnt.X.ToString().Replace(",", ".") + "', '" +
                    //                                                thirtPnt.Y.ToString().Replace(",", ".") + "', '" +
                    //                                                dGeoOrientation.ToString().Replace(",", ".") + "'," +
                    //                                                "' 0 '," +
                    //                                                "' 0 '," +
                    //                                                "' 0 '," +
                    //                                                "' 0 '," +
                    //                                                "' 0 '," +
                    //                                                "' 0 '," +
                    //                                                "' 0 '," +
                    //                                                "' 0 '" + "); END;";

                    string assemblyQuery = "BEGIN OC_EXECUTE_DEEPCOPY(" + m_ActiveGraphicComponent.FNO.ToString() + " ," +
                                           frmAssmbly.FeatureIdentifier.ToString() + ", " +
                                           m_ActiveGraphicComponent.FNO.ToString() + ", " +
                                           m_ActiveGraphicComponent.CNO.ToString() + ", " +
                                           m_ActiveGraphicComponent.FID.ToString() + ", " +
                                           ownerID.ToString() + "); END;";
                    Recordset oRS = m_GTApplication.DataContext.Execute(assemblyQuery, out lRecords, (int)CommandTypeEnum.adCmdText, new object());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #7
0
        private IGTGeometry GetClipBoundary(IGTApplication oApp, IGTPolygonGeometry clipIn)
        {
            IGTPolygonGeometry prClipPG = GTClassFactory.Create <IGTPolygonGeometry>();

            IGTPoint ipt;

            foreach (IGTPoint pt in clipIn.Points)
            {
                ipt = oApp.ActivePlotWindow.ActiveFrame.PlotMap.WorldToPaper(pt);
                prClipPG.Points.Add(ipt);
            }

            return(prClipPG);
        }
Example #8
0
        private void SetupLocationCriteria()
        {
            try
            {
                if (this.oMap == null)
                {
                    throw new Exception("Map object is null.");
                }

                IGTWorldRange oMapExtents = this.oMap.GetRange();

                IGTPolygonGeometry m_oPoly   = GTClassFactory.Create <IGTPolygonGeometry>();
                IGTPoint           m_ulPoint = GTClassFactory.Create <IGTPoint>();
                m_ulPoint.X = oMapExtents.BottomLeft.X;
                m_ulPoint.Y = oMapExtents.TopRight.Y;

                IGTPoint m_urPoint = GTClassFactory.Create <IGTPoint>();
                m_urPoint.X = oMapExtents.TopRight.X;
                m_urPoint.Y = oMapExtents.TopRight.Y;

                IGTPoint m_lrPoint = GTClassFactory.Create <IGTPoint>();
                m_lrPoint.X = oMapExtents.TopRight.X;
                m_lrPoint.Y = oMapExtents.BottomLeft.Y;

                IGTPoint m_llPoint = GTClassFactory.Create <IGTPoint>();
                m_llPoint.X = oMapExtents.BottomLeft.X;
                m_llPoint.Y = oMapExtents.BottomLeft.Y;

                m_oPoly.Points.Add(m_ulPoint);
                m_oPoly.Points.Add(m_urPoint);
                m_oPoly.Points.Add(m_lrPoint);
                m_oPoly.Points.Add(m_llPoint);

                this.oLocationCriteria = (IGTGeometry)m_oPoly;

                if (this.oLocationCriteria == null)
                {
                    throw new Exception("Map extents are null.");
                }
            }
            catch (Exception ex)
            {
                CommandUtilities.LogException(oDiag, "GTStreetLight.SetupLocationCriteria", ex);
                throw ex;
            }
        }
Example #9
0
        /// <summary>
        /// Method to which converts the World coordinates of the placed Tree trimming features to Paper coordinates
        /// </summary>
        /// <param name="p_plotMap">Plot Map</param>
        /// <param name="p_worldPolygon">Geometry of the placed feature which needs to be converted to Paper coordinates</param>
        /// <returns></returns>
        private IGTPolygonGeometry WorldToPaper(IGTPlotMap p_plotMap, IGTPolygonGeometry p_worldPolygon)
        {
            IGTPolygonGeometry paperPolygon = GTClassFactory.Create <IGTPolygonGeometry>();
            IGTPoint           pt           = null;
            IGTPoint           firstPT      = null;

            for (int count = 0; count < p_worldPolygon.Points.Count; count++)
            {
                IGTPoint worldPoint = p_worldPolygon.GetKeypointPosition(count);
                pt = WorldToPaper(p_plotMap, worldPoint);
                if (count == 0)
                {
                    firstPT = pt;
                }
                paperPolygon.Points.Add(pt);
            }
            paperPolygon.Points.Add(firstPT);
            return(paperPolygon);
        }
Example #10
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);
            }
        }
Example #11
0
        private void GetAssemblyPointsAndOrientation(IGTPolygonGeometry oGeometry, ref IGTPoint oPoint1, ref IGTPoint oPoint2, ref IGTPoint oPoint3, ref double dOrientation)
        {
            double pi            = 0.0;
            double dx            = 0.0;
            double dy            = 0.0;
            string sCoordinates1 = string.Empty;

            pi           = 4 * System.Math.Atan(1);
            dOrientation = 0;
            try
            {
                oPoint1 = oGeometry.Points[1];
                //oPoint1 = TransformPoint(oGeometry.Points[1]);
                oPoint2 = oGeometry.Points[2];
                // oPoint2 = TransformPoint(oGeometry.Points[2]);
                oPoint3 = oGeometry.Points[3];
                //oPoint3 = TransformPoint(oGeometry.Points[3]);

                //-----------------

                //IGTPolygonGeometry oTemp = (IGTPolygonGeometry)((System.Collections.Generic.IList<IGTGeometry>)(oGeometry));
                IGTPolygonGeometry oTemp = (IGTPolygonGeometry)(oGeometry);
                for (int i = 0; i < oTemp.Points.Count; i++)
                {
                    sCoordinates1 = string.Join(",", new string[] { sCoordinates1, oTemp.Points[i].X.ToString(), oTemp.Points[i].Y.ToString(), oTemp.Points[i].Z.ToString() });
                }


                sCoordinates1 = sCoordinates1.Remove(0, 1);
                sCoordinates1 = "test";
                Command cmd = new Command();
                cmd.CommandText = " call {OC_INSERT_TEMP_PLR_COORD('test')}";
                cmd.CommandType = CommandTypeEnum.adCmdText;


                // Parameter Coord1 = cmd.CreateParameter("Coord1", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 4000, sCoordinates1);
                // cmd.Parameters.Append(Coord1);

                // cmd.Parameters.Append(cmd.CreateParameter("Coord1", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 4000, sCoordinates1));

                int rAffected = 0;
                // Execute .NET stored procedure
                m_GTApplication.DataContext.ExecuteCommand(cmd, out rAffected, (int)ADODB.CommandTypeEnum.adCmdStoredProc);
                //int lRecords;

                //string query = "BEGIN OC_INSERT_TEMP_PLR_COORD(" + sCoordinates1 + "); END;";
                //ADODB.Recordset oRS = m_GTApplication.DataContext.Execute(query, out lRecords, (int)ADODB.CommandTypeEnum.adCmdText, new object());

                //--------------------

                //Orientation
                //dx = oPoint2.X - oPoint1.X;
                //dy = oPoint2.Y - oPoint1.Y;
                //if (dx == 0)
                //{
                //    if (dy >= 0)
                //    {
                //        dOrientation = pi / 2;
                //    }
                //    else
                //    {
                //        dOrientation = -(pi / 2);
                //    }
                //}
                //else
                //{
                //    dOrientation = System.Math.Atan(dy / dx);
                //    if (dx < 0)
                //    {
                //        dOrientation = dOrientation + pi;
                //    }
                //}
            }
            catch (Exception ex)
            {
            }
        }
Example #12
0
        /// <summary>
        /// Rotates input geometry relative to the reference geom
        /// </summary>
        /// <param name="ogeom"></param>
        /// <returns></returns>
        private void RotateGeom(IGTGeometry refGeom, ref IGTPolygonGeometry inpGeom)
        {
            double             dAngle    = 0;
            IGTPolygonGeometry oPolyGeom = null;

            try
            {
                if (refGeom == null || inpGeom == null)
                {
                    return;
                }
                if (refGeom.GetType().ToString() == "Intergraph.GTechnology.Private.GTOrientedPointGeometry")
                {
                    dAngle = AngleBetweenTwoPoints(((IGTOrientedPointGeometry)refGeom).Orientation);
                }
                else if (refGeom.GetType().ToString() == "Intergraph.GTechnology.Private.GTPolygonGeometry")
                {
                    oPolyGeom = (IGTPolygonGeometry)refGeom.Stroke();
                    dAngle    = AngleBetweenTwoPoints(oPolyGeom.Points[0], oPolyGeom.Points[1]);
                }

                if (dAngle < -90.0 || dAngle > 90.0)
                {
                    dAngle = dAngle + 180.0;
                }
                IGTVector transVec = GTClassFactory.Create <IGTVector>();

                if (inpGeom.GetType().ToString() == "Intergraph.GTechnology.Private.GTPolygonGeometry")
                {
                    // move and rotate the geometry to the correct position
                    if (m_ActiveMapWindow.DetailID == 0)
                    {
                        transVec.I = refGeom.FirstPoint.X * -1;
                        transVec.J = refGeom.FirstPoint.Y * -1;
                        transVec.K = refGeom.FirstPoint.Z * -1;
                    }
                    else
                    {
                        if (m_CentriodPoint != null)
                        {
                            transVec.I = m_CentriodPoint.X * -1;
                            transVec.J = m_CentriodPoint.Y * -1;
                            transVec.K = m_CentriodPoint.Z * -1;
                        }
                    }
                }

                IGTMatrix tmpTMatrix = GTClassFactory.Create <IGTMatrix>();
                tmpTMatrix = TranslationTransform(transVec);
                inpGeom    = (IGTPolygonGeometry)inpGeom.Multiply(inpGeom, tmpTMatrix);

                // rotate the geometry to the angle of the
                tmpTMatrix = GTClassFactory.Create <IGTMatrix>();
                tmpTMatrix = RotateZTransform(dAngle, 'D');
                inpGeom    = (IGTPolygonGeometry)inpGeom.Multiply(inpGeom, tmpTMatrix);

                transVec   = transVec.NegateVector(transVec);
                tmpTMatrix = GTClassFactory.Create <IGTMatrix>();
                tmpTMatrix = TranslationTransform(transVec);
                inpGeom    = (IGTPolygonGeometry)inpGeom.Multiply(inpGeom, tmpTMatrix);
            }

            catch (Exception)
            {
                throw;
            }

            finally
            {
            }
        }
Example #13
0
        private IGTPolygonGeometry GetPolyGeom(IGTPoint iPt, double xOffset, double yOffset, double length = 0)
        {
            try
            {
                if (iPt == null)
                {
                    return(null);
                }
                IGTPolylineGeometry oPolyLineGeom = GTClassFactory.Create <IGTPolylineGeometry>();
                IGTPolygonGeometry  oGeom         = GTClassFactory.Create <IGTPolygonGeometry>();
                IGTPoint            oTmpPt        = GTClassFactory.Create <IGTPoint>();
                IGTPoint            oMidPT        = GTClassFactory.Create <IGTPoint>();
                IGTPoint            oStartPt      = GTClassFactory.Create <IGTPoint>();;

                oMidPT.X = iPt.X;
                oMidPT.Y = iPt.Y;

                if (length > 0)
                {
                    //oStartPt.X = oMidPT.X;
                    //oStartPt.Y = oMidPT.Y - (length/2);
                    //oPolyLineGeom.Points.Add(oStartPt);

                    //oTmpPt.X = oStartPt.X + (length/2);
                    //oTmpPt.Y = oStartPt.Y;
                    //oPolyLineGeom.Points.Add(oTmpPt);

                    //oTmpPt.X = oTmpPt.X;
                    //oTmpPt.Y = oTmpPt.Y + length;
                    //oPolyLineGeom.Points.Add(oTmpPt);

                    //oTmpPt.X = oTmpPt.X - length;
                    //oTmpPt.Y = oTmpPt.Y;
                    //oPolyLineGeom.Points.Add(oTmpPt);

                    //oPolyLineGeom.Points.Add(oStartPt);

                    oStartPt.X = oMidPT.X;
                    oStartPt.Y = oMidPT.Y - 5;
                    oPolyLineGeom.Points.Add(oStartPt);

                    oTmpPt.X = oStartPt.X + 5;
                    oTmpPt.Y = oStartPt.Y;
                    oPolyLineGeom.Points.Add(oTmpPt);

                    oTmpPt.X = oTmpPt.X;
                    oTmpPt.Y = oTmpPt.Y + 10;
                    oPolyLineGeom.Points.Add(oTmpPt);

                    oTmpPt.X = oTmpPt.X - 10;
                    oTmpPt.Y = oTmpPt.Y;
                    oPolyLineGeom.Points.Add(oTmpPt);

                    oTmpPt.X = oTmpPt.X;
                    oTmpPt.Y = oTmpPt.Y - 10;
                    oPolyLineGeom.Points.Add(oTmpPt);

                    oPolyLineGeom.Points.Add(oStartPt);
                }

                else
                {
                    oStartPt.X = oMidPT.X + (-14);
                    oStartPt.Y = oMidPT.Y;
                    oPolyLineGeom.Points.Add(oStartPt);

                    oTmpPt.X = oMidPT.X + 14;
                    oTmpPt.Y = oMidPT.Y;
                    oPolyLineGeom.Points.Add(oTmpPt);

                    oTmpPt.X = oTmpPt.X;
                    oTmpPt.Y = oTmpPt.Y + 28;
                    oPolyLineGeom.Points.Add(oTmpPt);

                    oTmpPt.X = oTmpPt.X - 28;
                    oTmpPt.Y = oTmpPt.Y;
                    oPolyLineGeom.Points.Add(oTmpPt);

                    oPolyLineGeom.Points.Add(oStartPt);
                }
                foreach (IGTPoint pt in oPolyLineGeom.Points)
                {
                    oGeom.Points.Add(pt);
                }

                return(oGeom);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Example #14
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;
            }
        }
Example #15
0
        internal void BuildWorkPrint(List <PlotBoundaryAttributes> p_PlotBoundaryCollection, IGTApplication p_oApp, string p_destDir, string p_outputFileName, string p_legendName)
        {
            try
            {
                List <string> PDFNames = new List <string>();

                for (int i = 0; i < p_PlotBoundaryCollection.Count; i++)
                {
                    string       sErrMsg    = string.Empty;
                    IGTNamedPlot oNamedPlot = null;
                    IGTKeyObject oClipGeom  = p_oApp.DataContext.OpenFeature(p_PlotBoundaryCollection[i].FNO, p_PlotBoundaryCollection[i].FID);
                    IGTComponent oComp      = oClipGeom.Components.GetComponent(18802);

                    oComp.Recordset.MoveFirst();

                    IGTPolygonGeometry oGeom = (IGTPolygonGeometry)oComp.Geometry;

                    foreach (IGTNamedPlot item in p_oApp.NamedPlots)
                    {
                        if (item.Name.Equals(p_PlotBoundaryCollection[i].PlotTemplateName))
                        {
                            oNamedPlot = item;
                            break;
                        }
                    }

                    DeleteNamedPlot("OUTPUT - " + p_oApp.DataContext.ActiveJob + "-" + i, p_oApp);

                    IGTNamedPlot  oCopiedPlot = oNamedPlot.CopyPlot("OUTPUT - " + p_oApp.DataContext.ActiveJob + "-" + i);
                    IGTPlotWindow oPlotWindow = p_oApp.NewPlotWindow(oCopiedPlot);
                    IGTPlotFrame  oFrame      = null;

                    foreach (IGTPlotFrame tmpFrame in oPlotWindow.NamedPlot.Frames)
                    {
                        // IGTPlotFrame oFrame = oPlotWindow.NamedPlot.Frames[0];
                        if (tmpFrame.Type == GTPlotFrameTypeConstants.gtpftMap)
                        {
                            oFrame = tmpFrame;
                            break;
                        }
                    }
                    oFrame.Activate();
                    oFrame.PlotMap.DisplayService.ReplaceLegend(p_legendName);
                    AssignClipGeometryToFrame(p_oApp, oFrame, oGeom);

                    oPlotWindow.Activate();

                    SetAutomaticFields(oPlotWindow.NamedPlot, p_PlotBoundaryCollection.Count, i + 1, p_oApp);
                    p_oApp.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, string.Format("Generating Construction Print {0} of {1}", i + 1, p_PlotBoundaryCollection));
                    ExportToPDF(p_destDir, p_outputFileName + "-" + i + ".pdf", false, oPlotWindow, out sErrMsg);
                    PDFNames.Add(p_outputFileName + "-" + i + ".pdf");
                    oPlotWindow.Close();
                    DeleteNamedPlot("OUTPUT - " + p_oApp.DataContext.ActiveJob + "-" + i + 1, p_oApp);
                }

                if (PDFNames.Count > 0)
                {
                    MergePDFs(p_destDir, PDFNames, p_outputFileName);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #16
0
        private bool AssignClipGeometryToFrame(IGTApplication oApp, IGTPlotFrame apf, IGTPolygonGeometry clipPG)
        {
            bool bReturn = false;

            apf.Activate();

            // Need to Zoom out a little more as the WorldToPaper seems to fail on pts that are on the edge.
            IGTPoint    originPt       = GTClassFactory.Create <IGTPoint>(0, 0, 0);
            IGTGeometry prClipBufferPG = ((IGTGeometry)clipPG).CopyGeometryParallel(originPt, 2);

            apf.PlotMap.ZoomArea(prClipBufferPG.Range);
            apf.ClipGeometry = GetClipBoundary(oApp, clipPG);
            apf.IsClipped    = true;
            apf.Deactivate();
            oApp.RefreshWindows();
            bReturn = true;
            return(bReturn);
        }