예제 #1
0
        void locateGripsAtInt(int x, int y, ref ExGripDataCollection aRes, ExGripDataCollection coll, Point3d ptFirst, Tolerance tol)
        {
            foreach (ExGripData exgrData in coll)
            {
                Point3d ptCurrent = exgrData.Point;
                if (aRes.Count == 0)
                {
                    // First grip is obtained by comparing
                    // grip point device position with cursor position.
                    using (Teigha.GraphicsSystem.View pView = m_pDevice.ActiveView)
                    {
                        Point3d ptDC = ptCurrent.TransformBy(pView.WorldToDeviceMatrix);

                        double dDeltaX = Math.Abs(x - ptDC.X);
                        double dDeltaY = Math.Abs(y - ptDC.Y);
                        bool   bOk     = (dDeltaX <= m_GRIPSIZE) && (dDeltaY <= m_GRIPSIZE);
                        if (bOk)
                        {
                            ptFirst = ptCurrent;
                            aRes.Add(exgrData);
                        }
                    }
                }
                else
                {
                    if (ptCurrent.IsEqualTo(ptFirst, tol))
                    {
                        aRes.Add(exgrData);
                    }
                }
            }
        }
예제 #2
0
        void locateGripsByStatus(GripData.DrawType eStatus, ref ExGripDataCollection aResult)
        {
            foreach (KeyValuePair <ObjectId, ExGripDataExt> grData in m_gripDataDict)
            {
                foreach (ExGripData exgrDat in grData.Value.DataArray)
                {
                    if (exgrDat.Status == eStatus)
                    {
                        aResult.Add(exgrDat);
                    }
                }

                foreach (ExGripDataSubent exgrData in grData.Value.DataSub)
                {
                    foreach (ExGripData exgrDat in exgrData.SubData)
                    {
                        if (exgrDat.Status == eStatus)
                        {
                            aResult.Add(exgrDat);
                        }
                    }
                }
            }
        }
예제 #3
0
        void updateInvisibleGrips()
        {
            ExGripDataCollection aOverall = new ExGripDataCollection();

            foreach (KeyValuePair <ObjectId, ExGripDataExt> grDataDc in m_gripDataDict)
            {
                foreach (ExGripData grData in grDataDc.Value.DataArray)
                {
                    aOverall.Add(grData);
                }
                foreach (ExGripDataSubent grDataSub in grDataDc.Value.DataSub)
                {
                    foreach (ExGripData grData in grDataSub.SubData)
                    {
                        aOverall.Add(grData);
                    }
                }
            }

            int iSize = aOverall.Count;

            for (int i = 0; i < iSize; i++)
            {
                ExGripData grData = aOverall[i];
                grData.Invisible = false;
                grData.Shared    = false;

                IntegerCollection aEq = new IntegerCollection();
                aEq.Add(i);

                Point3d ptIni = grData.Point;

                int       iNext = i + 1;
                Tolerance tc    = new Tolerance(1E-6, 1E-6);
                while (iNext < iSize)
                {
                    Point3d ptCur = aOverall[iNext].Point;
                    if (ptIni.IsEqualTo(ptCur, tc))
                    {
                        aEq.Add(iNext);
                        iNext++;
                    }
                    else
                    {
                        break;
                    }
                }

                if (aEq.Count >= 2)
                {
                    int iVisible = 0;
                    int jSize    = aEq.Count;
                    for (int j = 0; j < iSize; j++)
                    {
                        ExGripData pGrip = aOverall[aEq[j]];

                        bool bOk = true;
                        if (pGrip.Data != null)
                        {
                            if (pGrip.Data.SkipWhenShared)
                            {
                                bOk = false;
                            }
                        }

                        if (bOk)
                        {
                            iVisible = j;
                            break;
                        }
                    }

                    for (int j = 0; j < iSize; j++)
                    {
                        ExGripData pGrip = aOverall[aEq[j]];
                        pGrip.Shared    = true;
                        pGrip.Invisible = (j != iVisible);
                    }
                }
            }
        }
예제 #4
0
        void updateEntityGrips(ObjectId id)
        {
            using (Entity ent = (Entity)id.GetObject(OpenMode.ForRead))
            {
                removeEntityGrips(ent, id, false);
                try // grip points are implemented not for all entities
                {
                    ExGripDataCollection exGrDataColl;
                    GripDataCollection   grips = new GripDataCollection();
                    if (ent.GetGripPoints(grips, activeViewUnitSize(), GRIPSIZE, activeViewDirection(), GetGripPointsFlags.GripPointsOnly))
                    {
                        exGrDataColl = new ExGripDataCollection();
                        foreach (GripData gr in grips)
                        {
                            exGrDataColl.Add(new ExGripData(id, gr, gr.GripPoint, this));
                        }
                    }
                    else
                    {
                        exGrDataColl = new ExGripDataCollection();
                        Point3dCollection gripsPts = new Point3dCollection();
                        ent.GetGripPoints(gripsPts, null, null);
                        foreach (Point3d pt in gripsPts)
                        {
                            exGrDataColl.Add(new ExGripData(id, pt, this));
                        }
                    }

                    if (null != exGrDataColl)
                    {
                        ExGripDataExt dExt = new ExGripDataExt();
                        foreach (ExGripData grDat in exGrDataColl)
                        {
                            FullSubentityPath entPath;
                            if (grDat.entPath(out entPath))
                            {
                                bool bFound = false;
                                ExGripDataSubentCollection grSubColl = dExt.DataSub;
                                for (int j = 0; j < grSubColl.Count; j++)
                                {
                                    if (grSubColl[j].EntPath == entPath)
                                    {
                                        bFound = true;
                                        grSubColl[j].SubData.Add(grDat);
                                        break;
                                    }
                                }
                                if (!bFound)
                                {
                                    ExGripDataSubent se = new ExGripDataSubent();
                                    se.EntPath = entPath;
                                    se.SubData.Add(grDat);
                                    dExt.DataSub.Add(se);
                                }
                            }
                            else
                            {
                                if (dExt.DataArray == null)
                                {
                                    dExt.DataArray = new ExGripDataCollection();
                                }
                                dExt.DataArray.Add(grDat);
                            }
                        }

                        m_gripDataDict.Add(id, dExt);

                        foreach (ExGripData grData in exGrDataColl)
                        {
                            showGrip(grData);
                        }
                    }
                }
                catch (System.Exception)
                {
                    // just skip non-supported entities
                }
                ent.Highlight();
            }
        }