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); } } } }
bool locateActiveGrips(out IntegerCollection aIndices) { ExGripDataCollection grDataCol = entPath() ? m_pOwner.GetSubentGripData(m_pOwner.GripDataDict[entityId()], subentPath).SubData : m_pOwner.GripDataDict[entityId()].DataArray; bool bExMethod = true; aIndices = new IntegerCollection(); int i = 0; foreach (ExGripData dat in grDataCol) { if (null == dat.Data) { bExMethod = false; } if (GripData.DrawType.DragImageGrip == dat.Status) { aIndices.Add(i); } i++; } return(bExMethod); }
public bool startHover(int x, int y) { bool bRet = endHover(); ExGripDataCollection aKeys = new ExGripDataCollection(); locateGripsAt(x, y, ref aKeys); if (0 != aKeys.Count) { m_hoverGripsColl = aKeys; foreach (ExGripData gr in m_hoverGripsColl) { if (GripData.DrawType.WarmGrip == gr.Status) { gr.Status = GripData.DrawType.HoverGrip; if (m_pGsModel != null) { m_pGsModel.OnModified(gr, null); } else { m_pDevice.Invalidate(); } } } bRet = true; } return(bRet); }
public void uninit() { m_pDevice = null; m_pGsModel = null; m_hoverGripsColl = null; m_gripDataDict = null; m_aDrags = null; }
public ExGripManager() { m_hoverGripsColl = new ExGripDataCollection(); m_ptBasePoint = Point3d.Origin; m_ptLastPoint = Point3d.Origin; m_gripDataDict = new Dictionary <ObjectId, ExGripDataExt>(); m_aDrags = new ExGripDragCollection(); }
public void locateGripsAt(int x, int y, ref ExGripDataCollection aRes) { Point3d ptFirst = new Point3d(); Tolerance tol = new Tolerance(1E-4, 1E-4); foreach (KeyValuePair <ObjectId, ExGripDataExt> grData in m_gripDataDict) { locateGripsAtInt(x, y, ref aRes, grData.Value.DataArray, ptFirst, tol); foreach (ExGripDataSubent exgrData in grData.Value.DataSub) { locateGripsAtInt(x, y, ref aRes, exgrData.SubData, ptFirst, tol); } } }
public void moveEntity(Point3d ptMoveAt) { IntegerCollection aIndices; bool bExMethod = locateActiveGrips(out aIndices); Vector3d vOffset = ptMoveAt - m_pOwner.BasePoint; using (DBObject dbObj = entityId().GetObject(OpenMode.ForWrite)) { if (dbObj is Entity) { Entity ent = (Entity)dbObj; ExGripDataCollection grDataCol = entPath() ? m_pOwner.GetSubentGripData(m_pOwner.GripDataDict[entityId()], subentPath).SubData : m_pOwner.GripDataDict[entityId()].DataArray; if (bExMethod) { IntPtr[] aIds = new IntPtr[aIndices.Count]; int index = 0; foreach (int i in aIndices) { if (i < grDataCol.Count) { aIds[index++] = grDataCol[i].Data.AppData; } } if (entPath()) { FullSubentityPath[] aPaths = new FullSubentityPath[1]; aPaths[0] = subentPath; ent.MoveGripPointsAtSubentityPaths(aPaths, aIds, vOffset, 0); } else { ent.MoveGripPointsAt(aIds, vOffset, MoveGripPointsFlags.Osnapped); } } else { ent.MoveGripPointsAt(aIndices, vOffset); } } } }
public void DragFinal(Point3d ptFinal, bool bOk) { if (bOk) { using (Teigha.GraphicsSystem.View pView = m_pDevice.ActiveView) { foreach (ExGripDrag grDrag in m_aDrags) { grDrag.moveEntity(ptFinal); pView.Erase(grDrag); grDrag.notifyDragEnded(); updateEntityGrips(grDrag.entityId()); grDrag.uninit(); } } } else { foreach (ExGripDrag grDrag in m_aDrags) { grDrag.notifyDragAborted(); } } m_aDrags.Clear(); if (bOk) { updateInvisibleGrips(); } foreach (ExGripData exgrData in aActiveKeys) { exgrData.Status = GripData.DrawType.WarmGrip; } aActiveKeys = null; }
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); } } } } }
public ExGripDataExt() { m_pDataArray = new ExGripDataCollection(); m_pDataSub = new ExGripDataSubentCollection(); }
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); } } } }
public bool OnMouseDown(int x, int y) { endHover(); ExGripDataCollection aKeys = new ExGripDataCollection(); locateGripsAt(x, y, ref aKeys); if (aKeys.Count > 0) { //if ( bShift ) TODO { bool bMakeHot = true; foreach (KeyValuePair <ObjectId, ExGripDataExt> grData in m_gripDataDict) { foreach (ExGripData exgrData in grData.Value.DataArray) { if (GripData.DrawType.HotGrip == exgrData.Status) { bMakeHot = false; break; } } foreach (ExGripDataSubent grDatSub in grData.Value.DataSub) { foreach (ExGripData exgrData in grDatSub.SubData) { if (GripData.DrawType.HotGrip == exgrData.Status) { bMakeHot = false; break; } } if (bMakeHot == false) { break; } } if (bMakeHot == false) { break; } } if (bMakeHot) { foreach (ExGripData exgrData in aKeys) { exgrData.Status = GripData.DrawType.HotGrip; } } aActiveKeys = new ExGripDataCollection(); locateGripsByStatus(GripData.DrawType.HotGrip, ref aActiveKeys); if (aActiveKeys.Count == 0) { // Valid situation. // If trigger grip performed entity modification and returned eGripHotToWarm // then nothing is to be done cause entity modification will cause reactor to regen grips. return(false); } foreach (ExGripData exgrData in aActiveKeys) { exgrData.Status = GripData.DrawType.DragImageGrip; } foreach (KeyValuePair <ObjectId, ExGripDataExt> grData in m_gripDataDict) { bool bActive = false; foreach (ExGripData exgrData in grData.Value.DataArray) { if (GripData.DrawType.DragImageGrip == exgrData.Status) { bActive = true; m_aDrags.Add(new ExGripDrag(grData.Key, this)); break; } } foreach (ExGripDataSubent grDatSub in grData.Value.DataSub) { foreach (ExGripData exgrData in grDatSub.SubData) { if (GripData.DrawType.DragImageGrip == exgrData.Status) { bActive = true; m_aDrags.Add(new ExGripDrag(exgrData.SubentPath, this)); break; } } if (bActive == true) { break; } } } using (Teigha.GraphicsSystem.View pView = m_pDevice.ActiveView) { foreach (ExGripDrag grDrag in m_aDrags) { grDrag.notifyDragStarted(); grDrag.cloneEntity(); pView.Add(grDrag); } } m_ptBasePoint = aKeys[0].Point; m_ptLastPoint = m_ptBasePoint; } } else { return(false); } return(true); }
public ExGripDataSubent() { m_entPath = new FullSubentityPath(); m_pSubData = new ExGripDataCollection(); }
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(); } }