www.mxdraw.com
内容索引主面
前一个向上下一个
McDbMText 类

多行文本实体类型

C++
class McDbMText : public McDbEntity;

McDbMText.h

例如:多行文字类,绘制多行文字函数代码如下:

    McDbMText* Mx::AddMText(IN McDbBlockTableRecord* pBlkRec,
                            IN LPCTSTR pszContents,
                            IN McGePoint3d  pos,
                            IN double width,
                            IN double textHeight,

                            IN double rotation                              /*= 0.0*/,      
                            IN McGeVector3d direction                       /*= McGeVector3d::kXAxis*/,
                            IN int  attachment      /*=  McDbMText::kTopLeft*/,
                            IN int    flowDirection /*= McDbMText::kLtoR*/,
                            IN double dFactor                               /*= 1.0*/,
                            IN McDb::LineSpacingStyle style             /*  = McDb::kAtLeast*/
                            )
    {
        McDbObjectId retId;
        McDbMText* pMText = new McDbMText;
        pMText->setContents(pszContents);
        pMText->setLocation(pos);
        pMText->setWidth(width);
        pMText->setTextHeight(textHeight);
        pMText->setRotation(rotation);
        pMText->setDirection(direction);
        pMText->setAttachment(McDbMText::AttachmentPoint(attachment) );
        pMText->setFlowDirection(McDbMText::FlowDirection(flowDirection) );
        pMText->setLineSpacingFactor(dFactor);
        pMText->setLineSpacingFactor(style);
        pBlkRec->appendAcDbEntity(retId,pMText);
        return pMText;
    }

 

例如: 得到多行文字的文字内容

        McDbVoidPtrArray entSet;
        pMtext->explode(entSet);

        for(int i = 0; i < entSet.length();i++)
        {
            McDbObject* pObj = (McDbObject*)entSet[i];

            McDbText* pText = McDbText::cast(pObj);
            if(pText != NULL)
            {
                CString sV = pText->textString();
            }

            delete pObj;
        }

 

例如: 动态拖放McDbMText

        class CMxDrawMTextDragDraw : public McEdGetPointWorldDraw
        {
        public:

            CMxDrawMTextDragDraw(McDbMText* pMtext);
            virtual ~CMxDrawMTextDragDraw();
            virtual Mdesk::Boolean  worldDraw(McGiWorldDraw * wd,McGePoint3d currentPoint);


        private:
            McDbMText* m_pMtext;
        };

        CMxDrawMTextDragDraw::CMxDrawMTextDragDraw(McDbMText* pMtext)
            : m_pMtext(pMtext)
        {

        }

        CMxDrawMTextDragDraw::~CMxDrawMTextDragDraw()
        {

        }

        Mdesk::Boolean  CMxDrawMTextDragDraw::worldDraw(McGiWorldDraw * wd,McGePoint3d currentPoint)
        {
            m_pMtext->setLocation(currentPoint);
            m_pMtext->reCompute();
            m_pMtext->worldDraw(wd);
            return Mdesk::kTrue;
        }


        void CTestCommands::DragMText()
        {

            MrxDbgRbList spFilter = Mx::mcutBuildList(RTDXF0,_T("MTEXT"),0);
            McDbObjectId id;
            McGePoint3d ptPick;

            if(MrxDbgUtils::selectEnt(_T("选择一个多行文本"),spFilter.data(),id,ptPick) != RTNORM)
                return;

            McDbObjectPointer<McDbMText> spMText(id,McDb::kForRead);
            if(spMText.openStatus() != Mcad::eOk)
                return;

            std::auto_ptr<McDbMText>spTmp((McDbMText*)spMText->clone() );

            MrxDbgUiPrPoint getPt(_T("指定新位置"),NULL);

            CMxDrawMTextDragDraw dragDraw(spTmp.get());
            getPt.setUserDraw(&dragDraw);

            MrxDbgUiPrBase::Status  ret = getPt.go();
            if(ret != MrxDbgUiPrBase::kOk)
            {
                return;
            }

            spMText->upgradeOpen();
            spMText->setLocation(spTmp->location() );

            return;
        }
Copyright (c) 2010. All rights reserved.
你认为该帮助怎么样? 发送反馈信息!