需求描述:需要实现在三维场景中添加广告牌显示的功能,用于实现图片的显示。
解决思路:准备采用超图底层的广告牌UGGeoBillboard来实现,已经在Extensions4Qt工程下的layer3d.cpp中写了一个AddPicture的接口,也在GettingStarted的mainwindow.cpp中的CreateModel中调用了。
当前状态:广告牌对象创建返回false。
Feature3D *Layer3D::AddPicture(QString &pictureFile,OgdcPoint3D &position,QString &strID)
{
    //!新建图片对象
    UGGeoPicture* pPicture = new UGGeoPicture();
    QImage* pImage = new QImage(pictureFile);
    UGImageData* pImageData = new UGImageData();
    pImageData->nHeight = pImage->height();
    pImageData->nWidth = pImage->width();
    pImageData->nWidthBytes = pImage->bytesPerLine();
    pImageData->btBitsPixel = 32;
    pImageData->pBits = new UGbyte[pImage->byteCount()];
    memcpy(pImageData->pBits,pImage->bits(),pImage->byteCount());
    UGArray<UGImageData*> arrImageData;
    arrImageData.Add(pImageData);
    UGPoint2D pntCenter(position.x,position.y);
    //返回true
    bool bIsOk = pPicture->Make(arrImageData,pntCenter,UGSize2D(pImage->width(),pImage->height()));
    //! 新建布告板对象
    UGGeoBillboard *pUGGeoBillboard = new UGGeoBillboard();
    //返回false
    bIsOk=pUGGeoBillboard->MakeWithGeometry(pPicture);
    pUGGeoBillboard->SetHeight(72);
    pUGGeoBillboard->SetWidth(48);
    if(bIsOk)
    {
        pUGGeoBillboard->SetPosition(position);
        return this->AddFeature(pUGGeoBillboard,strID);
    }
    else
        return NULL;
}