|
发表于 2009-5-12 01:02:32
|
显示全部楼层
实际上,这并不难,至少复制了旧方法。我所做的只是在 setAppData 中添加一些标识抓地力
的东西
- enum
- {
- kCenter = 10001,
- kMidpointBottom = 10002,
- kMidpointRight = 10003,
- kMidpointTop = 10004,
- kMidpointLeft= 10005,
- };
- Acad::ErrorStatus MrxRectangle::getGripPoints( AcDbGripDataPtrArray& grips, const double curViewUnitSize,
- const int gripSize,const AcGeVector3d& curViewDir,
- const int bitflags ) const
- {
- assertReadEnabled();
- AcDbGripData *pGrpCenter = new AcDbGripData();
- AcDbGripData *pGrpBottom = new AcDbGripData();
- AcDbGripData *pGrpRight = new AcDbGripData();
- AcDbGripData *pGrpTop = new AcDbGripData();
- AcDbGripData *pGrpLeft = new AcDbGripData();
- AcGePoint3d mpb;
- AcGePoint3d mpr;
- AcGePoint3d mpt;
- AcGePoint3d mpl;
- AcGePoint3d cp;
- this->getMPB(mpb);
- this->getMPR(mpr);
- this->getMPT(mpt);
- this->getMPL(mpl);
- this->getCenter(cp);
- pGrpCenter->setGripPoint(cp);
- pGrpCenter->setAppData((void*)kCenter); // int 10001
- pGrpBottom->setGripPoint(mpb);
- pGrpBottom->setAppData((void*)kMidpointBottom); // int 10002
- pGrpRight->setGripPoint(mpr);
- pGrpRight->setAppData((void*)kMidpointRight); // int 10003
- pGrpTop->setGripPoint(mpt);
- pGrpTop->setAppData((void*)kMidpointTop); // int 10004
- pGrpLeft->setGripPoint(mpl);
- pGrpLeft->setAppData((void*)kMidpointLeft); // int 10004
- grips.append(pGrpCenter);
- grips.append(pGrpBottom);
- grips.append(pGrpRight);
- grips.append(pGrpTop);
- grips.append(pGrpLeft);
- return Acad::eOk;
- }
- Acad::ErrorStatus MrxRectangle::moveGripPointsAt( const AcDbVoidPtrArray& gripAppData,
- const AcGeVector3d& offset, const int bitflags )
- {
- assertWriteEnabled();
- if (gripAppData.length()== 0 || offset.isZeroLength())
- {
- return Acad::eOk;
- }
- for(int i = 0; i getPlane(plane,planarity);
- AcGeVector2d offset2d = offset.convert2d(plane);
- this->getPointAt(0,pt1);
- this->getPointAt(1,pt2);
- this->getPointAt(3,pt3);
- AcGeVector2d x = pt1 - pt2;
- AcGeVector2d y = pt3 - pt2;
- if(offset2d.angleTo(y) setPointAt(0,pt1);
- this->setPointAt(1,pt2);
- }
- break;
- case kMidpointTop:
- {
- double length;
- AcGePoint2d pt1,pt2,pt3;
- AcGePlane plane;
- AcDb::Planarity planarity;
- this->getPlane(plane,planarity);
- AcGeVector2d offset2d = offset.convert2d(plane);
- this->getPointAt(2,pt1);
- this->getPointAt(3,pt2);
- this->getPointAt(0,pt3);
- AcGeVector2d x = pt1 - pt2;
- AcGeVector2d y = pt3 - pt2;
- if(offset2d.angleTo(y) setPointAt(2,pt1);
- this->setPointAt(3,pt2);
- }
- break;
- case kMidpointRight:
- {
- double length;
- AcGePoint2d pt1,pt2,pt3;
- AcGePlane plane;
- AcDb::Planarity planarity;
- this->getPlane(plane,planarity);
- AcGeVector2d offset2d = offset.convert2d(plane);
- this->getPointAt(1,pt1);
- this->getPointAt(2,pt2);
- this->getPointAt(3,pt3);
- AcGeVector2d x = pt1 - pt2;
- AcGeVector2d y = pt3 - pt2;
- if(offset2d.angleTo(y) setPointAt(1,pt1);
- this->setPointAt(2,pt2);
- }
- break;
- case kMidpointLeft:
- {
- double length;
- AcGePoint2d pt1,pt2,pt3;
- AcGePlane plane;
- AcDb::Planarity planarity;
- this->getPlane(plane,planarity);
- AcGeVector2d offset2d = offset.convert2d(plane);
- this->getPointAt(3,pt1);
- this->getPointAt(0,pt2);
- this->getPointAt(2,pt3);
- AcGeVector2d x = pt1 - pt2;
- AcGeVector2d y = pt3 - pt2;
- if(offset2d.angleTo(y) setPointAt(3,pt1);
- this->setPointAt(0,pt2);
- }
- break;
- case kCenter:
- {
- transformBy(AcGeMatrix3d::translation(offset));
- }
- break;
- }
- }
- return Acad::eOk;
- }
|
|