occ 中繪製二維矩形

在屏幕上繪製一個二級矩形this

 

 

#include <Visual3d_Layer.hxx>3d

#include <V3d_LayerMgr.hxx>ci

#include <Visual3d_ViewManager.hxx>it

 

#include "FTFont.h"io

#include "FTGLBitmapFont.h"編譯

  class V3d_TextItem : public Visual3d_LayerItem { public:class

   V3d_TextItem(const Handle(Visual3d_Layer)& theLayer);渲染

  void RedrawLayerPrs();map

private:view

 Standard_Real            myX1;  

Standard_Real            myY1;

 TCollection_AsciiString  myText;  

Standard_Real            myHeight;  

Handle(Visual3d_Layer)   myLayer;

 Quantity_Color           myColor;  

Quantity_Color           mySubtitleColor;

 Aspect_TypeOfDisplayText myType;  

TCollection_AsciiString  myFontName;

};

 

 V3d_TextItem::V3d_TextItem (const Handle(Visual3d_Layer)& theLayer) : myLayer(theLayer)

{

 if (!myLayer.IsNull ())   myLayer->AddLayerItem (this);

}

 void V3d_TextItem::RedrawLayerPrs ()

 

 interactive_context_->CurrentViewer()->InitActiveViews();  

Handle(V3d_View) v3d_view = interactive_context_->CurrentViewer()->ActiveView();

   Handle(Visual3d_Layer) anOverlay = interactive_context_->CurrentViewer()->Viewer()->OverLayer();  

if (anOverlay.IsNull ())

  {   

Handle(V3d_LayerMgr) aMgr = new V3d_LayerMgr (v3d_view);    anOverlay = aMgr->Overlay ();    v3d_view->SetLayerMgr (aMgr);  

}

 

  anOverlay->Begin();  

anOverlay->DrawRectangle(0, 0, 100, 100);

  anOverlay->End();

 

一個Visual3d_Layer關聯一個v3d, 先編譯到一個顯示列表裏面,而後再渲染。

相關文章
相關標籤/搜索