Exemple #1
0
AcDbObjectId CArxHelper::CreateMLeader(const CString& strText, const AcGePoint3d& ptArrow, const AcGePoint3d& ptBase, const AcGeVector3d& vectDir)
{
	AcDbObjectId leaderId = AcDbObjectId::kNull;
	AcDbMText* pMText = new AcDbMText();
	pMText->setContents(strText);
	pMText->setColorIndex(4);
	AcDbExtents extents;
	pMText->getGeomExtents(extents);
	AcDbMLeader *pEnt=new AcDbMLeader();
	int i = 0;
	pEnt->setContentType(AcDbMLeaderStyle::kMTextContent);
	pEnt->addLeader(i);
	pEnt->addLeaderLine(ptArrow,i);
	pEnt->addLastVertex(i,ptBase);
	pEnt->setDoglegLength(1);
	pEnt->setDoglegDirection(i,vectDir);
	pEnt->setArrowSize(0.001);
	pEnt->setTextAttachmentType(AcDbMLeaderStyle::kAttachmentBottomLine,AcDbMLeaderStyle::kLeftLeader);
	pEnt->setTextAttachmentType(AcDbMLeaderStyle::kAttachmentBottomLine,AcDbMLeaderStyle::kRightLeader);
	pEnt->setTextAlignmentType(AcDbMLeaderStyle::kLeftAlignment);
	pEnt->setMText(pMText);

	AcGePoint3d pt = ptBase+vectDir*(extents.maxPoint().x-extents.minPoint().x)*1.1+AcGeVector3d::kYAxis*(extents.maxPoint().y-extents.minPoint().y)*1.1;
	pEnt->setTextLocation(pt);

	leaderId = AddToCAD(pEnt);
	return leaderId;
}
static void DrawZValue( AcGiWorldDraw* mode, double z, const AcGePoint3d& tpt, double angle, double height )
{
    AcGeVector3d v( AcGeVector3d::kXAxis );
    v.rotateBy( angle, AcGeVector3d::kZAxis );
    if( v.x < 0 )
    {
        angle += PI;
    }

    CString text;
    text.Format( _T( " %.5f " ), z );

    AcDbMText mt;
    mt.setLocation( tpt );
    mt.setTextHeight( height );
    mt.setAttachment( AcDbMText::kMiddleCenter );
    mt.setRotation( angle );
    mt.setBackgroundFill( true );
    mt.setUseBackgroundColor( true );
    mt.setBackgroundScaleFactor( 1.0 );
    mt.setContents( text );

    // 经过测试发现,AcDbMText调用worldDraw的同时会修改mode的一些属性
    mt.setColorIndex( mode->subEntityTraits().color() );

    mt.worldDraw( mode );
}
Exemple #3
0
void DrawMText( AcGiWorldDraw* mode, const AcGePoint3d& pt, double angle, const CString& str, double height, AcDbMText::AttachmentPoint ap, const CString& style )
{
    //acutPrintf(_T("\n绘制前--文字颜色:%d"), mode->subEntityTraits().color());
    AcDbMText mt;

 //   //AcDbObjectId style; // 文字样式
	AcDbObjectId fontId = GetTextStyle(style);
	if(!fontId.isNull())
	{
		acutPrintf(_T("\n设置样式为罗马字体"));
		mt.setTextStyle(fontId);
	}
    mt.setLocation( pt );
    mt.setTextHeight( height );

	mt.setAttachment( ap );
    mt.setRotation( angle );

    mt.setContents( str );

    // 经过测试发现,AcDbMText调用worldDraw的同时会修改mode的一些属性
    mt.setColorIndex( mode->subEntityTraits().color() );
	
    mt.worldDraw( mode );

    //acutPrintf(_T("\n绘制后--文字颜色:%d"), mode->subEntityTraits().color());
}